@@ -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 | } |
@@ -64,9 +64,9 @@ discard block |
||
64 | 64 | * @param array $registration_query_params |
65 | 65 | * @return EE_Transaction_Processor |
66 | 66 | */ |
67 | - private function __construct( $registration_query_params = array() ) { |
|
67 | + private function __construct($registration_query_params = array()) { |
|
68 | 68 | // make sure some query params are set for retrieving registrations |
69 | - $this->_set_registration_query_params( $registration_query_params ); |
|
69 | + $this->_set_registration_query_params($registration_query_params); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | |
@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | * @access private |
76 | 76 | * @param array $registration_query_params |
77 | 77 | */ |
78 | - private function _set_registration_query_params( $registration_query_params ) { |
|
79 | - $this->_registration_query_params = ! empty( $registration_query_params ) ? $registration_query_params : array( 'order_by' => array( 'REG_count' => 'ASC' )); |
|
78 | + private function _set_registration_query_params($registration_query_params) { |
|
79 | + $this->_registration_query_params = ! empty($registration_query_params) ? $registration_query_params : array('order_by' => array('REG_count' => 'ASC')); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | |
@@ -93,9 +93,9 @@ discard block |
||
93 | 93 | /** |
94 | 94 | * @param string $old_txn_status |
95 | 95 | */ |
96 | - public function set_old_txn_status( $old_txn_status ) { |
|
96 | + public function set_old_txn_status($old_txn_status) { |
|
97 | 97 | // only set the first time |
98 | - if ( $this->_old_txn_status === null ) { |
|
98 | + if ($this->_old_txn_status === null) { |
|
99 | 99 | $this->_old_txn_status = $old_txn_status; |
100 | 100 | } |
101 | 101 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | /** |
115 | 115 | * @param string $new_txn_status |
116 | 116 | */ |
117 | - public function set_new_txn_status( $new_txn_status ) { |
|
117 | + public function set_new_txn_status($new_txn_status) { |
|
118 | 118 | $this->_new_txn_status = $new_txn_status; |
119 | 119 | } |
120 | 120 | |
@@ -145,17 +145,17 @@ discard block |
||
145 | 145 | * @param bool $check_all |
146 | 146 | * @return boolean | int |
147 | 147 | */ |
148 | - private function _reg_steps_completed( EE_Transaction $transaction, $reg_step_slug = '', $check_all = TRUE ) { |
|
148 | + private function _reg_steps_completed(EE_Transaction $transaction, $reg_step_slug = '', $check_all = TRUE) { |
|
149 | 149 | $reg_steps = $transaction->reg_steps(); |
150 | - if ( ! is_array( $reg_steps ) || empty( $reg_steps )) { |
|
150 | + if ( ! is_array($reg_steps) || empty($reg_steps)) { |
|
151 | 151 | return false; |
152 | 152 | } |
153 | 153 | // loop thru reg steps array) |
154 | - foreach ( $reg_steps as $slug => $reg_step_completed ) { |
|
154 | + foreach ($reg_steps as $slug => $reg_step_completed) { |
|
155 | 155 | // if NOT checking ALL steps (only checking one step) |
156 | - if ( ! $check_all ) { |
|
156 | + if ( ! $check_all) { |
|
157 | 157 | // and this is the one |
158 | - if ( $slug == $reg_step_slug ) { |
|
158 | + if ($slug == $reg_step_slug) { |
|
159 | 159 | return $reg_step_completed; |
160 | 160 | } else { |
161 | 161 | // skip to next reg step in loop |
@@ -163,9 +163,9 @@ discard block |
||
163 | 163 | } |
164 | 164 | } |
165 | 165 | // if any reg step is NOT completed (ignoring any specific steps), then just leave |
166 | - if ( $reg_step_completed !== true && $slug != $reg_step_slug ) { |
|
166 | + if ($reg_step_completed !== true && $slug != $reg_step_slug) { |
|
167 | 167 | return false; |
168 | - } else if ( $slug == $reg_step_slug ) { |
|
168 | + } else if ($slug == $reg_step_slug) { |
|
169 | 169 | // if we reach this point, then we are testing either: |
170 | 170 | // all_reg_steps_completed_except() or |
171 | 171 | // all_reg_steps_completed_except_final_step(), |
@@ -190,8 +190,8 @@ discard block |
||
190 | 190 | * @param EE_Transaction $transaction |
191 | 191 | * @return boolean |
192 | 192 | */ |
193 | - public function all_reg_steps_completed( EE_Transaction $transaction ) { |
|
194 | - return $this->_reg_steps_completed( $transaction ); |
|
193 | + public function all_reg_steps_completed(EE_Transaction $transaction) { |
|
194 | + return $this->_reg_steps_completed($transaction); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | |
@@ -208,8 +208,8 @@ discard block |
||
208 | 208 | * @param string $exception |
209 | 209 | * @return boolean |
210 | 210 | */ |
211 | - public function all_reg_steps_completed_except( EE_Transaction $transaction, $exception = '' ) { |
|
212 | - return $this->_reg_steps_completed( $transaction, $exception ); |
|
211 | + public function all_reg_steps_completed_except(EE_Transaction $transaction, $exception = '') { |
|
212 | + return $this->_reg_steps_completed($transaction, $exception); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | |
@@ -225,8 +225,8 @@ discard block |
||
225 | 225 | * @param EE_Transaction $transaction |
226 | 226 | * @return boolean |
227 | 227 | */ |
228 | - public function all_reg_steps_completed_except_final_step( EE_Transaction $transaction ) { |
|
229 | - return $this->_reg_steps_completed( $transaction, 'finalize_registration' ); |
|
228 | + public function all_reg_steps_completed_except_final_step(EE_Transaction $transaction) { |
|
229 | + return $this->_reg_steps_completed($transaction, 'finalize_registration'); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | |
@@ -243,8 +243,8 @@ discard block |
||
243 | 243 | * @param string $reg_step_slug |
244 | 244 | * @return boolean | int |
245 | 245 | */ |
246 | - public function reg_step_completed( EE_Transaction $transaction, $reg_step_slug ) { |
|
247 | - return $this->_reg_steps_completed( $transaction, $reg_step_slug, FALSE ); |
|
246 | + public function reg_step_completed(EE_Transaction $transaction, $reg_step_slug) { |
|
247 | + return $this->_reg_steps_completed($transaction, $reg_step_slug, FALSE); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | |
@@ -260,8 +260,8 @@ discard block |
||
260 | 260 | * @param EE_Transaction $transaction |
261 | 261 | * @return boolean | int |
262 | 262 | */ |
263 | - public function final_reg_step_completed( EE_Transaction $transaction ) { |
|
264 | - return $this->_reg_steps_completed( $transaction, 'finalize_registration', FALSE ); |
|
263 | + public function final_reg_step_completed(EE_Transaction $transaction) { |
|
264 | + return $this->_reg_steps_completed($transaction, 'finalize_registration', FALSE); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | |
@@ -275,9 +275,9 @@ discard block |
||
275 | 275 | * @param string $reg_step_slug |
276 | 276 | * @return boolean |
277 | 277 | */ |
278 | - public function set_reg_step_initiated( EE_Transaction $transaction, $reg_step_slug ) { |
|
278 | + public function set_reg_step_initiated(EE_Transaction $transaction, $reg_step_slug) { |
|
279 | 279 | $current_time = time(); |
280 | - return $this->_set_reg_step_completed_status( $transaction, $reg_step_slug, $current_time ); |
|
280 | + return $this->_set_reg_step_completed_status($transaction, $reg_step_slug, $current_time); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | |
@@ -291,8 +291,8 @@ discard block |
||
291 | 291 | * @param string $reg_step_slug |
292 | 292 | * @return boolean |
293 | 293 | */ |
294 | - public function set_reg_step_completed( EE_Transaction $transaction, $reg_step_slug ) { |
|
295 | - return $this->_set_reg_step_completed_status( $transaction, $reg_step_slug, TRUE ); |
|
294 | + public function set_reg_step_completed(EE_Transaction $transaction, $reg_step_slug) { |
|
295 | + return $this->_set_reg_step_completed_status($transaction, $reg_step_slug, TRUE); |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | |
@@ -306,8 +306,8 @@ discard block |
||
306 | 306 | * @param string $reg_step_slug |
307 | 307 | * @return boolean |
308 | 308 | */ |
309 | - public function set_reg_step_not_completed( EE_Transaction $transaction, $reg_step_slug ) { |
|
310 | - return $this->_set_reg_step_completed_status( $transaction, $reg_step_slug, FALSE ); |
|
309 | + public function set_reg_step_not_completed(EE_Transaction $transaction, $reg_step_slug) { |
|
310 | + return $this->_set_reg_step_completed_status($transaction, $reg_step_slug, FALSE); |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | |
@@ -323,36 +323,36 @@ discard block |
||
323 | 323 | * @param boolean | int $status |
324 | 324 | * @return boolean |
325 | 325 | */ |
326 | - private function _set_reg_step_completed_status( EE_Transaction $transaction, $reg_step_slug, $status ) { |
|
326 | + private function _set_reg_step_completed_status(EE_Transaction $transaction, $reg_step_slug, $status) { |
|
327 | 327 | // validate status |
328 | - $status = is_bool( $status ) || is_numeric( $status ) ? $status : false; |
|
328 | + $status = is_bool($status) || is_numeric($status) ? $status : false; |
|
329 | 329 | // get reg steps array |
330 | 330 | $txn_reg_steps = $transaction->reg_steps(); |
331 | 331 | // if reg step does NOT exist |
332 | - if ( ! isset( $txn_reg_steps[ $reg_step_slug ] )) { |
|
332 | + if ( ! isset($txn_reg_steps[$reg_step_slug])) { |
|
333 | 333 | return false; |
334 | 334 | } |
335 | 335 | // if we're trying to complete a step that is already completed |
336 | - if ( $txn_reg_steps[ $reg_step_slug ] === true ) { |
|
336 | + if ($txn_reg_steps[$reg_step_slug] === true) { |
|
337 | 337 | return true; |
338 | 338 | } |
339 | 339 | // if we're trying to complete a step that hasn't even started |
340 | - if ( $status === true && $txn_reg_steps[ $reg_step_slug ] === false ) { |
|
340 | + if ($status === true && $txn_reg_steps[$reg_step_slug] === false) { |
|
341 | 341 | return false; |
342 | 342 | } |
343 | 343 | // if current status value matches the incoming value (no change) |
344 | - if ( $txn_reg_steps[ $reg_step_slug ] === $status ) { |
|
344 | + if ($txn_reg_steps[$reg_step_slug] === $status) { |
|
345 | 345 | // this will happen in cases where multiple AJAX requests occur during the same step |
346 | 346 | return true; |
347 | 347 | } |
348 | 348 | // if we're trying to set a start time |
349 | - if ( is_numeric( $status ) && is_numeric( $txn_reg_steps[ $reg_step_slug ] )) { |
|
349 | + if (is_numeric($status) && is_numeric($txn_reg_steps[$reg_step_slug])) { |
|
350 | 350 | // skip the update below, but don't return FALSE so that errors won't be displayed |
351 | 351 | return true; |
352 | 352 | } |
353 | 353 | // update completed status |
354 | - $txn_reg_steps[ $reg_step_slug ] = $status; |
|
355 | - $transaction->set_reg_steps( $txn_reg_steps ); |
|
354 | + $txn_reg_steps[$reg_step_slug] = $status; |
|
355 | + $transaction->set_reg_steps($txn_reg_steps); |
|
356 | 356 | $transaction->save(); |
357 | 357 | // DEBUG LOG |
358 | 358 | //$this->log( |
@@ -378,11 +378,11 @@ discard block |
||
378 | 378 | * @param string $reg_step_slug |
379 | 379 | * @return void |
380 | 380 | */ |
381 | - public function remove_reg_step( EE_Transaction $transaction, $reg_step_slug ) { |
|
381 | + public function remove_reg_step(EE_Transaction $transaction, $reg_step_slug) { |
|
382 | 382 | // get reg steps array |
383 | 383 | $txn_reg_steps = $transaction->reg_steps(); |
384 | - unset( $txn_reg_steps[ $reg_step_slug ] ); |
|
385 | - $transaction->set_reg_steps( $txn_reg_steps ); |
|
384 | + unset($txn_reg_steps[$reg_step_slug]); |
|
385 | + $transaction->set_reg_steps($txn_reg_steps); |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | |
@@ -396,14 +396,14 @@ discard block |
||
396 | 396 | * @param EE_Transaction $transaction |
397 | 397 | * @return boolean |
398 | 398 | */ |
399 | - public function toggle_failed_transaction_status( EE_Transaction $transaction ) { |
|
399 | + public function toggle_failed_transaction_status(EE_Transaction $transaction) { |
|
400 | 400 | // set incoming TXN_Status |
401 | - $this->set_old_txn_status( $transaction->status_ID() ); |
|
401 | + $this->set_old_txn_status($transaction->status_ID()); |
|
402 | 402 | // if TXN status is still set as "failed"... |
403 | - if ( $transaction->status_ID() == EEM_Transaction::failed_status_code ) { |
|
403 | + if ($transaction->status_ID() == EEM_Transaction::failed_status_code) { |
|
404 | 404 | // set incoming TXN_Status |
405 | - $this->set_new_txn_status( EEM_Transaction::abandoned_status_code ); |
|
406 | - $transaction->set_status( EEM_Transaction::abandoned_status_code ); |
|
405 | + $this->set_new_txn_status(EEM_Transaction::abandoned_status_code); |
|
406 | + $transaction->set_status(EEM_Transaction::abandoned_status_code); |
|
407 | 407 | return TRUE; |
408 | 408 | } |
409 | 409 | return FALSE; |
@@ -419,20 +419,20 @@ discard block |
||
419 | 419 | * @param EE_Transaction $transaction |
420 | 420 | * @return boolean |
421 | 421 | */ |
422 | - public function toggle_abandoned_transaction_status( EE_Transaction $transaction ) { |
|
422 | + public function toggle_abandoned_transaction_status(EE_Transaction $transaction) { |
|
423 | 423 | // set incoming TXN_Status |
424 | - $this->set_old_txn_status( $transaction->status_ID() ); |
|
424 | + $this->set_old_txn_status($transaction->status_ID()); |
|
425 | 425 | // if TXN status has not been updated already due to a payment, and is still set as "failed" or "abandoned"... |
426 | - if ( $transaction->status_ID() == EEM_Transaction::failed_status_code || $transaction->status_ID() == EEM_Transaction::abandoned_status_code ) { |
|
427 | - $this->set_new_txn_status( EEM_Transaction::incomplete_status_code ); |
|
426 | + if ($transaction->status_ID() == EEM_Transaction::failed_status_code || $transaction->status_ID() == EEM_Transaction::abandoned_status_code) { |
|
427 | + $this->set_new_txn_status(EEM_Transaction::incomplete_status_code); |
|
428 | 428 | // if a contact record for the primary registrant has been created |
429 | - if ( $transaction->primary_registration() instanceof EE_Registration && $transaction->primary_registration()->attendee() instanceof EE_Attendee ) { |
|
430 | - $transaction->set_status( EEM_Transaction::incomplete_status_code ); |
|
431 | - $this->set_new_txn_status( EEM_Transaction::incomplete_status_code ); |
|
429 | + if ($transaction->primary_registration() instanceof EE_Registration && $transaction->primary_registration()->attendee() instanceof EE_Attendee) { |
|
430 | + $transaction->set_status(EEM_Transaction::incomplete_status_code); |
|
431 | + $this->set_new_txn_status(EEM_Transaction::incomplete_status_code); |
|
432 | 432 | } else { |
433 | 433 | // no contact record? yer abandoned! |
434 | - $transaction->set_status( EEM_Transaction::abandoned_status_code ); |
|
435 | - $this->set_new_txn_status( EEM_Transaction::abandoned_status_code ); |
|
434 | + $transaction->set_status(EEM_Transaction::abandoned_status_code); |
|
435 | + $this->set_new_txn_status(EEM_Transaction::abandoned_status_code); |
|
436 | 436 | } |
437 | 437 | return TRUE; |
438 | 438 | } |
@@ -450,16 +450,16 @@ discard block |
||
450 | 450 | * @param array $registration_query_params - array of query WHERE params to use when retrieving cached registrations from a transaction |
451 | 451 | * @return boolean |
452 | 452 | */ |
453 | - public function manually_update_registration_statuses( EE_Transaction $transaction, $new_reg_status = '', $registration_query_params = array() ) { |
|
454 | - $status_updates = $this->_call_method_on_registrations_via_Registration_Processor( 'manually_update_registration_status', $transaction, $registration_query_params, $new_reg_status ); |
|
453 | + public function manually_update_registration_statuses(EE_Transaction $transaction, $new_reg_status = '', $registration_query_params = array()) { |
|
454 | + $status_updates = $this->_call_method_on_registrations_via_Registration_Processor('manually_update_registration_status', $transaction, $registration_query_params, $new_reg_status); |
|
455 | 455 | // send messages |
456 | 456 | /** @type EE_Registration_Processor $registration_processor */ |
457 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
457 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
458 | 458 | $registration_processor->trigger_registration_update_notifications( |
459 | 459 | $transaction->primary_registration(), |
460 | - array( 'manually_updated' => true ) |
|
460 | + array('manually_updated' => true) |
|
461 | 461 | ); |
462 | - do_action( 'AHEE__EE_Transaction_Processor__manually_update_registration_statuses', $transaction, $status_updates ); |
|
462 | + do_action('AHEE__EE_Transaction_Processor__manually_update_registration_statuses', $transaction, $status_updates); |
|
463 | 463 | return $status_updates; |
464 | 464 | } |
465 | 465 | |
@@ -473,9 +473,9 @@ discard block |
||
473 | 473 | * @param array $registration_query_params - array of query WHERE params to use when retrieving cached registrations from a transaction |
474 | 474 | * @return boolean |
475 | 475 | */ |
476 | - public function toggle_registration_statuses_for_default_approved_events( EE_Transaction $transaction, $registration_query_params = array() ) { |
|
477 | - $status_updates = $this->_call_method_on_registrations_via_Registration_Processor( 'toggle_registration_status_for_default_approved_events', $transaction, $registration_query_params ); |
|
478 | - do_action( 'AHEE__EE_Transaction_Processor__toggle_registration_statuses_for_default_approved_events', $transaction, $status_updates ); |
|
476 | + public function toggle_registration_statuses_for_default_approved_events(EE_Transaction $transaction, $registration_query_params = array()) { |
|
477 | + $status_updates = $this->_call_method_on_registrations_via_Registration_Processor('toggle_registration_status_for_default_approved_events', $transaction, $registration_query_params); |
|
478 | + do_action('AHEE__EE_Transaction_Processor__toggle_registration_statuses_for_default_approved_events', $transaction, $status_updates); |
|
479 | 479 | return $status_updates; |
480 | 480 | } |
481 | 481 | |
@@ -489,9 +489,9 @@ discard block |
||
489 | 489 | * @param array $registration_query_params - array of query WHERE params to use when retrieving cached registrations from a transaction |
490 | 490 | * @return boolean |
491 | 491 | */ |
492 | - public function toggle_registration_statuses_if_no_monies_owing( EE_Transaction $transaction, $registration_query_params = array() ) { |
|
493 | - $status_updates = $this->_call_method_on_registrations_via_Registration_Processor( 'toggle_registration_status_if_no_monies_owing', $transaction, $registration_query_params ); |
|
494 | - do_action( 'AHEE__EE_Transaction_Processor__toggle_registration_statuses_if_no_monies_owing', $transaction, $status_updates ); |
|
492 | + public function toggle_registration_statuses_if_no_monies_owing(EE_Transaction $transaction, $registration_query_params = array()) { |
|
493 | + $status_updates = $this->_call_method_on_registrations_via_Registration_Processor('toggle_registration_status_if_no_monies_owing', $transaction, $registration_query_params); |
|
494 | + do_action('AHEE__EE_Transaction_Processor__toggle_registration_statuses_if_no_monies_owing', $transaction, $status_updates); |
|
495 | 495 | return $status_updates; |
496 | 496 | } |
497 | 497 | |
@@ -507,17 +507,17 @@ discard block |
||
507 | 507 | * @throws \EE_Error |
508 | 508 | * @return array |
509 | 509 | */ |
510 | - public function update_transaction_and_registrations_after_checkout_or_payment( EE_Transaction $transaction, $payment = NULL, $registration_query_params = array() ) { |
|
510 | + public function update_transaction_and_registrations_after_checkout_or_payment(EE_Transaction $transaction, $payment = NULL, $registration_query_params = array()) { |
|
511 | 511 | // set incoming TXN_Status, and consider it new since old status should have been set |
512 | - $this->set_new_txn_status( $transaction->status_ID() ); |
|
513 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, $transaction->status_ID(), '$transaction->status_ID()' ); |
|
512 | + $this->set_new_txn_status($transaction->status_ID()); |
|
513 | + do_action('AHEE_log', __FILE__, __FUNCTION__, $transaction->status_ID(), '$transaction->status_ID()'); |
|
514 | 514 | // make sure some query params are set for retrieving registrations |
515 | - $this->_set_registration_query_params( $registration_query_params ); |
|
515 | + $this->_set_registration_query_params($registration_query_params); |
|
516 | 516 | // get final reg step status |
517 | - $finalized = $this->final_reg_step_completed( $transaction ); |
|
517 | + $finalized = $this->final_reg_step_completed($transaction); |
|
518 | 518 | // if the 'finalize_registration' step has been initiated (has a timestamp) but has not yet been fully completed (TRUE) |
519 | - if ( is_numeric( $finalized ) && $finalized !== true ) { |
|
520 | - $this->set_reg_step_completed( $transaction, 'finalize_registration' ); |
|
519 | + if (is_numeric($finalized) && $finalized !== true) { |
|
520 | + $this->set_reg_step_completed($transaction, 'finalize_registration'); |
|
521 | 521 | $finalized = true; |
522 | 522 | } |
523 | 523 | $transaction->save(); |
@@ -540,13 +540,13 @@ discard block |
||
540 | 540 | |
541 | 541 | // send messages |
542 | 542 | /** @type EE_Registration_Processor $registration_processor */ |
543 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
543 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
544 | 544 | $registration_processor->trigger_registration_update_notifications( |
545 | 545 | $transaction->primary_registration(), |
546 | 546 | $update_params |
547 | 547 | ); |
548 | 548 | |
549 | - do_action( 'AHEE__EE_Transaction_Processor__update_transaction_and_registrations_after_checkout_or_payment', $transaction, $update_params ); |
|
549 | + do_action('AHEE__EE_Transaction_Processor__update_transaction_and_registrations_after_checkout_or_payment', $transaction, $update_params); |
|
550 | 550 | return $update_params; |
551 | 551 | } |
552 | 552 | |
@@ -564,23 +564,23 @@ discard block |
||
564 | 564 | * @throws \EE_Error |
565 | 565 | * @return boolean |
566 | 566 | */ |
567 | - private function _call_method_on_registrations_via_Registration_Processor( $method_name, EE_Transaction $transaction, $registration_query_params = array(), $additional_param = NULL ) { |
|
567 | + private function _call_method_on_registrations_via_Registration_Processor($method_name, EE_Transaction $transaction, $registration_query_params = array(), $additional_param = NULL) { |
|
568 | 568 | $response = FALSE; |
569 | 569 | /** @type EE_Registration_Processor $registration_processor */ |
570 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
570 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
571 | 571 | // check that method exists |
572 | - if ( ! method_exists( $registration_processor, $method_name )) { |
|
573 | - throw new EE_Error( __( 'Method does not exist.', 'event_espresso' )); |
|
572 | + if ( ! method_exists($registration_processor, $method_name)) { |
|
573 | + throw new EE_Error(__('Method does not exist.', 'event_espresso')); |
|
574 | 574 | } |
575 | 575 | // make sure some query params are set for retrieving registrations |
576 | - $this->_set_registration_query_params( $registration_query_params ); |
|
576 | + $this->_set_registration_query_params($registration_query_params); |
|
577 | 577 | // loop through cached registrations |
578 | - foreach ( $transaction->registrations( $this->_registration_query_params ) as $registration ) { |
|
579 | - if ( $registration instanceof EE_Registration ) { |
|
580 | - if ( $additional_param ) { |
|
581 | - $response = $registration_processor->$method_name( $registration, $additional_param ) ? TRUE : $response; |
|
578 | + foreach ($transaction->registrations($this->_registration_query_params) as $registration) { |
|
579 | + if ($registration instanceof EE_Registration) { |
|
580 | + if ($additional_param) { |
|
581 | + $response = $registration_processor->$method_name($registration, $additional_param) ? TRUE : $response; |
|
582 | 582 | } else { |
583 | - $response = $registration_processor->$method_name( $registration ) ? TRUE : $response; |
|
583 | + $response = $registration_processor->$method_name($registration) ? TRUE : $response; |
|
584 | 584 | } |
585 | 585 | } |
586 | 586 | } |
@@ -605,46 +605,46 @@ discard block |
||
605 | 605 | public function set_transaction_payment_method_based_on_registration_statuses( |
606 | 606 | EE_Registration $edited_registration |
607 | 607 | ) { |
608 | - if ( $edited_registration instanceof EE_Registration ) { |
|
608 | + if ($edited_registration instanceof EE_Registration) { |
|
609 | 609 | $transaction = $edited_registration->transaction(); |
610 | - if ( $transaction instanceof EE_Transaction ) { |
|
610 | + if ($transaction instanceof EE_Transaction) { |
|
611 | 611 | $all_not_approved = true; |
612 | - foreach ( $transaction->registrations() as $registration ) { |
|
613 | - if ( $registration instanceof EE_Registration ) { |
|
612 | + foreach ($transaction->registrations() as $registration) { |
|
613 | + if ($registration instanceof EE_Registration) { |
|
614 | 614 | // if any REG != "Not Approved" then toggle to false |
615 | 615 | $all_not_approved = $registration->is_not_approved() ? $all_not_approved : false; |
616 | 616 | } |
617 | 617 | } |
618 | 618 | // if ALL Registrations are "Not Approved" |
619 | - if ( $all_not_approved ) { |
|
620 | - $transaction->set_payment_method_ID( null ); |
|
619 | + if ($all_not_approved) { |
|
620 | + $transaction->set_payment_method_ID(null); |
|
621 | 621 | $transaction->save(); |
622 | 622 | } else { |
623 | - $available_payment_methods = EEM_Payment_Method::instance()->get_all_for_transaction( $transaction, EEM_Payment_Method::scope_cart ); |
|
624 | - if ( ! empty( $available_payment_methods ) ) { |
|
623 | + $available_payment_methods = EEM_Payment_Method::instance()->get_all_for_transaction($transaction, EEM_Payment_Method::scope_cart); |
|
624 | + if ( ! empty($available_payment_methods)) { |
|
625 | 625 | $PMD_ID = 0; |
626 | - foreach ( $available_payment_methods as $available_payment_method ) { |
|
627 | - if ( $available_payment_method instanceof EE_Payment_Method && $available_payment_method->open_by_default() ) { |
|
626 | + foreach ($available_payment_methods as $available_payment_method) { |
|
627 | + if ($available_payment_method instanceof EE_Payment_Method && $available_payment_method->open_by_default()) { |
|
628 | 628 | $PMD_ID = $available_payment_method->ID(); |
629 | 629 | break; |
630 | 630 | } |
631 | 631 | } |
632 | - if ( ! $PMD_ID ) { |
|
633 | - $first_payment_method = reset( $available_payment_methods ); |
|
634 | - if ( $first_payment_method instanceof EE_Payment_Method ) { |
|
632 | + if ( ! $PMD_ID) { |
|
633 | + $first_payment_method = reset($available_payment_methods); |
|
634 | + if ($first_payment_method instanceof EE_Payment_Method) { |
|
635 | 635 | $PMD_ID = $first_payment_method->ID(); |
636 | 636 | } else { |
637 | 637 | EE_Error::add_error( |
638 | - __( 'A valid Payment Method could not be determined. Please ensure that at least one Payment Method is activated.', 'event_espresso' ), |
|
638 | + __('A valid Payment Method could not be determined. Please ensure that at least one Payment Method is activated.', 'event_espresso'), |
|
639 | 639 | __FILE__, __LINE__, __FUNCTION__ |
640 | 640 | ); |
641 | 641 | } |
642 | 642 | } |
643 | - $transaction->set_payment_method_ID( $PMD_ID ); |
|
643 | + $transaction->set_payment_method_ID($PMD_ID); |
|
644 | 644 | $transaction->save(); |
645 | 645 | } else { |
646 | 646 | EE_Error::add_error( |
647 | - __( 'Please activate at least one Payment Method in order for things to operate correctly.', 'event_espresso' ), |
|
647 | + __('Please activate at least one Payment Method in order for things to operate correctly.', 'event_espresso'), |
|
648 | 648 | __FILE__, __LINE__, __FUNCTION__ |
649 | 649 | ); |
650 | 650 | } |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | * @return EED_Add_New_State |
17 | 17 | */ |
18 | 18 | public static function instance() { |
19 | - return parent::get_instance( __CLASS__ ); |
|
19 | + return parent::get_instance(__CLASS__); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | |
@@ -27,16 +27,16 @@ discard block |
||
27 | 27 | * @return void |
28 | 28 | */ |
29 | 29 | public static function set_hooks() { |
30 | - add_action( 'wp_loaded', array( 'EED_Add_New_State', 'set_definitions' ), 2 ); |
|
31 | - add_action( 'wp_enqueue_scripts', array( 'EED_Add_New_State', 'translate_js_strings' ), 0 ); |
|
32 | - add_action( 'wp_enqueue_scripts', array( 'EED_Add_New_State', 'wp_enqueue_scripts' ), 10 ); |
|
33 | - add_filter( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', array( 'EED_Add_New_State', 'display_add_new_state_micro_form' ), 1, 1 ); |
|
34 | - add_filter( 'FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form', array( 'EED_Add_New_State', 'display_add_new_state_micro_form' ), 1, 1 ); |
|
35 | - add_filter( 'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', array( 'EED_Add_New_State', 'unset_new_state_request_params' ), 10, 1 ); |
|
36 | - add_filter( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', array( 'EED_Add_New_State', 'inject_new_reg_state_into_options' ), 10, 5 ); |
|
37 | - add_filter( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options', array( 'EED_Add_New_State', 'inject_new_reg_country_into_options' ), 10, 5 ); |
|
38 | - add_filter( 'FHEE__EE_State_Select_Input____construct__state_options', array( 'EED_Add_New_State', 'state_options' ), 10, 1 ); |
|
39 | - add_filter( 'FHEE__EE_Country_Select_Input____construct__country_options', array( 'EED_Add_New_State', 'country_options' ), 10, 1 ); |
|
30 | + add_action('wp_loaded', array('EED_Add_New_State', 'set_definitions'), 2); |
|
31 | + add_action('wp_enqueue_scripts', array('EED_Add_New_State', 'translate_js_strings'), 0); |
|
32 | + add_action('wp_enqueue_scripts', array('EED_Add_New_State', 'wp_enqueue_scripts'), 10); |
|
33 | + add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1); |
|
34 | + add_filter('FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form', array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1); |
|
35 | + add_filter('FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', array('EED_Add_New_State', 'unset_new_state_request_params'), 10, 1); |
|
36 | + add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', array('EED_Add_New_State', 'inject_new_reg_state_into_options'), 10, 5); |
|
37 | + add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options', array('EED_Add_New_State', 'inject_new_reg_country_into_options'), 10, 5); |
|
38 | + add_filter('FHEE__EE_State_Select_Input____construct__state_options', array('EED_Add_New_State', 'state_options'), 10, 1); |
|
39 | + add_filter('FHEE__EE_Country_Select_Input____construct__country_options', array('EED_Add_New_State', 'country_options'), 10, 1); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -46,19 +46,19 @@ discard block |
||
46 | 46 | * @return void |
47 | 47 | */ |
48 | 48 | public static function set_hooks_admin() { |
49 | - add_action( 'wp_loaded', array( 'EED_Add_New_State', 'set_definitions' ), 2 ); |
|
50 | - add_filter( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', array( 'EED_Add_New_State', 'display_add_new_state_micro_form' ), 1, 1 ); |
|
51 | - add_filter( 'FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form', array( 'EED_Add_New_State', 'display_add_new_state_micro_form' ), 1, 1 ); |
|
52 | - add_action( 'wp_ajax_espresso_add_new_state', array( 'EED_Add_New_State', 'add_new_state' )); |
|
53 | - add_action( 'wp_ajax_nopriv_espresso_add_new_state', array( 'EED_Add_New_State', 'add_new_state' )); |
|
54 | - add_filter( 'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', array( 'EED_Add_New_State', 'unset_new_state_request_params' ), 10, 1 ); |
|
55 | - add_action( 'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved', array( 'EED_Add_New_State', 'update_country_settings' ), 10, 3 ); |
|
56 | - add_action( 'AHEE__General_Settings_Admin_Page__delete_state__state_deleted', array( 'EED_Add_New_State', 'update_country_settings' ), 10, 3 ); |
|
57 | - add_filter( 'FHEE__EE_State_Select_Input____construct__state_options', array( 'EED_Add_New_State', 'state_options' ), 10, 1 ); |
|
58 | - add_filter( 'FHEE__EE_Country_Select_Input____construct__country_options', array( 'EED_Add_New_State', 'country_options' ), 10, 1 ); |
|
59 | - add_filter( 'FHEE__Single_Page_Checkout___check_form_submission__request_params', array( 'EED_Add_New_State', 'filter_checkout_request_params' ), 10, 1 ); |
|
60 | - add_filter( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', array( 'EED_Add_New_State', 'inject_new_reg_state_into_options' ), 10, 5 ); |
|
61 | - add_filter( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options', array( 'EED_Add_New_State', 'inject_new_reg_country_into_options' ), 10, 5 ); |
|
49 | + add_action('wp_loaded', array('EED_Add_New_State', 'set_definitions'), 2); |
|
50 | + add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1); |
|
51 | + add_filter('FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form', array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1); |
|
52 | + add_action('wp_ajax_espresso_add_new_state', array('EED_Add_New_State', 'add_new_state')); |
|
53 | + add_action('wp_ajax_nopriv_espresso_add_new_state', array('EED_Add_New_State', 'add_new_state')); |
|
54 | + add_filter('FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', array('EED_Add_New_State', 'unset_new_state_request_params'), 10, 1); |
|
55 | + add_action('AHEE__General_Settings_Admin_Page__update_country_settings__state_saved', array('EED_Add_New_State', 'update_country_settings'), 10, 3); |
|
56 | + add_action('AHEE__General_Settings_Admin_Page__delete_state__state_deleted', array('EED_Add_New_State', 'update_country_settings'), 10, 3); |
|
57 | + add_filter('FHEE__EE_State_Select_Input____construct__state_options', array('EED_Add_New_State', 'state_options'), 10, 1); |
|
58 | + add_filter('FHEE__EE_Country_Select_Input____construct__country_options', array('EED_Add_New_State', 'country_options'), 10, 1); |
|
59 | + add_filter('FHEE__Single_Page_Checkout___check_form_submission__request_params', array('EED_Add_New_State', 'filter_checkout_request_params'), 10, 1); |
|
60 | + add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', array('EED_Add_New_State', 'inject_new_reg_state_into_options'), 10, 5); |
|
61 | + add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options', array('EED_Add_New_State', 'inject_new_reg_country_into_options'), 10, 5); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | |
@@ -70,8 +70,8 @@ discard block |
||
70 | 70 | * @return void |
71 | 71 | */ |
72 | 72 | public static function set_definitions() { |
73 | - define( 'ANS_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS ); |
|
74 | - define( 'ANS_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS ); |
|
73 | + define('ANS_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS); |
|
74 | + define('ANS_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * @param \WP $WP |
84 | 84 | * @return void |
85 | 85 | */ |
86 | - public function run( $WP ) { |
|
86 | + public function run($WP) { |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | |
@@ -111,9 +111,9 @@ discard block |
||
111 | 111 | * @return void |
112 | 112 | */ |
113 | 113 | public static function wp_enqueue_scripts() { |
114 | - if ( apply_filters( 'EED_Single_Page_Checkout__SPCO_active', false ) ) { |
|
115 | - wp_register_script( 'add_new_state', ANS_ASSETS_URL . 'add_new_state.js', array( 'espresso_core', 'single_page_checkout' ), EVENT_ESPRESSO_VERSION, true ); |
|
116 | - wp_enqueue_script( 'add_new_state' ); |
|
114 | + if (apply_filters('EED_Single_Page_Checkout__SPCO_active', false)) { |
|
115 | + wp_register_script('add_new_state', ANS_ASSETS_URL.'add_new_state.js', array('espresso_core', 'single_page_checkout'), EVENT_ESPRESSO_VERSION, true); |
|
116 | + wp_enqueue_script('add_new_state'); |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
@@ -127,30 +127,30 @@ discard block |
||
127 | 127 | * @return string |
128 | 128 | */ |
129 | 129 | // public static function display_add_new_state_micro_form( $html, EE_Form_Input_With_Options_Base $input ){ |
130 | - public static function display_add_new_state_micro_form( EE_Form_Section_Proper $question_group_reg_form ){ |
|
130 | + public static function display_add_new_state_micro_form(EE_Form_Section_Proper $question_group_reg_form) { |
|
131 | 131 | // only add the 'new_state_micro_form' when displaying reg forms, |
132 | 132 | // not during processing since we process the 'new_state_micro_form' in it's own AJAX request |
133 | - $action = EE_Registry::instance()->REQ->get( 'action', '' ); |
|
134 | - if ( $action === 'process_reg_step' || $action === 'update_reg_step' ) { |
|
133 | + $action = EE_Registry::instance()->REQ->get('action', ''); |
|
134 | + if ($action === 'process_reg_step' || $action === 'update_reg_step') { |
|
135 | 135 | return $question_group_reg_form; |
136 | 136 | } |
137 | 137 | // is the "state" question in this form section? |
138 | - $input = $question_group_reg_form->get_subsection( 'state' ); |
|
138 | + $input = $question_group_reg_form->get_subsection('state'); |
|
139 | 139 | // we're only doing this for state select inputs |
140 | - if ( $input instanceof EE_State_Select_Input ) { |
|
140 | + if ($input instanceof EE_State_Select_Input) { |
|
141 | 141 | // load helpers |
142 | - EE_Registry::instance()->load_helper( 'HTML' ); |
|
142 | + EE_Registry::instance()->load_helper('HTML'); |
|
143 | 143 | // grab any set values from the request |
144 | - $country_name = str_replace( 'state', 'new_state_country', $input->html_name() ); |
|
145 | - $state_name = str_replace( 'state', 'new_state_name', $input->html_name() ); |
|
146 | - $abbrv_name = str_replace( 'state', 'new_state_abbrv', $input->html_name() ); |
|
147 | - $new_state_submit_id = str_replace( 'state', 'new_state', $input->html_id() ); |
|
144 | + $country_name = str_replace('state', 'new_state_country', $input->html_name()); |
|
145 | + $state_name = str_replace('state', 'new_state_name', $input->html_name()); |
|
146 | + $abbrv_name = str_replace('state', 'new_state_abbrv', $input->html_name()); |
|
147 | + $new_state_submit_id = str_replace('state', 'new_state', $input->html_id()); |
|
148 | 148 | $country_options = array(); |
149 | 149 | $countries = EEM_Country::instance()->get_all_countries(); |
150 | - if ( ! empty( $countries )) { |
|
151 | - foreach( $countries as $country ){ |
|
152 | - if ( $country instanceof EE_Country ) { |
|
153 | - $country_options[ $country->ID() ] = $country->name(); |
|
150 | + if ( ! empty($countries)) { |
|
151 | + foreach ($countries as $country) { |
|
152 | + if ($country instanceof EE_Country) { |
|
153 | + $country_options[$country->ID()] = $country->name(); |
|
154 | 154 | } |
155 | 155 | } |
156 | 156 | } |
@@ -163,8 +163,8 @@ discard block |
||
163 | 163 | // add hidden input to indicate that a new state is being added |
164 | 164 | 'add_new_state' => new EE_Hidden_Input( |
165 | 165 | array( |
166 | - 'html_name' => str_replace( 'state', 'add_new_state', $input->html_name() ), |
|
167 | - 'html_id' => str_replace( 'state', 'add_new_state', $input->html_id() ), |
|
166 | + 'html_name' => str_replace('state', 'add_new_state', $input->html_name()), |
|
167 | + 'html_id' => str_replace('state', 'add_new_state', $input->html_id()), |
|
168 | 168 | 'default' => 0 |
169 | 169 | ) |
170 | 170 | ), |
@@ -176,10 +176,10 @@ discard block |
||
176 | 176 | '', |
177 | 177 | __('click here to add a new state/province', 'event_espresso'), |
178 | 178 | '', |
179 | - 'display-' . $input->html_id(), |
|
179 | + 'display-'.$input->html_id(), |
|
180 | 180 | 'ee-form-add-new-state-lnk display-the-hidden smaller-text hide-if-no-js', |
181 | 181 | '', |
182 | - 'rel="' . $input->html_id() . '"' |
|
182 | + 'rel="'.$input->html_id().'"' |
|
183 | 183 | ) |
184 | 184 | ) |
185 | 185 | ), |
@@ -187,13 +187,13 @@ discard block |
||
187 | 187 | 'add_new_state_micro_form' =>new EE_Form_Section_HTML( |
188 | 188 | apply_filters( |
189 | 189 | 'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_micro_form', |
190 | - EEH_HTML::div( '', $input->html_id() . '-dv', 'ee-form-add-new-state-dv', 'display: none;' ) . |
|
191 | - EEH_HTML::h6( __('If your State/Province does not appear in the list above, you can easily add it by doing the following:', 'event_espresso')) . |
|
192 | - EEH_HTML::ul() . |
|
193 | - EEH_HTML::li( __('first select the Country that your State/Province belongs to', 'event_espresso') ) . |
|
194 | - EEH_HTML::li( __('enter the name of your State/Province', 'event_espresso') ) . |
|
195 | - EEH_HTML::li( __('enter a two to six letter abbreviation for the name of your State/Province', 'event_espresso') ) . |
|
196 | - EEH_HTML::li( __('click the ADD button', 'event_espresso') ) . |
|
190 | + EEH_HTML::div('', $input->html_id().'-dv', 'ee-form-add-new-state-dv', 'display: none;'). |
|
191 | + EEH_HTML::h6(__('If your State/Province does not appear in the list above, you can easily add it by doing the following:', 'event_espresso')). |
|
192 | + EEH_HTML::ul(). |
|
193 | + EEH_HTML::li(__('first select the Country that your State/Province belongs to', 'event_espresso')). |
|
194 | + EEH_HTML::li(__('enter the name of your State/Province', 'event_espresso')). |
|
195 | + EEH_HTML::li(__('enter a two to six letter abbreviation for the name of your State/Province', 'event_espresso')). |
|
196 | + EEH_HTML::li(__('click the ADD button', 'event_espresso')). |
|
197 | 197 | EEH_HTML::ulx() |
198 | 198 | ) |
199 | 199 | ), |
@@ -202,10 +202,10 @@ discard block |
||
202 | 202 | $country_options, |
203 | 203 | array( |
204 | 204 | 'html_name' => $country_name, |
205 | - 'html_id' => str_replace( 'state', 'new_state_country', $input->html_id() ), |
|
206 | - 'html_class' => $input->html_class() . ' new-state-country', |
|
205 | + 'html_id' => str_replace('state', 'new_state_country', $input->html_id()), |
|
206 | + 'html_class' => $input->html_class().' new-state-country', |
|
207 | 207 | 'html_label_text' => __('New State/Province Country', 'event_espresso'), |
208 | - 'default' => EE_Registry::instance()->REQ->get( $country_name, '' ), |
|
208 | + 'default' => EE_Registry::instance()->REQ->get($country_name, ''), |
|
209 | 209 | 'required' => false |
210 | 210 | ) |
211 | 211 | ), |
@@ -213,23 +213,23 @@ discard block |
||
213 | 213 | 'new_state_name' => new EE_Text_Input( |
214 | 214 | array( |
215 | 215 | 'html_name' => $state_name, |
216 | - 'html_id' => str_replace( 'state', 'new_state_name', $input->html_id() ), |
|
217 | - 'html_class' => $input->html_class() . ' new-state-state', |
|
216 | + 'html_id' => str_replace('state', 'new_state_name', $input->html_id()), |
|
217 | + 'html_class' => $input->html_class().' new-state-state', |
|
218 | 218 | 'html_label_text' => __('New State/Province Name', 'event_espresso'), |
219 | - 'default' => EE_Registry::instance()->REQ->get( $state_name, '' ), |
|
219 | + 'default' => EE_Registry::instance()->REQ->get($state_name, ''), |
|
220 | 220 | 'required' => false |
221 | 221 | ) |
222 | 222 | ), |
223 | - 'spacer' => new EE_Form_Section_HTML( EEH_HTML::br() ), |
|
223 | + 'spacer' => new EE_Form_Section_HTML(EEH_HTML::br()), |
|
224 | 224 | // NEW STATE NAME |
225 | 225 | 'new_state_abbrv' => new EE_Text_Input( |
226 | 226 | array( |
227 | 227 | 'html_name' => $abbrv_name, |
228 | - 'html_id' => str_replace( 'state', 'new_state_abbrv', $input->html_id() ), |
|
229 | - 'html_class' => $input->html_class() . ' new-state-abbrv', |
|
228 | + 'html_id' => str_replace('state', 'new_state_abbrv', $input->html_id()), |
|
229 | + 'html_class' => $input->html_class().' new-state-abbrv', |
|
230 | 230 | 'html_label_text' => __('New State/Province Abbreviation', 'event_espresso'), |
231 | 231 | 'html_other_attributes' => 'size="24"', |
232 | - 'default' => EE_Registry::instance()->REQ->get( $abbrv_name, '' ), |
|
232 | + 'default' => EE_Registry::instance()->REQ->get($abbrv_name, ''), |
|
233 | 233 | 'required' => false |
234 | 234 | ) |
235 | 235 | ), |
@@ -237,26 +237,26 @@ discard block |
||
237 | 237 | 'add_new_state_submit_button' => new EE_Form_Section_HTML( |
238 | 238 | apply_filters( |
239 | 239 | 'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_submit_button', |
240 | - EEH_HTML::nbsp(3) . |
|
241 | - EEH_HTML::link( '', __('ADD', 'event_espresso'), '', 'submit-' . $new_state_submit_id, 'ee-form-add-new-state-submit button button-secondary', '', 'rel="' . $new_state_submit_id . '"' ) |
|
240 | + EEH_HTML::nbsp(3). |
|
241 | + EEH_HTML::link('', __('ADD', 'event_espresso'), '', 'submit-'.$new_state_submit_id, 'ee-form-add-new-state-submit button button-secondary', '', 'rel="'.$new_state_submit_id.'"') |
|
242 | 242 | ) |
243 | 243 | ), |
244 | 244 | // extra info |
245 | 245 | 'add_new_state_extra' => new EE_Form_Section_HTML( |
246 | 246 | apply_filters( |
247 | 247 | 'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_extra', |
248 | - EEH_HTML::br(2) . |
|
249 | - EEH_HTML::div( '', '', 'small-text' ) . |
|
250 | - EEH_HTML::strong( __('Don\'t know your State/Province Abbreviation?', 'event_espresso') ) . |
|
251 | - EEH_HTML::br() . |
|
248 | + EEH_HTML::br(2). |
|
249 | + EEH_HTML::div('', '', 'small-text'). |
|
250 | + EEH_HTML::strong(__('Don\'t know your State/Province Abbreviation?', 'event_espresso')). |
|
251 | + EEH_HTML::br(). |
|
252 | 252 | sprintf( |
253 | 253 | __('You can look here: %s, for a list of Countries and links to their State/Province Abbreviations ("Subdivisions assigned codes" column).', 'event_espresso'), |
254 | - EEH_HTML::link( 'http://en.wikipedia.org/wiki/ISO_3166-2', 'http://en.wikipedia.org/wiki/ISO_3166-2', '', '', 'ee-form-add-new-state-wiki-lnk' ) |
|
255 | - ) . |
|
256 | - EEH_HTML::divx() . |
|
257 | - EEH_HTML::br() . |
|
258 | - EEH_HTML::link( '', __('cancel new state/province', 'event_espresso'), '', 'hide-' . $input->html_id(), 'ee-form-cancel-new-state-lnk smaller-text', '', 'rel="' . $input->html_id() . '"' ) . |
|
259 | - EEH_HTML::divx() . |
|
254 | + EEH_HTML::link('http://en.wikipedia.org/wiki/ISO_3166-2', 'http://en.wikipedia.org/wiki/ISO_3166-2', '', '', 'ee-form-add-new-state-wiki-lnk') |
|
255 | + ). |
|
256 | + EEH_HTML::divx(). |
|
257 | + EEH_HTML::br(). |
|
258 | + EEH_HTML::link('', __('cancel new state/province', 'event_espresso'), '', 'hide-'.$input->html_id(), 'ee-form-cancel-new-state-lnk smaller-text', '', 'rel="'.$input->html_id().'"'). |
|
259 | + EEH_HTML::divx(). |
|
260 | 260 | EEH_HTML::br() |
261 | 261 | ) |
262 | 262 | ) |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | ) |
265 | 265 | ) |
266 | 266 | ); |
267 | - $question_group_reg_form->add_subsections( array( 'new_state_micro_form' => $new_state_micro_form ), 'state', false ); |
|
267 | + $question_group_reg_form->add_subsections(array('new_state_micro_form' => $new_state_micro_form), 'state', false); |
|
268 | 268 | } |
269 | 269 | return $question_group_reg_form; |
270 | 270 | } |
@@ -281,41 +281,41 @@ discard block |
||
281 | 281 | */ |
282 | 282 | public static function add_new_state() { |
283 | 283 | $REQ = EE_Registry::instance()->load_core('Request_Handler'); |
284 | - if ( $REQ->is_set( 'add_new_state' ) && $REQ->get( 'add_new_state' ) == 1 ) { |
|
284 | + if ($REQ->is_set('add_new_state') && $REQ->get('add_new_state') == 1) { |
|
285 | 285 | EE_Registry::instance()->load_model('State'); |
286 | 286 | // grab country ISO code, new state name, and new state abbreviation |
287 | - $state_country = $REQ->is_set( 'new_state_country' ) ? sanitize_text_field( $REQ->get( 'new_state_country' )) : FALSE; |
|
288 | - $state_name = $REQ->is_set( 'new_state_name' ) ? sanitize_text_field( $REQ->get( 'new_state_name' )) : FALSE; |
|
289 | - $state_abbr = $REQ->is_set( 'new_state_abbrv' ) ? sanitize_text_field( $REQ->get( 'new_state_abbrv' )) : FALSE; |
|
287 | + $state_country = $REQ->is_set('new_state_country') ? sanitize_text_field($REQ->get('new_state_country')) : FALSE; |
|
288 | + $state_name = $REQ->is_set('new_state_name') ? sanitize_text_field($REQ->get('new_state_name')) : FALSE; |
|
289 | + $state_abbr = $REQ->is_set('new_state_abbrv') ? sanitize_text_field($REQ->get('new_state_abbrv')) : FALSE; |
|
290 | 290 | |
291 | 291 | //echo '<h4>$state_country : ' . $state_country . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; |
292 | 292 | //echo '<h4>$state_name : ' . $state_name . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; |
293 | 293 | //echo '<h4>$state_abbr : ' . $state_abbr . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; |
294 | 294 | |
295 | - if ( $state_country && $state_name && $state_abbr ) { |
|
296 | - $new_state = EED_Add_New_State::save_new_state_to_db( array( |
|
297 | - 'CNT_ISO'=> strtoupper( $state_country ), |
|
298 | - 'STA_abbrev' => strtoupper( $state_abbr ), |
|
299 | - 'STA_name' => ucwords( $state_name ), |
|
295 | + if ($state_country && $state_name && $state_abbr) { |
|
296 | + $new_state = EED_Add_New_State::save_new_state_to_db(array( |
|
297 | + 'CNT_ISO'=> strtoupper($state_country), |
|
298 | + 'STA_abbrev' => strtoupper($state_abbr), |
|
299 | + 'STA_name' => ucwords($state_name), |
|
300 | 300 | 'STA_active' => FALSE |
301 | 301 | )); |
302 | 302 | |
303 | - if ( $new_state instanceof EE_State ) { |
|
303 | + if ($new_state instanceof EE_State) { |
|
304 | 304 | // clean house |
305 | - EE_Registry::instance()->REQ->un_set( 'add_new_state' ); |
|
306 | - EE_Registry::instance()->REQ->un_set( 'new_state_country' ); |
|
307 | - EE_Registry::instance()->REQ->un_set( 'new_state_name' ); |
|
308 | - EE_Registry::instance()->REQ->un_set( 'new_state_abbrv' ); |
|
305 | + EE_Registry::instance()->REQ->un_set('add_new_state'); |
|
306 | + EE_Registry::instance()->REQ->un_set('new_state_country'); |
|
307 | + EE_Registry::instance()->REQ->un_set('new_state_name'); |
|
308 | + EE_Registry::instance()->REQ->un_set('new_state_abbrv'); |
|
309 | 309 | |
310 | 310 | // get any existing new states |
311 | 311 | $new_states = EE_Registry::instance()->SSN->get_session_data( |
312 | 312 | 'new_states' |
313 | 313 | ); |
314 | - $new_states[ $new_state->ID() ] = $new_state; |
|
315 | - EE_Registry::instance()->SSN->set_session_data( array( 'new_states' => $new_states )); |
|
314 | + $new_states[$new_state->ID()] = $new_state; |
|
315 | + EE_Registry::instance()->SSN->set_session_data(array('new_states' => $new_states)); |
|
316 | 316 | |
317 | - if ( EE_Registry::instance()->REQ->ajax ) { |
|
318 | - echo json_encode( array( |
|
317 | + if (EE_Registry::instance()->REQ->ajax) { |
|
318 | + echo json_encode(array( |
|
319 | 319 | 'success' => TRUE, |
320 | 320 | 'id' => $new_state->ID(), |
321 | 321 | 'name' => $new_state->name(), |
@@ -330,12 +330,12 @@ discard block |
||
330 | 330 | } |
331 | 331 | |
332 | 332 | } else { |
333 | - $error = __( 'A new State/Province could not be added because invalid or missing data was received.', 'event_espresso' ); |
|
334 | - if ( EE_Registry::instance()->REQ->ajax ) { |
|
335 | - echo json_encode( array( 'error' => $error )); |
|
333 | + $error = __('A new State/Province could not be added because invalid or missing data was received.', 'event_espresso'); |
|
334 | + if (EE_Registry::instance()->REQ->ajax) { |
|
335 | + echo json_encode(array('error' => $error)); |
|
336 | 336 | exit(); |
337 | 337 | } else { |
338 | - EE_Error::add_error( $error, __FILE__, __FUNCTION__, __LINE__ ); |
|
338 | + EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
339 | 339 | } |
340 | 340 | } |
341 | 341 | } |
@@ -353,11 +353,11 @@ discard block |
||
353 | 353 | * @param array $request_params |
354 | 354 | * @return array |
355 | 355 | */ |
356 | - public static function filter_checkout_request_params ( $request_params ) { |
|
357 | - foreach ( $request_params as $form_section ) { |
|
358 | - if ( is_array( $form_section )) { |
|
359 | - EED_Add_New_State::unset_new_state_request_params( $form_section ); |
|
360 | - EED_Add_New_State::filter_checkout_request_params( $form_section ); |
|
356 | + public static function filter_checkout_request_params($request_params) { |
|
357 | + foreach ($request_params as $form_section) { |
|
358 | + if (is_array($form_section)) { |
|
359 | + EED_Add_New_State::unset_new_state_request_params($form_section); |
|
360 | + EED_Add_New_State::filter_checkout_request_params($form_section); |
|
361 | 361 | } |
362 | 362 | } |
363 | 363 | return $request_params; |
@@ -372,12 +372,12 @@ discard block |
||
372 | 372 | * @param array $request_params |
373 | 373 | * @return boolean |
374 | 374 | */ |
375 | - public static function unset_new_state_request_params ( $request_params ) { |
|
376 | - unset( $request_params[ 'new_state_micro_form' ] ); |
|
377 | - unset( $request_params[ 'add_new_state' ] ); |
|
378 | - unset( $request_params[ 'new_state_country' ] ); |
|
379 | - unset( $request_params[ 'new_state_name' ] ); |
|
380 | - unset( $request_params[ 'new_state_abbrv' ] ); |
|
375 | + public static function unset_new_state_request_params($request_params) { |
|
376 | + unset($request_params['new_state_micro_form']); |
|
377 | + unset($request_params['add_new_state']); |
|
378 | + unset($request_params['new_state_country']); |
|
379 | + unset($request_params['new_state_name']); |
|
380 | + unset($request_params['new_state_abbrv']); |
|
381 | 381 | return $request_params; |
382 | 382 | } |
383 | 383 | |
@@ -390,25 +390,25 @@ discard block |
||
390 | 390 | * @param array $props_n_values |
391 | 391 | * @return boolean |
392 | 392 | */ |
393 | - public static function save_new_state_to_db ( $props_n_values = array() ) { |
|
393 | + public static function save_new_state_to_db($props_n_values = array()) { |
|
394 | 394 | // EEH_Debug_Tools::printr( $props_n_values, '$props_n_values <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
395 | - $existing_state = EEM_State::instance()->get_all( array( $props_n_values, 'limit' => 1 )); |
|
396 | - if ( ! empty( $existing_state )) { |
|
397 | - return array_pop( $existing_state ); |
|
395 | + $existing_state = EEM_State::instance()->get_all(array($props_n_values, 'limit' => 1)); |
|
396 | + if ( ! empty($existing_state)) { |
|
397 | + return array_pop($existing_state); |
|
398 | 398 | } |
399 | - $new_state = EE_State::new_instance( $props_n_values ); |
|
400 | - if ( $new_state instanceof EE_State ) { |
|
399 | + $new_state = EE_State::new_instance($props_n_values); |
|
400 | + if ($new_state instanceof EE_State) { |
|
401 | 401 | // if not non-ajax admin |
402 | - $new_state_key = $new_state->country_iso() . '-' . $new_state->abbrev(); |
|
402 | + $new_state_key = $new_state->country_iso().'-'.$new_state->abbrev(); |
|
403 | 403 | $new_state_notice = sprintf( |
404 | - __( 'A new State named "%1$s (%2$s)" was dynamically added from an Event Espresso form for the Country of "%3$s".%5$sTo verify, edit, and/or delete this new State, please go to the %4$s and update the States / Provinces section.%5$sCheck "Yes" to have this new State added to dropdown select lists in forms.', 'event_espresso' ), |
|
405 | - '<b>' . $new_state->name() . '</b>', |
|
406 | - '<b>' . $new_state->abbrev() . '</b>', |
|
407 | - '<b>' . $new_state->country()->name() . '</b>', |
|
408 | - '<a href="' . add_query_arg( array( 'page' => 'espresso_general_settings', 'action' => 'country_settings', 'country' => $new_state->country_iso() ), admin_url( 'admin.php' )) . '">' . __( 'Event Espresso - General Settings > Countries Tab', 'event_espresso' ) . '</a>', |
|
404 | + __('A new State named "%1$s (%2$s)" was dynamically added from an Event Espresso form for the Country of "%3$s".%5$sTo verify, edit, and/or delete this new State, please go to the %4$s and update the States / Provinces section.%5$sCheck "Yes" to have this new State added to dropdown select lists in forms.', 'event_espresso'), |
|
405 | + '<b>'.$new_state->name().'</b>', |
|
406 | + '<b>'.$new_state->abbrev().'</b>', |
|
407 | + '<b>'.$new_state->country()->name().'</b>', |
|
408 | + '<a href="'.add_query_arg(array('page' => 'espresso_general_settings', 'action' => 'country_settings', 'country' => $new_state->country_iso()), admin_url('admin.php')).'">'.__('Event Espresso - General Settings > Countries Tab', 'event_espresso').'</a>', |
|
409 | 409 | '<br />' |
410 | 410 | ); |
411 | - EE_Error::add_persistent_admin_notice( $new_state_key, $new_state_notice ); |
|
411 | + EE_Error::add_persistent_admin_notice($new_state_key, $new_state_notice); |
|
412 | 412 | $new_state->save(); |
413 | 413 | EEM_State::instance()->reset_cached_states(); |
414 | 414 | return $new_state; |
@@ -427,22 +427,22 @@ discard block |
||
427 | 427 | * @param array $cols_n_values |
428 | 428 | * @return boolean |
429 | 429 | */ |
430 | - public static function update_country_settings( $CNT_ISO = '', $STA_ID = '', $cols_n_values = array() ) { |
|
431 | - $CNT_ISO = ! empty( $CNT_ISO ) ? $CNT_ISO : FALSE; |
|
432 | - if ( ! $CNT_ISO ) { |
|
433 | - EE_Error::add_error( __( 'An invalid or missing Country ISO Code was received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
430 | + public static function update_country_settings($CNT_ISO = '', $STA_ID = '', $cols_n_values = array()) { |
|
431 | + $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : FALSE; |
|
432 | + if ( ! $CNT_ISO) { |
|
433 | + EE_Error::add_error(__('An invalid or missing Country ISO Code was received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
434 | 434 | } |
435 | - $STA_abbrev = is_array( $cols_n_values ) && isset( $cols_n_values['STA_abbrev'] ) ? $cols_n_values['STA_abbrev'] : FALSE; |
|
436 | - if ( ! $STA_abbrev && ! empty( $STA_ID )) { |
|
437 | - $state = EEM_State::instance()->get_one_by_ID( $STA_ID ); |
|
438 | - if ( $state instanceof EE_State ) { |
|
435 | + $STA_abbrev = is_array($cols_n_values) && isset($cols_n_values['STA_abbrev']) ? $cols_n_values['STA_abbrev'] : FALSE; |
|
436 | + if ( ! $STA_abbrev && ! empty($STA_ID)) { |
|
437 | + $state = EEM_State::instance()->get_one_by_ID($STA_ID); |
|
438 | + if ($state instanceof EE_State) { |
|
439 | 439 | $STA_abbrev = $state->abbrev(); |
440 | 440 | } |
441 | 441 | } |
442 | - if ( ! $STA_abbrev ) { |
|
443 | - EE_Error::add_error( __( 'An invalid or missing State Abbreviation was received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
442 | + if ( ! $STA_abbrev) { |
|
443 | + EE_Error::add_error(__('An invalid or missing State Abbreviation was received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
444 | 444 | } |
445 | - EE_Error::dismiss_persistent_admin_notice( $CNT_ISO . '-' . $STA_abbrev, TRUE, TRUE ); |
|
445 | + EE_Error::dismiss_persistent_admin_notice($CNT_ISO.'-'.$STA_abbrev, TRUE, TRUE); |
|
446 | 446 | } |
447 | 447 | |
448 | 448 | |
@@ -458,19 +458,19 @@ discard block |
||
458 | 458 | * @param $answer |
459 | 459 | * @return bool |
460 | 460 | */ |
461 | - public static function inject_new_reg_state_into_options( $state_options = array(), EE_SPCO_Reg_Step_Attendee_Information $reg_step, EE_Registration $registration, EE_Question $question, $answer ) { |
|
462 | - if ( $answer instanceof EE_Answer && $question instanceof EE_Question && $question->type() === EEM_Question::QST_type_state ) { |
|
461 | + public static function inject_new_reg_state_into_options($state_options = array(), EE_SPCO_Reg_Step_Attendee_Information $reg_step, EE_Registration $registration, EE_Question $question, $answer) { |
|
462 | + if ($answer instanceof EE_Answer && $question instanceof EE_Question && $question->type() === EEM_Question::QST_type_state) { |
|
463 | 463 | $STA_ID = $answer->value(); |
464 | - if ( ! empty( $STA_ID ) ) { |
|
465 | - $state = EEM_State::instance()->get_one_by_ID( $STA_ID ); |
|
466 | - if ( $state instanceof EE_State ) { |
|
464 | + if ( ! empty($STA_ID)) { |
|
465 | + $state = EEM_State::instance()->get_one_by_ID($STA_ID); |
|
466 | + if ($state instanceof EE_State) { |
|
467 | 467 | $country = $state->country(); |
468 | - if ( $country instanceof EE_Country ) { |
|
469 | - if ( ! isset( $state_options[ $country->name() ] )) { |
|
470 | - $state_options[ $country->name() ] = array(); |
|
468 | + if ($country instanceof EE_Country) { |
|
469 | + if ( ! isset($state_options[$country->name()])) { |
|
470 | + $state_options[$country->name()] = array(); |
|
471 | 471 | } |
472 | - if ( ! isset( $state_options[ $country->name() ][ $STA_ID ] )) { |
|
473 | - $state_options[ $country->name() ][ $STA_ID ] = $state->name(); |
|
472 | + if ( ! isset($state_options[$country->name()][$STA_ID])) { |
|
473 | + $state_options[$country->name()][$STA_ID] = $state->name(); |
|
474 | 474 | } |
475 | 475 | } |
476 | 476 | } |
@@ -492,14 +492,14 @@ discard block |
||
492 | 492 | * @param $answer |
493 | 493 | * @return bool |
494 | 494 | */ |
495 | - public static function inject_new_reg_country_into_options( $country_options = array(), EE_SPCO_Reg_Step_Attendee_Information $reg_step, EE_Registration $registration, EE_Question $question, $answer ) { |
|
496 | - if ( $answer instanceof EE_Answer && $question instanceof EE_Question && $question->type() === EEM_Question::QST_type_country ) { |
|
495 | + public static function inject_new_reg_country_into_options($country_options = array(), EE_SPCO_Reg_Step_Attendee_Information $reg_step, EE_Registration $registration, EE_Question $question, $answer) { |
|
496 | + if ($answer instanceof EE_Answer && $question instanceof EE_Question && $question->type() === EEM_Question::QST_type_country) { |
|
497 | 497 | $CNT_ISO = $answer->value(); |
498 | - if ( ! empty( $CNT_ISO ) ) { |
|
499 | - $country = EEM_Country::instance()->get_one_by_ID( $CNT_ISO ); |
|
500 | - if ( $country instanceof EE_Country ) { |
|
501 | - if ( ! isset( $country_options[ $CNT_ISO ] ) ) { |
|
502 | - $country_options[ $CNT_ISO ] = $country->name(); |
|
498 | + if ( ! empty($CNT_ISO)) { |
|
499 | + $country = EEM_Country::instance()->get_one_by_ID($CNT_ISO); |
|
500 | + if ($country instanceof EE_Country) { |
|
501 | + if ( ! isset($country_options[$CNT_ISO])) { |
|
502 | + $country_options[$CNT_ISO] = $country->name(); |
|
503 | 503 | } |
504 | 504 | } |
505 | 505 | } |
@@ -516,17 +516,17 @@ discard block |
||
516 | 516 | * @param EE_State[] $state_options |
517 | 517 | * @return boolean |
518 | 518 | */ |
519 | - public static function state_options( $state_options = array() ) { |
|
519 | + public static function state_options($state_options = array()) { |
|
520 | 520 | $new_states = EE_Registry::instance()->SSN->get_session_data( |
521 | 521 | 'new_states' |
522 | 522 | ); |
523 | - if ( is_array( $new_states ) && ! empty( $new_states )) { |
|
524 | - foreach ( $new_states as $new_state ) { |
|
523 | + if (is_array($new_states) && ! empty($new_states)) { |
|
524 | + foreach ($new_states as $new_state) { |
|
525 | 525 | if ( |
526 | 526 | $new_state instanceof EE_State |
527 | 527 | && $new_state->country() instanceof EE_Country |
528 | 528 | ) { |
529 | - $state_options[ $new_state->country()->name() ][ $new_state->ID() ] = $new_state->name(); |
|
529 | + $state_options[$new_state->country()->name()][$new_state->ID()] = $new_state->name(); |
|
530 | 530 | } |
531 | 531 | } |
532 | 532 | } |
@@ -542,17 +542,17 @@ discard block |
||
542 | 542 | * @param EE_Country[] $country_options |
543 | 543 | * @return boolean |
544 | 544 | */ |
545 | - public static function country_options( $country_options = array() ) { |
|
545 | + public static function country_options($country_options = array()) { |
|
546 | 546 | $new_states = EE_Registry::instance()->SSN->get_session_data( |
547 | 547 | 'new_states' |
548 | 548 | ); |
549 | - if ( is_array( $new_states ) && ! empty( $new_states )) { |
|
550 | - foreach ( $new_states as $new_state ) { |
|
549 | + if (is_array($new_states) && ! empty($new_states)) { |
|
550 | + foreach ($new_states as $new_state) { |
|
551 | 551 | if ( |
552 | 552 | $new_state instanceof EE_State |
553 | 553 | && $new_state->country() instanceof EE_Country |
554 | 554 | ) { |
555 | - $country_options[ $new_state->country()->ID() ] = $new_state->country()->name(); |
|
555 | + $country_options[$new_state->country()->ID()] = $new_state->country()->name(); |
|
556 | 556 | } |
557 | 557 | } |
558 | 558 | } |
@@ -1,13 +1,13 @@ |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2 | 2 | /** |
3 | - * |
|
4 | - * EED_Add_New_State class |
|
5 | - * |
|
6 | - * @package Event Espresso |
|
7 | - * @subpackage /modules/add_new_state/ |
|
8 | - * @author Brent Christensen |
|
9 | - * |
|
10 | - */ |
|
3 | + * |
|
4 | + * EED_Add_New_State class |
|
5 | + * |
|
6 | + * @package Event Espresso |
|
7 | + * @subpackage /modules/add_new_state/ |
|
8 | + * @author Brent Christensen |
|
9 | + * |
|
10 | + */ |
|
11 | 11 | class EED_Add_New_State extends EED_Module { |
12 | 12 | |
13 | 13 |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | * @return EED_Single_Page_Checkout |
39 | 39 | */ |
40 | 40 | public static function instance() { |
41 | - add_filter( 'EED_Single_Page_Checkout__SPCO_active', '__return_true' ); |
|
42 | - return parent::get_instance( __CLASS__ ); |
|
41 | + add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true'); |
|
42 | + return parent::get_instance(__CLASS__); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | |
@@ -84,22 +84,22 @@ discard block |
||
84 | 84 | */ |
85 | 85 | public static function set_hooks_admin() { |
86 | 86 | EED_Single_Page_Checkout::set_definitions(); |
87 | - if ( defined( 'DOING_AJAX' )) { |
|
87 | + if (defined('DOING_AJAX')) { |
|
88 | 88 | // going to start an output buffer in case anything gets accidentally output that might disrupt our JSON response |
89 | 89 | ob_start(); |
90 | 90 | EED_Single_Page_Checkout::load_request_handler(); |
91 | 91 | EED_Single_Page_Checkout::load_reg_steps(); |
92 | 92 | } else { |
93 | 93 | // 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 |
94 | - add_action( 'pre_get_posts', array( 'EED_Single_Page_Checkout', 'load_reg_steps' ), 1 ); |
|
94 | + add_action('pre_get_posts', array('EED_Single_Page_Checkout', 'load_reg_steps'), 1); |
|
95 | 95 | } |
96 | 96 | // set ajax hooks |
97 | - add_action( 'wp_ajax_process_reg_step', array( 'EED_Single_Page_Checkout', 'process_reg_step' )); |
|
98 | - add_action( 'wp_ajax_nopriv_process_reg_step', array( 'EED_Single_Page_Checkout', 'process_reg_step' )); |
|
99 | - add_action( 'wp_ajax_display_spco_reg_step', array( 'EED_Single_Page_Checkout', 'display_reg_step' )); |
|
100 | - add_action( 'wp_ajax_nopriv_display_spco_reg_step', array( 'EED_Single_Page_Checkout', 'display_reg_step' )); |
|
101 | - add_action( 'wp_ajax_update_reg_step', array( 'EED_Single_Page_Checkout', 'update_reg_step' )); |
|
102 | - add_action( 'wp_ajax_nopriv_update_reg_step', array( 'EED_Single_Page_Checkout', 'update_reg_step' )); |
|
97 | + add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
98 | + add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
99 | + add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
100 | + add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
101 | + add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
102 | + add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -108,8 +108,8 @@ discard block |
||
108 | 108 | * process ajax request |
109 | 109 | * @param string $ajax_action |
110 | 110 | */ |
111 | - public static function process_ajax_request( $ajax_action ) { |
|
112 | - EE_Registry::instance()->REQ->set( 'action', $ajax_action ); |
|
111 | + public static function process_ajax_request($ajax_action) { |
|
112 | + EE_Registry::instance()->REQ->set('action', $ajax_action); |
|
113 | 113 | EED_Single_Page_Checkout::instance()->_initialize(); |
114 | 114 | } |
115 | 115 | |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * ajax display registration step |
120 | 120 | */ |
121 | 121 | public static function display_reg_step() { |
122 | - EED_Single_Page_Checkout::process_ajax_request( 'display_spco_reg_step' ); |
|
122 | + EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step'); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * ajax process registration step |
129 | 129 | */ |
130 | 130 | public static function process_reg_step() { |
131 | - EED_Single_Page_Checkout::process_ajax_request( 'process_reg_step' ); |
|
131 | + EED_Single_Page_Checkout::process_ajax_request('process_reg_step'); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * ajax process registration step |
138 | 138 | */ |
139 | 139 | public static function update_reg_step() { |
140 | - EED_Single_Page_Checkout::process_ajax_request( 'update_reg_step' ); |
|
140 | + EED_Single_Page_Checkout::process_ajax_request('update_reg_step'); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * @return void |
150 | 150 | */ |
151 | 151 | public static function update_checkout() { |
152 | - EED_Single_Page_Checkout::process_ajax_request( 'update_checkout' ); |
|
152 | + EED_Single_Page_Checkout::process_ajax_request('update_checkout'); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | |
@@ -162,8 +162,8 @@ discard block |
||
162 | 162 | */ |
163 | 163 | public static function load_request_handler() { |
164 | 164 | // load core Request_Handler class |
165 | - if ( ! isset( EE_Registry::instance()->REQ )) { |
|
166 | - EE_Registry::instance()->load_core( 'Request_Handler' ); |
|
165 | + if ( ! isset(EE_Registry::instance()->REQ)) { |
|
166 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
167 | 167 | } |
168 | 168 | } |
169 | 169 | |
@@ -176,14 +176,14 @@ discard block |
||
176 | 176 | * @return void |
177 | 177 | */ |
178 | 178 | public static function set_definitions() { |
179 | - define( 'SPCO_BASE_PATH', rtrim( str_replace( array( '\\', '/' ), DS, plugin_dir_path( __FILE__ )), DS ) . DS ); |
|
180 | - define( 'SPCO_CSS_URL', plugin_dir_url( __FILE__ ) . 'css' . DS ); |
|
181 | - define( 'SPCO_IMG_URL', plugin_dir_url( __FILE__ ) . 'img' . DS ); |
|
182 | - define( 'SPCO_JS_URL', plugin_dir_url( __FILE__ ) . 'js' . DS ); |
|
183 | - define( 'SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS ); |
|
184 | - define( 'SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS ); |
|
185 | - define( 'SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS ); |
|
186 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( SPCO_BASE_PATH, TRUE ); |
|
179 | + define('SPCO_BASE_PATH', rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS).DS); |
|
180 | + define('SPCO_CSS_URL', plugin_dir_url(__FILE__).'css'.DS); |
|
181 | + define('SPCO_IMG_URL', plugin_dir_url(__FILE__).'img'.DS); |
|
182 | + define('SPCO_JS_URL', plugin_dir_url(__FILE__).'js'.DS); |
|
183 | + define('SPCO_INC_PATH', SPCO_BASE_PATH.'inc'.DS); |
|
184 | + define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH.'reg_steps'.DS); |
|
185 | + define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH.'templates'.DS); |
|
186 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, TRUE); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | |
@@ -198,31 +198,31 @@ discard block |
||
198 | 198 | */ |
199 | 199 | public static function load_reg_steps() { |
200 | 200 | static $reg_steps_loaded = FALSE; |
201 | - if ( $reg_steps_loaded ) { |
|
201 | + if ($reg_steps_loaded) { |
|
202 | 202 | return; |
203 | 203 | } |
204 | 204 | // load EE_SPCO_Reg_Step base class |
205 | 205 | // EE_Registry::instance()->load_file( SPCO_INC_PATH, 'EE_SPCO_Reg_Step', 'class' ); |
206 | 206 | // filter list of reg_steps |
207 | - $reg_steps_to_load = apply_filters( 'AHEE__SPCO__load_reg_steps__reg_steps_to_load', EED_Single_Page_Checkout::get_reg_steps() ); |
|
207 | + $reg_steps_to_load = apply_filters('AHEE__SPCO__load_reg_steps__reg_steps_to_load', EED_Single_Page_Checkout::get_reg_steps()); |
|
208 | 208 | // sort by key (order) |
209 | - ksort( $reg_steps_to_load ); |
|
209 | + ksort($reg_steps_to_load); |
|
210 | 210 | // loop through folders |
211 | - foreach ( $reg_steps_to_load as $order => $reg_step ) { |
|
211 | + foreach ($reg_steps_to_load as $order => $reg_step) { |
|
212 | 212 | // we need a |
213 | - if ( isset( $reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'] )) { |
|
213 | + if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
214 | 214 | // copy over to the reg_steps_array |
215 | - EED_Single_Page_Checkout::$_reg_steps_array[ $order ] = $reg_step; |
|
215 | + EED_Single_Page_Checkout::$_reg_steps_array[$order] = $reg_step; |
|
216 | 216 | // register custom key route for each reg step ( ie: step=>"slug" - this is the entire reason we load the reg steps array now ) |
217 | - EE_Config::register_route( $reg_step['slug'], 'EED_Single_Page_Checkout', 'run', 'step' ); |
|
217 | + EE_Config::register_route($reg_step['slug'], 'EED_Single_Page_Checkout', 'run', 'step'); |
|
218 | 218 | // add AJAX or other hooks |
219 | - if ( isset( $reg_step['has_hooks'] ) && $reg_step['has_hooks'] ) { |
|
219 | + if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) { |
|
220 | 220 | // setup autoloaders if necessary |
221 | - if ( ! class_exists( $reg_step['class_name'] )) { |
|
222 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( $reg_step['file_path'], TRUE ); |
|
221 | + if ( ! class_exists($reg_step['class_name'])) { |
|
222 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder($reg_step['file_path'], TRUE); |
|
223 | 223 | } |
224 | - if ( is_callable( $reg_step['class_name'], 'set_hooks' )) { |
|
225 | - call_user_func( array( $reg_step['class_name'], 'set_hooks' )); |
|
224 | + if (is_callable($reg_step['class_name'], 'set_hooks')) { |
|
225 | + call_user_func(array($reg_step['class_name'], 'set_hooks')); |
|
226 | 226 | } |
227 | 227 | } |
228 | 228 | } |
@@ -241,28 +241,28 @@ discard block |
||
241 | 241 | */ |
242 | 242 | public static function get_reg_steps() { |
243 | 243 | $reg_steps = EE_Registry::instance()->CFG->registration->reg_steps; |
244 | - if ( empty( $reg_steps )) { |
|
244 | + if (empty($reg_steps)) { |
|
245 | 245 | $reg_steps = array( |
246 | 246 | 10 => array( |
247 | - 'file_path' => SPCO_REG_STEPS_PATH . 'attendee_information', |
|
247 | + 'file_path' => SPCO_REG_STEPS_PATH.'attendee_information', |
|
248 | 248 | 'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information', |
249 | 249 | 'slug' => 'attendee_information', |
250 | 250 | 'has_hooks' => FALSE |
251 | 251 | ), |
252 | 252 | 20 => array( |
253 | - 'file_path' => SPCO_REG_STEPS_PATH . 'registration_confirmation', |
|
253 | + 'file_path' => SPCO_REG_STEPS_PATH.'registration_confirmation', |
|
254 | 254 | 'class_name' => 'EE_SPCO_Reg_Step_Registration_Confirmation', |
255 | 255 | 'slug' => 'registration_confirmation', |
256 | 256 | 'has_hooks' => FALSE |
257 | 257 | ), |
258 | 258 | 30 => array( |
259 | - 'file_path' => SPCO_REG_STEPS_PATH . 'payment_options', |
|
259 | + 'file_path' => SPCO_REG_STEPS_PATH.'payment_options', |
|
260 | 260 | 'class_name' => 'EE_SPCO_Reg_Step_Payment_Options', |
261 | 261 | 'slug' => 'payment_options', |
262 | 262 | 'has_hooks' => TRUE |
263 | 263 | ), |
264 | 264 | 999 => array( |
265 | - 'file_path' => SPCO_REG_STEPS_PATH . 'finalize_registration', |
|
265 | + 'file_path' => SPCO_REG_STEPS_PATH.'finalize_registration', |
|
266 | 266 | 'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration', |
267 | 267 | 'slug' => 'finalize_registration', |
268 | 268 | 'has_hooks' => FALSE |
@@ -282,9 +282,9 @@ discard block |
||
282 | 282 | */ |
283 | 283 | public static function registration_checkout_for_admin() { |
284 | 284 | EED_Single_Page_Checkout::load_reg_steps(); |
285 | - EE_Registry::instance()->REQ->set( 'step', 'attendee_information' ); |
|
286 | - EE_Registry::instance()->REQ->set( 'action', 'display_spco_reg_step' ); |
|
287 | - EE_Registry::instance()->REQ->set( 'process_form_submission', false ); |
|
285 | + EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
286 | + EE_Registry::instance()->REQ->set('action', 'display_spco_reg_step'); |
|
287 | + EE_Registry::instance()->REQ->set('process_form_submission', false); |
|
288 | 288 | EED_Single_Page_Checkout::instance()->_initialize(); |
289 | 289 | EED_Single_Page_Checkout::instance()->_display_spco_reg_form(); |
290 | 290 | return EE_Registry::instance()->REQ->get_output(); |
@@ -300,14 +300,14 @@ discard block |
||
300 | 300 | */ |
301 | 301 | public static function process_registration_from_admin() { |
302 | 302 | EED_Single_Page_Checkout::load_reg_steps(); |
303 | - EE_Registry::instance()->REQ->set( 'step', 'attendee_information' ); |
|
304 | - EE_Registry::instance()->REQ->set( 'action', 'process_reg_step' ); |
|
305 | - EE_Registry::instance()->REQ->set( 'process_form_submission', true ); |
|
303 | + EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
304 | + EE_Registry::instance()->REQ->set('action', 'process_reg_step'); |
|
305 | + EE_Registry::instance()->REQ->set('process_form_submission', true); |
|
306 | 306 | EED_Single_Page_Checkout::instance()->_initialize(); |
307 | - if ( EED_Single_Page_Checkout::instance()->checkout->current_step->completed() ) { |
|
308 | - $final_reg_step = end( EED_Single_Page_Checkout::instance()->checkout->reg_steps ); |
|
309 | - if ( $final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration ) { |
|
310 | - if ( $final_reg_step->process_reg_step() ) { |
|
307 | + if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) { |
|
308 | + $final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps); |
|
309 | + if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) { |
|
310 | + if ($final_reg_step->process_reg_step()) { |
|
311 | 311 | return EED_Single_Page_Checkout::instance()->checkout->transaction; |
312 | 312 | } |
313 | 313 | } |
@@ -324,8 +324,8 @@ discard block |
||
324 | 324 | * @param WP_Query $WP_Query |
325 | 325 | * @return void |
326 | 326 | */ |
327 | - public function run( $WP_Query ) { |
|
328 | - if ( $WP_Query instanceof WP_Query && $WP_Query->is_main_query() && apply_filters( 'FHEE__EED_Single_Page_Checkout__run', true )) { |
|
327 | + public function run($WP_Query) { |
|
328 | + if ($WP_Query instanceof WP_Query && $WP_Query->is_main_query() && apply_filters('FHEE__EED_Single_Page_Checkout__run', true)) { |
|
329 | 329 | $this->_initialize(); |
330 | 330 | } |
331 | 331 | } |
@@ -340,8 +340,8 @@ discard block |
||
340 | 340 | * @param WP_Query $WP_Query |
341 | 341 | * @return void |
342 | 342 | */ |
343 | - public static function init( $WP_Query ) { |
|
344 | - EED_Single_Page_Checkout::instance()->run( $WP_Query ); |
|
343 | + public static function init($WP_Query) { |
|
344 | + EED_Single_Page_Checkout::instance()->run($WP_Query); |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | |
@@ -355,32 +355,32 @@ discard block |
||
355 | 355 | */ |
356 | 356 | private function _initialize() { |
357 | 357 | // ensure SPCO doesn't run twice |
358 | - if ( EED_Single_Page_Checkout::$_initialized ) { |
|
358 | + if (EED_Single_Page_Checkout::$_initialized) { |
|
359 | 359 | return; |
360 | 360 | } |
361 | 361 | // setup the EE_Checkout object |
362 | 362 | $this->checkout = $this->_initialize_checkout(); |
363 | 363 | // filter checkout |
364 | - $this->checkout = apply_filters( 'FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout ); |
|
364 | + $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout); |
|
365 | 365 | // get the $_GET |
366 | 366 | $this->_get_request_vars(); |
367 | 367 | // filter continue_reg |
368 | - $this->checkout->continue_reg = apply_filters( 'FHEE__EED_Single_Page_Checkout__init___continue_reg', TRUE, $this->checkout ); |
|
368 | + $this->checkout->continue_reg = apply_filters('FHEE__EED_Single_Page_Checkout__init___continue_reg', TRUE, $this->checkout); |
|
369 | 369 | // load the reg steps array |
370 | - if ( ! $this->_load_and_instantiate_reg_steps() ) { |
|
370 | + if ( ! $this->_load_and_instantiate_reg_steps()) { |
|
371 | 371 | EED_Single_Page_Checkout::$_initialized = true; |
372 | 372 | return; |
373 | 373 | } |
374 | 374 | // set the current step |
375 | - $this->checkout->set_current_step( $this->checkout->step ); |
|
375 | + $this->checkout->set_current_step($this->checkout->step); |
|
376 | 376 | // and the next step |
377 | 377 | $this->checkout->set_next_step(); |
378 | 378 | // was there already a valid transaction in the checkout from the session ? |
379 | - if ( ! $this->checkout->transaction instanceof EE_Transaction ) { |
|
379 | + if ( ! $this->checkout->transaction instanceof EE_Transaction) { |
|
380 | 380 | // get transaction from db or session |
381 | 381 | $this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin() ? $this->_get_transaction_and_cart_for_previous_visit() : $this->_get_cart_for_current_session_and_setup_new_transaction(); |
382 | - if ( ! $this->checkout->transaction instanceof EE_Transaction ) { |
|
383 | - EE_Error::add_error( __( 'Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
382 | + if ( ! $this->checkout->transaction instanceof EE_Transaction) { |
|
383 | + EE_Error::add_error(__('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
384 | 384 | // add some style and make it dance |
385 | 385 | $this->checkout->transaction = EE_Transaction::new_instance(); |
386 | 386 | $this->add_styles_and_scripts(); |
@@ -388,10 +388,10 @@ discard block |
||
388 | 388 | return; |
389 | 389 | } |
390 | 390 | // and the registrations for the transaction |
391 | - $this->_get_registrations( $this->checkout->transaction ); |
|
391 | + $this->_get_registrations($this->checkout->transaction); |
|
392 | 392 | } |
393 | 393 | // verify that everything has been setup correctly |
394 | - if ( ! $this->_final_verifications() ) { |
|
394 | + if ( ! $this->_final_verifications()) { |
|
395 | 395 | EED_Single_Page_Checkout::$_initialized = true; |
396 | 396 | return; |
397 | 397 | } |
@@ -416,9 +416,9 @@ discard block |
||
416 | 416 | // set no cache headers and constants |
417 | 417 | EE_System::do_not_cache(); |
418 | 418 | // add anchor |
419 | - add_action( 'loop_start', array( $this, 'set_checkout_anchor' ), 1 ); |
|
419 | + add_action('loop_start', array($this, 'set_checkout_anchor'), 1); |
|
420 | 420 | // remove transaction lock |
421 | - add_action( 'shutdown', array( $this, 'unlock_transaction' ), 1 ); |
|
421 | + add_action('shutdown', array($this, 'unlock_transaction'), 1); |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | |
@@ -435,20 +435,20 @@ discard block |
||
435 | 435 | // look in session for existing checkout |
436 | 436 | $checkout = EE_Registry::instance()->SSN->checkout(); |
437 | 437 | // verify |
438 | - if ( ! $checkout instanceof EE_Checkout ) { |
|
438 | + if ( ! $checkout instanceof EE_Checkout) { |
|
439 | 439 | // instantiate EE_Checkout object for handling the properties of the current checkout process |
440 | - $checkout = EE_Registry::instance()->load_file( SPCO_INC_PATH, 'EE_Checkout', 'class', array(), FALSE ); |
|
440 | + $checkout = EE_Registry::instance()->load_file(SPCO_INC_PATH, 'EE_Checkout', 'class', array(), FALSE); |
|
441 | 441 | // verify again |
442 | - if ( ! $checkout instanceof EE_Checkout ) { |
|
443 | - throw new EE_Error( __( 'The EE_Checkout class could not be loaded.', 'event_espresso' ) ); |
|
442 | + if ( ! $checkout instanceof EE_Checkout) { |
|
443 | + throw new EE_Error(__('The EE_Checkout class could not be loaded.', 'event_espresso')); |
|
444 | 444 | } |
445 | 445 | } else { |
446 | - if ( $checkout->current_step->is_final_step() && $checkout->exit_spco() === true ) { |
|
447 | - wp_safe_redirect( $checkout->redirect_url ); |
|
446 | + if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) { |
|
447 | + wp_safe_redirect($checkout->redirect_url); |
|
448 | 448 | exit(); |
449 | 449 | } |
450 | 450 | } |
451 | - $checkout = apply_filters( 'FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout ); |
|
451 | + $checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout); |
|
452 | 452 | // reset anything that needs a clean slate for each request |
453 | 453 | $checkout->reset_for_current_request(); |
454 | 454 | return $checkout; |
@@ -466,22 +466,22 @@ discard block |
||
466 | 466 | // load classes |
467 | 467 | EED_Single_Page_Checkout::load_request_handler(); |
468 | 468 | //make sure this request is marked as belonging to EE |
469 | - EE_Registry::instance()->REQ->set_espresso_page( TRUE ); |
|
469 | + EE_Registry::instance()->REQ->set_espresso_page(TRUE); |
|
470 | 470 | // which step is being requested ? |
471 | - $this->checkout->step = EE_Registry::instance()->REQ->get( 'step', $this->_get_first_step() ); |
|
471 | + $this->checkout->step = EE_Registry::instance()->REQ->get('step', $this->_get_first_step()); |
|
472 | 472 | // which step is being edited ? |
473 | - $this->checkout->edit_step = EE_Registry::instance()->REQ->get( 'edit_step', '' ); |
|
473 | + $this->checkout->edit_step = EE_Registry::instance()->REQ->get('edit_step', ''); |
|
474 | 474 | // and what we're doing on the current step |
475 | - $this->checkout->action = EE_Registry::instance()->REQ->get( 'action', 'display_spco_reg_step' ); |
|
475 | + $this->checkout->action = EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step'); |
|
476 | 476 | // returning to edit ? |
477 | - $this->checkout->reg_url_link = EE_Registry::instance()->REQ->get( 'e_reg_url_link', '' ); |
|
477 | + $this->checkout->reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link', ''); |
|
478 | 478 | // or some other kind of revisit ? |
479 | - $this->checkout->revisit = EE_Registry::instance()->REQ->get( 'revisit', FALSE ); |
|
479 | + $this->checkout->revisit = EE_Registry::instance()->REQ->get('revisit', FALSE); |
|
480 | 480 | // and whether or not to generate a reg form for this request |
481 | - $this->checkout->generate_reg_form = EE_Registry::instance()->REQ->get( 'generate_reg_form', TRUE ); // TRUE FALSE |
|
481 | + $this->checkout->generate_reg_form = EE_Registry::instance()->REQ->get('generate_reg_form', TRUE); // TRUE FALSE |
|
482 | 482 | // and whether or not to process a reg form submission for this request |
483 | - $this->checkout->process_form_submission = EE_Registry::instance()->REQ->get( 'process_form_submission', FALSE ); // TRUE FALSE |
|
484 | - $this->checkout->process_form_submission = $this->checkout->action !== 'display_spco_reg_step' ? $this->checkout->process_form_submission : FALSE; // TRUE FALSE |
|
483 | + $this->checkout->process_form_submission = EE_Registry::instance()->REQ->get('process_form_submission', FALSE); // TRUE FALSE |
|
484 | + $this->checkout->process_form_submission = $this->checkout->action !== 'display_spco_reg_step' ? $this->checkout->process_form_submission : FALSE; // TRUE FALSE |
|
485 | 485 | //$this->_display_request_vars(); |
486 | 486 | } |
487 | 487 | |
@@ -494,17 +494,17 @@ discard block |
||
494 | 494 | * @return void |
495 | 495 | */ |
496 | 496 | protected function _display_request_vars() { |
497 | - if ( ! WP_DEBUG ) { |
|
497 | + if ( ! WP_DEBUG) { |
|
498 | 498 | return; |
499 | 499 | } |
500 | - EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ ); |
|
501 | - EEH_Debug_Tools::printr( $this->checkout->step, '$this->checkout->step', __FILE__, __LINE__ ); |
|
502 | - EEH_Debug_Tools::printr( $this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__ ); |
|
503 | - EEH_Debug_Tools::printr( $this->checkout->action, '$this->checkout->action', __FILE__, __LINE__ ); |
|
504 | - EEH_Debug_Tools::printr( $this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__ ); |
|
505 | - EEH_Debug_Tools::printr( $this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__ ); |
|
506 | - EEH_Debug_Tools::printr( $this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__ ); |
|
507 | - EEH_Debug_Tools::printr( $this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__ ); |
|
500 | + EEH_Debug_Tools::printr($_REQUEST, '$_REQUEST', __FILE__, __LINE__); |
|
501 | + EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__); |
|
502 | + EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__); |
|
503 | + EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__); |
|
504 | + EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__); |
|
505 | + EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__); |
|
506 | + EEH_Debug_Tools::printr($this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__); |
|
507 | + EEH_Debug_Tools::printr($this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__); |
|
508 | 508 | } |
509 | 509 | |
510 | 510 | |
@@ -518,8 +518,8 @@ discard block |
||
518 | 518 | * @return array |
519 | 519 | */ |
520 | 520 | private function _get_first_step() { |
521 | - $first_step = reset( EED_Single_Page_Checkout::$_reg_steps_array ); |
|
522 | - return isset( $first_step['slug'] ) ? $first_step['slug'] : 'attendee_information'; |
|
521 | + $first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array); |
|
522 | + return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information'; |
|
523 | 523 | } |
524 | 524 | |
525 | 525 | |
@@ -535,37 +535,37 @@ discard block |
||
535 | 535 | private function _load_and_instantiate_reg_steps() { |
536 | 536 | // have reg_steps already been instantiated ? |
537 | 537 | if ( |
538 | - empty( $this->checkout->reg_steps ) || |
|
539 | - apply_filters( 'FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout ) |
|
538 | + empty($this->checkout->reg_steps) || |
|
539 | + apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout) |
|
540 | 540 | ) { |
541 | 541 | // if not, then loop through raw reg steps array |
542 | - foreach ( EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step ) { |
|
543 | - if ( ! $this->_load_and_instantiate_reg_step( $reg_step, $order )) { |
|
542 | + foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) { |
|
543 | + if ( ! $this->_load_and_instantiate_reg_step($reg_step, $order)) { |
|
544 | 544 | return false; |
545 | 545 | } |
546 | 546 | } |
547 | 547 | EE_Registry::instance()->CFG->registration->skip_reg_confirmation = TRUE; |
548 | 548 | EE_Registry::instance()->CFG->registration->reg_confirmation_last = TRUE; |
549 | 549 | // skip the registration_confirmation page ? |
550 | - if ( EE_Registry::instance()->CFG->registration->skip_reg_confirmation ) { |
|
550 | + if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) { |
|
551 | 551 | // just remove it from the reg steps array |
552 | - $this->checkout->remove_reg_step( 'registration_confirmation', false ); |
|
553 | - } else if ( EE_Registry::instance()->CFG->registration->reg_confirmation_last && isset( $this->checkout->reg_steps['registration_confirmation'] )) { |
|
552 | + $this->checkout->remove_reg_step('registration_confirmation', false); |
|
553 | + } else if (EE_Registry::instance()->CFG->registration->reg_confirmation_last && isset($this->checkout->reg_steps['registration_confirmation'])) { |
|
554 | 554 | // set the order to something big like 100 |
555 | - $this->checkout->set_reg_step_order( 'registration_confirmation', 100 ); |
|
555 | + $this->checkout->set_reg_step_order('registration_confirmation', 100); |
|
556 | 556 | } |
557 | 557 | // filter the array for good luck |
558 | - $this->checkout->reg_steps = apply_filters( 'FHEE__Single_Page_Checkout__load_reg_steps__reg_steps', $this->checkout->reg_steps ); |
|
558 | + $this->checkout->reg_steps = apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reg_steps', $this->checkout->reg_steps); |
|
559 | 559 | // finally re-sort based on the reg step class order properties |
560 | 560 | $this->checkout->sort_reg_steps(); |
561 | 561 | } else { |
562 | - foreach ( $this->checkout->reg_steps as $reg_step ) { |
|
562 | + foreach ($this->checkout->reg_steps as $reg_step) { |
|
563 | 563 | // set all current step stati to FALSE |
564 | - $reg_step->set_is_current_step( FALSE ); |
|
564 | + $reg_step->set_is_current_step(FALSE); |
|
565 | 565 | } |
566 | 566 | } |
567 | - if ( empty( $this->checkout->reg_steps )) { |
|
568 | - EE_Error::add_error( __( 'No Reg Steps were loaded..', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
567 | + if (empty($this->checkout->reg_steps)) { |
|
568 | + EE_Error::add_error(__('No Reg Steps were loaded..', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
569 | 569 | return false; |
570 | 570 | } |
571 | 571 | // make reg step details available to JS |
@@ -583,34 +583,34 @@ discard block |
||
583 | 583 | * @param int $order |
584 | 584 | * @return bool |
585 | 585 | */ |
586 | - private function _load_and_instantiate_reg_step( $reg_step = array(), $order = 0 ) { |
|
586 | + private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0) { |
|
587 | 587 | |
588 | 588 | // we need a file_path, class_name, and slug to add a reg step |
589 | - if ( isset( $reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'] )) { |
|
589 | + if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
590 | 590 | // if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step) |
591 | - if ( $this->checkout->reg_url_link && $this->checkout->step !== $reg_step['slug'] && $reg_step['slug'] !== 'finalize_registration' ) { |
|
591 | + if ($this->checkout->reg_url_link && $this->checkout->step !== $reg_step['slug'] && $reg_step['slug'] !== 'finalize_registration') { |
|
592 | 592 | return true; |
593 | 593 | } |
594 | 594 | // instantiate step class using file path and class name |
595 | - $reg_step_obj = EE_Registry::instance()->load_file( $reg_step['file_path'], $reg_step['class_name'], 'class', $this->checkout, FALSE ); |
|
595 | + $reg_step_obj = EE_Registry::instance()->load_file($reg_step['file_path'], $reg_step['class_name'], 'class', $this->checkout, FALSE); |
|
596 | 596 | // did we gets the goods ? |
597 | - if ( $reg_step_obj instanceof EE_SPCO_Reg_Step ) { |
|
597 | + if ($reg_step_obj instanceof EE_SPCO_Reg_Step) { |
|
598 | 598 | // set reg step order based on config |
599 | - $reg_step_obj->set_order( $order ); |
|
599 | + $reg_step_obj->set_order($order); |
|
600 | 600 | // add instantiated reg step object to the master reg steps array |
601 | - $this->checkout->add_reg_step( $reg_step_obj ); |
|
601 | + $this->checkout->add_reg_step($reg_step_obj); |
|
602 | 602 | } else { |
603 | - EE_Error::add_error( __( 'The current step could not be set.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
603 | + EE_Error::add_error(__('The current step could not be set.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
604 | 604 | return false; |
605 | 605 | } |
606 | 606 | } else { |
607 | - if ( WP_DEBUG ) { |
|
607 | + if (WP_DEBUG) { |
|
608 | 608 | EE_Error::add_error( |
609 | 609 | sprintf( |
610 | - __( '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' ), |
|
611 | - isset( $reg_step['file_path'] ) ? $reg_step['file_path'] : '', |
|
612 | - isset( $reg_step['class_name'] ) ? $reg_step['class_name'] : '', |
|
613 | - isset( $reg_step['slug'] ) ? $reg_step['slug'] : '', |
|
610 | + __('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'), |
|
611 | + isset($reg_step['file_path']) ? $reg_step['file_path'] : '', |
|
612 | + isset($reg_step['class_name']) ? $reg_step['class_name'] : '', |
|
613 | + isset($reg_step['slug']) ? $reg_step['slug'] : '', |
|
614 | 614 | '<ul>', |
615 | 615 | '<li>', |
616 | 616 | '</li>', |
@@ -634,16 +634,16 @@ discard block |
||
634 | 634 | */ |
635 | 635 | private function _get_transaction_and_cart_for_previous_visit() { |
636 | 636 | /** @var $TXN_model EEM_Transaction */ |
637 | - $TXN_model = EE_Registry::instance()->load_model( 'Transaction' ); |
|
637 | + $TXN_model = EE_Registry::instance()->load_model('Transaction'); |
|
638 | 638 | // 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 |
639 | - $transaction = $TXN_model->get_transaction_from_reg_url_link( $this->checkout->reg_url_link ); |
|
639 | + $transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link); |
|
640 | 640 | // verify transaction |
641 | - if ( $transaction instanceof EE_Transaction ) { |
|
641 | + if ($transaction instanceof EE_Transaction) { |
|
642 | 642 | // and get the cart that was used for that transaction |
643 | - $this->checkout->cart = $this->_get_cart_for_transaction( $transaction ); |
|
643 | + $this->checkout->cart = $this->_get_cart_for_transaction($transaction); |
|
644 | 644 | return $transaction; |
645 | 645 | } else { |
646 | - EE_Error::add_error( __( 'Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
646 | + EE_Error::add_error(__('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
647 | 647 | return NULL; |
648 | 648 | } |
649 | 649 | } |
@@ -657,11 +657,11 @@ discard block |
||
657 | 657 | * @param EE_Transaction $transaction |
658 | 658 | * @return EE_Cart |
659 | 659 | */ |
660 | - private function _get_cart_for_transaction( $transaction ) { |
|
661 | - $cart = $transaction instanceof EE_Transaction ? EE_Cart::get_cart_from_txn( $transaction ) : NULL; |
|
660 | + private function _get_cart_for_transaction($transaction) { |
|
661 | + $cart = $transaction instanceof EE_Transaction ? EE_Cart::get_cart_from_txn($transaction) : NULL; |
|
662 | 662 | // verify cart |
663 | - if ( ! $cart instanceof EE_Cart ) { |
|
664 | - $cart = EE_Registry::instance()->load_core( 'Cart' ); |
|
663 | + if ( ! $cart instanceof EE_Cart) { |
|
664 | + $cart = EE_Registry::instance()->load_core('Cart'); |
|
665 | 665 | } |
666 | 666 | return $cart; |
667 | 667 | } |
@@ -676,8 +676,8 @@ discard block |
||
676 | 676 | * @param EE_Transaction $transaction |
677 | 677 | * @return EE_Cart |
678 | 678 | */ |
679 | - public function get_cart_for_transaction( EE_Transaction $transaction ) { |
|
680 | - return EE_Cart::get_cart_from_txn( $transaction ); |
|
679 | + public function get_cart_for_transaction(EE_Transaction $transaction) { |
|
680 | + return EE_Cart::get_cart_from_txn($transaction); |
|
681 | 681 | } |
682 | 682 | |
683 | 683 | |
@@ -692,17 +692,17 @@ discard block |
||
692 | 692 | private function _get_cart_for_current_session_and_setup_new_transaction() { |
693 | 693 | // if there's no transaction, then this is the FIRST visit to SPCO |
694 | 694 | // so load up the cart ( passing nothing for the TXN because it doesn't exist yet ) |
695 | - $this->checkout->cart = $this->_get_cart_for_transaction( NULL ); |
|
695 | + $this->checkout->cart = $this->_get_cart_for_transaction(NULL); |
|
696 | 696 | // and then create a new transaction |
697 | 697 | $transaction = $this->_initialize_transaction(); |
698 | 698 | // verify transaction |
699 | - if ( $transaction instanceof EE_Transaction ) { |
|
699 | + if ($transaction instanceof EE_Transaction) { |
|
700 | 700 | // save it so that we have an ID for other objects to use |
701 | 701 | $transaction->save(); |
702 | 702 | // and save TXN data to the cart |
703 | - $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn( $transaction->ID() ); |
|
703 | + $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID()); |
|
704 | 704 | } else { |
705 | - EE_Error::add_error( __( 'A Valid Transaction could not be initialized.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
705 | + EE_Error::add_error(__('A Valid Transaction could not be initialized.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
706 | 706 | } |
707 | 707 | return $transaction; |
708 | 708 | } |
@@ -722,15 +722,15 @@ discard block |
||
722 | 722 | // grab the cart grand total |
723 | 723 | $cart_total = $this->checkout->cart->get_cart_grand_total(); |
724 | 724 | // create new TXN |
725 | - return EE_Transaction::new_instance( array( |
|
725 | + return EE_Transaction::new_instance(array( |
|
726 | 726 | 'TXN_timestamp' => time(), |
727 | 727 | 'TXN_reg_steps' => $this->checkout->initialize_txn_reg_steps_array(), |
728 | 728 | 'TXN_total' => $cart_total > 0 ? $cart_total : 0, |
729 | 729 | 'TXN_paid' => 0, |
730 | 730 | 'STS_ID' => EEM_Transaction::failed_status_code, |
731 | 731 | )); |
732 | - } catch( Exception $e ) { |
|
733 | - EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
732 | + } catch (Exception $e) { |
|
733 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
734 | 734 | } |
735 | 735 | return NULL; |
736 | 736 | } |
@@ -744,34 +744,34 @@ discard block |
||
744 | 744 | * @param EE_Transaction $transaction |
745 | 745 | * @return EE_Cart |
746 | 746 | */ |
747 | - private function _get_registrations( EE_Transaction $transaction ) { |
|
747 | + private function _get_registrations(EE_Transaction $transaction) { |
|
748 | 748 | // first step: grab the registrants { : o |
749 | - $registrations = $transaction->registrations( $this->checkout->reg_cache_where_params, true ); |
|
749 | + $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, true); |
|
750 | 750 | // verify registrations have been set |
751 | - if ( empty( $registrations )) { |
|
751 | + if (empty($registrations)) { |
|
752 | 752 | // if no cached registrations, then check the db |
753 | - $registrations = $transaction->registrations( $this->checkout->reg_cache_where_params, false ); |
|
753 | + $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false); |
|
754 | 754 | // still nothing ? well as long as this isn't a revisit |
755 | - if ( empty( $registrations ) && ! $this->checkout->revisit ) { |
|
755 | + if (empty($registrations) && ! $this->checkout->revisit) { |
|
756 | 756 | // generate new registrations from scratch |
757 | - $registrations = $this->_initialize_registrations( $transaction ); |
|
757 | + $registrations = $this->_initialize_registrations($transaction); |
|
758 | 758 | } |
759 | 759 | } |
760 | 760 | // sort by their original registration order |
761 | - usort( $registrations, array( 'EED_Single_Page_Checkout', 'sort_registrations_by_REG_count' )); |
|
761 | + usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count')); |
|
762 | 762 | // then loop thru the array |
763 | - foreach ( $registrations as $registration ) { |
|
763 | + foreach ($registrations as $registration) { |
|
764 | 764 | // verify each registration |
765 | - if ( $registration instanceof EE_Registration ) { |
|
765 | + if ($registration instanceof EE_Registration) { |
|
766 | 766 | // we display all attendee info for the primary registrant |
767 | - if ( $this->checkout->reg_url_link == $registration->reg_url_link() && $registration->is_primary_registrant() ) { |
|
767 | + if ($this->checkout->reg_url_link == $registration->reg_url_link() && $registration->is_primary_registrant()) { |
|
768 | 768 | $this->checkout->primary_revisit = TRUE; |
769 | 769 | break; |
770 | - } else if ( $this->checkout->revisit && $this->checkout->reg_url_link != $registration->reg_url_link() ) { |
|
770 | + } else if ($this->checkout->revisit && $this->checkout->reg_url_link != $registration->reg_url_link()) { |
|
771 | 771 | // but hide info if it doesn't belong to you |
772 | - $transaction->clear_cache( 'Registration', $registration->ID() ); |
|
772 | + $transaction->clear_cache('Registration', $registration->ID()); |
|
773 | 773 | } |
774 | - $this->checkout->set_reg_status_updated( $registration->ID(), false ); |
|
774 | + $this->checkout->set_reg_status_updated($registration->ID(), false); |
|
775 | 775 | } |
776 | 776 | } |
777 | 777 | } |
@@ -785,17 +785,17 @@ discard block |
||
785 | 785 | * @param EE_Transaction $transaction |
786 | 786 | * @return array |
787 | 787 | */ |
788 | - private function _initialize_registrations( EE_Transaction $transaction ) { |
|
788 | + private function _initialize_registrations(EE_Transaction $transaction) { |
|
789 | 789 | $att_nmbr = 0; |
790 | 790 | $registrations = array(); |
791 | - if ( $transaction instanceof EE_Transaction ) { |
|
791 | + if ($transaction instanceof EE_Transaction) { |
|
792 | 792 | /** @type EE_Registration_Processor $registration_processor */ |
793 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
793 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
794 | 794 | $this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count(); |
795 | 795 | // now let's add the cart items to the $transaction |
796 | - foreach ( $this->checkout->cart->get_tickets() as $line_item ) { |
|
796 | + foreach ($this->checkout->cart->get_tickets() as $line_item) { |
|
797 | 797 | //do the following for each ticket of this type they selected |
798 | - for ( $x = 1; $x <= $line_item->quantity(); $x++ ) { |
|
798 | + for ($x = 1; $x <= $line_item->quantity(); $x++) { |
|
799 | 799 | $att_nmbr++; |
800 | 800 | $registration = $registration_processor->generate_ONE_registration_from_line_item( |
801 | 801 | $line_item, |
@@ -803,12 +803,12 @@ discard block |
||
803 | 803 | $att_nmbr, |
804 | 804 | $this->checkout->total_ticket_count |
805 | 805 | ); |
806 | - if ( $registration instanceof EE_Registration ) { |
|
807 | - $registrations[ $registration->ID() ] = $registration; |
|
806 | + if ($registration instanceof EE_Registration) { |
|
807 | + $registrations[$registration->ID()] = $registration; |
|
808 | 808 | } |
809 | 809 | } |
810 | 810 | } |
811 | - $registration_processor->fix_reg_final_price_rounding_issue( $transaction ); |
|
811 | + $registration_processor->fix_reg_final_price_rounding_issue($transaction); |
|
812 | 812 | } |
813 | 813 | return $registrations; |
814 | 814 | } |
@@ -823,12 +823,12 @@ discard block |
||
823 | 823 | * @param EE_Registration $reg_B |
824 | 824 | * @return array() |
825 | 825 | */ |
826 | - public static function sort_registrations_by_REG_count( EE_Registration $reg_A, EE_Registration $reg_B ) { |
|
826 | + public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B) { |
|
827 | 827 | // this shouldn't ever happen within the same TXN, but oh well |
828 | - if ( $reg_A->count() == $reg_B->count() ) { |
|
828 | + if ($reg_A->count() == $reg_B->count()) { |
|
829 | 829 | return 0; |
830 | 830 | } |
831 | - return ( $reg_A->count() > $reg_B->count() ) ? 1 : -1; |
|
831 | + return ($reg_A->count() > $reg_B->count()) ? 1 : -1; |
|
832 | 832 | } |
833 | 833 | |
834 | 834 | |
@@ -843,35 +843,35 @@ discard block |
||
843 | 843 | */ |
844 | 844 | private function _final_verifications() { |
845 | 845 | // filter checkout |
846 | - $this->checkout = apply_filters( 'FHEE__EED_Single_Page_Checkout___final_verifications__checkout', $this->checkout ); |
|
846 | + $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___final_verifications__checkout', $this->checkout); |
|
847 | 847 | //verify that current step is still set correctly |
848 | - if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step ) { |
|
849 | - 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__ ); |
|
848 | + if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) { |
|
849 | + 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__); |
|
850 | 850 | return false; |
851 | 851 | } |
852 | 852 | // if returning to SPCO, then verify that primary registrant is set |
853 | - if ( ! empty( $this->checkout->reg_url_link )) { |
|
853 | + if ( ! empty($this->checkout->reg_url_link)) { |
|
854 | 854 | $valid_registrant = $this->checkout->transaction->primary_registration(); |
855 | - if ( ! $valid_registrant instanceof EE_Registration ) { |
|
856 | - 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__ ); |
|
855 | + if ( ! $valid_registrant instanceof EE_Registration) { |
|
856 | + 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__); |
|
857 | 857 | return false; |
858 | 858 | } |
859 | 859 | $valid_registrant = null; |
860 | - foreach ( $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ) as $registration ) { |
|
861 | - if ( $registration instanceof EE_Registration ) { |
|
862 | - if ( $registration->reg_url_link() == $this->checkout->reg_url_link ) { |
|
860 | + foreach ($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration) { |
|
861 | + if ($registration instanceof EE_Registration) { |
|
862 | + if ($registration->reg_url_link() == $this->checkout->reg_url_link) { |
|
863 | 863 | $valid_registrant = $registration; |
864 | 864 | } |
865 | 865 | } |
866 | 866 | } |
867 | - if ( ! $valid_registrant instanceof EE_Registration ) { |
|
868 | - 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__ ); |
|
867 | + if ( ! $valid_registrant instanceof EE_Registration) { |
|
868 | + 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__); |
|
869 | 869 | return false; |
870 | 870 | } |
871 | 871 | } |
872 | 872 | // now that things have been kinda sufficiently verified, |
873 | 873 | // let's add the checkout to the session so that's available other systems |
874 | - EE_Registry::instance()->SSN->set_checkout( $this->checkout ); |
|
874 | + EE_Registry::instance()->SSN->set_checkout($this->checkout); |
|
875 | 875 | return true; |
876 | 876 | } |
877 | 877 | |
@@ -887,28 +887,28 @@ discard block |
||
887 | 887 | * @access private |
888 | 888 | * @param bool $reinitializing |
889 | 889 | */ |
890 | - private function _initialize_reg_steps( $reinitializing = false ) { |
|
891 | - $this->checkout->set_reg_step_initiated( $this->checkout->current_step ); |
|
890 | + private function _initialize_reg_steps($reinitializing = false) { |
|
891 | + $this->checkout->set_reg_step_initiated($this->checkout->current_step); |
|
892 | 892 | // loop thru all steps to call their individual "initialize" methods and set i18n strings for JS |
893 | - foreach ( $this->checkout->reg_steps as $reg_step ) { |
|
894 | - if ( ! $reg_step->initialize_reg_step() ) { |
|
893 | + foreach ($this->checkout->reg_steps as $reg_step) { |
|
894 | + if ( ! $reg_step->initialize_reg_step()) { |
|
895 | 895 | // if not initialized then maybe this step is being removed... |
896 | - if ( $reg_step->is_current_step() && ! $reinitializing ) { |
|
896 | + if ($reg_step->is_current_step() && ! $reinitializing) { |
|
897 | 897 | // if it was the current step, then we need to start over here |
898 | - $this->_initialize_reg_steps( true ); |
|
898 | + $this->_initialize_reg_steps(true); |
|
899 | 899 | return; |
900 | 900 | } |
901 | 901 | continue; |
902 | 902 | } |
903 | 903 | // i18n |
904 | 904 | $reg_step->translate_js_strings(); |
905 | - if ( $reg_step->is_current_step() ) { |
|
905 | + if ($reg_step->is_current_step()) { |
|
906 | 906 | // the text that appears on the reg step form submit button |
907 | 907 | $reg_step->set_submit_button_text(); |
908 | 908 | } |
909 | 909 | } |
910 | 910 | // dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information |
911 | - do_action( "AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", $this->checkout->current_step ); |
|
911 | + do_action("AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", $this->checkout->current_step); |
|
912 | 912 | } |
913 | 913 | |
914 | 914 | |
@@ -921,39 +921,39 @@ discard block |
||
921 | 921 | */ |
922 | 922 | private function _check_form_submission() { |
923 | 923 | //does this request require the reg form to be generated ? |
924 | - if ( $this->checkout->generate_reg_form ) { |
|
924 | + if ($this->checkout->generate_reg_form) { |
|
925 | 925 | // ever heard that song by Blue Rodeo ? |
926 | 926 | try { |
927 | 927 | $this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form(); |
928 | 928 | // if not displaying a form, then check for form submission |
929 | - if ( $this->checkout->process_form_submission && $this->checkout->current_step->reg_form->was_submitted() ) { |
|
929 | + if ($this->checkout->process_form_submission && $this->checkout->current_step->reg_form->was_submitted()) { |
|
930 | 930 | // clear out any old data in case this step is being run again |
931 | - $this->checkout->current_step->set_valid_data( array() ); |
|
931 | + $this->checkout->current_step->set_valid_data(array()); |
|
932 | 932 | // capture submitted form data |
933 | 933 | $this->checkout->current_step->reg_form->receive_form_submission( |
934 | - apply_filters( 'FHEE__Single_Page_Checkout___check_form_submission__request_params', EE_Registry::instance()->REQ->params(), $this->checkout ) |
|
934 | + apply_filters('FHEE__Single_Page_Checkout___check_form_submission__request_params', EE_Registry::instance()->REQ->params(), $this->checkout) |
|
935 | 935 | ); |
936 | 936 | // validate submitted form data |
937 | - if ( ! $this->checkout->current_step->reg_form->is_valid() || ! $this->checkout->continue_reg ) { |
|
937 | + if ( ! $this->checkout->current_step->reg_form->is_valid() || ! $this->checkout->continue_reg) { |
|
938 | 938 | // thou shall not pass !!! |
939 | 939 | $this->checkout->continue_reg = FALSE; |
940 | 940 | // any form validation errors? |
941 | - if ( $this->checkout->current_step->reg_form->submission_error_message() != '' ) { |
|
941 | + if ($this->checkout->current_step->reg_form->submission_error_message() != '') { |
|
942 | 942 | $submission_error_messages = array(); |
943 | 943 | // bad, bad, bad registrant |
944 | - foreach( $this->checkout->current_step->reg_form->get_validation_errors_accumulated() as $validation_error ){ |
|
945 | - if ( $validation_error instanceof EE_Validation_Error ) { |
|
946 | - $submission_error_messages[] = sprintf( __( '%s : %s', 'event_espresso' ), $validation_error->get_form_section()->html_label_text(), $validation_error->getMessage() ); |
|
944 | + foreach ($this->checkout->current_step->reg_form->get_validation_errors_accumulated() as $validation_error) { |
|
945 | + if ($validation_error instanceof EE_Validation_Error) { |
|
946 | + $submission_error_messages[] = sprintf(__('%s : %s', 'event_espresso'), $validation_error->get_form_section()->html_label_text(), $validation_error->getMessage()); |
|
947 | 947 | } |
948 | 948 | } |
949 | - EE_Error::add_error( join( '<br />', $submission_error_messages ), __FILE__, __FUNCTION__, __LINE__ ); |
|
949 | + EE_Error::add_error(join('<br />', $submission_error_messages), __FILE__, __FUNCTION__, __LINE__); |
|
950 | 950 | } |
951 | 951 | // well not really... what will happen is we'll just get redirected back to redo the current step |
952 | 952 | $this->go_to_next_step(); |
953 | 953 | return; |
954 | 954 | } |
955 | 955 | } |
956 | - } catch( EE_Error $e ) { |
|
956 | + } catch (EE_Error $e) { |
|
957 | 957 | $e->get_error(); |
958 | 958 | } |
959 | 959 | } |
@@ -969,38 +969,38 @@ discard block |
||
969 | 969 | */ |
970 | 970 | private function _process_form_action() { |
971 | 971 | // what cha wanna do? |
972 | - switch( $this->checkout->action ) { |
|
972 | + switch ($this->checkout->action) { |
|
973 | 973 | // AJAX next step reg form |
974 | 974 | case 'display_spco_reg_step' : |
975 | 975 | $this->checkout->redirect = FALSE; |
976 | - if ( EE_Registry::instance()->REQ->ajax ) { |
|
977 | - $this->checkout->json_response->set_reg_step_html( $this->checkout->current_step->display_reg_form() ); |
|
976 | + if (EE_Registry::instance()->REQ->ajax) { |
|
977 | + $this->checkout->json_response->set_reg_step_html($this->checkout->current_step->display_reg_form()); |
|
978 | 978 | } |
979 | 979 | break; |
980 | 980 | |
981 | 981 | default : |
982 | 982 | // meh... do one of those other steps first |
983 | - if ( ! empty( $this->checkout->action ) && is_callable( array( $this->checkout->current_step, $this->checkout->action ))) { |
|
983 | + if ( ! empty($this->checkout->action) && is_callable(array($this->checkout->current_step, $this->checkout->action))) { |
|
984 | 984 | // dynamically creates hook point like: AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step |
985 | - do_action( "AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step ); |
|
985 | + do_action("AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step); |
|
986 | 986 | // call action on current step |
987 | - if ( call_user_func( array( $this->checkout->current_step, $this->checkout->action )) ) { |
|
987 | + if (call_user_func(array($this->checkout->current_step, $this->checkout->action))) { |
|
988 | 988 | // good registrant, you get to proceed |
989 | - if ( $this->checkout->current_step->success_message() != '' ) { |
|
990 | - if ( apply_filters( 'FHEE__Single_Page_Checkout___process_form_action__display_success', false ) ) { |
|
991 | - EE_Error::add_success( $this->checkout->current_step->success_message() . '<br />' . $this->checkout->next_step->_instructions() ); |
|
989 | + if ($this->checkout->current_step->success_message() != '') { |
|
990 | + if (apply_filters('FHEE__Single_Page_Checkout___process_form_action__display_success', false)) { |
|
991 | + EE_Error::add_success($this->checkout->current_step->success_message().'<br />'.$this->checkout->next_step->_instructions()); |
|
992 | 992 | } |
993 | 993 | } |
994 | 994 | // pack it up, pack it in... |
995 | 995 | $this->_setup_redirect(); |
996 | 996 | } |
997 | 997 | // dynamically creates hook point like: AHEE__Single_Page_Checkout__after_payment_options__process_reg_step |
998 | - do_action( "AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step ); |
|
998 | + do_action("AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step); |
|
999 | 999 | |
1000 | 1000 | } else { |
1001 | 1001 | EE_Error::add_error( |
1002 | 1002 | sprintf( |
1003 | - __( 'The requested form action "%s" does not exist for the current "%s" registration step.', 'event_espresso' ), |
|
1003 | + __('The requested form action "%s" does not exist for the current "%s" registration step.', 'event_espresso'), |
|
1004 | 1004 | $this->checkout->action, |
1005 | 1005 | $this->checkout->current_step->name() |
1006 | 1006 | ), |
@@ -1026,10 +1026,10 @@ discard block |
||
1026 | 1026 | public function add_styles_and_scripts() { |
1027 | 1027 | // i18n |
1028 | 1028 | $this->translate_js_strings(); |
1029 | - if ( $this->checkout->admin_request ) { |
|
1030 | - add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10 ); |
|
1029 | + if ($this->checkout->admin_request) { |
|
1030 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
1031 | 1031 | } else { |
1032 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles_and_scripts' ), 10 ); |
|
1032 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
1033 | 1033 | } |
1034 | 1034 | } |
1035 | 1035 | |
@@ -1045,42 +1045,42 @@ discard block |
||
1045 | 1045 | EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit; |
1046 | 1046 | EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link; |
1047 | 1047 | 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'); |
1048 | - 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' ); |
|
1049 | - 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' ); |
|
1050 | - 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' ); |
|
1048 | + 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'); |
|
1049 | + 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'); |
|
1050 | + 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'); |
|
1051 | 1051 | EE_Registry::$i18n_js_strings['reg_step_error'] = __('This registration step could not be completed. Please refresh the page and try again.', 'event_espresso'); |
1052 | 1052 | 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'); |
1053 | - 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/>' ); |
|
1054 | - EE_Registry::$i18n_js_strings['language'] = get_bloginfo( 'language' ); |
|
1053 | + 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/>'); |
|
1054 | + EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language'); |
|
1055 | 1055 | EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id(); |
1056 | 1056 | EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency; |
1057 | 1057 | EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20'; |
1058 | - EE_Registry::$i18n_js_strings['timer_years'] = __( 'years', 'event_espresso' ); |
|
1059 | - EE_Registry::$i18n_js_strings['timer_months'] = __( 'months', 'event_espresso' ); |
|
1060 | - EE_Registry::$i18n_js_strings['timer_weeks'] = __( 'weeks', 'event_espresso' ); |
|
1061 | - EE_Registry::$i18n_js_strings['timer_days'] = __( 'days', 'event_espresso' ); |
|
1062 | - EE_Registry::$i18n_js_strings['timer_hours'] = __( 'hours', 'event_espresso' ); |
|
1063 | - EE_Registry::$i18n_js_strings['timer_minutes'] = __( 'minutes', 'event_espresso' ); |
|
1064 | - EE_Registry::$i18n_js_strings['timer_seconds'] = __( 'seconds', 'event_espresso' ); |
|
1065 | - EE_Registry::$i18n_js_strings['timer_year'] = __( 'year', 'event_espresso' ); |
|
1066 | - EE_Registry::$i18n_js_strings['timer_month'] = __( 'month', 'event_espresso' ); |
|
1067 | - EE_Registry::$i18n_js_strings['timer_week'] = __( 'week', 'event_espresso' ); |
|
1068 | - EE_Registry::$i18n_js_strings['timer_day'] = __( 'day', 'event_espresso' ); |
|
1069 | - EE_Registry::$i18n_js_strings['timer_hour'] = __( 'hour', 'event_espresso' ); |
|
1070 | - EE_Registry::$i18n_js_strings['timer_minute'] = __( 'minute', 'event_espresso' ); |
|
1071 | - EE_Registry::$i18n_js_strings['timer_second'] = __( 'second', 'event_espresso' ); |
|
1058 | + EE_Registry::$i18n_js_strings['timer_years'] = __('years', 'event_espresso'); |
|
1059 | + EE_Registry::$i18n_js_strings['timer_months'] = __('months', 'event_espresso'); |
|
1060 | + EE_Registry::$i18n_js_strings['timer_weeks'] = __('weeks', 'event_espresso'); |
|
1061 | + EE_Registry::$i18n_js_strings['timer_days'] = __('days', 'event_espresso'); |
|
1062 | + EE_Registry::$i18n_js_strings['timer_hours'] = __('hours', 'event_espresso'); |
|
1063 | + EE_Registry::$i18n_js_strings['timer_minutes'] = __('minutes', 'event_espresso'); |
|
1064 | + EE_Registry::$i18n_js_strings['timer_seconds'] = __('seconds', 'event_espresso'); |
|
1065 | + EE_Registry::$i18n_js_strings['timer_year'] = __('year', 'event_espresso'); |
|
1066 | + EE_Registry::$i18n_js_strings['timer_month'] = __('month', 'event_espresso'); |
|
1067 | + EE_Registry::$i18n_js_strings['timer_week'] = __('week', 'event_espresso'); |
|
1068 | + EE_Registry::$i18n_js_strings['timer_day'] = __('day', 'event_espresso'); |
|
1069 | + EE_Registry::$i18n_js_strings['timer_hour'] = __('hour', 'event_espresso'); |
|
1070 | + EE_Registry::$i18n_js_strings['timer_minute'] = __('minute', 'event_espresso'); |
|
1071 | + EE_Registry::$i18n_js_strings['timer_second'] = __('second', 'event_espresso'); |
|
1072 | 1072 | EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf( |
1073 | - __( '%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' ), |
|
1073 | + __('%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'), |
|
1074 | 1074 | '<h4 class="important-notice">', |
1075 | 1075 | '</h4>', |
1076 | 1076 | '<br />', |
1077 | 1077 | '<p>', |
1078 | - '<a href="'. get_post_type_archive_link( 'espresso_events' ) . '" title="', |
|
1078 | + '<a href="'.get_post_type_archive_link('espresso_events').'" title="', |
|
1079 | 1079 | '">', |
1080 | 1080 | '</a>', |
1081 | 1081 | '</p>' |
1082 | 1082 | ); |
1083 | - EE_Registry::$i18n_js_strings[ 'ajax_submit' ] = apply_filters( 'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', true ); |
|
1083 | + EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters('FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', true); |
|
1084 | 1084 | } |
1085 | 1085 | |
1086 | 1086 | |
@@ -1093,25 +1093,25 @@ discard block |
||
1093 | 1093 | */ |
1094 | 1094 | public function enqueue_styles_and_scripts() { |
1095 | 1095 | // load css |
1096 | - wp_register_style( 'single_page_checkout', SPCO_CSS_URL . 'single_page_checkout.css', array(), EVENT_ESPRESSO_VERSION ); |
|
1097 | - wp_enqueue_style( 'single_page_checkout' ); |
|
1096 | + wp_register_style('single_page_checkout', SPCO_CSS_URL.'single_page_checkout.css', array(), EVENT_ESPRESSO_VERSION); |
|
1097 | + wp_enqueue_style('single_page_checkout'); |
|
1098 | 1098 | // load JS |
1099 | - wp_register_script( 'jquery_plugin', EE_THIRD_PARTY_URL . 'jquery .plugin.min.js', array( 'jquery' ), '1.0.1', TRUE ); |
|
1100 | - wp_register_script( 'jquery_countdown', EE_THIRD_PARTY_URL . 'jquery .countdown.min.js', array( 'jquery_plugin' ), '2.0.2', TRUE ); |
|
1101 | - 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 ); |
|
1102 | - wp_enqueue_script( 'single_page_checkout' ); |
|
1099 | + wp_register_script('jquery_plugin', EE_THIRD_PARTY_URL.'jquery .plugin.min.js', array('jquery'), '1.0.1', TRUE); |
|
1100 | + wp_register_script('jquery_countdown', EE_THIRD_PARTY_URL.'jquery .countdown.min.js', array('jquery_plugin'), '2.0.2', TRUE); |
|
1101 | + 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); |
|
1102 | + wp_enqueue_script('single_page_checkout'); |
|
1103 | 1103 | |
1104 | 1104 | /** |
1105 | 1105 | * global action hook for enqueueing styles and scripts with |
1106 | 1106 | * spco calls. |
1107 | 1107 | */ |
1108 | - do_action( 'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this ); |
|
1108 | + do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this); |
|
1109 | 1109 | |
1110 | 1110 | /** |
1111 | 1111 | * dynamic action hook for enqueueing styles and scripts with spco calls. |
1112 | 1112 | * The hook will end up being something like AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information |
1113 | 1113 | */ |
1114 | - do_action( 'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(), $this ); |
|
1114 | + do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__'.$this->checkout->current_step->slug(), $this); |
|
1115 | 1115 | |
1116 | 1116 | // add css and JS for current step |
1117 | 1117 | $this->checkout->current_step->enqueue_styles_and_scripts(); |
@@ -1127,20 +1127,20 @@ discard block |
||
1127 | 1127 | */ |
1128 | 1128 | private function _display_spco_reg_form() { |
1129 | 1129 | // if registering via the admin, just display the reg form for the current step |
1130 | - if ( $this->checkout->admin_request ) { |
|
1131 | - EE_Registry::instance()->REQ->add_output( $this->checkout->current_step->display_reg_form() ); |
|
1130 | + if ($this->checkout->admin_request) { |
|
1131 | + EE_Registry::instance()->REQ->add_output($this->checkout->current_step->display_reg_form()); |
|
1132 | 1132 | } else { |
1133 | 1133 | // add powered by EE msg |
1134 | - add_action( 'AHEE__SPCO__reg_form_footer', array( 'EED_Single_Page_Checkout', 'display_registration_footer' )); |
|
1134 | + add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer')); |
|
1135 | 1135 | |
1136 | - $empty_cart = count( $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ) ) < 1 ? true : false; |
|
1136 | + $empty_cart = count($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params)) < 1 ? true : false; |
|
1137 | 1137 | $cookies_not_set_msg = ''; |
1138 | - if ( $empty_cart ) { |
|
1139 | - if ( ! isset( $_COOKIE[ 'ee_cookie_test' ] ) ) { |
|
1138 | + if ($empty_cart) { |
|
1139 | + if ( ! isset($_COOKIE['ee_cookie_test'])) { |
|
1140 | 1140 | $cookies_not_set_msg = apply_filters( |
1141 | 1141 | 'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg', |
1142 | 1142 | sprintf( |
1143 | - __( '%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' ), |
|
1143 | + __('%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'), |
|
1144 | 1144 | '<div class="ee-attention">', |
1145 | 1145 | '</div>', |
1146 | 1146 | '<h6 class="important-notice">', |
@@ -1161,7 +1161,7 @@ discard block |
||
1161 | 1161 | 'layout_strategy' => |
1162 | 1162 | new EE_Template_Layout( |
1163 | 1163 | array( |
1164 | - 'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php', |
|
1164 | + 'layout_template_file' => SPCO_TEMPLATES_PATH.'registration_page_wrapper.template.php', |
|
1165 | 1165 | 'template_args' => array( |
1166 | 1166 | 'empty_cart' => $empty_cart, |
1167 | 1167 | 'revisit' => $this->checkout->revisit, |
@@ -1170,8 +1170,8 @@ discard block |
||
1170 | 1170 | 'empty_msg' => apply_filters( |
1171 | 1171 | 'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg', |
1172 | 1172 | sprintf( |
1173 | - __( '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' ), |
|
1174 | - '<a href="' . get_post_type_archive_link( 'espresso_events' ) . '" title="', |
|
1173 | + __('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'), |
|
1174 | + '<a href="'.get_post_type_archive_link('espresso_events').'" title="', |
|
1175 | 1175 | '">', |
1176 | 1176 | '</a>' |
1177 | 1177 | ) |
@@ -1179,14 +1179,14 @@ discard block |
||
1179 | 1179 | 'cookies_not_set_msg' => $cookies_not_set_msg, |
1180 | 1180 | 'registration_time_limit' => $this->checkout->get_registration_time_limit(), |
1181 | 1181 | 'session_expiration' => |
1182 | - gmdate( 'M d, Y H:i:s', EE_Registry::instance()->SSN->expiration() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ) |
|
1182 | + gmdate('M d, Y H:i:s', EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS)) |
|
1183 | 1183 | ) |
1184 | 1184 | ) |
1185 | 1185 | ) |
1186 | 1186 | ) |
1187 | 1187 | ); |
1188 | 1188 | // load template and add to output sent that gets filtered into the_content() |
1189 | - EE_Registry::instance()->REQ->add_output( $this->checkout->registration_form->get_html_and_js() ); |
|
1189 | + EE_Registry::instance()->REQ->add_output($this->checkout->registration_form->get_html_and_js()); |
|
1190 | 1190 | } |
1191 | 1191 | } |
1192 | 1192 | |
@@ -1200,8 +1200,8 @@ discard block |
||
1200 | 1200 | * @internal param string $label |
1201 | 1201 | * @return string |
1202 | 1202 | */ |
1203 | - public function add_extra_finalize_registration_inputs( $next_step ) { |
|
1204 | - if ( $next_step == 'finalize_registration' ) { |
|
1203 | + public function add_extra_finalize_registration_inputs($next_step) { |
|
1204 | + if ($next_step == 'finalize_registration') { |
|
1205 | 1205 | echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>'; |
1206 | 1206 | } |
1207 | 1207 | } |
@@ -1215,18 +1215,18 @@ discard block |
||
1215 | 1215 | * @return string |
1216 | 1216 | */ |
1217 | 1217 | public static function display_registration_footer() { |
1218 | - if ( apply_filters( 'FHEE__EE_Front__Controller__show_reg_footer', EE_Registry::instance()->CFG->admin->show_reg_footer ) ) { |
|
1219 | - EE_Registry::instance()->CFG->admin->affiliate_id = ! empty( EE_Registry::instance()->CFG->admin->affiliate_id ) ? EE_Registry::instance()->CFG->admin->affiliate_id : 'default'; |
|
1220 | - $url = add_query_arg( array( 'ap_id' => EE_Registry::instance()->CFG->admin->affiliate_id ), 'http://eventespresso.com/' ); |
|
1221 | - $url = apply_filters( 'FHEE__EE_Front_Controller__registration_footer__url', $url ); |
|
1218 | + if (apply_filters('FHEE__EE_Front__Controller__show_reg_footer', EE_Registry::instance()->CFG->admin->show_reg_footer)) { |
|
1219 | + EE_Registry::instance()->CFG->admin->affiliate_id = ! empty(EE_Registry::instance()->CFG->admin->affiliate_id) ? EE_Registry::instance()->CFG->admin->affiliate_id : 'default'; |
|
1220 | + $url = add_query_arg(array('ap_id' => EE_Registry::instance()->CFG->admin->affiliate_id), 'http://eventespresso.com/'); |
|
1221 | + $url = apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url); |
|
1222 | 1222 | echo apply_filters( |
1223 | 1223 | 'FHEE__EE_Front_Controller__display_registration_footer', |
1224 | 1224 | sprintf( |
1225 | - __( '%1$sEvent Registration Powered by Event Espresso%2$sEvent Registration and Ticketing%3$s Powered by %4$sEvent Espresso - Event Registration and Management System for WordPress%5$sEvent Espresso%6$s', 'event_espresso' ), |
|
1226 | - '<div id="espresso-registration-footer-dv"><a href="' . $url . '" title="', |
|
1225 | + __('%1$sEvent Registration Powered by Event Espresso%2$sEvent Registration and Ticketing%3$s Powered by %4$sEvent Espresso - Event Registration and Management System for WordPress%5$sEvent Espresso%6$s', 'event_espresso'), |
|
1226 | + '<div id="espresso-registration-footer-dv"><a href="'.$url.'" title="', |
|
1227 | 1227 | '" target="_blank">', |
1228 | 1228 | '</a>', |
1229 | - '<a href="' . $url . '" title="', |
|
1229 | + '<a href="'.$url.'" title="', |
|
1230 | 1230 | '" target="_blank">', |
1231 | 1231 | '</a></div>' |
1232 | 1232 | ) |
@@ -1257,12 +1257,12 @@ discard block |
||
1257 | 1257 | * @return array |
1258 | 1258 | */ |
1259 | 1259 | private function _setup_redirect() { |
1260 | - if ( $this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step ) { |
|
1260 | + if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
1261 | 1261 | $this->checkout->redirect = TRUE; |
1262 | - if ( empty( $this->checkout->redirect_url )) { |
|
1262 | + if (empty($this->checkout->redirect_url)) { |
|
1263 | 1263 | $this->checkout->redirect_url = $this->checkout->next_step->reg_step_url(); |
1264 | 1264 | } |
1265 | - $this->checkout->redirect_url = apply_filters( 'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url', $this->checkout->redirect_url, $this->checkout ); |
|
1265 | + $this->checkout->redirect_url = apply_filters('FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url', $this->checkout->redirect_url, $this->checkout); |
|
1266 | 1266 | } |
1267 | 1267 | } |
1268 | 1268 | |
@@ -1275,12 +1275,12 @@ discard block |
||
1275 | 1275 | * @return void |
1276 | 1276 | */ |
1277 | 1277 | public function go_to_next_step() { |
1278 | - if ( EE_Registry::instance()->REQ->ajax ) { |
|
1278 | + if (EE_Registry::instance()->REQ->ajax) { |
|
1279 | 1279 | // capture contents of output buffer we started earlier in the request, and insert into JSON response |
1280 | - $this->checkout->json_response->set_unexpected_errors( ob_get_clean() ); |
|
1280 | + $this->checkout->json_response->set_unexpected_errors(ob_get_clean()); |
|
1281 | 1281 | } |
1282 | 1282 | // just return for these conditions |
1283 | - if ( $this->checkout->admin_request || $this->checkout->action == 'redirect_form' || $this->checkout->action == 'update_checkout' ) { |
|
1283 | + if ($this->checkout->admin_request || $this->checkout->action == 'redirect_form' || $this->checkout->action == 'update_checkout') { |
|
1284 | 1284 | return; |
1285 | 1285 | } |
1286 | 1286 | // AJAX response |
@@ -1301,7 +1301,7 @@ discard block |
||
1301 | 1301 | */ |
1302 | 1302 | protected function _handle_json_response() { |
1303 | 1303 | // if this is an ajax request |
1304 | - if ( EE_Registry::instance()->REQ->ajax ) { |
|
1304 | + if (EE_Registry::instance()->REQ->ajax) { |
|
1305 | 1305 | // DEBUG LOG |
1306 | 1306 | //$this->checkout->log( |
1307 | 1307 | // __CLASS__, __FUNCTION__, __LINE__, |
@@ -1311,10 +1311,10 @@ discard block |
||
1311 | 1311 | // 'continue_reg' => $this->checkout->continue_reg, |
1312 | 1312 | // ) |
1313 | 1313 | //); |
1314 | - $this->checkout->json_response->set_registration_time_limit( $this->checkout->get_registration_time_limit() ); |
|
1315 | - $this->checkout->json_response->set_payment_amount( $this->checkout->amount_owing ); |
|
1314 | + $this->checkout->json_response->set_registration_time_limit($this->checkout->get_registration_time_limit()); |
|
1315 | + $this->checkout->json_response->set_payment_amount($this->checkout->amount_owing); |
|
1316 | 1316 | // just send the ajax ( |
1317 | - $json_response = apply_filters( 'FHEE__EE_Single_Page_Checkout__JSON_response', $this->checkout->json_response ); |
|
1317 | + $json_response = apply_filters('FHEE__EE_Single_Page_Checkout__JSON_response', $this->checkout->json_response); |
|
1318 | 1318 | $this->unlock_transaction(); |
1319 | 1319 | echo $json_response; |
1320 | 1320 | exit(); |
@@ -1331,9 +1331,9 @@ discard block |
||
1331 | 1331 | */ |
1332 | 1332 | protected function _handle_html_redirects() { |
1333 | 1333 | // going somewhere ? |
1334 | - if ( $this->checkout->redirect && ! empty( $this->checkout->redirect_url ) ) { |
|
1334 | + if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) { |
|
1335 | 1335 | // store notices in a transient |
1336 | - EE_Error::get_notices( false, true, true ); |
|
1336 | + EE_Error::get_notices(false, true, true); |
|
1337 | 1337 | $this->unlock_transaction(); |
1338 | 1338 | // DEBUG LOG |
1339 | 1339 | //$this->checkout->log( |
@@ -1344,7 +1344,7 @@ discard block |
||
1344 | 1344 | // 'headers_list' => headers_list(), |
1345 | 1345 | // ) |
1346 | 1346 | //); |
1347 | - wp_safe_redirect( $this->checkout->redirect_url ); |
|
1347 | + wp_safe_redirect($this->checkout->redirect_url); |
|
1348 | 1348 | exit(); |
1349 | 1349 | } |
1350 | 1350 | } |
@@ -57,15 +57,15 @@ discard block |
||
57 | 57 | * @return EED_Ticket_Selector |
58 | 58 | */ |
59 | 59 | public static function instance() { |
60 | - return parent::get_instance( __CLASS__ ); |
|
60 | + return parent::get_instance(__CLASS__); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | |
64 | 64 | |
65 | - protected function set_config(){ |
|
66 | - $this->set_config_section( 'template_settings' ); |
|
67 | - $this->set_config_class( 'EE_Ticket_Selector_Config' ); |
|
68 | - $this->set_config_name( 'EED_Ticket_Selector' ); |
|
65 | + protected function set_config() { |
|
66 | + $this->set_config_section('template_settings'); |
|
67 | + $this->set_config_class('EE_Ticket_Selector_Config'); |
|
68 | + $this->set_config_name('EED_Ticket_Selector'); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | |
@@ -80,14 +80,14 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public static function set_hooks() { |
82 | 82 | // routing |
83 | - EE_Config::register_route( 'iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector' ); |
|
84 | - EE_Config::register_route( 'process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections' ); |
|
85 | - add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 ); |
|
83 | + EE_Config::register_route('iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector'); |
|
84 | + EE_Config::register_route('process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections'); |
|
85 | + add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2); |
|
86 | 86 | //add_action( 'AHEE_event_details_before_post', array( 'EED_Ticket_Selector', 'ticket_selector_form_open' ), 10, 1 ); |
87 | - add_action( 'AHEE_event_details_header_bottom', array( 'EED_Ticket_Selector', 'display_ticket_selector' ), 10, 1 ); |
|
87 | + add_action('AHEE_event_details_header_bottom', array('EED_Ticket_Selector', 'display_ticket_selector'), 10, 1); |
|
88 | 88 | //add_action( 'AHEE__ticket_selector_chart__template__after_ticket_selector', array( 'EED_Ticket_Selector', 'display_ticket_selector_submit' ), 10, 1 ); |
89 | 89 | //add_action( 'AHEE_event_details_after_post', array( 'EED_Ticket_Selector', 'ticket_selector_form_close' ), 10 ); |
90 | - add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets' ), 10 ); |
|
90 | + add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets'), 10); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | |
@@ -99,10 +99,10 @@ discard block |
||
99 | 99 | * @return void |
100 | 100 | */ |
101 | 101 | public static function set_hooks_admin() { |
102 | - add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 ); |
|
102 | + add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2); |
|
103 | 103 | //add button for iframe code to event editor. |
104 | - add_filter( 'get_sample_permalink_html', array( 'EED_Ticket_Selector', 'iframe_code_button' ), 10, 4 ); |
|
105 | - add_action( 'admin_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets_admin' ), 10 ); |
|
104 | + add_filter('get_sample_permalink_html', array('EED_Ticket_Selector', 'iframe_code_button'), 10, 4); |
|
105 | + add_action('admin_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets_admin'), 10); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | |
@@ -114,15 +114,15 @@ discard block |
||
114 | 114 | * @return void |
115 | 115 | */ |
116 | 116 | public static function set_definitions() { |
117 | - define( 'TICKET_SELECTOR_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS ); |
|
118 | - define( 'TICKET_SELECTOR_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS ); |
|
117 | + define('TICKET_SELECTOR_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS); |
|
118 | + define('TICKET_SELECTOR_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS); |
|
119 | 119 | |
120 | 120 | //if config is not set, initialize |
121 | 121 | //If config is not set, set it. |
122 | - if ( ! isset( EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector ) ) { |
|
122 | + if ( ! isset(EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector)) { |
|
123 | 123 | EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = new EE_Ticket_Selector_Config(); |
124 | 124 | } |
125 | - EE_Registry::$i18n_js_strings[ 'ts_embed_iframe_title' ] = __( 'Copy and Paste the following:', 'event_espresso' ); |
|
125 | + EE_Registry::$i18n_js_strings['ts_embed_iframe_title'] = __('Copy and Paste the following:', 'event_espresso'); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | * @param object $WP |
134 | 134 | * @return void |
135 | 135 | */ |
136 | - public function run( $WP ) {} |
|
136 | + public function run($WP) {} |
|
137 | 137 | |
138 | 138 | |
139 | 139 | /** |
@@ -145,23 +145,23 @@ discard block |
||
145 | 145 | public function ticket_selector_iframe() { |
146 | 146 | self::$_in_iframe = true; |
147 | 147 | /** @type EEM_Event $EEM_Event */ |
148 | - $EEM_Event = EE_Registry::instance()->load_model( 'Event' ); |
|
148 | + $EEM_Event = EE_Registry::instance()->load_model('Event'); |
|
149 | 149 | $event = $EEM_Event->get_one_by_ID( |
150 | - EE_Registry::instance()->REQ->get( 'event', 0 ) |
|
150 | + EE_Registry::instance()->REQ->get('event', 0) |
|
151 | 151 | ); |
152 | - EE_Registry::instance()->REQ->set_espresso_page( true ); |
|
153 | - $template_args['ticket_selector'] = EED_Ticket_Selector::display_ticket_selector( $event ); |
|
152 | + EE_Registry::instance()->REQ->set_espresso_page(true); |
|
153 | + $template_args['ticket_selector'] = EED_Ticket_Selector::display_ticket_selector($event); |
|
154 | 154 | $template_args['css'] = apply_filters( |
155 | 155 | 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css', |
156 | 156 | array( |
157 | - TICKET_SELECTOR_ASSETS_URL . 'ticket_selector_embed.css?ver=' . EVENT_ESPRESSO_VERSION, |
|
158 | - TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css?ver=' . EVENT_ESPRESSO_VERSION, |
|
159 | - includes_url( 'css/dashicons.min.css?ver=' . $GLOBALS['wp_version'] ), |
|
160 | - EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION |
|
157 | + TICKET_SELECTOR_ASSETS_URL.'ticket_selector_embed.css?ver='.EVENT_ESPRESSO_VERSION, |
|
158 | + TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css?ver='.EVENT_ESPRESSO_VERSION, |
|
159 | + includes_url('css/dashicons.min.css?ver='.$GLOBALS['wp_version']), |
|
160 | + EE_GLOBAL_ASSETS_URL.'css/espresso_default.css?ver='.EVENT_ESPRESSO_VERSION |
|
161 | 161 | ) |
162 | 162 | ); |
163 | - EE_Registry::$i18n_js_strings[ 'ticket_selector_iframe' ] = true; |
|
164 | - EE_Registry::$i18n_js_strings[ 'EEDTicketSelectorMsg' ] = __( 'Please choose at least one ticket before continuing.', 'event_espresso' ); |
|
163 | + EE_Registry::$i18n_js_strings['ticket_selector_iframe'] = true; |
|
164 | + EE_Registry::$i18n_js_strings['EEDTicketSelectorMsg'] = __('Please choose at least one ticket before continuing.', 'event_espresso'); |
|
165 | 165 | $template_args['eei18n'] = apply_filters( |
166 | 166 | 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__eei18n_js_strings', |
167 | 167 | EE_Registry::localize_i18n_js_strings() |
@@ -169,19 +169,19 @@ discard block |
||
169 | 169 | $template_args['js'] = apply_filters( |
170 | 170 | 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
171 | 171 | array( |
172 | - includes_url( 'js/jquery/jquery.js?ver=' . $GLOBALS['wp_version'] ), |
|
173 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js?ver=' . EVENT_ESPRESSO_VERSION, |
|
174 | - TICKET_SELECTOR_ASSETS_URL . 'ticket_selector_iframe_embed.js?ver=' . EVENT_ESPRESSO_VERSION |
|
172 | + includes_url('js/jquery/jquery.js?ver='.$GLOBALS['wp_version']), |
|
173 | + EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js?ver='.EVENT_ESPRESSO_VERSION, |
|
174 | + TICKET_SELECTOR_ASSETS_URL.'ticket_selector_iframe_embed.js?ver='.EVENT_ESPRESSO_VERSION |
|
175 | 175 | ) |
176 | 176 | ); |
177 | 177 | EE_Registry::instance()->load_helper('Template'); |
178 | - $template_args[ 'notices' ] = EEH_Template::display_template( |
|
179 | - EE_TEMPLATES . 'espresso-ajax-notices.template.php', |
|
178 | + $template_args['notices'] = EEH_Template::display_template( |
|
179 | + EE_TEMPLATES.'espresso-ajax-notices.template.php', |
|
180 | 180 | array(), |
181 | 181 | true |
182 | 182 | ); |
183 | 183 | EEH_Template::display_template( |
184 | - TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_selector_chart_iframe.template.php', |
|
184 | + TICKET_SELECTOR_TEMPLATES_PATH.'ticket_selector_chart_iframe.template.php', |
|
185 | 185 | $template_args |
186 | 186 | ); |
187 | 187 | exit; |
@@ -200,23 +200,23 @@ discard block |
||
200 | 200 | * |
201 | 201 | * @return string The new html string for the permalink area. |
202 | 202 | */ |
203 | - public static function iframe_code_button( $permalink_string, $id, $new_title, $new_slug ) { |
|
203 | + public static function iframe_code_button($permalink_string, $id, $new_title, $new_slug) { |
|
204 | 204 | //make sure this is ONLY when editing and the event id has been set. |
205 | - if ( ! empty( $id ) ) { |
|
206 | - $post = get_post( $id ); |
|
205 | + if ( ! empty($id)) { |
|
206 | + $post = get_post($id); |
|
207 | 207 | |
208 | 208 | //if NOT event then let's get out. |
209 | - if ( $post->post_type !== 'espresso_events' ) { |
|
209 | + if ($post->post_type !== 'espresso_events') { |
|
210 | 210 | return $permalink_string; |
211 | 211 | } |
212 | 212 | |
213 | - $ticket_selector_url = add_query_arg( array( 'ticket_selector' => 'iframe', 'event' => $id ), site_url() ); |
|
213 | + $ticket_selector_url = add_query_arg(array('ticket_selector' => 'iframe', 'event' => $id), site_url()); |
|
214 | 214 | |
215 | - $permalink_string .= '<a id="js-ticket-selector-embed-trigger" class="button button-small" href="#" tabindex="-1">' . __('Embed', 'event_espresso') . '</a> '; |
|
215 | + $permalink_string .= '<a id="js-ticket-selector-embed-trigger" class="button button-small" href="#" tabindex="-1">'.__('Embed', 'event_espresso').'</a> '; |
|
216 | 216 | $permalink_string .= ' |
217 | 217 | <div id="js-ts-iframe" style="display:none"> |
218 | 218 | <div style="width:100%; height: 500px;"> |
219 | - <iframe src="' . $ticket_selector_url . '" width="100%" height="100%"></iframe> |
|
219 | + <iframe src="' . $ticket_selector_url.'" width="100%" height="100%"></iframe> |
|
220 | 220 | </div> |
221 | 221 | </div>'; |
222 | 222 | } |
@@ -235,22 +235,22 @@ discard block |
||
235 | 235 | * @param mixed $event |
236 | 236 | * @return bool |
237 | 237 | */ |
238 | - protected static function set_event( $event = null ) { |
|
239 | - if( $event === null ) { |
|
238 | + protected static function set_event($event = null) { |
|
239 | + if ($event === null) { |
|
240 | 240 | global $post; |
241 | 241 | $event = $post; |
242 | 242 | } |
243 | - if ( $event instanceof EE_Event ) { |
|
243 | + if ($event instanceof EE_Event) { |
|
244 | 244 | self::$_event = $event; |
245 | - } else if ( $event instanceof WP_Post && isset( $event->EE_Event ) && $event->EE_Event instanceof EE_Event ) { |
|
245 | + } else if ($event instanceof WP_Post && isset($event->EE_Event) && $event->EE_Event instanceof EE_Event) { |
|
246 | 246 | self::$_event = $event->EE_Event; |
247 | - } else if ( $event instanceof WP_Post && $event->post_type == 'espresso_events' ) { |
|
248 | - $event->EE_Event = EEM_Event::instance()->instantiate_class_from_post_object( $event ); |
|
247 | + } else if ($event instanceof WP_Post && $event->post_type == 'espresso_events') { |
|
248 | + $event->EE_Event = EEM_Event::instance()->instantiate_class_from_post_object($event); |
|
249 | 249 | self::$_event = $event->EE_Event; |
250 | 250 | } else { |
251 | - $user_msg = __( 'No Event object or an invalid Event object was supplied.', 'event_espresso' ); |
|
252 | - $dev_msg = $user_msg . __( 'In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.', 'event_espresso' ); |
|
253 | - EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
251 | + $user_msg = __('No Event object or an invalid Event object was supplied.', 'event_espresso'); |
|
252 | + $dev_msg = $user_msg.__('In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.', 'event_espresso'); |
|
253 | + EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__); |
|
254 | 254 | return false; |
255 | 255 | } |
256 | 256 | return true; |
@@ -269,11 +269,11 @@ discard block |
||
269 | 269 | * @param bool $view_details |
270 | 270 | * @return string |
271 | 271 | */ |
272 | - public static function display_ticket_selector( $event = NULL, $view_details = FALSE ) { |
|
272 | + public static function display_ticket_selector($event = NULL, $view_details = FALSE) { |
|
273 | 273 | // reset filter for displaying submit button |
274 | - remove_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' ); |
|
274 | + remove_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
275 | 275 | // poke and prod incoming event till it tells us what it is |
276 | - if ( ! EED_Ticket_Selector::set_event( $event )) { |
|
276 | + if ( ! EED_Ticket_Selector::set_event($event)) { |
|
277 | 277 | return false; |
278 | 278 | } |
279 | 279 | $event_post = self::$_event instanceof EE_Event ? self::$_event->ID() : $event; |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | && ( |
285 | 285 | ! self::$_event->display_ticket_selector() |
286 | 286 | || $view_details |
287 | - || post_password_required( $event_post ) |
|
287 | + || post_password_required($event_post) |
|
288 | 288 | || ( |
289 | 289 | $_event_active_status != EE_Datetime::active |
290 | 290 | && $_event_active_status != EE_Datetime::upcoming |
@@ -302,70 +302,70 @@ discard block |
||
302 | 302 | $template_args = array(); |
303 | 303 | $template_args['event_status'] = $_event_active_status; |
304 | 304 | |
305 | - $template_args['date_format'] = apply_filters( 'FHEE__EED_Ticket_Selector__display_ticket_selector__date_format', get_option( 'date_format' ) ); |
|
306 | - $template_args['time_format'] = apply_filters( 'FHEE__EED_Ticket_Selector__display_ticket_selector__time_format', get_option( 'time_format' ) ); |
|
305 | + $template_args['date_format'] = apply_filters('FHEE__EED_Ticket_Selector__display_ticket_selector__date_format', get_option('date_format')); |
|
306 | + $template_args['time_format'] = apply_filters('FHEE__EED_Ticket_Selector__display_ticket_selector__time_format', get_option('time_format')); |
|
307 | 307 | |
308 | 308 | $template_args['EVT_ID'] = self::$_event->ID(); |
309 | 309 | $template_args['event'] = self::$_event; |
310 | 310 | |
311 | 311 | // is the event expired ? |
312 | 312 | $template_args['event_is_expired'] = self::$_event->is_expired(); |
313 | - if ( $template_args['event_is_expired'] ) { |
|
314 | - return '<div class="ee-event-expired-notice"><span class="important-notice">' . __( 'We\'re sorry, but all tickets sales have ended because the event is expired.', 'event_espresso' ) . '</span></div>'; |
|
313 | + if ($template_args['event_is_expired']) { |
|
314 | + return '<div class="ee-event-expired-notice"><span class="important-notice">'.__('We\'re sorry, but all tickets sales have ended because the event is expired.', 'event_espresso').'</span></div>'; |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | $ticket_query_args = array( |
318 | - array( 'Datetime.EVT_ID' => self::$_event->ID() ), |
|
319 | - 'order_by' => array( 'TKT_order' => 'ASC', 'TKT_required' => 'DESC', 'TKT_start_date' => 'ASC', 'TKT_end_date' => 'ASC' , 'Datetime.DTT_EVT_start' => 'DESC' ) |
|
318 | + array('Datetime.EVT_ID' => self::$_event->ID()), |
|
319 | + 'order_by' => array('TKT_order' => 'ASC', 'TKT_required' => 'DESC', 'TKT_start_date' => 'ASC', 'TKT_end_date' => 'ASC', 'Datetime.DTT_EVT_start' => 'DESC') |
|
320 | 320 | ); |
321 | 321 | |
322 | - if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets ) { |
|
322 | + if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets) { |
|
323 | 323 | //use the correct applicable time query depending on what version of core is being run. |
324 | - $current_time = method_exists( 'EEM_Datetime', 'current_time_for_query' ) ? time() : current_time('timestamp'); |
|
325 | - $ticket_query_args[0]['TKT_end_date'] = array( '>', $current_time ); |
|
324 | + $current_time = method_exists('EEM_Datetime', 'current_time_for_query') ? time() : current_time('timestamp'); |
|
325 | + $ticket_query_args[0]['TKT_end_date'] = array('>', $current_time); |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | // get all tickets for this event ordered by the datetime |
329 | - $template_args['tickets'] = EEM_Ticket::instance()->get_all( $ticket_query_args ); |
|
329 | + $template_args['tickets'] = EEM_Ticket::instance()->get_all($ticket_query_args); |
|
330 | 330 | |
331 | - if ( count( $template_args['tickets'] ) < 1 ) { |
|
332 | - return '<div class="ee-event-expired-notice"><span class="important-notice">' . __( 'We\'re sorry, but all ticket sales have ended.', 'event_espresso' ) . '</span></div>'; |
|
331 | + if (count($template_args['tickets']) < 1) { |
|
332 | + return '<div class="ee-event-expired-notice"><span class="important-notice">'.__('We\'re sorry, but all ticket sales have ended.', 'event_espresso').'</span></div>'; |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | // filter the maximum qty that can appear in the Ticket Selector qty dropdowns |
336 | - $template_args['max_atndz'] = apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector__max_tickets', self::$_event->additional_limit() ); |
|
337 | - if ( $template_args['max_atndz'] < 1 ) { |
|
338 | - $sales_closed_msg = __( 'We\'re sorry, but ticket sales have been closed at this time. Please check back again later.', 'event_espresso' ); |
|
339 | - if ( current_user_can( 'edit_post', self::$_event->ID() )) { |
|
340 | - $sales_closed_msg .= sprintf( |
|
341 | - __( '%sNote to Event Admin:%sThe "Maximum number of tickets allowed per order for this event" in the Event Registration Options has been set to "0". This effectively turns off ticket sales. %s(click to edit this event)%s', 'event_espresso' ), |
|
336 | + $template_args['max_atndz'] = apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector__max_tickets', self::$_event->additional_limit()); |
|
337 | + if ($template_args['max_atndz'] < 1) { |
|
338 | + $sales_closed_msg = __('We\'re sorry, but ticket sales have been closed at this time. Please check back again later.', 'event_espresso'); |
|
339 | + if (current_user_can('edit_post', self::$_event->ID())) { |
|
340 | + $sales_closed_msg .= sprintf( |
|
341 | + __('%sNote to Event Admin:%sThe "Maximum number of tickets allowed per order for this event" in the Event Registration Options has been set to "0". This effectively turns off ticket sales. %s(click to edit this event)%s', 'event_espresso'), |
|
342 | 342 | '<div class="ee-attention" style="text-align: left;"><b>', |
343 | 343 | '</b><br />', |
344 | - $link = '<span class="edit-link"><a class="post-edit-link" href="' . get_edit_post_link( self::$_event->ID() ) . '">', |
|
344 | + $link = '<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link(self::$_event->ID()).'">', |
|
345 | 345 | '</a></span></div>' |
346 | 346 | ); |
347 | 347 | } |
348 | - return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>'; |
|
348 | + return '<p><span class="important-notice">'.$sales_closed_msg.'</span></p>'; |
|
349 | 349 | } |
350 | 350 | |
351 | - $templates['ticket_selector'] = TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_selector_chart.template.php'; |
|
352 | - $templates['ticket_selector'] = apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector__template_path', $templates['ticket_selector'], self::$_event ); |
|
351 | + $templates['ticket_selector'] = TICKET_SELECTOR_TEMPLATES_PATH.'ticket_selector_chart.template.php'; |
|
352 | + $templates['ticket_selector'] = apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector__template_path', $templates['ticket_selector'], self::$_event); |
|
353 | 353 | |
354 | 354 | // redirecting to another site for registration ?? |
355 | 355 | $external_url = self::$_event->external_url() !== NULL || self::$_event->external_url() !== '' ? self::$_event->external_url() : FALSE; |
356 | 356 | // set up the form (but not for the admin) |
357 | - $ticket_selector = ! is_admin() ? EED_Ticket_Selector::ticket_selector_form_open( self::$_event->ID(), $external_url ) : ''; |
|
357 | + $ticket_selector = ! is_admin() ? EED_Ticket_Selector::ticket_selector_form_open(self::$_event->ID(), $external_url) : ''; |
|
358 | 358 | // if not redirecting to another site for registration |
359 | - if ( ! $external_url ) { |
|
360 | - EE_Registry::instance()->load_helper( 'Template' ); |
|
361 | - EE_Registry::instance()->load_helper( 'URL' ); |
|
359 | + if ( ! $external_url) { |
|
360 | + EE_Registry::instance()->load_helper('Template'); |
|
361 | + EE_Registry::instance()->load_helper('URL'); |
|
362 | 362 | // then display the ticket selector |
363 | - $ticket_selector .= EEH_Template::locate_template( $templates['ticket_selector'], $template_args ); |
|
363 | + $ticket_selector .= EEH_Template::locate_template($templates['ticket_selector'], $template_args); |
|
364 | 364 | } else { |
365 | 365 | // if not we still need to trigger the display of the submit button |
366 | - add_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' ); |
|
366 | + add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
367 | 367 | //display notice to admin that registration is external |
368 | - $ticket_selector .= ! is_admin() ? '' : __( 'Registration is at an external URL for this event.', 'event_espresso' ); |
|
368 | + $ticket_selector .= ! is_admin() ? '' : __('Registration is at an external URL for this event.', 'event_espresso'); |
|
369 | 369 | } |
370 | 370 | // submit button and form close tag |
371 | 371 | $ticket_selector .= ! is_admin() ? EED_Ticket_Selector::display_ticket_selector_submit() : ''; |
@@ -385,27 +385,27 @@ discard block |
||
385 | 385 | * @param string $external_url |
386 | 386 | * @return string |
387 | 387 | */ |
388 | - public static function ticket_selector_form_open( $ID = 0, $external_url = '' ) { |
|
388 | + public static function ticket_selector_form_open($ID = 0, $external_url = '') { |
|
389 | 389 | // if redirecting, we don't need any anything else |
390 | - if ( $external_url ) { |
|
391 | - EE_Registry::instance()->load_helper( 'URL' ); |
|
392 | - $html = '<form method="GET" action="' . EEH_URL::refactor_url( $external_url ) . '">'; |
|
393 | - $query_args = EEH_URL::get_query_string( $external_url ); |
|
394 | - foreach ( $query_args as $query_arg => $value ) { |
|
395 | - $html .= '<input type="hidden" name="' . $query_arg . '" value="' . $value . '">'; |
|
390 | + if ($external_url) { |
|
391 | + EE_Registry::instance()->load_helper('URL'); |
|
392 | + $html = '<form method="GET" action="'.EEH_URL::refactor_url($external_url).'">'; |
|
393 | + $query_args = EEH_URL::get_query_string($external_url); |
|
394 | + foreach ($query_args as $query_arg => $value) { |
|
395 | + $html .= '<input type="hidden" name="'.$query_arg.'" value="'.$value.'">'; |
|
396 | 396 | } |
397 | 397 | return $html; |
398 | 398 | } |
399 | - EE_Registry::instance()->load_helper( 'Event_View' ); |
|
400 | - $checkout_url = EEH_Event_View::event_link_url( $ID ); |
|
401 | - if ( ! $checkout_url ) { |
|
402 | - EE_Error::add_error( __('The URL for the Event Details page could not be retrieved.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
399 | + EE_Registry::instance()->load_helper('Event_View'); |
|
400 | + $checkout_url = EEH_Event_View::event_link_url($ID); |
|
401 | + if ( ! $checkout_url) { |
|
402 | + EE_Error::add_error(__('The URL for the Event Details page could not be retrieved.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
403 | 403 | } |
404 | 404 | $extra_params = self::$_in_iframe ? ' target="_blank"' : ''; |
405 | - $html = '<form method="POST" action="' . $checkout_url . '"' . $extra_params . '>'; |
|
406 | - $html .= wp_nonce_field( 'process_ticket_selections', 'process_ticket_selections_nonce', TRUE, FALSE ); |
|
405 | + $html = '<form method="POST" action="'.$checkout_url.'"'.$extra_params.'>'; |
|
406 | + $html .= wp_nonce_field('process_ticket_selections', 'process_ticket_selections_nonce', TRUE, FALSE); |
|
407 | 407 | $html .= '<input type="hidden" name="ee" value="process_ticket_selections">'; |
408 | - $html = apply_filters( 'FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, self::$_event ); |
|
408 | + $html = apply_filters('FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, self::$_event); |
|
409 | 409 | return $html; |
410 | 410 | } |
411 | 411 | |
@@ -420,21 +420,21 @@ discard block |
||
420 | 420 | * @return string |
421 | 421 | */ |
422 | 422 | public static function display_ticket_selector_submit() { |
423 | - if ( ! is_admin() ) { |
|
424 | - if ( apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', FALSE ) ) { |
|
423 | + if ( ! is_admin()) { |
|
424 | + if (apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', FALSE)) { |
|
425 | 425 | $btn_text = apply_filters( |
426 | 426 | 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text', |
427 | - __('Register Now', 'event_espresso' ), |
|
427 | + __('Register Now', 'event_espresso'), |
|
428 | 428 | self::$_event |
429 | 429 | ); |
430 | - $html = '<input id="ticket-selector-submit-'. self::$_event->ID() .'-btn"'; |
|
430 | + $html = '<input id="ticket-selector-submit-'.self::$_event->ID().'-btn"'; |
|
431 | 431 | $html .= ' class="ticket-selector-submit-btn ticket-selector-submit-ajax"'; |
432 | - $html .= ' type="submit" value="' . $btn_text . '" />'; |
|
433 | - $html .= apply_filters( 'FHEE__EE_Ticket_Selector__after_ticket_selector_submit', '', self::$_event ); |
|
432 | + $html .= ' type="submit" value="'.$btn_text.'" />'; |
|
433 | + $html .= apply_filters('FHEE__EE_Ticket_Selector__after_ticket_selector_submit', '', self::$_event); |
|
434 | 434 | $html .= '<div class="clear"><br/></div></form>'; |
435 | 435 | return $html; |
436 | - } else if ( is_archive() ) { |
|
437 | - return EED_Ticket_Selector::ticket_selector_form_close() . EED_Ticket_Selector::display_view_details_btn(); |
|
436 | + } else if (is_archive()) { |
|
437 | + return EED_Ticket_Selector::ticket_selector_form_close().EED_Ticket_Selector::display_view_details_btn(); |
|
438 | 438 | } |
439 | 439 | } |
440 | 440 | return ''; |
@@ -466,13 +466,13 @@ discard block |
||
466 | 466 | * @return string |
467 | 467 | */ |
468 | 468 | public static function display_view_details_btn() { |
469 | - if ( ! self::$_event->get_permalink() ) { |
|
470 | - EE_Error::add_error( __('The URL for the Event Details page could not be retrieved.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
469 | + if ( ! self::$_event->get_permalink()) { |
|
470 | + EE_Error::add_error(__('The URL for the Event Details page could not be retrieved.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
471 | 471 | } |
472 | - $view_details_btn = '<form method="POST" action="' . self::$_event->get_permalink() . '">'; |
|
473 | - $btn_text = apply_filters( 'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text', __( 'View Details', 'event_espresso' ), self::$_event ); |
|
474 | - $view_details_btn .= '<input id="ticket-selector-submit-'. self::$_event->ID() .'-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="' . $btn_text . '" />'; |
|
475 | - $view_details_btn .= apply_filters( 'FHEE__EE_Ticket_Selector__after_view_details_btn', '', self::$_event ); |
|
472 | + $view_details_btn = '<form method="POST" action="'.self::$_event->get_permalink().'">'; |
|
473 | + $btn_text = apply_filters('FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text', __('View Details', 'event_espresso'), self::$_event); |
|
474 | + $view_details_btn .= '<input id="ticket-selector-submit-'.self::$_event->ID().'-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="'.$btn_text.'" />'; |
|
475 | + $view_details_btn .= apply_filters('FHEE__EE_Ticket_Selector__after_view_details_btn', '', self::$_event); |
|
476 | 476 | $view_details_btn .= '<div class="clear"><br/></div>'; |
477 | 477 | $view_details_btn .= '</form>'; |
478 | 478 | return $view_details_btn; |
@@ -491,11 +491,11 @@ discard block |
||
491 | 491 | * @return array or FALSE |
492 | 492 | */ |
493 | 493 | public function process_ticket_selections() { |
494 | - do_action( 'EED_Ticket_Selector__process_ticket_selections__before' ); |
|
494 | + do_action('EED_Ticket_Selector__process_ticket_selections__before'); |
|
495 | 495 | // check nonce |
496 | - if ( ! is_admin() && ( ! EE_Registry::instance()->REQ->is_set( 'process_ticket_selections_nonce' ) || ! wp_verify_nonce( EE_Registry::instance()->REQ->get( 'process_ticket_selections_nonce' ), 'process_ticket_selections' ))) { |
|
496 | + if ( ! is_admin() && ( ! EE_Registry::instance()->REQ->is_set('process_ticket_selections_nonce') || ! wp_verify_nonce(EE_Registry::instance()->REQ->get('process_ticket_selections_nonce'), 'process_ticket_selections'))) { |
|
497 | 497 | EE_Error::add_error( |
498 | - sprintf( __( 'We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.', 'event_espresso' ), '<br/>' ), |
|
498 | + sprintf(__('We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.', 'event_espresso'), '<br/>'), |
|
499 | 499 | __FILE__, __FUNCTION__, __LINE__ |
500 | 500 | ); |
501 | 501 | return FALSE; |
@@ -509,16 +509,16 @@ discard block |
||
509 | 509 | |
510 | 510 | //we should really only have 1 registration in the works now (ie, no MER) so clear any previous items in the cart. |
511 | 511 | // When MER happens this will probably need to be tweaked, possibly wrapped in a conditional checking for some constant defined in MER etc. |
512 | - EE_Registry::instance()->load_core( 'Session' ); |
|
512 | + EE_Registry::instance()->load_core('Session'); |
|
513 | 513 | // unless otherwise requested, clear the session |
514 | - if ( apply_filters( 'FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', TRUE )) { |
|
515 | - EE_Registry::instance()->SSN->clear_session( __CLASS__, __FUNCTION__ ); |
|
514 | + if (apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', TRUE)) { |
|
515 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
516 | 516 | } |
517 | 517 | //d( EE_Registry::instance()->SSN ); |
518 | 518 | |
519 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
519 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
520 | 520 | // do we have an event id? |
521 | - if ( EE_Registry::instance()->REQ->is_set( 'tkt-slctr-event-id' ) ) { |
|
521 | + if (EE_Registry::instance()->REQ->is_set('tkt-slctr-event-id')) { |
|
522 | 522 | // validate/sanitize data |
523 | 523 | $valid = self::_validate_post_data(); |
524 | 524 | |
@@ -528,43 +528,43 @@ discard block |
||
528 | 528 | //EEH_Debug_Tools::printr( $valid[ 'max_atndz' ], 'max_atndz', __FILE__, __LINE__ ); |
529 | 529 | |
530 | 530 | //check total tickets ordered vs max number of attendees that can register |
531 | - if ( $valid['total_tickets'] > $valid['max_atndz'] ) { |
|
531 | + if ($valid['total_tickets'] > $valid['max_atndz']) { |
|
532 | 532 | |
533 | 533 | // ordering too many tickets !!! |
534 | 534 | $singular = 'You have attempted to purchase %s ticket.'; |
535 | 535 | $plural = 'You have attempted to purchase %s tickets.'; |
536 | - $limit_error_1 = sprintf( _n( $singular, $plural, $valid['total_tickets'], 'event_espresso' ), $valid['total_tickets'], $valid['total_tickets'] ); |
|
536 | + $limit_error_1 = sprintf(_n($singular, $plural, $valid['total_tickets'], 'event_espresso'), $valid['total_tickets'], $valid['total_tickets']); |
|
537 | 537 | // dev only message |
538 | 538 | $singular = 'The registration limit for this event is %s ticket per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.'; |
539 | 539 | $plural = 'The registration limit for this event is %s tickets per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.'; |
540 | - $limit_error_2 = sprintf( _n( $singular, $plural, $valid['max_atndz'], 'event_espresso' ), $valid['max_atndz'], $valid['max_atndz'] ); |
|
541 | - EE_Error::add_error( $limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__ ); |
|
540 | + $limit_error_2 = sprintf(_n($singular, $plural, $valid['max_atndz'], 'event_espresso'), $valid['max_atndz'], $valid['max_atndz']); |
|
541 | + EE_Error::add_error($limit_error_1.'<br/>'.$limit_error_2, __FILE__, __FUNCTION__, __LINE__); |
|
542 | 542 | } else { |
543 | 543 | |
544 | 544 | // all data appears to be valid |
545 | 545 | $tckts_slctd = FALSE; |
546 | 546 | $success = TRUE; |
547 | 547 | // load cart |
548 | - EE_Registry::instance()->load_core( 'Cart' ); |
|
548 | + EE_Registry::instance()->load_core('Cart'); |
|
549 | 549 | |
550 | 550 | // cycle thru the number of data rows sent from the event listing |
551 | - for ( $x = 0; $x < $valid['rows']; $x++ ) { |
|
551 | + for ($x = 0; $x < $valid['rows']; $x++) { |
|
552 | 552 | // does this row actually contain a ticket quantity? |
553 | - if ( isset( $valid['qty'][$x] ) && $valid['qty'][$x] > 0 ) { |
|
553 | + if (isset($valid['qty'][$x]) && $valid['qty'][$x] > 0) { |
|
554 | 554 | // YES we have a ticket quantity |
555 | 555 | $tckts_slctd = TRUE; |
556 | 556 | // d( $valid['ticket_obj'][$x] ); |
557 | - if ( $valid['ticket_obj'][$x] instanceof EE_Ticket ) { |
|
557 | + if ($valid['ticket_obj'][$x] instanceof EE_Ticket) { |
|
558 | 558 | // then add ticket to cart |
559 | - $ticket_added = self::_add_ticket_to_cart( $valid['ticket_obj'][$x], $valid['qty'][$x] ); |
|
559 | + $ticket_added = self::_add_ticket_to_cart($valid['ticket_obj'][$x], $valid['qty'][$x]); |
|
560 | 560 | $success = ! $ticket_added ? FALSE : $success; |
561 | - if ( EE_Error::has_error() ) { |
|
561 | + if (EE_Error::has_error()) { |
|
562 | 562 | break; |
563 | 563 | } |
564 | 564 | } else { |
565 | 565 | // nothing added to cart retrieved |
566 | 566 | EE_Error::add_error( |
567 | - sprintf( __( 'A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.', 'event_espresso' ), '<br/>' ), |
|
567 | + sprintf(__('A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.', 'event_espresso'), '<br/>'), |
|
568 | 568 | __FILE__, __FUNCTION__, __LINE__ |
569 | 569 | ); |
570 | 570 | } |
@@ -573,45 +573,45 @@ discard block |
||
573 | 573 | //d( EE_Registry::instance()->CART ); |
574 | 574 | //die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE |
575 | 575 | |
576 | - if ( $tckts_slctd ) { |
|
577 | - if ( $success ) { |
|
578 | - do_action( 'FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout', EE_Registry::instance()->CART, $this ); |
|
576 | + if ($tckts_slctd) { |
|
577 | + if ($success) { |
|
578 | + do_action('FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout', EE_Registry::instance()->CART, $this); |
|
579 | 579 | EE_Registry::instance()->CART->recalculate_all_cart_totals(); |
580 | - EE_Registry::instance()->CART->save_cart( FALSE ); |
|
580 | + EE_Registry::instance()->CART->save_cart(FALSE); |
|
581 | 581 | EE_Registry::instance()->SSN->update(); |
582 | 582 | //d( EE_Registry::instance()->CART ); |
583 | 583 | //die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< OR HERE TO KILL REDIRECT AFTER CART UPDATE |
584 | 584 | // just return TRUE for registrations being made from admin |
585 | - if ( is_admin() ) { |
|
585 | + if (is_admin()) { |
|
586 | 586 | return TRUE; |
587 | 587 | } |
588 | - wp_safe_redirect( apply_filters( 'FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url', EE_Registry::instance()->CFG->core->reg_page_url() )); |
|
588 | + wp_safe_redirect(apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url', EE_Registry::instance()->CFG->core->reg_page_url())); |
|
589 | 589 | exit(); |
590 | 590 | |
591 | 591 | } else { |
592 | - if ( ! EE_Error::has_error() ) { |
|
592 | + if ( ! EE_Error::has_error()) { |
|
593 | 593 | // nothing added to cart |
594 | - EE_Error::add_attention( __( 'No tickets were added for the event', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
594 | + EE_Error::add_attention(__('No tickets were added for the event', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
595 | 595 | } |
596 | 596 | } |
597 | 597 | |
598 | 598 | } else { |
599 | 599 | // no ticket quantities were selected |
600 | - EE_Error::add_error( __( 'You need to select a ticket quantity before you can proceed.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
600 | + EE_Error::add_error(__('You need to select a ticket quantity before you can proceed.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
601 | 601 | } |
602 | 602 | } |
603 | 603 | //die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL BEFORE REDIRECT |
604 | 604 | // at this point, just return if registration is being made from admin |
605 | - if ( is_admin() ) { |
|
605 | + if (is_admin()) { |
|
606 | 606 | return FALSE; |
607 | 607 | } |
608 | - if ( $valid['return_url'] ) { |
|
609 | - EE_Error::get_notices( FALSE, TRUE ); |
|
610 | - wp_safe_redirect( $valid['return_url'] ); |
|
608 | + if ($valid['return_url']) { |
|
609 | + EE_Error::get_notices(FALSE, TRUE); |
|
610 | + wp_safe_redirect($valid['return_url']); |
|
611 | 611 | exit(); |
612 | - } elseif ( isset( $event_to_add['id'] )) { |
|
613 | - EE_Error::get_notices( FALSE, TRUE ); |
|
614 | - wp_safe_redirect( get_permalink( $event_to_add['id'] )); |
|
612 | + } elseif (isset($event_to_add['id'])) { |
|
613 | + EE_Error::get_notices(FALSE, TRUE); |
|
614 | + wp_safe_redirect(get_permalink($event_to_add['id'])); |
|
615 | 615 | exit(); |
616 | 616 | } else { |
617 | 617 | echo EE_Error::get_notices(); |
@@ -620,7 +620,7 @@ discard block |
||
620 | 620 | } else { |
621 | 621 | // $_POST['tkt-slctr-event-id'] was not set ?!?!?!? |
622 | 622 | EE_Error::add_error( |
623 | - sprintf( __( 'An event id was not provided or was not received.%sPlease click the back button on your browser and try again.', 'event_espresso' ), '<br/>' ), |
|
623 | + sprintf(__('An event id was not provided or was not received.%sPlease click the back button on your browser and try again.', 'event_espresso'), '<br/>'), |
|
624 | 624 | __FILE__, __FUNCTION__, __LINE__ |
625 | 625 | ); |
626 | 626 | } |
@@ -638,18 +638,18 @@ discard block |
||
638 | 638 | * @return array or FALSE |
639 | 639 | */ |
640 | 640 | private static function _validate_post_data() { |
641 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
641 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
642 | 642 | |
643 | 643 | // start with an empty array() |
644 | 644 | $valid_data = array(); |
645 | 645 | // d( $_POST ); |
646 | 646 | //if event id is valid |
647 | - $id = absint( EE_Registry::instance()->REQ->get( 'tkt-slctr-event-id' )); |
|
648 | - if ( $id ) { |
|
647 | + $id = absint(EE_Registry::instance()->REQ->get('tkt-slctr-event-id')); |
|
648 | + if ($id) { |
|
649 | 649 | // grab valid id |
650 | 650 | $valid_data['id'] = $id; |
651 | 651 | // grab and sanitize return-url |
652 | - $valid_data['return_url'] = esc_url_raw( EE_Registry::instance()->REQ->get( 'tkt-slctr-return-url-' . $id )); |
|
652 | + $valid_data['return_url'] = esc_url_raw(EE_Registry::instance()->REQ->get('tkt-slctr-return-url-'.$id)); |
|
653 | 653 | // array of other form names |
654 | 654 | $inputs_to_clean = array( |
655 | 655 | 'event_id' => 'tkt-slctr-event-id', |
@@ -662,22 +662,22 @@ discard block |
||
662 | 662 | // let's track the total number of tickets ordered.' |
663 | 663 | $valid_data['total_tickets'] = 0; |
664 | 664 | // cycle through $inputs_to_clean array |
665 | - foreach ( $inputs_to_clean as $what => $input_to_clean ) { |
|
665 | + foreach ($inputs_to_clean as $what => $input_to_clean) { |
|
666 | 666 | // check for POST data |
667 | - if ( EE_Registry::instance()->REQ->is_set( $input_to_clean . $id )) { |
|
667 | + if (EE_Registry::instance()->REQ->is_set($input_to_clean.$id)) { |
|
668 | 668 | // grab value |
669 | - $input_value = EE_Registry::instance()->REQ->get( $input_to_clean . $id ); |
|
669 | + $input_value = EE_Registry::instance()->REQ->get($input_to_clean.$id); |
|
670 | 670 | switch ($what) { |
671 | 671 | |
672 | 672 | // integers |
673 | 673 | case 'event_id': |
674 | - $valid_data[$what] = absint( $input_value ); |
|
674 | + $valid_data[$what] = absint($input_value); |
|
675 | 675 | // get event via the event id we put in the form |
676 | - $valid_data['event'] = EE_Registry::instance()->load_model( 'Event' )->get_one_by_ID( $valid_data['event_id'] ); |
|
676 | + $valid_data['event'] = EE_Registry::instance()->load_model('Event')->get_one_by_ID($valid_data['event_id']); |
|
677 | 677 | break; |
678 | 678 | case 'rows': |
679 | 679 | case 'max_atndz': |
680 | - $valid_data[$what] = absint( $input_value ); |
|
680 | + $valid_data[$what] = absint($input_value); |
|
681 | 681 | break; |
682 | 682 | |
683 | 683 | // arrays of integers |
@@ -685,27 +685,27 @@ discard block |
||
685 | 685 | // d( $input_value ); |
686 | 686 | $row_qty = $input_value; |
687 | 687 | // if qty is coming from a radio button input, then we need to assemble an array of rows |
688 | - if( ! is_array( $row_qty )) { |
|
688 | + if ( ! is_array($row_qty)) { |
|
689 | 689 | // get number of rows |
690 | - $rows = EE_Registry::instance()->REQ->is_set( 'tkt-slctr-rows-' . $id ) ? absint( EE_Registry::instance()->REQ->get( 'tkt-slctr-rows-' . $id )) : 1; |
|
690 | + $rows = EE_Registry::instance()->REQ->is_set('tkt-slctr-rows-'.$id) ? absint(EE_Registry::instance()->REQ->get('tkt-slctr-rows-'.$id)) : 1; |
|
691 | 691 | // d( $rows ); |
692 | 692 | // explode ints by the dash |
693 | - $row_qty = explode( '-', $row_qty ); |
|
694 | - $row = isset( $row_qty[0] ) ? ( absint( $row_qty[0] )) : 1; |
|
695 | - $qty = isset( $row_qty[1] ) ? absint( $row_qty[1] ) : 0; |
|
696 | - $row_qty = array( $row => $qty ); |
|
693 | + $row_qty = explode('-', $row_qty); |
|
694 | + $row = isset($row_qty[0]) ? (absint($row_qty[0])) : 1; |
|
695 | + $qty = isset($row_qty[1]) ? absint($row_qty[1]) : 0; |
|
696 | + $row_qty = array($row => $qty); |
|
697 | 697 | // d( $row_qty ); |
698 | - for( $x = 1; $x <= $rows; $x++ ) { |
|
699 | - if ( ! isset( $row_qty[$x] )) { |
|
698 | + for ($x = 1; $x <= $rows; $x++) { |
|
699 | + if ( ! isset($row_qty[$x])) { |
|
700 | 700 | $row_qty[$x] = 0; |
701 | 701 | } |
702 | 702 | } |
703 | 703 | } |
704 | - ksort( $row_qty ); |
|
704 | + ksort($row_qty); |
|
705 | 705 | // d( $row_qty ); |
706 | 706 | // cycle thru values |
707 | - foreach ( $row_qty as $qty ) { |
|
708 | - $qty = absint( $qty ); |
|
707 | + foreach ($row_qty as $qty) { |
|
708 | + $qty = absint($qty); |
|
709 | 709 | // sanitize as integers |
710 | 710 | $valid_data[$what][] = $qty; |
711 | 711 | $valid_data['total_tickets'] += $qty; |
@@ -716,19 +716,19 @@ discard block |
||
716 | 716 | case 'ticket_id': |
717 | 717 | $value_array = array(); |
718 | 718 | // cycle thru values |
719 | - foreach ( $input_value as $key=>$value ) { |
|
719 | + foreach ($input_value as $key=>$value) { |
|
720 | 720 | // allow only numbers, letters, spaces, commas and dashes |
721 | - $value_array[ $key ] = wp_strip_all_tags( $value ); |
|
721 | + $value_array[$key] = wp_strip_all_tags($value); |
|
722 | 722 | // get ticket via the ticket id we put in the form |
723 | - $ticket_obj = EE_Registry::instance()->load_model( 'Ticket' )->get_one_by_ID( $value ); |
|
724 | - $valid_data['ticket_obj'][ $key ] = $ticket_obj; |
|
723 | + $ticket_obj = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($value); |
|
724 | + $valid_data['ticket_obj'][$key] = $ticket_obj; |
|
725 | 725 | } |
726 | - $valid_data[ $what ] = $value_array; |
|
726 | + $valid_data[$what] = $value_array; |
|
727 | 727 | break; |
728 | 728 | |
729 | 729 | case 'return_url' : |
730 | 730 | // grab and sanitize return-url |
731 | - $valid_data[$what] = esc_url_raw( $input_value ); |
|
731 | + $valid_data[$what] = esc_url_raw($input_value); |
|
732 | 732 | break; |
733 | 733 | |
734 | 734 | } // end switch $what |
@@ -736,7 +736,7 @@ discard block |
||
736 | 736 | } // end foreach $inputs_to_clean |
737 | 737 | |
738 | 738 | } else { |
739 | - EE_Error::add_error( __('The event id provided was not valid.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
739 | + EE_Error::add_error(__('The event id provided was not valid.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
740 | 740 | return FALSE; |
741 | 741 | } |
742 | 742 | |
@@ -754,28 +754,28 @@ discard block |
||
754 | 754 | * @param int $qty |
755 | 755 | * @return TRUE on success, FALSE on fail |
756 | 756 | */ |
757 | - private static function _add_ticket_to_cart( EE_Ticket $ticket = NULL, $qty = 1 ) { |
|
758 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
757 | + private static function _add_ticket_to_cart(EE_Ticket $ticket = NULL, $qty = 1) { |
|
758 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
759 | 759 | // get the number of spaces left for this datetime ticket |
760 | - $available_spaces = self::_ticket_datetime_availability( $ticket ); |
|
760 | + $available_spaces = self::_ticket_datetime_availability($ticket); |
|
761 | 761 | // compare available spaces against the number of tickets being purchased |
762 | - if ( $available_spaces >= $qty ) { |
|
762 | + if ($available_spaces >= $qty) { |
|
763 | 763 | // allow addons to prevent a ticket from being added to cart |
764 | - if ( ! apply_filters( 'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart', true, $ticket, $qty, $available_spaces ) ) { |
|
764 | + if ( ! apply_filters('FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart', true, $ticket, $qty, $available_spaces)) { |
|
765 | 765 | return false; |
766 | 766 | } |
767 | 767 | // add event to cart |
768 | - if( EE_Registry::instance()->CART->add_ticket_to_cart( $ticket, $qty )) { |
|
769 | - self::_recalculate_ticket_datetime_availability( $ticket, $qty ); |
|
768 | + if (EE_Registry::instance()->CART->add_ticket_to_cart($ticket, $qty)) { |
|
769 | + self::_recalculate_ticket_datetime_availability($ticket, $qty); |
|
770 | 770 | return true; |
771 | 771 | } else { |
772 | 772 | return false; |
773 | 773 | } |
774 | 774 | } else { |
775 | 775 | // tickets can not be purchased but let's find the exact number left for the last ticket selected PRIOR to subtracting tickets |
776 | - $available_spaces = self::_ticket_datetime_availability( $ticket, true ); |
|
776 | + $available_spaces = self::_ticket_datetime_availability($ticket, true); |
|
777 | 777 | // greedy greedy greedy eh? |
778 | - if ( $available_spaces > 0 ) { |
|
778 | + if ($available_spaces > 0) { |
|
779 | 779 | // add error messaging - we're using the _n function that will generate the appropriate singular or plural message based on the number of $available_spaces |
780 | 780 | EE_Error::add_error( |
781 | 781 | sprintf( |
@@ -791,7 +791,7 @@ discard block |
||
791 | 791 | __FILE__, __FUNCTION__, __LINE__ |
792 | 792 | ); |
793 | 793 | } else { |
794 | - EE_Error::add_error( __('We\'re sorry, but there are no available spaces left for this event at this particular date and time.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
794 | + EE_Error::add_error(__('We\'re sorry, but there are no available spaces left for this event at this particular date and time.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
795 | 795 | } |
796 | 796 | return false; |
797 | 797 | } |
@@ -809,22 +809,22 @@ discard block |
||
809 | 809 | * @param bool $get_original_ticket_spaces |
810 | 810 | * @return int |
811 | 811 | */ |
812 | - private static function _ticket_datetime_availability( EE_Ticket $ticket, $get_original_ticket_spaces = FALSE ) { |
|
812 | + private static function _ticket_datetime_availability(EE_Ticket $ticket, $get_original_ticket_spaces = FALSE) { |
|
813 | 813 | // if the $_available_spaces array has not been set up yet... |
814 | - if ( ! isset( self::$_available_spaces['tickets'][ $ticket->ID() ] )) { |
|
815 | - self::_set_initial_ticket_datetime_availability( $ticket ); |
|
814 | + if ( ! isset(self::$_available_spaces['tickets'][$ticket->ID()])) { |
|
815 | + self::_set_initial_ticket_datetime_availability($ticket); |
|
816 | 816 | } |
817 | 817 | $available_spaces = $ticket->qty() - $ticket->sold(); |
818 | - if ( isset( self::$_available_spaces['tickets'][ $ticket->ID() ] )) { |
|
818 | + if (isset(self::$_available_spaces['tickets'][$ticket->ID()])) { |
|
819 | 819 | // loop thru tickets, which will ALSO include individual ticket records AND a total |
820 | - foreach ( self::$_available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces ) { |
|
820 | + foreach (self::$_available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) { |
|
821 | 821 | // if we want the original datetime availability BEFORE we started subtracting tickets ? |
822 | - if ( $get_original_ticket_spaces ) { |
|
822 | + if ($get_original_ticket_spaces) { |
|
823 | 823 | // then grab the available spaces from the "tickets" array and compare with the above to get the lowest number |
824 | - $available_spaces = min( $available_spaces, self::$_available_spaces['tickets'][ $ticket->ID() ][ $DTD_ID ] ); |
|
824 | + $available_spaces = min($available_spaces, self::$_available_spaces['tickets'][$ticket->ID()][$DTD_ID]); |
|
825 | 825 | } else { |
826 | 826 | // we want the updated ticket availability as stored in the "datetimes" array |
827 | - $available_spaces = min( $available_spaces, self::$_available_spaces['datetimes'][ $DTD_ID ] ); |
|
827 | + $available_spaces = min($available_spaces, self::$_available_spaces['datetimes'][$DTD_ID]); |
|
828 | 828 | } |
829 | 829 | } |
830 | 830 | } |
@@ -840,23 +840,23 @@ discard block |
||
840 | 840 | * @param EE_Ticket $ticket |
841 | 841 | * @return int |
842 | 842 | */ |
843 | - private static function _set_initial_ticket_datetime_availability( EE_Ticket $ticket ) { |
|
843 | + private static function _set_initial_ticket_datetime_availability(EE_Ticket $ticket) { |
|
844 | 844 | // first, get all of the datetimes that are available to this ticket |
845 | 845 | $datetimes = $ticket->get_many_related( |
846 | 846 | 'Datetime', |
847 | - array( array( 'DTT_EVT_end' => array( '>=', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_end' ) ) ), 'order_by' => array( 'DTT_EVT_start' => 'ASC' )) |
|
847 | + array(array('DTT_EVT_end' => array('>=', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'))), 'order_by' => array('DTT_EVT_start' => 'ASC')) |
|
848 | 848 | ); |
849 | - if ( ! empty( $datetimes )) { |
|
849 | + if ( ! empty($datetimes)) { |
|
850 | 850 | // now loop thru all of the datetimes |
851 | - foreach ( $datetimes as $datetime ) { |
|
852 | - if ( $datetime instanceof EE_Datetime ) { |
|
851 | + foreach ($datetimes as $datetime) { |
|
852 | + if ($datetime instanceof EE_Datetime) { |
|
853 | 853 | // the number of spaces available for the datetime without considering individual ticket quantities |
854 | 854 | $spaces_remaining = $datetime->spaces_remaining(); |
855 | 855 | // save the total available spaces ( the lesser of the ticket qty minus the number of tickets sold or the datetime spaces remaining) to this ticket using the datetime ID as the key |
856 | - self::$_available_spaces['tickets'][ $ticket->ID() ][ $datetime->ID() ] = min(( $ticket->qty() - $ticket->sold() ), $spaces_remaining ); |
|
856 | + self::$_available_spaces['tickets'][$ticket->ID()][$datetime->ID()] = min(($ticket->qty() - $ticket->sold()), $spaces_remaining); |
|
857 | 857 | // if the remaining spaces for this datetime is already set, then compare that against the datetime spaces remaining, and take the lowest number, |
858 | 858 | // else just take the datetime spaces remaining, and assign to the datetimes array |
859 | - self::$_available_spaces['datetimes'][ $datetime->ID() ] = isset( self::$_available_spaces['datetimes'][ $datetime->ID() ] ) ? min( self::$_available_spaces['datetimes'][ $datetime->ID() ], $spaces_remaining ) : $spaces_remaining; |
|
859 | + self::$_available_spaces['datetimes'][$datetime->ID()] = isset(self::$_available_spaces['datetimes'][$datetime->ID()]) ? min(self::$_available_spaces['datetimes'][$datetime->ID()], $spaces_remaining) : $spaces_remaining; |
|
860 | 860 | } |
861 | 861 | } |
862 | 862 | } |
@@ -872,12 +872,12 @@ discard block |
||
872 | 872 | * @param int $qty |
873 | 873 | * @return int |
874 | 874 | */ |
875 | - private static function _recalculate_ticket_datetime_availability( EE_Ticket $ticket, $qty = 0 ) { |
|
876 | - if ( isset( self::$_available_spaces['tickets'][ $ticket->ID() ] )) { |
|
875 | + private static function _recalculate_ticket_datetime_availability(EE_Ticket $ticket, $qty = 0) { |
|
876 | + if (isset(self::$_available_spaces['tickets'][$ticket->ID()])) { |
|
877 | 877 | // loop thru tickets, which will ALSO include individual ticket records AND a total |
878 | - foreach ( self::$_available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces ) { |
|
878 | + foreach (self::$_available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) { |
|
879 | 879 | // subtract the qty of selected tickets from each datetime's available spaces this ticket has access to, |
880 | - self::$_available_spaces['datetimes'][ $DTD_ID ] = self::$_available_spaces['datetimes'][ $DTD_ID ] - $qty; |
|
880 | + self::$_available_spaces['datetimes'][$DTD_ID] = self::$_available_spaces['datetimes'][$DTD_ID] - $qty; |
|
881 | 881 | } |
882 | 882 | } |
883 | 883 | } |
@@ -894,8 +894,8 @@ discard block |
||
894 | 894 | */ |
895 | 895 | public static function load_tckt_slctr_assets() { |
896 | 896 | // add some style |
897 | - if ( apply_filters( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE ) ) { |
|
898 | - wp_register_style('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css'); |
|
897 | + if (apply_filters('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE)) { |
|
898 | + wp_register_style('ticket_selector', TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css'); |
|
899 | 899 | wp_enqueue_style('ticket_selector'); |
900 | 900 | // make it dance |
901 | 901 | // wp_register_script('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js', array('espresso_core'), '', TRUE); |
@@ -909,9 +909,9 @@ discard block |
||
909 | 909 | |
910 | 910 | public static function load_tckt_slctr_assets_admin() { |
911 | 911 | //iframe button js on admin event editor page |
912 | - if ( EE_Registry::instance()->REQ->get('page') == 'espresso_events' && EE_Registry::instance()->REQ->get('action') == 'edit' ) { |
|
913 | - wp_register_script( 'ticket_selector_embed', TICKET_SELECTOR_ASSETS_URL . 'ticket-selector-embed.js', array( 'ee-dialog' ), EVENT_ESPRESSO_VERSION, true ); |
|
914 | - wp_enqueue_script( 'ticket_selector_embed' ); |
|
912 | + if (EE_Registry::instance()->REQ->get('page') == 'espresso_events' && EE_Registry::instance()->REQ->get('action') == 'edit') { |
|
913 | + wp_register_script('ticket_selector_embed', TICKET_SELECTOR_ASSETS_URL.'ticket-selector-embed.js', array('ee-dialog'), EVENT_ESPRESSO_VERSION, true); |
|
914 | + wp_enqueue_script('ticket_selector_embed'); |
|
915 | 915 | } |
916 | 916 | } |
917 | 917 |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | * @param WP $WP |
20 | 20 | * @return void |
21 | 21 | */ |
22 | - public function run( WP $WP ) {} |
|
22 | + public function run(WP $WP) {} |
|
23 | 23 | |
24 | 24 | |
25 | 25 | /** |
@@ -69,14 +69,14 @@ discard block |
||
69 | 69 | * @param array $attributes |
70 | 70 | * @return string |
71 | 71 | */ |
72 | - public function process_shortcode( $attributes = array() ) { |
|
72 | + public function process_shortcode($attributes = array()) { |
|
73 | 73 | |
74 | 74 | //load helpers |
75 | - EE_Registry::instance()->load_helper( 'Event_View' ); |
|
76 | - EE_Registry::instance()->load_helper( 'Template' ); |
|
75 | + EE_Registry::instance()->load_helper('Event_View'); |
|
76 | + EE_Registry::instance()->load_helper('Template'); |
|
77 | 77 | |
78 | 78 | // merge in any attributes passed via fallback shortcode processor |
79 | - $attributes = array_merge( (array) $attributes, (array) $this->_attributes ); |
|
79 | + $attributes = array_merge((array) $attributes, (array) $this->_attributes); |
|
80 | 80 | |
81 | 81 | //set default attributes |
82 | 82 | $default_shortcode_attributes = array( |
@@ -88,9 +88,9 @@ discard block |
||
88 | 88 | ); |
89 | 89 | |
90 | 90 | // allow the defaults to be filtered |
91 | - $default_shortcode_attributes = apply_filters( 'EES_Espresso_Event_Attendees__process_shortcode__default_shortcode_atts', $default_shortcode_attributes ); |
|
91 | + $default_shortcode_attributes = apply_filters('EES_Espresso_Event_Attendees__process_shortcode__default_shortcode_atts', $default_shortcode_attributes); |
|
92 | 92 | // grab attributes and merge with defaults, then extract |
93 | - $attributes = array_merge( $default_shortcode_attributes, $attributes ); |
|
93 | + $attributes = array_merge($default_shortcode_attributes, $attributes); |
|
94 | 94 | |
95 | 95 | $template_args = array( |
96 | 96 | 'contacts' => array(), |
@@ -106,31 +106,31 @@ discard block |
||
106 | 106 | $error = false; |
107 | 107 | |
108 | 108 | //what event? |
109 | - if ( empty( $attributes['event_id'] ) && empty( $attributes['datetime_id'] ) && empty( $attributes['ticket_id'] ) ) { |
|
109 | + if (empty($attributes['event_id']) && empty($attributes['datetime_id']) && empty($attributes['ticket_id'])) { |
|
110 | 110 | //seems like is_espresso_event_single() isn't working as expected. So using alternate method. |
111 | - if ( is_single() && is_espresso_event() ) { |
|
111 | + if (is_single() && is_espresso_event()) { |
|
112 | 112 | $event = EEH_Event_View::get_event(); |
113 | - if ( $event instanceof EE_Event ) { |
|
113 | + if ($event instanceof EE_Event) { |
|
114 | 114 | $template_args['event'] = $event; |
115 | 115 | $query[0]['Registration.EVT_ID'] = $event->ID(); |
116 | 116 | } |
117 | 117 | } else { |
118 | 118 | //try getting the earliest active event if none then get the |
119 | - $events = EEM_Event::instance()->get_active_events( array( 'limit' => 1, |
|
120 | - 'order_by' => array( 'Datetime.DTT_EVT_start' => 'ASC' ) |
|
121 | - ) ); |
|
122 | - $events = empty( $events ) ? EEM_Event::instance()->get_upcoming_events( array( 'limit' => 1, |
|
123 | - 'order_by' => array( 'Datetime.DTT_EVT_start' => 'ASC' ) |
|
124 | - ) ) : $events; |
|
125 | - $event = reset( $events ); |
|
126 | - if ( $event instanceof EE_Event ) { |
|
119 | + $events = EEM_Event::instance()->get_active_events(array('limit' => 1, |
|
120 | + 'order_by' => array('Datetime.DTT_EVT_start' => 'ASC') |
|
121 | + )); |
|
122 | + $events = empty($events) ? EEM_Event::instance()->get_upcoming_events(array('limit' => 1, |
|
123 | + 'order_by' => array('Datetime.DTT_EVT_start' => 'ASC') |
|
124 | + )) : $events; |
|
125 | + $event = reset($events); |
|
126 | + if ($event instanceof EE_Event) { |
|
127 | 127 | $query[0]['Registration.EVT_ID'] = $event->ID(); |
128 | 128 | $template_args['event'] = $event; |
129 | 129 | } |
130 | 130 | } |
131 | - } elseif ( ! empty( $attributes['event_id'] ) ) { |
|
132 | - $event = EEM_Event::instance()->get_one_by_ID( $attributes['event_id'] ); |
|
133 | - if ( $event instanceof EE_Event ) { |
|
131 | + } elseif ( ! empty($attributes['event_id'])) { |
|
132 | + $event = EEM_Event::instance()->get_one_by_ID($attributes['event_id']); |
|
133 | + if ($event instanceof EE_Event) { |
|
134 | 134 | $query[0]['Registration.EVT_ID'] = $attributes['event_id']; |
135 | 135 | $template_args['event'] = $event; |
136 | 136 | } else { |
@@ -139,9 +139,9 @@ discard block |
||
139 | 139 | } |
140 | 140 | |
141 | 141 | //datetime? |
142 | - if ( ! empty( $attributes['datetime_id'] ) && empty( $attributes['event_id'] ) ) { |
|
143 | - $datetime = EEM_Datetime::instance()->get_one_by_ID( $attributes['datetime_id'] ); |
|
144 | - if ( $datetime instanceof EE_Datetime ) { |
|
142 | + if ( ! empty($attributes['datetime_id']) && empty($attributes['event_id'])) { |
|
143 | + $datetime = EEM_Datetime::instance()->get_one_by_ID($attributes['datetime_id']); |
|
144 | + if ($datetime instanceof EE_Datetime) { |
|
145 | 145 | $query[0]['Registration.Ticket.Datetime.DTT_ID'] = $attributes['datetime_id']; |
146 | 146 | $query['default_where_conditions'] = 'this_model_only'; |
147 | 147 | $template_args['datetime'] = $datetime; |
@@ -152,9 +152,9 @@ discard block |
||
152 | 152 | } |
153 | 153 | |
154 | 154 | //ticket?just |
155 | - if ( ! empty( $attributes['ticket_id'] ) && empty( $attributes['event_id'] ) && empty( $attributes['datetime_id'] ) ) { |
|
156 | - $ticket = EEM_Ticket::instance()->get_one_by_ID( $attributes['ticket_id'] ); |
|
157 | - if ( $ticket instanceof EE_Ticket ) { |
|
155 | + if ( ! empty($attributes['ticket_id']) && empty($attributes['event_id']) && empty($attributes['datetime_id'])) { |
|
156 | + $ticket = EEM_Ticket::instance()->get_one_by_ID($attributes['ticket_id']); |
|
157 | + if ($ticket instanceof EE_Ticket) { |
|
158 | 158 | $query[0]['Registration.TKT_ID'] = $attributes['ticket_id']; |
159 | 159 | $template_args['ticket'] = $ticket; |
160 | 160 | $template_args['event'] = $ticket->first_datetime() instanceof EE_Datetime ? $ticket->first_datetime()->event() : null; |
@@ -165,17 +165,17 @@ discard block |
||
165 | 165 | |
166 | 166 | //status |
167 | 167 | $reg_status_array = EEM_Registration::reg_status_array(); |
168 | - if ( $attributes['status'] != 'all' && isset( $reg_status_array[$attributes['status']] ) ) { |
|
168 | + if ($attributes['status'] != 'all' && isset($reg_status_array[$attributes['status']])) { |
|
169 | 169 | $query[0]['Registration.STS_ID'] = $attributes['status']; |
170 | 170 | } |
171 | - $query['group_by'] = array( 'ATT_ID' ); |
|
172 | - $query['order_by'] = apply_filters( 'FHEE__EES_Espresso_Event_Attendees__process_shortcode__order_by', array( 'ATT_lname' => 'ASC', 'ATT_fname' => 'ASC' ) ); |
|
171 | + $query['group_by'] = array('ATT_ID'); |
|
172 | + $query['order_by'] = apply_filters('FHEE__EES_Espresso_Event_Attendees__process_shortcode__order_by', array('ATT_lname' => 'ASC', 'ATT_fname' => 'ASC')); |
|
173 | 173 | |
174 | 174 | //if we have NO query where conditions, then there was an invalid parameter or the shortcode was used incorrectly |
175 | 175 | //so when WP_DEBUG is set and true, we'll show a message, otherwise we'll just return an empty string. |
176 | - if ( ( ! isset( $query[0] ) || ! is_array( $query[0] ) ) || $error ) { |
|
177 | - if ( WP_DEBUG ) { |
|
178 | - return '<div class="important-notice ee-attention">' . __( 'The [ESPRESSO_EVENT_ATTENDEES] shortcode has been used incorrectly. Please double check the arguments you used for any typos. In the case of ID type arguments, its possible the given ID does not correspond to existing data in the database.', 'event_espresso' ) . '</div>'; |
|
176 | + if (( ! isset($query[0]) || ! is_array($query[0])) || $error) { |
|
177 | + if (WP_DEBUG) { |
|
178 | + return '<div class="important-notice ee-attention">'.__('The [ESPRESSO_EVENT_ATTENDEES] shortcode has been used incorrectly. Please double check the arguments you used for any typos. In the case of ID type arguments, its possible the given ID does not correspond to existing data in the database.', 'event_espresso').'</div>'; |
|
179 | 179 | } else { |
180 | 180 | return ''; |
181 | 181 | } |
@@ -183,11 +183,11 @@ discard block |
||
183 | 183 | |
184 | 184 | |
185 | 185 | //get contacts! |
186 | - $template_args['contacts'] = EEM_Attendee::instance()->get_all( $query ); |
|
186 | + $template_args['contacts'] = EEM_Attendee::instance()->get_all($query); |
|
187 | 187 | |
188 | 188 | |
189 | 189 | //all set let's load up the template and return. |
190 | - return EEH_Template::locate_template( 'loop-espresso_event_attendees.php', $template_args, true, true ); |
|
190 | + return EEH_Template::locate_template('loop-espresso_event_attendees.php', $template_args, true, true); |
|
191 | 191 | |
192 | 192 | } |
193 | 193 |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2 | 2 | // if you're a dev and want to receive all errors via email add this to your wp-config.php: define( 'EE_ERROR_EMAILS', TRUE ); |
3 | -if ( defined( 'WP_DEBUG' ) && WP_DEBUG === TRUE && defined( 'EE_ERROR_EMAILS' ) && EE_ERROR_EMAILS === TRUE ) { |
|
4 | - set_error_handler( array( 'EE_Error', 'error_handler' )); |
|
5 | - register_shutdown_function( array( 'EE_Error', 'fatal_error_handler' )); |
|
3 | +if (defined('WP_DEBUG') && WP_DEBUG === TRUE && defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS === TRUE) { |
|
4 | + set_error_handler(array('EE_Error', 'error_handler')); |
|
5 | + register_shutdown_function(array('EE_Error', 'fatal_error_handler')); |
|
6 | 6 | } |
7 | 7 | /** |
8 | 8 | * |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * @access private |
65 | 65 | * @var boolean |
66 | 66 | */ |
67 | - private static $_espresso_notices = array( 'success' => FALSE, 'errors' => FALSE, 'attention' => FALSE ); |
|
67 | + private static $_espresso_notices = array('success' => FALSE, 'errors' => FALSE, 'attention' => FALSE); |
|
68 | 68 | |
69 | 69 | |
70 | 70 | |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | * @access public |
76 | 76 | * @echo string |
77 | 77 | */ |
78 | - function __construct( $message, $code = 0, Exception $previous = NULL ) { |
|
79 | - if ( version_compare( phpversion(), '5.3.0', '<' )) { |
|
80 | - parent::__construct( $message, $code ); |
|
78 | + function __construct($message, $code = 0, Exception $previous = NULL) { |
|
79 | + if (version_compare(phpversion(), '5.3.0', '<')) { |
|
80 | + parent::__construct($message, $code); |
|
81 | 81 | } else { |
82 | - parent::__construct( $message, $code, $previous ); |
|
82 | + parent::__construct($message, $code, $previous); |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
@@ -94,10 +94,10 @@ discard block |
||
94 | 94 | * @param $line |
95 | 95 | * @return void |
96 | 96 | */ |
97 | - public static function error_handler( $code, $message, $file, $line ) { |
|
98 | - $type = EE_Error::error_type( $code ); |
|
97 | + public static function error_handler($code, $message, $file, $line) { |
|
98 | + $type = EE_Error::error_type($code); |
|
99 | 99 | $site = site_url(); |
100 | - switch ( $site ) { |
|
100 | + switch ($site) { |
|
101 | 101 | case 'http://ee4.eventespresso.com/' : |
102 | 102 | case 'http://ee4decaf.eventespresso.com/' : |
103 | 103 | case 'http://ee4hf.eventespresso.com/' : |
@@ -110,16 +110,16 @@ discard block |
||
110 | 110 | $to = '[email protected]'; |
111 | 111 | break; |
112 | 112 | default : |
113 | - $to = get_option( 'admin_email' ); |
|
113 | + $to = get_option('admin_email'); |
|
114 | 114 | } |
115 | - $subject = $type . ' ' . $message . ' in ' . EVENT_ESPRESSO_VERSION . ' on ' . site_url(); |
|
116 | - $msg = EE_Error::_format_error( $type, $message, $file, $line ); |
|
117 | - if ( function_exists( 'wp_mail' )) { |
|
118 | - add_filter( 'wp_mail_content_type', array( 'EE_Error', 'set_content_type' )); |
|
119 | - wp_mail( $to, $subject, $msg ); |
|
115 | + $subject = $type.' '.$message.' in '.EVENT_ESPRESSO_VERSION.' on '.site_url(); |
|
116 | + $msg = EE_Error::_format_error($type, $message, $file, $line); |
|
117 | + if (function_exists('wp_mail')) { |
|
118 | + add_filter('wp_mail_content_type', array('EE_Error', 'set_content_type')); |
|
119 | + wp_mail($to, $subject, $msg); |
|
120 | 120 | } |
121 | 121 | echo '<div id="message" class="espresso-notices error"><p>'; |
122 | - echo $type . ': ' . $message . '<br />' . $file . ' line ' . $line; |
|
122 | + echo $type.': '.$message.'<br />'.$file.' line '.$line; |
|
123 | 123 | echo '<br /></p></div>'; |
124 | 124 | } |
125 | 125 | |
@@ -132,8 +132,8 @@ discard block |
||
132 | 132 | * @param $code |
133 | 133 | * @return string |
134 | 134 | */ |
135 | - public static function error_type( $code ) { |
|
136 | - switch( $code ) { |
|
135 | + public static function error_type($code) { |
|
136 | + switch ($code) { |
|
137 | 137 | case E_ERROR: // 1 // |
138 | 138 | return 'E_ERROR'; |
139 | 139 | case E_WARNING: // 2 // |
@@ -179,8 +179,8 @@ discard block |
||
179 | 179 | */ |
180 | 180 | public static function fatal_error_handler() { |
181 | 181 | $last_error = error_get_last(); |
182 | - if ( $last_error['type'] === E_ERROR ) { |
|
183 | - EE_Error::error_handler( E_ERROR, $last_error['message'], $last_error['file'], $last_error['line'] ); |
|
182 | + if ($last_error['type'] === E_ERROR) { |
|
183 | + EE_Error::error_handler(E_ERROR, $last_error['message'], $last_error['file'], $last_error['line']); |
|
184 | 184 | } |
185 | 185 | } |
186 | 186 | |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | * @param $line |
196 | 196 | * @return string |
197 | 197 | */ |
198 | - private static function _format_error( $code, $message, $file, $line ) { |
|
198 | + private static function _format_error($code, $message, $file, $line) { |
|
199 | 199 | $html = "<table cellpadding='5'><thead bgcolor='#f8f8f8'><th>Item</th><th align='left'>Details</th></thead><tbody>"; |
200 | 200 | $html .= "<tr valign='top'><td><b>Code</b></td><td>$code</td></tr>"; |
201 | 201 | $html .= "<tr valign='top'><td><b>Error</b></td><td>$message</td></tr>"; |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | * @param $content_type |
214 | 214 | * @return string |
215 | 215 | */ |
216 | - public static function set_content_type( $content_type ) { |
|
216 | + public static function set_content_type($content_type) { |
|
217 | 217 | return 'text/html'; |
218 | 218 | } |
219 | 219 | |
@@ -227,24 +227,24 @@ discard block |
||
227 | 227 | */ |
228 | 228 | public function get_error() { |
229 | 229 | |
230 | - if( apply_filters( 'FHEE__EE_Error__get_error__show_normal_exceptions', FALSE ) ){ |
|
230 | + if (apply_filters('FHEE__EE_Error__get_error__show_normal_exceptions', FALSE)) { |
|
231 | 231 | throw $this; |
232 | 232 | } |
233 | 233 | // get separate user and developer messages if they exist |
234 | - $msg = explode( '||', $this->getMessage() ); |
|
234 | + $msg = explode('||', $this->getMessage()); |
|
235 | 235 | $user_msg = $msg[0]; |
236 | - $dev_msg = isset( $msg[1] ) ? $msg[1] : $msg[0]; |
|
236 | + $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0]; |
|
237 | 237 | $msg = WP_DEBUG ? $dev_msg : $user_msg; |
238 | 238 | |
239 | 239 | // add details to _all_exceptions array |
240 | 240 | $x_time = time(); |
241 | - self::$_all_exceptions[ $x_time ]['name'] = get_class( $this ); |
|
242 | - self::$_all_exceptions[ $x_time ]['file'] = $this->getFile(); |
|
243 | - self::$_all_exceptions[ $x_time ]['line'] = $this->getLine(); |
|
244 | - self::$_all_exceptions[ $x_time ]['msg'] = $msg; |
|
245 | - self::$_all_exceptions[ $x_time ]['code'] = $this->getCode(); |
|
246 | - self::$_all_exceptions[ $x_time ]['trace'] = $this->getTrace(); |
|
247 | - self::$_all_exceptions[ $x_time ]['string'] = $this->getTraceAsString(); |
|
241 | + self::$_all_exceptions[$x_time]['name'] = get_class($this); |
|
242 | + self::$_all_exceptions[$x_time]['file'] = $this->getFile(); |
|
243 | + self::$_all_exceptions[$x_time]['line'] = $this->getLine(); |
|
244 | + self::$_all_exceptions[$x_time]['msg'] = $msg; |
|
245 | + self::$_all_exceptions[$x_time]['code'] = $this->getCode(); |
|
246 | + self::$_all_exceptions[$x_time]['trace'] = $this->getTrace(); |
|
247 | + self::$_all_exceptions[$x_time]['string'] = $this->getTraceAsString(); |
|
248 | 248 | self::$_error_count++; |
249 | 249 | |
250 | 250 | //add_action( 'shutdown', array( $this, 'display_errors' )); |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | * @access public |
260 | 260 | * @return boolean |
261 | 261 | */ |
262 | - public static function has_error(){ |
|
262 | + public static function has_error() { |
|
263 | 263 | return self::$_error_count ? TRUE : FALSE; |
264 | 264 | } |
265 | 265 | |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | * @access public |
271 | 271 | * @echo string |
272 | 272 | */ |
273 | - public function display_errors(){ |
|
273 | + public function display_errors() { |
|
274 | 274 | |
275 | 275 | $trace_details = ''; |
276 | 276 | |
@@ -331,18 +331,18 @@ discard block |
||
331 | 331 | </style> |
332 | 332 | <div id="ee-error-message" class="error">'; |
333 | 333 | |
334 | - if ( ! WP_DEBUG ) { |
|
334 | + if ( ! WP_DEBUG) { |
|
335 | 335 | $output .= ' |
336 | 336 | <p>'; |
337 | 337 | } |
338 | 338 | |
339 | 339 | // cycle thru errors |
340 | - foreach ( self::$_all_exceptions as $time => $ex ) { |
|
340 | + foreach (self::$_all_exceptions as $time => $ex) { |
|
341 | 341 | |
342 | 342 | // process trace info |
343 | - if ( empty( $ex['trace'] )) { |
|
343 | + if (empty($ex['trace'])) { |
|
344 | 344 | |
345 | - $trace_details .= __( 'Sorry, but no trace information was available for this exception.', 'event_espresso' ); |
|
345 | + $trace_details .= __('Sorry, but no trace information was available for this exception.', 'event_espresso'); |
|
346 | 346 | |
347 | 347 | } else { |
348 | 348 | |
@@ -357,50 +357,50 @@ discard block |
||
357 | 357 | <th scope="col" align="left">Method( arguments )</th> |
358 | 358 | </tr>'; |
359 | 359 | |
360 | - $last_on_stack = count( $ex['trace'] ) - 1; |
|
360 | + $last_on_stack = count($ex['trace']) - 1; |
|
361 | 361 | // reverse array so that stack is in proper chronological order |
362 | - $sorted_trace = array_reverse( $ex['trace'] ); |
|
362 | + $sorted_trace = array_reverse($ex['trace']); |
|
363 | 363 | |
364 | - foreach ( $sorted_trace as $nmbr => $trace ) { |
|
364 | + foreach ($sorted_trace as $nmbr => $trace) { |
|
365 | 365 | |
366 | - $file = isset( $trace['file'] ) ? $trace['file'] : '' ; |
|
367 | - $class = isset( $trace['class'] ) ? $trace['class'] : ''; |
|
368 | - $type = isset( $trace['type'] ) ? $trace['type'] : ''; |
|
369 | - $function = isset( $trace['function'] ) ? $trace['function'] : ''; |
|
370 | - $args = isset( $trace['args'] ) ? $this->_convert_args_to_string( $trace['args'] ) : ''; |
|
371 | - $line = isset( $trace['line'] ) ? $trace['line'] : ''; |
|
366 | + $file = isset($trace['file']) ? $trace['file'] : ''; |
|
367 | + $class = isset($trace['class']) ? $trace['class'] : ''; |
|
368 | + $type = isset($trace['type']) ? $trace['type'] : ''; |
|
369 | + $function = isset($trace['function']) ? $trace['function'] : ''; |
|
370 | + $args = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : ''; |
|
371 | + $line = isset($trace['line']) ? $trace['line'] : ''; |
|
372 | 372 | $zebra = $nmbr % 2 ? ' odd' : ''; |
373 | 373 | |
374 | - if ( empty( $file ) && ! empty( $class )) { |
|
375 | - $a = new ReflectionClass( $class ); |
|
374 | + if (empty($file) && ! empty($class)) { |
|
375 | + $a = new ReflectionClass($class); |
|
376 | 376 | $file = $a->getFileName(); |
377 | - if ( empty( $line ) && ! empty( $function )) { |
|
378 | - $b = new ReflectionMethod( $class, $function ); |
|
377 | + if (empty($line) && ! empty($function)) { |
|
378 | + $b = new ReflectionMethod($class, $function); |
|
379 | 379 | $line = $b->getStartLine(); |
380 | 380 | } |
381 | 381 | } |
382 | 382 | |
383 | - if ( $nmbr == $last_on_stack ) { |
|
383 | + if ($nmbr == $last_on_stack) { |
|
384 | 384 | $file = $ex['file'] != '' ? $ex['file'] : $file; |
385 | 385 | $line = $ex['line'] != '' ? $ex['line'] : $line; |
386 | - $error_code = self::generate_error_code ( $file, $trace['function'], $line ); |
|
386 | + $error_code = self::generate_error_code($file, $trace['function'], $line); |
|
387 | 387 | } |
388 | 388 | |
389 | - $nmbr_dsply = ! empty( $nmbr ) ? $nmbr : ' '; |
|
390 | - $line_dsply = ! empty( $line ) ? $line : ' '; |
|
391 | - $file_dsply = ! empty( $file ) ? $file : ' '; |
|
392 | - $class_dsply = ! empty( $class ) ? $class : ' '; |
|
393 | - $type_dsply = ! empty( $type ) ? $type : ' '; |
|
394 | - $function_dsply = ! empty( $function ) ? $function : ' '; |
|
395 | - $args_dsply = ! empty( $args ) ? '( ' . $args . ' )' : ''; |
|
389 | + $nmbr_dsply = ! empty($nmbr) ? $nmbr : ' '; |
|
390 | + $line_dsply = ! empty($line) ? $line : ' '; |
|
391 | + $file_dsply = ! empty($file) ? $file : ' '; |
|
392 | + $class_dsply = ! empty($class) ? $class : ' '; |
|
393 | + $type_dsply = ! empty($type) ? $type : ' '; |
|
394 | + $function_dsply = ! empty($function) ? $function : ' '; |
|
395 | + $args_dsply = ! empty($args) ? '( '.$args.' )' : ''; |
|
396 | 396 | |
397 | 397 | $trace_details .= ' |
398 | 398 | <tr> |
399 | - <td align="right" class="' . $zebra . '">' . $nmbr_dsply . '</td> |
|
400 | - <td align="right" class="' . $zebra . '">' . $line_dsply . '</td> |
|
401 | - <td align="left" class="' . $zebra . '">' . $file_dsply . '</td> |
|
402 | - <td align="left" class="' . $zebra . '">' . $class_dsply . '</td> |
|
403 | - <td align="left" class="' . $zebra . '">' . $type_dsply . $function_dsply . $args_dsply . '</td> |
|
399 | + <td align="right" class="' . $zebra.'">'.$nmbr_dsply.'</td> |
|
400 | + <td align="right" class="' . $zebra.'">'.$line_dsply.'</td> |
|
401 | + <td align="left" class="' . $zebra.'">'.$file_dsply.'</td> |
|
402 | + <td align="left" class="' . $zebra.'">'.$class_dsply.'</td> |
|
403 | + <td align="left" class="' . $zebra.'">'.$type_dsply.$function_dsply.$args_dsply.'</td> |
|
404 | 404 | </tr>'; |
405 | 405 | |
406 | 406 | |
@@ -415,9 +415,9 @@ discard block |
||
415 | 415 | $ex['code'] = $ex['code'] ? $ex['code'] : $error_code; |
416 | 416 | |
417 | 417 | // add generic non-identifying messages for non-privileged uesrs |
418 | - if ( ! WP_DEBUG ) { |
|
418 | + if ( ! WP_DEBUG) { |
|
419 | 419 | |
420 | - $output .= '<span class="ee-error-user-msg-spn">' . trim( $ex['msg'] ) . '</span> <sup>' . $ex['code'] . '</sup><br />'; |
|
420 | + $output .= '<span class="ee-error-user-msg-spn">'.trim($ex['msg']).'</span> <sup>'.$ex['code'].'</sup><br />'; |
|
421 | 421 | |
422 | 422 | } else { |
423 | 423 | |
@@ -425,24 +425,24 @@ discard block |
||
425 | 425 | $output .= ' |
426 | 426 | <div class="ee-error-dev-msg-dv"> |
427 | 427 | <p class="ee-error-dev-msg-pg"> |
428 | - <strong class="ee-error-dev-msg-str">An ' . $ex['name'] . ' exception was thrown!</strong> <span>code: ' . $ex['code'] . '</span><br /> |
|
429 | - <span class="big-text">"' . trim( $ex['msg'] ) . '"</span><br/> |
|
430 | - <a id="display-ee-error-trace-' . self::$_error_count . $time . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-' . self::$_error_count . $time . '"> |
|
431 | - ' . __( 'click to view backtrace and class/method details', 'event_espresso' ) . ' |
|
428 | + <strong class="ee-error-dev-msg-str">An ' . $ex['name'].' exception was thrown!</strong> <span>code: '.$ex['code'].'</span><br /> |
|
429 | + <span class="big-text">"' . trim($ex['msg']).'"</span><br/> |
|
430 | + <a id="display-ee-error-trace-' . self::$_error_count.$time.'" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-'.self::$_error_count.$time.'"> |
|
431 | + ' . __('click to view backtrace and class/method details', 'event_espresso').' |
|
432 | 432 | </a><br /> |
433 | 433 | <span class="small-text lt-grey-text">'.$ex['file'].' ( line no: '.$ex['line'].' )</span> |
434 | 434 | </p> |
435 | - <div id="ee-error-trace-' . self::$_error_count . $time . '-dv" class="ee-error-trace-dv" style="display: none;"> |
|
435 | + <div id="ee-error-trace-' . self::$_error_count.$time.'-dv" class="ee-error-trace-dv" style="display: none;"> |
|
436 | 436 | ' . $trace_details; |
437 | 437 | |
438 | - if ( ! empty( $class )) { |
|
438 | + if ( ! empty($class)) { |
|
439 | 439 | $output .= ' |
440 | 440 | <div style="padding:3px; margin:0 0 1em; border:1px solid #666; background:#fff; border-radius:3px;"> |
441 | 441 | <div style="padding:1em 2em; border:1px solid #666; background:#f9f9f9;"> |
442 | 442 | <h3>Class Details</h3>'; |
443 | - $a = new ReflectionClass( $class ); |
|
443 | + $a = new ReflectionClass($class); |
|
444 | 444 | $output .= ' |
445 | - <pre>' . $a . '</pre> |
|
445 | + <pre>' . $a.'</pre> |
|
446 | 446 | </div> |
447 | 447 | </div>'; |
448 | 448 | } |
@@ -454,14 +454,14 @@ discard block |
||
454 | 454 | |
455 | 455 | } |
456 | 456 | |
457 | - $this->write_to_error_log( $time, $ex ); |
|
457 | + $this->write_to_error_log($time, $ex); |
|
458 | 458 | |
459 | 459 | } |
460 | 460 | |
461 | 461 | // remove last linebreak |
462 | - $output = substr( $output, 0, ( count( $output ) - 7 )); |
|
462 | + $output = substr($output, 0, (count($output) - 7)); |
|
463 | 463 | |
464 | - if ( ! WP_DEBUG ) { |
|
464 | + if ( ! WP_DEBUG) { |
|
465 | 465 | $output .= ' |
466 | 466 | </p>'; |
467 | 467 | } |
@@ -469,10 +469,10 @@ discard block |
||
469 | 469 | $output .= ' |
470 | 470 | </div>'; |
471 | 471 | |
472 | - $output .= self::_print_scripts( TRUE ); |
|
472 | + $output .= self::_print_scripts(TRUE); |
|
473 | 473 | |
474 | - if ( defined( 'DOING_AJAX' )) { |
|
475 | - echo json_encode( array( 'error' => $output )); |
|
474 | + if (defined('DOING_AJAX')) { |
|
475 | + echo json_encode(array('error' => $output)); |
|
476 | 476 | exit(); |
477 | 477 | } |
478 | 478 | |
@@ -492,29 +492,29 @@ discard block |
||
492 | 492 | * @ param array $arguments |
493 | 493 | * @ return string |
494 | 494 | */ |
495 | - private function _convert_args_to_string ( $arguments = array(), $array = FALSE ) { |
|
495 | + private function _convert_args_to_string($arguments = array(), $array = FALSE) { |
|
496 | 496 | |
497 | 497 | $arg_string = ''; |
498 | - if ( ! empty( $arguments )) { |
|
498 | + if ( ! empty($arguments)) { |
|
499 | 499 | |
500 | 500 | $args = array(); |
501 | 501 | |
502 | - foreach ( $arguments as $arg ) { |
|
502 | + foreach ($arguments as $arg) { |
|
503 | 503 | |
504 | - if ( ! empty( $arg )) { |
|
504 | + if ( ! empty($arg)) { |
|
505 | 505 | |
506 | - if ( is_string( $arg )) { |
|
507 | - $args[] = " '" . $arg . "'"; |
|
508 | - } elseif ( is_array( $arg )) { |
|
509 | - $args[] = 'ARRAY(' . $this->_convert_args_to_string( $arg, TRUE ); |
|
510 | - } elseif ( is_null( $arg )) { |
|
506 | + if (is_string($arg)) { |
|
507 | + $args[] = " '".$arg."'"; |
|
508 | + } elseif (is_array($arg)) { |
|
509 | + $args[] = 'ARRAY('.$this->_convert_args_to_string($arg, TRUE); |
|
510 | + } elseif (is_null($arg)) { |
|
511 | 511 | $args[] = ' NULL'; |
512 | - } elseif ( is_bool( $arg )) { |
|
513 | - $args[] = ( $arg ) ? ' TRUE' : ' FALSE'; |
|
514 | - } elseif ( is_object( $arg )) { |
|
515 | - $args[] = ' OBJECT ' . get_class( $arg ); |
|
516 | - } elseif ( is_resource( $arg )) { |
|
517 | - $args[] = get_resource_type( $arg ); |
|
512 | + } elseif (is_bool($arg)) { |
|
513 | + $args[] = ($arg) ? ' TRUE' : ' FALSE'; |
|
514 | + } elseif (is_object($arg)) { |
|
515 | + $args[] = ' OBJECT '.get_class($arg); |
|
516 | + } elseif (is_resource($arg)) { |
|
517 | + $args[] = get_resource_type($arg); |
|
518 | 518 | } else { |
519 | 519 | $args[] = $arg; |
520 | 520 | } |
@@ -522,9 +522,9 @@ discard block |
||
522 | 522 | } |
523 | 523 | |
524 | 524 | } |
525 | - $arg_string = implode( ', ', $args ); |
|
525 | + $arg_string = implode(', ', $args); |
|
526 | 526 | } |
527 | - if ( $array ) { |
|
527 | + if ($array) { |
|
528 | 528 | $arg_string .= ' )'; |
529 | 529 | } |
530 | 530 | return $arg_string; |
@@ -544,8 +544,8 @@ discard block |
||
544 | 544 | * @param string $line the line number where the error occurred - just use __LINE__ |
545 | 545 | * @return void |
546 | 546 | */ |
547 | - public static function add_error( $msg = NULL, $file = NULL, $func = NULL, $line = NULL ) { |
|
548 | - self::_add_notice ( 'errors', $msg, $file, $func, $line ); |
|
547 | + public static function add_error($msg = NULL, $file = NULL, $func = NULL, $line = NULL) { |
|
548 | + self::_add_notice('errors', $msg, $file, $func, $line); |
|
549 | 549 | self::$_error_count++; |
550 | 550 | } |
551 | 551 | |
@@ -563,8 +563,8 @@ discard block |
||
563 | 563 | * @param string $line the line number where the error occurred - just use __LINE__ |
564 | 564 | * @return void |
565 | 565 | */ |
566 | - public static function add_success( $msg = NULL, $file = NULL, $func = NULL, $line = NULL ) { |
|
567 | - self::_add_notice ( 'success', $msg, $file, $func, $line ); |
|
566 | + public static function add_success($msg = NULL, $file = NULL, $func = NULL, $line = NULL) { |
|
567 | + self::_add_notice('success', $msg, $file, $func, $line); |
|
568 | 568 | } |
569 | 569 | |
570 | 570 | |
@@ -581,8 +581,8 @@ discard block |
||
581 | 581 | * @param string $line the line number where the error occurred - just use __LINE__ |
582 | 582 | * @return void |
583 | 583 | */ |
584 | - public static function add_attention( $msg = NULL, $file = NULL, $func = NULL, $line = NULL ) { |
|
585 | - self::_add_notice ( 'attention', $msg, $file, $func, $line ); |
|
584 | + public static function add_attention($msg = NULL, $file = NULL, $func = NULL, $line = NULL) { |
|
585 | + self::_add_notice('attention', $msg, $file, $func, $line); |
|
586 | 586 | } |
587 | 587 | |
588 | 588 | |
@@ -600,12 +600,12 @@ discard block |
||
600 | 600 | * @param string $line the line number where the error occurred - just use __LINE__ |
601 | 601 | * @return void |
602 | 602 | */ |
603 | - private static function _add_notice( $type = 'success', $msg = NULL, $file = NULL, $func = NULL, $line = NULL ) { |
|
604 | - if ( empty( $msg )) { |
|
603 | + private static function _add_notice($type = 'success', $msg = NULL, $file = NULL, $func = NULL, $line = NULL) { |
|
604 | + if (empty($msg)) { |
|
605 | 605 | EE_Error::doing_it_wrong( |
606 | - 'EE_Error::add_' . $type . '()', |
|
606 | + 'EE_Error::add_'.$type.'()', |
|
607 | 607 | sprintf( |
608 | - __( 'Notifications are not much use without a message! Please add a message to the EE_Error::add_%s() call made in %s on line %d', 'event_espresso' ), |
|
608 | + __('Notifications are not much use without a message! Please add a message to the EE_Error::add_%s() call made in %s on line %d', 'event_espresso'), |
|
609 | 609 | $type, |
610 | 610 | $file, |
611 | 611 | $line |
@@ -613,27 +613,27 @@ discard block |
||
613 | 613 | EVENT_ESPRESSO_VERSION |
614 | 614 | ); |
615 | 615 | } |
616 | - if ( $type == 'errors' && ( empty( $file ) || empty( $func ) || empty( $line ))) { |
|
616 | + if ($type == 'errors' && (empty($file) || empty($func) || empty($line))) { |
|
617 | 617 | EE_Error::doing_it_wrong( |
618 | 618 | 'EE_Error::add_error()', |
619 | - __('You need to provide the file name, function name, and line number that the error occurred on in order to better assist with debugging.', 'event_espresso' ), |
|
619 | + __('You need to provide the file name, function name, and line number that the error occurred on in order to better assist with debugging.', 'event_espresso'), |
|
620 | 620 | EVENT_ESPRESSO_VERSION |
621 | 621 | ); |
622 | 622 | } |
623 | 623 | // get separate user and developer messages if they exist |
624 | - $msg = explode( '||', $msg ); |
|
624 | + $msg = explode('||', $msg); |
|
625 | 625 | $user_msg = $msg[0]; |
626 | - $dev_msg = isset( $msg[1] ) ? $msg[1] : $msg[0]; |
|
626 | + $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0]; |
|
627 | 627 | $msg = WP_DEBUG ? $dev_msg : $user_msg; |
628 | 628 | // add notice if message exists |
629 | - if ( ! empty( $msg )) { |
|
629 | + if ( ! empty($msg)) { |
|
630 | 630 | // get error code, but only on error |
631 | - if ( WP_DEBUG && $type == 'errors' ) { |
|
632 | - $msg .= '<br/><span class="tiny-text">' . EE_Error::generate_error_code( $file, $func, $line ) . '</span>'; |
|
631 | + if (WP_DEBUG && $type == 'errors') { |
|
632 | + $msg .= '<br/><span class="tiny-text">'.EE_Error::generate_error_code($file, $func, $line).'</span>'; |
|
633 | 633 | } |
634 | 634 | // add notice |
635 | - self::$_espresso_notices[ $type ][] = $msg; |
|
636 | - add_action( 'wp_footer', array( 'EE_Error', 'enqueue_error_scripts' ), 1 ); |
|
635 | + self::$_espresso_notices[$type][] = $msg; |
|
636 | + add_action('wp_footer', array('EE_Error', 'enqueue_error_scripts'), 1); |
|
637 | 637 | } |
638 | 638 | |
639 | 639 | } |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | * @access private |
688 | 688 | * @return void |
689 | 689 | */ |
690 | - public static function reset_notices(){ |
|
690 | + public static function reset_notices() { |
|
691 | 691 | self::$_espresso_notices['success'] = FALSE; |
692 | 692 | self::$_espresso_notices['attention'] = FALSE; |
693 | 693 | self::$_espresso_notices['errors'] = FALSE; |
@@ -700,14 +700,14 @@ discard block |
||
700 | 700 | * @access public |
701 | 701 | * @return int |
702 | 702 | */ |
703 | - public static function has_notices(){ |
|
703 | + public static function has_notices() { |
|
704 | 704 | $has_notices = 0; |
705 | 705 | // check for success messages |
706 | - $has_notices = self::$_espresso_notices['success'] && ! empty( self::$_espresso_notices['success'] ) ? 3 : $has_notices; |
|
706 | + $has_notices = self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success']) ? 3 : $has_notices; |
|
707 | 707 | // check for attention messages |
708 | - $has_notices = self::$_espresso_notices['attention'] && ! empty( self::$_espresso_notices['attention'] ) ? 2 : $has_notices; |
|
708 | + $has_notices = self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention']) ? 2 : $has_notices; |
|
709 | 709 | // check for error messages |
710 | - $has_notices = self::$_espresso_notices['errors'] && ! empty( self::$_espresso_notices['errors'] ) ? 1 : $has_notices; |
|
710 | + $has_notices = self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors']) ? 1 : $has_notices; |
|
711 | 711 | return $has_notices; |
712 | 712 | } |
713 | 713 | |
@@ -722,8 +722,8 @@ discard block |
||
722 | 722 | * @param boolean $remove_empty whether or not to unset empty messages |
723 | 723 | * @return array |
724 | 724 | */ |
725 | - public static function get_notices( $format_output = TRUE, $save_to_transient = FALSE, $remove_empty = TRUE ) { |
|
726 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
725 | + public static function get_notices($format_output = TRUE, $save_to_transient = FALSE, $remove_empty = TRUE) { |
|
726 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
727 | 727 | |
728 | 728 | $success_messages = ''; |
729 | 729 | $attention_messages = ''; |
@@ -733,44 +733,44 @@ discard block |
||
733 | 733 | // EEH_Debug_Tools::printr( self::$_espresso_notices, 'espresso_notices <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
734 | 734 | |
735 | 735 | // either save notices to the db |
736 | - if ( $save_to_transient ) { |
|
737 | - update_option( 'ee_notices', self::$_espresso_notices ); |
|
736 | + if ($save_to_transient) { |
|
737 | + update_option('ee_notices', self::$_espresso_notices); |
|
738 | 738 | return; |
739 | 739 | } |
740 | 740 | // grab any notices that have been previously saved |
741 | - if ( $notices = get_option( 'ee_notices', FALSE )) { |
|
742 | - foreach ( $notices as $type => $notice ) { |
|
743 | - if ( is_array( $notice ) && ! empty( $notice )) { |
|
741 | + if ($notices = get_option('ee_notices', FALSE)) { |
|
742 | + foreach ($notices as $type => $notice) { |
|
743 | + if (is_array($notice) && ! empty($notice)) { |
|
744 | 744 | // make sure that existsing notice type is an array |
745 | - self::$_espresso_notices[ $type ] = is_array( self::$_espresso_notices[ $type ] ) && ! empty( self::$_espresso_notices[ $type ] ) ? self::$_espresso_notices[ $type ] : array(); |
|
745 | + self::$_espresso_notices[$type] = is_array(self::$_espresso_notices[$type]) && ! empty(self::$_espresso_notices[$type]) ? self::$_espresso_notices[$type] : array(); |
|
746 | 746 | // merge stored notices with any newly created ones |
747 | - self::$_espresso_notices[ $type ] = array_merge( self::$_espresso_notices[ $type ], $notice ); |
|
747 | + self::$_espresso_notices[$type] = array_merge(self::$_espresso_notices[$type], $notice); |
|
748 | 748 | $print_scripts = TRUE; |
749 | 749 | } |
750 | 750 | } |
751 | 751 | // now clear any stored notices |
752 | - update_option( 'ee_notices', FALSE ); |
|
752 | + update_option('ee_notices', FALSE); |
|
753 | 753 | } |
754 | 754 | |
755 | 755 | // check for success messages |
756 | - if ( self::$_espresso_notices['success'] && ! empty( self::$_espresso_notices['success'] )) { |
|
756 | + if (self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success'])) { |
|
757 | 757 | // combine messages |
758 | - $success_messages .= implode( self::$_espresso_notices['success'], '<br />' ); |
|
758 | + $success_messages .= implode(self::$_espresso_notices['success'], '<br />'); |
|
759 | 759 | $print_scripts = TRUE; |
760 | 760 | } |
761 | 761 | |
762 | 762 | // check for attention messages |
763 | - if ( self::$_espresso_notices['attention'] && ! empty( self::$_espresso_notices['attention'] ) ) { |
|
763 | + if (self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention'])) { |
|
764 | 764 | // combine messages |
765 | - $attention_messages .= implode( self::$_espresso_notices['attention'], '<br />' ); |
|
765 | + $attention_messages .= implode(self::$_espresso_notices['attention'], '<br />'); |
|
766 | 766 | $print_scripts = TRUE; |
767 | 767 | } |
768 | 768 | |
769 | 769 | // check for error messages |
770 | - if ( self::$_espresso_notices['errors'] && ! empty( self::$_espresso_notices['errors'] ) ) { |
|
771 | - $error_messages .= count( self::$_espresso_notices['errors'] ) > 1 ? __( 'The following errors have occurred:<br />', 'event_espresso' ) : __( 'An error has occurred:<br />', 'event_espresso' ); |
|
770 | + if (self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors'])) { |
|
771 | + $error_messages .= count(self::$_espresso_notices['errors']) > 1 ? __('The following errors have occurred:<br />', 'event_espresso') : __('An error has occurred:<br />', 'event_espresso'); |
|
772 | 772 | // combine messages |
773 | - $error_messages .= implode( self::$_espresso_notices['errors'], '<br />' ); |
|
773 | + $error_messages .= implode(self::$_espresso_notices['errors'], '<br />'); |
|
774 | 774 | $print_scripts = TRUE; |
775 | 775 | } |
776 | 776 | |
@@ -784,21 +784,21 @@ discard block |
||
784 | 784 | $css_id = is_admin() ? 'message' : 'espresso-notices-success'; |
785 | 785 | $css_class = is_admin() ? 'updated fade' : 'success fade-away'; |
786 | 786 | //showMessage( $success_messages ); |
787 | - $notices .= '<div id="' . $css_id . '" class="espresso-notices ' . $css_class . '" style="display:none;"><p>' . $success_messages . '</p>' . $close . '</div>'; |
|
787 | + $notices .= '<div id="'.$css_id.'" class="espresso-notices '.$css_class.'" style="display:none;"><p>'.$success_messages.'</p>'.$close.'</div>'; |
|
788 | 788 | } |
789 | 789 | |
790 | 790 | if ($attention_messages != '') { |
791 | 791 | $css_id = is_admin() ? 'message' : 'espresso-notices-attention'; |
792 | 792 | $css_class = is_admin() ? 'updated ee-notices-attention' : 'attention fade-away'; |
793 | 793 | //showMessage( $error_messages, TRUE ); |
794 | - $notices .= '<div id="' . $css_id . '" class="espresso-notices ' . $css_class . '" style="display:none;"><p>' . $attention_messages . '</p>' . $close . '</div>'; |
|
794 | + $notices .= '<div id="'.$css_id.'" class="espresso-notices '.$css_class.'" style="display:none;"><p>'.$attention_messages.'</p>'.$close.'</div>'; |
|
795 | 795 | } |
796 | 796 | |
797 | 797 | if ($error_messages != '') { |
798 | 798 | $css_id = is_admin() ? 'message' : 'espresso-notices-error'; |
799 | 799 | $css_class = is_admin() ? 'error' : 'error fade-away'; |
800 | 800 | //showMessage( $error_messages, TRUE ); |
801 | - $notices .= '<div id="' . $css_id . '" class="espresso-notices ' . $css_class . '" style="display:none;"><p>' . $error_messages . '</p>' . $close . '</div>'; |
|
801 | + $notices .= '<div id="'.$css_id.'" class="espresso-notices '.$css_class.'" style="display:none;"><p>'.$error_messages.'</p>'.$close.'</div>'; |
|
802 | 802 | } |
803 | 803 | |
804 | 804 | $notices .= '</div>'; |
@@ -811,7 +811,7 @@ discard block |
||
811 | 811 | 'errors' => $error_messages |
812 | 812 | ); |
813 | 813 | |
814 | - if ( $remove_empty ) { |
|
814 | + if ($remove_empty) { |
|
815 | 815 | // remove empty notices |
816 | 816 | foreach ($notices as $type => $notice) { |
817 | 817 | if (empty($notice)) { |
@@ -821,7 +821,7 @@ discard block |
||
821 | 821 | } |
822 | 822 | } |
823 | 823 | |
824 | - if ( $print_scripts ) { |
|
824 | + if ($print_scripts) { |
|
825 | 825 | self::_print_scripts(); |
826 | 826 | } |
827 | 827 | |
@@ -841,17 +841,17 @@ discard block |
||
841 | 841 | * @param bool $force_update allows one to enforce the reappearance of a persistent message. |
842 | 842 | * @return void |
843 | 843 | */ |
844 | - public static function add_persistent_admin_notice( $pan_name = '', $pan_message, $force_update = FALSE ) { |
|
845 | - if ( ! empty( $pan_name ) && ! empty( $pan_message )) { |
|
846 | - $persistent_admin_notices = get_option( 'ee_pers_admin_notices', array() ); |
|
844 | + public static function add_persistent_admin_notice($pan_name = '', $pan_message, $force_update = FALSE) { |
|
845 | + if ( ! empty($pan_name) && ! empty($pan_message)) { |
|
846 | + $persistent_admin_notices = get_option('ee_pers_admin_notices', array()); |
|
847 | 847 | //maybe initialize persistent_admin_notices |
848 | - if ( empty( $persistent_admin_notices )) { |
|
849 | - add_option( 'ee_pers_admin_notices', array(), '', 'no' ); |
|
848 | + if (empty($persistent_admin_notices)) { |
|
849 | + add_option('ee_pers_admin_notices', array(), '', 'no'); |
|
850 | 850 | } |
851 | - $pan_name = sanitize_key( $pan_name ); |
|
852 | - if ( ! array_key_exists( $pan_name, $persistent_admin_notices ) || $force_update ) { |
|
853 | - $persistent_admin_notices[ $pan_name ] = $pan_message; |
|
854 | - update_option( 'ee_pers_admin_notices', $persistent_admin_notices ); |
|
851 | + $pan_name = sanitize_key($pan_name); |
|
852 | + if ( ! array_key_exists($pan_name, $persistent_admin_notices) || $force_update) { |
|
853 | + $persistent_admin_notices[$pan_name] = $pan_message; |
|
854 | + update_option('ee_pers_admin_notices', $persistent_admin_notices); |
|
855 | 855 | } |
856 | 856 | } |
857 | 857 | } |
@@ -867,34 +867,34 @@ discard block |
||
867 | 867 | * @param bool $return_immediately |
868 | 868 | * @return void |
869 | 869 | */ |
870 | - public static function dismiss_persistent_admin_notice( $pan_name = '', $purge = FALSE, $return_immediately = FALSE ) { |
|
871 | - $pan_name = EE_Registry::instance()->REQ->is_set( 'ee_nag_notice' ) ? EE_Registry::instance()->REQ->get( 'ee_nag_notice' ) : $pan_name; |
|
872 | - if ( ! empty( $pan_name )) { |
|
873 | - $persistent_admin_notices = get_option( 'ee_pers_admin_notices', array() ); |
|
870 | + public static function dismiss_persistent_admin_notice($pan_name = '', $purge = FALSE, $return_immediately = FALSE) { |
|
871 | + $pan_name = EE_Registry::instance()->REQ->is_set('ee_nag_notice') ? EE_Registry::instance()->REQ->get('ee_nag_notice') : $pan_name; |
|
872 | + if ( ! empty($pan_name)) { |
|
873 | + $persistent_admin_notices = get_option('ee_pers_admin_notices', array()); |
|
874 | 874 | // check if notice we wish to dismiss is actually in the $persistent_admin_notices array |
875 | - if ( is_array( $persistent_admin_notices ) && isset( $persistent_admin_notices[ $pan_name ] )) { |
|
875 | + if (is_array($persistent_admin_notices) && isset($persistent_admin_notices[$pan_name])) { |
|
876 | 876 | // completely delete nag notice, or just NULL message so that it can NOT be added again ? |
877 | - if ( $purge ) { |
|
878 | - unset( $persistent_admin_notices[ $pan_name ] ); |
|
877 | + if ($purge) { |
|
878 | + unset($persistent_admin_notices[$pan_name]); |
|
879 | 879 | } else { |
880 | - $persistent_admin_notices[ $pan_name ] = NULL; |
|
880 | + $persistent_admin_notices[$pan_name] = NULL; |
|
881 | 881 | } |
882 | - if ( update_option( 'ee_pers_admin_notices', $persistent_admin_notices ) === FALSE ) { |
|
883 | - EE_Error::add_error( sprintf( __( 'The persistent admin notice for "%s" could not be deleted.', 'event_espresso' ), $pan_name ), __FILE__, __FUNCTION__, __LINE__ ); |
|
882 | + if (update_option('ee_pers_admin_notices', $persistent_admin_notices) === FALSE) { |
|
883 | + EE_Error::add_error(sprintf(__('The persistent admin notice for "%s" could not be deleted.', 'event_espresso'), $pan_name), __FILE__, __FUNCTION__, __LINE__); |
|
884 | 884 | } |
885 | 885 | } |
886 | 886 | } |
887 | - if ( $return_immediately ) { |
|
887 | + if ($return_immediately) { |
|
888 | 888 | return; |
889 | - } else if ( EE_Registry::instance()->REQ->ajax ) { |
|
889 | + } else if (EE_Registry::instance()->REQ->ajax) { |
|
890 | 890 | // grab any notices and concatenate into string |
891 | - echo json_encode( array( 'errors' => implode( '<br />', EE_Error::get_notices( FALSE )))); |
|
891 | + echo json_encode(array('errors' => implode('<br />', EE_Error::get_notices(FALSE)))); |
|
892 | 892 | exit(); |
893 | 893 | } else { |
894 | 894 | // save errors to a transient to be displayed on next request (after redirect) |
895 | - EE_Error::get_notices( FALSE, TRUE ); |
|
896 | - $return_url = EE_Registry::instance()->REQ->is_set( 'return_url' ) ? EE_Registry::instance()->REQ->get( 'return_url' ) : ''; |
|
897 | - wp_safe_redirect( urldecode( $return_url )); |
|
895 | + EE_Error::get_notices(FALSE, TRUE); |
|
896 | + $return_url = EE_Registry::instance()->REQ->is_set('return_url') ? EE_Registry::instance()->REQ->get('return_url') : ''; |
|
897 | + wp_safe_redirect(urldecode($return_url)); |
|
898 | 898 | } |
899 | 899 | } |
900 | 900 | |
@@ -909,20 +909,20 @@ discard block |
||
909 | 909 | * @param string $return_url URL to go back to aftger nag notice is dismissed |
910 | 910 | * @return string |
911 | 911 | */ |
912 | - public static function display_persistent_admin_notices( $pan_name = '', $pan_message = '', $return_url = '' ) { |
|
913 | - if ( ! empty( $pan_name ) && ! empty( $pan_message )) { |
|
912 | + public static function display_persistent_admin_notices($pan_name = '', $pan_message = '', $return_url = '') { |
|
913 | + if ( ! empty($pan_name) && ! empty($pan_message)) { |
|
914 | 914 | $args = array( |
915 | 915 | 'nag_notice' => $pan_name, |
916 | - 'return_url' => urlencode( $return_url ), |
|
916 | + 'return_url' => urlencode($return_url), |
|
917 | 917 | 'ajax_url' => WP_AJAX_URL, |
918 | - 'unknown_error' => __( 'An unknown error has occurred on the server while attempting to dismiss this notice.', 'event_espresso' ) |
|
918 | + 'unknown_error' => __('An unknown error has occurred on the server while attempting to dismiss this notice.', 'event_espresso') |
|
919 | 919 | ); |
920 | - wp_localize_script( 'espresso_core', 'ee_dismiss', $args ); |
|
920 | + wp_localize_script('espresso_core', 'ee_dismiss', $args); |
|
921 | 921 | return ' |
922 | - <div id="' . $pan_name . '" class="espresso-notices updated ee-nag-notice clearfix" style="border-left: 4px solid #fcb93c;"> |
|
923 | - <p>' . $pan_message . '</p> |
|
924 | - <a class="dismiss-ee-nag-notice hide-if-no-js" style="float: right; cursor: pointer; text-decoration:none;" rel="' . $pan_name . '"> |
|
925 | - <span class="dashicons dashicons-dismiss" style="position:relative; top:-1px; margin-right:.25em;"></span>'.__( 'Dismiss', 'event_espresso' ) .' |
|
922 | + <div id="' . $pan_name.'" class="espresso-notices updated ee-nag-notice clearfix" style="border-left: 4px solid #fcb93c;"> |
|
923 | + <p>' . $pan_message.'</p> |
|
924 | + <a class="dismiss-ee-nag-notice hide-if-no-js" style="float: right; cursor: pointer; text-decoration:none;" rel="' . $pan_name.'"> |
|
925 | + <span class="dashicons dashicons-dismiss" style="position:relative; top:-1px; margin-right:.25em;"></span>'.__('Dismiss', 'event_espresso').' |
|
926 | 926 | </a> |
927 | 927 | <div style="clear:both;"></div> |
928 | 928 | </div>'; |
@@ -938,17 +938,17 @@ discard block |
||
938 | 938 | * @param string $return_url |
939 | 939 | * @return array |
940 | 940 | */ |
941 | - public static function get_persistent_admin_notices( $return_url = '' ) { |
|
941 | + public static function get_persistent_admin_notices($return_url = '') { |
|
942 | 942 | $notices = ''; |
943 | 943 | // check for persistent admin notices |
944 | - if ( $persistent_admin_notices = get_option( 'ee_pers_admin_notices', FALSE )) { |
|
944 | + if ($persistent_admin_notices = get_option('ee_pers_admin_notices', FALSE)) { |
|
945 | 945 | // load scripts |
946 | - wp_register_script( 'espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
947 | - wp_register_script( 'ee_error_js', EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js', array('espresso_core'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
948 | - wp_enqueue_script( 'ee_error_js' ); |
|
946 | + wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
947 | + wp_register_script('ee_error_js', EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js', array('espresso_core'), EVENT_ESPRESSO_VERSION, TRUE); |
|
948 | + wp_enqueue_script('ee_error_js'); |
|
949 | 949 | // and display notices |
950 | - foreach( $persistent_admin_notices as $pan_name => $pan_message ) { |
|
951 | - $notices .= self::display_persistent_admin_notices( $pan_name, $pan_message, $return_url ); |
|
950 | + foreach ($persistent_admin_notices as $pan_name => $pan_message) { |
|
951 | + $notices .= self::display_persistent_admin_notices($pan_name, $pan_message, $return_url); |
|
952 | 952 | } |
953 | 953 | } |
954 | 954 | return $notices; |
@@ -963,26 +963,26 @@ discard block |
||
963 | 963 | * @param bool $force_print |
964 | 964 | * @return void |
965 | 965 | */ |
966 | - private static function _print_scripts( $force_print = FALSE ) { |
|
967 | - if (( did_action( 'admin_enqueue_scripts' ) || did_action( 'wp_enqueue_scripts' )) && ! $force_print ) { |
|
968 | - if ( wp_script_is( 'ee_error_js', 'enqueued' )) { |
|
966 | + private static function _print_scripts($force_print = FALSE) { |
|
967 | + if ((did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts')) && ! $force_print) { |
|
968 | + if (wp_script_is('ee_error_js', 'enqueued')) { |
|
969 | 969 | return; |
970 | - } else if ( wp_script_is( 'ee_error_js', 'registered' )) { |
|
971 | - add_filter( 'FHEE_load_css', '__return_true' ); |
|
972 | - add_filter( 'FHEE_load_js', '__return_true' ); |
|
973 | - wp_enqueue_script( 'ee_error_js' ); |
|
974 | - wp_localize_script( 'ee_error_js','ee_settings', array( 'wp_debug'=>WP_DEBUG )); |
|
970 | + } else if (wp_script_is('ee_error_js', 'registered')) { |
|
971 | + add_filter('FHEE_load_css', '__return_true'); |
|
972 | + add_filter('FHEE_load_js', '__return_true'); |
|
973 | + wp_enqueue_script('ee_error_js'); |
|
974 | + wp_localize_script('ee_error_js', 'ee_settings', array('wp_debug'=>WP_DEBUG)); |
|
975 | 975 | } |
976 | 976 | } else { |
977 | 977 | return ' |
978 | 978 | <script> |
979 | 979 | /* <![CDATA[ */ |
980 | -var ee_settings = {"wp_debug":"' . WP_DEBUG . '"}; |
|
980 | +var ee_settings = {"wp_debug":"' . WP_DEBUG.'"}; |
|
981 | 981 | /* ]]> */ |
982 | 982 | </script> |
983 | -<script src="' . includes_url() . 'js/jquery/jquery.js" type="text/javascript"></script> |
|
984 | -<script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script> |
|
985 | -<script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script> |
|
983 | +<script src="' . includes_url().'js/jquery/jquery.js" type="text/javascript"></script> |
|
984 | +<script src="' . EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js'.'?ver='.espresso_version().'" type="text/javascript"></script> |
|
985 | +<script src="' . EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js'.'?ver='.espresso_version().'" type="text/javascript"></script> |
|
986 | 986 | '; |
987 | 987 | |
988 | 988 | } |
@@ -1016,11 +1016,11 @@ discard block |
||
1016 | 1016 | * @ param string $line |
1017 | 1017 | * @ return string |
1018 | 1018 | */ |
1019 | - public static function generate_error_code ( $file = '', $func = '', $line = '' ) { |
|
1020 | - $file = explode( '.', basename( $file )); |
|
1021 | - $error_code = ! empty( $file[0] ) ? $file[0] : ''; |
|
1022 | - $error_code .= ! empty( $func ) ? ' - ' . $func : ''; |
|
1023 | - $error_code .= ! empty( $line ) ? ' - ' . $line : ''; |
|
1019 | + public static function generate_error_code($file = '', $func = '', $line = '') { |
|
1020 | + $file = explode('.', basename($file)); |
|
1021 | + $error_code = ! empty($file[0]) ? $file[0] : ''; |
|
1022 | + $error_code .= ! empty($func) ? ' - '.$func : ''; |
|
1023 | + $error_code .= ! empty($line) ? ' - '.$line : ''; |
|
1024 | 1024 | return $error_code; |
1025 | 1025 | } |
1026 | 1026 | |
@@ -1036,37 +1036,37 @@ discard block |
||
1036 | 1036 | * @ param object $ex |
1037 | 1037 | * @ return void |
1038 | 1038 | */ |
1039 | - public function write_to_error_log ( $time = FALSE, $ex = FALSE, $clear = FALSE ) { |
|
1039 | + public function write_to_error_log($time = FALSE, $ex = FALSE, $clear = FALSE) { |
|
1040 | 1040 | |
1041 | - if ( ! $ex ) { |
|
1041 | + if ( ! $ex) { |
|
1042 | 1042 | return; |
1043 | 1043 | } |
1044 | 1044 | |
1045 | - if ( ! $time ) { |
|
1045 | + if ( ! $time) { |
|
1046 | 1046 | $time = time(); |
1047 | 1047 | } |
1048 | 1048 | |
1049 | - $exception_log = '----------------------------------------------------------------------------------------' . PHP_EOL; |
|
1050 | - $exception_log .= '[' . date( 'Y-m-d H:i:s', $time ) . '] Exception Details' . PHP_EOL; |
|
1051 | - $exception_log .= 'Message: ' . $ex['msg'] . PHP_EOL; |
|
1052 | - $exception_log .= 'Code: '. $ex['code'] . PHP_EOL; |
|
1053 | - $exception_log .= 'File: '. $ex['file'] . PHP_EOL; |
|
1054 | - $exception_log .= 'Line No: ' . $ex['line'] . PHP_EOL; |
|
1055 | - $exception_log .= 'Stack trace: ' . PHP_EOL; |
|
1056 | - $exception_log .= $ex['string'] . PHP_EOL; |
|
1057 | - $exception_log .= '----------------------------------------------------------------------------------------' . PHP_EOL; |
|
1058 | - |
|
1059 | - EE_Registry::instance()->load_helper( 'File' ); |
|
1049 | + $exception_log = '----------------------------------------------------------------------------------------'.PHP_EOL; |
|
1050 | + $exception_log .= '['.date('Y-m-d H:i:s', $time).'] Exception Details'.PHP_EOL; |
|
1051 | + $exception_log .= 'Message: '.$ex['msg'].PHP_EOL; |
|
1052 | + $exception_log .= 'Code: '.$ex['code'].PHP_EOL; |
|
1053 | + $exception_log .= 'File: '.$ex['file'].PHP_EOL; |
|
1054 | + $exception_log .= 'Line No: '.$ex['line'].PHP_EOL; |
|
1055 | + $exception_log .= 'Stack trace: '.PHP_EOL; |
|
1056 | + $exception_log .= $ex['string'].PHP_EOL; |
|
1057 | + $exception_log .= '----------------------------------------------------------------------------------------'.PHP_EOL; |
|
1058 | + |
|
1059 | + EE_Registry::instance()->load_helper('File'); |
|
1060 | 1060 | try { |
1061 | - EEH_File::ensure_file_exists_and_is_writable( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file ); |
|
1062 | - EEH_File::add_htaccess_deny_from_all( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' ); |
|
1063 | - if ( ! $clear ) { |
|
1061 | + EEH_File::ensure_file_exists_and_is_writable(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.self::$_exception_log_file); |
|
1062 | + EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR.'logs'); |
|
1063 | + if ( ! $clear) { |
|
1064 | 1064 | //get existing log file and append new log info |
1065 | - $exception_log = EEH_File::get_file_contents( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file ) . $exception_log; |
|
1065 | + $exception_log = EEH_File::get_file_contents(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.self::$_exception_log_file).$exception_log; |
|
1066 | 1066 | } |
1067 | - EEH_File::write_to_file( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file, $exception_log ); |
|
1068 | - } catch( EE_Error $e ){ |
|
1069 | - EE_Error::add_error( sprintf( __( 'Event Espresso error logging could not be setup because: %s', 'event_espresso' ), $e->getMessage() )); |
|
1067 | + EEH_File::write_to_file(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.self::$_exception_log_file, $exception_log); |
|
1068 | + } catch (EE_Error $e) { |
|
1069 | + EE_Error::add_error(sprintf(__('Event Espresso error logging could not be setup because: %s', 'event_espresso'), $e->getMessage())); |
|
1070 | 1070 | return; |
1071 | 1071 | } |
1072 | 1072 | |
@@ -1090,10 +1090,10 @@ discard block |
||
1090 | 1090 | * @param int $error_type |
1091 | 1091 | * @return void |
1092 | 1092 | */ |
1093 | - public static function doing_it_wrong( $function, $message, $version, $error_type = E_USER_NOTICE ) { |
|
1094 | - if ( defined('WP_DEBUG') && WP_DEBUG ) { |
|
1093 | + public static function doing_it_wrong($function, $message, $version, $error_type = E_USER_NOTICE) { |
|
1094 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
1095 | 1095 | EE_Registry::instance()->load_helper('Debug_Tools'); |
1096 | - EEH_Debug_Tools::instance()->doing_it_wrong( $function, $message, $version, $error_type ); |
|
1096 | + EEH_Debug_Tools::instance()->doing_it_wrong($function, $message, $version, $error_type); |
|
1097 | 1097 | } |
1098 | 1098 | } |
1099 | 1099 | |
@@ -1113,13 +1113,13 @@ discard block |
||
1113 | 1113 | */ |
1114 | 1114 | function espresso_error_enqueue_scripts() { |
1115 | 1115 | // js for error handling |
1116 | - wp_register_script( 'espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, FALSE ); |
|
1117 | - wp_register_script( 'ee_error_js', EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js', array('espresso_core'), EVENT_ESPRESSO_VERSION, FALSE ); |
|
1116 | + wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, FALSE); |
|
1117 | + wp_register_script('ee_error_js', EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js', array('espresso_core'), EVENT_ESPRESSO_VERSION, FALSE); |
|
1118 | 1118 | } |
1119 | -if ( is_admin() ) { |
|
1120 | - add_action( 'admin_enqueue_scripts', 'espresso_error_enqueue_scripts', 2 ); |
|
1119 | +if (is_admin()) { |
|
1120 | + add_action('admin_enqueue_scripts', 'espresso_error_enqueue_scripts', 2); |
|
1121 | 1121 | } else { |
1122 | - add_action( 'wp_enqueue_scripts', 'espresso_error_enqueue_scripts', 2 ); |
|
1122 | + add_action('wp_enqueue_scripts', 'espresso_error_enqueue_scripts', 2); |
|
1123 | 1123 | } |
1124 | 1124 | |
1125 | 1125 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object. |
45 | 45 | * @return \Payments_Admin_Page |
46 | 46 | */ |
47 | - public function __construct( $routing = TRUE ) { |
|
48 | - parent::__construct( $routing ); |
|
47 | + public function __construct($routing = TRUE) { |
|
48 | + parent::__construct($routing); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | |
@@ -130,19 +130,19 @@ discard block |
||
130 | 130 | protected function _set_page_config() { |
131 | 131 | $payment_method_list_config = array( |
132 | 132 | 'nav' => array( |
133 | - 'label' => __( 'Payment Methods', 'event_espresso' ), |
|
133 | + 'label' => __('Payment Methods', 'event_espresso'), |
|
134 | 134 | 'order' => 10 |
135 | 135 | ), |
136 | 136 | 'metaboxes' => $this->_default_espresso_metaboxes, |
137 | 137 | 'help_tabs' => array_merge( |
138 | 138 | array( |
139 | 139 | 'payment_methods_overview_help_tab' => array( |
140 | - 'title' => __( 'Payment Methods Overview', 'event_espresso' ), |
|
140 | + 'title' => __('Payment Methods Overview', 'event_espresso'), |
|
141 | 141 | 'filename' => 'payment_methods_overview' |
142 | 142 | ) |
143 | 143 | ), |
144 | 144 | $this->_add_payment_method_help_tabs() ), |
145 | - 'help_tour' => array( 'Payment_Methods_Selection_Help_Tour' ), |
|
145 | + 'help_tour' => array('Payment_Methods_Selection_Help_Tour'), |
|
146 | 146 | 'require_nonce' => false |
147 | 147 | ); |
148 | 148 | |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | ) |
161 | 161 | ), |
162 | 162 | //'help_tour' => array( 'Payment_Methods_Settings_Help_Tour' ), |
163 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_publish_post_box' ) ), |
|
163 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
164 | 164 | 'require_nonce' => FALSE |
165 | 165 | ), |
166 | 166 | 'payment_log'=>array( |
@@ -179,18 +179,18 @@ discard block |
||
179 | 179 | /** |
180 | 180 | * @return array |
181 | 181 | */ |
182 | - protected function _add_payment_method_help_tabs(){ |
|
182 | + protected function _add_payment_method_help_tabs() { |
|
183 | 183 | EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
184 | 184 | $payment_method_types = EE_Payment_Method_Manager::instance()->payment_method_types(); |
185 | 185 | $all_pmt_help_tabs_config = array(); |
186 | - foreach( $payment_method_types as $payment_method_type ){ |
|
187 | - if ( ! EE_Registry::instance()->CAP->current_user_can( $payment_method_type->cap_name(), 'specific_payment_method_type_access' ) ) { |
|
186 | + foreach ($payment_method_types as $payment_method_type) { |
|
187 | + if ( ! EE_Registry::instance()->CAP->current_user_can($payment_method_type->cap_name(), 'specific_payment_method_type_access')) { |
|
188 | 188 | continue; |
189 | 189 | } |
190 | - foreach( $payment_method_type->help_tabs_config() as $help_tab_name => $config ){ |
|
190 | + foreach ($payment_method_type->help_tabs_config() as $help_tab_name => $config) { |
|
191 | 191 | $all_pmt_help_tabs_config[$help_tab_name] = array( |
192 | 192 | 'title'=>$config['title'], |
193 | - 'content'=>EEH_Template::display_template( $payment_method_type->file_folder().'help_tabs'.DS.$config['filename'].'.help_tab.php', array('admin_page_obj'=>$this), true) |
|
193 | + 'content'=>EEH_Template::display_template($payment_method_type->file_folder().'help_tabs'.DS.$config['filename'].'.help_tab.php', array('admin_page_obj'=>$this), true) |
|
194 | 194 | ); |
195 | 195 | } |
196 | 196 | } |
@@ -211,9 +211,9 @@ discard block |
||
211 | 211 | |
212 | 212 | |
213 | 213 | public function load_scripts_styles() { |
214 | - wp_enqueue_script( 'ee_admin_js' ); |
|
215 | - wp_enqueue_script( 'ee-text-links' ); |
|
216 | - wp_enqueue_script( 'espresso_payments', EE_PAYMENTS_ASSETS_URL . 'espresso_payments_admin.js', array( 'espresso-ui-theme', 'ee-datepicker' ), EVENT_ESPRESSO_VERSION, TRUE ); |
|
214 | + wp_enqueue_script('ee_admin_js'); |
|
215 | + wp_enqueue_script('ee-text-links'); |
|
216 | + wp_enqueue_script('espresso_payments', EE_PAYMENTS_ASSETS_URL.'espresso_payments_admin.js', array('espresso-ui-theme', 'ee-datepicker'), EVENT_ESPRESSO_VERSION, TRUE); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | |
@@ -222,9 +222,9 @@ discard block |
||
222 | 222 | |
223 | 223 | public function load_scripts_styles_default() { |
224 | 224 | //styles |
225 | - wp_register_style( 'espresso_payments', EE_PAYMENTS_ASSETS_URL . 'ee-payments.css', array(), EVENT_ESPRESSO_VERSION ); |
|
226 | - wp_enqueue_style( 'espresso_payments' ); |
|
227 | - wp_enqueue_style( 'ee-text-links' ); |
|
225 | + wp_register_style('espresso_payments', EE_PAYMENTS_ASSETS_URL.'ee-payments.css', array(), EVENT_ESPRESSO_VERSION); |
|
226 | + wp_enqueue_style('espresso_payments'); |
|
227 | + wp_enqueue_style('ee-text-links'); |
|
228 | 228 | //scripts |
229 | 229 | } |
230 | 230 | |
@@ -238,46 +238,46 @@ discard block |
||
238 | 238 | * to the loading process. However, people MUST setup the details for the payment method so its safe to do a |
239 | 239 | * recheck here. |
240 | 240 | */ |
241 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
241 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
242 | 242 | EEM_Payment_Method::instance()->verify_button_urls(); |
243 | - EE_Registry::instance()->load_helper( 'Tabbed_Content' ); |
|
244 | - EE_Registry::instance()->load_helper( 'HTML' ); |
|
243 | + EE_Registry::instance()->load_helper('Tabbed_Content'); |
|
244 | + EE_Registry::instance()->load_helper('HTML'); |
|
245 | 245 | //setup tabs, one for each payment method type |
246 | 246 | $tabs = array(); |
247 | 247 | $payment_methods = array(); |
248 | - foreach( EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj ) { |
|
248 | + foreach (EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj) { |
|
249 | 249 | // we don't want to show admin-only PMTs for now |
250 | - if ( $pmt_obj instanceof EE_PMT_Admin_Only ) { |
|
250 | + if ($pmt_obj instanceof EE_PMT_Admin_Only) { |
|
251 | 251 | continue; |
252 | 252 | } |
253 | 253 | //check access |
254 | - if ( ! EE_Registry::instance()->CAP->current_user_can( $pmt_obj->cap_name(), 'specific_payment_method_type_access' ) ) { |
|
254 | + if ( ! EE_Registry::instance()->CAP->current_user_can($pmt_obj->cap_name(), 'specific_payment_method_type_access')) { |
|
255 | 255 | continue; |
256 | 256 | } |
257 | 257 | //check for any active pms of that type |
258 | - $payment_method = EEM_Payment_Method::instance()->get_one_of_type( $pmt_obj->system_name() ); |
|
259 | - if ( ! $payment_method instanceof EE_Payment_Method ) { |
|
258 | + $payment_method = EEM_Payment_Method::instance()->get_one_of_type($pmt_obj->system_name()); |
|
259 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
260 | 260 | $payment_method = EE_Payment_Method::new_instance( |
261 | 261 | array( |
262 | - 'PMD_slug' =>sanitize_key( $pmt_obj->system_name() ), |
|
262 | + 'PMD_slug' =>sanitize_key($pmt_obj->system_name()), |
|
263 | 263 | 'PMD_type' =>$pmt_obj->system_name(), |
264 | 264 | 'PMD_name' =>$pmt_obj->pretty_name(), |
265 | 265 | 'PMD_admin_name' =>$pmt_obj->pretty_name() |
266 | 266 | ) |
267 | 267 | ); |
268 | 268 | } |
269 | - $payment_methods[ $payment_method->slug() ] = $payment_method; |
|
269 | + $payment_methods[$payment_method->slug()] = $payment_method; |
|
270 | 270 | } |
271 | - $payment_methods = apply_filters( 'FHEE__Payments_Admin_Page___payment_methods_list__payment_methods', $payment_methods ); |
|
272 | - foreach( $payment_methods as $payment_method ) { |
|
273 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
271 | + $payment_methods = apply_filters('FHEE__Payments_Admin_Page___payment_methods_list__payment_methods', $payment_methods); |
|
272 | + foreach ($payment_methods as $payment_method) { |
|
273 | + if ($payment_method instanceof EE_Payment_Method) { |
|
274 | 274 | add_meta_box( |
275 | 275 | //html id |
276 | - 'espresso_' . $payment_method->slug() . '_payment_settings', |
|
276 | + 'espresso_'.$payment_method->slug().'_payment_settings', |
|
277 | 277 | //title |
278 | - sprintf( __( '%s Settings', 'event_espresso' ), $payment_method->admin_name() ), |
|
278 | + sprintf(__('%s Settings', 'event_espresso'), $payment_method->admin_name()), |
|
279 | 279 | //callback |
280 | - array( $this, 'payment_method_settings_meta_box' ), |
|
280 | + array($this, 'payment_method_settings_meta_box'), |
|
281 | 281 | //post type |
282 | 282 | null, |
283 | 283 | //context |
@@ -285,19 +285,19 @@ discard block |
||
285 | 285 | //priority |
286 | 286 | 'default', |
287 | 287 | //callback args |
288 | - array( 'payment_method' => $payment_method ) |
|
288 | + array('payment_method' => $payment_method) |
|
289 | 289 | ); |
290 | 290 | //setup for tabbed content |
291 | - $tabs[ $payment_method->slug() ] = array( |
|
291 | + $tabs[$payment_method->slug()] = array( |
|
292 | 292 | 'label' => $payment_method->admin_name(), |
293 | 293 | 'class' => $payment_method->active() ? 'gateway-active' : '', |
294 | - 'href' => 'espresso_' . $payment_method->slug() . '_payment_settings', |
|
295 | - 'title' => __( 'Modify this Payment Method', 'event_espresso' ), |
|
294 | + 'href' => 'espresso_'.$payment_method->slug().'_payment_settings', |
|
295 | + 'title' => __('Modify this Payment Method', 'event_espresso'), |
|
296 | 296 | 'slug' => $payment_method->slug() |
297 | 297 | ); |
298 | 298 | } |
299 | 299 | } |
300 | - $this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links( $tabs, 'payment_method_links', '|', $this->_get_active_payment_method_slug() ); |
|
300 | + $this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links($tabs, 'payment_method_links', '|', $this->_get_active_payment_method_slug()); |
|
301 | 301 | $this->display_admin_page_with_sidebar(); |
302 | 302 | |
303 | 303 | } |
@@ -308,20 +308,20 @@ discard block |
||
308 | 308 | * _get_active_payment_method_slug |
309 | 309 | * @return string |
310 | 310 | */ |
311 | - protected function _get_active_payment_method_slug(){ |
|
311 | + protected function _get_active_payment_method_slug() { |
|
312 | 312 | $payment_method_slug = FALSE; |
313 | 313 | //decide which payment method tab to open first, as dictated by the request's 'payment_method' |
314 | - if ( isset( $this->_req_data['payment_method'] )) { |
|
314 | + if (isset($this->_req_data['payment_method'])) { |
|
315 | 315 | // if they provided the current payment method, use it |
316 | - $payment_method_slug = sanitize_key( $this->_req_data['payment_method'] ); |
|
316 | + $payment_method_slug = sanitize_key($this->_req_data['payment_method']); |
|
317 | 317 | } |
318 | - $payment_method = EEM_Payment_Method::instance()->get_one( array( array( 'PMD_slug' => $payment_method_slug ))); |
|
318 | + $payment_method = EEM_Payment_Method::instance()->get_one(array(array('PMD_slug' => $payment_method_slug))); |
|
319 | 319 | // if that didn't work or wasn't provided, find another way to select the current pm |
320 | - if ( ! $this->_verify_payment_method( $payment_method )) { |
|
320 | + if ( ! $this->_verify_payment_method($payment_method)) { |
|
321 | 321 | // like, looking for an active one |
322 | - $payment_method = EEM_Payment_Method::instance()->get_one_active( 'CART' ); |
|
322 | + $payment_method = EEM_Payment_Method::instance()->get_one_active('CART'); |
|
323 | 323 | // test that one as well |
324 | - if ( $this->_verify_payment_method( $payment_method )) { |
|
324 | + if ($this->_verify_payment_method($payment_method)) { |
|
325 | 325 | $payment_method_slug = $payment_method->slug(); |
326 | 326 | } else { |
327 | 327 | $payment_method_slug = 'paypal_standard'; |
@@ -339,11 +339,11 @@ discard block |
||
339 | 339 | * @param \EE_Payment_Method $payment_method |
340 | 340 | * @return boolean |
341 | 341 | */ |
342 | - protected function _verify_payment_method( $payment_method ){ |
|
342 | + protected function _verify_payment_method($payment_method) { |
|
343 | 343 | if ( |
344 | 344 | $payment_method instanceof EE_Payment_Method && |
345 | 345 | $payment_method->type_obj() instanceof EE_PMT_Base && |
346 | - EE_Registry::instance()->CAP->current_user_can( $payment_method->type_obj()->cap_name(), 'specific_payment_method_type_access' ) |
|
346 | + EE_Registry::instance()->CAP->current_user_can($payment_method->type_obj()->cap_name(), 'specific_payment_method_type_access') |
|
347 | 347 | ) { |
348 | 348 | return TRUE; |
349 | 349 | } |
@@ -360,21 +360,21 @@ discard block |
||
360 | 360 | * @return string |
361 | 361 | * @throws EE_Error |
362 | 362 | */ |
363 | - public function payment_method_settings_meta_box( $post_obj_which_is_null, $metabox ){ |
|
364 | - $payment_method = isset( $metabox['args'], $metabox['args']['payment_method'] ) ? $metabox['args']['payment_method'] : NULL; |
|
365 | - if ( ! $payment_method instanceof EE_Payment_Method ){ |
|
366 | - throw new EE_Error( sprintf( __( 'Payment method metabox setup incorrectly. No Payment method object was supplied', 'event_espresso' ))); |
|
363 | + public function payment_method_settings_meta_box($post_obj_which_is_null, $metabox) { |
|
364 | + $payment_method = isset($metabox['args'], $metabox['args']['payment_method']) ? $metabox['args']['payment_method'] : NULL; |
|
365 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
366 | + throw new EE_Error(sprintf(__('Payment method metabox setup incorrectly. No Payment method object was supplied', 'event_espresso'))); |
|
367 | 367 | } |
368 | 368 | $payment_method_scopes = $payment_method->active(); |
369 | 369 | // if the payment method really exists show its form, otherwise the activation template |
370 | - if ( $payment_method->ID() && ! empty( $payment_method_scopes )) { |
|
371 | - $form = $this->_generate_payment_method_settings_form( $payment_method ); |
|
372 | - if ( $form->form_data_present_in( $this->_req_data )) { |
|
373 | - $form->receive_form_submission( $this->_req_data ); |
|
370 | + if ($payment_method->ID() && ! empty($payment_method_scopes)) { |
|
371 | + $form = $this->_generate_payment_method_settings_form($payment_method); |
|
372 | + if ($form->form_data_present_in($this->_req_data)) { |
|
373 | + $form->receive_form_submission($this->_req_data); |
|
374 | 374 | } |
375 | - echo $form->form_open() . $form->get_html_and_js() . $form->form_close(); |
|
375 | + echo $form->form_open().$form->get_html_and_js().$form->form_close(); |
|
376 | 376 | } else { |
377 | - echo $this->_activate_payment_method_button( $payment_method )->get_html_and_js(); |
|
377 | + echo $this->_activate_payment_method_button($payment_method)->get_html_and_js(); |
|
378 | 378 | } |
379 | 379 | } |
380 | 380 | |
@@ -387,14 +387,14 @@ discard block |
||
387 | 387 | * @param \EE_Payment_Method $payment_method |
388 | 388 | * @return \EE_Form_Section_Proper |
389 | 389 | */ |
390 | - protected function _generate_payment_method_settings_form( EE_Payment_Method $payment_method ) { |
|
391 | - if ( ! $payment_method instanceof EE_Payment_Method ){ |
|
390 | + protected function _generate_payment_method_settings_form(EE_Payment_Method $payment_method) { |
|
391 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
392 | 392 | return new EE_Form_Section_Proper(); |
393 | 393 | } |
394 | 394 | return new EE_Form_Section_Proper( |
395 | 395 | array( |
396 | - 'name' => $payment_method->slug() . '_settings_form', |
|
397 | - 'html_id' => $payment_method->slug() . '_settings_form', |
|
396 | + 'name' => $payment_method->slug().'_settings_form', |
|
397 | + 'html_id' => $payment_method->slug().'_settings_form', |
|
398 | 398 | 'action' => EE_Admin_Page::add_query_args_and_nonce( |
399 | 399 | array( |
400 | 400 | 'action' => 'update_payment_method', |
@@ -406,12 +406,12 @@ discard block |
||
406 | 406 | 'subsections' => apply_filters( |
407 | 407 | 'FHEE__Payments_Admin_Page___generate_payment_method_settings_form__form_subsections', |
408 | 408 | array( |
409 | - 'pci_dss_compliance_' . $payment_method->slug() => $this->_pci_dss_compliance( $payment_method ), |
|
410 | - 'currency_support_' . $payment_method->slug() => $this->_currency_support( $payment_method ), |
|
411 | - 'payment_method_settings_' . $payment_method->slug() => $this->_payment_method_settings( $payment_method ), |
|
412 | - 'update_' . $payment_method->slug() => $this->_update_payment_method_button( $payment_method ), |
|
413 | - 'deactivate_' . $payment_method->slug() => $this->_deactivate_payment_method_button( $payment_method ), |
|
414 | - 'fine_print_' . $payment_method->slug() => $this->_fine_print() |
|
409 | + 'pci_dss_compliance_'.$payment_method->slug() => $this->_pci_dss_compliance($payment_method), |
|
410 | + 'currency_support_'.$payment_method->slug() => $this->_currency_support($payment_method), |
|
411 | + 'payment_method_settings_'.$payment_method->slug() => $this->_payment_method_settings($payment_method), |
|
412 | + 'update_'.$payment_method->slug() => $this->_update_payment_method_button($payment_method), |
|
413 | + 'deactivate_'.$payment_method->slug() => $this->_deactivate_payment_method_button($payment_method), |
|
414 | + 'fine_print_'.$payment_method->slug() => $this->_fine_print() |
|
415 | 415 | ), |
416 | 416 | $payment_method |
417 | 417 | ) |
@@ -428,19 +428,19 @@ discard block |
||
428 | 428 | * @param \EE_Payment_Method $payment_method |
429 | 429 | * @return \EE_Form_Section_Proper |
430 | 430 | */ |
431 | - protected function _pci_dss_compliance( EE_Payment_Method $payment_method ) { |
|
432 | - if ( $payment_method->type_obj()->requires_https() ) { |
|
431 | + protected function _pci_dss_compliance(EE_Payment_Method $payment_method) { |
|
432 | + if ($payment_method->type_obj()->requires_https()) { |
|
433 | 433 | return new EE_Form_Section_HTML( |
434 | 434 | EEH_HTML::tr( |
435 | 435 | EEH_HTML::th( |
436 | 436 | EEH_HTML::label( |
437 | - EEH_HTML::strong( __( 'IMPORTANT', 'event_espresso' ), '', 'important-notice' ) |
|
437 | + EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice') |
|
438 | 438 | ) |
439 | - ) . |
|
439 | + ). |
|
440 | 440 | EEH_HTML::td( |
441 | - EEH_HTML::strong( __( 'You are responsible for your own website security and Payment Card Industry Data Security Standards (PCI DSS) compliance.', 'event_espresso' )) . |
|
442 | - EEH_HTML::br() . |
|
443 | - __( 'Learn more about ', 'event_espresso' ) . EEH_HTML::link( 'https://www.pcisecuritystandards.org/merchants/index.php', __( 'PCI DSS compliance', 'event_espresso' )) |
|
441 | + EEH_HTML::strong(__('You are responsible for your own website security and Payment Card Industry Data Security Standards (PCI DSS) compliance.', 'event_espresso')). |
|
442 | + EEH_HTML::br(). |
|
443 | + __('Learn more about ', 'event_espresso').EEH_HTML::link('https://www.pcisecuritystandards.org/merchants/index.php', __('PCI DSS compliance', 'event_espresso')) |
|
444 | 444 | ) |
445 | 445 | ) |
446 | 446 | ); |
@@ -458,19 +458,19 @@ discard block |
||
458 | 458 | * @param \EE_Payment_Method $payment_method |
459 | 459 | * @return \EE_Form_Section_Proper |
460 | 460 | */ |
461 | - protected function _currency_support( EE_Payment_Method $payment_method ) { |
|
462 | - if ( ! $payment_method->usable_for_currency( EE_Config::instance()->currency->code )) { |
|
461 | + protected function _currency_support(EE_Payment_Method $payment_method) { |
|
462 | + if ( ! $payment_method->usable_for_currency(EE_Config::instance()->currency->code)) { |
|
463 | 463 | return new EE_Form_Section_HTML( |
464 | 464 | EEH_HTML::tr( |
465 | 465 | EEH_HTML::th( |
466 | 466 | EEH_HTML::label( |
467 | - EEH_HTML::strong( __( 'IMPORTANT', 'event_espresso' ), '', 'important-notice' ) |
|
467 | + EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice') |
|
468 | 468 | ) |
469 | - ) . |
|
469 | + ). |
|
470 | 470 | EEH_HTML::td( |
471 | 471 | EEH_HTML::strong( |
472 | 472 | sprintf( |
473 | - __( 'This payment method does not support the currency set on your site (%1$s) and so will not appear as a payment option to registrants. Please activate a different payment method or change your site\'s country and associated currency.', 'event_espresso'), |
|
473 | + __('This payment method does not support the currency set on your site (%1$s) and so will not appear as a payment option to registrants. Please activate a different payment method or change your site\'s country and associated currency.', 'event_espresso'), |
|
474 | 474 | EE_Config::instance()->currency->code |
475 | 475 | ) |
476 | 476 | ) |
@@ -490,9 +490,9 @@ discard block |
||
490 | 490 | * @param \EE_Payment_Method $payment_method |
491 | 491 | * @return \EE_Form_Section_HTML |
492 | 492 | */ |
493 | - protected function _payment_method_settings( EE_Payment_Method $payment_method ) { |
|
493 | + protected function _payment_method_settings(EE_Payment_Method $payment_method) { |
|
494 | 494 | //modify the form so we only have/show fields that will be implemented for this version |
495 | - return $this->_simplify_form( $payment_method->type_obj()->settings_form(), $payment_method->name() ); |
|
495 | + return $this->_simplify_form($payment_method->type_obj()->settings_form(), $payment_method->name()); |
|
496 | 496 | } |
497 | 497 | |
498 | 498 | |
@@ -505,8 +505,8 @@ discard block |
||
505 | 505 | * @return \EE_Payment_Method_Form |
506 | 506 | * @throws \EE_Error |
507 | 507 | */ |
508 | - protected function _simplify_form( $form_section, $payment_method_name = '' ){ |
|
509 | - if ( $form_section instanceof EE_Payment_Method_Form ) { |
|
508 | + protected function _simplify_form($form_section, $payment_method_name = '') { |
|
509 | + if ($form_section instanceof EE_Payment_Method_Form) { |
|
510 | 510 | $form_section->exclude( |
511 | 511 | array( |
512 | 512 | 'PMD_type', //dont want them changing the type |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | ); |
518 | 518 | return $form_section; |
519 | 519 | } else { |
520 | - throw new EE_Error( sprintf( __( 'The EE_Payment_Method_Form for the "%1$s" payment method is missing or invalid.', 'event_espresso' ), $payment_method_name )); |
|
520 | + throw new EE_Error(sprintf(__('The EE_Payment_Method_Form for the "%1$s" payment method is missing or invalid.', 'event_espresso'), $payment_method_name)); |
|
521 | 521 | } |
522 | 522 | } |
523 | 523 | |
@@ -530,18 +530,18 @@ discard block |
||
530 | 530 | * @param \EE_Payment_Method $payment_method |
531 | 531 | * @return \EE_Form_Section_HTML |
532 | 532 | */ |
533 | - protected function _update_payment_method_button( EE_Payment_Method $payment_method ) { |
|
533 | + protected function _update_payment_method_button(EE_Payment_Method $payment_method) { |
|
534 | 534 | $update_button = new EE_Submit_Input( |
535 | 535 | array( |
536 | - 'html_id' => 'save_' . $payment_method->slug() . '_settings', |
|
537 | - 'default' => sprintf( __( 'Update %s Payment Settings', 'event_espresso' ), $payment_method->admin_name() ), |
|
536 | + 'html_id' => 'save_'.$payment_method->slug().'_settings', |
|
537 | + 'default' => sprintf(__('Update %s Payment Settings', 'event_espresso'), $payment_method->admin_name()), |
|
538 | 538 | 'html_label' => EEH_HTML::nbsp() |
539 | 539 | ) |
540 | 540 | ); |
541 | 541 | return new EE_Form_Section_HTML( |
542 | - EEH_HTML::no_row( EEH_HTML::br(2) ) . |
|
542 | + EEH_HTML::no_row(EEH_HTML::br(2)). |
|
543 | 543 | EEH_HTML::tr( |
544 | - EEH_HTML::th( __( 'Update Settings', 'event_espresso') ) . |
|
544 | + EEH_HTML::th(__('Update Settings', 'event_espresso')). |
|
545 | 545 | EEH_HTML::td( |
546 | 546 | $update_button->get_html_for_input() |
547 | 547 | ) |
@@ -558,11 +558,11 @@ discard block |
||
558 | 558 | * @param \EE_Payment_Method $payment_method |
559 | 559 | * @return \EE_Form_Section_Proper |
560 | 560 | */ |
561 | - protected function _deactivate_payment_method_button( EE_Payment_Method $payment_method ) { |
|
562 | - $link_text_and_title = sprintf( __( 'Deactivate %1$s Payments?', 'event_espresso'), $payment_method->admin_name() ); |
|
561 | + protected function _deactivate_payment_method_button(EE_Payment_Method $payment_method) { |
|
562 | + $link_text_and_title = sprintf(__('Deactivate %1$s Payments?', 'event_espresso'), $payment_method->admin_name()); |
|
563 | 563 | return new EE_Form_Section_HTML( |
564 | 564 | EEH_HTML::tr( |
565 | - EEH_HTML::th( __( 'Deactivate Payment Method', 'event_espresso') ) . |
|
565 | + EEH_HTML::th(__('Deactivate Payment Method', 'event_espresso')). |
|
566 | 566 | EEH_HTML::td( |
567 | 567 | EEH_HTML::link( |
568 | 568 | EE_Admin_Page::add_query_args_and_nonce( |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | ), |
575 | 575 | $link_text_and_title, |
576 | 576 | $link_text_and_title, |
577 | - 'deactivate_' . $payment_method->slug(), |
|
577 | + 'deactivate_'.$payment_method->slug(), |
|
578 | 578 | 'espresso-button button-secondary' |
579 | 579 | ) |
580 | 580 | ) |
@@ -590,12 +590,12 @@ discard block |
||
590 | 590 | * @param \EE_Payment_Method $payment_method |
591 | 591 | * @return \EE_Form_Section_Proper |
592 | 592 | */ |
593 | - protected function _activate_payment_method_button( EE_Payment_Method $payment_method ) { |
|
594 | - $link_text_and_title = sprintf( __( 'Activate %1$s Payment Method?', 'event_espresso'), $payment_method->admin_name() ); |
|
593 | + protected function _activate_payment_method_button(EE_Payment_Method $payment_method) { |
|
594 | + $link_text_and_title = sprintf(__('Activate %1$s Payment Method?', 'event_espresso'), $payment_method->admin_name()); |
|
595 | 595 | return new EE_Form_Section_Proper( |
596 | 596 | array( |
597 | - 'name' => 'activate_' . $payment_method->slug() . '_settings_form', |
|
598 | - 'html_id' => 'activate_' . $payment_method->slug() . '_settings_form', |
|
597 | + 'name' => 'activate_'.$payment_method->slug().'_settings_form', |
|
598 | + 'html_id' => 'activate_'.$payment_method->slug().'_settings_form', |
|
599 | 599 | 'action' => '#', |
600 | 600 | 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
601 | 601 | 'subsections' => apply_filters( |
@@ -604,8 +604,8 @@ discard block |
||
604 | 604 | new EE_Form_Section_HTML( |
605 | 605 | EEH_HTML::tr( |
606 | 606 | EEH_HTML::th( |
607 | - EEH_HTML::label( __( 'Click to Activate ', 'event_espresso' )) |
|
608 | - ) . |
|
607 | + EEH_HTML::label(__('Click to Activate ', 'event_espresso')) |
|
608 | + ). |
|
609 | 609 | EEH_HTML::td( |
610 | 610 | EEH_HTML::link( |
611 | 611 | EE_Admin_Page::add_query_args_and_nonce( |
@@ -617,7 +617,7 @@ discard block |
||
617 | 617 | ), |
618 | 618 | $link_text_and_title, |
619 | 619 | $link_text_and_title, |
620 | - 'activate_' . $payment_method->slug(), |
|
620 | + 'activate_'.$payment_method->slug(), |
|
621 | 621 | 'espresso-button-green button-primary' |
622 | 622 | ) |
623 | 623 | ) |
@@ -638,9 +638,9 @@ discard block |
||
638 | 638 | protected function _fine_print() { |
639 | 639 | return new EE_Form_Section_HTML( |
640 | 640 | EEH_HTML::tr( |
641 | - EEH_HTML::th() . |
|
641 | + EEH_HTML::th(). |
|
642 | 642 | EEH_HTML::td( |
643 | - EEH_HTML::p( __( 'All fields marked with a * are required fields', 'event_espresso' ), '', 'grey-text' ) |
|
643 | + EEH_HTML::p(__('All fields marked with a * are required fields', 'event_espresso'), '', 'grey-text') |
|
644 | 644 | ) |
645 | 645 | ) |
646 | 646 | ); |
@@ -652,15 +652,15 @@ discard block |
||
652 | 652 | * Activates a payment method of that type. Mostly assuming there is only 1 of that type (or none so far) |
653 | 653 | * @global WP_User $current_user |
654 | 654 | */ |
655 | - protected function _activate_payment_method(){ |
|
656 | - if(isset($this->_req_data['payment_method_type'])){ |
|
655 | + protected function _activate_payment_method() { |
|
656 | + if (isset($this->_req_data['payment_method_type'])) { |
|
657 | 657 | $payment_method_type = sanitize_text_field($this->_req_data['payment_method_type']); |
658 | 658 | //see if one exists |
659 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
660 | - $payment_method = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( $payment_method_type ); |
|
659 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
660 | + $payment_method = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type($payment_method_type); |
|
661 | 661 | |
662 | - $this->_redirect_after_action(1, 'Payment Method', 'activated', array('action' => 'default','payment_method'=>$payment_method->slug())); |
|
663 | - }else{ |
|
662 | + $this->_redirect_after_action(1, 'Payment Method', 'activated', array('action' => 'default', 'payment_method'=>$payment_method->slug())); |
|
663 | + } else { |
|
664 | 664 | $this->_redirect_after_action(FALSE, 'Payment Method', 'activated', array('action' => 'default')); |
665 | 665 | } |
666 | 666 | } |
@@ -668,14 +668,14 @@ discard block |
||
668 | 668 | /** |
669 | 669 | * Deactivates the payment method with the specified slug, and redirects. |
670 | 670 | */ |
671 | - protected function _deactivate_payment_method(){ |
|
672 | - if(isset($this->_req_data['payment_method'])){ |
|
671 | + protected function _deactivate_payment_method() { |
|
672 | + if (isset($this->_req_data['payment_method'])) { |
|
673 | 673 | $payment_method_slug = sanitize_key($this->_req_data['payment_method']); |
674 | 674 | //deactivate it |
675 | 675 | EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
676 | - $count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method( $payment_method_slug ); |
|
677 | - $this->_redirect_after_action($count_updated, 'Payment Method', 'deactivated', array('action' => 'default','payment_method'=>$payment_method_slug)); |
|
678 | - }else{ |
|
676 | + $count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method($payment_method_slug); |
|
677 | + $this->_redirect_after_action($count_updated, 'Payment Method', 'deactivated', array('action' => 'default', 'payment_method'=>$payment_method_slug)); |
|
678 | + } else { |
|
679 | 679 | $this->_redirect_after_action(FALSE, 'Payment Method', 'deactivated', array('action' => 'default')); |
680 | 680 | } |
681 | 681 | } |
@@ -689,39 +689,39 @@ discard block |
||
689 | 689 | * subsequently called 'headers_sent_func' which is _payment_methods_list) |
690 | 690 | * @return void |
691 | 691 | */ |
692 | - protected function _update_payment_method(){ |
|
693 | - if( $_SERVER['REQUEST_METHOD'] == 'POST'){ |
|
692 | + protected function _update_payment_method() { |
|
693 | + if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
694 | 694 | //ok let's find which gateway form to use based on the form input |
695 | 695 | EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
696 | 696 | /** @var $correct_pmt_form_to_use EE_Payment_Method_Form */ |
697 | 697 | $correct_pmt_form_to_use = NULL; |
698 | 698 | $pmt_obj = NULL; |
699 | - foreach(EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj){ |
|
699 | + foreach (EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj) { |
|
700 | 700 | /** @var $pmt_obj EE_PMT_Base */ |
701 | 701 | //get the form and simplify it, like what we do when we display it |
702 | 702 | $pmt_form = $pmt_obj->settings_form(); |
703 | 703 | $this->_simplify_form($pmt_form); |
704 | - if($pmt_form->form_data_present_in($this->_req_data)){ |
|
704 | + if ($pmt_form->form_data_present_in($this->_req_data)) { |
|
705 | 705 | $correct_pmt_form_to_use = $pmt_form; |
706 | 706 | break; |
707 | 707 | } |
708 | 708 | } |
709 | 709 | //if we couldn't find the correct payment method type... |
710 | - if( ! $correct_pmt_form_to_use ){ |
|
710 | + if ( ! $correct_pmt_form_to_use) { |
|
711 | 711 | EE_Error::add_error(__("We could not find which payment method type your form submission related to. Please contact support", 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
712 | 712 | $this->_redirect_after_action(FALSE, 'Payment Method', 'activated', array('action' => 'default')); |
713 | 713 | } |
714 | 714 | $correct_pmt_form_to_use->receive_form_submission($this->_req_data); |
715 | - if($correct_pmt_form_to_use->is_valid()){ |
|
715 | + if ($correct_pmt_form_to_use->is_valid()) { |
|
716 | 716 | $correct_pmt_form_to_use->save(); |
717 | 717 | $pm = $correct_pmt_form_to_use->get_model_object(); |
718 | 718 | /** @var $pm EE_Payment_Method */ |
719 | - $this->_redirect_after_action(TRUE, 'Payment Method', 'updated', array('action' => 'default','payment_method'=>$pm->slug())); |
|
720 | - }else{ |
|
719 | + $this->_redirect_after_action(TRUE, 'Payment Method', 'updated', array('action' => 'default', 'payment_method'=>$pm->slug())); |
|
720 | + } else { |
|
721 | 721 | EE_Error::add_error( |
722 | 722 | sprintf( |
723 | 723 | __('Payment method of type %s was not saved because there were validation errors. They have been marked in the form', 'event_espresso'), |
724 | - $pmt_obj instanceof EE_PMT_Base ? $pmt_obj->pretty_name() : __( '"(unknown)"', 'event_espresso' ) |
|
724 | + $pmt_obj instanceof EE_PMT_Base ? $pmt_obj->pretty_name() : __('"(unknown)"', 'event_espresso') |
|
725 | 725 | ), |
726 | 726 | __FILE__, |
727 | 727 | __FUNCTION__, |
@@ -738,11 +738,11 @@ discard block |
||
738 | 738 | protected function _payment_settings() { |
739 | 739 | |
740 | 740 | $this->_template_args['values'] = $this->_yes_no_values; |
741 | - $this->_template_args['show_pending_payment_options'] = isset( EE_Registry::instance()->CFG->registration->show_pending_payment_options ) ? absint( EE_Registry::instance()->CFG->registration->show_pending_payment_options ) : FALSE; |
|
741 | + $this->_template_args['show_pending_payment_options'] = isset(EE_Registry::instance()->CFG->registration->show_pending_payment_options) ? absint(EE_Registry::instance()->CFG->registration->show_pending_payment_options) : FALSE; |
|
742 | 742 | |
743 | - $this->_set_add_edit_form_tags( 'update_payment_settings' ); |
|
744 | - $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
|
745 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( EE_PAYMENTS_TEMPLATE_PATH . 'payment_settings.template.php', $this->_template_args, TRUE ); |
|
743 | + $this->_set_add_edit_form_tags('update_payment_settings'); |
|
744 | + $this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE); |
|
745 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template(EE_PAYMENTS_TEMPLATE_PATH.'payment_settings.template.php', $this->_template_args, TRUE); |
|
746 | 746 | $this->display_admin_page_with_sidebar(); |
747 | 747 | |
748 | 748 | } |
@@ -756,13 +756,13 @@ discard block |
||
756 | 756 | * @return array |
757 | 757 | */ |
758 | 758 | protected function _update_payment_settings() { |
759 | - EE_Registry::instance()->CFG->registration->show_pending_payment_options = isset( $this->_req_data['show_pending_payment_options'] ) ? $this->_req_data['show_pending_payment_options'] : FALSE; |
|
760 | - EE_Registry::instance()->CFG = apply_filters( 'FHEE__Payments_Admin_Page___update_payment_settings__CFG', EE_Registry::instance()->CFG ); |
|
759 | + EE_Registry::instance()->CFG->registration->show_pending_payment_options = isset($this->_req_data['show_pending_payment_options']) ? $this->_req_data['show_pending_payment_options'] : FALSE; |
|
760 | + EE_Registry::instance()->CFG = apply_filters('FHEE__Payments_Admin_Page___update_payment_settings__CFG', EE_Registry::instance()->CFG); |
|
761 | 761 | |
762 | 762 | |
763 | - $what = __('Payment Settings','event_espresso'); |
|
764 | - $success = $this->_update_espresso_configuration( $what, EE_Registry::instance()->CFG, __FILE__, __FUNCTION__, __LINE__ ); |
|
765 | - $this->_redirect_after_action( $success, $what, __('updated','event_espresso'), array( 'action' => 'payment_settings' ) ); |
|
763 | + $what = __('Payment Settings', 'event_espresso'); |
|
764 | + $success = $this->_update_espresso_configuration($what, EE_Registry::instance()->CFG, __FILE__, __FUNCTION__, __LINE__); |
|
765 | + $this->_redirect_after_action($success, $what, __('updated', 'event_espresso'), array('action' => 'payment_settings')); |
|
766 | 766 | |
767 | 767 | } |
768 | 768 | protected function _payment_log_overview_list_table() { |
@@ -788,18 +788,18 @@ discard block |
||
788 | 788 | * @param bool $count |
789 | 789 | * @return array |
790 | 790 | */ |
791 | - public function get_payment_logs($per_page = 50, $current_page = 0, $count = false){ |
|
792 | - EE_Registry::instance()->load_model( 'Change_Log' ); |
|
791 | + public function get_payment_logs($per_page = 50, $current_page = 0, $count = false) { |
|
792 | + EE_Registry::instance()->load_model('Change_Log'); |
|
793 | 793 | //we may need to do multiple queries (joining differently), so we actually wan tan array of query params |
794 | - $query_params = array(array('LOG_type'=> EEM_Change_Log::type_gateway)); |
|
794 | + $query_params = array(array('LOG_type'=> EEM_Change_Log::type_gateway)); |
|
795 | 795 | //check if they've selected a specific payment method |
796 | - if( isset($this->_req_data['_payment_method']) && $this->_req_data['_payment_method'] !== 'all'){ |
|
796 | + if (isset($this->_req_data['_payment_method']) && $this->_req_data['_payment_method'] !== 'all') { |
|
797 | 797 | $query_params[0]['OR*pm_or_pay_pm'] = array('Payment.Payment_Method.PMD_ID'=>$this->_req_data['_payment_method'], |
798 | 798 | 'Payment_Method.PMD_ID'=>$this->_req_data['_payment_method']); |
799 | 799 | } |
800 | 800 | //take into account search |
801 | - if(isset($this->_req_data['s']) && $this->_req_data['s']){ |
|
802 | - $similarity_string = array('LIKE','%'.str_replace("","%",$this->_req_data['s']) .'%'); |
|
801 | + if (isset($this->_req_data['s']) && $this->_req_data['s']) { |
|
802 | + $similarity_string = array('LIKE', '%'.str_replace("", "%", $this->_req_data['s']).'%'); |
|
803 | 803 | $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_fname'] = $similarity_string; |
804 | 804 | $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_lname'] = $similarity_string; |
805 | 805 | $query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_email'] = $similarity_string; |
@@ -814,48 +814,48 @@ discard block |
||
814 | 814 | $query_params[0]['OR*s']['LOG_message'] = $similarity_string; |
815 | 815 | |
816 | 816 | } |
817 | - if(isset( $this->_req_data['payment-filter-start-date'] ) && isset( $this->_req_data['payment-filter-end-date'] )){ |
|
817 | + if (isset($this->_req_data['payment-filter-start-date']) && isset($this->_req_data['payment-filter-end-date'])) { |
|
818 | 818 | //add date |
819 | - $start_date =wp_strip_all_tags( $this->_req_data['payment-filter-start-date'] ); |
|
820 | - $end_date = wp_strip_all_tags( $this->_req_data['payment-filter-end-date'] ); |
|
819 | + $start_date = wp_strip_all_tags($this->_req_data['payment-filter-start-date']); |
|
820 | + $end_date = wp_strip_all_tags($this->_req_data['payment-filter-end-date']); |
|
821 | 821 | //make sure our timestamps start and end right at the boundaries for each day |
822 | - $start_date = date( 'Y-m-d', strtotime( $start_date ) ) . ' 00:00:00'; |
|
823 | - $end_date = date( 'Y-m-d', strtotime( $end_date ) ) . ' 23:59:59'; |
|
822 | + $start_date = date('Y-m-d', strtotime($start_date)).' 00:00:00'; |
|
823 | + $end_date = date('Y-m-d', strtotime($end_date)).' 23:59:59'; |
|
824 | 824 | |
825 | 825 | //convert to timestamps |
826 | - $start_date = strtotime( $start_date ); |
|
827 | - $end_date = strtotime( $end_date ); |
|
826 | + $start_date = strtotime($start_date); |
|
827 | + $end_date = strtotime($end_date); |
|
828 | 828 | |
829 | 829 | //makes sure start date is the lowest value and vice versa |
830 | - $start_date = min( $start_date, $end_date ); |
|
831 | - $end_date = max( $start_date, $end_date ); |
|
830 | + $start_date = min($start_date, $end_date); |
|
831 | + $end_date = max($start_date, $end_date); |
|
832 | 832 | |
833 | 833 | //convert for query |
834 | - $start_date = EEM_Change_Log::instance()->convert_datetime_for_query( 'LOG_time', date( 'Y-m-d H:i:s', $start_date ), 'Y-m-d H:i:s' ); |
|
835 | - $end_date = EEM_Change_Log::instance()->convert_datetime_for_query( 'LOG_time', date( 'Y-m-d H:i:s', $end_date ), 'Y-m-d H:i:s' ); |
|
834 | + $start_date = EEM_Change_Log::instance()->convert_datetime_for_query('LOG_time', date('Y-m-d H:i:s', $start_date), 'Y-m-d H:i:s'); |
|
835 | + $end_date = EEM_Change_Log::instance()->convert_datetime_for_query('LOG_time', date('Y-m-d H:i:s', $end_date), 'Y-m-d H:i:s'); |
|
836 | 836 | |
837 | - $query_params[0]['LOG_time'] = array('BETWEEN',array($start_date,$end_date)); |
|
837 | + $query_params[0]['LOG_time'] = array('BETWEEN', array($start_date, $end_date)); |
|
838 | 838 | |
839 | 839 | } |
840 | - if($count){ |
|
840 | + if ($count) { |
|
841 | 841 | return EEM_Change_Log::instance()->count($query_params); |
842 | 842 | } |
843 | - if(isset($this->_req_data['order'])){ |
|
844 | - $sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'DESC'; |
|
843 | + if (isset($this->_req_data['order'])) { |
|
844 | + $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'DESC'; |
|
845 | 845 | $query_params['order_by'] = array('LOG_time' => $sort); |
846 | - }else{ |
|
846 | + } else { |
|
847 | 847 | $query_params['order_by'] = array('LOG_time' => 'DESC'); |
848 | 848 | } |
849 | - $offset = ($current_page-1)*$per_page; |
|
849 | + $offset = ($current_page - 1) * $per_page; |
|
850 | 850 | |
851 | - if( ! isset($this->_req_data['download_results'])){ |
|
852 | - $query_params['limit'] = array( $offset, $per_page ); |
|
851 | + if ( ! isset($this->_req_data['download_results'])) { |
|
852 | + $query_params['limit'] = array($offset, $per_page); |
|
853 | 853 | } |
854 | 854 | |
855 | 855 | |
856 | 856 | |
857 | 857 | //now they've requested to instead just download the file instead of viewing it. |
858 | - if(isset($this->_req_data['download_results'])){ |
|
858 | + if (isset($this->_req_data['download_results'])) { |
|
859 | 859 | $wpdb_results = EEM_Change_Log::instance()->get_all_efficiently($query_params); |
860 | 860 | header('Content-Disposition: attachment'); |
861 | 861 | header("Content-Disposition: attachment; filename=ee_payment_logs_for_".sanitize_key(site_url())); |
@@ -877,36 +877,36 @@ discard block |
||
877 | 877 | * @param EE_Change_Log $logB |
878 | 878 | * @return int |
879 | 879 | */ |
880 | - protected function _sort_logs_again($logA,$logB){ |
|
880 | + protected function _sort_logs_again($logA, $logB) { |
|
881 | 881 | $timeA = $logA->get_raw('LOG_time'); |
882 | 882 | $timeB = $logB->get_raw('LOG_time'); |
883 | - if($timeA == $timeB){ |
|
883 | + if ($timeA == $timeB) { |
|
884 | 884 | return 0; |
885 | 885 | } |
886 | 886 | $comparison = $timeA < $timeB ? -1 : 1; |
887 | - if(strtoupper($this->_sort_logs_again_direction) == 'DESC'){ |
|
887 | + if (strtoupper($this->_sort_logs_again_direction) == 'DESC') { |
|
888 | 888 | return $comparison * -1; |
889 | - }else{ |
|
889 | + } else { |
|
890 | 890 | return $comparison; |
891 | 891 | } |
892 | 892 | } |
893 | 893 | |
894 | 894 | protected function _payment_log_details() { |
895 | - EE_Registry::instance()->load_model( 'Change_Log' ); |
|
895 | + EE_Registry::instance()->load_model('Change_Log'); |
|
896 | 896 | /** @var $payment_log EE_Change_Log */ |
897 | 897 | $payment_log = EEM_Change_Log::instance()->get_one_by_ID($this->_req_data['ID']); |
898 | 898 | $payment_method = NULL; |
899 | 899 | $transaction = NULL; |
900 | - if( $payment_log instanceof EE_Change_Log ){ |
|
901 | - if( $payment_log->object() instanceof EE_Payment ){ |
|
900 | + if ($payment_log instanceof EE_Change_Log) { |
|
901 | + if ($payment_log->object() instanceof EE_Payment) { |
|
902 | 902 | $payment_method = $payment_log->object()->payment_method(); |
903 | 903 | $transaction = $payment_log->object()->transaction(); |
904 | - }elseif($payment_log->object() instanceof EE_Payment_Method){ |
|
904 | + }elseif ($payment_log->object() instanceof EE_Payment_Method) { |
|
905 | 905 | $payment_method = $payment_log->object(); |
906 | 906 | } |
907 | 907 | } |
908 | 908 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
909 | - EE_PAYMENTS_TEMPLATE_PATH . 'payment_log_details.template.php', |
|
909 | + EE_PAYMENTS_TEMPLATE_PATH.'payment_log_details.template.php', |
|
910 | 910 | array( |
911 | 911 | 'payment_log'=>$payment_log, |
912 | 912 | 'payment_method'=>$payment_method, |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -46,22 +46,22 @@ discard block |
||
46 | 46 | * @return string the assembled html string containing the tabbed content for display. |
47 | 47 | * @throws \EE_Error |
48 | 48 | */ |
49 | - public static function display($tabs_contents, $tabs_names = array(), $small_tabs = true, $tabs_content = TRUE ) { |
|
49 | + public static function display($tabs_contents, $tabs_names = array(), $small_tabs = true, $tabs_content = TRUE) { |
|
50 | 50 | |
51 | 51 | //first check if $tabs_names is not empty then the count must match the count of $tabs_content otherwise we've got a problem houston |
52 | - if ( !empty( $tabs_names) && ( count( (array) $tabs_names) != count( (array) $tabs_content) ) ) { |
|
53 | - throw new EE_Error( __('The count for $tabs_names and $tabs_content does not match.', 'event_espresso') ); |
|
52 | + if ( ! empty($tabs_names) && (count((array) $tabs_names) != count((array) $tabs_content))) { |
|
53 | + throw new EE_Error(__('The count for $tabs_names and $tabs_content does not match.', 'event_espresso')); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | //make sure we've got incoming data setup properly |
57 | - $tabs = !empty( $tabs_names ) ? (array) $tabs_names : array_keys( (array) $tabs_contents ); |
|
58 | - $tabs_content = !empty( $tabs_names ) ? array_combine( (array) $tabs_names, (array) $tabs_content ) : $tabs_contents; |
|
57 | + $tabs = ! empty($tabs_names) ? (array) $tabs_names : array_keys((array) $tabs_contents); |
|
58 | + $tabs_content = ! empty($tabs_names) ? array_combine((array) $tabs_names, (array) $tabs_content) : $tabs_contents; |
|
59 | 59 | |
60 | - $all_tabs = '<h2 class="nav-tab-wrapper">' . "\n"; |
|
60 | + $all_tabs = '<h2 class="nav-tab-wrapper">'."\n"; |
|
61 | 61 | $all_tabs_content = ''; |
62 | 62 | |
63 | 63 | $index = 0; |
64 | - foreach ( $tabs as $tab ) { |
|
64 | + foreach ($tabs as $tab) { |
|
65 | 65 | $active = $index === 0 ? true : false; |
66 | 66 | $all_tabs .= self::tab($tab, $active); |
67 | 67 | $all_tabs_content .= self::tab_content($tab, $tabs_content[$tab], $active); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | |
79 | 79 | $tab_container_class = $small_tabs ? 'ee-nav-tabs ee-nav-tabs-small' : 'ee-nav-tabs'; |
80 | 80 | |
81 | - return '<div class="'. $tab_container_class . '">' . "\n\t" . $all_tabs . $all_tabs_content . "\n" . '</div>'; |
|
81 | + return '<div class="'.$tab_container_class.'">'."\n\t".$all_tabs.$all_tabs_content."\n".'</div>'; |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | |
@@ -102,11 +102,11 @@ discard block |
||
102 | 102 | * @throws \EE_Error |
103 | 103 | */ |
104 | 104 | public static function display_admin_nav_tabs($nav_tabs = array()) { |
105 | - if ( empty($nav_tabs) ) |
|
106 | - throw new EE_Error( __('Nav Tabs cannot be generated because the tab array is missing', 'event_espresso' ) ); |
|
105 | + if (empty($nav_tabs)) |
|
106 | + throw new EE_Error(__('Nav Tabs cannot be generated because the tab array is missing', 'event_espresso')); |
|
107 | 107 | |
108 | - $all_tabs = '<h2 class="nav-tab-wrapper">' . "\n"; |
|
109 | - foreach ( $nav_tabs as $slug => $tab ) { |
|
108 | + $all_tabs = '<h2 class="nav-tab-wrapper">'."\n"; |
|
109 | + foreach ($nav_tabs as $slug => $tab) { |
|
110 | 110 | $all_tabs .= self::tab($slug, false, $tab['link_text'], $tab['url'], $tab['css_class']); |
111 | 111 | } |
112 | 112 | $all_tabs .= '</h2>'; |
@@ -122,13 +122,13 @@ discard block |
||
122 | 122 | * @param bool|string $css If string given then the generated tab will include that as the class. |
123 | 123 | * @return string html for tab |
124 | 124 | */ |
125 | - private static function tab($name, $active = false, $nice_name = FALSE, $url = FALSE, $css = FALSE ) { |
|
125 | + private static function tab($name, $active = false, $nice_name = FALSE, $url = FALSE, $css = FALSE) { |
|
126 | 126 | $name = str_replace(' ', '-', $name); |
127 | 127 | $class = $active ? 'nav-tab nav-tab-active' : 'nav-tab'; |
128 | - $class = $css ? $class . ' ' . $css : $class; |
|
129 | - $nice_name = $nice_name ? $nice_name : ucwords( preg_replace('/(-|_)/', ' ', $name) ); |
|
130 | - $url = $url ? $url : '#' . $name; |
|
131 | - $tab = '<a class="' . $class . '" rel="ee-tab-' . $name . '" href="' . $url . '">' . $nice_name . '</a>' . "\n\t"; |
|
128 | + $class = $css ? $class.' '.$css : $class; |
|
129 | + $nice_name = $nice_name ? $nice_name : ucwords(preg_replace('/(-|_)/', ' ', $name)); |
|
130 | + $url = $url ? $url : '#'.$name; |
|
131 | + $tab = '<a class="'.$class.'" rel="ee-tab-'.$name.'" href="'.$url.'">'.$nice_name.'</a>'."\n\t"; |
|
132 | 132 | return $tab; |
133 | 133 | } |
134 | 134 | |
@@ -144,9 +144,9 @@ discard block |
||
144 | 144 | */ |
145 | 145 | private static function tab_content($name, $tab_content, $active = false) { |
146 | 146 | $class = $active ? 'nav-tab-content' : 'nav-tab-content hidden'; |
147 | - $name = str_replace( ' ', '-', $name); |
|
148 | - $content = "\t" . '<div class="'. $class . '" id="ee-tab-' . $name . '">' . "\n"; |
|
149 | - $content .= "\t" . $tab_content . "\n"; |
|
147 | + $name = str_replace(' ', '-', $name); |
|
148 | + $content = "\t".'<div class="'.$class.'" id="ee-tab-'.$name.'">'."\n"; |
|
149 | + $content .= "\t".$tab_content."\n"; |
|
150 | 150 | $content .= '<div style="clear:both"></div></div>'; |
151 | 151 | return $content; |
152 | 152 | } |
@@ -172,9 +172,9 @@ discard block |
||
172 | 172 | * @param string $default You can include a string for the item that will receive the "item_display" class for the js. |
173 | 173 | * @return string a html snippet of of all the formatted link elements. |
174 | 174 | */ |
175 | - public static function tab_text_links( $item_array, $container_class = '', $sep = '|', $default = '' ) { |
|
176 | - $item_array = apply_filters( 'FHEE__EEH_Tabbed_Content__tab_text_links', $item_array, $container_class ); |
|
177 | - if ( !is_array($item_array) || empty( $item_array ) ) |
|
175 | + public static function tab_text_links($item_array, $container_class = '', $sep = '|', $default = '') { |
|
176 | + $item_array = apply_filters('FHEE__EEH_Tabbed_Content__tab_text_links', $item_array, $container_class); |
|
177 | + if ( ! is_array($item_array) || empty($item_array)) |
|
178 | 178 | return false; //get out we don't have even the basic thing we need! |
179 | 179 | |
180 | 180 | |
@@ -185,15 +185,15 @@ discard block |
||
185 | 185 | 'title' => esc_attr__('Link for Item', 'event_espresso'), |
186 | 186 | 'slug' => 'item_slug' |
187 | 187 | ); |
188 | - $container_class = !empty($container_class) ? 'ee-text-links ' . $container_class : 'ee-text-links'; |
|
189 | - $list = '<ul class="' . $container_class . '">'; |
|
188 | + $container_class = ! empty($container_class) ? 'ee-text-links '.$container_class : 'ee-text-links'; |
|
189 | + $list = '<ul class="'.$container_class.'">'; |
|
190 | 190 | |
191 | 191 | $ci = 1; |
192 | - foreach ( $item_array as $item ) { |
|
193 | - $item = wp_parse_args( $item, $defaults ); |
|
194 | - $item['class'] = !empty($default) && $default == $item['slug'] ? 'item_display ' . $item['class'] : $item['class']; |
|
192 | + foreach ($item_array as $item) { |
|
193 | + $item = wp_parse_args($item, $defaults); |
|
194 | + $item['class'] = ! empty($default) && $default == $item['slug'] ? 'item_display '.$item['class'] : $item['class']; |
|
195 | 195 | $list .= self::_text_link_item($item); |
196 | - if ( !empty($sep) && $ci != count($item_array) ) |
|
196 | + if ( ! empty($sep) && $ci != count($item_array)) |
|
197 | 197 | $list .= self::_text_link_item($sep); |
198 | 198 | $ci++; |
199 | 199 | } |
@@ -204,9 +204,9 @@ discard block |
||
204 | 204 | |
205 | 205 | |
206 | 206 | |
207 | - private static function _text_link_item( $item ) { |
|
207 | + private static function _text_link_item($item) { |
|
208 | 208 | //if this isn't an array then we're doing a separator |
209 | - if ( !is_array( $item ) ) { |
|
209 | + if ( ! is_array($item)) { |
|
210 | 210 | $label = $item; |
211 | 211 | $class = 'ee-text-link-sep'; |
212 | 212 | $href = ''; |
@@ -215,12 +215,12 @@ discard block |
||
215 | 215 | extract($item); |
216 | 216 | } |
217 | 217 | |
218 | - $class = $class != 'ee-text-link-sep' ? 'class="ee-text-link-li ' . $class . '"' : 'class="ee-text-link-sep"'; |
|
218 | + $class = $class != 'ee-text-link-sep' ? 'class="ee-text-link-li '.$class.'"' : 'class="ee-text-link-sep"'; |
|
219 | 219 | |
220 | - $content = '<li ' . $class . '>'; |
|
221 | - $content .= !empty($href) ? '<a class="ee-text-link" href="#' . $href . '" title="' . $title . '">' : ''; |
|
220 | + $content = '<li '.$class.'>'; |
|
221 | + $content .= ! empty($href) ? '<a class="ee-text-link" href="#'.$href.'" title="'.$title.'">' : ''; |
|
222 | 222 | $content .= $label; |
223 | - $content .= !empty($href) ? '</a>' : ''; |
|
223 | + $content .= ! empty($href) ? '</a>' : ''; |
|
224 | 224 | $content .= '</li>'; |
225 | 225 | return $content; |
226 | 226 | } |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -513,7 +515,7 @@ discard block |
||
513 | 515 | |
514 | 516 | if($count){ |
515 | 517 | return EEM_Price::instance()->count_deleted_and_undeleted(array($_where)); |
516 | - }else{ |
|
518 | + } else{ |
|
517 | 519 | return EEM_Price::instance()->get_all_deleted_and_undeleted($query_params); |
518 | 520 | } |
519 | 521 | } |
@@ -943,7 +945,7 @@ discard block |
||
943 | 945 | 'limit'=>$limit); |
944 | 946 | if($count){ |
945 | 947 | return EEM_Price_Type::instance()->count_deleted_and_undeleted($query_params); |
946 | - }else{ |
|
948 | + } else{ |
|
947 | 949 | return EEM_Price_Type::instance()->get_all_deleted_and_undeleted($query_params); |
948 | 950 | } |
949 | 951 |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public static function instance() { |
37 | 37 | // check if class object is instantiated, and instantiated properly |
38 | - if ( ! self::$_instance instanceof EE_Payment_Method_Manager ) { |
|
38 | + if ( ! self::$_instance instanceof EE_Payment_Method_Manager) { |
|
39 | 39 | self::$_instance = new self(); |
40 | 40 | } |
41 | 41 | EE_Registry::instance()->load_lib('PMT_Base'); |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * Resets the instance and returns a new one |
47 | 47 | * @return EE_Payment_Method_Manager |
48 | 48 | */ |
49 | - public static function reset(){ |
|
49 | + public static function reset() { |
|
50 | 50 | self::$_instance = NULL; |
51 | 51 | return self::instance(); |
52 | 52 | } |
@@ -57,12 +57,12 @@ discard block |
||
57 | 57 | * or just re-use the PMTs we found last time we checked during this request (if |
58 | 58 | * we have not yet checked during this request, then we need to check anyways) |
59 | 59 | */ |
60 | - public function maybe_register_payment_methods( $force_recheck = FALSE ){ |
|
61 | - if( ! $this->_payment_method_types || $force_recheck ){ |
|
60 | + public function maybe_register_payment_methods($force_recheck = FALSE) { |
|
61 | + if ( ! $this->_payment_method_types || $force_recheck) { |
|
62 | 62 | $this->_register_payment_methods(); |
63 | 63 | //if in admin lets ensure caps are set. |
64 | - if ( is_admin() ) { |
|
65 | - add_filter( 'FHEE__EE_Capabilities__init_caps_map__caps', array( $this, 'add_payment_method_caps' ) ); |
|
64 | + if (is_admin()) { |
|
65 | + add_filter('FHEE__EE_Capabilities__init_caps_map__caps', array($this, 'add_payment_method_caps')); |
|
66 | 66 | EE_Registry::instance()->CAP->init_caps(); |
67 | 67 | } |
68 | 68 | } |
@@ -75,19 +75,19 @@ discard block |
||
75 | 75 | */ |
76 | 76 | protected function _register_payment_methods() { |
77 | 77 | // grab list of installed modules |
78 | - $pm_to_register = glob( EE_PAYMENT_METHODS . '*', GLOB_ONLYDIR ); |
|
78 | + $pm_to_register = glob(EE_PAYMENT_METHODS.'*', GLOB_ONLYDIR); |
|
79 | 79 | // filter list of modules to register |
80 | - $pm_to_register = apply_filters( 'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register', $pm_to_register ); |
|
80 | + $pm_to_register = apply_filters('FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register', $pm_to_register); |
|
81 | 81 | |
82 | 82 | // loop through folders |
83 | - foreach ( $pm_to_register as $pm_path ) { |
|
84 | - $this->register_payment_method( $pm_path ); |
|
83 | + foreach ($pm_to_register as $pm_path) { |
|
84 | + $this->register_payment_method($pm_path); |
|
85 | 85 | } |
86 | - do_action( 'FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods' ); |
|
86 | + do_action('FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods'); |
|
87 | 87 | // filter list of installed modules |
88 | 88 | //keep them organized alphabetically by the payment method type's name |
89 | - ksort( $this->_payment_method_types ); |
|
90 | - return apply_filters( 'FHEE__EE_Payment_Method_Manager__register_payment_methods__installed_payment_methods', $this->_payment_method_types ); |
|
89 | + ksort($this->_payment_method_types); |
|
90 | + return apply_filters('FHEE__EE_Payment_Method_Manager__register_payment_methods__installed_payment_methods', $this->_payment_method_types); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | |
@@ -99,35 +99,35 @@ discard block |
||
99 | 99 | * @param string $payment_method_path - full path up to and including payment method folder |
100 | 100 | * @return boolean |
101 | 101 | */ |
102 | - public function register_payment_method( $payment_method_path = '' ) { |
|
103 | - do_action( 'AHEE__EE_Payment_Method_Manager__register_payment_method__begin',$payment_method_path ); |
|
102 | + public function register_payment_method($payment_method_path = '') { |
|
103 | + do_action('AHEE__EE_Payment_Method_Manager__register_payment_method__begin', $payment_method_path); |
|
104 | 104 | $module_ext = '.pm.php'; |
105 | 105 | // make all separators match |
106 | - $payment_method_path = rtrim( str_replace( '/\\', DS, $payment_method_path ), DS ); |
|
106 | + $payment_method_path = rtrim(str_replace('/\\', DS, $payment_method_path), DS); |
|
107 | 107 | // grab and sanitize module name |
108 | - $module_dir = basename( $payment_method_path ); |
|
108 | + $module_dir = basename($payment_method_path); |
|
109 | 109 | // create classname from module directory name |
110 | - $module = str_replace( ' ', '_', str_replace( '_', ' ', $module_dir )); |
|
110 | + $module = str_replace(' ', '_', str_replace('_', ' ', $module_dir)); |
|
111 | 111 | // add class prefix |
112 | - $module_class = 'EE_PMT_' . $module; |
|
112 | + $module_class = 'EE_PMT_'.$module; |
|
113 | 113 | // does the module exist ? |
114 | - if ( ! is_readable( $payment_method_path . DS . $module_class . $module_ext )) { |
|
115 | - $msg = sprintf( __( 'The requested %s payment method file could not be found or is not readable due to file permissions.', 'event_espresso' ), $module ); |
|
116 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
114 | + if ( ! is_readable($payment_method_path.DS.$module_class.$module_ext)) { |
|
115 | + $msg = sprintf(__('The requested %s payment method file could not be found or is not readable due to file permissions.', 'event_espresso'), $module); |
|
116 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
117 | 117 | return FALSE; |
118 | 118 | } |
119 | - if ( WP_DEBUG === TRUE ) { EEH_Debug_Tools::instance()->start_timer(); } |
|
119 | + if (WP_DEBUG === TRUE) { EEH_Debug_Tools::instance()->start_timer(); } |
|
120 | 120 | // load the module class file |
121 | - require_once( $payment_method_path . DS . $module_class . $module_ext ); |
|
122 | - if ( WP_DEBUG === TRUE ) { EEH_Debug_Tools::instance()->stop_timer("Requiring payment method $module_class"); } |
|
121 | + require_once($payment_method_path.DS.$module_class.$module_ext); |
|
122 | + if (WP_DEBUG === TRUE) { EEH_Debug_Tools::instance()->stop_timer("Requiring payment method $module_class"); } |
|
123 | 123 | // verify that class exists |
124 | - if ( ! class_exists( $module_class )) { |
|
125 | - $msg = sprintf( __( 'The requested %s module class does not exist.', 'event_espresso' ), $module_class ); |
|
126 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
124 | + if ( ! class_exists($module_class)) { |
|
125 | + $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class); |
|
126 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
127 | 127 | return FALSE; |
128 | 128 | } |
129 | 129 | // add to array of registered modules |
130 | - $this->_payment_method_types[ $module ] = $payment_method_path . DS . $module_class . $module_ext; |
|
130 | + $this->_payment_method_types[$module] = $payment_method_path.DS.$module_class.$module_ext; |
|
131 | 131 | return TRUE; |
132 | 132 | } |
133 | 133 | /** |
@@ -136,15 +136,15 @@ discard block |
||
136 | 136 | * @param boolean $force_recheck whether to force re-checking for new payment method types |
137 | 137 | * @return boolean |
138 | 138 | */ |
139 | - public function payment_method_type_exists($payment_method_name, $force_recheck = FALSE){ |
|
140 | - if ( ! is_array( $this->_payment_method_types ) || ! isset( $this->_payment_method_types[$payment_method_name] ) |
|
141 | - || $force_recheck ) { |
|
139 | + public function payment_method_type_exists($payment_method_name, $force_recheck = FALSE) { |
|
140 | + if ( ! is_array($this->_payment_method_types) || ! isset($this->_payment_method_types[$payment_method_name]) |
|
141 | + || $force_recheck) { |
|
142 | 142 | $this->maybe_register_payment_methods($force_recheck); |
143 | 143 | } |
144 | - if(isset($this->_payment_method_types[$payment_method_name])){ |
|
144 | + if (isset($this->_payment_method_types[$payment_method_name])) { |
|
145 | 145 | require_once($this->_payment_method_types[$payment_method_name]); |
146 | 146 | return true; |
147 | - }else{ |
|
147 | + } else { |
|
148 | 148 | return false; |
149 | 149 | } |
150 | 150 | } |
@@ -155,16 +155,16 @@ discard block |
||
155 | 155 | * @param boolean $force_recheck whether to force re-checking for new payment method types |
156 | 156 | * @return array |
157 | 157 | */ |
158 | - public function payment_method_type_names($with_prefixes = FALSE, $force_recheck = FALSE ){ |
|
158 | + public function payment_method_type_names($with_prefixes = FALSE, $force_recheck = FALSE) { |
|
159 | 159 | $this->maybe_register_payment_methods($force_recheck); |
160 | - if($with_prefixes){ |
|
160 | + if ($with_prefixes) { |
|
161 | 161 | $classnames = array_keys($this->_payment_method_types); |
162 | 162 | $payment_methods = array(); |
163 | - foreach($classnames as $classname){ |
|
163 | + foreach ($classnames as $classname) { |
|
164 | 164 | $payment_methods[] = $this->payment_method_class_from_type($classname); |
165 | 165 | } |
166 | 166 | return $payment_methods; |
167 | - }else{ |
|
167 | + } else { |
|
168 | 168 | return array_keys($this->_payment_method_types); |
169 | 169 | } |
170 | 170 | } |
@@ -174,10 +174,10 @@ discard block |
||
174 | 174 | * @param boolean $force_recheck whether to force re-checking for new payment method types |
175 | 175 | * @return EE_PMT_Base[] |
176 | 176 | */ |
177 | - public function payment_method_types( $force_recheck = FALSE ){ |
|
177 | + public function payment_method_types($force_recheck = FALSE) { |
|
178 | 178 | $this->maybe_register_payment_methods($force_recheck); |
179 | 179 | $pmt_objs = array(); |
180 | - foreach($this->payment_method_type_names(true) as $classname){ |
|
180 | + foreach ($this->payment_method_type_names(true) as $classname) { |
|
181 | 181 | $pmt_objs[] = new $classname; |
182 | 182 | } |
183 | 183 | return $pmt_objs; |
@@ -189,8 +189,8 @@ discard block |
||
189 | 189 | * @param string $classname |
190 | 190 | * @return string |
191 | 191 | */ |
192 | - public function payment_method_type_sans_class_prefix($classname){ |
|
193 | - $pmt_name = str_replace("EE_PMT_","",$classname); |
|
192 | + public function payment_method_type_sans_class_prefix($classname) { |
|
193 | + $pmt_name = str_replace("EE_PMT_", "", $classname); |
|
194 | 194 | return $pmt_name; |
195 | 195 | } |
196 | 196 | |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | * @param string $type |
200 | 200 | * @return string |
201 | 201 | */ |
202 | - public function payment_method_class_from_type($type){ |
|
202 | + public function payment_method_class_from_type($type) { |
|
203 | 203 | $this->maybe_register_payment_methods(); |
204 | 204 | return "EE_PMT_".$type; |
205 | 205 | } |
@@ -213,38 +213,38 @@ discard block |
||
213 | 213 | * @return \EE_Payment_Method |
214 | 214 | * @throws \EE_Error |
215 | 215 | */ |
216 | - public function activate_a_payment_method_of_type( $payment_method_type ){ |
|
216 | + public function activate_a_payment_method_of_type($payment_method_type) { |
|
217 | 217 | $payment_method = EEM_Payment_Method::instance()->get_one_of_type($payment_method_type); |
218 | - if( ! $payment_method instanceof EE_Payment_Method ){ |
|
218 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
219 | 219 | $pm_type_class = $this->payment_method_class_from_type($payment_method_type); |
220 | - if(class_exists($pm_type_class)){ |
|
220 | + if (class_exists($pm_type_class)) { |
|
221 | 221 | /** @var $pm_type_obj EE_PMT_Base */ |
222 | 222 | $pm_type_obj = new $pm_type_class; |
223 | 223 | $payment_method = EEM_Payment_Method::instance()->get_one_by_slug($pm_type_obj->system_name()); |
224 | - if( ! $payment_method){ |
|
225 | - $payment_method = $this->create_payment_method_of_type( $pm_type_obj ); |
|
224 | + if ( ! $payment_method) { |
|
225 | + $payment_method = $this->create_payment_method_of_type($pm_type_obj); |
|
226 | 226 | } |
227 | - $payment_method->set_type( $payment_method_type ); |
|
228 | - $this->initialize_payment_method( $payment_method ); |
|
227 | + $payment_method->set_type($payment_method_type); |
|
228 | + $this->initialize_payment_method($payment_method); |
|
229 | 229 | } else { |
230 | 230 | throw new EE_Error( |
231 | 231 | sprintf( |
232 | - __( 'There is no payment method of type %1$s, so it could not be activated', 'event_espresso'), |
|
232 | + __('There is no payment method of type %1$s, so it could not be activated', 'event_espresso'), |
|
233 | 233 | $pm_type_class ) |
234 | 234 | ); |
235 | 235 | } |
236 | 236 | } |
237 | 237 | $payment_method->set_active(); |
238 | 238 | $payment_method->save(); |
239 | - $this->set_usable_currencies_on_payment_method( $payment_method ); |
|
240 | - if( $payment_method->type() == 'Invoice' ){ |
|
241 | - $messages = EE_Registry::instance()->load_lib( 'messages' ); |
|
242 | - $messages->ensure_message_type_is_active( 'invoice', 'html' ); |
|
243 | - $messages->ensure_messenger_is_active( 'pdf' ); |
|
239 | + $this->set_usable_currencies_on_payment_method($payment_method); |
|
240 | + if ($payment_method->type() == 'Invoice') { |
|
241 | + $messages = EE_Registry::instance()->load_lib('messages'); |
|
242 | + $messages->ensure_message_type_is_active('invoice', 'html'); |
|
243 | + $messages->ensure_messenger_is_active('pdf'); |
|
244 | 244 | EE_Error::add_attention( |
245 | 245 | sprintf( |
246 | - __( 'Note, when the invoice payment method is activated, the invoice message type, html messenger, and pdf messenger are activated as well for the %1$smessages system%2$s.', 'event_espresso' ), |
|
247 | - '<a href="' . admin_url( 'admin.php?page=espresso_messages') . '">', |
|
246 | + __('Note, when the invoice payment method is activated, the invoice message type, html messenger, and pdf messenger are activated as well for the %1$smessages system%2$s.', 'event_espresso'), |
|
247 | + '<a href="'.admin_url('admin.php?page=espresso_messages').'">', |
|
248 | 248 | '</a>' |
249 | 249 | ) |
250 | 250 | ); |
@@ -258,17 +258,17 @@ discard block |
||
258 | 258 | * @param EE_PMT_Base $pm_type_obj |
259 | 259 | * @return EE_Payment_Method |
260 | 260 | */ |
261 | - public function create_payment_method_of_type( $pm_type_obj ) { |
|
261 | + public function create_payment_method_of_type($pm_type_obj) { |
|
262 | 262 | global $current_user; |
263 | 263 | $payment_method = EE_Payment_Method::new_instance( |
264 | 264 | array( |
265 | 265 | 'PMD_type' => $pm_type_obj->system_name(), |
266 | 266 | 'PMD_name' => $pm_type_obj->pretty_name(), |
267 | 267 | 'PMD_admin_name' => $pm_type_obj->pretty_name(), |
268 | - 'PMD_slug' => $pm_type_obj->system_name(),//automatically converted to slug |
|
268 | + 'PMD_slug' => $pm_type_obj->system_name(), //automatically converted to slug |
|
269 | 269 | 'PMD_wp_user' => $current_user->ID, |
270 | 270 | 'PMD_order' => EEM_Payment_Method::instance()->count( |
271 | - array( array( 'PMD_type' => array( '!=', 'Admin_Only' ))) |
|
271 | + array(array('PMD_type' => array('!=', 'Admin_Only'))) |
|
272 | 272 | ) * 10, |
273 | 273 | ) |
274 | 274 | ); |
@@ -280,16 +280,16 @@ discard block |
||
280 | 280 | * @param EE_Payment_Method $payment_method |
281 | 281 | * @return EE_Payment_Method |
282 | 282 | */ |
283 | - public function initialize_payment_method( $payment_method ) { |
|
283 | + public function initialize_payment_method($payment_method) { |
|
284 | 284 | $pm_type_obj = $payment_method->type_obj(); |
285 | - $payment_method->set_description( $pm_type_obj->default_description() ); |
|
286 | - if( ! $payment_method->button_url() ){ |
|
287 | - $payment_method->set_button_url( $pm_type_obj->default_button_url() ); |
|
285 | + $payment_method->set_description($pm_type_obj->default_description()); |
|
286 | + if ( ! $payment_method->button_url()) { |
|
287 | + $payment_method->set_button_url($pm_type_obj->default_button_url()); |
|
288 | 288 | } |
289 | 289 | //now add setup its default extra meta properties |
290 | 290 | $extra_metas = $pm_type_obj->settings_form()->extra_meta_inputs(); |
291 | - foreach( $extra_metas as $meta_name => $input ){ |
|
292 | - $payment_method->update_extra_meta($meta_name, $input->raw_value() ); |
|
291 | + foreach ($extra_metas as $meta_name => $input) { |
|
292 | + $payment_method->update_extra_meta($meta_name, $input->raw_value()); |
|
293 | 293 | } |
294 | 294 | return $payment_method; |
295 | 295 | } |
@@ -299,8 +299,8 @@ discard block |
||
299 | 299 | * @param EE_Payment_Method $payment_method |
300 | 300 | * @return EE_Payment_Method |
301 | 301 | */ |
302 | - public function set_usable_currencies_on_payment_method( $payment_method ) { |
|
303 | - foreach($payment_method->get_all_usable_currencies() as $currency_obj){ |
|
302 | + public function set_usable_currencies_on_payment_method($payment_method) { |
|
303 | + foreach ($payment_method->get_all_usable_currencies() as $currency_obj) { |
|
304 | 304 | $payment_method->_add_relation_to($currency_obj, 'Currency'); |
305 | 305 | } |
306 | 306 | return $payment_method; |
@@ -318,8 +318,8 @@ discard block |
||
318 | 318 | * |
319 | 319 | * @return int count of rows updated. |
320 | 320 | */ |
321 | - public function deactivate_payment_method( $payment_method_slug ) { |
|
322 | - $count_updated = EEM_Payment_Method::instance()->update(array('PMD_scope'=>array()),array(array('PMD_slug'=>$payment_method_slug))); |
|
321 | + public function deactivate_payment_method($payment_method_slug) { |
|
322 | + $count_updated = EEM_Payment_Method::instance()->update(array('PMD_scope'=>array()), array(array('PMD_slug'=>$payment_method_slug))); |
|
323 | 323 | return $count_updated; |
324 | 324 | } |
325 | 325 | |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | * @param array $caps capabilities being filtered |
333 | 333 | * @return array |
334 | 334 | */ |
335 | - public function add_payment_method_caps( $caps ) { |
|
335 | + public function add_payment_method_caps($caps) { |
|
336 | 336 | /* add dynamic caps from payment methods |
337 | 337 | * at the time of writing, october 20 2014, these are the caps added: |
338 | 338 | * ee_payment_method_admin_only |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | * their related capability automatically added too, so long as they are |
348 | 348 | * registered properly using EE_Register_Payment_Method::register() |
349 | 349 | */ |
350 | - foreach( $this->payment_method_types() as $payment_method_type_obj ){ |
|
350 | + foreach ($this->payment_method_types() as $payment_method_type_obj) { |
|
351 | 351 | $caps['administrator'][] = $payment_method_type_obj->cap_name(); |
352 | 352 | } |
353 | 353 | return $caps; |