@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\exceptions; |
3 | 3 | |
4 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
5 | - exit( 'No direct script access allowed' ); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -15,5 +15,5 @@ discard block |
||
15 | 15 | * @author Darren Ethier |
16 | 16 | * @since 4.9.11.rc.001 |
17 | 17 | */ |
18 | -class SendMessageException extends \RuntimeException {} |
|
18 | +class SendMessageException extends \RuntimeException {} |
|
19 | 19 | // End of file SendMessageException.php |
20 | 20 | \ No newline at end of file |
@@ -3,8 +3,8 @@ discard block |
||
3 | 3 | use EventEspresso\core\domain\entities\RegUrlLink; |
4 | 4 | use EventEspresso\core\domain\services\registration\CreateRegistrationService; |
5 | 5 | |
6 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
7 | -EE_Registry::instance()->load_class( 'Processor_Base' ); |
|
6 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
7 | +EE_Registry::instance()->load_class('Processor_Base'); |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Class EE_Registration_Processor |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public static function instance() { |
68 | 68 | // check if class object is instantiated |
69 | - if ( ! self::$_instance instanceof EE_Registration_Processor ) { |
|
69 | + if ( ! self::$_instance instanceof EE_Registration_Processor) { |
|
70 | 70 | self::$_instance = new self(); |
71 | 71 | } |
72 | 72 | return self::$_instance; |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | * @param int $REG_ID |
87 | 87 | * @return string |
88 | 88 | */ |
89 | - public function old_reg_status( $REG_ID ) { |
|
90 | - return isset( $this->_old_reg_status[ $REG_ID ] ) ? $this->_old_reg_status[ $REG_ID ] : null; |
|
89 | + public function old_reg_status($REG_ID) { |
|
90 | + return isset($this->_old_reg_status[$REG_ID]) ? $this->_old_reg_status[$REG_ID] : null; |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | |
@@ -96,10 +96,10 @@ discard block |
||
96 | 96 | * @param int $REG_ID |
97 | 97 | * @param string $old_reg_status |
98 | 98 | */ |
99 | - public function set_old_reg_status( $REG_ID, $old_reg_status ) { |
|
99 | + public function set_old_reg_status($REG_ID, $old_reg_status) { |
|
100 | 100 | // only set the first time |
101 | - if ( ! isset( $this->_old_reg_status[ $REG_ID ] ) ) { |
|
102 | - $this->_old_reg_status[ $REG_ID ] = $old_reg_status; |
|
101 | + if ( ! isset($this->_old_reg_status[$REG_ID])) { |
|
102 | + $this->_old_reg_status[$REG_ID] = $old_reg_status; |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | * @param int $REG_ID |
110 | 110 | * @return string |
111 | 111 | */ |
112 | - public function new_reg_status( $REG_ID ) { |
|
113 | - return isset( $this->_new_reg_status[ $REG_ID ] ) ? $this->_new_reg_status[ $REG_ID ] : null; |
|
112 | + public function new_reg_status($REG_ID) { |
|
113 | + return isset($this->_new_reg_status[$REG_ID]) ? $this->_new_reg_status[$REG_ID] : null; |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | * @param int $REG_ID |
120 | 120 | * @param string $new_reg_status |
121 | 121 | */ |
122 | - public function set_new_reg_status( $REG_ID, $new_reg_status ) { |
|
123 | - $this->_new_reg_status[ $REG_ID ] = $new_reg_status; |
|
122 | + public function set_new_reg_status($REG_ID, $new_reg_status) { |
|
123 | + $this->_new_reg_status[$REG_ID] = $new_reg_status; |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | * @param int $REG_ID |
132 | 132 | * @return bool |
133 | 133 | */ |
134 | - public function reg_status_updated( $REG_ID ) { |
|
135 | - return $this->new_reg_status( $REG_ID ) !== $this->old_reg_status( $REG_ID ) ? true : false; |
|
134 | + public function reg_status_updated($REG_ID) { |
|
135 | + return $this->new_reg_status($REG_ID) !== $this->old_reg_status($REG_ID) ? true : false; |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | |
@@ -141,13 +141,13 @@ discard block |
||
141 | 141 | * @param \EE_Registration $registration |
142 | 142 | * @throws \EE_Error |
143 | 143 | */ |
144 | - public function update_registration_status_and_trigger_notifications( \EE_Registration $registration ) { |
|
145 | - $this->toggle_incomplete_registration_status_to_default( $registration, false ); |
|
146 | - $this->toggle_registration_status_for_default_approved_events( $registration, false ); |
|
147 | - $this->toggle_registration_status_if_no_monies_owing( $registration, false ); |
|
144 | + public function update_registration_status_and_trigger_notifications(\EE_Registration $registration) { |
|
145 | + $this->toggle_incomplete_registration_status_to_default($registration, false); |
|
146 | + $this->toggle_registration_status_for_default_approved_events($registration, false); |
|
147 | + $this->toggle_registration_status_if_no_monies_owing($registration, false); |
|
148 | 148 | $registration->save(); |
149 | 149 | // trigger notifications |
150 | - $this->trigger_registration_update_notifications( $registration ); |
|
150 | + $this->trigger_registration_update_notifications($registration); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | |
@@ -162,18 +162,18 @@ discard block |
||
162 | 162 | * @return boolean |
163 | 163 | * @throws \EE_Error |
164 | 164 | */ |
165 | - public function manually_update_registration_status( EE_Registration $registration, $new_reg_status = '', $save = true ) { |
|
165 | + public function manually_update_registration_status(EE_Registration $registration, $new_reg_status = '', $save = true) { |
|
166 | 166 | // set initial REG_Status |
167 | - $this->set_old_reg_status( $registration->ID(), $registration->status_ID() ); |
|
167 | + $this->set_old_reg_status($registration->ID(), $registration->status_ID()); |
|
168 | 168 | // set incoming REG_Status |
169 | - $this->set_new_reg_status( $registration->ID(), $new_reg_status ); |
|
169 | + $this->set_new_reg_status($registration->ID(), $new_reg_status); |
|
170 | 170 | // toggle reg status but only if it has changed and the user can do so |
171 | 171 | if ( |
172 | - $this->reg_status_updated( $registration->ID() ) && |
|
173 | - EE_Registry::instance()->CAP->current_user_can( 'ee_edit_registration', 'toggle_registration_status', $registration->ID() ) |
|
172 | + $this->reg_status_updated($registration->ID()) && |
|
173 | + EE_Registry::instance()->CAP->current_user_can('ee_edit_registration', 'toggle_registration_status', $registration->ID()) |
|
174 | 174 | ) { |
175 | 175 | // change status to new value |
176 | - if ( $registration->set_status( $this->new_reg_status( $registration->ID() ) ) && $save ) { |
|
176 | + if ($registration->set_status($this->new_reg_status($registration->ID())) && $save) { |
|
177 | 177 | $registration->save(); |
178 | 178 | } |
179 | 179 | return TRUE; |
@@ -193,30 +193,30 @@ discard block |
||
193 | 193 | * @return void |
194 | 194 | * @throws \EE_Error |
195 | 195 | */ |
196 | - public function toggle_incomplete_registration_status_to_default( EE_Registration $registration, $save = TRUE ) { |
|
196 | + public function toggle_incomplete_registration_status_to_default(EE_Registration $registration, $save = TRUE) { |
|
197 | 197 | $existing_reg_status = $registration->status_ID(); |
198 | 198 | // set initial REG_Status |
199 | - $this->set_old_reg_status( $registration->ID(), $existing_reg_status ); |
|
199 | + $this->set_old_reg_status($registration->ID(), $existing_reg_status); |
|
200 | 200 | // is the registration currently incomplete ? |
201 | - if ( $registration->status_ID() === EEM_Registration::status_id_incomplete ) { |
|
201 | + if ($registration->status_ID() === EEM_Registration::status_id_incomplete) { |
|
202 | 202 | // grab default reg status for the event, if set |
203 | 203 | $event_default_registration_status = $registration->event()->default_registration_status(); |
204 | 204 | // if no default reg status is set for the event, then use the global value |
205 | - $STS_ID = ! empty( $event_default_registration_status ) |
|
205 | + $STS_ID = ! empty($event_default_registration_status) |
|
206 | 206 | ? $event_default_registration_status |
207 | 207 | : EE_Registry::instance()->CFG->registration->default_STS_ID; |
208 | 208 | // if the event default reg status is approved, then downgrade temporarily to payment pending to ensure that payments are triggered |
209 | 209 | $STS_ID = $STS_ID === EEM_Registration::status_id_approved ? EEM_Registration::status_id_pending_payment : $STS_ID; |
210 | 210 | // set incoming REG_Status |
211 | - $this->set_new_reg_status( $registration->ID(), $STS_ID ); |
|
212 | - $registration->set_status( $STS_ID ); |
|
213 | - if ( $save ) { |
|
211 | + $this->set_new_reg_status($registration->ID(), $STS_ID); |
|
212 | + $registration->set_status($STS_ID); |
|
213 | + if ($save) { |
|
214 | 214 | $registration->save(); |
215 | 215 | } |
216 | 216 | // don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor |
217 | - if ( ! EE_Processor_Base::$IPN ) { |
|
217 | + if ( ! EE_Processor_Base::$IPN) { |
|
218 | 218 | // otherwise, send out notifications |
219 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 ); |
|
219 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10); |
|
220 | 220 | } |
221 | 221 | // DEBUG LOG |
222 | 222 | //$this->log( |
@@ -241,10 +241,10 @@ discard block |
||
241 | 241 | * @return boolean |
242 | 242 | * @throws \EE_Error |
243 | 243 | */ |
244 | - public function toggle_registration_status_for_default_approved_events( EE_Registration $registration, $save = TRUE ) { |
|
244 | + public function toggle_registration_status_for_default_approved_events(EE_Registration $registration, $save = TRUE) { |
|
245 | 245 | $reg_status = $registration->status_ID(); |
246 | 246 | // set initial REG_Status |
247 | - $this->set_old_reg_status( $registration->ID(), $reg_status ); |
|
247 | + $this->set_old_reg_status($registration->ID(), $reg_status); |
|
248 | 248 | // if not already, toggle reg status to approved IF the event default reg status is approved |
249 | 249 | // ( as long as the registration wasn't cancelled or declined at some point ) |
250 | 250 | if ( |
@@ -254,16 +254,16 @@ discard block |
||
254 | 254 | $registration->event()->default_registration_status() === EEM_Registration::status_id_approved |
255 | 255 | ) { |
256 | 256 | // set incoming REG_Status |
257 | - $this->set_new_reg_status( $registration->ID(), EEM_Registration::status_id_approved ); |
|
257 | + $this->set_new_reg_status($registration->ID(), EEM_Registration::status_id_approved); |
|
258 | 258 | // toggle status to approved |
259 | - $registration->set_status( EEM_Registration::status_id_approved ); |
|
260 | - if ( $save ) { |
|
259 | + $registration->set_status(EEM_Registration::status_id_approved); |
|
260 | + if ($save) { |
|
261 | 261 | $registration->save(); |
262 | 262 | } |
263 | 263 | // don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor |
264 | - if ( ! EE_Processor_Base::$IPN ) { |
|
264 | + if ( ! EE_Processor_Base::$IPN) { |
|
265 | 265 | // otherwise, send out notifications |
266 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 ); |
|
266 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10); |
|
267 | 267 | } |
268 | 268 | // DEBUG LOG |
269 | 269 | //$this->log( |
@@ -291,19 +291,19 @@ discard block |
||
291 | 291 | * @return bool |
292 | 292 | * @throws \EE_Error |
293 | 293 | */ |
294 | - public function toggle_registration_status_if_no_monies_owing( EE_Registration $registration, $save = TRUE, $additional_details = array() ) { |
|
294 | + public function toggle_registration_status_if_no_monies_owing(EE_Registration $registration, $save = TRUE, $additional_details = array()) { |
|
295 | 295 | // set initial REG_Status |
296 | - $this->set_old_reg_status( $registration->ID(), $registration->status_ID() ); |
|
296 | + $this->set_old_reg_status($registration->ID(), $registration->status_ID()); |
|
297 | 297 | //EEH_Debug_Tools::printr( $additional_details, '$additional_details', __FILE__, __LINE__ ); |
298 | 298 | // was a payment just made ? |
299 | 299 | if ( |
300 | - isset( $additional_details[ 'payment_updates' ], $additional_details[ 'last_payment' ] ) && |
|
301 | - $additional_details[ 'payment_updates' ] && |
|
302 | - $additional_details[ 'last_payment' ] instanceof EE_Payment |
|
300 | + isset($additional_details['payment_updates'], $additional_details['last_payment']) && |
|
301 | + $additional_details['payment_updates'] && |
|
302 | + $additional_details['last_payment'] instanceof EE_Payment |
|
303 | 303 | ) { |
304 | - $payment = $additional_details[ 'last_payment' ]; |
|
304 | + $payment = $additional_details['last_payment']; |
|
305 | 305 | $total_paid = 0; |
306 | - foreach ( self::$_amount_paid as $reg => $amount_paid ) { |
|
306 | + foreach (self::$_amount_paid as $reg => $amount_paid) { |
|
307 | 307 | $total_paid += $amount_paid; |
308 | 308 | } |
309 | 309 | } else { |
@@ -327,30 +327,30 @@ discard block |
||
327 | 327 | $registration->transaction()->is_completed() || |
328 | 328 | $registration->transaction()->is_overpaid() || |
329 | 329 | $registration->transaction()->is_free() || |
330 | - apply_filters( 'FHEE__EE_Registration_Processor__toggle_registration_status_if_no_monies_owing', false, $registration ) |
|
330 | + apply_filters('FHEE__EE_Registration_Processor__toggle_registration_status_if_no_monies_owing', false, $registration) |
|
331 | 331 | ) || ( |
332 | 332 | $payment instanceof EE_Payment && |
333 | 333 | $payment->is_approved() && |
334 | 334 | // this specific registration has not yet been paid for |
335 | - ! isset( self::$_amount_paid[ $registration->ID() ] ) && |
|
335 | + ! isset(self::$_amount_paid[$registration->ID()]) && |
|
336 | 336 | // payment amount, less what we have already attributed to other registrations, is greater than this reg's final price |
337 | 337 | $payment->amount() - $total_paid >= $registration->final_price() |
338 | 338 | ) |
339 | 339 | ) |
340 | 340 | ) { |
341 | 341 | // mark as paid |
342 | - self::$_amount_paid[ $registration->ID() ] = $registration->final_price(); |
|
342 | + self::$_amount_paid[$registration->ID()] = $registration->final_price(); |
|
343 | 343 | // track new REG_Status |
344 | - $this->set_new_reg_status( $registration->ID(), EEM_Registration::status_id_approved ); |
|
344 | + $this->set_new_reg_status($registration->ID(), EEM_Registration::status_id_approved); |
|
345 | 345 | // toggle status to approved |
346 | - $registration->set_status( EEM_Registration::status_id_approved ); |
|
347 | - if ( $save ) { |
|
346 | + $registration->set_status(EEM_Registration::status_id_approved); |
|
347 | + if ($save) { |
|
348 | 348 | $registration->save(); |
349 | 349 | } |
350 | 350 | // don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor |
351 | - if ( ! EE_Processor_Base::$IPN ) { |
|
351 | + if ( ! EE_Processor_Base::$IPN) { |
|
352 | 352 | // otherwise, send out notifications |
353 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 ); |
|
353 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10); |
|
354 | 354 | } |
355 | 355 | // DEBUG LOG |
356 | 356 | //$this->log( |
@@ -376,27 +376,27 @@ discard block |
||
376 | 376 | * @param array $additional_details |
377 | 377 | * @return void |
378 | 378 | */ |
379 | - public function trigger_registration_update_notifications( $registration, $additional_details = array() ) { |
|
379 | + public function trigger_registration_update_notifications($registration, $additional_details = array()) { |
|
380 | 380 | try { |
381 | - if ( ! $registration instanceof EE_Registration ) { |
|
382 | - throw new EE_Error( __( 'An invalid registration was received.', 'event_espresso' ) ); |
|
381 | + if ( ! $registration instanceof EE_Registration) { |
|
382 | + throw new EE_Error(__('An invalid registration was received.', 'event_espresso')); |
|
383 | 383 | } |
384 | - EE_Registry::instance()->load_helper( 'Debug_Tools' ); |
|
384 | + EE_Registry::instance()->load_helper('Debug_Tools'); |
|
385 | 385 | EEH_Debug_Tools::log( |
386 | 386 | __CLASS__, |
387 | 387 | __FUNCTION__, |
388 | 388 | __LINE__, |
389 | - array( $registration->transaction(), $additional_details ), |
|
389 | + array($registration->transaction(), $additional_details), |
|
390 | 390 | false, |
391 | - 'EE_Transaction: ' . $registration->transaction()->ID() |
|
391 | + 'EE_Transaction: '.$registration->transaction()->ID() |
|
392 | 392 | ); |
393 | 393 | do_action( |
394 | 394 | 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', |
395 | 395 | $registration, |
396 | 396 | $additional_details |
397 | 397 | ); |
398 | - } catch( Exception $e ) { |
|
399 | - EE_Error::add_error( $e->getMessage(), $e->getFile(), 'unknown_function_from_exception', $e->getLine() ); |
|
398 | + } catch (Exception $e) { |
|
399 | + EE_Error::add_error($e->getMessage(), $e->getFile(), 'unknown_function_from_exception', $e->getLine()); |
|
400 | 400 | } |
401 | 401 | } |
402 | 402 | |
@@ -410,22 +410,22 @@ discard block |
||
410 | 410 | * @return bool |
411 | 411 | * @throws \EE_Error |
412 | 412 | */ |
413 | - public function update_registration_after_checkout_or_payment( EE_Registration $registration, $additional_details = array() ) { |
|
413 | + public function update_registration_after_checkout_or_payment(EE_Registration $registration, $additional_details = array()) { |
|
414 | 414 | // set initial REG_Status |
415 | - $this->set_old_reg_status( $registration->ID(), $registration->status_ID() ); |
|
415 | + $this->set_old_reg_status($registration->ID(), $registration->status_ID()); |
|
416 | 416 | |
417 | 417 | // if the registration status gets updated, then save the registration |
418 | 418 | if ( |
419 | - $this->toggle_registration_status_for_default_approved_events( $registration, false ) |
|
420 | - || $this->toggle_registration_status_if_no_monies_owing( $registration, false, $additional_details ) |
|
419 | + $this->toggle_registration_status_for_default_approved_events($registration, false) |
|
420 | + || $this->toggle_registration_status_if_no_monies_owing($registration, false, $additional_details) |
|
421 | 421 | ) { |
422 | 422 | $registration->save(); |
423 | 423 | } |
424 | 424 | |
425 | 425 | // set new REG_Status |
426 | - $this->set_new_reg_status( $registration->ID(), $registration->status_ID() ); |
|
427 | - return $this->reg_status_updated( $registration->ID() ) |
|
428 | - && $this->new_reg_status( $registration->ID() ) === EEM_Registration::status_id_approved |
|
426 | + $this->set_new_reg_status($registration->ID(), $registration->status_ID()); |
|
427 | + return $this->reg_status_updated($registration->ID()) |
|
428 | + && $this->new_reg_status($registration->ID()) === EEM_Registration::status_id_approved |
|
429 | 429 | ? true |
430 | 430 | : false; |
431 | 431 | } |
@@ -441,20 +441,20 @@ discard block |
||
441 | 441 | * @return void |
442 | 442 | * @throws \EE_Error |
443 | 443 | */ |
444 | - public function update_registration_final_prices( $transaction, $save_regs = true ) { |
|
445 | - $reg_final_price_per_ticket_line_item = EEH_Line_Item::calculate_reg_final_prices_per_line_item( $transaction->total_line_item() ); |
|
446 | - foreach( $transaction->registrations() as $registration ) { |
|
444 | + public function update_registration_final_prices($transaction, $save_regs = true) { |
|
445 | + $reg_final_price_per_ticket_line_item = EEH_Line_Item::calculate_reg_final_prices_per_line_item($transaction->total_line_item()); |
|
446 | + foreach ($transaction->registrations() as $registration) { |
|
447 | 447 | /** @var EE_Line_Item $line_item */ |
448 | - $line_item = EEM_Line_Item::instance()->get_line_item_for_registration( $registration ); |
|
449 | - if( isset( $reg_final_price_per_ticket_line_item[ $line_item->ID() ] ) ) { |
|
450 | - $registration->set_final_price( $reg_final_price_per_ticket_line_item[ $line_item->ID() ] ); |
|
451 | - if( $save_regs ) { |
|
448 | + $line_item = EEM_Line_Item::instance()->get_line_item_for_registration($registration); |
|
449 | + if (isset($reg_final_price_per_ticket_line_item[$line_item->ID()])) { |
|
450 | + $registration->set_final_price($reg_final_price_per_ticket_line_item[$line_item->ID()]); |
|
451 | + if ($save_regs) { |
|
452 | 452 | $registration->save(); |
453 | 453 | } |
454 | 454 | } |
455 | 455 | } |
456 | 456 | //and make sure there's no rounding problem |
457 | - $this->fix_reg_final_price_rounding_issue( $transaction ); |
|
457 | + $this->fix_reg_final_price_rounding_issue($transaction); |
|
458 | 458 | } |
459 | 459 | |
460 | 460 | |
@@ -474,7 +474,7 @@ discard block |
||
474 | 474 | * @return boolean success verifying that there is NO difference after this method is done |
475 | 475 | * @throws \EE_Error |
476 | 476 | */ |
477 | - public function fix_reg_final_price_rounding_issue( $transaction ) { |
|
477 | + public function fix_reg_final_price_rounding_issue($transaction) { |
|
478 | 478 | $reg_final_price_sum = EEM_Registration::instance()->sum( |
479 | 479 | array( |
480 | 480 | array( |
@@ -483,9 +483,9 @@ discard block |
||
483 | 483 | ), |
484 | 484 | 'REG_final_price' |
485 | 485 | ); |
486 | - $diff = $transaction->total() - (float) $reg_final_price_sum; |
|
486 | + $diff = $transaction->total() - (float) $reg_final_price_sum; |
|
487 | 487 | //ok then, just grab one of the registrations |
488 | - if( $diff !== 0 ) { |
|
488 | + if ($diff !== 0) { |
|
489 | 489 | $a_reg = EEM_Registration::instance()->get_one( |
490 | 490 | array( |
491 | 491 | array( |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | )); |
495 | 495 | $success = $a_reg instanceof EE_Registration |
496 | 496 | ? $a_reg->save( |
497 | - array( 'REG_final_price' => $a_reg->final_price() + $diff ) |
|
497 | + array('REG_final_price' => $a_reg->final_price() + $diff) |
|
498 | 498 | ) |
499 | 499 | : false; |
500 | 500 | return $success ? true : false; |
@@ -519,13 +519,13 @@ discard block |
||
519 | 519 | $update_reg = true |
520 | 520 | ) { |
521 | 521 | // these reg statuses should not be considered in any calculations involving monies owing |
522 | - $closed_reg_statuses = ! empty( $closed_reg_statuses ) ? $closed_reg_statuses |
|
522 | + $closed_reg_statuses = ! empty($closed_reg_statuses) ? $closed_reg_statuses |
|
523 | 523 | : EEM_Registration::closed_reg_statuses(); |
524 | - if ( ! in_array( $registration->status_ID(), $closed_reg_statuses ) ) { |
|
524 | + if ( ! in_array($registration->status_ID(), $closed_reg_statuses)) { |
|
525 | 525 | return false; |
526 | 526 | } |
527 | 527 | $registration->set_final_price(0); |
528 | - if ( $update_reg ) { |
|
528 | + if ($update_reg) { |
|
529 | 529 | $registration->save(); |
530 | 530 | } |
531 | 531 | return true; |
@@ -548,23 +548,23 @@ discard block |
||
548 | 548 | $update_reg = true |
549 | 549 | ) { |
550 | 550 | // these reg statuses should not be considered in any calculations involving monies owing |
551 | - $closed_reg_statuses = ! empty( $closed_reg_statuses ) ? $closed_reg_statuses |
|
551 | + $closed_reg_statuses = ! empty($closed_reg_statuses) ? $closed_reg_statuses |
|
552 | 552 | : EEM_Registration::closed_reg_statuses(); |
553 | - if ( in_array( $registration->status_ID(), $closed_reg_statuses ) ) { |
|
553 | + if (in_array($registration->status_ID(), $closed_reg_statuses)) { |
|
554 | 554 | return false; |
555 | 555 | } |
556 | 556 | $ticket = $registration->ticket(); |
557 | - if ( ! $ticket instanceof EE_Ticket ) { |
|
557 | + if ( ! $ticket instanceof EE_Ticket) { |
|
558 | 558 | throw new EE_Error( |
559 | 559 | sprintf( |
560 | - __( 'The Ticket for Registration %1$d was not found or is invalid.', |
|
561 | - 'event_espresso' ), |
|
560 | + __('The Ticket for Registration %1$d was not found or is invalid.', |
|
561 | + 'event_espresso'), |
|
562 | 562 | $registration->ticket_ID() |
563 | 563 | ) |
564 | 564 | ); |
565 | 565 | } |
566 | - $registration->set_final_price( $ticket->price() ); |
|
567 | - if ( $update_reg ) { |
|
566 | + $registration->set_final_price($ticket->price()); |
|
567 | + if ($update_reg) { |
|
568 | 568 | $registration->save(); |
569 | 569 | } |
570 | 570 | return true; |
@@ -602,7 +602,7 @@ discard block |
||
602 | 602 | $total_ticket_count = 1 |
603 | 603 | ) { |
604 | 604 | EE_Error::doing_it_wrong( |
605 | - __CLASS__ . '::' . __FUNCTION__, |
|
605 | + __CLASS__.'::'.__FUNCTION__, |
|
606 | 606 | sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'), |
607 | 607 | '\EventEspresso\core\domain\services\registration\CreateRegistrationService::create()'), |
608 | 608 | '4.9.1', |
@@ -645,7 +645,7 @@ discard block |
||
645 | 645 | public function generate_reg_url_link($att_nmbr, $item) |
646 | 646 | { |
647 | 647 | EE_Error::doing_it_wrong( |
648 | - __CLASS__ . '::' . __FUNCTION__, |
|
648 | + __CLASS__.'::'.__FUNCTION__, |
|
649 | 649 | sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'), |
650 | 650 | 'EventEspresso\core\domain\entities\RegUrlLink'), |
651 | 651 | '4.9.1', |
@@ -665,11 +665,11 @@ discard block |
||
665 | 665 | * @return string |
666 | 666 | * @throws \EE_Error |
667 | 667 | */ |
668 | - public function generate_reg_code( EE_Registration $registration ) { |
|
668 | + public function generate_reg_code(EE_Registration $registration) { |
|
669 | 669 | EE_Error::doing_it_wrong( |
670 | - __CLASS__ . '::' . __FUNCTION__, |
|
670 | + __CLASS__.'::'.__FUNCTION__, |
|
671 | 671 | sprintf( |
672 | - __( 'This method is deprecated. Please use "%s" instead', 'event_espresso' ), |
|
672 | + __('This method is deprecated. Please use "%s" instead', 'event_espresso'), |
|
673 | 673 | 'EventEspresso\core\domain\entities\RegCode' |
674 | 674 | ), |
675 | 675 | '4.9.1', |
@@ -678,7 +678,7 @@ discard block |
||
678 | 678 | return apply_filters( |
679 | 679 | 'FHEE__EE_Registration_Processor___generate_reg_code__new_reg_code', |
680 | 680 | new RegCode( |
681 | - RegUrlLink::fromRegistration( $registration ), |
|
681 | + RegUrlLink::fromRegistration($registration), |
|
682 | 682 | $registration->transaction(), |
683 | 683 | $registration->ticket() |
684 | 684 | ), |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | use \EventEspresso\core\exceptions\SendMessageException; |
3 | 3 | |
4 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
5 | - exit( 'No direct script access allowed' ); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | /** |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | * |
77 | 77 | * @param \EE_Message_Repository $message_repository |
78 | 78 | */ |
79 | - public function __construct( EE_Message_Repository $message_repository ) { |
|
80 | - $this->_batch_count = apply_filters( 'FHEE__EE_Messages_Queue___batch_count', 50 ); |
|
79 | + public function __construct(EE_Message_Repository $message_repository) { |
|
80 | + $this->_batch_count = apply_filters('FHEE__EE_Messages_Queue___batch_count', 50); |
|
81 | 81 | $this->_rate_limit = $this->get_rate_limit(); |
82 | 82 | $this->_message_repository = $message_repository; |
83 | 83 | } |
@@ -96,10 +96,10 @@ discard block |
||
96 | 96 | * use the messenger send method but typically is based on preview data. |
97 | 97 | * @return bool Whether the message was successfully added to the repository or not. |
98 | 98 | */ |
99 | - public function add( EE_Message $message, $data = array(), $preview = false, $test_send = false ) { |
|
99 | + public function add(EE_Message $message, $data = array(), $preview = false, $test_send = false) { |
|
100 | 100 | $data['preview'] = $preview; |
101 | 101 | $data['test_send'] = $test_send; |
102 | - return $this->_message_repository->add( $message, $data ); |
|
102 | + return $this->_message_repository->add($message, $data); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -111,13 +111,13 @@ discard block |
||
111 | 111 | * @param bool $persist This flag indicates whether to attempt to delete the object from the db as well. |
112 | 112 | * @return bool |
113 | 113 | */ |
114 | - public function remove( EE_Message $message, $persist = false ) { |
|
115 | - if ( $persist && $this->_message_repository->current() !== $message ) { |
|
114 | + public function remove(EE_Message $message, $persist = false) { |
|
115 | + if ($persist && $this->_message_repository->current() !== $message) { |
|
116 | 116 | //get pointer on right message |
117 | - if ( $this->_message_repository->has( $message ) ) { |
|
117 | + if ($this->_message_repository->has($message)) { |
|
118 | 118 | $this->_message_repository->rewind(); |
119 | - while( $this->_message_repository->valid() ) { |
|
120 | - if ( $this->_message_repository->current() === $message ) { |
|
119 | + while ($this->_message_repository->valid()) { |
|
120 | + if ($this->_message_repository->current() === $message) { |
|
121 | 121 | break; |
122 | 122 | } |
123 | 123 | $this->_message_repository->next(); |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | return false; |
127 | 127 | } |
128 | 128 | } |
129 | - return $persist ? $this->_message_repository->delete() : $this->_message_repository->remove( $message ); |
|
129 | + return $persist ? $this->_message_repository->delete() : $this->_message_repository->remove($message); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | |
@@ -166,29 +166,29 @@ discard block |
||
166 | 166 | * @return bool true if successfully retrieved batch, false no batch ready. |
167 | 167 | */ |
168 | 168 | public function get_batch_to_generate() { |
169 | - if ( $this->is_locked( EE_Messages_Queue::action_generating ) ) { |
|
169 | + if ($this->is_locked(EE_Messages_Queue::action_generating)) { |
|
170 | 170 | return false; |
171 | 171 | } |
172 | 172 | |
173 | 173 | //lock batch generation to prevent race conditions. |
174 | - $this->lock_queue( EE_Messages_Queue::action_generating ); |
|
174 | + $this->lock_queue(EE_Messages_Queue::action_generating); |
|
175 | 175 | |
176 | 176 | $query_args = array( |
177 | 177 | // key 0 = where conditions |
178 | - 0 => array( 'STS_ID' => EEM_Message::status_incomplete ), |
|
178 | + 0 => array('STS_ID' => EEM_Message::status_incomplete), |
|
179 | 179 | 'order_by' => $this->_get_priority_orderby(), |
180 | 180 | 'limit' => $this->_batch_count |
181 | 181 | ); |
182 | - $messages = EEM_Message::instance()->get_all( $query_args ); |
|
182 | + $messages = EEM_Message::instance()->get_all($query_args); |
|
183 | 183 | |
184 | - if ( ! $messages ) { |
|
184 | + if ( ! $messages) { |
|
185 | 185 | return false; //nothing to generate |
186 | 186 | } |
187 | 187 | |
188 | - foreach ( $messages as $message ) { |
|
189 | - if ( $message instanceof EE_Message ) { |
|
188 | + foreach ($messages as $message) { |
|
189 | + if ($message instanceof EE_Message) { |
|
190 | 190 | $data = $message->all_extra_meta_array(); |
191 | - $this->add( $message, $data ); |
|
191 | + $this->add($message, $data); |
|
192 | 192 | } |
193 | 193 | } |
194 | 194 | return true; |
@@ -211,34 +211,34 @@ discard block |
||
211 | 211 | * to assist with notifying user. |
212 | 212 | */ |
213 | 213 | public function get_to_send_batch_and_send() { |
214 | - if ( $this->is_locked( EE_Messages_Queue::action_sending ) || $this->_rate_limit < 1 ) { |
|
214 | + if ($this->is_locked(EE_Messages_Queue::action_sending) || $this->_rate_limit < 1) { |
|
215 | 215 | return false; |
216 | 216 | } |
217 | 217 | |
218 | - $this->lock_queue( EE_Messages_Queue::action_sending ); |
|
218 | + $this->lock_queue(EE_Messages_Queue::action_sending); |
|
219 | 219 | |
220 | 220 | $batch = $this->_batch_count < $this->_rate_limit ? $this->_batch_count : $this->_rate_limit; |
221 | 221 | |
222 | 222 | $query_args = array( |
223 | 223 | // key 0 = where conditions |
224 | - 0 => array( 'STS_ID' => array( 'IN', EEM_Message::instance()->stati_indicating_to_send() ) ), |
|
224 | + 0 => array('STS_ID' => array('IN', EEM_Message::instance()->stati_indicating_to_send())), |
|
225 | 225 | 'order_by' => $this->_get_priority_orderby(), |
226 | 226 | 'limit' => $batch |
227 | 227 | ); |
228 | 228 | |
229 | - $messages_to_send = EEM_Message::instance()->get_all( $query_args ); |
|
229 | + $messages_to_send = EEM_Message::instance()->get_all($query_args); |
|
230 | 230 | |
231 | 231 | |
232 | 232 | //any to send? |
233 | - if ( ! $messages_to_send ) { |
|
234 | - $this->unlock_queue( EE_Messages_Queue::action_sending ); |
|
233 | + if ( ! $messages_to_send) { |
|
234 | + $this->unlock_queue(EE_Messages_Queue::action_sending); |
|
235 | 235 | return false; |
236 | 236 | } |
237 | 237 | |
238 | 238 | //add to queue. |
239 | - foreach ( $messages_to_send as $message ) { |
|
240 | - if ( $message instanceof EE_Message ) { |
|
241 | - $this->add( $message ); |
|
239 | + foreach ($messages_to_send as $message) { |
|
240 | + if ($message instanceof EE_Message) { |
|
241 | + $this->add($message); |
|
242 | 242 | } |
243 | 243 | } |
244 | 244 | |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | $this->execute(); |
247 | 247 | |
248 | 248 | //release lock |
249 | - $this->unlock_queue( EE_Messages_Queue::action_sending ); |
|
249 | + $this->unlock_queue(EE_Messages_Queue::action_sending); |
|
250 | 250 | return true; |
251 | 251 | } |
252 | 252 | |
@@ -258,8 +258,8 @@ discard block |
||
258 | 258 | * |
259 | 259 | * @param string $type The type of queue being locked. |
260 | 260 | */ |
261 | - public function lock_queue( $type = EE_Messages_Queue::action_generating ) { |
|
262 | - set_transient( $this->_get_lock_key( $type ), 1, $this->_get_lock_expiry( $type ) ); |
|
261 | + public function lock_queue($type = EE_Messages_Queue::action_generating) { |
|
262 | + set_transient($this->_get_lock_key($type), 1, $this->_get_lock_expiry($type)); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | |
@@ -270,8 +270,8 @@ discard block |
||
270 | 270 | * |
271 | 271 | * @param string $type The type of queue being unlocked. |
272 | 272 | */ |
273 | - public function unlock_queue( $type = EE_Messages_Queue::action_generating ) { |
|
274 | - delete_transient( $this->_get_lock_key( $type ) ); |
|
273 | + public function unlock_queue($type = EE_Messages_Queue::action_generating) { |
|
274 | + delete_transient($this->_get_lock_key($type)); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | |
@@ -282,8 +282,8 @@ discard block |
||
282 | 282 | * @param string $type The type of lock. |
283 | 283 | * @return string |
284 | 284 | */ |
285 | - protected function _get_lock_key( $type = EE_Messages_Queue::action_generating ) { |
|
286 | - return '_ee_lock_' . $type; |
|
285 | + protected function _get_lock_key($type = EE_Messages_Queue::action_generating) { |
|
286 | + return '_ee_lock_'.$type; |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | |
@@ -294,8 +294,8 @@ discard block |
||
294 | 294 | * @param string $type The type of lock |
295 | 295 | * @return int time to expiry in seconds. |
296 | 296 | */ |
297 | - protected function _get_lock_expiry( $type = EE_Messages_Queue::action_generating ) { |
|
298 | - return (int) apply_filters( 'FHEE__EE_Messages_Queue__lock_expiry', HOUR_IN_SECONDS, $type ); |
|
297 | + protected function _get_lock_expiry($type = EE_Messages_Queue::action_generating) { |
|
298 | + return (int) apply_filters('FHEE__EE_Messages_Queue__lock_expiry', HOUR_IN_SECONDS, $type); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | * @return int |
314 | 314 | */ |
315 | 315 | protected function _get_rate_limit_expiry() { |
316 | - return (int) apply_filters( 'FHEE__EE_Messages_Queue__rate_limit_expiry', HOUR_IN_SECONDS ); |
|
316 | + return (int) apply_filters('FHEE__EE_Messages_Queue__rate_limit_expiry', HOUR_IN_SECONDS); |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | * @return int |
325 | 325 | */ |
326 | 326 | protected function _default_rate_limit() { |
327 | - return (int) apply_filters( 'FHEE__EE_Messages_Queue___rate_limit', 200 ); |
|
327 | + return (int) apply_filters('FHEE__EE_Messages_Queue___rate_limit', 200); |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | |
@@ -350,14 +350,14 @@ discard block |
||
350 | 350 | * @param string $type The type of lock being checked for. |
351 | 351 | * @return bool |
352 | 352 | */ |
353 | - public function is_locked( $type = EE_Messages_Queue::action_generating ) { |
|
353 | + public function is_locked($type = EE_Messages_Queue::action_generating) { |
|
354 | 354 | /** |
355 | 355 | * This filters the default is_locked behaviour. |
356 | 356 | */ |
357 | 357 | $is_locked = filter_var( |
358 | 358 | apply_filters( |
359 | 359 | 'FHEE__EE_Messages_Queue__is_locked', |
360 | - get_transient( $this->_get_lock_key( $type ) ), |
|
360 | + get_transient($this->_get_lock_key($type)), |
|
361 | 361 | $this |
362 | 362 | ), |
363 | 363 | FILTER_VALIDATE_BOOLEAN |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | * Also implemented here because messages processed on the same request should not have any locks applied. |
369 | 369 | */ |
370 | 370 | if ( |
371 | - apply_filters( 'FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false ) |
|
371 | + apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false) |
|
372 | 372 | || EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request |
373 | 373 | ) { |
374 | 374 | $is_locked = false; |
@@ -390,9 +390,9 @@ discard block |
||
390 | 390 | * @return int |
391 | 391 | */ |
392 | 392 | public function get_rate_limit() { |
393 | - if ( ! $rate_limit = get_transient( $this->_get_rate_limit_key() ) ) { |
|
393 | + if ( ! $rate_limit = get_transient($this->_get_rate_limit_key())) { |
|
394 | 394 | $rate_limit = $this->_default_rate_limit(); |
395 | - set_transient( $this->_get_rate_limit_key(), $rate_limit, $this->_get_rate_limit_key() ); |
|
395 | + set_transient($this->_get_rate_limit_key(), $rate_limit, $this->_get_rate_limit_key()); |
|
396 | 396 | } |
397 | 397 | return $rate_limit; |
398 | 398 | } |
@@ -404,12 +404,12 @@ discard block |
||
404 | 404 | * This updates existing rate limit with the new limit which is the old minus the batch. |
405 | 405 | * @param int $batch_completed This sets the new rate limit based on the given batch that was completed. |
406 | 406 | */ |
407 | - public function set_rate_limit( $batch_completed ) { |
|
407 | + public function set_rate_limit($batch_completed) { |
|
408 | 408 | //first get the most up to date rate limit (in case its expired and reset) |
409 | 409 | $rate_limit = $this->get_rate_limit(); |
410 | 410 | $new_limit = $rate_limit - $batch_completed; |
411 | 411 | //updating the transient option directly to avoid resetting the expiry. |
412 | - update_option( '_transient_' . $this->_get_rate_limit_key(), $new_limit ); |
|
412 | + update_option('_transient_'.$this->_get_rate_limit_key(), $new_limit); |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | * @param string $task This indicates what type of request is going to be initiated. |
423 | 423 | * @param int $priority This indicates the priority that triggers initiating the request. |
424 | 424 | */ |
425 | - public function initiate_request_by_priority( $task = 'generate', $priority = EEM_Message::priority_high ) { |
|
425 | + public function initiate_request_by_priority($task = 'generate', $priority = EEM_Message::priority_high) { |
|
426 | 426 | //determine what status is matched with the priority as part of the trigger conditions. |
427 | 427 | $status = $task == 'generate' |
428 | 428 | ? EEM_Message::status_incomplete |
@@ -442,19 +442,19 @@ discard block |
||
442 | 442 | * the same request. |
443 | 443 | */ |
444 | 444 | if ( |
445 | - apply_filters( 'FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false ) |
|
445 | + apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false) |
|
446 | 446 | || EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request |
447 | 447 | ) { |
448 | - $messages_processor = EE_Registry::instance()->load_lib( 'Messages_Processor' ); |
|
449 | - if ( $messages_processor instanceof EE_Messages_Processor ) { |
|
450 | - return $messages_processor->process_immediately_from_queue( $this ); |
|
448 | + $messages_processor = EE_Registry::instance()->load_lib('Messages_Processor'); |
|
449 | + if ($messages_processor instanceof EE_Messages_Processor) { |
|
450 | + return $messages_processor->process_immediately_from_queue($this); |
|
451 | 451 | } |
452 | 452 | //if we get here then that means the messages processor couldn't be loaded so messages will just remain |
453 | 453 | //queued for manual triggering by end user. |
454 | 454 | } |
455 | 455 | |
456 | - if ( $this->_message_repository->count_by_priority_and_status( $priority, $status ) ) { |
|
457 | - EE_Messages_Scheduler::initiate_scheduled_non_blocking_request( $task ); |
|
456 | + if ($this->_message_repository->count_by_priority_and_status($priority, $status)) { |
|
457 | + EE_Messages_Scheduler::initiate_scheduled_non_blocking_request($task); |
|
458 | 458 | } |
459 | 459 | } |
460 | 460 | |
@@ -479,53 +479,53 @@ discard block |
||
479 | 479 | * Also, if the messenger is an request type messenger (or a preview), |
480 | 480 | * its entirely possible that the messenger will exit before |
481 | 481 | */ |
482 | - public function execute( $save = true, $sending_messenger = null, $by_priority = false ) { |
|
482 | + public function execute($save = true, $sending_messenger = null, $by_priority = false) { |
|
483 | 483 | $messages_sent = 0; |
484 | 484 | $this->_did_hook = array(); |
485 | 485 | $this->_message_repository->rewind(); |
486 | 486 | |
487 | - while ( $this->_message_repository->valid() ) { |
|
487 | + while ($this->_message_repository->valid()) { |
|
488 | 488 | $error_messages = array(); |
489 | 489 | /** @type EE_Message $message */ |
490 | 490 | $message = $this->_message_repository->current(); |
491 | 491 | //only process things that are queued for sending |
492 | - if ( ! in_array( $message->STS_ID(), EEM_Message::instance()->stati_indicating_to_send() ) ) { |
|
492 | + if ( ! in_array($message->STS_ID(), EEM_Message::instance()->stati_indicating_to_send())) { |
|
493 | 493 | $this->_message_repository->next(); |
494 | 494 | continue; |
495 | 495 | } |
496 | 496 | //if $by_priority is set and does not match then continue; |
497 | - if ( $by_priority && $by_priority != $message->priority() ) { |
|
497 | + if ($by_priority && $by_priority != $message->priority()) { |
|
498 | 498 | $this->_message_repository->next(); |
499 | 499 | continue; |
500 | 500 | } |
501 | 501 | //error checking |
502 | - if ( ! $message->valid_messenger() ) { |
|
502 | + if ( ! $message->valid_messenger()) { |
|
503 | 503 | $error_messages[] = sprintf( |
504 | - __( 'The %s messenger is not active at time of sending.', 'event_espresso' ), |
|
504 | + __('The %s messenger is not active at time of sending.', 'event_espresso'), |
|
505 | 505 | $message->messenger() |
506 | 506 | ); |
507 | 507 | } |
508 | - if ( ! $message->valid_message_type() ) { |
|
508 | + if ( ! $message->valid_message_type()) { |
|
509 | 509 | $error_messages[] = sprintf( |
510 | - __( 'The %s message type is not active at the time of sending.', 'event_espresso' ), |
|
510 | + __('The %s message type is not active at the time of sending.', 'event_espresso'), |
|
511 | 511 | $message->message_type() |
512 | 512 | ); |
513 | 513 | } |
514 | 514 | // if there was supposed to be a sending messenger for this message, but it was invalid/inactive, |
515 | 515 | // then it will instead be an EE_Error object, so let's check for that |
516 | - if ( $sending_messenger instanceof EE_Error ) { |
|
516 | + if ($sending_messenger instanceof EE_Error) { |
|
517 | 517 | $error_messages[] = $sending_messenger->getMessage(); |
518 | 518 | } |
519 | 519 | // if there are no errors, then let's process the message |
520 | - if ( empty( $error_messages ) && $this->_process_message( $message, $sending_messenger ) ) { |
|
520 | + if (empty($error_messages) && $this->_process_message($message, $sending_messenger)) { |
|
521 | 521 | $messages_sent++; |
522 | 522 | } |
523 | - $this->_set_error_message( $message, $error_messages ); |
|
523 | + $this->_set_error_message($message, $error_messages); |
|
524 | 524 | //add modified time |
525 | - $message->set_modified( time() ); |
|
525 | + $message->set_modified(time()); |
|
526 | 526 | $this->_message_repository->next(); |
527 | 527 | } |
528 | - if ( $save ) { |
|
528 | + if ($save) { |
|
529 | 529 | $this->save(); |
530 | 530 | } |
531 | 531 | return $messages_sent; |
@@ -540,7 +540,7 @@ discard block |
||
540 | 540 | * @param mixed $sending_messenger (optional) |
541 | 541 | * @return bool |
542 | 542 | */ |
543 | - protected function _process_message( EE_Message $message, $sending_messenger = null ) { |
|
543 | + protected function _process_message(EE_Message $message, $sending_messenger = null) { |
|
544 | 544 | // these *should* have been validated in the execute() method above |
545 | 545 | $messenger = $message->messenger_object(); |
546 | 546 | $message_type = $message->message_type_object(); |
@@ -550,20 +550,20 @@ discard block |
||
550 | 550 | && $messenger instanceof EE_messenger |
551 | 551 | && $sending_messenger->name != $messenger->name |
552 | 552 | ) { |
553 | - $messenger->do_secondary_messenger_hooks( $sending_messenger->name ); |
|
553 | + $messenger->do_secondary_messenger_hooks($sending_messenger->name); |
|
554 | 554 | $messenger = $sending_messenger; |
555 | 555 | } |
556 | 556 | // send using messenger, but double check objects |
557 | - if ( $messenger instanceof EE_messenger && $message_type instanceof EE_message_type ) { |
|
557 | + if ($messenger instanceof EE_messenger && $message_type instanceof EE_message_type) { |
|
558 | 558 | //set hook for message type (but only if not using another messenger to send). |
559 | - if ( ! isset( $this->_did_hook[ $message_type->name ] ) ) { |
|
560 | - $message_type->do_messenger_hooks( $messenger ); |
|
561 | - $this->_did_hook[ $message_type->name ] = 1; |
|
559 | + if ( ! isset($this->_did_hook[$message_type->name])) { |
|
560 | + $message_type->do_messenger_hooks($messenger); |
|
561 | + $this->_did_hook[$message_type->name] = 1; |
|
562 | 562 | } |
563 | 563 | //if preview then use preview method |
564 | 564 | return $this->_message_repository->is_preview() |
565 | - ? $this->_do_preview( $message, $messenger, $message_type, $this->_message_repository->is_test_send() ) |
|
566 | - : $this->_do_send( $message, $messenger, $message_type ); |
|
565 | + ? $this->_do_preview($message, $messenger, $message_type, $this->_message_repository->is_test_send()) |
|
566 | + : $this->_do_send($message, $messenger, $message_type); |
|
567 | 567 | } |
568 | 568 | return false; |
569 | 569 | } |
@@ -581,12 +581,12 @@ discard block |
||
581 | 581 | * @param array $status Stati to check for in queue |
582 | 582 | * @return int Count of EE_Message's matching the given status. |
583 | 583 | */ |
584 | - public function count_STS_in_queue( $status ) { |
|
584 | + public function count_STS_in_queue($status) { |
|
585 | 585 | $count = 0; |
586 | - $status = is_array( $status ) ? $status : array( $status ); |
|
586 | + $status = is_array($status) ? $status : array($status); |
|
587 | 587 | $this->_message_repository->rewind(); |
588 | - foreach( $this->_message_repository as $message ) { |
|
589 | - if ( in_array( $message->STS_ID(), $status ) ) { |
|
588 | + foreach ($this->_message_repository as $message) { |
|
589 | + if (in_array($message->STS_ID(), $status)) { |
|
590 | 590 | $count++; |
591 | 591 | } |
592 | 592 | } |
@@ -603,15 +603,15 @@ discard block |
||
603 | 603 | * @param $test_send |
604 | 604 | * @return bool true means all went well, false means, not so much. |
605 | 605 | */ |
606 | - protected function _do_preview( EE_Message $message, EE_messenger $messenger, EE_message_type $message_type, $test_send ) { |
|
607 | - if ( $preview = $messenger->get_preview( $message, $message_type, $test_send ) ) { |
|
608 | - if ( ! $test_send ) { |
|
609 | - $message->set_content( $preview ); |
|
606 | + protected function _do_preview(EE_Message $message, EE_messenger $messenger, EE_message_type $message_type, $test_send) { |
|
607 | + if ($preview = $messenger->get_preview($message, $message_type, $test_send)) { |
|
608 | + if ( ! $test_send) { |
|
609 | + $message->set_content($preview); |
|
610 | 610 | } |
611 | - $message->set_STS_ID( EEM_Message::status_sent ); |
|
611 | + $message->set_STS_ID(EEM_Message::status_sent); |
|
612 | 612 | return true; |
613 | 613 | } else { |
614 | - $message->set_STS_ID( EEM_Message::status_failed ); |
|
614 | + $message->set_STS_ID(EEM_Message::status_failed); |
|
615 | 615 | return false; |
616 | 616 | } |
617 | 617 | } |
@@ -633,18 +633,18 @@ discard block |
||
633 | 633 | * |
634 | 634 | * @return bool true means all went well, false means, not so much. |
635 | 635 | */ |
636 | - protected function _do_send( EE_Message $message, EE_messenger $messenger, EE_message_type $message_type ) { |
|
636 | + protected function _do_send(EE_Message $message, EE_messenger $messenger, EE_message_type $message_type) { |
|
637 | 637 | try { |
638 | - if ( $messenger->send_message( $message, $message_type ) ) { |
|
639 | - $message->set_STS_ID( EEM_Message::status_sent ); |
|
638 | + if ($messenger->send_message($message, $message_type)) { |
|
639 | + $message->set_STS_ID(EEM_Message::status_sent); |
|
640 | 640 | return true; |
641 | 641 | } else { |
642 | - $message->set_STS_ID( EEM_Message::status_retry ); |
|
642 | + $message->set_STS_ID(EEM_Message::status_retry); |
|
643 | 643 | return false; |
644 | 644 | } |
645 | - } catch( SendMessageException $e ) { |
|
646 | - $message->set_STS_ID( EEM_Message::status_failed ); |
|
647 | - $message->set_error_message( $e->getMessage() ); |
|
645 | + } catch (SendMessageException $e) { |
|
646 | + $message->set_STS_ID(EEM_Message::status_failed); |
|
647 | + $message->set_error_message($e->getMessage()); |
|
648 | 648 | return false; |
649 | 649 | } |
650 | 650 | } |
@@ -658,21 +658,21 @@ discard block |
||
658 | 658 | * @param EE_Message $message |
659 | 659 | * @param array $error_messages the response from the messenger. |
660 | 660 | */ |
661 | - protected function _set_error_message( EE_Message $message, $error_messages ) { |
|
661 | + protected function _set_error_message(EE_Message $message, $error_messages) { |
|
662 | 662 | $error_messages = (array) $error_messages; |
663 | - if ( in_array( $message->STS_ID(), EEM_Message::instance()->stati_indicating_failed_sending() ) ) { |
|
663 | + if (in_array($message->STS_ID(), EEM_Message::instance()->stati_indicating_failed_sending())) { |
|
664 | 664 | $notices = EE_Error::has_notices(); |
665 | - $error_messages[] = __( 'Messenger and Message Type were valid and active, but the messenger send method failed.', 'event_espresso' ); |
|
666 | - if ( $notices === 1 ) { |
|
665 | + $error_messages[] = __('Messenger and Message Type were valid and active, but the messenger send method failed.', 'event_espresso'); |
|
666 | + if ($notices === 1) { |
|
667 | 667 | $notices = EE_Error::get_vanilla_notices(); |
668 | - $notices['errors'] = isset( $notices['errors'] ) ? $notices['errors'] : array(); |
|
669 | - $error_messages[] = implode( "\n", $notices['errors'] ); |
|
668 | + $notices['errors'] = isset($notices['errors']) ? $notices['errors'] : array(); |
|
669 | + $error_messages[] = implode("\n", $notices['errors']); |
|
670 | 670 | } |
671 | 671 | } |
672 | - if ( count( $error_messages ) > 0 ) { |
|
673 | - $msg = __( 'Message was not executed successfully.', 'event_espresso' ); |
|
674 | - $msg = $msg . "\n" . implode( "\n", $error_messages ); |
|
675 | - $message->set_error_message( $msg ); |
|
672 | + if (count($error_messages) > 0) { |
|
673 | + $msg = __('Message was not executed successfully.', 'event_espresso'); |
|
674 | + $msg = $msg."\n".implode("\n", $error_messages); |
|
675 | + $message->set_error_message($msg); |
|
676 | 676 | } |
677 | 677 | } |
678 | 678 |
@@ -595,7 +595,7 @@ |
||
595 | 595 | *@param EE_Message $message |
596 | 596 | * @param EE_messenger $messenger |
597 | 597 | * @param EE_message_type $message_type |
598 | - * @param $test_send |
|
598 | + * @param boolean $test_send |
|
599 | 599 | * @return bool true means all went well, false means, not so much. |
600 | 600 | */ |
601 | 601 | protected function _do_preview( EE_Message $message, EE_messenger $messenger, EE_message_type $message_type, $test_send ) { |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | use \EventEspresso\core\exceptions\SendMessageException; |
3 | 3 | |
4 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
5 | 5 | exit('NO direct script access allowed'); |
6 | 6 | |
7 | 7 | /** |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | * @return void |
280 | 280 | */ |
281 | 281 | public function enqueue_scripts_styles() { |
282 | - do_action( 'AHEE__EE_messenger__enqueue_scripts_styles'); |
|
282 | + do_action('AHEE__EE_messenger__enqueue_scripts_styles'); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | |
350 | 350 | $this->_supports_labels->template_variation_description = __('These are different styles to choose from for the selected template structure. Usually these affect things like font style, color, borders etc. In some cases the styles will also make minor layout changes.'); |
351 | 351 | |
352 | - $this->_supports_labels = apply_filters( 'FHEE__EE_messenger___set_supports_labels_defaults___supports_labels', $this->_supports_labels, $this ); |
|
352 | + $this->_supports_labels = apply_filters('FHEE__EE_messenger___set_supports_labels_defaults___supports_labels', $this->_supports_labels, $this); |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | |
@@ -364,10 +364,10 @@ discard block |
||
364 | 364 | * @return stdClass |
365 | 365 | */ |
366 | 366 | public function get_supports_labels() { |
367 | - if ( empty( $this->_supports_labels->template_pack ) || empty( $this->_supports_labels->template_variation) ) { |
|
367 | + if (empty($this->_supports_labels->template_pack) || empty($this->_supports_labels->template_variation)) { |
|
368 | 368 | $this->_set_supports_labels_defaults(); |
369 | 369 | } |
370 | - return apply_filters( 'FHEE__EE_messenger__get_supports_labels', $this->_supports_labels, $this ); |
|
370 | + return apply_filters('FHEE__EE_messenger__get_supports_labels', $this->_supports_labels, $this); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | |
@@ -387,10 +387,10 @@ discard block |
||
387 | 387 | * |
388 | 388 | * @return string path or url for the requested variation. |
389 | 389 | */ |
390 | - public function get_variation( EE_Messages_Template_Pack $pack, $message_type_name, $url = FALSE, $type = 'main', $variation = 'default', $skip_filters = FALSE ) { |
|
390 | + public function get_variation(EE_Messages_Template_Pack $pack, $message_type_name, $url = FALSE, $type = 'main', $variation = 'default', $skip_filters = FALSE) { |
|
391 | 391 | $this->_tmp_pack = $pack; |
392 | - $variation_path = apply_filters( 'EE_messenger__get_variation__variation', false, $pack, $this->name, $message_type_name, $url, $type, $variation, $skip_filters ); |
|
393 | - $variation_path = empty( $variation_path ) ? $this->_tmp_pack->get_variation( $this->name, $message_type_name, $type, $variation, $url, '.css', $skip_filters ) : $variation_path; |
|
392 | + $variation_path = apply_filters('EE_messenger__get_variation__variation', false, $pack, $this->name, $message_type_name, $url, $type, $variation, $skip_filters); |
|
393 | + $variation_path = empty($variation_path) ? $this->_tmp_pack->get_variation($this->name, $message_type_name, $type, $variation, $url, '.css', $skip_filters) : $variation_path; |
|
394 | 394 | return $variation_path; |
395 | 395 | |
396 | 396 | } |
@@ -408,13 +408,13 @@ discard block |
||
408 | 408 | * @return array |
409 | 409 | */ |
410 | 410 | public function get_default_message_types() { |
411 | - $class = get_class( $this ); |
|
411 | + $class = get_class($this); |
|
412 | 412 | |
413 | 413 | //messenger specific filter |
414 | - $default_types = apply_filters( 'FHEE__' . $class . '__get_default_message_types__default_types', $this->_default_message_types, $this ); |
|
414 | + $default_types = apply_filters('FHEE__'.$class.'__get_default_message_types__default_types', $this->_default_message_types, $this); |
|
415 | 415 | |
416 | 416 | //all messengers filter |
417 | - $default_types = apply_filters( 'FHEE__EE_messenger__get_default_message_types__default_types', $default_types, $this ); |
|
417 | + $default_types = apply_filters('FHEE__EE_messenger__get_default_message_types__default_types', $default_types, $this); |
|
418 | 418 | return $default_types; |
419 | 419 | } |
420 | 420 | |
@@ -429,14 +429,14 @@ discard block |
||
429 | 429 | * @return array |
430 | 430 | */ |
431 | 431 | public function get_valid_message_types() { |
432 | - $class = get_class( $this ); |
|
432 | + $class = get_class($this); |
|
433 | 433 | |
434 | 434 | //messenger specific filter |
435 | 435 | //messenger specific filter |
436 | - $valid_types = apply_filters( 'FHEE__' . $class . '__get_valid_message_types__valid_types', $this->_valid_message_types, $this ); |
|
436 | + $valid_types = apply_filters('FHEE__'.$class.'__get_valid_message_types__valid_types', $this->_valid_message_types, $this); |
|
437 | 437 | |
438 | 438 | //all messengers filter |
439 | - $valid_types = apply_filters( 'FHEE__EE_messenger__get_valid_message_types__valid_types', $valid_types, $this ); |
|
439 | + $valid_types = apply_filters('FHEE__EE_messenger__get_valid_message_types__valid_types', $valid_types, $this); |
|
440 | 440 | return $valid_types; |
441 | 441 | } |
442 | 442 | |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | * @access public |
451 | 451 | * @param array $new_config Whatever is put in here will reset the _validator_config property |
452 | 452 | */ |
453 | - public function set_validator_config( $new_config ) { |
|
453 | + public function set_validator_config($new_config) { |
|
454 | 454 | $this->_validator_config = $new_config; |
455 | 455 | } |
456 | 456 | |
@@ -466,8 +466,8 @@ discard block |
||
466 | 466 | public function get_validator_config() { |
467 | 467 | $class = get_class($this); |
468 | 468 | |
469 | - $config = apply_filters( 'FHEE__' . $class . '__get_validator_config', $this->_validator_config, $this ); |
|
470 | - $config = apply_filters( 'FHEE__EE_messenger__get_validator_config', $config, $this ); |
|
469 | + $config = apply_filters('FHEE__'.$class.'__get_validator_config', $this->_validator_config, $this); |
|
470 | + $config = apply_filters('FHEE__EE_messenger__get_validator_config', $config, $this); |
|
471 | 471 | return $config; |
472 | 472 | } |
473 | 473 | |
@@ -484,8 +484,8 @@ discard block |
||
484 | 484 | * @access public |
485 | 485 | * @return string content for page |
486 | 486 | */ |
487 | - public function get_messenger_admin_page_content( $page, $action = null, $extra = array(), $message_types = array() ) { |
|
488 | - return $this->_get_admin_page_content( $page, $action, $extra, $message_types ); |
|
487 | + public function get_messenger_admin_page_content($page, $action = null, $extra = array(), $message_types = array()) { |
|
488 | + return $this->_get_admin_page_content($page, $action, $extra, $message_types); |
|
489 | 489 | } |
490 | 490 | |
491 | 491 | |
@@ -495,20 +495,20 @@ discard block |
||
495 | 495 | * @param array $extra |
496 | 496 | * @return mixed|string |
497 | 497 | */ |
498 | - protected function _get_admin_content_events_edit( $message_types, $extra ) { |
|
498 | + protected function _get_admin_content_events_edit($message_types, $extra) { |
|
499 | 499 | //defaults |
500 | 500 | $template_args = array(); |
501 | 501 | $selector_rows = ''; |
502 | 502 | |
503 | 503 | //we don't need message types here so we're just going to ignore. we do, however, expect the event id here. The event id is needed to provide a link to setup a custom template for this event. |
504 | - $event_id = isset( $extra['event'] ) ? $extra['event'] : NULL; |
|
504 | + $event_id = isset($extra['event']) ? $extra['event'] : NULL; |
|
505 | 505 | |
506 | - $template_wrapper_path = EE_LIBRARIES . 'messages/messenger/admin_templates/event_switcher_wrapper.template.php'; |
|
507 | - $template_row_path = EE_LIBRARIES . 'messages/messenger/admin_templates/event_switcher_row.template.php'; |
|
506 | + $template_wrapper_path = EE_LIBRARIES.'messages/messenger/admin_templates/event_switcher_wrapper.template.php'; |
|
507 | + $template_row_path = EE_LIBRARIES.'messages/messenger/admin_templates/event_switcher_row.template.php'; |
|
508 | 508 | |
509 | 509 | //array of template objects for global and custom (non-trashed) (but remember just for this messenger!) |
510 | 510 | $global_templates = EEM_Message_Template_Group::instance()->get_all( |
511 | - array( array( 'MTP_messenger' => $this->name, 'MTP_is_global' => true, 'MTP_is_active' => true ) ) |
|
511 | + array(array('MTP_messenger' => $this->name, 'MTP_is_global' => true, 'MTP_is_active' => true)) |
|
512 | 512 | ); |
513 | 513 | $templates_for_event = EEM_Message_Template_Group::instance()->get_all_custom_templates_by_event( |
514 | 514 | $event_id, |
@@ -517,55 +517,55 @@ discard block |
||
517 | 517 | 'MTP_is_active' => true |
518 | 518 | ) |
519 | 519 | ); |
520 | - $templates_for_event = !empty( $templates_for_event ) ? $templates_for_event : array(); |
|
520 | + $templates_for_event = ! empty($templates_for_event) ? $templates_for_event : array(); |
|
521 | 521 | |
522 | 522 | //so we need to setup the rows for the selectors and we use the global mtpgs (cause those will the active message template groups) |
523 | - foreach ( $global_templates as $mtpgID => $mtpg ) { |
|
524 | - if ( $mtpg instanceof EE_Message_Template_Group ) { |
|
523 | + foreach ($global_templates as $mtpgID => $mtpg) { |
|
524 | + if ($mtpg instanceof EE_Message_Template_Group) { |
|
525 | 525 | //verify this message type is supposed to show on this page |
526 | 526 | $mtp_obj = $mtpg->message_type_obj(); |
527 | - if ( ! $mtp_obj instanceof EE_message_type ) { |
|
527 | + if ( ! $mtp_obj instanceof EE_message_type) { |
|
528 | 528 | continue; |
529 | 529 | } |
530 | - $mtp_obj->admin_registered_pages = (array)$mtp_obj->admin_registered_pages; |
|
531 | - if ( ! in_array( 'events_edit', $mtp_obj->admin_registered_pages ) ) { |
|
530 | + $mtp_obj->admin_registered_pages = (array) $mtp_obj->admin_registered_pages; |
|
531 | + if ( ! in_array('events_edit', $mtp_obj->admin_registered_pages)) { |
|
532 | 532 | continue; |
533 | 533 | } |
534 | 534 | $select_values = array(); |
535 | - $select_values[ $mtpgID ] = __( 'Global', 'event_espresso' ); |
|
536 | - $default_value = array_key_exists( $mtpgID, $templates_for_event ) && ! $mtpg->get( 'MTP_is_override' ) ? $mtpgID : null; |
|
535 | + $select_values[$mtpgID] = __('Global', 'event_espresso'); |
|
536 | + $default_value = array_key_exists($mtpgID, $templates_for_event) && ! $mtpg->get('MTP_is_override') ? $mtpgID : null; |
|
537 | 537 | //if the override has been set for the global template, then that means even if there are custom templates already created we ignore them because of the set override. |
538 | - if ( ! $mtpg->get( 'MTP_is_override' ) ) { |
|
538 | + if ( ! $mtpg->get('MTP_is_override')) { |
|
539 | 539 | //any custom templates for this message type? |
540 | - $custom_templates = EEM_Message_Template_Group::instance()->get_custom_message_template_by_m_and_mt( $this->name, $mtpg->message_type() ); |
|
541 | - foreach ( $custom_templates as $cmtpgID => $cmtpg ) { |
|
542 | - $select_values[ $cmtpgID ] = $cmtpg->name(); |
|
543 | - $default_value = array_key_exists( $cmtpgID, $templates_for_event ) ? $cmtpgID : $default_value; |
|
540 | + $custom_templates = EEM_Message_Template_Group::instance()->get_custom_message_template_by_m_and_mt($this->name, $mtpg->message_type()); |
|
541 | + foreach ($custom_templates as $cmtpgID => $cmtpg) { |
|
542 | + $select_values[$cmtpgID] = $cmtpg->name(); |
|
543 | + $default_value = array_key_exists($cmtpgID, $templates_for_event) ? $cmtpgID : $default_value; |
|
544 | 544 | } |
545 | 545 | } |
546 | 546 | //if there is no $default_value then we set it as the global |
547 | - $default_value = empty( $default_value ) ? $mtpgID : $default_value; |
|
548 | - $edit_url = EEH_URL::add_query_args_and_nonce( array( 'page' => 'espresso_messages', 'action' => 'edit_message_template', 'id' => $default_value ), admin_url( 'admin.php' ) ); |
|
549 | - $create_url = EEH_URL::add_query_args_and_nonce( array( 'page' => 'espresso_messages', 'action' => 'add_new_message_template', 'GRP_ID' => $default_value ), admin_url( 'admin.php' ) ); |
|
550 | - $st_args[ 'mt_name' ] = ucwords( $mtp_obj->label[ 'singular' ] ); |
|
551 | - $st_args[ 'mt_slug' ] = $mtpg->message_type(); |
|
552 | - $st_args[ 'messenger_slug' ] = $this->name; |
|
553 | - $st_args[ 'selector' ] = EEH_Form_Fields::select_input( 'event_message_templates_relation[' . $mtpgID . ']', $select_values, $default_value, 'data-messenger="' . $this->name . '" data-messagetype="' . $mtpg->message_type() . '"', 'message-template-selector' ); |
|
547 | + $default_value = empty($default_value) ? $mtpgID : $default_value; |
|
548 | + $edit_url = EEH_URL::add_query_args_and_nonce(array('page' => 'espresso_messages', 'action' => 'edit_message_template', 'id' => $default_value), admin_url('admin.php')); |
|
549 | + $create_url = EEH_URL::add_query_args_and_nonce(array('page' => 'espresso_messages', 'action' => 'add_new_message_template', 'GRP_ID' => $default_value), admin_url('admin.php')); |
|
550 | + $st_args['mt_name'] = ucwords($mtp_obj->label['singular']); |
|
551 | + $st_args['mt_slug'] = $mtpg->message_type(); |
|
552 | + $st_args['messenger_slug'] = $this->name; |
|
553 | + $st_args['selector'] = EEH_Form_Fields::select_input('event_message_templates_relation['.$mtpgID.']', $select_values, $default_value, 'data-messenger="'.$this->name.'" data-messagetype="'.$mtpg->message_type().'"', 'message-template-selector'); |
|
554 | 554 | //note that message template group that has override_all_custom set will remove the ability to set a custom message template based off of the global (and that also in turn overrides any other custom templates). |
555 | - $st_args[ 'create_button' ] = $mtpg->get( 'MTP_is_override' ) ? '' : '<a data-messenger="' . $this->name . '" data-messagetype="' . $mtpg->message_type() . '" data-grpid="' . $default_value . '" target="_blank" href="' . $create_url . '" class="button button-small create-mtpg-button">' . __( 'Create New Custom', 'event_espresso' ) . '</a>'; |
|
556 | - $st_args[ 'create_button' ] = EE_Registry::instance()->CAP->current_user_can( 'ee_edit_messages', 'espresso_messages_add_new_message_template' ) ? $st_args[ 'create_button' ] : ''; |
|
557 | - $st_args[ 'edit_button' ] = EE_Registry::instance()->CAP->current_user_can( 'ee_edit_message', 'espresso_messages_edit_message_template', $mtpgID ) ? '<a data-messagetype="' . $mtpg->message_type() . '" data-grpid="' . $default_value . '" target="_blank" href="' . $edit_url . '" class="button button-small edit-mtpg-button">' . __( 'Edit', 'event_espresso' ) . '</a>' : ''; |
|
558 | - $selector_rows .= EEH_Template::display_template( $template_row_path, $st_args, true ); |
|
555 | + $st_args['create_button'] = $mtpg->get('MTP_is_override') ? '' : '<a data-messenger="'.$this->name.'" data-messagetype="'.$mtpg->message_type().'" data-grpid="'.$default_value.'" target="_blank" href="'.$create_url.'" class="button button-small create-mtpg-button">'.__('Create New Custom', 'event_espresso').'</a>'; |
|
556 | + $st_args['create_button'] = EE_Registry::instance()->CAP->current_user_can('ee_edit_messages', 'espresso_messages_add_new_message_template') ? $st_args['create_button'] : ''; |
|
557 | + $st_args['edit_button'] = EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $mtpgID) ? '<a data-messagetype="'.$mtpg->message_type().'" data-grpid="'.$default_value.'" target="_blank" href="'.$edit_url.'" class="button button-small edit-mtpg-button">'.__('Edit', 'event_espresso').'</a>' : ''; |
|
558 | + $selector_rows .= EEH_Template::display_template($template_row_path, $st_args, true); |
|
559 | 559 | } |
560 | 560 | } |
561 | 561 | |
562 | 562 | //if no selectors present then get out. |
563 | - if ( empty( $selector_rows ) ) { |
|
563 | + if (empty($selector_rows)) { |
|
564 | 564 | return ''; |
565 | 565 | } |
566 | 566 | |
567 | 567 | $template_args['selector_rows'] = $selector_rows; |
568 | - return EEH_Template::display_template( $template_wrapper_path, $template_args, TRUE ); |
|
568 | + return EEH_Template::display_template($template_wrapper_path, $template_args, TRUE); |
|
569 | 569 | } |
570 | 570 | |
571 | 571 | |
@@ -580,8 +580,8 @@ discard block |
||
580 | 580 | * @return array $this->_template_fields |
581 | 581 | */ |
582 | 582 | public function get_template_fields() { |
583 | - $template_fields = apply_filters( 'FHEE__' . get_class($this) . '__get_template_fields', $this->_template_fields, $this ); |
|
584 | - $template_fields = apply_filters( 'FHEE__EE_messenger__get_template_fields', $template_fields, $this ); |
|
583 | + $template_fields = apply_filters('FHEE__'.get_class($this).'__get_template_fields', $this->_template_fields, $this); |
|
584 | + $template_fields = apply_filters('FHEE__EE_messenger__get_template_fields', $template_fields, $this); |
|
585 | 585 | return $template_fields; |
586 | 586 | } |
587 | 587 | |
@@ -595,9 +595,9 @@ discard block |
||
595 | 595 | * @param mixed $value |
596 | 596 | */ |
597 | 597 | protected function _set_template_value($item, $value) { |
598 | - if ( array_key_exists($item, $this->_template_fields) ) { |
|
599 | - $prop = '_' . $item; |
|
600 | - $this->{$prop}= $value; |
|
598 | + if (array_key_exists($item, $this->_template_fields)) { |
|
599 | + $prop = '_'.$item; |
|
600 | + $this->{$prop} = $value; |
|
601 | 601 | } |
602 | 602 | } |
603 | 603 | |
@@ -615,18 +615,18 @@ discard block |
||
615 | 615 | * |
616 | 616 | * @throws SendMessageException |
617 | 617 | */ |
618 | - final public function send_message( $message, EE_message_type $message_type ) { |
|
618 | + final public function send_message($message, EE_message_type $message_type) { |
|
619 | 619 | try { |
620 | - $this->_validate_and_setup( $message ); |
|
620 | + $this->_validate_and_setup($message); |
|
621 | 621 | $this->_incoming_message_type = $message_type; |
622 | 622 | $response = $this->_send_message(); |
623 | - if ( $response instanceof WP_Error ) { |
|
624 | - EE_Error::add_error( $response->get_error_message(), __FILE__, __FUNCTION__, __LINE__ ); |
|
623 | + if ($response instanceof WP_Error) { |
|
624 | + EE_Error::add_error($response->get_error_message(), __FILE__, __FUNCTION__, __LINE__); |
|
625 | 625 | $response = false; |
626 | 626 | } |
627 | - } catch ( \Exception $e ) { |
|
627 | + } catch (\Exception $e) { |
|
628 | 628 | //convert to an instance of SendMessageException |
629 | - throw new SendMessageException( $e->getMessage() ); |
|
629 | + throw new SendMessageException($e->getMessage()); |
|
630 | 630 | } |
631 | 631 | return $response; |
632 | 632 | } |
@@ -640,28 +640,28 @@ discard block |
||
640 | 640 | * @param bool $send true we will actually use the _send method (for test sends). FALSE we just return preview |
641 | 641 | * @return string return the message html content |
642 | 642 | */ |
643 | - public function get_preview( EE_Message $message, EE_message_type $message_type, $send = false ) { |
|
644 | - $this->_validate_and_setup( $message ); |
|
643 | + public function get_preview(EE_Message $message, EE_message_type $message_type, $send = false) { |
|
644 | + $this->_validate_and_setup($message); |
|
645 | 645 | |
646 | 646 | $this->_incoming_message_type = $message_type; |
647 | 647 | |
648 | - if ( $send ) { |
|
648 | + if ($send) { |
|
649 | 649 | //are we overriding any existing template fields? |
650 | 650 | $settings = $this->get_existing_test_settings(); |
651 | - if ( ! empty( $settings ) ) { |
|
652 | - foreach ( $settings as $field => $value ) { |
|
653 | - $this->_set_template_value( $field, $value ); |
|
651 | + if ( ! empty($settings)) { |
|
652 | + foreach ($settings as $field => $value) { |
|
653 | + $this->_set_template_value($field, $value); |
|
654 | 654 | } |
655 | 655 | } |
656 | 656 | } |
657 | 657 | |
658 | 658 | //enqueue preview js so that any links/buttons on the page are disabled. |
659 | - if ( ! $send ) { |
|
659 | + if ( ! $send) { |
|
660 | 660 | // the below may seem like duplication. However, typically if a messenger enqueues scripts/styles, |
661 | 661 | // it deregisters all existing wp scripts and styles first. So the second hook ensures our previewer still gets setup. |
662 | - add_action( 'admin_enqueue_scripts', array( $this, 'add_preview_script' ), 10 ); |
|
663 | - add_action( 'wp_enqueue_scripts', array( $this, 'add_preview_script' ), 10 ); |
|
664 | - add_action( 'AHEE__EE_messenger__enqueue_scripts_styles', array( $this, 'add_preview_script' ), 10 ); |
|
662 | + add_action('admin_enqueue_scripts', array($this, 'add_preview_script'), 10); |
|
663 | + add_action('wp_enqueue_scripts', array($this, 'add_preview_script'), 10); |
|
664 | + add_action('AHEE__EE_messenger__enqueue_scripts_styles', array($this, 'add_preview_script'), 10); |
|
665 | 665 | } |
666 | 666 | |
667 | 667 | return $send ? $this->_send_message() : $this->_preview(); |
@@ -679,10 +679,10 @@ discard block |
||
679 | 679 | */ |
680 | 680 | public function add_preview_script() { |
681 | 681 | //error message |
682 | - EE_Registry::$i18n_js_strings[ 'links_disabled' ] = __( 'All the links on this page have been disabled because this is a generated preview message for the purpose of ensuring layout, style, and content setup. To test generated links, you must trigger an actual message notification.', 'event_espresso' ); |
|
683 | - wp_register_script( 'ee-messages-preview-js', EE_LIBRARIES_URL . 'messages/messenger/assets/js/ee-messages-preview.js', array( 'jquery' ), EVENT_ESPRESSO_VERSION, true ); |
|
684 | - wp_localize_script( 'ee-messages-preview-js', 'eei18n', EE_Registry::$i18n_js_strings ); |
|
685 | - wp_enqueue_script( 'ee-messages-preview-js' ); |
|
682 | + EE_Registry::$i18n_js_strings['links_disabled'] = __('All the links on this page have been disabled because this is a generated preview message for the purpose of ensuring layout, style, and content setup. To test generated links, you must trigger an actual message notification.', 'event_espresso'); |
|
683 | + wp_register_script('ee-messages-preview-js', EE_LIBRARIES_URL.'messages/messenger/assets/js/ee-messages-preview.js', array('jquery'), EVENT_ESPRESSO_VERSION, true); |
|
684 | + wp_localize_script('ee-messages-preview-js', 'eei18n', EE_Registry::$i18n_js_strings); |
|
685 | + wp_enqueue_script('ee-messages-preview-js'); |
|
686 | 686 | } |
687 | 687 | |
688 | 688 | |
@@ -693,13 +693,13 @@ discard block |
||
693 | 693 | * @param EE_Message $message |
694 | 694 | * @throws EE_Error |
695 | 695 | */ |
696 | - protected function _validate_and_setup( EE_Message $message ) { |
|
696 | + protected function _validate_and_setup(EE_Message $message) { |
|
697 | 697 | $template_pack = $message->get_template_pack(); |
698 | 698 | $variation = $message->get_template_pack_variation(); |
699 | 699 | |
700 | 700 | //verify we have the required template pack value on the $message object. |
701 | - if ( ! $template_pack instanceof EE_Messages_Template_Pack ) { |
|
702 | - throw new EE_Error( __('Incoming $message object must have an EE_Messages_Template_Pack object available.', 'event_espresso' ) ); |
|
701 | + if ( ! $template_pack instanceof EE_Messages_Template_Pack) { |
|
702 | + throw new EE_Error(__('Incoming $message object must have an EE_Messages_Template_Pack object available.', 'event_espresso')); |
|
703 | 703 | } |
704 | 704 | |
705 | 705 | $this->_tmp_pack = $template_pack; |
@@ -708,11 +708,11 @@ discard block |
||
708 | 708 | |
709 | 709 | $template_fields = $this->get_template_fields(); |
710 | 710 | |
711 | - foreach ( $template_fields as $template => $value ) { |
|
712 | - if ( $template !== 'extra' ) { |
|
713 | - $column_value = $message->get_field_or_extra_meta( 'MSG_' . $template ); |
|
711 | + foreach ($template_fields as $template => $value) { |
|
712 | + if ($template !== 'extra') { |
|
713 | + $column_value = $message->get_field_or_extra_meta('MSG_'.$template); |
|
714 | 714 | $message_template_value = $column_value ? $column_value : null; |
715 | - $this->_set_template_value( $template, $message_template_value ); |
|
715 | + $this->_set_template_value($template, $message_template_value); |
|
716 | 716 | } |
717 | 717 | } |
718 | 718 | } |
@@ -727,19 +727,19 @@ discard block |
||
727 | 727 | * @return string |
728 | 728 | * @throws \EE_Error |
729 | 729 | */ |
730 | - protected function _get_main_template( $preview = FALSE ) { |
|
730 | + protected function _get_main_template($preview = FALSE) { |
|
731 | 731 | $type = $preview ? 'preview' : 'main'; |
732 | 732 | |
733 | - $wrapper_template = $this->_tmp_pack->get_wrapper( $this->name, $type ); |
|
733 | + $wrapper_template = $this->_tmp_pack->get_wrapper($this->name, $type); |
|
734 | 734 | |
735 | 735 | //check file exists and is readable |
736 | - if ( !is_readable( $wrapper_template ) ) |
|
737 | - throw new EE_Error( sprintf( __('Unable to access the template file for the %s messenger main content wrapper. The location being attempted is %s.', 'event_espresso' ), ucwords($this->label['singular']) , $wrapper_template ) ); |
|
736 | + if ( ! is_readable($wrapper_template)) |
|
737 | + throw new EE_Error(sprintf(__('Unable to access the template file for the %s messenger main content wrapper. The location being attempted is %s.', 'event_espresso'), ucwords($this->label['singular']), $wrapper_template)); |
|
738 | 738 | |
739 | 739 | //add message type to template args |
740 | 740 | $this->_template_args['message_type'] = $this->_incoming_message_type; |
741 | 741 | |
742 | - return EEH_Template::display_template( $wrapper_template, $this->_template_args, TRUE ); |
|
742 | + return EEH_Template::display_template($wrapper_template, $this->_template_args, TRUE); |
|
743 | 743 | } |
744 | 744 | |
745 | 745 | |
@@ -775,9 +775,9 @@ discard block |
||
775 | 775 | */ |
776 | 776 | public function get_existing_test_settings() { |
777 | 777 | /** @var EE_Message_Resource_Manager $Message_Resource_Manager */ |
778 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
778 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
779 | 779 | $settings = $Message_Resource_Manager->get_active_messengers_option(); |
780 | - return isset( $settings[ $this->name ]['test_settings'] ) ? $settings[ $this->name ]['test_settings'] : array(); |
|
780 | + return isset($settings[$this->name]['test_settings']) ? $settings[$this->name]['test_settings'] : array(); |
|
781 | 781 | } |
782 | 782 | |
783 | 783 | |
@@ -789,12 +789,12 @@ discard block |
||
789 | 789 | * @param $settings |
790 | 790 | * @return bool success/fail |
791 | 791 | */ |
792 | - public function set_existing_test_settings( $settings ) { |
|
792 | + public function set_existing_test_settings($settings) { |
|
793 | 793 | /** @var EE_Message_Resource_Manager $Message_Resource_Manager */ |
794 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
794 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
795 | 795 | $existing = $Message_Resource_Manager->get_active_messengers_option(); |
796 | - $existing[ $this->name ]['test_settings'] = $settings; |
|
797 | - return $Message_Resource_Manager->update_active_messengers_option( $existing ); |
|
796 | + $existing[$this->name]['test_settings'] = $settings; |
|
797 | + return $Message_Resource_Manager->update_active_messengers_option($existing); |
|
798 | 798 | } |
799 | 799 | |
800 | 800 | |
@@ -807,21 +807,21 @@ discard block |
||
807 | 807 | * @param string $field The field to retrieve the label for |
808 | 808 | * @return string The label |
809 | 809 | */ |
810 | - public function get_field_label( $field ) { |
|
810 | + public function get_field_label($field) { |
|
811 | 811 | //first let's see if the field requests is in the top level array. |
812 | - if ( isset( $this->_template_fields[$field] ) && !empty( $this->_template_fields[$field]['label'] ) ) |
|
812 | + if (isset($this->_template_fields[$field]) && ! empty($this->_template_fields[$field]['label'])) |
|
813 | 813 | return $this->_template[$field]['label']; |
814 | 814 | |
815 | 815 | //nope so let's look in the extra array to see if it's there HOWEVER if the field exists as a top level index in the extra array then we know the label is in the 'main' index. |
816 | - if ( isset( $this->_template_fields['extra'] ) && !empty( $this->_template_fields['extra'][$field] ) && !empty( $this->_template_fields['extra'][$field]['main']['label'] ) ) |
|
816 | + if (isset($this->_template_fields['extra']) && ! empty($this->_template_fields['extra'][$field]) && ! empty($this->_template_fields['extra'][$field]['main']['label'])) |
|
817 | 817 | return $this->_template_fields['extra'][$field]['main']['label']; |
818 | 818 | |
819 | 819 | //now it's possible this field may just be existing in any of the extra array items. |
820 | - if ( !empty( $this->_template_fields['extra'] ) && is_array( $this->_template_fields['extra'] ) ) { |
|
821 | - foreach ( $this->_template_fields['extra'] as $main_field => $subfields ) { |
|
822 | - if ( !is_array( $subfields ) ) |
|
820 | + if ( ! empty($this->_template_fields['extra']) && is_array($this->_template_fields['extra'])) { |
|
821 | + foreach ($this->_template_fields['extra'] as $main_field => $subfields) { |
|
822 | + if ( ! is_array($subfields)) |
|
823 | 823 | continue; |
824 | - if ( isset( $subfields[$field] ) && !empty( $subfields[$field]['label'] ) ) |
|
824 | + if (isset($subfields[$field]) && ! empty($subfields[$field]['label'])) |
|
825 | 825 | return $subfields[$field]['label']; |
826 | 826 | } |
827 | 827 | } |
@@ -842,7 +842,7 @@ discard block |
||
842 | 842 | * |
843 | 843 | * @return void |
844 | 844 | */ |
845 | - public function do_secondary_messenger_hooks( $sending_messenger_name ) { |
|
845 | + public function do_secondary_messenger_hooks($sending_messenger_name) { |
|
846 | 846 | return; |
847 | 847 | } |
848 | 848 |
@@ -1,8 +1,9 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | use \EventEspresso\core\exceptions\SendMessageException; |
3 | 3 | |
4 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
4 | +if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
5 | 5 | exit('NO direct script access allowed'); |
6 | +} |
|
6 | 7 | |
7 | 8 | /** |
8 | 9 | * EE_messenger class |
@@ -733,8 +734,9 @@ discard block |
||
733 | 734 | $wrapper_template = $this->_tmp_pack->get_wrapper( $this->name, $type ); |
734 | 735 | |
735 | 736 | //check file exists and is readable |
736 | - if ( !is_readable( $wrapper_template ) ) |
|
737 | - throw new EE_Error( sprintf( __('Unable to access the template file for the %s messenger main content wrapper. The location being attempted is %s.', 'event_espresso' ), ucwords($this->label['singular']) , $wrapper_template ) ); |
|
737 | + if ( !is_readable( $wrapper_template ) ) { |
|
738 | + throw new EE_Error( sprintf( __('Unable to access the template file for the %s messenger main content wrapper. The location being attempted is %s.', 'event_espresso' ), ucwords($this->label['singular']) , $wrapper_template ) ); |
|
739 | + } |
|
738 | 740 | |
739 | 741 | //add message type to template args |
740 | 742 | $this->_template_args['message_type'] = $this->_incoming_message_type; |
@@ -809,20 +811,24 @@ discard block |
||
809 | 811 | */ |
810 | 812 | public function get_field_label( $field ) { |
811 | 813 | //first let's see if the field requests is in the top level array. |
812 | - if ( isset( $this->_template_fields[$field] ) && !empty( $this->_template_fields[$field]['label'] ) ) |
|
813 | - return $this->_template[$field]['label']; |
|
814 | + if ( isset( $this->_template_fields[$field] ) && !empty( $this->_template_fields[$field]['label'] ) ) { |
|
815 | + return $this->_template[$field]['label']; |
|
816 | + } |
|
814 | 817 | |
815 | 818 | //nope so let's look in the extra array to see if it's there HOWEVER if the field exists as a top level index in the extra array then we know the label is in the 'main' index. |
816 | - if ( isset( $this->_template_fields['extra'] ) && !empty( $this->_template_fields['extra'][$field] ) && !empty( $this->_template_fields['extra'][$field]['main']['label'] ) ) |
|
817 | - return $this->_template_fields['extra'][$field]['main']['label']; |
|
819 | + if ( isset( $this->_template_fields['extra'] ) && !empty( $this->_template_fields['extra'][$field] ) && !empty( $this->_template_fields['extra'][$field]['main']['label'] ) ) { |
|
820 | + return $this->_template_fields['extra'][$field]['main']['label']; |
|
821 | + } |
|
818 | 822 | |
819 | 823 | //now it's possible this field may just be existing in any of the extra array items. |
820 | 824 | if ( !empty( $this->_template_fields['extra'] ) && is_array( $this->_template_fields['extra'] ) ) { |
821 | 825 | foreach ( $this->_template_fields['extra'] as $main_field => $subfields ) { |
822 | - if ( !is_array( $subfields ) ) |
|
823 | - continue; |
|
824 | - if ( isset( $subfields[$field] ) && !empty( $subfields[$field]['label'] ) ) |
|
825 | - return $subfields[$field]['label']; |
|
826 | + if ( !is_array( $subfields ) ) { |
|
827 | + continue; |
|
828 | + } |
|
829 | + if ( isset( $subfields[$field] ) && !empty( $subfields[$field]['label'] ) ) { |
|
830 | + return $subfields[$field]['label']; |
|
831 | + } |
|
826 | 832 | } |
827 | 833 | } |
828 | 834 |
@@ -284,12 +284,12 @@ discard block |
||
284 | 284 | ); |
285 | 285 | $title = esc_attr__( 'Duplicate Event', 'event_espresso' ); |
286 | 286 | $return .= '<a href="' |
287 | - . $href |
|
288 | - . '" title="' |
|
289 | - . $title |
|
290 | - . '" id="ee-duplicate-event-button" class="button button-small" value="duplicate_event">' |
|
291 | - . $title |
|
292 | - . '</button>'; |
|
287 | + . $href |
|
288 | + . '" title="' |
|
289 | + . $title |
|
290 | + . '" id="ee-duplicate-event-button" class="button button-small" value="duplicate_event">' |
|
291 | + . $title |
|
292 | + . '</button>'; |
|
293 | 293 | } |
294 | 294 | return $return; |
295 | 295 | } |
@@ -450,11 +450,11 @@ discard block |
||
450 | 450 | ); |
451 | 451 | $reports_link = EE_Admin_Page::add_query_args_and_nonce( $reports_query_args, REG_ADMIN_URL ); |
452 | 452 | $action_links[] = '<a href="' |
453 | - . $reports_link |
|
454 | - . '" title="' |
|
455 | - . esc_attr__( 'View Report', 'event_espresso' ) |
|
456 | - . '"><div class="dashicons dashicons-chart-bar"></div></a>' |
|
457 | - . "\n\t"; |
|
453 | + . $reports_link |
|
454 | + . '" title="' |
|
455 | + . esc_attr__( 'View Report', 'event_espresso' ) |
|
456 | + . '"><div class="dashicons dashicons-chart-bar"></div></a>' |
|
457 | + . "\n\t"; |
|
458 | 458 | } |
459 | 459 | if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_global_messages', 'view_filtered_messages' ) ) { |
460 | 460 | EE_Registry::instance()->load_helper( 'MSG_Template' ); |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | /** |
332 | 332 | * @param $template |
333 | 333 | * @param $template_args |
334 | - * @return mixed |
|
334 | + * @return string |
|
335 | 335 | */ |
336 | 336 | public function add_additional_datetime_button( $template, $template_args ) { |
337 | 337 | return EEH_Template::display_template( |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | /** |
347 | 347 | * @param $template |
348 | 348 | * @param $template_args |
349 | - * @return mixed |
|
349 | + * @return string |
|
350 | 350 | */ |
351 | 351 | public function add_datetime_clone_button( $template, $template_args ) { |
352 | 352 | return EEH_Template::display_template( |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | /** |
362 | 362 | * @param $template |
363 | 363 | * @param $template_args |
364 | - * @return mixed |
|
364 | + * @return string |
|
365 | 365 | */ |
366 | 366 | public function datetime_timezones_template( $template, $template_args ) { |
367 | 367 | return EEH_Template::display_template( |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'NO direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('NO direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | |
@@ -21,26 +21,26 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param bool $routing |
23 | 23 | */ |
24 | - public function __construct( $routing = true ) { |
|
25 | - parent::__construct( $routing ); |
|
26 | - if ( ! defined( 'EVENTS_CAF_TEMPLATE_PATH' ) ) { |
|
27 | - define( 'EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/' ); |
|
28 | - define( 'EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/' ); |
|
29 | - define( 'EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/' ); |
|
24 | + public function __construct($routing = true) { |
|
25 | + parent::__construct($routing); |
|
26 | + if ( ! defined('EVENTS_CAF_TEMPLATE_PATH')) { |
|
27 | + define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'events/templates/'); |
|
28 | + define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND.'events/assets/'); |
|
29 | + define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'events/assets/'); |
|
30 | 30 | } |
31 | 31 | } |
32 | 32 | |
33 | 33 | |
34 | 34 | |
35 | 35 | protected function _extend_page_config() { |
36 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events'; |
|
36 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'events'; |
|
37 | 37 | //is there a evt_id in the request? |
38 | - $evt_id = ! empty( $this->_req_data['EVT_ID'] ) && ! is_array( $this->_req_data['EVT_ID'] ) |
|
38 | + $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) |
|
39 | 39 | ? $this->_req_data['EVT_ID'] |
40 | 40 | : 0; |
41 | - $evt_id = ! empty( $this->_req_data['post'] ) ? $this->_req_data['post'] : $evt_id; |
|
41 | + $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id; |
|
42 | 42 | //tkt_id? |
43 | - $tkt_id = ! empty( $this->_req_data['TKT_ID'] ) && ! is_array( $this->_req_data['TKT_ID'] ) |
|
43 | + $tkt_id = ! empty($this->_req_data['TKT_ID']) && ! is_array($this->_req_data['TKT_ID']) |
|
44 | 44 | ? $this->_req_data['TKT_ID'] |
45 | 45 | : 0; |
46 | 46 | $new_page_routes = array( |
@@ -59,13 +59,13 @@ discard block |
||
59 | 59 | 'capability' => 'ee_delete_default_ticket', |
60 | 60 | 'obj_id' => $tkt_id, |
61 | 61 | 'noheader' => true, |
62 | - 'args' => array( 'trash' => true ), |
|
62 | + 'args' => array('trash' => true), |
|
63 | 63 | ), |
64 | 64 | 'trash_tickets' => array( |
65 | 65 | 'func' => '_trash_or_restore_ticket', |
66 | 66 | 'capability' => 'ee_delete_default_tickets', |
67 | 67 | 'noheader' => true, |
68 | - 'args' => array( 'trash' => true ), |
|
68 | + 'args' => array('trash' => true), |
|
69 | 69 | ), |
70 | 70 | 'restore_ticket' => array( |
71 | 71 | 'func' => '_trash_or_restore_ticket', |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | 'noheader' => true, |
125 | 125 | ), |
126 | 126 | ); |
127 | - $this->_page_routes = array_merge( $this->_page_routes, $new_page_routes ); |
|
127 | + $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
128 | 128 | //partial route/config override |
129 | 129 | $this->_page_config['import_events']['metaboxes'] = $this->_default_espresso_metaboxes; |
130 | 130 | $this->_page_config['create_new']['metaboxes'][] = '_premium_event_editor_meta_boxes'; |
@@ -134,15 +134,15 @@ discard block |
||
134 | 134 | $this->_page_config['default']['list_table'] = 'Extend_Events_Admin_List_Table'; |
135 | 135 | //add tickets tab but only if there are more than one default ticket! |
136 | 136 | $tkt_count = EEM_Ticket::instance()->count_deleted_and_undeleted( |
137 | - array( array( 'TKT_is_default' => 1 ) ), |
|
137 | + array(array('TKT_is_default' => 1)), |
|
138 | 138 | 'TKT_ID', |
139 | 139 | true |
140 | 140 | ); |
141 | - if ( $tkt_count > 1 ) { |
|
141 | + if ($tkt_count > 1) { |
|
142 | 142 | $new_page_config = array( |
143 | 143 | 'ticket_list_table' => array( |
144 | 144 | 'nav' => array( |
145 | - 'label' => esc_html__( 'Default Tickets', 'event_espresso' ), |
|
145 | + 'label' => esc_html__('Default Tickets', 'event_espresso'), |
|
146 | 146 | 'order' => 60, |
147 | 147 | ), |
148 | 148 | 'list_table' => 'Tickets_List_Table', |
@@ -153,53 +153,53 @@ discard block |
||
153 | 153 | //template settings |
154 | 154 | $new_page_config['template_settings'] = array( |
155 | 155 | 'nav' => array( |
156 | - 'label' => esc_html__( 'Templates', 'event_espresso' ), |
|
156 | + 'label' => esc_html__('Templates', 'event_espresso'), |
|
157 | 157 | 'order' => 30, |
158 | 158 | ), |
159 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_publish_post_box' ) ), |
|
159 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
160 | 160 | 'help_tabs' => array( |
161 | 161 | 'general_settings_templates_help_tab' => array( |
162 | - 'title' => esc_html__( 'Templates', 'event_espresso' ), |
|
162 | + 'title' => esc_html__('Templates', 'event_espresso'), |
|
163 | 163 | 'filename' => 'general_settings_templates', |
164 | 164 | ), |
165 | 165 | ), |
166 | - 'help_tour' => array( 'Templates_Help_Tour' ), |
|
166 | + 'help_tour' => array('Templates_Help_Tour'), |
|
167 | 167 | 'require_nonce' => false, |
168 | 168 | ); |
169 | - $this->_page_config = array_merge( $this->_page_config, $new_page_config ); |
|
169 | + $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
170 | 170 | //add filters and actions |
171 | 171 | //modifying _views |
172 | 172 | add_filter( |
173 | 173 | 'FHEE_event_datetime_metabox_add_additional_date_time_template', |
174 | - array( $this, 'add_additional_datetime_button' ), |
|
174 | + array($this, 'add_additional_datetime_button'), |
|
175 | 175 | 10, |
176 | 176 | 2 |
177 | 177 | ); |
178 | 178 | add_filter( |
179 | 179 | 'FHEE_event_datetime_metabox_clone_button_template', |
180 | - array( $this, 'add_datetime_clone_button' ), |
|
180 | + array($this, 'add_datetime_clone_button'), |
|
181 | 181 | 10, |
182 | 182 | 2 |
183 | 183 | ); |
184 | 184 | add_filter( |
185 | 185 | 'FHEE_event_datetime_metabox_timezones_template', |
186 | - array( $this, 'datetime_timezones_template' ), |
|
186 | + array($this, 'datetime_timezones_template'), |
|
187 | 187 | 10, |
188 | 188 | 2 |
189 | 189 | ); |
190 | 190 | //filters for event list table |
191 | - add_filter( 'FHEE__Extend_Events_Admin_List_Table__filters', array( $this, 'list_table_filters' ), 10, 2 ); |
|
191 | + add_filter('FHEE__Extend_Events_Admin_List_Table__filters', array($this, 'list_table_filters'), 10, 2); |
|
192 | 192 | add_filter( |
193 | 193 | 'FHEE__Events_Admin_List_Table__column_actions__action_links', |
194 | - array( $this, 'extra_list_table_actions' ), |
|
194 | + array($this, 'extra_list_table_actions'), |
|
195 | 195 | 10, |
196 | 196 | 2 |
197 | 197 | ); |
198 | 198 | //legend item |
199 | - add_filter( 'FHEE__Events_Admin_Page___event_legend_items__items', array( $this, 'additional_legend_items' ) ); |
|
200 | - add_action( 'admin_init', array( $this, 'admin_init' ) ); |
|
199 | + add_filter('FHEE__Events_Admin_Page___event_legend_items__items', array($this, 'additional_legend_items')); |
|
200 | + add_action('admin_init', array($this, 'admin_init')); |
|
201 | 201 | //heartbeat stuff |
202 | - add_filter( 'heartbeat_received', array( $this, 'heartbeat_response' ), 10, 2 ); |
|
202 | + add_filter('heartbeat_received', array($this, 'heartbeat_response'), 10, 2); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | |
@@ -215,11 +215,11 @@ discard block |
||
215 | 215 | 'Do you really want to delete this image? Please remember to update your event to complete the removal.', |
216 | 216 | 'event_espresso' |
217 | 217 | ), |
218 | - 'event_starts_on' => esc_html__( 'Event Starts on', 'event_espresso' ), |
|
219 | - 'event_ends_on' => esc_html__( 'Event Ends on', 'event_espresso' ), |
|
220 | - 'event_datetime_actions' => esc_html__( 'Actions', 'event_espresso' ), |
|
221 | - 'event_clone_dt_msg' => esc_html__( 'Clone this Event Date and Time', 'event_espresso' ), |
|
222 | - 'remove_event_dt_msg' => esc_html__( 'Remove this Event Time', 'event_espresso' ), |
|
218 | + 'event_starts_on' => esc_html__('Event Starts on', 'event_espresso'), |
|
219 | + 'event_ends_on' => esc_html__('Event Ends on', 'event_espresso'), |
|
220 | + 'event_datetime_actions' => esc_html__('Actions', 'event_espresso'), |
|
221 | + 'event_clone_dt_msg' => esc_html__('Clone this Event Date and Time', 'event_espresso'), |
|
222 | + 'remove_event_dt_msg' => esc_html__('Remove this Event Time', 'event_espresso'), |
|
223 | 223 | ) |
224 | 224 | ); |
225 | 225 | } |
@@ -234,12 +234,12 @@ discard block |
||
234 | 234 | * @param array $data The incoming data package. |
235 | 235 | * @return array possibly appended response. |
236 | 236 | */ |
237 | - public function heartbeat_response( $response, $data ) { |
|
237 | + public function heartbeat_response($response, $data) { |
|
238 | 238 | /** |
239 | 239 | * check whether count of tickets is approaching the potential |
240 | 240 | * limits for the server. |
241 | 241 | */ |
242 | - if ( ! empty( $data['input_count'] ) ) { |
|
242 | + if ( ! empty($data['input_count'])) { |
|
243 | 243 | $response['max_input_vars_check'] = EE_Registry::instance()->CFG->environment->max_input_vars_limit_check( |
244 | 244 | $data['input_count'] |
245 | 245 | ); |
@@ -262,15 +262,15 @@ discard block |
||
262 | 262 | * @param string $new_slug |
263 | 263 | * @return string |
264 | 264 | */ |
265 | - public function extra_permalink_field_buttons( $return, $id, $new_title, $new_slug ) { |
|
266 | - $return = parent::extra_permalink_field_buttons( $return, $id, $new_title, $new_slug ); |
|
265 | + public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) { |
|
266 | + $return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug); |
|
267 | 267 | //make sure this is only when editing |
268 | - if ( ! empty( $id ) ) { |
|
268 | + if ( ! empty($id)) { |
|
269 | 269 | $href = EE_Admin_Page::add_query_args_and_nonce( |
270 | - array( 'action' => 'duplicate_event', 'EVT_ID' => $id ), |
|
270 | + array('action' => 'duplicate_event', 'EVT_ID' => $id), |
|
271 | 271 | $this->_admin_base_url |
272 | 272 | ); |
273 | - $title = esc_attr__( 'Duplicate Event', 'event_espresso' ); |
|
273 | + $title = esc_attr__('Duplicate Event', 'event_espresso'); |
|
274 | 274 | $return .= '<a href="' |
275 | 275 | . $href |
276 | 276 | . '" title="' |
@@ -288,19 +288,19 @@ discard block |
||
288 | 288 | $this->_views = array( |
289 | 289 | 'all' => array( |
290 | 290 | 'slug' => 'all', |
291 | - 'label' => esc_html__( 'All', 'event_espresso' ), |
|
291 | + 'label' => esc_html__('All', 'event_espresso'), |
|
292 | 292 | 'count' => 0, |
293 | 293 | 'bulk_action' => array( |
294 | - 'trash_tickets' => esc_html__( 'Move to Trash', 'event_espresso' ), |
|
294 | + 'trash_tickets' => esc_html__('Move to Trash', 'event_espresso'), |
|
295 | 295 | ), |
296 | 296 | ), |
297 | 297 | 'trashed' => array( |
298 | 298 | 'slug' => 'trashed', |
299 | - 'label' => esc_html__( 'Trash', 'event_espresso' ), |
|
299 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
300 | 300 | 'count' => 0, |
301 | 301 | 'bulk_action' => array( |
302 | - 'restore_tickets' => esc_html__( 'Restore from Trash', 'event_espresso' ), |
|
303 | - 'delete_tickets' => esc_html__( 'Delete Permanently', 'event_espresso' ), |
|
302 | + 'restore_tickets' => esc_html__('Restore from Trash', 'event_espresso'), |
|
303 | + 'delete_tickets' => esc_html__('Delete Permanently', 'event_espresso'), |
|
304 | 304 | ), |
305 | 305 | ), |
306 | 306 | ); |
@@ -311,19 +311,19 @@ discard block |
||
311 | 311 | public function load_scripts_styles_edit() { |
312 | 312 | wp_register_script( |
313 | 313 | 'ee-event-editor-heartbeat', |
314 | - EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js', |
|
315 | - array( 'ee_admin_js', 'heartbeat' ), |
|
314 | + EVENTS_CAF_ASSETS_URL.'event-editor-heartbeat.js', |
|
315 | + array('ee_admin_js', 'heartbeat'), |
|
316 | 316 | EVENT_ESPRESSO_VERSION, |
317 | 317 | true |
318 | 318 | ); |
319 | 319 | /** |
320 | 320 | * load accounting js. |
321 | 321 | */ |
322 | - add_filter( 'FHEE_load_accounting_js', '__return_true' ); |
|
322 | + add_filter('FHEE_load_accounting_js', '__return_true'); |
|
323 | 323 | //styles |
324 | - wp_enqueue_style( 'espresso-ui-theme' ); |
|
325 | - wp_enqueue_script( 'event_editor_js' ); |
|
326 | - wp_enqueue_script( 'ee-event-editor-heartbeat' ); |
|
324 | + wp_enqueue_style('espresso-ui-theme'); |
|
325 | + wp_enqueue_script('event_editor_js'); |
|
326 | + wp_enqueue_script('ee-event-editor-heartbeat'); |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | |
@@ -333,9 +333,9 @@ discard block |
||
333 | 333 | * @param $template_args |
334 | 334 | * @return mixed |
335 | 335 | */ |
336 | - public function add_additional_datetime_button( $template, $template_args ) { |
|
336 | + public function add_additional_datetime_button($template, $template_args) { |
|
337 | 337 | return EEH_Template::display_template( |
338 | - EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php', |
|
338 | + EVENTS_CAF_TEMPLATE_PATH.'event_datetime_add_additional_time.template.php', |
|
339 | 339 | $template_args, |
340 | 340 | true |
341 | 341 | ); |
@@ -348,9 +348,9 @@ discard block |
||
348 | 348 | * @param $template_args |
349 | 349 | * @return mixed |
350 | 350 | */ |
351 | - public function add_datetime_clone_button( $template, $template_args ) { |
|
351 | + public function add_datetime_clone_button($template, $template_args) { |
|
352 | 352 | return EEH_Template::display_template( |
353 | - EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php', |
|
353 | + EVENTS_CAF_TEMPLATE_PATH.'event_datetime_metabox_clone_button.template.php', |
|
354 | 354 | $template_args, |
355 | 355 | true |
356 | 356 | ); |
@@ -363,9 +363,9 @@ discard block |
||
363 | 363 | * @param $template_args |
364 | 364 | * @return mixed |
365 | 365 | */ |
366 | - public function datetime_timezones_template( $template, $template_args ) { |
|
366 | + public function datetime_timezones_template($template, $template_args) { |
|
367 | 367 | return EEH_Template::display_template( |
368 | - EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php', |
|
368 | + EVENTS_CAF_TEMPLATE_PATH.'event_datetime_timezones.template.php', |
|
369 | 369 | $template_args, |
370 | 370 | true |
371 | 371 | ); |
@@ -378,22 +378,22 @@ discard block |
||
378 | 378 | $new_views = array( |
379 | 379 | 'today' => array( |
380 | 380 | 'slug' => 'today', |
381 | - 'label' => esc_html__( 'Today', 'event_espresso' ), |
|
381 | + 'label' => esc_html__('Today', 'event_espresso'), |
|
382 | 382 | 'count' => $this->total_events_today(), |
383 | 383 | 'bulk_action' => array( |
384 | - 'trash_events' => esc_html__( 'Move to Trash', 'event_espresso' ), |
|
384 | + 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
385 | 385 | ), |
386 | 386 | ), |
387 | 387 | 'month' => array( |
388 | 388 | 'slug' => 'month', |
389 | - 'label' => esc_html__( 'This Month', 'event_espresso' ), |
|
389 | + 'label' => esc_html__('This Month', 'event_espresso'), |
|
390 | 390 | 'count' => $this->total_events_this_month(), |
391 | 391 | 'bulk_action' => array( |
392 | - 'trash_events' => esc_html__( 'Move to Trash', 'event_espresso' ), |
|
392 | + 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
393 | 393 | ), |
394 | 394 | ), |
395 | 395 | ); |
396 | - $this->_views = array_merge( $this->_views, $new_views ); |
|
396 | + $this->_views = array_merge($this->_views, $new_views); |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | * @param \EE_Event $event |
404 | 404 | * @return array |
405 | 405 | */ |
406 | - public function extra_list_table_actions( array $action_links, \EE_Event $event ) { |
|
406 | + public function extra_list_table_actions(array $action_links, \EE_Event $event) { |
|
407 | 407 | if ( |
408 | 408 | EE_Registry::instance()->CAP->current_user_can( |
409 | 409 | 'ee_read_registrations', |
@@ -415,20 +415,20 @@ discard block |
||
415 | 415 | 'action' => 'reports', |
416 | 416 | 'EVT_ID' => $event->ID(), |
417 | 417 | ); |
418 | - $reports_link = EE_Admin_Page::add_query_args_and_nonce( $reports_query_args, REG_ADMIN_URL ); |
|
418 | + $reports_link = EE_Admin_Page::add_query_args_and_nonce($reports_query_args, REG_ADMIN_URL); |
|
419 | 419 | $action_links[] = '<a href="' |
420 | 420 | . $reports_link |
421 | 421 | . '" title="' |
422 | - . esc_attr__( 'View Report', 'event_espresso' ) |
|
422 | + . esc_attr__('View Report', 'event_espresso') |
|
423 | 423 | . '"><div class="dashicons dashicons-chart-bar"></div></a>' |
424 | 424 | . "\n\t"; |
425 | 425 | } |
426 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_global_messages', 'view_filtered_messages' ) ) { |
|
427 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
426 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
427 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
428 | 428 | $action_links[] = EEH_MSG_Template::get_message_action_link( |
429 | 429 | 'see_notifications_for', |
430 | 430 | null, |
431 | - array( 'EVT_ID' => $event->ID() ) |
|
431 | + array('EVT_ID' => $event->ID()) |
|
432 | 432 | ); |
433 | 433 | } |
434 | 434 | return $action_links; |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | * @param $items |
441 | 441 | * @return mixed |
442 | 442 | */ |
443 | - public function additional_legend_items( $items ) { |
|
443 | + public function additional_legend_items($items) { |
|
444 | 444 | if ( |
445 | 445 | EE_Registry::instance()->CAP->current_user_can( |
446 | 446 | 'ee_read_registrations', |
@@ -449,12 +449,12 @@ discard block |
||
449 | 449 | ) { |
450 | 450 | $items['reports'] = array( |
451 | 451 | 'class' => 'dashicons dashicons-chart-bar', |
452 | - 'desc' => esc_html__( 'Event Reports', 'event_espresso' ), |
|
452 | + 'desc' => esc_html__('Event Reports', 'event_espresso'), |
|
453 | 453 | ); |
454 | 454 | } |
455 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_global_messages', 'view_filtered_messages' ) ) { |
|
456 | - $related_for_icon = EEH_MSG_Template::get_message_action_icon( 'see_notifications_for' ); |
|
457 | - if ( isset( $related_for_icon['css_class'] ) && isset( $related_for_icon['label'] ) ) { |
|
455 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
456 | + $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for'); |
|
457 | + if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) { |
|
458 | 458 | $items['view_related_messages'] = array( |
459 | 459 | 'class' => $related_for_icon['css_class'], |
460 | 460 | 'desc' => $related_for_icon['label'], |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | protected function _duplicate_event() { |
481 | 481 | // first make sure the ID for the event is in the request. |
482 | 482 | // If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?) |
483 | - if ( ! isset( $this->_req_data['EVT_ID'] ) ) { |
|
483 | + if ( ! isset($this->_req_data['EVT_ID'])) { |
|
484 | 484 | EE_Error::add_error( |
485 | 485 | esc_html__( |
486 | 486 | 'In order to duplicate an event an Event ID is required. None was given.', |
@@ -490,15 +490,15 @@ discard block |
||
490 | 490 | __FUNCTION__, |
491 | 491 | __LINE__ |
492 | 492 | ); |
493 | - $this->_redirect_after_action( false, '', '', array(), true ); |
|
493 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
494 | 494 | return; |
495 | 495 | } |
496 | 496 | //k we've got EVT_ID so let's use that to get the event we'll duplicate |
497 | - $orig_event = EEM_Event::instance()->get_one_by_ID( $this->_req_data['EVT_ID'] ); |
|
498 | - if ( ! $orig_event instanceof EE_Event ) { |
|
497 | + $orig_event = EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']); |
|
498 | + if ( ! $orig_event instanceof EE_Event) { |
|
499 | 499 | throw new EE_Error( |
500 | 500 | sprintf( |
501 | - esc_html__( 'An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso' ), |
|
501 | + esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'), |
|
502 | 502 | $this->_req_data['EVT_ID'] |
503 | 503 | ) |
504 | 504 | ); |
@@ -506,56 +506,56 @@ discard block |
||
506 | 506 | //k now let's clone the $orig_event before getting relations |
507 | 507 | $new_event = clone $orig_event; |
508 | 508 | //original datetimes |
509 | - $orig_datetimes = $orig_event->get_many_related( 'Datetime' ); |
|
509 | + $orig_datetimes = $orig_event->get_many_related('Datetime'); |
|
510 | 510 | //other original relations |
511 | - $orig_ven = $orig_event->get_many_related( 'Venue' ); |
|
511 | + $orig_ven = $orig_event->get_many_related('Venue'); |
|
512 | 512 | //reset the ID and modify other details to make it clear this is a dupe |
513 | - $new_event->set( 'EVT_ID', 0 ); |
|
514 | - $new_name = $new_event->name() . ' ' . esc_html__( '**DUPLICATE**', 'event_espresso' ); |
|
515 | - $new_event->set( 'EVT_name', $new_name ); |
|
513 | + $new_event->set('EVT_ID', 0); |
|
514 | + $new_name = $new_event->name().' '.esc_html__('**DUPLICATE**', 'event_espresso'); |
|
515 | + $new_event->set('EVT_name', $new_name); |
|
516 | 516 | $new_event->set( |
517 | 517 | 'EVT_slug', |
518 | 518 | wp_unique_post_slug( |
519 | - sanitize_title( $orig_event->name() ), |
|
519 | + sanitize_title($orig_event->name()), |
|
520 | 520 | 0, |
521 | 521 | 'publish', |
522 | 522 | 'espresso_events', |
523 | 523 | 0 |
524 | 524 | ) |
525 | 525 | ); |
526 | - $new_event->set( 'status', 'draft' ); |
|
526 | + $new_event->set('status', 'draft'); |
|
527 | 527 | //duplicate discussion settings |
528 | - $new_event->set( 'comment_status', $orig_event->get( 'comment_status' ) ); |
|
529 | - $new_event->set( 'ping_status', $orig_event->get( 'ping_status' ) ); |
|
528 | + $new_event->set('comment_status', $orig_event->get('comment_status')); |
|
529 | + $new_event->set('ping_status', $orig_event->get('ping_status')); |
|
530 | 530 | //save the new event |
531 | 531 | $new_event->save(); |
532 | 532 | //venues |
533 | - foreach ( $orig_ven as $ven ) { |
|
534 | - $new_event->_add_relation_to( $ven, 'Venue' ); |
|
533 | + foreach ($orig_ven as $ven) { |
|
534 | + $new_event->_add_relation_to($ven, 'Venue'); |
|
535 | 535 | } |
536 | 536 | $new_event->save(); |
537 | 537 | //now we need to get the question group relations and handle that |
538 | 538 | //first primary question groups |
539 | 539 | $orig_primary_qgs = $orig_event->get_many_related( |
540 | 540 | 'Question_Group', |
541 | - array( array( 'Event_Question_Group.EQG_primary' => 1 ) ) |
|
541 | + array(array('Event_Question_Group.EQG_primary' => 1)) |
|
542 | 542 | ); |
543 | - if ( ! empty( $orig_primary_qgs ) ) { |
|
544 | - foreach ( $orig_primary_qgs as $id => $obj ) { |
|
545 | - if ( $obj instanceof EE_Question_Group ) { |
|
546 | - $new_event->_add_relation_to( $obj, 'Question_Group', array( 'EQG_primary' => 1 ) ); |
|
543 | + if ( ! empty($orig_primary_qgs)) { |
|
544 | + foreach ($orig_primary_qgs as $id => $obj) { |
|
545 | + if ($obj instanceof EE_Question_Group) { |
|
546 | + $new_event->_add_relation_to($obj, 'Question_Group', array('EQG_primary' => 1)); |
|
547 | 547 | } |
548 | 548 | } |
549 | 549 | } |
550 | 550 | //next additional attendee question groups |
551 | 551 | $orig_additional_qgs = $orig_event->get_many_related( |
552 | 552 | 'Question_Group', |
553 | - array( array( 'Event_Question_Group.EQG_primary' => 0 ) ) |
|
553 | + array(array('Event_Question_Group.EQG_primary' => 0)) |
|
554 | 554 | ); |
555 | - if ( ! empty( $orig_additional_qgs ) ) { |
|
556 | - foreach ( $orig_additional_qgs as $id => $obj ) { |
|
557 | - if ( $obj instanceof EE_Question_Group ) { |
|
558 | - $new_event->_add_relation_to( $obj, 'Question_Group', array( 'EQG_primary' => 0 ) ); |
|
555 | + if ( ! empty($orig_additional_qgs)) { |
|
556 | + foreach ($orig_additional_qgs as $id => $obj) { |
|
557 | + if ($obj instanceof EE_Question_Group) { |
|
558 | + $new_event->_add_relation_to($obj, 'Question_Group', array('EQG_primary' => 0)); |
|
559 | 559 | } |
560 | 560 | } |
561 | 561 | } |
@@ -563,70 +563,70 @@ discard block |
||
563 | 563 | $new_event->save(); |
564 | 564 | //k now that we have the new event saved we can loop through the datetimes and start adding relations. |
565 | 565 | $cloned_tickets = array(); |
566 | - foreach ( $orig_datetimes as $orig_dtt ) { |
|
567 | - if ( ! $orig_dtt instanceof EE_Datetime ) { |
|
566 | + foreach ($orig_datetimes as $orig_dtt) { |
|
567 | + if ( ! $orig_dtt instanceof EE_Datetime) { |
|
568 | 568 | continue; |
569 | 569 | } |
570 | 570 | $new_dtt = clone $orig_dtt; |
571 | 571 | $orig_tkts = $orig_dtt->tickets(); |
572 | 572 | //save new dtt then add to event |
573 | - $new_dtt->set( 'DTT_ID', 0 ); |
|
574 | - $new_dtt->set( 'DTT_sold', 0 ); |
|
573 | + $new_dtt->set('DTT_ID', 0); |
|
574 | + $new_dtt->set('DTT_sold', 0); |
|
575 | 575 | $new_dtt->save(); |
576 | - $new_event->_add_relation_to( $new_dtt, 'Datetime' ); |
|
576 | + $new_event->_add_relation_to($new_dtt, 'Datetime'); |
|
577 | 577 | $new_event->save(); |
578 | 578 | //now let's get the ticket relations setup. |
579 | - foreach ( (array) $orig_tkts as $orig_tkt ) { |
|
579 | + foreach ((array) $orig_tkts as $orig_tkt) { |
|
580 | 580 | //it's possible a datetime will have no tickets so let's verify we HAVE a ticket first. |
581 | - if ( ! $orig_tkt instanceof EE_Ticket ) { |
|
581 | + if ( ! $orig_tkt instanceof EE_Ticket) { |
|
582 | 582 | continue; |
583 | 583 | } |
584 | 584 | //is this ticket archived? If it is then let's skip |
585 | - if ( $orig_tkt->get( 'TKT_deleted' ) ) { |
|
585 | + if ($orig_tkt->get('TKT_deleted')) { |
|
586 | 586 | continue; |
587 | 587 | } |
588 | 588 | // does this original ticket already exist in the clone_tickets cache? |
589 | 589 | // If so we'll just use the new ticket from it. |
590 | - if ( isset( $cloned_tickets[ $orig_tkt->ID() ] ) ) { |
|
591 | - $new_tkt = $cloned_tickets[ $orig_tkt->ID() ]; |
|
590 | + if (isset($cloned_tickets[$orig_tkt->ID()])) { |
|
591 | + $new_tkt = $cloned_tickets[$orig_tkt->ID()]; |
|
592 | 592 | } else { |
593 | 593 | $new_tkt = clone $orig_tkt; |
594 | 594 | //get relations on the $orig_tkt that we need to setup. |
595 | 595 | $orig_prices = $orig_tkt->prices(); |
596 | - $new_tkt->set( 'TKT_ID', 0 ); |
|
597 | - $new_tkt->set( 'TKT_sold', 0 ); |
|
596 | + $new_tkt->set('TKT_ID', 0); |
|
597 | + $new_tkt->set('TKT_sold', 0); |
|
598 | 598 | $new_tkt->save(); //make sure new ticket has ID. |
599 | 599 | //price relations on new ticket need to be setup. |
600 | - foreach ( $orig_prices as $orig_price ) { |
|
600 | + foreach ($orig_prices as $orig_price) { |
|
601 | 601 | $new_price = clone $orig_price; |
602 | - $new_price->set( 'PRC_ID', 0 ); |
|
602 | + $new_price->set('PRC_ID', 0); |
|
603 | 603 | $new_price->save(); |
604 | - $new_tkt->_add_relation_to( $new_price, 'Price' ); |
|
604 | + $new_tkt->_add_relation_to($new_price, 'Price'); |
|
605 | 605 | $new_tkt->save(); |
606 | 606 | } |
607 | 607 | } |
608 | 608 | // k now we can add the new ticket as a relation to the new datetime |
609 | 609 | // and make sure its added to our cached $cloned_tickets array |
610 | 610 | // for use with later datetimes that have the same ticket. |
611 | - $new_dtt->_add_relation_to( $new_tkt, 'Ticket' ); |
|
611 | + $new_dtt->_add_relation_to($new_tkt, 'Ticket'); |
|
612 | 612 | $new_dtt->save(); |
613 | - $cloned_tickets[ $orig_tkt->ID() ] = $new_tkt; |
|
613 | + $cloned_tickets[$orig_tkt->ID()] = $new_tkt; |
|
614 | 614 | } |
615 | 615 | } |
616 | 616 | //clone taxonomy information |
617 | 617 | $taxonomies_to_clone_with = apply_filters( |
618 | 618 | 'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone', |
619 | - array( 'espresso_event_categories', 'espresso_event_type', 'post_tag' ) |
|
619 | + array('espresso_event_categories', 'espresso_event_type', 'post_tag') |
|
620 | 620 | ); |
621 | 621 | //get terms for original event (notice) |
622 | - $orig_terms = wp_get_object_terms( $orig_event->ID(), $taxonomies_to_clone_with ); |
|
622 | + $orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with); |
|
623 | 623 | //loop through terms and add them to new event. |
624 | - foreach ( $orig_terms as $term ) { |
|
625 | - wp_set_object_terms( $new_event->ID(), $term->term_id, $term->taxonomy, true ); |
|
624 | + foreach ($orig_terms as $term) { |
|
625 | + wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true); |
|
626 | 626 | } |
627 | - do_action( 'AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event ); |
|
627 | + do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event); |
|
628 | 628 | //now let's redirect to the edit page for this duplicated event if we have a new event id. |
629 | - if ( $new_event->ID() ) { |
|
629 | + if ($new_event->ID()) { |
|
630 | 630 | $redirect_args = array( |
631 | 631 | 'post' => $new_event->ID(), |
632 | 632 | 'action' => 'edit', |
@@ -642,19 +642,19 @@ discard block |
||
642 | 642 | 'action' => 'default', |
643 | 643 | ); |
644 | 644 | EE_Error::add_error( |
645 | - esc_html__( 'Not able to duplicate event. Something went wrong.', 'event_espresso' ), |
|
645 | + esc_html__('Not able to duplicate event. Something went wrong.', 'event_espresso'), |
|
646 | 646 | __FILE__, |
647 | 647 | __FUNCTION__, |
648 | 648 | __LINE__ |
649 | 649 | ); |
650 | 650 | } |
651 | - $this->_redirect_after_action( false, '', '', $redirect_args, true ); |
|
651 | + $this->_redirect_after_action(false, '', '', $redirect_args, true); |
|
652 | 652 | } |
653 | 653 | |
654 | 654 | |
655 | 655 | |
656 | 656 | protected function _import_page() { |
657 | - $title = esc_html__( 'Import', 'event_espresso' ); |
|
657 | + $title = esc_html__('Import', 'event_espresso'); |
|
658 | 658 | $intro = esc_html__( |
659 | 659 | 'If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ', |
660 | 660 | 'event_espresso' |
@@ -662,13 +662,13 @@ discard block |
||
662 | 662 | $form_url = EVENTS_ADMIN_URL; |
663 | 663 | $action = 'import_events'; |
664 | 664 | $type = 'csv'; |
665 | - $this->_template_args['form'] = EE_Import::instance()->upload_form( $title, $intro, $form_url, $action, $type ); |
|
665 | + $this->_template_args['form'] = EE_Import::instance()->upload_form($title, $intro, $form_url, $action, $type); |
|
666 | 666 | $this->_template_args['sample_file_link'] = EE_Admin_Page::add_query_args_and_nonce( |
667 | - array( 'action' => 'sample_export_file' ), |
|
667 | + array('action' => 'sample_export_file'), |
|
668 | 668 | $this->_admin_base_url |
669 | 669 | ); |
670 | 670 | $content = EEH_Template::display_template( |
671 | - EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php', |
|
671 | + EVENTS_CAF_TEMPLATE_PATH.'import_page.template.php', |
|
672 | 672 | $this->_template_args, |
673 | 673 | true |
674 | 674 | ); |
@@ -685,9 +685,9 @@ discard block |
||
685 | 685 | * @return void |
686 | 686 | */ |
687 | 687 | protected function _import_events() { |
688 | - require_once( EE_CLASSES . 'EE_Import.class.php' ); |
|
688 | + require_once(EE_CLASSES.'EE_Import.class.php'); |
|
689 | 689 | $success = EE_Import::instance()->import(); |
690 | - $this->_redirect_after_action( $success, 'Import File', 'ran', array( 'action' => 'import_page' ), true ); |
|
690 | + $this->_redirect_after_action($success, 'Import File', 'ran', array('action' => 'import_page'), true); |
|
691 | 691 | } |
692 | 692 | |
693 | 693 | |
@@ -700,9 +700,9 @@ discard block |
||
700 | 700 | * @return void |
701 | 701 | */ |
702 | 702 | protected function _events_export() { |
703 | - if ( isset( $this->_req_data['EVT_ID'] ) ) { |
|
703 | + if (isset($this->_req_data['EVT_ID'])) { |
|
704 | 704 | $event_ids = $this->_req_data['EVT_ID']; |
705 | - } elseif ( isset( $this->_req_data['EVT_IDs'] ) ) { |
|
705 | + } elseif (isset($this->_req_data['EVT_IDs'])) { |
|
706 | 706 | $event_ids = $this->_req_data['EVT_IDs']; |
707 | 707 | } else { |
708 | 708 | $event_ids = null; |
@@ -713,10 +713,10 @@ discard block |
||
713 | 713 | 'action' => 'all_event_data', |
714 | 714 | 'EVT_ID' => $event_ids, |
715 | 715 | ); |
716 | - $this->_req_data = array_merge( $this->_req_data, $new_request_args ); |
|
717 | - if ( is_readable( EE_CLASSES . 'EE_Export.class.php' ) ) { |
|
718 | - require_once( EE_CLASSES . 'EE_Export.class.php' ); |
|
719 | - $EE_Export = EE_Export::instance( $this->_req_data ); |
|
716 | + $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
717 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
718 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
719 | + $EE_Export = EE_Export::instance($this->_req_data); |
|
720 | 720 | $EE_Export->export(); |
721 | 721 | } |
722 | 722 | } |
@@ -735,10 +735,10 @@ discard block |
||
735 | 735 | 'action' => 'categories', |
736 | 736 | 'category_ids' => $this->_req_data['EVT_CAT_ID'], |
737 | 737 | ); |
738 | - $this->_req_data = array_merge( $this->_req_data, $new_request_args ); |
|
739 | - if ( is_readable( EE_CLASSES . 'EE_Export.class.php' ) ) { |
|
740 | - require_once( EE_CLASSES . 'EE_Export.class.php' ); |
|
741 | - $EE_Export = EE_Export::instance( $this->_req_data ); |
|
738 | + $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
739 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
740 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
741 | + $EE_Export = EE_Export::instance($this->_req_data); |
|
742 | 742 | $EE_Export->export(); |
743 | 743 | } |
744 | 744 | } |
@@ -766,10 +766,10 @@ discard block |
||
766 | 766 | 'FHEE__General_Settings_Admin_Page__template_settings__template_args', |
767 | 767 | $this->_template_args |
768 | 768 | ); |
769 | - $this->_set_add_edit_form_tags( 'update_template_settings' ); |
|
770 | - $this->_set_publish_post_box_vars( null, false, false, null, false ); |
|
769 | + $this->_set_add_edit_form_tags('update_template_settings'); |
|
770 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
771 | 771 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
772 | - EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php', |
|
772 | + EVENTS_CAF_TEMPLATE_PATH.'template_settings.template.php', |
|
773 | 773 | $this->_template_args, |
774 | 774 | true |
775 | 775 | ); |
@@ -790,9 +790,9 @@ discard block |
||
790 | 790 | ); |
791 | 791 | //update custom post type slugs and detect if we need to flush rewrite rules |
792 | 792 | $old_slug = EE_Registry::instance()->CFG->core->event_cpt_slug; |
793 | - EE_Registry::instance()->CFG->core->event_cpt_slug = empty( $this->_req_data['event_cpt_slug'] ) |
|
793 | + EE_Registry::instance()->CFG->core->event_cpt_slug = empty($this->_req_data['event_cpt_slug']) |
|
794 | 794 | ? EE_Registry::instance()->CFG->core->event_cpt_slug |
795 | - : sanitize_title_with_dashes( $this->_req_data['event_cpt_slug'] ); |
|
795 | + : sanitize_title_with_dashes($this->_req_data['event_cpt_slug']); |
|
796 | 796 | $what = 'Template Settings'; |
797 | 797 | $success = $this->_update_espresso_configuration( |
798 | 798 | $what, |
@@ -801,10 +801,10 @@ discard block |
||
801 | 801 | __FUNCTION__, |
802 | 802 | __LINE__ |
803 | 803 | ); |
804 | - if ( EE_Registry::instance()->CFG->core->event_cpt_slug != $old_slug ) { |
|
805 | - update_option( 'ee_flush_rewrite_rules', true ); |
|
804 | + if (EE_Registry::instance()->CFG->core->event_cpt_slug != $old_slug) { |
|
805 | + update_option('ee_flush_rewrite_rules', true); |
|
806 | 806 | } |
807 | - $this->_redirect_after_action( $success, $what, 'updated', array( 'action' => 'template_settings' ) ); |
|
807 | + $this->_redirect_after_action($success, $what, 'updated', array('action' => 'template_settings')); |
|
808 | 808 | } |
809 | 809 | |
810 | 810 | |
@@ -820,8 +820,8 @@ discard block |
||
820 | 820 | $this->verify_cpt_object(); |
821 | 821 | add_meta_box( |
822 | 822 | 'espresso_event_editor_event_options', |
823 | - esc_html__( 'Event Registration Options', 'event_espresso' ), |
|
824 | - array( $this, 'registration_options_meta_box' ), |
|
823 | + esc_html__('Event Registration Options', 'event_espresso'), |
|
824 | + array($this, 'registration_options_meta_box'), |
|
825 | 825 | $this->page_slug, |
826 | 826 | 'side', |
827 | 827 | 'core' |
@@ -837,8 +837,8 @@ discard block |
||
837 | 837 | */ |
838 | 838 | public function registration_options_meta_box() { |
839 | 839 | $yes_no_values = array( |
840 | - array( 'id' => true, 'text' => esc_html__( 'Yes', 'event_espresso' ) ), |
|
841 | - array( 'id' => false, 'text' => esc_html__( 'No', 'event_espresso' ) ), |
|
840 | + array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')), |
|
841 | + array('id' => false, 'text' => esc_html__('No', 'event_espresso')), |
|
842 | 842 | ); |
843 | 843 | $default_reg_status_values = EEM_Registration::reg_status_array( |
844 | 844 | array( |
@@ -849,7 +849,7 @@ discard block |
||
849 | 849 | ), |
850 | 850 | true |
851 | 851 | ); |
852 | - $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status( false ); |
|
852 | + $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false); |
|
853 | 853 | $template_args['_event'] = $this->_cpt_model_obj; |
854 | 854 | $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit(); |
855 | 855 | $template_args['default_registration_status'] = EEH_Form_Fields::select_input( |
@@ -883,7 +883,7 @@ discard block |
||
883 | 883 | $default_reg_status_values |
884 | 884 | ); |
885 | 885 | EEH_Template::display_template( |
886 | - EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
886 | + EVENTS_CAF_TEMPLATE_PATH.'event_registration_options.template.php', |
|
887 | 887 | $template_args |
888 | 888 | ); |
889 | 889 | } |
@@ -901,20 +901,20 @@ discard block |
||
901 | 901 | * @param array $list_table_obj the list table object |
902 | 902 | * @return array new filters |
903 | 903 | */ |
904 | - public function list_table_filters( $old_filters, $list_table_obj ) { |
|
904 | + public function list_table_filters($old_filters, $list_table_obj) { |
|
905 | 905 | $filters = array(); |
906 | 906 | //first month/year filters |
907 | 907 | $filters[] = $this->espresso_event_months_dropdown(); |
908 | - $status = isset( $this->_req_data['status'] ) ? $this->_req_data['status'] : null; |
|
908 | + $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null; |
|
909 | 909 | //active status dropdown |
910 | - if ( $status !== 'draft' ) { |
|
910 | + if ($status !== 'draft') { |
|
911 | 911 | $filters[] = $this->active_status_dropdown( |
912 | - isset( $this->_req_data['active_status'] ) ? $this->_req_data['active_status'] : '' |
|
912 | + isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : '' |
|
913 | 913 | ); |
914 | 914 | } |
915 | 915 | //category filter |
916 | 916 | $filters[] = $this->category_dropdown(); |
917 | - return array_merge( $old_filters, $filters ); |
|
917 | + return array_merge($old_filters, $filters); |
|
918 | 918 | } |
919 | 919 | |
920 | 920 | |
@@ -928,15 +928,15 @@ discard block |
||
928 | 928 | public function espresso_event_months_dropdown() { |
929 | 929 | // what we need to do is get all PRIMARY datetimes for all events to filter on. |
930 | 930 | // Note we need to include any other filters that are set! |
931 | - $status = isset( $this->_req_data['status'] ) ? $this->_req_data['status'] : null; |
|
931 | + $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null; |
|
932 | 932 | //categories? |
933 | - $category = isset( $this->_req_data['EVT_CAT'] ) && $this->_req_data['EVT_CAT'] > 0 |
|
933 | + $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 |
|
934 | 934 | ? $this->_req_data['EVT_CAT'] |
935 | 935 | : null; |
936 | 936 | //active status? |
937 | - $active_status = isset( $this->_req_data['active_status'] ) ? $this->_req_data['active_status'] : null; |
|
938 | - $cur_date = isset( $this->_req_data['month_range'] ) ? $this->_req_data['month_range'] : ''; |
|
939 | - return EEH_Form_Fields::generate_event_months_dropdown( $cur_date, $status, $category, $active_status ); |
|
937 | + $active_status = isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : null; |
|
938 | + $cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : ''; |
|
939 | + return EEH_Form_Fields::generate_event_months_dropdown($cur_date, $status, $category, $active_status); |
|
940 | 940 | } |
941 | 941 | |
942 | 942 | |
@@ -947,18 +947,18 @@ discard block |
||
947 | 947 | * @param string $current_value whatever the current active status is |
948 | 948 | * @return string |
949 | 949 | */ |
950 | - public function active_status_dropdown( $current_value = '' ) { |
|
950 | + public function active_status_dropdown($current_value = '') { |
|
951 | 951 | $select_name = 'active_status'; |
952 | 952 | $values = array( |
953 | - 'none' => esc_html__( 'Show Active/Inactive', 'event_espresso' ), |
|
954 | - 'active' => esc_html__( 'Active', 'event_espresso' ), |
|
955 | - 'upcoming' => esc_html__( 'Upcoming', 'event_espresso' ), |
|
956 | - 'expired' => esc_html__( 'Expired', 'event_espresso' ), |
|
957 | - 'inactive' => esc_html__( 'Inactive', 'event_espresso' ), |
|
953 | + 'none' => esc_html__('Show Active/Inactive', 'event_espresso'), |
|
954 | + 'active' => esc_html__('Active', 'event_espresso'), |
|
955 | + 'upcoming' => esc_html__('Upcoming', 'event_espresso'), |
|
956 | + 'expired' => esc_html__('Expired', 'event_espresso'), |
|
957 | + 'inactive' => esc_html__('Inactive', 'event_espresso'), |
|
958 | 958 | ); |
959 | 959 | $id = 'id="espresso-active-status-dropdown-filter"'; |
960 | 960 | $class = 'wide'; |
961 | - return EEH_Form_Fields::select_input( $select_name, $values, $current_value, $id, $class ); |
|
961 | + return EEH_Form_Fields::select_input($select_name, $values, $current_value, $id, $class); |
|
962 | 962 | } |
963 | 963 | |
964 | 964 | |
@@ -970,8 +970,8 @@ discard block |
||
970 | 970 | * @return string html |
971 | 971 | */ |
972 | 972 | public function category_dropdown() { |
973 | - $cur_cat = isset( $this->_req_data['EVT_CAT'] ) ? $this->_req_data['EVT_CAT'] : -1; |
|
974 | - return EEH_Form_Fields::generate_event_category_dropdown( $cur_cat ); |
|
973 | + $cur_cat = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1; |
|
974 | + return EEH_Form_Fields::generate_event_category_dropdown($cur_cat); |
|
975 | 975 | } |
976 | 976 | |
977 | 977 | |
@@ -985,20 +985,20 @@ discard block |
||
985 | 985 | public function total_events_today() { |
986 | 986 | $start = EEM_Datetime::instance()->convert_datetime_for_query( |
987 | 987 | 'DTT_EVT_start', |
988 | - date( 'Y-m-d' ) . ' 00:00:00', |
|
988 | + date('Y-m-d').' 00:00:00', |
|
989 | 989 | 'Y-m-d H:i:s', |
990 | 990 | 'UTC' |
991 | 991 | ); |
992 | 992 | $end = EEM_Datetime::instance()->convert_datetime_for_query( |
993 | 993 | 'DTT_EVT_start', |
994 | - date( 'Y-m-d' ) . ' 23:59:59', |
|
994 | + date('Y-m-d').' 23:59:59', |
|
995 | 995 | 'Y-m-d H:i:s', |
996 | 996 | 'UTC' |
997 | 997 | ); |
998 | 998 | $where = array( |
999 | - 'Datetime.DTT_EVT_start' => array( 'BETWEEN', array( $start, $end ) ), |
|
999 | + 'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)), |
|
1000 | 1000 | ); |
1001 | - $count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
1001 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
1002 | 1002 | return $count; |
1003 | 1003 | } |
1004 | 1004 | |
@@ -1012,25 +1012,25 @@ discard block |
||
1012 | 1012 | */ |
1013 | 1013 | public function total_events_this_month() { |
1014 | 1014 | //Dates |
1015 | - $this_year_r = date( 'Y' ); |
|
1016 | - $this_month_r = date( 'm' ); |
|
1017 | - $days_this_month = date( 't' ); |
|
1015 | + $this_year_r = date('Y'); |
|
1016 | + $this_month_r = date('m'); |
|
1017 | + $days_this_month = date('t'); |
|
1018 | 1018 | $start = EEM_Datetime::instance()->convert_datetime_for_query( |
1019 | 1019 | 'DTT_EVT_start', |
1020 | - $this_year_r . '-' . $this_month_r . '-01 00:00:00', |
|
1020 | + $this_year_r.'-'.$this_month_r.'-01 00:00:00', |
|
1021 | 1021 | 'Y-m-d H:i:s', |
1022 | 1022 | 'UTC' |
1023 | 1023 | ); |
1024 | 1024 | $end = EEM_Datetime::instance()->convert_datetime_for_query( |
1025 | 1025 | 'DTT_EVT_start', |
1026 | - $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59', |
|
1026 | + $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' 23:59:59', |
|
1027 | 1027 | 'Y-m-d H:i:s', |
1028 | 1028 | 'UTC' |
1029 | 1029 | ); |
1030 | 1030 | $where = array( |
1031 | - 'Datetime.DTT_EVT_start' => array( 'BETWEEN', array( $start, $end ) ), |
|
1031 | + 'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)), |
|
1032 | 1032 | ); |
1033 | - $count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
1033 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
1034 | 1034 | return $count; |
1035 | 1035 | } |
1036 | 1036 | |
@@ -1038,7 +1038,7 @@ discard block |
||
1038 | 1038 | |
1039 | 1039 | /** DEFAULT TICKETS STUFF **/ |
1040 | 1040 | public function _tickets_overview_list_table() { |
1041 | - $this->_search_btn_label = esc_html__( 'Tickets', 'event_espresso' ); |
|
1041 | + $this->_search_btn_label = esc_html__('Tickets', 'event_espresso'); |
|
1042 | 1042 | $this->display_admin_list_table_page_with_no_sidebar(); |
1043 | 1043 | } |
1044 | 1044 | |
@@ -1050,46 +1050,46 @@ discard block |
||
1050 | 1050 | * @param bool $trashed |
1051 | 1051 | * @return \EE_Soft_Delete_Base_Class[]|int |
1052 | 1052 | */ |
1053 | - public function get_default_tickets( $per_page = 10, $count = false, $trashed = false ) { |
|
1054 | - $orderby = empty( $this->_req_data['orderby'] ) ? 'TKT_name' : $this->_req_data['orderby']; |
|
1055 | - $order = empty( $this->_req_data['order'] ) ? 'ASC' : $this->_req_data['order']; |
|
1056 | - switch ( $orderby ) { |
|
1053 | + public function get_default_tickets($per_page = 10, $count = false, $trashed = false) { |
|
1054 | + $orderby = empty($this->_req_data['orderby']) ? 'TKT_name' : $this->_req_data['orderby']; |
|
1055 | + $order = empty($this->_req_data['order']) ? 'ASC' : $this->_req_data['order']; |
|
1056 | + switch ($orderby) { |
|
1057 | 1057 | case 'TKT_name' : |
1058 | - $orderby = array( 'TKT_name' => $order ); |
|
1058 | + $orderby = array('TKT_name' => $order); |
|
1059 | 1059 | break; |
1060 | 1060 | case 'TKT_price' : |
1061 | - $orderby = array( 'TKT_price' => $order ); |
|
1061 | + $orderby = array('TKT_price' => $order); |
|
1062 | 1062 | break; |
1063 | 1063 | case 'TKT_uses' : |
1064 | - $orderby = array( 'TKT_uses' => $order ); |
|
1064 | + $orderby = array('TKT_uses' => $order); |
|
1065 | 1065 | break; |
1066 | 1066 | case 'TKT_min' : |
1067 | - $orderby = array( 'TKT_min' => $order ); |
|
1067 | + $orderby = array('TKT_min' => $order); |
|
1068 | 1068 | break; |
1069 | 1069 | case 'TKT_max' : |
1070 | - $orderby = array( 'TKT_max' => $order ); |
|
1070 | + $orderby = array('TKT_max' => $order); |
|
1071 | 1071 | break; |
1072 | 1072 | case 'TKT_qty' : |
1073 | - $orderby = array( 'TKT_qty' => $order ); |
|
1073 | + $orderby = array('TKT_qty' => $order); |
|
1074 | 1074 | break; |
1075 | 1075 | } |
1076 | - $current_page = isset( $this->_req_data['paged'] ) && ! empty( $this->_req_data['paged'] ) |
|
1076 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) |
|
1077 | 1077 | ? $this->_req_data['paged'] |
1078 | 1078 | : 1; |
1079 | - $per_page = isset( $this->_req_data['perpage'] ) && ! empty( $this->_req_data['perpage'] ) |
|
1079 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) |
|
1080 | 1080 | ? $this->_req_data['perpage'] |
1081 | 1081 | : $per_page; |
1082 | 1082 | $_where = array( |
1083 | 1083 | 'TKT_is_default' => 1, |
1084 | 1084 | 'TKT_deleted' => $trashed, |
1085 | 1085 | ); |
1086 | - $offset = ( $current_page - 1 ) * $per_page; |
|
1087 | - $limit = array( $offset, $per_page ); |
|
1088 | - if ( isset( $this->_req_data['s'] ) ) { |
|
1089 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
1086 | + $offset = ($current_page - 1) * $per_page; |
|
1087 | + $limit = array($offset, $per_page); |
|
1088 | + if (isset($this->_req_data['s'])) { |
|
1089 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
1090 | 1090 | $_where['OR'] = array( |
1091 | - 'TKT_name' => array( 'LIKE', $sstr ), |
|
1092 | - 'TKT_description' => array( 'LIKE', $sstr ), |
|
1091 | + 'TKT_name' => array('LIKE', $sstr), |
|
1092 | + 'TKT_description' => array('LIKE', $sstr), |
|
1093 | 1093 | ); |
1094 | 1094 | } |
1095 | 1095 | $query_params = array( |
@@ -1098,10 +1098,10 @@ discard block |
||
1098 | 1098 | 'limit' => $limit, |
1099 | 1099 | 'group_by' => 'TKT_ID', |
1100 | 1100 | ); |
1101 | - if ( $count ) { |
|
1102 | - return EEM_Ticket::instance()->count_deleted_and_undeleted( array( $_where ) ); |
|
1101 | + if ($count) { |
|
1102 | + return EEM_Ticket::instance()->count_deleted_and_undeleted(array($_where)); |
|
1103 | 1103 | } else { |
1104 | - return EEM_Ticket::instance()->get_all_deleted_and_undeleted( $query_params ); |
|
1104 | + return EEM_Ticket::instance()->get_all_deleted_and_undeleted($query_params); |
|
1105 | 1105 | } |
1106 | 1106 | } |
1107 | 1107 | |
@@ -1110,34 +1110,34 @@ discard block |
||
1110 | 1110 | /** |
1111 | 1111 | * @param bool $trash |
1112 | 1112 | */ |
1113 | - protected function _trash_or_restore_ticket( $trash = false ) { |
|
1113 | + protected function _trash_or_restore_ticket($trash = false) { |
|
1114 | 1114 | $success = 1; |
1115 | 1115 | $TKT = EEM_Ticket::instance(); |
1116 | 1116 | //checkboxes? |
1117 | - if ( ! empty( $this->_req_data['checkbox'] ) && is_array( $this->_req_data['checkbox'] ) ) { |
|
1117 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1118 | 1118 | //if array has more than one element then success message should be plural |
1119 | - $success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1; |
|
1119 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
1120 | 1120 | //cycle thru the boxes |
1121 | - while ( list( $TKT_ID, $value ) = each( $this->_req_data['checkbox'] ) ) { |
|
1122 | - if ( $trash ) { |
|
1123 | - if ( ! $TKT->delete_by_ID( $TKT_ID ) ) { |
|
1121 | + while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) { |
|
1122 | + if ($trash) { |
|
1123 | + if ( ! $TKT->delete_by_ID($TKT_ID)) { |
|
1124 | 1124 | $success = 0; |
1125 | 1125 | } |
1126 | 1126 | } else { |
1127 | - if ( ! $TKT->restore_by_ID( $TKT_ID ) ) { |
|
1127 | + if ( ! $TKT->restore_by_ID($TKT_ID)) { |
|
1128 | 1128 | $success = 0; |
1129 | 1129 | } |
1130 | 1130 | } |
1131 | 1131 | } |
1132 | 1132 | } else { |
1133 | 1133 | //grab single id and trash |
1134 | - $TKT_ID = absint( $this->_req_data['TKT_ID'] ); |
|
1135 | - if ( $trash ) { |
|
1136 | - if ( ! $TKT->delete_by_ID( $TKT_ID ) ) { |
|
1134 | + $TKT_ID = absint($this->_req_data['TKT_ID']); |
|
1135 | + if ($trash) { |
|
1136 | + if ( ! $TKT->delete_by_ID($TKT_ID)) { |
|
1137 | 1137 | $success = 0; |
1138 | 1138 | } |
1139 | 1139 | } else { |
1140 | - if ( ! $TKT->restore_by_ID( $TKT_ID ) ) { |
|
1140 | + if ( ! $TKT->restore_by_ID($TKT_ID)) { |
|
1141 | 1141 | $success = 0; |
1142 | 1142 | } |
1143 | 1143 | } |
@@ -1147,7 +1147,7 @@ discard block |
||
1147 | 1147 | 'action' => 'ticket_list_table', |
1148 | 1148 | 'status' => $trash ? '' : 'trashed', |
1149 | 1149 | ); |
1150 | - $this->_redirect_after_action( $success, 'Tickets', $action_desc, $query_args ); |
|
1150 | + $this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args); |
|
1151 | 1151 | } |
1152 | 1152 | |
1153 | 1153 | |
@@ -1155,20 +1155,20 @@ discard block |
||
1155 | 1155 | protected function _delete_ticket() { |
1156 | 1156 | $success = 1; |
1157 | 1157 | //checkboxes? |
1158 | - if ( ! empty( $this->_req_data['checkbox'] ) && is_array( $this->_req_data['checkbox'] ) ) { |
|
1158 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1159 | 1159 | //if array has more than one element then success message should be plural |
1160 | - $success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1; |
|
1160 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
1161 | 1161 | //cycle thru the boxes |
1162 | - while ( list( $TKT_ID, $value ) = each( $this->_req_data['checkbox'] ) ) { |
|
1162 | + while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) { |
|
1163 | 1163 | //delete |
1164 | - if ( ! $this->_delete_the_ticket( $TKT_ID ) ) { |
|
1164 | + if ( ! $this->_delete_the_ticket($TKT_ID)) { |
|
1165 | 1165 | $success = 0; |
1166 | 1166 | } |
1167 | 1167 | } |
1168 | 1168 | } else { |
1169 | 1169 | //grab single id and trash |
1170 | - $TKT_ID = absint( $this->_req_data['TKT_ID'] ); |
|
1171 | - if ( ! $this->_delete_the_ticket( $TKT_ID ) ) { |
|
1170 | + $TKT_ID = absint($this->_req_data['TKT_ID']); |
|
1171 | + if ( ! $this->_delete_the_ticket($TKT_ID)) { |
|
1172 | 1172 | $success = 0; |
1173 | 1173 | } |
1174 | 1174 | } |
@@ -1178,15 +1178,15 @@ discard block |
||
1178 | 1178 | 'status' => 'trashed', |
1179 | 1179 | ); |
1180 | 1180 | //fail safe. If the default ticket count === 1 then we need to redirect to event overview. |
1181 | - if ( EEM_Ticket::instance()->count_deleted_and_undeleted( |
|
1182 | - array( array( 'TKT_is_default' => 1 ) ), |
|
1181 | + if (EEM_Ticket::instance()->count_deleted_and_undeleted( |
|
1182 | + array(array('TKT_is_default' => 1)), |
|
1183 | 1183 | 'TKT_ID', |
1184 | 1184 | true |
1185 | 1185 | ) |
1186 | 1186 | ) { |
1187 | 1187 | $query_args = array(); |
1188 | 1188 | } |
1189 | - $this->_redirect_after_action( $success, 'Tickets', $action_desc, $query_args ); |
|
1189 | + $this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args); |
|
1190 | 1190 | } |
1191 | 1191 | |
1192 | 1192 | |
@@ -1195,11 +1195,11 @@ discard block |
||
1195 | 1195 | * @param int $TKT_ID |
1196 | 1196 | * @return bool|int |
1197 | 1197 | */ |
1198 | - protected function _delete_the_ticket( $TKT_ID ) { |
|
1199 | - $tkt = EEM_Ticket::instance()->get_one_by_ID( $TKT_ID ); |
|
1200 | - $tkt->_remove_relations( 'Datetime' ); |
|
1198 | + protected function _delete_the_ticket($TKT_ID) { |
|
1199 | + $tkt = EEM_Ticket::instance()->get_one_by_ID($TKT_ID); |
|
1200 | + $tkt->_remove_relations('Datetime'); |
|
1201 | 1201 | //delete all related prices first |
1202 | - $tkt->delete_related_permanently( 'Price' ); |
|
1202 | + $tkt->delete_related_permanently('Price'); |
|
1203 | 1203 | return $tkt->delete_permanently(); |
1204 | 1204 | } |
1205 | 1205 |
@@ -690,7 +690,7 @@ discard block |
||
690 | 690 | * _get_transaction_and_cart_for_previous_visit |
691 | 691 | * |
692 | 692 | * @access private |
693 | - * @return mixed EE_Transaction|NULL |
|
693 | + * @return EE_Transaction|null EE_Transaction|NULL |
|
694 | 694 | */ |
695 | 695 | private function _get_transaction_and_cart_for_previous_visit() { |
696 | 696 | /** @var $TXN_model EEM_Transaction */ |
@@ -768,7 +768,7 @@ discard block |
||
768 | 768 | * generates a new EE_Transaction object and adds it to the $_transaction property. |
769 | 769 | * |
770 | 770 | * @access private |
771 | - * @return mixed EE_Transaction|NULL |
|
771 | + * @return EE_Transaction|null EE_Transaction|NULL |
|
772 | 772 | */ |
773 | 773 | private function _initialize_transaction() { |
774 | 774 | try { |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php use EventEspresso\core\domain\services\capabilities\PublicCapabilities; |
2 | 2 | use EventEspresso\core\exceptions\InvalidEntityException; |
3 | 3 | |
4 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');} |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); } |
|
5 | 5 | /** |
6 | 6 | * Single Page Checkout (SPCO) |
7 | 7 | * |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | * @return EED_Single_Page_Checkout |
51 | 51 | */ |
52 | 52 | public static function instance() { |
53 | - add_filter( 'EED_Single_Page_Checkout__SPCO_active', '__return_true' ); |
|
54 | - return parent::get_instance( __CLASS__ ); |
|
53 | + add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true'); |
|
54 | + return parent::get_instance(__CLASS__); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | |
@@ -96,22 +96,22 @@ discard block |
||
96 | 96 | */ |
97 | 97 | public static function set_hooks_admin() { |
98 | 98 | EED_Single_Page_Checkout::set_definitions(); |
99 | - if ( defined( 'DOING_AJAX' )) { |
|
99 | + if (defined('DOING_AJAX')) { |
|
100 | 100 | // going to start an output buffer in case anything gets accidentally output that might disrupt our JSON response |
101 | 101 | ob_start(); |
102 | 102 | EED_Single_Page_Checkout::load_request_handler(); |
103 | 103 | EED_Single_Page_Checkout::load_reg_steps(); |
104 | 104 | } else { |
105 | 105 | // hook into the top of pre_get_posts to set the reg step routing, which gives other modules or plugins a chance to modify the reg steps, but just before the routes get called |
106 | - add_action( 'pre_get_posts', array( 'EED_Single_Page_Checkout', 'load_reg_steps' ), 1 ); |
|
106 | + add_action('pre_get_posts', array('EED_Single_Page_Checkout', 'load_reg_steps'), 1); |
|
107 | 107 | } |
108 | 108 | // set ajax hooks |
109 | - add_action( 'wp_ajax_process_reg_step', array( 'EED_Single_Page_Checkout', 'process_reg_step' )); |
|
110 | - add_action( 'wp_ajax_nopriv_process_reg_step', array( 'EED_Single_Page_Checkout', 'process_reg_step' )); |
|
111 | - add_action( 'wp_ajax_display_spco_reg_step', array( 'EED_Single_Page_Checkout', 'display_reg_step' )); |
|
112 | - add_action( 'wp_ajax_nopriv_display_spco_reg_step', array( 'EED_Single_Page_Checkout', 'display_reg_step' )); |
|
113 | - add_action( 'wp_ajax_update_reg_step', array( 'EED_Single_Page_Checkout', 'update_reg_step' )); |
|
114 | - add_action( 'wp_ajax_nopriv_update_reg_step', array( 'EED_Single_Page_Checkout', 'update_reg_step' )); |
|
109 | + add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
110 | + add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
111 | + add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
112 | + add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
113 | + add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
114 | + add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | * @param string $ajax_action |
123 | 123 | * @throws \EE_Error |
124 | 124 | */ |
125 | - public static function process_ajax_request( $ajax_action ) { |
|
126 | - EE_Registry::instance()->REQ->set( 'action', $ajax_action ); |
|
125 | + public static function process_ajax_request($ajax_action) { |
|
126 | + EE_Registry::instance()->REQ->set('action', $ajax_action); |
|
127 | 127 | EED_Single_Page_Checkout::instance()->_initialize(); |
128 | 128 | } |
129 | 129 | |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | * @throws \EE_Error |
136 | 136 | */ |
137 | 137 | public static function display_reg_step() { |
138 | - EED_Single_Page_Checkout::process_ajax_request( 'display_spco_reg_step' ); |
|
138 | + EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step'); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | * @throws \EE_Error |
147 | 147 | */ |
148 | 148 | public static function process_reg_step() { |
149 | - EED_Single_Page_Checkout::process_ajax_request( 'process_reg_step' ); |
|
149 | + EED_Single_Page_Checkout::process_ajax_request('process_reg_step'); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @throws \EE_Error |
158 | 158 | */ |
159 | 159 | public static function update_reg_step() { |
160 | - EED_Single_Page_Checkout::process_ajax_request( 'update_reg_step' ); |
|
160 | + EED_Single_Page_Checkout::process_ajax_request('update_reg_step'); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * @throws \EE_Error |
171 | 171 | */ |
172 | 172 | public static function update_checkout() { |
173 | - EED_Single_Page_Checkout::process_ajax_request( 'update_checkout' ); |
|
173 | + EED_Single_Page_Checkout::process_ajax_request('update_checkout'); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | |
@@ -183,8 +183,8 @@ discard block |
||
183 | 183 | */ |
184 | 184 | public static function load_request_handler() { |
185 | 185 | // load core Request_Handler class |
186 | - if ( ! isset( EE_Registry::instance()->REQ )) { |
|
187 | - EE_Registry::instance()->load_core( 'Request_Handler' ); |
|
186 | + if ( ! isset(EE_Registry::instance()->REQ)) { |
|
187 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
188 | 188 | } |
189 | 189 | } |
190 | 190 | |
@@ -198,14 +198,14 @@ discard block |
||
198 | 198 | * @throws \EE_Error |
199 | 199 | */ |
200 | 200 | public static function set_definitions() { |
201 | - define( 'SPCO_BASE_PATH', rtrim( str_replace( array( '\\', '/' ), DS, plugin_dir_path( __FILE__ )), DS ) . DS ); |
|
202 | - define( 'SPCO_CSS_URL', plugin_dir_url( __FILE__ ) . 'css' . DS ); |
|
203 | - define( 'SPCO_IMG_URL', plugin_dir_url( __FILE__ ) . 'img' . DS ); |
|
204 | - define( 'SPCO_JS_URL', plugin_dir_url( __FILE__ ) . 'js' . DS ); |
|
205 | - define( 'SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS ); |
|
206 | - define( 'SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS ); |
|
207 | - define( 'SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS ); |
|
208 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( SPCO_BASE_PATH, TRUE ); |
|
201 | + define('SPCO_BASE_PATH', rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS).DS); |
|
202 | + define('SPCO_CSS_URL', plugin_dir_url(__FILE__).'css'.DS); |
|
203 | + define('SPCO_IMG_URL', plugin_dir_url(__FILE__).'img'.DS); |
|
204 | + define('SPCO_JS_URL', plugin_dir_url(__FILE__).'js'.DS); |
|
205 | + define('SPCO_INC_PATH', SPCO_BASE_PATH.'inc'.DS); |
|
206 | + define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH.'reg_steps'.DS); |
|
207 | + define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH.'templates'.DS); |
|
208 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, TRUE); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | */ |
221 | 221 | public static function load_reg_steps() { |
222 | 222 | static $reg_steps_loaded = FALSE; |
223 | - if ( $reg_steps_loaded ) { |
|
223 | + if ($reg_steps_loaded) { |
|
224 | 224 | return; |
225 | 225 | } |
226 | 226 | // filter list of reg_steps |
@@ -229,24 +229,24 @@ discard block |
||
229 | 229 | EED_Single_Page_Checkout::get_reg_steps() |
230 | 230 | ); |
231 | 231 | // sort by key (order) |
232 | - ksort( $reg_steps_to_load ); |
|
232 | + ksort($reg_steps_to_load); |
|
233 | 233 | // loop through folders |
234 | - foreach ( $reg_steps_to_load as $order => $reg_step ) { |
|
234 | + foreach ($reg_steps_to_load as $order => $reg_step) { |
|
235 | 235 | // we need a |
236 | - if ( isset( $reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'] )) { |
|
236 | + if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
237 | 237 | // copy over to the reg_steps_array |
238 | - EED_Single_Page_Checkout::$_reg_steps_array[ $order ] = $reg_step; |
|
238 | + EED_Single_Page_Checkout::$_reg_steps_array[$order] = $reg_step; |
|
239 | 239 | // register custom key route for each reg step |
240 | 240 | // ie: step=>"slug" - this is the entire reason we load the reg steps array now |
241 | - EE_Config::register_route( $reg_step['slug'], 'EED_Single_Page_Checkout', 'run', 'step' ); |
|
241 | + EE_Config::register_route($reg_step['slug'], 'EED_Single_Page_Checkout', 'run', 'step'); |
|
242 | 242 | // add AJAX or other hooks |
243 | - if ( isset( $reg_step['has_hooks'] ) && $reg_step['has_hooks'] ) { |
|
243 | + if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) { |
|
244 | 244 | // setup autoloaders if necessary |
245 | - if ( ! class_exists( $reg_step['class_name'] )) { |
|
246 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( $reg_step['file_path'], TRUE ); |
|
245 | + if ( ! class_exists($reg_step['class_name'])) { |
|
246 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder($reg_step['file_path'], TRUE); |
|
247 | 247 | } |
248 | - if ( is_callable( $reg_step['class_name'], 'set_hooks' )) { |
|
249 | - call_user_func( array( $reg_step['class_name'], 'set_hooks' )); |
|
248 | + if (is_callable($reg_step['class_name'], 'set_hooks')) { |
|
249 | + call_user_func(array($reg_step['class_name'], 'set_hooks')); |
|
250 | 250 | } |
251 | 251 | } |
252 | 252 | } |
@@ -265,28 +265,28 @@ discard block |
||
265 | 265 | */ |
266 | 266 | public static function get_reg_steps() { |
267 | 267 | $reg_steps = EE_Registry::instance()->CFG->registration->reg_steps; |
268 | - if ( empty( $reg_steps )) { |
|
268 | + if (empty($reg_steps)) { |
|
269 | 269 | $reg_steps = array( |
270 | 270 | 10 => array( |
271 | - 'file_path' => SPCO_REG_STEPS_PATH . 'attendee_information', |
|
271 | + 'file_path' => SPCO_REG_STEPS_PATH.'attendee_information', |
|
272 | 272 | 'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information', |
273 | 273 | 'slug' => 'attendee_information', |
274 | 274 | 'has_hooks' => FALSE |
275 | 275 | ), |
276 | 276 | 20 => array( |
277 | - 'file_path' => SPCO_REG_STEPS_PATH . 'registration_confirmation', |
|
277 | + 'file_path' => SPCO_REG_STEPS_PATH.'registration_confirmation', |
|
278 | 278 | 'class_name' => 'EE_SPCO_Reg_Step_Registration_Confirmation', |
279 | 279 | 'slug' => 'registration_confirmation', |
280 | 280 | 'has_hooks' => FALSE |
281 | 281 | ), |
282 | 282 | 30 => array( |
283 | - 'file_path' => SPCO_REG_STEPS_PATH . 'payment_options', |
|
283 | + 'file_path' => SPCO_REG_STEPS_PATH.'payment_options', |
|
284 | 284 | 'class_name' => 'EE_SPCO_Reg_Step_Payment_Options', |
285 | 285 | 'slug' => 'payment_options', |
286 | 286 | 'has_hooks' => TRUE |
287 | 287 | ), |
288 | 288 | 999 => array( |
289 | - 'file_path' => SPCO_REG_STEPS_PATH . 'finalize_registration', |
|
289 | + 'file_path' => SPCO_REG_STEPS_PATH.'finalize_registration', |
|
290 | 290 | 'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration', |
291 | 291 | 'slug' => 'finalize_registration', |
292 | 292 | 'has_hooks' => FALSE |
@@ -307,9 +307,9 @@ discard block |
||
307 | 307 | */ |
308 | 308 | public static function registration_checkout_for_admin() { |
309 | 309 | EED_Single_Page_Checkout::load_reg_steps(); |
310 | - EE_Registry::instance()->REQ->set( 'step', 'attendee_information' ); |
|
311 | - EE_Registry::instance()->REQ->set( 'action', 'display_spco_reg_step' ); |
|
312 | - EE_Registry::instance()->REQ->set( 'process_form_submission', false ); |
|
310 | + EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
311 | + EE_Registry::instance()->REQ->set('action', 'display_spco_reg_step'); |
|
312 | + EE_Registry::instance()->REQ->set('process_form_submission', false); |
|
313 | 313 | EED_Single_Page_Checkout::instance()->_initialize(); |
314 | 314 | EED_Single_Page_Checkout::instance()->_display_spco_reg_form(); |
315 | 315 | return EE_Registry::instance()->REQ->get_output(); |
@@ -326,15 +326,15 @@ discard block |
||
326 | 326 | */ |
327 | 327 | public static function process_registration_from_admin() { |
328 | 328 | EED_Single_Page_Checkout::load_reg_steps(); |
329 | - EE_Registry::instance()->REQ->set( 'step', 'attendee_information' ); |
|
330 | - EE_Registry::instance()->REQ->set( 'action', 'process_reg_step' ); |
|
331 | - EE_Registry::instance()->REQ->set( 'process_form_submission', true ); |
|
329 | + EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
330 | + EE_Registry::instance()->REQ->set('action', 'process_reg_step'); |
|
331 | + EE_Registry::instance()->REQ->set('process_form_submission', true); |
|
332 | 332 | EED_Single_Page_Checkout::instance()->_initialize(); |
333 | - if ( EED_Single_Page_Checkout::instance()->checkout->current_step->completed() ) { |
|
334 | - $final_reg_step = end( EED_Single_Page_Checkout::instance()->checkout->reg_steps ); |
|
335 | - if ( $final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration ) { |
|
336 | - EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated( $final_reg_step ); |
|
337 | - if ( $final_reg_step->process_reg_step() ) { |
|
333 | + if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) { |
|
334 | + $final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps); |
|
335 | + if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) { |
|
336 | + EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated($final_reg_step); |
|
337 | + if ($final_reg_step->process_reg_step()) { |
|
338 | 338 | $final_reg_step->set_completed(); |
339 | 339 | EED_Single_Page_Checkout::instance()->checkout->update_txn_reg_steps_array(); |
340 | 340 | return EED_Single_Page_Checkout::instance()->checkout->transaction; |
@@ -354,11 +354,11 @@ discard block |
||
354 | 354 | * @return void |
355 | 355 | * @throws \EE_Error |
356 | 356 | */ |
357 | - public function run( $WP_Query ) { |
|
357 | + public function run($WP_Query) { |
|
358 | 358 | if ( |
359 | 359 | $WP_Query instanceof WP_Query |
360 | 360 | && $WP_Query->is_main_query() |
361 | - && apply_filters( 'FHEE__EED_Single_Page_Checkout__run', true ) |
|
361 | + && apply_filters('FHEE__EED_Single_Page_Checkout__run', true) |
|
362 | 362 | ) { |
363 | 363 | $this->_initialize(); |
364 | 364 | } |
@@ -374,8 +374,8 @@ discard block |
||
374 | 374 | * @return void |
375 | 375 | * @throws \EE_Error |
376 | 376 | */ |
377 | - public static function init( $WP_Query ) { |
|
378 | - EED_Single_Page_Checkout::instance()->run( $WP_Query ); |
|
377 | + public static function init($WP_Query) { |
|
378 | + EED_Single_Page_Checkout::instance()->run($WP_Query); |
|
379 | 379 | } |
380 | 380 | |
381 | 381 | |
@@ -389,34 +389,34 @@ discard block |
||
389 | 389 | */ |
390 | 390 | private function _initialize() { |
391 | 391 | // ensure SPCO doesn't run twice |
392 | - if ( EED_Single_Page_Checkout::$_initialized ) { |
|
392 | + if (EED_Single_Page_Checkout::$_initialized) { |
|
393 | 393 | return; |
394 | 394 | } |
395 | 395 | try { |
396 | 396 | // setup the EE_Checkout object |
397 | 397 | $this->checkout = $this->_initialize_checkout(); |
398 | 398 | // filter checkout |
399 | - $this->checkout = apply_filters( 'FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout ); |
|
399 | + $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout); |
|
400 | 400 | // get the $_GET |
401 | 401 | $this->_get_request_vars(); |
402 | 402 | // filter continue_reg |
403 | - $this->checkout->continue_reg = apply_filters( 'FHEE__EED_Single_Page_Checkout__init___continue_reg', TRUE, $this->checkout ); |
|
403 | + $this->checkout->continue_reg = apply_filters('FHEE__EED_Single_Page_Checkout__init___continue_reg', TRUE, $this->checkout); |
|
404 | 404 | // load the reg steps array |
405 | - if ( ! $this->_load_and_instantiate_reg_steps() ) { |
|
405 | + if ( ! $this->_load_and_instantiate_reg_steps()) { |
|
406 | 406 | EED_Single_Page_Checkout::$_initialized = true; |
407 | 407 | return; |
408 | 408 | } |
409 | 409 | // set the current step |
410 | - $this->checkout->set_current_step( $this->checkout->step ); |
|
410 | + $this->checkout->set_current_step($this->checkout->step); |
|
411 | 411 | // and the next step |
412 | 412 | $this->checkout->set_next_step(); |
413 | 413 | // was there already a valid transaction in the checkout from the session ? |
414 | - if ( ! $this->checkout->transaction instanceof EE_Transaction ) { |
|
414 | + if ( ! $this->checkout->transaction instanceof EE_Transaction) { |
|
415 | 415 | // get transaction from db or session |
416 | 416 | $this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin() |
417 | 417 | ? $this->_get_transaction_and_cart_for_previous_visit() |
418 | 418 | : $this->_get_cart_for_current_session_and_setup_new_transaction(); |
419 | - if ( ! $this->checkout->transaction instanceof EE_Transaction ) { |
|
419 | + if ( ! $this->checkout->transaction instanceof EE_Transaction) { |
|
420 | 420 | // add some style and make it dance |
421 | 421 | $this->checkout->transaction = EE_Transaction::new_instance(); |
422 | 422 | $this->add_styles_and_scripts(); |
@@ -424,10 +424,10 @@ discard block |
||
424 | 424 | return; |
425 | 425 | } |
426 | 426 | // and the registrations for the transaction |
427 | - $this->_get_registrations( $this->checkout->transaction ); |
|
427 | + $this->_get_registrations($this->checkout->transaction); |
|
428 | 428 | } |
429 | 429 | // verify that everything has been setup correctly |
430 | - if ( ! $this->_final_verifications() ) { |
|
430 | + if ( ! $this->_final_verifications()) { |
|
431 | 431 | EED_Single_Page_Checkout::$_initialized = true; |
432 | 432 | return; |
433 | 433 | } |
@@ -452,9 +452,9 @@ discard block |
||
452 | 452 | // set no cache headers and constants |
453 | 453 | EE_System::do_not_cache(); |
454 | 454 | // add anchor |
455 | - add_action( 'loop_start', array( $this, 'set_checkout_anchor' ), 1 ); |
|
456 | - } catch ( Exception $e ) { |
|
457 | - EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__ ); |
|
455 | + add_action('loop_start', array($this, 'set_checkout_anchor'), 1); |
|
456 | + } catch (Exception $e) { |
|
457 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
458 | 458 | } |
459 | 459 | } |
460 | 460 | |
@@ -472,20 +472,20 @@ discard block |
||
472 | 472 | // look in session for existing checkout |
473 | 473 | $checkout = EE_Registry::instance()->SSN->checkout(); |
474 | 474 | // verify |
475 | - if ( ! $checkout instanceof EE_Checkout ) { |
|
475 | + if ( ! $checkout instanceof EE_Checkout) { |
|
476 | 476 | // instantiate EE_Checkout object for handling the properties of the current checkout process |
477 | - $checkout = EE_Registry::instance()->load_file( SPCO_INC_PATH, 'EE_Checkout', 'class', array(), FALSE ); |
|
477 | + $checkout = EE_Registry::instance()->load_file(SPCO_INC_PATH, 'EE_Checkout', 'class', array(), FALSE); |
|
478 | 478 | } else { |
479 | - if ( $checkout->current_step->is_final_step() && $checkout->exit_spco() === true ) { |
|
479 | + if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) { |
|
480 | 480 | $this->unlock_transaction(); |
481 | - wp_safe_redirect( $checkout->redirect_url ); |
|
481 | + wp_safe_redirect($checkout->redirect_url); |
|
482 | 482 | exit(); |
483 | 483 | } |
484 | 484 | } |
485 | - $checkout = apply_filters( 'FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout ); |
|
485 | + $checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout); |
|
486 | 486 | // verify again |
487 | - if ( ! $checkout instanceof EE_Checkout ) { |
|
488 | - throw new EE_Error( __( 'The EE_Checkout class could not be loaded.', 'event_espresso' ) ); |
|
487 | + if ( ! $checkout instanceof EE_Checkout) { |
|
488 | + throw new EE_Error(__('The EE_Checkout class could not be loaded.', 'event_espresso')); |
|
489 | 489 | } |
490 | 490 | // reset anything that needs a clean slate for each request |
491 | 491 | $checkout->reset_for_current_request(); |
@@ -505,24 +505,24 @@ discard block |
||
505 | 505 | // load classes |
506 | 506 | EED_Single_Page_Checkout::load_request_handler(); |
507 | 507 | //make sure this request is marked as belonging to EE |
508 | - EE_Registry::instance()->REQ->set_espresso_page( TRUE ); |
|
508 | + EE_Registry::instance()->REQ->set_espresso_page(TRUE); |
|
509 | 509 | // which step is being requested ? |
510 | - $this->checkout->step = EE_Registry::instance()->REQ->get( 'step', $this->_get_first_step() ); |
|
510 | + $this->checkout->step = EE_Registry::instance()->REQ->get('step', $this->_get_first_step()); |
|
511 | 511 | // which step is being edited ? |
512 | - $this->checkout->edit_step = EE_Registry::instance()->REQ->get( 'edit_step', '' ); |
|
512 | + $this->checkout->edit_step = EE_Registry::instance()->REQ->get('edit_step', ''); |
|
513 | 513 | // and what we're doing on the current step |
514 | - $this->checkout->action = EE_Registry::instance()->REQ->get( 'action', 'display_spco_reg_step' ); |
|
514 | + $this->checkout->action = EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step'); |
|
515 | 515 | // returning to edit ? |
516 | - $this->checkout->reg_url_link = EE_Registry::instance()->REQ->get( 'e_reg_url_link', '' ); |
|
516 | + $this->checkout->reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link', ''); |
|
517 | 517 | // or some other kind of revisit ? |
518 | - $this->checkout->revisit = EE_Registry::instance()->REQ->get( 'revisit', FALSE ); |
|
518 | + $this->checkout->revisit = EE_Registry::instance()->REQ->get('revisit', FALSE); |
|
519 | 519 | // and whether or not to generate a reg form for this request |
520 | - $this->checkout->generate_reg_form = EE_Registry::instance()->REQ->get( 'generate_reg_form', TRUE ); // TRUE FALSE |
|
520 | + $this->checkout->generate_reg_form = EE_Registry::instance()->REQ->get('generate_reg_form', TRUE); // TRUE FALSE |
|
521 | 521 | // and whether or not to process a reg form submission for this request |
522 | - $this->checkout->process_form_submission = EE_Registry::instance()->REQ->get( 'process_form_submission', FALSE ); // TRUE FALSE |
|
522 | + $this->checkout->process_form_submission = EE_Registry::instance()->REQ->get('process_form_submission', FALSE); // TRUE FALSE |
|
523 | 523 | $this->checkout->process_form_submission = $this->checkout->action !== 'display_spco_reg_step' |
524 | 524 | ? $this->checkout->process_form_submission |
525 | - : FALSE; // TRUE FALSE |
|
525 | + : FALSE; // TRUE FALSE |
|
526 | 526 | // $this->_display_request_vars(); |
527 | 527 | } |
528 | 528 | |
@@ -535,17 +535,17 @@ discard block |
||
535 | 535 | * @return void |
536 | 536 | */ |
537 | 537 | protected function _display_request_vars() { |
538 | - if ( ! WP_DEBUG ) { |
|
538 | + if ( ! WP_DEBUG) { |
|
539 | 539 | return; |
540 | 540 | } |
541 | - EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ ); |
|
542 | - EEH_Debug_Tools::printr( $this->checkout->step, '$this->checkout->step', __FILE__, __LINE__ ); |
|
543 | - EEH_Debug_Tools::printr( $this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__ ); |
|
544 | - EEH_Debug_Tools::printr( $this->checkout->action, '$this->checkout->action', __FILE__, __LINE__ ); |
|
545 | - EEH_Debug_Tools::printr( $this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__ ); |
|
546 | - EEH_Debug_Tools::printr( $this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__ ); |
|
547 | - EEH_Debug_Tools::printr( $this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__ ); |
|
548 | - EEH_Debug_Tools::printr( $this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__ ); |
|
541 | + EEH_Debug_Tools::printr($_REQUEST, '$_REQUEST', __FILE__, __LINE__); |
|
542 | + EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__); |
|
543 | + EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__); |
|
544 | + EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__); |
|
545 | + EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__); |
|
546 | + EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__); |
|
547 | + EEH_Debug_Tools::printr($this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__); |
|
548 | + EEH_Debug_Tools::printr($this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__); |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | |
@@ -559,8 +559,8 @@ discard block |
||
559 | 559 | * @return array |
560 | 560 | */ |
561 | 561 | private function _get_first_step() { |
562 | - $first_step = reset( EED_Single_Page_Checkout::$_reg_steps_array ); |
|
563 | - return isset( $first_step['slug'] ) ? $first_step['slug'] : 'attendee_information'; |
|
562 | + $first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array); |
|
563 | + return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information'; |
|
564 | 564 | } |
565 | 565 | |
566 | 566 | |
@@ -576,27 +576,27 @@ discard block |
||
576 | 576 | private function _load_and_instantiate_reg_steps() { |
577 | 577 | // have reg_steps already been instantiated ? |
578 | 578 | if ( |
579 | - empty( $this->checkout->reg_steps ) || |
|
580 | - apply_filters( 'FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout ) |
|
579 | + empty($this->checkout->reg_steps) || |
|
580 | + apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout) |
|
581 | 581 | ) { |
582 | 582 | // if not, then loop through raw reg steps array |
583 | - foreach ( EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step ) { |
|
584 | - if ( ! $this->_load_and_instantiate_reg_step( $reg_step, $order )) { |
|
583 | + foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) { |
|
584 | + if ( ! $this->_load_and_instantiate_reg_step($reg_step, $order)) { |
|
585 | 585 | return false; |
586 | 586 | } |
587 | 587 | } |
588 | 588 | EE_Registry::instance()->CFG->registration->skip_reg_confirmation = TRUE; |
589 | 589 | EE_Registry::instance()->CFG->registration->reg_confirmation_last = TRUE; |
590 | 590 | // skip the registration_confirmation page ? |
591 | - if ( EE_Registry::instance()->CFG->registration->skip_reg_confirmation ) { |
|
591 | + if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) { |
|
592 | 592 | // just remove it from the reg steps array |
593 | - $this->checkout->remove_reg_step( 'registration_confirmation', false ); |
|
593 | + $this->checkout->remove_reg_step('registration_confirmation', false); |
|
594 | 594 | } else if ( |
595 | - isset( $this->checkout->reg_steps['registration_confirmation'] ) |
|
595 | + isset($this->checkout->reg_steps['registration_confirmation']) |
|
596 | 596 | && EE_Registry::instance()->CFG->registration->reg_confirmation_last |
597 | 597 | ) { |
598 | 598 | // set the order to something big like 100 |
599 | - $this->checkout->set_reg_step_order( 'registration_confirmation', 100 ); |
|
599 | + $this->checkout->set_reg_step_order('registration_confirmation', 100); |
|
600 | 600 | } |
601 | 601 | // filter the array for good luck |
602 | 602 | $this->checkout->reg_steps = apply_filters( |
@@ -606,13 +606,13 @@ discard block |
||
606 | 606 | // finally re-sort based on the reg step class order properties |
607 | 607 | $this->checkout->sort_reg_steps(); |
608 | 608 | } else { |
609 | - foreach ( $this->checkout->reg_steps as $reg_step ) { |
|
609 | + foreach ($this->checkout->reg_steps as $reg_step) { |
|
610 | 610 | // set all current step stati to FALSE |
611 | - $reg_step->set_is_current_step( FALSE ); |
|
611 | + $reg_step->set_is_current_step(FALSE); |
|
612 | 612 | } |
613 | 613 | } |
614 | - if ( empty( $this->checkout->reg_steps )) { |
|
615 | - EE_Error::add_error( __( 'No Reg Steps were loaded..', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
614 | + if (empty($this->checkout->reg_steps)) { |
|
615 | + EE_Error::add_error(__('No Reg Steps were loaded..', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
616 | 616 | return false; |
617 | 617 | } |
618 | 618 | // make reg step details available to JS |
@@ -630,10 +630,10 @@ discard block |
||
630 | 630 | * @param int $order |
631 | 631 | * @return bool |
632 | 632 | */ |
633 | - private function _load_and_instantiate_reg_step( $reg_step = array(), $order = 0 ) { |
|
633 | + private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0) { |
|
634 | 634 | |
635 | 635 | // we need a file_path, class_name, and slug to add a reg step |
636 | - if ( isset( $reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'] )) { |
|
636 | + if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
637 | 637 | // if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step) |
638 | 638 | if ( |
639 | 639 | $this->checkout->reg_url_link |
@@ -651,26 +651,26 @@ discard block |
||
651 | 651 | FALSE |
652 | 652 | ); |
653 | 653 | // did we gets the goods ? |
654 | - if ( $reg_step_obj instanceof EE_SPCO_Reg_Step ) { |
|
654 | + if ($reg_step_obj instanceof EE_SPCO_Reg_Step) { |
|
655 | 655 | // set reg step order based on config |
656 | - $reg_step_obj->set_order( $order ); |
|
656 | + $reg_step_obj->set_order($order); |
|
657 | 657 | // add instantiated reg step object to the master reg steps array |
658 | - $this->checkout->add_reg_step( $reg_step_obj ); |
|
658 | + $this->checkout->add_reg_step($reg_step_obj); |
|
659 | 659 | } else { |
660 | 660 | EE_Error::add_error( |
661 | - __( 'The current step could not be set.', 'event_espresso' ), |
|
661 | + __('The current step could not be set.', 'event_espresso'), |
|
662 | 662 | __FILE__, __FUNCTION__, __LINE__ |
663 | 663 | ); |
664 | 664 | return false; |
665 | 665 | } |
666 | 666 | } else { |
667 | - if ( WP_DEBUG ) { |
|
667 | + if (WP_DEBUG) { |
|
668 | 668 | EE_Error::add_error( |
669 | 669 | sprintf( |
670 | - __( 'A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s', 'event_espresso' ), |
|
671 | - isset( $reg_step['file_path'] ) ? $reg_step['file_path'] : '', |
|
672 | - isset( $reg_step['class_name'] ) ? $reg_step['class_name'] : '', |
|
673 | - isset( $reg_step['slug'] ) ? $reg_step['slug'] : '', |
|
670 | + __('A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s', 'event_espresso'), |
|
671 | + isset($reg_step['file_path']) ? $reg_step['file_path'] : '', |
|
672 | + isset($reg_step['class_name']) ? $reg_step['class_name'] : '', |
|
673 | + isset($reg_step['slug']) ? $reg_step['slug'] : '', |
|
674 | 674 | '<ul>', |
675 | 675 | '<li>', |
676 | 676 | '</li>', |
@@ -694,16 +694,16 @@ discard block |
||
694 | 694 | */ |
695 | 695 | private function _get_transaction_and_cart_for_previous_visit() { |
696 | 696 | /** @var $TXN_model EEM_Transaction */ |
697 | - $TXN_model = EE_Registry::instance()->load_model( 'Transaction' ); |
|
697 | + $TXN_model = EE_Registry::instance()->load_model('Transaction'); |
|
698 | 698 | // because the reg_url_link is present in the request, this is a return visit to SPCO, so we'll get the transaction data from the db |
699 | - $transaction = $TXN_model->get_transaction_from_reg_url_link( $this->checkout->reg_url_link ); |
|
699 | + $transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link); |
|
700 | 700 | // verify transaction |
701 | - if ( $transaction instanceof EE_Transaction ) { |
|
701 | + if ($transaction instanceof EE_Transaction) { |
|
702 | 702 | // and get the cart that was used for that transaction |
703 | - $this->checkout->cart = $this->_get_cart_for_transaction( $transaction ); |
|
703 | + $this->checkout->cart = $this->_get_cart_for_transaction($transaction); |
|
704 | 704 | return $transaction; |
705 | 705 | } else { |
706 | - EE_Error::add_error( __( 'Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
706 | + EE_Error::add_error(__('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
707 | 707 | return NULL; |
708 | 708 | } |
709 | 709 | } |
@@ -717,8 +717,8 @@ discard block |
||
717 | 717 | * @param EE_Transaction $transaction |
718 | 718 | * @return EE_Cart |
719 | 719 | */ |
720 | - private function _get_cart_for_transaction( $transaction ) { |
|
721 | - return $this->checkout->get_cart_for_transaction( $transaction ); |
|
720 | + private function _get_cart_for_transaction($transaction) { |
|
721 | + return $this->checkout->get_cart_for_transaction($transaction); |
|
722 | 722 | } |
723 | 723 | |
724 | 724 | |
@@ -730,8 +730,8 @@ discard block |
||
730 | 730 | * @param EE_Transaction $transaction |
731 | 731 | * @return EE_Cart |
732 | 732 | */ |
733 | - public function get_cart_for_transaction( EE_Transaction $transaction ) { |
|
734 | - return $this->checkout->get_cart_for_transaction( $transaction ); |
|
733 | + public function get_cart_for_transaction(EE_Transaction $transaction) { |
|
734 | + return $this->checkout->get_cart_for_transaction($transaction); |
|
735 | 735 | } |
736 | 736 | |
737 | 737 | |
@@ -747,17 +747,17 @@ discard block |
||
747 | 747 | private function _get_cart_for_current_session_and_setup_new_transaction() { |
748 | 748 | // if there's no transaction, then this is the FIRST visit to SPCO |
749 | 749 | // so load up the cart ( passing nothing for the TXN because it doesn't exist yet ) |
750 | - $this->checkout->cart = $this->_get_cart_for_transaction( NULL ); |
|
750 | + $this->checkout->cart = $this->_get_cart_for_transaction(NULL); |
|
751 | 751 | // and then create a new transaction |
752 | 752 | $transaction = $this->_initialize_transaction(); |
753 | 753 | // verify transaction |
754 | - if ( $transaction instanceof EE_Transaction ) { |
|
754 | + if ($transaction instanceof EE_Transaction) { |
|
755 | 755 | // save it so that we have an ID for other objects to use |
756 | 756 | $transaction->save(); |
757 | 757 | // and save TXN data to the cart |
758 | - $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn( $transaction->ID() ); |
|
758 | + $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID()); |
|
759 | 759 | } else { |
760 | - EE_Error::add_error( __( 'A Valid Transaction could not be initialized.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
760 | + EE_Error::add_error(__('A Valid Transaction could not be initialized.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
761 | 761 | } |
762 | 762 | return $transaction; |
763 | 763 | } |
@@ -785,8 +785,8 @@ discard block |
||
785 | 785 | 'STS_ID' => EEM_Transaction::failed_status_code, |
786 | 786 | ) |
787 | 787 | ); |
788 | - } catch( Exception $e ) { |
|
789 | - EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
788 | + } catch (Exception $e) { |
|
789 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
790 | 790 | } |
791 | 791 | return NULL; |
792 | 792 | } |
@@ -801,38 +801,38 @@ discard block |
||
801 | 801 | * @return EE_Cart |
802 | 802 | * @throws \EE_Error |
803 | 803 | */ |
804 | - private function _get_registrations( EE_Transaction $transaction ) { |
|
804 | + private function _get_registrations(EE_Transaction $transaction) { |
|
805 | 805 | // first step: grab the registrants { : o |
806 | - $registrations = $transaction->registrations( $this->checkout->reg_cache_where_params, true ); |
|
806 | + $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, true); |
|
807 | 807 | // verify registrations have been set |
808 | - if ( empty( $registrations )) { |
|
808 | + if (empty($registrations)) { |
|
809 | 809 | // if no cached registrations, then check the db |
810 | - $registrations = $transaction->registrations( $this->checkout->reg_cache_where_params, false ); |
|
810 | + $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false); |
|
811 | 811 | // still nothing ? well as long as this isn't a revisit |
812 | - if ( empty( $registrations ) && ! $this->checkout->revisit ) { |
|
812 | + if (empty($registrations) && ! $this->checkout->revisit) { |
|
813 | 813 | // generate new registrations from scratch |
814 | - $registrations = $this->_initialize_registrations( $transaction ); |
|
814 | + $registrations = $this->_initialize_registrations($transaction); |
|
815 | 815 | } |
816 | 816 | } |
817 | 817 | // sort by their original registration order |
818 | - usort( $registrations, array( 'EED_Single_Page_Checkout', 'sort_registrations_by_REG_count' )); |
|
818 | + usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count')); |
|
819 | 819 | // then loop thru the array |
820 | - foreach ( $registrations as $registration ) { |
|
820 | + foreach ($registrations as $registration) { |
|
821 | 821 | // verify each registration |
822 | - if ( $registration instanceof EE_Registration ) { |
|
822 | + if ($registration instanceof EE_Registration) { |
|
823 | 823 | // we display all attendee info for the primary registrant |
824 | - if ( $this->checkout->reg_url_link === $registration->reg_url_link() |
|
824 | + if ($this->checkout->reg_url_link === $registration->reg_url_link() |
|
825 | 825 | && $registration->is_primary_registrant() |
826 | 826 | ) { |
827 | 827 | $this->checkout->primary_revisit = true; |
828 | 828 | break; |
829 | - } else if ( $this->checkout->revisit |
|
829 | + } else if ($this->checkout->revisit |
|
830 | 830 | && $this->checkout->reg_url_link !== $registration->reg_url_link() |
831 | 831 | ) { |
832 | 832 | // but hide info if it doesn't belong to you |
833 | - $transaction->clear_cache( 'Registration', $registration->ID() ); |
|
833 | + $transaction->clear_cache('Registration', $registration->ID()); |
|
834 | 834 | } |
835 | - $this->checkout->set_reg_status_updated( $registration->ID(), false ); |
|
835 | + $this->checkout->set_reg_status_updated($registration->ID(), false); |
|
836 | 836 | } |
837 | 837 | } |
838 | 838 | } |
@@ -847,17 +847,17 @@ discard block |
||
847 | 847 | * @return array |
848 | 848 | * @throws \EE_Error |
849 | 849 | */ |
850 | - private function _initialize_registrations( EE_Transaction $transaction ) { |
|
850 | + private function _initialize_registrations(EE_Transaction $transaction) { |
|
851 | 851 | $att_nmbr = 0; |
852 | 852 | $registrations = array(); |
853 | - if ( $transaction instanceof EE_Transaction ) { |
|
853 | + if ($transaction instanceof EE_Transaction) { |
|
854 | 854 | /** @type EE_Registration_Processor $registration_processor */ |
855 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
855 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
856 | 856 | $this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count(); |
857 | 857 | // now let's add the cart items to the $transaction |
858 | - foreach ( $this->checkout->cart->get_tickets() as $line_item ) { |
|
858 | + foreach ($this->checkout->cart->get_tickets() as $line_item) { |
|
859 | 859 | //do the following for each ticket of this type they selected |
860 | - for ( $x = 1; $x <= $line_item->quantity(); $x++ ) { |
|
860 | + for ($x = 1; $x <= $line_item->quantity(); $x++) { |
|
861 | 861 | $att_nmbr++; |
862 | 862 | /** @var EventEspresso\core\services\commands\registration\CreateRegistrationCommand $CreateRegistrationCommand */ |
863 | 863 | $CreateRegistrationCommand = EE_Registry::instance() |
@@ -873,17 +873,17 @@ discard block |
||
873 | 873 | // override capabilities for frontend registrations |
874 | 874 | if ( ! is_admin()) { |
875 | 875 | $CreateRegistrationCommand->setCapCheck( |
876 | - new PublicCapabilities( '', 'create_new_registration' ) |
|
876 | + new PublicCapabilities('', 'create_new_registration') |
|
877 | 877 | ); |
878 | 878 | } |
879 | - $registration = EE_Registry::instance()->BUS->execute( $CreateRegistrationCommand ); |
|
880 | - if ( ! $registration instanceof EE_Registration ) { |
|
881 | - throw new InvalidEntityException( $registration, 'EE_Registration' ); |
|
879 | + $registration = EE_Registry::instance()->BUS->execute($CreateRegistrationCommand); |
|
880 | + if ( ! $registration instanceof EE_Registration) { |
|
881 | + throw new InvalidEntityException($registration, 'EE_Registration'); |
|
882 | 882 | } |
883 | - $registrations[ $registration->ID() ] = $registration; |
|
883 | + $registrations[$registration->ID()] = $registration; |
|
884 | 884 | } |
885 | 885 | } |
886 | - $registration_processor->fix_reg_final_price_rounding_issue( $transaction ); |
|
886 | + $registration_processor->fix_reg_final_price_rounding_issue($transaction); |
|
887 | 887 | } |
888 | 888 | return $registrations; |
889 | 889 | } |
@@ -898,12 +898,12 @@ discard block |
||
898 | 898 | * @param EE_Registration $reg_B |
899 | 899 | * @return int |
900 | 900 | */ |
901 | - public static function sort_registrations_by_REG_count( EE_Registration $reg_A, EE_Registration $reg_B ) { |
|
901 | + public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B) { |
|
902 | 902 | // this shouldn't ever happen within the same TXN, but oh well |
903 | - if ( $reg_A->count() === $reg_B->count() ) { |
|
903 | + if ($reg_A->count() === $reg_B->count()) { |
|
904 | 904 | return 0; |
905 | 905 | } |
906 | - return ( $reg_A->count() > $reg_B->count() ) ? 1 : -1; |
|
906 | + return ($reg_A->count() > $reg_B->count()) ? 1 : -1; |
|
907 | 907 | } |
908 | 908 | |
909 | 909 | |
@@ -918,21 +918,21 @@ discard block |
||
918 | 918 | */ |
919 | 919 | private function _final_verifications() { |
920 | 920 | // filter checkout |
921 | - $this->checkout = apply_filters( 'FHEE__EED_Single_Page_Checkout___final_verifications__checkout', $this->checkout ); |
|
921 | + $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___final_verifications__checkout', $this->checkout); |
|
922 | 922 | //verify that current step is still set correctly |
923 | - if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step ) { |
|
924 | - EE_Error::add_error( __( 'We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
923 | + if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) { |
|
924 | + EE_Error::add_error(__('We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
925 | 925 | return false; |
926 | 926 | } |
927 | 927 | // if returning to SPCO, then verify that primary registrant is set |
928 | - if ( ! empty( $this->checkout->reg_url_link )) { |
|
928 | + if ( ! empty($this->checkout->reg_url_link)) { |
|
929 | 929 | $valid_registrant = $this->checkout->transaction->primary_registration(); |
930 | - if ( ! $valid_registrant instanceof EE_Registration ) { |
|
931 | - EE_Error::add_error( __( 'We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
930 | + if ( ! $valid_registrant instanceof EE_Registration) { |
|
931 | + EE_Error::add_error(__('We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
932 | 932 | return false; |
933 | 933 | } |
934 | 934 | $valid_registrant = null; |
935 | - foreach ( $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ) as $registration ) { |
|
935 | + foreach ($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration) { |
|
936 | 936 | if ( |
937 | 937 | $registration instanceof EE_Registration |
938 | 938 | && $registration->reg_url_link() === $this->checkout->reg_url_link |
@@ -940,9 +940,9 @@ discard block |
||
940 | 940 | $valid_registrant = $registration; |
941 | 941 | } |
942 | 942 | } |
943 | - if ( ! $valid_registrant instanceof EE_Registration ) { |
|
943 | + if ( ! $valid_registrant instanceof EE_Registration) { |
|
944 | 944 | // hmmm... maybe we have the wrong session because the user is opening multiple tabs ? |
945 | - if ( EED_Single_Page_Checkout::$_checkout_verified ) { |
|
945 | + if (EED_Single_Page_Checkout::$_checkout_verified) { |
|
946 | 946 | // clear the session, mark the checkout as unverified, and try again |
947 | 947 | EE_Registry::instance()->SSN->clear_session(); |
948 | 948 | EED_Single_Page_Checkout::$_initialized = false; |
@@ -951,13 +951,13 @@ discard block |
||
951 | 951 | EE_Error::reset_notices(); |
952 | 952 | return false; |
953 | 953 | } |
954 | - EE_Error::add_error( __( 'We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
954 | + EE_Error::add_error(__('We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
955 | 955 | return false; |
956 | 956 | } |
957 | 957 | } |
958 | 958 | // now that things have been kinda sufficiently verified, |
959 | 959 | // let's add the checkout to the session so that's available other systems |
960 | - EE_Registry::instance()->SSN->set_checkout( $this->checkout ); |
|
960 | + EE_Registry::instance()->SSN->set_checkout($this->checkout); |
|
961 | 961 | return true; |
962 | 962 | } |
963 | 963 | |
@@ -972,15 +972,15 @@ discard block |
||
972 | 972 | * @param bool $reinitializing |
973 | 973 | * @throws \EE_Error |
974 | 974 | */ |
975 | - private function _initialize_reg_steps( $reinitializing = false ) { |
|
976 | - $this->checkout->set_reg_step_initiated( $this->checkout->current_step ); |
|
975 | + private function _initialize_reg_steps($reinitializing = false) { |
|
976 | + $this->checkout->set_reg_step_initiated($this->checkout->current_step); |
|
977 | 977 | // loop thru all steps to call their individual "initialize" methods and set i18n strings for JS |
978 | - foreach ( $this->checkout->reg_steps as $reg_step ) { |
|
979 | - if ( ! $reg_step->initialize_reg_step() ) { |
|
978 | + foreach ($this->checkout->reg_steps as $reg_step) { |
|
979 | + if ( ! $reg_step->initialize_reg_step()) { |
|
980 | 980 | // if not initialized then maybe this step is being removed... |
981 | - if ( ! $reinitializing && $reg_step->is_current_step() ) { |
|
981 | + if ( ! $reinitializing && $reg_step->is_current_step()) { |
|
982 | 982 | // if it was the current step, then we need to start over here |
983 | - $this->_initialize_reg_steps( true ); |
|
983 | + $this->_initialize_reg_steps(true); |
|
984 | 984 | return; |
985 | 985 | } |
986 | 986 | continue; |
@@ -989,13 +989,13 @@ discard block |
||
989 | 989 | $reg_step->enqueue_styles_and_scripts(); |
990 | 990 | // i18n |
991 | 991 | $reg_step->translate_js_strings(); |
992 | - if ( $reg_step->is_current_step() ) { |
|
992 | + if ($reg_step->is_current_step()) { |
|
993 | 993 | // the text that appears on the reg step form submit button |
994 | 994 | $reg_step->set_submit_button_text(); |
995 | 995 | } |
996 | 996 | } |
997 | 997 | // dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information |
998 | - do_action( "AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", $this->checkout->current_step ); |
|
998 | + do_action("AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", $this->checkout->current_step); |
|
999 | 999 | } |
1000 | 1000 | |
1001 | 1001 | |
@@ -1008,43 +1008,43 @@ discard block |
||
1008 | 1008 | */ |
1009 | 1009 | private function _check_form_submission() { |
1010 | 1010 | //does this request require the reg form to be generated ? |
1011 | - if ( $this->checkout->generate_reg_form ) { |
|
1011 | + if ($this->checkout->generate_reg_form) { |
|
1012 | 1012 | // ever heard that song by Blue Rodeo ? |
1013 | 1013 | try { |
1014 | 1014 | $this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form(); |
1015 | 1015 | // if not displaying a form, then check for form submission |
1016 | - if ( $this->checkout->process_form_submission && $this->checkout->current_step->reg_form->was_submitted() ) { |
|
1016 | + if ($this->checkout->process_form_submission && $this->checkout->current_step->reg_form->was_submitted()) { |
|
1017 | 1017 | // clear out any old data in case this step is being run again |
1018 | - $this->checkout->current_step->set_valid_data( array() ); |
|
1018 | + $this->checkout->current_step->set_valid_data(array()); |
|
1019 | 1019 | // capture submitted form data |
1020 | 1020 | $this->checkout->current_step->reg_form->receive_form_submission( |
1021 | - apply_filters( 'FHEE__Single_Page_Checkout___check_form_submission__request_params', EE_Registry::instance()->REQ->params(), $this->checkout ) |
|
1021 | + apply_filters('FHEE__Single_Page_Checkout___check_form_submission__request_params', EE_Registry::instance()->REQ->params(), $this->checkout) |
|
1022 | 1022 | ); |
1023 | 1023 | // validate submitted form data |
1024 | - if ( ! $this->checkout->continue_reg && ! $this->checkout->current_step->reg_form->is_valid() ) { |
|
1024 | + if ( ! $this->checkout->continue_reg && ! $this->checkout->current_step->reg_form->is_valid()) { |
|
1025 | 1025 | // thou shall not pass !!! |
1026 | 1026 | $this->checkout->continue_reg = FALSE; |
1027 | 1027 | // any form validation errors? |
1028 | - if ( $this->checkout->current_step->reg_form->submission_error_message() !== '' ) { |
|
1028 | + if ($this->checkout->current_step->reg_form->submission_error_message() !== '') { |
|
1029 | 1029 | $submission_error_messages = array(); |
1030 | 1030 | // bad, bad, bad registrant |
1031 | - foreach( $this->checkout->current_step->reg_form->get_validation_errors_accumulated() as $validation_error ){ |
|
1032 | - if ( $validation_error instanceof EE_Validation_Error ) { |
|
1031 | + foreach ($this->checkout->current_step->reg_form->get_validation_errors_accumulated() as $validation_error) { |
|
1032 | + if ($validation_error instanceof EE_Validation_Error) { |
|
1033 | 1033 | $submission_error_messages[] = sprintf( |
1034 | - __( '%s : %s', 'event_espresso' ), |
|
1034 | + __('%s : %s', 'event_espresso'), |
|
1035 | 1035 | $validation_error->get_form_section()->html_label_text(), |
1036 | 1036 | $validation_error->getMessage() |
1037 | 1037 | ); |
1038 | 1038 | } |
1039 | 1039 | } |
1040 | - EE_Error::add_error( implode( '<br />', $submission_error_messages ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1040 | + EE_Error::add_error(implode('<br />', $submission_error_messages), __FILE__, __FUNCTION__, __LINE__); |
|
1041 | 1041 | } |
1042 | 1042 | // well not really... what will happen is we'll just get redirected back to redo the current step |
1043 | 1043 | $this->go_to_next_step(); |
1044 | 1044 | return; |
1045 | 1045 | } |
1046 | 1046 | } |
1047 | - } catch( EE_Error $e ) { |
|
1047 | + } catch (EE_Error $e) { |
|
1048 | 1048 | $e->get_error(); |
1049 | 1049 | } |
1050 | 1050 | } |
@@ -1061,22 +1061,22 @@ discard block |
||
1061 | 1061 | */ |
1062 | 1062 | private function _process_form_action() { |
1063 | 1063 | // what cha wanna do? |
1064 | - switch( $this->checkout->action ) { |
|
1064 | + switch ($this->checkout->action) { |
|
1065 | 1065 | // AJAX next step reg form |
1066 | 1066 | case 'display_spco_reg_step' : |
1067 | 1067 | $this->checkout->redirect = FALSE; |
1068 | - if ( EE_Registry::instance()->REQ->ajax ) { |
|
1069 | - $this->checkout->json_response->set_reg_step_html( $this->checkout->current_step->display_reg_form() ); |
|
1068 | + if (EE_Registry::instance()->REQ->ajax) { |
|
1069 | + $this->checkout->json_response->set_reg_step_html($this->checkout->current_step->display_reg_form()); |
|
1070 | 1070 | } |
1071 | 1071 | break; |
1072 | 1072 | |
1073 | 1073 | default : |
1074 | 1074 | // meh... do one of those other steps first |
1075 | - if ( ! empty( $this->checkout->action ) && is_callable( array( $this->checkout->current_step, $this->checkout->action ))) { |
|
1075 | + if ( ! empty($this->checkout->action) && is_callable(array($this->checkout->current_step, $this->checkout->action))) { |
|
1076 | 1076 | // dynamically creates hook point like: AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step |
1077 | - do_action( "AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step ); |
|
1077 | + do_action("AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step); |
|
1078 | 1078 | // call action on current step |
1079 | - if ( call_user_func( array( $this->checkout->current_step, $this->checkout->action )) ) { |
|
1079 | + if (call_user_func(array($this->checkout->current_step, $this->checkout->action))) { |
|
1080 | 1080 | // good registrant, you get to proceed |
1081 | 1081 | if ( |
1082 | 1082 | $this->checkout->current_step->success_message() !== '' |
@@ -1087,7 +1087,7 @@ discard block |
||
1087 | 1087 | ) { |
1088 | 1088 | EE_Error::add_success( |
1089 | 1089 | $this->checkout->current_step->success_message() |
1090 | - . '<br />' . $this->checkout->next_step->_instructions() |
|
1090 | + . '<br />'.$this->checkout->next_step->_instructions() |
|
1091 | 1091 | ); |
1092 | 1092 | |
1093 | 1093 | } |
@@ -1095,12 +1095,12 @@ discard block |
||
1095 | 1095 | $this->_setup_redirect(); |
1096 | 1096 | } |
1097 | 1097 | // dynamically creates hook point like: AHEE__Single_Page_Checkout__after_payment_options__process_reg_step |
1098 | - do_action( "AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step ); |
|
1098 | + do_action("AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step); |
|
1099 | 1099 | |
1100 | 1100 | } else { |
1101 | 1101 | EE_Error::add_error( |
1102 | 1102 | sprintf( |
1103 | - __( 'The requested form action "%s" does not exist for the current "%s" registration step.', 'event_espresso' ), |
|
1103 | + __('The requested form action "%s" does not exist for the current "%s" registration step.', 'event_espresso'), |
|
1104 | 1104 | $this->checkout->action, |
1105 | 1105 | $this->checkout->current_step->name() |
1106 | 1106 | ), |
@@ -1126,10 +1126,10 @@ discard block |
||
1126 | 1126 | public function add_styles_and_scripts() { |
1127 | 1127 | // i18n |
1128 | 1128 | $this->translate_js_strings(); |
1129 | - if ( $this->checkout->admin_request ) { |
|
1130 | - add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10 ); |
|
1129 | + if ($this->checkout->admin_request) { |
|
1130 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
1131 | 1131 | } else { |
1132 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles_and_scripts' ), 10 ); |
|
1132 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
1133 | 1133 | } |
1134 | 1134 | } |
1135 | 1135 | |
@@ -1145,42 +1145,42 @@ discard block |
||
1145 | 1145 | EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit; |
1146 | 1146 | EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link; |
1147 | 1147 | EE_Registry::$i18n_js_strings['server_error'] = __('An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso'); |
1148 | - EE_Registry::$i18n_js_strings['invalid_json_response'] = __( 'An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso' ); |
|
1149 | - EE_Registry::$i18n_js_strings['validation_error'] = __( 'There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.', 'event_espresso' ); |
|
1150 | - EE_Registry::$i18n_js_strings['invalid_payment_method'] = __( 'There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.', 'event_espresso' ); |
|
1148 | + EE_Registry::$i18n_js_strings['invalid_json_response'] = __('An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso'); |
|
1149 | + EE_Registry::$i18n_js_strings['validation_error'] = __('There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.', 'event_espresso'); |
|
1150 | + EE_Registry::$i18n_js_strings['invalid_payment_method'] = __('There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.', 'event_espresso'); |
|
1151 | 1151 | EE_Registry::$i18n_js_strings['reg_step_error'] = __('This registration step could not be completed. Please refresh the page and try again.', 'event_espresso'); |
1152 | 1152 | EE_Registry::$i18n_js_strings['invalid_coupon'] = __('We\'re sorry but that coupon code does not appear to be valid. If this is incorrect, please contact the site administrator.', 'event_espresso'); |
1153 | - EE_Registry::$i18n_js_strings['process_registration'] = sprintf( __( 'Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.', 'event_espresso' ), '<br/>', '<br/>' ); |
|
1154 | - EE_Registry::$i18n_js_strings['language'] = get_bloginfo( 'language' ); |
|
1153 | + EE_Registry::$i18n_js_strings['process_registration'] = sprintf(__('Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.', 'event_espresso'), '<br/>', '<br/>'); |
|
1154 | + EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language'); |
|
1155 | 1155 | EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id(); |
1156 | 1156 | EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency; |
1157 | 1157 | EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20'; |
1158 | - EE_Registry::$i18n_js_strings['timer_years'] = __( 'years', 'event_espresso' ); |
|
1159 | - EE_Registry::$i18n_js_strings['timer_months'] = __( 'months', 'event_espresso' ); |
|
1160 | - EE_Registry::$i18n_js_strings['timer_weeks'] = __( 'weeks', 'event_espresso' ); |
|
1161 | - EE_Registry::$i18n_js_strings['timer_days'] = __( 'days', 'event_espresso' ); |
|
1162 | - EE_Registry::$i18n_js_strings['timer_hours'] = __( 'hours', 'event_espresso' ); |
|
1163 | - EE_Registry::$i18n_js_strings['timer_minutes'] = __( 'minutes', 'event_espresso' ); |
|
1164 | - EE_Registry::$i18n_js_strings['timer_seconds'] = __( 'seconds', 'event_espresso' ); |
|
1165 | - EE_Registry::$i18n_js_strings['timer_year'] = __( 'year', 'event_espresso' ); |
|
1166 | - EE_Registry::$i18n_js_strings['timer_month'] = __( 'month', 'event_espresso' ); |
|
1167 | - EE_Registry::$i18n_js_strings['timer_week'] = __( 'week', 'event_espresso' ); |
|
1168 | - EE_Registry::$i18n_js_strings['timer_day'] = __( 'day', 'event_espresso' ); |
|
1169 | - EE_Registry::$i18n_js_strings['timer_hour'] = __( 'hour', 'event_espresso' ); |
|
1170 | - EE_Registry::$i18n_js_strings['timer_minute'] = __( 'minute', 'event_espresso' ); |
|
1171 | - EE_Registry::$i18n_js_strings['timer_second'] = __( 'second', 'event_espresso' ); |
|
1158 | + EE_Registry::$i18n_js_strings['timer_years'] = __('years', 'event_espresso'); |
|
1159 | + EE_Registry::$i18n_js_strings['timer_months'] = __('months', 'event_espresso'); |
|
1160 | + EE_Registry::$i18n_js_strings['timer_weeks'] = __('weeks', 'event_espresso'); |
|
1161 | + EE_Registry::$i18n_js_strings['timer_days'] = __('days', 'event_espresso'); |
|
1162 | + EE_Registry::$i18n_js_strings['timer_hours'] = __('hours', 'event_espresso'); |
|
1163 | + EE_Registry::$i18n_js_strings['timer_minutes'] = __('minutes', 'event_espresso'); |
|
1164 | + EE_Registry::$i18n_js_strings['timer_seconds'] = __('seconds', 'event_espresso'); |
|
1165 | + EE_Registry::$i18n_js_strings['timer_year'] = __('year', 'event_espresso'); |
|
1166 | + EE_Registry::$i18n_js_strings['timer_month'] = __('month', 'event_espresso'); |
|
1167 | + EE_Registry::$i18n_js_strings['timer_week'] = __('week', 'event_espresso'); |
|
1168 | + EE_Registry::$i18n_js_strings['timer_day'] = __('day', 'event_espresso'); |
|
1169 | + EE_Registry::$i18n_js_strings['timer_hour'] = __('hour', 'event_espresso'); |
|
1170 | + EE_Registry::$i18n_js_strings['timer_minute'] = __('minute', 'event_espresso'); |
|
1171 | + EE_Registry::$i18n_js_strings['timer_second'] = __('second', 'event_espresso'); |
|
1172 | 1172 | EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf( |
1173 | - __( '%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s', 'event_espresso' ), |
|
1173 | + __('%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s', 'event_espresso'), |
|
1174 | 1174 | '<h4 class="important-notice">', |
1175 | 1175 | '</h4>', |
1176 | 1176 | '<br />', |
1177 | 1177 | '<p>', |
1178 | - '<a href="'. get_post_type_archive_link( 'espresso_events' ) . '" title="', |
|
1178 | + '<a href="'.get_post_type_archive_link('espresso_events').'" title="', |
|
1179 | 1179 | '">', |
1180 | 1180 | '</a>', |
1181 | 1181 | '</p>' |
1182 | 1182 | ); |
1183 | - EE_Registry::$i18n_js_strings[ 'ajax_submit' ] = apply_filters( 'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', true ); |
|
1183 | + EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters('FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', true); |
|
1184 | 1184 | } |
1185 | 1185 | |
1186 | 1186 | |
@@ -1193,25 +1193,25 @@ discard block |
||
1193 | 1193 | */ |
1194 | 1194 | public function enqueue_styles_and_scripts() { |
1195 | 1195 | // load css |
1196 | - wp_register_style( 'single_page_checkout', SPCO_CSS_URL . 'single_page_checkout.css', array(), EVENT_ESPRESSO_VERSION ); |
|
1197 | - wp_enqueue_style( 'single_page_checkout' ); |
|
1196 | + wp_register_style('single_page_checkout', SPCO_CSS_URL.'single_page_checkout.css', array(), EVENT_ESPRESSO_VERSION); |
|
1197 | + wp_enqueue_style('single_page_checkout'); |
|
1198 | 1198 | // load JS |
1199 | - wp_register_script( 'jquery_plugin', EE_THIRD_PARTY_URL . 'jquery .plugin.min.js', array( 'jquery' ), '1.0.1', TRUE ); |
|
1200 | - wp_register_script( 'jquery_countdown', EE_THIRD_PARTY_URL . 'jquery .countdown.min.js', array( 'jquery_plugin' ), '2.0.2', TRUE ); |
|
1201 | - wp_register_script( 'single_page_checkout', SPCO_JS_URL . 'single_page_checkout.js', array( 'espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown' ), EVENT_ESPRESSO_VERSION, TRUE ); |
|
1202 | - wp_enqueue_script( 'single_page_checkout' ); |
|
1199 | + wp_register_script('jquery_plugin', EE_THIRD_PARTY_URL.'jquery .plugin.min.js', array('jquery'), '1.0.1', TRUE); |
|
1200 | + wp_register_script('jquery_countdown', EE_THIRD_PARTY_URL.'jquery .countdown.min.js', array('jquery_plugin'), '2.0.2', TRUE); |
|
1201 | + wp_register_script('single_page_checkout', SPCO_JS_URL.'single_page_checkout.js', array('espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown'), EVENT_ESPRESSO_VERSION, TRUE); |
|
1202 | + wp_enqueue_script('single_page_checkout'); |
|
1203 | 1203 | |
1204 | 1204 | /** |
1205 | 1205 | * global action hook for enqueueing styles and scripts with |
1206 | 1206 | * spco calls. |
1207 | 1207 | */ |
1208 | - do_action( 'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this ); |
|
1208 | + do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this); |
|
1209 | 1209 | |
1210 | 1210 | /** |
1211 | 1211 | * dynamic action hook for enqueueing styles and scripts with spco calls. |
1212 | 1212 | * The hook will end up being something like AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information |
1213 | 1213 | */ |
1214 | - do_action( 'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(), $this ); |
|
1214 | + do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__'.$this->checkout->current_step->slug(), $this); |
|
1215 | 1215 | |
1216 | 1216 | } |
1217 | 1217 | |
@@ -1226,19 +1226,19 @@ discard block |
||
1226 | 1226 | */ |
1227 | 1227 | private function _display_spco_reg_form() { |
1228 | 1228 | // if registering via the admin, just display the reg form for the current step |
1229 | - if ( $this->checkout->admin_request ) { |
|
1230 | - EE_Registry::instance()->REQ->add_output( $this->checkout->current_step->display_reg_form() ); |
|
1229 | + if ($this->checkout->admin_request) { |
|
1230 | + EE_Registry::instance()->REQ->add_output($this->checkout->current_step->display_reg_form()); |
|
1231 | 1231 | } else { |
1232 | 1232 | // add powered by EE msg |
1233 | - add_action( 'AHEE__SPCO__reg_form_footer', array( 'EED_Single_Page_Checkout', 'display_registration_footer' )); |
|
1233 | + add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer')); |
|
1234 | 1234 | |
1235 | - $empty_cart = count( $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ) ) < 1 ? true : false; |
|
1235 | + $empty_cart = count($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params)) < 1 ? true : false; |
|
1236 | 1236 | $cookies_not_set_msg = ''; |
1237 | - if ( $empty_cart && ! isset( $_COOKIE[ 'ee_cookie_test' ] ) ) { |
|
1237 | + if ($empty_cart && ! isset($_COOKIE['ee_cookie_test'])) { |
|
1238 | 1238 | $cookies_not_set_msg = apply_filters( |
1239 | 1239 | 'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg', |
1240 | 1240 | sprintf( |
1241 | - __( '%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s', 'event_espresso' ), |
|
1241 | + __('%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s', 'event_espresso'), |
|
1242 | 1242 | '<div class="ee-attention">', |
1243 | 1243 | '</div>', |
1244 | 1244 | '<h6 class="important-notice">', |
@@ -1258,7 +1258,7 @@ discard block |
||
1258 | 1258 | 'layout_strategy' => |
1259 | 1259 | new EE_Template_Layout( |
1260 | 1260 | array( |
1261 | - 'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php', |
|
1261 | + 'layout_template_file' => SPCO_TEMPLATES_PATH.'registration_page_wrapper.template.php', |
|
1262 | 1262 | 'template_args' => array( |
1263 | 1263 | 'empty_cart' => $empty_cart, |
1264 | 1264 | 'revisit' => $this->checkout->revisit, |
@@ -1267,8 +1267,8 @@ discard block |
||
1267 | 1267 | 'empty_msg' => apply_filters( |
1268 | 1268 | 'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg', |
1269 | 1269 | sprintf( |
1270 | - __( 'You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.', 'event_espresso' ), |
|
1271 | - '<a href="' . get_post_type_archive_link( 'espresso_events' ) . '" title="', |
|
1270 | + __('You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.', 'event_espresso'), |
|
1271 | + '<a href="'.get_post_type_archive_link('espresso_events').'" title="', |
|
1272 | 1272 | '">', |
1273 | 1273 | '</a>' |
1274 | 1274 | ) |
@@ -1276,14 +1276,14 @@ discard block |
||
1276 | 1276 | 'cookies_not_set_msg' => $cookies_not_set_msg, |
1277 | 1277 | 'registration_time_limit' => $this->checkout->get_registration_time_limit(), |
1278 | 1278 | 'session_expiration' => |
1279 | - gmdate( 'M d, Y H:i:s', EE_Registry::instance()->SSN->expiration() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ) |
|
1279 | + gmdate('M d, Y H:i:s', EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS)) |
|
1280 | 1280 | ) |
1281 | 1281 | ) |
1282 | 1282 | ) |
1283 | 1283 | ) |
1284 | 1284 | ); |
1285 | 1285 | // load template and add to output sent that gets filtered into the_content() |
1286 | - EE_Registry::instance()->REQ->add_output( $this->checkout->registration_form->get_html_and_js() ); |
|
1286 | + EE_Registry::instance()->REQ->add_output($this->checkout->registration_form->get_html_and_js()); |
|
1287 | 1287 | } |
1288 | 1288 | } |
1289 | 1289 | |
@@ -1297,8 +1297,8 @@ discard block |
||
1297 | 1297 | * @internal param string $label |
1298 | 1298 | * @return string |
1299 | 1299 | */ |
1300 | - public function add_extra_finalize_registration_inputs( $next_step ) { |
|
1301 | - if ( $next_step === 'finalize_registration' ) { |
|
1300 | + public function add_extra_finalize_registration_inputs($next_step) { |
|
1301 | + if ($next_step === 'finalize_registration') { |
|
1302 | 1302 | echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>'; |
1303 | 1303 | } |
1304 | 1304 | } |
@@ -1320,13 +1320,13 @@ discard block |
||
1320 | 1320 | ) { |
1321 | 1321 | add_filter( |
1322 | 1322 | 'FHEE__EEH_Template__powered_by_event_espresso__url', |
1323 | - function( $url) { |
|
1324 | - return apply_filters( 'FHEE__EE_Front_Controller__registration_footer__url', $url ); |
|
1323 | + function($url) { |
|
1324 | + return apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url); |
|
1325 | 1325 | } |
1326 | 1326 | ); |
1327 | 1327 | echo apply_filters( |
1328 | 1328 | 'FHEE__EE_Front_Controller__display_registration_footer', |
1329 | - \EEH_Template::powered_by_event_espresso( '', 'espresso-registration-footer-dv' ) |
|
1329 | + \EEH_Template::powered_by_event_espresso('', 'espresso-registration-footer-dv') |
|
1330 | 1330 | ); |
1331 | 1331 | } |
1332 | 1332 | return ''; |
@@ -1342,7 +1342,7 @@ discard block |
||
1342 | 1342 | * @throws \EE_Error |
1343 | 1343 | */ |
1344 | 1344 | public function unlock_transaction() { |
1345 | - if ( $this->checkout->transaction instanceof EE_Transaction ) { |
|
1345 | + if ($this->checkout->transaction instanceof EE_Transaction) { |
|
1346 | 1346 | $this->checkout->transaction->unlock(); |
1347 | 1347 | } |
1348 | 1348 | } |
@@ -1357,12 +1357,12 @@ discard block |
||
1357 | 1357 | * @return array |
1358 | 1358 | */ |
1359 | 1359 | private function _setup_redirect() { |
1360 | - if ( $this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step ) { |
|
1360 | + if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
1361 | 1361 | $this->checkout->redirect = TRUE; |
1362 | - if ( empty( $this->checkout->redirect_url )) { |
|
1362 | + if (empty($this->checkout->redirect_url)) { |
|
1363 | 1363 | $this->checkout->redirect_url = $this->checkout->next_step->reg_step_url(); |
1364 | 1364 | } |
1365 | - $this->checkout->redirect_url = apply_filters( 'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url', $this->checkout->redirect_url, $this->checkout ); |
|
1365 | + $this->checkout->redirect_url = apply_filters('FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url', $this->checkout->redirect_url, $this->checkout); |
|
1366 | 1366 | } |
1367 | 1367 | } |
1368 | 1368 | |
@@ -1376,9 +1376,9 @@ discard block |
||
1376 | 1376 | * @throws \EE_Error |
1377 | 1377 | */ |
1378 | 1378 | public function go_to_next_step() { |
1379 | - if ( EE_Registry::instance()->REQ->ajax ) { |
|
1379 | + if (EE_Registry::instance()->REQ->ajax) { |
|
1380 | 1380 | // capture contents of output buffer we started earlier in the request, and insert into JSON response |
1381 | - $this->checkout->json_response->set_unexpected_errors( ob_get_clean() ); |
|
1381 | + $this->checkout->json_response->set_unexpected_errors(ob_get_clean()); |
|
1382 | 1382 | } |
1383 | 1383 | $this->unlock_transaction(); |
1384 | 1384 | // just return for these conditions |
@@ -1407,7 +1407,7 @@ discard block |
||
1407 | 1407 | */ |
1408 | 1408 | protected function _handle_json_response() { |
1409 | 1409 | // if this is an ajax request |
1410 | - if ( EE_Registry::instance()->REQ->ajax ) { |
|
1410 | + if (EE_Registry::instance()->REQ->ajax) { |
|
1411 | 1411 | // DEBUG LOG |
1412 | 1412 | //$this->checkout->log( |
1413 | 1413 | // __CLASS__, __FUNCTION__, __LINE__, |
@@ -1420,7 +1420,7 @@ discard block |
||
1420 | 1420 | $this->checkout->json_response->set_registration_time_limit( |
1421 | 1421 | $this->checkout->get_registration_time_limit() |
1422 | 1422 | ); |
1423 | - $this->checkout->json_response->set_payment_amount( $this->checkout->amount_owing ); |
|
1423 | + $this->checkout->json_response->set_payment_amount($this->checkout->amount_owing); |
|
1424 | 1424 | // just send the ajax ( |
1425 | 1425 | $json_response = apply_filters( |
1426 | 1426 | 'FHEE__EE_Single_Page_Checkout__JSON_response', |
@@ -1441,9 +1441,9 @@ discard block |
||
1441 | 1441 | */ |
1442 | 1442 | protected function _handle_html_redirects() { |
1443 | 1443 | // going somewhere ? |
1444 | - if ( $this->checkout->redirect && ! empty( $this->checkout->redirect_url ) ) { |
|
1444 | + if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) { |
|
1445 | 1445 | // store notices in a transient |
1446 | - EE_Error::get_notices( false, true, true ); |
|
1446 | + EE_Error::get_notices(false, true, true); |
|
1447 | 1447 | // DEBUG LOG |
1448 | 1448 | //$this->checkout->log( |
1449 | 1449 | // __CLASS__, __FUNCTION__, __LINE__, |
@@ -1453,7 +1453,7 @@ discard block |
||
1453 | 1453 | // 'headers_list' => headers_list(), |
1454 | 1454 | // ) |
1455 | 1455 | //); |
1456 | - wp_safe_redirect( $this->checkout->redirect_url ); |
|
1456 | + wp_safe_redirect($this->checkout->redirect_url); |
|
1457 | 1457 | exit(); |
1458 | 1458 | } |
1459 | 1459 | } |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | |
277 | 277 | /** |
278 | 278 | * @param $REG_ID |
279 | - * @param $reg_status |
|
279 | + * @param boolean $reg_status |
|
280 | 280 | */ |
281 | 281 | public function set_reg_status_updated( $REG_ID, $reg_status ) { |
282 | 282 | $this->reg_status_updated[ $REG_ID ] = filter_var( $reg_status, FILTER_VALIDATE_BOOLEAN ); |
@@ -1110,6 +1110,7 @@ discard block |
||
1110 | 1110 | * |
1111 | 1111 | * @param string | int $reg_cache_ID |
1112 | 1112 | * @param EE_Registration $registration |
1113 | + * @param integer $reg_cache_ID |
|
1113 | 1114 | * @return void |
1114 | 1115 | * @throws \EE_Error |
1115 | 1116 | */ |
@@ -241,9 +241,9 @@ discard block |
||
241 | 241 | $this->reg_page_base_url = EE_Registry::instance()->CFG->core->reg_page_url(); |
242 | 242 | $this->thank_you_page_url = EE_Registry::instance()->CFG->core->thank_you_page_url(); |
243 | 243 | $this->cancel_page_url = EE_Registry::instance()->CFG->core->cancel_page_url(); |
244 | - $this->continue_reg = apply_filters( 'FHEE__EE_Checkout___construct___continue_reg', TRUE ); |
|
244 | + $this->continue_reg = apply_filters('FHEE__EE_Checkout___construct___continue_reg', TRUE); |
|
245 | 245 | $this->admin_request = is_admin() && ! EE_Registry::instance()->REQ->ajax; |
246 | - $this->reg_cache_where_params = array( 'order_by' => array( 'REG_count' => 'ASC' )); |
|
246 | + $this->reg_cache_where_params = array('order_by' => array('REG_count' => 'ASC')); |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | |
@@ -254,8 +254,8 @@ discard block |
||
254 | 254 | * @return boolean |
255 | 255 | */ |
256 | 256 | public function any_reg_status_updated() { |
257 | - foreach ( $this->reg_status_updated as $reg_status ) { |
|
258 | - if ( $reg_status ) { |
|
257 | + foreach ($this->reg_status_updated as $reg_status) { |
|
258 | + if ($reg_status) { |
|
259 | 259 | return true; |
260 | 260 | } |
261 | 261 | } |
@@ -268,8 +268,8 @@ discard block |
||
268 | 268 | * @param $REG_ID |
269 | 269 | * @return boolean |
270 | 270 | */ |
271 | - public function reg_status_updated( $REG_ID ) { |
|
272 | - return isset( $this->reg_status_updated[ $REG_ID ] ) ? $this->reg_status_updated[ $REG_ID ] : false; |
|
271 | + public function reg_status_updated($REG_ID) { |
|
272 | + return isset($this->reg_status_updated[$REG_ID]) ? $this->reg_status_updated[$REG_ID] : false; |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | |
@@ -278,8 +278,8 @@ discard block |
||
278 | 278 | * @param $REG_ID |
279 | 279 | * @param $reg_status |
280 | 280 | */ |
281 | - public function set_reg_status_updated( $REG_ID, $reg_status ) { |
|
282 | - $this->reg_status_updated[ $REG_ID ] = filter_var( $reg_status, FILTER_VALIDATE_BOOLEAN ); |
|
281 | + public function set_reg_status_updated($REG_ID, $reg_status) { |
|
282 | + $this->reg_status_updated[$REG_ID] = filter_var($reg_status, FILTER_VALIDATE_BOOLEAN); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | * can ONLY be set by the Finalize_Registration reg step |
301 | 301 | */ |
302 | 302 | public function set_exit_spco() { |
303 | - if ( $this->current_step instanceof EE_SPCO_Reg_Step_Finalize_Registration ) { |
|
303 | + if ($this->current_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) { |
|
304 | 304 | $this->exit_spco = true; |
305 | 305 | } |
306 | 306 | } |
@@ -317,12 +317,12 @@ discard block |
||
317 | 317 | */ |
318 | 318 | public function reset_for_current_request() { |
319 | 319 | $this->process_form_submission = FALSE; |
320 | - $this->continue_reg = apply_filters( 'FHEE__EE_Checkout___construct___continue_reg', true ); |
|
320 | + $this->continue_reg = apply_filters('FHEE__EE_Checkout___construct___continue_reg', true); |
|
321 | 321 | $this->admin_request = is_admin() && ! EE_Registry::instance()->REQ->front_ajax; |
322 | 322 | $this->continue_reg = true; |
323 | 323 | $this->redirect = false; |
324 | 324 | // don't reset the cached redirect form if we're about to be asked to display it !!! |
325 | - if ( EE_Registry::instance()->REQ->get( 'action', 'display_spco_reg_step' ) !== 'redirect_form' ) { |
|
325 | + if (EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step') !== 'redirect_form') { |
|
326 | 326 | $this->redirect_form = ''; |
327 | 327 | } |
328 | 328 | $this->redirect_url = ''; |
@@ -339,8 +339,8 @@ discard block |
||
339 | 339 | * @param EE_SPCO_Reg_Step $reg_step_obj |
340 | 340 | * @return void |
341 | 341 | */ |
342 | - public function add_reg_step( EE_SPCO_Reg_Step $reg_step_obj ) { |
|
343 | - $this->reg_steps[ $reg_step_obj->slug() ] = $reg_step_obj; |
|
342 | + public function add_reg_step(EE_SPCO_Reg_Step $reg_step_obj) { |
|
343 | + $this->reg_steps[$reg_step_obj->slug()] = $reg_step_obj; |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | |
@@ -356,22 +356,22 @@ discard block |
||
356 | 356 | * @return void |
357 | 357 | * @throws \EE_Error |
358 | 358 | */ |
359 | - public function skip_reg_step( $reg_step_slug = '' ) { |
|
360 | - $step_to_skip = $this->find_reg_step( $reg_step_slug ); |
|
361 | - if ( $step_to_skip instanceof EE_SPCO_Reg_Step && $step_to_skip->is_current_step() ) { |
|
362 | - $step_to_skip->set_is_current_step( false ); |
|
359 | + public function skip_reg_step($reg_step_slug = '') { |
|
360 | + $step_to_skip = $this->find_reg_step($reg_step_slug); |
|
361 | + if ($step_to_skip instanceof EE_SPCO_Reg_Step && $step_to_skip->is_current_step()) { |
|
362 | + $step_to_skip->set_is_current_step(false); |
|
363 | 363 | $step_to_skip->set_completed(); |
364 | 364 | // advance to the next step |
365 | - $this->set_current_step( $this->next_step->slug() ); |
|
365 | + $this->set_current_step($this->next_step->slug()); |
|
366 | 366 | // also reset the step param in the request in case any other code references that directly |
367 | - EE_Registry::instance()->REQ->set( 'step', $this->current_step->slug() ); |
|
367 | + EE_Registry::instance()->REQ->set('step', $this->current_step->slug()); |
|
368 | 368 | // since we are skipping a step and setting the current step to be what was previously the next step, |
369 | 369 | // we need to check that the next step is now correct, and not still set to the current step. |
370 | - if ( $this->current_step->slug() === $this->next_step->slug() ) { |
|
370 | + if ($this->current_step->slug() === $this->next_step->slug()) { |
|
371 | 371 | // correctly setup the next step |
372 | 372 | $this->set_next_step(); |
373 | 373 | } |
374 | - $this->set_reg_step_initiated( $this->current_step ); |
|
374 | + $this->set_reg_step_initiated($this->current_step); |
|
375 | 375 | } |
376 | 376 | } |
377 | 377 | |
@@ -385,14 +385,14 @@ discard block |
||
385 | 385 | * @param bool $reset whether to reset reg steps after removal |
386 | 386 | * @throws EE_Error |
387 | 387 | */ |
388 | - public function remove_reg_step( $reg_step_slug = '', $reset = true ) { |
|
389 | - unset( $this->reg_steps[ $reg_step_slug ] ); |
|
390 | - if ( $this->transaction instanceof EE_Transaction ) { |
|
388 | + public function remove_reg_step($reg_step_slug = '', $reset = true) { |
|
389 | + unset($this->reg_steps[$reg_step_slug]); |
|
390 | + if ($this->transaction instanceof EE_Transaction) { |
|
391 | 391 | // now remove reg step from TXN and save |
392 | - $this->transaction->remove_reg_step( $reg_step_slug ); |
|
392 | + $this->transaction->remove_reg_step($reg_step_slug); |
|
393 | 393 | $this->transaction->save(); |
394 | 394 | } |
395 | - if ( $reset ) { |
|
395 | + if ($reset) { |
|
396 | 396 | $this->reset_reg_steps(); |
397 | 397 | } |
398 | 398 | } |
@@ -407,9 +407,9 @@ discard block |
||
407 | 407 | * @param int $order |
408 | 408 | * @return void |
409 | 409 | */ |
410 | - public function set_reg_step_order( $reg_step_slug = '', $order = 100 ) { |
|
411 | - if ( isset( $this->reg_steps[ $reg_step_slug ] )) { |
|
412 | - $this->reg_steps[ $reg_step_slug ]->set_order( $order ); |
|
410 | + public function set_reg_step_order($reg_step_slug = '', $order = 100) { |
|
411 | + if (isset($this->reg_steps[$reg_step_slug])) { |
|
412 | + $this->reg_steps[$reg_step_slug]->set_order($order); |
|
413 | 413 | } |
414 | 414 | } |
415 | 415 | |
@@ -422,25 +422,25 @@ discard block |
||
422 | 422 | * @param string $current_step |
423 | 423 | * @return void |
424 | 424 | */ |
425 | - public function set_current_step( $current_step ) { |
|
425 | + public function set_current_step($current_step) { |
|
426 | 426 | // grab what step we're on |
427 | - $this->current_step = isset( $this->reg_steps[ $current_step ] ) ? $this->reg_steps[ $current_step ] : reset( $this->reg_steps ); |
|
427 | + $this->current_step = isset($this->reg_steps[$current_step]) ? $this->reg_steps[$current_step] : reset($this->reg_steps); |
|
428 | 428 | // verify instance |
429 | - if ( $this->current_step instanceof EE_SPCO_Reg_Step ) { |
|
429 | + if ($this->current_step instanceof EE_SPCO_Reg_Step) { |
|
430 | 430 | // we don't want to repeat completed steps if this is the first time through SPCO |
431 | - if ( $this->continue_reg && ! $this->revisit && $this->current_step->completed() ) { |
|
431 | + if ($this->continue_reg && ! $this->revisit && $this->current_step->completed()) { |
|
432 | 432 | // so advance to the next step |
433 | 433 | $this->set_next_step(); |
434 | - if ( $this->next_step instanceof EE_SPCO_Reg_Step ) { |
|
434 | + if ($this->next_step instanceof EE_SPCO_Reg_Step) { |
|
435 | 435 | // and attempt to set it as the current step |
436 | - $this->set_current_step( $this->next_step->slug() ); |
|
436 | + $this->set_current_step($this->next_step->slug()); |
|
437 | 437 | } |
438 | 438 | return; |
439 | 439 | } |
440 | - $this->current_step->set_is_current_step( TRUE ); |
|
440 | + $this->current_step->set_is_current_step(TRUE); |
|
441 | 441 | } else { |
442 | 442 | EE_Error::add_error( |
443 | - __( 'The current step could not be set.', 'event_espresso' ), |
|
443 | + __('The current step could not be set.', 'event_espresso'), |
|
444 | 444 | __FILE__, __FUNCTION__, __LINE__ |
445 | 445 | ); |
446 | 446 | } |
@@ -457,20 +457,20 @@ discard block |
||
457 | 457 | */ |
458 | 458 | public function set_next_step() { |
459 | 459 | // set pointer to start of array |
460 | - reset( $this->reg_steps ); |
|
460 | + reset($this->reg_steps); |
|
461 | 461 | // if there is more than one step |
462 | - if ( count( $this->reg_steps ) > 1 ) { |
|
462 | + if (count($this->reg_steps) > 1) { |
|
463 | 463 | // advance to the current step and set pointer |
464 | - while ( key( $this->reg_steps ) !== $this->current_step->slug() && key( $this->reg_steps ) !== '' ) { |
|
465 | - next( $this->reg_steps ); |
|
464 | + while (key($this->reg_steps) !== $this->current_step->slug() && key($this->reg_steps) !== '') { |
|
465 | + next($this->reg_steps); |
|
466 | 466 | } |
467 | 467 | } |
468 | 468 | // advance one more spot ( if it exists ) |
469 | - $this->next_step = next( $this->reg_steps ); |
|
469 | + $this->next_step = next($this->reg_steps); |
|
470 | 470 | // verify instance |
471 | - $this->next_step = $this->next_step instanceof EE_SPCO_Reg_Step ? $this->next_step : NULL; |
|
471 | + $this->next_step = $this->next_step instanceof EE_SPCO_Reg_Step ? $this->next_step : NULL; |
|
472 | 472 | // then back to current step to reset |
473 | - prev( $this->reg_steps ); |
|
473 | + prev($this->reg_steps); |
|
474 | 474 | } |
475 | 475 | |
476 | 476 | |
@@ -484,8 +484,8 @@ discard block |
||
484 | 484 | * @return EE_SPCO_Reg_Step | null |
485 | 485 | */ |
486 | 486 | public function get_next_reg_step() { |
487 | - $next = next( $this->reg_steps ); |
|
488 | - prev( $this->reg_steps ); |
|
487 | + $next = next($this->reg_steps); |
|
488 | + prev($this->reg_steps); |
|
489 | 489 | return $next instanceof EE_SPCO_Reg_Step ? $next : null; |
490 | 490 | } |
491 | 491 | |
@@ -500,8 +500,8 @@ discard block |
||
500 | 500 | * @return EE_SPCO_Reg_Step | null |
501 | 501 | */ |
502 | 502 | public function get_prev_reg_step() { |
503 | - $prev = prev( $this->reg_steps ); |
|
504 | - next( $this->reg_steps ); |
|
503 | + $prev = prev($this->reg_steps); |
|
504 | + next($this->reg_steps); |
|
505 | 505 | return $prev instanceof EE_SPCO_Reg_Step ? $prev : null; |
506 | 506 | } |
507 | 507 | |
@@ -514,8 +514,8 @@ discard block |
||
514 | 514 | * @return void |
515 | 515 | */ |
516 | 516 | public function sort_reg_steps() { |
517 | - $reg_step_sorting_callback = apply_filters( 'FHEE__EE_Checkout__sort_reg_steps__reg_step_sorting_callback', 'reg_step_sorting_callback' ); |
|
518 | - uasort( $this->reg_steps, array( $this, $reg_step_sorting_callback )); |
|
517 | + $reg_step_sorting_callback = apply_filters('FHEE__EE_Checkout__sort_reg_steps__reg_step_sorting_callback', 'reg_step_sorting_callback'); |
|
518 | + uasort($this->reg_steps, array($this, $reg_step_sorting_callback)); |
|
519 | 519 | } |
520 | 520 | |
521 | 521 | |
@@ -528,19 +528,19 @@ discard block |
||
528 | 528 | * @param string $reg_step_slug |
529 | 529 | * @return EE_SPCO_Reg_Step|null |
530 | 530 | */ |
531 | - public function find_reg_step( $reg_step_slug = '' ) { |
|
532 | - if ( ! empty( $reg_step_slug ) ) { |
|
531 | + public function find_reg_step($reg_step_slug = '') { |
|
532 | + if ( ! empty($reg_step_slug)) { |
|
533 | 533 | // copy reg step array |
534 | 534 | $reg_steps = $this->reg_steps; |
535 | 535 | // set pointer to start of array |
536 | - reset( $reg_steps ); |
|
536 | + reset($reg_steps); |
|
537 | 537 | // if there is more than one step |
538 | - if ( count( $reg_steps ) > 1 ) { |
|
538 | + if (count($reg_steps) > 1) { |
|
539 | 539 | // advance to the current step and set pointer |
540 | - while ( key( $reg_steps ) !== $reg_step_slug && key( $reg_steps ) !== '' ) { |
|
541 | - next( $reg_steps ); |
|
540 | + while (key($reg_steps) !== $reg_step_slug && key($reg_steps) !== '') { |
|
541 | + next($reg_steps); |
|
542 | 542 | } |
543 | - return current( $reg_steps ); |
|
543 | + return current($reg_steps); |
|
544 | 544 | } |
545 | 545 | } |
546 | 546 | return null; |
@@ -556,17 +556,17 @@ discard block |
||
556 | 556 | * @param EE_SPCO_Reg_Step $reg_step_B |
557 | 557 | * @return int |
558 | 558 | */ |
559 | - public function reg_step_sorting_callback( EE_SPCO_Reg_Step $reg_step_A, EE_SPCO_Reg_Step $reg_step_B ) { |
|
559 | + public function reg_step_sorting_callback(EE_SPCO_Reg_Step $reg_step_A, EE_SPCO_Reg_Step $reg_step_B) { |
|
560 | 560 | // send finalize_registration step to the end of the array |
561 | - if ( $reg_step_A->slug() === 'finalize_registration' ) { |
|
561 | + if ($reg_step_A->slug() === 'finalize_registration') { |
|
562 | 562 | return 1; |
563 | - } else if ( $reg_step_B->slug() === 'finalize_registration' ) { |
|
563 | + } else if ($reg_step_B->slug() === 'finalize_registration') { |
|
564 | 564 | return -1; |
565 | 565 | } |
566 | - if ( $reg_step_A->order() === $reg_step_B->order() ) { |
|
566 | + if ($reg_step_A->order() === $reg_step_B->order()) { |
|
567 | 567 | return 0; |
568 | 568 | } |
569 | - return ( $reg_step_A->order() > $reg_step_B->order() ) ? 1 : -1; |
|
569 | + return ($reg_step_A->order() > $reg_step_B->order()) ? 1 : -1; |
|
570 | 570 | } |
571 | 571 | |
572 | 572 | |
@@ -578,7 +578,7 @@ discard block |
||
578 | 578 | * @param EE_SPCO_Reg_Step $reg_step |
579 | 579 | * @throws \EE_Error |
580 | 580 | */ |
581 | - public function set_reg_step_initiated( EE_SPCO_Reg_Step $reg_step ) { |
|
581 | + public function set_reg_step_initiated(EE_SPCO_Reg_Step $reg_step) { |
|
582 | 582 | // call set_reg_step_initiated ??? |
583 | 583 | if ( |
584 | 584 | // first time visiting SPCO ? |
@@ -591,11 +591,11 @@ discard block |
||
591 | 591 | ) |
592 | 592 | ) { |
593 | 593 | // set the start time for this reg step |
594 | - if ( ! $this->transaction->set_reg_step_initiated( $reg_step->slug() ) ) { |
|
595 | - if ( WP_DEBUG ) { |
|
594 | + if ( ! $this->transaction->set_reg_step_initiated($reg_step->slug())) { |
|
595 | + if (WP_DEBUG) { |
|
596 | 596 | EE_Error::add_error( |
597 | 597 | sprintf( |
598 | - __( 'The "%1$s" registration step was not initialized properly.', 'event_espresso' ), |
|
598 | + __('The "%1$s" registration step was not initialized properly.', 'event_espresso'), |
|
599 | 599 | $reg_step->name() |
600 | 600 | ), |
601 | 601 | __FILE__, __FUNCTION__, __LINE__ |
@@ -614,10 +614,10 @@ discard block |
||
614 | 614 | * @return void |
615 | 615 | */ |
616 | 616 | public function set_reg_step_JSON_info() { |
617 | - EE_Registry::$i18n_js_strings[ 'reg_steps' ] = array(); |
|
617 | + EE_Registry::$i18n_js_strings['reg_steps'] = array(); |
|
618 | 618 | // pass basic reg step data to JS |
619 | - foreach ( $this->reg_steps as $reg_step ) { |
|
620 | - EE_Registry::$i18n_js_strings[ 'reg_steps' ][] = $reg_step->slug(); |
|
619 | + foreach ($this->reg_steps as $reg_step) { |
|
620 | + EE_Registry::$i18n_js_strings['reg_steps'][] = $reg_step->slug(); |
|
621 | 621 | } |
622 | 622 | // reset reg step html |
623 | 623 | // $this->json_response->set_reg_step_html( '' ); |
@@ -633,7 +633,7 @@ discard block |
||
633 | 633 | */ |
634 | 634 | public function reset_reg_steps() { |
635 | 635 | $this->sort_reg_steps(); |
636 | - $this->set_current_step( EE_Registry::instance()->REQ->get( 'step' )); |
|
636 | + $this->set_current_step(EE_Registry::instance()->REQ->get('step')); |
|
637 | 637 | $this->set_next_step(); |
638 | 638 | // the text that appears on the reg step form submit button |
639 | 639 | $this->current_step->set_submit_button_text(); |
@@ -650,9 +650,9 @@ discard block |
||
650 | 650 | */ |
651 | 651 | public function get_registration_time_limit() { |
652 | 652 | |
653 | - $registration_time_limit = (float)( EE_Registry::instance() ->SSN->expiration() - time() ); |
|
653 | + $registration_time_limit = (float) (EE_Registry::instance() ->SSN->expiration() - time()); |
|
654 | 654 | $time_limit_format = $registration_time_limit > 60 * MINUTE_IN_SECONDS ? 'H:i:s' : 'i:s'; |
655 | - $registration_time_limit = gmdate( $time_limit_format, $registration_time_limit ); |
|
655 | + $registration_time_limit = gmdate($time_limit_format, $registration_time_limit); |
|
656 | 656 | return apply_filters( |
657 | 657 | 'FHEE__EE_Checkout__get_registration_time_limit__registration_time_limit', |
658 | 658 | $registration_time_limit |
@@ -672,7 +672,7 @@ discard block |
||
672 | 672 | // overpaid TXN |
673 | 673 | // free TXN ( total = 0.00 ) |
674 | 674 | // then payment required is TRUE |
675 | - return ! ( $this->admin_request || $this->transaction->is_completed() || $this->transaction->is_overpaid() || $this->transaction->is_free() ) ? TRUE : FALSE; |
|
675 | + return ! ($this->admin_request || $this->transaction->is_completed() || $this->transaction->is_overpaid() || $this->transaction->is_free()) ? TRUE : FALSE; |
|
676 | 676 | } |
677 | 677 | |
678 | 678 | |
@@ -684,12 +684,12 @@ discard block |
||
684 | 684 | * @param EE_Transaction $transaction |
685 | 685 | * @return EE_Cart |
686 | 686 | */ |
687 | - public function get_cart_for_transaction( $transaction ) { |
|
688 | - $session = EE_Registry::instance()->load_core( 'Session' ); |
|
689 | - $cart = $transaction instanceof EE_Transaction ? EE_Cart::get_cart_from_txn( $transaction, $session ) : null; |
|
687 | + public function get_cart_for_transaction($transaction) { |
|
688 | + $session = EE_Registry::instance()->load_core('Session'); |
|
689 | + $cart = $transaction instanceof EE_Transaction ? EE_Cart::get_cart_from_txn($transaction, $session) : null; |
|
690 | 690 | // verify cart |
691 | - if ( ! $cart instanceof EE_Cart ) { |
|
692 | - $cart = EE_Registry::instance()->load_core( 'Cart' ); |
|
691 | + if ( ! $cart instanceof EE_Cart) { |
|
692 | + $cart = EE_Registry::instance()->load_core('Cart'); |
|
693 | 693 | } |
694 | 694 | |
695 | 695 | return $cart; |
@@ -705,8 +705,8 @@ discard block |
||
705 | 705 | */ |
706 | 706 | public function initialize_txn_reg_steps_array() { |
707 | 707 | $txn_reg_steps_array = array(); |
708 | - foreach ( $this->reg_steps as $reg_step ) { |
|
709 | - $txn_reg_steps_array[ $reg_step->slug() ] = FALSE; |
|
708 | + foreach ($this->reg_steps as $reg_step) { |
|
709 | + $txn_reg_steps_array[$reg_step->slug()] = FALSE; |
|
710 | 710 | } |
711 | 711 | return $txn_reg_steps_array; |
712 | 712 | } |
@@ -722,14 +722,14 @@ discard block |
||
722 | 722 | */ |
723 | 723 | public function update_txn_reg_steps_array() { |
724 | 724 | $updated = false; |
725 | - foreach ( $this->reg_steps as $reg_step ) { |
|
726 | - if ( $reg_step->completed() ) { |
|
727 | - $updated = $this->transaction->set_reg_step_completed( $reg_step->slug() ) |
|
725 | + foreach ($this->reg_steps as $reg_step) { |
|
726 | + if ($reg_step->completed()) { |
|
727 | + $updated = $this->transaction->set_reg_step_completed($reg_step->slug()) |
|
728 | 728 | ? true |
729 | 729 | : $updated; |
730 | 730 | } |
731 | 731 | } |
732 | - if ( $updated ) { |
|
732 | + if ($updated) { |
|
733 | 733 | $this->transaction->save(); |
734 | 734 | } |
735 | 735 | return $updated; |
@@ -745,14 +745,14 @@ discard block |
||
745 | 745 | * @throws \EE_Error |
746 | 746 | */ |
747 | 747 | public function stash_transaction_and_checkout() { |
748 | - if ( ! $this->revisit ) { |
|
748 | + if ( ! $this->revisit) { |
|
749 | 749 | $this->update_txn_reg_steps_array(); |
750 | 750 | } |
751 | 751 | $this->track_transaction_and_registration_status_updates(); |
752 | 752 | // save all data to the db, but suppress errors |
753 | 753 | //$this->save_all_data( FALSE ); |
754 | 754 | // cache the checkout in the session |
755 | - EE_Registry::instance()->SSN->set_checkout( $this ); |
|
755 | + EE_Registry::instance()->SSN->set_checkout($this); |
|
756 | 756 | } |
757 | 757 | |
758 | 758 | |
@@ -767,15 +767,15 @@ discard block |
||
767 | 767 | */ |
768 | 768 | public function track_transaction_and_registration_status_updates() { |
769 | 769 | // verify the transaction |
770 | - if ( $this->transaction instanceof EE_Transaction ) { |
|
770 | + if ($this->transaction instanceof EE_Transaction) { |
|
771 | 771 | // has there been a TXN status change during this checkout? |
772 | 772 | $this->txn_status_updated = $this->transaction->txn_status_updated(); |
773 | 773 | /** @type EE_Registration_Processor $registration_processor */ |
774 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
774 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
775 | 775 | // grab the saved registrations from the transaction |
776 | - foreach ( $this->transaction->registrations( $this->reg_cache_where_params ) as $registration ) { |
|
777 | - if ( $registration_processor->reg_status_updated( $registration->ID() ) ) { |
|
778 | - $this->set_reg_status_updated( $registration->ID(), true ); |
|
776 | + foreach ($this->transaction->registrations($this->reg_cache_where_params) as $registration) { |
|
777 | + if ($registration_processor->reg_status_updated($registration->ID())) { |
|
778 | + $this->set_reg_status_updated($registration->ID(), true); |
|
779 | 779 | } |
780 | 780 | } |
781 | 781 | } |
@@ -796,7 +796,7 @@ discard block |
||
796 | 796 | * @return bool |
797 | 797 | * @throws \EE_Error |
798 | 798 | */ |
799 | - public function visit_allows_processing_of_this_registration( EE_Registration $registration ) { |
|
799 | + public function visit_allows_processing_of_this_registration(EE_Registration $registration) { |
|
800 | 800 | return ! $this->revisit |
801 | 801 | || $this->primary_revisit |
802 | 802 | || ( |
@@ -829,18 +829,18 @@ discard block |
||
829 | 829 | * @return bool |
830 | 830 | * @throws \EE_Error |
831 | 831 | */ |
832 | - public function save_all_data( $show_errors = TRUE ) { |
|
832 | + public function save_all_data($show_errors = TRUE) { |
|
833 | 833 | // verify the transaction |
834 | - if ( $this->transaction instanceof EE_Transaction ) { |
|
834 | + if ($this->transaction instanceof EE_Transaction) { |
|
835 | 835 | // save to ensure that TXN has ID |
836 | 836 | $this->transaction->save(); |
837 | 837 | // grab the saved registrations from the transaction |
838 | - foreach ( $this->transaction->registrations( $this->reg_cache_where_params ) as $registration ) { |
|
839 | - $this->_save_registration( $registration, $show_errors ); |
|
838 | + foreach ($this->transaction->registrations($this->reg_cache_where_params) as $registration) { |
|
839 | + $this->_save_registration($registration, $show_errors); |
|
840 | 840 | } |
841 | 841 | } else { |
842 | - if ( $show_errors ) { |
|
843 | - EE_Error::add_error( __( 'A valid Transaction was not found when attempting to save your registration information.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
842 | + if ($show_errors) { |
|
843 | + EE_Error::add_error(__('A valid Transaction was not found when attempting to save your registration information.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
844 | 844 | } |
845 | 845 | return FALSE; |
846 | 846 | } |
@@ -857,32 +857,32 @@ discard block |
||
857 | 857 | * @return void |
858 | 858 | * @throws \EE_Error |
859 | 859 | */ |
860 | - private function _save_registration( $registration, $show_errors = TRUE ) { |
|
860 | + private function _save_registration($registration, $show_errors = TRUE) { |
|
861 | 861 | // verify object |
862 | - if ( $registration instanceof EE_Registration ) { |
|
862 | + if ($registration instanceof EE_Registration) { |
|
863 | 863 | // should this registration be processed during this visit ? |
864 | - if ( $this->visit_allows_processing_of_this_registration( $registration ) ) { |
|
864 | + if ($this->visit_allows_processing_of_this_registration($registration)) { |
|
865 | 865 | //set TXN ID |
866 | - if ( ! $registration->transaction_ID() ) { |
|
867 | - $registration->set_transaction_id( $this->transaction->ID() ); |
|
866 | + if ( ! $registration->transaction_ID()) { |
|
867 | + $registration->set_transaction_id($this->transaction->ID()); |
|
868 | 868 | } |
869 | 869 | // verify and save the attendee |
870 | - $this->_save_registration_attendee( $registration, $show_errors ); |
|
870 | + $this->_save_registration_attendee($registration, $show_errors); |
|
871 | 871 | // save answers to reg form questions |
872 | - $this->_save_registration_answers( $registration, $show_errors ); |
|
872 | + $this->_save_registration_answers($registration, $show_errors); |
|
873 | 873 | // save changes |
874 | 874 | $registration->save(); |
875 | 875 | // update txn cache |
876 | - if ( ! $this->transaction->update_cache_after_object_save( 'Registration', $registration )) { |
|
877 | - if ( $show_errors ) { |
|
878 | - EE_Error::add_error( __( 'The newly saved Registration object could not be cached on the Transaction.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
876 | + if ( ! $this->transaction->update_cache_after_object_save('Registration', $registration)) { |
|
877 | + if ($show_errors) { |
|
878 | + EE_Error::add_error(__('The newly saved Registration object could not be cached on the Transaction.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
879 | 879 | } |
880 | 880 | } |
881 | 881 | } |
882 | 882 | } else { |
883 | - if ( $show_errors ) { |
|
883 | + if ($show_errors) { |
|
884 | 884 | EE_Error::add_error( |
885 | - __( 'An invalid Registration object was discovered when attempting to save your registration information.', 'event_espresso' ), |
|
885 | + __('An invalid Registration object was discovered when attempting to save your registration information.', 'event_espresso'), |
|
886 | 886 | __FILE__, __FUNCTION__, __LINE__ |
887 | 887 | ); |
888 | 888 | } |
@@ -899,25 +899,25 @@ discard block |
||
899 | 899 | * @return void |
900 | 900 | * @throws \EE_Error |
901 | 901 | */ |
902 | - private function _save_registration_attendee( $registration, $show_errors = TRUE ) { |
|
903 | - if ( $registration->attendee() instanceof EE_Attendee ) { |
|
902 | + private function _save_registration_attendee($registration, $show_errors = TRUE) { |
|
903 | + if ($registration->attendee() instanceof EE_Attendee) { |
|
904 | 904 | // save so that ATT has ID |
905 | 905 | $registration->attendee()->save(); |
906 | - if ( ! $registration->update_cache_after_object_save( 'Attendee', $registration->attendee() ) ) { |
|
907 | - if ( $show_errors ) { |
|
906 | + if ( ! $registration->update_cache_after_object_save('Attendee', $registration->attendee())) { |
|
907 | + if ($show_errors) { |
|
908 | 908 | EE_Error::add_error( |
909 | - __( 'The newly saved Attendee object could not be cached on the registration.', 'event_espresso' ), |
|
909 | + __('The newly saved Attendee object could not be cached on the registration.', 'event_espresso'), |
|
910 | 910 | __FILE__, __FUNCTION__, __LINE__ |
911 | 911 | ); |
912 | 912 | } |
913 | 913 | } |
914 | 914 | } else { |
915 | - if ( $show_errors ) { |
|
915 | + if ($show_errors) { |
|
916 | 916 | EE_Error::add_error( |
917 | 917 | sprintf( |
918 | 918 | '%1$s||%1$s $attendee = %2$s', |
919 | - __( 'Either no Attendee information was found, or an invalid Attendee object was discovered when attempting to save your registration information.', 'event_espresso' ), |
|
920 | - var_export( $registration->attendee(), true ) |
|
919 | + __('Either no Attendee information was found, or an invalid Attendee object was discovered when attempting to save your registration information.', 'event_espresso'), |
|
920 | + var_export($registration->attendee(), true) |
|
921 | 921 | ), |
922 | 922 | __FILE__, __FUNCTION__, __LINE__ |
923 | 923 | ); |
@@ -935,25 +935,25 @@ discard block |
||
935 | 935 | * @return void |
936 | 936 | * @throws \EE_Error |
937 | 937 | */ |
938 | - private function _save_registration_answers( $registration, $show_errors = TRUE ) { |
|
938 | + private function _save_registration_answers($registration, $show_errors = TRUE) { |
|
939 | 939 | // now save the answers |
940 | - foreach ( $registration->answers() as $cache_key => $answer ) { |
|
940 | + foreach ($registration->answers() as $cache_key => $answer) { |
|
941 | 941 | // verify object |
942 | - if ( $answer instanceof EE_Answer ) { |
|
943 | - $answer->set_registration( $registration->ID() ); |
|
942 | + if ($answer instanceof EE_Answer) { |
|
943 | + $answer->set_registration($registration->ID()); |
|
944 | 944 | $answer->save(); |
945 | - if ( ! $registration->update_cache_after_object_save( 'Answer', $answer, $cache_key )) { |
|
946 | - if ( $show_errors ) { |
|
945 | + if ( ! $registration->update_cache_after_object_save('Answer', $answer, $cache_key)) { |
|
946 | + if ($show_errors) { |
|
947 | 947 | EE_Error::add_error( |
948 | - __( 'The newly saved Answer object could not be cached on the registration.', 'event_espresso' ), |
|
948 | + __('The newly saved Answer object could not be cached on the registration.', 'event_espresso'), |
|
949 | 949 | __FILE__, __FUNCTION__, __LINE__ |
950 | 950 | ); |
951 | 951 | } |
952 | 952 | } |
953 | 953 | } else { |
954 | - if ( $show_errors ) { |
|
954 | + if ($show_errors) { |
|
955 | 955 | EE_Error::add_error( |
956 | - __( 'An invalid Answer object was discovered when attempting to save your registration information.', 'event_espresso' ), |
|
956 | + __('An invalid Answer object was discovered when attempting to save your registration information.', 'event_espresso'), |
|
957 | 957 | __FILE__, __FUNCTION__, __LINE__ |
958 | 958 | ); |
959 | 959 | } |
@@ -972,7 +972,7 @@ discard block |
||
972 | 972 | * @return bool |
973 | 973 | * @throws \EE_Error |
974 | 974 | */ |
975 | - public function refresh_all_entities( $from_db = false ) { |
|
975 | + public function refresh_all_entities($from_db = false) { |
|
976 | 976 | $from_db = $this->current_step->is_final_step() || $this->action === 'process_gateway_response' |
977 | 977 | ? true |
978 | 978 | : $from_db; |
@@ -996,11 +996,11 @@ discard block |
||
996 | 996 | */ |
997 | 997 | protected function refresh_from_db() { |
998 | 998 | // verify the transaction |
999 | - if ( $this->transaction instanceof EE_Transaction && $this->transaction->ID() ) { |
|
999 | + if ($this->transaction instanceof EE_Transaction && $this->transaction->ID()) { |
|
1000 | 1000 | // pull fresh TXN data from the db |
1001 | - $this->transaction = $this->transaction->get_model()->refresh_entity_map_from_db( $this->transaction->ID() ); |
|
1001 | + $this->transaction = $this->transaction->get_model()->refresh_entity_map_from_db($this->transaction->ID()); |
|
1002 | 1002 | // update EE_Checkout's cached primary_attendee object |
1003 | - $this->primary_attendee_obj = $this->_refresh_primary_attendee_obj_from_db( $this->transaction ); |
|
1003 | + $this->primary_attendee_obj = $this->_refresh_primary_attendee_obj_from_db($this->transaction); |
|
1004 | 1004 | // update EE_Checkout's cached payment object |
1005 | 1005 | $payment = $this->transaction->last_payment(); |
1006 | 1006 | $this->payment = $payment instanceof EE_Payment ? $payment : $this->payment; |
@@ -1008,9 +1008,9 @@ discard block |
||
1008 | 1008 | $payment_method = $this->payment instanceof EE_Payment ? $this->payment->payment_method() : null; |
1009 | 1009 | $this->payment_method = $payment_method instanceof EE_Payment_Method ? $payment_method : $this->payment_method; |
1010 | 1010 | //now refresh the cart, based on the TXN |
1011 | - $this->cart = $this->get_cart_for_transaction( $this->transaction ); |
|
1011 | + $this->cart = $this->get_cart_for_transaction($this->transaction); |
|
1012 | 1012 | } else { |
1013 | - EE_Error::add_error( __( 'A valid Transaction was not found when attempting to update the model entity mapper.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
1013 | + EE_Error::add_error(__('A valid Transaction was not found when attempting to update the model entity mapper.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1014 | 1014 | return FALSE; |
1015 | 1015 | } |
1016 | 1016 | return TRUE; |
@@ -1025,21 +1025,21 @@ discard block |
||
1025 | 1025 | * @return EE_Attendee | null |
1026 | 1026 | * @throws \EE_Error |
1027 | 1027 | */ |
1028 | - protected function _refresh_primary_attendee_obj_from_db( EE_Transaction $transaction ) { |
|
1028 | + protected function _refresh_primary_attendee_obj_from_db(EE_Transaction $transaction) { |
|
1029 | 1029 | |
1030 | 1030 | $primary_attendee_obj = null; |
1031 | 1031 | // grab the saved registrations from the transaction |
1032 | - foreach ( $transaction->registrations( $this->reg_cache_where_params, true ) as $registration ) { |
|
1032 | + foreach ($transaction->registrations($this->reg_cache_where_params, true) as $registration) { |
|
1033 | 1033 | // verify object |
1034 | - if ( $registration instanceof EE_Registration ) { |
|
1034 | + if ($registration instanceof EE_Registration) { |
|
1035 | 1035 | $attendee = $registration->attendee(); |
1036 | 1036 | // verify object && maybe cache primary_attendee_obj ? |
1037 | - if ( $attendee instanceof EE_Attendee&& $registration->is_primary_registrant() ) { |
|
1037 | + if ($attendee instanceof EE_Attendee && $registration->is_primary_registrant()) { |
|
1038 | 1038 | $primary_attendee_obj = $attendee; |
1039 | 1039 | } |
1040 | 1040 | } else { |
1041 | 1041 | EE_Error::add_error( |
1042 | - __( 'An invalid Registration object was discovered when attempting to update the model entity mapper.', 'event_espresso' ), |
|
1042 | + __('An invalid Registration object was discovered when attempting to update the model entity mapper.', 'event_espresso'), |
|
1043 | 1043 | __FILE__, __FUNCTION__, __LINE__ |
1044 | 1044 | ); |
1045 | 1045 | } |
@@ -1060,43 +1060,43 @@ discard block |
||
1060 | 1060 | */ |
1061 | 1061 | protected function refresh_entity_map() { |
1062 | 1062 | // verify the transaction |
1063 | - if ( $this->transaction instanceof EE_Transaction && $this->transaction->ID() ) { |
|
1063 | + if ($this->transaction instanceof EE_Transaction && $this->transaction->ID()) { |
|
1064 | 1064 | // never cache payment info |
1065 | - $this->transaction->clear_cache( 'Payment' ); |
|
1065 | + $this->transaction->clear_cache('Payment'); |
|
1066 | 1066 | // is the Payment Options Reg Step completed ? |
1067 | - if ( $this->transaction->reg_step_completed( 'payment_options' ) ) { |
|
1067 | + if ($this->transaction->reg_step_completed('payment_options')) { |
|
1068 | 1068 | // then check for payments and update TXN accordingly |
1069 | 1069 | /** @type EE_Transaction_Payments $transaction_payments */ |
1070 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
1071 | - $transaction_payments->calculate_total_payments_and_update_status( $this->transaction ); |
|
1070 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
1071 | + $transaction_payments->calculate_total_payments_and_update_status($this->transaction); |
|
1072 | 1072 | } |
1073 | 1073 | // grab the saved registrations from the transaction |
1074 | 1074 | foreach ( |
1075 | - $this->transaction->registrations( $this->reg_cache_where_params ) as $reg_cache_ID => $registration |
|
1075 | + $this->transaction->registrations($this->reg_cache_where_params) as $reg_cache_ID => $registration |
|
1076 | 1076 | ) { |
1077 | - $this->_refresh_registration( $reg_cache_ID, $registration ); |
|
1077 | + $this->_refresh_registration($reg_cache_ID, $registration); |
|
1078 | 1078 | } |
1079 | 1079 | // make sure our cached TXN is added to the model entity mapper |
1080 | - $this->transaction = $this->transaction->get_model()->refresh_entity_map_with( $this->transaction->ID(), $this->transaction ); |
|
1080 | + $this->transaction = $this->transaction->get_model()->refresh_entity_map_with($this->transaction->ID(), $this->transaction); |
|
1081 | 1081 | |
1082 | 1082 | } else { |
1083 | - EE_Error::add_error( __( 'A valid Transaction was not found when attempting to update the model entity mapper.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
1083 | + EE_Error::add_error(__('A valid Transaction was not found when attempting to update the model entity mapper.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1084 | 1084 | return FALSE; |
1085 | 1085 | } |
1086 | 1086 | // verify and update the cart because inaccurate totals are not so much fun |
1087 | - if ( $this->cart instanceof EE_Cart ) { |
|
1087 | + if ($this->cart instanceof EE_Cart) { |
|
1088 | 1088 | $grand_total = $this->cart->get_grand_total(); |
1089 | - if ( $grand_total instanceof EE_Line_Item && $grand_total->ID() ) { |
|
1089 | + if ($grand_total instanceof EE_Line_Item && $grand_total->ID()) { |
|
1090 | 1090 | $grand_total->recalculate_total_including_taxes(); |
1091 | 1091 | $grand_total = $grand_total->get_model()->refresh_entity_map_with( |
1092 | 1092 | $this->cart->get_grand_total()->ID(), |
1093 | 1093 | $this->cart->get_grand_total() |
1094 | 1094 | ); |
1095 | 1095 | } |
1096 | - if ( $grand_total instanceof EE_Line_Item ) { |
|
1097 | - $this->cart = EE_Cart::instance( $grand_total ); |
|
1096 | + if ($grand_total instanceof EE_Line_Item) { |
|
1097 | + $this->cart = EE_Cart::instance($grand_total); |
|
1098 | 1098 | } else { |
1099 | - EE_Error::add_error( __( 'A valid Cart was not found when attempting to update the model entity mapper.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1099 | + EE_Error::add_error(__('A valid Cart was not found when attempting to update the model entity mapper.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1100 | 1100 | return false; |
1101 | 1101 | } |
1102 | 1102 | } |
@@ -1113,19 +1113,19 @@ discard block |
||
1113 | 1113 | * @return void |
1114 | 1114 | * @throws \EE_Error |
1115 | 1115 | */ |
1116 | - protected function _refresh_registration( $reg_cache_ID, $registration ) { |
|
1116 | + protected function _refresh_registration($reg_cache_ID, $registration) { |
|
1117 | 1117 | |
1118 | 1118 | // verify object |
1119 | - if ( $registration instanceof EE_Registration ) { |
|
1119 | + if ($registration instanceof EE_Registration) { |
|
1120 | 1120 | // update the entity mapper attendee |
1121 | - $this->_refresh_registration_attendee( $registration ); |
|
1121 | + $this->_refresh_registration_attendee($registration); |
|
1122 | 1122 | // update the entity mapper answers for reg form questions |
1123 | - $this->_refresh_registration_answers( $registration ); |
|
1123 | + $this->_refresh_registration_answers($registration); |
|
1124 | 1124 | // make sure the cached registration is added to the model entity mapper |
1125 | - $registration->get_model()->refresh_entity_map_with( $reg_cache_ID, $registration ); |
|
1125 | + $registration->get_model()->refresh_entity_map_with($reg_cache_ID, $registration); |
|
1126 | 1126 | } else { |
1127 | 1127 | EE_Error::add_error( |
1128 | - __( 'An invalid Registration object was discovered when attempting to update the model entity mapper.', 'event_espresso' ), |
|
1128 | + __('An invalid Registration object was discovered when attempting to update the model entity mapper.', 'event_espresso'), |
|
1129 | 1129 | __FILE__, __FUNCTION__, __LINE__ |
1130 | 1130 | ); |
1131 | 1131 | } |
@@ -1140,15 +1140,15 @@ discard block |
||
1140 | 1140 | * @return void |
1141 | 1141 | * @throws \EE_Error |
1142 | 1142 | */ |
1143 | - protected function _refresh_registration_attendee( $registration ) { |
|
1143 | + protected function _refresh_registration_attendee($registration) { |
|
1144 | 1144 | |
1145 | 1145 | $attendee = $registration->attendee(); |
1146 | 1146 | // verify object |
1147 | - if ( $attendee instanceof EE_Attendee && $attendee->ID() ) { |
|
1147 | + if ($attendee instanceof EE_Attendee && $attendee->ID()) { |
|
1148 | 1148 | // make sure the cached attendee is added to the model entity mapper |
1149 | - $registration->attendee()->get_model()->refresh_entity_map_with( $attendee->ID(), $attendee ); |
|
1149 | + $registration->attendee()->get_model()->refresh_entity_map_with($attendee->ID(), $attendee); |
|
1150 | 1150 | // maybe cache primary_attendee_obj ? |
1151 | - if ( $registration->is_primary_registrant() ) { |
|
1151 | + if ($registration->is_primary_registrant()) { |
|
1152 | 1152 | $this->primary_attendee_obj = $attendee; |
1153 | 1153 | } |
1154 | 1154 | } |
@@ -1163,19 +1163,19 @@ discard block |
||
1163 | 1163 | * @return void |
1164 | 1164 | * @throws \EE_Error |
1165 | 1165 | */ |
1166 | - protected function _refresh_registration_answers( $registration ) { |
|
1166 | + protected function _refresh_registration_answers($registration) { |
|
1167 | 1167 | |
1168 | 1168 | // now update the answers |
1169 | - foreach ( $registration->answers() as $cache_key => $answer ) { |
|
1169 | + foreach ($registration->answers() as $cache_key => $answer) { |
|
1170 | 1170 | // verify object |
1171 | - if ( $answer instanceof EE_Answer ) { |
|
1172 | - if ( $answer->ID() ) { |
|
1171 | + if ($answer instanceof EE_Answer) { |
|
1172 | + if ($answer->ID()) { |
|
1173 | 1173 | // make sure the cached answer is added to the model entity mapper |
1174 | - $answer->get_model()->refresh_entity_map_with( $answer->ID(), $answer ); |
|
1174 | + $answer->get_model()->refresh_entity_map_with($answer->ID(), $answer); |
|
1175 | 1175 | } |
1176 | 1176 | } else { |
1177 | 1177 | EE_Error::add_error( |
1178 | - __( 'An invalid Answer object was discovered when attempting to update the model entity mapper.', 'event_espresso' ), |
|
1178 | + __('An invalid Answer object was discovered when attempting to update the model entity mapper.', 'event_espresso'), |
|
1179 | 1179 | __FILE__, __FUNCTION__, __LINE__ |
1180 | 1180 | ); |
1181 | 1181 | } |
@@ -1190,7 +1190,7 @@ discard block |
||
1190 | 1190 | * this will reinstate the EE_Checkout object on each EE_SPCO_Reg_Step object |
1191 | 1191 | */ |
1192 | 1192 | public function __wakeup() { |
1193 | - foreach ( $this->reg_steps as $reg_step ) { |
|
1193 | + foreach ($this->reg_steps as $reg_step) { |
|
1194 | 1194 | $reg_step->checkout = $this; |
1195 | 1195 | } |
1196 | 1196 | } |
@@ -1207,12 +1207,12 @@ discard block |
||
1207 | 1207 | * @param bool $display_request |
1208 | 1208 | * @throws \EE_Error |
1209 | 1209 | */ |
1210 | - public function log( $class = '', $func = '', $line = '', $info = array(), $display_request = false ) { |
|
1210 | + public function log($class = '', $func = '', $line = '', $info = array(), $display_request = false) { |
|
1211 | 1211 | $disabled = true; |
1212 | - if ( WP_DEBUG && ! $disabled ) { |
|
1213 | - $debug_data = get_option( 'EE_DEBUG_SPCO_' . EE_Session::instance()->id(), array() ); |
|
1212 | + if (WP_DEBUG && ! $disabled) { |
|
1213 | + $debug_data = get_option('EE_DEBUG_SPCO_'.EE_Session::instance()->id(), array()); |
|
1214 | 1214 | $default_data = array( |
1215 | - $class => $func . '() : ' . $line, |
|
1215 | + $class => $func.'() : '.$line, |
|
1216 | 1216 | 'request->step' => $this->step, |
1217 | 1217 | 'request->action' => $this->action, |
1218 | 1218 | 'current_step->slug' => $this->current_step instanceof EE_SPCO_Reg_Step ? |
@@ -1224,24 +1224,24 @@ discard block |
||
1224 | 1224 | 'reg_url_link' => $this->reg_url_link, |
1225 | 1225 | 'REQ' => $display_request ? $_REQUEST : '', |
1226 | 1226 | ); |
1227 | - if ( $this->transaction instanceof EE_Transaction ) { |
|
1228 | - $default_data[ 'TXN_status' ] = $this->transaction->status_ID(); |
|
1229 | - $default_data[ 'TXN_reg_steps' ] = $this->transaction->reg_steps(); |
|
1230 | - foreach ( $this->transaction->registrations( $this->reg_cache_where_params ) as $REG_ID => $registration ) { |
|
1231 | - $default_data[ 'registrations' ][ $REG_ID ] = $registration->status_ID(); |
|
1227 | + if ($this->transaction instanceof EE_Transaction) { |
|
1228 | + $default_data['TXN_status'] = $this->transaction->status_ID(); |
|
1229 | + $default_data['TXN_reg_steps'] = $this->transaction->reg_steps(); |
|
1230 | + foreach ($this->transaction->registrations($this->reg_cache_where_params) as $REG_ID => $registration) { |
|
1231 | + $default_data['registrations'][$REG_ID] = $registration->status_ID(); |
|
1232 | 1232 | } |
1233 | - if ( $this->transaction->ID() ) { |
|
1234 | - $TXN_ID = 'EE_Transaction: ' . $this->transaction->ID(); |
|
1233 | + if ($this->transaction->ID()) { |
|
1234 | + $TXN_ID = 'EE_Transaction: '.$this->transaction->ID(); |
|
1235 | 1235 | // don't serialize objects |
1236 | - $info = $this->_strip_objects( $info ); |
|
1237 | - if ( ! isset( $debug_data[ $TXN_ID ] ) ) { |
|
1238 | - $debug_data[ $TXN_ID ] = array(); |
|
1236 | + $info = $this->_strip_objects($info); |
|
1237 | + if ( ! isset($debug_data[$TXN_ID])) { |
|
1238 | + $debug_data[$TXN_ID] = array(); |
|
1239 | 1239 | } |
1240 | - $debug_data[ $TXN_ID ][ microtime() ] = array_merge( |
|
1240 | + $debug_data[$TXN_ID][microtime()] = array_merge( |
|
1241 | 1241 | $default_data, |
1242 | 1242 | $info |
1243 | 1243 | ); |
1244 | - update_option( 'EE_DEBUG_SPCO_' . EE_Session::instance()->id(), $debug_data ); |
|
1244 | + update_option('EE_DEBUG_SPCO_'.EE_Session::instance()->id(), $debug_data); |
|
1245 | 1245 | } |
1246 | 1246 | } |
1247 | 1247 | } |
@@ -1254,23 +1254,23 @@ discard block |
||
1254 | 1254 | * @param array $info |
1255 | 1255 | * @return array |
1256 | 1256 | */ |
1257 | - public function _strip_objects( $info = array() ) { |
|
1258 | - foreach ( (array)$info as $key => $value ) { |
|
1259 | - if ( is_array( $value )) { |
|
1260 | - $info[ $key ] = $this->_strip_objects( $value ); |
|
1261 | - } else if ( is_object( $value ) ) { |
|
1262 | - $object_class = get_class( $value ); |
|
1263 | - $info[ $object_class ] = array(); |
|
1264 | - $info[ $object_class ][ 'ID' ] = method_exists( $value, 'ID' ) ? $value->ID() : 0; |
|
1265 | - if ( method_exists( $value, 'status' ) ) { |
|
1266 | - $info[ $object_class ][ 'status' ] = $value->status(); |
|
1267 | - } else if ( method_exists( $value, 'status_ID' ) ) { |
|
1268 | - $info[ $object_class ][ 'status' ] = $value->status_ID(); |
|
1257 | + public function _strip_objects($info = array()) { |
|
1258 | + foreach ((array) $info as $key => $value) { |
|
1259 | + if (is_array($value)) { |
|
1260 | + $info[$key] = $this->_strip_objects($value); |
|
1261 | + } else if (is_object($value)) { |
|
1262 | + $object_class = get_class($value); |
|
1263 | + $info[$object_class] = array(); |
|
1264 | + $info[$object_class]['ID'] = method_exists($value, 'ID') ? $value->ID() : 0; |
|
1265 | + if (method_exists($value, 'status')) { |
|
1266 | + $info[$object_class]['status'] = $value->status(); |
|
1267 | + } else if (method_exists($value, 'status_ID')) { |
|
1268 | + $info[$object_class]['status'] = $value->status_ID(); |
|
1269 | 1269 | } |
1270 | - unset( $info[ $key ] ); |
|
1270 | + unset($info[$key]); |
|
1271 | 1271 | } |
1272 | 1272 | } |
1273 | - return (array)$info; |
|
1273 | + return (array) $info; |
|
1274 | 1274 | } |
1275 | 1275 | |
1276 | 1276 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
2 | -EE_Registry::instance()->load_class( 'Processor_Base' ); |
|
2 | +EE_Registry::instance()->load_class('Processor_Base'); |
|
3 | 3 | /** |
4 | 4 | * |
5 | 5 | * EE_Payment_Processor |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public static function instance() { |
29 | 29 | // check if class object is instantiated |
30 | - if ( ! self::$_instance instanceof EE_Payment_Processor ) { |
|
30 | + if ( ! self::$_instance instanceof EE_Payment_Processor) { |
|
31 | 31 | self::$_instance = new self(); |
32 | 32 | } |
33 | 33 | return self::$_instance; |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | *@access private |
42 | 42 | */ |
43 | 43 | private function __construct() { |
44 | - do_action( 'AHEE__EE_Payment_Processor__construct' ); |
|
44 | + do_action('AHEE__EE_Payment_Processor__construct'); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | $update_txn = true, |
81 | 81 | $cancel_url = '' |
82 | 82 | ) { |
83 | - if( (float)$amount < 0 ) { |
|
83 | + if ((float) $amount < 0) { |
|
84 | 84 | throw new EE_Error( |
85 | 85 | sprintf( |
86 | 86 | __( |
@@ -93,33 +93,33 @@ discard block |
||
93 | 93 | ); |
94 | 94 | } |
95 | 95 | // verify payment method |
96 | - $payment_method = EEM_Payment_Method::instance()->ensure_is_obj( $payment_method, TRUE ); |
|
96 | + $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method, TRUE); |
|
97 | 97 | // verify transaction |
98 | - EEM_Transaction::instance()->ensure_is_obj( $transaction ); |
|
99 | - $transaction->set_payment_method_ID( $payment_method->ID() ); |
|
98 | + EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
99 | + $transaction->set_payment_method_ID($payment_method->ID()); |
|
100 | 100 | // verify payment method type |
101 | - if ( $payment_method->type_obj() instanceof EE_PMT_Base ) { |
|
101 | + if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
|
102 | 102 | $payment = $payment_method->type_obj()->process_payment( |
103 | 103 | $transaction, |
104 | - min( $amount, $transaction->remaining() ),//make sure we don't overcharge |
|
104 | + min($amount, $transaction->remaining()), //make sure we don't overcharge |
|
105 | 105 | $billing_form, |
106 | 106 | $return_url, |
107 | - add_query_arg( array( 'ee_cancel_payment' => true ), $cancel_url ), |
|
107 | + add_query_arg(array('ee_cancel_payment' => true), $cancel_url), |
|
108 | 108 | $method, |
109 | 109 | $by_admin |
110 | 110 | ); |
111 | 111 | // check if payment method uses an off-site gateway |
112 | - if ( $payment_method->type_obj()->payment_occurs() !== EE_PMT_Base::offsite ) { |
|
112 | + if ($payment_method->type_obj()->payment_occurs() !== EE_PMT_Base::offsite) { |
|
113 | 113 | // don't process payments for off-site gateways yet because no payment has occurred yet |
114 | - $this->update_txn_based_on_payment( $transaction, $payment, $update_txn ); |
|
114 | + $this->update_txn_based_on_payment($transaction, $payment, $update_txn); |
|
115 | 115 | } |
116 | 116 | return $payment; |
117 | 117 | } else { |
118 | 118 | EE_Error::add_error( |
119 | 119 | sprintf( |
120 | - __( 'A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ), |
|
120 | + __('A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'), |
|
121 | 121 | '<br/>', |
122 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
122 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
123 | 123 | ), __FILE__, __FUNCTION__, __LINE__ |
124 | 124 | ); |
125 | 125 | return NULL; |
@@ -135,11 +135,11 @@ discard block |
||
135 | 135 | * @throws EE_Error |
136 | 136 | * @return string |
137 | 137 | */ |
138 | - public function get_ipn_url_for_payment_method( $transaction, $payment_method ){ |
|
138 | + public function get_ipn_url_for_payment_method($transaction, $payment_method) { |
|
139 | 139 | /** @type \EE_Transaction $transaction */ |
140 | - $transaction = EEM_Transaction::instance()->ensure_is_obj( $transaction ); |
|
140 | + $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
141 | 141 | $primary_reg = $transaction->primary_registration(); |
142 | - if( ! $primary_reg instanceof EE_Registration ){ |
|
142 | + if ( ! $primary_reg instanceof EE_Registration) { |
|
143 | 143 | throw new EE_Error( |
144 | 144 | sprintf( |
145 | 145 | __( |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | ) |
151 | 151 | ); |
152 | 152 | } |
153 | - $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method,true); |
|
153 | + $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method, true); |
|
154 | 154 | $url = add_query_arg( |
155 | 155 | array( |
156 | 156 | 'e_reg_url_link'=>$primary_reg->reg_url_link(), |
@@ -187,92 +187,92 @@ discard block |
||
187 | 187 | $update_txn = true, |
188 | 188 | $separate_IPN_request = true |
189 | 189 | ) { |
190 | - EE_Registry::instance()->load_model( 'Change_Log' ); |
|
191 | - $_req_data = $this->_remove_unusable_characters_from_array( (array)$_req_data ); |
|
192 | - EE_Processor_Base::set_IPN( $separate_IPN_request ); |
|
190 | + EE_Registry::instance()->load_model('Change_Log'); |
|
191 | + $_req_data = $this->_remove_unusable_characters_from_array((array) $_req_data); |
|
192 | + EE_Processor_Base::set_IPN($separate_IPN_request); |
|
193 | 193 | $obj_for_log = null; |
194 | - if( $transaction instanceof EE_Transaction ){ |
|
194 | + if ($transaction instanceof EE_Transaction) { |
|
195 | 195 | $obj_for_log = $transaction; |
196 | - if( $payment_method instanceof EE_Payment_Method ) { |
|
196 | + if ($payment_method instanceof EE_Payment_Method) { |
|
197 | 197 | $obj_for_log = EEM_Payment::instance()->get_one( |
198 | 198 | array( |
199 | - array( 'TXN_ID' => $transaction->ID(), 'PMD_ID' => $payment_method->ID() ), |
|
200 | - 'order_by' => array( 'PAY_timestamp' => 'desc' ) |
|
199 | + array('TXN_ID' => $transaction->ID(), 'PMD_ID' => $payment_method->ID()), |
|
200 | + 'order_by' => array('PAY_timestamp' => 'desc') |
|
201 | 201 | ) |
202 | 202 | ); |
203 | 203 | } |
204 | - } else if( $payment_method instanceof EE_Payment ) { |
|
204 | + } else if ($payment_method instanceof EE_Payment) { |
|
205 | 205 | $obj_for_log = $payment_method; |
206 | 206 | } |
207 | 207 | $log = EEM_Change_Log::instance()->log( |
208 | 208 | EEM_Change_Log::type_gateway, |
209 | - array( 'IPN data received' => $_req_data ), |
|
209 | + array('IPN data received' => $_req_data), |
|
210 | 210 | $obj_for_log |
211 | 211 | ); |
212 | - try{ |
|
212 | + try { |
|
213 | 213 | /** |
214 | 214 | * @var EE_Payment $payment |
215 | 215 | */ |
216 | 216 | $payment = NULL; |
217 | - if($transaction && $payment_method){ |
|
217 | + if ($transaction && $payment_method) { |
|
218 | 218 | /** @type EE_Transaction $transaction */ |
219 | 219 | $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
220 | 220 | /** @type EE_Payment_Method $payment_method */ |
221 | 221 | $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method); |
222 | - if ( $payment_method->type_obj() instanceof EE_PMT_Base ) { |
|
223 | - $payment = $payment_method->type_obj()->handle_ipn( $_req_data, $transaction ); |
|
222 | + if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
|
223 | + $payment = $payment_method->type_obj()->handle_ipn($_req_data, $transaction); |
|
224 | 224 | $log->set_object($payment); |
225 | 225 | } else { |
226 | 226 | // not a payment |
227 | 227 | EE_Error::add_error( |
228 | 228 | sprintf( |
229 | - __( 'A valid payment method could not be determined due to a technical issue.%sPlease refresh your browser and try again or contact %s for assistance.', 'event_espresso' ), |
|
229 | + __('A valid payment method could not be determined due to a technical issue.%sPlease refresh your browser and try again or contact %s for assistance.', 'event_espresso'), |
|
230 | 230 | '<br/>', |
231 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
231 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
232 | 232 | ), |
233 | 233 | __FILE__, __FUNCTION__, __LINE__ |
234 | 234 | ); |
235 | 235 | } |
236 | - }else{ |
|
236 | + } else { |
|
237 | 237 | //that's actually pretty ok. The IPN just wasn't able |
238 | 238 | //to identify which transaction or payment method this was for |
239 | 239 | // give all active payment methods a chance to claim it |
240 | 240 | $active_payment_methods = EEM_Payment_Method::instance()->get_all_active(); |
241 | - foreach( $active_payment_methods as $active_payment_method ){ |
|
242 | - try{ |
|
243 | - $payment = $active_payment_method->type_obj()->handle_unclaimed_ipn( $_req_data ); |
|
241 | + foreach ($active_payment_methods as $active_payment_method) { |
|
242 | + try { |
|
243 | + $payment = $active_payment_method->type_obj()->handle_unclaimed_ipn($_req_data); |
|
244 | 244 | $payment_method = $active_payment_method; |
245 | 245 | EEM_Change_Log::instance()->log( |
246 | 246 | EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $payment |
247 | 247 | ); |
248 | 248 | break; |
249 | - } catch( EE_Error $e ) { |
|
249 | + } catch (EE_Error $e) { |
|
250 | 250 | //that's fine- it apparently couldn't handle the IPN |
251 | 251 | } |
252 | 252 | } |
253 | 253 | |
254 | 254 | } |
255 | 255 | // EEM_Payment_Log::instance()->log("got to 7",$transaction,$payment_method); |
256 | - if( $payment instanceof EE_Payment){ |
|
256 | + if ($payment instanceof EE_Payment) { |
|
257 | 257 | $payment->save(); |
258 | 258 | // update the TXN |
259 | - $this->update_txn_based_on_payment( $transaction, $payment, $update_txn, $separate_IPN_request ); |
|
260 | - }else{ |
|
259 | + $this->update_txn_based_on_payment($transaction, $payment, $update_txn, $separate_IPN_request); |
|
260 | + } else { |
|
261 | 261 | //we couldn't find the payment for this IPN... let's try and log at least SOMETHING |
262 | - if($payment_method){ |
|
262 | + if ($payment_method) { |
|
263 | 263 | EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $payment_method); |
264 | - }elseif($transaction){ |
|
264 | + }elseif ($transaction) { |
|
265 | 265 | EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $transaction); |
266 | 266 | } |
267 | 267 | } |
268 | 268 | return $payment; |
269 | 269 | |
270 | - } catch( EE_Error $e ) { |
|
270 | + } catch (EE_Error $e) { |
|
271 | 271 | do_action( |
272 | 272 | 'AHEE__log', __FILE__, __FUNCTION__, sprintf( |
273 | - __( 'Error occurred while receiving IPN. Transaction: %1$s, req data: %2$s. The error was "%3$s"', 'event_espresso' ), |
|
274 | - print_r( $transaction, TRUE ), |
|
275 | - print_r( $_req_data, TRUE ), |
|
273 | + __('Error occurred while receiving IPN. Transaction: %1$s, req data: %2$s. The error was "%3$s"', 'event_espresso'), |
|
274 | + print_r($transaction, TRUE), |
|
275 | + print_r($_req_data, TRUE), |
|
276 | 276 | $e->getMessage() |
277 | 277 | ) |
278 | 278 | ); |
@@ -287,10 +287,10 @@ discard block |
||
287 | 287 | * @param array $request_data |
288 | 288 | * @return array |
289 | 289 | */ |
290 | - protected function _remove_unusable_characters_from_array( array $request_data ) { |
|
290 | + protected function _remove_unusable_characters_from_array(array $request_data) { |
|
291 | 291 | $return_data = array(); |
292 | - foreach( $request_data as $key => $value ) { |
|
293 | - $return_data[ $this->_remove_unusable_characters( $key ) ] = $this->_remove_unusable_characters( $value ); |
|
292 | + foreach ($request_data as $key => $value) { |
|
293 | + $return_data[$this->_remove_unusable_characters($key)] = $this->_remove_unusable_characters($value); |
|
294 | 294 | } |
295 | 295 | return $return_data; |
296 | 296 | } |
@@ -302,8 +302,8 @@ discard block |
||
302 | 302 | * @param string $request_data |
303 | 303 | * @return string |
304 | 304 | */ |
305 | - protected function _remove_unusable_characters( $request_data ) { |
|
306 | - return preg_replace( '/[^[:print:]]/', '', $request_data ); |
|
305 | + protected function _remove_unusable_characters($request_data) { |
|
306 | + return preg_replace('/[^[:print:]]/', '', $request_data); |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | |
@@ -325,13 +325,13 @@ discard block |
||
325 | 325 | * @deprecated 4.6.24 method is no longer used. Instead it is up to client code, like SPCO, |
326 | 326 | * to call handle_ipn() for offsite gateways that don't receive separate IPNs |
327 | 327 | */ |
328 | - public function finalize_payment_for( $transaction, $update_txn = TRUE ){ |
|
328 | + public function finalize_payment_for($transaction, $update_txn = TRUE) { |
|
329 | 329 | /** @var $transaction EE_Transaction */ |
330 | - $transaction = EEM_Transaction::instance()->ensure_is_obj( $transaction ); |
|
330 | + $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
331 | 331 | $last_payment_method = $transaction->payment_method(); |
332 | - if ( $last_payment_method instanceof EE_Payment_Method ) { |
|
333 | - $payment = $last_payment_method->type_obj()->finalize_payment_for( $transaction ); |
|
334 | - $this->update_txn_based_on_payment( $transaction, $payment, $update_txn ); |
|
332 | + if ($last_payment_method instanceof EE_Payment_Method) { |
|
333 | + $payment = $last_payment_method->type_obj()->finalize_payment_for($transaction); |
|
334 | + $this->update_txn_based_on_payment($transaction, $payment, $update_txn); |
|
335 | 335 | return $payment; |
336 | 336 | } else { |
337 | 337 | return NULL; |
@@ -354,9 +354,9 @@ discard block |
||
354 | 354 | EE_Payment $payment_to_refund, |
355 | 355 | $refund_info = array() |
356 | 356 | ) { |
357 | - if ( $payment_method instanceof EE_Payment_Method && $payment_method->type_obj()->supports_sending_refunds() ) { |
|
358 | - $payment_method->type_obj()->process_refund( $payment_to_refund, $refund_info ); |
|
359 | - $this->update_txn_based_on_payment( $payment_to_refund->transaction(), $payment_to_refund ); |
|
357 | + if ($payment_method instanceof EE_Payment_Method && $payment_method->type_obj()->supports_sending_refunds()) { |
|
358 | + $payment_method->type_obj()->process_refund($payment_to_refund, $refund_info); |
|
359 | + $this->update_txn_based_on_payment($payment_to_refund->transaction(), $payment_to_refund); |
|
360 | 360 | } |
361 | 361 | return $payment_to_refund; |
362 | 362 | } |
@@ -397,12 +397,12 @@ discard block |
||
397 | 397 | * TXN is locked before updating |
398 | 398 | * @throws \EE_Error |
399 | 399 | */ |
400 | - public function update_txn_based_on_payment( $transaction, $payment, $update_txn = true, $IPN = false ){ |
|
400 | + public function update_txn_based_on_payment($transaction, $payment, $update_txn = true, $IPN = false) { |
|
401 | 401 | $do_action = 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__not_successful'; |
402 | 402 | /** @type EE_Transaction $transaction */ |
403 | - $transaction = EEM_Transaction::instance()->ensure_is_obj( $transaction ); |
|
403 | + $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
404 | 404 | // can we freely update the TXN at this moment? |
405 | - if ( $IPN && $transaction->is_locked() ) { |
|
405 | + if ($IPN && $transaction->is_locked()) { |
|
406 | 406 | // don't update the transaction at this exact moment |
407 | 407 | // because the TXN is active in another request |
408 | 408 | EE_Cron_Tasks::schedule_update_transaction_with_payment( |
@@ -412,38 +412,38 @@ discard block |
||
412 | 412 | ); |
413 | 413 | } else { |
414 | 414 | // verify payment and that it has been saved |
415 | - if ( $payment instanceof EE_Payment && $payment->ID() ) { |
|
416 | - if( |
|
415 | + if ($payment instanceof EE_Payment && $payment->ID()) { |
|
416 | + if ( |
|
417 | 417 | $payment->payment_method() instanceof EE_Payment_Method |
418 | 418 | && $payment->payment_method()->type_obj() instanceof EE_PMT_Base |
419 | - ){ |
|
420 | - $payment->payment_method()->type_obj()->update_txn_based_on_payment( $payment ); |
|
419 | + ) { |
|
420 | + $payment->payment_method()->type_obj()->update_txn_based_on_payment($payment); |
|
421 | 421 | // update TXN registrations with payment info |
422 | - $this->process_registration_payments( $transaction, $payment ); |
|
422 | + $this->process_registration_payments($transaction, $payment); |
|
423 | 423 | } |
424 | 424 | $do_action = $payment->just_approved() |
425 | 425 | ? 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__successful' |
426 | 426 | : $do_action; |
427 | 427 | } else { |
428 | 428 | // send out notifications |
429 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true' ); |
|
429 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true'); |
|
430 | 430 | $do_action = 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__no_payment_made'; |
431 | 431 | } |
432 | - if ( $payment->status() !== EEM_Payment::status_id_failed ) { |
|
432 | + if ($payment->status() !== EEM_Payment::status_id_failed) { |
|
433 | 433 | /** @type EE_Transaction_Payments $transaction_payments */ |
434 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
434 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
435 | 435 | // set new value for total paid |
436 | - $transaction_payments->calculate_total_payments_and_update_status( $transaction ); |
|
436 | + $transaction_payments->calculate_total_payments_and_update_status($transaction); |
|
437 | 437 | // call EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment() ??? |
438 | - if ( $update_txn ) { |
|
439 | - $this->_post_payment_processing( $transaction, $payment, $IPN ); |
|
438 | + if ($update_txn) { |
|
439 | + $this->_post_payment_processing($transaction, $payment, $IPN); |
|
440 | 440 | } |
441 | 441 | } |
442 | 442 | // granular hook for others to use. |
443 | - do_action( $do_action, $transaction, $payment ); |
|
444 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $do_action, '$do_action' ); |
|
443 | + do_action($do_action, $transaction, $payment); |
|
444 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $do_action, '$do_action'); |
|
445 | 445 | //global hook for others to use. |
446 | - do_action( 'AHEE__EE_Payment_Processor__update_txn_based_on_payment', $transaction, $payment ); |
|
446 | + do_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', $transaction, $payment); |
|
447 | 447 | } |
448 | 448 | } |
449 | 449 | |
@@ -463,25 +463,25 @@ discard block |
||
463 | 463 | $registrations = array() |
464 | 464 | ) { |
465 | 465 | // only process if payment was successful |
466 | - if ( $payment->status() !== EEM_Payment::status_id_approved ) { |
|
466 | + if ($payment->status() !== EEM_Payment::status_id_approved) { |
|
467 | 467 | return; |
468 | 468 | } |
469 | 469 | //EEM_Registration::instance()->show_next_x_db_queries(); |
470 | - if ( empty( $registrations )) { |
|
470 | + if (empty($registrations)) { |
|
471 | 471 | // find registrations with monies owing that can receive a payment |
472 | 472 | $registrations = $transaction->registrations( |
473 | 473 | array( |
474 | 474 | array( |
475 | 475 | // only these reg statuses can receive payments |
476 | - 'STS_ID' => array( 'IN', EEM_Registration::reg_statuses_that_allow_payment() ), |
|
477 | - 'REG_final_price' => array( '!=', 0 ), |
|
478 | - 'REG_final_price*' => array( '!=', 'REG_paid', true ), |
|
476 | + 'STS_ID' => array('IN', EEM_Registration::reg_statuses_that_allow_payment()), |
|
477 | + 'REG_final_price' => array('!=', 0), |
|
478 | + 'REG_final_price*' => array('!=', 'REG_paid', true), |
|
479 | 479 | ) |
480 | 480 | ) |
481 | 481 | ); |
482 | 482 | } |
483 | 483 | // still nothing ??!?? |
484 | - if ( empty( $registrations )) { |
|
484 | + if (empty($registrations)) { |
|
485 | 485 | return; |
486 | 486 | } |
487 | 487 | // todo: break out the following logic into a separate strategy class |
@@ -493,28 +493,28 @@ discard block |
||
493 | 493 | |
494 | 494 | $refund = $payment->is_a_refund(); |
495 | 495 | // how much is available to apply to registrations? |
496 | - $available_payment_amount = abs( $payment->amount() ); |
|
497 | - foreach ( $registrations as $registration ) { |
|
498 | - if ( $registration instanceof EE_Registration ) { |
|
496 | + $available_payment_amount = abs($payment->amount()); |
|
497 | + foreach ($registrations as $registration) { |
|
498 | + if ($registration instanceof EE_Registration) { |
|
499 | 499 | // nothing left? |
500 | - if ( $available_payment_amount <= 0 ) { |
|
500 | + if ($available_payment_amount <= 0) { |
|
501 | 501 | break; |
502 | 502 | } |
503 | - if ( $refund ) { |
|
504 | - $available_payment_amount = $this->process_registration_refund( $registration, $payment, $available_payment_amount ); |
|
503 | + if ($refund) { |
|
504 | + $available_payment_amount = $this->process_registration_refund($registration, $payment, $available_payment_amount); |
|
505 | 505 | } else { |
506 | - $available_payment_amount = $this->process_registration_payment( $registration, $payment, $available_payment_amount ); |
|
506 | + $available_payment_amount = $this->process_registration_payment($registration, $payment, $available_payment_amount); |
|
507 | 507 | } |
508 | 508 | } |
509 | 509 | } |
510 | - if ( $available_payment_amount > 0 && apply_filters( 'FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', false ) ) { |
|
510 | + if ($available_payment_amount > 0 && apply_filters('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', false)) { |
|
511 | 511 | EE_Error::add_attention( |
512 | 512 | sprintf( |
513 | - __( 'A remainder of %1$s exists after applying this payment to Registration(s) %2$s.%3$sPlease verify that the original payment amount of %4$s is correct. If so, you should edit this payment and select at least one additional registration in the "Registrations to Apply Payment to" section, so that the remainder of this payment can be applied to the additional registration(s).', 'event_espresso' ), |
|
514 | - EEH_Template::format_currency( $available_payment_amount ), |
|
515 | - implode( ', ', array_keys( $registrations ) ), |
|
513 | + __('A remainder of %1$s exists after applying this payment to Registration(s) %2$s.%3$sPlease verify that the original payment amount of %4$s is correct. If so, you should edit this payment and select at least one additional registration in the "Registrations to Apply Payment to" section, so that the remainder of this payment can be applied to the additional registration(s).', 'event_espresso'), |
|
514 | + EEH_Template::format_currency($available_payment_amount), |
|
515 | + implode(', ', array_keys($registrations)), |
|
516 | 516 | '<br/>', |
517 | - EEH_Template::format_currency( $payment->amount() ) |
|
517 | + EEH_Template::format_currency($payment->amount()) |
|
518 | 518 | ), |
519 | 519 | __FILE__, __FUNCTION__, __LINE__ |
520 | 520 | ); |
@@ -532,17 +532,17 @@ discard block |
||
532 | 532 | * @return float |
533 | 533 | * @throws \EE_Error |
534 | 534 | */ |
535 | - public function process_registration_payment( EE_Registration $registration, EE_Payment $payment, $available_payment_amount = 0.00 ) { |
|
535 | + public function process_registration_payment(EE_Registration $registration, EE_Payment $payment, $available_payment_amount = 0.00) { |
|
536 | 536 | $owing = $registration->final_price() - $registration->paid(); |
537 | - if ( $owing > 0 ) { |
|
537 | + if ($owing > 0) { |
|
538 | 538 | // don't allow payment amount to exceed the available payment amount, OR the amount owing |
539 | - $payment_amount = min( $available_payment_amount, $owing ); |
|
539 | + $payment_amount = min($available_payment_amount, $owing); |
|
540 | 540 | // update $available_payment_amount |
541 | 541 | $available_payment_amount -= $payment_amount; |
542 | 542 | //calculate and set new REG_paid |
543 | - $registration->set_paid( $registration->paid() + $payment_amount ); |
|
543 | + $registration->set_paid($registration->paid() + $payment_amount); |
|
544 | 544 | // now save it |
545 | - $this->_apply_registration_payment( $registration, $payment, $payment_amount ); |
|
545 | + $this->_apply_registration_payment($registration, $payment, $payment_amount); |
|
546 | 546 | } |
547 | 547 | return $available_payment_amount; |
548 | 548 | } |
@@ -558,19 +558,19 @@ discard block |
||
558 | 558 | * @return void |
559 | 559 | * @throws \EE_Error |
560 | 560 | */ |
561 | - protected function _apply_registration_payment( EE_Registration $registration, EE_Payment $payment, $payment_amount = 0.00 ) { |
|
561 | + protected function _apply_registration_payment(EE_Registration $registration, EE_Payment $payment, $payment_amount = 0.00) { |
|
562 | 562 | // find any existing reg payment records for this registration and payment |
563 | 563 | $existing_reg_payment = EEM_Registration_Payment::instance()->get_one( |
564 | - array( array( 'REG_ID' => $registration->ID(), 'PAY_ID' => $payment->ID() ) ) |
|
564 | + array(array('REG_ID' => $registration->ID(), 'PAY_ID' => $payment->ID())) |
|
565 | 565 | ); |
566 | 566 | // if existing registration payment exists |
567 | - if ( $existing_reg_payment instanceof EE_Registration_Payment ) { |
|
567 | + if ($existing_reg_payment instanceof EE_Registration_Payment) { |
|
568 | 568 | // then update that record |
569 | - $existing_reg_payment->set_amount( $payment_amount ); |
|
569 | + $existing_reg_payment->set_amount($payment_amount); |
|
570 | 570 | $existing_reg_payment->save(); |
571 | 571 | } else { |
572 | 572 | // or add new relation between registration and payment and set amount |
573 | - $registration->_add_relation_to( $payment, 'Payment', array( 'RPY_amount' => $payment_amount ) ); |
|
573 | + $registration->_add_relation_to($payment, 'Payment', array('RPY_amount' => $payment_amount)); |
|
574 | 574 | // make it stick |
575 | 575 | $registration->save(); |
576 | 576 | } |
@@ -587,21 +587,21 @@ discard block |
||
587 | 587 | * @return float |
588 | 588 | * @throws \EE_Error |
589 | 589 | */ |
590 | - public function process_registration_refund( EE_Registration $registration, EE_Payment $payment, $available_refund_amount = 0.00 ) { |
|
590 | + public function process_registration_refund(EE_Registration $registration, EE_Payment $payment, $available_refund_amount = 0.00) { |
|
591 | 591 | //EEH_Debug_Tools::printr( $payment->amount(), '$payment->amount()', __FILE__, __LINE__ ); |
592 | - if ( $registration->paid() > 0 ) { |
|
592 | + if ($registration->paid() > 0) { |
|
593 | 593 | // ensure $available_refund_amount is NOT negative |
594 | - $available_refund_amount = (float)abs( $available_refund_amount ); |
|
594 | + $available_refund_amount = (float) abs($available_refund_amount); |
|
595 | 595 | // don't allow refund amount to exceed the available payment amount, OR the amount paid |
596 | - $refund_amount = min( $available_refund_amount, (float)$registration->paid() ); |
|
596 | + $refund_amount = min($available_refund_amount, (float) $registration->paid()); |
|
597 | 597 | // update $available_payment_amount |
598 | 598 | $available_refund_amount -= $refund_amount; |
599 | 599 | //calculate and set new REG_paid |
600 | - $registration->set_paid( $registration->paid() - $refund_amount ); |
|
600 | + $registration->set_paid($registration->paid() - $refund_amount); |
|
601 | 601 | // convert payment amount back to a negative value for storage in the db |
602 | - $refund_amount = (float)abs( $refund_amount ) * -1; |
|
602 | + $refund_amount = (float) abs($refund_amount) * -1; |
|
603 | 603 | // now save it |
604 | - $this->_apply_registration_payment( $registration, $payment, $refund_amount ); |
|
604 | + $this->_apply_registration_payment($registration, $payment, $refund_amount); |
|
605 | 605 | } |
606 | 606 | return $available_refund_amount; |
607 | 607 | } |
@@ -620,53 +620,53 @@ discard block |
||
620 | 620 | * @param bool $IPN |
621 | 621 | * @throws \EE_Error |
622 | 622 | */ |
623 | - protected function _post_payment_processing( EE_Transaction $transaction, EE_Payment $payment, $IPN = false ) { |
|
623 | + protected function _post_payment_processing(EE_Transaction $transaction, EE_Payment $payment, $IPN = false) { |
|
624 | 624 | |
625 | 625 | /** @type EE_Transaction_Processor $transaction_processor */ |
626 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
626 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
627 | 627 | // is the Payment Options Reg Step completed ? |
628 | - $payment_options_step_completed = $transaction->reg_step_completed( 'payment_options' ); |
|
628 | + $payment_options_step_completed = $transaction->reg_step_completed('payment_options'); |
|
629 | 629 | // if the Payment Options Reg Step is completed... |
630 | 630 | $revisit = $payment_options_step_completed === true ? true : false; |
631 | 631 | // then this is kinda sorta a revisit with regards to payments at least |
632 | - $transaction_processor->set_revisit( $revisit ); |
|
632 | + $transaction_processor->set_revisit($revisit); |
|
633 | 633 | // if this is an IPN, let's consider the Payment Options Reg Step completed if not already |
634 | 634 | if ( |
635 | 635 | $IPN && |
636 | 636 | $payment_options_step_completed !== true && |
637 | - ( $payment->is_approved() || $payment->is_pending() ) |
|
637 | + ($payment->is_approved() || $payment->is_pending()) |
|
638 | 638 | ) { |
639 | 639 | $payment_options_step_completed = $transaction->set_reg_step_completed( |
640 | 640 | 'payment_options' |
641 | 641 | ); |
642 | 642 | } |
643 | 643 | // maybe update status, but don't save transaction just yet |
644 | - $transaction->update_status_based_on_total_paid( false ); |
|
644 | + $transaction->update_status_based_on_total_paid(false); |
|
645 | 645 | // check if 'finalize_registration' step has been completed... |
646 | - $finalized = $transaction->reg_step_completed( 'finalize_registration' ); |
|
646 | + $finalized = $transaction->reg_step_completed('finalize_registration'); |
|
647 | 647 | // if this is an IPN and the final step has not been initiated |
648 | - if ( $IPN && $payment_options_step_completed && $finalized === false ) { |
|
648 | + if ($IPN && $payment_options_step_completed && $finalized === false) { |
|
649 | 649 | // and if it hasn't already been set as being started... |
650 | - $finalized = $transaction->set_reg_step_initiated( 'finalize_registration' ); |
|
650 | + $finalized = $transaction->set_reg_step_initiated('finalize_registration'); |
|
651 | 651 | } |
652 | 652 | $transaction->save(); |
653 | 653 | // because the above will return false if the final step was not fully completed, we need to check again... |
654 | - if ( $IPN && $finalized !== false ) { |
|
654 | + if ($IPN && $finalized !== false) { |
|
655 | 655 | // and if we are all good to go, then send out notifications |
656 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true' ); |
|
656 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true'); |
|
657 | 657 | //ok, now process the transaction according to the payment |
658 | - $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( $transaction, $payment ); |
|
658 | + $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment($transaction, $payment); |
|
659 | 659 | } |
660 | 660 | // DEBUG LOG |
661 | 661 | $payment_method = $payment->payment_method(); |
662 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
662 | + if ($payment_method instanceof EE_Payment_Method) { |
|
663 | 663 | $payment_method_type_obj = $payment_method->type_obj(); |
664 | - if ( $payment_method_type_obj instanceof EE_PMT_Base ) { |
|
664 | + if ($payment_method_type_obj instanceof EE_PMT_Base) { |
|
665 | 665 | $gateway = $payment_method_type_obj->get_gateway(); |
666 | - if ( $gateway instanceof EE_Gateway ){ |
|
666 | + if ($gateway instanceof EE_Gateway) { |
|
667 | 667 | $gateway->log( |
668 | 668 | array( |
669 | - 'message' => __( 'Post Payment Transaction Details', 'event_espresso' ), |
|
669 | + 'message' => __('Post Payment Transaction Details', 'event_espresso'), |
|
670 | 670 | 'transaction' => $transaction->model_field_array(), |
671 | 671 | 'finalized' => $finalized, |
672 | 672 | 'IPN' => $IPN, |
@@ -13,9 +13,9 @@ discard block |
||
13 | 13 | */ |
14 | 14 | class EE_Payment_Processor extends EE_Processor_Base { |
15 | 15 | /** |
16 | - * @var EE_Payment_Processor $_instance |
|
16 | + * @var EE_Payment_Processor $_instance |
|
17 | 17 | * @access private |
18 | - */ |
|
18 | + */ |
|
19 | 19 | private static $_instance; |
20 | 20 | |
21 | 21 | |
@@ -50,7 +50,6 @@ discard block |
||
50 | 50 | /** |
51 | 51 | * Using the selected gateway, processes the payment for that transaction, and updates the transaction appropriately. |
52 | 52 | * Saves the payment that is generated |
53 | - |
|
54 | 53 | * |
55 | 54 | *@param EE_Payment_Method $payment_method |
56 | 55 | * @param EE_Transaction $transaction |
@@ -130,7 +129,6 @@ discard block |
||
130 | 129 | |
131 | 130 | |
132 | 131 | /** |
133 | - |
|
134 | 132 | * @param EE_Transaction|int $transaction |
135 | 133 | * @param EE_Payment_Method $payment_method |
136 | 134 | * @throws EE_Error |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
2 | -EE_Registry::instance()->load_class( 'Processor_Base' ); |
|
2 | +EE_Registry::instance()->load_class('Processor_Base'); |
|
3 | 3 | |
4 | 4 | /** |
5 | 5 | * Class EE_Transaction_Processor |
@@ -50,10 +50,10 @@ discard block |
||
50 | 50 | * @param array $registration_query_params |
51 | 51 | *@return EE_Transaction_Processor instance |
52 | 52 | */ |
53 | - public static function instance( $registration_query_params = array() ) { |
|
53 | + public static function instance($registration_query_params = array()) { |
|
54 | 54 | // check if class object is instantiated |
55 | - if ( ! self::$_instance instanceof EE_Transaction_Processor ) { |
|
56 | - self::$_instance = new self( $registration_query_params ); |
|
55 | + if ( ! self::$_instance instanceof EE_Transaction_Processor) { |
|
56 | + self::$_instance = new self($registration_query_params); |
|
57 | 57 | } |
58 | 58 | return self::$_instance; |
59 | 59 | } |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | /** |
64 | 64 | * @param array $registration_query_params |
65 | 65 | */ |
66 | - private function __construct( $registration_query_params = array() ) { |
|
66 | + private function __construct($registration_query_params = array()) { |
|
67 | 67 | // make sure some query params are set for retrieving registrations |
68 | - $this->_set_registration_query_params( $registration_query_params ); |
|
68 | + $this->_set_registration_query_params($registration_query_params); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | |
@@ -74,8 +74,8 @@ discard block |
||
74 | 74 | * @access private |
75 | 75 | * @param array $registration_query_params |
76 | 76 | */ |
77 | - private function _set_registration_query_params( $registration_query_params ) { |
|
78 | - $this->_registration_query_params = ! empty( $registration_query_params ) ? $registration_query_params : array( 'order_by' => array( 'REG_count' => 'ASC' )); |
|
77 | + private function _set_registration_query_params($registration_query_params) { |
|
78 | + $this->_registration_query_params = ! empty($registration_query_params) ? $registration_query_params : array('order_by' => array('REG_count' => 'ASC')); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | |
@@ -104,10 +104,10 @@ discard block |
||
104 | 104 | ); |
105 | 105 | // send messages |
106 | 106 | /** @type EE_Registration_Processor $registration_processor */ |
107 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
107 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
108 | 108 | $registration_processor->trigger_registration_update_notifications( |
109 | 109 | $transaction->primary_registration(), |
110 | - array( 'manually_updated' => true ) |
|
110 | + array('manually_updated' => true) |
|
111 | 111 | ); |
112 | 112 | do_action( |
113 | 113 | 'AHEE__EE_Transaction_Processor__manually_update_registration_statuses', |
@@ -194,13 +194,13 @@ discard block |
||
194 | 194 | $registration_query_params = array() |
195 | 195 | ) { |
196 | 196 | // make sure some query params are set for retrieving registrations |
197 | - $this->_set_registration_query_params( $registration_query_params ); |
|
197 | + $this->_set_registration_query_params($registration_query_params); |
|
198 | 198 | // get final reg step status |
199 | 199 | $finalized = $transaction->final_reg_step_completed(); |
200 | 200 | // if the 'finalize_registration' step has been initiated (has a timestamp) |
201 | 201 | // but has not yet been fully completed (TRUE) |
202 | - if ( is_int( $finalized ) && $finalized !== false && $finalized !== true ) { |
|
203 | - $transaction->set_reg_step_completed( 'finalize_registration' ); |
|
202 | + if (is_int($finalized) && $finalized !== false && $finalized !== true) { |
|
203 | + $transaction->set_reg_step_completed('finalize_registration'); |
|
204 | 204 | $finalized = true; |
205 | 205 | } |
206 | 206 | $transaction->save(); |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | |
224 | 224 | // send messages |
225 | 225 | /** @type EE_Registration_Processor $registration_processor */ |
226 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
226 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
227 | 227 | $registration_processor->trigger_registration_update_notifications( |
228 | 228 | $transaction->primary_registration(), |
229 | 229 | $update_params |
@@ -254,22 +254,22 @@ discard block |
||
254 | 254 | $update_txn = true |
255 | 255 | ) { |
256 | 256 | // these reg statuses should not be considered in any calculations involving monies owing |
257 | - $closed_reg_statuses = ! empty( $closed_reg_statuses ) ? $closed_reg_statuses : EEM_Registration::closed_reg_statuses(); |
|
258 | - if ( in_array( $registration->status_ID(), $closed_reg_statuses ) ) { |
|
257 | + $closed_reg_statuses = ! empty($closed_reg_statuses) ? $closed_reg_statuses : EEM_Registration::closed_reg_statuses(); |
|
258 | + if (in_array($registration->status_ID(), $closed_reg_statuses)) { |
|
259 | 259 | return false; |
260 | 260 | } |
261 | 261 | try { |
262 | - $transaction = $this->get_transaction_for_registration( $registration ); |
|
262 | + $transaction = $this->get_transaction_for_registration($registration); |
|
263 | 263 | $ticket_line_item = $this->get_ticket_line_item_for_transaction_registration( |
264 | 264 | $transaction, |
265 | 265 | $registration |
266 | 266 | ); |
267 | 267 | // un-cancel the ticket |
268 | - $success = EEH_Line_Item::reinstate_canceled_ticket_line_item( $ticket_line_item ); |
|
269 | - } catch ( EE_Error $e ) { |
|
268 | + $success = EEH_Line_Item::reinstate_canceled_ticket_line_item($ticket_line_item); |
|
269 | + } catch (EE_Error $e) { |
|
270 | 270 | EE_Error::add_error( |
271 | 271 | sprintf( |
272 | - __( 'The Ticket Line Item for Registration %1$d could not be reinstated because :%2$s%3$s', 'event_espresso' ), |
|
272 | + __('The Ticket Line Item for Registration %1$d could not be reinstated because :%2$s%3$s', 'event_espresso'), |
|
273 | 273 | $registration->ID(), |
274 | 274 | '<br />', |
275 | 275 | $e->getMessage() |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | ); |
279 | 279 | return false; |
280 | 280 | } |
281 | - if ( $update_txn ) { |
|
281 | + if ($update_txn) { |
|
282 | 282 | return $transaction->save() ? $success : false; |
283 | 283 | } |
284 | 284 | return $success; |
@@ -302,18 +302,18 @@ discard block |
||
302 | 302 | $update_txn = true |
303 | 303 | ) { |
304 | 304 | // these reg statuses should not be considered in any calculations involving monies owing |
305 | - $closed_reg_statuses = ! empty( $closed_reg_statuses ) ? $closed_reg_statuses : EEM_Registration::closed_reg_statuses(); |
|
306 | - if ( ! in_array( $registration->status_ID(), $closed_reg_statuses ) ) { |
|
305 | + $closed_reg_statuses = ! empty($closed_reg_statuses) ? $closed_reg_statuses : EEM_Registration::closed_reg_statuses(); |
|
306 | + if ( ! in_array($registration->status_ID(), $closed_reg_statuses)) { |
|
307 | 307 | return false; |
308 | 308 | } |
309 | 309 | try { |
310 | - $transaction = $this->get_transaction_for_registration( $registration ); |
|
311 | - $ticket_line_item = $this->get_ticket_line_item_for_transaction_registration( $transaction, $registration ); |
|
312 | - EEH_Line_Item::cancel_ticket_line_item( $ticket_line_item ); |
|
313 | - } catch ( EE_Error $e ) { |
|
310 | + $transaction = $this->get_transaction_for_registration($registration); |
|
311 | + $ticket_line_item = $this->get_ticket_line_item_for_transaction_registration($transaction, $registration); |
|
312 | + EEH_Line_Item::cancel_ticket_line_item($ticket_line_item); |
|
313 | + } catch (EE_Error $e) { |
|
314 | 314 | EE_Error::add_error( |
315 | 315 | sprintf( |
316 | - __( 'The Ticket Line Item for Registration %1$d could not be cancelled because :%2$s%3$s', 'event_espresso' ), |
|
316 | + __('The Ticket Line Item for Registration %1$d could not be cancelled because :%2$s%3$s', 'event_espresso'), |
|
317 | 317 | $registration->ID(), |
318 | 318 | '<br />', |
319 | 319 | $e->getMessage() |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | ); |
323 | 323 | return false; |
324 | 324 | } |
325 | - if ( $update_txn ) { |
|
325 | + if ($update_txn) { |
|
326 | 326 | return $transaction->save() ? true : false; |
327 | 327 | } |
328 | 328 | return true; |
@@ -338,12 +338,12 @@ discard block |
||
338 | 338 | * @return EE_Transaction |
339 | 339 | * @throws EE_Error |
340 | 340 | */ |
341 | - public function get_transaction_for_registration( EE_Registration $registration ) { |
|
341 | + public function get_transaction_for_registration(EE_Registration $registration) { |
|
342 | 342 | $transaction = $registration->transaction(); |
343 | - if ( ! $transaction instanceof EE_Transaction ) { |
|
343 | + if ( ! $transaction instanceof EE_Transaction) { |
|
344 | 344 | throw new EE_Error( |
345 | 345 | sprintf( |
346 | - __( 'The Transaction for Registration %1$d was not found or is invalid.', 'event_espresso' ), |
|
346 | + __('The Transaction for Registration %1$d was not found or is invalid.', 'event_espresso'), |
|
347 | 347 | $registration->ID() |
348 | 348 | ) |
349 | 349 | ); |
@@ -366,16 +366,16 @@ discard block |
||
366 | 366 | EE_Transaction $transaction, |
367 | 367 | EE_Registration $registration |
368 | 368 | ) { |
369 | - EE_Registry::instance()->load_helper( 'Line_Item' ); |
|
369 | + EE_Registry::instance()->load_helper('Line_Item'); |
|
370 | 370 | $ticket_line_item = EEM_Line_Item::instance()->get_ticket_line_item_for_transaction( |
371 | 371 | $transaction->ID(), |
372 | 372 | $registration->ticket_ID() |
373 | 373 | ); |
374 | - if ( ! $ticket_line_item instanceof EE_Line_Item ) { |
|
374 | + if ( ! $ticket_line_item instanceof EE_Line_Item) { |
|
375 | 375 | throw new EE_Error( |
376 | 376 | sprintf( |
377 | - __( 'The Line Item for Transaction %1$d and Ticket %2$d was not found or is invalid.', |
|
378 | - 'event_espresso' ), |
|
377 | + __('The Line Item for Transaction %1$d and Ticket %2$d was not found or is invalid.', |
|
378 | + 'event_espresso'), |
|
379 | 379 | $transaction->ID(), |
380 | 380 | $registration->ticket_ID() |
381 | 381 | ) |
@@ -408,22 +408,22 @@ discard block |
||
408 | 408 | $update_txn = true |
409 | 409 | ) { |
410 | 410 | // make sure some query params are set for retrieving registrations |
411 | - $this->_set_registration_query_params( $registration_query_params ); |
|
411 | + $this->_set_registration_query_params($registration_query_params); |
|
412 | 412 | // these reg statuses should not be considered in any calculations involving monies owing |
413 | - $closed_reg_statuses = ! empty( $closed_reg_statuses ) ? $closed_reg_statuses : EEM_Registration::closed_reg_statuses(); |
|
413 | + $closed_reg_statuses = ! empty($closed_reg_statuses) ? $closed_reg_statuses : EEM_Registration::closed_reg_statuses(); |
|
414 | 414 | // loop through cached registrations |
415 | - foreach ( $transaction->registrations( $this->_registration_query_params ) as $registration ) { |
|
415 | + foreach ($transaction->registrations($this->_registration_query_params) as $registration) { |
|
416 | 416 | if ( |
417 | 417 | $registration instanceof EE_Registration |
418 | - && ! in_array( $registration->status_ID(), $closed_reg_statuses ) |
|
418 | + && ! in_array($registration->status_ID(), $closed_reg_statuses) |
|
419 | 419 | ) { |
420 | 420 | return false; |
421 | 421 | } |
422 | 422 | } |
423 | - if ( in_array( $new_TXN_status, EEM_Transaction::txn_status_array() ) ) { |
|
424 | - $transaction->set_status( $new_TXN_status ); |
|
423 | + if (in_array($new_TXN_status, EEM_Transaction::txn_status_array())) { |
|
424 | + $transaction->set_status($new_TXN_status); |
|
425 | 425 | } |
426 | - if ( $update_txn ) { |
|
426 | + if ($update_txn) { |
|
427 | 427 | return $transaction->save() ? true : false; |
428 | 428 | } |
429 | 429 | return true; |
@@ -452,22 +452,22 @@ discard block |
||
452 | 452 | ) { |
453 | 453 | $response = false; |
454 | 454 | /** @type EE_Registration_Processor $registration_processor */ |
455 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
455 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
456 | 456 | // check that method exists |
457 | - if ( ! method_exists( $registration_processor, $method_name )) { |
|
458 | - throw new EE_Error( __( 'Method does not exist.', 'event_espresso' )); |
|
457 | + if ( ! method_exists($registration_processor, $method_name)) { |
|
458 | + throw new EE_Error(__('Method does not exist.', 'event_espresso')); |
|
459 | 459 | } |
460 | 460 | // make sure some query params are set for retrieving registrations |
461 | - $this->_set_registration_query_params( $registration_query_params ); |
|
461 | + $this->_set_registration_query_params($registration_query_params); |
|
462 | 462 | // loop through cached registrations |
463 | - foreach ( $transaction->registrations( $this->_registration_query_params ) as $registration ) { |
|
464 | - if ( $registration instanceof EE_Registration ) { |
|
465 | - if ( $additional_param ) { |
|
466 | - $response = $registration_processor->{$method_name}( $registration, $additional_param ) |
|
463 | + foreach ($transaction->registrations($this->_registration_query_params) as $registration) { |
|
464 | + if ($registration instanceof EE_Registration) { |
|
465 | + if ($additional_param) { |
|
466 | + $response = $registration_processor->{$method_name}($registration, $additional_param) |
|
467 | 467 | ? true |
468 | 468 | : $response; |
469 | 469 | } else { |
470 | - $response = $registration_processor->{$method_name}( $registration ) |
|
470 | + $response = $registration_processor->{$method_name}($registration) |
|
471 | 471 | ? true |
472 | 472 | : $response; |
473 | 473 | } |
@@ -494,28 +494,28 @@ discard block |
||
494 | 494 | public function set_transaction_payment_method_based_on_registration_statuses( |
495 | 495 | EE_Registration $edited_registration |
496 | 496 | ) { |
497 | - if ( $edited_registration instanceof EE_Registration ) { |
|
497 | + if ($edited_registration instanceof EE_Registration) { |
|
498 | 498 | $transaction = $edited_registration->transaction(); |
499 | - if ( $transaction instanceof EE_Transaction ) { |
|
499 | + if ($transaction instanceof EE_Transaction) { |
|
500 | 500 | $all_not_approved = true; |
501 | - foreach ( $transaction->registrations() as $registration ) { |
|
502 | - if ( $registration instanceof EE_Registration ) { |
|
501 | + foreach ($transaction->registrations() as $registration) { |
|
502 | + if ($registration instanceof EE_Registration) { |
|
503 | 503 | // if any REG != "Not Approved" then toggle to false |
504 | 504 | $all_not_approved = $registration->is_not_approved() ? $all_not_approved : false; |
505 | 505 | } |
506 | 506 | } |
507 | 507 | // if ALL Registrations are "Not Approved" |
508 | - if ( $all_not_approved ) { |
|
509 | - $transaction->set_payment_method_ID( null ); |
|
508 | + if ($all_not_approved) { |
|
509 | + $transaction->set_payment_method_ID(null); |
|
510 | 510 | $transaction->save(); |
511 | 511 | } else { |
512 | 512 | $available_payment_methods = EEM_Payment_Method::instance()->get_all_for_transaction( |
513 | 513 | $transaction, |
514 | 514 | EEM_Payment_Method::scope_cart |
515 | 515 | ); |
516 | - if ( ! empty( $available_payment_methods ) ) { |
|
516 | + if ( ! empty($available_payment_methods)) { |
|
517 | 517 | $PMD_ID = 0; |
518 | - foreach ( $available_payment_methods as $available_payment_method ) { |
|
518 | + foreach ($available_payment_methods as $available_payment_method) { |
|
519 | 519 | if ( |
520 | 520 | $available_payment_method instanceof EE_Payment_Method |
521 | 521 | && $available_payment_method->open_by_default() |
@@ -524,22 +524,22 @@ discard block |
||
524 | 524 | break; |
525 | 525 | } |
526 | 526 | } |
527 | - if ( ! $PMD_ID ) { |
|
528 | - $first_payment_method = reset( $available_payment_methods ); |
|
529 | - if ( $first_payment_method instanceof EE_Payment_Method ) { |
|
527 | + if ( ! $PMD_ID) { |
|
528 | + $first_payment_method = reset($available_payment_methods); |
|
529 | + if ($first_payment_method instanceof EE_Payment_Method) { |
|
530 | 530 | $PMD_ID = $first_payment_method->ID(); |
531 | 531 | } else { |
532 | 532 | EE_Error::add_error( |
533 | - __( 'A valid Payment Method could not be determined. Please ensure that at least one Payment Method is activated.', 'event_espresso' ), |
|
533 | + __('A valid Payment Method could not be determined. Please ensure that at least one Payment Method is activated.', 'event_espresso'), |
|
534 | 534 | __FILE__, __LINE__, __FUNCTION__ |
535 | 535 | ); |
536 | 536 | } |
537 | 537 | } |
538 | - $transaction->set_payment_method_ID( $PMD_ID ); |
|
538 | + $transaction->set_payment_method_ID($PMD_ID); |
|
539 | 539 | $transaction->save(); |
540 | 540 | } else { |
541 | 541 | EE_Error::add_error( |
542 | - __( 'Please activate at least one Payment Method in order for things to operate correctly.', 'event_espresso' ), |
|
542 | + __('Please activate at least one Payment Method in order for things to operate correctly.', 'event_espresso'), |
|
543 | 543 | __FILE__, __LINE__, __FUNCTION__ |
544 | 544 | ); |
545 | 545 | } |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | * @deprecated 4.9.12 |
577 | 577 | * @param string $old_txn_status |
578 | 578 | */ |
579 | - public function set_old_txn_status( $old_txn_status ) { |
|
579 | + public function set_old_txn_status($old_txn_status) { |
|
580 | 580 | EE_Error::doing_it_wrong( |
581 | 581 | __METHOD__, |
582 | 582 | esc_html__( |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | '4.9.12' |
587 | 587 | ); |
588 | 588 | // only set the first time |
589 | - if ( $this->_old_txn_status === null ) { |
|
589 | + if ($this->_old_txn_status === null) { |
|
590 | 590 | $this->_old_txn_status = $old_txn_status; |
591 | 591 | } |
592 | 592 | } |
@@ -615,7 +615,7 @@ discard block |
||
615 | 615 | * @deprecated 4.9.12 |
616 | 616 | * @param string $new_txn_status |
617 | 617 | */ |
618 | - public function set_new_txn_status( $new_txn_status ) { |
|
618 | + public function set_new_txn_status($new_txn_status) { |
|
619 | 619 | EE_Error::doing_it_wrong( |
620 | 620 | __METHOD__, |
621 | 621 | esc_html__( |
@@ -659,7 +659,7 @@ discard block |
||
659 | 659 | * @param EE_Transaction $transaction |
660 | 660 | * @return boolean |
661 | 661 | */ |
662 | - public function all_reg_steps_completed( EE_Transaction $transaction ) { |
|
662 | + public function all_reg_steps_completed(EE_Transaction $transaction) { |
|
663 | 663 | EE_Error::doing_it_wrong( |
664 | 664 | __METHOD__, |
665 | 665 | esc_html__( |
@@ -686,7 +686,7 @@ discard block |
||
686 | 686 | * @param string $exception |
687 | 687 | * @return boolean |
688 | 688 | */ |
689 | - public function all_reg_steps_completed_except( EE_Transaction $transaction, $exception = '' ) { |
|
689 | + public function all_reg_steps_completed_except(EE_Transaction $transaction, $exception = '') { |
|
690 | 690 | EE_Error::doing_it_wrong( |
691 | 691 | __METHOD__, |
692 | 692 | esc_html__( |
@@ -696,7 +696,7 @@ discard block |
||
696 | 696 | '4.9.12', |
697 | 697 | '5.0.0' |
698 | 698 | ); |
699 | - return $transaction->all_reg_steps_completed_except( $exception ); |
|
699 | + return $transaction->all_reg_steps_completed_except($exception); |
|
700 | 700 | } |
701 | 701 | |
702 | 702 | |
@@ -712,7 +712,7 @@ discard block |
||
712 | 712 | * @param EE_Transaction $transaction |
713 | 713 | * @return boolean |
714 | 714 | */ |
715 | - public function all_reg_steps_completed_except_final_step( EE_Transaction $transaction ) { |
|
715 | + public function all_reg_steps_completed_except_final_step(EE_Transaction $transaction) { |
|
716 | 716 | EE_Error::doing_it_wrong( |
717 | 717 | __METHOD__, |
718 | 718 | esc_html__( |
@@ -739,7 +739,7 @@ discard block |
||
739 | 739 | * @param string $reg_step_slug |
740 | 740 | * @return boolean | int |
741 | 741 | */ |
742 | - public function reg_step_completed( EE_Transaction $transaction, $reg_step_slug ) { |
|
742 | + public function reg_step_completed(EE_Transaction $transaction, $reg_step_slug) { |
|
743 | 743 | EE_Error::doing_it_wrong( |
744 | 744 | __METHOD__, |
745 | 745 | esc_html__( |
@@ -749,7 +749,7 @@ discard block |
||
749 | 749 | '4.9.12', |
750 | 750 | '5.0.0' |
751 | 751 | ); |
752 | - return $transaction->reg_step_completed( $reg_step_slug ); |
|
752 | + return $transaction->reg_step_completed($reg_step_slug); |
|
753 | 753 | } |
754 | 754 | |
755 | 755 | |
@@ -765,7 +765,7 @@ discard block |
||
765 | 765 | * @param EE_Transaction $transaction |
766 | 766 | * @return boolean | int |
767 | 767 | */ |
768 | - public function final_reg_step_completed( EE_Transaction $transaction ) { |
|
768 | + public function final_reg_step_completed(EE_Transaction $transaction) { |
|
769 | 769 | EE_Error::doing_it_wrong( |
770 | 770 | __METHOD__, |
771 | 771 | esc_html__( |
@@ -791,7 +791,7 @@ discard block |
||
791 | 791 | * @return boolean |
792 | 792 | * @throws \EE_Error |
793 | 793 | */ |
794 | - public function set_reg_step_initiated( EE_Transaction $transaction, $reg_step_slug ) { |
|
794 | + public function set_reg_step_initiated(EE_Transaction $transaction, $reg_step_slug) { |
|
795 | 795 | EE_Error::doing_it_wrong( |
796 | 796 | __METHOD__, |
797 | 797 | esc_html__( |
@@ -801,7 +801,7 @@ discard block |
||
801 | 801 | '4.9.12', |
802 | 802 | '5.0.0' |
803 | 803 | ); |
804 | - return $transaction->set_reg_step_initiated( $reg_step_slug ); |
|
804 | + return $transaction->set_reg_step_initiated($reg_step_slug); |
|
805 | 805 | } |
806 | 806 | |
807 | 807 | |
@@ -817,7 +817,7 @@ discard block |
||
817 | 817 | * @return boolean |
818 | 818 | * @throws \EE_Error |
819 | 819 | */ |
820 | - public function set_reg_step_completed( EE_Transaction $transaction, $reg_step_slug ) { |
|
820 | + public function set_reg_step_completed(EE_Transaction $transaction, $reg_step_slug) { |
|
821 | 821 | EE_Error::doing_it_wrong( |
822 | 822 | __METHOD__, |
823 | 823 | esc_html__( |
@@ -827,7 +827,7 @@ discard block |
||
827 | 827 | '4.9.12', |
828 | 828 | '5.0.0' |
829 | 829 | ); |
830 | - return $transaction->set_reg_step_completed( $reg_step_slug ); |
|
830 | + return $transaction->set_reg_step_completed($reg_step_slug); |
|
831 | 831 | } |
832 | 832 | |
833 | 833 | |
@@ -843,7 +843,7 @@ discard block |
||
843 | 843 | * @return boolean |
844 | 844 | * @throws \EE_Error |
845 | 845 | */ |
846 | - public function set_reg_step_not_completed( EE_Transaction $transaction, $reg_step_slug ) { |
|
846 | + public function set_reg_step_not_completed(EE_Transaction $transaction, $reg_step_slug) { |
|
847 | 847 | EE_Error::doing_it_wrong( |
848 | 848 | __METHOD__, |
849 | 849 | esc_html__( |
@@ -853,7 +853,7 @@ discard block |
||
853 | 853 | '4.9.12', |
854 | 854 | '5.0.0' |
855 | 855 | ); |
856 | - return $transaction->set_reg_step_not_completed( $reg_step_slug ); |
|
856 | + return $transaction->set_reg_step_not_completed($reg_step_slug); |
|
857 | 857 | } |
858 | 858 | |
859 | 859 | |
@@ -870,7 +870,7 @@ discard block |
||
870 | 870 | * @param string $reg_step_slug |
871 | 871 | * @return void |
872 | 872 | */ |
873 | - public function remove_reg_step( EE_Transaction $transaction, $reg_step_slug ) { |
|
873 | + public function remove_reg_step(EE_Transaction $transaction, $reg_step_slug) { |
|
874 | 874 | EE_Error::doing_it_wrong( |
875 | 875 | __METHOD__, |
876 | 876 | esc_html__( |
@@ -880,7 +880,7 @@ discard block |
||
880 | 880 | '4.9.12', |
881 | 881 | '5.0.0' |
882 | 882 | ); |
883 | - $transaction->remove_reg_step( $reg_step_slug ); |
|
883 | + $transaction->remove_reg_step($reg_step_slug); |
|
884 | 884 | } |
885 | 885 | |
886 | 886 | |
@@ -896,7 +896,7 @@ discard block |
||
896 | 896 | * @return boolean |
897 | 897 | * @throws \EE_Error |
898 | 898 | */ |
899 | - public function toggle_failed_transaction_status( EE_Transaction $transaction ) { |
|
899 | + public function toggle_failed_transaction_status(EE_Transaction $transaction) { |
|
900 | 900 | EE_Error::doing_it_wrong( |
901 | 901 | __METHOD__, |
902 | 902 | esc_html__( |
@@ -920,7 +920,7 @@ discard block |
||
920 | 920 | * @param EE_Transaction $transaction |
921 | 921 | * @return boolean |
922 | 922 | */ |
923 | - public function toggle_abandoned_transaction_status( EE_Transaction $transaction ) { |
|
923 | + public function toggle_abandoned_transaction_status(EE_Transaction $transaction) { |
|
924 | 924 | EE_Error::doing_it_wrong( |
925 | 925 | __METHOD__, |
926 | 926 | esc_html__( |
@@ -564,6 +564,7 @@ |
||
564 | 564 | * @param \EE_Payment | NULL $payment |
565 | 565 | * @param array $registration_query_params array of query WHERE params to use |
566 | 566 | * when retrieving cached registrations from a transaction |
567 | + * @param EE_Payment $payment |
|
567 | 568 | * @throws \EE_Error |
568 | 569 | * @return array |
569 | 570 | */ |