@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public static function set_definitions() |
128 | 128 | { |
129 | - define('THANK_YOU_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/'); |
|
130 | - define('THANK_YOU_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/'); |
|
129 | + define('THANK_YOU_ASSETS_URL', plugin_dir_url(__FILE__).'assets/'); |
|
130 | + define('THANK_YOU_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)).'templates/'); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | return $this->_current_txn; |
143 | 143 | } |
144 | 144 | $TXN_model = EE_Registry::instance()->load_model('Transaction'); |
145 | - if (! $TXN_model instanceof EEM_Transaction) { |
|
145 | + if ( ! $TXN_model instanceof EEM_Transaction) { |
|
146 | 146 | EE_Error::add_error( |
147 | 147 | __('The transaction model could not be established.', 'event_espresso'), |
148 | 148 | __FILE__, |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | */ |
180 | 180 | public function get_txn_payments($since = 0) |
181 | 181 | { |
182 | - if (! $this->get_txn()) { |
|
182 | + if ( ! $this->get_txn()) { |
|
183 | 183 | return false; |
184 | 184 | } |
185 | 185 | $args = array('order_by' => array('PAY_timestamp' => 'ASC')); |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | */ |
210 | 210 | private function _get_reg_url_link() |
211 | 211 | { |
212 | - if (! empty($this->_reg_url_link)) { |
|
212 | + if ( ! empty($this->_reg_url_link)) { |
|
213 | 213 | return; |
214 | 214 | } |
215 | 215 | // only do thank you page stuff if we have a REG_url_link in the url |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | { |
322 | 322 | wp_register_script( |
323 | 323 | 'thank_you_page', |
324 | - THANK_YOU_ASSETS_URL . 'thank_you_page.js', |
|
324 | + THANK_YOU_ASSETS_URL.'thank_you_page.js', |
|
325 | 325 | array('espresso_core', 'heartbeat'), |
326 | 326 | EVENT_ESPRESSO_VERSION, |
327 | 327 | true |
@@ -340,9 +340,9 @@ discard block |
||
340 | 340 | public function init() |
341 | 341 | { |
342 | 342 | $this->_get_reg_url_link(); |
343 | - if (! $this->get_txn()) { |
|
343 | + if ( ! $this->get_txn()) { |
|
344 | 344 | echo EEH_HTML::div( |
345 | - EEH_HTML::h4(__('We\'re sorry...', 'event_espresso'), '', '') . |
|
345 | + EEH_HTML::h4(__('We\'re sorry...', 'event_espresso'), '', ''). |
|
346 | 346 | sprintf( |
347 | 347 | __( |
348 | 348 | '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', |
@@ -432,12 +432,12 @@ discard block |
||
432 | 432 | public function thank_you_page_results() |
433 | 433 | { |
434 | 434 | $this->init(); |
435 | - if (! $this->_current_txn instanceof EE_Transaction) { |
|
435 | + if ( ! $this->_current_txn instanceof EE_Transaction) { |
|
436 | 436 | return EE_Error::get_notices(); |
437 | 437 | } |
438 | 438 | // link to receipt |
439 | 439 | $template_args['TXN_receipt_url'] = $this->_current_txn->receipt_url('html'); |
440 | - if (! empty($template_args['TXN_receipt_url'])) { |
|
440 | + if ( ! empty($template_args['TXN_receipt_url'])) { |
|
441 | 441 | $template_args['order_conf_desc'] = __( |
442 | 442 | '%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.', |
443 | 443 | 'event_espresso' |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | add_action('AHEE__thank_you_page_overview_template__content', array($this, 'get_ajax_content')); |
456 | 456 | } |
457 | 457 | return EEH_Template::locate_template( |
458 | - THANK_YOU_TEMPLATES_PATH . 'thank-you-page-overview.template.php', |
|
458 | + THANK_YOU_TEMPLATES_PATH.'thank-you-page-overview.template.php', |
|
459 | 459 | $template_args, |
460 | 460 | true, |
461 | 461 | true |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | '$SPCO_attendee_information_url' |
508 | 508 | ); |
509 | 509 | echo EEH_Template::locate_template( |
510 | - THANK_YOU_TEMPLATES_PATH . 'thank-you-page-registration-details.template.php', |
|
510 | + THANK_YOU_TEMPLATES_PATH.'thank-you-page-registration-details.template.php', |
|
511 | 511 | $template_args, |
512 | 512 | true, |
513 | 513 | true |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | */ |
581 | 581 | public function get_ajax_content() |
582 | 582 | { |
583 | - if (! $this->get_txn()) { |
|
583 | + if ( ! $this->get_txn()) { |
|
584 | 584 | return; |
585 | 585 | } |
586 | 586 | // first determine which event(s) require pre-approval or not |
@@ -591,9 +591,9 @@ discard block |
||
591 | 591 | $event = $registration->event(); |
592 | 592 | if ($event instanceof EE_Event) { |
593 | 593 | if ($registration->is_not_approved() && $registration->event() instanceof EE_Event) { |
594 | - $events_requiring_pre_approval[ $event->ID() ] = $event; |
|
594 | + $events_requiring_pre_approval[$event->ID()] = $event; |
|
595 | 595 | } else { |
596 | - $events[ $event->ID() ] = $event; |
|
596 | + $events[$event->ID()] = $event; |
|
597 | 597 | } |
598 | 598 | } |
599 | 599 | } |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | */ |
612 | 612 | public function display_details_for_events($events = array()) |
613 | 613 | { |
614 | - if (! empty($events)) { |
|
614 | + if ( ! empty($events)) { |
|
615 | 615 | ?> |
616 | 616 | <div id="espresso-thank-you-page-ajax-content-dv"> |
617 | 617 | <div id="espresso-thank-you-page-ajax-transaction-dv"></div> |
@@ -624,7 +624,7 @@ discard block |
||
624 | 624 | 'event_espresso' |
625 | 625 | ); ?></span> |
626 | 626 | </div> |
627 | - <?php if (! $this->_is_offline_payment_method && ! $this->_payments_closed) : ?> |
|
627 | + <?php if ( ! $this->_is_offline_payment_method && ! $this->_payments_closed) : ?> |
|
628 | 628 | <p id="ee-ajax-loading-pg" class="highlight-bg small-text clear"> |
629 | 629 | <?php echo apply_filters( |
630 | 630 | 'EED_Thank_You_Page__get_ajax_content__waiting_for_IPN_msg', |
@@ -655,7 +655,7 @@ discard block |
||
655 | 655 | */ |
656 | 656 | public function display_details_for_events_requiring_pre_approval($events = array()) |
657 | 657 | { |
658 | - if (! empty($events)) { |
|
658 | + if ( ! empty($events)) { |
|
659 | 659 | ?> |
660 | 660 | <div id="espresso-thank-you-page-not-approved-message-dv"> |
661 | 661 | <h4 class="orange-text"><?php _e('Important Notice:', 'event_espresso'); ?></h4> |
@@ -712,7 +712,7 @@ discard block |
||
712 | 712 | '$SPCO_payment_options_url' |
713 | 713 | ); |
714 | 714 | return EEH_Template::locate_template( |
715 | - THANK_YOU_TEMPLATES_PATH . 'thank-you-page-transaction-details.template.php', |
|
715 | + THANK_YOU_TEMPLATES_PATH.'thank-you-page-transaction-details.template.php', |
|
716 | 716 | $template_args, |
717 | 717 | true, |
718 | 718 | true |
@@ -741,25 +741,25 @@ discard block |
||
741 | 741 | $payment->set_status(EEM_Payment::status_id_pending); |
742 | 742 | } |
743 | 743 | $payment_declined_msg = $payment->STS_ID() === EEM_Payment::status_id_declined |
744 | - ? '<br /><span class="small-text">' . $payment->gateway_response() . '</span>' |
|
744 | + ? '<br /><span class="small-text">'.$payment->gateway_response().'</span>' |
|
745 | 745 | : ''; |
746 | 746 | $html .= ' |
747 | 747 | <tr> |
748 | 748 | <td> |
749 | - ' . $payment->timestamp() . ' |
|
749 | + ' . $payment->timestamp().' |
|
750 | 750 | </td> |
751 | 751 | <td> |
752 | 752 | ' . ( |
753 | 753 | $payment->payment_method() instanceof EE_Payment_Method |
754 | 754 | ? $payment->payment_method()->name() |
755 | 755 | : __('Unknown', 'event_espresso') |
756 | - ) . ' |
|
756 | + ).' |
|
757 | 757 | </td> |
758 | 758 | <td class="jst-rght"> |
759 | - ' . EEH_Template::format_currency($payment->amount()) . ' |
|
759 | + ' . EEH_Template::format_currency($payment->amount()).' |
|
760 | 760 | </td> |
761 | 761 | <td class="jst-rght" style="line-height:1;"> |
762 | - ' . $payment->pretty_status(true) . $payment_declined_msg . ' |
|
762 | + ' . $payment->pretty_status(true).$payment_declined_msg.' |
|
763 | 763 | </td> |
764 | 764 | </tr>'; |
765 | 765 | do_action('AHEE__thank_you_page_payment_details_template__after_each_payment', $payment); |
@@ -817,7 +817,7 @@ discard block |
||
817 | 817 | '$SPCO_payment_options_url' |
818 | 818 | ); |
819 | 819 | return EEH_Template::locate_template( |
820 | - THANK_YOU_TEMPLATES_PATH . 'thank-you-page-payment-details.template.php', |
|
820 | + THANK_YOU_TEMPLATES_PATH.'thank-you-page-payment-details.template.php', |
|
821 | 821 | $template_args, |
822 | 822 | true, |
823 | 823 | true |
@@ -10,611 +10,611 @@ discard block |
||
10 | 10 | class EED_Thank_You_Page extends EED_Module |
11 | 11 | { |
12 | 12 | |
13 | - /** |
|
14 | - * time in seconds to wait for the IPN to arrive before telling the registrant to bugger off ( 1200s = 20 minutes ) |
|
15 | - */ |
|
16 | - const IPN_wait_time = 1200; |
|
17 | - |
|
18 | - /** |
|
19 | - * The transaction specified by the reg_url_link passed from the Request, or from the Session |
|
20 | - * |
|
21 | - * @var EE_Transaction $_current_txn |
|
22 | - */ |
|
23 | - private $_current_txn; |
|
24 | - |
|
25 | - /** |
|
26 | - * @var EE_Registration $_primary_registrant |
|
27 | - */ |
|
28 | - private $_primary_registrant; |
|
29 | - |
|
30 | - /** |
|
31 | - * The reg_url_link passed from the Request, or from the Session |
|
32 | - * |
|
33 | - * @var string $_reg_url_link |
|
34 | - */ |
|
35 | - private $_reg_url_link; |
|
36 | - |
|
37 | - /** |
|
38 | - * whether the incoming reg_url_link is for the primary registrant or not |
|
39 | - * |
|
40 | - * @var boolean $_is_primary |
|
41 | - */ |
|
42 | - private $_is_primary; |
|
43 | - |
|
44 | - /** |
|
45 | - * The URL for revisiting the SPCO attendee information step |
|
46 | - * |
|
47 | - * @var string $_SPCO_attendee_information_url |
|
48 | - */ |
|
49 | - private $_SPCO_attendee_information_url; |
|
50 | - |
|
51 | - /** |
|
52 | - * The URL for revisiting the SPCO payment options step |
|
53 | - * |
|
54 | - * @var string $_SPCO_payment_options_url |
|
55 | - */ |
|
56 | - private $_SPCO_payment_options_url; |
|
57 | - |
|
58 | - /** |
|
59 | - * whether to display the Payment Options link |
|
60 | - * |
|
61 | - * @var boolean $_show_try_pay_again_link |
|
62 | - */ |
|
63 | - private $_show_try_pay_again_link = false; |
|
64 | - |
|
65 | - /** |
|
66 | - * whether payments are allowed at this time |
|
67 | - * |
|
68 | - * @var boolean $_payments_closed |
|
69 | - */ |
|
70 | - private $_payments_closed = false; |
|
71 | - |
|
72 | - /** |
|
73 | - * whether the selected payment method is Bank, Check , Invoice, etc |
|
74 | - * |
|
75 | - * @var boolean $_is_offline_payment_method |
|
76 | - */ |
|
77 | - private $_is_offline_payment_method = true; |
|
78 | - |
|
79 | - |
|
80 | - /** |
|
81 | - * @return EED_Module|EED_Thank_You_Page |
|
82 | - */ |
|
83 | - public static function instance() |
|
84 | - { |
|
85 | - return parent::get_instance(__CLASS__); |
|
86 | - } |
|
87 | - |
|
88 | - |
|
89 | - /** |
|
90 | - * set_hooks - for hooking into EE Core, modules, etc |
|
91 | - * |
|
92 | - * @return void |
|
93 | - */ |
|
94 | - public static function set_hooks() |
|
95 | - { |
|
96 | - add_action('wp_loaded', array('EED_Thank_You_Page', 'set_definitions'), 2); |
|
97 | - } |
|
98 | - |
|
99 | - |
|
100 | - /** |
|
101 | - * set_hooks_admin - for hooking into EE Admin Core, modules, etc |
|
102 | - * |
|
103 | - * @return void |
|
104 | - */ |
|
105 | - public static function set_hooks_admin() |
|
106 | - { |
|
107 | - add_action( |
|
108 | - 'wp_ajax_espresso_resend_reg_confirmation_email', |
|
109 | - array('EED_Thank_You_Page', 'resend_reg_confirmation_email'), |
|
110 | - 10, |
|
111 | - 2 |
|
112 | - ); |
|
113 | - add_action( |
|
114 | - 'wp_ajax_nopriv_espresso_resend_reg_confirmation_email', |
|
115 | - array('EED_Thank_You_Page', 'resend_reg_confirmation_email'), |
|
116 | - 10, |
|
117 | - 2 |
|
118 | - ); |
|
119 | - } |
|
120 | - |
|
121 | - |
|
122 | - /** |
|
123 | - * set_definitions |
|
124 | - * |
|
125 | - * @return void |
|
126 | - */ |
|
127 | - public static function set_definitions() |
|
128 | - { |
|
129 | - define('THANK_YOU_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/'); |
|
130 | - define('THANK_YOU_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/'); |
|
131 | - } |
|
132 | - |
|
133 | - |
|
134 | - /** |
|
135 | - * get_txn |
|
136 | - * |
|
137 | - * @return EE_Transaction |
|
138 | - */ |
|
139 | - public function get_txn() |
|
140 | - { |
|
141 | - if ($this->_current_txn instanceof EE_Transaction) { |
|
142 | - return $this->_current_txn; |
|
143 | - } |
|
144 | - $TXN_model = EE_Registry::instance()->load_model('Transaction'); |
|
145 | - if (! $TXN_model instanceof EEM_Transaction) { |
|
146 | - EE_Error::add_error( |
|
147 | - __('The transaction model could not be established.', 'event_espresso'), |
|
148 | - __FILE__, |
|
149 | - __FUNCTION__, |
|
150 | - __LINE__ |
|
151 | - ); |
|
152 | - return null; |
|
153 | - } |
|
154 | - // get the transaction. yes, we may have just loaded it, but it may have been updated, or this may be via an ajax request |
|
155 | - $this->_current_txn = $TXN_model->get_transaction_from_reg_url_link($this->_reg_url_link); |
|
156 | - // verify TXN |
|
157 | - if (WP_DEBUG && ! $this->_current_txn instanceof EE_Transaction) { |
|
158 | - EE_Error::add_error( |
|
159 | - __( |
|
160 | - 'No transaction information could be retrieved or the transaction data is not of the correct type.', |
|
161 | - 'event_espresso' |
|
162 | - ), |
|
163 | - __FILE__, |
|
164 | - __FUNCTION__, |
|
165 | - __LINE__ |
|
166 | - ); |
|
167 | - return null; |
|
168 | - } |
|
169 | - return $this->_current_txn; |
|
170 | - } |
|
171 | - |
|
172 | - |
|
173 | - /** |
|
174 | - * get_txn_payments |
|
175 | - * |
|
176 | - * @param int $since |
|
177 | - * @return mixed array of EE_Payment || FALSE |
|
178 | - * @throws \EE_Error |
|
179 | - */ |
|
180 | - public function get_txn_payments($since = 0) |
|
181 | - { |
|
182 | - if (! $this->get_txn()) { |
|
183 | - return false; |
|
184 | - } |
|
185 | - $args = array('order_by' => array('PAY_timestamp' => 'ASC')); |
|
186 | - if ($since > 0) { |
|
187 | - $args[0] = array('PAY_timestamp' => array('>', $since)); |
|
188 | - } |
|
189 | - // get array of payments with most recent first |
|
190 | - return $this->_current_txn->payments($args); |
|
191 | - } |
|
192 | - |
|
193 | - |
|
194 | - /** |
|
195 | - * @return bool |
|
196 | - */ |
|
197 | - public function isOfflinePaymentMethod() |
|
198 | - { |
|
199 | - return $this->_is_offline_payment_method; |
|
200 | - } |
|
201 | - |
|
202 | - |
|
203 | - |
|
204 | - |
|
205 | - /** |
|
206 | - * get_reg_url_link |
|
207 | - * |
|
208 | - * @return void |
|
209 | - */ |
|
210 | - private function _get_reg_url_link() |
|
211 | - { |
|
212 | - if (! empty($this->_reg_url_link)) { |
|
213 | - return; |
|
214 | - } |
|
215 | - // only do thank you page stuff if we have a REG_url_link in the url |
|
216 | - if (WP_DEBUG && ! EE_Registry::instance()->REQ->is_set('e_reg_url_link')) { |
|
217 | - EE_Error::add_error( |
|
218 | - __( |
|
219 | - 'No transaction information could be retrieved because the registration URL link is missing or invalid.', |
|
220 | - 'event_espresso' |
|
221 | - ), |
|
222 | - __FILE__, |
|
223 | - __FUNCTION__, |
|
224 | - __LINE__ |
|
225 | - ); |
|
226 | - return; |
|
227 | - } |
|
228 | - // check for reg_url_link |
|
229 | - $this->_reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link'); |
|
230 | - } |
|
231 | - |
|
232 | - |
|
233 | - /** |
|
234 | - * set_reg_url_link |
|
235 | - * |
|
236 | - * @param string $reg_url_link |
|
237 | - */ |
|
238 | - public function set_reg_url_link($reg_url_link = null) |
|
239 | - { |
|
240 | - $this->_reg_url_link = ! empty($reg_url_link) ? $reg_url_link : $this->_reg_url_link; |
|
241 | - } |
|
242 | - |
|
243 | - |
|
244 | - /** |
|
245 | - * run - initial module setup |
|
246 | - * this method is primarily used for activating resources in the EE_Front_Controller thru the use of filters |
|
247 | - * |
|
248 | - * @param WP $WP |
|
249 | - * @return void |
|
250 | - * @throws \EE_Error |
|
251 | - */ |
|
252 | - public function run($WP) |
|
253 | - { |
|
254 | - } |
|
255 | - |
|
256 | - |
|
257 | - /** |
|
258 | - * load_resources |
|
259 | - * |
|
260 | - * @return void |
|
261 | - * @throws \EE_Error |
|
262 | - */ |
|
263 | - public function load_resources() |
|
264 | - { |
|
265 | - $this->_get_reg_url_link(); |
|
266 | - // resend_reg_confirmation_email ? |
|
267 | - if (EE_Registry::instance()->REQ->is_set('resend')) { |
|
268 | - EED_Thank_You_Page::resend_reg_confirmation_email(); |
|
269 | - } |
|
270 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
271 | - $this->_translate_strings(); |
|
272 | - // load assets |
|
273 | - add_action('wp_enqueue_scripts', array($this, 'load_js'), 10); |
|
274 | - } |
|
275 | - |
|
276 | - |
|
277 | - /** |
|
278 | - * load_js |
|
279 | - * |
|
280 | - * @return void |
|
281 | - */ |
|
282 | - protected function _translate_strings() |
|
283 | - { |
|
284 | - EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->_reg_url_link; |
|
285 | - EE_Registry::$i18n_js_strings['initial_access'] = time(); |
|
286 | - EE_Registry::$i18n_js_strings['IPN_wait_time'] = EED_Thank_You_Page::IPN_wait_time; |
|
287 | - EE_Registry::$i18n_js_strings['TXN_complete'] = EEM_Transaction::complete_status_code; |
|
288 | - EE_Registry::$i18n_js_strings['TXN_incomplete'] = EEM_Transaction::incomplete_status_code; |
|
289 | - EE_Registry::$i18n_js_strings['checking_for_new_payments'] = __( |
|
290 | - 'checking for new payments...', |
|
291 | - 'event_espresso' |
|
292 | - ); |
|
293 | - EE_Registry::$i18n_js_strings['loading_payment_info'] = __( |
|
294 | - 'loading payment information...', |
|
295 | - 'event_espresso' |
|
296 | - ); |
|
297 | - EE_Registry::$i18n_js_strings['server_error'] = __( |
|
298 | - 'An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again.', |
|
299 | - 'event_espresso' |
|
300 | - ); |
|
301 | - EE_Registry::$i18n_js_strings['slow_IPN'] = apply_filters( |
|
302 | - 'EED_Thank_You_Page__load_js__slow_IPN', |
|
303 | - sprintf( |
|
304 | - __( |
|
305 | - '%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', |
|
306 | - 'event_espresso' |
|
307 | - ), |
|
308 | - '<div id="espresso-thank-you-page-slow-IPN-dv" class="ee-attention jst-left">', |
|
309 | - '</div>' |
|
310 | - ) |
|
311 | - ); |
|
312 | - } |
|
313 | - |
|
314 | - |
|
315 | - /** |
|
316 | - * load_js |
|
317 | - * |
|
318 | - * @return void |
|
319 | - */ |
|
320 | - public function load_js() |
|
321 | - { |
|
322 | - wp_register_script( |
|
323 | - 'thank_you_page', |
|
324 | - THANK_YOU_ASSETS_URL . 'thank_you_page.js', |
|
325 | - array('espresso_core', 'heartbeat'), |
|
326 | - EVENT_ESPRESSO_VERSION, |
|
327 | - true |
|
328 | - ); |
|
329 | - wp_enqueue_script('thank_you_page'); |
|
330 | - wp_enqueue_style('espresso_default'); |
|
331 | - } |
|
332 | - |
|
333 | - |
|
334 | - /** |
|
335 | - * init |
|
336 | - * |
|
337 | - * @return void |
|
338 | - * @throws \EE_Error |
|
339 | - */ |
|
340 | - public function init() |
|
341 | - { |
|
342 | - $this->_get_reg_url_link(); |
|
343 | - if (! $this->get_txn()) { |
|
344 | - echo EEH_HTML::div( |
|
345 | - EEH_HTML::h4(__('We\'re sorry...', 'event_espresso'), '', '') . |
|
346 | - sprintf( |
|
347 | - __( |
|
348 | - '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', |
|
349 | - 'event_espresso' |
|
350 | - ), |
|
351 | - '<br/>' |
|
352 | - ), |
|
353 | - '', |
|
354 | - 'ee-attention' |
|
355 | - ); |
|
356 | - return null; |
|
357 | - } |
|
358 | - // if we've made it to the Thank You page, then let's toggle any "Failed" transactions to "Incomplete" |
|
359 | - if ($this->_current_txn->status_ID() === EEM_Transaction::failed_status_code) { |
|
360 | - $this->_current_txn->set_status(EEM_Transaction::incomplete_status_code); |
|
361 | - $this->_current_txn->save(); |
|
362 | - } |
|
363 | - $this->_primary_registrant = $this->_current_txn->primary_registration() instanceof EE_Registration |
|
364 | - ? $this->_current_txn->primary_registration() |
|
365 | - : null; |
|
366 | - $this->_is_primary = $this->_primary_registrant->reg_url_link() === $this->_reg_url_link ? true : false; |
|
367 | - $show_try_pay_again_link_default = apply_filters( |
|
368 | - 'AFEE__EED_Thank_You_Page__init__show_try_pay_again_link_default', |
|
369 | - true |
|
370 | - ); |
|
371 | - $this->_show_try_pay_again_link = $show_try_pay_again_link_default; |
|
372 | - // txn status ? |
|
373 | - if ($this->_current_txn->is_completed()) { |
|
374 | - $this->_show_try_pay_again_link = $show_try_pay_again_link_default; |
|
375 | - } elseif ( |
|
376 | - $this->_current_txn->is_incomplete() |
|
377 | - && ($this->_primary_registrant->is_approved() |
|
378 | - || $this->_primary_registrant->is_pending_payment()) |
|
379 | - ) { |
|
380 | - $this->_show_try_pay_again_link = true; |
|
381 | - } elseif ($this->_primary_registrant->is_approved() || $this->_primary_registrant->is_pending_payment()) { |
|
382 | - // its pending |
|
383 | - $this->_show_try_pay_again_link = isset( |
|
384 | - EE_Registry::instance()->CFG->registration->show_pending_payment_options |
|
385 | - ) |
|
386 | - && EE_Registry::instance()->CFG |
|
387 | - ->registration->show_pending_payment_options |
|
388 | - ? true |
|
389 | - : $show_try_pay_again_link_default; |
|
390 | - } |
|
391 | - $this->_payments_closed = ! $this->_current_txn->payment_method() instanceof EE_Payment_Method |
|
392 | - ? true |
|
393 | - : false; |
|
394 | - $this->_is_offline_payment_method = false; |
|
395 | - if ( |
|
13 | + /** |
|
14 | + * time in seconds to wait for the IPN to arrive before telling the registrant to bugger off ( 1200s = 20 minutes ) |
|
15 | + */ |
|
16 | + const IPN_wait_time = 1200; |
|
17 | + |
|
18 | + /** |
|
19 | + * The transaction specified by the reg_url_link passed from the Request, or from the Session |
|
20 | + * |
|
21 | + * @var EE_Transaction $_current_txn |
|
22 | + */ |
|
23 | + private $_current_txn; |
|
24 | + |
|
25 | + /** |
|
26 | + * @var EE_Registration $_primary_registrant |
|
27 | + */ |
|
28 | + private $_primary_registrant; |
|
29 | + |
|
30 | + /** |
|
31 | + * The reg_url_link passed from the Request, or from the Session |
|
32 | + * |
|
33 | + * @var string $_reg_url_link |
|
34 | + */ |
|
35 | + private $_reg_url_link; |
|
36 | + |
|
37 | + /** |
|
38 | + * whether the incoming reg_url_link is for the primary registrant or not |
|
39 | + * |
|
40 | + * @var boolean $_is_primary |
|
41 | + */ |
|
42 | + private $_is_primary; |
|
43 | + |
|
44 | + /** |
|
45 | + * The URL for revisiting the SPCO attendee information step |
|
46 | + * |
|
47 | + * @var string $_SPCO_attendee_information_url |
|
48 | + */ |
|
49 | + private $_SPCO_attendee_information_url; |
|
50 | + |
|
51 | + /** |
|
52 | + * The URL for revisiting the SPCO payment options step |
|
53 | + * |
|
54 | + * @var string $_SPCO_payment_options_url |
|
55 | + */ |
|
56 | + private $_SPCO_payment_options_url; |
|
57 | + |
|
58 | + /** |
|
59 | + * whether to display the Payment Options link |
|
60 | + * |
|
61 | + * @var boolean $_show_try_pay_again_link |
|
62 | + */ |
|
63 | + private $_show_try_pay_again_link = false; |
|
64 | + |
|
65 | + /** |
|
66 | + * whether payments are allowed at this time |
|
67 | + * |
|
68 | + * @var boolean $_payments_closed |
|
69 | + */ |
|
70 | + private $_payments_closed = false; |
|
71 | + |
|
72 | + /** |
|
73 | + * whether the selected payment method is Bank, Check , Invoice, etc |
|
74 | + * |
|
75 | + * @var boolean $_is_offline_payment_method |
|
76 | + */ |
|
77 | + private $_is_offline_payment_method = true; |
|
78 | + |
|
79 | + |
|
80 | + /** |
|
81 | + * @return EED_Module|EED_Thank_You_Page |
|
82 | + */ |
|
83 | + public static function instance() |
|
84 | + { |
|
85 | + return parent::get_instance(__CLASS__); |
|
86 | + } |
|
87 | + |
|
88 | + |
|
89 | + /** |
|
90 | + * set_hooks - for hooking into EE Core, modules, etc |
|
91 | + * |
|
92 | + * @return void |
|
93 | + */ |
|
94 | + public static function set_hooks() |
|
95 | + { |
|
96 | + add_action('wp_loaded', array('EED_Thank_You_Page', 'set_definitions'), 2); |
|
97 | + } |
|
98 | + |
|
99 | + |
|
100 | + /** |
|
101 | + * set_hooks_admin - for hooking into EE Admin Core, modules, etc |
|
102 | + * |
|
103 | + * @return void |
|
104 | + */ |
|
105 | + public static function set_hooks_admin() |
|
106 | + { |
|
107 | + add_action( |
|
108 | + 'wp_ajax_espresso_resend_reg_confirmation_email', |
|
109 | + array('EED_Thank_You_Page', 'resend_reg_confirmation_email'), |
|
110 | + 10, |
|
111 | + 2 |
|
112 | + ); |
|
113 | + add_action( |
|
114 | + 'wp_ajax_nopriv_espresso_resend_reg_confirmation_email', |
|
115 | + array('EED_Thank_You_Page', 'resend_reg_confirmation_email'), |
|
116 | + 10, |
|
117 | + 2 |
|
118 | + ); |
|
119 | + } |
|
120 | + |
|
121 | + |
|
122 | + /** |
|
123 | + * set_definitions |
|
124 | + * |
|
125 | + * @return void |
|
126 | + */ |
|
127 | + public static function set_definitions() |
|
128 | + { |
|
129 | + define('THANK_YOU_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/'); |
|
130 | + define('THANK_YOU_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/'); |
|
131 | + } |
|
132 | + |
|
133 | + |
|
134 | + /** |
|
135 | + * get_txn |
|
136 | + * |
|
137 | + * @return EE_Transaction |
|
138 | + */ |
|
139 | + public function get_txn() |
|
140 | + { |
|
141 | + if ($this->_current_txn instanceof EE_Transaction) { |
|
142 | + return $this->_current_txn; |
|
143 | + } |
|
144 | + $TXN_model = EE_Registry::instance()->load_model('Transaction'); |
|
145 | + if (! $TXN_model instanceof EEM_Transaction) { |
|
146 | + EE_Error::add_error( |
|
147 | + __('The transaction model could not be established.', 'event_espresso'), |
|
148 | + __FILE__, |
|
149 | + __FUNCTION__, |
|
150 | + __LINE__ |
|
151 | + ); |
|
152 | + return null; |
|
153 | + } |
|
154 | + // get the transaction. yes, we may have just loaded it, but it may have been updated, or this may be via an ajax request |
|
155 | + $this->_current_txn = $TXN_model->get_transaction_from_reg_url_link($this->_reg_url_link); |
|
156 | + // verify TXN |
|
157 | + if (WP_DEBUG && ! $this->_current_txn instanceof EE_Transaction) { |
|
158 | + EE_Error::add_error( |
|
159 | + __( |
|
160 | + 'No transaction information could be retrieved or the transaction data is not of the correct type.', |
|
161 | + 'event_espresso' |
|
162 | + ), |
|
163 | + __FILE__, |
|
164 | + __FUNCTION__, |
|
165 | + __LINE__ |
|
166 | + ); |
|
167 | + return null; |
|
168 | + } |
|
169 | + return $this->_current_txn; |
|
170 | + } |
|
171 | + |
|
172 | + |
|
173 | + /** |
|
174 | + * get_txn_payments |
|
175 | + * |
|
176 | + * @param int $since |
|
177 | + * @return mixed array of EE_Payment || FALSE |
|
178 | + * @throws \EE_Error |
|
179 | + */ |
|
180 | + public function get_txn_payments($since = 0) |
|
181 | + { |
|
182 | + if (! $this->get_txn()) { |
|
183 | + return false; |
|
184 | + } |
|
185 | + $args = array('order_by' => array('PAY_timestamp' => 'ASC')); |
|
186 | + if ($since > 0) { |
|
187 | + $args[0] = array('PAY_timestamp' => array('>', $since)); |
|
188 | + } |
|
189 | + // get array of payments with most recent first |
|
190 | + return $this->_current_txn->payments($args); |
|
191 | + } |
|
192 | + |
|
193 | + |
|
194 | + /** |
|
195 | + * @return bool |
|
196 | + */ |
|
197 | + public function isOfflinePaymentMethod() |
|
198 | + { |
|
199 | + return $this->_is_offline_payment_method; |
|
200 | + } |
|
201 | + |
|
202 | + |
|
203 | + |
|
204 | + |
|
205 | + /** |
|
206 | + * get_reg_url_link |
|
207 | + * |
|
208 | + * @return void |
|
209 | + */ |
|
210 | + private function _get_reg_url_link() |
|
211 | + { |
|
212 | + if (! empty($this->_reg_url_link)) { |
|
213 | + return; |
|
214 | + } |
|
215 | + // only do thank you page stuff if we have a REG_url_link in the url |
|
216 | + if (WP_DEBUG && ! EE_Registry::instance()->REQ->is_set('e_reg_url_link')) { |
|
217 | + EE_Error::add_error( |
|
218 | + __( |
|
219 | + 'No transaction information could be retrieved because the registration URL link is missing or invalid.', |
|
220 | + 'event_espresso' |
|
221 | + ), |
|
222 | + __FILE__, |
|
223 | + __FUNCTION__, |
|
224 | + __LINE__ |
|
225 | + ); |
|
226 | + return; |
|
227 | + } |
|
228 | + // check for reg_url_link |
|
229 | + $this->_reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link'); |
|
230 | + } |
|
231 | + |
|
232 | + |
|
233 | + /** |
|
234 | + * set_reg_url_link |
|
235 | + * |
|
236 | + * @param string $reg_url_link |
|
237 | + */ |
|
238 | + public function set_reg_url_link($reg_url_link = null) |
|
239 | + { |
|
240 | + $this->_reg_url_link = ! empty($reg_url_link) ? $reg_url_link : $this->_reg_url_link; |
|
241 | + } |
|
242 | + |
|
243 | + |
|
244 | + /** |
|
245 | + * run - initial module setup |
|
246 | + * this method is primarily used for activating resources in the EE_Front_Controller thru the use of filters |
|
247 | + * |
|
248 | + * @param WP $WP |
|
249 | + * @return void |
|
250 | + * @throws \EE_Error |
|
251 | + */ |
|
252 | + public function run($WP) |
|
253 | + { |
|
254 | + } |
|
255 | + |
|
256 | + |
|
257 | + /** |
|
258 | + * load_resources |
|
259 | + * |
|
260 | + * @return void |
|
261 | + * @throws \EE_Error |
|
262 | + */ |
|
263 | + public function load_resources() |
|
264 | + { |
|
265 | + $this->_get_reg_url_link(); |
|
266 | + // resend_reg_confirmation_email ? |
|
267 | + if (EE_Registry::instance()->REQ->is_set('resend')) { |
|
268 | + EED_Thank_You_Page::resend_reg_confirmation_email(); |
|
269 | + } |
|
270 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
271 | + $this->_translate_strings(); |
|
272 | + // load assets |
|
273 | + add_action('wp_enqueue_scripts', array($this, 'load_js'), 10); |
|
274 | + } |
|
275 | + |
|
276 | + |
|
277 | + /** |
|
278 | + * load_js |
|
279 | + * |
|
280 | + * @return void |
|
281 | + */ |
|
282 | + protected function _translate_strings() |
|
283 | + { |
|
284 | + EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->_reg_url_link; |
|
285 | + EE_Registry::$i18n_js_strings['initial_access'] = time(); |
|
286 | + EE_Registry::$i18n_js_strings['IPN_wait_time'] = EED_Thank_You_Page::IPN_wait_time; |
|
287 | + EE_Registry::$i18n_js_strings['TXN_complete'] = EEM_Transaction::complete_status_code; |
|
288 | + EE_Registry::$i18n_js_strings['TXN_incomplete'] = EEM_Transaction::incomplete_status_code; |
|
289 | + EE_Registry::$i18n_js_strings['checking_for_new_payments'] = __( |
|
290 | + 'checking for new payments...', |
|
291 | + 'event_espresso' |
|
292 | + ); |
|
293 | + EE_Registry::$i18n_js_strings['loading_payment_info'] = __( |
|
294 | + 'loading payment information...', |
|
295 | + 'event_espresso' |
|
296 | + ); |
|
297 | + EE_Registry::$i18n_js_strings['server_error'] = __( |
|
298 | + 'An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again.', |
|
299 | + 'event_espresso' |
|
300 | + ); |
|
301 | + EE_Registry::$i18n_js_strings['slow_IPN'] = apply_filters( |
|
302 | + 'EED_Thank_You_Page__load_js__slow_IPN', |
|
303 | + sprintf( |
|
304 | + __( |
|
305 | + '%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', |
|
306 | + 'event_espresso' |
|
307 | + ), |
|
308 | + '<div id="espresso-thank-you-page-slow-IPN-dv" class="ee-attention jst-left">', |
|
309 | + '</div>' |
|
310 | + ) |
|
311 | + ); |
|
312 | + } |
|
313 | + |
|
314 | + |
|
315 | + /** |
|
316 | + * load_js |
|
317 | + * |
|
318 | + * @return void |
|
319 | + */ |
|
320 | + public function load_js() |
|
321 | + { |
|
322 | + wp_register_script( |
|
323 | + 'thank_you_page', |
|
324 | + THANK_YOU_ASSETS_URL . 'thank_you_page.js', |
|
325 | + array('espresso_core', 'heartbeat'), |
|
326 | + EVENT_ESPRESSO_VERSION, |
|
327 | + true |
|
328 | + ); |
|
329 | + wp_enqueue_script('thank_you_page'); |
|
330 | + wp_enqueue_style('espresso_default'); |
|
331 | + } |
|
332 | + |
|
333 | + |
|
334 | + /** |
|
335 | + * init |
|
336 | + * |
|
337 | + * @return void |
|
338 | + * @throws \EE_Error |
|
339 | + */ |
|
340 | + public function init() |
|
341 | + { |
|
342 | + $this->_get_reg_url_link(); |
|
343 | + if (! $this->get_txn()) { |
|
344 | + echo EEH_HTML::div( |
|
345 | + EEH_HTML::h4(__('We\'re sorry...', 'event_espresso'), '', '') . |
|
346 | + sprintf( |
|
347 | + __( |
|
348 | + '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', |
|
349 | + 'event_espresso' |
|
350 | + ), |
|
351 | + '<br/>' |
|
352 | + ), |
|
353 | + '', |
|
354 | + 'ee-attention' |
|
355 | + ); |
|
356 | + return null; |
|
357 | + } |
|
358 | + // if we've made it to the Thank You page, then let's toggle any "Failed" transactions to "Incomplete" |
|
359 | + if ($this->_current_txn->status_ID() === EEM_Transaction::failed_status_code) { |
|
360 | + $this->_current_txn->set_status(EEM_Transaction::incomplete_status_code); |
|
361 | + $this->_current_txn->save(); |
|
362 | + } |
|
363 | + $this->_primary_registrant = $this->_current_txn->primary_registration() instanceof EE_Registration |
|
364 | + ? $this->_current_txn->primary_registration() |
|
365 | + : null; |
|
366 | + $this->_is_primary = $this->_primary_registrant->reg_url_link() === $this->_reg_url_link ? true : false; |
|
367 | + $show_try_pay_again_link_default = apply_filters( |
|
368 | + 'AFEE__EED_Thank_You_Page__init__show_try_pay_again_link_default', |
|
369 | + true |
|
370 | + ); |
|
371 | + $this->_show_try_pay_again_link = $show_try_pay_again_link_default; |
|
372 | + // txn status ? |
|
373 | + if ($this->_current_txn->is_completed()) { |
|
374 | + $this->_show_try_pay_again_link = $show_try_pay_again_link_default; |
|
375 | + } elseif ( |
|
376 | + $this->_current_txn->is_incomplete() |
|
377 | + && ($this->_primary_registrant->is_approved() |
|
378 | + || $this->_primary_registrant->is_pending_payment()) |
|
379 | + ) { |
|
380 | + $this->_show_try_pay_again_link = true; |
|
381 | + } elseif ($this->_primary_registrant->is_approved() || $this->_primary_registrant->is_pending_payment()) { |
|
382 | + // its pending |
|
383 | + $this->_show_try_pay_again_link = isset( |
|
384 | + EE_Registry::instance()->CFG->registration->show_pending_payment_options |
|
385 | + ) |
|
386 | + && EE_Registry::instance()->CFG |
|
387 | + ->registration->show_pending_payment_options |
|
388 | + ? true |
|
389 | + : $show_try_pay_again_link_default; |
|
390 | + } |
|
391 | + $this->_payments_closed = ! $this->_current_txn->payment_method() instanceof EE_Payment_Method |
|
392 | + ? true |
|
393 | + : false; |
|
394 | + $this->_is_offline_payment_method = false; |
|
395 | + if ( |
|
396 | 396 | // if payment method is unknown |
397 | - ! $this->_current_txn->payment_method() instanceof EE_Payment_Method |
|
398 | - || ( |
|
399 | - // or is an offline payment method |
|
400 | - $this->_current_txn->payment_method() instanceof EE_Payment_Method |
|
401 | - && $this->_current_txn->payment_method()->is_off_line() |
|
402 | - ) |
|
403 | - ) { |
|
404 | - $this->_is_offline_payment_method = true; |
|
405 | - } |
|
406 | - // link to SPCO |
|
407 | - $revisit_spco_url = add_query_arg( |
|
408 | - array('ee' => '_register', 'revisit' => true, 'e_reg_url_link' => $this->_reg_url_link), |
|
409 | - EE_Registry::instance()->CFG->core->reg_page_url() |
|
410 | - ); |
|
411 | - // link to SPCO payment_options |
|
412 | - $this->_SPCO_payment_options_url = $this->_primary_registrant instanceof EE_Registration |
|
413 | - ? $this->_primary_registrant->payment_overview_url() |
|
414 | - : add_query_arg( |
|
415 | - array('step' => 'payment_options'), |
|
416 | - $revisit_spco_url |
|
417 | - ); |
|
418 | - // link to SPCO attendee_information |
|
419 | - $this->_SPCO_attendee_information_url = $this->_primary_registrant instanceof EE_Registration |
|
420 | - ? $this->_primary_registrant->edit_attendee_information_url() |
|
421 | - : false; |
|
422 | - do_action('AHEE__EED_Thank_You_Page__init_end', $this->_current_txn); |
|
423 | - // set no cache headers and constants |
|
424 | - EE_System::do_not_cache(); |
|
425 | - } |
|
426 | - |
|
427 | - |
|
428 | - /** |
|
429 | - * display_thank_you_page_results |
|
430 | - * |
|
431 | - * @return string |
|
432 | - * @throws \EE_Error |
|
433 | - */ |
|
434 | - public function thank_you_page_results() |
|
435 | - { |
|
436 | - $this->init(); |
|
437 | - if (! $this->_current_txn instanceof EE_Transaction) { |
|
438 | - return EE_Error::get_notices(); |
|
439 | - } |
|
440 | - // link to receipt |
|
441 | - $template_args['TXN_receipt_url'] = $this->_current_txn->receipt_url('html'); |
|
442 | - if (! empty($template_args['TXN_receipt_url'])) { |
|
443 | - $template_args['order_conf_desc'] = __( |
|
444 | - '%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.', |
|
445 | - 'event_espresso' |
|
446 | - ); |
|
447 | - } else { |
|
448 | - $template_args['order_conf_desc'] = __( |
|
449 | - '%1$sCongratulations%2$sYour registration has been successfully processed.%3$sCheck your email for your registration confirmation.', |
|
450 | - 'event_espresso' |
|
451 | - ); |
|
452 | - } |
|
453 | - $template_args['transaction'] = $this->_current_txn; |
|
454 | - $template_args['revisit'] = EE_Registry::instance()->REQ->get('revisit', false); |
|
455 | - add_action('AHEE__thank_you_page_overview_template__content', array($this, 'get_registration_details')); |
|
456 | - if ($this->_is_primary && ! $this->_current_txn->is_free()) { |
|
457 | - add_action('AHEE__thank_you_page_overview_template__content', array($this, 'get_ajax_content')); |
|
458 | - } |
|
459 | - return EEH_Template::locate_template( |
|
460 | - THANK_YOU_TEMPLATES_PATH . 'thank-you-page-overview.template.php', |
|
461 | - $template_args, |
|
462 | - true, |
|
463 | - true |
|
464 | - ); |
|
465 | - } |
|
466 | - |
|
467 | - |
|
468 | - |
|
469 | - /** |
|
470 | - * _update_server_wait_time |
|
471 | - * |
|
472 | - * @param array $thank_you_page_data thank you page portion of the incoming JSON array from the WP heartbeat data |
|
473 | - * @return array |
|
474 | - * @throws \EE_Error |
|
475 | - */ |
|
476 | - private function _update_server_wait_time($thank_you_page_data = array()) |
|
477 | - { |
|
478 | - $response['espresso_thank_you_page'] = array( |
|
479 | - 'still_waiting' => isset($thank_you_page_data['initial_access']) |
|
480 | - ? time() - $thank_you_page_data['initial_access'] |
|
481 | - : 0, |
|
482 | - 'txn_status' => $this->_current_txn->status_ID(), |
|
483 | - ); |
|
484 | - return $response; |
|
485 | - } |
|
486 | - |
|
487 | - |
|
488 | - /** |
|
489 | - * get_registration_details |
|
490 | - * |
|
491 | - * @throws \EE_Error |
|
492 | - */ |
|
493 | - public function get_registration_details() |
|
494 | - { |
|
495 | - // prepare variables for displaying |
|
496 | - $template_args = array(); |
|
497 | - $template_args['transaction'] = $this->_current_txn; |
|
498 | - $template_args['reg_url_link'] = $this->_reg_url_link; |
|
499 | - $template_args['is_primary'] = $this->_is_primary; |
|
500 | - $template_args['SPCO_attendee_information_url'] = $this->_SPCO_attendee_information_url; |
|
501 | - $template_args['resend_reg_confirmation_url'] = add_query_arg( |
|
502 | - array('token' => $this->_reg_url_link, 'resend_reg_confirmation' => 'true'), |
|
503 | - EE_Registry::instance()->CFG->core->thank_you_page_url() |
|
504 | - ); |
|
505 | - // verify template arguments |
|
506 | - EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction'); |
|
507 | - EEH_Template_Validator::verify_isnt_null( |
|
508 | - $template_args['SPCO_attendee_information_url'], |
|
509 | - '$SPCO_attendee_information_url' |
|
510 | - ); |
|
511 | - echo EEH_Template::locate_template( |
|
512 | - THANK_YOU_TEMPLATES_PATH . 'thank-you-page-registration-details.template.php', |
|
513 | - $template_args, |
|
514 | - true, |
|
515 | - true |
|
516 | - ); |
|
517 | - } |
|
518 | - |
|
519 | - |
|
520 | - /** |
|
521 | - * resend_reg_confirmation_email |
|
522 | - * |
|
523 | - * @throws \EE_Error |
|
524 | - */ |
|
525 | - public static function resend_reg_confirmation_email() |
|
526 | - { |
|
527 | - EE_Registry::instance()->load_core('Request_Handler'); |
|
528 | - $reg_url_link = EE_Registry::instance()->REQ->get('token'); |
|
529 | - // was a REG_ID passed ? |
|
530 | - if ($reg_url_link) { |
|
531 | - $registration = EE_Registry::instance()->load_model('Registration')->get_one( |
|
532 | - array(array('REG_url_link' => $reg_url_link)) |
|
533 | - ); |
|
534 | - if ($registration instanceof EE_Registration) { |
|
535 | - // resend email |
|
536 | - EED_Messages::process_resend(array('_REG_ID' => $registration->ID())); |
|
537 | - } else { |
|
538 | - EE_Error::add_error( |
|
539 | - __( |
|
540 | - 'The Registration Confirmation email could not be sent because a valid Registration could not be retrieved from the database.', |
|
541 | - 'event_espresso' |
|
542 | - ), |
|
543 | - __FILE__, |
|
544 | - __FUNCTION__, |
|
545 | - __LINE__ |
|
546 | - ); |
|
547 | - } |
|
548 | - } else { |
|
549 | - EE_Error::add_error( |
|
550 | - __( |
|
551 | - 'The Registration Confirmation email could not be sent because a registration token is missing or invalid.', |
|
552 | - 'event_espresso' |
|
553 | - ), |
|
554 | - __FILE__, |
|
555 | - __FUNCTION__, |
|
556 | - __LINE__ |
|
557 | - ); |
|
558 | - } |
|
559 | - // request sent via AJAX ? |
|
560 | - if (EE_FRONT_AJAX) { |
|
561 | - echo wp_json_encode(EE_Error::get_notices(false)); |
|
562 | - die(); |
|
563 | - // or was JS disabled ? |
|
564 | - } else { |
|
565 | - // save errors so that they get picked up on the next request |
|
566 | - EE_Error::get_notices(true, true); |
|
567 | - wp_safe_redirect( |
|
568 | - add_query_arg( |
|
569 | - array('e_reg_url_link' => $reg_url_link), |
|
570 | - EE_Registry::instance()->CFG->core->thank_you_page_url() |
|
571 | - ) |
|
572 | - ); |
|
573 | - } |
|
574 | - } |
|
575 | - |
|
576 | - |
|
577 | - /** |
|
578 | - * get_ajax_content |
|
579 | - * |
|
580 | - * @return void |
|
581 | - * @throws \EE_Error |
|
582 | - */ |
|
583 | - public function get_ajax_content() |
|
584 | - { |
|
585 | - if (! $this->get_txn()) { |
|
586 | - return; |
|
587 | - } |
|
588 | - // first determine which event(s) require pre-approval or not |
|
589 | - $events = array(); |
|
590 | - $events_requiring_pre_approval = array(); |
|
591 | - foreach ($this->_current_txn->registrations() as $registration) { |
|
592 | - if ($registration instanceof EE_Registration) { |
|
593 | - $event = $registration->event(); |
|
594 | - if ($event instanceof EE_Event) { |
|
595 | - if ($registration->is_not_approved() && $registration->event() instanceof EE_Event) { |
|
596 | - $events_requiring_pre_approval[ $event->ID() ] = $event; |
|
597 | - } else { |
|
598 | - $events[ $event->ID() ] = $event; |
|
599 | - } |
|
600 | - } |
|
601 | - } |
|
602 | - } |
|
603 | - $this->display_details_for_events_requiring_pre_approval($events_requiring_pre_approval); |
|
604 | - $this->display_details_for_events($events); |
|
605 | - } |
|
606 | - |
|
607 | - |
|
608 | - /** |
|
609 | - * display_details_for_events |
|
610 | - * |
|
611 | - * @param EE_Event[] $events |
|
612 | - * @return void |
|
613 | - */ |
|
614 | - public function display_details_for_events($events = array()) |
|
615 | - { |
|
616 | - if (! empty($events)) { |
|
617 | - ?> |
|
397 | + ! $this->_current_txn->payment_method() instanceof EE_Payment_Method |
|
398 | + || ( |
|
399 | + // or is an offline payment method |
|
400 | + $this->_current_txn->payment_method() instanceof EE_Payment_Method |
|
401 | + && $this->_current_txn->payment_method()->is_off_line() |
|
402 | + ) |
|
403 | + ) { |
|
404 | + $this->_is_offline_payment_method = true; |
|
405 | + } |
|
406 | + // link to SPCO |
|
407 | + $revisit_spco_url = add_query_arg( |
|
408 | + array('ee' => '_register', 'revisit' => true, 'e_reg_url_link' => $this->_reg_url_link), |
|
409 | + EE_Registry::instance()->CFG->core->reg_page_url() |
|
410 | + ); |
|
411 | + // link to SPCO payment_options |
|
412 | + $this->_SPCO_payment_options_url = $this->_primary_registrant instanceof EE_Registration |
|
413 | + ? $this->_primary_registrant->payment_overview_url() |
|
414 | + : add_query_arg( |
|
415 | + array('step' => 'payment_options'), |
|
416 | + $revisit_spco_url |
|
417 | + ); |
|
418 | + // link to SPCO attendee_information |
|
419 | + $this->_SPCO_attendee_information_url = $this->_primary_registrant instanceof EE_Registration |
|
420 | + ? $this->_primary_registrant->edit_attendee_information_url() |
|
421 | + : false; |
|
422 | + do_action('AHEE__EED_Thank_You_Page__init_end', $this->_current_txn); |
|
423 | + // set no cache headers and constants |
|
424 | + EE_System::do_not_cache(); |
|
425 | + } |
|
426 | + |
|
427 | + |
|
428 | + /** |
|
429 | + * display_thank_you_page_results |
|
430 | + * |
|
431 | + * @return string |
|
432 | + * @throws \EE_Error |
|
433 | + */ |
|
434 | + public function thank_you_page_results() |
|
435 | + { |
|
436 | + $this->init(); |
|
437 | + if (! $this->_current_txn instanceof EE_Transaction) { |
|
438 | + return EE_Error::get_notices(); |
|
439 | + } |
|
440 | + // link to receipt |
|
441 | + $template_args['TXN_receipt_url'] = $this->_current_txn->receipt_url('html'); |
|
442 | + if (! empty($template_args['TXN_receipt_url'])) { |
|
443 | + $template_args['order_conf_desc'] = __( |
|
444 | + '%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.', |
|
445 | + 'event_espresso' |
|
446 | + ); |
|
447 | + } else { |
|
448 | + $template_args['order_conf_desc'] = __( |
|
449 | + '%1$sCongratulations%2$sYour registration has been successfully processed.%3$sCheck your email for your registration confirmation.', |
|
450 | + 'event_espresso' |
|
451 | + ); |
|
452 | + } |
|
453 | + $template_args['transaction'] = $this->_current_txn; |
|
454 | + $template_args['revisit'] = EE_Registry::instance()->REQ->get('revisit', false); |
|
455 | + add_action('AHEE__thank_you_page_overview_template__content', array($this, 'get_registration_details')); |
|
456 | + if ($this->_is_primary && ! $this->_current_txn->is_free()) { |
|
457 | + add_action('AHEE__thank_you_page_overview_template__content', array($this, 'get_ajax_content')); |
|
458 | + } |
|
459 | + return EEH_Template::locate_template( |
|
460 | + THANK_YOU_TEMPLATES_PATH . 'thank-you-page-overview.template.php', |
|
461 | + $template_args, |
|
462 | + true, |
|
463 | + true |
|
464 | + ); |
|
465 | + } |
|
466 | + |
|
467 | + |
|
468 | + |
|
469 | + /** |
|
470 | + * _update_server_wait_time |
|
471 | + * |
|
472 | + * @param array $thank_you_page_data thank you page portion of the incoming JSON array from the WP heartbeat data |
|
473 | + * @return array |
|
474 | + * @throws \EE_Error |
|
475 | + */ |
|
476 | + private function _update_server_wait_time($thank_you_page_data = array()) |
|
477 | + { |
|
478 | + $response['espresso_thank_you_page'] = array( |
|
479 | + 'still_waiting' => isset($thank_you_page_data['initial_access']) |
|
480 | + ? time() - $thank_you_page_data['initial_access'] |
|
481 | + : 0, |
|
482 | + 'txn_status' => $this->_current_txn->status_ID(), |
|
483 | + ); |
|
484 | + return $response; |
|
485 | + } |
|
486 | + |
|
487 | + |
|
488 | + /** |
|
489 | + * get_registration_details |
|
490 | + * |
|
491 | + * @throws \EE_Error |
|
492 | + */ |
|
493 | + public function get_registration_details() |
|
494 | + { |
|
495 | + // prepare variables for displaying |
|
496 | + $template_args = array(); |
|
497 | + $template_args['transaction'] = $this->_current_txn; |
|
498 | + $template_args['reg_url_link'] = $this->_reg_url_link; |
|
499 | + $template_args['is_primary'] = $this->_is_primary; |
|
500 | + $template_args['SPCO_attendee_information_url'] = $this->_SPCO_attendee_information_url; |
|
501 | + $template_args['resend_reg_confirmation_url'] = add_query_arg( |
|
502 | + array('token' => $this->_reg_url_link, 'resend_reg_confirmation' => 'true'), |
|
503 | + EE_Registry::instance()->CFG->core->thank_you_page_url() |
|
504 | + ); |
|
505 | + // verify template arguments |
|
506 | + EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction'); |
|
507 | + EEH_Template_Validator::verify_isnt_null( |
|
508 | + $template_args['SPCO_attendee_information_url'], |
|
509 | + '$SPCO_attendee_information_url' |
|
510 | + ); |
|
511 | + echo EEH_Template::locate_template( |
|
512 | + THANK_YOU_TEMPLATES_PATH . 'thank-you-page-registration-details.template.php', |
|
513 | + $template_args, |
|
514 | + true, |
|
515 | + true |
|
516 | + ); |
|
517 | + } |
|
518 | + |
|
519 | + |
|
520 | + /** |
|
521 | + * resend_reg_confirmation_email |
|
522 | + * |
|
523 | + * @throws \EE_Error |
|
524 | + */ |
|
525 | + public static function resend_reg_confirmation_email() |
|
526 | + { |
|
527 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
528 | + $reg_url_link = EE_Registry::instance()->REQ->get('token'); |
|
529 | + // was a REG_ID passed ? |
|
530 | + if ($reg_url_link) { |
|
531 | + $registration = EE_Registry::instance()->load_model('Registration')->get_one( |
|
532 | + array(array('REG_url_link' => $reg_url_link)) |
|
533 | + ); |
|
534 | + if ($registration instanceof EE_Registration) { |
|
535 | + // resend email |
|
536 | + EED_Messages::process_resend(array('_REG_ID' => $registration->ID())); |
|
537 | + } else { |
|
538 | + EE_Error::add_error( |
|
539 | + __( |
|
540 | + 'The Registration Confirmation email could not be sent because a valid Registration could not be retrieved from the database.', |
|
541 | + 'event_espresso' |
|
542 | + ), |
|
543 | + __FILE__, |
|
544 | + __FUNCTION__, |
|
545 | + __LINE__ |
|
546 | + ); |
|
547 | + } |
|
548 | + } else { |
|
549 | + EE_Error::add_error( |
|
550 | + __( |
|
551 | + 'The Registration Confirmation email could not be sent because a registration token is missing or invalid.', |
|
552 | + 'event_espresso' |
|
553 | + ), |
|
554 | + __FILE__, |
|
555 | + __FUNCTION__, |
|
556 | + __LINE__ |
|
557 | + ); |
|
558 | + } |
|
559 | + // request sent via AJAX ? |
|
560 | + if (EE_FRONT_AJAX) { |
|
561 | + echo wp_json_encode(EE_Error::get_notices(false)); |
|
562 | + die(); |
|
563 | + // or was JS disabled ? |
|
564 | + } else { |
|
565 | + // save errors so that they get picked up on the next request |
|
566 | + EE_Error::get_notices(true, true); |
|
567 | + wp_safe_redirect( |
|
568 | + add_query_arg( |
|
569 | + array('e_reg_url_link' => $reg_url_link), |
|
570 | + EE_Registry::instance()->CFG->core->thank_you_page_url() |
|
571 | + ) |
|
572 | + ); |
|
573 | + } |
|
574 | + } |
|
575 | + |
|
576 | + |
|
577 | + /** |
|
578 | + * get_ajax_content |
|
579 | + * |
|
580 | + * @return void |
|
581 | + * @throws \EE_Error |
|
582 | + */ |
|
583 | + public function get_ajax_content() |
|
584 | + { |
|
585 | + if (! $this->get_txn()) { |
|
586 | + return; |
|
587 | + } |
|
588 | + // first determine which event(s) require pre-approval or not |
|
589 | + $events = array(); |
|
590 | + $events_requiring_pre_approval = array(); |
|
591 | + foreach ($this->_current_txn->registrations() as $registration) { |
|
592 | + if ($registration instanceof EE_Registration) { |
|
593 | + $event = $registration->event(); |
|
594 | + if ($event instanceof EE_Event) { |
|
595 | + if ($registration->is_not_approved() && $registration->event() instanceof EE_Event) { |
|
596 | + $events_requiring_pre_approval[ $event->ID() ] = $event; |
|
597 | + } else { |
|
598 | + $events[ $event->ID() ] = $event; |
|
599 | + } |
|
600 | + } |
|
601 | + } |
|
602 | + } |
|
603 | + $this->display_details_for_events_requiring_pre_approval($events_requiring_pre_approval); |
|
604 | + $this->display_details_for_events($events); |
|
605 | + } |
|
606 | + |
|
607 | + |
|
608 | + /** |
|
609 | + * display_details_for_events |
|
610 | + * |
|
611 | + * @param EE_Event[] $events |
|
612 | + * @return void |
|
613 | + */ |
|
614 | + public function display_details_for_events($events = array()) |
|
615 | + { |
|
616 | + if (! empty($events)) { |
|
617 | + ?> |
|
618 | 618 | <div id="espresso-thank-you-page-ajax-content-dv"> |
619 | 619 | <div id="espresso-thank-you-page-ajax-transaction-dv"></div> |
620 | 620 | <div id="espresso-thank-you-page-ajax-payment-dv"></div> |
@@ -622,19 +622,19 @@ discard block |
||
622 | 622 | <div id="ee-ajax-loading-dv" class="float-left lt-blue-text"> |
623 | 623 | <span class="dashicons dashicons-upload"></span><span id="ee-ajax-loading-msg-spn"> |
624 | 624 | <?php _e( |
625 | - 'loading transaction and payment information...', |
|
626 | - 'event_espresso' |
|
627 | - ); ?></span> |
|
625 | + 'loading transaction and payment information...', |
|
626 | + 'event_espresso' |
|
627 | + ); ?></span> |
|
628 | 628 | </div> |
629 | 629 | <?php if (! $this->_is_offline_payment_method && ! $this->_payments_closed) : ?> |
630 | 630 | <p id="ee-ajax-loading-pg" class="highlight-bg small-text clear"> |
631 | 631 | <?php echo apply_filters( |
632 | - 'EED_Thank_You_Page__get_ajax_content__waiting_for_IPN_msg', |
|
633 | - __( |
|
634 | - '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.', |
|
635 | - 'event_espresso' |
|
636 | - ) |
|
637 | - ); ?> |
|
632 | + 'EED_Thank_You_Page__get_ajax_content__waiting_for_IPN_msg', |
|
633 | + __( |
|
634 | + '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.', |
|
635 | + 'event_espresso' |
|
636 | + ) |
|
637 | + ); ?> |
|
638 | 638 | <br/> |
639 | 639 | <span class="jst-rght ee-block small-text lt-grey-text"> |
640 | 640 | <?php _e('current wait time ', 'event_espresso'); ?> |
@@ -645,118 +645,118 @@ discard block |
||
645 | 645 | <div class="clear"></div> |
646 | 646 | </div> |
647 | 647 | <?php |
648 | - } |
|
649 | - } |
|
650 | - |
|
651 | - |
|
652 | - /** |
|
653 | - * display_details_for_events_requiring_pre_approval |
|
654 | - * |
|
655 | - * @param EE_Event[] $events |
|
656 | - * @return void |
|
657 | - */ |
|
658 | - public function display_details_for_events_requiring_pre_approval($events = array()) |
|
659 | - { |
|
660 | - if (! empty($events)) { |
|
661 | - ?> |
|
648 | + } |
|
649 | + } |
|
650 | + |
|
651 | + |
|
652 | + /** |
|
653 | + * display_details_for_events_requiring_pre_approval |
|
654 | + * |
|
655 | + * @param EE_Event[] $events |
|
656 | + * @return void |
|
657 | + */ |
|
658 | + public function display_details_for_events_requiring_pre_approval($events = array()) |
|
659 | + { |
|
660 | + if (! empty($events)) { |
|
661 | + ?> |
|
662 | 662 | <div id="espresso-thank-you-page-not-approved-message-dv"> |
663 | 663 | <h4 class="orange-text"><?php _e('Important Notice:', 'event_espresso'); ?></h4> |
664 | 664 | <p id="events-requiring-pre-approval-pg" class="small-text"> |
665 | 665 | <?php echo apply_filters( |
666 | - 'AHEE__EED_Thank_You_Page__get_ajax_content__not_approved_message', |
|
667 | - __( |
|
668 | - '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.', |
|
669 | - 'event_espresso' |
|
670 | - ) |
|
671 | - ); ?> |
|
666 | + 'AHEE__EED_Thank_You_Page__get_ajax_content__not_approved_message', |
|
667 | + __( |
|
668 | + '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.', |
|
669 | + 'event_espresso' |
|
670 | + ) |
|
671 | + ); ?> |
|
672 | 672 | </p> |
673 | 673 | <ul class="events-requiring-pre-approval-ul"> |
674 | 674 | <?php |
675 | - foreach ($events as $event) { |
|
676 | - if ($event instanceof EE_Event) { |
|
677 | - echo '<li><span class="dashicons dashicons-marker ee-icon-size-16 orange-text"></span>', |
|
678 | - $event->name(), |
|
679 | - '</li>'; |
|
680 | - } |
|
681 | - } ?> |
|
675 | + foreach ($events as $event) { |
|
676 | + if ($event instanceof EE_Event) { |
|
677 | + echo '<li><span class="dashicons dashicons-marker ee-icon-size-16 orange-text"></span>', |
|
678 | + $event->name(), |
|
679 | + '</li>'; |
|
680 | + } |
|
681 | + } ?> |
|
682 | 682 | </ul> |
683 | 683 | <div class="clear"></div> |
684 | 684 | </div> |
685 | 685 | <?php |
686 | - } |
|
687 | - } |
|
688 | - |
|
689 | - |
|
690 | - /** |
|
691 | - * get_transaction_details |
|
692 | - * |
|
693 | - * @return string |
|
694 | - * @throws \EE_Error |
|
695 | - */ |
|
696 | - public function get_transaction_details() |
|
697 | - { |
|
698 | - // prepare variables for displaying |
|
699 | - $template_args = array(); |
|
700 | - $template_args['transaction'] = $this->_current_txn; |
|
701 | - $template_args['reg_url_link'] = $this->_reg_url_link; |
|
702 | - $template_args['primary_registrant_name'] = $this->_primary_registrant->attendee()->full_name(true); |
|
703 | - // link to SPCO payment_options |
|
704 | - $template_args['show_try_pay_again_link'] = $this->_show_try_pay_again_link; |
|
705 | - $template_args['SPCO_payment_options_url'] = $this->_SPCO_payment_options_url; |
|
706 | - // verify template arguments |
|
707 | - EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction'); |
|
708 | - EEH_Template_Validator::verify_isnt_null( |
|
709 | - $template_args['show_try_pay_again_link'], |
|
710 | - '$show_try_pay_again_link' |
|
711 | - ); |
|
712 | - EEH_Template_Validator::verify_isnt_null( |
|
713 | - $template_args['SPCO_payment_options_url'], |
|
714 | - '$SPCO_payment_options_url' |
|
715 | - ); |
|
716 | - return EEH_Template::locate_template( |
|
717 | - THANK_YOU_TEMPLATES_PATH . 'thank-you-page-transaction-details.template.php', |
|
718 | - $template_args, |
|
719 | - true, |
|
720 | - true |
|
721 | - ); |
|
722 | - } |
|
723 | - |
|
724 | - |
|
725 | - /** |
|
726 | - * get_payment_row_html |
|
727 | - * |
|
728 | - * @param EE_Payment $payment |
|
729 | - * @return string |
|
730 | - * @throws \EE_Error |
|
731 | - */ |
|
732 | - public function get_payment_row_html($payment = null) |
|
733 | - { |
|
734 | - $html = ''; |
|
735 | - if ($payment instanceof EE_Payment) { |
|
736 | - if ( |
|
737 | - $payment->payment_method() instanceof EE_Payment_Method |
|
738 | - && $payment->status() === EEM_Payment::status_id_failed |
|
739 | - && $payment->payment_method()->is_off_site() |
|
740 | - ) { |
|
741 | - // considering the registrant has made it to the Thank You page, |
|
742 | - // any failed payments may actually be pending and the IPN is just slow |
|
743 | - // so let's |
|
744 | - $payment->set_status(EEM_Payment::status_id_pending); |
|
745 | - } |
|
746 | - $payment_declined_msg = $payment->STS_ID() === EEM_Payment::status_id_declined |
|
747 | - ? '<br /><span class="small-text">' . $payment->gateway_response() . '</span>' |
|
748 | - : ''; |
|
749 | - $html .= ' |
|
686 | + } |
|
687 | + } |
|
688 | + |
|
689 | + |
|
690 | + /** |
|
691 | + * get_transaction_details |
|
692 | + * |
|
693 | + * @return string |
|
694 | + * @throws \EE_Error |
|
695 | + */ |
|
696 | + public function get_transaction_details() |
|
697 | + { |
|
698 | + // prepare variables for displaying |
|
699 | + $template_args = array(); |
|
700 | + $template_args['transaction'] = $this->_current_txn; |
|
701 | + $template_args['reg_url_link'] = $this->_reg_url_link; |
|
702 | + $template_args['primary_registrant_name'] = $this->_primary_registrant->attendee()->full_name(true); |
|
703 | + // link to SPCO payment_options |
|
704 | + $template_args['show_try_pay_again_link'] = $this->_show_try_pay_again_link; |
|
705 | + $template_args['SPCO_payment_options_url'] = $this->_SPCO_payment_options_url; |
|
706 | + // verify template arguments |
|
707 | + EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction'); |
|
708 | + EEH_Template_Validator::verify_isnt_null( |
|
709 | + $template_args['show_try_pay_again_link'], |
|
710 | + '$show_try_pay_again_link' |
|
711 | + ); |
|
712 | + EEH_Template_Validator::verify_isnt_null( |
|
713 | + $template_args['SPCO_payment_options_url'], |
|
714 | + '$SPCO_payment_options_url' |
|
715 | + ); |
|
716 | + return EEH_Template::locate_template( |
|
717 | + THANK_YOU_TEMPLATES_PATH . 'thank-you-page-transaction-details.template.php', |
|
718 | + $template_args, |
|
719 | + true, |
|
720 | + true |
|
721 | + ); |
|
722 | + } |
|
723 | + |
|
724 | + |
|
725 | + /** |
|
726 | + * get_payment_row_html |
|
727 | + * |
|
728 | + * @param EE_Payment $payment |
|
729 | + * @return string |
|
730 | + * @throws \EE_Error |
|
731 | + */ |
|
732 | + public function get_payment_row_html($payment = null) |
|
733 | + { |
|
734 | + $html = ''; |
|
735 | + if ($payment instanceof EE_Payment) { |
|
736 | + if ( |
|
737 | + $payment->payment_method() instanceof EE_Payment_Method |
|
738 | + && $payment->status() === EEM_Payment::status_id_failed |
|
739 | + && $payment->payment_method()->is_off_site() |
|
740 | + ) { |
|
741 | + // considering the registrant has made it to the Thank You page, |
|
742 | + // any failed payments may actually be pending and the IPN is just slow |
|
743 | + // so let's |
|
744 | + $payment->set_status(EEM_Payment::status_id_pending); |
|
745 | + } |
|
746 | + $payment_declined_msg = $payment->STS_ID() === EEM_Payment::status_id_declined |
|
747 | + ? '<br /><span class="small-text">' . $payment->gateway_response() . '</span>' |
|
748 | + : ''; |
|
749 | + $html .= ' |
|
750 | 750 | <tr> |
751 | 751 | <td> |
752 | 752 | ' . $payment->timestamp() . ' |
753 | 753 | </td> |
754 | 754 | <td> |
755 | 755 | ' . ( |
756 | - $payment->payment_method() instanceof EE_Payment_Method |
|
757 | - ? $payment->payment_method()->name() |
|
758 | - : __('Unknown', 'event_espresso') |
|
759 | - ) . ' |
|
756 | + $payment->payment_method() instanceof EE_Payment_Method |
|
757 | + ? $payment->payment_method()->name() |
|
758 | + : __('Unknown', 'event_espresso') |
|
759 | + ) . ' |
|
760 | 760 | </td> |
761 | 761 | <td class="jst-rght"> |
762 | 762 | ' . EEH_Template::format_currency($payment->amount()) . ' |
@@ -765,83 +765,83 @@ discard block |
||
765 | 765 | ' . $payment->pretty_status(true) . $payment_declined_msg . ' |
766 | 766 | </td> |
767 | 767 | </tr>'; |
768 | - do_action('AHEE__thank_you_page_payment_details_template__after_each_payment', $payment); |
|
769 | - } |
|
770 | - return $html; |
|
771 | - } |
|
772 | - |
|
773 | - |
|
774 | - /** |
|
775 | - * get_payment_details |
|
776 | - * |
|
777 | - * @param array $payments |
|
778 | - * @return string |
|
779 | - * @throws \EE_Error |
|
780 | - */ |
|
781 | - public function get_payment_details($payments = array()) |
|
782 | - { |
|
783 | - // prepare variables for displaying |
|
784 | - $template_args = array(); |
|
785 | - $template_args['transaction'] = $this->_current_txn; |
|
786 | - $template_args['reg_url_link'] = $this->_reg_url_link; |
|
787 | - $template_args['payments'] = array(); |
|
788 | - foreach ($payments as $payment) { |
|
789 | - $template_args['payments'][] = $this->get_payment_row_html($payment); |
|
790 | - } |
|
791 | - // create a hacky payment object, but dont save it |
|
792 | - $payment = EE_Payment::new_instance( |
|
793 | - array( |
|
794 | - 'TXN_ID' => $this->_current_txn->ID(), |
|
795 | - 'STS_ID' => EEM_Payment::status_id_pending, |
|
796 | - 'PAY_timestamp' => time(), |
|
797 | - 'PAY_amount' => $this->_current_txn->total(), |
|
798 | - 'PMD_ID' => $this->_current_txn->payment_method_ID(), |
|
799 | - ) |
|
800 | - ); |
|
801 | - $payment_method = $this->_current_txn->payment_method(); |
|
802 | - if ($payment_method instanceof EE_Payment_Method && $payment_method->type_obj() instanceof EE_PMT_Base) { |
|
803 | - $template_args['gateway_content'] = $payment_method->type_obj()->payment_overview_content($payment); |
|
804 | - } else { |
|
805 | - $template_args['gateway_content'] = ''; |
|
806 | - } |
|
807 | - // link to SPCO payment_options |
|
808 | - $template_args['show_try_pay_again_link'] = $this->_show_try_pay_again_link; |
|
809 | - $template_args['SPCO_payment_options_url'] = $this->_SPCO_payment_options_url; |
|
810 | - // verify template arguments |
|
811 | - EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction'); |
|
812 | - EEH_Template_Validator::verify_isnt_null($template_args['payments'], '$payments'); |
|
813 | - EEH_Template_Validator::verify_isnt_null( |
|
814 | - $template_args['show_try_pay_again_link'], |
|
815 | - '$show_try_pay_again_link' |
|
816 | - ); |
|
817 | - EEH_Template_Validator::verify_isnt_null($template_args['gateway_content'], '$gateway_content'); |
|
818 | - EEH_Template_Validator::verify_isnt_null( |
|
819 | - $template_args['SPCO_payment_options_url'], |
|
820 | - '$SPCO_payment_options_url' |
|
821 | - ); |
|
822 | - return EEH_Template::locate_template( |
|
823 | - THANK_YOU_TEMPLATES_PATH . 'thank-you-page-payment-details.template.php', |
|
824 | - $template_args, |
|
825 | - true, |
|
826 | - true |
|
827 | - ); |
|
828 | - } |
|
829 | - |
|
830 | - |
|
831 | - /** |
|
832 | - * get_payment_details |
|
833 | - * |
|
834 | - * @param array $payments |
|
835 | - * @return string |
|
836 | - * @throws \EE_Error |
|
837 | - */ |
|
838 | - public function get_new_payments($payments = array()) |
|
839 | - { |
|
840 | - $payments_html = ''; |
|
841 | - // prepare variables for displaying |
|
842 | - foreach ($payments as $payment) { |
|
843 | - $payments_html .= $this->get_payment_row_html($payment); |
|
844 | - } |
|
845 | - return $payments_html; |
|
846 | - } |
|
768 | + do_action('AHEE__thank_you_page_payment_details_template__after_each_payment', $payment); |
|
769 | + } |
|
770 | + return $html; |
|
771 | + } |
|
772 | + |
|
773 | + |
|
774 | + /** |
|
775 | + * get_payment_details |
|
776 | + * |
|
777 | + * @param array $payments |
|
778 | + * @return string |
|
779 | + * @throws \EE_Error |
|
780 | + */ |
|
781 | + public function get_payment_details($payments = array()) |
|
782 | + { |
|
783 | + // prepare variables for displaying |
|
784 | + $template_args = array(); |
|
785 | + $template_args['transaction'] = $this->_current_txn; |
|
786 | + $template_args['reg_url_link'] = $this->_reg_url_link; |
|
787 | + $template_args['payments'] = array(); |
|
788 | + foreach ($payments as $payment) { |
|
789 | + $template_args['payments'][] = $this->get_payment_row_html($payment); |
|
790 | + } |
|
791 | + // create a hacky payment object, but dont save it |
|
792 | + $payment = EE_Payment::new_instance( |
|
793 | + array( |
|
794 | + 'TXN_ID' => $this->_current_txn->ID(), |
|
795 | + 'STS_ID' => EEM_Payment::status_id_pending, |
|
796 | + 'PAY_timestamp' => time(), |
|
797 | + 'PAY_amount' => $this->_current_txn->total(), |
|
798 | + 'PMD_ID' => $this->_current_txn->payment_method_ID(), |
|
799 | + ) |
|
800 | + ); |
|
801 | + $payment_method = $this->_current_txn->payment_method(); |
|
802 | + if ($payment_method instanceof EE_Payment_Method && $payment_method->type_obj() instanceof EE_PMT_Base) { |
|
803 | + $template_args['gateway_content'] = $payment_method->type_obj()->payment_overview_content($payment); |
|
804 | + } else { |
|
805 | + $template_args['gateway_content'] = ''; |
|
806 | + } |
|
807 | + // link to SPCO payment_options |
|
808 | + $template_args['show_try_pay_again_link'] = $this->_show_try_pay_again_link; |
|
809 | + $template_args['SPCO_payment_options_url'] = $this->_SPCO_payment_options_url; |
|
810 | + // verify template arguments |
|
811 | + EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction'); |
|
812 | + EEH_Template_Validator::verify_isnt_null($template_args['payments'], '$payments'); |
|
813 | + EEH_Template_Validator::verify_isnt_null( |
|
814 | + $template_args['show_try_pay_again_link'], |
|
815 | + '$show_try_pay_again_link' |
|
816 | + ); |
|
817 | + EEH_Template_Validator::verify_isnt_null($template_args['gateway_content'], '$gateway_content'); |
|
818 | + EEH_Template_Validator::verify_isnt_null( |
|
819 | + $template_args['SPCO_payment_options_url'], |
|
820 | + '$SPCO_payment_options_url' |
|
821 | + ); |
|
822 | + return EEH_Template::locate_template( |
|
823 | + THANK_YOU_TEMPLATES_PATH . 'thank-you-page-payment-details.template.php', |
|
824 | + $template_args, |
|
825 | + true, |
|
826 | + true |
|
827 | + ); |
|
828 | + } |
|
829 | + |
|
830 | + |
|
831 | + /** |
|
832 | + * get_payment_details |
|
833 | + * |
|
834 | + * @param array $payments |
|
835 | + * @return string |
|
836 | + * @throws \EE_Error |
|
837 | + */ |
|
838 | + public function get_new_payments($payments = array()) |
|
839 | + { |
|
840 | + $payments_html = ''; |
|
841 | + // prepare variables for displaying |
|
842 | + foreach ($payments as $payment) { |
|
843 | + $payments_html .= $this->get_payment_row_html($payment); |
|
844 | + } |
|
845 | + return $payments_html; |
|
846 | + } |
|
847 | 847 | } |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | */ |
163 | 163 | public function venue_location($content) |
164 | 164 | { |
165 | - return $content . EEH_Template::locate_template('content-espresso_venues-location.php'); |
|
165 | + return $content.EEH_Template::locate_template('content-espresso_venues-location.php'); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | |
@@ -177,16 +177,16 @@ discard block |
||
177 | 177 | // get some style |
178 | 178 | if (apply_filters('FHEE_enable_default_espresso_css', true) && is_single()) { |
179 | 179 | // first check theme folder |
180 | - if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) { |
|
180 | + if (is_readable(get_stylesheet_directory().$this->theme.'/style.css')) { |
|
181 | 181 | wp_register_style( |
182 | 182 | $this->theme, |
183 | - get_stylesheet_directory_uri() . $this->theme . '/style.css', |
|
183 | + get_stylesheet_directory_uri().$this->theme.'/style.css', |
|
184 | 184 | array('dashicons', 'espresso_default') |
185 | 185 | ); |
186 | - } elseif (is_readable(EE_TEMPLATES . $this->theme . '/style.css')) { |
|
186 | + } elseif (is_readable(EE_TEMPLATES.$this->theme.'/style.css')) { |
|
187 | 187 | wp_register_style( |
188 | 188 | $this->theme, |
189 | - EE_TEMPLATES_URL . $this->theme . '/style.css', |
|
189 | + EE_TEMPLATES_URL.$this->theme.'/style.css', |
|
190 | 190 | array('dashicons', 'espresso_default') |
191 | 191 | ); |
192 | 192 | } |
@@ -29,173 +29,173 @@ |
||
29 | 29 | class EED_Venue_Single extends EED_Module |
30 | 30 | { |
31 | 31 | |
32 | - /** |
|
33 | - * @return EED_Venue_Single |
|
34 | - */ |
|
35 | - public static function instance() |
|
36 | - { |
|
37 | - return parent::get_instance(__CLASS__); |
|
38 | - } |
|
39 | - |
|
40 | - |
|
41 | - /** |
|
42 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
43 | - * |
|
44 | - * @return void |
|
45 | - * @throws InvalidArgumentException |
|
46 | - * @throws InvalidDataTypeException |
|
47 | - * @throws InvalidInterfaceException |
|
48 | - */ |
|
49 | - public static function set_hooks() |
|
50 | - { |
|
51 | - /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */ |
|
52 | - $custom_post_type_definitions = LoaderFactory::getLoader()->getShared( |
|
53 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
54 | - ); |
|
55 | - $custom_post_types = $custom_post_type_definitions->getDefinitions(); |
|
56 | - EE_Config::register_route( |
|
57 | - $custom_post_types['espresso_venues']['singular_slug'], |
|
58 | - 'Venue_Single', |
|
59 | - 'run' |
|
60 | - ); |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
65 | - * |
|
66 | - * @access public |
|
67 | - * @return void |
|
68 | - */ |
|
69 | - public static function set_hooks_admin() |
|
70 | - { |
|
71 | - } |
|
72 | - |
|
73 | - |
|
74 | - /** |
|
75 | - * run - initial module setup |
|
76 | - * |
|
77 | - * @access public |
|
78 | - * @param \WP $WP |
|
79 | - */ |
|
80 | - public function run($WP) |
|
81 | - { |
|
82 | - // check what template is loaded |
|
83 | - add_filter('template_include', array($this, 'template_include'), 999, 1); |
|
84 | - add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10); |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - /** |
|
89 | - * template_include |
|
90 | - * |
|
91 | - * @access public |
|
92 | - * @param string $template |
|
93 | - * @return string |
|
94 | - */ |
|
95 | - public function template_include($template) |
|
96 | - { |
|
97 | - // not a custom template? |
|
98 | - if ( |
|
99 | - EE_Registry::instance() |
|
100 | - ->load_core('Front_Controller', array(), false, true) |
|
101 | - ->get_selected_template() != 'single-espresso_venues.php' |
|
102 | - ) { |
|
103 | - EEH_Template::load_espresso_theme_functions(); |
|
104 | - // then add extra event data via hooks |
|
105 | - add_filter('the_title', array($this, 'the_title'), 100, 1); |
|
106 | - add_filter('the_content', array($this, 'venue_details'), 100); |
|
107 | - // don't display entry meta because the existing theme will take car of that |
|
108 | - add_filter('FHEE__content_espresso_venues_details_template__display_entry_meta', '__return_false'); |
|
109 | - } |
|
110 | - return $template; |
|
111 | - } |
|
112 | - |
|
113 | - |
|
114 | - /** |
|
115 | - * the_title |
|
116 | - * |
|
117 | - * @access public |
|
118 | - * @param string $title |
|
119 | - * @return string |
|
120 | - */ |
|
121 | - public function the_title($title = '') |
|
122 | - { |
|
123 | - return $title; |
|
124 | - } |
|
125 | - |
|
126 | - |
|
127 | - /** |
|
128 | - * venue_details |
|
129 | - * |
|
130 | - * @access public |
|
131 | - * @param string $content |
|
132 | - * @return string |
|
133 | - */ |
|
134 | - public function venue_details($content) |
|
135 | - { |
|
136 | - global $post; |
|
137 | - if ( |
|
138 | - $post->post_type == 'espresso_venues' |
|
139 | - && ! post_password_required() |
|
140 | - ) { |
|
141 | - // since the 'content-espresso_venues-details.php' template might be used directly from within a theme, |
|
142 | - // it uses the_content() for displaying the $post->post_content |
|
143 | - // so in order to load a template that uses the_content() from within a callback being used to filter the_content(), |
|
144 | - // we need to first remove this callback from being applied to the_content() (otherwise it will recurse and blow up the interweb) |
|
145 | - remove_filter('the_content', array($this, 'venue_details'), 100); |
|
146 | - // add filters we want |
|
147 | - add_filter('the_content', array($this, 'venue_location'), 110); |
|
148 | - // now load our template |
|
149 | - $template = EEH_Template::locate_template('content-espresso_venues-details.php'); |
|
150 | - // remove other filters we added so they won't get applied to the next post |
|
151 | - remove_filter('the_content', array($this, 'venue_location'), 110); |
|
152 | - } |
|
153 | - // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
|
154 | - return ! empty($template) ? $template : $content; |
|
155 | - } |
|
156 | - |
|
157 | - |
|
158 | - /** |
|
159 | - * venue_location |
|
160 | - * |
|
161 | - * @access public |
|
162 | - * @param string $content |
|
163 | - * @return string |
|
164 | - */ |
|
165 | - public function venue_location($content) |
|
166 | - { |
|
167 | - return $content . EEH_Template::locate_template('content-espresso_venues-location.php'); |
|
168 | - } |
|
169 | - |
|
170 | - |
|
171 | - /** |
|
172 | - * wp_enqueue_scripts |
|
173 | - * |
|
174 | - * @access public |
|
175 | - * @return void |
|
176 | - */ |
|
177 | - public function wp_enqueue_scripts() |
|
178 | - { |
|
179 | - // get some style |
|
180 | - if (apply_filters('FHEE_enable_default_espresso_css', true) && is_single()) { |
|
181 | - // first check theme folder |
|
182 | - if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) { |
|
183 | - wp_register_style( |
|
184 | - $this->theme, |
|
185 | - get_stylesheet_directory_uri() . $this->theme . '/style.css', |
|
186 | - array('dashicons', 'espresso_default') |
|
187 | - ); |
|
188 | - } elseif (is_readable(EE_TEMPLATES . $this->theme . '/style.css')) { |
|
189 | - wp_register_style( |
|
190 | - $this->theme, |
|
191 | - EE_TEMPLATES_URL . $this->theme . '/style.css', |
|
192 | - array('dashicons', 'espresso_default') |
|
193 | - ); |
|
194 | - } |
|
195 | - wp_enqueue_style($this->theme); |
|
196 | - if (EE_Registry::instance()->CFG->map_settings->use_google_maps) { |
|
197 | - add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11); |
|
198 | - } |
|
199 | - } |
|
200 | - } |
|
32 | + /** |
|
33 | + * @return EED_Venue_Single |
|
34 | + */ |
|
35 | + public static function instance() |
|
36 | + { |
|
37 | + return parent::get_instance(__CLASS__); |
|
38 | + } |
|
39 | + |
|
40 | + |
|
41 | + /** |
|
42 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
43 | + * |
|
44 | + * @return void |
|
45 | + * @throws InvalidArgumentException |
|
46 | + * @throws InvalidDataTypeException |
|
47 | + * @throws InvalidInterfaceException |
|
48 | + */ |
|
49 | + public static function set_hooks() |
|
50 | + { |
|
51 | + /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */ |
|
52 | + $custom_post_type_definitions = LoaderFactory::getLoader()->getShared( |
|
53 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
54 | + ); |
|
55 | + $custom_post_types = $custom_post_type_definitions->getDefinitions(); |
|
56 | + EE_Config::register_route( |
|
57 | + $custom_post_types['espresso_venues']['singular_slug'], |
|
58 | + 'Venue_Single', |
|
59 | + 'run' |
|
60 | + ); |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
65 | + * |
|
66 | + * @access public |
|
67 | + * @return void |
|
68 | + */ |
|
69 | + public static function set_hooks_admin() |
|
70 | + { |
|
71 | + } |
|
72 | + |
|
73 | + |
|
74 | + /** |
|
75 | + * run - initial module setup |
|
76 | + * |
|
77 | + * @access public |
|
78 | + * @param \WP $WP |
|
79 | + */ |
|
80 | + public function run($WP) |
|
81 | + { |
|
82 | + // check what template is loaded |
|
83 | + add_filter('template_include', array($this, 'template_include'), 999, 1); |
|
84 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10); |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + /** |
|
89 | + * template_include |
|
90 | + * |
|
91 | + * @access public |
|
92 | + * @param string $template |
|
93 | + * @return string |
|
94 | + */ |
|
95 | + public function template_include($template) |
|
96 | + { |
|
97 | + // not a custom template? |
|
98 | + if ( |
|
99 | + EE_Registry::instance() |
|
100 | + ->load_core('Front_Controller', array(), false, true) |
|
101 | + ->get_selected_template() != 'single-espresso_venues.php' |
|
102 | + ) { |
|
103 | + EEH_Template::load_espresso_theme_functions(); |
|
104 | + // then add extra event data via hooks |
|
105 | + add_filter('the_title', array($this, 'the_title'), 100, 1); |
|
106 | + add_filter('the_content', array($this, 'venue_details'), 100); |
|
107 | + // don't display entry meta because the existing theme will take car of that |
|
108 | + add_filter('FHEE__content_espresso_venues_details_template__display_entry_meta', '__return_false'); |
|
109 | + } |
|
110 | + return $template; |
|
111 | + } |
|
112 | + |
|
113 | + |
|
114 | + /** |
|
115 | + * the_title |
|
116 | + * |
|
117 | + * @access public |
|
118 | + * @param string $title |
|
119 | + * @return string |
|
120 | + */ |
|
121 | + public function the_title($title = '') |
|
122 | + { |
|
123 | + return $title; |
|
124 | + } |
|
125 | + |
|
126 | + |
|
127 | + /** |
|
128 | + * venue_details |
|
129 | + * |
|
130 | + * @access public |
|
131 | + * @param string $content |
|
132 | + * @return string |
|
133 | + */ |
|
134 | + public function venue_details($content) |
|
135 | + { |
|
136 | + global $post; |
|
137 | + if ( |
|
138 | + $post->post_type == 'espresso_venues' |
|
139 | + && ! post_password_required() |
|
140 | + ) { |
|
141 | + // since the 'content-espresso_venues-details.php' template might be used directly from within a theme, |
|
142 | + // it uses the_content() for displaying the $post->post_content |
|
143 | + // so in order to load a template that uses the_content() from within a callback being used to filter the_content(), |
|
144 | + // we need to first remove this callback from being applied to the_content() (otherwise it will recurse and blow up the interweb) |
|
145 | + remove_filter('the_content', array($this, 'venue_details'), 100); |
|
146 | + // add filters we want |
|
147 | + add_filter('the_content', array($this, 'venue_location'), 110); |
|
148 | + // now load our template |
|
149 | + $template = EEH_Template::locate_template('content-espresso_venues-details.php'); |
|
150 | + // remove other filters we added so they won't get applied to the next post |
|
151 | + remove_filter('the_content', array($this, 'venue_location'), 110); |
|
152 | + } |
|
153 | + // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
|
154 | + return ! empty($template) ? $template : $content; |
|
155 | + } |
|
156 | + |
|
157 | + |
|
158 | + /** |
|
159 | + * venue_location |
|
160 | + * |
|
161 | + * @access public |
|
162 | + * @param string $content |
|
163 | + * @return string |
|
164 | + */ |
|
165 | + public function venue_location($content) |
|
166 | + { |
|
167 | + return $content . EEH_Template::locate_template('content-espresso_venues-location.php'); |
|
168 | + } |
|
169 | + |
|
170 | + |
|
171 | + /** |
|
172 | + * wp_enqueue_scripts |
|
173 | + * |
|
174 | + * @access public |
|
175 | + * @return void |
|
176 | + */ |
|
177 | + public function wp_enqueue_scripts() |
|
178 | + { |
|
179 | + // get some style |
|
180 | + if (apply_filters('FHEE_enable_default_espresso_css', true) && is_single()) { |
|
181 | + // first check theme folder |
|
182 | + if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) { |
|
183 | + wp_register_style( |
|
184 | + $this->theme, |
|
185 | + get_stylesheet_directory_uri() . $this->theme . '/style.css', |
|
186 | + array('dashicons', 'espresso_default') |
|
187 | + ); |
|
188 | + } elseif (is_readable(EE_TEMPLATES . $this->theme . '/style.css')) { |
|
189 | + wp_register_style( |
|
190 | + $this->theme, |
|
191 | + EE_TEMPLATES_URL . $this->theme . '/style.css', |
|
192 | + array('dashicons', 'espresso_default') |
|
193 | + ); |
|
194 | + } |
|
195 | + wp_enqueue_style($this->theme); |
|
196 | + if (EE_Registry::instance()->CFG->map_settings->use_google_maps) { |
|
197 | + add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11); |
|
198 | + } |
|
199 | + } |
|
200 | + } |
|
201 | 201 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public static function set_trap() |
55 | 55 | { |
56 | - define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . '/'); |
|
56 | + define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__).'/'); |
|
57 | 57 | add_action( |
58 | 58 | 'AHEE__ticket_selector_chart__template__after_ticket_selector', |
59 | 59 | array('EED_Bot_Trap', 'generate_bot_trap'), |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | $do_not_enter = esc_html__('please do not enter anything in this input', 'event_espresso'); |
120 | 120 | $time = microtime(true); |
121 | 121 | $html = '<div class="tkt-slctr-request-processor-dv" style="float:left; margin:0 0 0 -999em; height: 0;">'; |
122 | - $html .= '<label for="tkt-slctr-request-processor-email-' . $time . '">' . $do_not_enter . '</label>'; |
|
122 | + $html .= '<label for="tkt-slctr-request-processor-email-'.$time.'">'.$do_not_enter.'</label>'; |
|
123 | 123 | $html .= '<input type="email" id="tkt-slctr-request-processor-email-'; |
124 | - $html .= $time . '" name="tkt-slctr-request-processor-email" value=""/>'; |
|
124 | + $html .= $time.'" name="tkt-slctr-request-processor-email" value=""/>'; |
|
125 | 125 | $html .= '</div><!-- .tkt-slctr-request-processor-dv -->'; |
126 | 126 | echo $html; |
127 | 127 | } |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | return; |
148 | 148 | } |
149 | 149 | // check the given callback is valid first before executing |
150 | - if (! is_callable($triggered_trap_callback)) { |
|
150 | + if ( ! is_callable($triggered_trap_callback)) { |
|
151 | 151 | // invalid callback so lets just sub in our default. |
152 | 152 | $triggered_trap_callback = array('EED_Bot_Trap', 'triggered_trap_response'); |
153 | 153 | } |
@@ -16,306 +16,306 @@ |
||
16 | 16 | class EED_Bot_Trap extends EED_Module |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @return EED_Bot_Trap|EED_Module |
|
21 | - */ |
|
22 | - public static function instance() |
|
23 | - { |
|
24 | - return parent::get_instance(__CLASS__); |
|
25 | - } |
|
19 | + /** |
|
20 | + * @return EED_Bot_Trap|EED_Module |
|
21 | + */ |
|
22 | + public static function instance() |
|
23 | + { |
|
24 | + return parent::get_instance(__CLASS__); |
|
25 | + } |
|
26 | 26 | |
27 | 27 | |
28 | - /** |
|
29 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
30 | - * |
|
31 | - * @return void |
|
32 | - */ |
|
33 | - public static function set_hooks() |
|
34 | - { |
|
35 | - if ( |
|
36 | - apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) && |
|
37 | - EE_Registry::instance()->CFG->registration->use_bot_trap |
|
38 | - ) { |
|
39 | - EED_Bot_Trap::set_trap(); |
|
40 | - // redirect bots to bogus success page |
|
41 | - EE_Config::register_route( |
|
42 | - 'ticket_selection_received', |
|
43 | - 'EED_Bot_Trap', |
|
44 | - 'display_bot_trap_success' |
|
45 | - ); |
|
46 | - } |
|
47 | - } |
|
28 | + /** |
|
29 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
30 | + * |
|
31 | + * @return void |
|
32 | + */ |
|
33 | + public static function set_hooks() |
|
34 | + { |
|
35 | + if ( |
|
36 | + apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) && |
|
37 | + EE_Registry::instance()->CFG->registration->use_bot_trap |
|
38 | + ) { |
|
39 | + EED_Bot_Trap::set_trap(); |
|
40 | + // redirect bots to bogus success page |
|
41 | + EE_Config::register_route( |
|
42 | + 'ticket_selection_received', |
|
43 | + 'EED_Bot_Trap', |
|
44 | + 'display_bot_trap_success' |
|
45 | + ); |
|
46 | + } |
|
47 | + } |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
52 | - * |
|
53 | - * @return void |
|
54 | - */ |
|
55 | - public static function set_trap() |
|
56 | - { |
|
57 | - define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . '/'); |
|
58 | - add_action( |
|
59 | - 'AHEE__ticket_selector_chart__template__after_ticket_selector', |
|
60 | - array('EED_Bot_Trap', 'generate_bot_trap'), |
|
61 | - 10, |
|
62 | - 2 |
|
63 | - ); |
|
64 | - add_action( |
|
65 | - 'EED_Ticket_Selector__process_ticket_selections__before', |
|
66 | - array('EED_Bot_Trap', 'process_bot_trap'), |
|
67 | - 1, |
|
68 | - 2 |
|
69 | - ); |
|
70 | - } |
|
50 | + /** |
|
51 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
52 | + * |
|
53 | + * @return void |
|
54 | + */ |
|
55 | + public static function set_trap() |
|
56 | + { |
|
57 | + define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . '/'); |
|
58 | + add_action( |
|
59 | + 'AHEE__ticket_selector_chart__template__after_ticket_selector', |
|
60 | + array('EED_Bot_Trap', 'generate_bot_trap'), |
|
61 | + 10, |
|
62 | + 2 |
|
63 | + ); |
|
64 | + add_action( |
|
65 | + 'EED_Ticket_Selector__process_ticket_selections__before', |
|
66 | + array('EED_Bot_Trap', 'process_bot_trap'), |
|
67 | + 1, |
|
68 | + 2 |
|
69 | + ); |
|
70 | + } |
|
71 | 71 | |
72 | 72 | |
73 | - /** |
|
74 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
75 | - * |
|
76 | - * @return void |
|
77 | - */ |
|
78 | - public static function set_hooks_admin() |
|
79 | - { |
|
80 | - if ( |
|
81 | - defined('DOING_AJAX') |
|
82 | - && DOING_AJAX |
|
83 | - && apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) |
|
84 | - && EE_Registry::instance()->CFG->registration->use_bot_trap |
|
85 | - ) { |
|
86 | - EED_Bot_Trap::set_trap(); |
|
87 | - } |
|
88 | - add_action( |
|
89 | - 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
90 | - array('EED_Bot_Trap', 'bot_trap_settings_form'), |
|
91 | - 5 |
|
92 | - ); |
|
93 | - add_filter( |
|
94 | - 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', |
|
95 | - array('EED_Bot_Trap', 'update_bot_trap_settings_form'), |
|
96 | - 10, |
|
97 | - 1 |
|
98 | - ); |
|
99 | - } |
|
73 | + /** |
|
74 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
75 | + * |
|
76 | + * @return void |
|
77 | + */ |
|
78 | + public static function set_hooks_admin() |
|
79 | + { |
|
80 | + if ( |
|
81 | + defined('DOING_AJAX') |
|
82 | + && DOING_AJAX |
|
83 | + && apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) |
|
84 | + && EE_Registry::instance()->CFG->registration->use_bot_trap |
|
85 | + ) { |
|
86 | + EED_Bot_Trap::set_trap(); |
|
87 | + } |
|
88 | + add_action( |
|
89 | + 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
90 | + array('EED_Bot_Trap', 'bot_trap_settings_form'), |
|
91 | + 5 |
|
92 | + ); |
|
93 | + add_filter( |
|
94 | + 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', |
|
95 | + array('EED_Bot_Trap', 'update_bot_trap_settings_form'), |
|
96 | + 10, |
|
97 | + 1 |
|
98 | + ); |
|
99 | + } |
|
100 | 100 | |
101 | 101 | |
102 | - /** |
|
103 | - * run - initial module setup |
|
104 | - * |
|
105 | - * @param WP $WP |
|
106 | - * @return void |
|
107 | - */ |
|
108 | - public function run($WP) |
|
109 | - { |
|
110 | - } |
|
102 | + /** |
|
103 | + * run - initial module setup |
|
104 | + * |
|
105 | + * @param WP $WP |
|
106 | + * @return void |
|
107 | + */ |
|
108 | + public function run($WP) |
|
109 | + { |
|
110 | + } |
|
111 | 111 | |
112 | 112 | |
113 | - /** |
|
114 | - * generate_bot_trap |
|
115 | - * |
|
116 | - * @return void |
|
117 | - * @throws RuntimeException |
|
118 | - */ |
|
119 | - public static function generate_bot_trap() |
|
120 | - { |
|
121 | - $do_not_enter = esc_html__('please do not enter anything in this input', 'event_espresso'); |
|
122 | - $time = microtime(true); |
|
123 | - $html = '<div class="tkt-slctr-request-processor-dv" style="float:left; margin:0 0 0 -999em; height: 0;">'; |
|
124 | - $html .= '<label for="tkt-slctr-request-processor-email-' . $time . '">' . $do_not_enter . '</label>'; |
|
125 | - $html .= '<input type="email" id="tkt-slctr-request-processor-email-'; |
|
126 | - $html .= $time . '" name="tkt-slctr-request-processor-email" value=""/>'; |
|
127 | - $html .= '</div><!-- .tkt-slctr-request-processor-dv -->'; |
|
128 | - echo $html; |
|
129 | - } |
|
113 | + /** |
|
114 | + * generate_bot_trap |
|
115 | + * |
|
116 | + * @return void |
|
117 | + * @throws RuntimeException |
|
118 | + */ |
|
119 | + public static function generate_bot_trap() |
|
120 | + { |
|
121 | + $do_not_enter = esc_html__('please do not enter anything in this input', 'event_espresso'); |
|
122 | + $time = microtime(true); |
|
123 | + $html = '<div class="tkt-slctr-request-processor-dv" style="float:left; margin:0 0 0 -999em; height: 0;">'; |
|
124 | + $html .= '<label for="tkt-slctr-request-processor-email-' . $time . '">' . $do_not_enter . '</label>'; |
|
125 | + $html .= '<input type="email" id="tkt-slctr-request-processor-email-'; |
|
126 | + $html .= $time . '" name="tkt-slctr-request-processor-email" value=""/>'; |
|
127 | + $html .= '</div><!-- .tkt-slctr-request-processor-dv -->'; |
|
128 | + echo $html; |
|
129 | + } |
|
130 | 130 | |
131 | 131 | |
132 | - /** |
|
133 | - * process_bot_trap |
|
134 | - * |
|
135 | - * @param array|string $triggered_trap_callback Callback that will be executed for handling the |
|
136 | - * response if the bot trap is triggered. |
|
137 | - * It should receive one argument: a boolean indicating |
|
138 | - * whether the trap was triggered by suspicious timing or not. |
|
139 | - * @throws RuntimeException |
|
140 | - */ |
|
141 | - public static function process_bot_trap($triggered_trap_callback = array()) |
|
142 | - { |
|
143 | - // what's your email address Mr. Bot ? |
|
144 | - $empty_trap = isset($_REQUEST['tkt-slctr-request-processor-email']) |
|
145 | - && $_REQUEST['tkt-slctr-request-processor-email'] === ''; |
|
146 | - // are we human ? |
|
147 | - if ($empty_trap) { |
|
148 | - do_action('AHEE__EED_Bot_Trap__process_bot_trap__trap_not_triggered'); |
|
149 | - return; |
|
150 | - } |
|
151 | - // check the given callback is valid first before executing |
|
152 | - if (! is_callable($triggered_trap_callback)) { |
|
153 | - // invalid callback so lets just sub in our default. |
|
154 | - $triggered_trap_callback = array('EED_Bot_Trap', 'triggered_trap_response'); |
|
155 | - } |
|
156 | - call_user_func($triggered_trap_callback); |
|
157 | - } |
|
132 | + /** |
|
133 | + * process_bot_trap |
|
134 | + * |
|
135 | + * @param array|string $triggered_trap_callback Callback that will be executed for handling the |
|
136 | + * response if the bot trap is triggered. |
|
137 | + * It should receive one argument: a boolean indicating |
|
138 | + * whether the trap was triggered by suspicious timing or not. |
|
139 | + * @throws RuntimeException |
|
140 | + */ |
|
141 | + public static function process_bot_trap($triggered_trap_callback = array()) |
|
142 | + { |
|
143 | + // what's your email address Mr. Bot ? |
|
144 | + $empty_trap = isset($_REQUEST['tkt-slctr-request-processor-email']) |
|
145 | + && $_REQUEST['tkt-slctr-request-processor-email'] === ''; |
|
146 | + // are we human ? |
|
147 | + if ($empty_trap) { |
|
148 | + do_action('AHEE__EED_Bot_Trap__process_bot_trap__trap_not_triggered'); |
|
149 | + return; |
|
150 | + } |
|
151 | + // check the given callback is valid first before executing |
|
152 | + if (! is_callable($triggered_trap_callback)) { |
|
153 | + // invalid callback so lets just sub in our default. |
|
154 | + $triggered_trap_callback = array('EED_Bot_Trap', 'triggered_trap_response'); |
|
155 | + } |
|
156 | + call_user_func($triggered_trap_callback); |
|
157 | + } |
|
158 | 158 | |
159 | 159 | |
160 | - /** |
|
161 | - * This is the default callback executed by EED_Bot_Trap::process_bot_trap that handles the response. |
|
162 | - * |
|
163 | - * @throws InvalidArgumentException |
|
164 | - * @throws InvalidDataTypeException |
|
165 | - * @throws InvalidInterfaceException |
|
166 | - */ |
|
167 | - public static function triggered_trap_response() |
|
168 | - { |
|
169 | - // UH OH... |
|
170 | - $redirect_url = apply_filters( |
|
171 | - 'FHEE__EED_Bot_Trap__process_bot_trap__redirect_url', |
|
172 | - add_query_arg( |
|
173 | - array('ee' => 'ticket_selection_received'), |
|
174 | - EE_Registry::instance()->CFG->core->reg_page_url() |
|
175 | - ) |
|
176 | - ); |
|
177 | - // if AJAX, return the redirect URL |
|
178 | - if (defined('DOING_AJAX') && DOING_AJAX) { |
|
179 | - echo wp_json_encode( |
|
180 | - array_merge( |
|
181 | - EE_Error::get_notices(false), |
|
182 | - array( |
|
183 | - 'redirect_url' => $redirect_url, |
|
184 | - ) |
|
185 | - ) |
|
186 | - ); |
|
187 | - exit(); |
|
188 | - } |
|
189 | - wp_safe_redirect($redirect_url); |
|
190 | - exit(); |
|
191 | - } |
|
160 | + /** |
|
161 | + * This is the default callback executed by EED_Bot_Trap::process_bot_trap that handles the response. |
|
162 | + * |
|
163 | + * @throws InvalidArgumentException |
|
164 | + * @throws InvalidDataTypeException |
|
165 | + * @throws InvalidInterfaceException |
|
166 | + */ |
|
167 | + public static function triggered_trap_response() |
|
168 | + { |
|
169 | + // UH OH... |
|
170 | + $redirect_url = apply_filters( |
|
171 | + 'FHEE__EED_Bot_Trap__process_bot_trap__redirect_url', |
|
172 | + add_query_arg( |
|
173 | + array('ee' => 'ticket_selection_received'), |
|
174 | + EE_Registry::instance()->CFG->core->reg_page_url() |
|
175 | + ) |
|
176 | + ); |
|
177 | + // if AJAX, return the redirect URL |
|
178 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
179 | + echo wp_json_encode( |
|
180 | + array_merge( |
|
181 | + EE_Error::get_notices(false), |
|
182 | + array( |
|
183 | + 'redirect_url' => $redirect_url, |
|
184 | + ) |
|
185 | + ) |
|
186 | + ); |
|
187 | + exit(); |
|
188 | + } |
|
189 | + wp_safe_redirect($redirect_url); |
|
190 | + exit(); |
|
191 | + } |
|
192 | 192 | |
193 | 193 | |
194 | - /** |
|
195 | - * display_bot_trap_success |
|
196 | - * shows a "success" screen to bots so that they (ie: the ppl managing them) |
|
197 | - * think the form was submitted successfully |
|
198 | - * |
|
199 | - * @return void |
|
200 | - */ |
|
201 | - public static function display_bot_trap_success() |
|
202 | - { |
|
203 | - add_filter('FHEE__EED_Single_Page_Checkout__run', '__return_false'); |
|
204 | - $bot_notice = esc_html__( |
|
205 | - 'Thank you so much. Your ticket selections have been received for consideration.', |
|
206 | - 'event_espresso' |
|
207 | - ); |
|
208 | - $bot_notice = isset($_REQUEST['ee-notice']) && $_REQUEST['ee-notice'] !== '' |
|
209 | - ? sanitize_text_field(stripslashes($_REQUEST['ee-notice'])) |
|
210 | - : $bot_notice; |
|
211 | - EE_Registry::instance()->REQ->add_output(EEH_HTML::div($bot_notice, '', 'ee-attention')); |
|
212 | - } |
|
194 | + /** |
|
195 | + * display_bot_trap_success |
|
196 | + * shows a "success" screen to bots so that they (ie: the ppl managing them) |
|
197 | + * think the form was submitted successfully |
|
198 | + * |
|
199 | + * @return void |
|
200 | + */ |
|
201 | + public static function display_bot_trap_success() |
|
202 | + { |
|
203 | + add_filter('FHEE__EED_Single_Page_Checkout__run', '__return_false'); |
|
204 | + $bot_notice = esc_html__( |
|
205 | + 'Thank you so much. Your ticket selections have been received for consideration.', |
|
206 | + 'event_espresso' |
|
207 | + ); |
|
208 | + $bot_notice = isset($_REQUEST['ee-notice']) && $_REQUEST['ee-notice'] !== '' |
|
209 | + ? sanitize_text_field(stripslashes($_REQUEST['ee-notice'])) |
|
210 | + : $bot_notice; |
|
211 | + EE_Registry::instance()->REQ->add_output(EEH_HTML::div($bot_notice, '', 'ee-attention')); |
|
212 | + } |
|
213 | 213 | |
214 | 214 | |
215 | 215 | |
216 | - /*********************************** ADMIN **********************************/ |
|
216 | + /*********************************** ADMIN **********************************/ |
|
217 | 217 | |
218 | 218 | |
219 | - /** |
|
220 | - * bot_trap_settings_form |
|
221 | - * |
|
222 | - * @return void |
|
223 | - * @throws EE_Error |
|
224 | - * @throws InvalidArgumentException |
|
225 | - * @throws InvalidDataTypeException |
|
226 | - * @throws InvalidInterfaceException |
|
227 | - */ |
|
228 | - public static function bot_trap_settings_form() |
|
229 | - { |
|
230 | - EED_Bot_Trap::_bot_trap_settings_form()->enqueue_js(); |
|
231 | - echo EED_Bot_Trap::_bot_trap_settings_form()->get_html(); |
|
232 | - } |
|
219 | + /** |
|
220 | + * bot_trap_settings_form |
|
221 | + * |
|
222 | + * @return void |
|
223 | + * @throws EE_Error |
|
224 | + * @throws InvalidArgumentException |
|
225 | + * @throws InvalidDataTypeException |
|
226 | + * @throws InvalidInterfaceException |
|
227 | + */ |
|
228 | + public static function bot_trap_settings_form() |
|
229 | + { |
|
230 | + EED_Bot_Trap::_bot_trap_settings_form()->enqueue_js(); |
|
231 | + echo EED_Bot_Trap::_bot_trap_settings_form()->get_html(); |
|
232 | + } |
|
233 | 233 | |
234 | 234 | |
235 | - /** |
|
236 | - * _bot_trap_settings_form |
|
237 | - * |
|
238 | - * @return EE_Form_Section_Proper |
|
239 | - * @throws EE_Error |
|
240 | - */ |
|
241 | - protected static function _bot_trap_settings_form() |
|
242 | - { |
|
243 | - return new EE_Form_Section_Proper( |
|
244 | - array( |
|
245 | - 'name' => 'bot_trap_settings', |
|
246 | - 'html_id' => 'bot_trap_settings', |
|
247 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
248 | - 'subsections' => array( |
|
249 | - 'bot_trap_hdr' => new EE_Form_Section_HTML( |
|
250 | - EEH_HTML::h2(esc_html__('Bot Trap Settings', 'event_espresso')) |
|
251 | - ), |
|
252 | - 'use_bot_trap' => new EE_Yes_No_Input( |
|
253 | - array( |
|
254 | - 'html_label_text' => esc_html__('Enable Bot Trap', 'event_espresso'), |
|
255 | - 'html_help_text' => esc_html__( |
|
256 | - 'The Event Espresso Bot Trap will insert a fake input into your Ticket Selector forms that is hidden from regular site visitors, but visible to spam bots. Because the input asks for an email address, it is irresistible to spam bots who will of course enter text into it. Since regular site visitors can not see this input, any value detected during form submission means a bot has been detected, which will then be blocked from submitting the form.', |
|
257 | - 'event_espresso' |
|
258 | - ), |
|
259 | - 'default' => EE_Registry::instance()->CFG->registration->use_bot_trap !== null |
|
260 | - ? EE_Registry::instance()->CFG->registration->use_bot_trap |
|
261 | - : true, |
|
262 | - 'required' => false, |
|
263 | - ) |
|
264 | - ), |
|
265 | - ), |
|
266 | - ) |
|
267 | - ); |
|
268 | - } |
|
235 | + /** |
|
236 | + * _bot_trap_settings_form |
|
237 | + * |
|
238 | + * @return EE_Form_Section_Proper |
|
239 | + * @throws EE_Error |
|
240 | + */ |
|
241 | + protected static function _bot_trap_settings_form() |
|
242 | + { |
|
243 | + return new EE_Form_Section_Proper( |
|
244 | + array( |
|
245 | + 'name' => 'bot_trap_settings', |
|
246 | + 'html_id' => 'bot_trap_settings', |
|
247 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
248 | + 'subsections' => array( |
|
249 | + 'bot_trap_hdr' => new EE_Form_Section_HTML( |
|
250 | + EEH_HTML::h2(esc_html__('Bot Trap Settings', 'event_espresso')) |
|
251 | + ), |
|
252 | + 'use_bot_trap' => new EE_Yes_No_Input( |
|
253 | + array( |
|
254 | + 'html_label_text' => esc_html__('Enable Bot Trap', 'event_espresso'), |
|
255 | + 'html_help_text' => esc_html__( |
|
256 | + 'The Event Espresso Bot Trap will insert a fake input into your Ticket Selector forms that is hidden from regular site visitors, but visible to spam bots. Because the input asks for an email address, it is irresistible to spam bots who will of course enter text into it. Since regular site visitors can not see this input, any value detected during form submission means a bot has been detected, which will then be blocked from submitting the form.', |
|
257 | + 'event_espresso' |
|
258 | + ), |
|
259 | + 'default' => EE_Registry::instance()->CFG->registration->use_bot_trap !== null |
|
260 | + ? EE_Registry::instance()->CFG->registration->use_bot_trap |
|
261 | + : true, |
|
262 | + 'required' => false, |
|
263 | + ) |
|
264 | + ), |
|
265 | + ), |
|
266 | + ) |
|
267 | + ); |
|
268 | + } |
|
269 | 269 | |
270 | 270 | |
271 | - /** |
|
272 | - * update_bot_trap_settings_form |
|
273 | - * |
|
274 | - * @param EE_Registration_Config $EE_Registration_Config |
|
275 | - * @return EE_Registration_Config |
|
276 | - * @throws EE_Error |
|
277 | - * @throws InvalidArgumentException |
|
278 | - * @throws ReflectionException |
|
279 | - * @throws InvalidDataTypeException |
|
280 | - * @throws InvalidInterfaceException |
|
281 | - */ |
|
282 | - public static function update_bot_trap_settings_form(EE_Registration_Config $EE_Registration_Config) |
|
283 | - { |
|
284 | - try { |
|
285 | - $bot_trap_settings_form = EED_Bot_Trap::_bot_trap_settings_form(); |
|
286 | - // if not displaying a form, then check for form submission |
|
287 | - if ($bot_trap_settings_form->was_submitted()) { |
|
288 | - // capture form data |
|
289 | - $bot_trap_settings_form->receive_form_submission(); |
|
290 | - // validate form data |
|
291 | - if ($bot_trap_settings_form->is_valid()) { |
|
292 | - // grab validated data from form |
|
293 | - $valid_data = $bot_trap_settings_form->valid_data(); |
|
294 | - if (isset($valid_data['use_bot_trap'])) { |
|
295 | - $EE_Registration_Config->use_bot_trap = $valid_data['use_bot_trap']; |
|
296 | - } else { |
|
297 | - EE_Error::add_error( |
|
298 | - esc_html__( |
|
299 | - 'Invalid or missing Bot Trap settings. Please refresh the form and try again.', |
|
300 | - 'event_espresso' |
|
301 | - ), |
|
302 | - __FILE__, |
|
303 | - __FUNCTION__, |
|
304 | - __LINE__ |
|
305 | - ); |
|
306 | - } |
|
307 | - } elseif ($bot_trap_settings_form->submission_error_message() !== '') { |
|
308 | - EE_Error::add_error( |
|
309 | - $bot_trap_settings_form->submission_error_message(), |
|
310 | - __FILE__, |
|
311 | - __FUNCTION__, |
|
312 | - __LINE__ |
|
313 | - ); |
|
314 | - } |
|
315 | - } |
|
316 | - } catch (EE_Error $e) { |
|
317 | - $e->get_error(); |
|
318 | - } |
|
319 | - return $EE_Registration_Config; |
|
320 | - } |
|
271 | + /** |
|
272 | + * update_bot_trap_settings_form |
|
273 | + * |
|
274 | + * @param EE_Registration_Config $EE_Registration_Config |
|
275 | + * @return EE_Registration_Config |
|
276 | + * @throws EE_Error |
|
277 | + * @throws InvalidArgumentException |
|
278 | + * @throws ReflectionException |
|
279 | + * @throws InvalidDataTypeException |
|
280 | + * @throws InvalidInterfaceException |
|
281 | + */ |
|
282 | + public static function update_bot_trap_settings_form(EE_Registration_Config $EE_Registration_Config) |
|
283 | + { |
|
284 | + try { |
|
285 | + $bot_trap_settings_form = EED_Bot_Trap::_bot_trap_settings_form(); |
|
286 | + // if not displaying a form, then check for form submission |
|
287 | + if ($bot_trap_settings_form->was_submitted()) { |
|
288 | + // capture form data |
|
289 | + $bot_trap_settings_form->receive_form_submission(); |
|
290 | + // validate form data |
|
291 | + if ($bot_trap_settings_form->is_valid()) { |
|
292 | + // grab validated data from form |
|
293 | + $valid_data = $bot_trap_settings_form->valid_data(); |
|
294 | + if (isset($valid_data['use_bot_trap'])) { |
|
295 | + $EE_Registration_Config->use_bot_trap = $valid_data['use_bot_trap']; |
|
296 | + } else { |
|
297 | + EE_Error::add_error( |
|
298 | + esc_html__( |
|
299 | + 'Invalid or missing Bot Trap settings. Please refresh the form and try again.', |
|
300 | + 'event_espresso' |
|
301 | + ), |
|
302 | + __FILE__, |
|
303 | + __FUNCTION__, |
|
304 | + __LINE__ |
|
305 | + ); |
|
306 | + } |
|
307 | + } elseif ($bot_trap_settings_form->submission_error_message() !== '') { |
|
308 | + EE_Error::add_error( |
|
309 | + $bot_trap_settings_form->submission_error_message(), |
|
310 | + __FILE__, |
|
311 | + __FUNCTION__, |
|
312 | + __LINE__ |
|
313 | + ); |
|
314 | + } |
|
315 | + } |
|
316 | + } catch (EE_Error $e) { |
|
317 | + $e->get_error(); |
|
318 | + } |
|
319 | + return $EE_Registration_Config; |
|
320 | + } |
|
321 | 321 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | */ |
114 | 114 | protected function getLoader() |
115 | 115 | { |
116 | - if (!$this->loader instanceof LoaderInterface) { |
|
116 | + if ( ! $this->loader instanceof LoaderInterface) { |
|
117 | 117 | $this->loader = LoaderFactory::getLoader(); |
118 | 118 | } |
119 | 119 | return $this->loader; |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | && $_REQUEST['page'] == 'espresso_batch' |
132 | 132 | ) |
133 | 133 | ) { |
134 | - if (! isset($_REQUEST['default_nonce']) || ! wp_verify_nonce($_REQUEST['default_nonce'], 'default_nonce')) { |
|
134 | + if ( ! isset($_REQUEST['default_nonce']) || ! wp_verify_nonce($_REQUEST['default_nonce'], 'default_nonce')) { |
|
135 | 135 | wp_die(esc_html__('The link you clicked to start the batch job has expired. Please go back and refresh the previous page.', 'event_espresso')); |
136 | 136 | } |
137 | 137 | switch ($this->batch_request_type()) { |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
154 | 154 | wp_enqueue_script( |
155 | 155 | 'batch_runner_init', |
156 | - BATCH_URL . 'assets/batch_runner_init.js', |
|
156 | + BATCH_URL.'assets/batch_runner_init.js', |
|
157 | 157 | array('batch_runner'), |
158 | 158 | EVENT_ESPRESSO_VERSION, |
159 | 159 | true |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
178 | 178 | wp_enqueue_script( |
179 | 179 | 'batch_file_runner_init', |
180 | - BATCH_URL . 'assets/batch_file_runner_init.js', |
|
180 | + BATCH_URL.'assets/batch_file_runner_init.js', |
|
181 | 181 | array('batch_runner'), |
182 | 182 | EVENT_ESPRESSO_VERSION, |
183 | 183 | true |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | array( |
190 | 190 | 'download_and_redirecting' => sprintf( |
191 | 191 | __('File Generation complete. Downloading, and %1$sredirecting%2$s...', 'event_espresso'), |
192 | - '<a href="' . $_REQUEST['return_url'] . '">', |
|
192 | + '<a href="'.$_REQUEST['return_url'].'">', |
|
193 | 193 | '</a>' |
194 | 194 | ), |
195 | 195 | 'return_url' => $_REQUEST['return_url'], |
@@ -207,26 +207,26 @@ discard block |
||
207 | 207 | protected function _enqueue_batch_job_scripts_and_styles_and_start_job() |
208 | 208 | { |
209 | 209 | // just copy the bits of EE admin's eei18n that we need in the JS |
210 | - EE_Registry::$i18n_js_strings['batchJobError'] = esc_html__( |
|
210 | + EE_Registry::$i18n_js_strings['batchJobError'] = esc_html__( |
|
211 | 211 | 'An error occurred and the job has been stopped. Please refresh the page to try again.', |
212 | 212 | 'event_espresso' |
213 | 213 | ); |
214 | 214 | wp_register_script( |
215 | 215 | 'progress_bar', |
216 | - EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.js', |
|
216 | + EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/progress_bar.js', |
|
217 | 217 | array('jquery'), |
218 | 218 | EVENT_ESPRESSO_VERSION, |
219 | 219 | true |
220 | 220 | ); |
221 | 221 | wp_enqueue_style( |
222 | 222 | 'progress_bar', |
223 | - EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.css', |
|
223 | + EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/progress_bar.css', |
|
224 | 224 | array(), |
225 | 225 | EVENT_ESPRESSO_VERSION |
226 | 226 | ); |
227 | 227 | wp_enqueue_script( |
228 | 228 | 'batch_runner', |
229 | - EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/batch_runner.js', |
|
229 | + EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/batch_runner.js', |
|
230 | 230 | array('progress_bar', CoreAssetManager::JS_HANDLE_CORE), |
231 | 231 | EVENT_ESPRESSO_VERSION, |
232 | 232 | true |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | public function override_template($template) |
254 | 254 | { |
255 | 255 | if (isset($_REQUEST['espresso_batch']) && isset($_REQUEST['batch'])) { |
256 | - return EE_MODULES . 'batch/templates/batch_frontend_wrapper.template.html'; |
|
256 | + return EE_MODULES.'batch/templates/batch_frontend_wrapper.template.html'; |
|
257 | 257 | } |
258 | 258 | return $template; |
259 | 259 | } |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | public function show_admin_page() |
281 | 281 | { |
282 | 282 | echo EEH_Template::locate_template( |
283 | - EE_MODULES . 'batch/templates/batch_wrapper.template.html', |
|
283 | + EE_MODULES.'batch/templates/batch_wrapper.template.html', |
|
284 | 284 | array('batch_request_type' => $this->batch_request_type()) |
285 | 285 | ); |
286 | 286 | } |
@@ -29,359 +29,359 @@ |
||
29 | 29 | class EED_Batch extends EED_Module |
30 | 30 | { |
31 | 31 | |
32 | - /** |
|
33 | - * Possibly value for $_REQUEST[ 'batch' ]. Indicates to run a job that |
|
34 | - * processes data only |
|
35 | - */ |
|
36 | - const batch_job = 'job'; |
|
37 | - /** |
|
38 | - * Possibly value for $_REQUEST[ 'batch' ]. Indicates to run a job that |
|
39 | - * produces a file for download |
|
40 | - */ |
|
41 | - const batch_file_job = 'file'; |
|
42 | - /** |
|
43 | - * Possibly value for $_REQUEST[ 'batch' ]. Indicates this request is NOT |
|
44 | - * for a batch job. It's the same as not providing the $_REQUEST[ 'batch' ] |
|
45 | - * at all |
|
46 | - */ |
|
47 | - const batch_not_job = 'none'; |
|
32 | + /** |
|
33 | + * Possibly value for $_REQUEST[ 'batch' ]. Indicates to run a job that |
|
34 | + * processes data only |
|
35 | + */ |
|
36 | + const batch_job = 'job'; |
|
37 | + /** |
|
38 | + * Possibly value for $_REQUEST[ 'batch' ]. Indicates to run a job that |
|
39 | + * produces a file for download |
|
40 | + */ |
|
41 | + const batch_file_job = 'file'; |
|
42 | + /** |
|
43 | + * Possibly value for $_REQUEST[ 'batch' ]. Indicates this request is NOT |
|
44 | + * for a batch job. It's the same as not providing the $_REQUEST[ 'batch' ] |
|
45 | + * at all |
|
46 | + */ |
|
47 | + const batch_not_job = 'none'; |
|
48 | 48 | |
49 | - /** |
|
50 | - * |
|
51 | - * @var string 'file', or 'job', or false to indicate its not a batch request at all |
|
52 | - */ |
|
53 | - protected $_batch_request_type = null; |
|
49 | + /** |
|
50 | + * |
|
51 | + * @var string 'file', or 'job', or false to indicate its not a batch request at all |
|
52 | + */ |
|
53 | + protected $_batch_request_type = null; |
|
54 | 54 | |
55 | - /** |
|
56 | - * Because we want to use the response in both the localized JS and in the body |
|
57 | - * we need to make this response available between method calls |
|
58 | - * |
|
59 | - * @var \EventEspressoBatchRequest\Helpers\JobStepResponse |
|
60 | - */ |
|
61 | - protected $_job_step_response = null; |
|
55 | + /** |
|
56 | + * Because we want to use the response in both the localized JS and in the body |
|
57 | + * we need to make this response available between method calls |
|
58 | + * |
|
59 | + * @var \EventEspressoBatchRequest\Helpers\JobStepResponse |
|
60 | + */ |
|
61 | + protected $_job_step_response = null; |
|
62 | 62 | |
63 | - /** |
|
64 | - * @var LoaderInterface |
|
65 | - */ |
|
66 | - protected $loader; |
|
63 | + /** |
|
64 | + * @var LoaderInterface |
|
65 | + */ |
|
66 | + protected $loader; |
|
67 | 67 | |
68 | - /** |
|
69 | - * Gets the batch instance |
|
70 | - * |
|
71 | - * @return EED_Batch |
|
72 | - */ |
|
73 | - public static function instance() |
|
74 | - { |
|
75 | - return self::get_instance(); |
|
76 | - } |
|
68 | + /** |
|
69 | + * Gets the batch instance |
|
70 | + * |
|
71 | + * @return EED_Batch |
|
72 | + */ |
|
73 | + public static function instance() |
|
74 | + { |
|
75 | + return self::get_instance(); |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * Sets hooks to enable batch jobs on the frontend. Disabled by default |
|
80 | - * because it's an attack vector and there are currently no implementations |
|
81 | - */ |
|
82 | - public static function set_hooks() |
|
83 | - { |
|
84 | - // because this is a possibel attack vector, let's have this disabled until |
|
85 | - // we at least have a real use for it on the frontend |
|
86 | - if (apply_filters('FHEE__EED_Batch__set_hooks__enable_frontend_batch', false)) { |
|
87 | - add_action('wp_enqueue_scripts', array(self::instance(), 'enqueue_scripts')); |
|
88 | - add_filter('template_include', array(self::instance(), 'override_template'), 99); |
|
89 | - } |
|
90 | - } |
|
78 | + /** |
|
79 | + * Sets hooks to enable batch jobs on the frontend. Disabled by default |
|
80 | + * because it's an attack vector and there are currently no implementations |
|
81 | + */ |
|
82 | + public static function set_hooks() |
|
83 | + { |
|
84 | + // because this is a possibel attack vector, let's have this disabled until |
|
85 | + // we at least have a real use for it on the frontend |
|
86 | + if (apply_filters('FHEE__EED_Batch__set_hooks__enable_frontend_batch', false)) { |
|
87 | + add_action('wp_enqueue_scripts', array(self::instance(), 'enqueue_scripts')); |
|
88 | + add_filter('template_include', array(self::instance(), 'override_template'), 99); |
|
89 | + } |
|
90 | + } |
|
91 | 91 | |
92 | - /** |
|
93 | - * Initializes some hooks for the admin in order to run batch jobs |
|
94 | - */ |
|
95 | - public static function set_hooks_admin() |
|
96 | - { |
|
97 | - add_action('admin_menu', array(self::instance(), 'register_admin_pages')); |
|
98 | - add_action('admin_enqueue_scripts', array(self::instance(), 'enqueue_scripts')); |
|
92 | + /** |
|
93 | + * Initializes some hooks for the admin in order to run batch jobs |
|
94 | + */ |
|
95 | + public static function set_hooks_admin() |
|
96 | + { |
|
97 | + add_action('admin_menu', array(self::instance(), 'register_admin_pages')); |
|
98 | + add_action('admin_enqueue_scripts', array(self::instance(), 'enqueue_scripts')); |
|
99 | 99 | |
100 | - // ajax |
|
101 | - add_action('wp_ajax_espresso_batch_continue', array(self::instance(), 'batch_continue')); |
|
102 | - add_action('wp_ajax_espresso_batch_cleanup', array(self::instance(), 'batch_cleanup')); |
|
103 | - add_action('wp_ajax_nopriv_espresso_batch_continue', array(self::instance(), 'batch_continue')); |
|
104 | - add_action('wp_ajax_nopriv_espresso_batch_cleanup', array(self::instance(), 'batch_cleanup')); |
|
105 | - } |
|
100 | + // ajax |
|
101 | + add_action('wp_ajax_espresso_batch_continue', array(self::instance(), 'batch_continue')); |
|
102 | + add_action('wp_ajax_espresso_batch_cleanup', array(self::instance(), 'batch_cleanup')); |
|
103 | + add_action('wp_ajax_nopriv_espresso_batch_continue', array(self::instance(), 'batch_continue')); |
|
104 | + add_action('wp_ajax_nopriv_espresso_batch_cleanup', array(self::instance(), 'batch_cleanup')); |
|
105 | + } |
|
106 | 106 | |
107 | - /** |
|
108 | - * @since 4.9.80.p |
|
109 | - * @return LoaderInterface |
|
110 | - * @throws InvalidArgumentException |
|
111 | - * @throws InvalidDataTypeException |
|
112 | - * @throws InvalidInterfaceException |
|
113 | - */ |
|
114 | - protected function getLoader() |
|
115 | - { |
|
116 | - if (!$this->loader instanceof LoaderInterface) { |
|
117 | - $this->loader = LoaderFactory::getLoader(); |
|
118 | - } |
|
119 | - return $this->loader; |
|
120 | - } |
|
107 | + /** |
|
108 | + * @since 4.9.80.p |
|
109 | + * @return LoaderInterface |
|
110 | + * @throws InvalidArgumentException |
|
111 | + * @throws InvalidDataTypeException |
|
112 | + * @throws InvalidInterfaceException |
|
113 | + */ |
|
114 | + protected function getLoader() |
|
115 | + { |
|
116 | + if (!$this->loader instanceof LoaderInterface) { |
|
117 | + $this->loader = LoaderFactory::getLoader(); |
|
118 | + } |
|
119 | + return $this->loader; |
|
120 | + } |
|
121 | 121 | |
122 | - /** |
|
123 | - * Enqueues batch scripts on the frontend or admin, and creates a job |
|
124 | - */ |
|
125 | - public function enqueue_scripts() |
|
126 | - { |
|
127 | - if ( |
|
128 | - isset($_REQUEST['espresso_batch']) |
|
129 | - || |
|
130 | - ( |
|
131 | - isset($_REQUEST['page']) |
|
132 | - && $_REQUEST['page'] == 'espresso_batch' |
|
133 | - ) |
|
134 | - ) { |
|
135 | - if (! isset($_REQUEST['default_nonce']) || ! wp_verify_nonce($_REQUEST['default_nonce'], 'default_nonce')) { |
|
136 | - wp_die(esc_html__('The link you clicked to start the batch job has expired. Please go back and refresh the previous page.', 'event_espresso')); |
|
137 | - } |
|
138 | - switch ($this->batch_request_type()) { |
|
139 | - case self::batch_job: |
|
140 | - $this->enqueue_scripts_styles_batch_create(); |
|
141 | - break; |
|
142 | - case self::batch_file_job: |
|
143 | - $this->enqueue_scripts_styles_batch_file_create(); |
|
144 | - break; |
|
145 | - } |
|
146 | - } |
|
147 | - } |
|
122 | + /** |
|
123 | + * Enqueues batch scripts on the frontend or admin, and creates a job |
|
124 | + */ |
|
125 | + public function enqueue_scripts() |
|
126 | + { |
|
127 | + if ( |
|
128 | + isset($_REQUEST['espresso_batch']) |
|
129 | + || |
|
130 | + ( |
|
131 | + isset($_REQUEST['page']) |
|
132 | + && $_REQUEST['page'] == 'espresso_batch' |
|
133 | + ) |
|
134 | + ) { |
|
135 | + if (! isset($_REQUEST['default_nonce']) || ! wp_verify_nonce($_REQUEST['default_nonce'], 'default_nonce')) { |
|
136 | + wp_die(esc_html__('The link you clicked to start the batch job has expired. Please go back and refresh the previous page.', 'event_espresso')); |
|
137 | + } |
|
138 | + switch ($this->batch_request_type()) { |
|
139 | + case self::batch_job: |
|
140 | + $this->enqueue_scripts_styles_batch_create(); |
|
141 | + break; |
|
142 | + case self::batch_file_job: |
|
143 | + $this->enqueue_scripts_styles_batch_file_create(); |
|
144 | + break; |
|
145 | + } |
|
146 | + } |
|
147 | + } |
|
148 | 148 | |
149 | - /** |
|
150 | - * Create a batch job, enqueues a script to run it, and localizes some data for it |
|
151 | - */ |
|
152 | - public function enqueue_scripts_styles_batch_create() |
|
153 | - { |
|
154 | - $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
|
155 | - wp_enqueue_script( |
|
156 | - 'batch_runner_init', |
|
157 | - BATCH_URL . 'assets/batch_runner_init.js', |
|
158 | - array('batch_runner'), |
|
159 | - EVENT_ESPRESSO_VERSION, |
|
160 | - true |
|
161 | - ); |
|
162 | - wp_localize_script('batch_runner_init', 'ee_job_response', $job_response->to_array()); |
|
163 | - wp_localize_script( |
|
164 | - 'batch_runner_init', |
|
165 | - 'ee_job_i18n', |
|
166 | - array( |
|
167 | - 'return_url' => $_REQUEST['return_url'], |
|
168 | - ) |
|
169 | - ); |
|
170 | - } |
|
149 | + /** |
|
150 | + * Create a batch job, enqueues a script to run it, and localizes some data for it |
|
151 | + */ |
|
152 | + public function enqueue_scripts_styles_batch_create() |
|
153 | + { |
|
154 | + $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
|
155 | + wp_enqueue_script( |
|
156 | + 'batch_runner_init', |
|
157 | + BATCH_URL . 'assets/batch_runner_init.js', |
|
158 | + array('batch_runner'), |
|
159 | + EVENT_ESPRESSO_VERSION, |
|
160 | + true |
|
161 | + ); |
|
162 | + wp_localize_script('batch_runner_init', 'ee_job_response', $job_response->to_array()); |
|
163 | + wp_localize_script( |
|
164 | + 'batch_runner_init', |
|
165 | + 'ee_job_i18n', |
|
166 | + array( |
|
167 | + 'return_url' => $_REQUEST['return_url'], |
|
168 | + ) |
|
169 | + ); |
|
170 | + } |
|
171 | 171 | |
172 | - /** |
|
173 | - * Creates a batch job which will download a file, enqueues a script to run the job, and localizes some data for it |
|
174 | - */ |
|
175 | - public function enqueue_scripts_styles_batch_file_create() |
|
176 | - { |
|
177 | - // creates a job based on the request variable |
|
178 | - $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
|
179 | - wp_enqueue_script( |
|
180 | - 'batch_file_runner_init', |
|
181 | - BATCH_URL . 'assets/batch_file_runner_init.js', |
|
182 | - array('batch_runner'), |
|
183 | - EVENT_ESPRESSO_VERSION, |
|
184 | - true |
|
185 | - ); |
|
186 | - wp_localize_script('batch_file_runner_init', 'ee_job_response', $job_response->to_array()); |
|
187 | - wp_localize_script( |
|
188 | - 'batch_file_runner_init', |
|
189 | - 'ee_job_i18n', |
|
190 | - array( |
|
191 | - 'download_and_redirecting' => sprintf( |
|
192 | - __('File Generation complete. Downloading, and %1$sredirecting%2$s...', 'event_espresso'), |
|
193 | - '<a href="' . $_REQUEST['return_url'] . '">', |
|
194 | - '</a>' |
|
195 | - ), |
|
196 | - 'return_url' => $_REQUEST['return_url'], |
|
197 | - ) |
|
198 | - ); |
|
199 | - } |
|
172 | + /** |
|
173 | + * Creates a batch job which will download a file, enqueues a script to run the job, and localizes some data for it |
|
174 | + */ |
|
175 | + public function enqueue_scripts_styles_batch_file_create() |
|
176 | + { |
|
177 | + // creates a job based on the request variable |
|
178 | + $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
|
179 | + wp_enqueue_script( |
|
180 | + 'batch_file_runner_init', |
|
181 | + BATCH_URL . 'assets/batch_file_runner_init.js', |
|
182 | + array('batch_runner'), |
|
183 | + EVENT_ESPRESSO_VERSION, |
|
184 | + true |
|
185 | + ); |
|
186 | + wp_localize_script('batch_file_runner_init', 'ee_job_response', $job_response->to_array()); |
|
187 | + wp_localize_script( |
|
188 | + 'batch_file_runner_init', |
|
189 | + 'ee_job_i18n', |
|
190 | + array( |
|
191 | + 'download_and_redirecting' => sprintf( |
|
192 | + __('File Generation complete. Downloading, and %1$sredirecting%2$s...', 'event_espresso'), |
|
193 | + '<a href="' . $_REQUEST['return_url'] . '">', |
|
194 | + '</a>' |
|
195 | + ), |
|
196 | + 'return_url' => $_REQUEST['return_url'], |
|
197 | + ) |
|
198 | + ); |
|
199 | + } |
|
200 | 200 | |
201 | - /** |
|
202 | - * Enqueues scripts and styles common to any batch job, and creates |
|
203 | - * a job from the request data, and stores the response in the |
|
204 | - * $this->_job_step_response property |
|
205 | - * |
|
206 | - * @return \EventEspressoBatchRequest\Helpers\JobStepResponse |
|
207 | - */ |
|
208 | - protected function _enqueue_batch_job_scripts_and_styles_and_start_job() |
|
209 | - { |
|
210 | - // just copy the bits of EE admin's eei18n that we need in the JS |
|
211 | - EE_Registry::$i18n_js_strings['batchJobError'] = esc_html__( |
|
212 | - 'An error occurred and the job has been stopped. Please refresh the page to try again.', |
|
213 | - 'event_espresso' |
|
214 | - ); |
|
215 | - wp_register_script( |
|
216 | - 'progress_bar', |
|
217 | - EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.js', |
|
218 | - array('jquery'), |
|
219 | - EVENT_ESPRESSO_VERSION, |
|
220 | - true |
|
221 | - ); |
|
222 | - wp_enqueue_style( |
|
223 | - 'progress_bar', |
|
224 | - EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.css', |
|
225 | - array(), |
|
226 | - EVENT_ESPRESSO_VERSION |
|
227 | - ); |
|
228 | - wp_enqueue_script( |
|
229 | - 'batch_runner', |
|
230 | - EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/batch_runner.js', |
|
231 | - array('progress_bar', CoreAssetManager::JS_HANDLE_CORE), |
|
232 | - EVENT_ESPRESSO_VERSION, |
|
233 | - true |
|
234 | - ); |
|
235 | - $job_handler_classname = stripslashes($_GET['job_handler']); |
|
236 | - $request_data = array_diff_key( |
|
237 | - $_REQUEST, |
|
238 | - array_flip(array('action', 'page', 'ee', 'batch')) |
|
239 | - ); |
|
240 | - $batch_runner = $this->getLoader()->getShared('EventEspressoBatchRequest\BatchRequestProcessor'); |
|
241 | - // eg 'EventEspressoBatchRequest\JobHandlers\RegistrationsReport' |
|
242 | - $job_response = $batch_runner->create_job($job_handler_classname, $request_data); |
|
243 | - // remember the response for later. We need it to display the page body |
|
244 | - $this->_job_step_response = $job_response; |
|
245 | - return $job_response; |
|
246 | - } |
|
201 | + /** |
|
202 | + * Enqueues scripts and styles common to any batch job, and creates |
|
203 | + * a job from the request data, and stores the response in the |
|
204 | + * $this->_job_step_response property |
|
205 | + * |
|
206 | + * @return \EventEspressoBatchRequest\Helpers\JobStepResponse |
|
207 | + */ |
|
208 | + protected function _enqueue_batch_job_scripts_and_styles_and_start_job() |
|
209 | + { |
|
210 | + // just copy the bits of EE admin's eei18n that we need in the JS |
|
211 | + EE_Registry::$i18n_js_strings['batchJobError'] = esc_html__( |
|
212 | + 'An error occurred and the job has been stopped. Please refresh the page to try again.', |
|
213 | + 'event_espresso' |
|
214 | + ); |
|
215 | + wp_register_script( |
|
216 | + 'progress_bar', |
|
217 | + EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.js', |
|
218 | + array('jquery'), |
|
219 | + EVENT_ESPRESSO_VERSION, |
|
220 | + true |
|
221 | + ); |
|
222 | + wp_enqueue_style( |
|
223 | + 'progress_bar', |
|
224 | + EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.css', |
|
225 | + array(), |
|
226 | + EVENT_ESPRESSO_VERSION |
|
227 | + ); |
|
228 | + wp_enqueue_script( |
|
229 | + 'batch_runner', |
|
230 | + EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/batch_runner.js', |
|
231 | + array('progress_bar', CoreAssetManager::JS_HANDLE_CORE), |
|
232 | + EVENT_ESPRESSO_VERSION, |
|
233 | + true |
|
234 | + ); |
|
235 | + $job_handler_classname = stripslashes($_GET['job_handler']); |
|
236 | + $request_data = array_diff_key( |
|
237 | + $_REQUEST, |
|
238 | + array_flip(array('action', 'page', 'ee', 'batch')) |
|
239 | + ); |
|
240 | + $batch_runner = $this->getLoader()->getShared('EventEspressoBatchRequest\BatchRequestProcessor'); |
|
241 | + // eg 'EventEspressoBatchRequest\JobHandlers\RegistrationsReport' |
|
242 | + $job_response = $batch_runner->create_job($job_handler_classname, $request_data); |
|
243 | + // remember the response for later. We need it to display the page body |
|
244 | + $this->_job_step_response = $job_response; |
|
245 | + return $job_response; |
|
246 | + } |
|
247 | 247 | |
248 | - /** |
|
249 | - * If we are doing a frontend batch job, this makes it so WP shows our template's HTML |
|
250 | - * |
|
251 | - * @param string $template |
|
252 | - * @return string |
|
253 | - */ |
|
254 | - public function override_template($template) |
|
255 | - { |
|
256 | - if (isset($_REQUEST['espresso_batch']) && isset($_REQUEST['batch'])) { |
|
257 | - return EE_MODULES . 'batch/templates/batch_frontend_wrapper.template.html'; |
|
258 | - } |
|
259 | - return $template; |
|
260 | - } |
|
248 | + /** |
|
249 | + * If we are doing a frontend batch job, this makes it so WP shows our template's HTML |
|
250 | + * |
|
251 | + * @param string $template |
|
252 | + * @return string |
|
253 | + */ |
|
254 | + public function override_template($template) |
|
255 | + { |
|
256 | + if (isset($_REQUEST['espresso_batch']) && isset($_REQUEST['batch'])) { |
|
257 | + return EE_MODULES . 'batch/templates/batch_frontend_wrapper.template.html'; |
|
258 | + } |
|
259 | + return $template; |
|
260 | + } |
|
261 | 261 | |
262 | - /** |
|
263 | - * Adds an admin page which doesn't appear in the admin menu |
|
264 | - */ |
|
265 | - public function register_admin_pages() |
|
266 | - { |
|
267 | - add_submenu_page( |
|
268 | - '', // parent slug. we don't want this to actually appear in the menu |
|
269 | - __('Batch Job', 'event_espresso'), // page title |
|
270 | - 'n/a', // menu title |
|
271 | - 'read', // we want this page to actually be accessible to anyone, |
|
272 | - 'espresso_batch', // menu slug |
|
273 | - array(self::instance(), 'show_admin_page') |
|
274 | - ); |
|
275 | - } |
|
262 | + /** |
|
263 | + * Adds an admin page which doesn't appear in the admin menu |
|
264 | + */ |
|
265 | + public function register_admin_pages() |
|
266 | + { |
|
267 | + add_submenu_page( |
|
268 | + '', // parent slug. we don't want this to actually appear in the menu |
|
269 | + __('Batch Job', 'event_espresso'), // page title |
|
270 | + 'n/a', // menu title |
|
271 | + 'read', // we want this page to actually be accessible to anyone, |
|
272 | + 'espresso_batch', // menu slug |
|
273 | + array(self::instance(), 'show_admin_page') |
|
274 | + ); |
|
275 | + } |
|
276 | 276 | |
277 | - /** |
|
278 | - * Renders the admin page, after most of the work was already done during enqueuing scripts |
|
279 | - * of creating the job and localizing some data |
|
280 | - */ |
|
281 | - public function show_admin_page() |
|
282 | - { |
|
283 | - echo EEH_Template::locate_template( |
|
284 | - EE_MODULES . 'batch/templates/batch_wrapper.template.html', |
|
285 | - array('batch_request_type' => $this->batch_request_type()) |
|
286 | - ); |
|
287 | - } |
|
277 | + /** |
|
278 | + * Renders the admin page, after most of the work was already done during enqueuing scripts |
|
279 | + * of creating the job and localizing some data |
|
280 | + */ |
|
281 | + public function show_admin_page() |
|
282 | + { |
|
283 | + echo EEH_Template::locate_template( |
|
284 | + EE_MODULES . 'batch/templates/batch_wrapper.template.html', |
|
285 | + array('batch_request_type' => $this->batch_request_type()) |
|
286 | + ); |
|
287 | + } |
|
288 | 288 | |
289 | - /** |
|
290 | - * Receives ajax calls for continuing a job |
|
291 | - */ |
|
292 | - public function batch_continue() |
|
293 | - { |
|
294 | - $job_id = sanitize_text_field($_REQUEST['job_id']); |
|
295 | - $batch_runner = $this->getLoader()->getShared('EventEspressoBatchRequest\BatchRequestProcessor'); |
|
296 | - $response_obj = $batch_runner->continue_job($job_id); |
|
297 | - $this->_return_json($response_obj->to_array()); |
|
298 | - } |
|
289 | + /** |
|
290 | + * Receives ajax calls for continuing a job |
|
291 | + */ |
|
292 | + public function batch_continue() |
|
293 | + { |
|
294 | + $job_id = sanitize_text_field($_REQUEST['job_id']); |
|
295 | + $batch_runner = $this->getLoader()->getShared('EventEspressoBatchRequest\BatchRequestProcessor'); |
|
296 | + $response_obj = $batch_runner->continue_job($job_id); |
|
297 | + $this->_return_json($response_obj->to_array()); |
|
298 | + } |
|
299 | 299 | |
300 | - /** |
|
301 | - * Receives the ajax call to cleanup a job |
|
302 | - * |
|
303 | - * @return type |
|
304 | - */ |
|
305 | - public function batch_cleanup() |
|
306 | - { |
|
307 | - $job_id = sanitize_text_field($_REQUEST['job_id']); |
|
308 | - $batch_runner = $this->getLoader()->getShared('EventEspressoBatchRequest\BatchRequestProcessor'); |
|
309 | - $response_obj = $batch_runner->cleanup_job($job_id); |
|
310 | - $this->_return_json($response_obj->to_array()); |
|
311 | - } |
|
300 | + /** |
|
301 | + * Receives the ajax call to cleanup a job |
|
302 | + * |
|
303 | + * @return type |
|
304 | + */ |
|
305 | + public function batch_cleanup() |
|
306 | + { |
|
307 | + $job_id = sanitize_text_field($_REQUEST['job_id']); |
|
308 | + $batch_runner = $this->getLoader()->getShared('EventEspressoBatchRequest\BatchRequestProcessor'); |
|
309 | + $response_obj = $batch_runner->cleanup_job($job_id); |
|
310 | + $this->_return_json($response_obj->to_array()); |
|
311 | + } |
|
312 | 312 | |
313 | 313 | |
314 | - /** |
|
315 | - * Returns a json response |
|
316 | - * |
|
317 | - * @param array $data The data we want to send echo via in the JSON response's "data" element |
|
318 | - * |
|
319 | - * The returned json object is created from an array in the following format: |
|
320 | - * array( |
|
321 | - * 'notices' => '', // - contains any EE_Error formatted notices |
|
322 | - * 'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js. |
|
323 | - * We're also going to include the template args with every package (so js can pick out any specific template |
|
324 | - * args that might be included in here) |
|
325 | - * 'isEEajax' => true,//indicates this is a response from EE |
|
326 | - * ) |
|
327 | - */ |
|
328 | - protected function _return_json($data) |
|
329 | - { |
|
330 | - $json = array( |
|
331 | - 'notices' => EE_Error::get_notices(), |
|
332 | - 'data' => $data, |
|
333 | - 'isEEajax' => true |
|
334 | - // special flag so any ajax.Success methods in js can identify this return package as a EEajax package. |
|
335 | - ); |
|
314 | + /** |
|
315 | + * Returns a json response |
|
316 | + * |
|
317 | + * @param array $data The data we want to send echo via in the JSON response's "data" element |
|
318 | + * |
|
319 | + * The returned json object is created from an array in the following format: |
|
320 | + * array( |
|
321 | + * 'notices' => '', // - contains any EE_Error formatted notices |
|
322 | + * 'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js. |
|
323 | + * We're also going to include the template args with every package (so js can pick out any specific template |
|
324 | + * args that might be included in here) |
|
325 | + * 'isEEajax' => true,//indicates this is a response from EE |
|
326 | + * ) |
|
327 | + */ |
|
328 | + protected function _return_json($data) |
|
329 | + { |
|
330 | + $json = array( |
|
331 | + 'notices' => EE_Error::get_notices(), |
|
332 | + 'data' => $data, |
|
333 | + 'isEEajax' => true |
|
334 | + // special flag so any ajax.Success methods in js can identify this return package as a EEajax package. |
|
335 | + ); |
|
336 | 336 | |
337 | 337 | |
338 | - // make sure there are no php errors or headers_sent. Then we can set correct json header. |
|
339 | - if (null === error_get_last() || ! headers_sent()) { |
|
340 | - header('Content-Type: application/json; charset=UTF-8'); |
|
341 | - } |
|
342 | - echo wp_json_encode($json); |
|
343 | - exit(); |
|
344 | - } |
|
338 | + // make sure there are no php errors or headers_sent. Then we can set correct json header. |
|
339 | + if (null === error_get_last() || ! headers_sent()) { |
|
340 | + header('Content-Type: application/json; charset=UTF-8'); |
|
341 | + } |
|
342 | + echo wp_json_encode($json); |
|
343 | + exit(); |
|
344 | + } |
|
345 | 345 | |
346 | - /** |
|
347 | - * Gets the job step response which was done during the enqueuing of scripts |
|
348 | - * |
|
349 | - * @return \EventEspressoBatchRequest\Helpers\JobStepResponse |
|
350 | - */ |
|
351 | - public function job_step_response() |
|
352 | - { |
|
353 | - return $this->_job_step_response; |
|
354 | - } |
|
346 | + /** |
|
347 | + * Gets the job step response which was done during the enqueuing of scripts |
|
348 | + * |
|
349 | + * @return \EventEspressoBatchRequest\Helpers\JobStepResponse |
|
350 | + */ |
|
351 | + public function job_step_response() |
|
352 | + { |
|
353 | + return $this->_job_step_response; |
|
354 | + } |
|
355 | 355 | |
356 | - /** |
|
357 | - * Gets the batch request type indicated in the $_REQUEST |
|
358 | - * |
|
359 | - * @return string: EED_Batch::batch_job, EED_Batch::batch_file_job, EED_Batch::batch_not_job |
|
360 | - */ |
|
361 | - public function batch_request_type() |
|
362 | - { |
|
363 | - if ($this->_batch_request_type === null) { |
|
364 | - if (isset($_GET['batch'])) { |
|
365 | - if ($_GET['batch'] == self::batch_job) { |
|
366 | - $this->_batch_request_type = self::batch_job; |
|
367 | - } elseif ($_GET['batch'] == self::batch_file_job) { |
|
368 | - $this->_batch_request_type = self::batch_file_job; |
|
369 | - } |
|
370 | - } |
|
371 | - // if we didn't find that it was a batch request, indicate it wasn't |
|
372 | - if ($this->_batch_request_type === null) { |
|
373 | - $this->_batch_request_type = self::batch_not_job; |
|
374 | - } |
|
375 | - } |
|
376 | - return $this->_batch_request_type; |
|
377 | - } |
|
356 | + /** |
|
357 | + * Gets the batch request type indicated in the $_REQUEST |
|
358 | + * |
|
359 | + * @return string: EED_Batch::batch_job, EED_Batch::batch_file_job, EED_Batch::batch_not_job |
|
360 | + */ |
|
361 | + public function batch_request_type() |
|
362 | + { |
|
363 | + if ($this->_batch_request_type === null) { |
|
364 | + if (isset($_GET['batch'])) { |
|
365 | + if ($_GET['batch'] == self::batch_job) { |
|
366 | + $this->_batch_request_type = self::batch_job; |
|
367 | + } elseif ($_GET['batch'] == self::batch_file_job) { |
|
368 | + $this->_batch_request_type = self::batch_file_job; |
|
369 | + } |
|
370 | + } |
|
371 | + // if we didn't find that it was a batch request, indicate it wasn't |
|
372 | + if ($this->_batch_request_type === null) { |
|
373 | + $this->_batch_request_type = self::batch_not_job; |
|
374 | + } |
|
375 | + } |
|
376 | + return $this->_batch_request_type; |
|
377 | + } |
|
378 | 378 | |
379 | - /** |
|
380 | - * Unnecessary |
|
381 | - * |
|
382 | - * @param type $WP |
|
383 | - */ |
|
384 | - public function run($WP) |
|
385 | - { |
|
386 | - } |
|
379 | + /** |
|
380 | + * Unnecessary |
|
381 | + * |
|
382 | + * @param type $WP |
|
383 | + */ |
|
384 | + public function run($WP) |
|
385 | + { |
|
386 | + } |
|
387 | 387 | } |
@@ -12,217 +12,217 @@ |
||
12 | 12 | { |
13 | 13 | |
14 | 14 | |
15 | - /** |
|
16 | - * @return EED_Feeds |
|
17 | - */ |
|
18 | - public static function instance() |
|
19 | - { |
|
20 | - return parent::get_instance(__CLASS__); |
|
21 | - } |
|
22 | - |
|
23 | - |
|
24 | - /** |
|
25 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
26 | - * |
|
27 | - * @access public |
|
28 | - * @return void |
|
29 | - */ |
|
30 | - public static function set_hooks() |
|
31 | - { |
|
32 | - add_action('parse_request', array('EED_Feeds', 'parse_request'), 10); |
|
33 | - add_filter('default_feed', array('EED_Feeds', 'default_feed'), 10, 1); |
|
34 | - add_filter('comment_feed_join', array('EED_Feeds', 'comment_feed_join'), 10, 2); |
|
35 | - add_filter('comment_feed_where', array('EED_Feeds', 'comment_feed_where'), 10, 2); |
|
36 | - } |
|
37 | - |
|
38 | - /** |
|
39 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
40 | - * |
|
41 | - * @access public |
|
42 | - * @return void |
|
43 | - */ |
|
44 | - public static function set_hooks_admin() |
|
45 | - { |
|
46 | - } |
|
47 | - |
|
48 | - |
|
49 | - /** |
|
50 | - * run - initial module setup |
|
51 | - * |
|
52 | - * @access public |
|
53 | - * @return void |
|
54 | - */ |
|
55 | - public function run($WP) |
|
56 | - { |
|
57 | - } |
|
58 | - |
|
59 | - |
|
60 | - /** |
|
61 | - * default_feed |
|
62 | - * |
|
63 | - * @access public |
|
64 | - * @param type rss2, atom, rss, rdf, rssjs |
|
65 | - * @return string |
|
66 | - */ |
|
67 | - public static function default_feed($type = 'rss2') |
|
68 | - { |
|
69 | - // rss2, atom, rss, rdf, rssjs |
|
70 | - $type = 'rss2'; |
|
71 | - return $type; |
|
72 | - } |
|
73 | - |
|
74 | - |
|
75 | - /** |
|
76 | - * parse_request |
|
77 | - * |
|
78 | - * @access public |
|
79 | - * @return void |
|
80 | - */ |
|
81 | - public static function parse_request() |
|
82 | - { |
|
83 | - if (EE_Registry::instance()->REQ->is_set('post_type')) { |
|
84 | - // define path to templates |
|
85 | - define('RSS_FEEDS_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/'); |
|
86 | - // what kinda post_type are we dealing with ? |
|
87 | - switch (EE_Registry::instance()->REQ->get('post_type')) { |
|
88 | - case 'espresso_events': |
|
89 | - // for rss2, atom, rss, rdf |
|
90 | - add_filter('the_excerpt_rss', array('EED_Feeds', 'the_event_feed'), 10, 1); |
|
91 | - add_filter('the_content_feed', array('EED_Feeds', 'the_event_feed'), 10, 1); |
|
92 | - // for json ( also uses the above filter ) |
|
93 | - add_filter('rssjs_feed_item', array('EED_Feeds', 'the_event_rssjs_feed'), 10, 1); |
|
94 | - break; |
|
95 | - case 'espresso_venues': |
|
96 | - // for rss2, atom, rss, rdf |
|
97 | - add_filter('the_excerpt_rss', array('EED_Feeds', 'the_venue_feed'), 10, 1); |
|
98 | - add_filter('the_content_feed', array('EED_Feeds', 'the_venue_feed'), 10, 1); |
|
99 | - // for json ( also uses the above filter ) |
|
100 | - add_filter('rssjs_feed_item', array('EED_Feeds', 'the_venue_rssjs_feed'), 10, 1); |
|
101 | - break; |
|
102 | - } |
|
103 | - } |
|
104 | - } |
|
105 | - |
|
106 | - |
|
107 | - /** |
|
108 | - * comment_feed_join - EVEN THOUGH... our espresso_attendees custom post type is set to NOT PUBLIC |
|
109 | - * WordPress thought it would be a good idea to display the comments for them in the RSS feeds... we think NOT |
|
110 | - * so this little snippet of SQL taps into the comment feed query and removes comments for the |
|
111 | - * espresso_attendees post_type |
|
112 | - * |
|
113 | - * @access public |
|
114 | - * @param string $SQL the JOIN clause for the comment feed query |
|
115 | - * @return void |
|
116 | - */ |
|
117 | - public static function comment_feed_join($SQL) |
|
118 | - { |
|
119 | - global $wpdb; |
|
120 | - // check for wp_posts table in JOIN clause |
|
121 | - if (strpos($SQL, $wpdb->posts) !== false) { |
|
122 | - add_filter('EED_Feeds__comment_feed_where__espresso_attendees', '__return_true'); |
|
123 | - } |
|
124 | - return $SQL; |
|
125 | - } |
|
126 | - |
|
127 | - |
|
128 | - /** |
|
129 | - * comment_feed_where - EVEN THOUGH... our espresso_attendees custom post type is set to NOT PUBLIC |
|
130 | - * WordPress thought it would be a good idea to display the comments for them in the RSS feeds... we think NOT |
|
131 | - * so this little snippet of SQL taps into the comment feed query and removes comments for the |
|
132 | - * espresso_attendees post_type |
|
133 | - * |
|
134 | - * @access public |
|
135 | - * @param string $SQL the WHERE clause for the comment feed query |
|
136 | - * @return void |
|
137 | - */ |
|
138 | - public static function comment_feed_where($SQL) |
|
139 | - { |
|
140 | - global $wp_query, $wpdb; |
|
141 | - if ($wp_query->is_comment_feed && apply_filters('EED_Feeds__comment_feed_where__espresso_attendees', false)) { |
|
142 | - $SQL .= " AND $wpdb->posts.post_type != 'espresso_attendees'"; |
|
143 | - } |
|
144 | - return $SQL; |
|
145 | - } |
|
146 | - |
|
147 | - |
|
148 | - /** |
|
149 | - * the_event_feed |
|
150 | - * |
|
151 | - * @access public |
|
152 | - * @param string $content |
|
153 | - * @return void |
|
154 | - */ |
|
155 | - public static function the_event_feed($content) |
|
156 | - { |
|
157 | - if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php')) { |
|
158 | - global $post; |
|
159 | - $template_args = array( |
|
160 | - 'EVT_ID' => $post->ID, |
|
161 | - 'event_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content, |
|
162 | - ); |
|
163 | - $content = EEH_Template::display_template( |
|
164 | - RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php', |
|
165 | - $template_args, |
|
166 | - true |
|
167 | - ); |
|
168 | - } |
|
169 | - return $content; |
|
170 | - } |
|
171 | - |
|
172 | - |
|
173 | - /** |
|
174 | - * the_event_rssjs_feed |
|
175 | - * |
|
176 | - * @access public |
|
177 | - * @param object $item |
|
178 | - * @return void |
|
179 | - */ |
|
180 | - public static function the_event_rssjs_feed($item) |
|
181 | - { |
|
182 | - if (is_feed() && isset($item->description)) { |
|
183 | - $item->description = EED_Feeds::the_event_feed($item->description); |
|
184 | - } |
|
185 | - return $item; |
|
186 | - } |
|
187 | - |
|
188 | - |
|
189 | - /** |
|
190 | - * the_venue_feed |
|
191 | - * |
|
192 | - * @access public |
|
193 | - * @param string $content |
|
194 | - * @return void |
|
195 | - */ |
|
196 | - public static function the_venue_feed($content) |
|
197 | - { |
|
198 | - if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php')) { |
|
199 | - global $post; |
|
200 | - $template_args = array( |
|
201 | - 'VNU_ID' => $post->ID, |
|
202 | - 'venue_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content, |
|
203 | - ); |
|
204 | - $content = EEH_Template::display_template( |
|
205 | - RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php', |
|
206 | - $template_args, |
|
207 | - true |
|
208 | - ); |
|
209 | - } |
|
210 | - return $content; |
|
211 | - } |
|
212 | - |
|
213 | - |
|
214 | - /** |
|
215 | - * the_venue_rssjs_feed |
|
216 | - * |
|
217 | - * @access public |
|
218 | - * @param object $item |
|
219 | - * @return void |
|
220 | - */ |
|
221 | - public static function the_venue_rssjs_feed($item) |
|
222 | - { |
|
223 | - if (is_feed() && isset($item->description)) { |
|
224 | - $item->description = EED_Feeds::the_venue_feed($item->description); |
|
225 | - } |
|
226 | - return $item; |
|
227 | - } |
|
15 | + /** |
|
16 | + * @return EED_Feeds |
|
17 | + */ |
|
18 | + public static function instance() |
|
19 | + { |
|
20 | + return parent::get_instance(__CLASS__); |
|
21 | + } |
|
22 | + |
|
23 | + |
|
24 | + /** |
|
25 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
26 | + * |
|
27 | + * @access public |
|
28 | + * @return void |
|
29 | + */ |
|
30 | + public static function set_hooks() |
|
31 | + { |
|
32 | + add_action('parse_request', array('EED_Feeds', 'parse_request'), 10); |
|
33 | + add_filter('default_feed', array('EED_Feeds', 'default_feed'), 10, 1); |
|
34 | + add_filter('comment_feed_join', array('EED_Feeds', 'comment_feed_join'), 10, 2); |
|
35 | + add_filter('comment_feed_where', array('EED_Feeds', 'comment_feed_where'), 10, 2); |
|
36 | + } |
|
37 | + |
|
38 | + /** |
|
39 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
40 | + * |
|
41 | + * @access public |
|
42 | + * @return void |
|
43 | + */ |
|
44 | + public static function set_hooks_admin() |
|
45 | + { |
|
46 | + } |
|
47 | + |
|
48 | + |
|
49 | + /** |
|
50 | + * run - initial module setup |
|
51 | + * |
|
52 | + * @access public |
|
53 | + * @return void |
|
54 | + */ |
|
55 | + public function run($WP) |
|
56 | + { |
|
57 | + } |
|
58 | + |
|
59 | + |
|
60 | + /** |
|
61 | + * default_feed |
|
62 | + * |
|
63 | + * @access public |
|
64 | + * @param type rss2, atom, rss, rdf, rssjs |
|
65 | + * @return string |
|
66 | + */ |
|
67 | + public static function default_feed($type = 'rss2') |
|
68 | + { |
|
69 | + // rss2, atom, rss, rdf, rssjs |
|
70 | + $type = 'rss2'; |
|
71 | + return $type; |
|
72 | + } |
|
73 | + |
|
74 | + |
|
75 | + /** |
|
76 | + * parse_request |
|
77 | + * |
|
78 | + * @access public |
|
79 | + * @return void |
|
80 | + */ |
|
81 | + public static function parse_request() |
|
82 | + { |
|
83 | + if (EE_Registry::instance()->REQ->is_set('post_type')) { |
|
84 | + // define path to templates |
|
85 | + define('RSS_FEEDS_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/'); |
|
86 | + // what kinda post_type are we dealing with ? |
|
87 | + switch (EE_Registry::instance()->REQ->get('post_type')) { |
|
88 | + case 'espresso_events': |
|
89 | + // for rss2, atom, rss, rdf |
|
90 | + add_filter('the_excerpt_rss', array('EED_Feeds', 'the_event_feed'), 10, 1); |
|
91 | + add_filter('the_content_feed', array('EED_Feeds', 'the_event_feed'), 10, 1); |
|
92 | + // for json ( also uses the above filter ) |
|
93 | + add_filter('rssjs_feed_item', array('EED_Feeds', 'the_event_rssjs_feed'), 10, 1); |
|
94 | + break; |
|
95 | + case 'espresso_venues': |
|
96 | + // for rss2, atom, rss, rdf |
|
97 | + add_filter('the_excerpt_rss', array('EED_Feeds', 'the_venue_feed'), 10, 1); |
|
98 | + add_filter('the_content_feed', array('EED_Feeds', 'the_venue_feed'), 10, 1); |
|
99 | + // for json ( also uses the above filter ) |
|
100 | + add_filter('rssjs_feed_item', array('EED_Feeds', 'the_venue_rssjs_feed'), 10, 1); |
|
101 | + break; |
|
102 | + } |
|
103 | + } |
|
104 | + } |
|
105 | + |
|
106 | + |
|
107 | + /** |
|
108 | + * comment_feed_join - EVEN THOUGH... our espresso_attendees custom post type is set to NOT PUBLIC |
|
109 | + * WordPress thought it would be a good idea to display the comments for them in the RSS feeds... we think NOT |
|
110 | + * so this little snippet of SQL taps into the comment feed query and removes comments for the |
|
111 | + * espresso_attendees post_type |
|
112 | + * |
|
113 | + * @access public |
|
114 | + * @param string $SQL the JOIN clause for the comment feed query |
|
115 | + * @return void |
|
116 | + */ |
|
117 | + public static function comment_feed_join($SQL) |
|
118 | + { |
|
119 | + global $wpdb; |
|
120 | + // check for wp_posts table in JOIN clause |
|
121 | + if (strpos($SQL, $wpdb->posts) !== false) { |
|
122 | + add_filter('EED_Feeds__comment_feed_where__espresso_attendees', '__return_true'); |
|
123 | + } |
|
124 | + return $SQL; |
|
125 | + } |
|
126 | + |
|
127 | + |
|
128 | + /** |
|
129 | + * comment_feed_where - EVEN THOUGH... our espresso_attendees custom post type is set to NOT PUBLIC |
|
130 | + * WordPress thought it would be a good idea to display the comments for them in the RSS feeds... we think NOT |
|
131 | + * so this little snippet of SQL taps into the comment feed query and removes comments for the |
|
132 | + * espresso_attendees post_type |
|
133 | + * |
|
134 | + * @access public |
|
135 | + * @param string $SQL the WHERE clause for the comment feed query |
|
136 | + * @return void |
|
137 | + */ |
|
138 | + public static function comment_feed_where($SQL) |
|
139 | + { |
|
140 | + global $wp_query, $wpdb; |
|
141 | + if ($wp_query->is_comment_feed && apply_filters('EED_Feeds__comment_feed_where__espresso_attendees', false)) { |
|
142 | + $SQL .= " AND $wpdb->posts.post_type != 'espresso_attendees'"; |
|
143 | + } |
|
144 | + return $SQL; |
|
145 | + } |
|
146 | + |
|
147 | + |
|
148 | + /** |
|
149 | + * the_event_feed |
|
150 | + * |
|
151 | + * @access public |
|
152 | + * @param string $content |
|
153 | + * @return void |
|
154 | + */ |
|
155 | + public static function the_event_feed($content) |
|
156 | + { |
|
157 | + if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php')) { |
|
158 | + global $post; |
|
159 | + $template_args = array( |
|
160 | + 'EVT_ID' => $post->ID, |
|
161 | + 'event_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content, |
|
162 | + ); |
|
163 | + $content = EEH_Template::display_template( |
|
164 | + RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php', |
|
165 | + $template_args, |
|
166 | + true |
|
167 | + ); |
|
168 | + } |
|
169 | + return $content; |
|
170 | + } |
|
171 | + |
|
172 | + |
|
173 | + /** |
|
174 | + * the_event_rssjs_feed |
|
175 | + * |
|
176 | + * @access public |
|
177 | + * @param object $item |
|
178 | + * @return void |
|
179 | + */ |
|
180 | + public static function the_event_rssjs_feed($item) |
|
181 | + { |
|
182 | + if (is_feed() && isset($item->description)) { |
|
183 | + $item->description = EED_Feeds::the_event_feed($item->description); |
|
184 | + } |
|
185 | + return $item; |
|
186 | + } |
|
187 | + |
|
188 | + |
|
189 | + /** |
|
190 | + * the_venue_feed |
|
191 | + * |
|
192 | + * @access public |
|
193 | + * @param string $content |
|
194 | + * @return void |
|
195 | + */ |
|
196 | + public static function the_venue_feed($content) |
|
197 | + { |
|
198 | + if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php')) { |
|
199 | + global $post; |
|
200 | + $template_args = array( |
|
201 | + 'VNU_ID' => $post->ID, |
|
202 | + 'venue_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content, |
|
203 | + ); |
|
204 | + $content = EEH_Template::display_template( |
|
205 | + RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php', |
|
206 | + $template_args, |
|
207 | + true |
|
208 | + ); |
|
209 | + } |
|
210 | + return $content; |
|
211 | + } |
|
212 | + |
|
213 | + |
|
214 | + /** |
|
215 | + * the_venue_rssjs_feed |
|
216 | + * |
|
217 | + * @access public |
|
218 | + * @param object $item |
|
219 | + * @return void |
|
220 | + */ |
|
221 | + public static function the_venue_rssjs_feed($item) |
|
222 | + { |
|
223 | + if (is_feed() && isset($item->description)) { |
|
224 | + $item->description = EED_Feeds::the_venue_feed($item->description); |
|
225 | + } |
|
226 | + return $item; |
|
227 | + } |
|
228 | 228 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | { |
83 | 83 | if (EE_Registry::instance()->REQ->is_set('post_type')) { |
84 | 84 | // define path to templates |
85 | - define('RSS_FEEDS_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/'); |
|
85 | + define('RSS_FEEDS_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)).'templates/'); |
|
86 | 86 | // what kinda post_type are we dealing with ? |
87 | 87 | switch (EE_Registry::instance()->REQ->get('post_type')) { |
88 | 88 | case 'espresso_events': |
@@ -154,14 +154,14 @@ discard block |
||
154 | 154 | */ |
155 | 155 | public static function the_event_feed($content) |
156 | 156 | { |
157 | - if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php')) { |
|
157 | + if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH.'espresso_events_feed.template.php')) { |
|
158 | 158 | global $post; |
159 | 159 | $template_args = array( |
160 | 160 | 'EVT_ID' => $post->ID, |
161 | 161 | 'event_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content, |
162 | 162 | ); |
163 | 163 | $content = EEH_Template::display_template( |
164 | - RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php', |
|
164 | + RSS_FEEDS_TEMPLATES_PATH.'espresso_events_feed.template.php', |
|
165 | 165 | $template_args, |
166 | 166 | true |
167 | 167 | ); |
@@ -195,14 +195,14 @@ discard block |
||
195 | 195 | */ |
196 | 196 | public static function the_venue_feed($content) |
197 | 197 | { |
198 | - if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php')) { |
|
198 | + if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH.'espresso_venues_feed.template.php')) { |
|
199 | 199 | global $post; |
200 | 200 | $template_args = array( |
201 | 201 | 'VNU_ID' => $post->ID, |
202 | 202 | 'venue_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content, |
203 | 203 | ); |
204 | 204 | $content = EEH_Template::display_template( |
205 | - RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php', |
|
205 | + RSS_FEEDS_TEMPLATES_PATH.'espresso_venues_feed.template.php', |
|
206 | 206 | $template_args, |
207 | 207 | true |
208 | 208 | ); |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | */ |
171 | 171 | public function venue_location($content) |
172 | 172 | { |
173 | - return $content . EEH_Template::locate_template('content-espresso_venues-location.php'); |
|
173 | + return $content.EEH_Template::locate_template('content-espresso_venues-location.php'); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | |
@@ -185,16 +185,16 @@ discard block |
||
185 | 185 | // get some style |
186 | 186 | if (apply_filters('FHEE_enable_default_espresso_css', true) && is_archive()) { |
187 | 187 | // first check theme folder |
188 | - if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) { |
|
188 | + if (is_readable(get_stylesheet_directory().$this->theme.'/style.css')) { |
|
189 | 189 | wp_register_style( |
190 | 190 | $this->theme, |
191 | - get_stylesheet_directory_uri() . $this->theme . '/style.css', |
|
191 | + get_stylesheet_directory_uri().$this->theme.'/style.css', |
|
192 | 192 | array('dashicons', 'espresso_default') |
193 | 193 | ); |
194 | - } elseif (is_readable(EE_TEMPLATES . $this->theme . '/style.css')) { |
|
194 | + } elseif (is_readable(EE_TEMPLATES.$this->theme.'/style.css')) { |
|
195 | 195 | wp_register_style( |
196 | 196 | $this->theme, |
197 | - EE_TEMPLATES_URL . $this->theme . '/style.css', |
|
197 | + EE_TEMPLATES_URL.$this->theme.'/style.css', |
|
198 | 198 | array('dashicons', 'espresso_default') |
199 | 199 | ); |
200 | 200 | } |
@@ -29,178 +29,178 @@ |
||
29 | 29 | class EED_Venues_Archive extends EED_Module |
30 | 30 | { |
31 | 31 | |
32 | - /** |
|
33 | - * @return EED_Venues_Archive |
|
34 | - */ |
|
35 | - public static function instance() |
|
36 | - { |
|
37 | - return parent::get_instance(__CLASS__); |
|
38 | - } |
|
39 | - |
|
40 | - |
|
41 | - /** |
|
42 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
43 | - * |
|
44 | - * @return void |
|
45 | - * @throws InvalidArgumentException |
|
46 | - * @throws InvalidDataTypeException |
|
47 | - * @throws InvalidInterfaceException |
|
48 | - */ |
|
49 | - public static function set_hooks() |
|
50 | - { |
|
51 | - /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */ |
|
52 | - $custom_post_type_definitions = LoaderFactory::getLoader()->getShared( |
|
53 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
54 | - ); |
|
55 | - $custom_post_types = $custom_post_type_definitions->getDefinitions(); |
|
56 | - EE_Config::register_route( |
|
57 | - $custom_post_types['espresso_venues']['plural_slug'], |
|
58 | - 'Venues_Archive', |
|
59 | - 'run' |
|
60 | - ); |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
65 | - * |
|
66 | - * @access public |
|
67 | - * @return void |
|
68 | - */ |
|
69 | - public static function set_hooks_admin() |
|
70 | - { |
|
71 | - } |
|
72 | - |
|
73 | - |
|
74 | - /** |
|
75 | - * run - initial module setup |
|
76 | - * |
|
77 | - * @access public |
|
78 | - * @param \WP $WP |
|
79 | - */ |
|
80 | - public function run($WP) |
|
81 | - { |
|
82 | - // check what template is loaded |
|
83 | - add_filter('template_include', array($this, 'template_include'), 999, 1); |
|
84 | - add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10); |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - /** |
|
89 | - * template_include |
|
90 | - * |
|
91 | - * @access public |
|
92 | - * @param string $template |
|
93 | - * @return string |
|
94 | - */ |
|
95 | - public function template_include($template) |
|
96 | - { |
|
97 | - // not a custom template? |
|
98 | - if ( |
|
99 | - EE_Registry::instance()->load_core('Front_Controller', array(), false, true) |
|
100 | - ->get_selected_template() != 'archive-espresso_venues.php' |
|
101 | - ) { |
|
102 | - EEH_Template::load_espresso_theme_functions(); |
|
103 | - // then add extra event data via hooks |
|
104 | - add_filter('the_title', array($this, 'the_title'), 100, 1); |
|
105 | - // don't know if theme uses the_excerpt |
|
106 | - add_filter('the_excerpt', array($this, 'venue_details'), 100); |
|
107 | - // or the_content |
|
108 | - add_filter('the_content', array($this, 'venue_details'), 100); |
|
109 | - // don't display entry meta because the existing theme will take care of that |
|
110 | - add_filter('FHEE__content_espresso_venues_details_template__display_entry_meta', '__return_false'); |
|
111 | - } |
|
112 | - return $template; |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - /** |
|
117 | - * the_title |
|
118 | - * |
|
119 | - * @access public |
|
120 | - * @param string $title |
|
121 | - * @return string |
|
122 | - */ |
|
123 | - public function the_title($title = '') |
|
124 | - { |
|
125 | - return $title; |
|
126 | - } |
|
127 | - |
|
128 | - |
|
129 | - /** |
|
130 | - * venue_details |
|
131 | - * |
|
132 | - * @access public |
|
133 | - * @param string $content |
|
134 | - * @return string |
|
135 | - */ |
|
136 | - public function venue_details($content) |
|
137 | - { |
|
138 | - global $post; |
|
139 | - if ( |
|
140 | - $post->post_type == 'espresso_venues' |
|
141 | - && ! post_password_required() |
|
142 | - ) { |
|
143 | - // since the 'content-espresso_venues-details.php' template might be used directly from within a theme, |
|
144 | - // it uses the_content() for displaying the $post->post_content |
|
145 | - // so in order to load a template that uses the_content() from within a callback being used to filter the_content(), |
|
146 | - // we need to first remove this callback from being applied to the_content() (otherwise it will recurse and blow up the interweb) |
|
147 | - remove_filter('the_excerpt', array($this, 'venue_details'), 100); |
|
148 | - remove_filter('the_content', array($this, 'venue_details'), 100); |
|
149 | - // add filters we want |
|
150 | - add_filter('the_content', array($this, 'venue_location'), 110); |
|
151 | - add_filter('the_excerpt', array($this, 'venue_location'), 110); |
|
152 | - // now load our template |
|
153 | - $template = EEH_Template::locate_template('content-espresso_venues-details.php'); |
|
154 | - // now add our filter back in, plus some others |
|
155 | - add_filter('the_excerpt', array($this, 'venue_details'), 100); |
|
156 | - add_filter('the_content', array($this, 'venue_details'), 100); |
|
157 | - // remove other filters we added so they won't get applied to the next post |
|
158 | - remove_filter('the_content', array($this, 'venue_location'), 110); |
|
159 | - remove_filter('the_excerpt', array($this, 'venue_location'), 110); |
|
160 | - // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
|
161 | - } |
|
162 | - return ! empty($template) ? $template : $content; |
|
163 | - } |
|
164 | - |
|
165 | - |
|
166 | - /** |
|
167 | - * venue_location |
|
168 | - * |
|
169 | - * @access public |
|
170 | - * @param string $content |
|
171 | - * @return string |
|
172 | - */ |
|
173 | - public function venue_location($content) |
|
174 | - { |
|
175 | - return $content . EEH_Template::locate_template('content-espresso_venues-location.php'); |
|
176 | - } |
|
177 | - |
|
178 | - |
|
179 | - /** |
|
180 | - * wp_enqueue_scripts |
|
181 | - * |
|
182 | - * @access public |
|
183 | - * @return void |
|
184 | - */ |
|
185 | - public function wp_enqueue_scripts() |
|
186 | - { |
|
187 | - // get some style |
|
188 | - if (apply_filters('FHEE_enable_default_espresso_css', true) && is_archive()) { |
|
189 | - // first check theme folder |
|
190 | - if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) { |
|
191 | - wp_register_style( |
|
192 | - $this->theme, |
|
193 | - get_stylesheet_directory_uri() . $this->theme . '/style.css', |
|
194 | - array('dashicons', 'espresso_default') |
|
195 | - ); |
|
196 | - } elseif (is_readable(EE_TEMPLATES . $this->theme . '/style.css')) { |
|
197 | - wp_register_style( |
|
198 | - $this->theme, |
|
199 | - EE_TEMPLATES_URL . $this->theme . '/style.css', |
|
200 | - array('dashicons', 'espresso_default') |
|
201 | - ); |
|
202 | - } |
|
203 | - wp_enqueue_style($this->theme); |
|
204 | - } |
|
205 | - } |
|
32 | + /** |
|
33 | + * @return EED_Venues_Archive |
|
34 | + */ |
|
35 | + public static function instance() |
|
36 | + { |
|
37 | + return parent::get_instance(__CLASS__); |
|
38 | + } |
|
39 | + |
|
40 | + |
|
41 | + /** |
|
42 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
43 | + * |
|
44 | + * @return void |
|
45 | + * @throws InvalidArgumentException |
|
46 | + * @throws InvalidDataTypeException |
|
47 | + * @throws InvalidInterfaceException |
|
48 | + */ |
|
49 | + public static function set_hooks() |
|
50 | + { |
|
51 | + /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */ |
|
52 | + $custom_post_type_definitions = LoaderFactory::getLoader()->getShared( |
|
53 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
54 | + ); |
|
55 | + $custom_post_types = $custom_post_type_definitions->getDefinitions(); |
|
56 | + EE_Config::register_route( |
|
57 | + $custom_post_types['espresso_venues']['plural_slug'], |
|
58 | + 'Venues_Archive', |
|
59 | + 'run' |
|
60 | + ); |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
65 | + * |
|
66 | + * @access public |
|
67 | + * @return void |
|
68 | + */ |
|
69 | + public static function set_hooks_admin() |
|
70 | + { |
|
71 | + } |
|
72 | + |
|
73 | + |
|
74 | + /** |
|
75 | + * run - initial module setup |
|
76 | + * |
|
77 | + * @access public |
|
78 | + * @param \WP $WP |
|
79 | + */ |
|
80 | + public function run($WP) |
|
81 | + { |
|
82 | + // check what template is loaded |
|
83 | + add_filter('template_include', array($this, 'template_include'), 999, 1); |
|
84 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10); |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + /** |
|
89 | + * template_include |
|
90 | + * |
|
91 | + * @access public |
|
92 | + * @param string $template |
|
93 | + * @return string |
|
94 | + */ |
|
95 | + public function template_include($template) |
|
96 | + { |
|
97 | + // not a custom template? |
|
98 | + if ( |
|
99 | + EE_Registry::instance()->load_core('Front_Controller', array(), false, true) |
|
100 | + ->get_selected_template() != 'archive-espresso_venues.php' |
|
101 | + ) { |
|
102 | + EEH_Template::load_espresso_theme_functions(); |
|
103 | + // then add extra event data via hooks |
|
104 | + add_filter('the_title', array($this, 'the_title'), 100, 1); |
|
105 | + // don't know if theme uses the_excerpt |
|
106 | + add_filter('the_excerpt', array($this, 'venue_details'), 100); |
|
107 | + // or the_content |
|
108 | + add_filter('the_content', array($this, 'venue_details'), 100); |
|
109 | + // don't display entry meta because the existing theme will take care of that |
|
110 | + add_filter('FHEE__content_espresso_venues_details_template__display_entry_meta', '__return_false'); |
|
111 | + } |
|
112 | + return $template; |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + /** |
|
117 | + * the_title |
|
118 | + * |
|
119 | + * @access public |
|
120 | + * @param string $title |
|
121 | + * @return string |
|
122 | + */ |
|
123 | + public function the_title($title = '') |
|
124 | + { |
|
125 | + return $title; |
|
126 | + } |
|
127 | + |
|
128 | + |
|
129 | + /** |
|
130 | + * venue_details |
|
131 | + * |
|
132 | + * @access public |
|
133 | + * @param string $content |
|
134 | + * @return string |
|
135 | + */ |
|
136 | + public function venue_details($content) |
|
137 | + { |
|
138 | + global $post; |
|
139 | + if ( |
|
140 | + $post->post_type == 'espresso_venues' |
|
141 | + && ! post_password_required() |
|
142 | + ) { |
|
143 | + // since the 'content-espresso_venues-details.php' template might be used directly from within a theme, |
|
144 | + // it uses the_content() for displaying the $post->post_content |
|
145 | + // so in order to load a template that uses the_content() from within a callback being used to filter the_content(), |
|
146 | + // we need to first remove this callback from being applied to the_content() (otherwise it will recurse and blow up the interweb) |
|
147 | + remove_filter('the_excerpt', array($this, 'venue_details'), 100); |
|
148 | + remove_filter('the_content', array($this, 'venue_details'), 100); |
|
149 | + // add filters we want |
|
150 | + add_filter('the_content', array($this, 'venue_location'), 110); |
|
151 | + add_filter('the_excerpt', array($this, 'venue_location'), 110); |
|
152 | + // now load our template |
|
153 | + $template = EEH_Template::locate_template('content-espresso_venues-details.php'); |
|
154 | + // now add our filter back in, plus some others |
|
155 | + add_filter('the_excerpt', array($this, 'venue_details'), 100); |
|
156 | + add_filter('the_content', array($this, 'venue_details'), 100); |
|
157 | + // remove other filters we added so they won't get applied to the next post |
|
158 | + remove_filter('the_content', array($this, 'venue_location'), 110); |
|
159 | + remove_filter('the_excerpt', array($this, 'venue_location'), 110); |
|
160 | + // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
|
161 | + } |
|
162 | + return ! empty($template) ? $template : $content; |
|
163 | + } |
|
164 | + |
|
165 | + |
|
166 | + /** |
|
167 | + * venue_location |
|
168 | + * |
|
169 | + * @access public |
|
170 | + * @param string $content |
|
171 | + * @return string |
|
172 | + */ |
|
173 | + public function venue_location($content) |
|
174 | + { |
|
175 | + return $content . EEH_Template::locate_template('content-espresso_venues-location.php'); |
|
176 | + } |
|
177 | + |
|
178 | + |
|
179 | + /** |
|
180 | + * wp_enqueue_scripts |
|
181 | + * |
|
182 | + * @access public |
|
183 | + * @return void |
|
184 | + */ |
|
185 | + public function wp_enqueue_scripts() |
|
186 | + { |
|
187 | + // get some style |
|
188 | + if (apply_filters('FHEE_enable_default_espresso_css', true) && is_archive()) { |
|
189 | + // first check theme folder |
|
190 | + if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) { |
|
191 | + wp_register_style( |
|
192 | + $this->theme, |
|
193 | + get_stylesheet_directory_uri() . $this->theme . '/style.css', |
|
194 | + array('dashicons', 'espresso_default') |
|
195 | + ); |
|
196 | + } elseif (is_readable(EE_TEMPLATES . $this->theme . '/style.css')) { |
|
197 | + wp_register_style( |
|
198 | + $this->theme, |
|
199 | + EE_TEMPLATES_URL . $this->theme . '/style.css', |
|
200 | + array('dashicons', 'espresso_default') |
|
201 | + ); |
|
202 | + } |
|
203 | + wp_enqueue_style($this->theme); |
|
204 | + } |
|
205 | + } |
|
206 | 206 | } |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | $this->_gateway->set_unsupported_character_remover(new AsciiOnly()); |
118 | 118 | do_action('AHEE__EE_PMT_Base___construct__done_initializing_gateway_class', $this, $this->_gateway); |
119 | 119 | } |
120 | - if (! isset($this->_has_billing_form)) { |
|
120 | + if ( ! isset($this->_has_billing_form)) { |
|
121 | 121 | // by default, On Site gateways have a billing form |
122 | 122 | if ($this->payment_occurs() == EE_PMT_Base::onsite) { |
123 | 123 | $this->set_has_billing_form(true); |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | } |
127 | 127 | } |
128 | 128 | |
129 | - if (! $this->_pretty_name) { |
|
129 | + if ( ! $this->_pretty_name) { |
|
130 | 130 | throw new EE_Error( |
131 | 131 | sprintf( |
132 | 132 | __( |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | } |
139 | 139 | // if the child didn't specify a default button, use the credit card one |
140 | 140 | if ($this->_default_button_url === null) { |
141 | - $this->_default_button_url = EE_PLUGIN_DIR_URL . 'payment_methods/pay-by-credit-card.png'; |
|
141 | + $this->_default_button_url = EE_PLUGIN_DIR_URL.'payment_methods/pay-by-credit-card.png'; |
|
142 | 142 | } |
143 | 143 | } |
144 | 144 | |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | { |
160 | 160 | $reflector = new ReflectionClass(get_class($this)); |
161 | 161 | $fn = $reflector->getFileName(); |
162 | - $this->_file_folder = dirname($fn) . '/'; |
|
162 | + $this->_file_folder = dirname($fn).'/'; |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | */ |
193 | 193 | public function file_folder() |
194 | 194 | { |
195 | - if (! $this->_file_folder) { |
|
195 | + if ( ! $this->_file_folder) { |
|
196 | 196 | $this->_set_file_folder(); |
197 | 197 | } |
198 | 198 | return $this->_file_folder; |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | */ |
205 | 205 | public function file_url() |
206 | 206 | { |
207 | - if (! $this->_file_url) { |
|
207 | + if ( ! $this->_file_url) { |
|
208 | 208 | $this->_set_file_url(); |
209 | 209 | } |
210 | 210 | return $this->_file_url; |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | */ |
239 | 239 | public function settings_form() |
240 | 240 | { |
241 | - if (! $this->_settings_form) { |
|
241 | + if ( ! $this->_settings_form) { |
|
242 | 242 | $this->_settings_form = $this->generate_new_settings_form(); |
243 | 243 | $this->_settings_form->set_payment_method_type($this); |
244 | 244 | // if we have already assigned a model object to this pmt, make |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | public function billing_form(EE_Transaction $transaction = null, $extra_args = array()) |
293 | 293 | { |
294 | 294 | // has billing form already been regenerated ? or overwrite cache? |
295 | - if (! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form) { |
|
295 | + if ( ! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form) { |
|
296 | 296 | $this->_billing_form = $this->generate_new_billing_form($transaction, $extra_args); |
297 | 297 | } |
298 | 298 | // if we know who the attendee is, and this is a billing form |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | $payment = EEM_Payment::instance()->get_one(array($duplicate_properties)); |
395 | 395 | // if we didn't already have a payment in progress for the same thing, |
396 | 396 | // then we actually want to make a new payment |
397 | - if (! $payment instanceof EE_Payment) { |
|
397 | + if ( ! $payment instanceof EE_Payment) { |
|
398 | 398 | $payment = EE_Payment::new_instance( |
399 | 399 | array_merge( |
400 | 400 | $duplicate_properties, |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | public function handle_ipn($req_data, $transaction) |
496 | 496 | { |
497 | 497 | $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
498 | - if (! $this->_gateway instanceof EE_Offsite_Gateway) { |
|
498 | + if ( ! $this->_gateway instanceof EE_Offsite_Gateway) { |
|
499 | 499 | throw new EE_Error( |
500 | 500 | sprintf( |
501 | 501 | __("Could not handle IPN because '%s' is not an offsite gateway", "event_espresso"), |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | */ |
519 | 519 | protected function _save_billing_info_to_attendee($billing_form, $transaction) |
520 | 520 | { |
521 | - if (! $transaction || ! $transaction instanceof EE_Transaction) { |
|
521 | + if ( ! $transaction || ! $transaction instanceof EE_Transaction) { |
|
522 | 522 | EE_Error::add_error( |
523 | 523 | __("Cannot save billing info because no transaction was specified", "event_espresso"), |
524 | 524 | __FILE__, |
@@ -528,7 +528,7 @@ discard block |
||
528 | 528 | return false; |
529 | 529 | } |
530 | 530 | $primary_reg = $transaction->primary_registration(); |
531 | - if (! $primary_reg) { |
|
531 | + if ( ! $primary_reg) { |
|
532 | 532 | EE_Error::add_error( |
533 | 533 | __("Cannot save billing info because the transaction has no primary registration", "event_espresso"), |
534 | 534 | __FILE__, |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | return false; |
539 | 539 | } |
540 | 540 | $attendee = $primary_reg->attendee(); |
541 | - if (! $attendee) { |
|
541 | + if ( ! $attendee) { |
|
542 | 542 | EE_Error::add_error( |
543 | 543 | __( |
544 | 544 | "Cannot save billing info because the transaction's primary registration has no attendee!", |
@@ -651,7 +651,7 @@ discard block |
||
651 | 651 | */ |
652 | 652 | public function payment_occurs() |
653 | 653 | { |
654 | - if (! $this->_gateway) { |
|
654 | + if ( ! $this->_gateway) { |
|
655 | 655 | return EE_PMT_Base::offline; |
656 | 656 | } elseif ($this->_gateway instanceof EE_Onsite_Gateway) { |
657 | 657 | return EE_PMT_Base::onsite; |
@@ -682,7 +682,7 @@ discard block |
||
682 | 682 | public function payment_overview_content(EE_Payment $payment) |
683 | 683 | { |
684 | 684 | return EEH_Template::display_template( |
685 | - EE_LIBRARIES . 'payment_methods/templates/payment_details_content.template.php', |
|
685 | + EE_LIBRARIES.'payment_methods/templates/payment_details_content.template.php', |
|
686 | 686 | array('payment_method' => $this->_pm_instance, 'payment' => $payment), |
687 | 687 | true |
688 | 688 | ); |
@@ -780,7 +780,7 @@ discard block |
||
780 | 780 | */ |
781 | 781 | public function get_help_tab_name() |
782 | 782 | { |
783 | - return 'ee_' . strtolower($this->system_name()) . '_help_tab'; |
|
783 | + return 'ee_'.strtolower($this->system_name()).'_help_tab'; |
|
784 | 784 | } |
785 | 785 | |
786 | 786 | /** |
@@ -791,7 +791,7 @@ discard block |
||
791 | 791 | */ |
792 | 792 | public function cap_name() |
793 | 793 | { |
794 | - return 'ee_payment_method_' . strtolower($this->system_name()); |
|
794 | + return 'ee_payment_method_'.strtolower($this->system_name()); |
|
795 | 795 | } |
796 | 796 | |
797 | 797 | /** |
@@ -825,7 +825,7 @@ discard block |
||
825 | 825 | public function introductory_html() |
826 | 826 | { |
827 | 827 | return EEH_Template::locate_template( |
828 | - $this->file_folder() . 'templates/' . strtolower($this->system_name()) . '_intro.template.php', |
|
828 | + $this->file_folder().'templates/'.strtolower($this->system_name()).'_intro.template.php', |
|
829 | 829 | array('pmt_obj' => $this, 'pm_instance' => $this->_pm_instance) |
830 | 830 | ); |
831 | 831 | } |
@@ -22,814 +22,814 @@ |
||
22 | 22 | abstract class EE_PMT_Base |
23 | 23 | { |
24 | 24 | |
25 | - const onsite = 'on-site'; |
|
26 | - const offsite = 'off-site'; |
|
27 | - const offline = 'off-line'; |
|
28 | - |
|
29 | - /** |
|
30 | - * @var EE_Payment_Method |
|
31 | - */ |
|
32 | - protected $_pm_instance = null; |
|
33 | - |
|
34 | - /** |
|
35 | - * @var boolean |
|
36 | - */ |
|
37 | - protected $_requires_https = false; |
|
38 | - |
|
39 | - /** |
|
40 | - * @var boolean |
|
41 | - */ |
|
42 | - protected $_has_billing_form; |
|
43 | - |
|
44 | - /** |
|
45 | - * @var EE_Gateway |
|
46 | - */ |
|
47 | - protected $_gateway = null; |
|
48 | - |
|
49 | - /** |
|
50 | - * @var EE_Payment_Method_Form |
|
51 | - */ |
|
52 | - protected $_settings_form = null; |
|
53 | - |
|
54 | - /** |
|
55 | - * @var EE_Form_Section_Proper |
|
56 | - */ |
|
57 | - protected $_billing_form = null; |
|
58 | - |
|
59 | - /** |
|
60 | - * @var boolean |
|
61 | - */ |
|
62 | - protected $_cache_billing_form = true; |
|
63 | - |
|
64 | - /** |
|
65 | - * String of the absolute path to the folder containing this file, with a trailing slash. |
|
66 | - * eg '/public_html/wp-site/wp-content/plugins/event-espresso/payment_methods/Invoice/' |
|
67 | - * |
|
68 | - * @var string |
|
69 | - */ |
|
70 | - protected $_file_folder = null; |
|
71 | - |
|
72 | - /** |
|
73 | - * String to the absolute URL to this file (useful for getting its web-accessible resources |
|
74 | - * like images, js, or css) |
|
75 | - * |
|
76 | - * @var string |
|
77 | - */ |
|
78 | - protected $_file_url = null; |
|
79 | - |
|
80 | - /** |
|
81 | - * Pretty name for the payment method |
|
82 | - * |
|
83 | - * @var string |
|
84 | - */ |
|
85 | - protected $_pretty_name = null; |
|
86 | - |
|
87 | - /** |
|
88 | - * |
|
89 | - * @var string |
|
90 | - */ |
|
91 | - protected $_default_button_url = null; |
|
92 | - |
|
93 | - /** |
|
94 | - * |
|
95 | - * @var string |
|
96 | - */ |
|
97 | - protected $_default_description = null; |
|
98 | - |
|
99 | - |
|
100 | - /** |
|
101 | - * |
|
102 | - * @param EE_Payment_Method $pm_instance |
|
103 | - * @throws EE_Error |
|
104 | - * @return EE_PMT_Base |
|
105 | - */ |
|
106 | - public function __construct($pm_instance = null) |
|
107 | - { |
|
108 | - if ($pm_instance instanceof EE_Payment_Method) { |
|
109 | - $this->set_instance($pm_instance); |
|
110 | - } |
|
111 | - if ($this->_gateway) { |
|
112 | - $this->_gateway->set_payment_model(EEM_Payment::instance()); |
|
113 | - $this->_gateway->set_payment_log(EEM_Change_Log::instance()); |
|
114 | - $this->_gateway->set_template_helper(new EEH_Template()); |
|
115 | - $this->_gateway->set_line_item_helper(new EEH_Line_Item()); |
|
116 | - $this->_gateway->set_money_helper(new EEH_Money()); |
|
117 | - $this->_gateway->set_gateway_data_formatter(new GatewayDataFormatter()); |
|
118 | - $this->_gateway->set_unsupported_character_remover(new AsciiOnly()); |
|
119 | - do_action('AHEE__EE_PMT_Base___construct__done_initializing_gateway_class', $this, $this->_gateway); |
|
120 | - } |
|
121 | - if (! isset($this->_has_billing_form)) { |
|
122 | - // by default, On Site gateways have a billing form |
|
123 | - if ($this->payment_occurs() == EE_PMT_Base::onsite) { |
|
124 | - $this->set_has_billing_form(true); |
|
125 | - } else { |
|
126 | - $this->set_has_billing_form(false); |
|
127 | - } |
|
128 | - } |
|
129 | - |
|
130 | - if (! $this->_pretty_name) { |
|
131 | - throw new EE_Error( |
|
132 | - sprintf( |
|
133 | - __( |
|
134 | - "You must set the pretty name for the Payment Method Type in the constructor (_pretty_name), and please make it internationalized", |
|
135 | - "event_espresso" |
|
136 | - ) |
|
137 | - ) |
|
138 | - ); |
|
139 | - } |
|
140 | - // if the child didn't specify a default button, use the credit card one |
|
141 | - if ($this->_default_button_url === null) { |
|
142 | - $this->_default_button_url = EE_PLUGIN_DIR_URL . 'payment_methods/pay-by-credit-card.png'; |
|
143 | - } |
|
144 | - } |
|
145 | - |
|
146 | - |
|
147 | - /** |
|
148 | - * @param boolean $has_billing_form |
|
149 | - */ |
|
150 | - public function set_has_billing_form($has_billing_form) |
|
151 | - { |
|
152 | - $this->_has_billing_form = filter_var($has_billing_form, FILTER_VALIDATE_BOOLEAN); |
|
153 | - } |
|
154 | - |
|
155 | - |
|
156 | - /** |
|
157 | - * sets the file_folder property |
|
158 | - */ |
|
159 | - protected function _set_file_folder() |
|
160 | - { |
|
161 | - $reflector = new ReflectionClass(get_class($this)); |
|
162 | - $fn = $reflector->getFileName(); |
|
163 | - $this->_file_folder = dirname($fn) . '/'; |
|
164 | - } |
|
165 | - |
|
166 | - |
|
167 | - /** |
|
168 | - * sets the file URL with a trailing slash for this PMT |
|
169 | - */ |
|
170 | - protected function _set_file_url() |
|
171 | - { |
|
172 | - $plugins_dir_fixed = str_replace('\\', '/', WP_PLUGIN_DIR); |
|
173 | - $file_folder_fixed = str_replace('\\', '/', $this->file_folder()); |
|
174 | - $file_path = str_replace($plugins_dir_fixed, WP_PLUGIN_URL, $file_folder_fixed); |
|
175 | - $this->_file_url = set_url_scheme($file_path); |
|
176 | - } |
|
177 | - |
|
178 | - /** |
|
179 | - * Gets the default description on all payment methods of this type |
|
180 | - * |
|
181 | - * @return string |
|
182 | - */ |
|
183 | - public function default_description() |
|
184 | - { |
|
185 | - return $this->_default_description; |
|
186 | - } |
|
187 | - |
|
188 | - |
|
189 | - /** |
|
190 | - * Returns the folder containing the PMT child class, with a trailing slash |
|
191 | - * |
|
192 | - * @return string |
|
193 | - */ |
|
194 | - public function file_folder() |
|
195 | - { |
|
196 | - if (! $this->_file_folder) { |
|
197 | - $this->_set_file_folder(); |
|
198 | - } |
|
199 | - return $this->_file_folder; |
|
200 | - } |
|
201 | - |
|
202 | - |
|
203 | - /** |
|
204 | - * @return string |
|
205 | - */ |
|
206 | - public function file_url() |
|
207 | - { |
|
208 | - if (! $this->_file_url) { |
|
209 | - $this->_set_file_url(); |
|
210 | - } |
|
211 | - return $this->_file_url; |
|
212 | - } |
|
213 | - |
|
214 | - |
|
215 | - /** |
|
216 | - * Sets the payment method instance this payment method type is for. |
|
217 | - * Its important teh payment method instance is set before |
|
218 | - * |
|
219 | - * @param EE_Payment_Method $payment_method_instance |
|
220 | - */ |
|
221 | - public function set_instance($payment_method_instance) |
|
222 | - { |
|
223 | - $this->_pm_instance = $payment_method_instance; |
|
224 | - // if they have already requested the settings form, make sure its |
|
225 | - // data matches this model object |
|
226 | - if ($this->_settings_form) { |
|
227 | - $this->settings_form()->populate_model_obj($payment_method_instance); |
|
228 | - } |
|
229 | - if ($this->_gateway && $this->_gateway instanceof EE_Gateway) { |
|
230 | - $this->_gateway->set_settings($payment_method_instance->settings_array()); |
|
231 | - } |
|
232 | - } |
|
233 | - |
|
234 | - |
|
235 | - /** |
|
236 | - * Gets teh form for displaying to admins where they setup the payment method |
|
237 | - * |
|
238 | - * @return EE_Payment_Method_Form |
|
239 | - */ |
|
240 | - public function settings_form() |
|
241 | - { |
|
242 | - if (! $this->_settings_form) { |
|
243 | - $this->_settings_form = $this->generate_new_settings_form(); |
|
244 | - $this->_settings_form->set_payment_method_type($this); |
|
245 | - // if we have already assigned a model object to this pmt, make |
|
246 | - // sure its reflected in teh form we just generated |
|
247 | - if ($this->_pm_instance) { |
|
248 | - $this->_settings_form->populate_model_obj($this->_pm_instance); |
|
249 | - } |
|
250 | - } |
|
251 | - return $this->_settings_form; |
|
252 | - } |
|
253 | - |
|
254 | - |
|
255 | - /** |
|
256 | - * Gets the form for all the settings related to this payment method type |
|
257 | - * |
|
258 | - * @return EE_Payment_Method_Form |
|
259 | - */ |
|
260 | - abstract public function generate_new_settings_form(); |
|
261 | - |
|
262 | - |
|
263 | - /** |
|
264 | - * Sets the form for settings. This may be useful if we have already received |
|
265 | - * a form submission and have form data it in, and want to use it anytime we're showing |
|
266 | - * this payment method type's settings form later in the request |
|
267 | - * |
|
268 | - * @param EE_Payment_Method_Form $form |
|
269 | - */ |
|
270 | - public function set_settings_form($form) |
|
271 | - { |
|
272 | - $this->_settings_form = $form; |
|
273 | - } |
|
274 | - |
|
275 | - |
|
276 | - /** |
|
277 | - * @return boolean |
|
278 | - */ |
|
279 | - public function has_billing_form() |
|
280 | - { |
|
281 | - return $this->_has_billing_form; |
|
282 | - } |
|
283 | - |
|
284 | - |
|
285 | - /** |
|
286 | - * Gets the form for displaying to attendees where they can enter their billing info |
|
287 | - * which will be sent to teh gateway (can be null) |
|
288 | - * |
|
289 | - * @param \EE_Transaction $transaction |
|
290 | - * @param array $extra_args |
|
291 | - * @return \EE_Billing_Attendee_Info_Form|\EE_Billing_Info_Form|null |
|
292 | - */ |
|
293 | - public function billing_form(EE_Transaction $transaction = null, $extra_args = array()) |
|
294 | - { |
|
295 | - // has billing form already been regenerated ? or overwrite cache? |
|
296 | - if (! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form) { |
|
297 | - $this->_billing_form = $this->generate_new_billing_form($transaction, $extra_args); |
|
298 | - } |
|
299 | - // if we know who the attendee is, and this is a billing form |
|
300 | - // that uses attendee info, populate it |
|
301 | - if ( |
|
302 | - apply_filters( |
|
303 | - 'FHEE__populate_billing_form_fields_from_attendee', |
|
304 | - ($this->_billing_form instanceof EE_Billing_Attendee_Info_Form |
|
305 | - && $transaction instanceof EE_Transaction |
|
306 | - && $transaction->primary_registration() instanceof EE_Registration |
|
307 | - && $transaction->primary_registration()->attendee() instanceof EE_Attendee |
|
308 | - ), |
|
309 | - $this->_billing_form, |
|
310 | - $transaction |
|
311 | - ) |
|
312 | - ) { |
|
313 | - $this->_billing_form->populate_from_attendee($transaction->primary_registration()->attendee()); |
|
314 | - } |
|
315 | - return $this->_billing_form; |
|
316 | - } |
|
317 | - |
|
318 | - |
|
319 | - /** |
|
320 | - * Creates the billing form for this payment method type |
|
321 | - * |
|
322 | - * @param \EE_Transaction $transaction |
|
323 | - * @return \EE_Billing_Info_Form |
|
324 | - */ |
|
325 | - abstract public function generate_new_billing_form(EE_Transaction $transaction = null); |
|
326 | - |
|
327 | - |
|
328 | - /** |
|
329 | - * apply_billing_form_debug_settings |
|
330 | - * applies debug data to the form |
|
331 | - * |
|
332 | - * @param \EE_Billing_Info_Form $billing_form |
|
333 | - * @return \EE_Billing_Info_Form |
|
334 | - */ |
|
335 | - public function apply_billing_form_debug_settings(EE_Billing_Info_Form $billing_form) |
|
336 | - { |
|
337 | - return $billing_form; |
|
338 | - } |
|
339 | - |
|
340 | - |
|
341 | - /** |
|
342 | - * Sets the billing form for this payment method type. You may want to use this |
|
343 | - * if you have form |
|
344 | - * |
|
345 | - * @param EE_Payment_Method $form |
|
346 | - */ |
|
347 | - public function set_billing_form($form) |
|
348 | - { |
|
349 | - $this->_billing_form = $form; |
|
350 | - } |
|
351 | - |
|
352 | - |
|
353 | - /** |
|
354 | - * Returns whether or not this payment method requires HTTPS to be used |
|
355 | - * |
|
356 | - * @return boolean |
|
357 | - */ |
|
358 | - public function requires_https() |
|
359 | - { |
|
360 | - return $this->_requires_https; |
|
361 | - } |
|
362 | - |
|
363 | - |
|
364 | - /** |
|
365 | - * |
|
366 | - * @param EE_Transaction $transaction |
|
367 | - * @param float $amount |
|
368 | - * @param EE_Billing_Info_Form $billing_info |
|
369 | - * @param string $return_url |
|
370 | - * @param string $fail_url |
|
371 | - * @param string $method |
|
372 | - * @param bool $by_admin |
|
373 | - * @return EE_Payment |
|
374 | - * @throws EE_Error |
|
375 | - */ |
|
376 | - public function process_payment( |
|
377 | - EE_Transaction $transaction, |
|
378 | - $amount = null, |
|
379 | - $billing_info = null, |
|
380 | - $return_url = null, |
|
381 | - $fail_url = '', |
|
382 | - $method = 'CART', |
|
383 | - $by_admin = false |
|
384 | - ) { |
|
385 | - // @todo: add surcharge for the payment method, if any |
|
386 | - if ($this->_gateway) { |
|
387 | - // there is a gateway, so we're going to make a payment object |
|
388 | - // but wait! do they already have a payment in progress that we thought was failed? |
|
389 | - $duplicate_properties = array( |
|
390 | - 'STS_ID' => EEM_Payment::status_id_failed, |
|
391 | - 'TXN_ID' => $transaction->ID(), |
|
392 | - 'PMD_ID' => $this->_pm_instance->ID(), |
|
393 | - 'PAY_source' => $method, |
|
394 | - 'PAY_amount' => $amount !== null ? $amount : $transaction->remaining(), |
|
395 | - 'PAY_gateway_response' => null, |
|
396 | - ); |
|
397 | - $payment = EEM_Payment::instance()->get_one(array($duplicate_properties)); |
|
398 | - // if we didn't already have a payment in progress for the same thing, |
|
399 | - // then we actually want to make a new payment |
|
400 | - if (! $payment instanceof EE_Payment) { |
|
401 | - $payment = EE_Payment::new_instance( |
|
402 | - array_merge( |
|
403 | - $duplicate_properties, |
|
404 | - array( |
|
405 | - 'PAY_timestamp' => time(), |
|
406 | - 'PAY_txn_id_chq_nmbr' => null, |
|
407 | - 'PAY_po_number' => null, |
|
408 | - 'PAY_extra_accntng' => null, |
|
409 | - 'PAY_details' => null, |
|
410 | - ) |
|
411 | - ) |
|
412 | - ); |
|
413 | - } |
|
414 | - // make sure the payment has been saved to show we started it, and so it has an ID should the gateway try to log it |
|
415 | - $payment->save(); |
|
416 | - $billing_values = $this->_get_billing_values_from_form($billing_info); |
|
417 | - |
|
418 | - // Offsite Gateway |
|
419 | - if ($this->_gateway instanceof EE_Offsite_Gateway) { |
|
420 | - $payment = $this->_gateway->set_redirection_info( |
|
421 | - $payment, |
|
422 | - $billing_values, |
|
423 | - $return_url, |
|
424 | - EE_Config::instance()->core->txn_page_url( |
|
425 | - array( |
|
426 | - 'e_reg_url_link' => $transaction->primary_registration()->reg_url_link(), |
|
427 | - 'ee_payment_method' => $this->_pm_instance->slug(), |
|
428 | - ) |
|
429 | - ), |
|
430 | - $fail_url |
|
431 | - ); |
|
432 | - $payment->save(); |
|
433 | - // Onsite Gateway |
|
434 | - } elseif ($this->_gateway instanceof EE_Onsite_Gateway) { |
|
435 | - $payment = $this->_gateway->do_direct_payment($payment, $billing_values); |
|
436 | - $payment->save(); |
|
437 | - } else { |
|
438 | - throw new EE_Error( |
|
439 | - sprintf( |
|
440 | - __( |
|
441 | - 'Gateway for payment method type "%s" is "%s", not a subclass of either EE_Offsite_Gateway or EE_Onsite_Gateway, or null (to indicate NO gateway)', |
|
442 | - 'event_espresso' |
|
443 | - ), |
|
444 | - get_class($this), |
|
445 | - gettype($this->_gateway) |
|
446 | - ) |
|
447 | - ); |
|
448 | - } |
|
449 | - } else { |
|
450 | - // no gateway provided |
|
451 | - // there is no payment. Must be an offline gateway |
|
452 | - // create a payment object anyways, but dont save it |
|
453 | - $payment = EE_Payment::new_instance( |
|
454 | - array( |
|
455 | - 'STS_ID' => EEM_Payment::status_id_pending, |
|
456 | - 'TXN_ID' => $transaction->ID(), |
|
457 | - 'PMD_ID' => $transaction->payment_method_ID(), |
|
458 | - 'PAY_amount' => 0.00, |
|
459 | - 'PAY_timestamp' => time(), |
|
460 | - ) |
|
461 | - ); |
|
462 | - } |
|
463 | - |
|
464 | - // if there is billing info, clean it and save it now |
|
465 | - if ($billing_info instanceof EE_Billing_Attendee_Info_Form) { |
|
466 | - $this->_save_billing_info_to_attendee($billing_info, $transaction); |
|
467 | - } |
|
468 | - |
|
469 | - return $payment; |
|
470 | - } |
|
471 | - |
|
472 | - /** |
|
473 | - * Gets the values we want to pass onto the gateway. Normally these |
|
474 | - * are just the 'pretty' values, but there may be times the data may need |
|
475 | - * a little massaging. Proper subsections will become arrays of inputs |
|
476 | - * |
|
477 | - * @param EE_Billing_Info_Form $billing_form |
|
478 | - * @return array |
|
479 | - */ |
|
480 | - protected function _get_billing_values_from_form($billing_form) |
|
481 | - { |
|
482 | - if ($billing_form instanceof EE_Form_Section_Proper) { |
|
483 | - return $billing_form->input_pretty_values(true); |
|
484 | - } else { |
|
485 | - return null; |
|
486 | - } |
|
487 | - } |
|
488 | - |
|
489 | - |
|
490 | - /** |
|
491 | - * Handles an instant payment notification when the transaction is known (by default). |
|
492 | - * |
|
493 | - * @param array $req_data |
|
494 | - * @param EE_Transaction $transaction |
|
495 | - * @return EE_Payment |
|
496 | - * @throws EE_Error |
|
497 | - */ |
|
498 | - public function handle_ipn($req_data, $transaction) |
|
499 | - { |
|
500 | - $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
501 | - if (! $this->_gateway instanceof EE_Offsite_Gateway) { |
|
502 | - throw new EE_Error( |
|
503 | - sprintf( |
|
504 | - __("Could not handle IPN because '%s' is not an offsite gateway", "event_espresso"), |
|
505 | - print_r($this->_gateway, true) |
|
506 | - ) |
|
507 | - ); |
|
508 | - } |
|
509 | - $payment = $this->_gateway->handle_payment_update($req_data, $transaction); |
|
510 | - return $payment; |
|
511 | - } |
|
512 | - |
|
513 | - |
|
514 | - /** |
|
515 | - * Saves the billing info onto the attendee of the primary registrant on this transaction, and |
|
516 | - * cleans it first. |
|
517 | - * |
|
518 | - * @param EE_Billing_Attendee_Info_Form $billing_form |
|
519 | - * @param EE_Transaction $transaction |
|
520 | - * @return boolean success |
|
521 | - */ |
|
522 | - protected function _save_billing_info_to_attendee($billing_form, $transaction) |
|
523 | - { |
|
524 | - if (! $transaction || ! $transaction instanceof EE_Transaction) { |
|
525 | - EE_Error::add_error( |
|
526 | - __("Cannot save billing info because no transaction was specified", "event_espresso"), |
|
527 | - __FILE__, |
|
528 | - __FUNCTION__, |
|
529 | - __LINE__ |
|
530 | - ); |
|
531 | - return false; |
|
532 | - } |
|
533 | - $primary_reg = $transaction->primary_registration(); |
|
534 | - if (! $primary_reg) { |
|
535 | - EE_Error::add_error( |
|
536 | - __("Cannot save billing info because the transaction has no primary registration", "event_espresso"), |
|
537 | - __FILE__, |
|
538 | - __FUNCTION__, |
|
539 | - __LINE__ |
|
540 | - ); |
|
541 | - return false; |
|
542 | - } |
|
543 | - $attendee = $primary_reg->attendee(); |
|
544 | - if (! $attendee) { |
|
545 | - EE_Error::add_error( |
|
546 | - __( |
|
547 | - "Cannot save billing info because the transaction's primary registration has no attendee!", |
|
548 | - "event_espresso" |
|
549 | - ), |
|
550 | - __FILE__, |
|
551 | - __FUNCTION__, |
|
552 | - __LINE__ |
|
553 | - ); |
|
554 | - return false; |
|
555 | - } |
|
556 | - return $attendee->save_and_clean_billing_info_for_payment_method($billing_form, $transaction->payment_method()); |
|
557 | - } |
|
558 | - |
|
559 | - |
|
560 | - /** |
|
561 | - * Gets the payment this IPN is for. Children may often want to |
|
562 | - * override this to inspect the request |
|
563 | - * |
|
564 | - * @param EE_Transaction $transaction |
|
565 | - * @param array $req_data |
|
566 | - * @return EE_Payment |
|
567 | - */ |
|
568 | - protected function find_payment_for_ipn(EE_Transaction $transaction, $req_data = array()) |
|
569 | - { |
|
570 | - return $transaction->last_payment(); |
|
571 | - } |
|
572 | - |
|
573 | - |
|
574 | - /** |
|
575 | - * In case generic code cannot provide the payment processor with a specific payment method |
|
576 | - * and transaction, it will try calling this method on each activate payment method. |
|
577 | - * If the payment method is able to identify the request as being for it, it should fetch |
|
578 | - * the payment its for and return it. If not, it should throw an EE_Error to indicate it cannot |
|
579 | - * handle the IPN |
|
580 | - * |
|
581 | - * @param array $req_data |
|
582 | - * @return EE_Payment only if this payment method can find the info its needs from $req_data |
|
583 | - * and identifies the IPN as being for this payment method (not just fo ra payment method of this type) |
|
584 | - * @throws EE_Error |
|
585 | - */ |
|
586 | - public function handle_unclaimed_ipn($req_data = array()) |
|
587 | - { |
|
588 | - throw new EE_Error( |
|
589 | - sprintf(__("Payment Method '%s' cannot handle unclaimed IPNs", "event_espresso"), get_class($this)) |
|
590 | - ); |
|
591 | - } |
|
592 | - |
|
593 | - |
|
594 | - /** |
|
595 | - * Logic to be accomplished when the payment attempt is complete. |
|
596 | - * Most payment methods don't need to do anything at this point; but some, like Mijireh, do. |
|
597 | - * (Mijireh is an offsite gateway which doesn't send an IPN. So when the user returns to EE from |
|
598 | - * mijireh, this method needs to be called so the Mijireh PM can ping Mijireh to know the status |
|
599 | - * of the payment). Fed a transaction because it's always assumed to be the last payment that |
|
600 | - * we're dealing with. Returns that last payment (if there is one) |
|
601 | - * |
|
602 | - * @param EE_Transaction $transaction |
|
603 | - * @return EE_Payment |
|
604 | - */ |
|
605 | - public function finalize_payment_for($transaction) |
|
606 | - { |
|
607 | - return $transaction->last_payment(); |
|
608 | - } |
|
609 | - |
|
610 | - |
|
611 | - /** |
|
612 | - * Whether or not this payment method's gateway supports sending refund requests |
|
613 | - * |
|
614 | - * @return boolean |
|
615 | - */ |
|
616 | - public function supports_sending_refunds() |
|
617 | - { |
|
618 | - if ($this->_gateway && $this->_gateway instanceof EE_Gateway) { |
|
619 | - return $this->_gateway->supports_sending_refunds(); |
|
620 | - } else { |
|
621 | - return false; |
|
622 | - } |
|
623 | - } |
|
624 | - |
|
625 | - |
|
626 | - /** |
|
627 | - * |
|
628 | - * @param EE_Payment $payment |
|
629 | - * @param array $refund_info |
|
630 | - * @throws EE_Error |
|
631 | - * @return EE_Payment |
|
632 | - */ |
|
633 | - public function process_refund(EE_Payment $payment, $refund_info = array()) |
|
634 | - { |
|
635 | - if ($this->_gateway && $this->_gateway instanceof EE_Gateway) { |
|
636 | - return $this->_gateway->do_direct_refund($payment, $refund_info); |
|
637 | - } else { |
|
638 | - throw new EE_Error( |
|
639 | - sprintf( |
|
640 | - __('Payment Method Type "%s" does not support sending refund requests', 'event_espresso'), |
|
641 | - get_class($this) |
|
642 | - ) |
|
643 | - ); |
|
644 | - } |
|
645 | - } |
|
646 | - |
|
647 | - |
|
648 | - /** |
|
649 | - * Returns one the class's constants onsite,offsite, or offline, depending on this |
|
650 | - * payment method's gateway. |
|
651 | - * |
|
652 | - * @return string |
|
653 | - * @throws EE_Error |
|
654 | - */ |
|
655 | - public function payment_occurs() |
|
656 | - { |
|
657 | - if (! $this->_gateway) { |
|
658 | - return EE_PMT_Base::offline; |
|
659 | - } elseif ($this->_gateway instanceof EE_Onsite_Gateway) { |
|
660 | - return EE_PMT_Base::onsite; |
|
661 | - } elseif ($this->_gateway instanceof EE_Offsite_Gateway) { |
|
662 | - return EE_PMT_Base::offsite; |
|
663 | - } else { |
|
664 | - throw new EE_Error( |
|
665 | - sprintf( |
|
666 | - __( |
|
667 | - "Payment method type '%s's gateway isn't an instance of EE_Onsite_Gateway, EE_Offsite_Gateway, or null. It must be one of those", |
|
668 | - "event_espresso" |
|
669 | - ), |
|
670 | - get_class($this) |
|
671 | - ) |
|
672 | - ); |
|
673 | - } |
|
674 | - } |
|
675 | - |
|
676 | - |
|
677 | - /** |
|
678 | - * For adding any html output ab ove the payment overview. |
|
679 | - * Many gateways won't want ot display anything, so this function just returns an empty string. |
|
680 | - * Other gateways may want to override this, such as offline gateways. |
|
681 | - * |
|
682 | - * @param EE_Payment $payment |
|
683 | - * @return string |
|
684 | - */ |
|
685 | - public function payment_overview_content(EE_Payment $payment) |
|
686 | - { |
|
687 | - return EEH_Template::display_template( |
|
688 | - EE_LIBRARIES . 'payment_methods/templates/payment_details_content.template.php', |
|
689 | - array('payment_method' => $this->_pm_instance, 'payment' => $payment), |
|
690 | - true |
|
691 | - ); |
|
692 | - } |
|
693 | - |
|
694 | - |
|
695 | - /** |
|
696 | - * @return array where keys are the help tab name, |
|
697 | - * values are: array { |
|
698 | - * @type string $title i18n name for the help tab |
|
699 | - * @type string $filename name of the file located in ./help_tabs/ (ie, in a folder next to this file) |
|
700 | - * @type array $template_args any arguments you want passed to the template file while rendering. |
|
701 | - * Keys will be variable names and values with be their values. |
|
702 | - */ |
|
703 | - public function help_tabs_config() |
|
704 | - { |
|
705 | - return array(); |
|
706 | - } |
|
707 | - |
|
708 | - |
|
709 | - /** |
|
710 | - * The system name for this PMT (eg AIM, Paypal_Pro, Invoice... what gets put into |
|
711 | - * the payment method's table's PMT_type column) |
|
712 | - * |
|
713 | - * @return string |
|
714 | - */ |
|
715 | - public function system_name() |
|
716 | - { |
|
717 | - $classname = get_class($this); |
|
718 | - return str_replace("EE_PMT_", '', $classname); |
|
719 | - } |
|
720 | - |
|
721 | - |
|
722 | - /** |
|
723 | - * A pretty i18n version of the PMT name. Often the same as the "pretty_name", but you can change it by overriding |
|
724 | - * this method. |
|
725 | - * @return string |
|
726 | - */ |
|
727 | - public function defaultFrontendName() |
|
728 | - { |
|
729 | - return $this->pretty_name(); |
|
730 | - } |
|
731 | - |
|
732 | - |
|
733 | - /** |
|
734 | - * A pretty i18n version of the PMT name |
|
735 | - * |
|
736 | - * @return string |
|
737 | - */ |
|
738 | - public function pretty_name() |
|
739 | - { |
|
740 | - return $this->_pretty_name; |
|
741 | - } |
|
742 | - |
|
743 | - |
|
744 | - /** |
|
745 | - * Gets the default absolute URL to the payment method type's button |
|
746 | - * |
|
747 | - * @return string |
|
748 | - */ |
|
749 | - public function default_button_url() |
|
750 | - { |
|
751 | - return $this->_default_button_url; |
|
752 | - } |
|
753 | - |
|
754 | - |
|
755 | - /** |
|
756 | - * Gets the gateway used by this payment method (if any) |
|
757 | - * |
|
758 | - * @return EE_Gateway |
|
759 | - */ |
|
760 | - public function get_gateway() |
|
761 | - { |
|
762 | - return $this->_gateway; |
|
763 | - } |
|
764 | - |
|
765 | - |
|
766 | - /** |
|
767 | - * @return string html for the link to a help tab |
|
768 | - */ |
|
769 | - public function get_help_tab_link() |
|
770 | - { |
|
771 | - return EEH_Template::get_help_tab_link( |
|
772 | - $this->get_help_tab_name(), |
|
773 | - 'espresso_payment_settings', |
|
774 | - 'default' |
|
775 | - ); |
|
776 | - } |
|
777 | - |
|
778 | - |
|
779 | - /** |
|
780 | - * Returns the name of the help tab for this PMT |
|
781 | - * |
|
782 | - * @return string |
|
783 | - */ |
|
784 | - public function get_help_tab_name() |
|
785 | - { |
|
786 | - return 'ee_' . strtolower($this->system_name()) . '_help_tab'; |
|
787 | - } |
|
788 | - |
|
789 | - /** |
|
790 | - * The name of the wp capability that should be associated with the usage of |
|
791 | - * this PMT by an admin |
|
792 | - * |
|
793 | - * @return string |
|
794 | - */ |
|
795 | - public function cap_name() |
|
796 | - { |
|
797 | - return 'ee_payment_method_' . strtolower($this->system_name()); |
|
798 | - } |
|
799 | - |
|
800 | - /** |
|
801 | - * Called by client code to tell the gateway that if it wants to change |
|
802 | - * the transaction or line items or registrations related to teh payment it already |
|
803 | - * processed (we think, but possibly not) that now's the time to do it. |
|
804 | - * It is expected that gateways will store any info they need for this on the PAY_details, |
|
805 | - * or maybe an extra meta value |
|
806 | - * |
|
807 | - * @param EE_Payment $payment |
|
808 | - * @return void |
|
809 | - */ |
|
810 | - public function update_txn_based_on_payment($payment) |
|
811 | - { |
|
812 | - if ($this->_gateway instanceof EE_Gateway) { |
|
813 | - $this->_gateway->update_txn_based_on_payment($payment); |
|
814 | - } |
|
815 | - } |
|
816 | - |
|
817 | - /** |
|
818 | - * Returns a string of HTML describing this payment method type for an admin, |
|
819 | - * primarily intended for them to read before activating it. |
|
820 | - * The easiest way to set this is to create a folder 'templates' alongside |
|
821 | - * your EE_PMT_{System_Name} file, and in it create a file named "{system_name}_intro.template.php". |
|
822 | - * Eg, if your payment method file is named "EE_PMT_Foo_Bar.pm.php", |
|
823 | - * then you'd create a file named "templates" in the same folder as it, and name the file |
|
824 | - * "foo_bar_intro.template.php", and its content will be returned by this method |
|
825 | - * |
|
826 | - * @return string |
|
827 | - */ |
|
828 | - public function introductory_html() |
|
829 | - { |
|
830 | - return EEH_Template::locate_template( |
|
831 | - $this->file_folder() . 'templates/' . strtolower($this->system_name()) . '_intro.template.php', |
|
832 | - array('pmt_obj' => $this, 'pm_instance' => $this->_pm_instance) |
|
833 | - ); |
|
834 | - } |
|
25 | + const onsite = 'on-site'; |
|
26 | + const offsite = 'off-site'; |
|
27 | + const offline = 'off-line'; |
|
28 | + |
|
29 | + /** |
|
30 | + * @var EE_Payment_Method |
|
31 | + */ |
|
32 | + protected $_pm_instance = null; |
|
33 | + |
|
34 | + /** |
|
35 | + * @var boolean |
|
36 | + */ |
|
37 | + protected $_requires_https = false; |
|
38 | + |
|
39 | + /** |
|
40 | + * @var boolean |
|
41 | + */ |
|
42 | + protected $_has_billing_form; |
|
43 | + |
|
44 | + /** |
|
45 | + * @var EE_Gateway |
|
46 | + */ |
|
47 | + protected $_gateway = null; |
|
48 | + |
|
49 | + /** |
|
50 | + * @var EE_Payment_Method_Form |
|
51 | + */ |
|
52 | + protected $_settings_form = null; |
|
53 | + |
|
54 | + /** |
|
55 | + * @var EE_Form_Section_Proper |
|
56 | + */ |
|
57 | + protected $_billing_form = null; |
|
58 | + |
|
59 | + /** |
|
60 | + * @var boolean |
|
61 | + */ |
|
62 | + protected $_cache_billing_form = true; |
|
63 | + |
|
64 | + /** |
|
65 | + * String of the absolute path to the folder containing this file, with a trailing slash. |
|
66 | + * eg '/public_html/wp-site/wp-content/plugins/event-espresso/payment_methods/Invoice/' |
|
67 | + * |
|
68 | + * @var string |
|
69 | + */ |
|
70 | + protected $_file_folder = null; |
|
71 | + |
|
72 | + /** |
|
73 | + * String to the absolute URL to this file (useful for getting its web-accessible resources |
|
74 | + * like images, js, or css) |
|
75 | + * |
|
76 | + * @var string |
|
77 | + */ |
|
78 | + protected $_file_url = null; |
|
79 | + |
|
80 | + /** |
|
81 | + * Pretty name for the payment method |
|
82 | + * |
|
83 | + * @var string |
|
84 | + */ |
|
85 | + protected $_pretty_name = null; |
|
86 | + |
|
87 | + /** |
|
88 | + * |
|
89 | + * @var string |
|
90 | + */ |
|
91 | + protected $_default_button_url = null; |
|
92 | + |
|
93 | + /** |
|
94 | + * |
|
95 | + * @var string |
|
96 | + */ |
|
97 | + protected $_default_description = null; |
|
98 | + |
|
99 | + |
|
100 | + /** |
|
101 | + * |
|
102 | + * @param EE_Payment_Method $pm_instance |
|
103 | + * @throws EE_Error |
|
104 | + * @return EE_PMT_Base |
|
105 | + */ |
|
106 | + public function __construct($pm_instance = null) |
|
107 | + { |
|
108 | + if ($pm_instance instanceof EE_Payment_Method) { |
|
109 | + $this->set_instance($pm_instance); |
|
110 | + } |
|
111 | + if ($this->_gateway) { |
|
112 | + $this->_gateway->set_payment_model(EEM_Payment::instance()); |
|
113 | + $this->_gateway->set_payment_log(EEM_Change_Log::instance()); |
|
114 | + $this->_gateway->set_template_helper(new EEH_Template()); |
|
115 | + $this->_gateway->set_line_item_helper(new EEH_Line_Item()); |
|
116 | + $this->_gateway->set_money_helper(new EEH_Money()); |
|
117 | + $this->_gateway->set_gateway_data_formatter(new GatewayDataFormatter()); |
|
118 | + $this->_gateway->set_unsupported_character_remover(new AsciiOnly()); |
|
119 | + do_action('AHEE__EE_PMT_Base___construct__done_initializing_gateway_class', $this, $this->_gateway); |
|
120 | + } |
|
121 | + if (! isset($this->_has_billing_form)) { |
|
122 | + // by default, On Site gateways have a billing form |
|
123 | + if ($this->payment_occurs() == EE_PMT_Base::onsite) { |
|
124 | + $this->set_has_billing_form(true); |
|
125 | + } else { |
|
126 | + $this->set_has_billing_form(false); |
|
127 | + } |
|
128 | + } |
|
129 | + |
|
130 | + if (! $this->_pretty_name) { |
|
131 | + throw new EE_Error( |
|
132 | + sprintf( |
|
133 | + __( |
|
134 | + "You must set the pretty name for the Payment Method Type in the constructor (_pretty_name), and please make it internationalized", |
|
135 | + "event_espresso" |
|
136 | + ) |
|
137 | + ) |
|
138 | + ); |
|
139 | + } |
|
140 | + // if the child didn't specify a default button, use the credit card one |
|
141 | + if ($this->_default_button_url === null) { |
|
142 | + $this->_default_button_url = EE_PLUGIN_DIR_URL . 'payment_methods/pay-by-credit-card.png'; |
|
143 | + } |
|
144 | + } |
|
145 | + |
|
146 | + |
|
147 | + /** |
|
148 | + * @param boolean $has_billing_form |
|
149 | + */ |
|
150 | + public function set_has_billing_form($has_billing_form) |
|
151 | + { |
|
152 | + $this->_has_billing_form = filter_var($has_billing_form, FILTER_VALIDATE_BOOLEAN); |
|
153 | + } |
|
154 | + |
|
155 | + |
|
156 | + /** |
|
157 | + * sets the file_folder property |
|
158 | + */ |
|
159 | + protected function _set_file_folder() |
|
160 | + { |
|
161 | + $reflector = new ReflectionClass(get_class($this)); |
|
162 | + $fn = $reflector->getFileName(); |
|
163 | + $this->_file_folder = dirname($fn) . '/'; |
|
164 | + } |
|
165 | + |
|
166 | + |
|
167 | + /** |
|
168 | + * sets the file URL with a trailing slash for this PMT |
|
169 | + */ |
|
170 | + protected function _set_file_url() |
|
171 | + { |
|
172 | + $plugins_dir_fixed = str_replace('\\', '/', WP_PLUGIN_DIR); |
|
173 | + $file_folder_fixed = str_replace('\\', '/', $this->file_folder()); |
|
174 | + $file_path = str_replace($plugins_dir_fixed, WP_PLUGIN_URL, $file_folder_fixed); |
|
175 | + $this->_file_url = set_url_scheme($file_path); |
|
176 | + } |
|
177 | + |
|
178 | + /** |
|
179 | + * Gets the default description on all payment methods of this type |
|
180 | + * |
|
181 | + * @return string |
|
182 | + */ |
|
183 | + public function default_description() |
|
184 | + { |
|
185 | + return $this->_default_description; |
|
186 | + } |
|
187 | + |
|
188 | + |
|
189 | + /** |
|
190 | + * Returns the folder containing the PMT child class, with a trailing slash |
|
191 | + * |
|
192 | + * @return string |
|
193 | + */ |
|
194 | + public function file_folder() |
|
195 | + { |
|
196 | + if (! $this->_file_folder) { |
|
197 | + $this->_set_file_folder(); |
|
198 | + } |
|
199 | + return $this->_file_folder; |
|
200 | + } |
|
201 | + |
|
202 | + |
|
203 | + /** |
|
204 | + * @return string |
|
205 | + */ |
|
206 | + public function file_url() |
|
207 | + { |
|
208 | + if (! $this->_file_url) { |
|
209 | + $this->_set_file_url(); |
|
210 | + } |
|
211 | + return $this->_file_url; |
|
212 | + } |
|
213 | + |
|
214 | + |
|
215 | + /** |
|
216 | + * Sets the payment method instance this payment method type is for. |
|
217 | + * Its important teh payment method instance is set before |
|
218 | + * |
|
219 | + * @param EE_Payment_Method $payment_method_instance |
|
220 | + */ |
|
221 | + public function set_instance($payment_method_instance) |
|
222 | + { |
|
223 | + $this->_pm_instance = $payment_method_instance; |
|
224 | + // if they have already requested the settings form, make sure its |
|
225 | + // data matches this model object |
|
226 | + if ($this->_settings_form) { |
|
227 | + $this->settings_form()->populate_model_obj($payment_method_instance); |
|
228 | + } |
|
229 | + if ($this->_gateway && $this->_gateway instanceof EE_Gateway) { |
|
230 | + $this->_gateway->set_settings($payment_method_instance->settings_array()); |
|
231 | + } |
|
232 | + } |
|
233 | + |
|
234 | + |
|
235 | + /** |
|
236 | + * Gets teh form for displaying to admins where they setup the payment method |
|
237 | + * |
|
238 | + * @return EE_Payment_Method_Form |
|
239 | + */ |
|
240 | + public function settings_form() |
|
241 | + { |
|
242 | + if (! $this->_settings_form) { |
|
243 | + $this->_settings_form = $this->generate_new_settings_form(); |
|
244 | + $this->_settings_form->set_payment_method_type($this); |
|
245 | + // if we have already assigned a model object to this pmt, make |
|
246 | + // sure its reflected in teh form we just generated |
|
247 | + if ($this->_pm_instance) { |
|
248 | + $this->_settings_form->populate_model_obj($this->_pm_instance); |
|
249 | + } |
|
250 | + } |
|
251 | + return $this->_settings_form; |
|
252 | + } |
|
253 | + |
|
254 | + |
|
255 | + /** |
|
256 | + * Gets the form for all the settings related to this payment method type |
|
257 | + * |
|
258 | + * @return EE_Payment_Method_Form |
|
259 | + */ |
|
260 | + abstract public function generate_new_settings_form(); |
|
261 | + |
|
262 | + |
|
263 | + /** |
|
264 | + * Sets the form for settings. This may be useful if we have already received |
|
265 | + * a form submission and have form data it in, and want to use it anytime we're showing |
|
266 | + * this payment method type's settings form later in the request |
|
267 | + * |
|
268 | + * @param EE_Payment_Method_Form $form |
|
269 | + */ |
|
270 | + public function set_settings_form($form) |
|
271 | + { |
|
272 | + $this->_settings_form = $form; |
|
273 | + } |
|
274 | + |
|
275 | + |
|
276 | + /** |
|
277 | + * @return boolean |
|
278 | + */ |
|
279 | + public function has_billing_form() |
|
280 | + { |
|
281 | + return $this->_has_billing_form; |
|
282 | + } |
|
283 | + |
|
284 | + |
|
285 | + /** |
|
286 | + * Gets the form for displaying to attendees where they can enter their billing info |
|
287 | + * which will be sent to teh gateway (can be null) |
|
288 | + * |
|
289 | + * @param \EE_Transaction $transaction |
|
290 | + * @param array $extra_args |
|
291 | + * @return \EE_Billing_Attendee_Info_Form|\EE_Billing_Info_Form|null |
|
292 | + */ |
|
293 | + public function billing_form(EE_Transaction $transaction = null, $extra_args = array()) |
|
294 | + { |
|
295 | + // has billing form already been regenerated ? or overwrite cache? |
|
296 | + if (! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form) { |
|
297 | + $this->_billing_form = $this->generate_new_billing_form($transaction, $extra_args); |
|
298 | + } |
|
299 | + // if we know who the attendee is, and this is a billing form |
|
300 | + // that uses attendee info, populate it |
|
301 | + if ( |
|
302 | + apply_filters( |
|
303 | + 'FHEE__populate_billing_form_fields_from_attendee', |
|
304 | + ($this->_billing_form instanceof EE_Billing_Attendee_Info_Form |
|
305 | + && $transaction instanceof EE_Transaction |
|
306 | + && $transaction->primary_registration() instanceof EE_Registration |
|
307 | + && $transaction->primary_registration()->attendee() instanceof EE_Attendee |
|
308 | + ), |
|
309 | + $this->_billing_form, |
|
310 | + $transaction |
|
311 | + ) |
|
312 | + ) { |
|
313 | + $this->_billing_form->populate_from_attendee($transaction->primary_registration()->attendee()); |
|
314 | + } |
|
315 | + return $this->_billing_form; |
|
316 | + } |
|
317 | + |
|
318 | + |
|
319 | + /** |
|
320 | + * Creates the billing form for this payment method type |
|
321 | + * |
|
322 | + * @param \EE_Transaction $transaction |
|
323 | + * @return \EE_Billing_Info_Form |
|
324 | + */ |
|
325 | + abstract public function generate_new_billing_form(EE_Transaction $transaction = null); |
|
326 | + |
|
327 | + |
|
328 | + /** |
|
329 | + * apply_billing_form_debug_settings |
|
330 | + * applies debug data to the form |
|
331 | + * |
|
332 | + * @param \EE_Billing_Info_Form $billing_form |
|
333 | + * @return \EE_Billing_Info_Form |
|
334 | + */ |
|
335 | + public function apply_billing_form_debug_settings(EE_Billing_Info_Form $billing_form) |
|
336 | + { |
|
337 | + return $billing_form; |
|
338 | + } |
|
339 | + |
|
340 | + |
|
341 | + /** |
|
342 | + * Sets the billing form for this payment method type. You may want to use this |
|
343 | + * if you have form |
|
344 | + * |
|
345 | + * @param EE_Payment_Method $form |
|
346 | + */ |
|
347 | + public function set_billing_form($form) |
|
348 | + { |
|
349 | + $this->_billing_form = $form; |
|
350 | + } |
|
351 | + |
|
352 | + |
|
353 | + /** |
|
354 | + * Returns whether or not this payment method requires HTTPS to be used |
|
355 | + * |
|
356 | + * @return boolean |
|
357 | + */ |
|
358 | + public function requires_https() |
|
359 | + { |
|
360 | + return $this->_requires_https; |
|
361 | + } |
|
362 | + |
|
363 | + |
|
364 | + /** |
|
365 | + * |
|
366 | + * @param EE_Transaction $transaction |
|
367 | + * @param float $amount |
|
368 | + * @param EE_Billing_Info_Form $billing_info |
|
369 | + * @param string $return_url |
|
370 | + * @param string $fail_url |
|
371 | + * @param string $method |
|
372 | + * @param bool $by_admin |
|
373 | + * @return EE_Payment |
|
374 | + * @throws EE_Error |
|
375 | + */ |
|
376 | + public function process_payment( |
|
377 | + EE_Transaction $transaction, |
|
378 | + $amount = null, |
|
379 | + $billing_info = null, |
|
380 | + $return_url = null, |
|
381 | + $fail_url = '', |
|
382 | + $method = 'CART', |
|
383 | + $by_admin = false |
|
384 | + ) { |
|
385 | + // @todo: add surcharge for the payment method, if any |
|
386 | + if ($this->_gateway) { |
|
387 | + // there is a gateway, so we're going to make a payment object |
|
388 | + // but wait! do they already have a payment in progress that we thought was failed? |
|
389 | + $duplicate_properties = array( |
|
390 | + 'STS_ID' => EEM_Payment::status_id_failed, |
|
391 | + 'TXN_ID' => $transaction->ID(), |
|
392 | + 'PMD_ID' => $this->_pm_instance->ID(), |
|
393 | + 'PAY_source' => $method, |
|
394 | + 'PAY_amount' => $amount !== null ? $amount : $transaction->remaining(), |
|
395 | + 'PAY_gateway_response' => null, |
|
396 | + ); |
|
397 | + $payment = EEM_Payment::instance()->get_one(array($duplicate_properties)); |
|
398 | + // if we didn't already have a payment in progress for the same thing, |
|
399 | + // then we actually want to make a new payment |
|
400 | + if (! $payment instanceof EE_Payment) { |
|
401 | + $payment = EE_Payment::new_instance( |
|
402 | + array_merge( |
|
403 | + $duplicate_properties, |
|
404 | + array( |
|
405 | + 'PAY_timestamp' => time(), |
|
406 | + 'PAY_txn_id_chq_nmbr' => null, |
|
407 | + 'PAY_po_number' => null, |
|
408 | + 'PAY_extra_accntng' => null, |
|
409 | + 'PAY_details' => null, |
|
410 | + ) |
|
411 | + ) |
|
412 | + ); |
|
413 | + } |
|
414 | + // make sure the payment has been saved to show we started it, and so it has an ID should the gateway try to log it |
|
415 | + $payment->save(); |
|
416 | + $billing_values = $this->_get_billing_values_from_form($billing_info); |
|
417 | + |
|
418 | + // Offsite Gateway |
|
419 | + if ($this->_gateway instanceof EE_Offsite_Gateway) { |
|
420 | + $payment = $this->_gateway->set_redirection_info( |
|
421 | + $payment, |
|
422 | + $billing_values, |
|
423 | + $return_url, |
|
424 | + EE_Config::instance()->core->txn_page_url( |
|
425 | + array( |
|
426 | + 'e_reg_url_link' => $transaction->primary_registration()->reg_url_link(), |
|
427 | + 'ee_payment_method' => $this->_pm_instance->slug(), |
|
428 | + ) |
|
429 | + ), |
|
430 | + $fail_url |
|
431 | + ); |
|
432 | + $payment->save(); |
|
433 | + // Onsite Gateway |
|
434 | + } elseif ($this->_gateway instanceof EE_Onsite_Gateway) { |
|
435 | + $payment = $this->_gateway->do_direct_payment($payment, $billing_values); |
|
436 | + $payment->save(); |
|
437 | + } else { |
|
438 | + throw new EE_Error( |
|
439 | + sprintf( |
|
440 | + __( |
|
441 | + 'Gateway for payment method type "%s" is "%s", not a subclass of either EE_Offsite_Gateway or EE_Onsite_Gateway, or null (to indicate NO gateway)', |
|
442 | + 'event_espresso' |
|
443 | + ), |
|
444 | + get_class($this), |
|
445 | + gettype($this->_gateway) |
|
446 | + ) |
|
447 | + ); |
|
448 | + } |
|
449 | + } else { |
|
450 | + // no gateway provided |
|
451 | + // there is no payment. Must be an offline gateway |
|
452 | + // create a payment object anyways, but dont save it |
|
453 | + $payment = EE_Payment::new_instance( |
|
454 | + array( |
|
455 | + 'STS_ID' => EEM_Payment::status_id_pending, |
|
456 | + 'TXN_ID' => $transaction->ID(), |
|
457 | + 'PMD_ID' => $transaction->payment_method_ID(), |
|
458 | + 'PAY_amount' => 0.00, |
|
459 | + 'PAY_timestamp' => time(), |
|
460 | + ) |
|
461 | + ); |
|
462 | + } |
|
463 | + |
|
464 | + // if there is billing info, clean it and save it now |
|
465 | + if ($billing_info instanceof EE_Billing_Attendee_Info_Form) { |
|
466 | + $this->_save_billing_info_to_attendee($billing_info, $transaction); |
|
467 | + } |
|
468 | + |
|
469 | + return $payment; |
|
470 | + } |
|
471 | + |
|
472 | + /** |
|
473 | + * Gets the values we want to pass onto the gateway. Normally these |
|
474 | + * are just the 'pretty' values, but there may be times the data may need |
|
475 | + * a little massaging. Proper subsections will become arrays of inputs |
|
476 | + * |
|
477 | + * @param EE_Billing_Info_Form $billing_form |
|
478 | + * @return array |
|
479 | + */ |
|
480 | + protected function _get_billing_values_from_form($billing_form) |
|
481 | + { |
|
482 | + if ($billing_form instanceof EE_Form_Section_Proper) { |
|
483 | + return $billing_form->input_pretty_values(true); |
|
484 | + } else { |
|
485 | + return null; |
|
486 | + } |
|
487 | + } |
|
488 | + |
|
489 | + |
|
490 | + /** |
|
491 | + * Handles an instant payment notification when the transaction is known (by default). |
|
492 | + * |
|
493 | + * @param array $req_data |
|
494 | + * @param EE_Transaction $transaction |
|
495 | + * @return EE_Payment |
|
496 | + * @throws EE_Error |
|
497 | + */ |
|
498 | + public function handle_ipn($req_data, $transaction) |
|
499 | + { |
|
500 | + $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
501 | + if (! $this->_gateway instanceof EE_Offsite_Gateway) { |
|
502 | + throw new EE_Error( |
|
503 | + sprintf( |
|
504 | + __("Could not handle IPN because '%s' is not an offsite gateway", "event_espresso"), |
|
505 | + print_r($this->_gateway, true) |
|
506 | + ) |
|
507 | + ); |
|
508 | + } |
|
509 | + $payment = $this->_gateway->handle_payment_update($req_data, $transaction); |
|
510 | + return $payment; |
|
511 | + } |
|
512 | + |
|
513 | + |
|
514 | + /** |
|
515 | + * Saves the billing info onto the attendee of the primary registrant on this transaction, and |
|
516 | + * cleans it first. |
|
517 | + * |
|
518 | + * @param EE_Billing_Attendee_Info_Form $billing_form |
|
519 | + * @param EE_Transaction $transaction |
|
520 | + * @return boolean success |
|
521 | + */ |
|
522 | + protected function _save_billing_info_to_attendee($billing_form, $transaction) |
|
523 | + { |
|
524 | + if (! $transaction || ! $transaction instanceof EE_Transaction) { |
|
525 | + EE_Error::add_error( |
|
526 | + __("Cannot save billing info because no transaction was specified", "event_espresso"), |
|
527 | + __FILE__, |
|
528 | + __FUNCTION__, |
|
529 | + __LINE__ |
|
530 | + ); |
|
531 | + return false; |
|
532 | + } |
|
533 | + $primary_reg = $transaction->primary_registration(); |
|
534 | + if (! $primary_reg) { |
|
535 | + EE_Error::add_error( |
|
536 | + __("Cannot save billing info because the transaction has no primary registration", "event_espresso"), |
|
537 | + __FILE__, |
|
538 | + __FUNCTION__, |
|
539 | + __LINE__ |
|
540 | + ); |
|
541 | + return false; |
|
542 | + } |
|
543 | + $attendee = $primary_reg->attendee(); |
|
544 | + if (! $attendee) { |
|
545 | + EE_Error::add_error( |
|
546 | + __( |
|
547 | + "Cannot save billing info because the transaction's primary registration has no attendee!", |
|
548 | + "event_espresso" |
|
549 | + ), |
|
550 | + __FILE__, |
|
551 | + __FUNCTION__, |
|
552 | + __LINE__ |
|
553 | + ); |
|
554 | + return false; |
|
555 | + } |
|
556 | + return $attendee->save_and_clean_billing_info_for_payment_method($billing_form, $transaction->payment_method()); |
|
557 | + } |
|
558 | + |
|
559 | + |
|
560 | + /** |
|
561 | + * Gets the payment this IPN is for. Children may often want to |
|
562 | + * override this to inspect the request |
|
563 | + * |
|
564 | + * @param EE_Transaction $transaction |
|
565 | + * @param array $req_data |
|
566 | + * @return EE_Payment |
|
567 | + */ |
|
568 | + protected function find_payment_for_ipn(EE_Transaction $transaction, $req_data = array()) |
|
569 | + { |
|
570 | + return $transaction->last_payment(); |
|
571 | + } |
|
572 | + |
|
573 | + |
|
574 | + /** |
|
575 | + * In case generic code cannot provide the payment processor with a specific payment method |
|
576 | + * and transaction, it will try calling this method on each activate payment method. |
|
577 | + * If the payment method is able to identify the request as being for it, it should fetch |
|
578 | + * the payment its for and return it. If not, it should throw an EE_Error to indicate it cannot |
|
579 | + * handle the IPN |
|
580 | + * |
|
581 | + * @param array $req_data |
|
582 | + * @return EE_Payment only if this payment method can find the info its needs from $req_data |
|
583 | + * and identifies the IPN as being for this payment method (not just fo ra payment method of this type) |
|
584 | + * @throws EE_Error |
|
585 | + */ |
|
586 | + public function handle_unclaimed_ipn($req_data = array()) |
|
587 | + { |
|
588 | + throw new EE_Error( |
|
589 | + sprintf(__("Payment Method '%s' cannot handle unclaimed IPNs", "event_espresso"), get_class($this)) |
|
590 | + ); |
|
591 | + } |
|
592 | + |
|
593 | + |
|
594 | + /** |
|
595 | + * Logic to be accomplished when the payment attempt is complete. |
|
596 | + * Most payment methods don't need to do anything at this point; but some, like Mijireh, do. |
|
597 | + * (Mijireh is an offsite gateway which doesn't send an IPN. So when the user returns to EE from |
|
598 | + * mijireh, this method needs to be called so the Mijireh PM can ping Mijireh to know the status |
|
599 | + * of the payment). Fed a transaction because it's always assumed to be the last payment that |
|
600 | + * we're dealing with. Returns that last payment (if there is one) |
|
601 | + * |
|
602 | + * @param EE_Transaction $transaction |
|
603 | + * @return EE_Payment |
|
604 | + */ |
|
605 | + public function finalize_payment_for($transaction) |
|
606 | + { |
|
607 | + return $transaction->last_payment(); |
|
608 | + } |
|
609 | + |
|
610 | + |
|
611 | + /** |
|
612 | + * Whether or not this payment method's gateway supports sending refund requests |
|
613 | + * |
|
614 | + * @return boolean |
|
615 | + */ |
|
616 | + public function supports_sending_refunds() |
|
617 | + { |
|
618 | + if ($this->_gateway && $this->_gateway instanceof EE_Gateway) { |
|
619 | + return $this->_gateway->supports_sending_refunds(); |
|
620 | + } else { |
|
621 | + return false; |
|
622 | + } |
|
623 | + } |
|
624 | + |
|
625 | + |
|
626 | + /** |
|
627 | + * |
|
628 | + * @param EE_Payment $payment |
|
629 | + * @param array $refund_info |
|
630 | + * @throws EE_Error |
|
631 | + * @return EE_Payment |
|
632 | + */ |
|
633 | + public function process_refund(EE_Payment $payment, $refund_info = array()) |
|
634 | + { |
|
635 | + if ($this->_gateway && $this->_gateway instanceof EE_Gateway) { |
|
636 | + return $this->_gateway->do_direct_refund($payment, $refund_info); |
|
637 | + } else { |
|
638 | + throw new EE_Error( |
|
639 | + sprintf( |
|
640 | + __('Payment Method Type "%s" does not support sending refund requests', 'event_espresso'), |
|
641 | + get_class($this) |
|
642 | + ) |
|
643 | + ); |
|
644 | + } |
|
645 | + } |
|
646 | + |
|
647 | + |
|
648 | + /** |
|
649 | + * Returns one the class's constants onsite,offsite, or offline, depending on this |
|
650 | + * payment method's gateway. |
|
651 | + * |
|
652 | + * @return string |
|
653 | + * @throws EE_Error |
|
654 | + */ |
|
655 | + public function payment_occurs() |
|
656 | + { |
|
657 | + if (! $this->_gateway) { |
|
658 | + return EE_PMT_Base::offline; |
|
659 | + } elseif ($this->_gateway instanceof EE_Onsite_Gateway) { |
|
660 | + return EE_PMT_Base::onsite; |
|
661 | + } elseif ($this->_gateway instanceof EE_Offsite_Gateway) { |
|
662 | + return EE_PMT_Base::offsite; |
|
663 | + } else { |
|
664 | + throw new EE_Error( |
|
665 | + sprintf( |
|
666 | + __( |
|
667 | + "Payment method type '%s's gateway isn't an instance of EE_Onsite_Gateway, EE_Offsite_Gateway, or null. It must be one of those", |
|
668 | + "event_espresso" |
|
669 | + ), |
|
670 | + get_class($this) |
|
671 | + ) |
|
672 | + ); |
|
673 | + } |
|
674 | + } |
|
675 | + |
|
676 | + |
|
677 | + /** |
|
678 | + * For adding any html output ab ove the payment overview. |
|
679 | + * Many gateways won't want ot display anything, so this function just returns an empty string. |
|
680 | + * Other gateways may want to override this, such as offline gateways. |
|
681 | + * |
|
682 | + * @param EE_Payment $payment |
|
683 | + * @return string |
|
684 | + */ |
|
685 | + public function payment_overview_content(EE_Payment $payment) |
|
686 | + { |
|
687 | + return EEH_Template::display_template( |
|
688 | + EE_LIBRARIES . 'payment_methods/templates/payment_details_content.template.php', |
|
689 | + array('payment_method' => $this->_pm_instance, 'payment' => $payment), |
|
690 | + true |
|
691 | + ); |
|
692 | + } |
|
693 | + |
|
694 | + |
|
695 | + /** |
|
696 | + * @return array where keys are the help tab name, |
|
697 | + * values are: array { |
|
698 | + * @type string $title i18n name for the help tab |
|
699 | + * @type string $filename name of the file located in ./help_tabs/ (ie, in a folder next to this file) |
|
700 | + * @type array $template_args any arguments you want passed to the template file while rendering. |
|
701 | + * Keys will be variable names and values with be their values. |
|
702 | + */ |
|
703 | + public function help_tabs_config() |
|
704 | + { |
|
705 | + return array(); |
|
706 | + } |
|
707 | + |
|
708 | + |
|
709 | + /** |
|
710 | + * The system name for this PMT (eg AIM, Paypal_Pro, Invoice... what gets put into |
|
711 | + * the payment method's table's PMT_type column) |
|
712 | + * |
|
713 | + * @return string |
|
714 | + */ |
|
715 | + public function system_name() |
|
716 | + { |
|
717 | + $classname = get_class($this); |
|
718 | + return str_replace("EE_PMT_", '', $classname); |
|
719 | + } |
|
720 | + |
|
721 | + |
|
722 | + /** |
|
723 | + * A pretty i18n version of the PMT name. Often the same as the "pretty_name", but you can change it by overriding |
|
724 | + * this method. |
|
725 | + * @return string |
|
726 | + */ |
|
727 | + public function defaultFrontendName() |
|
728 | + { |
|
729 | + return $this->pretty_name(); |
|
730 | + } |
|
731 | + |
|
732 | + |
|
733 | + /** |
|
734 | + * A pretty i18n version of the PMT name |
|
735 | + * |
|
736 | + * @return string |
|
737 | + */ |
|
738 | + public function pretty_name() |
|
739 | + { |
|
740 | + return $this->_pretty_name; |
|
741 | + } |
|
742 | + |
|
743 | + |
|
744 | + /** |
|
745 | + * Gets the default absolute URL to the payment method type's button |
|
746 | + * |
|
747 | + * @return string |
|
748 | + */ |
|
749 | + public function default_button_url() |
|
750 | + { |
|
751 | + return $this->_default_button_url; |
|
752 | + } |
|
753 | + |
|
754 | + |
|
755 | + /** |
|
756 | + * Gets the gateway used by this payment method (if any) |
|
757 | + * |
|
758 | + * @return EE_Gateway |
|
759 | + */ |
|
760 | + public function get_gateway() |
|
761 | + { |
|
762 | + return $this->_gateway; |
|
763 | + } |
|
764 | + |
|
765 | + |
|
766 | + /** |
|
767 | + * @return string html for the link to a help tab |
|
768 | + */ |
|
769 | + public function get_help_tab_link() |
|
770 | + { |
|
771 | + return EEH_Template::get_help_tab_link( |
|
772 | + $this->get_help_tab_name(), |
|
773 | + 'espresso_payment_settings', |
|
774 | + 'default' |
|
775 | + ); |
|
776 | + } |
|
777 | + |
|
778 | + |
|
779 | + /** |
|
780 | + * Returns the name of the help tab for this PMT |
|
781 | + * |
|
782 | + * @return string |
|
783 | + */ |
|
784 | + public function get_help_tab_name() |
|
785 | + { |
|
786 | + return 'ee_' . strtolower($this->system_name()) . '_help_tab'; |
|
787 | + } |
|
788 | + |
|
789 | + /** |
|
790 | + * The name of the wp capability that should be associated with the usage of |
|
791 | + * this PMT by an admin |
|
792 | + * |
|
793 | + * @return string |
|
794 | + */ |
|
795 | + public function cap_name() |
|
796 | + { |
|
797 | + return 'ee_payment_method_' . strtolower($this->system_name()); |
|
798 | + } |
|
799 | + |
|
800 | + /** |
|
801 | + * Called by client code to tell the gateway that if it wants to change |
|
802 | + * the transaction or line items or registrations related to teh payment it already |
|
803 | + * processed (we think, but possibly not) that now's the time to do it. |
|
804 | + * It is expected that gateways will store any info they need for this on the PAY_details, |
|
805 | + * or maybe an extra meta value |
|
806 | + * |
|
807 | + * @param EE_Payment $payment |
|
808 | + * @return void |
|
809 | + */ |
|
810 | + public function update_txn_based_on_payment($payment) |
|
811 | + { |
|
812 | + if ($this->_gateway instanceof EE_Gateway) { |
|
813 | + $this->_gateway->update_txn_based_on_payment($payment); |
|
814 | + } |
|
815 | + } |
|
816 | + |
|
817 | + /** |
|
818 | + * Returns a string of HTML describing this payment method type for an admin, |
|
819 | + * primarily intended for them to read before activating it. |
|
820 | + * The easiest way to set this is to create a folder 'templates' alongside |
|
821 | + * your EE_PMT_{System_Name} file, and in it create a file named "{system_name}_intro.template.php". |
|
822 | + * Eg, if your payment method file is named "EE_PMT_Foo_Bar.pm.php", |
|
823 | + * then you'd create a file named "templates" in the same folder as it, and name the file |
|
824 | + * "foo_bar_intro.template.php", and its content will be returned by this method |
|
825 | + * |
|
826 | + * @return string |
|
827 | + */ |
|
828 | + public function introductory_html() |
|
829 | + { |
|
830 | + return EEH_Template::locate_template( |
|
831 | + $this->file_folder() . 'templates/' . strtolower($this->system_name()) . '_intro.template.php', |
|
832 | + array('pmt_obj' => $this, 'pm_instance' => $this->_pm_instance) |
|
833 | + ); |
|
834 | + } |
|
835 | 835 | } |
@@ -129,12 +129,12 @@ |
||
129 | 129 | <?php |
130 | 130 | function esp_gravatar_profile($email) |
131 | 131 | { |
132 | - echo 'https://www.gravatar.com/' . md5($email); |
|
132 | + echo 'https://www.gravatar.com/'.md5($email); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | function esp_gravatar_image($email, $name) |
136 | 136 | { |
137 | - echo '<img src="https://0.gravatar.com/avatar/' . md5($email) . '?s=60" class="gravatar" alt="' . $name . '"/>'; |
|
137 | + echo '<img src="https://0.gravatar.com/avatar/'.md5($email).'?s=60" class="gravatar" alt="'.$name.'"/>'; |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | ?> |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <p class="about-description"> |
2 | 2 | <?php esc_html_e( |
3 | - 'Event Espresso is created by an international team of passionate individuals with a drive to empower your events!', |
|
4 | - 'event_espresso' |
|
5 | - ); ?></p> |
|
3 | + 'Event Espresso is created by an international team of passionate individuals with a drive to empower your events!', |
|
4 | + 'event_espresso' |
|
5 | + ); ?></p> |
|
6 | 6 | <h3 class="wp-people-group"><?php esc_html_e('Founders', 'event_espresso'); ?></h3> |
7 | 7 | <ul class="wp-people-group" id="ee-people-group-owners"> |
8 | 8 | <li class="wp-person" id="ee-person-sshoultes"> |
@@ -85,15 +85,15 @@ discard block |
||
85 | 85 | <h3 class="wp-people-group"><?php esc_html_e('Contributor Recognition', 'event_espresso'); ?></h3> |
86 | 86 | <p class="description"> |
87 | 87 | <?php |
88 | - printf( |
|
89 | - esc_html__( |
|
90 | - 'For every major release we want to recognize the people who contributed to the release via a GitHub pull request. Want to see your name listed here? %sWhen you submit a pull request that gets included in a major release%s, we\'ll add your name here linked to your GitHub profile.', |
|
91 | - 'event_espresso' |
|
92 | - ), |
|
93 | - '<a href="https://github.com/eventespresso/event-espresso-core" title="Contribute to Event Espresso by making a pull request via GitHub">', |
|
94 | - '</a>' |
|
95 | - ); |
|
96 | - ?> |
|
88 | + printf( |
|
89 | + esc_html__( |
|
90 | + 'For every major release we want to recognize the people who contributed to the release via a GitHub pull request. Want to see your name listed here? %sWhen you submit a pull request that gets included in a major release%s, we\'ll add your name here linked to your GitHub profile.', |
|
91 | + 'event_espresso' |
|
92 | + ), |
|
93 | + '<a href="https://github.com/eventespresso/event-espresso-core" title="Contribute to Event Espresso by making a pull request via GitHub">', |
|
94 | + '</a>' |
|
95 | + ); |
|
96 | + ?> |
|
97 | 97 | </p> |
98 | 98 | <p class="wp-credits-list"> |
99 | 99 | <ul> |
@@ -108,15 +108,15 @@ discard block |
||
108 | 108 | <h3 class="wp-people-group"><?php esc_html_e('External Libraries', 'event_espresso'); ?></h3> |
109 | 109 | <p class="description"> |
110 | 110 | <?php |
111 | - printf( |
|
112 | - esc_html__( |
|
113 | - 'Along with the libraries %sincluded with WordPress%s, Event Espresso utilizes the following third party libraries:', |
|
114 | - 'event_espresso' |
|
115 | - ), |
|
116 | - '<a href="credits.php">', |
|
117 | - '</a>' |
|
118 | - ); |
|
119 | - ?> |
|
111 | + printf( |
|
112 | + esc_html__( |
|
113 | + 'Along with the libraries %sincluded with WordPress%s, Event Espresso utilizes the following third party libraries:', |
|
114 | + 'event_espresso' |
|
115 | + ), |
|
116 | + '<a href="credits.php">', |
|
117 | + '</a>' |
|
118 | + ); |
|
119 | + ?> |
|
120 | 120 | </p> |
121 | 121 | <p class="wp-credits-list"> |
122 | 122 | <a href="https://openexchangerates.github.io/accounting.js/">accounting.js</a>, |
@@ -133,12 +133,12 @@ discard block |
||
133 | 133 | <?php |
134 | 134 | function esp_gravatar_profile($email) |
135 | 135 | { |
136 | - echo 'https://www.gravatar.com/' . md5($email); |
|
136 | + echo 'https://www.gravatar.com/' . md5($email); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | function esp_gravatar_image($email, $name) |
140 | 140 | { |
141 | - echo '<img src="https://0.gravatar.com/avatar/' . md5($email) . '?s=60" class="gravatar" alt="' . $name . '"/>'; |
|
141 | + echo '<img src="https://0.gravatar.com/avatar/' . md5($email) . '?s=60" class="gravatar" alt="' . $name . '"/>'; |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | ?> |
@@ -1,225 +1,225 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * |
|
4 | - * Class EE_Default_Line_Item_Display_Strategy |
|
5 | - * |
|
6 | - * Description |
|
7 | - * |
|
8 | - * @package Event Espresso |
|
9 | - * @subpackage core |
|
10 | - * @author Brent Christensen |
|
11 | - * |
|
12 | - * |
|
13 | - */ |
|
3 | + * |
|
4 | + * Class EE_Default_Line_Item_Display_Strategy |
|
5 | + * |
|
6 | + * Description |
|
7 | + * |
|
8 | + * @package Event Espresso |
|
9 | + * @subpackage core |
|
10 | + * @author Brent Christensen |
|
11 | + * |
|
12 | + * |
|
13 | + */ |
|
14 | 14 | |
15 | 15 | class EE_Default_Line_Item_Display_Strategy implements EEI_Line_Item_Display |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * total amount of tax to apply |
|
20 | - * @type float $_tax_rate |
|
21 | - */ |
|
22 | - private $_tax_rate = 0; |
|
23 | - |
|
24 | - /** |
|
25 | - * total amount including tax we can bill for at this time |
|
26 | - * @type float $_grand_total |
|
27 | - */ |
|
28 | - private $_grand_total = 0.00; |
|
29 | - |
|
30 | - /** |
|
31 | - * total number of items being billed for |
|
32 | - * @type int $_total_items |
|
33 | - */ |
|
34 | - private $_total_items = 0; |
|
35 | - |
|
36 | - |
|
37 | - |
|
38 | - /** |
|
39 | - * @return float |
|
40 | - */ |
|
41 | - public function grand_total() |
|
42 | - { |
|
43 | - return $this->_grand_total; |
|
44 | - } |
|
45 | - |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * @return int |
|
50 | - */ |
|
51 | - public function total_items() |
|
52 | - { |
|
53 | - return $this->_total_items; |
|
54 | - } |
|
55 | - |
|
56 | - |
|
57 | - |
|
58 | - /** |
|
59 | - * @param EE_Line_Item $line_item |
|
60 | - * @param array $options |
|
61 | - * @return mixed |
|
62 | - */ |
|
63 | - public function display_line_item(EE_Line_Item $line_item, $options = array()) |
|
64 | - { |
|
65 | - |
|
66 | - $html = ''; |
|
67 | - // set some default options and merge with incoming |
|
68 | - $default_options = array( |
|
69 | - 'show_desc' => true, // TRUE FALSE |
|
70 | - 'odd' => false |
|
71 | - ); |
|
72 | - $options = array_merge($default_options, (array) $options); |
|
73 | - |
|
74 | - switch ($line_item->type()) { |
|
75 | - case EEM_Line_Item::type_line_item: |
|
76 | - // item row |
|
77 | - $html .= $this->_item_row($line_item, $options); |
|
78 | - // got any kids? |
|
79 | - foreach ($line_item->children() as $child_line_item) { |
|
80 | - $this->display_line_item($child_line_item, $options); |
|
81 | - } |
|
82 | - break; |
|
83 | - |
|
84 | - case EEM_Line_Item::type_sub_line_item: |
|
85 | - $html .= $this->_sub_item_row($line_item, $options); |
|
86 | - break; |
|
87 | - |
|
88 | - case EEM_Line_Item::type_sub_total: |
|
89 | - break; |
|
90 | - |
|
91 | - case EEM_Line_Item::type_tax: |
|
92 | - $this->_tax_rate += $line_item->percent(); |
|
93 | - break; |
|
94 | - |
|
95 | - case EEM_Line_Item::type_tax_sub_total: |
|
96 | - foreach ($line_item->children() as $child_line_item) { |
|
97 | - if ($child_line_item->type() == EEM_Line_Item::type_tax) { |
|
98 | - // recursively feed children back into this method |
|
99 | - $this->display_line_item($child_line_item, $options); |
|
100 | - } |
|
101 | - } |
|
102 | - break; |
|
103 | - |
|
104 | - case EEM_Line_Item::type_total: |
|
105 | - // get all child line items |
|
106 | - $children = $line_item->children(); |
|
107 | - if ($options['set_tax_rate'] === true) { |
|
108 | - // loop thru tax child line items just to determine tax rate |
|
109 | - foreach ($children as $child_line_item) { |
|
110 | - if ($child_line_item->type() == EEM_Line_Item::type_tax_sub_total) { |
|
111 | - // recursively feed children back into this method |
|
112 | - $this->display_line_item($child_line_item, $options); |
|
113 | - } |
|
114 | - } |
|
115 | - } else { |
|
116 | - // now loop thru all non-tax child line items |
|
117 | - foreach ($children as $child_line_item) { |
|
118 | - if ($child_line_item->type() != EEM_Line_Item::type_tax_sub_total) { |
|
119 | - // recursively feed children back into this method |
|
120 | - $html .= $this->display_line_item($child_line_item, $options); |
|
121 | - } |
|
122 | - } |
|
123 | - } |
|
124 | - break; |
|
125 | - } |
|
126 | - |
|
127 | - return $html; |
|
128 | - } |
|
129 | - |
|
130 | - |
|
131 | - |
|
132 | - /** |
|
133 | - * _total_row |
|
134 | - * |
|
135 | - * @param EE_Line_Item $line_item |
|
136 | - * @param array $options |
|
137 | - * @return mixed |
|
138 | - */ |
|
139 | - private function _item_row(EE_Line_Item $line_item, $options = array()) |
|
140 | - { |
|
141 | - // start of row |
|
142 | - $row_class = $options['odd'] ? 'item odd' : 'item'; |
|
143 | - $html = EEH_HTML::tr('', '', $row_class); |
|
144 | - // name && desc |
|
145 | - $name_and_desc = apply_filters( |
|
146 | - 'FHEE__EE_Default_Line_Item_Display_Strategy__item_row__name', |
|
147 | - $line_item->name(), |
|
148 | - $line_item |
|
149 | - ); |
|
150 | - $name_and_desc .= apply_filters( |
|
151 | - 'FHEE__EE_Default_Line_Item_Display_Strategy__item_row__desc', |
|
152 | - ( $options['show_desc'] ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : '' ), |
|
153 | - $line_item, |
|
154 | - $options |
|
155 | - ); |
|
156 | - if ($line_item->is_taxable()) { |
|
157 | - $ticket_price_includes_taxes = EE_Registry::instance()->CFG->tax_settings->prices_displayed_including_taxes |
|
158 | - ? esc_html__('* price includes taxes', 'event_espresso') |
|
159 | - : esc_html__('* price does not include taxes', 'event_espresso'); |
|
160 | - $name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">' |
|
161 | - . $ticket_price_includes_taxes |
|
162 | - . '</span>'; |
|
163 | - } |
|
164 | - |
|
165 | - // name td |
|
166 | - $html .= EEH_HTML::td($name_and_desc, '', 'item_l'); |
|
167 | - // quantity td |
|
168 | - $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght'); |
|
169 | - $tax_rate = $line_item->is_taxable() |
|
170 | - && EE_Registry::instance()->CFG->tax_settings->prices_displayed_including_taxes |
|
171 | - ? 1 + ( $this->_tax_rate / 100 ) |
|
172 | - : 1; |
|
173 | - // price td |
|
174 | - $unit_price = apply_filters( |
|
175 | - 'FHEE__EE_Default_Line_Item_Display_Strategy___item_row__unit_price', |
|
176 | - EEH_Template::format_currency($line_item->unit_price() * $tax_rate, false, false), |
|
177 | - $line_item, |
|
178 | - $tax_rate |
|
179 | - ); |
|
180 | - $html .= EEH_HTML::td($unit_price, '', 'item_c jst-rght'); |
|
181 | - // total td |
|
182 | - $total = apply_filters( |
|
183 | - 'FHEE__EE_Default_Line_Item_Display_Strategy___item_row__total', |
|
184 | - EEH_Template::format_currency($line_item->unit_price() * $line_item->quantity() * $tax_rate, false, false), |
|
185 | - $line_item, |
|
186 | - $tax_rate |
|
187 | - ); |
|
188 | - $html .= EEH_HTML::td($total, '', 'item_r jst-rght'); |
|
189 | - // end of row |
|
190 | - $html .= EEH_HTML::trx(); |
|
191 | - |
|
192 | - return $html; |
|
193 | - } |
|
194 | - |
|
195 | - |
|
196 | - |
|
197 | - /** |
|
198 | - * _sub_item_row |
|
199 | - * |
|
200 | - * @param EE_Line_Item $line_item |
|
201 | - * @param array $options |
|
202 | - * @return mixed |
|
203 | - */ |
|
204 | - private function _sub_item_row(EE_Line_Item $line_item, $options = array()) |
|
205 | - { |
|
206 | - // start of row |
|
207 | - $html = EEH_HTML::tr('', 'item sub-item-row'); |
|
208 | - // name && desc |
|
209 | - $name_and_desc = $line_item->name(); |
|
210 | - $name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : ''; |
|
211 | - // name td |
|
212 | - $html .= EEH_HTML::td(/*__FUNCTION__ .*/ $name_and_desc, '', 'item_l sub-item'); |
|
213 | - // discount/surcharge td |
|
214 | - if ($line_item->is_percent()) { |
|
215 | - $html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c'); |
|
216 | - } else { |
|
217 | - $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
218 | - } |
|
219 | - // total td |
|
220 | - $html .= EEH_HTML::td(EEH_Template::format_currency($line_item->total(), false, false), '', 'item_r jst-rght'); |
|
221 | - // end of row |
|
222 | - $html .= EEH_HTML::trx(); |
|
223 | - return $html; |
|
224 | - } |
|
18 | + /** |
|
19 | + * total amount of tax to apply |
|
20 | + * @type float $_tax_rate |
|
21 | + */ |
|
22 | + private $_tax_rate = 0; |
|
23 | + |
|
24 | + /** |
|
25 | + * total amount including tax we can bill for at this time |
|
26 | + * @type float $_grand_total |
|
27 | + */ |
|
28 | + private $_grand_total = 0.00; |
|
29 | + |
|
30 | + /** |
|
31 | + * total number of items being billed for |
|
32 | + * @type int $_total_items |
|
33 | + */ |
|
34 | + private $_total_items = 0; |
|
35 | + |
|
36 | + |
|
37 | + |
|
38 | + /** |
|
39 | + * @return float |
|
40 | + */ |
|
41 | + public function grand_total() |
|
42 | + { |
|
43 | + return $this->_grand_total; |
|
44 | + } |
|
45 | + |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * @return int |
|
50 | + */ |
|
51 | + public function total_items() |
|
52 | + { |
|
53 | + return $this->_total_items; |
|
54 | + } |
|
55 | + |
|
56 | + |
|
57 | + |
|
58 | + /** |
|
59 | + * @param EE_Line_Item $line_item |
|
60 | + * @param array $options |
|
61 | + * @return mixed |
|
62 | + */ |
|
63 | + public function display_line_item(EE_Line_Item $line_item, $options = array()) |
|
64 | + { |
|
65 | + |
|
66 | + $html = ''; |
|
67 | + // set some default options and merge with incoming |
|
68 | + $default_options = array( |
|
69 | + 'show_desc' => true, // TRUE FALSE |
|
70 | + 'odd' => false |
|
71 | + ); |
|
72 | + $options = array_merge($default_options, (array) $options); |
|
73 | + |
|
74 | + switch ($line_item->type()) { |
|
75 | + case EEM_Line_Item::type_line_item: |
|
76 | + // item row |
|
77 | + $html .= $this->_item_row($line_item, $options); |
|
78 | + // got any kids? |
|
79 | + foreach ($line_item->children() as $child_line_item) { |
|
80 | + $this->display_line_item($child_line_item, $options); |
|
81 | + } |
|
82 | + break; |
|
83 | + |
|
84 | + case EEM_Line_Item::type_sub_line_item: |
|
85 | + $html .= $this->_sub_item_row($line_item, $options); |
|
86 | + break; |
|
87 | + |
|
88 | + case EEM_Line_Item::type_sub_total: |
|
89 | + break; |
|
90 | + |
|
91 | + case EEM_Line_Item::type_tax: |
|
92 | + $this->_tax_rate += $line_item->percent(); |
|
93 | + break; |
|
94 | + |
|
95 | + case EEM_Line_Item::type_tax_sub_total: |
|
96 | + foreach ($line_item->children() as $child_line_item) { |
|
97 | + if ($child_line_item->type() == EEM_Line_Item::type_tax) { |
|
98 | + // recursively feed children back into this method |
|
99 | + $this->display_line_item($child_line_item, $options); |
|
100 | + } |
|
101 | + } |
|
102 | + break; |
|
103 | + |
|
104 | + case EEM_Line_Item::type_total: |
|
105 | + // get all child line items |
|
106 | + $children = $line_item->children(); |
|
107 | + if ($options['set_tax_rate'] === true) { |
|
108 | + // loop thru tax child line items just to determine tax rate |
|
109 | + foreach ($children as $child_line_item) { |
|
110 | + if ($child_line_item->type() == EEM_Line_Item::type_tax_sub_total) { |
|
111 | + // recursively feed children back into this method |
|
112 | + $this->display_line_item($child_line_item, $options); |
|
113 | + } |
|
114 | + } |
|
115 | + } else { |
|
116 | + // now loop thru all non-tax child line items |
|
117 | + foreach ($children as $child_line_item) { |
|
118 | + if ($child_line_item->type() != EEM_Line_Item::type_tax_sub_total) { |
|
119 | + // recursively feed children back into this method |
|
120 | + $html .= $this->display_line_item($child_line_item, $options); |
|
121 | + } |
|
122 | + } |
|
123 | + } |
|
124 | + break; |
|
125 | + } |
|
126 | + |
|
127 | + return $html; |
|
128 | + } |
|
129 | + |
|
130 | + |
|
131 | + |
|
132 | + /** |
|
133 | + * _total_row |
|
134 | + * |
|
135 | + * @param EE_Line_Item $line_item |
|
136 | + * @param array $options |
|
137 | + * @return mixed |
|
138 | + */ |
|
139 | + private function _item_row(EE_Line_Item $line_item, $options = array()) |
|
140 | + { |
|
141 | + // start of row |
|
142 | + $row_class = $options['odd'] ? 'item odd' : 'item'; |
|
143 | + $html = EEH_HTML::tr('', '', $row_class); |
|
144 | + // name && desc |
|
145 | + $name_and_desc = apply_filters( |
|
146 | + 'FHEE__EE_Default_Line_Item_Display_Strategy__item_row__name', |
|
147 | + $line_item->name(), |
|
148 | + $line_item |
|
149 | + ); |
|
150 | + $name_and_desc .= apply_filters( |
|
151 | + 'FHEE__EE_Default_Line_Item_Display_Strategy__item_row__desc', |
|
152 | + ( $options['show_desc'] ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : '' ), |
|
153 | + $line_item, |
|
154 | + $options |
|
155 | + ); |
|
156 | + if ($line_item->is_taxable()) { |
|
157 | + $ticket_price_includes_taxes = EE_Registry::instance()->CFG->tax_settings->prices_displayed_including_taxes |
|
158 | + ? esc_html__('* price includes taxes', 'event_espresso') |
|
159 | + : esc_html__('* price does not include taxes', 'event_espresso'); |
|
160 | + $name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">' |
|
161 | + . $ticket_price_includes_taxes |
|
162 | + . '</span>'; |
|
163 | + } |
|
164 | + |
|
165 | + // name td |
|
166 | + $html .= EEH_HTML::td($name_and_desc, '', 'item_l'); |
|
167 | + // quantity td |
|
168 | + $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght'); |
|
169 | + $tax_rate = $line_item->is_taxable() |
|
170 | + && EE_Registry::instance()->CFG->tax_settings->prices_displayed_including_taxes |
|
171 | + ? 1 + ( $this->_tax_rate / 100 ) |
|
172 | + : 1; |
|
173 | + // price td |
|
174 | + $unit_price = apply_filters( |
|
175 | + 'FHEE__EE_Default_Line_Item_Display_Strategy___item_row__unit_price', |
|
176 | + EEH_Template::format_currency($line_item->unit_price() * $tax_rate, false, false), |
|
177 | + $line_item, |
|
178 | + $tax_rate |
|
179 | + ); |
|
180 | + $html .= EEH_HTML::td($unit_price, '', 'item_c jst-rght'); |
|
181 | + // total td |
|
182 | + $total = apply_filters( |
|
183 | + 'FHEE__EE_Default_Line_Item_Display_Strategy___item_row__total', |
|
184 | + EEH_Template::format_currency($line_item->unit_price() * $line_item->quantity() * $tax_rate, false, false), |
|
185 | + $line_item, |
|
186 | + $tax_rate |
|
187 | + ); |
|
188 | + $html .= EEH_HTML::td($total, '', 'item_r jst-rght'); |
|
189 | + // end of row |
|
190 | + $html .= EEH_HTML::trx(); |
|
191 | + |
|
192 | + return $html; |
|
193 | + } |
|
194 | + |
|
195 | + |
|
196 | + |
|
197 | + /** |
|
198 | + * _sub_item_row |
|
199 | + * |
|
200 | + * @param EE_Line_Item $line_item |
|
201 | + * @param array $options |
|
202 | + * @return mixed |
|
203 | + */ |
|
204 | + private function _sub_item_row(EE_Line_Item $line_item, $options = array()) |
|
205 | + { |
|
206 | + // start of row |
|
207 | + $html = EEH_HTML::tr('', 'item sub-item-row'); |
|
208 | + // name && desc |
|
209 | + $name_and_desc = $line_item->name(); |
|
210 | + $name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : ''; |
|
211 | + // name td |
|
212 | + $html .= EEH_HTML::td(/*__FUNCTION__ .*/ $name_and_desc, '', 'item_l sub-item'); |
|
213 | + // discount/surcharge td |
|
214 | + if ($line_item->is_percent()) { |
|
215 | + $html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c'); |
|
216 | + } else { |
|
217 | + $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
218 | + } |
|
219 | + // total td |
|
220 | + $html .= EEH_HTML::td(EEH_Template::format_currency($line_item->total(), false, false), '', 'item_r jst-rght'); |
|
221 | + // end of row |
|
222 | + $html .= EEH_HTML::trx(); |
|
223 | + return $html; |
|
224 | + } |
|
225 | 225 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | $html = ''; |
67 | 67 | // set some default options and merge with incoming |
68 | 68 | $default_options = array( |
69 | - 'show_desc' => true, // TRUE FALSE |
|
69 | + 'show_desc' => true, // TRUE FALSE |
|
70 | 70 | 'odd' => false |
71 | 71 | ); |
72 | 72 | $options = array_merge($default_options, (array) $options); |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | ); |
150 | 150 | $name_and_desc .= apply_filters( |
151 | 151 | 'FHEE__EE_Default_Line_Item_Display_Strategy__item_row__desc', |
152 | - ( $options['show_desc'] ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : '' ), |
|
152 | + ($options['show_desc'] ? '<span class="line-item-desc-spn smaller-text">: '.$line_item->desc().'</span>' : ''), |
|
153 | 153 | $line_item, |
154 | 154 | $options |
155 | 155 | ); |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght'); |
169 | 169 | $tax_rate = $line_item->is_taxable() |
170 | 170 | && EE_Registry::instance()->CFG->tax_settings->prices_displayed_including_taxes |
171 | - ? 1 + ( $this->_tax_rate / 100 ) |
|
171 | + ? 1 + ($this->_tax_rate / 100) |
|
172 | 172 | : 1; |
173 | 173 | // price td |
174 | 174 | $unit_price = apply_filters( |
@@ -207,12 +207,12 @@ discard block |
||
207 | 207 | $html = EEH_HTML::tr('', 'item sub-item-row'); |
208 | 208 | // name && desc |
209 | 209 | $name_and_desc = $line_item->name(); |
210 | - $name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : ''; |
|
210 | + $name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: '.$line_item->desc().'</span>' : ''; |
|
211 | 211 | // name td |
212 | 212 | $html .= EEH_HTML::td(/*__FUNCTION__ .*/ $name_and_desc, '', 'item_l sub-item'); |
213 | 213 | // discount/surcharge td |
214 | 214 | if ($line_item->is_percent()) { |
215 | - $html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c'); |
|
215 | + $html .= EEH_HTML::td($line_item->percent().'%', '', 'item_c'); |
|
216 | 216 | } else { |
217 | 217 | $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
218 | 218 | } |