@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php use EventEspresso\core\exceptions\EntityNotFoundException; |
2 | 2 | |
3 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
4 | - exit( 'No direct script access allowed' ); |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | + exit('No direct script access allowed'); |
|
5 | 5 | } |
6 | 6 | /** |
7 | 7 | * EE_Registration class |
@@ -59,9 +59,9 @@ discard block |
||
59 | 59 | * date_format and the second value is the time format |
60 | 60 | * @return EE_Registration |
61 | 61 | */ |
62 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
63 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats ); |
|
64 | - return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
|
62 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
63 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
64 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | * the website will be used. |
73 | 73 | * @return EE_Registration |
74 | 74 | */ |
75 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
76 | - return new self( $props_n_values, TRUE, $timezone ); |
|
75 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
76 | + return new self($props_n_values, TRUE, $timezone); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | |
@@ -83,8 +83,8 @@ discard block |
||
83 | 83 | * |
84 | 84 | * @param int $EVT_ID Event ID |
85 | 85 | */ |
86 | - public function set_event( $EVT_ID = 0 ) { |
|
87 | - $this->set( 'EVT_ID', $EVT_ID ); |
|
86 | + public function set_event($EVT_ID = 0) { |
|
87 | + $this->set('EVT_ID', $EVT_ID); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | |
@@ -98,18 +98,18 @@ discard block |
||
98 | 98 | * @throws \EE_Error |
99 | 99 | * @throws \RuntimeException |
100 | 100 | */ |
101 | - public function set( $field_name, $field_value, $use_default = FALSE ) { |
|
102 | - switch( $field_name ) { |
|
101 | + public function set($field_name, $field_value, $use_default = FALSE) { |
|
102 | + switch ($field_name) { |
|
103 | 103 | case 'REG_code' : |
104 | - if ( ! empty( $field_value ) && $this->reg_code() === null ) { |
|
105 | - $this->set_reg_code( $field_value, $use_default ); |
|
104 | + if ( ! empty($field_value) && $this->reg_code() === null) { |
|
105 | + $this->set_reg_code($field_value, $use_default); |
|
106 | 106 | } |
107 | 107 | break; |
108 | 108 | case 'STS_ID' : |
109 | - $this->set_status( $field_value, $use_default ); |
|
109 | + $this->set_status($field_value, $use_default); |
|
110 | 110 | break; |
111 | 111 | default : |
112 | - parent::set( $field_name, $field_value, $use_default ); |
|
112 | + parent::set($field_name, $field_value, $use_default); |
|
113 | 113 | } |
114 | 114 | } |
115 | 115 | |
@@ -127,40 +127,40 @@ discard block |
||
127 | 127 | * @throws \RuntimeException |
128 | 128 | * @throws \EE_Error |
129 | 129 | */ |
130 | - public function set_status( $new_STS_ID = NULL, $use_default = FALSE ) { |
|
130 | + public function set_status($new_STS_ID = NULL, $use_default = FALSE) { |
|
131 | 131 | // get current REG_Status |
132 | 132 | $old_STS_ID = $this->status_ID(); |
133 | 133 | // if status has changed |
134 | 134 | if ( |
135 | 135 | $old_STS_ID !== $new_STS_ID // and that status has actually changed |
136 | - && ! empty( $old_STS_ID ) // and that old status is actually set |
|
137 | - && ! empty( $new_STS_ID ) // as well as the new status |
|
136 | + && ! empty($old_STS_ID) // and that old status is actually set |
|
137 | + && ! empty($new_STS_ID) // as well as the new status |
|
138 | 138 | && $this->ID() // ensure registration is in the db |
139 | 139 | ) { |
140 | 140 | // TO approved |
141 | - if ( $new_STS_ID === EEM_Registration::status_id_approved ) { |
|
141 | + if ($new_STS_ID === EEM_Registration::status_id_approved) { |
|
142 | 142 | // reserve a space by incrementing ticket and datetime sold values |
143 | 143 | $this->_reserve_registration_space(); |
144 | - do_action( 'AHEE__EE_Registration__set_status__to_approved', $this, $old_STS_ID, $new_STS_ID ); |
|
144 | + do_action('AHEE__EE_Registration__set_status__to_approved', $this, $old_STS_ID, $new_STS_ID); |
|
145 | 145 | // OR FROM approved |
146 | - } else if ( $old_STS_ID === EEM_Registration::status_id_approved ) { |
|
146 | + } else if ($old_STS_ID === EEM_Registration::status_id_approved) { |
|
147 | 147 | // release a space by decrementing ticket and datetime sold values |
148 | 148 | $this->_release_registration_space(); |
149 | - do_action( 'AHEE__EE_Registration__set_status__from_approved', $this, $old_STS_ID, $new_STS_ID ); |
|
149 | + do_action('AHEE__EE_Registration__set_status__from_approved', $this, $old_STS_ID, $new_STS_ID); |
|
150 | 150 | } |
151 | 151 | // update status |
152 | 152 | parent::set('STS_ID', $new_STS_ID, $use_default); |
153 | 153 | $this->_update_if_canceled_or_declined($new_STS_ID, $old_STS_ID); |
154 | 154 | /** @type EE_Transaction_Payments $transaction_payments */ |
155 | 155 | $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
156 | - $transaction_payments->recalculate_transaction_total( $this->transaction(), false ); |
|
157 | - $this->transaction()->update_status_based_on_total_paid( true ); |
|
158 | - do_action( 'AHEE__EE_Registration__set_status__after_update', $this ); |
|
156 | + $transaction_payments->recalculate_transaction_total($this->transaction(), false); |
|
157 | + $this->transaction()->update_status_based_on_total_paid(true); |
|
158 | + do_action('AHEE__EE_Registration__set_status__after_update', $this); |
|
159 | 159 | return TRUE; |
160 | 160 | } else { |
161 | 161 | //even though the old value matches the new value, it's still good to |
162 | 162 | //allow the parent set method to have a say |
163 | - parent::set( 'STS_ID', $new_STS_ID, $use_default ); |
|
163 | + parent::set('STS_ID', $new_STS_ID, $use_default); |
|
164 | 164 | return TRUE; |
165 | 165 | } |
166 | 166 | } |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | * get Status ID |
229 | 229 | */ |
230 | 230 | public function status_ID() { |
231 | - return $this->get( 'STS_ID' ); |
|
231 | + return $this->get('STS_ID'); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | |
@@ -259,12 +259,12 @@ discard block |
||
259 | 259 | * @return EE_Ticket|EE_Base_Class |
260 | 260 | * @throws \EE_Error |
261 | 261 | */ |
262 | - public function ticket( $include_archived = TRUE ) { |
|
262 | + public function ticket($include_archived = TRUE) { |
|
263 | 263 | $query_params = array(); |
264 | - if ( $include_archived ) { |
|
265 | - $query_params[ 'default_where_conditions' ] = 'none'; |
|
264 | + if ($include_archived) { |
|
265 | + $query_params['default_where_conditions'] = 'none'; |
|
266 | 266 | } |
267 | - return $this->get_first_related( 'Ticket', $query_params ); |
|
267 | + return $this->get_first_related('Ticket', $query_params); |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | */ |
293 | 293 | public function wp_user() { |
294 | 294 | $event = $this->event(); |
295 | - if ( $event instanceof EE_Event ) { |
|
295 | + if ($event instanceof EE_Event) { |
|
296 | 296 | return $event->wp_user(); |
297 | 297 | } |
298 | 298 | return 0; |
@@ -363,8 +363,8 @@ discard block |
||
363 | 363 | * |
364 | 364 | * @param int $ATT_ID Attendee ID |
365 | 365 | */ |
366 | - public function set_attendee_id( $ATT_ID = 0 ) { |
|
367 | - $this->set( 'ATT_ID', $ATT_ID ); |
|
366 | + public function set_attendee_id($ATT_ID = 0) { |
|
367 | + $this->set('ATT_ID', $ATT_ID); |
|
368 | 368 | } |
369 | 369 | |
370 | 370 | |
@@ -374,8 +374,8 @@ discard block |
||
374 | 374 | * |
375 | 375 | * @param int $TXN_ID Transaction ID |
376 | 376 | */ |
377 | - public function set_transaction_id( $TXN_ID = 0 ) { |
|
378 | - $this->set( 'TXN_ID', $TXN_ID ); |
|
377 | + public function set_transaction_id($TXN_ID = 0) { |
|
378 | + $this->set('TXN_ID', $TXN_ID); |
|
379 | 379 | } |
380 | 380 | |
381 | 381 | |
@@ -385,8 +385,8 @@ discard block |
||
385 | 385 | * |
386 | 386 | * @param string $REG_session PHP Session ID |
387 | 387 | */ |
388 | - public function set_session( $REG_session = '' ) { |
|
389 | - $this->set( 'REG_session', $REG_session ); |
|
388 | + public function set_session($REG_session = '') { |
|
389 | + $this->set('REG_session', $REG_session); |
|
390 | 390 | } |
391 | 391 | |
392 | 392 | |
@@ -396,8 +396,8 @@ discard block |
||
396 | 396 | * |
397 | 397 | * @param string $REG_url_link Registration URL Link |
398 | 398 | */ |
399 | - public function set_reg_url_link( $REG_url_link = '' ) { |
|
400 | - $this->set( 'REG_url_link', $REG_url_link ); |
|
399 | + public function set_reg_url_link($REG_url_link = '') { |
|
400 | + $this->set('REG_url_link', $REG_url_link); |
|
401 | 401 | } |
402 | 402 | |
403 | 403 | |
@@ -407,8 +407,8 @@ discard block |
||
407 | 407 | * |
408 | 408 | * @param int $REG_count Primary Attendee |
409 | 409 | */ |
410 | - public function set_count( $REG_count = 1 ) { |
|
411 | - $this->set( 'REG_count', $REG_count ); |
|
410 | + public function set_count($REG_count = 1) { |
|
411 | + $this->set('REG_count', $REG_count); |
|
412 | 412 | } |
413 | 413 | |
414 | 414 | |
@@ -418,8 +418,8 @@ discard block |
||
418 | 418 | * |
419 | 419 | * @param boolean $REG_group_size Group Registration |
420 | 420 | */ |
421 | - public function set_group_size( $REG_group_size = FALSE ) { |
|
422 | - $this->set( 'REG_group_size', $REG_group_size ); |
|
421 | + public function set_group_size($REG_group_size = FALSE) { |
|
422 | + $this->set('REG_group_size', $REG_group_size); |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | |
@@ -495,8 +495,8 @@ discard block |
||
495 | 495 | * |
496 | 496 | * @param mixed ( int or string ) $REG_date Registration Date - Unix timestamp or string representation of Date |
497 | 497 | */ |
498 | - public function set_reg_date( $REG_date = FALSE ) { |
|
499 | - $this->set( 'REG_date', $REG_date ); |
|
498 | + public function set_reg_date($REG_date = FALSE) { |
|
499 | + $this->set('REG_date', $REG_date); |
|
500 | 500 | } |
501 | 501 | |
502 | 502 | |
@@ -507,8 +507,8 @@ discard block |
||
507 | 507 | * @access public |
508 | 508 | * @param float $REG_final_price |
509 | 509 | */ |
510 | - public function set_final_price( $REG_final_price = 0.00 ) { |
|
511 | - $this->set( 'REG_final_price', $REG_final_price ); |
|
510 | + public function set_final_price($REG_final_price = 0.00) { |
|
511 | + $this->set('REG_final_price', $REG_final_price); |
|
512 | 512 | } |
513 | 513 | |
514 | 514 | |
@@ -519,8 +519,8 @@ discard block |
||
519 | 519 | * @access public |
520 | 520 | * @param float $REG_paid |
521 | 521 | */ |
522 | - public function set_paid( $REG_paid = 0.00 ) { |
|
523 | - $this->set( 'REG_paid', $REG_paid ); |
|
522 | + public function set_paid($REG_paid = 0.00) { |
|
523 | + $this->set('REG_paid', $REG_paid); |
|
524 | 524 | } |
525 | 525 | |
526 | 526 | |
@@ -530,8 +530,8 @@ discard block |
||
530 | 530 | * |
531 | 531 | * @param boolean $REG_att_is_going Attendee Is Going |
532 | 532 | */ |
533 | - public function set_att_is_going( $REG_att_is_going = FALSE ) { |
|
534 | - $this->set( 'REG_att_is_going', $REG_att_is_going ); |
|
533 | + public function set_att_is_going($REG_att_is_going = FALSE) { |
|
534 | + $this->set('REG_att_is_going', $REG_att_is_going); |
|
535 | 535 | } |
536 | 536 | |
537 | 537 | |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | * @return EE_Attendee |
542 | 542 | */ |
543 | 543 | public function attendee() { |
544 | - return $this->get_first_related( 'Attendee' ); |
|
544 | + return $this->get_first_related('Attendee'); |
|
545 | 545 | } |
546 | 546 | |
547 | 547 | |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | * get Event ID |
551 | 551 | */ |
552 | 552 | public function event_ID() { |
553 | - return $this->get( 'EVT_ID' ); |
|
553 | + return $this->get('EVT_ID'); |
|
554 | 554 | } |
555 | 555 | |
556 | 556 | |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | */ |
561 | 561 | public function event_name() { |
562 | 562 | $event = $this->event_obj(); |
563 | - if ( $event ) { |
|
563 | + if ($event) { |
|
564 | 564 | return $event->name(); |
565 | 565 | } else { |
566 | 566 | return NULL; |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | * @return EE_Event |
575 | 575 | */ |
576 | 576 | public function event_obj() { |
577 | - return $this->get_first_related( 'Event' ); |
|
577 | + return $this->get_first_related('Event'); |
|
578 | 578 | } |
579 | 579 | |
580 | 580 | |
@@ -583,7 +583,7 @@ discard block |
||
583 | 583 | * get Attendee ID |
584 | 584 | */ |
585 | 585 | public function attendee_ID() { |
586 | - return $this->get( 'ATT_ID' ); |
|
586 | + return $this->get('ATT_ID'); |
|
587 | 587 | } |
588 | 588 | |
589 | 589 | |
@@ -592,7 +592,7 @@ discard block |
||
592 | 592 | * get PHP Session ID |
593 | 593 | */ |
594 | 594 | public function session_ID() { |
595 | - return $this->get( 'REG_session' ); |
|
595 | + return $this->get('REG_session'); |
|
596 | 596 | } |
597 | 597 | |
598 | 598 | |
@@ -602,7 +602,7 @@ discard block |
||
602 | 602 | * @param string $messenger 'pdf' or 'html'. Default 'html'. |
603 | 603 | * @return string |
604 | 604 | */ |
605 | - public function receipt_url( $messenger = 'html' ) { |
|
605 | + public function receipt_url($messenger = 'html') { |
|
606 | 606 | |
607 | 607 | /** |
608 | 608 | * The below will be deprecated one version after this. We check first if there is a custom receipt template already in use on old system. If there is then we just return the standard url for it. |
@@ -610,12 +610,12 @@ discard block |
||
610 | 610 | * @since 4.5.0 |
611 | 611 | */ |
612 | 612 | $template_relative_path = 'modules/gateways/Invoice/lib/templates/receipt_body.template.php'; |
613 | - $has_custom = EEH_Template::locate_template( $template_relative_path , array(), TRUE, TRUE, TRUE ); |
|
613 | + $has_custom = EEH_Template::locate_template($template_relative_path, array(), TRUE, TRUE, TRUE); |
|
614 | 614 | |
615 | - if ( $has_custom ) { |
|
616 | - return add_query_arg( array( 'receipt' => 'true' ), $this->invoice_url( 'launch' ) ); |
|
615 | + if ($has_custom) { |
|
616 | + return add_query_arg(array('receipt' => 'true'), $this->invoice_url('launch')); |
|
617 | 617 | } |
618 | - return apply_filters( 'FHEE__EE_Registration__receipt_url__receipt_url', '', $this, $messenger, 'receipt' ); |
|
618 | + return apply_filters('FHEE__EE_Registration__receipt_url__receipt_url', '', $this, $messenger, 'receipt'); |
|
619 | 619 | } |
620 | 620 | |
621 | 621 | |
@@ -626,28 +626,28 @@ discard block |
||
626 | 626 | * @param string $messenger 'pdf' or 'html'. Default 'html'. |
627 | 627 | * @return string |
628 | 628 | */ |
629 | - public function invoice_url( $messenger = 'html' ) { |
|
629 | + public function invoice_url($messenger = 'html') { |
|
630 | 630 | /** |
631 | 631 | * The below will be deprecated one version after this. We check first if there is a custom invoice template already in use on old system. If there is then we just return the standard url for it. |
632 | 632 | * |
633 | 633 | * @since 4.5.0 |
634 | 634 | */ |
635 | 635 | $template_relative_path = 'modules/gateways/Invoice/lib/templates/invoice_body.template.php'; |
636 | - $has_custom = EEH_Template::locate_template( $template_relative_path , array(), TRUE, TRUE, TRUE ); |
|
636 | + $has_custom = EEH_Template::locate_template($template_relative_path, array(), TRUE, TRUE, TRUE); |
|
637 | 637 | |
638 | - if ( $has_custom ) { |
|
639 | - if ( $messenger == 'html' ) { |
|
640 | - return $this->invoice_url( 'launch' ); |
|
638 | + if ($has_custom) { |
|
639 | + if ($messenger == 'html') { |
|
640 | + return $this->invoice_url('launch'); |
|
641 | 641 | } |
642 | 642 | $route = $messenger == 'download' || $messenger == 'pdf' ? 'download_invoice' : 'launch_invoice'; |
643 | 643 | |
644 | - $query_args = array( 'ee' => $route, 'id' => $this->reg_url_link() ); |
|
645 | - if ( $messenger == 'html' ) { |
|
644 | + $query_args = array('ee' => $route, 'id' => $this->reg_url_link()); |
|
645 | + if ($messenger == 'html') { |
|
646 | 646 | $query_args['html'] = TRUE; |
647 | 647 | } |
648 | - return add_query_arg( $query_args, get_permalink( EE_Registry::instance()->CFG->core->thank_you_page_id ) ); |
|
648 | + return add_query_arg($query_args, get_permalink(EE_Registry::instance()->CFG->core->thank_you_page_id)); |
|
649 | 649 | } |
650 | - return apply_filters( 'FHEE__EE_Registration__invoice_url__invoice_url', '', $this, $messenger, 'invoice' ); |
|
650 | + return apply_filters('FHEE__EE_Registration__invoice_url__invoice_url', '', $this, $messenger, 'invoice'); |
|
651 | 651 | } |
652 | 652 | |
653 | 653 | |
@@ -660,7 +660,7 @@ discard block |
||
660 | 660 | * @throws \EE_Error |
661 | 661 | */ |
662 | 662 | public function reg_url_link() { |
663 | - return (string)$this->get( 'REG_url_link' ); |
|
663 | + return (string) $this->get('REG_url_link'); |
|
664 | 664 | } |
665 | 665 | |
666 | 666 | |
@@ -670,8 +670,8 @@ discard block |
||
670 | 670 | * @param string $type 'download','launch', or 'html' (default is 'launch') |
671 | 671 | * @return void |
672 | 672 | */ |
673 | - public function e_invoice_url( $type = 'launch' ) { |
|
674 | - echo $this->invoice_url( $type ); |
|
673 | + public function e_invoice_url($type = 'launch') { |
|
674 | + echo $this->invoice_url($type); |
|
675 | 675 | } |
676 | 676 | |
677 | 677 | |
@@ -691,7 +691,7 @@ discard block |
||
691 | 691 | * @return string |
692 | 692 | */ |
693 | 693 | public function payment_overview_url() { |
694 | - return add_query_arg( array( 'e_reg_url_link' => $this->reg_url_link(), 'step' => 'payment_options', 'revisit' => TRUE ), EE_Registry::instance()->CFG->core->reg_page_url() ); |
|
694 | + return add_query_arg(array('e_reg_url_link' => $this->reg_url_link(), 'step' => 'payment_options', 'revisit' => TRUE), EE_Registry::instance()->CFG->core->reg_page_url()); |
|
695 | 695 | } |
696 | 696 | |
697 | 697 | |
@@ -702,7 +702,7 @@ discard block |
||
702 | 702 | * @return string |
703 | 703 | */ |
704 | 704 | public function edit_attendee_information_url() { |
705 | - return add_query_arg( array( 'e_reg_url_link' => $this->reg_url_link(), 'step' => 'attendee_information', 'revisit' => TRUE ), EE_Registry::instance()->CFG->core->reg_page_url() ); |
|
705 | + return add_query_arg(array('e_reg_url_link' => $this->reg_url_link(), 'step' => 'attendee_information', 'revisit' => TRUE), EE_Registry::instance()->CFG->core->reg_page_url()); |
|
706 | 706 | } |
707 | 707 | |
708 | 708 | |
@@ -712,7 +712,7 @@ discard block |
||
712 | 712 | * @return string |
713 | 713 | */ |
714 | 714 | public function get_admin_edit_url() { |
715 | - return EEH_URL::add_query_args_and_nonce( array( 'page' => 'espresso_registrations', 'action' => 'view_registration', '_REG_ID' => $this->ID() ), admin_url( 'admin.php' ) ); |
|
715 | + return EEH_URL::add_query_args_and_nonce(array('page' => 'espresso_registrations', 'action' => 'view_registration', '_REG_ID' => $this->ID()), admin_url('admin.php')); |
|
716 | 716 | } |
717 | 717 | |
718 | 718 | |
@@ -721,7 +721,7 @@ discard block |
||
721 | 721 | * is_primary_registrant? |
722 | 722 | */ |
723 | 723 | public function is_primary_registrant() { |
724 | - return $this->get( 'REG_count' ) == 1 ? TRUE : FALSE; |
|
724 | + return $this->get('REG_count') == 1 ? TRUE : FALSE; |
|
725 | 725 | } |
726 | 726 | |
727 | 727 | |
@@ -730,12 +730,12 @@ discard block |
||
730 | 730 | * This returns the primary registration object for this registration group (which may be this object). |
731 | 731 | * @return EE_Registration |
732 | 732 | */ |
733 | - public function get_primary_registration() { |
|
734 | - if ( $this->is_primary_registrant() ) |
|
733 | + public function get_primary_registration() { |
|
734 | + if ($this->is_primary_registrant()) |
|
735 | 735 | return $this; |
736 | 736 | |
737 | 737 | //k reg_count !== 1 so let's get the EE_Registration object matching this txn_id and reg_count == 1 |
738 | - $primary_registrant = EEM_Registration::instance()->get_one( array( array('TXN_ID' => $this->transaction_ID(), 'REG_count' => 1 ) ) ); |
|
738 | + $primary_registrant = EEM_Registration::instance()->get_one(array(array('TXN_ID' => $this->transaction_ID(), 'REG_count' => 1))); |
|
739 | 739 | return $primary_registrant; |
740 | 740 | } |
741 | 741 | |
@@ -746,7 +746,7 @@ discard block |
||
746 | 746 | * @access public |
747 | 747 | */ |
748 | 748 | public function count() { |
749 | - return $this->get( 'REG_count' ); |
|
749 | + return $this->get('REG_count'); |
|
750 | 750 | } |
751 | 751 | |
752 | 752 | |
@@ -755,7 +755,7 @@ discard block |
||
755 | 755 | * get Group Size |
756 | 756 | */ |
757 | 757 | public function group_size() { |
758 | - return $this->get( 'REG_group_size' ); |
|
758 | + return $this->get('REG_group_size'); |
|
759 | 759 | } |
760 | 760 | |
761 | 761 | |
@@ -764,7 +764,7 @@ discard block |
||
764 | 764 | * get Registration Date |
765 | 765 | */ |
766 | 766 | public function date() { |
767 | - return $this->get( 'REG_date' ); |
|
767 | + return $this->get('REG_date'); |
|
768 | 768 | } |
769 | 769 | |
770 | 770 | |
@@ -775,8 +775,8 @@ discard block |
||
775 | 775 | * @param string $time_format |
776 | 776 | * @return string |
777 | 777 | */ |
778 | - public function pretty_date( $date_format = NULL, $time_format = NULL ) { |
|
779 | - return $this->get_datetime( 'REG_date', $date_format, $time_format ); |
|
778 | + public function pretty_date($date_format = NULL, $time_format = NULL) { |
|
779 | + return $this->get_datetime('REG_date', $date_format, $time_format); |
|
780 | 780 | } |
781 | 781 | |
782 | 782 | |
@@ -788,7 +788,7 @@ discard block |
||
788 | 788 | * @return float |
789 | 789 | */ |
790 | 790 | public function final_price() { |
791 | - return $this->get( 'REG_final_price' ); |
|
791 | + return $this->get('REG_final_price'); |
|
792 | 792 | } |
793 | 793 | |
794 | 794 | |
@@ -799,7 +799,7 @@ discard block |
||
799 | 799 | * @return string |
800 | 800 | */ |
801 | 801 | public function pretty_final_price() { |
802 | - return $this->get_pretty( 'REG_final_price' ); |
|
802 | + return $this->get_pretty('REG_final_price'); |
|
803 | 803 | } |
804 | 804 | |
805 | 805 | |
@@ -809,7 +809,7 @@ discard block |
||
809 | 809 | * @return float |
810 | 810 | */ |
811 | 811 | public function paid() { |
812 | - return $this->get( 'REG_paid' ); |
|
812 | + return $this->get('REG_paid'); |
|
813 | 813 | } |
814 | 814 | |
815 | 815 | |
@@ -819,7 +819,7 @@ discard block |
||
819 | 819 | * @return float |
820 | 820 | */ |
821 | 821 | public function pretty_paid() { |
822 | - return $this->get_pretty( 'REG_paid' ); |
|
822 | + return $this->get_pretty('REG_paid'); |
|
823 | 823 | } |
824 | 824 | |
825 | 825 | |
@@ -830,11 +830,11 @@ discard block |
||
830 | 830 | * @param array $requires_payment |
831 | 831 | * @return bool |
832 | 832 | */ |
833 | - public function owes_monies_and_can_pay( $requires_payment = array()) { |
|
833 | + public function owes_monies_and_can_pay($requires_payment = array()) { |
|
834 | 834 | // these reg statuses require payment (if event is not free) |
835 | - $requires_payment = ! empty( $requires_payment ) ? $requires_payment : EEM_Registration::reg_statuses_that_allow_payment(); |
|
835 | + $requires_payment = ! empty($requires_payment) ? $requires_payment : EEM_Registration::reg_statuses_that_allow_payment(); |
|
836 | 836 | if ( |
837 | - in_array( $this->status_ID(), $requires_payment ) && |
|
837 | + in_array($this->status_ID(), $requires_payment) && |
|
838 | 838 | $this->final_price() != 0 && |
839 | 839 | $this->final_price() != $this->paid() |
840 | 840 | ) { |
@@ -851,8 +851,8 @@ discard block |
||
851 | 851 | * @param bool $show_icons |
852 | 852 | * @return void |
853 | 853 | */ |
854 | - public function e_pretty_status( $show_icons = FALSE ) { |
|
855 | - echo $this->pretty_status( $show_icons ); |
|
854 | + public function e_pretty_status($show_icons = FALSE) { |
|
855 | + echo $this->pretty_status($show_icons); |
|
856 | 856 | } |
857 | 857 | |
858 | 858 | |
@@ -863,10 +863,10 @@ discard block |
||
863 | 863 | * @param bool $show_icons |
864 | 864 | * @return string |
865 | 865 | */ |
866 | - public function pretty_status( $show_icons = FALSE ) { |
|
867 | - $status = EEM_Status::instance()->localized_status( array( $this->status_ID() => __( 'unknown', 'event_espresso' ) ), FALSE, 'sentence' ); |
|
866 | + public function pretty_status($show_icons = FALSE) { |
|
867 | + $status = EEM_Status::instance()->localized_status(array($this->status_ID() => __('unknown', 'event_espresso')), FALSE, 'sentence'); |
|
868 | 868 | $icon = ''; |
869 | - switch ( $this->status_ID() ) { |
|
869 | + switch ($this->status_ID()) { |
|
870 | 870 | case EEM_Registration::status_id_approved: |
871 | 871 | $icon = $show_icons ? '<span class="dashicons dashicons-star-filled ee-icon-size-16 green-text"></span>' : ''; |
872 | 872 | break; |
@@ -889,7 +889,7 @@ discard block |
||
889 | 889 | $icon = $show_icons ? '<span class="dashicons dashicons-clipboard ee-icon-size-16 purple-text"></span>' : ''; |
890 | 890 | break; |
891 | 891 | } |
892 | - return $icon . $status[ $this->status_ID() ]; |
|
892 | + return $icon.$status[$this->status_ID()]; |
|
893 | 893 | } |
894 | 894 | |
895 | 895 | |
@@ -898,7 +898,7 @@ discard block |
||
898 | 898 | * get Attendee Is Going |
899 | 899 | */ |
900 | 900 | public function att_is_going() { |
901 | - return $this->get( 'REG_att_is_going' ); |
|
901 | + return $this->get('REG_att_is_going'); |
|
902 | 902 | } |
903 | 903 | |
904 | 904 | |
@@ -908,8 +908,8 @@ discard block |
||
908 | 908 | * @param array $query_params like EEM_Base::get_all |
909 | 909 | * @return EE_Answer[] |
910 | 910 | */ |
911 | - public function answers( $query_params = NULL ) { |
|
912 | - return $this->get_many_related( 'Answer', $query_params ); |
|
911 | + public function answers($query_params = NULL) { |
|
912 | + return $this->get_many_related('Answer', $query_params); |
|
913 | 913 | } |
914 | 914 | |
915 | 915 | |
@@ -923,9 +923,9 @@ discard block |
||
923 | 923 | * (because the answer might be an array of answer values, so passing pretty_value=true |
924 | 924 | * will convert it into some kind of string) |
925 | 925 | */ |
926 | - public function answer_value_to_question( $question, $pretty_value=true ) { |
|
926 | + public function answer_value_to_question($question, $pretty_value = true) { |
|
927 | 927 | $question_id = EEM_Question::instance()->ensure_is_ID($question); |
928 | - return EEM_Answer::instance()->get_answer_value_to_question($this,$question_id,$pretty_value); |
|
928 | + return EEM_Answer::instance()->get_answer_value_to_question($this, $question_id, $pretty_value); |
|
929 | 929 | } |
930 | 930 | |
931 | 931 | |
@@ -938,13 +938,13 @@ discard block |
||
938 | 938 | */ |
939 | 939 | public function question_groups() { |
940 | 940 | $question_groups = array(); |
941 | - if ( $this->event() instanceof EE_Event ) { |
|
941 | + if ($this->event() instanceof EE_Event) { |
|
942 | 942 | $question_groups = $this->event()->question_groups( |
943 | 943 | array( |
944 | 944 | array( |
945 | 945 | 'Event_Question_Group.EQG_primary' => $this->count() == 1 ? true : false |
946 | 946 | ), |
947 | - 'order_by' => array( 'QSG_order' => 'ASC' ) |
|
947 | + 'order_by' => array('QSG_order' => 'ASC') |
|
948 | 948 | ) |
949 | 949 | ); |
950 | 950 | } |
@@ -961,7 +961,7 @@ discard block |
||
961 | 961 | */ |
962 | 962 | public function count_question_groups() { |
963 | 963 | $qg_count = 0; |
964 | - if ( $this->event() instanceof EE_Event ) { |
|
964 | + if ($this->event() instanceof EE_Event) { |
|
965 | 965 | $qg_count = $this->event()->count_related( |
966 | 966 | 'Question_Group', |
967 | 967 | array( |
@@ -982,7 +982,7 @@ discard block |
||
982 | 982 | * @return string |
983 | 983 | */ |
984 | 984 | public function reg_date() { |
985 | - return $this->get_datetime( 'REG_date' ); |
|
985 | + return $this->get_datetime('REG_date'); |
|
986 | 986 | } |
987 | 987 | |
988 | 988 | |
@@ -994,7 +994,7 @@ discard block |
||
994 | 994 | * @return EE_Datetime_Ticket |
995 | 995 | */ |
996 | 996 | public function datetime_ticket() { |
997 | - return $this->get_first_related( 'Datetime_Ticket' ); |
|
997 | + return $this->get_first_related('Datetime_Ticket'); |
|
998 | 998 | } |
999 | 999 | |
1000 | 1000 | |
@@ -1004,15 +1004,15 @@ discard block |
||
1004 | 1004 | * @param EE_Datetime_Ticket $datetime_ticket |
1005 | 1005 | * @return EE_Datetime_Ticket |
1006 | 1006 | */ |
1007 | - public function set_datetime_ticket( $datetime_ticket ) { |
|
1008 | - return $this->_add_relation_to( $datetime_ticket, 'Datetime_Ticket' ); |
|
1007 | + public function set_datetime_ticket($datetime_ticket) { |
|
1008 | + return $this->_add_relation_to($datetime_ticket, 'Datetime_Ticket'); |
|
1009 | 1009 | } |
1010 | 1010 | /** |
1011 | 1011 | * Gets deleted |
1012 | 1012 | * @return boolean |
1013 | 1013 | */ |
1014 | 1014 | public function deleted() { |
1015 | - return $this->get( 'REG_deleted' ); |
|
1015 | + return $this->get('REG_deleted'); |
|
1016 | 1016 | } |
1017 | 1017 | |
1018 | 1018 | /** |
@@ -1021,7 +1021,7 @@ discard block |
||
1021 | 1021 | * @return boolean |
1022 | 1022 | */ |
1023 | 1023 | public function set_deleted($deleted) { |
1024 | - if ( $deleted ) { |
|
1024 | + if ($deleted) { |
|
1025 | 1025 | $this->delete(); |
1026 | 1026 | } else { |
1027 | 1027 | $this->restore(); |
@@ -1035,7 +1035,7 @@ discard block |
||
1035 | 1035 | * @return EE_Status |
1036 | 1036 | */ |
1037 | 1037 | public function status_obj() { |
1038 | - return $this->get_first_related( 'Status' ); |
|
1038 | + return $this->get_first_related('Status'); |
|
1039 | 1039 | } |
1040 | 1040 | |
1041 | 1041 | |
@@ -1046,7 +1046,7 @@ discard block |
||
1046 | 1046 | * @return int |
1047 | 1047 | */ |
1048 | 1048 | public function count_checkins() { |
1049 | - return $this->get_model()->count_related( $this, 'Checkin' ); |
|
1049 | + return $this->get_model()->count_related($this, 'Checkin'); |
|
1050 | 1050 | } |
1051 | 1051 | |
1052 | 1052 | |
@@ -1056,7 +1056,7 @@ discard block |
||
1056 | 1056 | * @return int |
1057 | 1057 | */ |
1058 | 1058 | public function count_checkins_not_checkedout() { |
1059 | - return $this->get_model()->count_related( $this, 'Checkin', array( array( 'CHK_in' => 1 ) ) ); |
|
1059 | + return $this->get_model()->count_related($this, 'Checkin', array(array('CHK_in' => 1))); |
|
1060 | 1060 | } |
1061 | 1061 | |
1062 | 1062 | |
@@ -1069,20 +1069,20 @@ discard block |
||
1069 | 1069 | * |
1070 | 1070 | * @return bool |
1071 | 1071 | */ |
1072 | - public function can_checkin( $DTT_OR_ID, $check_approved = TRUE ) { |
|
1073 | - $DTT_ID = EEM_Datetime::instance()->ensure_is_ID( $DTT_OR_ID ); |
|
1072 | + public function can_checkin($DTT_OR_ID, $check_approved = TRUE) { |
|
1073 | + $DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID); |
|
1074 | 1074 | |
1075 | 1075 | //first check registration status |
1076 | - if ( ( $check_approved && ! $this->is_approved() ) || ! $DTT_ID ) { |
|
1076 | + if (($check_approved && ! $this->is_approved()) || ! $DTT_ID) { |
|
1077 | 1077 | return false; |
1078 | 1078 | } |
1079 | 1079 | //is there a datetime ticket that matches this dtt_ID? |
1080 | - if ( ! ( EEM_Datetime_Ticket::instance()->exists( array( array( 'TKT_ID' => $this->get('TKT_ID' ), 'DTT_ID' => $DTT_ID ) ) ) ) ) { |
|
1080 | + if ( ! (EEM_Datetime_Ticket::instance()->exists(array(array('TKT_ID' => $this->get('TKT_ID'), 'DTT_ID' => $DTT_ID))))) { |
|
1081 | 1081 | return false; |
1082 | 1082 | } |
1083 | 1083 | |
1084 | 1084 | //final check is against TKT_uses |
1085 | - return $this->verify_can_checkin_against_TKT_uses( $DTT_ID ); |
|
1085 | + return $this->verify_can_checkin_against_TKT_uses($DTT_ID); |
|
1086 | 1086 | } |
1087 | 1087 | |
1088 | 1088 | |
@@ -1095,10 +1095,10 @@ discard block |
||
1095 | 1095 | * @param int | EE_Datetime $DTT_OR_ID The datetime the registration is being checked against |
1096 | 1096 | * @return bool true means can checkin. false means cannot checkin. |
1097 | 1097 | */ |
1098 | - public function verify_can_checkin_against_TKT_uses( $DTT_OR_ID ) { |
|
1099 | - $DTT_ID = EEM_Datetime::instance()->ensure_is_ID( $DTT_OR_ID ); |
|
1098 | + public function verify_can_checkin_against_TKT_uses($DTT_OR_ID) { |
|
1099 | + $DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID); |
|
1100 | 1100 | |
1101 | - if ( ! $DTT_ID ) { |
|
1101 | + if ( ! $DTT_ID) { |
|
1102 | 1102 | return false; |
1103 | 1103 | } |
1104 | 1104 | |
@@ -1106,23 +1106,23 @@ discard block |
||
1106 | 1106 | |
1107 | 1107 | // if max uses is not set or equals infinity then return true cause its not a factor for whether user can check-in |
1108 | 1108 | // or not. |
1109 | - if ( ! $max_uses || $max_uses === EE_INF ) { |
|
1109 | + if ( ! $max_uses || $max_uses === EE_INF) { |
|
1110 | 1110 | return true; |
1111 | 1111 | } |
1112 | 1112 | |
1113 | 1113 | //does this datetime have a checkin record? If so, then the dtt count has already been verified so we can just |
1114 | 1114 | //go ahead and toggle. |
1115 | - if ( EEM_Checkin::instance()->exists( array( array( 'REG_ID' => $this->ID(), 'DTT_ID' => $DTT_ID ) ) ) ) { |
|
1115 | + if (EEM_Checkin::instance()->exists(array(array('REG_ID' => $this->ID(), 'DTT_ID' => $DTT_ID)))) { |
|
1116 | 1116 | return true; |
1117 | 1117 | } |
1118 | 1118 | |
1119 | 1119 | //made it here so the last check is whether the number of checkins per unique datetime on this registration |
1120 | 1120 | //disallows further check-ins. |
1121 | - $count_unique_dtt_checkins = EEM_Checkin::instance()->count( array( array( 'REG_ID' => $this->ID(), 'CHK_in' => true ) ), 'DTT_ID', true ); |
|
1121 | + $count_unique_dtt_checkins = EEM_Checkin::instance()->count(array(array('REG_ID' => $this->ID(), 'CHK_in' => true)), 'DTT_ID', true); |
|
1122 | 1122 | // checkins have already reached their max number of uses |
1123 | 1123 | // so registrant can NOT checkin |
1124 | - if ( $count_unique_dtt_checkins >= $max_uses ) { |
|
1125 | - EE_Error::add_error( __( 'Check-in denied because number of datetime uses for the ticket has been reached or exceeded.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1124 | + if ($count_unique_dtt_checkins >= $max_uses) { |
|
1125 | + EE_Error::add_error(__('Check-in denied because number of datetime uses for the ticket has been reached or exceeded.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1126 | 1126 | return false; |
1127 | 1127 | } |
1128 | 1128 | return true; |
@@ -1144,15 +1144,15 @@ discard block |
||
1144 | 1144 | * @return bool|int the chk_in status toggled to OR false if nothing got changed. |
1145 | 1145 | * @throws EE_Error |
1146 | 1146 | */ |
1147 | - public function toggle_checkin_status( $DTT_ID = null, $verify = false ) { |
|
1148 | - if ( empty( $DTT_ID ) ) { |
|
1147 | + public function toggle_checkin_status($DTT_ID = null, $verify = false) { |
|
1148 | + if (empty($DTT_ID)) { |
|
1149 | 1149 | $datetime = $this->get_latest_related_datetime(); |
1150 | 1150 | $DTT_ID = $datetime instanceof EE_Datetime ? $datetime->ID() : 0; |
1151 | 1151 | // verify the registration can checkin for the given DTT_ID |
1152 | - } elseif ( ! $this->can_checkin( $DTT_ID, $verify ) ) { |
|
1152 | + } elseif ( ! $this->can_checkin($DTT_ID, $verify)) { |
|
1153 | 1153 | EE_Error::add_error( |
1154 | 1154 | sprintf( |
1155 | - __( 'The given registration (ID:%1$d) can not be checked in to the given DTT_ID (%2$d), because the registration does not have access', 'event_espresso'), |
|
1155 | + __('The given registration (ID:%1$d) can not be checked in to the given DTT_ID (%2$d), because the registration does not have access', 'event_espresso'), |
|
1156 | 1156 | $this->ID(), |
1157 | 1157 | $DTT_ID |
1158 | 1158 | ), |
@@ -1166,8 +1166,8 @@ discard block |
||
1166 | 1166 | EE_Registration::checkin_status_out => EE_Registration::checkin_status_in |
1167 | 1167 | ); |
1168 | 1168 | //start by getting the current status so we know what status we'll be changing to. |
1169 | - $cur_status = $this->check_in_status_for_datetime( $DTT_ID, NULL ); |
|
1170 | - $status_to = $status_paths[ $cur_status ]; |
|
1169 | + $cur_status = $this->check_in_status_for_datetime($DTT_ID, NULL); |
|
1170 | + $status_to = $status_paths[$cur_status]; |
|
1171 | 1171 | // database only records true for checked IN or false for checked OUT |
1172 | 1172 | // no record ( null ) means checked in NEVER, but we obviously don't save that |
1173 | 1173 | $new_status = $status_to === EE_Registration::checkin_status_in ? true : false; |
@@ -1175,24 +1175,24 @@ discard block |
||
1175 | 1175 | // because we are keeping track of Check-ins over time. |
1176 | 1176 | // Eventually we'll probably want to show a list table |
1177 | 1177 | // for the individual Check-ins so that they can be managed. |
1178 | - $checkin = EE_Checkin::new_instance( array( |
|
1178 | + $checkin = EE_Checkin::new_instance(array( |
|
1179 | 1179 | 'REG_ID' => $this->ID(), |
1180 | 1180 | 'DTT_ID' => $DTT_ID, |
1181 | 1181 | 'CHK_in' => $new_status |
1182 | - ) ); |
|
1182 | + )); |
|
1183 | 1183 | // if the record could not be saved then return false |
1184 | - if ( $checkin->save() === 0 ) { |
|
1185 | - if ( WP_DEBUG ) { |
|
1184 | + if ($checkin->save() === 0) { |
|
1185 | + if (WP_DEBUG) { |
|
1186 | 1186 | global $wpdb; |
1187 | 1187 | $error = sprintf( |
1188 | - __( 'Registration check in update failed because of the following database error: %1$s%2$s', 'event_espresso' ), |
|
1188 | + __('Registration check in update failed because of the following database error: %1$s%2$s', 'event_espresso'), |
|
1189 | 1189 | '<br />', |
1190 | 1190 | $wpdb->last_error |
1191 | 1191 | ); |
1192 | 1192 | } else { |
1193 | - $error = __( 'Registration check in update failed because of an unknown database error', 'event_espresso' ); |
|
1193 | + $error = __('Registration check in update failed because of an unknown database error', 'event_espresso'); |
|
1194 | 1194 | } |
1195 | - EE_Error::add_error( $error, __FILE__, __FUNCTION__, __LINE__ ); |
|
1195 | + EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
1196 | 1196 | return false; |
1197 | 1197 | } |
1198 | 1198 | return $status_to; |
@@ -1213,7 +1213,7 @@ discard block |
||
1213 | 1213 | array( |
1214 | 1214 | 'Ticket.Registration.REG_ID' => $this->ID() |
1215 | 1215 | ), |
1216 | - 'order_by' => array( 'DTT_EVT_start' => 'DESC' ) |
|
1216 | + 'order_by' => array('DTT_EVT_start' => 'DESC') |
|
1217 | 1217 | ) |
1218 | 1218 | ); |
1219 | 1219 | } |
@@ -1232,7 +1232,7 @@ discard block |
||
1232 | 1232 | array( |
1233 | 1233 | 'Ticket.Registration.REG_ID' => $this->ID() |
1234 | 1234 | ), |
1235 | - 'order_by' => array( 'DTT_EVT_start' => 'ASC' ) |
|
1235 | + 'order_by' => array('DTT_EVT_start' => 'ASC') |
|
1236 | 1236 | ) |
1237 | 1237 | ); |
1238 | 1238 | } |
@@ -1251,21 +1251,21 @@ discard block |
||
1251 | 1251 | * @return int Integer representing Check-in status. |
1252 | 1252 | * @throws \EE_Error |
1253 | 1253 | */ |
1254 | - public function check_in_status_for_datetime( $DTT_ID = 0, $checkin = null ) { |
|
1254 | + public function check_in_status_for_datetime($DTT_ID = 0, $checkin = null) { |
|
1255 | 1255 | $checkin_query_params = array( |
1256 | - 'order_by' => array( 'CHK_timestamp' => 'DESC' ) |
|
1256 | + 'order_by' => array('CHK_timestamp' => 'DESC') |
|
1257 | 1257 | ); |
1258 | 1258 | |
1259 | - if ( $DTT_ID > 0 ) { |
|
1260 | - $checkin_query_params[0] = array( 'DTT_ID' => $DTT_ID ); |
|
1259 | + if ($DTT_ID > 0) { |
|
1260 | + $checkin_query_params[0] = array('DTT_ID' => $DTT_ID); |
|
1261 | 1261 | } |
1262 | 1262 | |
1263 | 1263 | //get checkin object (if exists) |
1264 | 1264 | $checkin = $checkin instanceof EE_Checkin |
1265 | 1265 | ? $checkin |
1266 | - : $this->get_first_related( 'Checkin', $checkin_query_params ); |
|
1267 | - if ( $checkin instanceof EE_Checkin ) { |
|
1268 | - if ( $checkin->get( 'CHK_in' ) ) { |
|
1266 | + : $this->get_first_related('Checkin', $checkin_query_params); |
|
1267 | + if ($checkin instanceof EE_Checkin) { |
|
1268 | + if ($checkin->get('CHK_in')) { |
|
1269 | 1269 | return EE_Registration::checkin_status_in; //checked in |
1270 | 1270 | } |
1271 | 1271 | return EE_Registration::checkin_status_out; //had checked in but is now checked out. |
@@ -1281,28 +1281,28 @@ discard block |
||
1281 | 1281 | * @param bool $error This just flags that you want an error message returned. This is put in so that the error message can be customized with the attendee name. |
1282 | 1282 | * @return string internationalized message |
1283 | 1283 | */ |
1284 | - public function get_checkin_msg( $DTT_ID, $error = FALSE ) { |
|
1284 | + public function get_checkin_msg($DTT_ID, $error = FALSE) { |
|
1285 | 1285 | //let's get the attendee first so we can include the name of the attendee |
1286 | - $attendee = $this->get_first_related( 'Attendee' ); |
|
1287 | - if ( $attendee instanceof EE_Attendee ) { |
|
1288 | - if ( $error ) { |
|
1289 | - return sprintf( __( "%s's check-in status was not changed.", "event_espresso" ), $attendee->full_name() ); |
|
1286 | + $attendee = $this->get_first_related('Attendee'); |
|
1287 | + if ($attendee instanceof EE_Attendee) { |
|
1288 | + if ($error) { |
|
1289 | + return sprintf(__("%s's check-in status was not changed.", "event_espresso"), $attendee->full_name()); |
|
1290 | 1290 | } |
1291 | - $cur_status = $this->check_in_status_for_datetime( $DTT_ID ); |
|
1291 | + $cur_status = $this->check_in_status_for_datetime($DTT_ID); |
|
1292 | 1292 | //what is the status message going to be? |
1293 | - switch ( $cur_status ) { |
|
1293 | + switch ($cur_status) { |
|
1294 | 1294 | case EE_Registration::checkin_status_never : |
1295 | - return sprintf( __( "%s has been removed from Check-in records", "event_espresso" ), $attendee->full_name() ); |
|
1295 | + return sprintf(__("%s has been removed from Check-in records", "event_espresso"), $attendee->full_name()); |
|
1296 | 1296 | break; |
1297 | 1297 | case EE_Registration::checkin_status_in : |
1298 | - return sprintf( __( '%s has been checked in', 'event_espresso' ), $attendee->full_name() ); |
|
1298 | + return sprintf(__('%s has been checked in', 'event_espresso'), $attendee->full_name()); |
|
1299 | 1299 | break; |
1300 | 1300 | case EE_Registration::checkin_status_out : |
1301 | - return sprintf( __( '%s has been checked out', 'event_espresso' ), $attendee->full_name() ); |
|
1301 | + return sprintf(__('%s has been checked out', 'event_espresso'), $attendee->full_name()); |
|
1302 | 1302 | break; |
1303 | 1303 | } |
1304 | 1304 | } |
1305 | - return __( "The check-in status could not be determined.", "event_espresso" ); |
|
1305 | + return __("The check-in status could not be determined.", "event_espresso"); |
|
1306 | 1306 | } |
1307 | 1307 | |
1308 | 1308 | |
@@ -1326,7 +1326,7 @@ discard block |
||
1326 | 1326 | * get Registration Code |
1327 | 1327 | */ |
1328 | 1328 | public function reg_code() { |
1329 | - return $this->get( 'REG_code' ); |
|
1329 | + return $this->get('REG_code'); |
|
1330 | 1330 | } |
1331 | 1331 | |
1332 | 1332 | |
@@ -1335,7 +1335,7 @@ discard block |
||
1335 | 1335 | * get Transaction ID |
1336 | 1336 | */ |
1337 | 1337 | public function transaction_ID() { |
1338 | - return $this->get( 'TXN_ID' ); |
|
1338 | + return $this->get('TXN_ID'); |
|
1339 | 1339 | } |
1340 | 1340 | |
1341 | 1341 | |
@@ -1344,7 +1344,7 @@ discard block |
||
1344 | 1344 | * @return int |
1345 | 1345 | */ |
1346 | 1346 | public function ticket_ID() { |
1347 | - return $this->get( 'TKT_ID' ); |
|
1347 | + return $this->get('TKT_ID'); |
|
1348 | 1348 | } |
1349 | 1349 | |
1350 | 1350 | |
@@ -1356,17 +1356,17 @@ discard block |
||
1356 | 1356 | * @param string $REG_code Registration Code |
1357 | 1357 | * @param boolean $use_default |
1358 | 1358 | */ |
1359 | - public function set_reg_code( $REG_code, $use_default = FALSE ) { |
|
1360 | - if ( empty( $REG_code )) { |
|
1361 | - EE_Error::add_error( __( 'REG_code can not be empty.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
1359 | + public function set_reg_code($REG_code, $use_default = FALSE) { |
|
1360 | + if (empty($REG_code)) { |
|
1361 | + EE_Error::add_error(__('REG_code can not be empty.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1362 | 1362 | return; |
1363 | 1363 | } |
1364 | - if ( ! $this->reg_code() ) { |
|
1365 | - parent::set( 'REG_code', $REG_code, $use_default ); |
|
1364 | + if ( ! $this->reg_code()) { |
|
1365 | + parent::set('REG_code', $REG_code, $use_default); |
|
1366 | 1366 | } else { |
1367 | 1367 | EE_Error::doing_it_wrong( |
1368 | - __CLASS__ . '::' . __FUNCTION__, |
|
1369 | - __( 'Can not change a registration REG_code once it has been set.', 'event_espresso' ), |
|
1368 | + __CLASS__.'::'.__FUNCTION__, |
|
1369 | + __('Can not change a registration REG_code once it has been set.', 'event_espresso'), |
|
1370 | 1370 | '4.6.0' |
1371 | 1371 | ); |
1372 | 1372 | } |
@@ -1386,17 +1386,17 @@ discard block |
||
1386 | 1386 | * @return EE_Registration[] or empty array if this isn't a group registration. |
1387 | 1387 | */ |
1388 | 1388 | public function get_all_other_registrations_in_group() { |
1389 | - if ( $this->group_size() < 2 ) { |
|
1389 | + if ($this->group_size() < 2) { |
|
1390 | 1390 | return array(); |
1391 | 1391 | } |
1392 | 1392 | |
1393 | 1393 | $query[0] = array( |
1394 | 1394 | 'TXN_ID' => $this->transaction_ID(), |
1395 | - 'REG_ID' => array( '!=', $this->ID() ), |
|
1395 | + 'REG_ID' => array('!=', $this->ID()), |
|
1396 | 1396 | 'TKT_ID' => $this->ticket_ID() |
1397 | 1397 | ); |
1398 | 1398 | |
1399 | - $registrations = $this->get_model()->get_all( $query ); |
|
1399 | + $registrations = $this->get_model()->get_all($query); |
|
1400 | 1400 | return $registrations; |
1401 | 1401 | } |
1402 | 1402 | |
@@ -1405,14 +1405,14 @@ discard block |
||
1405 | 1405 | * @return string |
1406 | 1406 | */ |
1407 | 1407 | public function get_admin_details_link() { |
1408 | - EE_Registry::instance()->load_helper( 'URL' ); |
|
1408 | + EE_Registry::instance()->load_helper('URL'); |
|
1409 | 1409 | return EEH_URL::add_query_args_and_nonce( |
1410 | 1410 | array( |
1411 | 1411 | 'page' => 'espresso_registrations', |
1412 | 1412 | 'action' => 'view_registration', |
1413 | 1413 | '_REG_ID' => $this->ID() |
1414 | 1414 | ), |
1415 | - admin_url( 'admin.php' ) |
|
1415 | + admin_url('admin.php') |
|
1416 | 1416 | ); |
1417 | 1417 | } |
1418 | 1418 | |
@@ -1437,12 +1437,12 @@ discard block |
||
1437 | 1437 | * @return string |
1438 | 1438 | */ |
1439 | 1439 | public function get_admin_overview_link() { |
1440 | - EE_Registry::instance()->load_helper( 'URL' ); |
|
1440 | + EE_Registry::instance()->load_helper('URL'); |
|
1441 | 1441 | return EEH_URL::add_query_args_and_nonce( |
1442 | 1442 | array( |
1443 | 1443 | 'page' => 'espresso_registrations' |
1444 | 1444 | ), |
1445 | - admin_url( 'admin.php' ) |
|
1445 | + admin_url('admin.php') |
|
1446 | 1446 | ); |
1447 | 1447 | } |
1448 | 1448 | |
@@ -1453,8 +1453,8 @@ discard block |
||
1453 | 1453 | * @return \EE_Registration[] |
1454 | 1454 | * @throws \EE_Error |
1455 | 1455 | */ |
1456 | - public function payments( $query_params = array() ) { |
|
1457 | - return $this->get_many_related( 'Payment', $query_params ); |
|
1456 | + public function payments($query_params = array()) { |
|
1457 | + return $this->get_many_related('Payment', $query_params); |
|
1458 | 1458 | } |
1459 | 1459 | |
1460 | 1460 | |
@@ -1464,8 +1464,8 @@ discard block |
||
1464 | 1464 | * @return \EE_Registration_Payment[] |
1465 | 1465 | * @throws \EE_Error |
1466 | 1466 | */ |
1467 | - public function registration_payments( $query_params = array() ) { |
|
1468 | - return $this->get_many_related( 'Registration_Payment', $query_params ); |
|
1467 | + public function registration_payments($query_params = array()) { |
|
1468 | + return $this->get_many_related('Registration_Payment', $query_params); |
|
1469 | 1469 | } |
1470 | 1470 | |
1471 | 1471 | |
@@ -1478,7 +1478,7 @@ discard block |
||
1478 | 1478 | * @return EE_Payment_Method|null |
1479 | 1479 | */ |
1480 | 1480 | public function payment_method() { |
1481 | - return EEM_Payment_Method::instance()->get_last_used_for_registration( $this ); |
|
1481 | + return EEM_Payment_Method::instance()->get_last_used_for_registration($this); |
|
1482 | 1482 | } |
1483 | 1483 | |
1484 | 1484 | |
@@ -1525,7 +1525,7 @@ discard block |
||
1525 | 1525 | */ |
1526 | 1526 | public function delete() |
1527 | 1527 | { |
1528 | - if($this->update_extra_meta(EE_Registration::PRE_TRASH_REG_STATUS_KEY, $this->status_ID()) === true) { |
|
1528 | + if ($this->update_extra_meta(EE_Registration::PRE_TRASH_REG_STATUS_KEY, $this->status_ID()) === true) { |
|
1529 | 1529 | $this->set_status(EEM_Registration::status_id_cancelled); |
1530 | 1530 | } |
1531 | 1531 | return parent::delete(); |
@@ -6,21 +6,21 @@ discard block |
||
6 | 6 | * @subpackage |
7 | 7 | * @author Mike Nelson |
8 | 8 | */ |
9 | -class EE_Datepicker_Input extends EE_Form_Input_Base{ |
|
9 | +class EE_Datepicker_Input extends EE_Form_Input_Base { |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * @param array $input_settings |
13 | 13 | */ |
14 | - function __construct( $input_settings = array() ){ |
|
15 | - $this->_set_display_strategy( new EE_Text_Input_Display_Strategy( 'datepicker' ) ); |
|
16 | - $this->_set_normalization_strategy( new EE_Text_Normalization() ); |
|
14 | + function __construct($input_settings = array()) { |
|
15 | + $this->_set_display_strategy(new EE_Text_Input_Display_Strategy('datepicker')); |
|
16 | + $this->_set_normalization_strategy(new EE_Text_Normalization()); |
|
17 | 17 | //we could do better for validation, but at least verify its plaintext |
18 | - $this->_add_validation_strategy( new EE_Plaintext_Validation_Strategy( isset( $input_settings[ 'validation_error_message' ] ) ? $input_settings[ 'validation_error_message' ] : NULL ) ); |
|
19 | - parent::__construct( $input_settings ); |
|
20 | - $this->set_html_class( $this->html_class() . ' datepicker' ); |
|
18 | + $this->_add_validation_strategy(new EE_Plaintext_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : NULL)); |
|
19 | + parent::__construct($input_settings); |
|
20 | + $this->set_html_class($this->html_class().' datepicker'); |
|
21 | 21 | // add some style and make it dance |
22 | - add_action( 'wp_enqueue_scripts', array( 'EE_Datepicker_Input', 'enqueue_styles_and_scripts' )); |
|
23 | - add_action( 'admin_enqueue_scripts', array( 'EE_Datepicker_Input', 'enqueue_styles_and_scripts' )); |
|
22 | + add_action('wp_enqueue_scripts', array('EE_Datepicker_Input', 'enqueue_styles_and_scripts')); |
|
23 | + add_action('admin_enqueue_scripts', array('EE_Datepicker_Input', 'enqueue_styles_and_scripts')); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | |
@@ -33,8 +33,8 @@ discard block |
||
33 | 33 | */ |
34 | 34 | public static function enqueue_styles_and_scripts() { |
35 | 35 | // load css |
36 | - wp_register_style( 'espresso-ui-theme', EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION ); |
|
37 | - wp_enqueue_style( 'espresso-ui-theme'); |
|
36 | + wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL.'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION); |
|
37 | + wp_enqueue_style('espresso-ui-theme'); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 |
@@ -17,67 +17,67 @@ discard block |
||
17 | 17 | class EEH_Schema { |
18 | 18 | |
19 | 19 | |
20 | - /** |
|
21 | - * generates JSON-based linked data for an event |
|
22 | - * |
|
23 | - * @param \EE_Event $event |
|
24 | - */ |
|
25 | - public static function add_json_linked_data_for_event(\EE_Event $event) |
|
26 | - { |
|
27 | - //Check we have a valid datetime for the event |
|
28 | - if(! $event->primary_datetime() instanceof EE_Datetime) { |
|
29 | - return; |
|
30 | - } |
|
31 | - |
|
32 | - $template_args = array( |
|
33 | - 'event_permalink' => '', |
|
34 | - 'event_name' => '', |
|
35 | - 'event_description' => '', |
|
36 | - 'event_start' => '', |
|
37 | - 'event_end' => '', |
|
38 | - 'currency' => '', |
|
39 | - 'event_tickets' => array(), |
|
40 | - 'venue_name' => '', |
|
41 | - 'venue_url' => '', |
|
42 | - 'venue_locality' => '', |
|
43 | - 'venue_region' => '', |
|
44 | - 'event_image' => '', |
|
45 | - ); |
|
46 | - $template_args['event_permalink'] = $event->get_permalink(); |
|
47 | - $template_args['event_name'] = $event->name(); |
|
48 | - $template_args['event_description'] = wp_strip_all_tags($event->short_description(200)); |
|
49 | - $template_args['event_start'] = $event->primary_datetime()->start_date(DateTime::ATOM); |
|
50 | - $template_args['event_end'] = $event->primary_datetime()->end_date(DateTime::ATOM); |
|
51 | - $template_args['currency'] = EE_Registry::instance()->CFG->currency->code; |
|
52 | - foreach ($event->tickets() as $ticket) { |
|
53 | - $ID = $ticket->ID(); |
|
54 | - $template_args['event_tickets'][$ID]['start_date'] = $ticket->start_date(DateTime::ATOM, null); |
|
55 | - $template_args['event_tickets'][$ID]['end_date'] = $ticket->end_date(DateTime::ATOM, null); |
|
56 | - $template_args['event_tickets'][$ID]['price'] = number_format( |
|
57 | - $ticket->price(), |
|
58 | - EE_Registry::instance()->CFG->currency->dec_plc, |
|
59 | - EE_Registry::instance()->CFG->currency->dec_mrk, |
|
60 | - EE_Registry::instance()->CFG->currency->thsnds |
|
61 | - ); |
|
62 | - } |
|
63 | - $VNU_ID = espresso_venue_id(); |
|
64 | - if ( ! empty($VNU_ID) && ! espresso_is_venue_private($VNU_ID)) { |
|
65 | - $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
66 | - $template_args['venue_name'] = get_the_title($VNU_ID); |
|
67 | - $template_args['venue_url'] = get_permalink($VNU_ID); |
|
68 | - $template_args['venue_locality'] = $venue->city(); |
|
69 | - $template_args['venue_region'] = $venue->state_name(); |
|
70 | - } |
|
71 | - $template_args['event_image'] = $event->feature_image_url(); |
|
72 | - $template_args = apply_filters( |
|
73 | - 'FHEE__EEH_Schema__add_json_linked_data_for_event__template_args', |
|
74 | - $template_args, |
|
75 | - $event, |
|
76 | - $VNU_ID |
|
77 | - ); |
|
78 | - extract($template_args, EXTR_OVERWRITE); |
|
79 | - include EE_TEMPLATES . 'json_linked_data_for_event.template.php'; |
|
80 | - } |
|
20 | + /** |
|
21 | + * generates JSON-based linked data for an event |
|
22 | + * |
|
23 | + * @param \EE_Event $event |
|
24 | + */ |
|
25 | + public static function add_json_linked_data_for_event(\EE_Event $event) |
|
26 | + { |
|
27 | + //Check we have a valid datetime for the event |
|
28 | + if(! $event->primary_datetime() instanceof EE_Datetime) { |
|
29 | + return; |
|
30 | + } |
|
31 | + |
|
32 | + $template_args = array( |
|
33 | + 'event_permalink' => '', |
|
34 | + 'event_name' => '', |
|
35 | + 'event_description' => '', |
|
36 | + 'event_start' => '', |
|
37 | + 'event_end' => '', |
|
38 | + 'currency' => '', |
|
39 | + 'event_tickets' => array(), |
|
40 | + 'venue_name' => '', |
|
41 | + 'venue_url' => '', |
|
42 | + 'venue_locality' => '', |
|
43 | + 'venue_region' => '', |
|
44 | + 'event_image' => '', |
|
45 | + ); |
|
46 | + $template_args['event_permalink'] = $event->get_permalink(); |
|
47 | + $template_args['event_name'] = $event->name(); |
|
48 | + $template_args['event_description'] = wp_strip_all_tags($event->short_description(200)); |
|
49 | + $template_args['event_start'] = $event->primary_datetime()->start_date(DateTime::ATOM); |
|
50 | + $template_args['event_end'] = $event->primary_datetime()->end_date(DateTime::ATOM); |
|
51 | + $template_args['currency'] = EE_Registry::instance()->CFG->currency->code; |
|
52 | + foreach ($event->tickets() as $ticket) { |
|
53 | + $ID = $ticket->ID(); |
|
54 | + $template_args['event_tickets'][$ID]['start_date'] = $ticket->start_date(DateTime::ATOM, null); |
|
55 | + $template_args['event_tickets'][$ID]['end_date'] = $ticket->end_date(DateTime::ATOM, null); |
|
56 | + $template_args['event_tickets'][$ID]['price'] = number_format( |
|
57 | + $ticket->price(), |
|
58 | + EE_Registry::instance()->CFG->currency->dec_plc, |
|
59 | + EE_Registry::instance()->CFG->currency->dec_mrk, |
|
60 | + EE_Registry::instance()->CFG->currency->thsnds |
|
61 | + ); |
|
62 | + } |
|
63 | + $VNU_ID = espresso_venue_id(); |
|
64 | + if ( ! empty($VNU_ID) && ! espresso_is_venue_private($VNU_ID)) { |
|
65 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
66 | + $template_args['venue_name'] = get_the_title($VNU_ID); |
|
67 | + $template_args['venue_url'] = get_permalink($VNU_ID); |
|
68 | + $template_args['venue_locality'] = $venue->city(); |
|
69 | + $template_args['venue_region'] = $venue->state_name(); |
|
70 | + } |
|
71 | + $template_args['event_image'] = $event->feature_image_url(); |
|
72 | + $template_args = apply_filters( |
|
73 | + 'FHEE__EEH_Schema__add_json_linked_data_for_event__template_args', |
|
74 | + $template_args, |
|
75 | + $event, |
|
76 | + $VNU_ID |
|
77 | + ); |
|
78 | + extract($template_args, EXTR_OVERWRITE); |
|
79 | + include EE_TEMPLATES . 'json_linked_data_for_event.template.php'; |
|
80 | + } |
|
81 | 81 | |
82 | 82 | |
83 | 83 | /** |
@@ -91,8 +91,8 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public static function location( $location = null ) { |
93 | 93 | return ! empty( $location ) ? '<div itemprop="location" itemscope itemtype="http://schema.org/Place">' |
94 | - . $location |
|
95 | - . '</div>' : ''; |
|
94 | + . $location |
|
95 | + . '</div>' : ''; |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | |
@@ -212,8 +212,8 @@ discard block |
||
212 | 212 | */ |
213 | 213 | public static function postalCode( EEI_Address $obj_with_address = null ) { |
214 | 214 | return $obj_with_address->zip() !== null && $obj_with_address->zip() !== '' ? '<span itemprop="postalCode">' |
215 | - . $obj_with_address->zip() |
|
216 | - . '</span>' : ''; |
|
215 | + . $obj_with_address->zip() |
|
216 | + . '</span>' : ''; |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | //Check the URL includes a scheme |
248 | 248 | $parsed_url = parse_url($url); |
249 | 249 | if ( empty($parsed_url['scheme']) ) { |
250 | - $url = 'http://' . ltrim($url, '/'); |
|
250 | + $url = 'http://' . ltrim($url, '/'); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | $atts = ''; |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
4 | - exit( 'No direct script access allowed' ); |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | + exit('No direct script access allowed'); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | public static function add_json_linked_data_for_event(\EE_Event $event) |
26 | 26 | { |
27 | 27 | //Check we have a valid datetime for the event |
28 | - if(! $event->primary_datetime() instanceof EE_Datetime) { |
|
28 | + if ( ! $event->primary_datetime() instanceof EE_Datetime) { |
|
29 | 29 | return; |
30 | 30 | } |
31 | 31 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | $VNU_ID |
77 | 77 | ); |
78 | 78 | extract($template_args, EXTR_OVERWRITE); |
79 | - include EE_TEMPLATES . 'json_linked_data_for_event.template.php'; |
|
79 | + include EE_TEMPLATES.'json_linked_data_for_event.template.php'; |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | |
@@ -89,8 +89,8 @@ discard block |
||
89 | 89 | * @param string $location |
90 | 90 | * @return string |
91 | 91 | */ |
92 | - public static function location( $location = null ) { |
|
93 | - return ! empty( $location ) ? '<div itemprop="location" itemscope itemtype="http://schema.org/Place">' |
|
92 | + public static function location($location = null) { |
|
93 | + return ! empty($location) ? '<div itemprop="location" itemscope itemtype="http://schema.org/Place">' |
|
94 | 94 | . $location |
95 | 95 | . '</div>' : ''; |
96 | 96 | } |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | * @param string $name |
106 | 106 | * @return string |
107 | 107 | */ |
108 | - public static function name( $name = null ) { |
|
109 | - return ! empty( $name ) ? '<span itemprop="name">' . $name . '</span>' : ''; |
|
108 | + public static function name($name = null) { |
|
109 | + return ! empty($name) ? '<span itemprop="name">'.$name.'</span>' : ''; |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | * @param EEI_Address $obj_with_address |
120 | 120 | * @return string |
121 | 121 | */ |
122 | - public static function streetAddress( EEI_Address $obj_with_address = null ) { |
|
122 | + public static function streetAddress(EEI_Address $obj_with_address = null) { |
|
123 | 123 | return $obj_with_address->address() !== null && $obj_with_address->address() !== '' |
124 | - ? '<span itemprop="streetAddress">' . $obj_with_address->address() . '</span>' : ''; |
|
124 | + ? '<span itemprop="streetAddress">'.$obj_with_address->address().'</span>' : ''; |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | |
@@ -134,14 +134,14 @@ discard block |
||
134 | 134 | * @param EEI_Address $obj_with_address |
135 | 135 | * @return string |
136 | 136 | */ |
137 | - public static function postOfficeBoxNumber( EEI_Address $obj_with_address = null ) { |
|
137 | + public static function postOfficeBoxNumber(EEI_Address $obj_with_address = null) { |
|
138 | 138 | // regex check for some form of PO Box or P.O. Box, etc, etc, etc |
139 | - if ( preg_match( |
|
139 | + if (preg_match( |
|
140 | 140 | "/^\s*((P(OST)?.?\s*(O(FF(ICE)?)?)?.?\s+(B(IN|OX))?)|B(IN|OX))/i", |
141 | 141 | $obj_with_address->address2() |
142 | - ) ) { |
|
142 | + )) { |
|
143 | 143 | return $obj_with_address->address2() !== null && $obj_with_address->address2() !== '' |
144 | - ? '<span itemprop="postOfficeBoxNumber">' . $obj_with_address->address2() . '</span>' : ''; |
|
144 | + ? '<span itemprop="postOfficeBoxNumber">'.$obj_with_address->address2().'</span>' : ''; |
|
145 | 145 | } else { |
146 | 146 | return $obj_with_address->address2(); |
147 | 147 | } |
@@ -157,9 +157,9 @@ discard block |
||
157 | 157 | * @param EEI_Address $obj_with_address |
158 | 158 | * @return string |
159 | 159 | */ |
160 | - public static function addressLocality( EEI_Address $obj_with_address = null ) { |
|
160 | + public static function addressLocality(EEI_Address $obj_with_address = null) { |
|
161 | 161 | return $obj_with_address->city() !== null && $obj_with_address->city() !== '' |
162 | - ? '<span itemprop="addressLocality">' . $obj_with_address->city() . '</span>' : ''; |
|
162 | + ? '<span itemprop="addressLocality">'.$obj_with_address->city().'</span>' : ''; |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | |
@@ -172,10 +172,10 @@ discard block |
||
172 | 172 | * @param EEI_Address $obj_with_address |
173 | 173 | * @return string |
174 | 174 | */ |
175 | - public static function addressRegion( EEI_Address $obj_with_address = null ) { |
|
175 | + public static function addressRegion(EEI_Address $obj_with_address = null) { |
|
176 | 176 | $state = $obj_with_address->state_name(); |
177 | - if ( ! empty( $state ) ) { |
|
178 | - return '<span itemprop="addressRegion">' . $state . '</span>'; |
|
177 | + if ( ! empty($state)) { |
|
178 | + return '<span itemprop="addressRegion">'.$state.'</span>'; |
|
179 | 179 | } else { |
180 | 180 | return ''; |
181 | 181 | } |
@@ -191,10 +191,10 @@ discard block |
||
191 | 191 | * @param EEI_Address $obj_with_address |
192 | 192 | * @return string |
193 | 193 | */ |
194 | - public static function addressCountry( EEI_Address $obj_with_address = null ) { |
|
194 | + public static function addressCountry(EEI_Address $obj_with_address = null) { |
|
195 | 195 | $country = $obj_with_address->country_name(); |
196 | - if ( ! empty( $country ) ) { |
|
197 | - return '<span itemprop="addressCountry">' . $country . '</span>'; |
|
196 | + if ( ! empty($country)) { |
|
197 | + return '<span itemprop="addressCountry">'.$country.'</span>'; |
|
198 | 198 | } else { |
199 | 199 | return ''; |
200 | 200 | } |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | * @param EEI_Address $obj_with_address |
211 | 211 | * @return string |
212 | 212 | */ |
213 | - public static function postalCode( EEI_Address $obj_with_address = null ) { |
|
213 | + public static function postalCode(EEI_Address $obj_with_address = null) { |
|
214 | 214 | return $obj_with_address->zip() !== null && $obj_with_address->zip() !== '' ? '<span itemprop="postalCode">' |
215 | 215 | . $obj_with_address->zip() |
216 | 216 | . '</span>' : ''; |
@@ -226,8 +226,8 @@ discard block |
||
226 | 226 | * @param string $phone_nmbr |
227 | 227 | * @return string |
228 | 228 | */ |
229 | - public static function telephone( $phone_nmbr = null ) { |
|
230 | - return $phone_nmbr !== null && $phone_nmbr !== '' ? '<span itemprop="telephone">' . $phone_nmbr . '</span>' |
|
229 | + public static function telephone($phone_nmbr = null) { |
|
230 | + return $phone_nmbr !== null && $phone_nmbr !== '' ? '<span itemprop="telephone">'.$phone_nmbr.'</span>' |
|
231 | 231 | : ''; |
232 | 232 | } |
233 | 233 | |
@@ -243,19 +243,19 @@ discard block |
||
243 | 243 | * @param array $attributes - array of additional link attributes in attribute_name => value pairs. ie: array( 'title' => 'click here', 'class' => 'link-class' ) |
244 | 244 | * @return string (link) |
245 | 245 | */ |
246 | - public static function url( $url = null, $text = null, $attributes = array() ) { |
|
246 | + public static function url($url = null, $text = null, $attributes = array()) { |
|
247 | 247 | //Check the URL includes a scheme |
248 | 248 | $parsed_url = parse_url($url); |
249 | - if ( empty($parsed_url['scheme']) ) { |
|
250 | - $url = 'http://' . ltrim($url, '/'); |
|
249 | + if (empty($parsed_url['scheme'])) { |
|
250 | + $url = 'http://'.ltrim($url, '/'); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | $atts = ''; |
254 | - foreach ( $attributes as $attribute => $value ) { |
|
255 | - $atts .= ' ' . $attribute . '="' . $value . '"'; |
|
254 | + foreach ($attributes as $attribute => $value) { |
|
255 | + $atts .= ' '.$attribute.'="'.$value.'"'; |
|
256 | 256 | } |
257 | 257 | $text = $text !== null && $text !== '' ? $text : $url; |
258 | - return $url !== null && $url !== '' ? '<a itemprop="url" href="' . $url . '"' . $atts . '>' . $text . '</a>' |
|
258 | + return $url !== null && $url !== '' ? '<a itemprop="url" href="'.$url.'"'.$atts.'>'.$text.'</a>' |
|
259 | 259 | : ''; |
260 | 260 | } |
261 | 261 |
@@ -42,27 +42,27 @@ discard block |
||
42 | 42 | |
43 | 43 | /** |
44 | 44 | * Handles the request for public site info |
45 | - * @global $wp_json_basic_auth_success boolean set by the basic auth plugin, indicates if the current user could be authenticated using basic auth data |
|
46 | - * @global $wp_json_basic_auth_received_data boolean set by the basic auth plugin, indicates if basic auth data was somehow received |
|
45 | + * @global $wp_json_basic_auth_success boolean set by the basic auth plugin, indicates if the current user could be authenticated using basic auth data |
|
46 | + * @global $wp_json_basic_auth_received_data boolean set by the basic auth plugin, indicates if basic auth data was somehow received |
|
47 | 47 | * @param \WP_REST_Request $request |
48 | 48 | * @return \EE_Config|\WP_Error |
49 | 49 | */ |
50 | 50 | public static function handle_request_site_info( \WP_REST_Request $request) { |
51 | - global $wp_json_basic_auth_success, $wp_json_basic_auth_received_data; |
|
52 | - $insecure_usage_of_basic_auth = apply_filters( |
|
53 | - 'EventEspresso__core__libraries__rest_api__controllers__config__handle_request_site_info__insecure_usage_of_basic_auth', |
|
54 | - $wp_json_basic_auth_success && ! is_ssl(), |
|
55 | - $request |
|
56 | - ); |
|
57 | - if( $insecure_usage_of_basic_auth ) { |
|
58 | - $warning = sprintf( |
|
59 | - esc_html__( 'Your data is not secured with SSL. %1$sPlease see our recommendations.%2$s', 'event_espresso' ), |
|
60 | - '<a href="https://eventespresso.com/wiki/rest-api-security-recommendations/">', |
|
61 | - '</a>' |
|
62 | - ); |
|
63 | - } else { |
|
64 | - $warning = ''; |
|
65 | - } |
|
51 | + global $wp_json_basic_auth_success, $wp_json_basic_auth_received_data; |
|
52 | + $insecure_usage_of_basic_auth = apply_filters( |
|
53 | + 'EventEspresso__core__libraries__rest_api__controllers__config__handle_request_site_info__insecure_usage_of_basic_auth', |
|
54 | + $wp_json_basic_auth_success && ! is_ssl(), |
|
55 | + $request |
|
56 | + ); |
|
57 | + if( $insecure_usage_of_basic_auth ) { |
|
58 | + $warning = sprintf( |
|
59 | + esc_html__( 'Your data is not secured with SSL. %1$sPlease see our recommendations.%2$s', 'event_espresso' ), |
|
60 | + '<a href="https://eventespresso.com/wiki/rest-api-security-recommendations/">', |
|
61 | + '</a>' |
|
62 | + ); |
|
63 | + } else { |
|
64 | + $warning = ''; |
|
65 | + } |
|
66 | 66 | return array( |
67 | 67 | 'default_timezone' => array( |
68 | 68 | 'pretty' => \EEH_DTT_Helper::get_timezone_string_for_display(), |
@@ -70,11 +70,11 @@ discard block |
||
70 | 70 | 'offset' => \EEH_DTT_Helper::get_site_timezone_gmt_offset(), |
71 | 71 | ), |
72 | 72 | 'default_currency' => \EE_Config::instance()->currency, |
73 | - 'authentication' => array( |
|
74 | - 'received_basic_auth_data' => (bool)$wp_json_basic_auth_received_data, |
|
75 | - 'insecure_usage_of_basic_auth' => (bool)$insecure_usage_of_basic_auth, |
|
76 | - 'warning' => $warning |
|
77 | - ) |
|
73 | + 'authentication' => array( |
|
74 | + 'received_basic_auth_data' => (bool)$wp_json_basic_auth_received_data, |
|
75 | + 'insecure_usage_of_basic_auth' => (bool)$insecure_usage_of_basic_auth, |
|
76 | + 'warning' => $warning |
|
77 | + ) |
|
78 | 78 | ); |
79 | 79 | } |
80 | 80 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\libraries\rest_api\controllers\config; |
3 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
4 | - exit( 'No direct script access allowed' ); |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | + exit('No direct script access allowed'); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | /** |
@@ -21,11 +21,11 @@ discard block |
||
21 | 21 | * @param \WP_REST_Request $request |
22 | 22 | * @return \EE_Config|\WP_Error |
23 | 23 | */ |
24 | - public static function handle_request( \WP_REST_Request $request) { |
|
24 | + public static function handle_request(\WP_REST_Request $request) { |
|
25 | 25 | $cap = \EE_Restriction_Generator_Base::get_default_restrictions_cap(); |
26 | - if( \EE_Capabilities::instance()->current_user_can( $cap, 'read_over_api' ) ){ |
|
26 | + if (\EE_Capabilities::instance()->current_user_can($cap, 'read_over_api')) { |
|
27 | 27 | return \EE_Config::instance(); |
28 | - }else{ |
|
28 | + } else { |
|
29 | 29 | return new \WP_Error( |
30 | 30 | 'cannot_read_config', |
31 | 31 | sprintf( |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | ), |
36 | 36 | $cap |
37 | 37 | ), |
38 | - array( 'status' => 403 ) |
|
38 | + array('status' => 403) |
|
39 | 39 | ); |
40 | 40 | } |
41 | 41 | } |
@@ -47,16 +47,16 @@ discard block |
||
47 | 47 | * @param \WP_REST_Request $request |
48 | 48 | * @return \EE_Config|\WP_Error |
49 | 49 | */ |
50 | - public static function handle_request_site_info( \WP_REST_Request $request) { |
|
50 | + public static function handle_request_site_info(\WP_REST_Request $request) { |
|
51 | 51 | global $wp_json_basic_auth_success, $wp_json_basic_auth_received_data; |
52 | 52 | $insecure_usage_of_basic_auth = apply_filters( |
53 | 53 | 'EventEspresso__core__libraries__rest_api__controllers__config__handle_request_site_info__insecure_usage_of_basic_auth', |
54 | 54 | $wp_json_basic_auth_success && ! is_ssl(), |
55 | 55 | $request |
56 | 56 | ); |
57 | - if( $insecure_usage_of_basic_auth ) { |
|
57 | + if ($insecure_usage_of_basic_auth) { |
|
58 | 58 | $warning = sprintf( |
59 | - esc_html__( 'Your data is not secured with SSL. %1$sPlease see our recommendations.%2$s', 'event_espresso' ), |
|
59 | + esc_html__('Your data is not secured with SSL. %1$sPlease see our recommendations.%2$s', 'event_espresso'), |
|
60 | 60 | '<a href="https://eventespresso.com/wiki/rest-api-security-recommendations/">', |
61 | 61 | '</a>' |
62 | 62 | ); |
@@ -66,13 +66,13 @@ discard block |
||
66 | 66 | return array( |
67 | 67 | 'default_timezone' => array( |
68 | 68 | 'pretty' => \EEH_DTT_Helper::get_timezone_string_for_display(), |
69 | - 'string' => get_option( 'timezone_string' ), |
|
69 | + 'string' => get_option('timezone_string'), |
|
70 | 70 | 'offset' => \EEH_DTT_Helper::get_site_timezone_gmt_offset(), |
71 | 71 | ), |
72 | 72 | 'default_currency' => \EE_Config::instance()->currency, |
73 | 73 | 'authentication' => array( |
74 | - 'received_basic_auth_data' => (bool)$wp_json_basic_auth_received_data, |
|
75 | - 'insecure_usage_of_basic_auth' => (bool)$insecure_usage_of_basic_auth, |
|
74 | + 'received_basic_auth_data' => (bool) $wp_json_basic_auth_received_data, |
|
75 | + 'insecure_usage_of_basic_auth' => (bool) $insecure_usage_of_basic_auth, |
|
76 | 76 | 'warning' => $warning |
77 | 77 | ) |
78 | 78 | ); |
@@ -19,398 +19,398 @@ |
||
19 | 19 | class TicketSelectorRowStandard extends TicketSelectorRow |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * @var TicketDetails $ticket_details |
|
24 | - */ |
|
25 | - protected $ticket_details; |
|
26 | - |
|
27 | - /** |
|
28 | - * @var \EE_Ticket_Selector_Config $template_settings |
|
29 | - */ |
|
30 | - protected $template_settings; |
|
31 | - |
|
32 | - /** |
|
33 | - * @var \EE_Tax_Config $tax_settings |
|
34 | - */ |
|
35 | - protected $tax_settings; |
|
36 | - |
|
37 | - /** |
|
38 | - * @var boolean $prices_displayed_including_taxes |
|
39 | - */ |
|
40 | - protected $prices_displayed_including_taxes; |
|
41 | - |
|
42 | - /** |
|
43 | - * @var int $row |
|
44 | - */ |
|
45 | - protected $row; |
|
46 | - |
|
47 | - /** |
|
48 | - * @var int $cols |
|
49 | - */ |
|
50 | - protected $cols; |
|
51 | - |
|
52 | - /** |
|
53 | - * @var boolean $hidden_input_qty |
|
54 | - */ |
|
55 | - protected $hidden_input_qty; |
|
56 | - |
|
57 | - /** |
|
58 | - * @var string $ticket_datetime_classes |
|
59 | - */ |
|
60 | - protected $ticket_datetime_classes; |
|
61 | - |
|
62 | - |
|
63 | - |
|
64 | - /** |
|
65 | - * TicketDetails constructor. |
|
66 | - * |
|
67 | - * @param TicketDetails $ticket_details |
|
68 | - * @param \EE_Tax_Config $tax_settings |
|
69 | - * @param int $total_tickets |
|
70 | - * @param int $max_atndz |
|
71 | - * @param int $row |
|
72 | - * @param int $cols |
|
73 | - * @param boolean $required_ticket_sold_out |
|
74 | - * @param string $event_status |
|
75 | - * @param string $ticket_datetime_classes |
|
76 | - * @throws EE_Error |
|
77 | - * @throws UnexpectedEntityException |
|
78 | - */ |
|
79 | - public function __construct( |
|
80 | - TicketDetails $ticket_details, |
|
81 | - \EE_Tax_Config $tax_settings, |
|
82 | - $total_tickets, |
|
83 | - $max_atndz, |
|
84 | - $row, |
|
85 | - $cols, |
|
86 | - $required_ticket_sold_out, |
|
87 | - $event_status, |
|
88 | - $ticket_datetime_classes |
|
89 | - ) { |
|
90 | - $this->ticket = $ticket_details->getTicket(); |
|
91 | - $this->ticket_details = $ticket_details; |
|
92 | - $this->template_settings = $ticket_details->getTemplateSettings(); |
|
93 | - $this->tax_settings = $tax_settings; |
|
94 | - $this->total_tickets = $total_tickets; |
|
95 | - $this->max_atndz = $max_atndz; |
|
96 | - $this->row = $row; |
|
97 | - $this->cols = $cols; |
|
98 | - $this->date_format = $ticket_details->getDateFormat(); |
|
99 | - $this->ticket_datetime_classes = $ticket_datetime_classes; |
|
100 | - parent::__construct($this->ticket, $max_atndz, $this->date_format, $event_status, $required_ticket_sold_out); |
|
101 | - } |
|
102 | - |
|
103 | - |
|
104 | - |
|
105 | - /** |
|
106 | - * other ticket rows will need to know if a required ticket is sold out, |
|
107 | - * so that they are not offered for sale |
|
108 | - * |
|
109 | - * @return boolean |
|
110 | - */ |
|
111 | - public function getRequiredTicketSoldOut() |
|
112 | - { |
|
113 | - return $this->required_ticket_sold_out; |
|
114 | - } |
|
115 | - |
|
116 | - |
|
117 | - |
|
118 | - /** |
|
119 | - * @return int |
|
120 | - */ |
|
121 | - public function getCols() |
|
122 | - { |
|
123 | - return $this->cols; |
|
124 | - } |
|
125 | - |
|
126 | - |
|
127 | - |
|
128 | - /** |
|
129 | - * getHtml |
|
130 | - * |
|
131 | - * @return string |
|
132 | - * @throws EE_Error |
|
133 | - */ |
|
134 | - public function getHtml() |
|
135 | - { |
|
136 | - $min = 0; |
|
137 | - $max = $this->ticket->max(); |
|
138 | - $remaining = $this->ticket->remaining(); |
|
139 | - if ($this->ticket->is_on_sale() && $this->ticket->is_remaining()) { |
|
140 | - list($min, $max) = $this->setTicketMinAndMax($remaining); |
|
141 | - } else { |
|
142 | - // set flag if ticket is required (flag is set to start date so that future tickets are not blocked) |
|
143 | - $this->required_ticket_sold_out = $this->ticket->required() && ! $remaining |
|
144 | - ? $this->ticket->start_date() |
|
145 | - : $this->required_ticket_sold_out; |
|
146 | - } |
|
147 | - list($ticket_price, $ticket_bundle) = $this->getTicketPriceDetails(); |
|
148 | - list($tkt_status, $ticket_status, $status_class) = $this->getTicketStatusClasses($remaining); |
|
149 | - /** |
|
150 | - * Allow plugins to hook in and abort the generation and display of this row to do |
|
151 | - * something else if they want. |
|
152 | - * For an addon to abort things, all they have to do is register a filter with this hook, and |
|
153 | - * return a value that is NOT false. Whatever is returned gets echoed instead of the |
|
154 | - * current row. |
|
155 | - * |
|
156 | - * @var string|bool |
|
157 | - */ |
|
158 | - $ticket_selector_row_html = apply_filters( |
|
159 | - 'FHEE__ticket_selector_chart_template__do_ticket_entire_row', |
|
160 | - false, |
|
161 | - $this->ticket, |
|
162 | - $max, |
|
163 | - $min, |
|
164 | - $this->required_ticket_sold_out, |
|
165 | - $ticket_price, |
|
166 | - $ticket_bundle, |
|
167 | - $ticket_status, |
|
168 | - $status_class |
|
169 | - ); |
|
170 | - if ($ticket_selector_row_html !== false) { |
|
171 | - return $ticket_selector_row_html; |
|
172 | - } |
|
173 | - $ticket_selector_row_html = \EEH_HTML::tr( |
|
174 | - '', '', |
|
175 | - "tckt-slctr-tbl-tr {$status_class}{$this->ticket_datetime_classes} " . espresso_get_object_css_class($this->ticket) |
|
176 | - ); |
|
177 | - /** |
|
178 | - * Allow plugins to hook in and abort the generation and display of the contents of this |
|
179 | - * row to do something else if they want. |
|
180 | - * For an addon to abort things, all they have to do is register a filter with this hook, and |
|
181 | - * return a value that is NOT false. Whatever is returned gets echoed instead of the |
|
182 | - * current row. |
|
183 | - * |
|
184 | - * @var string|bool |
|
185 | - */ |
|
186 | - $new_row_cells_content = apply_filters( |
|
187 | - 'FHEE__ticket_selector_chart_template__do_ticket_inside_row', |
|
188 | - false, |
|
189 | - $this->ticket, |
|
190 | - $max, |
|
191 | - $min, |
|
192 | - $this->required_ticket_sold_out, |
|
193 | - $ticket_price, |
|
194 | - $ticket_bundle, |
|
195 | - $ticket_status, |
|
196 | - $status_class |
|
197 | - ); |
|
198 | - if ($new_row_cells_content !== false) { |
|
199 | - return $ticket_selector_row_html |
|
200 | - . $new_row_cells_content |
|
201 | - . \EEH_HTML::trx(); |
|
202 | - } |
|
203 | - $this->hidden_input_qty = $this->max_atndz > 1 ? true : false; |
|
204 | - |
|
205 | - $ticket_selector_row_html .= $this->ticketNameTableCell(); |
|
206 | - $ticket_selector_row_html .= $this->ticketPriceTableCell($ticket_price, $ticket_bundle); |
|
207 | - $ticket_selector_row_html .= \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-qty cntr'); |
|
208 | - $this->setTicketStatusDisplay($tkt_status, $ticket_status, $remaining); |
|
209 | - if (empty($this->ticket_status_display)) { |
|
210 | - if ($this->max_atndz === 1) { |
|
211 | - // only ONE attendee is allowed to register at a time |
|
212 | - $ticket_selector_row_html .= $this->onlyOneAttendeeCanRegister(); |
|
213 | - } else if ($max > 0) { |
|
214 | - $ticket_selector_row_html .= $this->ticketQuantitySelector($min, $max); |
|
215 | - } |
|
216 | - } |
|
217 | - $ticket_selector_row_html .= $this->ticket_status_display; |
|
218 | - $ticket_selector_row_html .= $this->ticketQtyAndIdHiddenInputs(); |
|
219 | - $ticket_selector_row_html .= $this->ticket_details->display($ticket_price, $remaining, $this->cols); |
|
220 | - $ticket_selector_row_html .= \EEH_HTML::tdx(); |
|
221 | - $ticket_selector_row_html .= \EEH_HTML::trx(); |
|
222 | - |
|
223 | - |
|
224 | - $this->row++; |
|
225 | - return $ticket_selector_row_html; |
|
226 | - } |
|
227 | - |
|
228 | - |
|
229 | - |
|
230 | - /** |
|
231 | - * setTicketMinAndMax |
|
232 | - * |
|
233 | - * @param int $remaining |
|
234 | - * @return array |
|
235 | - * @throws EE_Error |
|
236 | - */ |
|
237 | - protected function setTicketMinAndMax($remaining) |
|
238 | - { |
|
239 | - // offer the number of $tickets_remaining or $this->max_atndz, whichever is smaller |
|
240 | - $max = min($remaining, $this->max_atndz); |
|
241 | - // but... we also want to restrict the number of tickets by the ticket max setting, |
|
242 | - // however, the max still can't be higher than what was just set above |
|
243 | - $max = $this->ticket->max() > 0 ? min($this->ticket->max(), $max) : $max; |
|
244 | - // and we also want to restrict the minimum number of tickets by the ticket min setting |
|
245 | - $min = $this->ticket->min() > 0 ? $this->ticket->min() : 0; |
|
246 | - // and if the ticket is required, then make sure that min qty is at least 1 |
|
247 | - $min = $this->ticket->required() ? max($min, 1) : $min; |
|
248 | - return array($min, $max); |
|
249 | - } |
|
250 | - |
|
251 | - |
|
252 | - |
|
253 | - /** |
|
254 | - * getTicketPriceDetails |
|
255 | - * |
|
256 | - * @return array |
|
257 | - * @throws EE_Error |
|
258 | - */ |
|
259 | - protected function getTicketPriceDetails() |
|
260 | - { |
|
261 | - $ticket_price = $this->tax_settings->prices_displayed_including_taxes |
|
262 | - ? $this->ticket->get_ticket_total_with_taxes() |
|
263 | - : $this->ticket->get_ticket_subtotal(); |
|
264 | - $ticket_bundle = false; |
|
265 | - $ticket_min = $this->ticket->min(); |
|
266 | - // for ticket bundles, set min and max qty the same |
|
267 | - if ($ticket_min !== 0 && $ticket_min === $this->ticket->max()) { |
|
268 | - $ticket_price *= $ticket_min; |
|
269 | - $ticket_bundle = true; |
|
270 | - } |
|
271 | - $ticket_price = apply_filters( |
|
272 | - 'FHEE__ticket_selector_chart_template__ticket_price', |
|
273 | - $ticket_price, |
|
274 | - $this->ticket |
|
275 | - ); |
|
276 | - return array($ticket_price, $ticket_bundle); |
|
277 | - } |
|
278 | - |
|
279 | - |
|
280 | - |
|
281 | - |
|
282 | - /** |
|
283 | - * ticketNameTableCell |
|
284 | - * |
|
285 | - * @return string |
|
286 | - * @throws EE_Error |
|
287 | - */ |
|
288 | - protected function ticketNameTableCell() |
|
289 | - { |
|
290 | - $html = \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-name'); |
|
291 | - $html .= \EEH_HTML::strong($this->ticket->get_pretty('TKT_name')); |
|
292 | - $html .= $this->ticket_details->getShowHideLinks(); |
|
293 | - if ($this->ticket->required()) { |
|
294 | - $html .= \EEH_HTML::p( |
|
295 | - apply_filters( |
|
296 | - 'FHEE__ticket_selector_chart_template__ticket_required_message', |
|
297 | - esc_html__('This ticket is required and must be purchased.', 'event_espresso') |
|
298 | - ), |
|
299 | - '', 'ticket-required-pg' |
|
300 | - ); |
|
301 | - } |
|
302 | - $html .= \EEH_HTML::tdx(); |
|
303 | - return $html; |
|
304 | - } |
|
305 | - |
|
306 | - |
|
307 | - |
|
308 | - /** |
|
309 | - * ticketPriceTableCell |
|
310 | - * |
|
311 | - * @param float $ticket_price |
|
312 | - * @param bool $ticket_bundle |
|
313 | - * @return string |
|
314 | - * @throws EE_Error |
|
315 | - */ |
|
316 | - protected function ticketPriceTableCell($ticket_price, $ticket_bundle) |
|
317 | - { |
|
318 | - $html = ''; |
|
319 | - if (apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', true)) { |
|
320 | - $html .= \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-price jst-rght'); |
|
321 | - $html .= \EEH_Template::format_currency($ticket_price); |
|
322 | - $html .= $this->ticket->taxable() |
|
323 | - ? \EEH_HTML::span( '*', '', 'taxable-tickets-asterisk grey-text' ) |
|
324 | - : ''; |
|
325 | - $html .= ' '; |
|
326 | - $html .= \EEH_HTML::span( |
|
327 | - $ticket_bundle |
|
328 | - ? apply_filters( |
|
329 | - 'FHEE__ticket_selector_chart_template__per_ticket_bundle_text', |
|
330 | - __(' / bundle', 'event_espresso') |
|
331 | - ) |
|
332 | - : apply_filters( |
|
333 | - 'FHEE__ticket_selector_chart_template__per_ticket_text', |
|
334 | - __('', 'event_espresso') |
|
335 | - ), |
|
336 | - '', 'smaller-text no-bold' |
|
337 | - ); |
|
338 | - $html .= ' '; |
|
339 | - $html .= \EEH_HTML::tdx(); |
|
340 | - $this->cols++; |
|
341 | - } |
|
342 | - return $html; |
|
343 | - } |
|
344 | - |
|
345 | - |
|
346 | - |
|
347 | - /** |
|
348 | - * onlyOneAttendeeCanRegister |
|
349 | - * |
|
350 | - * @return string |
|
351 | - */ |
|
352 | - protected function onlyOneAttendeeCanRegister() |
|
353 | - { |
|
354 | - // display submit button since we have tickets available |
|
355 | - add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
356 | - $this->hidden_input_qty = false; |
|
357 | - $html = '<input type="radio" name="tkt-slctr-qty-' . $this->EVT_ID . '"'; |
|
358 | - $html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"'; |
|
359 | - $html .= ' class="ticket-selector-tbl-qty-slct" value="' . $this->row . '-1"'; |
|
360 | - $html .= $this->total_tickets === 1 ? ' checked="checked"' : ''; |
|
361 | - $html .= ' title=""/>'; |
|
362 | - return $html; |
|
363 | - } |
|
364 | - |
|
365 | - |
|
366 | - |
|
367 | - /** |
|
368 | - * ticketQuantitySelector |
|
369 | - * |
|
370 | - * @param int $min |
|
371 | - * @param int $max |
|
372 | - * @return string |
|
373 | - * @throws EE_Error |
|
374 | - */ |
|
375 | - protected function ticketQuantitySelector($min = 0, $max = 0) |
|
376 | - { |
|
377 | - // display submit button since we have tickets available |
|
378 | - add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
379 | - $this->hidden_input_qty = false; |
|
380 | - $html = '<select name="tkt-slctr-qty-' . $this->EVT_ID . '[]"'; |
|
381 | - $html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"'; |
|
382 | - $html .= ' class="ticket-selector-tbl-qty-slct">'; |
|
383 | - // this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased |
|
384 | - if ($min !== 0 && ! $this->ticket->required()) { |
|
385 | - $html .= '<option value="0"> 0 </option>'; |
|
386 | - } |
|
387 | - // offer ticket quantities from the min to the max |
|
388 | - for ($i = $min; $i <= $max; $i++) { |
|
389 | - $html .= '<option value="' . $i . '"> ' . $i . ' </option>'; |
|
390 | - } |
|
391 | - $html .= '</select>'; |
|
392 | - return $html; |
|
393 | - } |
|
394 | - |
|
395 | - |
|
396 | - |
|
397 | - /** |
|
398 | - * getHiddenInputs |
|
399 | - * |
|
400 | - * @return string |
|
401 | - * @throws EE_Error |
|
402 | - */ |
|
403 | - protected function ticketQtyAndIdHiddenInputs() |
|
404 | - { |
|
405 | - $html = ''; |
|
406 | - // depending on group reg we need to change the format for qty |
|
407 | - if ($this->hidden_input_qty) { |
|
408 | - $html .= '<input type="hidden" name="tkt-slctr-qty-' . $this->EVT_ID . '[]" value="0"/>'; |
|
409 | - } |
|
410 | - $html .= '<input type="hidden" name="tkt-slctr-ticket-id-' . $this->EVT_ID . '[]"'; |
|
411 | - $html .= ' value="' . $this->ticket->ID() . '"/>'; |
|
412 | - return $html; |
|
413 | - } |
|
22 | + /** |
|
23 | + * @var TicketDetails $ticket_details |
|
24 | + */ |
|
25 | + protected $ticket_details; |
|
26 | + |
|
27 | + /** |
|
28 | + * @var \EE_Ticket_Selector_Config $template_settings |
|
29 | + */ |
|
30 | + protected $template_settings; |
|
31 | + |
|
32 | + /** |
|
33 | + * @var \EE_Tax_Config $tax_settings |
|
34 | + */ |
|
35 | + protected $tax_settings; |
|
36 | + |
|
37 | + /** |
|
38 | + * @var boolean $prices_displayed_including_taxes |
|
39 | + */ |
|
40 | + protected $prices_displayed_including_taxes; |
|
41 | + |
|
42 | + /** |
|
43 | + * @var int $row |
|
44 | + */ |
|
45 | + protected $row; |
|
46 | + |
|
47 | + /** |
|
48 | + * @var int $cols |
|
49 | + */ |
|
50 | + protected $cols; |
|
51 | + |
|
52 | + /** |
|
53 | + * @var boolean $hidden_input_qty |
|
54 | + */ |
|
55 | + protected $hidden_input_qty; |
|
56 | + |
|
57 | + /** |
|
58 | + * @var string $ticket_datetime_classes |
|
59 | + */ |
|
60 | + protected $ticket_datetime_classes; |
|
61 | + |
|
62 | + |
|
63 | + |
|
64 | + /** |
|
65 | + * TicketDetails constructor. |
|
66 | + * |
|
67 | + * @param TicketDetails $ticket_details |
|
68 | + * @param \EE_Tax_Config $tax_settings |
|
69 | + * @param int $total_tickets |
|
70 | + * @param int $max_atndz |
|
71 | + * @param int $row |
|
72 | + * @param int $cols |
|
73 | + * @param boolean $required_ticket_sold_out |
|
74 | + * @param string $event_status |
|
75 | + * @param string $ticket_datetime_classes |
|
76 | + * @throws EE_Error |
|
77 | + * @throws UnexpectedEntityException |
|
78 | + */ |
|
79 | + public function __construct( |
|
80 | + TicketDetails $ticket_details, |
|
81 | + \EE_Tax_Config $tax_settings, |
|
82 | + $total_tickets, |
|
83 | + $max_atndz, |
|
84 | + $row, |
|
85 | + $cols, |
|
86 | + $required_ticket_sold_out, |
|
87 | + $event_status, |
|
88 | + $ticket_datetime_classes |
|
89 | + ) { |
|
90 | + $this->ticket = $ticket_details->getTicket(); |
|
91 | + $this->ticket_details = $ticket_details; |
|
92 | + $this->template_settings = $ticket_details->getTemplateSettings(); |
|
93 | + $this->tax_settings = $tax_settings; |
|
94 | + $this->total_tickets = $total_tickets; |
|
95 | + $this->max_atndz = $max_atndz; |
|
96 | + $this->row = $row; |
|
97 | + $this->cols = $cols; |
|
98 | + $this->date_format = $ticket_details->getDateFormat(); |
|
99 | + $this->ticket_datetime_classes = $ticket_datetime_classes; |
|
100 | + parent::__construct($this->ticket, $max_atndz, $this->date_format, $event_status, $required_ticket_sold_out); |
|
101 | + } |
|
102 | + |
|
103 | + |
|
104 | + |
|
105 | + /** |
|
106 | + * other ticket rows will need to know if a required ticket is sold out, |
|
107 | + * so that they are not offered for sale |
|
108 | + * |
|
109 | + * @return boolean |
|
110 | + */ |
|
111 | + public function getRequiredTicketSoldOut() |
|
112 | + { |
|
113 | + return $this->required_ticket_sold_out; |
|
114 | + } |
|
115 | + |
|
116 | + |
|
117 | + |
|
118 | + /** |
|
119 | + * @return int |
|
120 | + */ |
|
121 | + public function getCols() |
|
122 | + { |
|
123 | + return $this->cols; |
|
124 | + } |
|
125 | + |
|
126 | + |
|
127 | + |
|
128 | + /** |
|
129 | + * getHtml |
|
130 | + * |
|
131 | + * @return string |
|
132 | + * @throws EE_Error |
|
133 | + */ |
|
134 | + public function getHtml() |
|
135 | + { |
|
136 | + $min = 0; |
|
137 | + $max = $this->ticket->max(); |
|
138 | + $remaining = $this->ticket->remaining(); |
|
139 | + if ($this->ticket->is_on_sale() && $this->ticket->is_remaining()) { |
|
140 | + list($min, $max) = $this->setTicketMinAndMax($remaining); |
|
141 | + } else { |
|
142 | + // set flag if ticket is required (flag is set to start date so that future tickets are not blocked) |
|
143 | + $this->required_ticket_sold_out = $this->ticket->required() && ! $remaining |
|
144 | + ? $this->ticket->start_date() |
|
145 | + : $this->required_ticket_sold_out; |
|
146 | + } |
|
147 | + list($ticket_price, $ticket_bundle) = $this->getTicketPriceDetails(); |
|
148 | + list($tkt_status, $ticket_status, $status_class) = $this->getTicketStatusClasses($remaining); |
|
149 | + /** |
|
150 | + * Allow plugins to hook in and abort the generation and display of this row to do |
|
151 | + * something else if they want. |
|
152 | + * For an addon to abort things, all they have to do is register a filter with this hook, and |
|
153 | + * return a value that is NOT false. Whatever is returned gets echoed instead of the |
|
154 | + * current row. |
|
155 | + * |
|
156 | + * @var string|bool |
|
157 | + */ |
|
158 | + $ticket_selector_row_html = apply_filters( |
|
159 | + 'FHEE__ticket_selector_chart_template__do_ticket_entire_row', |
|
160 | + false, |
|
161 | + $this->ticket, |
|
162 | + $max, |
|
163 | + $min, |
|
164 | + $this->required_ticket_sold_out, |
|
165 | + $ticket_price, |
|
166 | + $ticket_bundle, |
|
167 | + $ticket_status, |
|
168 | + $status_class |
|
169 | + ); |
|
170 | + if ($ticket_selector_row_html !== false) { |
|
171 | + return $ticket_selector_row_html; |
|
172 | + } |
|
173 | + $ticket_selector_row_html = \EEH_HTML::tr( |
|
174 | + '', '', |
|
175 | + "tckt-slctr-tbl-tr {$status_class}{$this->ticket_datetime_classes} " . espresso_get_object_css_class($this->ticket) |
|
176 | + ); |
|
177 | + /** |
|
178 | + * Allow plugins to hook in and abort the generation and display of the contents of this |
|
179 | + * row to do something else if they want. |
|
180 | + * For an addon to abort things, all they have to do is register a filter with this hook, and |
|
181 | + * return a value that is NOT false. Whatever is returned gets echoed instead of the |
|
182 | + * current row. |
|
183 | + * |
|
184 | + * @var string|bool |
|
185 | + */ |
|
186 | + $new_row_cells_content = apply_filters( |
|
187 | + 'FHEE__ticket_selector_chart_template__do_ticket_inside_row', |
|
188 | + false, |
|
189 | + $this->ticket, |
|
190 | + $max, |
|
191 | + $min, |
|
192 | + $this->required_ticket_sold_out, |
|
193 | + $ticket_price, |
|
194 | + $ticket_bundle, |
|
195 | + $ticket_status, |
|
196 | + $status_class |
|
197 | + ); |
|
198 | + if ($new_row_cells_content !== false) { |
|
199 | + return $ticket_selector_row_html |
|
200 | + . $new_row_cells_content |
|
201 | + . \EEH_HTML::trx(); |
|
202 | + } |
|
203 | + $this->hidden_input_qty = $this->max_atndz > 1 ? true : false; |
|
204 | + |
|
205 | + $ticket_selector_row_html .= $this->ticketNameTableCell(); |
|
206 | + $ticket_selector_row_html .= $this->ticketPriceTableCell($ticket_price, $ticket_bundle); |
|
207 | + $ticket_selector_row_html .= \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-qty cntr'); |
|
208 | + $this->setTicketStatusDisplay($tkt_status, $ticket_status, $remaining); |
|
209 | + if (empty($this->ticket_status_display)) { |
|
210 | + if ($this->max_atndz === 1) { |
|
211 | + // only ONE attendee is allowed to register at a time |
|
212 | + $ticket_selector_row_html .= $this->onlyOneAttendeeCanRegister(); |
|
213 | + } else if ($max > 0) { |
|
214 | + $ticket_selector_row_html .= $this->ticketQuantitySelector($min, $max); |
|
215 | + } |
|
216 | + } |
|
217 | + $ticket_selector_row_html .= $this->ticket_status_display; |
|
218 | + $ticket_selector_row_html .= $this->ticketQtyAndIdHiddenInputs(); |
|
219 | + $ticket_selector_row_html .= $this->ticket_details->display($ticket_price, $remaining, $this->cols); |
|
220 | + $ticket_selector_row_html .= \EEH_HTML::tdx(); |
|
221 | + $ticket_selector_row_html .= \EEH_HTML::trx(); |
|
222 | + |
|
223 | + |
|
224 | + $this->row++; |
|
225 | + return $ticket_selector_row_html; |
|
226 | + } |
|
227 | + |
|
228 | + |
|
229 | + |
|
230 | + /** |
|
231 | + * setTicketMinAndMax |
|
232 | + * |
|
233 | + * @param int $remaining |
|
234 | + * @return array |
|
235 | + * @throws EE_Error |
|
236 | + */ |
|
237 | + protected function setTicketMinAndMax($remaining) |
|
238 | + { |
|
239 | + // offer the number of $tickets_remaining or $this->max_atndz, whichever is smaller |
|
240 | + $max = min($remaining, $this->max_atndz); |
|
241 | + // but... we also want to restrict the number of tickets by the ticket max setting, |
|
242 | + // however, the max still can't be higher than what was just set above |
|
243 | + $max = $this->ticket->max() > 0 ? min($this->ticket->max(), $max) : $max; |
|
244 | + // and we also want to restrict the minimum number of tickets by the ticket min setting |
|
245 | + $min = $this->ticket->min() > 0 ? $this->ticket->min() : 0; |
|
246 | + // and if the ticket is required, then make sure that min qty is at least 1 |
|
247 | + $min = $this->ticket->required() ? max($min, 1) : $min; |
|
248 | + return array($min, $max); |
|
249 | + } |
|
250 | + |
|
251 | + |
|
252 | + |
|
253 | + /** |
|
254 | + * getTicketPriceDetails |
|
255 | + * |
|
256 | + * @return array |
|
257 | + * @throws EE_Error |
|
258 | + */ |
|
259 | + protected function getTicketPriceDetails() |
|
260 | + { |
|
261 | + $ticket_price = $this->tax_settings->prices_displayed_including_taxes |
|
262 | + ? $this->ticket->get_ticket_total_with_taxes() |
|
263 | + : $this->ticket->get_ticket_subtotal(); |
|
264 | + $ticket_bundle = false; |
|
265 | + $ticket_min = $this->ticket->min(); |
|
266 | + // for ticket bundles, set min and max qty the same |
|
267 | + if ($ticket_min !== 0 && $ticket_min === $this->ticket->max()) { |
|
268 | + $ticket_price *= $ticket_min; |
|
269 | + $ticket_bundle = true; |
|
270 | + } |
|
271 | + $ticket_price = apply_filters( |
|
272 | + 'FHEE__ticket_selector_chart_template__ticket_price', |
|
273 | + $ticket_price, |
|
274 | + $this->ticket |
|
275 | + ); |
|
276 | + return array($ticket_price, $ticket_bundle); |
|
277 | + } |
|
278 | + |
|
279 | + |
|
280 | + |
|
281 | + |
|
282 | + /** |
|
283 | + * ticketNameTableCell |
|
284 | + * |
|
285 | + * @return string |
|
286 | + * @throws EE_Error |
|
287 | + */ |
|
288 | + protected function ticketNameTableCell() |
|
289 | + { |
|
290 | + $html = \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-name'); |
|
291 | + $html .= \EEH_HTML::strong($this->ticket->get_pretty('TKT_name')); |
|
292 | + $html .= $this->ticket_details->getShowHideLinks(); |
|
293 | + if ($this->ticket->required()) { |
|
294 | + $html .= \EEH_HTML::p( |
|
295 | + apply_filters( |
|
296 | + 'FHEE__ticket_selector_chart_template__ticket_required_message', |
|
297 | + esc_html__('This ticket is required and must be purchased.', 'event_espresso') |
|
298 | + ), |
|
299 | + '', 'ticket-required-pg' |
|
300 | + ); |
|
301 | + } |
|
302 | + $html .= \EEH_HTML::tdx(); |
|
303 | + return $html; |
|
304 | + } |
|
305 | + |
|
306 | + |
|
307 | + |
|
308 | + /** |
|
309 | + * ticketPriceTableCell |
|
310 | + * |
|
311 | + * @param float $ticket_price |
|
312 | + * @param bool $ticket_bundle |
|
313 | + * @return string |
|
314 | + * @throws EE_Error |
|
315 | + */ |
|
316 | + protected function ticketPriceTableCell($ticket_price, $ticket_bundle) |
|
317 | + { |
|
318 | + $html = ''; |
|
319 | + if (apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', true)) { |
|
320 | + $html .= \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-price jst-rght'); |
|
321 | + $html .= \EEH_Template::format_currency($ticket_price); |
|
322 | + $html .= $this->ticket->taxable() |
|
323 | + ? \EEH_HTML::span( '*', '', 'taxable-tickets-asterisk grey-text' ) |
|
324 | + : ''; |
|
325 | + $html .= ' '; |
|
326 | + $html .= \EEH_HTML::span( |
|
327 | + $ticket_bundle |
|
328 | + ? apply_filters( |
|
329 | + 'FHEE__ticket_selector_chart_template__per_ticket_bundle_text', |
|
330 | + __(' / bundle', 'event_espresso') |
|
331 | + ) |
|
332 | + : apply_filters( |
|
333 | + 'FHEE__ticket_selector_chart_template__per_ticket_text', |
|
334 | + __('', 'event_espresso') |
|
335 | + ), |
|
336 | + '', 'smaller-text no-bold' |
|
337 | + ); |
|
338 | + $html .= ' '; |
|
339 | + $html .= \EEH_HTML::tdx(); |
|
340 | + $this->cols++; |
|
341 | + } |
|
342 | + return $html; |
|
343 | + } |
|
344 | + |
|
345 | + |
|
346 | + |
|
347 | + /** |
|
348 | + * onlyOneAttendeeCanRegister |
|
349 | + * |
|
350 | + * @return string |
|
351 | + */ |
|
352 | + protected function onlyOneAttendeeCanRegister() |
|
353 | + { |
|
354 | + // display submit button since we have tickets available |
|
355 | + add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
356 | + $this->hidden_input_qty = false; |
|
357 | + $html = '<input type="radio" name="tkt-slctr-qty-' . $this->EVT_ID . '"'; |
|
358 | + $html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"'; |
|
359 | + $html .= ' class="ticket-selector-tbl-qty-slct" value="' . $this->row . '-1"'; |
|
360 | + $html .= $this->total_tickets === 1 ? ' checked="checked"' : ''; |
|
361 | + $html .= ' title=""/>'; |
|
362 | + return $html; |
|
363 | + } |
|
364 | + |
|
365 | + |
|
366 | + |
|
367 | + /** |
|
368 | + * ticketQuantitySelector |
|
369 | + * |
|
370 | + * @param int $min |
|
371 | + * @param int $max |
|
372 | + * @return string |
|
373 | + * @throws EE_Error |
|
374 | + */ |
|
375 | + protected function ticketQuantitySelector($min = 0, $max = 0) |
|
376 | + { |
|
377 | + // display submit button since we have tickets available |
|
378 | + add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
379 | + $this->hidden_input_qty = false; |
|
380 | + $html = '<select name="tkt-slctr-qty-' . $this->EVT_ID . '[]"'; |
|
381 | + $html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"'; |
|
382 | + $html .= ' class="ticket-selector-tbl-qty-slct">'; |
|
383 | + // this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased |
|
384 | + if ($min !== 0 && ! $this->ticket->required()) { |
|
385 | + $html .= '<option value="0"> 0 </option>'; |
|
386 | + } |
|
387 | + // offer ticket quantities from the min to the max |
|
388 | + for ($i = $min; $i <= $max; $i++) { |
|
389 | + $html .= '<option value="' . $i . '"> ' . $i . ' </option>'; |
|
390 | + } |
|
391 | + $html .= '</select>'; |
|
392 | + return $html; |
|
393 | + } |
|
394 | + |
|
395 | + |
|
396 | + |
|
397 | + /** |
|
398 | + * getHiddenInputs |
|
399 | + * |
|
400 | + * @return string |
|
401 | + * @throws EE_Error |
|
402 | + */ |
|
403 | + protected function ticketQtyAndIdHiddenInputs() |
|
404 | + { |
|
405 | + $html = ''; |
|
406 | + // depending on group reg we need to change the format for qty |
|
407 | + if ($this->hidden_input_qty) { |
|
408 | + $html .= '<input type="hidden" name="tkt-slctr-qty-' . $this->EVT_ID . '[]" value="0"/>'; |
|
409 | + } |
|
410 | + $html .= '<input type="hidden" name="tkt-slctr-ticket-id-' . $this->EVT_ID . '[]"'; |
|
411 | + $html .= ' value="' . $this->ticket->ID() . '"/>'; |
|
412 | + return $html; |
|
413 | + } |
|
414 | 414 | |
415 | 415 | } |
416 | 416 | // End of file TicketSelectorRowStandard.php |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
3 | - exit('No direct script access allowed'); |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | |
@@ -16,256 +16,256 @@ discard block |
||
16 | 16 | { |
17 | 17 | |
18 | 18 | |
19 | - /** |
|
20 | - * EE_Message_Repository constructor |
|
21 | - */ |
|
22 | - public function __construct() |
|
23 | - { |
|
24 | - $this->interface = 'EE_Message'; |
|
25 | - parent::__construct(); |
|
26 | - } |
|
27 | - |
|
28 | - |
|
29 | - /** |
|
30 | - * Add the EE_Message to the repository. |
|
31 | - * This also ensures that the MSG_token is saves as a part of the info for retrieval. |
|
32 | - * |
|
33 | - * @param EE_Message $message |
|
34 | - * @param mixed $info Any included data is saved in the attached object info array indexed by 'data' |
|
35 | - * @return bool |
|
36 | - */ |
|
37 | - public function add($message, $info = null) |
|
38 | - { |
|
39 | - $attached = parent::add($message); |
|
40 | - //ensure $info is an array if not already |
|
41 | - $info = $info === null ? $info = array() : (array)$info; |
|
42 | - $data = $this->_init_data($info, $attached, $message); |
|
43 | - if ($attached) { |
|
44 | - $this->set_info($message, $data); |
|
45 | - } |
|
46 | - return $attached; |
|
47 | - } |
|
48 | - |
|
49 | - |
|
50 | - /** |
|
51 | - * Initializes the data from the incoming info. |
|
52 | - * |
|
53 | - * @param array $info incoming data. |
|
54 | - * @param bool $attached Indicates whether the object was attached successfully. |
|
55 | - * @param EE_Message $message |
|
56 | - * @return array |
|
57 | - */ |
|
58 | - protected function _init_data($info, $attached, $message) |
|
59 | - { |
|
60 | - $data = array( |
|
61 | - 'test_send' => false, |
|
62 | - 'preview' => false, |
|
63 | - 'data_handler_class_name' => '', |
|
64 | - 'data' => array( |
|
65 | - 'MSG_generation_data' => array(), |
|
66 | - ), |
|
67 | - ); |
|
68 | - if (isset($info['preview'])) { |
|
69 | - $data['preview'] = $info['preview']; |
|
70 | - unset($info['preview']); |
|
71 | - } |
|
72 | - if (isset($info['test_send'])) { |
|
73 | - $data['test_send'] = $info['test_send']; |
|
74 | - unset($info['test_send']); |
|
75 | - } |
|
76 | - if (isset($info['data_handler_class_name'])) { |
|
77 | - $data['data_handler_class_name'] = $info['data_handler_class_name']; |
|
78 | - unset($info['data_handler_class_name']); |
|
79 | - } |
|
80 | - if ($attached && $message->STS_ID() === EEM_Message::status_incomplete) { |
|
81 | - $generation_data = isset($info['MSG_generation_data']) ? $info['MSG_generation_data'] : array(); |
|
82 | - //if data isn't in $info...let's see if its available via the message object |
|
83 | - $generation_data = ! $generation_data ? $message->get_generation_data() : $generation_data; |
|
84 | - //still empty then let's just use info |
|
85 | - $generation_data = ! $generation_data ? $info : $generation_data; |
|
86 | - $data['data']['MSG_generation_data'] = $generation_data; |
|
87 | - } |
|
88 | - return $data; |
|
89 | - } |
|
90 | - |
|
91 | - |
|
92 | - /** |
|
93 | - * Save all EE_Message objects to the db. |
|
94 | - * |
|
95 | - * @param bool $do_hooks_only When true, only the hooks related to saving are fired. |
|
96 | - * @return array array( |
|
97 | - * 'updated' => 0, //count of how many messages updated |
|
98 | - * 'notupdated' => 0, //count of how many messages not updated. |
|
99 | - * 'errors' => array( $token ), //array of message object tokens that had errors in saving |
|
100 | - * ) |
|
101 | - */ |
|
102 | - public function saveAll($do_hooks_only = false) |
|
103 | - { |
|
104 | - $save_tracking = array('updated' => 0, 'notupdated' => 0, 'errors' => array()); |
|
105 | - |
|
106 | - if (! $do_hooks_only) { |
|
107 | - $this->rewind(); |
|
108 | - //exit early if there is nothing to save. |
|
109 | - if ($this->count() < 1) { |
|
110 | - return $save_tracking; |
|
111 | - } |
|
112 | - |
|
113 | - while ($this->valid()) { |
|
114 | - $saved = $this->current()->save(); |
|
115 | - if ($saved === false) { |
|
116 | - $save_tracking['errors'][] = $this->current()->MSG_token(); |
|
117 | - } elseif ($saved) { |
|
118 | - $save_tracking['updated']++; |
|
119 | - } else { |
|
120 | - $save_tracking['notupdated']++; |
|
121 | - } |
|
122 | - //maybe persist generation data if this is an incomplete EE_Message. |
|
123 | - $this->_maybe_persist_attached_data(); |
|
124 | - |
|
125 | - $this->next(); |
|
126 | - } |
|
127 | - } |
|
128 | - do_action('AHEE__EE_Message_Repository__saveAll__after', $save_tracking, $this, $do_hooks_only); |
|
129 | - return $save_tracking; |
|
130 | - } |
|
131 | - |
|
132 | - |
|
133 | - /** |
|
134 | - * Retrieves a EE_Message from the repository that matches the given token. |
|
135 | - * |
|
136 | - * @param string $token Token. |
|
137 | - * @return EE_Message | null |
|
138 | - */ |
|
139 | - public function getMessageByToken($token) |
|
140 | - { |
|
141 | - $this->rewind(); |
|
142 | - while ($this->valid()) { |
|
143 | - if ($this->current()->MSG_token() === $token) { |
|
144 | - $message = $this->current(); |
|
145 | - $this->rewind(); |
|
146 | - return $message; |
|
147 | - } |
|
148 | - $this->next(); |
|
149 | - } |
|
150 | - return null; |
|
151 | - } |
|
152 | - |
|
153 | - |
|
154 | - /** |
|
155 | - * This retrieves any data required for generation that may be saved with the current EE_Message in storage. |
|
156 | - * |
|
157 | - * @return array(); |
|
158 | - */ |
|
159 | - public function get_generation_data() |
|
160 | - { |
|
161 | - //first verify we're at a valid iterator point. |
|
162 | - if ( ! $this->valid()) { |
|
163 | - return array(); |
|
164 | - } |
|
165 | - $info = $this->getInfo(); |
|
166 | - return isset($info['data']) && isset($info['data']['MSG_generation_data']) ? $info['data']['MSG_generation_data'] : array(); |
|
167 | - } |
|
168 | - |
|
169 | - |
|
170 | - /** |
|
171 | - * Retrieves the data_handler_class_name or reference associated with the current EE_Message object in the iterator. |
|
172 | - * |
|
173 | - * @return string |
|
174 | - */ |
|
175 | - public function get_data_handler() |
|
176 | - { |
|
177 | - if ( ! $this->valid()) { |
|
178 | - return ''; |
|
179 | - } |
|
180 | - $info = $this->getInfo(); |
|
181 | - return isset($info['data_handler_class_name']) ? $info['data_handler_class_name'] : ''; |
|
182 | - } |
|
183 | - |
|
184 | - |
|
185 | - /** |
|
186 | - * Returns whether this EE_Message is for a preview or not. |
|
187 | - * |
|
188 | - * @return bool |
|
189 | - */ |
|
190 | - public function is_preview() |
|
191 | - { |
|
192 | - if ( ! $this->valid()) { |
|
193 | - return false; |
|
194 | - } |
|
195 | - $info = $this->getInfo(); |
|
196 | - return $info['preview']; |
|
197 | - } |
|
198 | - |
|
199 | - |
|
200 | - /** |
|
201 | - * Returns whether the current message pointed to is for a test send. |
|
202 | - * |
|
203 | - * @return bool |
|
204 | - */ |
|
205 | - public function is_test_send() |
|
206 | - { |
|
207 | - if ( ! $this->valid()) { |
|
208 | - return false; |
|
209 | - } |
|
210 | - $info = $this->getInfo(); |
|
211 | - return $info['test_send']; |
|
212 | - } |
|
213 | - |
|
214 | - |
|
215 | - /** |
|
216 | - * This checks if the current EE_Message in the iterator is incomplete. If it is, then |
|
217 | - * data is attached for later retrieval (batch generation). |
|
218 | - */ |
|
219 | - protected function _maybe_persist_attached_data() |
|
220 | - { |
|
221 | - if ( ! $this->valid()) { |
|
222 | - return; |
|
223 | - } |
|
224 | - |
|
225 | - $info = $this->getInfo(); |
|
226 | - $data_handler_class_name = isset($info['data_handler_class_name']) ? $info['data_handler_class_name'] : ''; |
|
227 | - $data = isset($info['data']) && isset($info['data']['MSG_generation_data']) ? $info['data']['MSG_generation_data'] : array(); |
|
228 | - if ($data && $this->current()->STS_ID() === EEM_Message::status_incomplete) { |
|
229 | - $this->current()->set_generation_data($data); |
|
230 | - $this->current()->set_field_or_extra_meta('data_handler_class_name', $data_handler_class_name); |
|
231 | - } |
|
232 | - } |
|
233 | - |
|
234 | - |
|
235 | - /** |
|
236 | - * This method returns a count of messages in the repository that have a given priority. |
|
237 | - * |
|
238 | - * @param int $priority the priority that is being filtered for the count. |
|
239 | - * @param array $status the optional status(es) that will also be filtered by when priority matches. |
|
240 | - * @return int count of messages in the queue matching the conditions. |
|
241 | - */ |
|
242 | - public function count_by_priority_and_status($priority, $status = array()) |
|
243 | - { |
|
244 | - if ( ! empty($status)) { |
|
245 | - $status = is_array($status) ? $status : array($status); |
|
246 | - } |
|
247 | - |
|
248 | - $count = 0; |
|
249 | - $this->rewind(); |
|
250 | - while ($this->valid()) { |
|
251 | - if ($this->current()->priority() === $priority && (($status && in_array($this->current()->STS_ID(), |
|
252 | - $status)) || ! $status) |
|
253 | - ) { |
|
254 | - $count++; |
|
255 | - } |
|
256 | - $this->next(); |
|
257 | - } |
|
258 | - return $count; |
|
259 | - } |
|
260 | - |
|
261 | - |
|
262 | - /** |
|
263 | - * @return EE_Message |
|
264 | - */ |
|
265 | - public function current() |
|
266 | - { |
|
267 | - return parent::current(); |
|
268 | - } |
|
19 | + /** |
|
20 | + * EE_Message_Repository constructor |
|
21 | + */ |
|
22 | + public function __construct() |
|
23 | + { |
|
24 | + $this->interface = 'EE_Message'; |
|
25 | + parent::__construct(); |
|
26 | + } |
|
27 | + |
|
28 | + |
|
29 | + /** |
|
30 | + * Add the EE_Message to the repository. |
|
31 | + * This also ensures that the MSG_token is saves as a part of the info for retrieval. |
|
32 | + * |
|
33 | + * @param EE_Message $message |
|
34 | + * @param mixed $info Any included data is saved in the attached object info array indexed by 'data' |
|
35 | + * @return bool |
|
36 | + */ |
|
37 | + public function add($message, $info = null) |
|
38 | + { |
|
39 | + $attached = parent::add($message); |
|
40 | + //ensure $info is an array if not already |
|
41 | + $info = $info === null ? $info = array() : (array)$info; |
|
42 | + $data = $this->_init_data($info, $attached, $message); |
|
43 | + if ($attached) { |
|
44 | + $this->set_info($message, $data); |
|
45 | + } |
|
46 | + return $attached; |
|
47 | + } |
|
48 | + |
|
49 | + |
|
50 | + /** |
|
51 | + * Initializes the data from the incoming info. |
|
52 | + * |
|
53 | + * @param array $info incoming data. |
|
54 | + * @param bool $attached Indicates whether the object was attached successfully. |
|
55 | + * @param EE_Message $message |
|
56 | + * @return array |
|
57 | + */ |
|
58 | + protected function _init_data($info, $attached, $message) |
|
59 | + { |
|
60 | + $data = array( |
|
61 | + 'test_send' => false, |
|
62 | + 'preview' => false, |
|
63 | + 'data_handler_class_name' => '', |
|
64 | + 'data' => array( |
|
65 | + 'MSG_generation_data' => array(), |
|
66 | + ), |
|
67 | + ); |
|
68 | + if (isset($info['preview'])) { |
|
69 | + $data['preview'] = $info['preview']; |
|
70 | + unset($info['preview']); |
|
71 | + } |
|
72 | + if (isset($info['test_send'])) { |
|
73 | + $data['test_send'] = $info['test_send']; |
|
74 | + unset($info['test_send']); |
|
75 | + } |
|
76 | + if (isset($info['data_handler_class_name'])) { |
|
77 | + $data['data_handler_class_name'] = $info['data_handler_class_name']; |
|
78 | + unset($info['data_handler_class_name']); |
|
79 | + } |
|
80 | + if ($attached && $message->STS_ID() === EEM_Message::status_incomplete) { |
|
81 | + $generation_data = isset($info['MSG_generation_data']) ? $info['MSG_generation_data'] : array(); |
|
82 | + //if data isn't in $info...let's see if its available via the message object |
|
83 | + $generation_data = ! $generation_data ? $message->get_generation_data() : $generation_data; |
|
84 | + //still empty then let's just use info |
|
85 | + $generation_data = ! $generation_data ? $info : $generation_data; |
|
86 | + $data['data']['MSG_generation_data'] = $generation_data; |
|
87 | + } |
|
88 | + return $data; |
|
89 | + } |
|
90 | + |
|
91 | + |
|
92 | + /** |
|
93 | + * Save all EE_Message objects to the db. |
|
94 | + * |
|
95 | + * @param bool $do_hooks_only When true, only the hooks related to saving are fired. |
|
96 | + * @return array array( |
|
97 | + * 'updated' => 0, //count of how many messages updated |
|
98 | + * 'notupdated' => 0, //count of how many messages not updated. |
|
99 | + * 'errors' => array( $token ), //array of message object tokens that had errors in saving |
|
100 | + * ) |
|
101 | + */ |
|
102 | + public function saveAll($do_hooks_only = false) |
|
103 | + { |
|
104 | + $save_tracking = array('updated' => 0, 'notupdated' => 0, 'errors' => array()); |
|
105 | + |
|
106 | + if (! $do_hooks_only) { |
|
107 | + $this->rewind(); |
|
108 | + //exit early if there is nothing to save. |
|
109 | + if ($this->count() < 1) { |
|
110 | + return $save_tracking; |
|
111 | + } |
|
112 | + |
|
113 | + while ($this->valid()) { |
|
114 | + $saved = $this->current()->save(); |
|
115 | + if ($saved === false) { |
|
116 | + $save_tracking['errors'][] = $this->current()->MSG_token(); |
|
117 | + } elseif ($saved) { |
|
118 | + $save_tracking['updated']++; |
|
119 | + } else { |
|
120 | + $save_tracking['notupdated']++; |
|
121 | + } |
|
122 | + //maybe persist generation data if this is an incomplete EE_Message. |
|
123 | + $this->_maybe_persist_attached_data(); |
|
124 | + |
|
125 | + $this->next(); |
|
126 | + } |
|
127 | + } |
|
128 | + do_action('AHEE__EE_Message_Repository__saveAll__after', $save_tracking, $this, $do_hooks_only); |
|
129 | + return $save_tracking; |
|
130 | + } |
|
131 | + |
|
132 | + |
|
133 | + /** |
|
134 | + * Retrieves a EE_Message from the repository that matches the given token. |
|
135 | + * |
|
136 | + * @param string $token Token. |
|
137 | + * @return EE_Message | null |
|
138 | + */ |
|
139 | + public function getMessageByToken($token) |
|
140 | + { |
|
141 | + $this->rewind(); |
|
142 | + while ($this->valid()) { |
|
143 | + if ($this->current()->MSG_token() === $token) { |
|
144 | + $message = $this->current(); |
|
145 | + $this->rewind(); |
|
146 | + return $message; |
|
147 | + } |
|
148 | + $this->next(); |
|
149 | + } |
|
150 | + return null; |
|
151 | + } |
|
152 | + |
|
153 | + |
|
154 | + /** |
|
155 | + * This retrieves any data required for generation that may be saved with the current EE_Message in storage. |
|
156 | + * |
|
157 | + * @return array(); |
|
158 | + */ |
|
159 | + public function get_generation_data() |
|
160 | + { |
|
161 | + //first verify we're at a valid iterator point. |
|
162 | + if ( ! $this->valid()) { |
|
163 | + return array(); |
|
164 | + } |
|
165 | + $info = $this->getInfo(); |
|
166 | + return isset($info['data']) && isset($info['data']['MSG_generation_data']) ? $info['data']['MSG_generation_data'] : array(); |
|
167 | + } |
|
168 | + |
|
169 | + |
|
170 | + /** |
|
171 | + * Retrieves the data_handler_class_name or reference associated with the current EE_Message object in the iterator. |
|
172 | + * |
|
173 | + * @return string |
|
174 | + */ |
|
175 | + public function get_data_handler() |
|
176 | + { |
|
177 | + if ( ! $this->valid()) { |
|
178 | + return ''; |
|
179 | + } |
|
180 | + $info = $this->getInfo(); |
|
181 | + return isset($info['data_handler_class_name']) ? $info['data_handler_class_name'] : ''; |
|
182 | + } |
|
183 | + |
|
184 | + |
|
185 | + /** |
|
186 | + * Returns whether this EE_Message is for a preview or not. |
|
187 | + * |
|
188 | + * @return bool |
|
189 | + */ |
|
190 | + public function is_preview() |
|
191 | + { |
|
192 | + if ( ! $this->valid()) { |
|
193 | + return false; |
|
194 | + } |
|
195 | + $info = $this->getInfo(); |
|
196 | + return $info['preview']; |
|
197 | + } |
|
198 | + |
|
199 | + |
|
200 | + /** |
|
201 | + * Returns whether the current message pointed to is for a test send. |
|
202 | + * |
|
203 | + * @return bool |
|
204 | + */ |
|
205 | + public function is_test_send() |
|
206 | + { |
|
207 | + if ( ! $this->valid()) { |
|
208 | + return false; |
|
209 | + } |
|
210 | + $info = $this->getInfo(); |
|
211 | + return $info['test_send']; |
|
212 | + } |
|
213 | + |
|
214 | + |
|
215 | + /** |
|
216 | + * This checks if the current EE_Message in the iterator is incomplete. If it is, then |
|
217 | + * data is attached for later retrieval (batch generation). |
|
218 | + */ |
|
219 | + protected function _maybe_persist_attached_data() |
|
220 | + { |
|
221 | + if ( ! $this->valid()) { |
|
222 | + return; |
|
223 | + } |
|
224 | + |
|
225 | + $info = $this->getInfo(); |
|
226 | + $data_handler_class_name = isset($info['data_handler_class_name']) ? $info['data_handler_class_name'] : ''; |
|
227 | + $data = isset($info['data']) && isset($info['data']['MSG_generation_data']) ? $info['data']['MSG_generation_data'] : array(); |
|
228 | + if ($data && $this->current()->STS_ID() === EEM_Message::status_incomplete) { |
|
229 | + $this->current()->set_generation_data($data); |
|
230 | + $this->current()->set_field_or_extra_meta('data_handler_class_name', $data_handler_class_name); |
|
231 | + } |
|
232 | + } |
|
233 | + |
|
234 | + |
|
235 | + /** |
|
236 | + * This method returns a count of messages in the repository that have a given priority. |
|
237 | + * |
|
238 | + * @param int $priority the priority that is being filtered for the count. |
|
239 | + * @param array $status the optional status(es) that will also be filtered by when priority matches. |
|
240 | + * @return int count of messages in the queue matching the conditions. |
|
241 | + */ |
|
242 | + public function count_by_priority_and_status($priority, $status = array()) |
|
243 | + { |
|
244 | + if ( ! empty($status)) { |
|
245 | + $status = is_array($status) ? $status : array($status); |
|
246 | + } |
|
247 | + |
|
248 | + $count = 0; |
|
249 | + $this->rewind(); |
|
250 | + while ($this->valid()) { |
|
251 | + if ($this->current()->priority() === $priority && (($status && in_array($this->current()->STS_ID(), |
|
252 | + $status)) || ! $status) |
|
253 | + ) { |
|
254 | + $count++; |
|
255 | + } |
|
256 | + $this->next(); |
|
257 | + } |
|
258 | + return $count; |
|
259 | + } |
|
260 | + |
|
261 | + |
|
262 | + /** |
|
263 | + * @return EE_Message |
|
264 | + */ |
|
265 | + public function current() |
|
266 | + { |
|
267 | + return parent::current(); |
|
268 | + } |
|
269 | 269 | |
270 | 270 | |
271 | 271 | } |
272 | 272 | \ No newline at end of file |
@@ -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 | |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | { |
39 | 39 | $attached = parent::add($message); |
40 | 40 | //ensure $info is an array if not already |
41 | - $info = $info === null ? $info = array() : (array)$info; |
|
41 | + $info = $info === null ? $info = array() : (array) $info; |
|
42 | 42 | $data = $this->_init_data($info, $attached, $message); |
43 | 43 | if ($attached) { |
44 | 44 | $this->set_info($message, $data); |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | { |
104 | 104 | $save_tracking = array('updated' => 0, 'notupdated' => 0, 'errors' => array()); |
105 | 105 | |
106 | - if (! $do_hooks_only) { |
|
106 | + if ( ! $do_hooks_only) { |
|
107 | 107 | $this->rewind(); |
108 | 108 | //exit early if there is nothing to save. |
109 | 109 | if ($this->count() < 1) { |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('ABSPATH')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /* |
5 | 5 | Plugin Name: Event Espresso |
@@ -40,243 +40,243 @@ discard block |
||
40 | 40 | * @since 4.0 |
41 | 41 | */ |
42 | 42 | if (function_exists('espresso_version')) { |
43 | - /** |
|
44 | - * espresso_duplicate_plugin_error |
|
45 | - * displays if more than one version of EE is activated at the same time |
|
46 | - */ |
|
47 | - function espresso_duplicate_plugin_error() |
|
48 | - { |
|
49 | - ?> |
|
43 | + /** |
|
44 | + * espresso_duplicate_plugin_error |
|
45 | + * displays if more than one version of EE is activated at the same time |
|
46 | + */ |
|
47 | + function espresso_duplicate_plugin_error() |
|
48 | + { |
|
49 | + ?> |
|
50 | 50 | <div class="error"> |
51 | 51 | <p> |
52 | 52 | <?php echo esc_html__( |
53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | - 'event_espresso' |
|
55 | - ); ?> |
|
53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | + 'event_espresso' |
|
55 | + ); ?> |
|
56 | 56 | </p> |
57 | 57 | </div> |
58 | 58 | <?php |
59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | - } |
|
59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | + } |
|
61 | 61 | |
62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
63 | 63 | } else { |
64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
65 | - if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | - /** |
|
67 | - * espresso_minimum_php_version_error |
|
68 | - * |
|
69 | - * @return void |
|
70 | - */ |
|
71 | - function espresso_minimum_php_version_error() |
|
72 | - { |
|
73 | - ?> |
|
64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
65 | + if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | + /** |
|
67 | + * espresso_minimum_php_version_error |
|
68 | + * |
|
69 | + * @return void |
|
70 | + */ |
|
71 | + function espresso_minimum_php_version_error() |
|
72 | + { |
|
73 | + ?> |
|
74 | 74 | <div class="error"> |
75 | 75 | <p> |
76 | 76 | <?php |
77 | - printf( |
|
78 | - esc_html__( |
|
79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | - 'event_espresso' |
|
81 | - ), |
|
82 | - EE_MIN_PHP_VER_REQUIRED, |
|
83 | - PHP_VERSION, |
|
84 | - '<br/>', |
|
85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | - ); |
|
87 | - ?> |
|
77 | + printf( |
|
78 | + esc_html__( |
|
79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | + 'event_espresso' |
|
81 | + ), |
|
82 | + EE_MIN_PHP_VER_REQUIRED, |
|
83 | + PHP_VERSION, |
|
84 | + '<br/>', |
|
85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | + ); |
|
87 | + ?> |
|
88 | 88 | </p> |
89 | 89 | </div> |
90 | 90 | <?php |
91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | - } |
|
91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | + } |
|
93 | 93 | |
94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | - } else { |
|
96 | - /** |
|
97 | - * espresso_version |
|
98 | - * Returns the plugin version |
|
99 | - * |
|
100 | - * @return string |
|
101 | - */ |
|
102 | - function espresso_version() |
|
103 | - { |
|
104 | - return apply_filters('FHEE__espresso__espresso_version', '4.9.35.rc.002'); |
|
105 | - } |
|
94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | + } else { |
|
96 | + /** |
|
97 | + * espresso_version |
|
98 | + * Returns the plugin version |
|
99 | + * |
|
100 | + * @return string |
|
101 | + */ |
|
102 | + function espresso_version() |
|
103 | + { |
|
104 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.35.rc.002'); |
|
105 | + } |
|
106 | 106 | |
107 | - // define versions |
|
108 | - define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
109 | - define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
110 | - define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
111 | - define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
112 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
113 | - //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
|
114 | - if ( ! defined('DS')) { |
|
115 | - define('DS', '/'); |
|
116 | - } |
|
117 | - if ( ! defined('PS')) { |
|
118 | - define('PS', PATH_SEPARATOR); |
|
119 | - } |
|
120 | - if ( ! defined('SP')) { |
|
121 | - define('SP', ' '); |
|
122 | - } |
|
123 | - if ( ! defined('EENL')) { |
|
124 | - define('EENL', "\n"); |
|
125 | - } |
|
126 | - define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
127 | - // define the plugin directory and URL |
|
128 | - define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
129 | - define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
130 | - define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
131 | - // main root folder paths |
|
132 | - define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS); |
|
133 | - define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS); |
|
134 | - define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS); |
|
135 | - define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS); |
|
136 | - define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS); |
|
137 | - define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS); |
|
138 | - define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS); |
|
139 | - define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS); |
|
140 | - // core system paths |
|
141 | - define('EE_ADMIN', EE_CORE . 'admin' . DS); |
|
142 | - define('EE_CPTS', EE_CORE . 'CPTs' . DS); |
|
143 | - define('EE_CLASSES', EE_CORE . 'db_classes' . DS); |
|
144 | - define('EE_INTERFACES', EE_CORE . 'interfaces' . DS); |
|
145 | - define('EE_BUSINESS', EE_CORE . 'business' . DS); |
|
146 | - define('EE_MODELS', EE_CORE . 'db_models' . DS); |
|
147 | - define('EE_HELPERS', EE_CORE . 'helpers' . DS); |
|
148 | - define('EE_LIBRARIES', EE_CORE . 'libraries' . DS); |
|
149 | - define('EE_TEMPLATES', EE_CORE . 'templates' . DS); |
|
150 | - define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS); |
|
151 | - define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS); |
|
152 | - define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS); |
|
153 | - // gateways |
|
154 | - define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS); |
|
155 | - define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS); |
|
156 | - // asset URL paths |
|
157 | - define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS); |
|
158 | - define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS); |
|
159 | - define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS); |
|
160 | - define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS); |
|
161 | - define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/'); |
|
162 | - define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/'); |
|
163 | - // define upload paths |
|
164 | - $uploads = wp_upload_dir(); |
|
165 | - // define the uploads directory and URL |
|
166 | - define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS); |
|
167 | - define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS); |
|
168 | - // define the templates directory and URL |
|
169 | - define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS); |
|
170 | - define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS); |
|
171 | - // define the gateway directory and URL |
|
172 | - define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
173 | - define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
174 | - // languages folder/path |
|
175 | - define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS); |
|
176 | - define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS); |
|
177 | - //check for dompdf fonts in uploads |
|
178 | - if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) { |
|
179 | - define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS); |
|
180 | - } |
|
181 | - //ajax constants |
|
182 | - define( |
|
183 | - 'EE_FRONT_AJAX', |
|
184 | - isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false |
|
185 | - ); |
|
186 | - define( |
|
187 | - 'EE_ADMIN_AJAX', |
|
188 | - isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false |
|
189 | - ); |
|
190 | - //just a handy constant occasionally needed for finding values representing infinity in the DB |
|
191 | - //you're better to use this than its straight value (currently -1) in case you ever |
|
192 | - //want to change its default value! or find when -1 means infinity |
|
193 | - define('EE_INF_IN_DB', -1); |
|
194 | - define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
195 | - define('EE_DEBUG', false); |
|
196 | - // for older WP versions |
|
197 | - if ( ! defined('MONTH_IN_SECONDS')) { |
|
198 | - define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30); |
|
199 | - } |
|
200 | - /** |
|
201 | - * espresso_plugin_activation |
|
202 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
203 | - */ |
|
204 | - function espresso_plugin_activation() |
|
205 | - { |
|
206 | - update_option('ee_espresso_activation', true); |
|
207 | - } |
|
107 | + // define versions |
|
108 | + define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
109 | + define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
110 | + define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
111 | + define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
112 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
113 | + //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
|
114 | + if ( ! defined('DS')) { |
|
115 | + define('DS', '/'); |
|
116 | + } |
|
117 | + if ( ! defined('PS')) { |
|
118 | + define('PS', PATH_SEPARATOR); |
|
119 | + } |
|
120 | + if ( ! defined('SP')) { |
|
121 | + define('SP', ' '); |
|
122 | + } |
|
123 | + if ( ! defined('EENL')) { |
|
124 | + define('EENL', "\n"); |
|
125 | + } |
|
126 | + define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
127 | + // define the plugin directory and URL |
|
128 | + define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
129 | + define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
130 | + define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
131 | + // main root folder paths |
|
132 | + define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS); |
|
133 | + define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS); |
|
134 | + define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS); |
|
135 | + define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS); |
|
136 | + define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS); |
|
137 | + define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS); |
|
138 | + define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS); |
|
139 | + define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS); |
|
140 | + // core system paths |
|
141 | + define('EE_ADMIN', EE_CORE . 'admin' . DS); |
|
142 | + define('EE_CPTS', EE_CORE . 'CPTs' . DS); |
|
143 | + define('EE_CLASSES', EE_CORE . 'db_classes' . DS); |
|
144 | + define('EE_INTERFACES', EE_CORE . 'interfaces' . DS); |
|
145 | + define('EE_BUSINESS', EE_CORE . 'business' . DS); |
|
146 | + define('EE_MODELS', EE_CORE . 'db_models' . DS); |
|
147 | + define('EE_HELPERS', EE_CORE . 'helpers' . DS); |
|
148 | + define('EE_LIBRARIES', EE_CORE . 'libraries' . DS); |
|
149 | + define('EE_TEMPLATES', EE_CORE . 'templates' . DS); |
|
150 | + define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS); |
|
151 | + define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS); |
|
152 | + define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS); |
|
153 | + // gateways |
|
154 | + define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS); |
|
155 | + define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS); |
|
156 | + // asset URL paths |
|
157 | + define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS); |
|
158 | + define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS); |
|
159 | + define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS); |
|
160 | + define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS); |
|
161 | + define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/'); |
|
162 | + define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/'); |
|
163 | + // define upload paths |
|
164 | + $uploads = wp_upload_dir(); |
|
165 | + // define the uploads directory and URL |
|
166 | + define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS); |
|
167 | + define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS); |
|
168 | + // define the templates directory and URL |
|
169 | + define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS); |
|
170 | + define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS); |
|
171 | + // define the gateway directory and URL |
|
172 | + define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
173 | + define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
174 | + // languages folder/path |
|
175 | + define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS); |
|
176 | + define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS); |
|
177 | + //check for dompdf fonts in uploads |
|
178 | + if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) { |
|
179 | + define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS); |
|
180 | + } |
|
181 | + //ajax constants |
|
182 | + define( |
|
183 | + 'EE_FRONT_AJAX', |
|
184 | + isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false |
|
185 | + ); |
|
186 | + define( |
|
187 | + 'EE_ADMIN_AJAX', |
|
188 | + isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false |
|
189 | + ); |
|
190 | + //just a handy constant occasionally needed for finding values representing infinity in the DB |
|
191 | + //you're better to use this than its straight value (currently -1) in case you ever |
|
192 | + //want to change its default value! or find when -1 means infinity |
|
193 | + define('EE_INF_IN_DB', -1); |
|
194 | + define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
195 | + define('EE_DEBUG', false); |
|
196 | + // for older WP versions |
|
197 | + if ( ! defined('MONTH_IN_SECONDS')) { |
|
198 | + define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30); |
|
199 | + } |
|
200 | + /** |
|
201 | + * espresso_plugin_activation |
|
202 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
203 | + */ |
|
204 | + function espresso_plugin_activation() |
|
205 | + { |
|
206 | + update_option('ee_espresso_activation', true); |
|
207 | + } |
|
208 | 208 | |
209 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
210 | - /** |
|
211 | - * espresso_load_error_handling |
|
212 | - * this function loads EE's class for handling exceptions and errors |
|
213 | - */ |
|
214 | - function espresso_load_error_handling() |
|
215 | - { |
|
216 | - // load debugging tools |
|
217 | - if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
218 | - require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php'); |
|
219 | - EEH_Debug_Tools::instance(); |
|
220 | - } |
|
221 | - // load error handling |
|
222 | - if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
223 | - require_once(EE_CORE . 'EE_Error.core.php'); |
|
224 | - } else { |
|
225 | - wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
226 | - } |
|
227 | - } |
|
209 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
210 | + /** |
|
211 | + * espresso_load_error_handling |
|
212 | + * this function loads EE's class for handling exceptions and errors |
|
213 | + */ |
|
214 | + function espresso_load_error_handling() |
|
215 | + { |
|
216 | + // load debugging tools |
|
217 | + if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
218 | + require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php'); |
|
219 | + EEH_Debug_Tools::instance(); |
|
220 | + } |
|
221 | + // load error handling |
|
222 | + if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
223 | + require_once(EE_CORE . 'EE_Error.core.php'); |
|
224 | + } else { |
|
225 | + wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
226 | + } |
|
227 | + } |
|
228 | 228 | |
229 | - /** |
|
230 | - * espresso_load_required |
|
231 | - * given a class name and path, this function will load that file or throw an exception |
|
232 | - * |
|
233 | - * @param string $classname |
|
234 | - * @param string $full_path_to_file |
|
235 | - * @throws EE_Error |
|
236 | - */ |
|
237 | - function espresso_load_required($classname, $full_path_to_file) |
|
238 | - { |
|
239 | - static $error_handling_loaded = false; |
|
240 | - if ( ! $error_handling_loaded) { |
|
241 | - espresso_load_error_handling(); |
|
242 | - $error_handling_loaded = true; |
|
243 | - } |
|
244 | - if (is_readable($full_path_to_file)) { |
|
245 | - require_once($full_path_to_file); |
|
246 | - } else { |
|
247 | - throw new EE_Error ( |
|
248 | - sprintf( |
|
249 | - esc_html__( |
|
250 | - 'The %s class file could not be located or is not readable due to file permissions.', |
|
251 | - 'event_espresso' |
|
252 | - ), |
|
253 | - $classname |
|
254 | - ) |
|
255 | - ); |
|
256 | - } |
|
257 | - } |
|
229 | + /** |
|
230 | + * espresso_load_required |
|
231 | + * given a class name and path, this function will load that file or throw an exception |
|
232 | + * |
|
233 | + * @param string $classname |
|
234 | + * @param string $full_path_to_file |
|
235 | + * @throws EE_Error |
|
236 | + */ |
|
237 | + function espresso_load_required($classname, $full_path_to_file) |
|
238 | + { |
|
239 | + static $error_handling_loaded = false; |
|
240 | + if ( ! $error_handling_loaded) { |
|
241 | + espresso_load_error_handling(); |
|
242 | + $error_handling_loaded = true; |
|
243 | + } |
|
244 | + if (is_readable($full_path_to_file)) { |
|
245 | + require_once($full_path_to_file); |
|
246 | + } else { |
|
247 | + throw new EE_Error ( |
|
248 | + sprintf( |
|
249 | + esc_html__( |
|
250 | + 'The %s class file could not be located or is not readable due to file permissions.', |
|
251 | + 'event_espresso' |
|
252 | + ), |
|
253 | + $classname |
|
254 | + ) |
|
255 | + ); |
|
256 | + } |
|
257 | + } |
|
258 | 258 | |
259 | - espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'); |
|
260 | - espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'); |
|
261 | - espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php'); |
|
262 | - new EE_Bootstrap(); |
|
263 | - } |
|
259 | + espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'); |
|
260 | + espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'); |
|
261 | + espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php'); |
|
262 | + new EE_Bootstrap(); |
|
263 | + } |
|
264 | 264 | } |
265 | 265 | if ( ! function_exists('espresso_deactivate_plugin')) { |
266 | - /** |
|
267 | - * deactivate_plugin |
|
268 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
269 | - * |
|
270 | - * @access public |
|
271 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
272 | - * @return void |
|
273 | - */ |
|
274 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
275 | - { |
|
276 | - if ( ! function_exists('deactivate_plugins')) { |
|
277 | - require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
278 | - } |
|
279 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
280 | - deactivate_plugins($plugin_basename); |
|
281 | - } |
|
266 | + /** |
|
267 | + * deactivate_plugin |
|
268 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
269 | + * |
|
270 | + * @access public |
|
271 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
272 | + * @return void |
|
273 | + */ |
|
274 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
275 | + { |
|
276 | + if ( ! function_exists('deactivate_plugins')) { |
|
277 | + require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
278 | + } |
|
279 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
280 | + deactivate_plugins($plugin_basename); |
|
281 | + } |
|
282 | 282 | } |
283 | 283 | \ No newline at end of file |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | use EventEspresso\core\exceptions\InvalidEntityException; |
3 | 3 | |
4 | 4 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
5 | - exit('No direct script access allowed'); |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -17,1715 +17,1715 @@ discard block |
||
17 | 17 | class EED_Single_Page_Checkout extends EED_Module |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * $_initialized - has the SPCO controller already been initialized ? |
|
22 | - * |
|
23 | - * @access private |
|
24 | - * @var bool $_initialized |
|
25 | - */ |
|
26 | - private static $_initialized = false; |
|
27 | - |
|
28 | - |
|
29 | - /** |
|
30 | - * $_checkout_verified - is the EE_Checkout verified as correct for this request ? |
|
31 | - * |
|
32 | - * @access private |
|
33 | - * @var bool $_valid_checkout |
|
34 | - */ |
|
35 | - private static $_checkout_verified = true; |
|
36 | - |
|
37 | - /** |
|
38 | - * $_reg_steps_array - holds initial array of reg steps |
|
39 | - * |
|
40 | - * @access private |
|
41 | - * @var array $_reg_steps_array |
|
42 | - */ |
|
43 | - private static $_reg_steps_array = array(); |
|
44 | - |
|
45 | - /** |
|
46 | - * $checkout - EE_Checkout object for handling the properties of the current checkout process |
|
47 | - * |
|
48 | - * @access public |
|
49 | - * @var EE_Checkout $checkout |
|
50 | - */ |
|
51 | - public $checkout; |
|
52 | - |
|
53 | - |
|
54 | - |
|
55 | - /** |
|
56 | - * @return EED_Single_Page_Checkout |
|
57 | - */ |
|
58 | - public static function instance() |
|
59 | - { |
|
60 | - add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true'); |
|
61 | - return parent::get_instance(__CLASS__); |
|
62 | - } |
|
63 | - |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * @return EE_CART |
|
68 | - */ |
|
69 | - public function cart() |
|
70 | - { |
|
71 | - return $this->checkout->cart; |
|
72 | - } |
|
73 | - |
|
74 | - |
|
75 | - |
|
76 | - /** |
|
77 | - * @return EE_Transaction |
|
78 | - */ |
|
79 | - public function transaction() |
|
80 | - { |
|
81 | - return $this->checkout->transaction; |
|
82 | - } |
|
83 | - |
|
84 | - |
|
85 | - |
|
86 | - /** |
|
87 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
88 | - * |
|
89 | - * @access public |
|
90 | - * @return void |
|
91 | - * @throws \EE_Error |
|
92 | - */ |
|
93 | - public static function set_hooks() |
|
94 | - { |
|
95 | - EED_Single_Page_Checkout::set_definitions(); |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - |
|
100 | - /** |
|
101 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
102 | - * |
|
103 | - * @access public |
|
104 | - * @return void |
|
105 | - * @throws \EE_Error |
|
106 | - */ |
|
107 | - public static function set_hooks_admin() |
|
108 | - { |
|
109 | - EED_Single_Page_Checkout::set_definitions(); |
|
110 | - if ( ! (defined('DOING_AJAX') && DOING_AJAX)) { |
|
111 | - return; |
|
112 | - } |
|
113 | - // going to start an output buffer in case anything gets accidentally output that might disrupt our JSON response |
|
114 | - ob_start(); |
|
115 | - EED_Single_Page_Checkout::load_request_handler(); |
|
116 | - EED_Single_Page_Checkout::load_reg_steps(); |
|
117 | - // set ajax hooks |
|
118 | - add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
119 | - add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
120 | - add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
121 | - add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
122 | - add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
123 | - add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
124 | - } |
|
125 | - |
|
126 | - |
|
127 | - |
|
128 | - /** |
|
129 | - * process ajax request |
|
130 | - * |
|
131 | - * @param string $ajax_action |
|
132 | - * @throws \EE_Error |
|
133 | - */ |
|
134 | - public static function process_ajax_request($ajax_action) |
|
135 | - { |
|
136 | - EE_Registry::instance()->REQ->set('action', $ajax_action); |
|
137 | - EED_Single_Page_Checkout::instance()->_initialize(); |
|
138 | - } |
|
139 | - |
|
140 | - |
|
141 | - |
|
142 | - /** |
|
143 | - * ajax display registration step |
|
144 | - * |
|
145 | - * @throws \EE_Error |
|
146 | - */ |
|
147 | - public static function display_reg_step() |
|
148 | - { |
|
149 | - EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step'); |
|
150 | - } |
|
151 | - |
|
152 | - |
|
153 | - |
|
154 | - /** |
|
155 | - * ajax process registration step |
|
156 | - * |
|
157 | - * @throws \EE_Error |
|
158 | - */ |
|
159 | - public static function process_reg_step() |
|
160 | - { |
|
161 | - EED_Single_Page_Checkout::process_ajax_request('process_reg_step'); |
|
162 | - } |
|
163 | - |
|
164 | - |
|
165 | - |
|
166 | - /** |
|
167 | - * ajax process registration step |
|
168 | - * |
|
169 | - * @throws \EE_Error |
|
170 | - */ |
|
171 | - public static function update_reg_step() |
|
172 | - { |
|
173 | - EED_Single_Page_Checkout::process_ajax_request('update_reg_step'); |
|
174 | - } |
|
175 | - |
|
176 | - |
|
177 | - |
|
178 | - /** |
|
179 | - * update_checkout |
|
180 | - * |
|
181 | - * @access public |
|
182 | - * @return void |
|
183 | - * @throws \EE_Error |
|
184 | - */ |
|
185 | - public static function update_checkout() |
|
186 | - { |
|
187 | - EED_Single_Page_Checkout::process_ajax_request('update_checkout'); |
|
188 | - } |
|
189 | - |
|
190 | - |
|
191 | - |
|
192 | - /** |
|
193 | - * load_request_handler |
|
194 | - * |
|
195 | - * @access public |
|
196 | - * @return void |
|
197 | - */ |
|
198 | - public static function load_request_handler() |
|
199 | - { |
|
200 | - // load core Request_Handler class |
|
201 | - if ( ! isset(EE_Registry::instance()->REQ)) { |
|
202 | - EE_Registry::instance()->load_core('Request_Handler'); |
|
203 | - } |
|
204 | - } |
|
205 | - |
|
206 | - |
|
207 | - |
|
208 | - /** |
|
209 | - * set_definitions |
|
210 | - * |
|
211 | - * @access public |
|
212 | - * @return void |
|
213 | - * @throws \EE_Error |
|
214 | - */ |
|
215 | - public static function set_definitions() |
|
216 | - { |
|
217 | - if(defined('SPCO_BASE_PATH')) { |
|
218 | - return; |
|
219 | - } |
|
220 | - define('SPCO_BASE_PATH', rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS) . DS); |
|
221 | - define('SPCO_CSS_URL', plugin_dir_url(__FILE__) . 'css' . DS); |
|
222 | - define('SPCO_IMG_URL', plugin_dir_url(__FILE__) . 'img' . DS); |
|
223 | - define('SPCO_JS_URL', plugin_dir_url(__FILE__) . 'js' . DS); |
|
224 | - define('SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS); |
|
225 | - define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS); |
|
226 | - define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS); |
|
227 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, true); |
|
228 | - EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf( |
|
229 | - __('%1$sWe\'re sorry, but you\'re registration time has expired.%2$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', |
|
230 | - 'event_espresso'), |
|
231 | - '<h4 class="important-notice">', |
|
232 | - '</h4>', |
|
233 | - '<br />', |
|
234 | - '<p>', |
|
235 | - '<a href="' . get_post_type_archive_link('espresso_events') . '" title="', |
|
236 | - '">', |
|
237 | - '</a>', |
|
238 | - '</p>' |
|
239 | - ); |
|
240 | - } |
|
241 | - |
|
242 | - |
|
243 | - |
|
244 | - /** |
|
245 | - * load_reg_steps |
|
246 | - * loads and instantiates each reg step based on the EE_Registry::instance()->CFG->registration->reg_steps array |
|
247 | - * |
|
248 | - * @access private |
|
249 | - * @throws \EE_Error |
|
250 | - */ |
|
251 | - public static function load_reg_steps() |
|
252 | - { |
|
253 | - static $reg_steps_loaded = false; |
|
254 | - if ($reg_steps_loaded) { |
|
255 | - return; |
|
256 | - } |
|
257 | - // filter list of reg_steps |
|
258 | - $reg_steps_to_load = (array)apply_filters( |
|
259 | - 'AHEE__SPCO__load_reg_steps__reg_steps_to_load', |
|
260 | - EED_Single_Page_Checkout::get_reg_steps() |
|
261 | - ); |
|
262 | - // sort by key (order) |
|
263 | - ksort($reg_steps_to_load); |
|
264 | - // loop through folders |
|
265 | - foreach ($reg_steps_to_load as $order => $reg_step) { |
|
266 | - // we need a |
|
267 | - if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
268 | - // copy over to the reg_steps_array |
|
269 | - EED_Single_Page_Checkout::$_reg_steps_array[$order] = $reg_step; |
|
270 | - // register custom key route for each reg step |
|
271 | - // ie: step=>"slug" - this is the entire reason we load the reg steps array now |
|
272 | - EE_Config::register_route($reg_step['slug'], 'EED_Single_Page_Checkout', 'run', 'step'); |
|
273 | - // add AJAX or other hooks |
|
274 | - if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) { |
|
275 | - // setup autoloaders if necessary |
|
276 | - if ( ! class_exists($reg_step['class_name'])) { |
|
277 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder($reg_step['file_path'], true); |
|
278 | - } |
|
279 | - if (is_callable($reg_step['class_name'], 'set_hooks')) { |
|
280 | - call_user_func(array($reg_step['class_name'], 'set_hooks')); |
|
281 | - } |
|
282 | - } |
|
283 | - } |
|
284 | - } |
|
285 | - $reg_steps_loaded = true; |
|
286 | - } |
|
287 | - |
|
288 | - |
|
289 | - |
|
290 | - /** |
|
291 | - * get_reg_steps |
|
292 | - * |
|
293 | - * @access public |
|
294 | - * @return array |
|
295 | - */ |
|
296 | - public static function get_reg_steps() |
|
297 | - { |
|
298 | - $reg_steps = EE_Registry::instance()->CFG->registration->reg_steps; |
|
299 | - if (empty($reg_steps)) { |
|
300 | - $reg_steps = array( |
|
301 | - 10 => array( |
|
302 | - 'file_path' => SPCO_REG_STEPS_PATH . 'attendee_information', |
|
303 | - 'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information', |
|
304 | - 'slug' => 'attendee_information', |
|
305 | - 'has_hooks' => false, |
|
306 | - ), |
|
307 | - 20 => array( |
|
308 | - 'file_path' => SPCO_REG_STEPS_PATH . 'registration_confirmation', |
|
309 | - 'class_name' => 'EE_SPCO_Reg_Step_Registration_Confirmation', |
|
310 | - 'slug' => 'registration_confirmation', |
|
311 | - 'has_hooks' => false, |
|
312 | - ), |
|
313 | - 30 => array( |
|
314 | - 'file_path' => SPCO_REG_STEPS_PATH . 'payment_options', |
|
315 | - 'class_name' => 'EE_SPCO_Reg_Step_Payment_Options', |
|
316 | - 'slug' => 'payment_options', |
|
317 | - 'has_hooks' => true, |
|
318 | - ), |
|
319 | - 999 => array( |
|
320 | - 'file_path' => SPCO_REG_STEPS_PATH . 'finalize_registration', |
|
321 | - 'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration', |
|
322 | - 'slug' => 'finalize_registration', |
|
323 | - 'has_hooks' => false, |
|
324 | - ), |
|
325 | - ); |
|
326 | - } |
|
327 | - return $reg_steps; |
|
328 | - } |
|
329 | - |
|
330 | - |
|
331 | - |
|
332 | - /** |
|
333 | - * registration_checkout_for_admin |
|
334 | - * |
|
335 | - * @access public |
|
336 | - * @return string |
|
337 | - * @throws \EE_Error |
|
338 | - */ |
|
339 | - public static function registration_checkout_for_admin() |
|
340 | - { |
|
341 | - EED_Single_Page_Checkout::load_request_handler(); |
|
342 | - EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
343 | - EE_Registry::instance()->REQ->set('action', 'display_spco_reg_step'); |
|
344 | - EE_Registry::instance()->REQ->set('process_form_submission', false); |
|
345 | - EED_Single_Page_Checkout::instance()->_initialize(); |
|
346 | - EED_Single_Page_Checkout::instance()->_display_spco_reg_form(); |
|
347 | - return EE_Registry::instance()->REQ->get_output(); |
|
348 | - } |
|
349 | - |
|
350 | - |
|
351 | - |
|
352 | - /** |
|
353 | - * process_registration_from_admin |
|
354 | - * |
|
355 | - * @access public |
|
356 | - * @return \EE_Transaction |
|
357 | - * @throws \EE_Error |
|
358 | - */ |
|
359 | - public static function process_registration_from_admin() |
|
360 | - { |
|
361 | - EED_Single_Page_Checkout::load_request_handler(); |
|
362 | - EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
363 | - EE_Registry::instance()->REQ->set('action', 'process_reg_step'); |
|
364 | - EE_Registry::instance()->REQ->set('process_form_submission', true); |
|
365 | - EED_Single_Page_Checkout::instance()->_initialize(); |
|
366 | - if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) { |
|
367 | - $final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps); |
|
368 | - if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) { |
|
369 | - EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated($final_reg_step); |
|
370 | - if ($final_reg_step->process_reg_step()) { |
|
371 | - $final_reg_step->set_completed(); |
|
372 | - EED_Single_Page_Checkout::instance()->checkout->update_txn_reg_steps_array(); |
|
373 | - return EED_Single_Page_Checkout::instance()->checkout->transaction; |
|
374 | - } |
|
375 | - } |
|
376 | - } |
|
377 | - return null; |
|
378 | - } |
|
379 | - |
|
380 | - |
|
381 | - |
|
382 | - /** |
|
383 | - * run |
|
384 | - * |
|
385 | - * @access public |
|
386 | - * @param WP_Query $WP_Query |
|
387 | - * @return void |
|
388 | - * @throws \EE_Error |
|
389 | - */ |
|
390 | - public function run($WP_Query) |
|
391 | - { |
|
392 | - if ( |
|
393 | - $WP_Query instanceof WP_Query |
|
394 | - && $WP_Query->is_main_query() |
|
395 | - && apply_filters('FHEE__EED_Single_Page_Checkout__run', true) |
|
396 | - && $this->_is_reg_checkout() |
|
397 | - ) { |
|
398 | - $this->_initialize(); |
|
399 | - } |
|
400 | - } |
|
401 | - |
|
402 | - |
|
403 | - |
|
404 | - /** |
|
405 | - * determines whether current url matches reg page url |
|
406 | - * |
|
407 | - * @return bool |
|
408 | - */ |
|
409 | - protected function _is_reg_checkout() |
|
410 | - { |
|
411 | - // get current permalink for reg page without any extra query args |
|
412 | - $reg_page_url = \get_permalink(EE_Config::instance()->core->reg_page_id); |
|
413 | - // get request URI for current request, but without the scheme or host |
|
414 | - $current_request_uri = \EEH_URL::filter_input_server_url('REQUEST_URI'); |
|
415 | - $current_request_uri = html_entity_decode($current_request_uri); |
|
416 | - // get array of query args from the current request URI |
|
417 | - $query_args = \EEH_URL::get_query_string($current_request_uri); |
|
418 | - // grab page id if it is set |
|
419 | - $page_id = isset($query_args['page_id']) ? absint($query_args['page_id']) : 0; |
|
420 | - // and remove the page id from the query args (we will re-add it later) |
|
421 | - unset($query_args['page_id']); |
|
422 | - // now strip all query args from current request URI |
|
423 | - $current_request_uri = remove_query_arg(array_keys($query_args), $current_request_uri); |
|
424 | - // and re-add the page id if it was set |
|
425 | - if ($page_id) { |
|
426 | - $current_request_uri = add_query_arg('page_id', $page_id, $current_request_uri); |
|
427 | - } |
|
428 | - // remove slashes and ? |
|
429 | - $current_request_uri = trim($current_request_uri, '?/'); |
|
430 | - // is current request URI part of the known full reg page URL ? |
|
431 | - return ! empty($current_request_uri) && strpos($reg_page_url, $current_request_uri) !== false; |
|
432 | - } |
|
433 | - |
|
434 | - |
|
435 | - |
|
436 | - /** |
|
437 | - * @param WP_Query $wp_query |
|
438 | - * @return void |
|
439 | - * @throws \EE_Error |
|
440 | - */ |
|
441 | - public static function init($wp_query) |
|
442 | - { |
|
443 | - EED_Single_Page_Checkout::instance()->run($wp_query); |
|
444 | - } |
|
445 | - |
|
446 | - |
|
447 | - |
|
448 | - /** |
|
449 | - * _initialize - initial module setup |
|
450 | - * |
|
451 | - * @access private |
|
452 | - * @throws EE_Error |
|
453 | - * @return void |
|
454 | - */ |
|
455 | - private function _initialize() |
|
456 | - { |
|
457 | - // ensure SPCO doesn't run twice |
|
458 | - if (EED_Single_Page_Checkout::$_initialized) { |
|
459 | - return; |
|
460 | - } |
|
461 | - try { |
|
462 | - EED_Single_Page_Checkout::load_reg_steps(); |
|
463 | - $this->_verify_session(); |
|
464 | - // setup the EE_Checkout object |
|
465 | - $this->checkout = $this->_initialize_checkout(); |
|
466 | - // filter checkout |
|
467 | - $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout); |
|
468 | - // get the $_GET |
|
469 | - $this->_get_request_vars(); |
|
470 | - if ($this->_block_bots()) { |
|
471 | - return; |
|
472 | - } |
|
473 | - // filter continue_reg |
|
474 | - $this->checkout->continue_reg = apply_filters('FHEE__EED_Single_Page_Checkout__init___continue_reg', true, $this->checkout); |
|
475 | - // load the reg steps array |
|
476 | - if ( ! $this->_load_and_instantiate_reg_steps()) { |
|
477 | - EED_Single_Page_Checkout::$_initialized = true; |
|
478 | - return; |
|
479 | - } |
|
480 | - // set the current step |
|
481 | - $this->checkout->set_current_step($this->checkout->step); |
|
482 | - // and the next step |
|
483 | - $this->checkout->set_next_step(); |
|
484 | - // verify that everything has been setup correctly |
|
485 | - if ( ! ($this->_verify_transaction_and_get_registrations() && $this->_final_verifications())) { |
|
486 | - EED_Single_Page_Checkout::$_initialized = true; |
|
487 | - return; |
|
488 | - } |
|
489 | - // lock the transaction |
|
490 | - $this->checkout->transaction->lock(); |
|
491 | - // make sure all of our cached objects are added to their respective model entity mappers |
|
492 | - $this->checkout->refresh_all_entities(); |
|
493 | - // set amount owing |
|
494 | - $this->checkout->amount_owing = $this->checkout->transaction->remaining(); |
|
495 | - // initialize each reg step, which gives them the chance to potentially alter the process |
|
496 | - $this->_initialize_reg_steps(); |
|
497 | - // DEBUG LOG |
|
498 | - //$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ ); |
|
499 | - // get reg form |
|
500 | - if( ! $this->_check_form_submission()) { |
|
501 | - EED_Single_Page_Checkout::$_initialized = true; |
|
502 | - return; |
|
503 | - } |
|
504 | - // checkout the action!!! |
|
505 | - $this->_process_form_action(); |
|
506 | - // add some style and make it dance |
|
507 | - $this->add_styles_and_scripts(); |
|
508 | - // kk... SPCO has successfully run |
|
509 | - EED_Single_Page_Checkout::$_initialized = true; |
|
510 | - // set no cache headers and constants |
|
511 | - EE_System::do_not_cache(); |
|
512 | - // add anchor |
|
513 | - add_action('loop_start', array($this, 'set_checkout_anchor'), 1); |
|
514 | - // remove transaction lock |
|
515 | - add_action('shutdown', array($this, 'unlock_transaction'), 1); |
|
516 | - } catch (Exception $e) { |
|
517 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
518 | - } |
|
519 | - } |
|
520 | - |
|
521 | - |
|
522 | - |
|
523 | - /** |
|
524 | - * _verify_session |
|
525 | - * checks that the session is valid and not expired |
|
526 | - * |
|
527 | - * @access private |
|
528 | - * @throws EE_Error |
|
529 | - */ |
|
530 | - private function _verify_session() |
|
531 | - { |
|
532 | - if ( ! EE_Registry::instance()->SSN instanceof EE_Session) { |
|
533 | - throw new EE_Error(__('The EE_Session class could not be loaded.', 'event_espresso')); |
|
534 | - } |
|
535 | - // is session still valid ? |
|
536 | - if (EE_Registry::instance()->SSN->expired() && EE_Registry::instance()->REQ->get('e_reg_url_link', '') === '') { |
|
537 | - $this->checkout = new EE_Checkout(); |
|
538 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
539 | - // EE_Registry::instance()->SSN->reset_cart(); |
|
540 | - // EE_Registry::instance()->SSN->reset_checkout(); |
|
541 | - // EE_Registry::instance()->SSN->reset_transaction(); |
|
542 | - EE_Error::add_attention(EE_Registry::$i18n_js_strings['registration_expiration_notice'], __FILE__, |
|
543 | - __FUNCTION__, __LINE__); |
|
544 | - // EE_Registry::instance()->SSN->reset_expired(); |
|
545 | - } |
|
546 | - } |
|
547 | - |
|
548 | - |
|
549 | - |
|
550 | - /** |
|
551 | - * _initialize_checkout |
|
552 | - * loads and instantiates EE_Checkout |
|
553 | - * |
|
554 | - * @access private |
|
555 | - * @throws EE_Error |
|
556 | - * @return EE_Checkout |
|
557 | - */ |
|
558 | - private function _initialize_checkout() |
|
559 | - { |
|
560 | - // look in session for existing checkout |
|
561 | - /** @type EE_Checkout $checkout */ |
|
562 | - $checkout = EE_Registry::instance()->SSN->checkout(); |
|
563 | - // verify |
|
564 | - if ( ! $checkout instanceof EE_Checkout) { |
|
565 | - // instantiate EE_Checkout object for handling the properties of the current checkout process |
|
566 | - $checkout = EE_Registry::instance()->load_file(SPCO_INC_PATH, 'EE_Checkout', 'class', array(), false); |
|
567 | - } else { |
|
568 | - if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) { |
|
569 | - $this->unlock_transaction(); |
|
570 | - wp_safe_redirect($checkout->redirect_url); |
|
571 | - exit(); |
|
572 | - } |
|
573 | - } |
|
574 | - $checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout); |
|
575 | - // verify again |
|
576 | - if ( ! $checkout instanceof EE_Checkout) { |
|
577 | - throw new EE_Error(__('The EE_Checkout class could not be loaded.', 'event_espresso')); |
|
578 | - } |
|
579 | - // reset anything that needs a clean slate for each request |
|
580 | - $checkout->reset_for_current_request(); |
|
581 | - return $checkout; |
|
582 | - } |
|
583 | - |
|
584 | - |
|
585 | - |
|
586 | - /** |
|
587 | - * _get_request_vars |
|
588 | - * |
|
589 | - * @access private |
|
590 | - * @return void |
|
591 | - * @throws \EE_Error |
|
592 | - */ |
|
593 | - private function _get_request_vars() |
|
594 | - { |
|
595 | - // load classes |
|
596 | - EED_Single_Page_Checkout::load_request_handler(); |
|
597 | - //make sure this request is marked as belonging to EE |
|
598 | - EE_Registry::instance()->REQ->set_espresso_page(true); |
|
599 | - // which step is being requested ? |
|
600 | - $this->checkout->step = EE_Registry::instance()->REQ->get('step', $this->_get_first_step()); |
|
601 | - // which step is being edited ? |
|
602 | - $this->checkout->edit_step = EE_Registry::instance()->REQ->get('edit_step', ''); |
|
603 | - // and what we're doing on the current step |
|
604 | - $this->checkout->action = EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step'); |
|
605 | - // timestamp |
|
606 | - $this->checkout->uts = EE_Registry::instance()->REQ->get('uts', 0); |
|
607 | - // returning to edit ? |
|
608 | - $this->checkout->reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link', ''); |
|
609 | - // or some other kind of revisit ? |
|
610 | - $this->checkout->revisit = filter_var( |
|
611 | - EE_Registry::instance()->REQ->get('revisit', false), |
|
612 | - FILTER_VALIDATE_BOOLEAN |
|
613 | - ); |
|
614 | - // and whether or not to generate a reg form for this request |
|
615 | - $this->checkout->generate_reg_form = filter_var( |
|
616 | - EE_Registry::instance()->REQ->get('generate_reg_form', true), |
|
617 | - FILTER_VALIDATE_BOOLEAN |
|
618 | - ); |
|
619 | - // and whether or not to process a reg form submission for this request |
|
620 | - $this->checkout->process_form_submission = filter_var( |
|
621 | - EE_Registry::instance()->REQ->get( |
|
622 | - 'process_form_submission', |
|
623 | - $this->checkout->action === 'process_reg_step' |
|
624 | - ), |
|
625 | - FILTER_VALIDATE_BOOLEAN |
|
626 | - ); |
|
627 | - $this->checkout->process_form_submission = filter_var( |
|
628 | - $this->checkout->action !== 'display_spco_reg_step' |
|
629 | - ? $this->checkout->process_form_submission |
|
630 | - : false, |
|
631 | - FILTER_VALIDATE_BOOLEAN |
|
632 | - ); |
|
633 | - // $this->_display_request_vars(); |
|
634 | - } |
|
635 | - |
|
636 | - |
|
637 | - |
|
638 | - /** |
|
639 | - * _display_request_vars |
|
640 | - * |
|
641 | - * @access protected |
|
642 | - * @return void |
|
643 | - */ |
|
644 | - protected function _display_request_vars() |
|
645 | - { |
|
646 | - if ( ! WP_DEBUG) { |
|
647 | - return; |
|
648 | - } |
|
649 | - EEH_Debug_Tools::printr($_REQUEST, '$_REQUEST', __FILE__, __LINE__); |
|
650 | - EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__); |
|
651 | - EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__); |
|
652 | - EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__); |
|
653 | - EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__); |
|
654 | - EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__); |
|
655 | - EEH_Debug_Tools::printr($this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__); |
|
656 | - EEH_Debug_Tools::printr($this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__); |
|
657 | - } |
|
658 | - |
|
659 | - |
|
660 | - |
|
661 | - /** |
|
662 | - * _block_bots |
|
663 | - * checks that the incoming request has either of the following set: |
|
664 | - * a uts (unix timestamp) which indicates that the request was redirected from the Ticket Selector |
|
665 | - * a REG URL Link, which indicates that the request is a return visit to SPCO for a valid TXN |
|
666 | - * so if you're not coming from the Ticket Selector nor returning for a valid IP... |
|
667 | - * then where you coming from man? |
|
668 | - * |
|
669 | - * @return boolean |
|
670 | - */ |
|
671 | - private function _block_bots() |
|
672 | - { |
|
673 | - $invalid_checkout_access = \EED_Invalid_Checkout_Access::getInvalidCheckoutAccess(); |
|
674 | - if ($invalid_checkout_access->checkoutAccessIsInvalid($this->checkout)) { |
|
675 | - return true; |
|
676 | - } |
|
677 | - return false; |
|
678 | - } |
|
679 | - |
|
680 | - |
|
681 | - |
|
682 | - /** |
|
683 | - * _get_first_step |
|
684 | - * gets slug for first step in $_reg_steps_array |
|
685 | - * |
|
686 | - * @access private |
|
687 | - * @throws EE_Error |
|
688 | - * @return string |
|
689 | - */ |
|
690 | - private function _get_first_step() |
|
691 | - { |
|
692 | - $first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array); |
|
693 | - return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information'; |
|
694 | - } |
|
695 | - |
|
696 | - |
|
697 | - |
|
698 | - /** |
|
699 | - * _load_and_instantiate_reg_steps |
|
700 | - * instantiates each reg step based on the loaded reg_steps array |
|
701 | - * |
|
702 | - * @access private |
|
703 | - * @throws EE_Error |
|
704 | - * @return bool |
|
705 | - */ |
|
706 | - private function _load_and_instantiate_reg_steps() |
|
707 | - { |
|
708 | - // have reg_steps already been instantiated ? |
|
709 | - if ( |
|
710 | - empty($this->checkout->reg_steps) |
|
711 | - || apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout) |
|
712 | - ) { |
|
713 | - // if not, then loop through raw reg steps array |
|
714 | - foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) { |
|
715 | - if ( ! $this->_load_and_instantiate_reg_step($reg_step, $order)) { |
|
716 | - return false; |
|
717 | - } |
|
718 | - } |
|
719 | - EE_Registry::instance()->CFG->registration->skip_reg_confirmation = true; |
|
720 | - EE_Registry::instance()->CFG->registration->reg_confirmation_last = true; |
|
721 | - // skip the registration_confirmation page ? |
|
722 | - if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) { |
|
723 | - // just remove it from the reg steps array |
|
724 | - $this->checkout->remove_reg_step('registration_confirmation', false); |
|
725 | - } else if ( |
|
726 | - isset($this->checkout->reg_steps['registration_confirmation']) |
|
727 | - && EE_Registry::instance()->CFG->registration->reg_confirmation_last |
|
728 | - ) { |
|
729 | - // set the order to something big like 100 |
|
730 | - $this->checkout->set_reg_step_order('registration_confirmation', 100); |
|
731 | - } |
|
732 | - // filter the array for good luck |
|
733 | - $this->checkout->reg_steps = apply_filters( |
|
734 | - 'FHEE__Single_Page_Checkout__load_reg_steps__reg_steps', |
|
735 | - $this->checkout->reg_steps |
|
736 | - ); |
|
737 | - // finally re-sort based on the reg step class order properties |
|
738 | - $this->checkout->sort_reg_steps(); |
|
739 | - } else { |
|
740 | - foreach ($this->checkout->reg_steps as $reg_step) { |
|
741 | - // set all current step stati to FALSE |
|
742 | - $reg_step->set_is_current_step(false); |
|
743 | - } |
|
744 | - } |
|
745 | - if (empty($this->checkout->reg_steps)) { |
|
746 | - EE_Error::add_error(__('No Reg Steps were loaded..', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
747 | - return false; |
|
748 | - } |
|
749 | - // make reg step details available to JS |
|
750 | - $this->checkout->set_reg_step_JSON_info(); |
|
751 | - return true; |
|
752 | - } |
|
753 | - |
|
754 | - |
|
755 | - |
|
756 | - /** |
|
757 | - * _load_and_instantiate_reg_step |
|
758 | - * |
|
759 | - * @access private |
|
760 | - * @param array $reg_step |
|
761 | - * @param int $order |
|
762 | - * @return bool |
|
763 | - */ |
|
764 | - private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0) |
|
765 | - { |
|
766 | - // we need a file_path, class_name, and slug to add a reg step |
|
767 | - if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
768 | - // if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step) |
|
769 | - if ( |
|
770 | - $this->checkout->reg_url_link |
|
771 | - && $this->checkout->step !== $reg_step['slug'] |
|
772 | - && $reg_step['slug'] !== 'finalize_registration' |
|
773 | - ) { |
|
774 | - return true; |
|
775 | - } |
|
776 | - // instantiate step class using file path and class name |
|
777 | - $reg_step_obj = EE_Registry::instance()->load_file( |
|
778 | - $reg_step['file_path'], |
|
779 | - $reg_step['class_name'], |
|
780 | - 'class', |
|
781 | - $this->checkout, |
|
782 | - false |
|
783 | - ); |
|
784 | - // did we gets the goods ? |
|
785 | - if ($reg_step_obj instanceof EE_SPCO_Reg_Step) { |
|
786 | - // set reg step order based on config |
|
787 | - $reg_step_obj->set_order($order); |
|
788 | - // add instantiated reg step object to the master reg steps array |
|
789 | - $this->checkout->add_reg_step($reg_step_obj); |
|
790 | - } else { |
|
791 | - EE_Error::add_error( |
|
792 | - __('The current step could not be set.', 'event_espresso'), |
|
793 | - __FILE__, __FUNCTION__, __LINE__ |
|
794 | - ); |
|
795 | - return false; |
|
796 | - } |
|
797 | - } else { |
|
798 | - if (WP_DEBUG) { |
|
799 | - EE_Error::add_error( |
|
800 | - sprintf( |
|
801 | - __('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'), |
|
802 | - isset($reg_step['file_path']) ? $reg_step['file_path'] : '', |
|
803 | - isset($reg_step['class_name']) ? $reg_step['class_name'] : '', |
|
804 | - isset($reg_step['slug']) ? $reg_step['slug'] : '', |
|
805 | - '<ul>', |
|
806 | - '<li>', |
|
807 | - '</li>', |
|
808 | - '</ul>' |
|
809 | - ), |
|
810 | - __FILE__, __FUNCTION__, __LINE__ |
|
811 | - ); |
|
812 | - } |
|
813 | - return false; |
|
814 | - } |
|
815 | - return true; |
|
816 | - } |
|
817 | - |
|
818 | - |
|
819 | - |
|
820 | - /** |
|
821 | - * _verify_transaction_and_get_registrations |
|
822 | - * |
|
823 | - * @access private |
|
824 | - * @return bool |
|
825 | - */ |
|
826 | - private function _verify_transaction_and_get_registrations() |
|
827 | - { |
|
828 | - // was there already a valid transaction in the checkout from the session ? |
|
829 | - if ( ! $this->checkout->transaction instanceof EE_Transaction) { |
|
830 | - // get transaction from db or session |
|
831 | - $this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin() |
|
832 | - ? $this->_get_transaction_and_cart_for_previous_visit() |
|
833 | - : $this->_get_cart_for_current_session_and_setup_new_transaction(); |
|
834 | - if ( ! $this->checkout->transaction instanceof EE_Transaction) { |
|
835 | - EE_Error::add_error( |
|
836 | - __('Your Registration and Transaction information could not be retrieved from the db.', |
|
837 | - 'event_espresso'), |
|
838 | - __FILE__, __FUNCTION__, __LINE__ |
|
839 | - ); |
|
840 | - $this->checkout->transaction = EE_Transaction::new_instance(); |
|
841 | - // add some style and make it dance |
|
842 | - $this->add_styles_and_scripts(); |
|
843 | - EED_Single_Page_Checkout::$_initialized = true; |
|
844 | - return false; |
|
845 | - } |
|
846 | - // and the registrations for the transaction |
|
847 | - $this->_get_registrations($this->checkout->transaction); |
|
848 | - } |
|
849 | - return true; |
|
850 | - } |
|
851 | - |
|
852 | - |
|
853 | - |
|
854 | - /** |
|
855 | - * _get_transaction_and_cart_for_previous_visit |
|
856 | - * |
|
857 | - * @access private |
|
858 | - * @return mixed EE_Transaction|NULL |
|
859 | - */ |
|
860 | - private function _get_transaction_and_cart_for_previous_visit() |
|
861 | - { |
|
862 | - /** @var $TXN_model EEM_Transaction */ |
|
863 | - $TXN_model = EE_Registry::instance()->load_model('Transaction'); |
|
864 | - // 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 |
|
865 | - $transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link); |
|
866 | - // verify transaction |
|
867 | - if ($transaction instanceof EE_Transaction) { |
|
868 | - // and get the cart that was used for that transaction |
|
869 | - $this->checkout->cart = $this->_get_cart_for_transaction($transaction); |
|
870 | - return $transaction; |
|
871 | - } else { |
|
872 | - EE_Error::add_error(__('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
873 | - return null; |
|
874 | - } |
|
875 | - } |
|
876 | - |
|
877 | - |
|
878 | - |
|
879 | - /** |
|
880 | - * _get_cart_for_transaction |
|
881 | - * |
|
882 | - * @access private |
|
883 | - * @param EE_Transaction $transaction |
|
884 | - * @return EE_Cart |
|
885 | - */ |
|
886 | - private function _get_cart_for_transaction($transaction) |
|
887 | - { |
|
888 | - return $this->checkout->get_cart_for_transaction($transaction); |
|
889 | - } |
|
890 | - |
|
891 | - |
|
892 | - |
|
893 | - /** |
|
894 | - * get_cart_for_transaction |
|
895 | - * |
|
896 | - * @access public |
|
897 | - * @param EE_Transaction $transaction |
|
898 | - * @return EE_Cart |
|
899 | - */ |
|
900 | - public function get_cart_for_transaction(EE_Transaction $transaction) |
|
901 | - { |
|
902 | - return $this->checkout->get_cart_for_transaction($transaction); |
|
903 | - } |
|
904 | - |
|
905 | - |
|
906 | - |
|
907 | - /** |
|
908 | - * _get_transaction_and_cart_for_current_session |
|
909 | - * generates a new EE_Transaction object and adds it to the $_transaction property. |
|
910 | - * |
|
911 | - * @access private |
|
912 | - * @return EE_Transaction |
|
913 | - * @throws \EE_Error |
|
914 | - */ |
|
915 | - private function _get_cart_for_current_session_and_setup_new_transaction() |
|
916 | - { |
|
917 | - // if there's no transaction, then this is the FIRST visit to SPCO |
|
918 | - // so load up the cart ( passing nothing for the TXN because it doesn't exist yet ) |
|
919 | - $this->checkout->cart = $this->_get_cart_for_transaction(null); |
|
920 | - // and then create a new transaction |
|
921 | - $transaction = $this->_initialize_transaction(); |
|
922 | - // verify transaction |
|
923 | - if ($transaction instanceof EE_Transaction) { |
|
924 | - // save it so that we have an ID for other objects to use |
|
925 | - $transaction->save(); |
|
926 | - // and save TXN data to the cart |
|
927 | - $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID()); |
|
928 | - } else { |
|
929 | - EE_Error::add_error(__('A Valid Transaction could not be initialized.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
930 | - } |
|
931 | - return $transaction; |
|
932 | - } |
|
933 | - |
|
934 | - |
|
935 | - |
|
936 | - /** |
|
937 | - * generates a new EE_Transaction object and adds it to the $_transaction property. |
|
938 | - * |
|
939 | - * @access private |
|
940 | - * @return mixed EE_Transaction|NULL |
|
941 | - */ |
|
942 | - private function _initialize_transaction() |
|
943 | - { |
|
944 | - try { |
|
945 | - // ensure cart totals have been calculated |
|
946 | - $this->checkout->cart->get_grand_total()->recalculate_total_including_taxes(); |
|
947 | - // grab the cart grand total |
|
948 | - $cart_total = $this->checkout->cart->get_cart_grand_total(); |
|
949 | - // create new TXN |
|
950 | - $transaction = EE_Transaction::new_instance( |
|
951 | - array( |
|
952 | - 'TXN_reg_steps' => $this->checkout->initialize_txn_reg_steps_array(), |
|
953 | - 'TXN_total' => $cart_total > 0 ? $cart_total : 0, |
|
954 | - 'TXN_paid' => 0, |
|
955 | - 'STS_ID' => EEM_Transaction::failed_status_code, |
|
956 | - ) |
|
957 | - ); |
|
958 | - // save it so that we have an ID for other objects to use |
|
959 | - $transaction->save(); |
|
960 | - // set cron job for following up on TXNs after their session has expired |
|
961 | - EE_Cron_Tasks::schedule_expired_transaction_check( |
|
962 | - EE_Registry::instance()->SSN->expiration() + 1, |
|
963 | - $transaction->ID() |
|
964 | - ); |
|
965 | - return $transaction; |
|
966 | - } catch (Exception $e) { |
|
967 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
968 | - } |
|
969 | - return null; |
|
970 | - } |
|
971 | - |
|
972 | - |
|
973 | - |
|
974 | - /** |
|
975 | - * _get_registrations |
|
976 | - * |
|
977 | - * @access private |
|
978 | - * @param EE_Transaction $transaction |
|
979 | - * @return void |
|
980 | - * @throws \EventEspresso\core\exceptions\InvalidEntityException |
|
981 | - * @throws \EE_Error |
|
982 | - */ |
|
983 | - private function _get_registrations(EE_Transaction $transaction) |
|
984 | - { |
|
985 | - // first step: grab the registrants { : o |
|
986 | - $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, true); |
|
987 | - // verify registrations have been set |
|
988 | - if (empty($registrations)) { |
|
989 | - // if no cached registrations, then check the db |
|
990 | - $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false); |
|
991 | - // still nothing ? well as long as this isn't a revisit |
|
992 | - if (empty($registrations) && ! $this->checkout->revisit) { |
|
993 | - // generate new registrations from scratch |
|
994 | - $registrations = $this->_initialize_registrations($transaction); |
|
995 | - } |
|
996 | - } |
|
997 | - // sort by their original registration order |
|
998 | - usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count')); |
|
999 | - // then loop thru the array |
|
1000 | - foreach ($registrations as $registration) { |
|
1001 | - // verify each registration |
|
1002 | - if ($registration instanceof EE_Registration) { |
|
1003 | - // we display all attendee info for the primary registrant |
|
1004 | - if ($this->checkout->reg_url_link === $registration->reg_url_link() |
|
1005 | - && $registration->is_primary_registrant() |
|
1006 | - ) { |
|
1007 | - $this->checkout->primary_revisit = true; |
|
1008 | - break; |
|
1009 | - } else if ($this->checkout->revisit |
|
1010 | - && $this->checkout->reg_url_link !== $registration->reg_url_link() |
|
1011 | - ) { |
|
1012 | - // but hide info if it doesn't belong to you |
|
1013 | - $transaction->clear_cache('Registration', $registration->ID()); |
|
1014 | - } |
|
1015 | - $this->checkout->set_reg_status_updated($registration->ID(), false); |
|
1016 | - } |
|
1017 | - } |
|
1018 | - } |
|
1019 | - |
|
1020 | - |
|
1021 | - |
|
1022 | - /** |
|
1023 | - * adds related EE_Registration objects for each ticket in the cart to the current EE_Transaction object |
|
1024 | - * |
|
1025 | - * @access private |
|
1026 | - * @param EE_Transaction $transaction |
|
1027 | - * @return array |
|
1028 | - * @throws \EventEspresso\core\exceptions\InvalidEntityException |
|
1029 | - * @throws \EE_Error |
|
1030 | - */ |
|
1031 | - private function _initialize_registrations(EE_Transaction $transaction) |
|
1032 | - { |
|
1033 | - $att_nmbr = 0; |
|
1034 | - $registrations = array(); |
|
1035 | - if ($transaction instanceof EE_Transaction) { |
|
1036 | - /** @type EE_Registration_Processor $registration_processor */ |
|
1037 | - $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
1038 | - $this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count(); |
|
1039 | - // now let's add the cart items to the $transaction |
|
1040 | - foreach ($this->checkout->cart->get_tickets() as $line_item) { |
|
1041 | - //do the following for each ticket of this type they selected |
|
1042 | - for ($x = 1; $x <= $line_item->quantity(); $x++) { |
|
1043 | - $att_nmbr++; |
|
1044 | - /** @var EventEspresso\core\services\commands\registration\CreateRegistrationCommand $CreateRegistrationCommand */ |
|
1045 | - $CreateRegistrationCommand = EE_Registry::instance() |
|
1046 | - ->create( |
|
1047 | - 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
1048 | - array( |
|
1049 | - $transaction, |
|
1050 | - $line_item, |
|
1051 | - $att_nmbr, |
|
1052 | - $this->checkout->total_ticket_count, |
|
1053 | - ) |
|
1054 | - ); |
|
1055 | - // override capabilities for frontend registrations |
|
1056 | - if ( ! is_admin()) { |
|
1057 | - $CreateRegistrationCommand->setCapCheck( |
|
1058 | - new PublicCapabilities('', 'create_new_registration') |
|
1059 | - ); |
|
1060 | - } |
|
1061 | - $registration = EE_Registry::instance()->BUS->execute($CreateRegistrationCommand); |
|
1062 | - if ( ! $registration instanceof EE_Registration) { |
|
1063 | - throw new InvalidEntityException($registration, 'EE_Registration'); |
|
1064 | - } |
|
1065 | - $registrations[ $registration->ID() ] = $registration; |
|
1066 | - } |
|
1067 | - } |
|
1068 | - $registration_processor->fix_reg_final_price_rounding_issue($transaction); |
|
1069 | - } |
|
1070 | - return $registrations; |
|
1071 | - } |
|
1072 | - |
|
1073 | - |
|
1074 | - |
|
1075 | - /** |
|
1076 | - * sorts registrations by REG_count |
|
1077 | - * |
|
1078 | - * @access public |
|
1079 | - * @param EE_Registration $reg_A |
|
1080 | - * @param EE_Registration $reg_B |
|
1081 | - * @return int |
|
1082 | - */ |
|
1083 | - public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B) |
|
1084 | - { |
|
1085 | - // this shouldn't ever happen within the same TXN, but oh well |
|
1086 | - if ($reg_A->count() === $reg_B->count()) { |
|
1087 | - return 0; |
|
1088 | - } |
|
1089 | - return ($reg_A->count() > $reg_B->count()) ? 1 : -1; |
|
1090 | - } |
|
1091 | - |
|
1092 | - |
|
1093 | - |
|
1094 | - /** |
|
1095 | - * _final_verifications |
|
1096 | - * just makes sure that everything is set up correctly before proceeding |
|
1097 | - * |
|
1098 | - * @access private |
|
1099 | - * @return bool |
|
1100 | - * @throws \EE_Error |
|
1101 | - */ |
|
1102 | - private function _final_verifications() |
|
1103 | - { |
|
1104 | - // filter checkout |
|
1105 | - $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___final_verifications__checkout', $this->checkout); |
|
1106 | - //verify that current step is still set correctly |
|
1107 | - if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) { |
|
1108 | - EE_Error::add_error( |
|
1109 | - __('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'), |
|
1110 | - __FILE__, |
|
1111 | - __FUNCTION__, |
|
1112 | - __LINE__ |
|
1113 | - ); |
|
1114 | - return false; |
|
1115 | - } |
|
1116 | - // if returning to SPCO, then verify that primary registrant is set |
|
1117 | - if ( ! empty($this->checkout->reg_url_link)) { |
|
1118 | - $valid_registrant = $this->checkout->transaction->primary_registration(); |
|
1119 | - if ( ! $valid_registrant instanceof EE_Registration) { |
|
1120 | - EE_Error::add_error( |
|
1121 | - __('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'), |
|
1122 | - __FILE__, |
|
1123 | - __FUNCTION__, |
|
1124 | - __LINE__ |
|
1125 | - ); |
|
1126 | - return false; |
|
1127 | - } |
|
1128 | - $valid_registrant = null; |
|
1129 | - foreach ($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration) { |
|
1130 | - if ( |
|
1131 | - $registration instanceof EE_Registration |
|
1132 | - && $registration->reg_url_link() === $this->checkout->reg_url_link |
|
1133 | - ) { |
|
1134 | - $valid_registrant = $registration; |
|
1135 | - } |
|
1136 | - } |
|
1137 | - if ( ! $valid_registrant instanceof EE_Registration) { |
|
1138 | - // hmmm... maybe we have the wrong session because the user is opening multiple tabs ? |
|
1139 | - if (EED_Single_Page_Checkout::$_checkout_verified) { |
|
1140 | - // clear the session, mark the checkout as unverified, and try again |
|
1141 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
1142 | - EED_Single_Page_Checkout::$_initialized = false; |
|
1143 | - EED_Single_Page_Checkout::$_checkout_verified = false; |
|
1144 | - $this->_initialize(); |
|
1145 | - EE_Error::reset_notices(); |
|
1146 | - return false; |
|
1147 | - } |
|
1148 | - EE_Error::add_error( |
|
1149 | - __('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'), |
|
1150 | - __FILE__, |
|
1151 | - __FUNCTION__, |
|
1152 | - __LINE__ |
|
1153 | - ); |
|
1154 | - return false; |
|
1155 | - } |
|
1156 | - } |
|
1157 | - // now that things have been kinda sufficiently verified, |
|
1158 | - // let's add the checkout to the session so that it's available to other systems |
|
1159 | - EE_Registry::instance()->SSN->set_checkout($this->checkout); |
|
1160 | - return true; |
|
1161 | - } |
|
1162 | - |
|
1163 | - |
|
1164 | - |
|
1165 | - /** |
|
1166 | - * _initialize_reg_steps |
|
1167 | - * first makes sure that EE_Transaction_Processor::set_reg_step_initiated() is called as required |
|
1168 | - * then loops thru all of the active reg steps and calls the initialize_reg_step() method |
|
1169 | - * |
|
1170 | - * @access private |
|
1171 | - * @param bool $reinitializing |
|
1172 | - * @throws \EE_Error |
|
1173 | - */ |
|
1174 | - private function _initialize_reg_steps($reinitializing = false) |
|
1175 | - { |
|
1176 | - $this->checkout->set_reg_step_initiated($this->checkout->current_step); |
|
1177 | - // loop thru all steps to call their individual "initialize" methods and set i18n strings for JS |
|
1178 | - foreach ($this->checkout->reg_steps as $reg_step) { |
|
1179 | - if ( ! $reg_step->initialize_reg_step()) { |
|
1180 | - // if not initialized then maybe this step is being removed... |
|
1181 | - if ( ! $reinitializing && $reg_step->is_current_step()) { |
|
1182 | - // if it was the current step, then we need to start over here |
|
1183 | - $this->_initialize_reg_steps(true); |
|
1184 | - return; |
|
1185 | - } |
|
1186 | - continue; |
|
1187 | - } |
|
1188 | - // add css and JS for current step |
|
1189 | - $reg_step->enqueue_styles_and_scripts(); |
|
1190 | - // i18n |
|
1191 | - $reg_step->translate_js_strings(); |
|
1192 | - if ($reg_step->is_current_step()) { |
|
1193 | - // the text that appears on the reg step form submit button |
|
1194 | - $reg_step->set_submit_button_text(); |
|
1195 | - } |
|
1196 | - } |
|
1197 | - // dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information |
|
1198 | - do_action("AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", $this->checkout->current_step); |
|
1199 | - } |
|
1200 | - |
|
1201 | - |
|
1202 | - |
|
1203 | - /** |
|
1204 | - * _check_form_submission |
|
1205 | - * |
|
1206 | - * @access private |
|
1207 | - * @return boolean |
|
1208 | - */ |
|
1209 | - private function _check_form_submission() |
|
1210 | - { |
|
1211 | - //does this request require the reg form to be generated ? |
|
1212 | - if ($this->checkout->generate_reg_form) { |
|
1213 | - // ever heard that song by Blue Rodeo ? |
|
1214 | - try { |
|
1215 | - $this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form(); |
|
1216 | - // if not displaying a form, then check for form submission |
|
1217 | - if ( |
|
1218 | - $this->checkout->process_form_submission |
|
1219 | - && $this->checkout->current_step->reg_form->was_submitted() |
|
1220 | - ) { |
|
1221 | - // clear out any old data in case this step is being run again |
|
1222 | - $this->checkout->current_step->set_valid_data(array()); |
|
1223 | - // capture submitted form data |
|
1224 | - $this->checkout->current_step->reg_form->receive_form_submission( |
|
1225 | - apply_filters( |
|
1226 | - 'FHEE__Single_Page_Checkout___check_form_submission__request_params', |
|
1227 | - EE_Registry::instance()->REQ->params(), |
|
1228 | - $this->checkout |
|
1229 | - ) |
|
1230 | - ); |
|
1231 | - // validate submitted form data |
|
1232 | - if ( ! $this->checkout->continue_reg || ! $this->checkout->current_step->reg_form->is_valid()) { |
|
1233 | - // thou shall not pass !!! |
|
1234 | - $this->checkout->continue_reg = false; |
|
1235 | - // any form validation errors? |
|
1236 | - if ($this->checkout->current_step->reg_form->submission_error_message() !== '') { |
|
1237 | - $submission_error_messages = array(); |
|
1238 | - // bad, bad, bad registrant |
|
1239 | - foreach ($this->checkout->current_step->reg_form->get_validation_errors_accumulated() as $validation_error) { |
|
1240 | - if ($validation_error instanceof EE_Validation_Error) { |
|
1241 | - $submission_error_messages[] = sprintf( |
|
1242 | - __('%s : %s', 'event_espresso'), |
|
1243 | - $validation_error->get_form_section()->html_label_text(), |
|
1244 | - $validation_error->getMessage() |
|
1245 | - ); |
|
1246 | - } |
|
1247 | - } |
|
1248 | - EE_Error::add_error(implode('<br />', $submission_error_messages), __FILE__, __FUNCTION__, __LINE__); |
|
1249 | - } |
|
1250 | - // well not really... what will happen is we'll just get redirected back to redo the current step |
|
1251 | - $this->go_to_next_step(); |
|
1252 | - return false; |
|
1253 | - } |
|
1254 | - } |
|
1255 | - } catch (EE_Error $e) { |
|
1256 | - $e->get_error(); |
|
1257 | - } |
|
1258 | - } |
|
1259 | - return true; |
|
1260 | - } |
|
1261 | - |
|
1262 | - |
|
1263 | - |
|
1264 | - /** |
|
1265 | - * _process_action |
|
1266 | - * |
|
1267 | - * @access private |
|
1268 | - * @return void |
|
1269 | - * @throws \EE_Error |
|
1270 | - */ |
|
1271 | - private function _process_form_action() |
|
1272 | - { |
|
1273 | - // what cha wanna do? |
|
1274 | - switch ($this->checkout->action) { |
|
1275 | - // AJAX next step reg form |
|
1276 | - case 'display_spco_reg_step' : |
|
1277 | - $this->checkout->redirect = false; |
|
1278 | - if (EE_Registry::instance()->REQ->ajax) { |
|
1279 | - $this->checkout->json_response->set_reg_step_html($this->checkout->current_step->display_reg_form()); |
|
1280 | - } |
|
1281 | - break; |
|
1282 | - default : |
|
1283 | - // meh... do one of those other steps first |
|
1284 | - if ( ! empty($this->checkout->action) && is_callable(array($this->checkout->current_step, $this->checkout->action))) { |
|
1285 | - // dynamically creates hook point like: AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step |
|
1286 | - do_action("AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step); |
|
1287 | - // call action on current step |
|
1288 | - if (call_user_func(array($this->checkout->current_step, $this->checkout->action))) { |
|
1289 | - // good registrant, you get to proceed |
|
1290 | - if ( |
|
1291 | - $this->checkout->current_step->success_message() !== '' |
|
1292 | - && apply_filters( |
|
1293 | - 'FHEE__Single_Page_Checkout___process_form_action__display_success', |
|
1294 | - false |
|
1295 | - ) |
|
1296 | - ) { |
|
1297 | - EE_Error::add_success( |
|
1298 | - $this->checkout->current_step->success_message() |
|
1299 | - . '<br />' . $this->checkout->next_step->_instructions() |
|
1300 | - ); |
|
1301 | - } |
|
1302 | - // pack it up, pack it in... |
|
1303 | - $this->_setup_redirect(); |
|
1304 | - } |
|
1305 | - // dynamically creates hook point like: AHEE__Single_Page_Checkout__after_payment_options__process_reg_step |
|
1306 | - do_action("AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step); |
|
1307 | - } else { |
|
1308 | - EE_Error::add_error( |
|
1309 | - sprintf( |
|
1310 | - __('The requested form action "%s" does not exist for the current "%s" registration step.', 'event_espresso'), |
|
1311 | - $this->checkout->action, |
|
1312 | - $this->checkout->current_step->name() |
|
1313 | - ), |
|
1314 | - __FILE__, |
|
1315 | - __FUNCTION__, |
|
1316 | - __LINE__ |
|
1317 | - ); |
|
1318 | - } |
|
1319 | - // end default |
|
1320 | - } |
|
1321 | - // store our progress so far |
|
1322 | - $this->checkout->stash_transaction_and_checkout(); |
|
1323 | - // advance to the next step! If you pass GO, collect $200 |
|
1324 | - $this->go_to_next_step(); |
|
1325 | - } |
|
1326 | - |
|
1327 | - |
|
1328 | - |
|
1329 | - /** |
|
1330 | - * add_styles_and_scripts |
|
1331 | - * |
|
1332 | - * @access public |
|
1333 | - * @return void |
|
1334 | - */ |
|
1335 | - public function add_styles_and_scripts() |
|
1336 | - { |
|
1337 | - // i18n |
|
1338 | - $this->translate_js_strings(); |
|
1339 | - if ($this->checkout->admin_request) { |
|
1340 | - add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
1341 | - } else { |
|
1342 | - add_action('wp_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
1343 | - } |
|
1344 | - } |
|
1345 | - |
|
1346 | - |
|
1347 | - |
|
1348 | - /** |
|
1349 | - * translate_js_strings |
|
1350 | - * |
|
1351 | - * @access public |
|
1352 | - * @return void |
|
1353 | - */ |
|
1354 | - public function translate_js_strings() |
|
1355 | - { |
|
1356 | - EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit; |
|
1357 | - EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link; |
|
1358 | - 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'); |
|
1359 | - 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'); |
|
1360 | - 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'); |
|
1361 | - 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'); |
|
1362 | - EE_Registry::$i18n_js_strings['reg_step_error'] = __('This registration step could not be completed. Please refresh the page and try again.', 'event_espresso'); |
|
1363 | - 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'); |
|
1364 | - EE_Registry::$i18n_js_strings['process_registration'] = sprintf( |
|
1365 | - __('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'), |
|
1366 | - '<br/>', |
|
1367 | - '<br/>' |
|
1368 | - ); |
|
1369 | - EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language'); |
|
1370 | - EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id(); |
|
1371 | - EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency; |
|
1372 | - EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20'; |
|
1373 | - EE_Registry::$i18n_js_strings['timer_years'] = __('years', 'event_espresso'); |
|
1374 | - EE_Registry::$i18n_js_strings['timer_months'] = __('months', 'event_espresso'); |
|
1375 | - EE_Registry::$i18n_js_strings['timer_weeks'] = __('weeks', 'event_espresso'); |
|
1376 | - EE_Registry::$i18n_js_strings['timer_days'] = __('days', 'event_espresso'); |
|
1377 | - EE_Registry::$i18n_js_strings['timer_hours'] = __('hours', 'event_espresso'); |
|
1378 | - EE_Registry::$i18n_js_strings['timer_minutes'] = __('minutes', 'event_espresso'); |
|
1379 | - EE_Registry::$i18n_js_strings['timer_seconds'] = __('seconds', 'event_espresso'); |
|
1380 | - EE_Registry::$i18n_js_strings['timer_year'] = __('year', 'event_espresso'); |
|
1381 | - EE_Registry::$i18n_js_strings['timer_month'] = __('month', 'event_espresso'); |
|
1382 | - EE_Registry::$i18n_js_strings['timer_week'] = __('week', 'event_espresso'); |
|
1383 | - EE_Registry::$i18n_js_strings['timer_day'] = __('day', 'event_espresso'); |
|
1384 | - EE_Registry::$i18n_js_strings['timer_hour'] = __('hour', 'event_espresso'); |
|
1385 | - EE_Registry::$i18n_js_strings['timer_minute'] = __('minute', 'event_espresso'); |
|
1386 | - EE_Registry::$i18n_js_strings['timer_second'] = __('second', 'event_espresso'); |
|
1387 | - EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf( |
|
1388 | - __( |
|
1389 | - '%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', |
|
1390 | - 'event_espresso' |
|
1391 | - ), |
|
1392 | - '<h4 class="important-notice">', |
|
1393 | - '</h4>', |
|
1394 | - '<br />', |
|
1395 | - '<p>', |
|
1396 | - '<a href="' . get_post_type_archive_link('espresso_events') . '" title="', |
|
1397 | - '">', |
|
1398 | - '</a>', |
|
1399 | - '</p>' |
|
1400 | - ); |
|
1401 | - EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters('FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', true); |
|
1402 | - EE_Registry::$i18n_js_strings['session_extension'] = absint( |
|
1403 | - apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', 10 * MINUTE_IN_SECONDS) |
|
1404 | - ); |
|
1405 | - EE_Registry::$i18n_js_strings['session_expiration'] = gmdate( |
|
1406 | - 'M d, Y H:i:s', EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS) |
|
1407 | - ); |
|
1408 | - } |
|
1409 | - |
|
1410 | - |
|
1411 | - |
|
1412 | - /** |
|
1413 | - * enqueue_styles_and_scripts |
|
1414 | - * |
|
1415 | - * @access public |
|
1416 | - * @return void |
|
1417 | - * @throws \EE_Error |
|
1418 | - */ |
|
1419 | - public function enqueue_styles_and_scripts() |
|
1420 | - { |
|
1421 | - // load css |
|
1422 | - wp_register_style('single_page_checkout', SPCO_CSS_URL . 'single_page_checkout.css', array(), EVENT_ESPRESSO_VERSION); |
|
1423 | - wp_enqueue_style('single_page_checkout'); |
|
1424 | - // load JS |
|
1425 | - wp_register_script('jquery_plugin', EE_THIRD_PARTY_URL . 'jquery .plugin.min.js', array('jquery'), '1.0.1', true); |
|
1426 | - wp_register_script('jquery_countdown', EE_THIRD_PARTY_URL . 'jquery .countdown.min.js', array('jquery_plugin'), '2.0.2', true); |
|
1427 | - 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); |
|
1428 | - if ($this->checkout->registration_form instanceof EE_Form_Section_Proper) { |
|
1429 | - $this->checkout->registration_form->enqueue_js(); |
|
1430 | - } |
|
1431 | - if ($this->checkout->current_step->reg_form instanceof EE_Form_Section_Proper) { |
|
1432 | - $this->checkout->current_step->reg_form->enqueue_js(); |
|
1433 | - } |
|
1434 | - wp_enqueue_script('single_page_checkout'); |
|
1435 | - /** |
|
1436 | - * global action hook for enqueueing styles and scripts with |
|
1437 | - * spco calls. |
|
1438 | - */ |
|
1439 | - do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this); |
|
1440 | - /** |
|
1441 | - * dynamic action hook for enqueueing styles and scripts with spco calls. |
|
1442 | - * The hook will end up being something like AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information |
|
1443 | - */ |
|
1444 | - do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(), $this); |
|
1445 | - } |
|
1446 | - |
|
1447 | - |
|
1448 | - |
|
1449 | - /** |
|
1450 | - * display the Registration Single Page Checkout Form |
|
1451 | - * |
|
1452 | - * @access private |
|
1453 | - * @return void |
|
1454 | - * @throws \EE_Error |
|
1455 | - */ |
|
1456 | - private function _display_spco_reg_form() |
|
1457 | - { |
|
1458 | - // if registering via the admin, just display the reg form for the current step |
|
1459 | - if ($this->checkout->admin_request) { |
|
1460 | - EE_Registry::instance()->REQ->add_output($this->checkout->current_step->display_reg_form()); |
|
1461 | - } else { |
|
1462 | - // add powered by EE msg |
|
1463 | - add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer')); |
|
1464 | - $empty_cart = count($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params)) < 1 |
|
1465 | - ? true |
|
1466 | - : false; |
|
1467 | - EE_Registry::$i18n_js_strings['empty_cart'] = $empty_cart; |
|
1468 | - $cookies_not_set_msg = ''; |
|
1469 | - if ($empty_cart && ! isset($_COOKIE['ee_cookie_test'])) { |
|
1470 | - $cookies_not_set_msg = apply_filters( |
|
1471 | - 'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg', |
|
1472 | - sprintf( |
|
1473 | - __( |
|
1474 | - '%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', |
|
1475 | - 'event_espresso' |
|
1476 | - ), |
|
1477 | - '<div class="ee-attention">', |
|
1478 | - '</div>', |
|
1479 | - '<h6 class="important-notice">', |
|
1480 | - '</h6>', |
|
1481 | - '<p>', |
|
1482 | - '</p>', |
|
1483 | - '<br />', |
|
1484 | - '<a href="http://www.whatarecookies.com/enable.asp" target="_blank">', |
|
1485 | - '</a>' |
|
1486 | - ) |
|
1487 | - ); |
|
1488 | - } |
|
1489 | - $this->checkout->registration_form = new EE_Form_Section_Proper( |
|
1490 | - array( |
|
1491 | - 'name' => 'single-page-checkout', |
|
1492 | - 'html_id' => 'ee-single-page-checkout-dv', |
|
1493 | - 'layout_strategy' => |
|
1494 | - new EE_Template_Layout( |
|
1495 | - array( |
|
1496 | - 'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php', |
|
1497 | - 'template_args' => array( |
|
1498 | - 'empty_cart' => $empty_cart, |
|
1499 | - 'revisit' => $this->checkout->revisit, |
|
1500 | - 'reg_steps' => $this->checkout->reg_steps, |
|
1501 | - 'next_step' => $this->checkout->next_step instanceof EE_SPCO_Reg_Step |
|
1502 | - ? $this->checkout->next_step->slug() |
|
1503 | - : '', |
|
1504 | - 'cancel_page_url' => $this->checkout->cancel_page_url, |
|
1505 | - 'empty_msg' => apply_filters( |
|
1506 | - 'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg', |
|
1507 | - sprintf( |
|
1508 | - __('You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.', |
|
1509 | - 'event_espresso'), |
|
1510 | - '<a href="' . get_post_type_archive_link('espresso_events') . '" title="', |
|
1511 | - '">', |
|
1512 | - '</a>' |
|
1513 | - ) |
|
1514 | - ), |
|
1515 | - 'cookies_not_set_msg' => $cookies_not_set_msg, |
|
1516 | - 'registration_time_limit' => $this->checkout->get_registration_time_limit(), |
|
1517 | - 'session_expiration' => gmdate( |
|
1518 | - 'M d, Y H:i:s', |
|
1519 | - EE_Registry::instance()->SSN->expiration() |
|
1520 | - + (get_option('gmt_offset') * HOUR_IN_SECONDS) |
|
1521 | - ), |
|
1522 | - ), |
|
1523 | - ) |
|
1524 | - ), |
|
1525 | - ) |
|
1526 | - ); |
|
1527 | - // load template and add to output sent that gets filtered into the_content() |
|
1528 | - EE_Registry::instance()->REQ->add_output($this->checkout->registration_form->get_html()); |
|
1529 | - } |
|
1530 | - } |
|
1531 | - |
|
1532 | - |
|
1533 | - |
|
1534 | - /** |
|
1535 | - * add_extra_finalize_registration_inputs |
|
1536 | - * |
|
1537 | - * @access public |
|
1538 | - * @param $next_step |
|
1539 | - * @internal param string $label |
|
1540 | - * @return void |
|
1541 | - */ |
|
1542 | - public function add_extra_finalize_registration_inputs($next_step) |
|
1543 | - { |
|
1544 | - if ($next_step === 'finalize_registration') { |
|
1545 | - echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>'; |
|
1546 | - } |
|
1547 | - } |
|
1548 | - |
|
1549 | - |
|
1550 | - |
|
1551 | - /** |
|
1552 | - * display_registration_footer |
|
1553 | - * |
|
1554 | - * @access public |
|
1555 | - * @return string |
|
1556 | - */ |
|
1557 | - public static function display_registration_footer() |
|
1558 | - { |
|
1559 | - if ( |
|
1560 | - apply_filters( |
|
1561 | - 'FHEE__EE_Front__Controller__show_reg_footer', |
|
1562 | - EE_Registry::instance()->CFG->admin->show_reg_footer |
|
1563 | - ) |
|
1564 | - ) { |
|
1565 | - add_filter( |
|
1566 | - 'FHEE__EEH_Template__powered_by_event_espresso__url', |
|
1567 | - function ($url) { |
|
1568 | - return apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url); |
|
1569 | - } |
|
1570 | - ); |
|
1571 | - echo apply_filters( |
|
1572 | - 'FHEE__EE_Front_Controller__display_registration_footer', |
|
1573 | - \EEH_Template::powered_by_event_espresso( |
|
1574 | - '', |
|
1575 | - 'espresso-registration-footer-dv', |
|
1576 | - array('utm_content' => 'registration_checkout') |
|
1577 | - ) |
|
1578 | - ); |
|
1579 | - } |
|
1580 | - return ''; |
|
1581 | - } |
|
1582 | - |
|
1583 | - |
|
1584 | - |
|
1585 | - /** |
|
1586 | - * unlock_transaction |
|
1587 | - * |
|
1588 | - * @access public |
|
1589 | - * @return void |
|
1590 | - * @throws \EE_Error |
|
1591 | - */ |
|
1592 | - public function unlock_transaction() |
|
1593 | - { |
|
1594 | - if ($this->checkout->transaction instanceof EE_Transaction) { |
|
1595 | - $this->checkout->transaction->unlock(); |
|
1596 | - } |
|
1597 | - } |
|
1598 | - |
|
1599 | - |
|
1600 | - |
|
1601 | - /** |
|
1602 | - * _setup_redirect |
|
1603 | - * |
|
1604 | - * @access private |
|
1605 | - * @return void |
|
1606 | - */ |
|
1607 | - private function _setup_redirect() |
|
1608 | - { |
|
1609 | - if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
1610 | - $this->checkout->redirect = true; |
|
1611 | - if (empty($this->checkout->redirect_url)) { |
|
1612 | - $this->checkout->redirect_url = $this->checkout->next_step->reg_step_url(); |
|
1613 | - } |
|
1614 | - $this->checkout->redirect_url = apply_filters( |
|
1615 | - 'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url', |
|
1616 | - $this->checkout->redirect_url, |
|
1617 | - $this->checkout |
|
1618 | - ); |
|
1619 | - } |
|
1620 | - } |
|
1621 | - |
|
1622 | - |
|
1623 | - |
|
1624 | - /** |
|
1625 | - * handle ajax message responses and redirects |
|
1626 | - * |
|
1627 | - * @access public |
|
1628 | - * @return void |
|
1629 | - * @throws \EE_Error |
|
1630 | - */ |
|
1631 | - public function go_to_next_step() |
|
1632 | - { |
|
1633 | - if (EE_Registry::instance()->REQ->ajax) { |
|
1634 | - // capture contents of output buffer we started earlier in the request, and insert into JSON response |
|
1635 | - $this->checkout->json_response->set_unexpected_errors(ob_get_clean()); |
|
1636 | - } |
|
1637 | - $this->unlock_transaction(); |
|
1638 | - // just return for these conditions |
|
1639 | - if ( |
|
1640 | - $this->checkout->admin_request |
|
1641 | - || $this->checkout->action === 'redirect_form' |
|
1642 | - || $this->checkout->action === 'update_checkout' |
|
1643 | - ) { |
|
1644 | - return; |
|
1645 | - } |
|
1646 | - // AJAX response |
|
1647 | - $this->_handle_json_response(); |
|
1648 | - // redirect to next step or the Thank You page |
|
1649 | - $this->_handle_html_redirects(); |
|
1650 | - // hmmm... must be something wrong, so let's just display the form again ! |
|
1651 | - $this->_display_spco_reg_form(); |
|
1652 | - } |
|
1653 | - |
|
1654 | - |
|
1655 | - |
|
1656 | - /** |
|
1657 | - * _handle_json_response |
|
1658 | - * |
|
1659 | - * @access protected |
|
1660 | - * @return void |
|
1661 | - */ |
|
1662 | - protected function _handle_json_response() |
|
1663 | - { |
|
1664 | - // if this is an ajax request |
|
1665 | - if (EE_Registry::instance()->REQ->ajax) { |
|
1666 | - // DEBUG LOG |
|
1667 | - //$this->checkout->log( |
|
1668 | - // __CLASS__, __FUNCTION__, __LINE__, |
|
1669 | - // array( |
|
1670 | - // 'json_response_redirect_url' => $this->checkout->json_response->redirect_url(), |
|
1671 | - // 'redirect' => $this->checkout->redirect, |
|
1672 | - // 'continue_reg' => $this->checkout->continue_reg, |
|
1673 | - // ) |
|
1674 | - //); |
|
1675 | - $this->checkout->json_response->set_registration_time_limit( |
|
1676 | - $this->checkout->get_registration_time_limit() |
|
1677 | - ); |
|
1678 | - $this->checkout->json_response->set_payment_amount($this->checkout->amount_owing); |
|
1679 | - // just send the ajax ( |
|
1680 | - $json_response = apply_filters( |
|
1681 | - 'FHEE__EE_Single_Page_Checkout__JSON_response', |
|
1682 | - $this->checkout->json_response |
|
1683 | - ); |
|
1684 | - echo $json_response; |
|
1685 | - exit(); |
|
1686 | - } |
|
1687 | - } |
|
1688 | - |
|
1689 | - |
|
1690 | - |
|
1691 | - /** |
|
1692 | - * _handle_redirects |
|
1693 | - * |
|
1694 | - * @access protected |
|
1695 | - * @return void |
|
1696 | - */ |
|
1697 | - protected function _handle_html_redirects() |
|
1698 | - { |
|
1699 | - // going somewhere ? |
|
1700 | - if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) { |
|
1701 | - // store notices in a transient |
|
1702 | - EE_Error::get_notices(false, true, true); |
|
1703 | - // DEBUG LOG |
|
1704 | - //$this->checkout->log( |
|
1705 | - // __CLASS__, __FUNCTION__, __LINE__, |
|
1706 | - // array( |
|
1707 | - // 'headers_sent' => headers_sent(), |
|
1708 | - // 'redirect_url' => $this->checkout->redirect_url, |
|
1709 | - // 'headers_list' => headers_list(), |
|
1710 | - // ) |
|
1711 | - //); |
|
1712 | - wp_safe_redirect($this->checkout->redirect_url); |
|
1713 | - exit(); |
|
1714 | - } |
|
1715 | - } |
|
1716 | - |
|
1717 | - |
|
1718 | - |
|
1719 | - /** |
|
1720 | - * set_checkout_anchor |
|
1721 | - * |
|
1722 | - * @access public |
|
1723 | - * @return void |
|
1724 | - */ |
|
1725 | - public function set_checkout_anchor() |
|
1726 | - { |
|
1727 | - echo '<a id="checkout" style="float: left; margin-left: -999em;"></a>'; |
|
1728 | - } |
|
20 | + /** |
|
21 | + * $_initialized - has the SPCO controller already been initialized ? |
|
22 | + * |
|
23 | + * @access private |
|
24 | + * @var bool $_initialized |
|
25 | + */ |
|
26 | + private static $_initialized = false; |
|
27 | + |
|
28 | + |
|
29 | + /** |
|
30 | + * $_checkout_verified - is the EE_Checkout verified as correct for this request ? |
|
31 | + * |
|
32 | + * @access private |
|
33 | + * @var bool $_valid_checkout |
|
34 | + */ |
|
35 | + private static $_checkout_verified = true; |
|
36 | + |
|
37 | + /** |
|
38 | + * $_reg_steps_array - holds initial array of reg steps |
|
39 | + * |
|
40 | + * @access private |
|
41 | + * @var array $_reg_steps_array |
|
42 | + */ |
|
43 | + private static $_reg_steps_array = array(); |
|
44 | + |
|
45 | + /** |
|
46 | + * $checkout - EE_Checkout object for handling the properties of the current checkout process |
|
47 | + * |
|
48 | + * @access public |
|
49 | + * @var EE_Checkout $checkout |
|
50 | + */ |
|
51 | + public $checkout; |
|
52 | + |
|
53 | + |
|
54 | + |
|
55 | + /** |
|
56 | + * @return EED_Single_Page_Checkout |
|
57 | + */ |
|
58 | + public static function instance() |
|
59 | + { |
|
60 | + add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true'); |
|
61 | + return parent::get_instance(__CLASS__); |
|
62 | + } |
|
63 | + |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * @return EE_CART |
|
68 | + */ |
|
69 | + public function cart() |
|
70 | + { |
|
71 | + return $this->checkout->cart; |
|
72 | + } |
|
73 | + |
|
74 | + |
|
75 | + |
|
76 | + /** |
|
77 | + * @return EE_Transaction |
|
78 | + */ |
|
79 | + public function transaction() |
|
80 | + { |
|
81 | + return $this->checkout->transaction; |
|
82 | + } |
|
83 | + |
|
84 | + |
|
85 | + |
|
86 | + /** |
|
87 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
88 | + * |
|
89 | + * @access public |
|
90 | + * @return void |
|
91 | + * @throws \EE_Error |
|
92 | + */ |
|
93 | + public static function set_hooks() |
|
94 | + { |
|
95 | + EED_Single_Page_Checkout::set_definitions(); |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + |
|
100 | + /** |
|
101 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
102 | + * |
|
103 | + * @access public |
|
104 | + * @return void |
|
105 | + * @throws \EE_Error |
|
106 | + */ |
|
107 | + public static function set_hooks_admin() |
|
108 | + { |
|
109 | + EED_Single_Page_Checkout::set_definitions(); |
|
110 | + if ( ! (defined('DOING_AJAX') && DOING_AJAX)) { |
|
111 | + return; |
|
112 | + } |
|
113 | + // going to start an output buffer in case anything gets accidentally output that might disrupt our JSON response |
|
114 | + ob_start(); |
|
115 | + EED_Single_Page_Checkout::load_request_handler(); |
|
116 | + EED_Single_Page_Checkout::load_reg_steps(); |
|
117 | + // set ajax hooks |
|
118 | + add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
119 | + add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
120 | + add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
121 | + add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
122 | + add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
123 | + add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
124 | + } |
|
125 | + |
|
126 | + |
|
127 | + |
|
128 | + /** |
|
129 | + * process ajax request |
|
130 | + * |
|
131 | + * @param string $ajax_action |
|
132 | + * @throws \EE_Error |
|
133 | + */ |
|
134 | + public static function process_ajax_request($ajax_action) |
|
135 | + { |
|
136 | + EE_Registry::instance()->REQ->set('action', $ajax_action); |
|
137 | + EED_Single_Page_Checkout::instance()->_initialize(); |
|
138 | + } |
|
139 | + |
|
140 | + |
|
141 | + |
|
142 | + /** |
|
143 | + * ajax display registration step |
|
144 | + * |
|
145 | + * @throws \EE_Error |
|
146 | + */ |
|
147 | + public static function display_reg_step() |
|
148 | + { |
|
149 | + EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step'); |
|
150 | + } |
|
151 | + |
|
152 | + |
|
153 | + |
|
154 | + /** |
|
155 | + * ajax process registration step |
|
156 | + * |
|
157 | + * @throws \EE_Error |
|
158 | + */ |
|
159 | + public static function process_reg_step() |
|
160 | + { |
|
161 | + EED_Single_Page_Checkout::process_ajax_request('process_reg_step'); |
|
162 | + } |
|
163 | + |
|
164 | + |
|
165 | + |
|
166 | + /** |
|
167 | + * ajax process registration step |
|
168 | + * |
|
169 | + * @throws \EE_Error |
|
170 | + */ |
|
171 | + public static function update_reg_step() |
|
172 | + { |
|
173 | + EED_Single_Page_Checkout::process_ajax_request('update_reg_step'); |
|
174 | + } |
|
175 | + |
|
176 | + |
|
177 | + |
|
178 | + /** |
|
179 | + * update_checkout |
|
180 | + * |
|
181 | + * @access public |
|
182 | + * @return void |
|
183 | + * @throws \EE_Error |
|
184 | + */ |
|
185 | + public static function update_checkout() |
|
186 | + { |
|
187 | + EED_Single_Page_Checkout::process_ajax_request('update_checkout'); |
|
188 | + } |
|
189 | + |
|
190 | + |
|
191 | + |
|
192 | + /** |
|
193 | + * load_request_handler |
|
194 | + * |
|
195 | + * @access public |
|
196 | + * @return void |
|
197 | + */ |
|
198 | + public static function load_request_handler() |
|
199 | + { |
|
200 | + // load core Request_Handler class |
|
201 | + if ( ! isset(EE_Registry::instance()->REQ)) { |
|
202 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
203 | + } |
|
204 | + } |
|
205 | + |
|
206 | + |
|
207 | + |
|
208 | + /** |
|
209 | + * set_definitions |
|
210 | + * |
|
211 | + * @access public |
|
212 | + * @return void |
|
213 | + * @throws \EE_Error |
|
214 | + */ |
|
215 | + public static function set_definitions() |
|
216 | + { |
|
217 | + if(defined('SPCO_BASE_PATH')) { |
|
218 | + return; |
|
219 | + } |
|
220 | + define('SPCO_BASE_PATH', rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS) . DS); |
|
221 | + define('SPCO_CSS_URL', plugin_dir_url(__FILE__) . 'css' . DS); |
|
222 | + define('SPCO_IMG_URL', plugin_dir_url(__FILE__) . 'img' . DS); |
|
223 | + define('SPCO_JS_URL', plugin_dir_url(__FILE__) . 'js' . DS); |
|
224 | + define('SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS); |
|
225 | + define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS); |
|
226 | + define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS); |
|
227 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, true); |
|
228 | + EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf( |
|
229 | + __('%1$sWe\'re sorry, but you\'re registration time has expired.%2$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', |
|
230 | + 'event_espresso'), |
|
231 | + '<h4 class="important-notice">', |
|
232 | + '</h4>', |
|
233 | + '<br />', |
|
234 | + '<p>', |
|
235 | + '<a href="' . get_post_type_archive_link('espresso_events') . '" title="', |
|
236 | + '">', |
|
237 | + '</a>', |
|
238 | + '</p>' |
|
239 | + ); |
|
240 | + } |
|
241 | + |
|
242 | + |
|
243 | + |
|
244 | + /** |
|
245 | + * load_reg_steps |
|
246 | + * loads and instantiates each reg step based on the EE_Registry::instance()->CFG->registration->reg_steps array |
|
247 | + * |
|
248 | + * @access private |
|
249 | + * @throws \EE_Error |
|
250 | + */ |
|
251 | + public static function load_reg_steps() |
|
252 | + { |
|
253 | + static $reg_steps_loaded = false; |
|
254 | + if ($reg_steps_loaded) { |
|
255 | + return; |
|
256 | + } |
|
257 | + // filter list of reg_steps |
|
258 | + $reg_steps_to_load = (array)apply_filters( |
|
259 | + 'AHEE__SPCO__load_reg_steps__reg_steps_to_load', |
|
260 | + EED_Single_Page_Checkout::get_reg_steps() |
|
261 | + ); |
|
262 | + // sort by key (order) |
|
263 | + ksort($reg_steps_to_load); |
|
264 | + // loop through folders |
|
265 | + foreach ($reg_steps_to_load as $order => $reg_step) { |
|
266 | + // we need a |
|
267 | + if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
268 | + // copy over to the reg_steps_array |
|
269 | + EED_Single_Page_Checkout::$_reg_steps_array[$order] = $reg_step; |
|
270 | + // register custom key route for each reg step |
|
271 | + // ie: step=>"slug" - this is the entire reason we load the reg steps array now |
|
272 | + EE_Config::register_route($reg_step['slug'], 'EED_Single_Page_Checkout', 'run', 'step'); |
|
273 | + // add AJAX or other hooks |
|
274 | + if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) { |
|
275 | + // setup autoloaders if necessary |
|
276 | + if ( ! class_exists($reg_step['class_name'])) { |
|
277 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder($reg_step['file_path'], true); |
|
278 | + } |
|
279 | + if (is_callable($reg_step['class_name'], 'set_hooks')) { |
|
280 | + call_user_func(array($reg_step['class_name'], 'set_hooks')); |
|
281 | + } |
|
282 | + } |
|
283 | + } |
|
284 | + } |
|
285 | + $reg_steps_loaded = true; |
|
286 | + } |
|
287 | + |
|
288 | + |
|
289 | + |
|
290 | + /** |
|
291 | + * get_reg_steps |
|
292 | + * |
|
293 | + * @access public |
|
294 | + * @return array |
|
295 | + */ |
|
296 | + public static function get_reg_steps() |
|
297 | + { |
|
298 | + $reg_steps = EE_Registry::instance()->CFG->registration->reg_steps; |
|
299 | + if (empty($reg_steps)) { |
|
300 | + $reg_steps = array( |
|
301 | + 10 => array( |
|
302 | + 'file_path' => SPCO_REG_STEPS_PATH . 'attendee_information', |
|
303 | + 'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information', |
|
304 | + 'slug' => 'attendee_information', |
|
305 | + 'has_hooks' => false, |
|
306 | + ), |
|
307 | + 20 => array( |
|
308 | + 'file_path' => SPCO_REG_STEPS_PATH . 'registration_confirmation', |
|
309 | + 'class_name' => 'EE_SPCO_Reg_Step_Registration_Confirmation', |
|
310 | + 'slug' => 'registration_confirmation', |
|
311 | + 'has_hooks' => false, |
|
312 | + ), |
|
313 | + 30 => array( |
|
314 | + 'file_path' => SPCO_REG_STEPS_PATH . 'payment_options', |
|
315 | + 'class_name' => 'EE_SPCO_Reg_Step_Payment_Options', |
|
316 | + 'slug' => 'payment_options', |
|
317 | + 'has_hooks' => true, |
|
318 | + ), |
|
319 | + 999 => array( |
|
320 | + 'file_path' => SPCO_REG_STEPS_PATH . 'finalize_registration', |
|
321 | + 'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration', |
|
322 | + 'slug' => 'finalize_registration', |
|
323 | + 'has_hooks' => false, |
|
324 | + ), |
|
325 | + ); |
|
326 | + } |
|
327 | + return $reg_steps; |
|
328 | + } |
|
329 | + |
|
330 | + |
|
331 | + |
|
332 | + /** |
|
333 | + * registration_checkout_for_admin |
|
334 | + * |
|
335 | + * @access public |
|
336 | + * @return string |
|
337 | + * @throws \EE_Error |
|
338 | + */ |
|
339 | + public static function registration_checkout_for_admin() |
|
340 | + { |
|
341 | + EED_Single_Page_Checkout::load_request_handler(); |
|
342 | + EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
343 | + EE_Registry::instance()->REQ->set('action', 'display_spco_reg_step'); |
|
344 | + EE_Registry::instance()->REQ->set('process_form_submission', false); |
|
345 | + EED_Single_Page_Checkout::instance()->_initialize(); |
|
346 | + EED_Single_Page_Checkout::instance()->_display_spco_reg_form(); |
|
347 | + return EE_Registry::instance()->REQ->get_output(); |
|
348 | + } |
|
349 | + |
|
350 | + |
|
351 | + |
|
352 | + /** |
|
353 | + * process_registration_from_admin |
|
354 | + * |
|
355 | + * @access public |
|
356 | + * @return \EE_Transaction |
|
357 | + * @throws \EE_Error |
|
358 | + */ |
|
359 | + public static function process_registration_from_admin() |
|
360 | + { |
|
361 | + EED_Single_Page_Checkout::load_request_handler(); |
|
362 | + EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
363 | + EE_Registry::instance()->REQ->set('action', 'process_reg_step'); |
|
364 | + EE_Registry::instance()->REQ->set('process_form_submission', true); |
|
365 | + EED_Single_Page_Checkout::instance()->_initialize(); |
|
366 | + if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) { |
|
367 | + $final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps); |
|
368 | + if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) { |
|
369 | + EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated($final_reg_step); |
|
370 | + if ($final_reg_step->process_reg_step()) { |
|
371 | + $final_reg_step->set_completed(); |
|
372 | + EED_Single_Page_Checkout::instance()->checkout->update_txn_reg_steps_array(); |
|
373 | + return EED_Single_Page_Checkout::instance()->checkout->transaction; |
|
374 | + } |
|
375 | + } |
|
376 | + } |
|
377 | + return null; |
|
378 | + } |
|
379 | + |
|
380 | + |
|
381 | + |
|
382 | + /** |
|
383 | + * run |
|
384 | + * |
|
385 | + * @access public |
|
386 | + * @param WP_Query $WP_Query |
|
387 | + * @return void |
|
388 | + * @throws \EE_Error |
|
389 | + */ |
|
390 | + public function run($WP_Query) |
|
391 | + { |
|
392 | + if ( |
|
393 | + $WP_Query instanceof WP_Query |
|
394 | + && $WP_Query->is_main_query() |
|
395 | + && apply_filters('FHEE__EED_Single_Page_Checkout__run', true) |
|
396 | + && $this->_is_reg_checkout() |
|
397 | + ) { |
|
398 | + $this->_initialize(); |
|
399 | + } |
|
400 | + } |
|
401 | + |
|
402 | + |
|
403 | + |
|
404 | + /** |
|
405 | + * determines whether current url matches reg page url |
|
406 | + * |
|
407 | + * @return bool |
|
408 | + */ |
|
409 | + protected function _is_reg_checkout() |
|
410 | + { |
|
411 | + // get current permalink for reg page without any extra query args |
|
412 | + $reg_page_url = \get_permalink(EE_Config::instance()->core->reg_page_id); |
|
413 | + // get request URI for current request, but without the scheme or host |
|
414 | + $current_request_uri = \EEH_URL::filter_input_server_url('REQUEST_URI'); |
|
415 | + $current_request_uri = html_entity_decode($current_request_uri); |
|
416 | + // get array of query args from the current request URI |
|
417 | + $query_args = \EEH_URL::get_query_string($current_request_uri); |
|
418 | + // grab page id if it is set |
|
419 | + $page_id = isset($query_args['page_id']) ? absint($query_args['page_id']) : 0; |
|
420 | + // and remove the page id from the query args (we will re-add it later) |
|
421 | + unset($query_args['page_id']); |
|
422 | + // now strip all query args from current request URI |
|
423 | + $current_request_uri = remove_query_arg(array_keys($query_args), $current_request_uri); |
|
424 | + // and re-add the page id if it was set |
|
425 | + if ($page_id) { |
|
426 | + $current_request_uri = add_query_arg('page_id', $page_id, $current_request_uri); |
|
427 | + } |
|
428 | + // remove slashes and ? |
|
429 | + $current_request_uri = trim($current_request_uri, '?/'); |
|
430 | + // is current request URI part of the known full reg page URL ? |
|
431 | + return ! empty($current_request_uri) && strpos($reg_page_url, $current_request_uri) !== false; |
|
432 | + } |
|
433 | + |
|
434 | + |
|
435 | + |
|
436 | + /** |
|
437 | + * @param WP_Query $wp_query |
|
438 | + * @return void |
|
439 | + * @throws \EE_Error |
|
440 | + */ |
|
441 | + public static function init($wp_query) |
|
442 | + { |
|
443 | + EED_Single_Page_Checkout::instance()->run($wp_query); |
|
444 | + } |
|
445 | + |
|
446 | + |
|
447 | + |
|
448 | + /** |
|
449 | + * _initialize - initial module setup |
|
450 | + * |
|
451 | + * @access private |
|
452 | + * @throws EE_Error |
|
453 | + * @return void |
|
454 | + */ |
|
455 | + private function _initialize() |
|
456 | + { |
|
457 | + // ensure SPCO doesn't run twice |
|
458 | + if (EED_Single_Page_Checkout::$_initialized) { |
|
459 | + return; |
|
460 | + } |
|
461 | + try { |
|
462 | + EED_Single_Page_Checkout::load_reg_steps(); |
|
463 | + $this->_verify_session(); |
|
464 | + // setup the EE_Checkout object |
|
465 | + $this->checkout = $this->_initialize_checkout(); |
|
466 | + // filter checkout |
|
467 | + $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout); |
|
468 | + // get the $_GET |
|
469 | + $this->_get_request_vars(); |
|
470 | + if ($this->_block_bots()) { |
|
471 | + return; |
|
472 | + } |
|
473 | + // filter continue_reg |
|
474 | + $this->checkout->continue_reg = apply_filters('FHEE__EED_Single_Page_Checkout__init___continue_reg', true, $this->checkout); |
|
475 | + // load the reg steps array |
|
476 | + if ( ! $this->_load_and_instantiate_reg_steps()) { |
|
477 | + EED_Single_Page_Checkout::$_initialized = true; |
|
478 | + return; |
|
479 | + } |
|
480 | + // set the current step |
|
481 | + $this->checkout->set_current_step($this->checkout->step); |
|
482 | + // and the next step |
|
483 | + $this->checkout->set_next_step(); |
|
484 | + // verify that everything has been setup correctly |
|
485 | + if ( ! ($this->_verify_transaction_and_get_registrations() && $this->_final_verifications())) { |
|
486 | + EED_Single_Page_Checkout::$_initialized = true; |
|
487 | + return; |
|
488 | + } |
|
489 | + // lock the transaction |
|
490 | + $this->checkout->transaction->lock(); |
|
491 | + // make sure all of our cached objects are added to their respective model entity mappers |
|
492 | + $this->checkout->refresh_all_entities(); |
|
493 | + // set amount owing |
|
494 | + $this->checkout->amount_owing = $this->checkout->transaction->remaining(); |
|
495 | + // initialize each reg step, which gives them the chance to potentially alter the process |
|
496 | + $this->_initialize_reg_steps(); |
|
497 | + // DEBUG LOG |
|
498 | + //$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ ); |
|
499 | + // get reg form |
|
500 | + if( ! $this->_check_form_submission()) { |
|
501 | + EED_Single_Page_Checkout::$_initialized = true; |
|
502 | + return; |
|
503 | + } |
|
504 | + // checkout the action!!! |
|
505 | + $this->_process_form_action(); |
|
506 | + // add some style and make it dance |
|
507 | + $this->add_styles_and_scripts(); |
|
508 | + // kk... SPCO has successfully run |
|
509 | + EED_Single_Page_Checkout::$_initialized = true; |
|
510 | + // set no cache headers and constants |
|
511 | + EE_System::do_not_cache(); |
|
512 | + // add anchor |
|
513 | + add_action('loop_start', array($this, 'set_checkout_anchor'), 1); |
|
514 | + // remove transaction lock |
|
515 | + add_action('shutdown', array($this, 'unlock_transaction'), 1); |
|
516 | + } catch (Exception $e) { |
|
517 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
518 | + } |
|
519 | + } |
|
520 | + |
|
521 | + |
|
522 | + |
|
523 | + /** |
|
524 | + * _verify_session |
|
525 | + * checks that the session is valid and not expired |
|
526 | + * |
|
527 | + * @access private |
|
528 | + * @throws EE_Error |
|
529 | + */ |
|
530 | + private function _verify_session() |
|
531 | + { |
|
532 | + if ( ! EE_Registry::instance()->SSN instanceof EE_Session) { |
|
533 | + throw new EE_Error(__('The EE_Session class could not be loaded.', 'event_espresso')); |
|
534 | + } |
|
535 | + // is session still valid ? |
|
536 | + if (EE_Registry::instance()->SSN->expired() && EE_Registry::instance()->REQ->get('e_reg_url_link', '') === '') { |
|
537 | + $this->checkout = new EE_Checkout(); |
|
538 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
539 | + // EE_Registry::instance()->SSN->reset_cart(); |
|
540 | + // EE_Registry::instance()->SSN->reset_checkout(); |
|
541 | + // EE_Registry::instance()->SSN->reset_transaction(); |
|
542 | + EE_Error::add_attention(EE_Registry::$i18n_js_strings['registration_expiration_notice'], __FILE__, |
|
543 | + __FUNCTION__, __LINE__); |
|
544 | + // EE_Registry::instance()->SSN->reset_expired(); |
|
545 | + } |
|
546 | + } |
|
547 | + |
|
548 | + |
|
549 | + |
|
550 | + /** |
|
551 | + * _initialize_checkout |
|
552 | + * loads and instantiates EE_Checkout |
|
553 | + * |
|
554 | + * @access private |
|
555 | + * @throws EE_Error |
|
556 | + * @return EE_Checkout |
|
557 | + */ |
|
558 | + private function _initialize_checkout() |
|
559 | + { |
|
560 | + // look in session for existing checkout |
|
561 | + /** @type EE_Checkout $checkout */ |
|
562 | + $checkout = EE_Registry::instance()->SSN->checkout(); |
|
563 | + // verify |
|
564 | + if ( ! $checkout instanceof EE_Checkout) { |
|
565 | + // instantiate EE_Checkout object for handling the properties of the current checkout process |
|
566 | + $checkout = EE_Registry::instance()->load_file(SPCO_INC_PATH, 'EE_Checkout', 'class', array(), false); |
|
567 | + } else { |
|
568 | + if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) { |
|
569 | + $this->unlock_transaction(); |
|
570 | + wp_safe_redirect($checkout->redirect_url); |
|
571 | + exit(); |
|
572 | + } |
|
573 | + } |
|
574 | + $checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout); |
|
575 | + // verify again |
|
576 | + if ( ! $checkout instanceof EE_Checkout) { |
|
577 | + throw new EE_Error(__('The EE_Checkout class could not be loaded.', 'event_espresso')); |
|
578 | + } |
|
579 | + // reset anything that needs a clean slate for each request |
|
580 | + $checkout->reset_for_current_request(); |
|
581 | + return $checkout; |
|
582 | + } |
|
583 | + |
|
584 | + |
|
585 | + |
|
586 | + /** |
|
587 | + * _get_request_vars |
|
588 | + * |
|
589 | + * @access private |
|
590 | + * @return void |
|
591 | + * @throws \EE_Error |
|
592 | + */ |
|
593 | + private function _get_request_vars() |
|
594 | + { |
|
595 | + // load classes |
|
596 | + EED_Single_Page_Checkout::load_request_handler(); |
|
597 | + //make sure this request is marked as belonging to EE |
|
598 | + EE_Registry::instance()->REQ->set_espresso_page(true); |
|
599 | + // which step is being requested ? |
|
600 | + $this->checkout->step = EE_Registry::instance()->REQ->get('step', $this->_get_first_step()); |
|
601 | + // which step is being edited ? |
|
602 | + $this->checkout->edit_step = EE_Registry::instance()->REQ->get('edit_step', ''); |
|
603 | + // and what we're doing on the current step |
|
604 | + $this->checkout->action = EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step'); |
|
605 | + // timestamp |
|
606 | + $this->checkout->uts = EE_Registry::instance()->REQ->get('uts', 0); |
|
607 | + // returning to edit ? |
|
608 | + $this->checkout->reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link', ''); |
|
609 | + // or some other kind of revisit ? |
|
610 | + $this->checkout->revisit = filter_var( |
|
611 | + EE_Registry::instance()->REQ->get('revisit', false), |
|
612 | + FILTER_VALIDATE_BOOLEAN |
|
613 | + ); |
|
614 | + // and whether or not to generate a reg form for this request |
|
615 | + $this->checkout->generate_reg_form = filter_var( |
|
616 | + EE_Registry::instance()->REQ->get('generate_reg_form', true), |
|
617 | + FILTER_VALIDATE_BOOLEAN |
|
618 | + ); |
|
619 | + // and whether or not to process a reg form submission for this request |
|
620 | + $this->checkout->process_form_submission = filter_var( |
|
621 | + EE_Registry::instance()->REQ->get( |
|
622 | + 'process_form_submission', |
|
623 | + $this->checkout->action === 'process_reg_step' |
|
624 | + ), |
|
625 | + FILTER_VALIDATE_BOOLEAN |
|
626 | + ); |
|
627 | + $this->checkout->process_form_submission = filter_var( |
|
628 | + $this->checkout->action !== 'display_spco_reg_step' |
|
629 | + ? $this->checkout->process_form_submission |
|
630 | + : false, |
|
631 | + FILTER_VALIDATE_BOOLEAN |
|
632 | + ); |
|
633 | + // $this->_display_request_vars(); |
|
634 | + } |
|
635 | + |
|
636 | + |
|
637 | + |
|
638 | + /** |
|
639 | + * _display_request_vars |
|
640 | + * |
|
641 | + * @access protected |
|
642 | + * @return void |
|
643 | + */ |
|
644 | + protected function _display_request_vars() |
|
645 | + { |
|
646 | + if ( ! WP_DEBUG) { |
|
647 | + return; |
|
648 | + } |
|
649 | + EEH_Debug_Tools::printr($_REQUEST, '$_REQUEST', __FILE__, __LINE__); |
|
650 | + EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__); |
|
651 | + EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__); |
|
652 | + EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__); |
|
653 | + EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__); |
|
654 | + EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__); |
|
655 | + EEH_Debug_Tools::printr($this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__); |
|
656 | + EEH_Debug_Tools::printr($this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__); |
|
657 | + } |
|
658 | + |
|
659 | + |
|
660 | + |
|
661 | + /** |
|
662 | + * _block_bots |
|
663 | + * checks that the incoming request has either of the following set: |
|
664 | + * a uts (unix timestamp) which indicates that the request was redirected from the Ticket Selector |
|
665 | + * a REG URL Link, which indicates that the request is a return visit to SPCO for a valid TXN |
|
666 | + * so if you're not coming from the Ticket Selector nor returning for a valid IP... |
|
667 | + * then where you coming from man? |
|
668 | + * |
|
669 | + * @return boolean |
|
670 | + */ |
|
671 | + private function _block_bots() |
|
672 | + { |
|
673 | + $invalid_checkout_access = \EED_Invalid_Checkout_Access::getInvalidCheckoutAccess(); |
|
674 | + if ($invalid_checkout_access->checkoutAccessIsInvalid($this->checkout)) { |
|
675 | + return true; |
|
676 | + } |
|
677 | + return false; |
|
678 | + } |
|
679 | + |
|
680 | + |
|
681 | + |
|
682 | + /** |
|
683 | + * _get_first_step |
|
684 | + * gets slug for first step in $_reg_steps_array |
|
685 | + * |
|
686 | + * @access private |
|
687 | + * @throws EE_Error |
|
688 | + * @return string |
|
689 | + */ |
|
690 | + private function _get_first_step() |
|
691 | + { |
|
692 | + $first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array); |
|
693 | + return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information'; |
|
694 | + } |
|
695 | + |
|
696 | + |
|
697 | + |
|
698 | + /** |
|
699 | + * _load_and_instantiate_reg_steps |
|
700 | + * instantiates each reg step based on the loaded reg_steps array |
|
701 | + * |
|
702 | + * @access private |
|
703 | + * @throws EE_Error |
|
704 | + * @return bool |
|
705 | + */ |
|
706 | + private function _load_and_instantiate_reg_steps() |
|
707 | + { |
|
708 | + // have reg_steps already been instantiated ? |
|
709 | + if ( |
|
710 | + empty($this->checkout->reg_steps) |
|
711 | + || apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout) |
|
712 | + ) { |
|
713 | + // if not, then loop through raw reg steps array |
|
714 | + foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) { |
|
715 | + if ( ! $this->_load_and_instantiate_reg_step($reg_step, $order)) { |
|
716 | + return false; |
|
717 | + } |
|
718 | + } |
|
719 | + EE_Registry::instance()->CFG->registration->skip_reg_confirmation = true; |
|
720 | + EE_Registry::instance()->CFG->registration->reg_confirmation_last = true; |
|
721 | + // skip the registration_confirmation page ? |
|
722 | + if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) { |
|
723 | + // just remove it from the reg steps array |
|
724 | + $this->checkout->remove_reg_step('registration_confirmation', false); |
|
725 | + } else if ( |
|
726 | + isset($this->checkout->reg_steps['registration_confirmation']) |
|
727 | + && EE_Registry::instance()->CFG->registration->reg_confirmation_last |
|
728 | + ) { |
|
729 | + // set the order to something big like 100 |
|
730 | + $this->checkout->set_reg_step_order('registration_confirmation', 100); |
|
731 | + } |
|
732 | + // filter the array for good luck |
|
733 | + $this->checkout->reg_steps = apply_filters( |
|
734 | + 'FHEE__Single_Page_Checkout__load_reg_steps__reg_steps', |
|
735 | + $this->checkout->reg_steps |
|
736 | + ); |
|
737 | + // finally re-sort based on the reg step class order properties |
|
738 | + $this->checkout->sort_reg_steps(); |
|
739 | + } else { |
|
740 | + foreach ($this->checkout->reg_steps as $reg_step) { |
|
741 | + // set all current step stati to FALSE |
|
742 | + $reg_step->set_is_current_step(false); |
|
743 | + } |
|
744 | + } |
|
745 | + if (empty($this->checkout->reg_steps)) { |
|
746 | + EE_Error::add_error(__('No Reg Steps were loaded..', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
747 | + return false; |
|
748 | + } |
|
749 | + // make reg step details available to JS |
|
750 | + $this->checkout->set_reg_step_JSON_info(); |
|
751 | + return true; |
|
752 | + } |
|
753 | + |
|
754 | + |
|
755 | + |
|
756 | + /** |
|
757 | + * _load_and_instantiate_reg_step |
|
758 | + * |
|
759 | + * @access private |
|
760 | + * @param array $reg_step |
|
761 | + * @param int $order |
|
762 | + * @return bool |
|
763 | + */ |
|
764 | + private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0) |
|
765 | + { |
|
766 | + // we need a file_path, class_name, and slug to add a reg step |
|
767 | + if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
768 | + // if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step) |
|
769 | + if ( |
|
770 | + $this->checkout->reg_url_link |
|
771 | + && $this->checkout->step !== $reg_step['slug'] |
|
772 | + && $reg_step['slug'] !== 'finalize_registration' |
|
773 | + ) { |
|
774 | + return true; |
|
775 | + } |
|
776 | + // instantiate step class using file path and class name |
|
777 | + $reg_step_obj = EE_Registry::instance()->load_file( |
|
778 | + $reg_step['file_path'], |
|
779 | + $reg_step['class_name'], |
|
780 | + 'class', |
|
781 | + $this->checkout, |
|
782 | + false |
|
783 | + ); |
|
784 | + // did we gets the goods ? |
|
785 | + if ($reg_step_obj instanceof EE_SPCO_Reg_Step) { |
|
786 | + // set reg step order based on config |
|
787 | + $reg_step_obj->set_order($order); |
|
788 | + // add instantiated reg step object to the master reg steps array |
|
789 | + $this->checkout->add_reg_step($reg_step_obj); |
|
790 | + } else { |
|
791 | + EE_Error::add_error( |
|
792 | + __('The current step could not be set.', 'event_espresso'), |
|
793 | + __FILE__, __FUNCTION__, __LINE__ |
|
794 | + ); |
|
795 | + return false; |
|
796 | + } |
|
797 | + } else { |
|
798 | + if (WP_DEBUG) { |
|
799 | + EE_Error::add_error( |
|
800 | + sprintf( |
|
801 | + __('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'), |
|
802 | + isset($reg_step['file_path']) ? $reg_step['file_path'] : '', |
|
803 | + isset($reg_step['class_name']) ? $reg_step['class_name'] : '', |
|
804 | + isset($reg_step['slug']) ? $reg_step['slug'] : '', |
|
805 | + '<ul>', |
|
806 | + '<li>', |
|
807 | + '</li>', |
|
808 | + '</ul>' |
|
809 | + ), |
|
810 | + __FILE__, __FUNCTION__, __LINE__ |
|
811 | + ); |
|
812 | + } |
|
813 | + return false; |
|
814 | + } |
|
815 | + return true; |
|
816 | + } |
|
817 | + |
|
818 | + |
|
819 | + |
|
820 | + /** |
|
821 | + * _verify_transaction_and_get_registrations |
|
822 | + * |
|
823 | + * @access private |
|
824 | + * @return bool |
|
825 | + */ |
|
826 | + private function _verify_transaction_and_get_registrations() |
|
827 | + { |
|
828 | + // was there already a valid transaction in the checkout from the session ? |
|
829 | + if ( ! $this->checkout->transaction instanceof EE_Transaction) { |
|
830 | + // get transaction from db or session |
|
831 | + $this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin() |
|
832 | + ? $this->_get_transaction_and_cart_for_previous_visit() |
|
833 | + : $this->_get_cart_for_current_session_and_setup_new_transaction(); |
|
834 | + if ( ! $this->checkout->transaction instanceof EE_Transaction) { |
|
835 | + EE_Error::add_error( |
|
836 | + __('Your Registration and Transaction information could not be retrieved from the db.', |
|
837 | + 'event_espresso'), |
|
838 | + __FILE__, __FUNCTION__, __LINE__ |
|
839 | + ); |
|
840 | + $this->checkout->transaction = EE_Transaction::new_instance(); |
|
841 | + // add some style and make it dance |
|
842 | + $this->add_styles_and_scripts(); |
|
843 | + EED_Single_Page_Checkout::$_initialized = true; |
|
844 | + return false; |
|
845 | + } |
|
846 | + // and the registrations for the transaction |
|
847 | + $this->_get_registrations($this->checkout->transaction); |
|
848 | + } |
|
849 | + return true; |
|
850 | + } |
|
851 | + |
|
852 | + |
|
853 | + |
|
854 | + /** |
|
855 | + * _get_transaction_and_cart_for_previous_visit |
|
856 | + * |
|
857 | + * @access private |
|
858 | + * @return mixed EE_Transaction|NULL |
|
859 | + */ |
|
860 | + private function _get_transaction_and_cart_for_previous_visit() |
|
861 | + { |
|
862 | + /** @var $TXN_model EEM_Transaction */ |
|
863 | + $TXN_model = EE_Registry::instance()->load_model('Transaction'); |
|
864 | + // 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 |
|
865 | + $transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link); |
|
866 | + // verify transaction |
|
867 | + if ($transaction instanceof EE_Transaction) { |
|
868 | + // and get the cart that was used for that transaction |
|
869 | + $this->checkout->cart = $this->_get_cart_for_transaction($transaction); |
|
870 | + return $transaction; |
|
871 | + } else { |
|
872 | + EE_Error::add_error(__('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
873 | + return null; |
|
874 | + } |
|
875 | + } |
|
876 | + |
|
877 | + |
|
878 | + |
|
879 | + /** |
|
880 | + * _get_cart_for_transaction |
|
881 | + * |
|
882 | + * @access private |
|
883 | + * @param EE_Transaction $transaction |
|
884 | + * @return EE_Cart |
|
885 | + */ |
|
886 | + private function _get_cart_for_transaction($transaction) |
|
887 | + { |
|
888 | + return $this->checkout->get_cart_for_transaction($transaction); |
|
889 | + } |
|
890 | + |
|
891 | + |
|
892 | + |
|
893 | + /** |
|
894 | + * get_cart_for_transaction |
|
895 | + * |
|
896 | + * @access public |
|
897 | + * @param EE_Transaction $transaction |
|
898 | + * @return EE_Cart |
|
899 | + */ |
|
900 | + public function get_cart_for_transaction(EE_Transaction $transaction) |
|
901 | + { |
|
902 | + return $this->checkout->get_cart_for_transaction($transaction); |
|
903 | + } |
|
904 | + |
|
905 | + |
|
906 | + |
|
907 | + /** |
|
908 | + * _get_transaction_and_cart_for_current_session |
|
909 | + * generates a new EE_Transaction object and adds it to the $_transaction property. |
|
910 | + * |
|
911 | + * @access private |
|
912 | + * @return EE_Transaction |
|
913 | + * @throws \EE_Error |
|
914 | + */ |
|
915 | + private function _get_cart_for_current_session_and_setup_new_transaction() |
|
916 | + { |
|
917 | + // if there's no transaction, then this is the FIRST visit to SPCO |
|
918 | + // so load up the cart ( passing nothing for the TXN because it doesn't exist yet ) |
|
919 | + $this->checkout->cart = $this->_get_cart_for_transaction(null); |
|
920 | + // and then create a new transaction |
|
921 | + $transaction = $this->_initialize_transaction(); |
|
922 | + // verify transaction |
|
923 | + if ($transaction instanceof EE_Transaction) { |
|
924 | + // save it so that we have an ID for other objects to use |
|
925 | + $transaction->save(); |
|
926 | + // and save TXN data to the cart |
|
927 | + $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID()); |
|
928 | + } else { |
|
929 | + EE_Error::add_error(__('A Valid Transaction could not be initialized.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
930 | + } |
|
931 | + return $transaction; |
|
932 | + } |
|
933 | + |
|
934 | + |
|
935 | + |
|
936 | + /** |
|
937 | + * generates a new EE_Transaction object and adds it to the $_transaction property. |
|
938 | + * |
|
939 | + * @access private |
|
940 | + * @return mixed EE_Transaction|NULL |
|
941 | + */ |
|
942 | + private function _initialize_transaction() |
|
943 | + { |
|
944 | + try { |
|
945 | + // ensure cart totals have been calculated |
|
946 | + $this->checkout->cart->get_grand_total()->recalculate_total_including_taxes(); |
|
947 | + // grab the cart grand total |
|
948 | + $cart_total = $this->checkout->cart->get_cart_grand_total(); |
|
949 | + // create new TXN |
|
950 | + $transaction = EE_Transaction::new_instance( |
|
951 | + array( |
|
952 | + 'TXN_reg_steps' => $this->checkout->initialize_txn_reg_steps_array(), |
|
953 | + 'TXN_total' => $cart_total > 0 ? $cart_total : 0, |
|
954 | + 'TXN_paid' => 0, |
|
955 | + 'STS_ID' => EEM_Transaction::failed_status_code, |
|
956 | + ) |
|
957 | + ); |
|
958 | + // save it so that we have an ID for other objects to use |
|
959 | + $transaction->save(); |
|
960 | + // set cron job for following up on TXNs after their session has expired |
|
961 | + EE_Cron_Tasks::schedule_expired_transaction_check( |
|
962 | + EE_Registry::instance()->SSN->expiration() + 1, |
|
963 | + $transaction->ID() |
|
964 | + ); |
|
965 | + return $transaction; |
|
966 | + } catch (Exception $e) { |
|
967 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
968 | + } |
|
969 | + return null; |
|
970 | + } |
|
971 | + |
|
972 | + |
|
973 | + |
|
974 | + /** |
|
975 | + * _get_registrations |
|
976 | + * |
|
977 | + * @access private |
|
978 | + * @param EE_Transaction $transaction |
|
979 | + * @return void |
|
980 | + * @throws \EventEspresso\core\exceptions\InvalidEntityException |
|
981 | + * @throws \EE_Error |
|
982 | + */ |
|
983 | + private function _get_registrations(EE_Transaction $transaction) |
|
984 | + { |
|
985 | + // first step: grab the registrants { : o |
|
986 | + $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, true); |
|
987 | + // verify registrations have been set |
|
988 | + if (empty($registrations)) { |
|
989 | + // if no cached registrations, then check the db |
|
990 | + $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false); |
|
991 | + // still nothing ? well as long as this isn't a revisit |
|
992 | + if (empty($registrations) && ! $this->checkout->revisit) { |
|
993 | + // generate new registrations from scratch |
|
994 | + $registrations = $this->_initialize_registrations($transaction); |
|
995 | + } |
|
996 | + } |
|
997 | + // sort by their original registration order |
|
998 | + usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count')); |
|
999 | + // then loop thru the array |
|
1000 | + foreach ($registrations as $registration) { |
|
1001 | + // verify each registration |
|
1002 | + if ($registration instanceof EE_Registration) { |
|
1003 | + // we display all attendee info for the primary registrant |
|
1004 | + if ($this->checkout->reg_url_link === $registration->reg_url_link() |
|
1005 | + && $registration->is_primary_registrant() |
|
1006 | + ) { |
|
1007 | + $this->checkout->primary_revisit = true; |
|
1008 | + break; |
|
1009 | + } else if ($this->checkout->revisit |
|
1010 | + && $this->checkout->reg_url_link !== $registration->reg_url_link() |
|
1011 | + ) { |
|
1012 | + // but hide info if it doesn't belong to you |
|
1013 | + $transaction->clear_cache('Registration', $registration->ID()); |
|
1014 | + } |
|
1015 | + $this->checkout->set_reg_status_updated($registration->ID(), false); |
|
1016 | + } |
|
1017 | + } |
|
1018 | + } |
|
1019 | + |
|
1020 | + |
|
1021 | + |
|
1022 | + /** |
|
1023 | + * adds related EE_Registration objects for each ticket in the cart to the current EE_Transaction object |
|
1024 | + * |
|
1025 | + * @access private |
|
1026 | + * @param EE_Transaction $transaction |
|
1027 | + * @return array |
|
1028 | + * @throws \EventEspresso\core\exceptions\InvalidEntityException |
|
1029 | + * @throws \EE_Error |
|
1030 | + */ |
|
1031 | + private function _initialize_registrations(EE_Transaction $transaction) |
|
1032 | + { |
|
1033 | + $att_nmbr = 0; |
|
1034 | + $registrations = array(); |
|
1035 | + if ($transaction instanceof EE_Transaction) { |
|
1036 | + /** @type EE_Registration_Processor $registration_processor */ |
|
1037 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
1038 | + $this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count(); |
|
1039 | + // now let's add the cart items to the $transaction |
|
1040 | + foreach ($this->checkout->cart->get_tickets() as $line_item) { |
|
1041 | + //do the following for each ticket of this type they selected |
|
1042 | + for ($x = 1; $x <= $line_item->quantity(); $x++) { |
|
1043 | + $att_nmbr++; |
|
1044 | + /** @var EventEspresso\core\services\commands\registration\CreateRegistrationCommand $CreateRegistrationCommand */ |
|
1045 | + $CreateRegistrationCommand = EE_Registry::instance() |
|
1046 | + ->create( |
|
1047 | + 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
1048 | + array( |
|
1049 | + $transaction, |
|
1050 | + $line_item, |
|
1051 | + $att_nmbr, |
|
1052 | + $this->checkout->total_ticket_count, |
|
1053 | + ) |
|
1054 | + ); |
|
1055 | + // override capabilities for frontend registrations |
|
1056 | + if ( ! is_admin()) { |
|
1057 | + $CreateRegistrationCommand->setCapCheck( |
|
1058 | + new PublicCapabilities('', 'create_new_registration') |
|
1059 | + ); |
|
1060 | + } |
|
1061 | + $registration = EE_Registry::instance()->BUS->execute($CreateRegistrationCommand); |
|
1062 | + if ( ! $registration instanceof EE_Registration) { |
|
1063 | + throw new InvalidEntityException($registration, 'EE_Registration'); |
|
1064 | + } |
|
1065 | + $registrations[ $registration->ID() ] = $registration; |
|
1066 | + } |
|
1067 | + } |
|
1068 | + $registration_processor->fix_reg_final_price_rounding_issue($transaction); |
|
1069 | + } |
|
1070 | + return $registrations; |
|
1071 | + } |
|
1072 | + |
|
1073 | + |
|
1074 | + |
|
1075 | + /** |
|
1076 | + * sorts registrations by REG_count |
|
1077 | + * |
|
1078 | + * @access public |
|
1079 | + * @param EE_Registration $reg_A |
|
1080 | + * @param EE_Registration $reg_B |
|
1081 | + * @return int |
|
1082 | + */ |
|
1083 | + public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B) |
|
1084 | + { |
|
1085 | + // this shouldn't ever happen within the same TXN, but oh well |
|
1086 | + if ($reg_A->count() === $reg_B->count()) { |
|
1087 | + return 0; |
|
1088 | + } |
|
1089 | + return ($reg_A->count() > $reg_B->count()) ? 1 : -1; |
|
1090 | + } |
|
1091 | + |
|
1092 | + |
|
1093 | + |
|
1094 | + /** |
|
1095 | + * _final_verifications |
|
1096 | + * just makes sure that everything is set up correctly before proceeding |
|
1097 | + * |
|
1098 | + * @access private |
|
1099 | + * @return bool |
|
1100 | + * @throws \EE_Error |
|
1101 | + */ |
|
1102 | + private function _final_verifications() |
|
1103 | + { |
|
1104 | + // filter checkout |
|
1105 | + $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___final_verifications__checkout', $this->checkout); |
|
1106 | + //verify that current step is still set correctly |
|
1107 | + if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) { |
|
1108 | + EE_Error::add_error( |
|
1109 | + __('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'), |
|
1110 | + __FILE__, |
|
1111 | + __FUNCTION__, |
|
1112 | + __LINE__ |
|
1113 | + ); |
|
1114 | + return false; |
|
1115 | + } |
|
1116 | + // if returning to SPCO, then verify that primary registrant is set |
|
1117 | + if ( ! empty($this->checkout->reg_url_link)) { |
|
1118 | + $valid_registrant = $this->checkout->transaction->primary_registration(); |
|
1119 | + if ( ! $valid_registrant instanceof EE_Registration) { |
|
1120 | + EE_Error::add_error( |
|
1121 | + __('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'), |
|
1122 | + __FILE__, |
|
1123 | + __FUNCTION__, |
|
1124 | + __LINE__ |
|
1125 | + ); |
|
1126 | + return false; |
|
1127 | + } |
|
1128 | + $valid_registrant = null; |
|
1129 | + foreach ($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration) { |
|
1130 | + if ( |
|
1131 | + $registration instanceof EE_Registration |
|
1132 | + && $registration->reg_url_link() === $this->checkout->reg_url_link |
|
1133 | + ) { |
|
1134 | + $valid_registrant = $registration; |
|
1135 | + } |
|
1136 | + } |
|
1137 | + if ( ! $valid_registrant instanceof EE_Registration) { |
|
1138 | + // hmmm... maybe we have the wrong session because the user is opening multiple tabs ? |
|
1139 | + if (EED_Single_Page_Checkout::$_checkout_verified) { |
|
1140 | + // clear the session, mark the checkout as unverified, and try again |
|
1141 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
1142 | + EED_Single_Page_Checkout::$_initialized = false; |
|
1143 | + EED_Single_Page_Checkout::$_checkout_verified = false; |
|
1144 | + $this->_initialize(); |
|
1145 | + EE_Error::reset_notices(); |
|
1146 | + return false; |
|
1147 | + } |
|
1148 | + EE_Error::add_error( |
|
1149 | + __('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'), |
|
1150 | + __FILE__, |
|
1151 | + __FUNCTION__, |
|
1152 | + __LINE__ |
|
1153 | + ); |
|
1154 | + return false; |
|
1155 | + } |
|
1156 | + } |
|
1157 | + // now that things have been kinda sufficiently verified, |
|
1158 | + // let's add the checkout to the session so that it's available to other systems |
|
1159 | + EE_Registry::instance()->SSN->set_checkout($this->checkout); |
|
1160 | + return true; |
|
1161 | + } |
|
1162 | + |
|
1163 | + |
|
1164 | + |
|
1165 | + /** |
|
1166 | + * _initialize_reg_steps |
|
1167 | + * first makes sure that EE_Transaction_Processor::set_reg_step_initiated() is called as required |
|
1168 | + * then loops thru all of the active reg steps and calls the initialize_reg_step() method |
|
1169 | + * |
|
1170 | + * @access private |
|
1171 | + * @param bool $reinitializing |
|
1172 | + * @throws \EE_Error |
|
1173 | + */ |
|
1174 | + private function _initialize_reg_steps($reinitializing = false) |
|
1175 | + { |
|
1176 | + $this->checkout->set_reg_step_initiated($this->checkout->current_step); |
|
1177 | + // loop thru all steps to call their individual "initialize" methods and set i18n strings for JS |
|
1178 | + foreach ($this->checkout->reg_steps as $reg_step) { |
|
1179 | + if ( ! $reg_step->initialize_reg_step()) { |
|
1180 | + // if not initialized then maybe this step is being removed... |
|
1181 | + if ( ! $reinitializing && $reg_step->is_current_step()) { |
|
1182 | + // if it was the current step, then we need to start over here |
|
1183 | + $this->_initialize_reg_steps(true); |
|
1184 | + return; |
|
1185 | + } |
|
1186 | + continue; |
|
1187 | + } |
|
1188 | + // add css and JS for current step |
|
1189 | + $reg_step->enqueue_styles_and_scripts(); |
|
1190 | + // i18n |
|
1191 | + $reg_step->translate_js_strings(); |
|
1192 | + if ($reg_step->is_current_step()) { |
|
1193 | + // the text that appears on the reg step form submit button |
|
1194 | + $reg_step->set_submit_button_text(); |
|
1195 | + } |
|
1196 | + } |
|
1197 | + // dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information |
|
1198 | + do_action("AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", $this->checkout->current_step); |
|
1199 | + } |
|
1200 | + |
|
1201 | + |
|
1202 | + |
|
1203 | + /** |
|
1204 | + * _check_form_submission |
|
1205 | + * |
|
1206 | + * @access private |
|
1207 | + * @return boolean |
|
1208 | + */ |
|
1209 | + private function _check_form_submission() |
|
1210 | + { |
|
1211 | + //does this request require the reg form to be generated ? |
|
1212 | + if ($this->checkout->generate_reg_form) { |
|
1213 | + // ever heard that song by Blue Rodeo ? |
|
1214 | + try { |
|
1215 | + $this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form(); |
|
1216 | + // if not displaying a form, then check for form submission |
|
1217 | + if ( |
|
1218 | + $this->checkout->process_form_submission |
|
1219 | + && $this->checkout->current_step->reg_form->was_submitted() |
|
1220 | + ) { |
|
1221 | + // clear out any old data in case this step is being run again |
|
1222 | + $this->checkout->current_step->set_valid_data(array()); |
|
1223 | + // capture submitted form data |
|
1224 | + $this->checkout->current_step->reg_form->receive_form_submission( |
|
1225 | + apply_filters( |
|
1226 | + 'FHEE__Single_Page_Checkout___check_form_submission__request_params', |
|
1227 | + EE_Registry::instance()->REQ->params(), |
|
1228 | + $this->checkout |
|
1229 | + ) |
|
1230 | + ); |
|
1231 | + // validate submitted form data |
|
1232 | + if ( ! $this->checkout->continue_reg || ! $this->checkout->current_step->reg_form->is_valid()) { |
|
1233 | + // thou shall not pass !!! |
|
1234 | + $this->checkout->continue_reg = false; |
|
1235 | + // any form validation errors? |
|
1236 | + if ($this->checkout->current_step->reg_form->submission_error_message() !== '') { |
|
1237 | + $submission_error_messages = array(); |
|
1238 | + // bad, bad, bad registrant |
|
1239 | + foreach ($this->checkout->current_step->reg_form->get_validation_errors_accumulated() as $validation_error) { |
|
1240 | + if ($validation_error instanceof EE_Validation_Error) { |
|
1241 | + $submission_error_messages[] = sprintf( |
|
1242 | + __('%s : %s', 'event_espresso'), |
|
1243 | + $validation_error->get_form_section()->html_label_text(), |
|
1244 | + $validation_error->getMessage() |
|
1245 | + ); |
|
1246 | + } |
|
1247 | + } |
|
1248 | + EE_Error::add_error(implode('<br />', $submission_error_messages), __FILE__, __FUNCTION__, __LINE__); |
|
1249 | + } |
|
1250 | + // well not really... what will happen is we'll just get redirected back to redo the current step |
|
1251 | + $this->go_to_next_step(); |
|
1252 | + return false; |
|
1253 | + } |
|
1254 | + } |
|
1255 | + } catch (EE_Error $e) { |
|
1256 | + $e->get_error(); |
|
1257 | + } |
|
1258 | + } |
|
1259 | + return true; |
|
1260 | + } |
|
1261 | + |
|
1262 | + |
|
1263 | + |
|
1264 | + /** |
|
1265 | + * _process_action |
|
1266 | + * |
|
1267 | + * @access private |
|
1268 | + * @return void |
|
1269 | + * @throws \EE_Error |
|
1270 | + */ |
|
1271 | + private function _process_form_action() |
|
1272 | + { |
|
1273 | + // what cha wanna do? |
|
1274 | + switch ($this->checkout->action) { |
|
1275 | + // AJAX next step reg form |
|
1276 | + case 'display_spco_reg_step' : |
|
1277 | + $this->checkout->redirect = false; |
|
1278 | + if (EE_Registry::instance()->REQ->ajax) { |
|
1279 | + $this->checkout->json_response->set_reg_step_html($this->checkout->current_step->display_reg_form()); |
|
1280 | + } |
|
1281 | + break; |
|
1282 | + default : |
|
1283 | + // meh... do one of those other steps first |
|
1284 | + if ( ! empty($this->checkout->action) && is_callable(array($this->checkout->current_step, $this->checkout->action))) { |
|
1285 | + // dynamically creates hook point like: AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step |
|
1286 | + do_action("AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step); |
|
1287 | + // call action on current step |
|
1288 | + if (call_user_func(array($this->checkout->current_step, $this->checkout->action))) { |
|
1289 | + // good registrant, you get to proceed |
|
1290 | + if ( |
|
1291 | + $this->checkout->current_step->success_message() !== '' |
|
1292 | + && apply_filters( |
|
1293 | + 'FHEE__Single_Page_Checkout___process_form_action__display_success', |
|
1294 | + false |
|
1295 | + ) |
|
1296 | + ) { |
|
1297 | + EE_Error::add_success( |
|
1298 | + $this->checkout->current_step->success_message() |
|
1299 | + . '<br />' . $this->checkout->next_step->_instructions() |
|
1300 | + ); |
|
1301 | + } |
|
1302 | + // pack it up, pack it in... |
|
1303 | + $this->_setup_redirect(); |
|
1304 | + } |
|
1305 | + // dynamically creates hook point like: AHEE__Single_Page_Checkout__after_payment_options__process_reg_step |
|
1306 | + do_action("AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step); |
|
1307 | + } else { |
|
1308 | + EE_Error::add_error( |
|
1309 | + sprintf( |
|
1310 | + __('The requested form action "%s" does not exist for the current "%s" registration step.', 'event_espresso'), |
|
1311 | + $this->checkout->action, |
|
1312 | + $this->checkout->current_step->name() |
|
1313 | + ), |
|
1314 | + __FILE__, |
|
1315 | + __FUNCTION__, |
|
1316 | + __LINE__ |
|
1317 | + ); |
|
1318 | + } |
|
1319 | + // end default |
|
1320 | + } |
|
1321 | + // store our progress so far |
|
1322 | + $this->checkout->stash_transaction_and_checkout(); |
|
1323 | + // advance to the next step! If you pass GO, collect $200 |
|
1324 | + $this->go_to_next_step(); |
|
1325 | + } |
|
1326 | + |
|
1327 | + |
|
1328 | + |
|
1329 | + /** |
|
1330 | + * add_styles_and_scripts |
|
1331 | + * |
|
1332 | + * @access public |
|
1333 | + * @return void |
|
1334 | + */ |
|
1335 | + public function add_styles_and_scripts() |
|
1336 | + { |
|
1337 | + // i18n |
|
1338 | + $this->translate_js_strings(); |
|
1339 | + if ($this->checkout->admin_request) { |
|
1340 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
1341 | + } else { |
|
1342 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
1343 | + } |
|
1344 | + } |
|
1345 | + |
|
1346 | + |
|
1347 | + |
|
1348 | + /** |
|
1349 | + * translate_js_strings |
|
1350 | + * |
|
1351 | + * @access public |
|
1352 | + * @return void |
|
1353 | + */ |
|
1354 | + public function translate_js_strings() |
|
1355 | + { |
|
1356 | + EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit; |
|
1357 | + EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link; |
|
1358 | + 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'); |
|
1359 | + 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'); |
|
1360 | + 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'); |
|
1361 | + 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'); |
|
1362 | + EE_Registry::$i18n_js_strings['reg_step_error'] = __('This registration step could not be completed. Please refresh the page and try again.', 'event_espresso'); |
|
1363 | + 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'); |
|
1364 | + EE_Registry::$i18n_js_strings['process_registration'] = sprintf( |
|
1365 | + __('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'), |
|
1366 | + '<br/>', |
|
1367 | + '<br/>' |
|
1368 | + ); |
|
1369 | + EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language'); |
|
1370 | + EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id(); |
|
1371 | + EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency; |
|
1372 | + EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20'; |
|
1373 | + EE_Registry::$i18n_js_strings['timer_years'] = __('years', 'event_espresso'); |
|
1374 | + EE_Registry::$i18n_js_strings['timer_months'] = __('months', 'event_espresso'); |
|
1375 | + EE_Registry::$i18n_js_strings['timer_weeks'] = __('weeks', 'event_espresso'); |
|
1376 | + EE_Registry::$i18n_js_strings['timer_days'] = __('days', 'event_espresso'); |
|
1377 | + EE_Registry::$i18n_js_strings['timer_hours'] = __('hours', 'event_espresso'); |
|
1378 | + EE_Registry::$i18n_js_strings['timer_minutes'] = __('minutes', 'event_espresso'); |
|
1379 | + EE_Registry::$i18n_js_strings['timer_seconds'] = __('seconds', 'event_espresso'); |
|
1380 | + EE_Registry::$i18n_js_strings['timer_year'] = __('year', 'event_espresso'); |
|
1381 | + EE_Registry::$i18n_js_strings['timer_month'] = __('month', 'event_espresso'); |
|
1382 | + EE_Registry::$i18n_js_strings['timer_week'] = __('week', 'event_espresso'); |
|
1383 | + EE_Registry::$i18n_js_strings['timer_day'] = __('day', 'event_espresso'); |
|
1384 | + EE_Registry::$i18n_js_strings['timer_hour'] = __('hour', 'event_espresso'); |
|
1385 | + EE_Registry::$i18n_js_strings['timer_minute'] = __('minute', 'event_espresso'); |
|
1386 | + EE_Registry::$i18n_js_strings['timer_second'] = __('second', 'event_espresso'); |
|
1387 | + EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf( |
|
1388 | + __( |
|
1389 | + '%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', |
|
1390 | + 'event_espresso' |
|
1391 | + ), |
|
1392 | + '<h4 class="important-notice">', |
|
1393 | + '</h4>', |
|
1394 | + '<br />', |
|
1395 | + '<p>', |
|
1396 | + '<a href="' . get_post_type_archive_link('espresso_events') . '" title="', |
|
1397 | + '">', |
|
1398 | + '</a>', |
|
1399 | + '</p>' |
|
1400 | + ); |
|
1401 | + EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters('FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', true); |
|
1402 | + EE_Registry::$i18n_js_strings['session_extension'] = absint( |
|
1403 | + apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', 10 * MINUTE_IN_SECONDS) |
|
1404 | + ); |
|
1405 | + EE_Registry::$i18n_js_strings['session_expiration'] = gmdate( |
|
1406 | + 'M d, Y H:i:s', EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS) |
|
1407 | + ); |
|
1408 | + } |
|
1409 | + |
|
1410 | + |
|
1411 | + |
|
1412 | + /** |
|
1413 | + * enqueue_styles_and_scripts |
|
1414 | + * |
|
1415 | + * @access public |
|
1416 | + * @return void |
|
1417 | + * @throws \EE_Error |
|
1418 | + */ |
|
1419 | + public function enqueue_styles_and_scripts() |
|
1420 | + { |
|
1421 | + // load css |
|
1422 | + wp_register_style('single_page_checkout', SPCO_CSS_URL . 'single_page_checkout.css', array(), EVENT_ESPRESSO_VERSION); |
|
1423 | + wp_enqueue_style('single_page_checkout'); |
|
1424 | + // load JS |
|
1425 | + wp_register_script('jquery_plugin', EE_THIRD_PARTY_URL . 'jquery .plugin.min.js', array('jquery'), '1.0.1', true); |
|
1426 | + wp_register_script('jquery_countdown', EE_THIRD_PARTY_URL . 'jquery .countdown.min.js', array('jquery_plugin'), '2.0.2', true); |
|
1427 | + 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); |
|
1428 | + if ($this->checkout->registration_form instanceof EE_Form_Section_Proper) { |
|
1429 | + $this->checkout->registration_form->enqueue_js(); |
|
1430 | + } |
|
1431 | + if ($this->checkout->current_step->reg_form instanceof EE_Form_Section_Proper) { |
|
1432 | + $this->checkout->current_step->reg_form->enqueue_js(); |
|
1433 | + } |
|
1434 | + wp_enqueue_script('single_page_checkout'); |
|
1435 | + /** |
|
1436 | + * global action hook for enqueueing styles and scripts with |
|
1437 | + * spco calls. |
|
1438 | + */ |
|
1439 | + do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this); |
|
1440 | + /** |
|
1441 | + * dynamic action hook for enqueueing styles and scripts with spco calls. |
|
1442 | + * The hook will end up being something like AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information |
|
1443 | + */ |
|
1444 | + do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(), $this); |
|
1445 | + } |
|
1446 | + |
|
1447 | + |
|
1448 | + |
|
1449 | + /** |
|
1450 | + * display the Registration Single Page Checkout Form |
|
1451 | + * |
|
1452 | + * @access private |
|
1453 | + * @return void |
|
1454 | + * @throws \EE_Error |
|
1455 | + */ |
|
1456 | + private function _display_spco_reg_form() |
|
1457 | + { |
|
1458 | + // if registering via the admin, just display the reg form for the current step |
|
1459 | + if ($this->checkout->admin_request) { |
|
1460 | + EE_Registry::instance()->REQ->add_output($this->checkout->current_step->display_reg_form()); |
|
1461 | + } else { |
|
1462 | + // add powered by EE msg |
|
1463 | + add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer')); |
|
1464 | + $empty_cart = count($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params)) < 1 |
|
1465 | + ? true |
|
1466 | + : false; |
|
1467 | + EE_Registry::$i18n_js_strings['empty_cart'] = $empty_cart; |
|
1468 | + $cookies_not_set_msg = ''; |
|
1469 | + if ($empty_cart && ! isset($_COOKIE['ee_cookie_test'])) { |
|
1470 | + $cookies_not_set_msg = apply_filters( |
|
1471 | + 'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg', |
|
1472 | + sprintf( |
|
1473 | + __( |
|
1474 | + '%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', |
|
1475 | + 'event_espresso' |
|
1476 | + ), |
|
1477 | + '<div class="ee-attention">', |
|
1478 | + '</div>', |
|
1479 | + '<h6 class="important-notice">', |
|
1480 | + '</h6>', |
|
1481 | + '<p>', |
|
1482 | + '</p>', |
|
1483 | + '<br />', |
|
1484 | + '<a href="http://www.whatarecookies.com/enable.asp" target="_blank">', |
|
1485 | + '</a>' |
|
1486 | + ) |
|
1487 | + ); |
|
1488 | + } |
|
1489 | + $this->checkout->registration_form = new EE_Form_Section_Proper( |
|
1490 | + array( |
|
1491 | + 'name' => 'single-page-checkout', |
|
1492 | + 'html_id' => 'ee-single-page-checkout-dv', |
|
1493 | + 'layout_strategy' => |
|
1494 | + new EE_Template_Layout( |
|
1495 | + array( |
|
1496 | + 'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php', |
|
1497 | + 'template_args' => array( |
|
1498 | + 'empty_cart' => $empty_cart, |
|
1499 | + 'revisit' => $this->checkout->revisit, |
|
1500 | + 'reg_steps' => $this->checkout->reg_steps, |
|
1501 | + 'next_step' => $this->checkout->next_step instanceof EE_SPCO_Reg_Step |
|
1502 | + ? $this->checkout->next_step->slug() |
|
1503 | + : '', |
|
1504 | + 'cancel_page_url' => $this->checkout->cancel_page_url, |
|
1505 | + 'empty_msg' => apply_filters( |
|
1506 | + 'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg', |
|
1507 | + sprintf( |
|
1508 | + __('You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.', |
|
1509 | + 'event_espresso'), |
|
1510 | + '<a href="' . get_post_type_archive_link('espresso_events') . '" title="', |
|
1511 | + '">', |
|
1512 | + '</a>' |
|
1513 | + ) |
|
1514 | + ), |
|
1515 | + 'cookies_not_set_msg' => $cookies_not_set_msg, |
|
1516 | + 'registration_time_limit' => $this->checkout->get_registration_time_limit(), |
|
1517 | + 'session_expiration' => gmdate( |
|
1518 | + 'M d, Y H:i:s', |
|
1519 | + EE_Registry::instance()->SSN->expiration() |
|
1520 | + + (get_option('gmt_offset') * HOUR_IN_SECONDS) |
|
1521 | + ), |
|
1522 | + ), |
|
1523 | + ) |
|
1524 | + ), |
|
1525 | + ) |
|
1526 | + ); |
|
1527 | + // load template and add to output sent that gets filtered into the_content() |
|
1528 | + EE_Registry::instance()->REQ->add_output($this->checkout->registration_form->get_html()); |
|
1529 | + } |
|
1530 | + } |
|
1531 | + |
|
1532 | + |
|
1533 | + |
|
1534 | + /** |
|
1535 | + * add_extra_finalize_registration_inputs |
|
1536 | + * |
|
1537 | + * @access public |
|
1538 | + * @param $next_step |
|
1539 | + * @internal param string $label |
|
1540 | + * @return void |
|
1541 | + */ |
|
1542 | + public function add_extra_finalize_registration_inputs($next_step) |
|
1543 | + { |
|
1544 | + if ($next_step === 'finalize_registration') { |
|
1545 | + echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>'; |
|
1546 | + } |
|
1547 | + } |
|
1548 | + |
|
1549 | + |
|
1550 | + |
|
1551 | + /** |
|
1552 | + * display_registration_footer |
|
1553 | + * |
|
1554 | + * @access public |
|
1555 | + * @return string |
|
1556 | + */ |
|
1557 | + public static function display_registration_footer() |
|
1558 | + { |
|
1559 | + if ( |
|
1560 | + apply_filters( |
|
1561 | + 'FHEE__EE_Front__Controller__show_reg_footer', |
|
1562 | + EE_Registry::instance()->CFG->admin->show_reg_footer |
|
1563 | + ) |
|
1564 | + ) { |
|
1565 | + add_filter( |
|
1566 | + 'FHEE__EEH_Template__powered_by_event_espresso__url', |
|
1567 | + function ($url) { |
|
1568 | + return apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url); |
|
1569 | + } |
|
1570 | + ); |
|
1571 | + echo apply_filters( |
|
1572 | + 'FHEE__EE_Front_Controller__display_registration_footer', |
|
1573 | + \EEH_Template::powered_by_event_espresso( |
|
1574 | + '', |
|
1575 | + 'espresso-registration-footer-dv', |
|
1576 | + array('utm_content' => 'registration_checkout') |
|
1577 | + ) |
|
1578 | + ); |
|
1579 | + } |
|
1580 | + return ''; |
|
1581 | + } |
|
1582 | + |
|
1583 | + |
|
1584 | + |
|
1585 | + /** |
|
1586 | + * unlock_transaction |
|
1587 | + * |
|
1588 | + * @access public |
|
1589 | + * @return void |
|
1590 | + * @throws \EE_Error |
|
1591 | + */ |
|
1592 | + public function unlock_transaction() |
|
1593 | + { |
|
1594 | + if ($this->checkout->transaction instanceof EE_Transaction) { |
|
1595 | + $this->checkout->transaction->unlock(); |
|
1596 | + } |
|
1597 | + } |
|
1598 | + |
|
1599 | + |
|
1600 | + |
|
1601 | + /** |
|
1602 | + * _setup_redirect |
|
1603 | + * |
|
1604 | + * @access private |
|
1605 | + * @return void |
|
1606 | + */ |
|
1607 | + private function _setup_redirect() |
|
1608 | + { |
|
1609 | + if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
1610 | + $this->checkout->redirect = true; |
|
1611 | + if (empty($this->checkout->redirect_url)) { |
|
1612 | + $this->checkout->redirect_url = $this->checkout->next_step->reg_step_url(); |
|
1613 | + } |
|
1614 | + $this->checkout->redirect_url = apply_filters( |
|
1615 | + 'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url', |
|
1616 | + $this->checkout->redirect_url, |
|
1617 | + $this->checkout |
|
1618 | + ); |
|
1619 | + } |
|
1620 | + } |
|
1621 | + |
|
1622 | + |
|
1623 | + |
|
1624 | + /** |
|
1625 | + * handle ajax message responses and redirects |
|
1626 | + * |
|
1627 | + * @access public |
|
1628 | + * @return void |
|
1629 | + * @throws \EE_Error |
|
1630 | + */ |
|
1631 | + public function go_to_next_step() |
|
1632 | + { |
|
1633 | + if (EE_Registry::instance()->REQ->ajax) { |
|
1634 | + // capture contents of output buffer we started earlier in the request, and insert into JSON response |
|
1635 | + $this->checkout->json_response->set_unexpected_errors(ob_get_clean()); |
|
1636 | + } |
|
1637 | + $this->unlock_transaction(); |
|
1638 | + // just return for these conditions |
|
1639 | + if ( |
|
1640 | + $this->checkout->admin_request |
|
1641 | + || $this->checkout->action === 'redirect_form' |
|
1642 | + || $this->checkout->action === 'update_checkout' |
|
1643 | + ) { |
|
1644 | + return; |
|
1645 | + } |
|
1646 | + // AJAX response |
|
1647 | + $this->_handle_json_response(); |
|
1648 | + // redirect to next step or the Thank You page |
|
1649 | + $this->_handle_html_redirects(); |
|
1650 | + // hmmm... must be something wrong, so let's just display the form again ! |
|
1651 | + $this->_display_spco_reg_form(); |
|
1652 | + } |
|
1653 | + |
|
1654 | + |
|
1655 | + |
|
1656 | + /** |
|
1657 | + * _handle_json_response |
|
1658 | + * |
|
1659 | + * @access protected |
|
1660 | + * @return void |
|
1661 | + */ |
|
1662 | + protected function _handle_json_response() |
|
1663 | + { |
|
1664 | + // if this is an ajax request |
|
1665 | + if (EE_Registry::instance()->REQ->ajax) { |
|
1666 | + // DEBUG LOG |
|
1667 | + //$this->checkout->log( |
|
1668 | + // __CLASS__, __FUNCTION__, __LINE__, |
|
1669 | + // array( |
|
1670 | + // 'json_response_redirect_url' => $this->checkout->json_response->redirect_url(), |
|
1671 | + // 'redirect' => $this->checkout->redirect, |
|
1672 | + // 'continue_reg' => $this->checkout->continue_reg, |
|
1673 | + // ) |
|
1674 | + //); |
|
1675 | + $this->checkout->json_response->set_registration_time_limit( |
|
1676 | + $this->checkout->get_registration_time_limit() |
|
1677 | + ); |
|
1678 | + $this->checkout->json_response->set_payment_amount($this->checkout->amount_owing); |
|
1679 | + // just send the ajax ( |
|
1680 | + $json_response = apply_filters( |
|
1681 | + 'FHEE__EE_Single_Page_Checkout__JSON_response', |
|
1682 | + $this->checkout->json_response |
|
1683 | + ); |
|
1684 | + echo $json_response; |
|
1685 | + exit(); |
|
1686 | + } |
|
1687 | + } |
|
1688 | + |
|
1689 | + |
|
1690 | + |
|
1691 | + /** |
|
1692 | + * _handle_redirects |
|
1693 | + * |
|
1694 | + * @access protected |
|
1695 | + * @return void |
|
1696 | + */ |
|
1697 | + protected function _handle_html_redirects() |
|
1698 | + { |
|
1699 | + // going somewhere ? |
|
1700 | + if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) { |
|
1701 | + // store notices in a transient |
|
1702 | + EE_Error::get_notices(false, true, true); |
|
1703 | + // DEBUG LOG |
|
1704 | + //$this->checkout->log( |
|
1705 | + // __CLASS__, __FUNCTION__, __LINE__, |
|
1706 | + // array( |
|
1707 | + // 'headers_sent' => headers_sent(), |
|
1708 | + // 'redirect_url' => $this->checkout->redirect_url, |
|
1709 | + // 'headers_list' => headers_list(), |
|
1710 | + // ) |
|
1711 | + //); |
|
1712 | + wp_safe_redirect($this->checkout->redirect_url); |
|
1713 | + exit(); |
|
1714 | + } |
|
1715 | + } |
|
1716 | + |
|
1717 | + |
|
1718 | + |
|
1719 | + /** |
|
1720 | + * set_checkout_anchor |
|
1721 | + * |
|
1722 | + * @access public |
|
1723 | + * @return void |
|
1724 | + */ |
|
1725 | + public function set_checkout_anchor() |
|
1726 | + { |
|
1727 | + echo '<a id="checkout" style="float: left; margin-left: -999em;"></a>'; |
|
1728 | + } |
|
1729 | 1729 | |
1730 | 1730 | |
1731 | 1731 |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | use EventEspresso\core\services\shortcodes\ShortcodesManager; |
3 | 3 | |
4 | 4 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
5 | - exit('No direct script access allowed'); |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -19,1440 +19,1440 @@ discard block |
||
19 | 19 | { |
20 | 20 | |
21 | 21 | |
22 | - /** |
|
23 | - * indicates this is a 'normal' request. Ie, not activation, nor upgrade, nor activation. |
|
24 | - * So examples of this would be a normal GET request on the frontend or backend, or a POST, etc |
|
25 | - */ |
|
26 | - const req_type_normal = 0; |
|
27 | - |
|
28 | - /** |
|
29 | - * Indicates this is a brand new installation of EE so we should install |
|
30 | - * tables and default data etc |
|
31 | - */ |
|
32 | - const req_type_new_activation = 1; |
|
33 | - |
|
34 | - /** |
|
35 | - * we've detected that EE has been reactivated (or EE was activated during maintenance mode, |
|
36 | - * and we just exited maintenance mode). We MUST check the database is setup properly |
|
37 | - * and that default data is setup too |
|
38 | - */ |
|
39 | - const req_type_reactivation = 2; |
|
40 | - |
|
41 | - /** |
|
42 | - * indicates that EE has been upgraded since its previous request. |
|
43 | - * We may have data migration scripts to call and will want to trigger maintenance mode |
|
44 | - */ |
|
45 | - const req_type_upgrade = 3; |
|
46 | - |
|
47 | - /** |
|
48 | - * TODO will detect that EE has been DOWNGRADED. We probably don't want to run in this case... |
|
49 | - */ |
|
50 | - const req_type_downgrade = 4; |
|
51 | - |
|
52 | - /** |
|
53 | - * @deprecated since version 4.6.0.dev.006 |
|
54 | - * Now whenever a new_activation is detected the request type is still just |
|
55 | - * new_activation (same for reactivation, upgrade, downgrade etc), but if we'r ein maintenance mode |
|
56 | - * EE_System::initialize_db_if_no_migrations_required and EE_Addon::initialize_db_if_no_migrations_required |
|
57 | - * will instead enqueue that EE plugin's db initialization for when we're taken out of maintenance mode. |
|
58 | - * (Specifically, when the migration manager indicates migrations are finished |
|
59 | - * EE_Data_Migration_Manager::initialize_db_for_enqueued_ee_plugins() will be called) |
|
60 | - */ |
|
61 | - const req_type_activation_but_not_installed = 5; |
|
62 | - |
|
63 | - /** |
|
64 | - * option prefix for recording the activation history (like core's "espresso_db_update") of addons |
|
65 | - */ |
|
66 | - const addon_activation_history_option_prefix = 'ee_addon_activation_history_'; |
|
67 | - |
|
68 | - |
|
69 | - /** |
|
70 | - * instance of the EE_System object |
|
71 | - * |
|
72 | - * @var $_instance |
|
73 | - * @access private |
|
74 | - */ |
|
75 | - private static $_instance = null; |
|
76 | - |
|
77 | - /** |
|
78 | - * @type EE_Registry $Registry |
|
79 | - * @access protected |
|
80 | - */ |
|
81 | - protected $registry; |
|
82 | - |
|
83 | - /** |
|
84 | - * Stores which type of request this is, options being one of the constants on EE_System starting with req_type_*. |
|
85 | - * It can be a brand-new activation, a reactivation, an upgrade, a downgrade, or a normal request. |
|
86 | - * |
|
87 | - * @var int |
|
88 | - */ |
|
89 | - private $_req_type; |
|
90 | - |
|
91 | - /** |
|
92 | - * Whether or not there was a non-micro version change in EE core version during this request |
|
93 | - * |
|
94 | - * @var boolean |
|
95 | - */ |
|
96 | - private $_major_version_change = false; |
|
97 | - |
|
98 | - |
|
99 | - |
|
100 | - /** |
|
101 | - * @singleton method used to instantiate class object |
|
102 | - * @access public |
|
103 | - * @param \EE_Registry $Registry |
|
104 | - * @return \EE_System |
|
105 | - */ |
|
106 | - public static function instance(EE_Registry $Registry = null) |
|
107 | - { |
|
108 | - // check if class object is instantiated |
|
109 | - if ( ! self::$_instance instanceof EE_System) { |
|
110 | - self::$_instance = new self($Registry); |
|
111 | - } |
|
112 | - return self::$_instance; |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - |
|
117 | - /** |
|
118 | - * resets the instance and returns it |
|
119 | - * |
|
120 | - * @return EE_System |
|
121 | - */ |
|
122 | - public static function reset() |
|
123 | - { |
|
124 | - self::$_instance->_req_type = null; |
|
125 | - //make sure none of the old hooks are left hanging around |
|
126 | - remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
127 | - //we need to reset the migration manager in order for it to detect DMSs properly |
|
128 | - EE_Data_Migration_Manager::reset(); |
|
129 | - self::instance()->detect_activations_or_upgrades(); |
|
130 | - self::instance()->perform_activations_upgrades_and_migrations(); |
|
131 | - return self::instance(); |
|
132 | - } |
|
133 | - |
|
134 | - |
|
135 | - |
|
136 | - /** |
|
137 | - * sets hooks for running rest of system |
|
138 | - * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point |
|
139 | - * starting EE Addons from any other point may lead to problems |
|
140 | - * |
|
141 | - * @access private |
|
142 | - * @param \EE_Registry $Registry |
|
143 | - */ |
|
144 | - private function __construct(EE_Registry $Registry) |
|
145 | - { |
|
146 | - $this->registry = $Registry; |
|
147 | - do_action('AHEE__EE_System__construct__begin', $this); |
|
148 | - // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc |
|
149 | - add_action('AHEE__EE_Bootstrap__load_espresso_addons', array($this, 'load_espresso_addons')); |
|
150 | - // when an ee addon is activated, we want to call the core hook(s) again |
|
151 | - // because the newly-activated addon didn't get a chance to run at all |
|
152 | - add_action('activate_plugin', array($this, 'load_espresso_addons'), 1); |
|
153 | - // detect whether install or upgrade |
|
154 | - add_action('AHEE__EE_Bootstrap__detect_activations_or_upgrades', array($this, 'detect_activations_or_upgrades'), |
|
155 | - 3); |
|
156 | - // load EE_Config, EE_Textdomain, etc |
|
157 | - add_action('AHEE__EE_Bootstrap__load_core_configuration', array($this, 'load_core_configuration'), 5); |
|
158 | - // load EE_Config, EE_Textdomain, etc |
|
159 | - add_action('AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', |
|
160 | - array($this, 'register_shortcodes_modules_and_widgets'), 7); |
|
161 | - // you wanna get going? I wanna get going... let's get going! |
|
162 | - add_action('AHEE__EE_Bootstrap__brew_espresso', array($this, 'brew_espresso'), 9); |
|
163 | - //other housekeeping |
|
164 | - //exclude EE critical pages from wp_list_pages |
|
165 | - add_filter('wp_list_pages_excludes', array($this, 'remove_pages_from_wp_list_pages'), 10); |
|
166 | - // ALL EE Addons should use the following hook point to attach their initial setup too |
|
167 | - // it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads |
|
168 | - do_action('AHEE__EE_System__construct__complete', $this); |
|
169 | - } |
|
170 | - |
|
171 | - |
|
172 | - |
|
173 | - /** |
|
174 | - * load_espresso_addons |
|
175 | - * allow addons to load first so that they can set hooks for running DMS's, etc |
|
176 | - * this is hooked into both: |
|
177 | - * 'AHEE__EE_Bootstrap__load_core_configuration' |
|
178 | - * which runs during the WP 'plugins_loaded' action at priority 5 |
|
179 | - * and the WP 'activate_plugin' hookpoint |
|
180 | - * |
|
181 | - * @access public |
|
182 | - * @return void |
|
183 | - */ |
|
184 | - public function load_espresso_addons() |
|
185 | - { |
|
186 | - // set autoloaders for all of the classes implementing EEI_Plugin_API |
|
187 | - // which provide helpers for EE plugin authors to more easily register certain components with EE. |
|
188 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api'); |
|
189 | - //load and setup EE_Capabilities |
|
190 | - $this->registry->load_core('Capabilities'); |
|
191 | - //caps need to be initialized on every request so that capability maps are set. |
|
192 | - //@see https://events.codebasehq.com/projects/event-espresso/tickets/8674 |
|
193 | - $this->registry->CAP->init_caps(); |
|
194 | - do_action('AHEE__EE_System__load_espresso_addons'); |
|
195 | - //if the WP API basic auth plugin isn't already loaded, load it now. |
|
196 | - //We want it for mobile apps. Just include the entire plugin |
|
197 | - //also, don't load the basic auth when a plugin is getting activated, because |
|
198 | - //it could be the basic auth plugin, and it doesn't check if its methods are already defined |
|
199 | - //and causes a fatal error |
|
200 | - if ( ! function_exists('json_basic_auth_handler') |
|
201 | - && ! function_exists('json_basic_auth_error') |
|
202 | - && ! ( |
|
203 | - isset($_GET['action']) |
|
204 | - && in_array($_GET['action'], array('activate', 'activate-selected')) |
|
205 | - ) |
|
206 | - && ! ( |
|
207 | - isset($_GET['activate']) |
|
208 | - && $_GET['activate'] === 'true' |
|
209 | - ) |
|
210 | - ) { |
|
211 | - include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php'; |
|
212 | - } |
|
213 | - do_action('AHEE__EE_System__load_espresso_addons__complete'); |
|
214 | - } |
|
215 | - |
|
216 | - |
|
217 | - |
|
218 | - /** |
|
219 | - * detect_activations_or_upgrades |
|
220 | - * Checks for activation or upgrade of core first; |
|
221 | - * then also checks if any registered addons have been activated or upgraded |
|
222 | - * This is hooked into 'AHEE__EE_Bootstrap__detect_activations_or_upgrades' |
|
223 | - * which runs during the WP 'plugins_loaded' action at priority 3 |
|
224 | - * |
|
225 | - * @access public |
|
226 | - * @return void |
|
227 | - */ |
|
228 | - public function detect_activations_or_upgrades() |
|
229 | - { |
|
230 | - //first off: let's make sure to handle core |
|
231 | - $this->detect_if_activation_or_upgrade(); |
|
232 | - foreach ($this->registry->addons as $addon) { |
|
233 | - //detect teh request type for that addon |
|
234 | - $addon->detect_activation_or_upgrade(); |
|
235 | - } |
|
236 | - } |
|
237 | - |
|
238 | - |
|
239 | - |
|
240 | - /** |
|
241 | - * detect_if_activation_or_upgrade |
|
242 | - * Takes care of detecting whether this is a brand new install or code upgrade, |
|
243 | - * and either setting up the DB or setting up maintenance mode etc. |
|
244 | - * |
|
245 | - * @access public |
|
246 | - * @return void |
|
247 | - */ |
|
248 | - public function detect_if_activation_or_upgrade() |
|
249 | - { |
|
250 | - do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin'); |
|
251 | - // load M-Mode class |
|
252 | - $this->registry->load_core('Maintenance_Mode'); |
|
253 | - // check if db has been updated, or if its a brand-new installation |
|
254 | - $espresso_db_update = $this->fix_espresso_db_upgrade_option(); |
|
255 | - $request_type = $this->detect_req_type($espresso_db_update); |
|
256 | - //EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ ); |
|
257 | - switch ($request_type) { |
|
258 | - case EE_System::req_type_new_activation: |
|
259 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation'); |
|
260 | - $this->_handle_core_version_change($espresso_db_update); |
|
261 | - break; |
|
262 | - case EE_System::req_type_reactivation: |
|
263 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation'); |
|
264 | - $this->_handle_core_version_change($espresso_db_update); |
|
265 | - break; |
|
266 | - case EE_System::req_type_upgrade: |
|
267 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade'); |
|
268 | - //migrations may be required now that we've upgraded |
|
269 | - EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
270 | - $this->_handle_core_version_change($espresso_db_update); |
|
271 | - // echo "done upgrade";die; |
|
272 | - break; |
|
273 | - case EE_System::req_type_downgrade: |
|
274 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade'); |
|
275 | - //its possible migrations are no longer required |
|
276 | - EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
277 | - $this->_handle_core_version_change($espresso_db_update); |
|
278 | - break; |
|
279 | - case EE_System::req_type_normal: |
|
280 | - default: |
|
281 | - // $this->_maybe_redirect_to_ee_about(); |
|
282 | - break; |
|
283 | - } |
|
284 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete'); |
|
285 | - } |
|
286 | - |
|
287 | - |
|
288 | - |
|
289 | - /** |
|
290 | - * Updates the list of installed versions and sets hooks for |
|
291 | - * initializing the database later during the request |
|
292 | - * |
|
293 | - * @param array $espresso_db_update |
|
294 | - */ |
|
295 | - protected function _handle_core_version_change($espresso_db_update) |
|
296 | - { |
|
297 | - $this->update_list_of_installed_versions($espresso_db_update); |
|
298 | - //get ready to verify the DB is ok (provided we aren't in maintenance mode, of course) |
|
299 | - add_action('AHEE__EE_System__perform_activations_upgrades_and_migrations', |
|
300 | - array($this, 'initialize_db_if_no_migrations_required')); |
|
301 | - } |
|
302 | - |
|
303 | - |
|
304 | - |
|
305 | - /** |
|
306 | - * standardizes the wp option 'espresso_db_upgrade' which actually stores |
|
307 | - * information about what versions of EE have been installed and activated, |
|
308 | - * NOT necessarily the state of the database |
|
309 | - * |
|
310 | - * @param null $espresso_db_update |
|
311 | - * @internal param array $espresso_db_update_value the value of the WordPress option. If not supplied, fetches it |
|
312 | - * from the options table |
|
313 | - * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction |
|
314 | - */ |
|
315 | - private function fix_espresso_db_upgrade_option($espresso_db_update = null) |
|
316 | - { |
|
317 | - do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update); |
|
318 | - if ( ! $espresso_db_update) { |
|
319 | - $espresso_db_update = get_option('espresso_db_update'); |
|
320 | - } |
|
321 | - // check that option is an array |
|
322 | - if ( ! is_array($espresso_db_update)) { |
|
323 | - // if option is FALSE, then it never existed |
|
324 | - if ($espresso_db_update === false) { |
|
325 | - // make $espresso_db_update an array and save option with autoload OFF |
|
326 | - $espresso_db_update = array(); |
|
327 | - add_option('espresso_db_update', $espresso_db_update, '', 'no'); |
|
328 | - } else { |
|
329 | - // option is NOT FALSE but also is NOT an array, so make it an array and save it |
|
330 | - $espresso_db_update = array($espresso_db_update => array()); |
|
331 | - update_option('espresso_db_update', $espresso_db_update); |
|
332 | - } |
|
333 | - } else { |
|
334 | - $corrected_db_update = array(); |
|
335 | - //if IS an array, but is it an array where KEYS are version numbers, and values are arrays? |
|
336 | - foreach ($espresso_db_update as $should_be_version_string => $should_be_array) { |
|
337 | - if (is_int($should_be_version_string) && ! is_array($should_be_array)) { |
|
338 | - //the key is an int, and the value IS NOT an array |
|
339 | - //so it must be numerically-indexed, where values are versions installed... |
|
340 | - //fix it! |
|
341 | - $version_string = $should_be_array; |
|
342 | - $corrected_db_update[$version_string] = array('unknown-date'); |
|
343 | - } else { |
|
344 | - //ok it checks out |
|
345 | - $corrected_db_update[$should_be_version_string] = $should_be_array; |
|
346 | - } |
|
347 | - } |
|
348 | - $espresso_db_update = $corrected_db_update; |
|
349 | - update_option('espresso_db_update', $espresso_db_update); |
|
350 | - } |
|
351 | - do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update); |
|
352 | - return $espresso_db_update; |
|
353 | - } |
|
354 | - |
|
355 | - |
|
356 | - |
|
357 | - /** |
|
358 | - * Does the traditional work of setting up the plugin's database and adding default data. |
|
359 | - * If migration script/process did not exist, this is what would happen on every activation/reactivation/upgrade. |
|
360 | - * NOTE: if we're in maintenance mode (which would be the case if we detect there are data |
|
361 | - * migration scripts that need to be run and a version change happens), enqueues core for database initialization, |
|
362 | - * so that it will be done when migrations are finished |
|
363 | - * |
|
364 | - * @param boolean $initialize_addons_too if true, we double-check addons' database tables etc too; |
|
365 | - * @param boolean $verify_schema if true will re-check the database tables have the correct schema. |
|
366 | - * This is a resource-intensive job |
|
367 | - * so we prefer to only do it when necessary |
|
368 | - * @return void |
|
369 | - */ |
|
370 | - public function initialize_db_if_no_migrations_required($initialize_addons_too = false, $verify_schema = true) |
|
371 | - { |
|
372 | - $request_type = $this->detect_req_type(); |
|
373 | - //only initialize system if we're not in maintenance mode. |
|
374 | - if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
375 | - update_option('ee_flush_rewrite_rules', true); |
|
376 | - if ($verify_schema) { |
|
377 | - EEH_Activation::initialize_db_and_folders(); |
|
378 | - } |
|
379 | - EEH_Activation::initialize_db_content(); |
|
380 | - EEH_Activation::system_initialization(); |
|
381 | - if ($initialize_addons_too) { |
|
382 | - $this->initialize_addons(); |
|
383 | - } |
|
384 | - } else { |
|
385 | - EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core'); |
|
386 | - } |
|
387 | - if ($request_type === EE_System::req_type_new_activation |
|
388 | - || $request_type === EE_System::req_type_reactivation |
|
389 | - || ( |
|
390 | - $request_type === EE_System::req_type_upgrade |
|
391 | - && $this->is_major_version_change() |
|
392 | - ) |
|
393 | - ) { |
|
394 | - add_action('AHEE__EE_System__initialize_last', array($this, 'redirect_to_about_ee'), 9); |
|
395 | - } |
|
396 | - } |
|
397 | - |
|
398 | - |
|
399 | - |
|
400 | - /** |
|
401 | - * Initializes the db for all registered addons |
|
402 | - */ |
|
403 | - public function initialize_addons() |
|
404 | - { |
|
405 | - //foreach registered addon, make sure its db is up-to-date too |
|
406 | - foreach ($this->registry->addons as $addon) { |
|
407 | - $addon->initialize_db_if_no_migrations_required(); |
|
408 | - } |
|
409 | - } |
|
410 | - |
|
411 | - |
|
412 | - |
|
413 | - /** |
|
414 | - * Adds the current code version to the saved wp option which stores a list of all ee versions ever installed. |
|
415 | - * |
|
416 | - * @param array $version_history |
|
417 | - * @param string $current_version_to_add version to be added to the version history |
|
418 | - * @return boolean success as to whether or not this option was changed |
|
419 | - */ |
|
420 | - public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null) |
|
421 | - { |
|
422 | - if ( ! $version_history) { |
|
423 | - $version_history = $this->fix_espresso_db_upgrade_option($version_history); |
|
424 | - } |
|
425 | - if ($current_version_to_add == null) { |
|
426 | - $current_version_to_add = espresso_version(); |
|
427 | - } |
|
428 | - $version_history[$current_version_to_add][] = date('Y-m-d H:i:s', time()); |
|
429 | - // re-save |
|
430 | - return update_option('espresso_db_update', $version_history); |
|
431 | - } |
|
432 | - |
|
433 | - |
|
434 | - |
|
435 | - /** |
|
436 | - * Detects if the current version indicated in the has existed in the list of |
|
437 | - * previously-installed versions of EE (espresso_db_update). Does NOT modify it (ie, no side-effect) |
|
438 | - * |
|
439 | - * @param array $espresso_db_update array from the wp option stored under the name 'espresso_db_update'. |
|
440 | - * If not supplied, fetches it from the options table. |
|
441 | - * Also, caches its result so later parts of the code can also know whether |
|
442 | - * there's been an update or not. This way we can add the current version to |
|
443 | - * espresso_db_update, but still know if this is a new install or not |
|
444 | - * @return int one of the constants on EE_System::req_type_ |
|
445 | - */ |
|
446 | - public function detect_req_type($espresso_db_update = null) |
|
447 | - { |
|
448 | - if ($this->_req_type === null) { |
|
449 | - $espresso_db_update = ! empty($espresso_db_update) ? $espresso_db_update |
|
450 | - : $this->fix_espresso_db_upgrade_option(); |
|
451 | - $this->_req_type = $this->detect_req_type_given_activation_history($espresso_db_update, |
|
452 | - 'ee_espresso_activation', espresso_version()); |
|
453 | - $this->_major_version_change = $this->_detect_major_version_change($espresso_db_update); |
|
454 | - } |
|
455 | - return $this->_req_type; |
|
456 | - } |
|
457 | - |
|
458 | - |
|
459 | - |
|
460 | - /** |
|
461 | - * Returns whether or not there was a non-micro version change (ie, change in either |
|
462 | - * the first or second number in the version. Eg 4.9.0.rc.001 to 4.10.0.rc.000, |
|
463 | - * but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
|
464 | - * |
|
465 | - * @param $activation_history |
|
466 | - * @return bool |
|
467 | - */ |
|
468 | - protected function _detect_major_version_change($activation_history) |
|
469 | - { |
|
470 | - $previous_version = EE_System::_get_most_recently_active_version_from_activation_history($activation_history); |
|
471 | - $previous_version_parts = explode('.', $previous_version); |
|
472 | - $current_version_parts = explode('.', espresso_version()); |
|
473 | - return isset($previous_version_parts[0], $previous_version_parts[1], $current_version_parts[0], $current_version_parts[1]) |
|
474 | - && ($previous_version_parts[0] !== $current_version_parts[0] |
|
475 | - || $previous_version_parts[1] !== $current_version_parts[1] |
|
476 | - ); |
|
477 | - } |
|
478 | - |
|
479 | - |
|
480 | - |
|
481 | - /** |
|
482 | - * Returns true if either the major or minor version of EE changed during this request. |
|
483 | - * Eg 4.9.0.rc.001 to 4.10.0.rc.000, but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
|
484 | - * |
|
485 | - * @return bool |
|
486 | - */ |
|
487 | - public function is_major_version_change() |
|
488 | - { |
|
489 | - return $this->_major_version_change; |
|
490 | - } |
|
491 | - |
|
492 | - |
|
493 | - |
|
494 | - /** |
|
495 | - * Determines the request type for any ee addon, given three piece of info: the current array of activation |
|
496 | - * histories (for core that' 'espresso_db_update' wp option); the name of the wordpress option which is temporarily |
|
497 | - * set upon activation of the plugin (for core it's 'ee_espresso_activation'); and the version that this plugin was |
|
498 | - * just activated to (for core that will always be espresso_version()) |
|
499 | - * |
|
500 | - * @param array $activation_history_for_addon the option's value which stores the activation history for this |
|
501 | - * ee plugin. for core that's 'espresso_db_update' |
|
502 | - * @param string $activation_indicator_option_name the name of the wordpress option that is temporarily set to |
|
503 | - * indicate that this plugin was just activated |
|
504 | - * @param string $version_to_upgrade_to the version that was just upgraded to (for core that will be |
|
505 | - * espresso_version()) |
|
506 | - * @return int one of the constants on EE_System::req_type_* |
|
507 | - */ |
|
508 | - public static function detect_req_type_given_activation_history( |
|
509 | - $activation_history_for_addon, |
|
510 | - $activation_indicator_option_name, |
|
511 | - $version_to_upgrade_to |
|
512 | - ) { |
|
513 | - $version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to); |
|
514 | - if ($activation_history_for_addon) { |
|
515 | - //it exists, so this isn't a completely new install |
|
516 | - //check if this version already in that list of previously installed versions |
|
517 | - if ( ! isset($activation_history_for_addon[$version_to_upgrade_to])) { |
|
518 | - //it a version we haven't seen before |
|
519 | - if ($version_is_higher === 1) { |
|
520 | - $req_type = EE_System::req_type_upgrade; |
|
521 | - } else { |
|
522 | - $req_type = EE_System::req_type_downgrade; |
|
523 | - } |
|
524 | - delete_option($activation_indicator_option_name); |
|
525 | - } else { |
|
526 | - // its not an update. maybe a reactivation? |
|
527 | - if (get_option($activation_indicator_option_name, false)) { |
|
528 | - if ($version_is_higher === -1) { |
|
529 | - $req_type = EE_System::req_type_downgrade; |
|
530 | - } elseif ($version_is_higher === 0) { |
|
531 | - //we've seen this version before, but it's an activation. must be a reactivation |
|
532 | - $req_type = EE_System::req_type_reactivation; |
|
533 | - } else {//$version_is_higher === 1 |
|
534 | - $req_type = EE_System::req_type_upgrade; |
|
535 | - } |
|
536 | - delete_option($activation_indicator_option_name); |
|
537 | - } else { |
|
538 | - //we've seen this version before and the activation indicate doesn't show it was just activated |
|
539 | - if ($version_is_higher === -1) { |
|
540 | - $req_type = EE_System::req_type_downgrade; |
|
541 | - } elseif ($version_is_higher === 0) { |
|
542 | - //we've seen this version before and it's not an activation. its normal request |
|
543 | - $req_type = EE_System::req_type_normal; |
|
544 | - } else {//$version_is_higher === 1 |
|
545 | - $req_type = EE_System::req_type_upgrade; |
|
546 | - } |
|
547 | - } |
|
548 | - } |
|
549 | - } else { |
|
550 | - //brand new install |
|
551 | - $req_type = EE_System::req_type_new_activation; |
|
552 | - delete_option($activation_indicator_option_name); |
|
553 | - } |
|
554 | - return $req_type; |
|
555 | - } |
|
556 | - |
|
557 | - |
|
558 | - |
|
559 | - /** |
|
560 | - * Detects if the $version_to_upgrade_to is higher than the most recent version in |
|
561 | - * the $activation_history_for_addon |
|
562 | - * |
|
563 | - * @param array $activation_history_for_addon (keys are versions, values are arrays of times activated, |
|
564 | - * sometimes containing 'unknown-date' |
|
565 | - * @param string $version_to_upgrade_to (current version) |
|
566 | - * @return int results of version_compare( $version_to_upgrade_to, $most_recently_active_version ). |
|
567 | - * ie, -1 if $version_to_upgrade_to is LOWER (downgrade); |
|
568 | - * 0 if $version_to_upgrade_to MATCHES (reactivation or normal request); |
|
569 | - * 1 if $version_to_upgrade_to is HIGHER (upgrade) ; |
|
570 | - */ |
|
571 | - protected static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to) |
|
572 | - { |
|
573 | - //find the most recently-activated version |
|
574 | - $most_recently_active_version = EE_System::_get_most_recently_active_version_from_activation_history($activation_history_for_addon); |
|
575 | - return version_compare($version_to_upgrade_to, $most_recently_active_version); |
|
576 | - } |
|
577 | - |
|
578 | - |
|
579 | - |
|
580 | - /** |
|
581 | - * Gets the most recently active version listed in the activation history, |
|
582 | - * and if none are found (ie, it's a brand new install) returns '0.0.0.dev.000'. |
|
583 | - * |
|
584 | - * @param array $activation_history (keys are versions, values are arrays of times activated, |
|
585 | - * sometimes containing 'unknown-date' |
|
586 | - * @return string |
|
587 | - */ |
|
588 | - protected static function _get_most_recently_active_version_from_activation_history($activation_history) |
|
589 | - { |
|
590 | - $most_recently_active_version_activation = '1970-01-01 00:00:00'; |
|
591 | - $most_recently_active_version = '0.0.0.dev.000'; |
|
592 | - if (is_array($activation_history)) { |
|
593 | - foreach ($activation_history as $version => $times_activated) { |
|
594 | - //check there is a record of when this version was activated. Otherwise, |
|
595 | - //mark it as unknown |
|
596 | - if ( ! $times_activated) { |
|
597 | - $times_activated = array('unknown-date'); |
|
598 | - } |
|
599 | - if (is_string($times_activated)) { |
|
600 | - $times_activated = array($times_activated); |
|
601 | - } |
|
602 | - foreach ($times_activated as $an_activation) { |
|
603 | - if ($an_activation != 'unknown-date' && $an_activation > $most_recently_active_version_activation) { |
|
604 | - $most_recently_active_version = $version; |
|
605 | - $most_recently_active_version_activation = $an_activation == 'unknown-date' |
|
606 | - ? '1970-01-01 00:00:00' : $an_activation; |
|
607 | - } |
|
608 | - } |
|
609 | - } |
|
610 | - } |
|
611 | - return $most_recently_active_version; |
|
612 | - } |
|
613 | - |
|
614 | - |
|
615 | - |
|
616 | - /** |
|
617 | - * This redirects to the about EE page after activation |
|
618 | - * |
|
619 | - * @return void |
|
620 | - */ |
|
621 | - public function redirect_to_about_ee() |
|
622 | - { |
|
623 | - $notices = EE_Error::get_notices(false); |
|
624 | - //if current user is an admin and it's not an ajax or rest request |
|
625 | - if ( |
|
626 | - ! (defined('DOING_AJAX') && DOING_AJAX) |
|
627 | - && ! (defined('REST_REQUEST') && REST_REQUEST) |
|
628 | - && ! isset($notices['errors']) |
|
629 | - && apply_filters( |
|
630 | - 'FHEE__EE_System__redirect_to_about_ee__do_redirect', |
|
631 | - $this->registry->CAP->current_user_can('manage_options', 'espresso_about_default') |
|
632 | - ) |
|
633 | - ) { |
|
634 | - $query_params = array('page' => 'espresso_about'); |
|
635 | - if (EE_System::instance()->detect_req_type() == EE_System::req_type_new_activation) { |
|
636 | - $query_params['new_activation'] = true; |
|
637 | - } |
|
638 | - if (EE_System::instance()->detect_req_type() == EE_System::req_type_reactivation) { |
|
639 | - $query_params['reactivation'] = true; |
|
640 | - } |
|
641 | - $url = add_query_arg($query_params, admin_url('admin.php')); |
|
642 | - wp_safe_redirect($url); |
|
643 | - exit(); |
|
644 | - } |
|
645 | - } |
|
646 | - |
|
647 | - |
|
648 | - |
|
649 | - /** |
|
650 | - * load_core_configuration |
|
651 | - * this is hooked into 'AHEE__EE_Bootstrap__load_core_configuration' |
|
652 | - * which runs during the WP 'plugins_loaded' action at priority 5 |
|
653 | - * |
|
654 | - * @return void |
|
655 | - */ |
|
656 | - public function load_core_configuration() |
|
657 | - { |
|
658 | - do_action('AHEE__EE_System__load_core_configuration__begin', $this); |
|
659 | - $this->registry->load_core('EE_Load_Textdomain'); |
|
660 | - //load textdomain |
|
661 | - EE_Load_Textdomain::load_textdomain(); |
|
662 | - // load and setup EE_Config and EE_Network_Config |
|
663 | - $this->registry->load_core('Config'); |
|
664 | - $this->registry->load_core('Network_Config'); |
|
665 | - // setup autoloaders |
|
666 | - // enable logging? |
|
667 | - if ($this->registry->CFG->admin->use_full_logging) { |
|
668 | - $this->registry->load_core('Log'); |
|
669 | - } |
|
670 | - // check for activation errors |
|
671 | - $activation_errors = get_option('ee_plugin_activation_errors', false); |
|
672 | - if ($activation_errors) { |
|
673 | - EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__); |
|
674 | - update_option('ee_plugin_activation_errors', false); |
|
675 | - } |
|
676 | - // get model names |
|
677 | - $this->_parse_model_names(); |
|
678 | - //load caf stuff a chance to play during the activation process too. |
|
679 | - $this->_maybe_brew_regular(); |
|
680 | - do_action('AHEE__EE_System__load_core_configuration__complete', $this); |
|
681 | - } |
|
682 | - |
|
683 | - |
|
684 | - |
|
685 | - /** |
|
686 | - * cycles through all of the models/*.model.php files, and assembles an array of model names |
|
687 | - * |
|
688 | - * @return void |
|
689 | - */ |
|
690 | - private function _parse_model_names() |
|
691 | - { |
|
692 | - //get all the files in the EE_MODELS folder that end in .model.php |
|
693 | - $models = glob(EE_MODELS . '*.model.php'); |
|
694 | - $model_names = array(); |
|
695 | - $non_abstract_db_models = array(); |
|
696 | - foreach ($models as $model) { |
|
697 | - // get model classname |
|
698 | - $classname = EEH_File::get_classname_from_filepath_with_standard_filename($model); |
|
699 | - $short_name = str_replace('EEM_', '', $classname); |
|
700 | - $reflectionClass = new ReflectionClass($classname); |
|
701 | - if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) { |
|
702 | - $non_abstract_db_models[$short_name] = $classname; |
|
703 | - } |
|
704 | - $model_names[$short_name] = $classname; |
|
705 | - } |
|
706 | - $this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names); |
|
707 | - $this->registry->non_abstract_db_models = apply_filters('FHEE__EE_System__parse_implemented_model_names', |
|
708 | - $non_abstract_db_models); |
|
709 | - } |
|
710 | - |
|
711 | - |
|
712 | - |
|
713 | - /** |
|
714 | - * The purpose of this method is to simply check for a file named "caffeinated/brewing_regular.php" for any hooks |
|
715 | - * that need to be setup before our EE_System launches. |
|
716 | - * |
|
717 | - * @return void |
|
718 | - */ |
|
719 | - private function _maybe_brew_regular() |
|
720 | - { |
|
721 | - if (( ! defined('EE_DECAF') || EE_DECAF !== true) && is_readable(EE_CAFF_PATH . 'brewing_regular.php')) { |
|
722 | - require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
723 | - } |
|
724 | - } |
|
725 | - |
|
726 | - |
|
727 | - |
|
728 | - /** |
|
729 | - * register_shortcodes_modules_and_widgets |
|
730 | - * generate lists of shortcodes and modules, then verify paths and classes |
|
731 | - * This is hooked into 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets' |
|
732 | - * which runs during the WP 'plugins_loaded' action at priority 7 |
|
733 | - * |
|
734 | - * @access public |
|
735 | - * @return void |
|
736 | - */ |
|
737 | - public function register_shortcodes_modules_and_widgets() |
|
738 | - { |
|
739 | - try { |
|
740 | - // load, register, and add shortcodes the new way |
|
741 | - new ShortcodesManager( |
|
742 | - // and the old way, but we'll put it under control of the new system |
|
743 | - EE_Config::getLegacyShortcodesManager() |
|
744 | - ); |
|
745 | - } catch (Exception $exception) { |
|
746 | - new ExceptionStackTraceDisplay($exception); |
|
747 | - } |
|
748 | - do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets'); |
|
749 | - // check for addons using old hookpoint |
|
750 | - if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) { |
|
751 | - $this->_incompatible_addon_error(); |
|
752 | - } |
|
753 | - } |
|
754 | - |
|
755 | - |
|
756 | - |
|
757 | - /** |
|
758 | - * _incompatible_addon_error |
|
759 | - * |
|
760 | - * @access public |
|
761 | - * @return void |
|
762 | - */ |
|
763 | - private function _incompatible_addon_error() |
|
764 | - { |
|
765 | - // get array of classes hooking into here |
|
766 | - $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook('AHEE__EE_System__register_shortcodes_modules_and_addons'); |
|
767 | - if ( ! empty($class_names)) { |
|
768 | - $msg = __('The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', |
|
769 | - 'event_espresso'); |
|
770 | - $msg .= '<ul>'; |
|
771 | - foreach ($class_names as $class_name) { |
|
772 | - $msg .= '<li><b>Event Espresso - ' . str_replace(array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '', |
|
773 | - $class_name) . '</b></li>'; |
|
774 | - } |
|
775 | - $msg .= '</ul>'; |
|
776 | - $msg .= __('Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', |
|
777 | - 'event_espresso'); |
|
778 | - // save list of incompatible addons to wp-options for later use |
|
779 | - add_option('ee_incompatible_addons', $class_names, '', 'no'); |
|
780 | - if (is_admin()) { |
|
781 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
782 | - } |
|
783 | - } |
|
784 | - } |
|
785 | - |
|
786 | - |
|
787 | - |
|
788 | - /** |
|
789 | - * brew_espresso |
|
790 | - * begins the process of setting hooks for initializing EE in the correct order |
|
791 | - * This is happening on the 'AHEE__EE_Bootstrap__brew_espresso' hookpoint |
|
792 | - * which runs during the WP 'plugins_loaded' action at priority 9 |
|
793 | - * |
|
794 | - * @return void |
|
795 | - */ |
|
796 | - public function brew_espresso() |
|
797 | - { |
|
798 | - do_action('AHEE__EE_System__brew_espresso__begin', $this); |
|
799 | - // load some final core systems |
|
800 | - add_action('init', array($this, 'set_hooks_for_core'), 1); |
|
801 | - add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3); |
|
802 | - add_action('init', array($this, 'load_CPTs_and_session'), 5); |
|
803 | - add_action('init', array($this, 'load_controllers'), 7); |
|
804 | - add_action('init', array($this, 'core_loaded_and_ready'), 9); |
|
805 | - add_action('init', array($this, 'initialize'), 10); |
|
806 | - add_action('init', array($this, 'initialize_last'), 100); |
|
807 | - add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 100); |
|
808 | - add_action('admin_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 100); |
|
809 | - add_action('admin_bar_menu', array($this, 'espresso_toolbar_items'), 100); |
|
810 | - if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', true)) { |
|
811 | - // pew pew pew |
|
812 | - $this->registry->load_core('PUE'); |
|
813 | - do_action('AHEE__EE_System__brew_espresso__after_pue_init'); |
|
814 | - } |
|
815 | - do_action('AHEE__EE_System__brew_espresso__complete', $this); |
|
816 | - } |
|
817 | - |
|
818 | - |
|
819 | - |
|
820 | - /** |
|
821 | - * set_hooks_for_core |
|
822 | - * |
|
823 | - * @access public |
|
824 | - * @return void |
|
825 | - */ |
|
826 | - public function set_hooks_for_core() |
|
827 | - { |
|
828 | - $this->_deactivate_incompatible_addons(); |
|
829 | - do_action('AHEE__EE_System__set_hooks_for_core'); |
|
830 | - } |
|
831 | - |
|
832 | - |
|
833 | - |
|
834 | - /** |
|
835 | - * Using the information gathered in EE_System::_incompatible_addon_error, |
|
836 | - * deactivates any addons considered incompatible with the current version of EE |
|
837 | - */ |
|
838 | - private function _deactivate_incompatible_addons() |
|
839 | - { |
|
840 | - $incompatible_addons = get_option('ee_incompatible_addons', array()); |
|
841 | - if ( ! empty($incompatible_addons)) { |
|
842 | - $active_plugins = get_option('active_plugins', array()); |
|
843 | - foreach ($active_plugins as $active_plugin) { |
|
844 | - foreach ($incompatible_addons as $incompatible_addon) { |
|
845 | - if (strpos($active_plugin, $incompatible_addon) !== false) { |
|
846 | - unset($_GET['activate']); |
|
847 | - espresso_deactivate_plugin($active_plugin); |
|
848 | - } |
|
849 | - } |
|
850 | - } |
|
851 | - } |
|
852 | - } |
|
853 | - |
|
854 | - |
|
855 | - |
|
856 | - /** |
|
857 | - * perform_activations_upgrades_and_migrations |
|
858 | - * |
|
859 | - * @access public |
|
860 | - * @return void |
|
861 | - */ |
|
862 | - public function perform_activations_upgrades_and_migrations() |
|
863 | - { |
|
864 | - //first check if we had previously attempted to setup EE's directories but failed |
|
865 | - if (EEH_Activation::upload_directories_incomplete()) { |
|
866 | - EEH_Activation::create_upload_directories(); |
|
867 | - } |
|
868 | - do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
869 | - } |
|
870 | - |
|
871 | - |
|
872 | - |
|
873 | - /** |
|
874 | - * load_CPTs_and_session |
|
875 | - * |
|
876 | - * @access public |
|
877 | - * @return void |
|
878 | - */ |
|
879 | - public function load_CPTs_and_session() |
|
880 | - { |
|
881 | - do_action('AHEE__EE_System__load_CPTs_and_session__start'); |
|
882 | - // register Custom Post Types |
|
883 | - $this->registry->load_core('Register_CPTs'); |
|
884 | - do_action('AHEE__EE_System__load_CPTs_and_session__complete'); |
|
885 | - } |
|
886 | - |
|
887 | - |
|
888 | - |
|
889 | - /** |
|
890 | - * load_controllers |
|
891 | - * this is the best place to load any additional controllers that needs access to EE core. |
|
892 | - * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this |
|
893 | - * time |
|
894 | - * |
|
895 | - * @access public |
|
896 | - * @return void |
|
897 | - */ |
|
898 | - public function load_controllers() |
|
899 | - { |
|
900 | - do_action('AHEE__EE_System__load_controllers__start'); |
|
901 | - // let's get it started |
|
902 | - if ( ! is_admin() && ! EE_Maintenance_Mode::instance()->level()) { |
|
903 | - do_action('AHEE__EE_System__load_controllers__load_front_controllers'); |
|
904 | - $this->registry->load_core('Front_Controller'); |
|
905 | - } else if ( ! EE_FRONT_AJAX) { |
|
906 | - do_action('AHEE__EE_System__load_controllers__load_admin_controllers'); |
|
907 | - EE_Registry::instance()->load_core('Admin'); |
|
908 | - } |
|
909 | - do_action('AHEE__EE_System__load_controllers__complete'); |
|
910 | - } |
|
911 | - |
|
912 | - |
|
913 | - |
|
914 | - /** |
|
915 | - * core_loaded_and_ready |
|
916 | - * all of the basic EE core should be loaded at this point and available regardless of M-Mode |
|
917 | - * |
|
918 | - * @access public |
|
919 | - * @return void |
|
920 | - */ |
|
921 | - public function core_loaded_and_ready() |
|
922 | - { |
|
923 | - do_action('AHEE__EE_System__core_loaded_and_ready'); |
|
924 | - // load_espresso_template_tags |
|
925 | - if (is_readable(EE_PUBLIC . 'template_tags.php')) { |
|
926 | - require_once(EE_PUBLIC . 'template_tags.php'); |
|
927 | - } |
|
928 | - do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons'); |
|
929 | - $this->registry->load_core('Session'); |
|
930 | - } |
|
931 | - |
|
932 | - |
|
933 | - |
|
934 | - /** |
|
935 | - * initialize |
|
936 | - * this is the best place to begin initializing client code |
|
937 | - * |
|
938 | - * @access public |
|
939 | - * @return void |
|
940 | - */ |
|
941 | - public function initialize() |
|
942 | - { |
|
943 | - do_action('AHEE__EE_System__initialize'); |
|
944 | - } |
|
945 | - |
|
946 | - |
|
947 | - |
|
948 | - /** |
|
949 | - * initialize_last |
|
950 | - * this is run really late during the WP init hookpoint, and ensures that mostly everything else that needs to |
|
951 | - * initialize has done so |
|
952 | - * |
|
953 | - * @access public |
|
954 | - * @return void |
|
955 | - */ |
|
956 | - public function initialize_last() |
|
957 | - { |
|
958 | - do_action('AHEE__EE_System__initialize_last'); |
|
959 | - } |
|
960 | - |
|
961 | - |
|
962 | - |
|
963 | - /** |
|
964 | - * set_hooks_for_shortcodes_modules_and_addons |
|
965 | - * this is the best place for other systems to set callbacks for hooking into other parts of EE |
|
966 | - * this happens at the very beginning of the wp_loaded hookpoint |
|
967 | - * |
|
968 | - * @access public |
|
969 | - * @return void |
|
970 | - */ |
|
971 | - public function set_hooks_for_shortcodes_modules_and_addons() |
|
972 | - { |
|
973 | - // do_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons' ); |
|
974 | - } |
|
975 | - |
|
976 | - |
|
977 | - |
|
978 | - /** |
|
979 | - * do_not_cache |
|
980 | - * sets no cache headers and defines no cache constants for WP plugins |
|
981 | - * |
|
982 | - * @access public |
|
983 | - * @return void |
|
984 | - */ |
|
985 | - public static function do_not_cache() |
|
986 | - { |
|
987 | - // set no cache constants |
|
988 | - if ( ! defined('DONOTCACHEPAGE')) { |
|
989 | - define('DONOTCACHEPAGE', true); |
|
990 | - } |
|
991 | - if ( ! defined('DONOTCACHCEOBJECT')) { |
|
992 | - define('DONOTCACHCEOBJECT', true); |
|
993 | - } |
|
994 | - if ( ! defined('DONOTCACHEDB')) { |
|
995 | - define('DONOTCACHEDB', true); |
|
996 | - } |
|
997 | - // add no cache headers |
|
998 | - add_action('send_headers', array('EE_System', 'nocache_headers'), 10); |
|
999 | - // plus a little extra for nginx and Google Chrome |
|
1000 | - add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1); |
|
1001 | - // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process |
|
1002 | - remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); |
|
1003 | - } |
|
1004 | - |
|
1005 | - |
|
1006 | - |
|
1007 | - /** |
|
1008 | - * extra_nocache_headers |
|
1009 | - * |
|
1010 | - * @access public |
|
1011 | - * @param $headers |
|
1012 | - * @return array |
|
1013 | - */ |
|
1014 | - public static function extra_nocache_headers($headers) |
|
1015 | - { |
|
1016 | - // for NGINX |
|
1017 | - $headers['X-Accel-Expires'] = 0; |
|
1018 | - // plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store" |
|
1019 | - $headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0'; |
|
1020 | - return $headers; |
|
1021 | - } |
|
1022 | - |
|
1023 | - |
|
1024 | - |
|
1025 | - /** |
|
1026 | - * nocache_headers |
|
1027 | - * |
|
1028 | - * @access public |
|
1029 | - * @return void |
|
1030 | - */ |
|
1031 | - public static function nocache_headers() |
|
1032 | - { |
|
1033 | - nocache_headers(); |
|
1034 | - } |
|
1035 | - |
|
1036 | - |
|
1037 | - |
|
1038 | - /** |
|
1039 | - * espresso_toolbar_items |
|
1040 | - * |
|
1041 | - * @access public |
|
1042 | - * @param WP_Admin_Bar $admin_bar |
|
1043 | - * @return void |
|
1044 | - */ |
|
1045 | - public function espresso_toolbar_items(WP_Admin_Bar $admin_bar) |
|
1046 | - { |
|
1047 | - // if in full M-Mode, or its an AJAX request, or user is NOT an admin |
|
1048 | - if (EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance |
|
1049 | - || defined('DOING_AJAX') |
|
1050 | - || ! $this->registry->CAP->current_user_can('ee_read_ee', 'ee_admin_bar_menu_top_level') |
|
1051 | - ) { |
|
1052 | - return; |
|
1053 | - } |
|
1054 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1055 | - $menu_class = 'espresso_menu_item_class'; |
|
1056 | - //we don't use the constants EVENTS_ADMIN_URL or REG_ADMIN_URL |
|
1057 | - //because they're only defined in each of their respective constructors |
|
1058 | - //and this might be a frontend request, in which case they aren't available |
|
1059 | - $events_admin_url = admin_url("admin.php?page=espresso_events"); |
|
1060 | - $reg_admin_url = admin_url("admin.php?page=espresso_registrations"); |
|
1061 | - $extensions_admin_url = admin_url("admin.php?page=espresso_packages"); |
|
1062 | - //Top Level |
|
1063 | - $admin_bar->add_menu(array( |
|
1064 | - 'id' => 'espresso-toolbar', |
|
1065 | - 'title' => '<span class="ee-icon ee-icon-ee-cup-thick ee-icon-size-20"></span><span class="ab-label">' |
|
1066 | - . _x('Event Espresso', 'admin bar menu group label', 'event_espresso') |
|
1067 | - . '</span>', |
|
1068 | - 'href' => $events_admin_url, |
|
1069 | - 'meta' => array( |
|
1070 | - 'title' => __('Event Espresso', 'event_espresso'), |
|
1071 | - 'class' => $menu_class . 'first', |
|
1072 | - ), |
|
1073 | - )); |
|
1074 | - //Events |
|
1075 | - if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events')) { |
|
1076 | - $admin_bar->add_menu(array( |
|
1077 | - 'id' => 'espresso-toolbar-events', |
|
1078 | - 'parent' => 'espresso-toolbar', |
|
1079 | - 'title' => __('Events', 'event_espresso'), |
|
1080 | - 'href' => $events_admin_url, |
|
1081 | - 'meta' => array( |
|
1082 | - 'title' => __('Events', 'event_espresso'), |
|
1083 | - 'target' => '', |
|
1084 | - 'class' => $menu_class, |
|
1085 | - ), |
|
1086 | - )); |
|
1087 | - } |
|
1088 | - if ($this->registry->CAP->current_user_can('ee_edit_events', 'ee_admin_bar_menu_espresso-toolbar-events-new')) { |
|
1089 | - //Events Add New |
|
1090 | - $admin_bar->add_menu(array( |
|
1091 | - 'id' => 'espresso-toolbar-events-new', |
|
1092 | - 'parent' => 'espresso-toolbar-events', |
|
1093 | - 'title' => __('Add New', 'event_espresso'), |
|
1094 | - 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'create_new'), $events_admin_url), |
|
1095 | - 'meta' => array( |
|
1096 | - 'title' => __('Add New', 'event_espresso'), |
|
1097 | - 'target' => '', |
|
1098 | - 'class' => $menu_class, |
|
1099 | - ), |
|
1100 | - )); |
|
1101 | - } |
|
1102 | - if (is_single() && (get_post_type() == 'espresso_events')) { |
|
1103 | - //Current post |
|
1104 | - global $post; |
|
1105 | - if ($this->registry->CAP->current_user_can('ee_edit_event', |
|
1106 | - 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID) |
|
1107 | - ) { |
|
1108 | - //Events Edit Current Event |
|
1109 | - $admin_bar->add_menu(array( |
|
1110 | - 'id' => 'espresso-toolbar-events-edit', |
|
1111 | - 'parent' => 'espresso-toolbar-events', |
|
1112 | - 'title' => __('Edit Event', 'event_espresso'), |
|
1113 | - 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'edit', 'post' => $post->ID), |
|
1114 | - $events_admin_url), |
|
1115 | - 'meta' => array( |
|
1116 | - 'title' => __('Edit Event', 'event_espresso'), |
|
1117 | - 'target' => '', |
|
1118 | - 'class' => $menu_class, |
|
1119 | - ), |
|
1120 | - )); |
|
1121 | - } |
|
1122 | - } |
|
1123 | - //Events View |
|
1124 | - if ($this->registry->CAP->current_user_can('ee_read_events', |
|
1125 | - 'ee_admin_bar_menu_espresso-toolbar-events-view') |
|
1126 | - ) { |
|
1127 | - $admin_bar->add_menu(array( |
|
1128 | - 'id' => 'espresso-toolbar-events-view', |
|
1129 | - 'parent' => 'espresso-toolbar-events', |
|
1130 | - 'title' => __('View', 'event_espresso'), |
|
1131 | - 'href' => $events_admin_url, |
|
1132 | - 'meta' => array( |
|
1133 | - 'title' => __('View', 'event_espresso'), |
|
1134 | - 'target' => '', |
|
1135 | - 'class' => $menu_class, |
|
1136 | - ), |
|
1137 | - )); |
|
1138 | - } |
|
1139 | - if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-all')) { |
|
1140 | - //Events View All |
|
1141 | - $admin_bar->add_menu(array( |
|
1142 | - 'id' => 'espresso-toolbar-events-all', |
|
1143 | - 'parent' => 'espresso-toolbar-events-view', |
|
1144 | - 'title' => __('All', 'event_espresso'), |
|
1145 | - 'href' => $events_admin_url, |
|
1146 | - 'meta' => array( |
|
1147 | - 'title' => __('All', 'event_espresso'), |
|
1148 | - 'target' => '', |
|
1149 | - 'class' => $menu_class, |
|
1150 | - ), |
|
1151 | - )); |
|
1152 | - } |
|
1153 | - if ($this->registry->CAP->current_user_can('ee_read_events', |
|
1154 | - 'ee_admin_bar_menu_espresso-toolbar-events-today') |
|
1155 | - ) { |
|
1156 | - //Events View Today |
|
1157 | - $admin_bar->add_menu(array( |
|
1158 | - 'id' => 'espresso-toolbar-events-today', |
|
1159 | - 'parent' => 'espresso-toolbar-events-view', |
|
1160 | - 'title' => __('Today', 'event_espresso'), |
|
1161 | - 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'today'), |
|
1162 | - $events_admin_url), |
|
1163 | - 'meta' => array( |
|
1164 | - 'title' => __('Today', 'event_espresso'), |
|
1165 | - 'target' => '', |
|
1166 | - 'class' => $menu_class, |
|
1167 | - ), |
|
1168 | - )); |
|
1169 | - } |
|
1170 | - if ($this->registry->CAP->current_user_can('ee_read_events', |
|
1171 | - 'ee_admin_bar_menu_espresso-toolbar-events-month') |
|
1172 | - ) { |
|
1173 | - //Events View This Month |
|
1174 | - $admin_bar->add_menu(array( |
|
1175 | - 'id' => 'espresso-toolbar-events-month', |
|
1176 | - 'parent' => 'espresso-toolbar-events-view', |
|
1177 | - 'title' => __('This Month', 'event_espresso'), |
|
1178 | - 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'month'), |
|
1179 | - $events_admin_url), |
|
1180 | - 'meta' => array( |
|
1181 | - 'title' => __('This Month', 'event_espresso'), |
|
1182 | - 'target' => '', |
|
1183 | - 'class' => $menu_class, |
|
1184 | - ), |
|
1185 | - )); |
|
1186 | - } |
|
1187 | - //Registration Overview |
|
1188 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1189 | - 'ee_admin_bar_menu_espresso-toolbar-registrations') |
|
1190 | - ) { |
|
1191 | - $admin_bar->add_menu(array( |
|
1192 | - 'id' => 'espresso-toolbar-registrations', |
|
1193 | - 'parent' => 'espresso-toolbar', |
|
1194 | - 'title' => __('Registrations', 'event_espresso'), |
|
1195 | - 'href' => $reg_admin_url, |
|
1196 | - 'meta' => array( |
|
1197 | - 'title' => __('Registrations', 'event_espresso'), |
|
1198 | - 'target' => '', |
|
1199 | - 'class' => $menu_class, |
|
1200 | - ), |
|
1201 | - )); |
|
1202 | - } |
|
1203 | - //Registration Overview Today |
|
1204 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1205 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-today') |
|
1206 | - ) { |
|
1207 | - $admin_bar->add_menu(array( |
|
1208 | - 'id' => 'espresso-toolbar-registrations-today', |
|
1209 | - 'parent' => 'espresso-toolbar-registrations', |
|
1210 | - 'title' => __('Today', 'event_espresso'), |
|
1211 | - 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'today'), |
|
1212 | - $reg_admin_url), |
|
1213 | - 'meta' => array( |
|
1214 | - 'title' => __('Today', 'event_espresso'), |
|
1215 | - 'target' => '', |
|
1216 | - 'class' => $menu_class, |
|
1217 | - ), |
|
1218 | - )); |
|
1219 | - } |
|
1220 | - //Registration Overview Today Completed |
|
1221 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1222 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved') |
|
1223 | - ) { |
|
1224 | - $admin_bar->add_menu(array( |
|
1225 | - 'id' => 'espresso-toolbar-registrations-today-approved', |
|
1226 | - 'parent' => 'espresso-toolbar-registrations-today', |
|
1227 | - 'title' => __('Approved', 'event_espresso'), |
|
1228 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1229 | - 'action' => 'default', |
|
1230 | - 'status' => 'today', |
|
1231 | - '_reg_status' => EEM_Registration::status_id_approved, |
|
1232 | - ), $reg_admin_url), |
|
1233 | - 'meta' => array( |
|
1234 | - 'title' => __('Approved', 'event_espresso'), |
|
1235 | - 'target' => '', |
|
1236 | - 'class' => $menu_class, |
|
1237 | - ), |
|
1238 | - )); |
|
1239 | - } |
|
1240 | - //Registration Overview Today Pending\ |
|
1241 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1242 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending') |
|
1243 | - ) { |
|
1244 | - $admin_bar->add_menu(array( |
|
1245 | - 'id' => 'espresso-toolbar-registrations-today-pending', |
|
1246 | - 'parent' => 'espresso-toolbar-registrations-today', |
|
1247 | - 'title' => __('Pending', 'event_espresso'), |
|
1248 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1249 | - 'action' => 'default', |
|
1250 | - 'status' => 'today', |
|
1251 | - 'reg_status' => EEM_Registration::status_id_pending_payment, |
|
1252 | - ), $reg_admin_url), |
|
1253 | - 'meta' => array( |
|
1254 | - 'title' => __('Pending Payment', 'event_espresso'), |
|
1255 | - 'target' => '', |
|
1256 | - 'class' => $menu_class, |
|
1257 | - ), |
|
1258 | - )); |
|
1259 | - } |
|
1260 | - //Registration Overview Today Incomplete |
|
1261 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1262 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved') |
|
1263 | - ) { |
|
1264 | - $admin_bar->add_menu(array( |
|
1265 | - 'id' => 'espresso-toolbar-registrations-today-not-approved', |
|
1266 | - 'parent' => 'espresso-toolbar-registrations-today', |
|
1267 | - 'title' => __('Not Approved', 'event_espresso'), |
|
1268 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1269 | - 'action' => 'default', |
|
1270 | - 'status' => 'today', |
|
1271 | - '_reg_status' => EEM_Registration::status_id_not_approved, |
|
1272 | - ), $reg_admin_url), |
|
1273 | - 'meta' => array( |
|
1274 | - 'title' => __('Not Approved', 'event_espresso'), |
|
1275 | - 'target' => '', |
|
1276 | - 'class' => $menu_class, |
|
1277 | - ), |
|
1278 | - )); |
|
1279 | - } |
|
1280 | - //Registration Overview Today Incomplete |
|
1281 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1282 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled') |
|
1283 | - ) { |
|
1284 | - $admin_bar->add_menu(array( |
|
1285 | - 'id' => 'espresso-toolbar-registrations-today-cancelled', |
|
1286 | - 'parent' => 'espresso-toolbar-registrations-today', |
|
1287 | - 'title' => __('Cancelled', 'event_espresso'), |
|
1288 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1289 | - 'action' => 'default', |
|
1290 | - 'status' => 'today', |
|
1291 | - '_reg_status' => EEM_Registration::status_id_cancelled, |
|
1292 | - ), $reg_admin_url), |
|
1293 | - 'meta' => array( |
|
1294 | - 'title' => __('Cancelled', 'event_espresso'), |
|
1295 | - 'target' => '', |
|
1296 | - 'class' => $menu_class, |
|
1297 | - ), |
|
1298 | - )); |
|
1299 | - } |
|
1300 | - //Registration Overview This Month |
|
1301 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1302 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-month') |
|
1303 | - ) { |
|
1304 | - $admin_bar->add_menu(array( |
|
1305 | - 'id' => 'espresso-toolbar-registrations-month', |
|
1306 | - 'parent' => 'espresso-toolbar-registrations', |
|
1307 | - 'title' => __('This Month', 'event_espresso'), |
|
1308 | - 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'month'), |
|
1309 | - $reg_admin_url), |
|
1310 | - 'meta' => array( |
|
1311 | - 'title' => __('This Month', 'event_espresso'), |
|
1312 | - 'target' => '', |
|
1313 | - 'class' => $menu_class, |
|
1314 | - ), |
|
1315 | - )); |
|
1316 | - } |
|
1317 | - //Registration Overview This Month Approved |
|
1318 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1319 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved') |
|
1320 | - ) { |
|
1321 | - $admin_bar->add_menu(array( |
|
1322 | - 'id' => 'espresso-toolbar-registrations-month-approved', |
|
1323 | - 'parent' => 'espresso-toolbar-registrations-month', |
|
1324 | - 'title' => __('Approved', 'event_espresso'), |
|
1325 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1326 | - 'action' => 'default', |
|
1327 | - 'status' => 'month', |
|
1328 | - '_reg_status' => EEM_Registration::status_id_approved, |
|
1329 | - ), $reg_admin_url), |
|
1330 | - 'meta' => array( |
|
1331 | - 'title' => __('Approved', 'event_espresso'), |
|
1332 | - 'target' => '', |
|
1333 | - 'class' => $menu_class, |
|
1334 | - ), |
|
1335 | - )); |
|
1336 | - } |
|
1337 | - //Registration Overview This Month Pending |
|
1338 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1339 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending') |
|
1340 | - ) { |
|
1341 | - $admin_bar->add_menu(array( |
|
1342 | - 'id' => 'espresso-toolbar-registrations-month-pending', |
|
1343 | - 'parent' => 'espresso-toolbar-registrations-month', |
|
1344 | - 'title' => __('Pending', 'event_espresso'), |
|
1345 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1346 | - 'action' => 'default', |
|
1347 | - 'status' => 'month', |
|
1348 | - '_reg_status' => EEM_Registration::status_id_pending_payment, |
|
1349 | - ), $reg_admin_url), |
|
1350 | - 'meta' => array( |
|
1351 | - 'title' => __('Pending', 'event_espresso'), |
|
1352 | - 'target' => '', |
|
1353 | - 'class' => $menu_class, |
|
1354 | - ), |
|
1355 | - )); |
|
1356 | - } |
|
1357 | - //Registration Overview This Month Not Approved |
|
1358 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1359 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved') |
|
1360 | - ) { |
|
1361 | - $admin_bar->add_menu(array( |
|
1362 | - 'id' => 'espresso-toolbar-registrations-month-not-approved', |
|
1363 | - 'parent' => 'espresso-toolbar-registrations-month', |
|
1364 | - 'title' => __('Not Approved', 'event_espresso'), |
|
1365 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1366 | - 'action' => 'default', |
|
1367 | - 'status' => 'month', |
|
1368 | - '_reg_status' => EEM_Registration::status_id_not_approved, |
|
1369 | - ), $reg_admin_url), |
|
1370 | - 'meta' => array( |
|
1371 | - 'title' => __('Not Approved', 'event_espresso'), |
|
1372 | - 'target' => '', |
|
1373 | - 'class' => $menu_class, |
|
1374 | - ), |
|
1375 | - )); |
|
1376 | - } |
|
1377 | - //Registration Overview This Month Cancelled |
|
1378 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1379 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled') |
|
1380 | - ) { |
|
1381 | - $admin_bar->add_menu(array( |
|
1382 | - 'id' => 'espresso-toolbar-registrations-month-cancelled', |
|
1383 | - 'parent' => 'espresso-toolbar-registrations-month', |
|
1384 | - 'title' => __('Cancelled', 'event_espresso'), |
|
1385 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1386 | - 'action' => 'default', |
|
1387 | - 'status' => 'month', |
|
1388 | - '_reg_status' => EEM_Registration::status_id_cancelled, |
|
1389 | - ), $reg_admin_url), |
|
1390 | - 'meta' => array( |
|
1391 | - 'title' => __('Cancelled', 'event_espresso'), |
|
1392 | - 'target' => '', |
|
1393 | - 'class' => $menu_class, |
|
1394 | - ), |
|
1395 | - )); |
|
1396 | - } |
|
1397 | - //Extensions & Services |
|
1398 | - if ($this->registry->CAP->current_user_can('ee_read_ee', |
|
1399 | - 'ee_admin_bar_menu_espresso-toolbar-extensions-and-services') |
|
1400 | - ) { |
|
1401 | - $admin_bar->add_menu(array( |
|
1402 | - 'id' => 'espresso-toolbar-extensions-and-services', |
|
1403 | - 'parent' => 'espresso-toolbar', |
|
1404 | - 'title' => __('Extensions & Services', 'event_espresso'), |
|
1405 | - 'href' => $extensions_admin_url, |
|
1406 | - 'meta' => array( |
|
1407 | - 'title' => __('Extensions & Services', 'event_espresso'), |
|
1408 | - 'target' => '', |
|
1409 | - 'class' => $menu_class, |
|
1410 | - ), |
|
1411 | - )); |
|
1412 | - } |
|
1413 | - } |
|
1414 | - |
|
1415 | - |
|
1416 | - |
|
1417 | - /** |
|
1418 | - * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are |
|
1419 | - * never returned with the function. |
|
1420 | - * |
|
1421 | - * @param array $exclude_array any existing pages being excluded are in this array. |
|
1422 | - * @return array |
|
1423 | - */ |
|
1424 | - public function remove_pages_from_wp_list_pages($exclude_array) |
|
1425 | - { |
|
1426 | - return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array()); |
|
1427 | - } |
|
1428 | - |
|
1429 | - |
|
1430 | - |
|
1431 | - |
|
1432 | - |
|
1433 | - |
|
1434 | - /*********************************************** WP_ENQUEUE_SCRIPTS HOOK ***********************************************/ |
|
1435 | - /** |
|
1436 | - * wp_enqueue_scripts |
|
1437 | - * |
|
1438 | - * @access public |
|
1439 | - * @return void |
|
1440 | - */ |
|
1441 | - public function wp_enqueue_scripts() |
|
1442 | - { |
|
1443 | - // unlike other systems, EE_System_scripts loading is turned ON by default, but prior to the init hook, can be turned off via: add_filter( 'FHEE_load_EE_System_scripts', '__return_false' ); |
|
1444 | - if (apply_filters('FHEE_load_EE_System_scripts', true)) { |
|
1445 | - // jquery_validate loading is turned OFF by default, but prior to the wp_enqueue_scripts hook, can be turned back on again via: add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
|
1446 | - if (apply_filters('FHEE_load_jquery_validate', false)) { |
|
1447 | - // register jQuery Validate and additional methods |
|
1448 | - wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
1449 | - array('jquery'), '1.15.0', true); |
|
1450 | - wp_register_script('jquery-validate-extra-methods', |
|
1451 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
1452 | - array('jquery', 'jquery-validate'), '1.15.0', true); |
|
1453 | - } |
|
1454 | - } |
|
1455 | - } |
|
22 | + /** |
|
23 | + * indicates this is a 'normal' request. Ie, not activation, nor upgrade, nor activation. |
|
24 | + * So examples of this would be a normal GET request on the frontend or backend, or a POST, etc |
|
25 | + */ |
|
26 | + const req_type_normal = 0; |
|
27 | + |
|
28 | + /** |
|
29 | + * Indicates this is a brand new installation of EE so we should install |
|
30 | + * tables and default data etc |
|
31 | + */ |
|
32 | + const req_type_new_activation = 1; |
|
33 | + |
|
34 | + /** |
|
35 | + * we've detected that EE has been reactivated (or EE was activated during maintenance mode, |
|
36 | + * and we just exited maintenance mode). We MUST check the database is setup properly |
|
37 | + * and that default data is setup too |
|
38 | + */ |
|
39 | + const req_type_reactivation = 2; |
|
40 | + |
|
41 | + /** |
|
42 | + * indicates that EE has been upgraded since its previous request. |
|
43 | + * We may have data migration scripts to call and will want to trigger maintenance mode |
|
44 | + */ |
|
45 | + const req_type_upgrade = 3; |
|
46 | + |
|
47 | + /** |
|
48 | + * TODO will detect that EE has been DOWNGRADED. We probably don't want to run in this case... |
|
49 | + */ |
|
50 | + const req_type_downgrade = 4; |
|
51 | + |
|
52 | + /** |
|
53 | + * @deprecated since version 4.6.0.dev.006 |
|
54 | + * Now whenever a new_activation is detected the request type is still just |
|
55 | + * new_activation (same for reactivation, upgrade, downgrade etc), but if we'r ein maintenance mode |
|
56 | + * EE_System::initialize_db_if_no_migrations_required and EE_Addon::initialize_db_if_no_migrations_required |
|
57 | + * will instead enqueue that EE plugin's db initialization for when we're taken out of maintenance mode. |
|
58 | + * (Specifically, when the migration manager indicates migrations are finished |
|
59 | + * EE_Data_Migration_Manager::initialize_db_for_enqueued_ee_plugins() will be called) |
|
60 | + */ |
|
61 | + const req_type_activation_but_not_installed = 5; |
|
62 | + |
|
63 | + /** |
|
64 | + * option prefix for recording the activation history (like core's "espresso_db_update") of addons |
|
65 | + */ |
|
66 | + const addon_activation_history_option_prefix = 'ee_addon_activation_history_'; |
|
67 | + |
|
68 | + |
|
69 | + /** |
|
70 | + * instance of the EE_System object |
|
71 | + * |
|
72 | + * @var $_instance |
|
73 | + * @access private |
|
74 | + */ |
|
75 | + private static $_instance = null; |
|
76 | + |
|
77 | + /** |
|
78 | + * @type EE_Registry $Registry |
|
79 | + * @access protected |
|
80 | + */ |
|
81 | + protected $registry; |
|
82 | + |
|
83 | + /** |
|
84 | + * Stores which type of request this is, options being one of the constants on EE_System starting with req_type_*. |
|
85 | + * It can be a brand-new activation, a reactivation, an upgrade, a downgrade, or a normal request. |
|
86 | + * |
|
87 | + * @var int |
|
88 | + */ |
|
89 | + private $_req_type; |
|
90 | + |
|
91 | + /** |
|
92 | + * Whether or not there was a non-micro version change in EE core version during this request |
|
93 | + * |
|
94 | + * @var boolean |
|
95 | + */ |
|
96 | + private $_major_version_change = false; |
|
97 | + |
|
98 | + |
|
99 | + |
|
100 | + /** |
|
101 | + * @singleton method used to instantiate class object |
|
102 | + * @access public |
|
103 | + * @param \EE_Registry $Registry |
|
104 | + * @return \EE_System |
|
105 | + */ |
|
106 | + public static function instance(EE_Registry $Registry = null) |
|
107 | + { |
|
108 | + // check if class object is instantiated |
|
109 | + if ( ! self::$_instance instanceof EE_System) { |
|
110 | + self::$_instance = new self($Registry); |
|
111 | + } |
|
112 | + return self::$_instance; |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + |
|
117 | + /** |
|
118 | + * resets the instance and returns it |
|
119 | + * |
|
120 | + * @return EE_System |
|
121 | + */ |
|
122 | + public static function reset() |
|
123 | + { |
|
124 | + self::$_instance->_req_type = null; |
|
125 | + //make sure none of the old hooks are left hanging around |
|
126 | + remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
127 | + //we need to reset the migration manager in order for it to detect DMSs properly |
|
128 | + EE_Data_Migration_Manager::reset(); |
|
129 | + self::instance()->detect_activations_or_upgrades(); |
|
130 | + self::instance()->perform_activations_upgrades_and_migrations(); |
|
131 | + return self::instance(); |
|
132 | + } |
|
133 | + |
|
134 | + |
|
135 | + |
|
136 | + /** |
|
137 | + * sets hooks for running rest of system |
|
138 | + * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point |
|
139 | + * starting EE Addons from any other point may lead to problems |
|
140 | + * |
|
141 | + * @access private |
|
142 | + * @param \EE_Registry $Registry |
|
143 | + */ |
|
144 | + private function __construct(EE_Registry $Registry) |
|
145 | + { |
|
146 | + $this->registry = $Registry; |
|
147 | + do_action('AHEE__EE_System__construct__begin', $this); |
|
148 | + // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc |
|
149 | + add_action('AHEE__EE_Bootstrap__load_espresso_addons', array($this, 'load_espresso_addons')); |
|
150 | + // when an ee addon is activated, we want to call the core hook(s) again |
|
151 | + // because the newly-activated addon didn't get a chance to run at all |
|
152 | + add_action('activate_plugin', array($this, 'load_espresso_addons'), 1); |
|
153 | + // detect whether install or upgrade |
|
154 | + add_action('AHEE__EE_Bootstrap__detect_activations_or_upgrades', array($this, 'detect_activations_or_upgrades'), |
|
155 | + 3); |
|
156 | + // load EE_Config, EE_Textdomain, etc |
|
157 | + add_action('AHEE__EE_Bootstrap__load_core_configuration', array($this, 'load_core_configuration'), 5); |
|
158 | + // load EE_Config, EE_Textdomain, etc |
|
159 | + add_action('AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', |
|
160 | + array($this, 'register_shortcodes_modules_and_widgets'), 7); |
|
161 | + // you wanna get going? I wanna get going... let's get going! |
|
162 | + add_action('AHEE__EE_Bootstrap__brew_espresso', array($this, 'brew_espresso'), 9); |
|
163 | + //other housekeeping |
|
164 | + //exclude EE critical pages from wp_list_pages |
|
165 | + add_filter('wp_list_pages_excludes', array($this, 'remove_pages_from_wp_list_pages'), 10); |
|
166 | + // ALL EE Addons should use the following hook point to attach their initial setup too |
|
167 | + // it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads |
|
168 | + do_action('AHEE__EE_System__construct__complete', $this); |
|
169 | + } |
|
170 | + |
|
171 | + |
|
172 | + |
|
173 | + /** |
|
174 | + * load_espresso_addons |
|
175 | + * allow addons to load first so that they can set hooks for running DMS's, etc |
|
176 | + * this is hooked into both: |
|
177 | + * 'AHEE__EE_Bootstrap__load_core_configuration' |
|
178 | + * which runs during the WP 'plugins_loaded' action at priority 5 |
|
179 | + * and the WP 'activate_plugin' hookpoint |
|
180 | + * |
|
181 | + * @access public |
|
182 | + * @return void |
|
183 | + */ |
|
184 | + public function load_espresso_addons() |
|
185 | + { |
|
186 | + // set autoloaders for all of the classes implementing EEI_Plugin_API |
|
187 | + // which provide helpers for EE plugin authors to more easily register certain components with EE. |
|
188 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api'); |
|
189 | + //load and setup EE_Capabilities |
|
190 | + $this->registry->load_core('Capabilities'); |
|
191 | + //caps need to be initialized on every request so that capability maps are set. |
|
192 | + //@see https://events.codebasehq.com/projects/event-espresso/tickets/8674 |
|
193 | + $this->registry->CAP->init_caps(); |
|
194 | + do_action('AHEE__EE_System__load_espresso_addons'); |
|
195 | + //if the WP API basic auth plugin isn't already loaded, load it now. |
|
196 | + //We want it for mobile apps. Just include the entire plugin |
|
197 | + //also, don't load the basic auth when a plugin is getting activated, because |
|
198 | + //it could be the basic auth plugin, and it doesn't check if its methods are already defined |
|
199 | + //and causes a fatal error |
|
200 | + if ( ! function_exists('json_basic_auth_handler') |
|
201 | + && ! function_exists('json_basic_auth_error') |
|
202 | + && ! ( |
|
203 | + isset($_GET['action']) |
|
204 | + && in_array($_GET['action'], array('activate', 'activate-selected')) |
|
205 | + ) |
|
206 | + && ! ( |
|
207 | + isset($_GET['activate']) |
|
208 | + && $_GET['activate'] === 'true' |
|
209 | + ) |
|
210 | + ) { |
|
211 | + include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php'; |
|
212 | + } |
|
213 | + do_action('AHEE__EE_System__load_espresso_addons__complete'); |
|
214 | + } |
|
215 | + |
|
216 | + |
|
217 | + |
|
218 | + /** |
|
219 | + * detect_activations_or_upgrades |
|
220 | + * Checks for activation or upgrade of core first; |
|
221 | + * then also checks if any registered addons have been activated or upgraded |
|
222 | + * This is hooked into 'AHEE__EE_Bootstrap__detect_activations_or_upgrades' |
|
223 | + * which runs during the WP 'plugins_loaded' action at priority 3 |
|
224 | + * |
|
225 | + * @access public |
|
226 | + * @return void |
|
227 | + */ |
|
228 | + public function detect_activations_or_upgrades() |
|
229 | + { |
|
230 | + //first off: let's make sure to handle core |
|
231 | + $this->detect_if_activation_or_upgrade(); |
|
232 | + foreach ($this->registry->addons as $addon) { |
|
233 | + //detect teh request type for that addon |
|
234 | + $addon->detect_activation_or_upgrade(); |
|
235 | + } |
|
236 | + } |
|
237 | + |
|
238 | + |
|
239 | + |
|
240 | + /** |
|
241 | + * detect_if_activation_or_upgrade |
|
242 | + * Takes care of detecting whether this is a brand new install or code upgrade, |
|
243 | + * and either setting up the DB or setting up maintenance mode etc. |
|
244 | + * |
|
245 | + * @access public |
|
246 | + * @return void |
|
247 | + */ |
|
248 | + public function detect_if_activation_or_upgrade() |
|
249 | + { |
|
250 | + do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin'); |
|
251 | + // load M-Mode class |
|
252 | + $this->registry->load_core('Maintenance_Mode'); |
|
253 | + // check if db has been updated, or if its a brand-new installation |
|
254 | + $espresso_db_update = $this->fix_espresso_db_upgrade_option(); |
|
255 | + $request_type = $this->detect_req_type($espresso_db_update); |
|
256 | + //EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ ); |
|
257 | + switch ($request_type) { |
|
258 | + case EE_System::req_type_new_activation: |
|
259 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation'); |
|
260 | + $this->_handle_core_version_change($espresso_db_update); |
|
261 | + break; |
|
262 | + case EE_System::req_type_reactivation: |
|
263 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation'); |
|
264 | + $this->_handle_core_version_change($espresso_db_update); |
|
265 | + break; |
|
266 | + case EE_System::req_type_upgrade: |
|
267 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade'); |
|
268 | + //migrations may be required now that we've upgraded |
|
269 | + EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
270 | + $this->_handle_core_version_change($espresso_db_update); |
|
271 | + // echo "done upgrade";die; |
|
272 | + break; |
|
273 | + case EE_System::req_type_downgrade: |
|
274 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade'); |
|
275 | + //its possible migrations are no longer required |
|
276 | + EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
277 | + $this->_handle_core_version_change($espresso_db_update); |
|
278 | + break; |
|
279 | + case EE_System::req_type_normal: |
|
280 | + default: |
|
281 | + // $this->_maybe_redirect_to_ee_about(); |
|
282 | + break; |
|
283 | + } |
|
284 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete'); |
|
285 | + } |
|
286 | + |
|
287 | + |
|
288 | + |
|
289 | + /** |
|
290 | + * Updates the list of installed versions and sets hooks for |
|
291 | + * initializing the database later during the request |
|
292 | + * |
|
293 | + * @param array $espresso_db_update |
|
294 | + */ |
|
295 | + protected function _handle_core_version_change($espresso_db_update) |
|
296 | + { |
|
297 | + $this->update_list_of_installed_versions($espresso_db_update); |
|
298 | + //get ready to verify the DB is ok (provided we aren't in maintenance mode, of course) |
|
299 | + add_action('AHEE__EE_System__perform_activations_upgrades_and_migrations', |
|
300 | + array($this, 'initialize_db_if_no_migrations_required')); |
|
301 | + } |
|
302 | + |
|
303 | + |
|
304 | + |
|
305 | + /** |
|
306 | + * standardizes the wp option 'espresso_db_upgrade' which actually stores |
|
307 | + * information about what versions of EE have been installed and activated, |
|
308 | + * NOT necessarily the state of the database |
|
309 | + * |
|
310 | + * @param null $espresso_db_update |
|
311 | + * @internal param array $espresso_db_update_value the value of the WordPress option. If not supplied, fetches it |
|
312 | + * from the options table |
|
313 | + * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction |
|
314 | + */ |
|
315 | + private function fix_espresso_db_upgrade_option($espresso_db_update = null) |
|
316 | + { |
|
317 | + do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update); |
|
318 | + if ( ! $espresso_db_update) { |
|
319 | + $espresso_db_update = get_option('espresso_db_update'); |
|
320 | + } |
|
321 | + // check that option is an array |
|
322 | + if ( ! is_array($espresso_db_update)) { |
|
323 | + // if option is FALSE, then it never existed |
|
324 | + if ($espresso_db_update === false) { |
|
325 | + // make $espresso_db_update an array and save option with autoload OFF |
|
326 | + $espresso_db_update = array(); |
|
327 | + add_option('espresso_db_update', $espresso_db_update, '', 'no'); |
|
328 | + } else { |
|
329 | + // option is NOT FALSE but also is NOT an array, so make it an array and save it |
|
330 | + $espresso_db_update = array($espresso_db_update => array()); |
|
331 | + update_option('espresso_db_update', $espresso_db_update); |
|
332 | + } |
|
333 | + } else { |
|
334 | + $corrected_db_update = array(); |
|
335 | + //if IS an array, but is it an array where KEYS are version numbers, and values are arrays? |
|
336 | + foreach ($espresso_db_update as $should_be_version_string => $should_be_array) { |
|
337 | + if (is_int($should_be_version_string) && ! is_array($should_be_array)) { |
|
338 | + //the key is an int, and the value IS NOT an array |
|
339 | + //so it must be numerically-indexed, where values are versions installed... |
|
340 | + //fix it! |
|
341 | + $version_string = $should_be_array; |
|
342 | + $corrected_db_update[$version_string] = array('unknown-date'); |
|
343 | + } else { |
|
344 | + //ok it checks out |
|
345 | + $corrected_db_update[$should_be_version_string] = $should_be_array; |
|
346 | + } |
|
347 | + } |
|
348 | + $espresso_db_update = $corrected_db_update; |
|
349 | + update_option('espresso_db_update', $espresso_db_update); |
|
350 | + } |
|
351 | + do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update); |
|
352 | + return $espresso_db_update; |
|
353 | + } |
|
354 | + |
|
355 | + |
|
356 | + |
|
357 | + /** |
|
358 | + * Does the traditional work of setting up the plugin's database and adding default data. |
|
359 | + * If migration script/process did not exist, this is what would happen on every activation/reactivation/upgrade. |
|
360 | + * NOTE: if we're in maintenance mode (which would be the case if we detect there are data |
|
361 | + * migration scripts that need to be run and a version change happens), enqueues core for database initialization, |
|
362 | + * so that it will be done when migrations are finished |
|
363 | + * |
|
364 | + * @param boolean $initialize_addons_too if true, we double-check addons' database tables etc too; |
|
365 | + * @param boolean $verify_schema if true will re-check the database tables have the correct schema. |
|
366 | + * This is a resource-intensive job |
|
367 | + * so we prefer to only do it when necessary |
|
368 | + * @return void |
|
369 | + */ |
|
370 | + public function initialize_db_if_no_migrations_required($initialize_addons_too = false, $verify_schema = true) |
|
371 | + { |
|
372 | + $request_type = $this->detect_req_type(); |
|
373 | + //only initialize system if we're not in maintenance mode. |
|
374 | + if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
375 | + update_option('ee_flush_rewrite_rules', true); |
|
376 | + if ($verify_schema) { |
|
377 | + EEH_Activation::initialize_db_and_folders(); |
|
378 | + } |
|
379 | + EEH_Activation::initialize_db_content(); |
|
380 | + EEH_Activation::system_initialization(); |
|
381 | + if ($initialize_addons_too) { |
|
382 | + $this->initialize_addons(); |
|
383 | + } |
|
384 | + } else { |
|
385 | + EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core'); |
|
386 | + } |
|
387 | + if ($request_type === EE_System::req_type_new_activation |
|
388 | + || $request_type === EE_System::req_type_reactivation |
|
389 | + || ( |
|
390 | + $request_type === EE_System::req_type_upgrade |
|
391 | + && $this->is_major_version_change() |
|
392 | + ) |
|
393 | + ) { |
|
394 | + add_action('AHEE__EE_System__initialize_last', array($this, 'redirect_to_about_ee'), 9); |
|
395 | + } |
|
396 | + } |
|
397 | + |
|
398 | + |
|
399 | + |
|
400 | + /** |
|
401 | + * Initializes the db for all registered addons |
|
402 | + */ |
|
403 | + public function initialize_addons() |
|
404 | + { |
|
405 | + //foreach registered addon, make sure its db is up-to-date too |
|
406 | + foreach ($this->registry->addons as $addon) { |
|
407 | + $addon->initialize_db_if_no_migrations_required(); |
|
408 | + } |
|
409 | + } |
|
410 | + |
|
411 | + |
|
412 | + |
|
413 | + /** |
|
414 | + * Adds the current code version to the saved wp option which stores a list of all ee versions ever installed. |
|
415 | + * |
|
416 | + * @param array $version_history |
|
417 | + * @param string $current_version_to_add version to be added to the version history |
|
418 | + * @return boolean success as to whether or not this option was changed |
|
419 | + */ |
|
420 | + public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null) |
|
421 | + { |
|
422 | + if ( ! $version_history) { |
|
423 | + $version_history = $this->fix_espresso_db_upgrade_option($version_history); |
|
424 | + } |
|
425 | + if ($current_version_to_add == null) { |
|
426 | + $current_version_to_add = espresso_version(); |
|
427 | + } |
|
428 | + $version_history[$current_version_to_add][] = date('Y-m-d H:i:s', time()); |
|
429 | + // re-save |
|
430 | + return update_option('espresso_db_update', $version_history); |
|
431 | + } |
|
432 | + |
|
433 | + |
|
434 | + |
|
435 | + /** |
|
436 | + * Detects if the current version indicated in the has existed in the list of |
|
437 | + * previously-installed versions of EE (espresso_db_update). Does NOT modify it (ie, no side-effect) |
|
438 | + * |
|
439 | + * @param array $espresso_db_update array from the wp option stored under the name 'espresso_db_update'. |
|
440 | + * If not supplied, fetches it from the options table. |
|
441 | + * Also, caches its result so later parts of the code can also know whether |
|
442 | + * there's been an update or not. This way we can add the current version to |
|
443 | + * espresso_db_update, but still know if this is a new install or not |
|
444 | + * @return int one of the constants on EE_System::req_type_ |
|
445 | + */ |
|
446 | + public function detect_req_type($espresso_db_update = null) |
|
447 | + { |
|
448 | + if ($this->_req_type === null) { |
|
449 | + $espresso_db_update = ! empty($espresso_db_update) ? $espresso_db_update |
|
450 | + : $this->fix_espresso_db_upgrade_option(); |
|
451 | + $this->_req_type = $this->detect_req_type_given_activation_history($espresso_db_update, |
|
452 | + 'ee_espresso_activation', espresso_version()); |
|
453 | + $this->_major_version_change = $this->_detect_major_version_change($espresso_db_update); |
|
454 | + } |
|
455 | + return $this->_req_type; |
|
456 | + } |
|
457 | + |
|
458 | + |
|
459 | + |
|
460 | + /** |
|
461 | + * Returns whether or not there was a non-micro version change (ie, change in either |
|
462 | + * the first or second number in the version. Eg 4.9.0.rc.001 to 4.10.0.rc.000, |
|
463 | + * but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
|
464 | + * |
|
465 | + * @param $activation_history |
|
466 | + * @return bool |
|
467 | + */ |
|
468 | + protected function _detect_major_version_change($activation_history) |
|
469 | + { |
|
470 | + $previous_version = EE_System::_get_most_recently_active_version_from_activation_history($activation_history); |
|
471 | + $previous_version_parts = explode('.', $previous_version); |
|
472 | + $current_version_parts = explode('.', espresso_version()); |
|
473 | + return isset($previous_version_parts[0], $previous_version_parts[1], $current_version_parts[0], $current_version_parts[1]) |
|
474 | + && ($previous_version_parts[0] !== $current_version_parts[0] |
|
475 | + || $previous_version_parts[1] !== $current_version_parts[1] |
|
476 | + ); |
|
477 | + } |
|
478 | + |
|
479 | + |
|
480 | + |
|
481 | + /** |
|
482 | + * Returns true if either the major or minor version of EE changed during this request. |
|
483 | + * Eg 4.9.0.rc.001 to 4.10.0.rc.000, but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
|
484 | + * |
|
485 | + * @return bool |
|
486 | + */ |
|
487 | + public function is_major_version_change() |
|
488 | + { |
|
489 | + return $this->_major_version_change; |
|
490 | + } |
|
491 | + |
|
492 | + |
|
493 | + |
|
494 | + /** |
|
495 | + * Determines the request type for any ee addon, given three piece of info: the current array of activation |
|
496 | + * histories (for core that' 'espresso_db_update' wp option); the name of the wordpress option which is temporarily |
|
497 | + * set upon activation of the plugin (for core it's 'ee_espresso_activation'); and the version that this plugin was |
|
498 | + * just activated to (for core that will always be espresso_version()) |
|
499 | + * |
|
500 | + * @param array $activation_history_for_addon the option's value which stores the activation history for this |
|
501 | + * ee plugin. for core that's 'espresso_db_update' |
|
502 | + * @param string $activation_indicator_option_name the name of the wordpress option that is temporarily set to |
|
503 | + * indicate that this plugin was just activated |
|
504 | + * @param string $version_to_upgrade_to the version that was just upgraded to (for core that will be |
|
505 | + * espresso_version()) |
|
506 | + * @return int one of the constants on EE_System::req_type_* |
|
507 | + */ |
|
508 | + public static function detect_req_type_given_activation_history( |
|
509 | + $activation_history_for_addon, |
|
510 | + $activation_indicator_option_name, |
|
511 | + $version_to_upgrade_to |
|
512 | + ) { |
|
513 | + $version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to); |
|
514 | + if ($activation_history_for_addon) { |
|
515 | + //it exists, so this isn't a completely new install |
|
516 | + //check if this version already in that list of previously installed versions |
|
517 | + if ( ! isset($activation_history_for_addon[$version_to_upgrade_to])) { |
|
518 | + //it a version we haven't seen before |
|
519 | + if ($version_is_higher === 1) { |
|
520 | + $req_type = EE_System::req_type_upgrade; |
|
521 | + } else { |
|
522 | + $req_type = EE_System::req_type_downgrade; |
|
523 | + } |
|
524 | + delete_option($activation_indicator_option_name); |
|
525 | + } else { |
|
526 | + // its not an update. maybe a reactivation? |
|
527 | + if (get_option($activation_indicator_option_name, false)) { |
|
528 | + if ($version_is_higher === -1) { |
|
529 | + $req_type = EE_System::req_type_downgrade; |
|
530 | + } elseif ($version_is_higher === 0) { |
|
531 | + //we've seen this version before, but it's an activation. must be a reactivation |
|
532 | + $req_type = EE_System::req_type_reactivation; |
|
533 | + } else {//$version_is_higher === 1 |
|
534 | + $req_type = EE_System::req_type_upgrade; |
|
535 | + } |
|
536 | + delete_option($activation_indicator_option_name); |
|
537 | + } else { |
|
538 | + //we've seen this version before and the activation indicate doesn't show it was just activated |
|
539 | + if ($version_is_higher === -1) { |
|
540 | + $req_type = EE_System::req_type_downgrade; |
|
541 | + } elseif ($version_is_higher === 0) { |
|
542 | + //we've seen this version before and it's not an activation. its normal request |
|
543 | + $req_type = EE_System::req_type_normal; |
|
544 | + } else {//$version_is_higher === 1 |
|
545 | + $req_type = EE_System::req_type_upgrade; |
|
546 | + } |
|
547 | + } |
|
548 | + } |
|
549 | + } else { |
|
550 | + //brand new install |
|
551 | + $req_type = EE_System::req_type_new_activation; |
|
552 | + delete_option($activation_indicator_option_name); |
|
553 | + } |
|
554 | + return $req_type; |
|
555 | + } |
|
556 | + |
|
557 | + |
|
558 | + |
|
559 | + /** |
|
560 | + * Detects if the $version_to_upgrade_to is higher than the most recent version in |
|
561 | + * the $activation_history_for_addon |
|
562 | + * |
|
563 | + * @param array $activation_history_for_addon (keys are versions, values are arrays of times activated, |
|
564 | + * sometimes containing 'unknown-date' |
|
565 | + * @param string $version_to_upgrade_to (current version) |
|
566 | + * @return int results of version_compare( $version_to_upgrade_to, $most_recently_active_version ). |
|
567 | + * ie, -1 if $version_to_upgrade_to is LOWER (downgrade); |
|
568 | + * 0 if $version_to_upgrade_to MATCHES (reactivation or normal request); |
|
569 | + * 1 if $version_to_upgrade_to is HIGHER (upgrade) ; |
|
570 | + */ |
|
571 | + protected static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to) |
|
572 | + { |
|
573 | + //find the most recently-activated version |
|
574 | + $most_recently_active_version = EE_System::_get_most_recently_active_version_from_activation_history($activation_history_for_addon); |
|
575 | + return version_compare($version_to_upgrade_to, $most_recently_active_version); |
|
576 | + } |
|
577 | + |
|
578 | + |
|
579 | + |
|
580 | + /** |
|
581 | + * Gets the most recently active version listed in the activation history, |
|
582 | + * and if none are found (ie, it's a brand new install) returns '0.0.0.dev.000'. |
|
583 | + * |
|
584 | + * @param array $activation_history (keys are versions, values are arrays of times activated, |
|
585 | + * sometimes containing 'unknown-date' |
|
586 | + * @return string |
|
587 | + */ |
|
588 | + protected static function _get_most_recently_active_version_from_activation_history($activation_history) |
|
589 | + { |
|
590 | + $most_recently_active_version_activation = '1970-01-01 00:00:00'; |
|
591 | + $most_recently_active_version = '0.0.0.dev.000'; |
|
592 | + if (is_array($activation_history)) { |
|
593 | + foreach ($activation_history as $version => $times_activated) { |
|
594 | + //check there is a record of when this version was activated. Otherwise, |
|
595 | + //mark it as unknown |
|
596 | + if ( ! $times_activated) { |
|
597 | + $times_activated = array('unknown-date'); |
|
598 | + } |
|
599 | + if (is_string($times_activated)) { |
|
600 | + $times_activated = array($times_activated); |
|
601 | + } |
|
602 | + foreach ($times_activated as $an_activation) { |
|
603 | + if ($an_activation != 'unknown-date' && $an_activation > $most_recently_active_version_activation) { |
|
604 | + $most_recently_active_version = $version; |
|
605 | + $most_recently_active_version_activation = $an_activation == 'unknown-date' |
|
606 | + ? '1970-01-01 00:00:00' : $an_activation; |
|
607 | + } |
|
608 | + } |
|
609 | + } |
|
610 | + } |
|
611 | + return $most_recently_active_version; |
|
612 | + } |
|
613 | + |
|
614 | + |
|
615 | + |
|
616 | + /** |
|
617 | + * This redirects to the about EE page after activation |
|
618 | + * |
|
619 | + * @return void |
|
620 | + */ |
|
621 | + public function redirect_to_about_ee() |
|
622 | + { |
|
623 | + $notices = EE_Error::get_notices(false); |
|
624 | + //if current user is an admin and it's not an ajax or rest request |
|
625 | + if ( |
|
626 | + ! (defined('DOING_AJAX') && DOING_AJAX) |
|
627 | + && ! (defined('REST_REQUEST') && REST_REQUEST) |
|
628 | + && ! isset($notices['errors']) |
|
629 | + && apply_filters( |
|
630 | + 'FHEE__EE_System__redirect_to_about_ee__do_redirect', |
|
631 | + $this->registry->CAP->current_user_can('manage_options', 'espresso_about_default') |
|
632 | + ) |
|
633 | + ) { |
|
634 | + $query_params = array('page' => 'espresso_about'); |
|
635 | + if (EE_System::instance()->detect_req_type() == EE_System::req_type_new_activation) { |
|
636 | + $query_params['new_activation'] = true; |
|
637 | + } |
|
638 | + if (EE_System::instance()->detect_req_type() == EE_System::req_type_reactivation) { |
|
639 | + $query_params['reactivation'] = true; |
|
640 | + } |
|
641 | + $url = add_query_arg($query_params, admin_url('admin.php')); |
|
642 | + wp_safe_redirect($url); |
|
643 | + exit(); |
|
644 | + } |
|
645 | + } |
|
646 | + |
|
647 | + |
|
648 | + |
|
649 | + /** |
|
650 | + * load_core_configuration |
|
651 | + * this is hooked into 'AHEE__EE_Bootstrap__load_core_configuration' |
|
652 | + * which runs during the WP 'plugins_loaded' action at priority 5 |
|
653 | + * |
|
654 | + * @return void |
|
655 | + */ |
|
656 | + public function load_core_configuration() |
|
657 | + { |
|
658 | + do_action('AHEE__EE_System__load_core_configuration__begin', $this); |
|
659 | + $this->registry->load_core('EE_Load_Textdomain'); |
|
660 | + //load textdomain |
|
661 | + EE_Load_Textdomain::load_textdomain(); |
|
662 | + // load and setup EE_Config and EE_Network_Config |
|
663 | + $this->registry->load_core('Config'); |
|
664 | + $this->registry->load_core('Network_Config'); |
|
665 | + // setup autoloaders |
|
666 | + // enable logging? |
|
667 | + if ($this->registry->CFG->admin->use_full_logging) { |
|
668 | + $this->registry->load_core('Log'); |
|
669 | + } |
|
670 | + // check for activation errors |
|
671 | + $activation_errors = get_option('ee_plugin_activation_errors', false); |
|
672 | + if ($activation_errors) { |
|
673 | + EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__); |
|
674 | + update_option('ee_plugin_activation_errors', false); |
|
675 | + } |
|
676 | + // get model names |
|
677 | + $this->_parse_model_names(); |
|
678 | + //load caf stuff a chance to play during the activation process too. |
|
679 | + $this->_maybe_brew_regular(); |
|
680 | + do_action('AHEE__EE_System__load_core_configuration__complete', $this); |
|
681 | + } |
|
682 | + |
|
683 | + |
|
684 | + |
|
685 | + /** |
|
686 | + * cycles through all of the models/*.model.php files, and assembles an array of model names |
|
687 | + * |
|
688 | + * @return void |
|
689 | + */ |
|
690 | + private function _parse_model_names() |
|
691 | + { |
|
692 | + //get all the files in the EE_MODELS folder that end in .model.php |
|
693 | + $models = glob(EE_MODELS . '*.model.php'); |
|
694 | + $model_names = array(); |
|
695 | + $non_abstract_db_models = array(); |
|
696 | + foreach ($models as $model) { |
|
697 | + // get model classname |
|
698 | + $classname = EEH_File::get_classname_from_filepath_with_standard_filename($model); |
|
699 | + $short_name = str_replace('EEM_', '', $classname); |
|
700 | + $reflectionClass = new ReflectionClass($classname); |
|
701 | + if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) { |
|
702 | + $non_abstract_db_models[$short_name] = $classname; |
|
703 | + } |
|
704 | + $model_names[$short_name] = $classname; |
|
705 | + } |
|
706 | + $this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names); |
|
707 | + $this->registry->non_abstract_db_models = apply_filters('FHEE__EE_System__parse_implemented_model_names', |
|
708 | + $non_abstract_db_models); |
|
709 | + } |
|
710 | + |
|
711 | + |
|
712 | + |
|
713 | + /** |
|
714 | + * The purpose of this method is to simply check for a file named "caffeinated/brewing_regular.php" for any hooks |
|
715 | + * that need to be setup before our EE_System launches. |
|
716 | + * |
|
717 | + * @return void |
|
718 | + */ |
|
719 | + private function _maybe_brew_regular() |
|
720 | + { |
|
721 | + if (( ! defined('EE_DECAF') || EE_DECAF !== true) && is_readable(EE_CAFF_PATH . 'brewing_regular.php')) { |
|
722 | + require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
723 | + } |
|
724 | + } |
|
725 | + |
|
726 | + |
|
727 | + |
|
728 | + /** |
|
729 | + * register_shortcodes_modules_and_widgets |
|
730 | + * generate lists of shortcodes and modules, then verify paths and classes |
|
731 | + * This is hooked into 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets' |
|
732 | + * which runs during the WP 'plugins_loaded' action at priority 7 |
|
733 | + * |
|
734 | + * @access public |
|
735 | + * @return void |
|
736 | + */ |
|
737 | + public function register_shortcodes_modules_and_widgets() |
|
738 | + { |
|
739 | + try { |
|
740 | + // load, register, and add shortcodes the new way |
|
741 | + new ShortcodesManager( |
|
742 | + // and the old way, but we'll put it under control of the new system |
|
743 | + EE_Config::getLegacyShortcodesManager() |
|
744 | + ); |
|
745 | + } catch (Exception $exception) { |
|
746 | + new ExceptionStackTraceDisplay($exception); |
|
747 | + } |
|
748 | + do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets'); |
|
749 | + // check for addons using old hookpoint |
|
750 | + if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) { |
|
751 | + $this->_incompatible_addon_error(); |
|
752 | + } |
|
753 | + } |
|
754 | + |
|
755 | + |
|
756 | + |
|
757 | + /** |
|
758 | + * _incompatible_addon_error |
|
759 | + * |
|
760 | + * @access public |
|
761 | + * @return void |
|
762 | + */ |
|
763 | + private function _incompatible_addon_error() |
|
764 | + { |
|
765 | + // get array of classes hooking into here |
|
766 | + $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook('AHEE__EE_System__register_shortcodes_modules_and_addons'); |
|
767 | + if ( ! empty($class_names)) { |
|
768 | + $msg = __('The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', |
|
769 | + 'event_espresso'); |
|
770 | + $msg .= '<ul>'; |
|
771 | + foreach ($class_names as $class_name) { |
|
772 | + $msg .= '<li><b>Event Espresso - ' . str_replace(array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '', |
|
773 | + $class_name) . '</b></li>'; |
|
774 | + } |
|
775 | + $msg .= '</ul>'; |
|
776 | + $msg .= __('Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', |
|
777 | + 'event_espresso'); |
|
778 | + // save list of incompatible addons to wp-options for later use |
|
779 | + add_option('ee_incompatible_addons', $class_names, '', 'no'); |
|
780 | + if (is_admin()) { |
|
781 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
782 | + } |
|
783 | + } |
|
784 | + } |
|
785 | + |
|
786 | + |
|
787 | + |
|
788 | + /** |
|
789 | + * brew_espresso |
|
790 | + * begins the process of setting hooks for initializing EE in the correct order |
|
791 | + * This is happening on the 'AHEE__EE_Bootstrap__brew_espresso' hookpoint |
|
792 | + * which runs during the WP 'plugins_loaded' action at priority 9 |
|
793 | + * |
|
794 | + * @return void |
|
795 | + */ |
|
796 | + public function brew_espresso() |
|
797 | + { |
|
798 | + do_action('AHEE__EE_System__brew_espresso__begin', $this); |
|
799 | + // load some final core systems |
|
800 | + add_action('init', array($this, 'set_hooks_for_core'), 1); |
|
801 | + add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3); |
|
802 | + add_action('init', array($this, 'load_CPTs_and_session'), 5); |
|
803 | + add_action('init', array($this, 'load_controllers'), 7); |
|
804 | + add_action('init', array($this, 'core_loaded_and_ready'), 9); |
|
805 | + add_action('init', array($this, 'initialize'), 10); |
|
806 | + add_action('init', array($this, 'initialize_last'), 100); |
|
807 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 100); |
|
808 | + add_action('admin_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 100); |
|
809 | + add_action('admin_bar_menu', array($this, 'espresso_toolbar_items'), 100); |
|
810 | + if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', true)) { |
|
811 | + // pew pew pew |
|
812 | + $this->registry->load_core('PUE'); |
|
813 | + do_action('AHEE__EE_System__brew_espresso__after_pue_init'); |
|
814 | + } |
|
815 | + do_action('AHEE__EE_System__brew_espresso__complete', $this); |
|
816 | + } |
|
817 | + |
|
818 | + |
|
819 | + |
|
820 | + /** |
|
821 | + * set_hooks_for_core |
|
822 | + * |
|
823 | + * @access public |
|
824 | + * @return void |
|
825 | + */ |
|
826 | + public function set_hooks_for_core() |
|
827 | + { |
|
828 | + $this->_deactivate_incompatible_addons(); |
|
829 | + do_action('AHEE__EE_System__set_hooks_for_core'); |
|
830 | + } |
|
831 | + |
|
832 | + |
|
833 | + |
|
834 | + /** |
|
835 | + * Using the information gathered in EE_System::_incompatible_addon_error, |
|
836 | + * deactivates any addons considered incompatible with the current version of EE |
|
837 | + */ |
|
838 | + private function _deactivate_incompatible_addons() |
|
839 | + { |
|
840 | + $incompatible_addons = get_option('ee_incompatible_addons', array()); |
|
841 | + if ( ! empty($incompatible_addons)) { |
|
842 | + $active_plugins = get_option('active_plugins', array()); |
|
843 | + foreach ($active_plugins as $active_plugin) { |
|
844 | + foreach ($incompatible_addons as $incompatible_addon) { |
|
845 | + if (strpos($active_plugin, $incompatible_addon) !== false) { |
|
846 | + unset($_GET['activate']); |
|
847 | + espresso_deactivate_plugin($active_plugin); |
|
848 | + } |
|
849 | + } |
|
850 | + } |
|
851 | + } |
|
852 | + } |
|
853 | + |
|
854 | + |
|
855 | + |
|
856 | + /** |
|
857 | + * perform_activations_upgrades_and_migrations |
|
858 | + * |
|
859 | + * @access public |
|
860 | + * @return void |
|
861 | + */ |
|
862 | + public function perform_activations_upgrades_and_migrations() |
|
863 | + { |
|
864 | + //first check if we had previously attempted to setup EE's directories but failed |
|
865 | + if (EEH_Activation::upload_directories_incomplete()) { |
|
866 | + EEH_Activation::create_upload_directories(); |
|
867 | + } |
|
868 | + do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
869 | + } |
|
870 | + |
|
871 | + |
|
872 | + |
|
873 | + /** |
|
874 | + * load_CPTs_and_session |
|
875 | + * |
|
876 | + * @access public |
|
877 | + * @return void |
|
878 | + */ |
|
879 | + public function load_CPTs_and_session() |
|
880 | + { |
|
881 | + do_action('AHEE__EE_System__load_CPTs_and_session__start'); |
|
882 | + // register Custom Post Types |
|
883 | + $this->registry->load_core('Register_CPTs'); |
|
884 | + do_action('AHEE__EE_System__load_CPTs_and_session__complete'); |
|
885 | + } |
|
886 | + |
|
887 | + |
|
888 | + |
|
889 | + /** |
|
890 | + * load_controllers |
|
891 | + * this is the best place to load any additional controllers that needs access to EE core. |
|
892 | + * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this |
|
893 | + * time |
|
894 | + * |
|
895 | + * @access public |
|
896 | + * @return void |
|
897 | + */ |
|
898 | + public function load_controllers() |
|
899 | + { |
|
900 | + do_action('AHEE__EE_System__load_controllers__start'); |
|
901 | + // let's get it started |
|
902 | + if ( ! is_admin() && ! EE_Maintenance_Mode::instance()->level()) { |
|
903 | + do_action('AHEE__EE_System__load_controllers__load_front_controllers'); |
|
904 | + $this->registry->load_core('Front_Controller'); |
|
905 | + } else if ( ! EE_FRONT_AJAX) { |
|
906 | + do_action('AHEE__EE_System__load_controllers__load_admin_controllers'); |
|
907 | + EE_Registry::instance()->load_core('Admin'); |
|
908 | + } |
|
909 | + do_action('AHEE__EE_System__load_controllers__complete'); |
|
910 | + } |
|
911 | + |
|
912 | + |
|
913 | + |
|
914 | + /** |
|
915 | + * core_loaded_and_ready |
|
916 | + * all of the basic EE core should be loaded at this point and available regardless of M-Mode |
|
917 | + * |
|
918 | + * @access public |
|
919 | + * @return void |
|
920 | + */ |
|
921 | + public function core_loaded_and_ready() |
|
922 | + { |
|
923 | + do_action('AHEE__EE_System__core_loaded_and_ready'); |
|
924 | + // load_espresso_template_tags |
|
925 | + if (is_readable(EE_PUBLIC . 'template_tags.php')) { |
|
926 | + require_once(EE_PUBLIC . 'template_tags.php'); |
|
927 | + } |
|
928 | + do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons'); |
|
929 | + $this->registry->load_core('Session'); |
|
930 | + } |
|
931 | + |
|
932 | + |
|
933 | + |
|
934 | + /** |
|
935 | + * initialize |
|
936 | + * this is the best place to begin initializing client code |
|
937 | + * |
|
938 | + * @access public |
|
939 | + * @return void |
|
940 | + */ |
|
941 | + public function initialize() |
|
942 | + { |
|
943 | + do_action('AHEE__EE_System__initialize'); |
|
944 | + } |
|
945 | + |
|
946 | + |
|
947 | + |
|
948 | + /** |
|
949 | + * initialize_last |
|
950 | + * this is run really late during the WP init hookpoint, and ensures that mostly everything else that needs to |
|
951 | + * initialize has done so |
|
952 | + * |
|
953 | + * @access public |
|
954 | + * @return void |
|
955 | + */ |
|
956 | + public function initialize_last() |
|
957 | + { |
|
958 | + do_action('AHEE__EE_System__initialize_last'); |
|
959 | + } |
|
960 | + |
|
961 | + |
|
962 | + |
|
963 | + /** |
|
964 | + * set_hooks_for_shortcodes_modules_and_addons |
|
965 | + * this is the best place for other systems to set callbacks for hooking into other parts of EE |
|
966 | + * this happens at the very beginning of the wp_loaded hookpoint |
|
967 | + * |
|
968 | + * @access public |
|
969 | + * @return void |
|
970 | + */ |
|
971 | + public function set_hooks_for_shortcodes_modules_and_addons() |
|
972 | + { |
|
973 | + // do_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons' ); |
|
974 | + } |
|
975 | + |
|
976 | + |
|
977 | + |
|
978 | + /** |
|
979 | + * do_not_cache |
|
980 | + * sets no cache headers and defines no cache constants for WP plugins |
|
981 | + * |
|
982 | + * @access public |
|
983 | + * @return void |
|
984 | + */ |
|
985 | + public static function do_not_cache() |
|
986 | + { |
|
987 | + // set no cache constants |
|
988 | + if ( ! defined('DONOTCACHEPAGE')) { |
|
989 | + define('DONOTCACHEPAGE', true); |
|
990 | + } |
|
991 | + if ( ! defined('DONOTCACHCEOBJECT')) { |
|
992 | + define('DONOTCACHCEOBJECT', true); |
|
993 | + } |
|
994 | + if ( ! defined('DONOTCACHEDB')) { |
|
995 | + define('DONOTCACHEDB', true); |
|
996 | + } |
|
997 | + // add no cache headers |
|
998 | + add_action('send_headers', array('EE_System', 'nocache_headers'), 10); |
|
999 | + // plus a little extra for nginx and Google Chrome |
|
1000 | + add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1); |
|
1001 | + // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process |
|
1002 | + remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); |
|
1003 | + } |
|
1004 | + |
|
1005 | + |
|
1006 | + |
|
1007 | + /** |
|
1008 | + * extra_nocache_headers |
|
1009 | + * |
|
1010 | + * @access public |
|
1011 | + * @param $headers |
|
1012 | + * @return array |
|
1013 | + */ |
|
1014 | + public static function extra_nocache_headers($headers) |
|
1015 | + { |
|
1016 | + // for NGINX |
|
1017 | + $headers['X-Accel-Expires'] = 0; |
|
1018 | + // plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store" |
|
1019 | + $headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0'; |
|
1020 | + return $headers; |
|
1021 | + } |
|
1022 | + |
|
1023 | + |
|
1024 | + |
|
1025 | + /** |
|
1026 | + * nocache_headers |
|
1027 | + * |
|
1028 | + * @access public |
|
1029 | + * @return void |
|
1030 | + */ |
|
1031 | + public static function nocache_headers() |
|
1032 | + { |
|
1033 | + nocache_headers(); |
|
1034 | + } |
|
1035 | + |
|
1036 | + |
|
1037 | + |
|
1038 | + /** |
|
1039 | + * espresso_toolbar_items |
|
1040 | + * |
|
1041 | + * @access public |
|
1042 | + * @param WP_Admin_Bar $admin_bar |
|
1043 | + * @return void |
|
1044 | + */ |
|
1045 | + public function espresso_toolbar_items(WP_Admin_Bar $admin_bar) |
|
1046 | + { |
|
1047 | + // if in full M-Mode, or its an AJAX request, or user is NOT an admin |
|
1048 | + if (EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance |
|
1049 | + || defined('DOING_AJAX') |
|
1050 | + || ! $this->registry->CAP->current_user_can('ee_read_ee', 'ee_admin_bar_menu_top_level') |
|
1051 | + ) { |
|
1052 | + return; |
|
1053 | + } |
|
1054 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1055 | + $menu_class = 'espresso_menu_item_class'; |
|
1056 | + //we don't use the constants EVENTS_ADMIN_URL or REG_ADMIN_URL |
|
1057 | + //because they're only defined in each of their respective constructors |
|
1058 | + //and this might be a frontend request, in which case they aren't available |
|
1059 | + $events_admin_url = admin_url("admin.php?page=espresso_events"); |
|
1060 | + $reg_admin_url = admin_url("admin.php?page=espresso_registrations"); |
|
1061 | + $extensions_admin_url = admin_url("admin.php?page=espresso_packages"); |
|
1062 | + //Top Level |
|
1063 | + $admin_bar->add_menu(array( |
|
1064 | + 'id' => 'espresso-toolbar', |
|
1065 | + 'title' => '<span class="ee-icon ee-icon-ee-cup-thick ee-icon-size-20"></span><span class="ab-label">' |
|
1066 | + . _x('Event Espresso', 'admin bar menu group label', 'event_espresso') |
|
1067 | + . '</span>', |
|
1068 | + 'href' => $events_admin_url, |
|
1069 | + 'meta' => array( |
|
1070 | + 'title' => __('Event Espresso', 'event_espresso'), |
|
1071 | + 'class' => $menu_class . 'first', |
|
1072 | + ), |
|
1073 | + )); |
|
1074 | + //Events |
|
1075 | + if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events')) { |
|
1076 | + $admin_bar->add_menu(array( |
|
1077 | + 'id' => 'espresso-toolbar-events', |
|
1078 | + 'parent' => 'espresso-toolbar', |
|
1079 | + 'title' => __('Events', 'event_espresso'), |
|
1080 | + 'href' => $events_admin_url, |
|
1081 | + 'meta' => array( |
|
1082 | + 'title' => __('Events', 'event_espresso'), |
|
1083 | + 'target' => '', |
|
1084 | + 'class' => $menu_class, |
|
1085 | + ), |
|
1086 | + )); |
|
1087 | + } |
|
1088 | + if ($this->registry->CAP->current_user_can('ee_edit_events', 'ee_admin_bar_menu_espresso-toolbar-events-new')) { |
|
1089 | + //Events Add New |
|
1090 | + $admin_bar->add_menu(array( |
|
1091 | + 'id' => 'espresso-toolbar-events-new', |
|
1092 | + 'parent' => 'espresso-toolbar-events', |
|
1093 | + 'title' => __('Add New', 'event_espresso'), |
|
1094 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'create_new'), $events_admin_url), |
|
1095 | + 'meta' => array( |
|
1096 | + 'title' => __('Add New', 'event_espresso'), |
|
1097 | + 'target' => '', |
|
1098 | + 'class' => $menu_class, |
|
1099 | + ), |
|
1100 | + )); |
|
1101 | + } |
|
1102 | + if (is_single() && (get_post_type() == 'espresso_events')) { |
|
1103 | + //Current post |
|
1104 | + global $post; |
|
1105 | + if ($this->registry->CAP->current_user_can('ee_edit_event', |
|
1106 | + 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID) |
|
1107 | + ) { |
|
1108 | + //Events Edit Current Event |
|
1109 | + $admin_bar->add_menu(array( |
|
1110 | + 'id' => 'espresso-toolbar-events-edit', |
|
1111 | + 'parent' => 'espresso-toolbar-events', |
|
1112 | + 'title' => __('Edit Event', 'event_espresso'), |
|
1113 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'edit', 'post' => $post->ID), |
|
1114 | + $events_admin_url), |
|
1115 | + 'meta' => array( |
|
1116 | + 'title' => __('Edit Event', 'event_espresso'), |
|
1117 | + 'target' => '', |
|
1118 | + 'class' => $menu_class, |
|
1119 | + ), |
|
1120 | + )); |
|
1121 | + } |
|
1122 | + } |
|
1123 | + //Events View |
|
1124 | + if ($this->registry->CAP->current_user_can('ee_read_events', |
|
1125 | + 'ee_admin_bar_menu_espresso-toolbar-events-view') |
|
1126 | + ) { |
|
1127 | + $admin_bar->add_menu(array( |
|
1128 | + 'id' => 'espresso-toolbar-events-view', |
|
1129 | + 'parent' => 'espresso-toolbar-events', |
|
1130 | + 'title' => __('View', 'event_espresso'), |
|
1131 | + 'href' => $events_admin_url, |
|
1132 | + 'meta' => array( |
|
1133 | + 'title' => __('View', 'event_espresso'), |
|
1134 | + 'target' => '', |
|
1135 | + 'class' => $menu_class, |
|
1136 | + ), |
|
1137 | + )); |
|
1138 | + } |
|
1139 | + if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-all')) { |
|
1140 | + //Events View All |
|
1141 | + $admin_bar->add_menu(array( |
|
1142 | + 'id' => 'espresso-toolbar-events-all', |
|
1143 | + 'parent' => 'espresso-toolbar-events-view', |
|
1144 | + 'title' => __('All', 'event_espresso'), |
|
1145 | + 'href' => $events_admin_url, |
|
1146 | + 'meta' => array( |
|
1147 | + 'title' => __('All', 'event_espresso'), |
|
1148 | + 'target' => '', |
|
1149 | + 'class' => $menu_class, |
|
1150 | + ), |
|
1151 | + )); |
|
1152 | + } |
|
1153 | + if ($this->registry->CAP->current_user_can('ee_read_events', |
|
1154 | + 'ee_admin_bar_menu_espresso-toolbar-events-today') |
|
1155 | + ) { |
|
1156 | + //Events View Today |
|
1157 | + $admin_bar->add_menu(array( |
|
1158 | + 'id' => 'espresso-toolbar-events-today', |
|
1159 | + 'parent' => 'espresso-toolbar-events-view', |
|
1160 | + 'title' => __('Today', 'event_espresso'), |
|
1161 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'today'), |
|
1162 | + $events_admin_url), |
|
1163 | + 'meta' => array( |
|
1164 | + 'title' => __('Today', 'event_espresso'), |
|
1165 | + 'target' => '', |
|
1166 | + 'class' => $menu_class, |
|
1167 | + ), |
|
1168 | + )); |
|
1169 | + } |
|
1170 | + if ($this->registry->CAP->current_user_can('ee_read_events', |
|
1171 | + 'ee_admin_bar_menu_espresso-toolbar-events-month') |
|
1172 | + ) { |
|
1173 | + //Events View This Month |
|
1174 | + $admin_bar->add_menu(array( |
|
1175 | + 'id' => 'espresso-toolbar-events-month', |
|
1176 | + 'parent' => 'espresso-toolbar-events-view', |
|
1177 | + 'title' => __('This Month', 'event_espresso'), |
|
1178 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'month'), |
|
1179 | + $events_admin_url), |
|
1180 | + 'meta' => array( |
|
1181 | + 'title' => __('This Month', 'event_espresso'), |
|
1182 | + 'target' => '', |
|
1183 | + 'class' => $menu_class, |
|
1184 | + ), |
|
1185 | + )); |
|
1186 | + } |
|
1187 | + //Registration Overview |
|
1188 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1189 | + 'ee_admin_bar_menu_espresso-toolbar-registrations') |
|
1190 | + ) { |
|
1191 | + $admin_bar->add_menu(array( |
|
1192 | + 'id' => 'espresso-toolbar-registrations', |
|
1193 | + 'parent' => 'espresso-toolbar', |
|
1194 | + 'title' => __('Registrations', 'event_espresso'), |
|
1195 | + 'href' => $reg_admin_url, |
|
1196 | + 'meta' => array( |
|
1197 | + 'title' => __('Registrations', 'event_espresso'), |
|
1198 | + 'target' => '', |
|
1199 | + 'class' => $menu_class, |
|
1200 | + ), |
|
1201 | + )); |
|
1202 | + } |
|
1203 | + //Registration Overview Today |
|
1204 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1205 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-today') |
|
1206 | + ) { |
|
1207 | + $admin_bar->add_menu(array( |
|
1208 | + 'id' => 'espresso-toolbar-registrations-today', |
|
1209 | + 'parent' => 'espresso-toolbar-registrations', |
|
1210 | + 'title' => __('Today', 'event_espresso'), |
|
1211 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'today'), |
|
1212 | + $reg_admin_url), |
|
1213 | + 'meta' => array( |
|
1214 | + 'title' => __('Today', 'event_espresso'), |
|
1215 | + 'target' => '', |
|
1216 | + 'class' => $menu_class, |
|
1217 | + ), |
|
1218 | + )); |
|
1219 | + } |
|
1220 | + //Registration Overview Today Completed |
|
1221 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1222 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved') |
|
1223 | + ) { |
|
1224 | + $admin_bar->add_menu(array( |
|
1225 | + 'id' => 'espresso-toolbar-registrations-today-approved', |
|
1226 | + 'parent' => 'espresso-toolbar-registrations-today', |
|
1227 | + 'title' => __('Approved', 'event_espresso'), |
|
1228 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1229 | + 'action' => 'default', |
|
1230 | + 'status' => 'today', |
|
1231 | + '_reg_status' => EEM_Registration::status_id_approved, |
|
1232 | + ), $reg_admin_url), |
|
1233 | + 'meta' => array( |
|
1234 | + 'title' => __('Approved', 'event_espresso'), |
|
1235 | + 'target' => '', |
|
1236 | + 'class' => $menu_class, |
|
1237 | + ), |
|
1238 | + )); |
|
1239 | + } |
|
1240 | + //Registration Overview Today Pending\ |
|
1241 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1242 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending') |
|
1243 | + ) { |
|
1244 | + $admin_bar->add_menu(array( |
|
1245 | + 'id' => 'espresso-toolbar-registrations-today-pending', |
|
1246 | + 'parent' => 'espresso-toolbar-registrations-today', |
|
1247 | + 'title' => __('Pending', 'event_espresso'), |
|
1248 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1249 | + 'action' => 'default', |
|
1250 | + 'status' => 'today', |
|
1251 | + 'reg_status' => EEM_Registration::status_id_pending_payment, |
|
1252 | + ), $reg_admin_url), |
|
1253 | + 'meta' => array( |
|
1254 | + 'title' => __('Pending Payment', 'event_espresso'), |
|
1255 | + 'target' => '', |
|
1256 | + 'class' => $menu_class, |
|
1257 | + ), |
|
1258 | + )); |
|
1259 | + } |
|
1260 | + //Registration Overview Today Incomplete |
|
1261 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1262 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved') |
|
1263 | + ) { |
|
1264 | + $admin_bar->add_menu(array( |
|
1265 | + 'id' => 'espresso-toolbar-registrations-today-not-approved', |
|
1266 | + 'parent' => 'espresso-toolbar-registrations-today', |
|
1267 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1268 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1269 | + 'action' => 'default', |
|
1270 | + 'status' => 'today', |
|
1271 | + '_reg_status' => EEM_Registration::status_id_not_approved, |
|
1272 | + ), $reg_admin_url), |
|
1273 | + 'meta' => array( |
|
1274 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1275 | + 'target' => '', |
|
1276 | + 'class' => $menu_class, |
|
1277 | + ), |
|
1278 | + )); |
|
1279 | + } |
|
1280 | + //Registration Overview Today Incomplete |
|
1281 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1282 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled') |
|
1283 | + ) { |
|
1284 | + $admin_bar->add_menu(array( |
|
1285 | + 'id' => 'espresso-toolbar-registrations-today-cancelled', |
|
1286 | + 'parent' => 'espresso-toolbar-registrations-today', |
|
1287 | + 'title' => __('Cancelled', 'event_espresso'), |
|
1288 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1289 | + 'action' => 'default', |
|
1290 | + 'status' => 'today', |
|
1291 | + '_reg_status' => EEM_Registration::status_id_cancelled, |
|
1292 | + ), $reg_admin_url), |
|
1293 | + 'meta' => array( |
|
1294 | + 'title' => __('Cancelled', 'event_espresso'), |
|
1295 | + 'target' => '', |
|
1296 | + 'class' => $menu_class, |
|
1297 | + ), |
|
1298 | + )); |
|
1299 | + } |
|
1300 | + //Registration Overview This Month |
|
1301 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1302 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-month') |
|
1303 | + ) { |
|
1304 | + $admin_bar->add_menu(array( |
|
1305 | + 'id' => 'espresso-toolbar-registrations-month', |
|
1306 | + 'parent' => 'espresso-toolbar-registrations', |
|
1307 | + 'title' => __('This Month', 'event_espresso'), |
|
1308 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'month'), |
|
1309 | + $reg_admin_url), |
|
1310 | + 'meta' => array( |
|
1311 | + 'title' => __('This Month', 'event_espresso'), |
|
1312 | + 'target' => '', |
|
1313 | + 'class' => $menu_class, |
|
1314 | + ), |
|
1315 | + )); |
|
1316 | + } |
|
1317 | + //Registration Overview This Month Approved |
|
1318 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1319 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved') |
|
1320 | + ) { |
|
1321 | + $admin_bar->add_menu(array( |
|
1322 | + 'id' => 'espresso-toolbar-registrations-month-approved', |
|
1323 | + 'parent' => 'espresso-toolbar-registrations-month', |
|
1324 | + 'title' => __('Approved', 'event_espresso'), |
|
1325 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1326 | + 'action' => 'default', |
|
1327 | + 'status' => 'month', |
|
1328 | + '_reg_status' => EEM_Registration::status_id_approved, |
|
1329 | + ), $reg_admin_url), |
|
1330 | + 'meta' => array( |
|
1331 | + 'title' => __('Approved', 'event_espresso'), |
|
1332 | + 'target' => '', |
|
1333 | + 'class' => $menu_class, |
|
1334 | + ), |
|
1335 | + )); |
|
1336 | + } |
|
1337 | + //Registration Overview This Month Pending |
|
1338 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1339 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending') |
|
1340 | + ) { |
|
1341 | + $admin_bar->add_menu(array( |
|
1342 | + 'id' => 'espresso-toolbar-registrations-month-pending', |
|
1343 | + 'parent' => 'espresso-toolbar-registrations-month', |
|
1344 | + 'title' => __('Pending', 'event_espresso'), |
|
1345 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1346 | + 'action' => 'default', |
|
1347 | + 'status' => 'month', |
|
1348 | + '_reg_status' => EEM_Registration::status_id_pending_payment, |
|
1349 | + ), $reg_admin_url), |
|
1350 | + 'meta' => array( |
|
1351 | + 'title' => __('Pending', 'event_espresso'), |
|
1352 | + 'target' => '', |
|
1353 | + 'class' => $menu_class, |
|
1354 | + ), |
|
1355 | + )); |
|
1356 | + } |
|
1357 | + //Registration Overview This Month Not Approved |
|
1358 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1359 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved') |
|
1360 | + ) { |
|
1361 | + $admin_bar->add_menu(array( |
|
1362 | + 'id' => 'espresso-toolbar-registrations-month-not-approved', |
|
1363 | + 'parent' => 'espresso-toolbar-registrations-month', |
|
1364 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1365 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1366 | + 'action' => 'default', |
|
1367 | + 'status' => 'month', |
|
1368 | + '_reg_status' => EEM_Registration::status_id_not_approved, |
|
1369 | + ), $reg_admin_url), |
|
1370 | + 'meta' => array( |
|
1371 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1372 | + 'target' => '', |
|
1373 | + 'class' => $menu_class, |
|
1374 | + ), |
|
1375 | + )); |
|
1376 | + } |
|
1377 | + //Registration Overview This Month Cancelled |
|
1378 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1379 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled') |
|
1380 | + ) { |
|
1381 | + $admin_bar->add_menu(array( |
|
1382 | + 'id' => 'espresso-toolbar-registrations-month-cancelled', |
|
1383 | + 'parent' => 'espresso-toolbar-registrations-month', |
|
1384 | + 'title' => __('Cancelled', 'event_espresso'), |
|
1385 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1386 | + 'action' => 'default', |
|
1387 | + 'status' => 'month', |
|
1388 | + '_reg_status' => EEM_Registration::status_id_cancelled, |
|
1389 | + ), $reg_admin_url), |
|
1390 | + 'meta' => array( |
|
1391 | + 'title' => __('Cancelled', 'event_espresso'), |
|
1392 | + 'target' => '', |
|
1393 | + 'class' => $menu_class, |
|
1394 | + ), |
|
1395 | + )); |
|
1396 | + } |
|
1397 | + //Extensions & Services |
|
1398 | + if ($this->registry->CAP->current_user_can('ee_read_ee', |
|
1399 | + 'ee_admin_bar_menu_espresso-toolbar-extensions-and-services') |
|
1400 | + ) { |
|
1401 | + $admin_bar->add_menu(array( |
|
1402 | + 'id' => 'espresso-toolbar-extensions-and-services', |
|
1403 | + 'parent' => 'espresso-toolbar', |
|
1404 | + 'title' => __('Extensions & Services', 'event_espresso'), |
|
1405 | + 'href' => $extensions_admin_url, |
|
1406 | + 'meta' => array( |
|
1407 | + 'title' => __('Extensions & Services', 'event_espresso'), |
|
1408 | + 'target' => '', |
|
1409 | + 'class' => $menu_class, |
|
1410 | + ), |
|
1411 | + )); |
|
1412 | + } |
|
1413 | + } |
|
1414 | + |
|
1415 | + |
|
1416 | + |
|
1417 | + /** |
|
1418 | + * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are |
|
1419 | + * never returned with the function. |
|
1420 | + * |
|
1421 | + * @param array $exclude_array any existing pages being excluded are in this array. |
|
1422 | + * @return array |
|
1423 | + */ |
|
1424 | + public function remove_pages_from_wp_list_pages($exclude_array) |
|
1425 | + { |
|
1426 | + return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array()); |
|
1427 | + } |
|
1428 | + |
|
1429 | + |
|
1430 | + |
|
1431 | + |
|
1432 | + |
|
1433 | + |
|
1434 | + /*********************************************** WP_ENQUEUE_SCRIPTS HOOK ***********************************************/ |
|
1435 | + /** |
|
1436 | + * wp_enqueue_scripts |
|
1437 | + * |
|
1438 | + * @access public |
|
1439 | + * @return void |
|
1440 | + */ |
|
1441 | + public function wp_enqueue_scripts() |
|
1442 | + { |
|
1443 | + // unlike other systems, EE_System_scripts loading is turned ON by default, but prior to the init hook, can be turned off via: add_filter( 'FHEE_load_EE_System_scripts', '__return_false' ); |
|
1444 | + if (apply_filters('FHEE_load_EE_System_scripts', true)) { |
|
1445 | + // jquery_validate loading is turned OFF by default, but prior to the wp_enqueue_scripts hook, can be turned back on again via: add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
|
1446 | + if (apply_filters('FHEE_load_jquery_validate', false)) { |
|
1447 | + // register jQuery Validate and additional methods |
|
1448 | + wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
1449 | + array('jquery'), '1.15.0', true); |
|
1450 | + wp_register_script('jquery-validate-extra-methods', |
|
1451 | + EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
1452 | + array('jquery', 'jquery-validate'), '1.15.0', true); |
|
1453 | + } |
|
1454 | + } |
|
1455 | + } |
|
1456 | 1456 | |
1457 | 1457 | |
1458 | 1458 |