@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | EE_Question_Option::new_instance(['QSO_value' => false, 'QSO_desc' => esc_html__('No', 'event_espresso')]), |
| 110 | 110 | EE_Question_Option::new_instance(['QSO_value' => true, 'QSO_desc' => esc_html__('Yes', 'event_espresso')]), |
| 111 | 111 | ]; |
| 112 | - $sort_values = [ |
|
| 112 | + $sort_values = [ |
|
| 113 | 113 | EE_Question_Option::new_instance(['QSO_value' => 'ASC', 'QSO_desc' => esc_html__('ASC', 'event_espresso')]), |
| 114 | 114 | EE_Question_Option::new_instance(['QSO_value' => 'DESC', 'QSO_desc' => esc_html__('DESC', 'event_espresso')]), |
| 115 | 115 | ]; |
@@ -326,8 +326,8 @@ discard block |
||
| 326 | 326 | // Before widget (defined by themes). |
| 327 | 327 | echo $before_widget; |
| 328 | 328 | // Display the widget title if one was input (before and after defined by themes). |
| 329 | - if (! empty($title)) { |
|
| 330 | - echo $before_title . $title . $after_title; |
|
| 329 | + if ( ! empty($title)) { |
|
| 330 | + echo $before_title.$title.$after_title; |
|
| 331 | 331 | } |
| 332 | 332 | echo $this->widgetContent($post); |
| 333 | 333 | // After widget (defined by themes). |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | */ |
| 347 | 347 | public function make_the_title_a_link($title) |
| 348 | 348 | { |
| 349 | - return '<a href="' . EEH_Event_View::event_archive_url() . '">' . $title . '</a>'; |
|
| 349 | + return '<a href="'.EEH_Event_View::event_archive_url().'">'.$title.'</a>'; |
|
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | |
@@ -427,7 +427,7 @@ discard block |
||
| 427 | 427 | foreach ($sizes as $image_size) { |
| 428 | 428 | $image_size = trim($image_size); |
| 429 | 429 | // no big images plz |
| 430 | - if (! in_array($image_size, ['large', 'post-thumbnail'])) { |
|
| 430 | + if ( ! in_array($image_size, ['large', 'post-thumbnail'])) { |
|
| 431 | 431 | $image_sizes[] = |
| 432 | 432 | EE_Question_Option::new_instance(['QSO_value' => $image_size, 'QSO_desc' => $image_size]); |
| 433 | 433 | } |
@@ -512,24 +512,24 @@ discard block |
||
| 512 | 512 | } |
| 513 | 513 | $list_items = ''; |
| 514 | 514 | foreach ($events as $event) { |
| 515 | - if ($event instanceof EE_Event && (! is_single() || $post->ID != $event->ID())) { |
|
| 515 | + if ($event instanceof EE_Event && ( ! is_single() || $post->ID != $event->ID())) { |
|
| 516 | 516 | $event_url = $this->eventUrl($event); |
| 517 | 517 | $list_items .= ' |
| 518 | - <li id="ee-upcoming-events-widget-li-' . esc_attr($event->ID()) . '" |
|
| 518 | + <li id="ee-upcoming-events-widget-li-' . esc_attr($event->ID()).'" |
|
| 519 | 519 | class="ee-upcoming-events-widget-li" |
| 520 | 520 | > |
| 521 | 521 | <h5 class="ee-upcoming-events-widget-title-h5"> |
| 522 | - <a class="ee-widget-event-name-a' . $this->linkClass($event) . '" href="' . $event_url . '"> |
|
| 523 | - ' . esc_html($event->name()) . ' |
|
| 522 | + <a class="ee-widget-event-name-a' . $this->linkClass($event).'" href="'.$event_url.'"> |
|
| 523 | + ' . esc_html($event->name()).' |
|
| 524 | 524 | </a> |
| 525 | 525 | </h5> |
| 526 | - ' . $this->eventWidgetContent($event, $event_url) . ' |
|
| 526 | + ' . $this->eventWidgetContent($event, $event_url).' |
|
| 527 | 527 | </li>'; |
| 528 | 528 | } |
| 529 | 529 | } |
| 530 | 530 | return ' |
| 531 | 531 | <ul class="ee-upcoming-events-widget-ul"> |
| 532 | - ' . $list_items . ' |
|
| 532 | + ' . $list_items.' |
|
| 533 | 533 | </ul>'; |
| 534 | 534 | } |
| 535 | 535 | |
@@ -561,7 +561,7 @@ discard block |
||
| 561 | 561 | return EEM_Event::instance()->get_all( |
| 562 | 562 | [ |
| 563 | 563 | $this->queryWhereParams(), |
| 564 | - 'limit' => '0,' . $this->limit, |
|
| 564 | + 'limit' => '0,'.$this->limit, |
|
| 565 | 565 | 'order_by' => 'Datetime.DTT_EVT_start', |
| 566 | 566 | 'order' => $this->order, |
| 567 | 567 | 'group_by' => 'EVT_ID', |
@@ -649,8 +649,8 @@ discard block |
||
| 649 | 649 | if (has_post_thumbnail($event->ID()) && $this->image_size != 'none') { |
| 650 | 650 | $content .= ' |
| 651 | 651 | <div class="ee-upcoming-events-widget-img-dv"> |
| 652 | - <a class="ee-upcoming-events-widget-img" href="' . $event_url . '"> |
|
| 653 | - ' . get_the_post_thumbnail($event->ID(), $this->image_size) . ' |
|
| 652 | + <a class="ee-upcoming-events-widget-img" href="' . $event_url.'"> |
|
| 653 | + ' . get_the_post_thumbnail($event->ID(), $this->image_size).' |
|
| 654 | 654 | </a> |
| 655 | 655 | </div>'; |
| 656 | 656 | } |
@@ -661,8 +661,8 @@ discard block |
||
| 661 | 661 | |
| 662 | 662 | if ($this->show_desc) { |
| 663 | 663 | global $allowedtags; |
| 664 | - $desc = $event->short_description(25); |
|
| 665 | - $content .= $desc ? '<p style="margin-top: .5em">' . wp_kses($desc, $allowedtags) . '</p>' : ''; |
|
| 664 | + $desc = $event->short_description(25); |
|
| 665 | + $content .= $desc ? '<p style="margin-top: .5em">'.wp_kses($desc, $allowedtags).'</p>' : ''; |
|
| 666 | 666 | } |
| 667 | 667 | |
| 668 | 668 | return $content; |
@@ -678,11 +678,11 @@ discard block |
||
| 678 | 678 | */ |
| 679 | 679 | private function eventDates(EE_Event $event) |
| 680 | 680 | { |
| 681 | - $date_format = apply_filters( |
|
| 681 | + $date_format = apply_filters( |
|
| 682 | 682 | 'FHEE__espresso_event_date_range__date_format', |
| 683 | 683 | get_option('date_format') |
| 684 | 684 | ); |
| 685 | - $time_format = apply_filters( |
|
| 685 | + $time_format = apply_filters( |
|
| 686 | 686 | 'FHEE__espresso_event_date_range__time_format', |
| 687 | 687 | get_option('time_format') |
| 688 | 688 | ); |
@@ -12,109 +12,109 @@ discard block |
||
| 12 | 12 | class EEW_Upcoming_Events extends EspressoWidget |
| 13 | 13 | { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * @var string |
|
| 17 | - */ |
|
| 18 | - private $title; |
|
| 19 | - /** |
|
| 20 | - * @var string |
|
| 21 | - */ |
|
| 22 | - private $category; |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * @var bool |
|
| 26 | - */ |
|
| 27 | - private $show_expired; |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * @var string |
|
| 31 | - */ |
|
| 32 | - private $image_size; |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * @var bool |
|
| 36 | - */ |
|
| 37 | - private $show_desc; |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * @var bool |
|
| 41 | - */ |
|
| 42 | - private $show_dates; |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * @var string |
|
| 46 | - */ |
|
| 47 | - private $date_limit; |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * @var string |
|
| 51 | - */ |
|
| 52 | - private $date_range; |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * @var string |
|
| 56 | - */ |
|
| 57 | - private $limit; |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * @var string |
|
| 61 | - */ |
|
| 62 | - private $order; |
|
| 63 | - |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * Register widget with WordPress. |
|
| 67 | - */ |
|
| 68 | - public function __construct() |
|
| 69 | - { |
|
| 70 | - parent::__construct( |
|
| 71 | - esc_html__('Event Espresso Upcoming Events', 'event_espresso'), |
|
| 72 | - ['description' => esc_html__('A widget to display your upcoming events.', 'event_espresso')] |
|
| 73 | - ); |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - |
|
| 77 | - /** |
|
| 78 | - * Back-end widget form. |
|
| 79 | - * |
|
| 80 | - * @param array $instance Previously saved values from database. |
|
| 81 | - * @return void |
|
| 82 | - * @throws EE_Error |
|
| 83 | - * @throws ReflectionException |
|
| 84 | - * @see WP_Widget::form() |
|
| 85 | - */ |
|
| 86 | - public function form($instance) |
|
| 87 | - { |
|
| 88 | - |
|
| 89 | - EE_Registry::instance()->load_class('Question_Option', [], false, false, true); |
|
| 90 | - // Set up some default widget settings. |
|
| 91 | - $defaults = [ |
|
| 92 | - 'title' => esc_html__('Upcoming Events', 'event_espresso'), |
|
| 93 | - 'category_name' => '', |
|
| 94 | - 'show_expired' => 0, |
|
| 95 | - 'show_desc' => true, |
|
| 96 | - 'show_dates' => true, |
|
| 97 | - 'show_everywhere' => false, |
|
| 98 | - 'date_limit' => 2, |
|
| 99 | - 'limit' => 10, |
|
| 100 | - 'sort' => 'ASC', |
|
| 101 | - 'date_range' => false, |
|
| 102 | - 'image_size' => 'medium', |
|
| 103 | - ]; |
|
| 104 | - |
|
| 105 | - $instance = wp_parse_args((array) $instance, $defaults); |
|
| 106 | - // don't add HTML labels for EE_Form_Fields generated inputs |
|
| 107 | - add_filter('FHEE__EEH_Form_Fields__label_html', '__return_empty_string'); |
|
| 108 | - $yes_no_values = [ |
|
| 109 | - EE_Question_Option::new_instance(['QSO_value' => false, 'QSO_desc' => esc_html__('No', 'event_espresso')]), |
|
| 110 | - EE_Question_Option::new_instance(['QSO_value' => true, 'QSO_desc' => esc_html__('Yes', 'event_espresso')]), |
|
| 111 | - ]; |
|
| 112 | - $sort_values = [ |
|
| 113 | - EE_Question_Option::new_instance(['QSO_value' => 'ASC', 'QSO_desc' => esc_html__('ASC', 'event_espresso')]), |
|
| 114 | - EE_Question_Option::new_instance(['QSO_value' => 'DESC', 'QSO_desc' => esc_html__('DESC', 'event_espresso')]), |
|
| 115 | - ]; |
|
| 116 | - |
|
| 117 | - ?> |
|
| 15 | + /** |
|
| 16 | + * @var string |
|
| 17 | + */ |
|
| 18 | + private $title; |
|
| 19 | + /** |
|
| 20 | + * @var string |
|
| 21 | + */ |
|
| 22 | + private $category; |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * @var bool |
|
| 26 | + */ |
|
| 27 | + private $show_expired; |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * @var string |
|
| 31 | + */ |
|
| 32 | + private $image_size; |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * @var bool |
|
| 36 | + */ |
|
| 37 | + private $show_desc; |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * @var bool |
|
| 41 | + */ |
|
| 42 | + private $show_dates; |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * @var string |
|
| 46 | + */ |
|
| 47 | + private $date_limit; |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * @var string |
|
| 51 | + */ |
|
| 52 | + private $date_range; |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * @var string |
|
| 56 | + */ |
|
| 57 | + private $limit; |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * @var string |
|
| 61 | + */ |
|
| 62 | + private $order; |
|
| 63 | + |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * Register widget with WordPress. |
|
| 67 | + */ |
|
| 68 | + public function __construct() |
|
| 69 | + { |
|
| 70 | + parent::__construct( |
|
| 71 | + esc_html__('Event Espresso Upcoming Events', 'event_espresso'), |
|
| 72 | + ['description' => esc_html__('A widget to display your upcoming events.', 'event_espresso')] |
|
| 73 | + ); |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + |
|
| 77 | + /** |
|
| 78 | + * Back-end widget form. |
|
| 79 | + * |
|
| 80 | + * @param array $instance Previously saved values from database. |
|
| 81 | + * @return void |
|
| 82 | + * @throws EE_Error |
|
| 83 | + * @throws ReflectionException |
|
| 84 | + * @see WP_Widget::form() |
|
| 85 | + */ |
|
| 86 | + public function form($instance) |
|
| 87 | + { |
|
| 88 | + |
|
| 89 | + EE_Registry::instance()->load_class('Question_Option', [], false, false, true); |
|
| 90 | + // Set up some default widget settings. |
|
| 91 | + $defaults = [ |
|
| 92 | + 'title' => esc_html__('Upcoming Events', 'event_espresso'), |
|
| 93 | + 'category_name' => '', |
|
| 94 | + 'show_expired' => 0, |
|
| 95 | + 'show_desc' => true, |
|
| 96 | + 'show_dates' => true, |
|
| 97 | + 'show_everywhere' => false, |
|
| 98 | + 'date_limit' => 2, |
|
| 99 | + 'limit' => 10, |
|
| 100 | + 'sort' => 'ASC', |
|
| 101 | + 'date_range' => false, |
|
| 102 | + 'image_size' => 'medium', |
|
| 103 | + ]; |
|
| 104 | + |
|
| 105 | + $instance = wp_parse_args((array) $instance, $defaults); |
|
| 106 | + // don't add HTML labels for EE_Form_Fields generated inputs |
|
| 107 | + add_filter('FHEE__EEH_Form_Fields__label_html', '__return_empty_string'); |
|
| 108 | + $yes_no_values = [ |
|
| 109 | + EE_Question_Option::new_instance(['QSO_value' => false, 'QSO_desc' => esc_html__('No', 'event_espresso')]), |
|
| 110 | + EE_Question_Option::new_instance(['QSO_value' => true, 'QSO_desc' => esc_html__('Yes', 'event_espresso')]), |
|
| 111 | + ]; |
|
| 112 | + $sort_values = [ |
|
| 113 | + EE_Question_Option::new_instance(['QSO_value' => 'ASC', 'QSO_desc' => esc_html__('ASC', 'event_espresso')]), |
|
| 114 | + EE_Question_Option::new_instance(['QSO_value' => 'DESC', 'QSO_desc' => esc_html__('DESC', 'event_espresso')]), |
|
| 115 | + ]; |
|
| 116 | + |
|
| 117 | + ?> |
|
| 118 | 118 | |
| 119 | 119 | <!-- Widget Title: Text Input --> |
| 120 | 120 | |
@@ -151,32 +151,32 @@ discard block |
||
| 151 | 151 | <?php esc_html_e('Show Expired Events:', 'event_espresso'); ?> |
| 152 | 152 | </label> |
| 153 | 153 | <?php |
| 154 | - $show_expired_options = $yes_no_values; |
|
| 155 | - $show_expired_options[] = EE_Question_Option::new_instance( |
|
| 156 | - ['QSO_value' => 2, 'QSO_desc' => esc_html__('Show Only Expired', 'event_espresso')] |
|
| 157 | - ); |
|
| 158 | - echo EEH_Form_Fields::select( |
|
| 159 | - esc_html__('Show Expired Events:', 'event_espresso'), |
|
| 160 | - $instance['show_expired'], |
|
| 161 | - $show_expired_options, |
|
| 162 | - $this->fieldName('show_expired'), |
|
| 163 | - $this->fieldID('show_expired') |
|
| 164 | - ); |
|
| 165 | - ?> |
|
| 154 | + $show_expired_options = $yes_no_values; |
|
| 155 | + $show_expired_options[] = EE_Question_Option::new_instance( |
|
| 156 | + ['QSO_value' => 2, 'QSO_desc' => esc_html__('Show Only Expired', 'event_espresso')] |
|
| 157 | + ); |
|
| 158 | + echo EEH_Form_Fields::select( |
|
| 159 | + esc_html__('Show Expired Events:', 'event_espresso'), |
|
| 160 | + $instance['show_expired'], |
|
| 161 | + $show_expired_options, |
|
| 162 | + $this->fieldName('show_expired'), |
|
| 163 | + $this->fieldID('show_expired') |
|
| 164 | + ); |
|
| 165 | + ?> |
|
| 166 | 166 | </p> |
| 167 | 167 | <p> |
| 168 | 168 | <label for="<?php echo $this->fieldID('sort'); ?>"> |
| 169 | 169 | <?php esc_html_e('Sort Events:', 'event_espresso'); ?> |
| 170 | 170 | </label> |
| 171 | 171 | <?php |
| 172 | - echo EEH_Form_Fields::select( |
|
| 173 | - esc_html__('Sort Events:', 'event_espresso'), |
|
| 174 | - $instance['sort'], |
|
| 175 | - $sort_values, |
|
| 176 | - $this->fieldName('sort'), |
|
| 177 | - $this->fieldID('sort') |
|
| 178 | - ); |
|
| 179 | - ?> |
|
| 172 | + echo EEH_Form_Fields::select( |
|
| 173 | + esc_html__('Sort Events:', 'event_espresso'), |
|
| 174 | + $instance['sort'], |
|
| 175 | + $sort_values, |
|
| 176 | + $this->fieldName('sort'), |
|
| 177 | + $this->fieldID('sort') |
|
| 178 | + ); |
|
| 179 | + ?> |
|
| 180 | 180 | </p> |
| 181 | 181 | <p> |
| 182 | 182 | <label for="<?php echo $this->fieldID('image_size'); ?>"> |
@@ -190,42 +190,42 @@ discard block |
||
| 190 | 190 | <?php esc_html_e('Show Description:', 'event_espresso'); ?> |
| 191 | 191 | </label> |
| 192 | 192 | <?php |
| 193 | - echo EEH_Form_Fields::select( |
|
| 194 | - esc_html__('Show Description:', 'event_espresso'), |
|
| 195 | - $instance['show_desc'], |
|
| 196 | - $yes_no_values, |
|
| 197 | - $this->fieldName('show_desc'), |
|
| 198 | - $this->fieldID('show_desc') |
|
| 199 | - ); |
|
| 200 | - ?> |
|
| 193 | + echo EEH_Form_Fields::select( |
|
| 194 | + esc_html__('Show Description:', 'event_espresso'), |
|
| 195 | + $instance['show_desc'], |
|
| 196 | + $yes_no_values, |
|
| 197 | + $this->fieldName('show_desc'), |
|
| 198 | + $this->fieldID('show_desc') |
|
| 199 | + ); |
|
| 200 | + ?> |
|
| 201 | 201 | </p> |
| 202 | 202 | <p> |
| 203 | 203 | <label for="<?php echo $this->fieldID('show_dates'); ?>"> |
| 204 | 204 | <?php esc_html_e('Show Dates:', 'event_espresso'); ?> |
| 205 | 205 | </label> |
| 206 | 206 | <?php |
| 207 | - echo EEH_Form_Fields::select( |
|
| 208 | - esc_html__('Show Dates:', 'event_espresso'), |
|
| 209 | - $instance['show_dates'], |
|
| 210 | - $yes_no_values, |
|
| 211 | - $this->fieldName('show_dates'), |
|
| 212 | - $this->fieldID('show_dates') |
|
| 213 | - ); |
|
| 214 | - ?> |
|
| 207 | + echo EEH_Form_Fields::select( |
|
| 208 | + esc_html__('Show Dates:', 'event_espresso'), |
|
| 209 | + $instance['show_dates'], |
|
| 210 | + $yes_no_values, |
|
| 211 | + $this->fieldName('show_dates'), |
|
| 212 | + $this->fieldID('show_dates') |
|
| 213 | + ); |
|
| 214 | + ?> |
|
| 215 | 215 | </p> |
| 216 | 216 | <p> |
| 217 | 217 | <label for="<?php echo $this->fieldID('show_everywhere'); ?>"> |
| 218 | 218 | <?php esc_html_e('Show on all Pages:', 'event_espresso'); ?> |
| 219 | 219 | </label> |
| 220 | 220 | <?php |
| 221 | - echo EEH_Form_Fields::select( |
|
| 222 | - esc_html__('Show on all Pages:', 'event_espresso'), |
|
| 223 | - $instance['show_everywhere'], |
|
| 224 | - $yes_no_values, |
|
| 225 | - $this->fieldName('show_everywhere'), |
|
| 226 | - $this->fieldID('show_everywhere') |
|
| 227 | - ); |
|
| 228 | - ?> |
|
| 221 | + echo EEH_Form_Fields::select( |
|
| 222 | + esc_html__('Show on all Pages:', 'event_espresso'), |
|
| 223 | + $instance['show_everywhere'], |
|
| 224 | + $yes_no_values, |
|
| 225 | + $this->fieldName('show_everywhere'), |
|
| 226 | + $this->fieldID('show_everywhere') |
|
| 227 | + ); |
|
| 228 | + ?> |
|
| 229 | 229 | </p> |
| 230 | 230 | <p> |
| 231 | 231 | <label for="<?php echo $this->fieldID('date_limit'); ?>"> |
@@ -243,278 +243,278 @@ discard block |
||
| 243 | 243 | <?php esc_html_e('Show Date Range:', 'event_espresso'); ?> |
| 244 | 244 | </label> |
| 245 | 245 | <?php |
| 246 | - echo EEH_Form_Fields::select( |
|
| 247 | - esc_html__('Show Date Range:', 'event_espresso'), |
|
| 248 | - $instance['date_range'], |
|
| 249 | - $yes_no_values, |
|
| 250 | - $this->fieldName('date_range'), |
|
| 251 | - $this->fieldID('date_range') |
|
| 252 | - ); |
|
| 253 | - ?> |
|
| 246 | + echo EEH_Form_Fields::select( |
|
| 247 | + esc_html__('Show Date Range:', 'event_espresso'), |
|
| 248 | + $instance['date_range'], |
|
| 249 | + $yes_no_values, |
|
| 250 | + $this->fieldName('date_range'), |
|
| 251 | + $this->fieldID('date_range') |
|
| 252 | + ); |
|
| 253 | + ?> |
|
| 254 | 254 | <span class="description"> |
| 255 | 255 | <br /> |
| 256 | 256 | <?php esc_html_e( |
| 257 | - 'This setting will replace the list of dates in the widget.', |
|
| 258 | - 'event_espresso' |
|
| 259 | - ); ?> |
|
| 257 | + 'This setting will replace the list of dates in the widget.', |
|
| 258 | + 'event_espresso' |
|
| 259 | + ); ?> |
|
| 260 | 260 | </span> |
| 261 | 261 | </p> |
| 262 | 262 | |
| 263 | 263 | <?php |
| 264 | - } |
|
| 265 | - |
|
| 266 | - |
|
| 267 | - /** |
|
| 268 | - * Sanitize widget form values as they are saved. |
|
| 269 | - * |
|
| 270 | - * @param array $new_instance Values just sent to be saved. |
|
| 271 | - * @param array $old_instance Previously saved values from database. |
|
| 272 | - * |
|
| 273 | - * @return array Updated safe values to be saved. |
|
| 274 | - * @see WP_Widget::update() |
|
| 275 | - * |
|
| 276 | - */ |
|
| 277 | - public function update($new_instance, $old_instance) |
|
| 278 | - { |
|
| 279 | - $instance = $old_instance; |
|
| 280 | - $instance['title'] = ! empty($new_instance['title']) ? strip_tags($new_instance['title']) : ''; |
|
| 281 | - $instance['category_name'] = $new_instance['category_name']; |
|
| 282 | - $instance['show_expired'] = $new_instance['show_expired']; |
|
| 283 | - $instance['limit'] = $new_instance['limit']; |
|
| 284 | - $instance['sort'] = $new_instance['sort']; |
|
| 285 | - $instance['image_size'] = $new_instance['image_size']; |
|
| 286 | - $instance['show_desc'] = $new_instance['show_desc']; |
|
| 287 | - $instance['show_dates'] = $new_instance['show_dates']; |
|
| 288 | - $instance['show_everywhere'] = $new_instance['show_everywhere']; |
|
| 289 | - $instance['date_limit'] = $new_instance['date_limit']; |
|
| 290 | - $instance['date_range'] = $new_instance['date_range']; |
|
| 291 | - return $instance; |
|
| 292 | - } |
|
| 293 | - |
|
| 294 | - |
|
| 295 | - /** |
|
| 296 | - * Front-end display of widget. |
|
| 297 | - * |
|
| 298 | - * @param array $args Widget arguments. |
|
| 299 | - * @param array $instance Saved values from database. |
|
| 300 | - * @throws EE_Error |
|
| 301 | - * @throws ReflectionException |
|
| 302 | - * @see WP_Widget::widget() |
|
| 303 | - * |
|
| 304 | - */ |
|
| 305 | - public function widget($args, $instance) |
|
| 306 | - { |
|
| 307 | - |
|
| 308 | - global $post; |
|
| 309 | - // make sure there is some kinda post object |
|
| 310 | - if ($post instanceof WP_Post) { |
|
| 311 | - $before_widget = ''; |
|
| 312 | - $before_title = ''; |
|
| 313 | - $after_title = ''; |
|
| 314 | - $after_widget = ''; |
|
| 315 | - // but NOT an events archives page, cuz that would be like two event lists on the same page |
|
| 316 | - $show_everywhere = ! isset($instance['show_everywhere']) || absint($instance['show_everywhere']); |
|
| 317 | - if ($show_everywhere || ! ($post->post_type == 'espresso_events' && is_archive())) { |
|
| 318 | - // let's use some of the event helper functions' |
|
| 319 | - // make separate vars out of attributes |
|
| 320 | - extract($args); |
|
| 321 | - |
|
| 322 | - // grab widget settings |
|
| 323 | - $this->parseWidgetSettings($instance); |
|
| 324 | - $title = $this->widgetTitle(); |
|
| 325 | - |
|
| 326 | - // Before widget (defined by themes). |
|
| 327 | - echo $before_widget; |
|
| 328 | - // Display the widget title if one was input (before and after defined by themes). |
|
| 329 | - if (! empty($title)) { |
|
| 330 | - echo $before_title . $title . $after_title; |
|
| 331 | - } |
|
| 332 | - echo $this->widgetContent($post); |
|
| 333 | - // After widget (defined by themes). |
|
| 334 | - echo $after_widget; |
|
| 335 | - } |
|
| 336 | - } |
|
| 337 | - } |
|
| 338 | - |
|
| 339 | - |
|
| 340 | - /** |
|
| 341 | - * make_the_title_a_link |
|
| 342 | - * callback for widget_title filter |
|
| 343 | - * |
|
| 344 | - * @param $title |
|
| 345 | - * @return string |
|
| 346 | - */ |
|
| 347 | - public function make_the_title_a_link($title) |
|
| 348 | - { |
|
| 349 | - return '<a href="' . EEH_Event_View::event_archive_url() . '">' . $title . '</a>'; |
|
| 350 | - } |
|
| 351 | - |
|
| 352 | - |
|
| 353 | - /** |
|
| 354 | - * @param string $field_name |
|
| 355 | - * @return string |
|
| 356 | - * @since 4.10.14.p |
|
| 357 | - */ |
|
| 358 | - public function fieldID($field_name) |
|
| 359 | - { |
|
| 360 | - return esc_attr(parent::get_field_id($field_name)); |
|
| 361 | - } |
|
| 362 | - |
|
| 363 | - |
|
| 364 | - /** |
|
| 365 | - * @param string $field_name |
|
| 366 | - * @return string |
|
| 367 | - * @since 4.10.14.p |
|
| 368 | - */ |
|
| 369 | - public function fieldName($field_name) |
|
| 370 | - { |
|
| 371 | - return esc_attr(parent::get_field_name($field_name)); |
|
| 372 | - } |
|
| 373 | - |
|
| 374 | - |
|
| 375 | - /** |
|
| 376 | - * @param array $instance |
|
| 377 | - * @throws EE_Error |
|
| 378 | - * @throws ReflectionException |
|
| 379 | - * @since 4.10.14.p |
|
| 380 | - */ |
|
| 381 | - private function eventCategoriesSelector(array $instance) |
|
| 382 | - { |
|
| 383 | - $event_categories = []; |
|
| 384 | - $categories = EEM_Term::instance()->get_all_ee_categories(true); |
|
| 385 | - if ($categories) { |
|
| 386 | - foreach ($categories as $category) { |
|
| 387 | - if ($category instanceof EE_Term) { |
|
| 388 | - $event_categories[] = |
|
| 389 | - EE_Question_Option::new_instance( |
|
| 390 | - [ |
|
| 391 | - 'QSO_value' => $category->get('slug'), |
|
| 392 | - 'QSO_desc' => $category->get('name'), |
|
| 393 | - ] |
|
| 394 | - ); |
|
| 395 | - } |
|
| 396 | - } |
|
| 397 | - } |
|
| 398 | - array_unshift( |
|
| 399 | - $event_categories, |
|
| 400 | - EE_Question_Option::new_instance( |
|
| 401 | - [ |
|
| 402 | - 'QSO_value' => '', |
|
| 403 | - 'QSO_desc' => esc_html__(' - display all - ', 'event_espresso'), |
|
| 404 | - ] |
|
| 405 | - ) |
|
| 406 | - ); |
|
| 407 | - echo EEH_Form_Fields::select( |
|
| 408 | - esc_html__('Event Category:', 'event_espresso'), |
|
| 409 | - $instance['category_name'], |
|
| 410 | - $event_categories, |
|
| 411 | - $this->fieldName('category_name'), |
|
| 412 | - $this->fieldID('category_name') |
|
| 413 | - ); |
|
| 414 | - } |
|
| 415 | - |
|
| 416 | - |
|
| 417 | - /** |
|
| 418 | - * @param array $instance |
|
| 419 | - * @since 4.10.14.p |
|
| 420 | - */ |
|
| 421 | - private function imageSizeSelector(array $instance) |
|
| 422 | - { |
|
| 423 | - $image_sizes = []; |
|
| 424 | - $sizes = get_intermediate_image_sizes(); |
|
| 425 | - if ($sizes) { |
|
| 426 | - // loop thru images and create option objects out of them |
|
| 427 | - foreach ($sizes as $image_size) { |
|
| 428 | - $image_size = trim($image_size); |
|
| 429 | - // no big images plz |
|
| 430 | - if (! in_array($image_size, ['large', 'post-thumbnail'])) { |
|
| 431 | - $image_sizes[] = |
|
| 432 | - EE_Question_Option::new_instance(['QSO_value' => $image_size, 'QSO_desc' => $image_size]); |
|
| 433 | - } |
|
| 434 | - } |
|
| 435 | - $image_sizes[] = |
|
| 436 | - EE_Question_Option::new_instance( |
|
| 437 | - ['QSO_value' => 'none', 'QSO_desc' => esc_html__('don\'t show images', 'event_espresso')] |
|
| 438 | - ); |
|
| 439 | - } |
|
| 440 | - echo EEH_Form_Fields::select( |
|
| 441 | - esc_html__('Image Size:', 'event_espresso'), |
|
| 442 | - $instance['image_size'], |
|
| 443 | - $image_sizes, |
|
| 444 | - $this->fieldName('image_size'), |
|
| 445 | - $this->fieldID('image_size') |
|
| 446 | - ); |
|
| 447 | - } |
|
| 448 | - |
|
| 449 | - |
|
| 450 | - /** |
|
| 451 | - * @param array $instance |
|
| 452 | - * @since 4.10.14.p |
|
| 453 | - */ |
|
| 454 | - private function parseWidgetSettings(array $instance) |
|
| 455 | - { |
|
| 456 | - $this->title = isset($instance['title']) && ! empty($instance['title']) ? $instance['title'] : ''; |
|
| 457 | - $this->category = isset($instance['category_name']) && ! empty($instance['category_name']) |
|
| 458 | - ? $instance['category_name'] |
|
| 459 | - : false; |
|
| 460 | - $this->show_expired = isset($instance['show_expired']) |
|
| 461 | - ? filter_var($instance['show_expired'], FILTER_VALIDATE_BOOLEAN) |
|
| 462 | - : 0; |
|
| 463 | - $this->image_size = isset($instance['image_size']) && ! empty($instance['image_size']) |
|
| 464 | - ? $instance['image_size'] |
|
| 465 | - : 'medium'; |
|
| 466 | - $this->show_desc = ! isset($instance['show_desc']) |
|
| 467 | - || filter_var($instance['show_desc'], FILTER_VALIDATE_BOOLEAN); |
|
| 468 | - $this->show_dates = ! isset($instance['show_dates']) |
|
| 469 | - || filter_var($instance['show_dates'], FILTER_VALIDATE_BOOLEAN); |
|
| 470 | - $this->date_limit = isset($instance['date_limit']) && ! empty($instance['date_limit']) |
|
| 471 | - ? $instance['date_limit'] |
|
| 472 | - : null; |
|
| 473 | - $this->date_range = isset($instance['date_range']) && ! empty($instance['date_range']) |
|
| 474 | - ? $instance['date_range'] |
|
| 475 | - : false; |
|
| 476 | - $this->limit = isset($instance['limit']) ? absint($instance['limit']) : 10; |
|
| 477 | - $this->order = isset($instance['order']) && $instance['order'] === 'DESC' |
|
| 478 | - ? 'DESC' |
|
| 479 | - : 'ASC'; |
|
| 480 | - } |
|
| 481 | - |
|
| 482 | - |
|
| 483 | - /** |
|
| 484 | - * @return mixed|void |
|
| 485 | - * @since 4.10.14.p |
|
| 486 | - */ |
|
| 487 | - private function widgetTitle() |
|
| 488 | - { |
|
| 489 | - // add function to make the title a link |
|
| 490 | - add_filter('widget_title', [$this, 'make_the_title_a_link'], 15); |
|
| 491 | - // filter the title |
|
| 492 | - $title = apply_filters('widget_title', $this->title); |
|
| 493 | - // remove the function from the filter, so it does not affect other widgets |
|
| 494 | - remove_filter('widget_title', [$this, 'make_the_title_a_link'], 15); |
|
| 495 | - return $title; |
|
| 496 | - } |
|
| 497 | - |
|
| 498 | - |
|
| 499 | - /** |
|
| 500 | - * @param WP_Post $post |
|
| 501 | - * @return string |
|
| 502 | - * @throws EE_Error |
|
| 503 | - * @throws ReflectionException |
|
| 504 | - * @since 4.10.14.p |
|
| 505 | - */ |
|
| 506 | - private function widgetContent(WP_Post $post) |
|
| 507 | - { |
|
| 508 | - // run the query |
|
| 509 | - $events = $this->getUpcomingEvents(); |
|
| 510 | - if (empty($events)) { |
|
| 511 | - return ''; |
|
| 512 | - } |
|
| 513 | - $list_items = ''; |
|
| 514 | - foreach ($events as $event) { |
|
| 515 | - if ($event instanceof EE_Event && (! is_single() || $post->ID != $event->ID())) { |
|
| 516 | - $event_url = $this->eventUrl($event); |
|
| 517 | - $list_items .= ' |
|
| 264 | + } |
|
| 265 | + |
|
| 266 | + |
|
| 267 | + /** |
|
| 268 | + * Sanitize widget form values as they are saved. |
|
| 269 | + * |
|
| 270 | + * @param array $new_instance Values just sent to be saved. |
|
| 271 | + * @param array $old_instance Previously saved values from database. |
|
| 272 | + * |
|
| 273 | + * @return array Updated safe values to be saved. |
|
| 274 | + * @see WP_Widget::update() |
|
| 275 | + * |
|
| 276 | + */ |
|
| 277 | + public function update($new_instance, $old_instance) |
|
| 278 | + { |
|
| 279 | + $instance = $old_instance; |
|
| 280 | + $instance['title'] = ! empty($new_instance['title']) ? strip_tags($new_instance['title']) : ''; |
|
| 281 | + $instance['category_name'] = $new_instance['category_name']; |
|
| 282 | + $instance['show_expired'] = $new_instance['show_expired']; |
|
| 283 | + $instance['limit'] = $new_instance['limit']; |
|
| 284 | + $instance['sort'] = $new_instance['sort']; |
|
| 285 | + $instance['image_size'] = $new_instance['image_size']; |
|
| 286 | + $instance['show_desc'] = $new_instance['show_desc']; |
|
| 287 | + $instance['show_dates'] = $new_instance['show_dates']; |
|
| 288 | + $instance['show_everywhere'] = $new_instance['show_everywhere']; |
|
| 289 | + $instance['date_limit'] = $new_instance['date_limit']; |
|
| 290 | + $instance['date_range'] = $new_instance['date_range']; |
|
| 291 | + return $instance; |
|
| 292 | + } |
|
| 293 | + |
|
| 294 | + |
|
| 295 | + /** |
|
| 296 | + * Front-end display of widget. |
|
| 297 | + * |
|
| 298 | + * @param array $args Widget arguments. |
|
| 299 | + * @param array $instance Saved values from database. |
|
| 300 | + * @throws EE_Error |
|
| 301 | + * @throws ReflectionException |
|
| 302 | + * @see WP_Widget::widget() |
|
| 303 | + * |
|
| 304 | + */ |
|
| 305 | + public function widget($args, $instance) |
|
| 306 | + { |
|
| 307 | + |
|
| 308 | + global $post; |
|
| 309 | + // make sure there is some kinda post object |
|
| 310 | + if ($post instanceof WP_Post) { |
|
| 311 | + $before_widget = ''; |
|
| 312 | + $before_title = ''; |
|
| 313 | + $after_title = ''; |
|
| 314 | + $after_widget = ''; |
|
| 315 | + // but NOT an events archives page, cuz that would be like two event lists on the same page |
|
| 316 | + $show_everywhere = ! isset($instance['show_everywhere']) || absint($instance['show_everywhere']); |
|
| 317 | + if ($show_everywhere || ! ($post->post_type == 'espresso_events' && is_archive())) { |
|
| 318 | + // let's use some of the event helper functions' |
|
| 319 | + // make separate vars out of attributes |
|
| 320 | + extract($args); |
|
| 321 | + |
|
| 322 | + // grab widget settings |
|
| 323 | + $this->parseWidgetSettings($instance); |
|
| 324 | + $title = $this->widgetTitle(); |
|
| 325 | + |
|
| 326 | + // Before widget (defined by themes). |
|
| 327 | + echo $before_widget; |
|
| 328 | + // Display the widget title if one was input (before and after defined by themes). |
|
| 329 | + if (! empty($title)) { |
|
| 330 | + echo $before_title . $title . $after_title; |
|
| 331 | + } |
|
| 332 | + echo $this->widgetContent($post); |
|
| 333 | + // After widget (defined by themes). |
|
| 334 | + echo $after_widget; |
|
| 335 | + } |
|
| 336 | + } |
|
| 337 | + } |
|
| 338 | + |
|
| 339 | + |
|
| 340 | + /** |
|
| 341 | + * make_the_title_a_link |
|
| 342 | + * callback for widget_title filter |
|
| 343 | + * |
|
| 344 | + * @param $title |
|
| 345 | + * @return string |
|
| 346 | + */ |
|
| 347 | + public function make_the_title_a_link($title) |
|
| 348 | + { |
|
| 349 | + return '<a href="' . EEH_Event_View::event_archive_url() . '">' . $title . '</a>'; |
|
| 350 | + } |
|
| 351 | + |
|
| 352 | + |
|
| 353 | + /** |
|
| 354 | + * @param string $field_name |
|
| 355 | + * @return string |
|
| 356 | + * @since 4.10.14.p |
|
| 357 | + */ |
|
| 358 | + public function fieldID($field_name) |
|
| 359 | + { |
|
| 360 | + return esc_attr(parent::get_field_id($field_name)); |
|
| 361 | + } |
|
| 362 | + |
|
| 363 | + |
|
| 364 | + /** |
|
| 365 | + * @param string $field_name |
|
| 366 | + * @return string |
|
| 367 | + * @since 4.10.14.p |
|
| 368 | + */ |
|
| 369 | + public function fieldName($field_name) |
|
| 370 | + { |
|
| 371 | + return esc_attr(parent::get_field_name($field_name)); |
|
| 372 | + } |
|
| 373 | + |
|
| 374 | + |
|
| 375 | + /** |
|
| 376 | + * @param array $instance |
|
| 377 | + * @throws EE_Error |
|
| 378 | + * @throws ReflectionException |
|
| 379 | + * @since 4.10.14.p |
|
| 380 | + */ |
|
| 381 | + private function eventCategoriesSelector(array $instance) |
|
| 382 | + { |
|
| 383 | + $event_categories = []; |
|
| 384 | + $categories = EEM_Term::instance()->get_all_ee_categories(true); |
|
| 385 | + if ($categories) { |
|
| 386 | + foreach ($categories as $category) { |
|
| 387 | + if ($category instanceof EE_Term) { |
|
| 388 | + $event_categories[] = |
|
| 389 | + EE_Question_Option::new_instance( |
|
| 390 | + [ |
|
| 391 | + 'QSO_value' => $category->get('slug'), |
|
| 392 | + 'QSO_desc' => $category->get('name'), |
|
| 393 | + ] |
|
| 394 | + ); |
|
| 395 | + } |
|
| 396 | + } |
|
| 397 | + } |
|
| 398 | + array_unshift( |
|
| 399 | + $event_categories, |
|
| 400 | + EE_Question_Option::new_instance( |
|
| 401 | + [ |
|
| 402 | + 'QSO_value' => '', |
|
| 403 | + 'QSO_desc' => esc_html__(' - display all - ', 'event_espresso'), |
|
| 404 | + ] |
|
| 405 | + ) |
|
| 406 | + ); |
|
| 407 | + echo EEH_Form_Fields::select( |
|
| 408 | + esc_html__('Event Category:', 'event_espresso'), |
|
| 409 | + $instance['category_name'], |
|
| 410 | + $event_categories, |
|
| 411 | + $this->fieldName('category_name'), |
|
| 412 | + $this->fieldID('category_name') |
|
| 413 | + ); |
|
| 414 | + } |
|
| 415 | + |
|
| 416 | + |
|
| 417 | + /** |
|
| 418 | + * @param array $instance |
|
| 419 | + * @since 4.10.14.p |
|
| 420 | + */ |
|
| 421 | + private function imageSizeSelector(array $instance) |
|
| 422 | + { |
|
| 423 | + $image_sizes = []; |
|
| 424 | + $sizes = get_intermediate_image_sizes(); |
|
| 425 | + if ($sizes) { |
|
| 426 | + // loop thru images and create option objects out of them |
|
| 427 | + foreach ($sizes as $image_size) { |
|
| 428 | + $image_size = trim($image_size); |
|
| 429 | + // no big images plz |
|
| 430 | + if (! in_array($image_size, ['large', 'post-thumbnail'])) { |
|
| 431 | + $image_sizes[] = |
|
| 432 | + EE_Question_Option::new_instance(['QSO_value' => $image_size, 'QSO_desc' => $image_size]); |
|
| 433 | + } |
|
| 434 | + } |
|
| 435 | + $image_sizes[] = |
|
| 436 | + EE_Question_Option::new_instance( |
|
| 437 | + ['QSO_value' => 'none', 'QSO_desc' => esc_html__('don\'t show images', 'event_espresso')] |
|
| 438 | + ); |
|
| 439 | + } |
|
| 440 | + echo EEH_Form_Fields::select( |
|
| 441 | + esc_html__('Image Size:', 'event_espresso'), |
|
| 442 | + $instance['image_size'], |
|
| 443 | + $image_sizes, |
|
| 444 | + $this->fieldName('image_size'), |
|
| 445 | + $this->fieldID('image_size') |
|
| 446 | + ); |
|
| 447 | + } |
|
| 448 | + |
|
| 449 | + |
|
| 450 | + /** |
|
| 451 | + * @param array $instance |
|
| 452 | + * @since 4.10.14.p |
|
| 453 | + */ |
|
| 454 | + private function parseWidgetSettings(array $instance) |
|
| 455 | + { |
|
| 456 | + $this->title = isset($instance['title']) && ! empty($instance['title']) ? $instance['title'] : ''; |
|
| 457 | + $this->category = isset($instance['category_name']) && ! empty($instance['category_name']) |
|
| 458 | + ? $instance['category_name'] |
|
| 459 | + : false; |
|
| 460 | + $this->show_expired = isset($instance['show_expired']) |
|
| 461 | + ? filter_var($instance['show_expired'], FILTER_VALIDATE_BOOLEAN) |
|
| 462 | + : 0; |
|
| 463 | + $this->image_size = isset($instance['image_size']) && ! empty($instance['image_size']) |
|
| 464 | + ? $instance['image_size'] |
|
| 465 | + : 'medium'; |
|
| 466 | + $this->show_desc = ! isset($instance['show_desc']) |
|
| 467 | + || filter_var($instance['show_desc'], FILTER_VALIDATE_BOOLEAN); |
|
| 468 | + $this->show_dates = ! isset($instance['show_dates']) |
|
| 469 | + || filter_var($instance['show_dates'], FILTER_VALIDATE_BOOLEAN); |
|
| 470 | + $this->date_limit = isset($instance['date_limit']) && ! empty($instance['date_limit']) |
|
| 471 | + ? $instance['date_limit'] |
|
| 472 | + : null; |
|
| 473 | + $this->date_range = isset($instance['date_range']) && ! empty($instance['date_range']) |
|
| 474 | + ? $instance['date_range'] |
|
| 475 | + : false; |
|
| 476 | + $this->limit = isset($instance['limit']) ? absint($instance['limit']) : 10; |
|
| 477 | + $this->order = isset($instance['order']) && $instance['order'] === 'DESC' |
|
| 478 | + ? 'DESC' |
|
| 479 | + : 'ASC'; |
|
| 480 | + } |
|
| 481 | + |
|
| 482 | + |
|
| 483 | + /** |
|
| 484 | + * @return mixed|void |
|
| 485 | + * @since 4.10.14.p |
|
| 486 | + */ |
|
| 487 | + private function widgetTitle() |
|
| 488 | + { |
|
| 489 | + // add function to make the title a link |
|
| 490 | + add_filter('widget_title', [$this, 'make_the_title_a_link'], 15); |
|
| 491 | + // filter the title |
|
| 492 | + $title = apply_filters('widget_title', $this->title); |
|
| 493 | + // remove the function from the filter, so it does not affect other widgets |
|
| 494 | + remove_filter('widget_title', [$this, 'make_the_title_a_link'], 15); |
|
| 495 | + return $title; |
|
| 496 | + } |
|
| 497 | + |
|
| 498 | + |
|
| 499 | + /** |
|
| 500 | + * @param WP_Post $post |
|
| 501 | + * @return string |
|
| 502 | + * @throws EE_Error |
|
| 503 | + * @throws ReflectionException |
|
| 504 | + * @since 4.10.14.p |
|
| 505 | + */ |
|
| 506 | + private function widgetContent(WP_Post $post) |
|
| 507 | + { |
|
| 508 | + // run the query |
|
| 509 | + $events = $this->getUpcomingEvents(); |
|
| 510 | + if (empty($events)) { |
|
| 511 | + return ''; |
|
| 512 | + } |
|
| 513 | + $list_items = ''; |
|
| 514 | + foreach ($events as $event) { |
|
| 515 | + if ($event instanceof EE_Event && (! is_single() || $post->ID != $event->ID())) { |
|
| 516 | + $event_url = $this->eventUrl($event); |
|
| 517 | + $list_items .= ' |
|
| 518 | 518 | <li id="ee-upcoming-events-widget-li-' . esc_attr($event->ID()) . '" |
| 519 | 519 | class="ee-upcoming-events-widget-li" |
| 520 | 520 | > |
@@ -525,193 +525,193 @@ discard block |
||
| 525 | 525 | </h5> |
| 526 | 526 | ' . $this->eventWidgetContent($event, $event_url) . ' |
| 527 | 527 | </li>'; |
| 528 | - } |
|
| 529 | - } |
|
| 530 | - return ' |
|
| 528 | + } |
|
| 529 | + } |
|
| 530 | + return ' |
|
| 531 | 531 | <ul class="ee-upcoming-events-widget-ul"> |
| 532 | 532 | ' . $list_items . ' |
| 533 | 533 | </ul>'; |
| 534 | - } |
|
| 535 | - |
|
| 536 | - |
|
| 537 | - /** |
|
| 538 | - * @param EE_Event $event |
|
| 539 | - * @return string|null |
|
| 540 | - * @throws EE_Error |
|
| 541 | - * @since 4.10.14.p |
|
| 542 | - */ |
|
| 543 | - private function eventUrl(EE_Event $event) |
|
| 544 | - { |
|
| 545 | - return esc_url_raw( |
|
| 546 | - apply_filters( |
|
| 547 | - 'FHEE_EEW_Upcoming_Events__widget__event_url', |
|
| 548 | - $event->get_permalink(), |
|
| 549 | - $event |
|
| 550 | - ) |
|
| 551 | - ); |
|
| 552 | - } |
|
| 553 | - |
|
| 554 | - |
|
| 555 | - /** |
|
| 556 | - * @return EE_Base_Class[] |
|
| 557 | - * @throws EE_Error |
|
| 558 | - */ |
|
| 559 | - private function getUpcomingEvents() |
|
| 560 | - { |
|
| 561 | - return EEM_Event::instance()->get_all( |
|
| 562 | - [ |
|
| 563 | - $this->queryWhereParams(), |
|
| 564 | - 'limit' => '0,' . $this->limit, |
|
| 565 | - 'order_by' => 'Datetime.DTT_EVT_start', |
|
| 566 | - 'order' => $this->order, |
|
| 567 | - 'group_by' => 'EVT_ID', |
|
| 568 | - ] |
|
| 569 | - ); |
|
| 570 | - } |
|
| 571 | - |
|
| 572 | - |
|
| 573 | - /** |
|
| 574 | - * @return mixed|void |
|
| 575 | - * @throws EE_Error |
|
| 576 | - * @since 4.10.14.p |
|
| 577 | - */ |
|
| 578 | - private function queryWhereParams() |
|
| 579 | - { |
|
| 580 | - // start to build our where clause |
|
| 581 | - $where = [ |
|
| 582 | - 'status' => ['IN', ['publish', 'sold_out']], |
|
| 583 | - ]; |
|
| 584 | - // add category |
|
| 585 | - if ($this->category) { |
|
| 586 | - $where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
|
| 587 | - $where['Term_Taxonomy.Term.slug'] = $this->category; |
|
| 588 | - } |
|
| 589 | - // if NOT expired then we want events that start today or in the future |
|
| 590 | - // if NOT show expired then we want events that start today or in the future |
|
| 591 | - if ($this->show_expired == 0) { |
|
| 592 | - $where['Datetime.DTT_EVT_end'] = [ |
|
| 593 | - '>=', |
|
| 594 | - EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'), |
|
| 595 | - ]; |
|
| 596 | - } |
|
| 597 | - // if show ONLY expired we want events that ended prior to today |
|
| 598 | - if ($this->show_expired == 2) { |
|
| 599 | - $where['Datetime.DTT_EVT_end'] = [ |
|
| 600 | - '<=', |
|
| 601 | - EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'), |
|
| 602 | - ]; |
|
| 603 | - } |
|
| 604 | - // allow $where to be filtered |
|
| 605 | - return apply_filters('FHEE__EEW_Upcoming_Events__widget__where', $where, $this->category, $this->show_expired); |
|
| 606 | - } |
|
| 607 | - |
|
| 608 | - |
|
| 609 | - /** |
|
| 610 | - * @param EE_Event $event |
|
| 611 | - * @return string |
|
| 612 | - * @throws EE_Error |
|
| 613 | - * @throws ReflectionException |
|
| 614 | - * @since 4.10.14.p |
|
| 615 | - */ |
|
| 616 | - private function linkClass(EE_Event $event) |
|
| 617 | - { |
|
| 618 | - // how big is the event name ? |
|
| 619 | - $name_length = strlen($event->name()); |
|
| 620 | - switch ($name_length) { |
|
| 621 | - case $name_length > 70: |
|
| 622 | - return ' three-line'; |
|
| 623 | - case $name_length > 35: |
|
| 624 | - return ' two-line'; |
|
| 625 | - } |
|
| 626 | - return ' one-line'; |
|
| 627 | - } |
|
| 628 | - |
|
| 629 | - |
|
| 630 | - /** |
|
| 631 | - * @param EE_Event $event |
|
| 632 | - * @param string $event_url |
|
| 633 | - * @return mixed|string|void |
|
| 634 | - * @throws EE_Error |
|
| 635 | - * @throws ReflectionException |
|
| 636 | - * @since 4.10.14.p |
|
| 637 | - */ |
|
| 638 | - private function eventWidgetContent(EE_Event $event, $event_url = '') |
|
| 639 | - { |
|
| 640 | - if (post_password_required($event->ID())) { |
|
| 641 | - return apply_filters( |
|
| 642 | - 'FHEE_EEW_Upcoming_Events__widget__password_form', |
|
| 643 | - get_the_password_form($event->ID()), |
|
| 644 | - $event |
|
| 645 | - ); |
|
| 646 | - } |
|
| 647 | - |
|
| 648 | - $content = ''; |
|
| 649 | - if (has_post_thumbnail($event->ID()) && $this->image_size != 'none') { |
|
| 650 | - $content .= ' |
|
| 534 | + } |
|
| 535 | + |
|
| 536 | + |
|
| 537 | + /** |
|
| 538 | + * @param EE_Event $event |
|
| 539 | + * @return string|null |
|
| 540 | + * @throws EE_Error |
|
| 541 | + * @since 4.10.14.p |
|
| 542 | + */ |
|
| 543 | + private function eventUrl(EE_Event $event) |
|
| 544 | + { |
|
| 545 | + return esc_url_raw( |
|
| 546 | + apply_filters( |
|
| 547 | + 'FHEE_EEW_Upcoming_Events__widget__event_url', |
|
| 548 | + $event->get_permalink(), |
|
| 549 | + $event |
|
| 550 | + ) |
|
| 551 | + ); |
|
| 552 | + } |
|
| 553 | + |
|
| 554 | + |
|
| 555 | + /** |
|
| 556 | + * @return EE_Base_Class[] |
|
| 557 | + * @throws EE_Error |
|
| 558 | + */ |
|
| 559 | + private function getUpcomingEvents() |
|
| 560 | + { |
|
| 561 | + return EEM_Event::instance()->get_all( |
|
| 562 | + [ |
|
| 563 | + $this->queryWhereParams(), |
|
| 564 | + 'limit' => '0,' . $this->limit, |
|
| 565 | + 'order_by' => 'Datetime.DTT_EVT_start', |
|
| 566 | + 'order' => $this->order, |
|
| 567 | + 'group_by' => 'EVT_ID', |
|
| 568 | + ] |
|
| 569 | + ); |
|
| 570 | + } |
|
| 571 | + |
|
| 572 | + |
|
| 573 | + /** |
|
| 574 | + * @return mixed|void |
|
| 575 | + * @throws EE_Error |
|
| 576 | + * @since 4.10.14.p |
|
| 577 | + */ |
|
| 578 | + private function queryWhereParams() |
|
| 579 | + { |
|
| 580 | + // start to build our where clause |
|
| 581 | + $where = [ |
|
| 582 | + 'status' => ['IN', ['publish', 'sold_out']], |
|
| 583 | + ]; |
|
| 584 | + // add category |
|
| 585 | + if ($this->category) { |
|
| 586 | + $where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
|
| 587 | + $where['Term_Taxonomy.Term.slug'] = $this->category; |
|
| 588 | + } |
|
| 589 | + // if NOT expired then we want events that start today or in the future |
|
| 590 | + // if NOT show expired then we want events that start today or in the future |
|
| 591 | + if ($this->show_expired == 0) { |
|
| 592 | + $where['Datetime.DTT_EVT_end'] = [ |
|
| 593 | + '>=', |
|
| 594 | + EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'), |
|
| 595 | + ]; |
|
| 596 | + } |
|
| 597 | + // if show ONLY expired we want events that ended prior to today |
|
| 598 | + if ($this->show_expired == 2) { |
|
| 599 | + $where['Datetime.DTT_EVT_end'] = [ |
|
| 600 | + '<=', |
|
| 601 | + EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'), |
|
| 602 | + ]; |
|
| 603 | + } |
|
| 604 | + // allow $where to be filtered |
|
| 605 | + return apply_filters('FHEE__EEW_Upcoming_Events__widget__where', $where, $this->category, $this->show_expired); |
|
| 606 | + } |
|
| 607 | + |
|
| 608 | + |
|
| 609 | + /** |
|
| 610 | + * @param EE_Event $event |
|
| 611 | + * @return string |
|
| 612 | + * @throws EE_Error |
|
| 613 | + * @throws ReflectionException |
|
| 614 | + * @since 4.10.14.p |
|
| 615 | + */ |
|
| 616 | + private function linkClass(EE_Event $event) |
|
| 617 | + { |
|
| 618 | + // how big is the event name ? |
|
| 619 | + $name_length = strlen($event->name()); |
|
| 620 | + switch ($name_length) { |
|
| 621 | + case $name_length > 70: |
|
| 622 | + return ' three-line'; |
|
| 623 | + case $name_length > 35: |
|
| 624 | + return ' two-line'; |
|
| 625 | + } |
|
| 626 | + return ' one-line'; |
|
| 627 | + } |
|
| 628 | + |
|
| 629 | + |
|
| 630 | + /** |
|
| 631 | + * @param EE_Event $event |
|
| 632 | + * @param string $event_url |
|
| 633 | + * @return mixed|string|void |
|
| 634 | + * @throws EE_Error |
|
| 635 | + * @throws ReflectionException |
|
| 636 | + * @since 4.10.14.p |
|
| 637 | + */ |
|
| 638 | + private function eventWidgetContent(EE_Event $event, $event_url = '') |
|
| 639 | + { |
|
| 640 | + if (post_password_required($event->ID())) { |
|
| 641 | + return apply_filters( |
|
| 642 | + 'FHEE_EEW_Upcoming_Events__widget__password_form', |
|
| 643 | + get_the_password_form($event->ID()), |
|
| 644 | + $event |
|
| 645 | + ); |
|
| 646 | + } |
|
| 647 | + |
|
| 648 | + $content = ''; |
|
| 649 | + if (has_post_thumbnail($event->ID()) && $this->image_size != 'none') { |
|
| 650 | + $content .= ' |
|
| 651 | 651 | <div class="ee-upcoming-events-widget-img-dv"> |
| 652 | 652 | <a class="ee-upcoming-events-widget-img" href="' . $event_url . '"> |
| 653 | 653 | ' . get_the_post_thumbnail($event->ID(), $this->image_size) . ' |
| 654 | 654 | </a> |
| 655 | 655 | </div>'; |
| 656 | - } |
|
| 657 | - |
|
| 658 | - if ($this->show_dates) { |
|
| 659 | - $content .= $this->eventDates($event); |
|
| 660 | - } |
|
| 661 | - |
|
| 662 | - if ($this->show_desc) { |
|
| 663 | - global $allowedtags; |
|
| 664 | - $desc = $event->short_description(25); |
|
| 665 | - $content .= $desc ? '<p style="margin-top: .5em">' . wp_kses($desc, $allowedtags) . '</p>' : ''; |
|
| 666 | - } |
|
| 667 | - |
|
| 668 | - return $content; |
|
| 669 | - } |
|
| 670 | - |
|
| 671 | - |
|
| 672 | - /** |
|
| 673 | - * @param EE_Event $event |
|
| 674 | - * @return string |
|
| 675 | - * @throws EE_Error |
|
| 676 | - * @throws ReflectionException |
|
| 677 | - * @since 4.10.14.p |
|
| 678 | - */ |
|
| 679 | - private function eventDates(EE_Event $event) |
|
| 680 | - { |
|
| 681 | - $date_format = apply_filters( |
|
| 682 | - 'FHEE__espresso_event_date_range__date_format', |
|
| 683 | - get_option('date_format') |
|
| 684 | - ); |
|
| 685 | - $time_format = apply_filters( |
|
| 686 | - 'FHEE__espresso_event_date_range__time_format', |
|
| 687 | - get_option('time_format') |
|
| 688 | - ); |
|
| 689 | - $single_date_format = apply_filters( |
|
| 690 | - 'FHEE__espresso_event_date_range__single_date_format', |
|
| 691 | - get_option('date_format') |
|
| 692 | - ); |
|
| 693 | - $single_time_format = apply_filters( |
|
| 694 | - 'FHEE__espresso_event_date_range__single_time_format', |
|
| 695 | - get_option('time_format') |
|
| 696 | - ); |
|
| 697 | - if ($this->date_range == true) { |
|
| 698 | - return espresso_event_date_range( |
|
| 699 | - $date_format, |
|
| 700 | - $time_format, |
|
| 701 | - $single_date_format, |
|
| 702 | - $single_time_format, |
|
| 703 | - $event->ID() |
|
| 704 | - ); |
|
| 705 | - } |
|
| 706 | - return espresso_list_of_event_dates( |
|
| 707 | - $event->ID(), |
|
| 708 | - $date_format, |
|
| 709 | - $time_format, |
|
| 710 | - false, |
|
| 711 | - null, |
|
| 712 | - true, |
|
| 713 | - true, |
|
| 714 | - $this->date_limit |
|
| 715 | - ); |
|
| 716 | - } |
|
| 656 | + } |
|
| 657 | + |
|
| 658 | + if ($this->show_dates) { |
|
| 659 | + $content .= $this->eventDates($event); |
|
| 660 | + } |
|
| 661 | + |
|
| 662 | + if ($this->show_desc) { |
|
| 663 | + global $allowedtags; |
|
| 664 | + $desc = $event->short_description(25); |
|
| 665 | + $content .= $desc ? '<p style="margin-top: .5em">' . wp_kses($desc, $allowedtags) . '</p>' : ''; |
|
| 666 | + } |
|
| 667 | + |
|
| 668 | + return $content; |
|
| 669 | + } |
|
| 670 | + |
|
| 671 | + |
|
| 672 | + /** |
|
| 673 | + * @param EE_Event $event |
|
| 674 | + * @return string |
|
| 675 | + * @throws EE_Error |
|
| 676 | + * @throws ReflectionException |
|
| 677 | + * @since 4.10.14.p |
|
| 678 | + */ |
|
| 679 | + private function eventDates(EE_Event $event) |
|
| 680 | + { |
|
| 681 | + $date_format = apply_filters( |
|
| 682 | + 'FHEE__espresso_event_date_range__date_format', |
|
| 683 | + get_option('date_format') |
|
| 684 | + ); |
|
| 685 | + $time_format = apply_filters( |
|
| 686 | + 'FHEE__espresso_event_date_range__time_format', |
|
| 687 | + get_option('time_format') |
|
| 688 | + ); |
|
| 689 | + $single_date_format = apply_filters( |
|
| 690 | + 'FHEE__espresso_event_date_range__single_date_format', |
|
| 691 | + get_option('date_format') |
|
| 692 | + ); |
|
| 693 | + $single_time_format = apply_filters( |
|
| 694 | + 'FHEE__espresso_event_date_range__single_time_format', |
|
| 695 | + get_option('time_format') |
|
| 696 | + ); |
|
| 697 | + if ($this->date_range == true) { |
|
| 698 | + return espresso_event_date_range( |
|
| 699 | + $date_format, |
|
| 700 | + $time_format, |
|
| 701 | + $single_date_format, |
|
| 702 | + $single_time_format, |
|
| 703 | + $event->ID() |
|
| 704 | + ); |
|
| 705 | + } |
|
| 706 | + return espresso_list_of_event_dates( |
|
| 707 | + $event->ID(), |
|
| 708 | + $date_format, |
|
| 709 | + $time_format, |
|
| 710 | + false, |
|
| 711 | + null, |
|
| 712 | + true, |
|
| 713 | + true, |
|
| 714 | + $this->date_limit |
|
| 715 | + ); |
|
| 716 | + } |
|
| 717 | 717 | } |
@@ -17,306 +17,306 @@ |
||
| 17 | 17 | class EED_Bot_Trap extends EED_Module |
| 18 | 18 | { |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * @return EED_Module|EED_Bot_Trap |
|
| 22 | - * @throws EE_Error |
|
| 23 | - * @throws ReflectionException |
|
| 24 | - */ |
|
| 25 | - public static function instance() |
|
| 26 | - { |
|
| 27 | - return parent::get_instance(__CLASS__); |
|
| 28 | - } |
|
| 20 | + /** |
|
| 21 | + * @return EED_Module|EED_Bot_Trap |
|
| 22 | + * @throws EE_Error |
|
| 23 | + * @throws ReflectionException |
|
| 24 | + */ |
|
| 25 | + public static function instance() |
|
| 26 | + { |
|
| 27 | + return parent::get_instance(__CLASS__); |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
| 33 | - * |
|
| 34 | - * @return void |
|
| 35 | - */ |
|
| 36 | - public static function set_hooks() |
|
| 37 | - { |
|
| 38 | - if ( |
|
| 39 | - apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) && |
|
| 40 | - EE_Registry::instance()->CFG->registration->use_bot_trap |
|
| 41 | - ) { |
|
| 42 | - EED_Bot_Trap::set_trap(); |
|
| 43 | - // redirect bots to bogus success page |
|
| 44 | - EE_Config::register_route( |
|
| 45 | - 'ticket_selection_received', |
|
| 46 | - 'EED_Bot_Trap', |
|
| 47 | - 'display_bot_trap_success' |
|
| 48 | - ); |
|
| 49 | - } |
|
| 50 | - } |
|
| 31 | + /** |
|
| 32 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
| 33 | + * |
|
| 34 | + * @return void |
|
| 35 | + */ |
|
| 36 | + public static function set_hooks() |
|
| 37 | + { |
|
| 38 | + if ( |
|
| 39 | + apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) && |
|
| 40 | + EE_Registry::instance()->CFG->registration->use_bot_trap |
|
| 41 | + ) { |
|
| 42 | + EED_Bot_Trap::set_trap(); |
|
| 43 | + // redirect bots to bogus success page |
|
| 44 | + EE_Config::register_route( |
|
| 45 | + 'ticket_selection_received', |
|
| 46 | + 'EED_Bot_Trap', |
|
| 47 | + 'display_bot_trap_success' |
|
| 48 | + ); |
|
| 49 | + } |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
| 55 | - * |
|
| 56 | - * @return void |
|
| 57 | - */ |
|
| 58 | - public static function set_trap() |
|
| 59 | - { |
|
| 60 | - define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . '/'); |
|
| 61 | - add_action( |
|
| 62 | - 'AHEE__ticket_selector_chart__template__after_ticket_selector', |
|
| 63 | - array('EED_Bot_Trap', 'generate_bot_trap'), |
|
| 64 | - 10, |
|
| 65 | - 2 |
|
| 66 | - ); |
|
| 67 | - add_action( |
|
| 68 | - 'EED_Ticket_Selector__process_ticket_selections__before', |
|
| 69 | - array('EED_Bot_Trap', 'process_bot_trap'), |
|
| 70 | - 1, |
|
| 71 | - 2 |
|
| 72 | - ); |
|
| 73 | - } |
|
| 53 | + /** |
|
| 54 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
| 55 | + * |
|
| 56 | + * @return void |
|
| 57 | + */ |
|
| 58 | + public static function set_trap() |
|
| 59 | + { |
|
| 60 | + define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . '/'); |
|
| 61 | + add_action( |
|
| 62 | + 'AHEE__ticket_selector_chart__template__after_ticket_selector', |
|
| 63 | + array('EED_Bot_Trap', 'generate_bot_trap'), |
|
| 64 | + 10, |
|
| 65 | + 2 |
|
| 66 | + ); |
|
| 67 | + add_action( |
|
| 68 | + 'EED_Ticket_Selector__process_ticket_selections__before', |
|
| 69 | + array('EED_Bot_Trap', 'process_bot_trap'), |
|
| 70 | + 1, |
|
| 71 | + 2 |
|
| 72 | + ); |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
| 78 | - * |
|
| 79 | - * @return void |
|
| 80 | - */ |
|
| 81 | - public static function set_hooks_admin() |
|
| 82 | - { |
|
| 83 | - if ( |
|
| 84 | - EED_Bot_Trap::getRequest()->isAjax() |
|
| 85 | - && apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) |
|
| 86 | - && EE_Registry::instance()->CFG->registration->use_bot_trap |
|
| 87 | - ) { |
|
| 88 | - EED_Bot_Trap::set_trap(); |
|
| 89 | - } |
|
| 90 | - add_action( |
|
| 91 | - 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
| 92 | - array('EED_Bot_Trap', 'bot_trap_settings_form'), |
|
| 93 | - 5 |
|
| 94 | - ); |
|
| 95 | - add_filter( |
|
| 96 | - 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', |
|
| 97 | - array('EED_Bot_Trap', 'update_bot_trap_settings_form'), |
|
| 98 | - 10, |
|
| 99 | - 1 |
|
| 100 | - ); |
|
| 101 | - } |
|
| 76 | + /** |
|
| 77 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
| 78 | + * |
|
| 79 | + * @return void |
|
| 80 | + */ |
|
| 81 | + public static function set_hooks_admin() |
|
| 82 | + { |
|
| 83 | + if ( |
|
| 84 | + EED_Bot_Trap::getRequest()->isAjax() |
|
| 85 | + && apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) |
|
| 86 | + && EE_Registry::instance()->CFG->registration->use_bot_trap |
|
| 87 | + ) { |
|
| 88 | + EED_Bot_Trap::set_trap(); |
|
| 89 | + } |
|
| 90 | + add_action( |
|
| 91 | + 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
| 92 | + array('EED_Bot_Trap', 'bot_trap_settings_form'), |
|
| 93 | + 5 |
|
| 94 | + ); |
|
| 95 | + add_filter( |
|
| 96 | + 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', |
|
| 97 | + array('EED_Bot_Trap', 'update_bot_trap_settings_form'), |
|
| 98 | + 10, |
|
| 99 | + 1 |
|
| 100 | + ); |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | 103 | |
| 104 | - /** |
|
| 105 | - * run - initial module setup |
|
| 106 | - * |
|
| 107 | - * @param WP $WP |
|
| 108 | - * @return void |
|
| 109 | - */ |
|
| 110 | - public function run($WP) |
|
| 111 | - { |
|
| 112 | - } |
|
| 104 | + /** |
|
| 105 | + * run - initial module setup |
|
| 106 | + * |
|
| 107 | + * @param WP $WP |
|
| 108 | + * @return void |
|
| 109 | + */ |
|
| 110 | + public function run($WP) |
|
| 111 | + { |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | 114 | |
| 115 | - /** |
|
| 116 | - * generate_bot_trap |
|
| 117 | - * |
|
| 118 | - * @return void |
|
| 119 | - * @throws RuntimeException |
|
| 120 | - */ |
|
| 121 | - public static function generate_bot_trap() |
|
| 122 | - { |
|
| 123 | - $do_not_enter = esc_html__('please do not enter anything in this input', 'event_espresso'); |
|
| 124 | - $time = esc_attr(microtime(true)); |
|
| 125 | - $html = '<div class="tkt-slctr-request-processor-dv" style="float:left; margin:0 0 0 -999em; height: 0;">'; |
|
| 126 | - $html .= '<label for="tkt-slctr-request-processor-email-' . $time . '">' . $do_not_enter . '</label>'; |
|
| 127 | - $html .= '<input type="email" id="tkt-slctr-request-processor-email-'; |
|
| 128 | - $html .= $time . '" name="tkt-slctr-request-processor-email" value=""/>'; |
|
| 129 | - $html .= '</div><!-- .tkt-slctr-request-processor-dv -->'; |
|
| 130 | - echo $html; // already escaped |
|
| 131 | - } |
|
| 115 | + /** |
|
| 116 | + * generate_bot_trap |
|
| 117 | + * |
|
| 118 | + * @return void |
|
| 119 | + * @throws RuntimeException |
|
| 120 | + */ |
|
| 121 | + public static function generate_bot_trap() |
|
| 122 | + { |
|
| 123 | + $do_not_enter = esc_html__('please do not enter anything in this input', 'event_espresso'); |
|
| 124 | + $time = esc_attr(microtime(true)); |
|
| 125 | + $html = '<div class="tkt-slctr-request-processor-dv" style="float:left; margin:0 0 0 -999em; height: 0;">'; |
|
| 126 | + $html .= '<label for="tkt-slctr-request-processor-email-' . $time . '">' . $do_not_enter . '</label>'; |
|
| 127 | + $html .= '<input type="email" id="tkt-slctr-request-processor-email-'; |
|
| 128 | + $html .= $time . '" name="tkt-slctr-request-processor-email" value=""/>'; |
|
| 129 | + $html .= '</div><!-- .tkt-slctr-request-processor-dv -->'; |
|
| 130 | + echo $html; // already escaped |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | 133 | |
| 134 | - /** |
|
| 135 | - * process_bot_trap |
|
| 136 | - * |
|
| 137 | - * @param array|string $triggered_trap_callback Callback that will be executed for handling the |
|
| 138 | - * response if the bot trap is triggered. |
|
| 139 | - * It should receive one argument: a boolean indicating |
|
| 140 | - * whether the trap was triggered by suspicious timing or not. |
|
| 141 | - * @throws RuntimeException |
|
| 142 | - */ |
|
| 143 | - public static function process_bot_trap($triggered_trap_callback = array()) |
|
| 144 | - { |
|
| 145 | - // what's your email address Mr. Bot ? |
|
| 146 | - $empty_trap = EED_Bot_Trap::getRequest()->getRequestParam('tkt-slctr-request-processor-email') === ''; |
|
| 147 | - // are we human ? |
|
| 148 | - if ($empty_trap) { |
|
| 149 | - do_action('AHEE__EED_Bot_Trap__process_bot_trap__trap_not_triggered'); |
|
| 150 | - return; |
|
| 151 | - } |
|
| 152 | - // check the given callback is valid first before executing |
|
| 153 | - if (! is_callable($triggered_trap_callback)) { |
|
| 154 | - // invalid callback so lets just sub in our default. |
|
| 155 | - $triggered_trap_callback = array('EED_Bot_Trap', 'triggered_trap_response'); |
|
| 156 | - } |
|
| 157 | - call_user_func($triggered_trap_callback); |
|
| 158 | - } |
|
| 134 | + /** |
|
| 135 | + * process_bot_trap |
|
| 136 | + * |
|
| 137 | + * @param array|string $triggered_trap_callback Callback that will be executed for handling the |
|
| 138 | + * response if the bot trap is triggered. |
|
| 139 | + * It should receive one argument: a boolean indicating |
|
| 140 | + * whether the trap was triggered by suspicious timing or not. |
|
| 141 | + * @throws RuntimeException |
|
| 142 | + */ |
|
| 143 | + public static function process_bot_trap($triggered_trap_callback = array()) |
|
| 144 | + { |
|
| 145 | + // what's your email address Mr. Bot ? |
|
| 146 | + $empty_trap = EED_Bot_Trap::getRequest()->getRequestParam('tkt-slctr-request-processor-email') === ''; |
|
| 147 | + // are we human ? |
|
| 148 | + if ($empty_trap) { |
|
| 149 | + do_action('AHEE__EED_Bot_Trap__process_bot_trap__trap_not_triggered'); |
|
| 150 | + return; |
|
| 151 | + } |
|
| 152 | + // check the given callback is valid first before executing |
|
| 153 | + if (! is_callable($triggered_trap_callback)) { |
|
| 154 | + // invalid callback so lets just sub in our default. |
|
| 155 | + $triggered_trap_callback = array('EED_Bot_Trap', 'triggered_trap_response'); |
|
| 156 | + } |
|
| 157 | + call_user_func($triggered_trap_callback); |
|
| 158 | + } |
|
| 159 | 159 | |
| 160 | 160 | |
| 161 | - /** |
|
| 162 | - * This is the default callback executed by EED_Bot_Trap::process_bot_trap that handles the response. |
|
| 163 | - * |
|
| 164 | - * @throws InvalidArgumentException |
|
| 165 | - * @throws InvalidDataTypeException |
|
| 166 | - * @throws InvalidInterfaceException |
|
| 167 | - */ |
|
| 168 | - public static function triggered_trap_response() |
|
| 169 | - { |
|
| 170 | - // UH OH... |
|
| 171 | - $redirect_url = apply_filters( |
|
| 172 | - 'FHEE__EED_Bot_Trap__process_bot_trap__redirect_url', |
|
| 173 | - add_query_arg( |
|
| 174 | - array('ee' => 'ticket_selection_received'), |
|
| 175 | - EE_Registry::instance()->CFG->core->reg_page_url() |
|
| 176 | - ) |
|
| 177 | - ); |
|
| 178 | - // if AJAX, return the redirect URL |
|
| 179 | - if (EED_Bot_Trap::getRequest()->isAjax()) { |
|
| 180 | - echo wp_json_encode( |
|
| 181 | - array_merge( |
|
| 182 | - EE_Error::get_notices(false), |
|
| 183 | - array( |
|
| 184 | - 'redirect_url' => $redirect_url, |
|
| 185 | - ) |
|
| 186 | - ) |
|
| 187 | - ); |
|
| 188 | - exit(); |
|
| 189 | - } |
|
| 190 | - wp_safe_redirect($redirect_url); |
|
| 191 | - exit(); |
|
| 192 | - } |
|
| 161 | + /** |
|
| 162 | + * This is the default callback executed by EED_Bot_Trap::process_bot_trap that handles the response. |
|
| 163 | + * |
|
| 164 | + * @throws InvalidArgumentException |
|
| 165 | + * @throws InvalidDataTypeException |
|
| 166 | + * @throws InvalidInterfaceException |
|
| 167 | + */ |
|
| 168 | + public static function triggered_trap_response() |
|
| 169 | + { |
|
| 170 | + // UH OH... |
|
| 171 | + $redirect_url = apply_filters( |
|
| 172 | + 'FHEE__EED_Bot_Trap__process_bot_trap__redirect_url', |
|
| 173 | + add_query_arg( |
|
| 174 | + array('ee' => 'ticket_selection_received'), |
|
| 175 | + EE_Registry::instance()->CFG->core->reg_page_url() |
|
| 176 | + ) |
|
| 177 | + ); |
|
| 178 | + // if AJAX, return the redirect URL |
|
| 179 | + if (EED_Bot_Trap::getRequest()->isAjax()) { |
|
| 180 | + echo wp_json_encode( |
|
| 181 | + array_merge( |
|
| 182 | + EE_Error::get_notices(false), |
|
| 183 | + array( |
|
| 184 | + 'redirect_url' => $redirect_url, |
|
| 185 | + ) |
|
| 186 | + ) |
|
| 187 | + ); |
|
| 188 | + exit(); |
|
| 189 | + } |
|
| 190 | + wp_safe_redirect($redirect_url); |
|
| 191 | + exit(); |
|
| 192 | + } |
|
| 193 | 193 | |
| 194 | 194 | |
| 195 | - /** |
|
| 196 | - * display_bot_trap_success |
|
| 197 | - * shows a "success" screen to bots so that they (ie: the ppl managing them) |
|
| 198 | - * think the form was submitted successfully |
|
| 199 | - * |
|
| 200 | - * @return void |
|
| 201 | - */ |
|
| 202 | - public static function display_bot_trap_success() |
|
| 203 | - { |
|
| 204 | - add_filter('FHEE__EED_Single_Page_Checkout__run', '__return_false'); |
|
| 205 | - $bot_notice = EED_Bot_Trap::getRequest()->getRequestParam( |
|
| 206 | - 'ee-notice', |
|
| 207 | - esc_html__( |
|
| 208 | - 'Thank you so much. Your ticket selections have been received for consideration.', |
|
| 209 | - 'event_espresso' |
|
| 210 | - ) |
|
| 211 | - ); |
|
| 212 | - EED_Bot_Trap::getResponse()->addOutput(EEH_HTML::div($bot_notice, '', 'ee-attention')); |
|
| 213 | - } |
|
| 195 | + /** |
|
| 196 | + * display_bot_trap_success |
|
| 197 | + * shows a "success" screen to bots so that they (ie: the ppl managing them) |
|
| 198 | + * think the form was submitted successfully |
|
| 199 | + * |
|
| 200 | + * @return void |
|
| 201 | + */ |
|
| 202 | + public static function display_bot_trap_success() |
|
| 203 | + { |
|
| 204 | + add_filter('FHEE__EED_Single_Page_Checkout__run', '__return_false'); |
|
| 205 | + $bot_notice = EED_Bot_Trap::getRequest()->getRequestParam( |
|
| 206 | + 'ee-notice', |
|
| 207 | + esc_html__( |
|
| 208 | + 'Thank you so much. Your ticket selections have been received for consideration.', |
|
| 209 | + 'event_espresso' |
|
| 210 | + ) |
|
| 211 | + ); |
|
| 212 | + EED_Bot_Trap::getResponse()->addOutput(EEH_HTML::div($bot_notice, '', 'ee-attention')); |
|
| 213 | + } |
|
| 214 | 214 | |
| 215 | 215 | |
| 216 | 216 | |
| 217 | - /*********************************** ADMIN **********************************/ |
|
| 217 | + /*********************************** ADMIN **********************************/ |
|
| 218 | 218 | |
| 219 | 219 | |
| 220 | - /** |
|
| 221 | - * bot_trap_settings_form |
|
| 222 | - * |
|
| 223 | - * @return void |
|
| 224 | - * @throws EE_Error |
|
| 225 | - * @throws InvalidArgumentException |
|
| 226 | - * @throws InvalidDataTypeException |
|
| 227 | - * @throws InvalidInterfaceException |
|
| 228 | - */ |
|
| 229 | - public static function bot_trap_settings_form() |
|
| 230 | - { |
|
| 231 | - EED_Bot_Trap::_bot_trap_settings_form()->enqueue_js(); |
|
| 232 | - echo EED_Bot_Trap::_bot_trap_settings_form()->get_html(); // already escaped |
|
| 233 | - } |
|
| 220 | + /** |
|
| 221 | + * bot_trap_settings_form |
|
| 222 | + * |
|
| 223 | + * @return void |
|
| 224 | + * @throws EE_Error |
|
| 225 | + * @throws InvalidArgumentException |
|
| 226 | + * @throws InvalidDataTypeException |
|
| 227 | + * @throws InvalidInterfaceException |
|
| 228 | + */ |
|
| 229 | + public static function bot_trap_settings_form() |
|
| 230 | + { |
|
| 231 | + EED_Bot_Trap::_bot_trap_settings_form()->enqueue_js(); |
|
| 232 | + echo EED_Bot_Trap::_bot_trap_settings_form()->get_html(); // already escaped |
|
| 233 | + } |
|
| 234 | 234 | |
| 235 | 235 | |
| 236 | - /** |
|
| 237 | - * _bot_trap_settings_form |
|
| 238 | - * |
|
| 239 | - * @return EE_Form_Section_Proper |
|
| 240 | - * @throws EE_Error |
|
| 241 | - */ |
|
| 242 | - protected static function _bot_trap_settings_form() |
|
| 243 | - { |
|
| 244 | - return new EE_Form_Section_Proper( |
|
| 245 | - array( |
|
| 246 | - 'name' => 'bot_trap_settings', |
|
| 247 | - 'html_id' => 'bot_trap_settings', |
|
| 248 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
| 249 | - 'subsections' => array( |
|
| 250 | - 'bot_trap_hdr' => new EE_Form_Section_HTML( |
|
| 251 | - EEH_HTML::h2(esc_html__('Bot Trap Settings', 'event_espresso')) |
|
| 252 | - ), |
|
| 253 | - 'use_bot_trap' => new EE_Yes_No_Input( |
|
| 254 | - array( |
|
| 255 | - 'html_label_text' => esc_html__('Enable Bot Trap', 'event_espresso'), |
|
| 256 | - 'html_help_text' => esc_html__( |
|
| 257 | - 'The Event Espresso Bot Trap will insert a fake input into your Ticket Selector forms that is hidden from regular site visitors, but visible to spam bots. Because the input asks for an email address, it is irresistible to spam bots who will of course enter text into it. Since regular site visitors can not see this input, any value detected during form submission means a bot has been detected, which will then be blocked from submitting the form.', |
|
| 258 | - 'event_espresso' |
|
| 259 | - ), |
|
| 260 | - 'default' => EE_Registry::instance()->CFG->registration->use_bot_trap !== null |
|
| 261 | - ? EE_Registry::instance()->CFG->registration->use_bot_trap |
|
| 262 | - : true, |
|
| 263 | - 'required' => false, |
|
| 264 | - ) |
|
| 265 | - ), |
|
| 266 | - ), |
|
| 267 | - ) |
|
| 268 | - ); |
|
| 269 | - } |
|
| 236 | + /** |
|
| 237 | + * _bot_trap_settings_form |
|
| 238 | + * |
|
| 239 | + * @return EE_Form_Section_Proper |
|
| 240 | + * @throws EE_Error |
|
| 241 | + */ |
|
| 242 | + protected static function _bot_trap_settings_form() |
|
| 243 | + { |
|
| 244 | + return new EE_Form_Section_Proper( |
|
| 245 | + array( |
|
| 246 | + 'name' => 'bot_trap_settings', |
|
| 247 | + 'html_id' => 'bot_trap_settings', |
|
| 248 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
| 249 | + 'subsections' => array( |
|
| 250 | + 'bot_trap_hdr' => new EE_Form_Section_HTML( |
|
| 251 | + EEH_HTML::h2(esc_html__('Bot Trap Settings', 'event_espresso')) |
|
| 252 | + ), |
|
| 253 | + 'use_bot_trap' => new EE_Yes_No_Input( |
|
| 254 | + array( |
|
| 255 | + 'html_label_text' => esc_html__('Enable Bot Trap', 'event_espresso'), |
|
| 256 | + 'html_help_text' => esc_html__( |
|
| 257 | + 'The Event Espresso Bot Trap will insert a fake input into your Ticket Selector forms that is hidden from regular site visitors, but visible to spam bots. Because the input asks for an email address, it is irresistible to spam bots who will of course enter text into it. Since regular site visitors can not see this input, any value detected during form submission means a bot has been detected, which will then be blocked from submitting the form.', |
|
| 258 | + 'event_espresso' |
|
| 259 | + ), |
|
| 260 | + 'default' => EE_Registry::instance()->CFG->registration->use_bot_trap !== null |
|
| 261 | + ? EE_Registry::instance()->CFG->registration->use_bot_trap |
|
| 262 | + : true, |
|
| 263 | + 'required' => false, |
|
| 264 | + ) |
|
| 265 | + ), |
|
| 266 | + ), |
|
| 267 | + ) |
|
| 268 | + ); |
|
| 269 | + } |
|
| 270 | 270 | |
| 271 | 271 | |
| 272 | - /** |
|
| 273 | - * update_bot_trap_settings_form |
|
| 274 | - * |
|
| 275 | - * @param EE_Registration_Config $EE_Registration_Config |
|
| 276 | - * @return EE_Registration_Config |
|
| 277 | - * @throws EE_Error |
|
| 278 | - * @throws InvalidArgumentException |
|
| 279 | - * @throws ReflectionException |
|
| 280 | - * @throws InvalidDataTypeException |
|
| 281 | - * @throws InvalidInterfaceException |
|
| 282 | - */ |
|
| 283 | - public static function update_bot_trap_settings_form(EE_Registration_Config $EE_Registration_Config) |
|
| 284 | - { |
|
| 285 | - try { |
|
| 286 | - $bot_trap_settings_form = EED_Bot_Trap::_bot_trap_settings_form(); |
|
| 287 | - // if not displaying a form, then check for form submission |
|
| 288 | - if ($bot_trap_settings_form->was_submitted()) { |
|
| 289 | - // capture form data |
|
| 290 | - $bot_trap_settings_form->receive_form_submission(); |
|
| 291 | - // validate form data |
|
| 292 | - if ($bot_trap_settings_form->is_valid()) { |
|
| 293 | - // grab validated data from form |
|
| 294 | - $valid_data = $bot_trap_settings_form->valid_data(); |
|
| 295 | - if (isset($valid_data['use_bot_trap'])) { |
|
| 296 | - $EE_Registration_Config->use_bot_trap = $valid_data['use_bot_trap']; |
|
| 297 | - } else { |
|
| 298 | - EE_Error::add_error( |
|
| 299 | - esc_html__( |
|
| 300 | - 'Invalid or missing Bot Trap settings. Please refresh the form and try again.', |
|
| 301 | - 'event_espresso' |
|
| 302 | - ), |
|
| 303 | - __FILE__, |
|
| 304 | - __FUNCTION__, |
|
| 305 | - __LINE__ |
|
| 306 | - ); |
|
| 307 | - } |
|
| 308 | - } elseif ($bot_trap_settings_form->submission_error_message() !== '') { |
|
| 309 | - EE_Error::add_error( |
|
| 310 | - $bot_trap_settings_form->submission_error_message(), |
|
| 311 | - __FILE__, |
|
| 312 | - __FUNCTION__, |
|
| 313 | - __LINE__ |
|
| 314 | - ); |
|
| 315 | - } |
|
| 316 | - } |
|
| 317 | - } catch (EE_Error $e) { |
|
| 318 | - $e->get_error(); |
|
| 319 | - } |
|
| 320 | - return $EE_Registration_Config; |
|
| 321 | - } |
|
| 272 | + /** |
|
| 273 | + * update_bot_trap_settings_form |
|
| 274 | + * |
|
| 275 | + * @param EE_Registration_Config $EE_Registration_Config |
|
| 276 | + * @return EE_Registration_Config |
|
| 277 | + * @throws EE_Error |
|
| 278 | + * @throws InvalidArgumentException |
|
| 279 | + * @throws ReflectionException |
|
| 280 | + * @throws InvalidDataTypeException |
|
| 281 | + * @throws InvalidInterfaceException |
|
| 282 | + */ |
|
| 283 | + public static function update_bot_trap_settings_form(EE_Registration_Config $EE_Registration_Config) |
|
| 284 | + { |
|
| 285 | + try { |
|
| 286 | + $bot_trap_settings_form = EED_Bot_Trap::_bot_trap_settings_form(); |
|
| 287 | + // if not displaying a form, then check for form submission |
|
| 288 | + if ($bot_trap_settings_form->was_submitted()) { |
|
| 289 | + // capture form data |
|
| 290 | + $bot_trap_settings_form->receive_form_submission(); |
|
| 291 | + // validate form data |
|
| 292 | + if ($bot_trap_settings_form->is_valid()) { |
|
| 293 | + // grab validated data from form |
|
| 294 | + $valid_data = $bot_trap_settings_form->valid_data(); |
|
| 295 | + if (isset($valid_data['use_bot_trap'])) { |
|
| 296 | + $EE_Registration_Config->use_bot_trap = $valid_data['use_bot_trap']; |
|
| 297 | + } else { |
|
| 298 | + EE_Error::add_error( |
|
| 299 | + esc_html__( |
|
| 300 | + 'Invalid or missing Bot Trap settings. Please refresh the form and try again.', |
|
| 301 | + 'event_espresso' |
|
| 302 | + ), |
|
| 303 | + __FILE__, |
|
| 304 | + __FUNCTION__, |
|
| 305 | + __LINE__ |
|
| 306 | + ); |
|
| 307 | + } |
|
| 308 | + } elseif ($bot_trap_settings_form->submission_error_message() !== '') { |
|
| 309 | + EE_Error::add_error( |
|
| 310 | + $bot_trap_settings_form->submission_error_message(), |
|
| 311 | + __FILE__, |
|
| 312 | + __FUNCTION__, |
|
| 313 | + __LINE__ |
|
| 314 | + ); |
|
| 315 | + } |
|
| 316 | + } |
|
| 317 | + } catch (EE_Error $e) { |
|
| 318 | + $e->get_error(); |
|
| 319 | + } |
|
| 320 | + return $EE_Registration_Config; |
|
| 321 | + } |
|
| 322 | 322 | } |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | */ |
| 58 | 58 | public static function set_trap() |
| 59 | 59 | { |
| 60 | - define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . '/'); |
|
| 60 | + define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__).'/'); |
|
| 61 | 61 | add_action( |
| 62 | 62 | 'AHEE__ticket_selector_chart__template__after_ticket_selector', |
| 63 | 63 | array('EED_Bot_Trap', 'generate_bot_trap'), |
@@ -123,9 +123,9 @@ discard block |
||
| 123 | 123 | $do_not_enter = esc_html__('please do not enter anything in this input', 'event_espresso'); |
| 124 | 124 | $time = esc_attr(microtime(true)); |
| 125 | 125 | $html = '<div class="tkt-slctr-request-processor-dv" style="float:left; margin:0 0 0 -999em; height: 0;">'; |
| 126 | - $html .= '<label for="tkt-slctr-request-processor-email-' . $time . '">' . $do_not_enter . '</label>'; |
|
| 126 | + $html .= '<label for="tkt-slctr-request-processor-email-'.$time.'">'.$do_not_enter.'</label>'; |
|
| 127 | 127 | $html .= '<input type="email" id="tkt-slctr-request-processor-email-'; |
| 128 | - $html .= $time . '" name="tkt-slctr-request-processor-email" value=""/>'; |
|
| 128 | + $html .= $time.'" name="tkt-slctr-request-processor-email" value=""/>'; |
|
| 129 | 129 | $html .= '</div><!-- .tkt-slctr-request-processor-dv -->'; |
| 130 | 130 | echo $html; // already escaped |
| 131 | 131 | } |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | return; |
| 151 | 151 | } |
| 152 | 152 | // check the given callback is valid first before executing |
| 153 | - if (! is_callable($triggered_trap_callback)) { |
|
| 153 | + if ( ! is_callable($triggered_trap_callback)) { |
|
| 154 | 154 | // invalid callback so lets just sub in our default. |
| 155 | 155 | $triggered_trap_callback = array('EED_Bot_Trap', 'triggered_trap_response'); |
| 156 | 156 | } |
@@ -20,1073 +20,1073 @@ |
||
| 20 | 20 | class EED_Ticket_Sales_Monitor extends EED_Module |
| 21 | 21 | { |
| 22 | 22 | |
| 23 | - const debug = false; |
|
| 24 | - |
|
| 25 | - private static $nl = ''; |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * an array of raw ticket data from EED_Ticket_Selector |
|
| 29 | - * |
|
| 30 | - * @var array $ticket_selections |
|
| 31 | - */ |
|
| 32 | - protected $ticket_selections = array(); |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * the raw ticket data from EED_Ticket_Selector is organized in rows |
|
| 36 | - * according to how they are displayed in the actual Ticket_Selector |
|
| 37 | - * this tracks the current row being processed |
|
| 38 | - * |
|
| 39 | - * @var int $current_row |
|
| 40 | - */ |
|
| 41 | - protected $current_row = 0; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * an array for tracking names of tickets that have sold out |
|
| 45 | - * |
|
| 46 | - * @var array $sold_out_tickets |
|
| 47 | - */ |
|
| 48 | - protected $sold_out_tickets = array(); |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * an array for tracking names of tickets that have had their quantities reduced |
|
| 52 | - * |
|
| 53 | - * @var array $decremented_tickets |
|
| 54 | - */ |
|
| 55 | - protected $decremented_tickets = array(); |
|
| 56 | - |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
| 60 | - * |
|
| 61 | - * @return void |
|
| 62 | - */ |
|
| 63 | - public static function set_hooks() |
|
| 64 | - { |
|
| 65 | - self::$nl = defined('EE_TESTS_DIR') ? "\n" : '<br />'; |
|
| 66 | - // release tickets for expired carts |
|
| 67 | - add_action( |
|
| 68 | - 'EED_Ticket_Selector__process_ticket_selections__before', |
|
| 69 | - array('EED_Ticket_Sales_Monitor', 'release_tickets_for_expired_carts'), |
|
| 70 | - 1 |
|
| 71 | - ); |
|
| 72 | - // check ticket reserves AFTER MER does it's check (hence priority 20) |
|
| 73 | - add_filter( |
|
| 74 | - 'FHEE__EE_Ticket_Selector___add_ticket_to_cart__ticket_qty', |
|
| 75 | - array('EED_Ticket_Sales_Monitor', 'validate_ticket_sale'), |
|
| 76 | - 20, |
|
| 77 | - 3 |
|
| 78 | - ); |
|
| 79 | - // add notices for sold out tickets |
|
| 80 | - add_action( |
|
| 81 | - 'AHEE__EE_Ticket_Selector__process_ticket_selections__after_tickets_added_to_cart', |
|
| 82 | - array('EED_Ticket_Sales_Monitor', 'post_notices'), |
|
| 83 | - 10 |
|
| 84 | - ); |
|
| 85 | - |
|
| 86 | - // handle tickets deleted from cart |
|
| 87 | - add_action( |
|
| 88 | - 'FHEE__EED_Multi_Event_Registration__delete_ticket__ticket_removed_from_cart', |
|
| 89 | - array('EED_Ticket_Sales_Monitor', 'ticket_removed_from_cart'), |
|
| 90 | - 10, |
|
| 91 | - 2 |
|
| 92 | - ); |
|
| 93 | - // handle emptied carts |
|
| 94 | - add_action( |
|
| 95 | - 'AHEE__EE_Session__reset_cart__before_reset', |
|
| 96 | - array('EED_Ticket_Sales_Monitor', 'session_cart_reset'), |
|
| 97 | - 10, |
|
| 98 | - 1 |
|
| 99 | - ); |
|
| 100 | - add_action( |
|
| 101 | - 'AHEE__EED_Multi_Event_Registration__empty_event_cart__before_delete_cart', |
|
| 102 | - array('EED_Ticket_Sales_Monitor', 'session_cart_reset'), |
|
| 103 | - 10, |
|
| 104 | - 1 |
|
| 105 | - ); |
|
| 106 | - // handle cancelled registrations |
|
| 107 | - add_action( |
|
| 108 | - 'AHEE__EE_Session__reset_checkout__before_reset', |
|
| 109 | - array('EED_Ticket_Sales_Monitor', 'session_checkout_reset'), |
|
| 110 | - 10, |
|
| 111 | - 1 |
|
| 112 | - ); |
|
| 113 | - // cron tasks |
|
| 114 | - add_action( |
|
| 115 | - 'AHEE__EE_Cron_Tasks__process_expired_transactions__abandoned_transaction', |
|
| 116 | - array('EED_Ticket_Sales_Monitor', 'process_abandoned_transactions'), |
|
| 117 | - 10, |
|
| 118 | - 1 |
|
| 119 | - ); |
|
| 120 | - add_action( |
|
| 121 | - 'AHEE__EE_Cron_Tasks__process_expired_transactions__incomplete_transaction', |
|
| 122 | - array('EED_Ticket_Sales_Monitor', 'process_abandoned_transactions'), |
|
| 123 | - 10, |
|
| 124 | - 1 |
|
| 125 | - ); |
|
| 126 | - add_action( |
|
| 127 | - 'AHEE__EE_Cron_Tasks__process_expired_transactions__failed_transaction', |
|
| 128 | - array('EED_Ticket_Sales_Monitor', 'process_failed_transactions'), |
|
| 129 | - 10, |
|
| 130 | - 1 |
|
| 131 | - ); |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - |
|
| 135 | - /** |
|
| 136 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
| 137 | - * |
|
| 138 | - * @return void |
|
| 139 | - */ |
|
| 140 | - public static function set_hooks_admin() |
|
| 141 | - { |
|
| 142 | - EED_Ticket_Sales_Monitor::set_hooks(); |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - |
|
| 146 | - /** |
|
| 147 | - * @return EED_Ticket_Sales_Monitor|EED_Module |
|
| 148 | - */ |
|
| 149 | - public static function instance() |
|
| 150 | - { |
|
| 151 | - return parent::get_instance(__CLASS__); |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - |
|
| 155 | - /** |
|
| 156 | - * @param WP_Query $WP_Query |
|
| 157 | - * @return void |
|
| 158 | - */ |
|
| 159 | - public function run($WP_Query) |
|
| 160 | - { |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - |
|
| 164 | - |
|
| 165 | - /********************************** PRE_TICKET_SALES **********************************/ |
|
| 166 | - |
|
| 167 | - |
|
| 168 | - /** |
|
| 169 | - * Retrieves grand totals from the line items that have no TXN ID |
|
| 170 | - * and timestamps less than the current time minus the session lifespan. |
|
| 171 | - * These are carts that have been abandoned before the "registrant" even attempted to checkout. |
|
| 172 | - * We're going to release the tickets for these line items before attempting to add more to the cart. |
|
| 173 | - * |
|
| 174 | - * @return void |
|
| 175 | - * @throws DomainException |
|
| 176 | - * @throws EE_Error |
|
| 177 | - * @throws InvalidArgumentException |
|
| 178 | - * @throws InvalidDataTypeException |
|
| 179 | - * @throws InvalidInterfaceException |
|
| 180 | - * @throws UnexpectedEntityException |
|
| 181 | - */ |
|
| 182 | - public static function release_tickets_for_expired_carts() |
|
| 183 | - { |
|
| 184 | - // self::debug hardcoded to false |
|
| 185 | - if (self::debug) { |
|
| 186 | - echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '()'; |
|
| 187 | - } |
|
| 188 | - do_action('AHEE__EED_Ticket_Sales_Monitor__release_tickets_for_expired_carts__begin'); |
|
| 189 | - $expired_ticket_IDs = array(); |
|
| 190 | - /** @var EventEspresso\core\domain\values\session\SessionLifespan $session_lifespan */ |
|
| 191 | - $session_lifespan = LoaderFactory::getLoader()->getShared( |
|
| 192 | - 'EventEspresso\core\domain\values\session\SessionLifespan' |
|
| 193 | - ); |
|
| 194 | - $timestamp = $session_lifespan->expiration(); |
|
| 195 | - $expired_ticket_line_items = EEM_Line_Item::instance()->getTicketLineItemsForExpiredCarts($timestamp); |
|
| 196 | - if (self::debug) { |
|
| 197 | - echo self::$nl . ' . time(): ' . time(); |
|
| 198 | - echo self::$nl . ' . time() as date: ' . date('Y-m-d H:i a'); |
|
| 199 | - echo self::$nl . ' . session expiration: ' . $session_lifespan->expiration(); |
|
| 200 | - echo self::$nl . ' . session expiration as date: ' . date('Y-m-d H:i a', $session_lifespan->expiration()); |
|
| 201 | - echo self::$nl . ' . timestamp: ' . $timestamp; |
|
| 202 | - echo self::$nl . ' . $expired_ticket_line_items: ' . count($expired_ticket_line_items); |
|
| 203 | - } |
|
| 204 | - if (! empty($expired_ticket_line_items)) { |
|
| 205 | - foreach ($expired_ticket_line_items as $expired_ticket_line_item) { |
|
| 206 | - if (! $expired_ticket_line_item instanceof EE_Line_Item) { |
|
| 207 | - continue; |
|
| 208 | - } |
|
| 209 | - $expired_ticket_IDs[ $expired_ticket_line_item->OBJ_ID() ] = $expired_ticket_line_item->OBJ_ID(); |
|
| 210 | - if (self::debug) { |
|
| 211 | - echo self::$nl . ' . $expired_ticket_line_item->OBJ_ID(): ' . $expired_ticket_line_item->OBJ_ID(); |
|
| 212 | - echo self::$nl . ' . $expired_ticket_line_item->timestamp(): ' |
|
| 213 | - . date( |
|
| 214 | - 'Y-m-d h:i a', |
|
| 215 | - $expired_ticket_line_item->timestamp(true) |
|
| 216 | - ); |
|
| 217 | - } |
|
| 218 | - } |
|
| 219 | - if (! empty($expired_ticket_IDs)) { |
|
| 220 | - EED_Ticket_Sales_Monitor::release_reservations_for_tickets( |
|
| 221 | - \EEM_Ticket::instance()->get_tickets_with_IDs($expired_ticket_IDs), |
|
| 222 | - array(), |
|
| 223 | - __FUNCTION__ |
|
| 224 | - ); |
|
| 225 | - // now let's get rid of expired line items so that they can't interfere with tracking |
|
| 226 | - EED_Ticket_Sales_Monitor::clear_expired_line_items_with_no_transaction($timestamp); |
|
| 227 | - } |
|
| 228 | - } |
|
| 229 | - do_action( |
|
| 230 | - 'AHEE__EED_Ticket_Sales_Monitor__release_tickets_for_expired_carts__end', |
|
| 231 | - $expired_ticket_IDs, |
|
| 232 | - $expired_ticket_line_items |
|
| 233 | - ); |
|
| 234 | - } |
|
| 235 | - |
|
| 236 | - |
|
| 237 | - |
|
| 238 | - /********************************** VALIDATE_TICKET_SALE **********************************/ |
|
| 239 | - |
|
| 240 | - |
|
| 241 | - /** |
|
| 242 | - * callback for 'FHEE__EED_Ticket_Selector__process_ticket_selections__valid_post_data' |
|
| 243 | - * |
|
| 244 | - * @param int $qty |
|
| 245 | - * @param EE_Ticket $ticket |
|
| 246 | - * @return bool |
|
| 247 | - * @throws UnexpectedEntityException |
|
| 248 | - * @throws EE_Error |
|
| 249 | - */ |
|
| 250 | - public static function validate_ticket_sale($qty = 1, EE_Ticket $ticket) |
|
| 251 | - { |
|
| 252 | - $qty = absint($qty); |
|
| 253 | - if ($qty > 0) { |
|
| 254 | - $qty = EED_Ticket_Sales_Monitor::instance()->_validate_ticket_sale($ticket, $qty); |
|
| 255 | - } |
|
| 256 | - // self::debug hardcoded to false |
|
| 257 | - if (self::debug) { |
|
| 258 | - echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '()'; |
|
| 259 | - echo self::$nl . self::$nl . '<b> RETURNED QTY: ' . $qty . '</b>'; |
|
| 260 | - } |
|
| 261 | - return $qty; |
|
| 262 | - } |
|
| 263 | - |
|
| 264 | - |
|
| 265 | - /** |
|
| 266 | - * checks whether an individual ticket is available for purchase based on datetime, and ticket details |
|
| 267 | - * |
|
| 268 | - * @param EE_Ticket $ticket |
|
| 269 | - * @param int $qty |
|
| 270 | - * @return int |
|
| 271 | - * @throws UnexpectedEntityException |
|
| 272 | - * @throws EE_Error |
|
| 273 | - */ |
|
| 274 | - protected function _validate_ticket_sale(EE_Ticket $ticket, $qty = 1) |
|
| 275 | - { |
|
| 276 | - // self::debug hardcoded to false |
|
| 277 | - if (self::debug) { |
|
| 278 | - echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() '; |
|
| 279 | - } |
|
| 280 | - if (! $ticket instanceof EE_Ticket) { |
|
| 281 | - return 0; |
|
| 282 | - } |
|
| 283 | - if (self::debug) { |
|
| 284 | - echo self::$nl . '<b> . ticket->ID: ' . $ticket->ID() . '</b>'; |
|
| 285 | - echo self::$nl . ' . original ticket->reserved: ' . $ticket->reserved(); |
|
| 286 | - } |
|
| 287 | - $ticket->refresh_from_db(); |
|
| 288 | - // first let's determine the ticket availability based on sales |
|
| 289 | - $available = $ticket->qty('saleable'); |
|
| 290 | - if (self::debug) { |
|
| 291 | - echo self::$nl . ' . . . ticket->qty: ' . $ticket->qty(); |
|
| 292 | - echo self::$nl . ' . . . ticket->sold: ' . $ticket->sold(); |
|
| 293 | - echo self::$nl . ' . . . ticket->reserved: ' . $ticket->reserved(); |
|
| 294 | - echo self::$nl . ' . . . ticket->qty(saleable): ' . $ticket->qty('saleable'); |
|
| 295 | - echo self::$nl . ' . . . available: ' . $available; |
|
| 296 | - } |
|
| 297 | - if ($available < 1) { |
|
| 298 | - $this->_ticket_sold_out($ticket); |
|
| 299 | - return 0; |
|
| 300 | - } |
|
| 301 | - if (self::debug) { |
|
| 302 | - echo self::$nl . ' . . . qty: ' . $qty; |
|
| 303 | - } |
|
| 304 | - if ($available < $qty) { |
|
| 305 | - $qty = $available; |
|
| 306 | - if (self::debug) { |
|
| 307 | - echo self::$nl . ' . . . QTY ADJUSTED: ' . $qty; |
|
| 308 | - } |
|
| 309 | - $this->_ticket_quantity_decremented($ticket); |
|
| 310 | - } |
|
| 311 | - if ($this->_reserve_ticket($ticket, $qty)) { |
|
| 312 | - return $qty; |
|
| 313 | - } else { |
|
| 314 | - return 0; |
|
| 315 | - } |
|
| 316 | - } |
|
| 317 | - |
|
| 318 | - |
|
| 319 | - /** |
|
| 320 | - * increments ticket reserved based on quantity passed |
|
| 321 | - * |
|
| 322 | - * @param EE_Ticket $ticket |
|
| 323 | - * @param int $quantity |
|
| 324 | - * @return bool indicating success or failure |
|
| 325 | - * @throws EE_Error |
|
| 326 | - */ |
|
| 327 | - protected function _reserve_ticket(EE_Ticket $ticket, $quantity = 1) |
|
| 328 | - { |
|
| 329 | - // self::debug hardcoded to false |
|
| 330 | - if (self::debug) { |
|
| 331 | - echo self::$nl . self::$nl . ' . . . INCREASE RESERVED: ' . $quantity; |
|
| 332 | - } |
|
| 333 | - return $ticket->increaseReserved($quantity, 'TicketSalesMonitor:' . __LINE__); |
|
| 334 | - } |
|
| 335 | - |
|
| 336 | - |
|
| 337 | - /** |
|
| 338 | - * @param EE_Ticket $ticket |
|
| 339 | - * @param int $quantity |
|
| 340 | - * @return bool |
|
| 341 | - * @throws EE_Error |
|
| 342 | - */ |
|
| 343 | - protected function _release_reserved_ticket(EE_Ticket $ticket, $quantity = 1) |
|
| 344 | - { |
|
| 345 | - // self::debug hardcoded to false |
|
| 346 | - if (self::debug) { |
|
| 347 | - echo self::$nl . ' . . . ticket->ID: ' . $ticket->ID(); |
|
| 348 | - echo self::$nl . ' . . . ticket->reserved before: ' . $ticket->reserved(); |
|
| 349 | - } |
|
| 350 | - $ticket->decreaseReserved($quantity, true, 'TicketSalesMonitor:' . __LINE__); |
|
| 351 | - if (self::debug) { |
|
| 352 | - echo self::$nl . ' . . . ticket->reserved after: ' . $ticket->reserved(); |
|
| 353 | - } |
|
| 354 | - return $ticket->save() ? 1 : 0; |
|
| 355 | - } |
|
| 356 | - |
|
| 357 | - |
|
| 358 | - /** |
|
| 359 | - * removes quantities within the ticket selector based on zero ticket availability |
|
| 360 | - * |
|
| 361 | - * @param EE_Ticket $ticket |
|
| 362 | - * @return void |
|
| 363 | - * @throws UnexpectedEntityException |
|
| 364 | - * @throws EE_Error |
|
| 365 | - */ |
|
| 366 | - protected function _ticket_sold_out(EE_Ticket $ticket) |
|
| 367 | - { |
|
| 368 | - // self::debug hardcoded to false |
|
| 369 | - if (self::debug) { |
|
| 370 | - echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() '; |
|
| 371 | - echo self::$nl . ' . . ticket->name: ' . $this->_get_ticket_and_event_name($ticket); |
|
| 372 | - } |
|
| 373 | - $this->sold_out_tickets[] = $this->_get_ticket_and_event_name($ticket); |
|
| 374 | - } |
|
| 375 | - |
|
| 376 | - |
|
| 377 | - /** |
|
| 378 | - * adjusts quantities within the ticket selector based on decreased ticket availability |
|
| 379 | - * |
|
| 380 | - * @param EE_Ticket $ticket |
|
| 381 | - * @return void |
|
| 382 | - * @throws UnexpectedEntityException |
|
| 383 | - * @throws EE_Error |
|
| 384 | - */ |
|
| 385 | - protected function _ticket_quantity_decremented(EE_Ticket $ticket) |
|
| 386 | - { |
|
| 387 | - // self::debug hardcoded to false |
|
| 388 | - if (self::debug) { |
|
| 389 | - echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() '; |
|
| 390 | - echo self::$nl . ' . . ticket->name: ' . $this->_get_ticket_and_event_name($ticket); |
|
| 391 | - } |
|
| 392 | - $this->decremented_tickets[] = $this->_get_ticket_and_event_name($ticket); |
|
| 393 | - } |
|
| 394 | - |
|
| 395 | - |
|
| 396 | - /** |
|
| 397 | - * builds string out of ticket and event name |
|
| 398 | - * |
|
| 399 | - * @param EE_Ticket $ticket |
|
| 400 | - * @return string |
|
| 401 | - * @throws UnexpectedEntityException |
|
| 402 | - * @throws EE_Error |
|
| 403 | - */ |
|
| 404 | - protected function _get_ticket_and_event_name(EE_Ticket $ticket) |
|
| 405 | - { |
|
| 406 | - $event = $ticket->get_related_event(); |
|
| 407 | - if ($event instanceof EE_Event) { |
|
| 408 | - $ticket_name = sprintf( |
|
| 409 | - _x('%1$s for %2$s', 'ticket name for event name', 'event_espresso'), |
|
| 410 | - $ticket->name(), |
|
| 411 | - $event->name() |
|
| 412 | - ); |
|
| 413 | - } else { |
|
| 414 | - $ticket_name = $ticket->name(); |
|
| 415 | - } |
|
| 416 | - return $ticket_name; |
|
| 417 | - } |
|
| 418 | - |
|
| 419 | - |
|
| 420 | - |
|
| 421 | - /********************************** EVENT CART **********************************/ |
|
| 422 | - |
|
| 423 | - |
|
| 424 | - /** |
|
| 425 | - * releases or reserves ticket(s) based on quantity passed |
|
| 426 | - * |
|
| 427 | - * @param EE_Line_Item $line_item |
|
| 428 | - * @param int $quantity |
|
| 429 | - * @return void |
|
| 430 | - * @throws EE_Error |
|
| 431 | - * @throws InvalidArgumentException |
|
| 432 | - * @throws InvalidDataTypeException |
|
| 433 | - * @throws InvalidInterfaceException |
|
| 434 | - */ |
|
| 435 | - public static function ticket_quantity_updated(EE_Line_Item $line_item, $quantity = 1) |
|
| 436 | - { |
|
| 437 | - $ticket = EEM_Ticket::instance()->get_one_by_ID(absint($line_item->OBJ_ID())); |
|
| 438 | - if ($ticket instanceof EE_Ticket) { |
|
| 439 | - $ticket->add_extra_meta( |
|
| 440 | - EE_Ticket::META_KEY_TICKET_RESERVATIONS, |
|
| 441 | - __LINE__ . ') ' . __METHOD__ . '()' |
|
| 442 | - ); |
|
| 443 | - if ($quantity > 0) { |
|
| 444 | - EED_Ticket_Sales_Monitor::instance()->_reserve_ticket($ticket, $quantity); |
|
| 445 | - } else { |
|
| 446 | - EED_Ticket_Sales_Monitor::instance()->_release_reserved_ticket($ticket, $quantity); |
|
| 447 | - } |
|
| 448 | - } |
|
| 449 | - } |
|
| 450 | - |
|
| 451 | - |
|
| 452 | - /** |
|
| 453 | - * releases reserved ticket(s) based on quantity passed |
|
| 454 | - * |
|
| 455 | - * @param EE_Ticket $ticket |
|
| 456 | - * @param int $quantity |
|
| 457 | - * @return void |
|
| 458 | - * @throws EE_Error |
|
| 459 | - */ |
|
| 460 | - public static function ticket_removed_from_cart(EE_Ticket $ticket, $quantity = 1) |
|
| 461 | - { |
|
| 462 | - $ticket->add_extra_meta( |
|
| 463 | - EE_Ticket::META_KEY_TICKET_RESERVATIONS, |
|
| 464 | - __LINE__ . ') ' . __METHOD__ . '()' |
|
| 465 | - ); |
|
| 466 | - EED_Ticket_Sales_Monitor::instance()->_release_reserved_ticket($ticket, $quantity); |
|
| 467 | - } |
|
| 468 | - |
|
| 469 | - |
|
| 470 | - |
|
| 471 | - /********************************** POST_NOTICES **********************************/ |
|
| 472 | - |
|
| 473 | - |
|
| 474 | - /** |
|
| 475 | - * @return void |
|
| 476 | - * @throws EE_Error |
|
| 477 | - * @throws InvalidArgumentException |
|
| 478 | - * @throws ReflectionException |
|
| 479 | - * @throws InvalidDataTypeException |
|
| 480 | - * @throws InvalidInterfaceException |
|
| 481 | - */ |
|
| 482 | - public static function post_notices() |
|
| 483 | - { |
|
| 484 | - EED_Ticket_Sales_Monitor::instance()->_post_notices(); |
|
| 485 | - } |
|
| 486 | - |
|
| 487 | - |
|
| 488 | - /** |
|
| 489 | - * @return void |
|
| 490 | - * @throws EE_Error |
|
| 491 | - * @throws InvalidArgumentException |
|
| 492 | - * @throws ReflectionException |
|
| 493 | - * @throws InvalidDataTypeException |
|
| 494 | - * @throws InvalidInterfaceException |
|
| 495 | - */ |
|
| 496 | - protected function _post_notices() |
|
| 497 | - { |
|
| 498 | - // self::debug hardcoded to false |
|
| 499 | - if (self::debug) { |
|
| 500 | - echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() '; |
|
| 501 | - } |
|
| 502 | - $refresh_msg = ''; |
|
| 503 | - $none_added_msg = ''; |
|
| 504 | - if (defined('DOING_AJAX') && DOING_AJAX) { |
|
| 505 | - $refresh_msg = esc_html__( |
|
| 506 | - 'Please refresh the page to view updated ticket quantities.', |
|
| 507 | - 'event_espresso' |
|
| 508 | - ); |
|
| 509 | - $none_added_msg = esc_html__('No tickets were added for the event.', 'event_espresso'); |
|
| 510 | - } |
|
| 511 | - if (! empty($this->sold_out_tickets)) { |
|
| 512 | - EE_Error::add_attention( |
|
| 513 | - sprintf( |
|
| 514 | - apply_filters( |
|
| 515 | - 'FHEE__EED_Ticket_Sales_Monitor___post_notices__sold_out_tickets_notice', |
|
| 516 | - esc_html__( |
|
| 517 | - 'We\'re sorry...%1$sThe following items have sold out since you first viewed this page, and can no longer be registered for:%1$s%1$s%2$s%1$s%1$sPlease note that availability can change at any time due to cancellations, so please check back again later if registration for this event(s) is important to you.%1$s%1$s%3$s%1$s%4$s%1$s', |
|
| 518 | - 'event_espresso' |
|
| 519 | - ) |
|
| 520 | - ), |
|
| 521 | - '<br />', |
|
| 522 | - implode('<br />', $this->sold_out_tickets), |
|
| 523 | - $none_added_msg, |
|
| 524 | - $refresh_msg |
|
| 525 | - ) |
|
| 526 | - ); |
|
| 527 | - // alter code flow in the Ticket Selector for better UX |
|
| 528 | - add_filter('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', '__return_true'); |
|
| 529 | - add_filter('FHEE__EED_Ticket_Selector__process_ticket_selections__success', '__return_false'); |
|
| 530 | - $this->sold_out_tickets = array(); |
|
| 531 | - // and reset the cart |
|
| 532 | - EED_Ticket_Sales_Monitor::session_cart_reset(EE_Registry::instance()->SSN); |
|
| 533 | - } |
|
| 534 | - if (! empty($this->decremented_tickets)) { |
|
| 535 | - EE_Error::add_attention( |
|
| 536 | - sprintf( |
|
| 537 | - apply_filters( |
|
| 538 | - 'FHEE__EED_Ticket_Sales_Monitor___ticket_quantity_decremented__notice', |
|
| 539 | - esc_html__( |
|
| 540 | - 'We\'re sorry...%1$sDue to sales that have occurred since you first viewed the last page, the following items have had their quantities adjusted to match the current available amount:%1$s%1$s%2$s%1$s%1$sPlease note that availability can change at any time due to cancellations, so please check back again later if registration for this event(s) is important to you.%1$s%1$s%3$s%1$s%4$s%1$s', |
|
| 541 | - 'event_espresso' |
|
| 542 | - ) |
|
| 543 | - ), |
|
| 544 | - '<br />', |
|
| 545 | - implode('<br />', $this->decremented_tickets), |
|
| 546 | - $none_added_msg, |
|
| 547 | - $refresh_msg |
|
| 548 | - ) |
|
| 549 | - ); |
|
| 550 | - $this->decremented_tickets = array(); |
|
| 551 | - } |
|
| 552 | - } |
|
| 553 | - |
|
| 554 | - |
|
| 555 | - |
|
| 556 | - /********************************** RELEASE_ALL_RESERVED_TICKETS_FOR_TRANSACTION **********************************/ |
|
| 557 | - |
|
| 558 | - |
|
| 559 | - /** |
|
| 560 | - * releases reserved tickets for all registrations of an EE_Transaction |
|
| 561 | - * by default, will NOT release tickets for finalized transactions |
|
| 562 | - * |
|
| 563 | - * @param EE_Transaction $transaction |
|
| 564 | - * @return int |
|
| 565 | - * @throws EE_Error |
|
| 566 | - * @throws InvalidSessionDataException |
|
| 567 | - */ |
|
| 568 | - protected function _release_all_reserved_tickets_for_transaction(EE_Transaction $transaction) |
|
| 569 | - { |
|
| 570 | - // self::debug hardcoded to false |
|
| 571 | - if (self::debug) { |
|
| 572 | - echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() '; |
|
| 573 | - echo self::$nl . ' . transaction->ID: ' . $transaction->ID(); |
|
| 574 | - echo self::$nl . ' . TXN status_ID: ' . $transaction->status_ID(); |
|
| 575 | - } |
|
| 576 | - // check if 'finalize_registration' step has been completed... |
|
| 577 | - $finalized = $transaction->reg_step_completed('finalize_registration'); |
|
| 578 | - if (self::debug) { |
|
| 579 | - // DEBUG LOG |
|
| 580 | - EEH_Debug_Tools::log( |
|
| 581 | - __CLASS__, |
|
| 582 | - __FUNCTION__, |
|
| 583 | - __LINE__, |
|
| 584 | - array('finalized' => $finalized), |
|
| 585 | - false, |
|
| 586 | - 'EE_Transaction: ' . $transaction->ID() |
|
| 587 | - ); |
|
| 588 | - } |
|
| 589 | - // how many tickets were released |
|
| 590 | - $count = 0; |
|
| 591 | - if (self::debug) { |
|
| 592 | - echo self::$nl . ' . . . TXN finalized: ' . $finalized; |
|
| 593 | - } |
|
| 594 | - $release_tickets_with_TXN_status = array( |
|
| 595 | - EEM_Transaction::failed_status_code, |
|
| 596 | - EEM_Transaction::abandoned_status_code, |
|
| 597 | - EEM_Transaction::incomplete_status_code, |
|
| 598 | - ); |
|
| 599 | - $events = array(); |
|
| 600 | - // if the session is getting cleared BEFORE the TXN has been finalized or the transaction is not completed |
|
| 601 | - if (! $finalized || in_array($transaction->status_ID(), $release_tickets_with_TXN_status, true)) { |
|
| 602 | - // cancel any reserved tickets for registrations that were not approved |
|
| 603 | - $registrations = $transaction->registrations(); |
|
| 604 | - if (self::debug) { |
|
| 605 | - echo self::$nl . ' . . . # registrations: ' . count($registrations); |
|
| 606 | - $reg = reset($registrations); |
|
| 607 | - $ticket = $reg->ticket(); |
|
| 608 | - if ($ticket instanceof EE_Ticket) { |
|
| 609 | - $ticket->add_extra_meta( |
|
| 610 | - EE_Ticket::META_KEY_TICKET_RESERVATIONS, |
|
| 611 | - __LINE__ . ') Release All Tickets TXN:' . $transaction->ID() |
|
| 612 | - ); |
|
| 613 | - } |
|
| 614 | - } |
|
| 615 | - if (! empty($registrations)) { |
|
| 616 | - foreach ($registrations as $registration) { |
|
| 617 | - if ( |
|
| 618 | - $registration instanceof EE_Registration |
|
| 619 | - && $this->_release_reserved_ticket_for_registration($registration, $transaction) |
|
| 620 | - ) { |
|
| 621 | - $count++; |
|
| 622 | - $events[ $registration->event_ID() ] = $registration->event(); |
|
| 623 | - } |
|
| 624 | - } |
|
| 625 | - } |
|
| 626 | - } |
|
| 627 | - if ($events !== array()) { |
|
| 628 | - foreach ($events as $event) { |
|
| 629 | - /** @var EE_Event $event */ |
|
| 630 | - $event->perform_sold_out_status_check(); |
|
| 631 | - } |
|
| 632 | - } |
|
| 633 | - return $count; |
|
| 634 | - } |
|
| 635 | - |
|
| 636 | - |
|
| 637 | - /** |
|
| 638 | - * releases reserved tickets for an EE_Registration |
|
| 639 | - * by default, will NOT release tickets for APPROVED registrations |
|
| 640 | - * |
|
| 641 | - * @param EE_Registration $registration |
|
| 642 | - * @param EE_Transaction $transaction |
|
| 643 | - * @return int |
|
| 644 | - * @throws EE_Error |
|
| 645 | - */ |
|
| 646 | - protected function _release_reserved_ticket_for_registration( |
|
| 647 | - EE_Registration $registration, |
|
| 648 | - EE_Transaction $transaction |
|
| 649 | - ) { |
|
| 650 | - $STS_ID = $transaction->status_ID(); |
|
| 651 | - // self::debug hardcoded to false |
|
| 652 | - if (self::debug) { |
|
| 653 | - echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() '; |
|
| 654 | - echo self::$nl . ' . . registration->ID: ' . $registration->ID(); |
|
| 655 | - echo self::$nl . ' . . registration->status_ID: ' . $registration->status_ID(); |
|
| 656 | - echo self::$nl . ' . . transaction->status_ID(): ' . $STS_ID; |
|
| 657 | - } |
|
| 658 | - if ( |
|
| 23 | + const debug = false; |
|
| 24 | + |
|
| 25 | + private static $nl = ''; |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * an array of raw ticket data from EED_Ticket_Selector |
|
| 29 | + * |
|
| 30 | + * @var array $ticket_selections |
|
| 31 | + */ |
|
| 32 | + protected $ticket_selections = array(); |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * the raw ticket data from EED_Ticket_Selector is organized in rows |
|
| 36 | + * according to how they are displayed in the actual Ticket_Selector |
|
| 37 | + * this tracks the current row being processed |
|
| 38 | + * |
|
| 39 | + * @var int $current_row |
|
| 40 | + */ |
|
| 41 | + protected $current_row = 0; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * an array for tracking names of tickets that have sold out |
|
| 45 | + * |
|
| 46 | + * @var array $sold_out_tickets |
|
| 47 | + */ |
|
| 48 | + protected $sold_out_tickets = array(); |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * an array for tracking names of tickets that have had their quantities reduced |
|
| 52 | + * |
|
| 53 | + * @var array $decremented_tickets |
|
| 54 | + */ |
|
| 55 | + protected $decremented_tickets = array(); |
|
| 56 | + |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
| 60 | + * |
|
| 61 | + * @return void |
|
| 62 | + */ |
|
| 63 | + public static function set_hooks() |
|
| 64 | + { |
|
| 65 | + self::$nl = defined('EE_TESTS_DIR') ? "\n" : '<br />'; |
|
| 66 | + // release tickets for expired carts |
|
| 67 | + add_action( |
|
| 68 | + 'EED_Ticket_Selector__process_ticket_selections__before', |
|
| 69 | + array('EED_Ticket_Sales_Monitor', 'release_tickets_for_expired_carts'), |
|
| 70 | + 1 |
|
| 71 | + ); |
|
| 72 | + // check ticket reserves AFTER MER does it's check (hence priority 20) |
|
| 73 | + add_filter( |
|
| 74 | + 'FHEE__EE_Ticket_Selector___add_ticket_to_cart__ticket_qty', |
|
| 75 | + array('EED_Ticket_Sales_Monitor', 'validate_ticket_sale'), |
|
| 76 | + 20, |
|
| 77 | + 3 |
|
| 78 | + ); |
|
| 79 | + // add notices for sold out tickets |
|
| 80 | + add_action( |
|
| 81 | + 'AHEE__EE_Ticket_Selector__process_ticket_selections__after_tickets_added_to_cart', |
|
| 82 | + array('EED_Ticket_Sales_Monitor', 'post_notices'), |
|
| 83 | + 10 |
|
| 84 | + ); |
|
| 85 | + |
|
| 86 | + // handle tickets deleted from cart |
|
| 87 | + add_action( |
|
| 88 | + 'FHEE__EED_Multi_Event_Registration__delete_ticket__ticket_removed_from_cart', |
|
| 89 | + array('EED_Ticket_Sales_Monitor', 'ticket_removed_from_cart'), |
|
| 90 | + 10, |
|
| 91 | + 2 |
|
| 92 | + ); |
|
| 93 | + // handle emptied carts |
|
| 94 | + add_action( |
|
| 95 | + 'AHEE__EE_Session__reset_cart__before_reset', |
|
| 96 | + array('EED_Ticket_Sales_Monitor', 'session_cart_reset'), |
|
| 97 | + 10, |
|
| 98 | + 1 |
|
| 99 | + ); |
|
| 100 | + add_action( |
|
| 101 | + 'AHEE__EED_Multi_Event_Registration__empty_event_cart__before_delete_cart', |
|
| 102 | + array('EED_Ticket_Sales_Monitor', 'session_cart_reset'), |
|
| 103 | + 10, |
|
| 104 | + 1 |
|
| 105 | + ); |
|
| 106 | + // handle cancelled registrations |
|
| 107 | + add_action( |
|
| 108 | + 'AHEE__EE_Session__reset_checkout__before_reset', |
|
| 109 | + array('EED_Ticket_Sales_Monitor', 'session_checkout_reset'), |
|
| 110 | + 10, |
|
| 111 | + 1 |
|
| 112 | + ); |
|
| 113 | + // cron tasks |
|
| 114 | + add_action( |
|
| 115 | + 'AHEE__EE_Cron_Tasks__process_expired_transactions__abandoned_transaction', |
|
| 116 | + array('EED_Ticket_Sales_Monitor', 'process_abandoned_transactions'), |
|
| 117 | + 10, |
|
| 118 | + 1 |
|
| 119 | + ); |
|
| 120 | + add_action( |
|
| 121 | + 'AHEE__EE_Cron_Tasks__process_expired_transactions__incomplete_transaction', |
|
| 122 | + array('EED_Ticket_Sales_Monitor', 'process_abandoned_transactions'), |
|
| 123 | + 10, |
|
| 124 | + 1 |
|
| 125 | + ); |
|
| 126 | + add_action( |
|
| 127 | + 'AHEE__EE_Cron_Tasks__process_expired_transactions__failed_transaction', |
|
| 128 | + array('EED_Ticket_Sales_Monitor', 'process_failed_transactions'), |
|
| 129 | + 10, |
|
| 130 | + 1 |
|
| 131 | + ); |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + |
|
| 135 | + /** |
|
| 136 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
| 137 | + * |
|
| 138 | + * @return void |
|
| 139 | + */ |
|
| 140 | + public static function set_hooks_admin() |
|
| 141 | + { |
|
| 142 | + EED_Ticket_Sales_Monitor::set_hooks(); |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + |
|
| 146 | + /** |
|
| 147 | + * @return EED_Ticket_Sales_Monitor|EED_Module |
|
| 148 | + */ |
|
| 149 | + public static function instance() |
|
| 150 | + { |
|
| 151 | + return parent::get_instance(__CLASS__); |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + |
|
| 155 | + /** |
|
| 156 | + * @param WP_Query $WP_Query |
|
| 157 | + * @return void |
|
| 158 | + */ |
|
| 159 | + public function run($WP_Query) |
|
| 160 | + { |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + |
|
| 164 | + |
|
| 165 | + /********************************** PRE_TICKET_SALES **********************************/ |
|
| 166 | + |
|
| 167 | + |
|
| 168 | + /** |
|
| 169 | + * Retrieves grand totals from the line items that have no TXN ID |
|
| 170 | + * and timestamps less than the current time minus the session lifespan. |
|
| 171 | + * These are carts that have been abandoned before the "registrant" even attempted to checkout. |
|
| 172 | + * We're going to release the tickets for these line items before attempting to add more to the cart. |
|
| 173 | + * |
|
| 174 | + * @return void |
|
| 175 | + * @throws DomainException |
|
| 176 | + * @throws EE_Error |
|
| 177 | + * @throws InvalidArgumentException |
|
| 178 | + * @throws InvalidDataTypeException |
|
| 179 | + * @throws InvalidInterfaceException |
|
| 180 | + * @throws UnexpectedEntityException |
|
| 181 | + */ |
|
| 182 | + public static function release_tickets_for_expired_carts() |
|
| 183 | + { |
|
| 184 | + // self::debug hardcoded to false |
|
| 185 | + if (self::debug) { |
|
| 186 | + echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '()'; |
|
| 187 | + } |
|
| 188 | + do_action('AHEE__EED_Ticket_Sales_Monitor__release_tickets_for_expired_carts__begin'); |
|
| 189 | + $expired_ticket_IDs = array(); |
|
| 190 | + /** @var EventEspresso\core\domain\values\session\SessionLifespan $session_lifespan */ |
|
| 191 | + $session_lifespan = LoaderFactory::getLoader()->getShared( |
|
| 192 | + 'EventEspresso\core\domain\values\session\SessionLifespan' |
|
| 193 | + ); |
|
| 194 | + $timestamp = $session_lifespan->expiration(); |
|
| 195 | + $expired_ticket_line_items = EEM_Line_Item::instance()->getTicketLineItemsForExpiredCarts($timestamp); |
|
| 196 | + if (self::debug) { |
|
| 197 | + echo self::$nl . ' . time(): ' . time(); |
|
| 198 | + echo self::$nl . ' . time() as date: ' . date('Y-m-d H:i a'); |
|
| 199 | + echo self::$nl . ' . session expiration: ' . $session_lifespan->expiration(); |
|
| 200 | + echo self::$nl . ' . session expiration as date: ' . date('Y-m-d H:i a', $session_lifespan->expiration()); |
|
| 201 | + echo self::$nl . ' . timestamp: ' . $timestamp; |
|
| 202 | + echo self::$nl . ' . $expired_ticket_line_items: ' . count($expired_ticket_line_items); |
|
| 203 | + } |
|
| 204 | + if (! empty($expired_ticket_line_items)) { |
|
| 205 | + foreach ($expired_ticket_line_items as $expired_ticket_line_item) { |
|
| 206 | + if (! $expired_ticket_line_item instanceof EE_Line_Item) { |
|
| 207 | + continue; |
|
| 208 | + } |
|
| 209 | + $expired_ticket_IDs[ $expired_ticket_line_item->OBJ_ID() ] = $expired_ticket_line_item->OBJ_ID(); |
|
| 210 | + if (self::debug) { |
|
| 211 | + echo self::$nl . ' . $expired_ticket_line_item->OBJ_ID(): ' . $expired_ticket_line_item->OBJ_ID(); |
|
| 212 | + echo self::$nl . ' . $expired_ticket_line_item->timestamp(): ' |
|
| 213 | + . date( |
|
| 214 | + 'Y-m-d h:i a', |
|
| 215 | + $expired_ticket_line_item->timestamp(true) |
|
| 216 | + ); |
|
| 217 | + } |
|
| 218 | + } |
|
| 219 | + if (! empty($expired_ticket_IDs)) { |
|
| 220 | + EED_Ticket_Sales_Monitor::release_reservations_for_tickets( |
|
| 221 | + \EEM_Ticket::instance()->get_tickets_with_IDs($expired_ticket_IDs), |
|
| 222 | + array(), |
|
| 223 | + __FUNCTION__ |
|
| 224 | + ); |
|
| 225 | + // now let's get rid of expired line items so that they can't interfere with tracking |
|
| 226 | + EED_Ticket_Sales_Monitor::clear_expired_line_items_with_no_transaction($timestamp); |
|
| 227 | + } |
|
| 228 | + } |
|
| 229 | + do_action( |
|
| 230 | + 'AHEE__EED_Ticket_Sales_Monitor__release_tickets_for_expired_carts__end', |
|
| 231 | + $expired_ticket_IDs, |
|
| 232 | + $expired_ticket_line_items |
|
| 233 | + ); |
|
| 234 | + } |
|
| 235 | + |
|
| 236 | + |
|
| 237 | + |
|
| 238 | + /********************************** VALIDATE_TICKET_SALE **********************************/ |
|
| 239 | + |
|
| 240 | + |
|
| 241 | + /** |
|
| 242 | + * callback for 'FHEE__EED_Ticket_Selector__process_ticket_selections__valid_post_data' |
|
| 243 | + * |
|
| 244 | + * @param int $qty |
|
| 245 | + * @param EE_Ticket $ticket |
|
| 246 | + * @return bool |
|
| 247 | + * @throws UnexpectedEntityException |
|
| 248 | + * @throws EE_Error |
|
| 249 | + */ |
|
| 250 | + public static function validate_ticket_sale($qty = 1, EE_Ticket $ticket) |
|
| 251 | + { |
|
| 252 | + $qty = absint($qty); |
|
| 253 | + if ($qty > 0) { |
|
| 254 | + $qty = EED_Ticket_Sales_Monitor::instance()->_validate_ticket_sale($ticket, $qty); |
|
| 255 | + } |
|
| 256 | + // self::debug hardcoded to false |
|
| 257 | + if (self::debug) { |
|
| 258 | + echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '()'; |
|
| 259 | + echo self::$nl . self::$nl . '<b> RETURNED QTY: ' . $qty . '</b>'; |
|
| 260 | + } |
|
| 261 | + return $qty; |
|
| 262 | + } |
|
| 263 | + |
|
| 264 | + |
|
| 265 | + /** |
|
| 266 | + * checks whether an individual ticket is available for purchase based on datetime, and ticket details |
|
| 267 | + * |
|
| 268 | + * @param EE_Ticket $ticket |
|
| 269 | + * @param int $qty |
|
| 270 | + * @return int |
|
| 271 | + * @throws UnexpectedEntityException |
|
| 272 | + * @throws EE_Error |
|
| 273 | + */ |
|
| 274 | + protected function _validate_ticket_sale(EE_Ticket $ticket, $qty = 1) |
|
| 275 | + { |
|
| 276 | + // self::debug hardcoded to false |
|
| 277 | + if (self::debug) { |
|
| 278 | + echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() '; |
|
| 279 | + } |
|
| 280 | + if (! $ticket instanceof EE_Ticket) { |
|
| 281 | + return 0; |
|
| 282 | + } |
|
| 283 | + if (self::debug) { |
|
| 284 | + echo self::$nl . '<b> . ticket->ID: ' . $ticket->ID() . '</b>'; |
|
| 285 | + echo self::$nl . ' . original ticket->reserved: ' . $ticket->reserved(); |
|
| 286 | + } |
|
| 287 | + $ticket->refresh_from_db(); |
|
| 288 | + // first let's determine the ticket availability based on sales |
|
| 289 | + $available = $ticket->qty('saleable'); |
|
| 290 | + if (self::debug) { |
|
| 291 | + echo self::$nl . ' . . . ticket->qty: ' . $ticket->qty(); |
|
| 292 | + echo self::$nl . ' . . . ticket->sold: ' . $ticket->sold(); |
|
| 293 | + echo self::$nl . ' . . . ticket->reserved: ' . $ticket->reserved(); |
|
| 294 | + echo self::$nl . ' . . . ticket->qty(saleable): ' . $ticket->qty('saleable'); |
|
| 295 | + echo self::$nl . ' . . . available: ' . $available; |
|
| 296 | + } |
|
| 297 | + if ($available < 1) { |
|
| 298 | + $this->_ticket_sold_out($ticket); |
|
| 299 | + return 0; |
|
| 300 | + } |
|
| 301 | + if (self::debug) { |
|
| 302 | + echo self::$nl . ' . . . qty: ' . $qty; |
|
| 303 | + } |
|
| 304 | + if ($available < $qty) { |
|
| 305 | + $qty = $available; |
|
| 306 | + if (self::debug) { |
|
| 307 | + echo self::$nl . ' . . . QTY ADJUSTED: ' . $qty; |
|
| 308 | + } |
|
| 309 | + $this->_ticket_quantity_decremented($ticket); |
|
| 310 | + } |
|
| 311 | + if ($this->_reserve_ticket($ticket, $qty)) { |
|
| 312 | + return $qty; |
|
| 313 | + } else { |
|
| 314 | + return 0; |
|
| 315 | + } |
|
| 316 | + } |
|
| 317 | + |
|
| 318 | + |
|
| 319 | + /** |
|
| 320 | + * increments ticket reserved based on quantity passed |
|
| 321 | + * |
|
| 322 | + * @param EE_Ticket $ticket |
|
| 323 | + * @param int $quantity |
|
| 324 | + * @return bool indicating success or failure |
|
| 325 | + * @throws EE_Error |
|
| 326 | + */ |
|
| 327 | + protected function _reserve_ticket(EE_Ticket $ticket, $quantity = 1) |
|
| 328 | + { |
|
| 329 | + // self::debug hardcoded to false |
|
| 330 | + if (self::debug) { |
|
| 331 | + echo self::$nl . self::$nl . ' . . . INCREASE RESERVED: ' . $quantity; |
|
| 332 | + } |
|
| 333 | + return $ticket->increaseReserved($quantity, 'TicketSalesMonitor:' . __LINE__); |
|
| 334 | + } |
|
| 335 | + |
|
| 336 | + |
|
| 337 | + /** |
|
| 338 | + * @param EE_Ticket $ticket |
|
| 339 | + * @param int $quantity |
|
| 340 | + * @return bool |
|
| 341 | + * @throws EE_Error |
|
| 342 | + */ |
|
| 343 | + protected function _release_reserved_ticket(EE_Ticket $ticket, $quantity = 1) |
|
| 344 | + { |
|
| 345 | + // self::debug hardcoded to false |
|
| 346 | + if (self::debug) { |
|
| 347 | + echo self::$nl . ' . . . ticket->ID: ' . $ticket->ID(); |
|
| 348 | + echo self::$nl . ' . . . ticket->reserved before: ' . $ticket->reserved(); |
|
| 349 | + } |
|
| 350 | + $ticket->decreaseReserved($quantity, true, 'TicketSalesMonitor:' . __LINE__); |
|
| 351 | + if (self::debug) { |
|
| 352 | + echo self::$nl . ' . . . ticket->reserved after: ' . $ticket->reserved(); |
|
| 353 | + } |
|
| 354 | + return $ticket->save() ? 1 : 0; |
|
| 355 | + } |
|
| 356 | + |
|
| 357 | + |
|
| 358 | + /** |
|
| 359 | + * removes quantities within the ticket selector based on zero ticket availability |
|
| 360 | + * |
|
| 361 | + * @param EE_Ticket $ticket |
|
| 362 | + * @return void |
|
| 363 | + * @throws UnexpectedEntityException |
|
| 364 | + * @throws EE_Error |
|
| 365 | + */ |
|
| 366 | + protected function _ticket_sold_out(EE_Ticket $ticket) |
|
| 367 | + { |
|
| 368 | + // self::debug hardcoded to false |
|
| 369 | + if (self::debug) { |
|
| 370 | + echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() '; |
|
| 371 | + echo self::$nl . ' . . ticket->name: ' . $this->_get_ticket_and_event_name($ticket); |
|
| 372 | + } |
|
| 373 | + $this->sold_out_tickets[] = $this->_get_ticket_and_event_name($ticket); |
|
| 374 | + } |
|
| 375 | + |
|
| 376 | + |
|
| 377 | + /** |
|
| 378 | + * adjusts quantities within the ticket selector based on decreased ticket availability |
|
| 379 | + * |
|
| 380 | + * @param EE_Ticket $ticket |
|
| 381 | + * @return void |
|
| 382 | + * @throws UnexpectedEntityException |
|
| 383 | + * @throws EE_Error |
|
| 384 | + */ |
|
| 385 | + protected function _ticket_quantity_decremented(EE_Ticket $ticket) |
|
| 386 | + { |
|
| 387 | + // self::debug hardcoded to false |
|
| 388 | + if (self::debug) { |
|
| 389 | + echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() '; |
|
| 390 | + echo self::$nl . ' . . ticket->name: ' . $this->_get_ticket_and_event_name($ticket); |
|
| 391 | + } |
|
| 392 | + $this->decremented_tickets[] = $this->_get_ticket_and_event_name($ticket); |
|
| 393 | + } |
|
| 394 | + |
|
| 395 | + |
|
| 396 | + /** |
|
| 397 | + * builds string out of ticket and event name |
|
| 398 | + * |
|
| 399 | + * @param EE_Ticket $ticket |
|
| 400 | + * @return string |
|
| 401 | + * @throws UnexpectedEntityException |
|
| 402 | + * @throws EE_Error |
|
| 403 | + */ |
|
| 404 | + protected function _get_ticket_and_event_name(EE_Ticket $ticket) |
|
| 405 | + { |
|
| 406 | + $event = $ticket->get_related_event(); |
|
| 407 | + if ($event instanceof EE_Event) { |
|
| 408 | + $ticket_name = sprintf( |
|
| 409 | + _x('%1$s for %2$s', 'ticket name for event name', 'event_espresso'), |
|
| 410 | + $ticket->name(), |
|
| 411 | + $event->name() |
|
| 412 | + ); |
|
| 413 | + } else { |
|
| 414 | + $ticket_name = $ticket->name(); |
|
| 415 | + } |
|
| 416 | + return $ticket_name; |
|
| 417 | + } |
|
| 418 | + |
|
| 419 | + |
|
| 420 | + |
|
| 421 | + /********************************** EVENT CART **********************************/ |
|
| 422 | + |
|
| 423 | + |
|
| 424 | + /** |
|
| 425 | + * releases or reserves ticket(s) based on quantity passed |
|
| 426 | + * |
|
| 427 | + * @param EE_Line_Item $line_item |
|
| 428 | + * @param int $quantity |
|
| 429 | + * @return void |
|
| 430 | + * @throws EE_Error |
|
| 431 | + * @throws InvalidArgumentException |
|
| 432 | + * @throws InvalidDataTypeException |
|
| 433 | + * @throws InvalidInterfaceException |
|
| 434 | + */ |
|
| 435 | + public static function ticket_quantity_updated(EE_Line_Item $line_item, $quantity = 1) |
|
| 436 | + { |
|
| 437 | + $ticket = EEM_Ticket::instance()->get_one_by_ID(absint($line_item->OBJ_ID())); |
|
| 438 | + if ($ticket instanceof EE_Ticket) { |
|
| 439 | + $ticket->add_extra_meta( |
|
| 440 | + EE_Ticket::META_KEY_TICKET_RESERVATIONS, |
|
| 441 | + __LINE__ . ') ' . __METHOD__ . '()' |
|
| 442 | + ); |
|
| 443 | + if ($quantity > 0) { |
|
| 444 | + EED_Ticket_Sales_Monitor::instance()->_reserve_ticket($ticket, $quantity); |
|
| 445 | + } else { |
|
| 446 | + EED_Ticket_Sales_Monitor::instance()->_release_reserved_ticket($ticket, $quantity); |
|
| 447 | + } |
|
| 448 | + } |
|
| 449 | + } |
|
| 450 | + |
|
| 451 | + |
|
| 452 | + /** |
|
| 453 | + * releases reserved ticket(s) based on quantity passed |
|
| 454 | + * |
|
| 455 | + * @param EE_Ticket $ticket |
|
| 456 | + * @param int $quantity |
|
| 457 | + * @return void |
|
| 458 | + * @throws EE_Error |
|
| 459 | + */ |
|
| 460 | + public static function ticket_removed_from_cart(EE_Ticket $ticket, $quantity = 1) |
|
| 461 | + { |
|
| 462 | + $ticket->add_extra_meta( |
|
| 463 | + EE_Ticket::META_KEY_TICKET_RESERVATIONS, |
|
| 464 | + __LINE__ . ') ' . __METHOD__ . '()' |
|
| 465 | + ); |
|
| 466 | + EED_Ticket_Sales_Monitor::instance()->_release_reserved_ticket($ticket, $quantity); |
|
| 467 | + } |
|
| 468 | + |
|
| 469 | + |
|
| 470 | + |
|
| 471 | + /********************************** POST_NOTICES **********************************/ |
|
| 472 | + |
|
| 473 | + |
|
| 474 | + /** |
|
| 475 | + * @return void |
|
| 476 | + * @throws EE_Error |
|
| 477 | + * @throws InvalidArgumentException |
|
| 478 | + * @throws ReflectionException |
|
| 479 | + * @throws InvalidDataTypeException |
|
| 480 | + * @throws InvalidInterfaceException |
|
| 481 | + */ |
|
| 482 | + public static function post_notices() |
|
| 483 | + { |
|
| 484 | + EED_Ticket_Sales_Monitor::instance()->_post_notices(); |
|
| 485 | + } |
|
| 486 | + |
|
| 487 | + |
|
| 488 | + /** |
|
| 489 | + * @return void |
|
| 490 | + * @throws EE_Error |
|
| 491 | + * @throws InvalidArgumentException |
|
| 492 | + * @throws ReflectionException |
|
| 493 | + * @throws InvalidDataTypeException |
|
| 494 | + * @throws InvalidInterfaceException |
|
| 495 | + */ |
|
| 496 | + protected function _post_notices() |
|
| 497 | + { |
|
| 498 | + // self::debug hardcoded to false |
|
| 499 | + if (self::debug) { |
|
| 500 | + echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() '; |
|
| 501 | + } |
|
| 502 | + $refresh_msg = ''; |
|
| 503 | + $none_added_msg = ''; |
|
| 504 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
| 505 | + $refresh_msg = esc_html__( |
|
| 506 | + 'Please refresh the page to view updated ticket quantities.', |
|
| 507 | + 'event_espresso' |
|
| 508 | + ); |
|
| 509 | + $none_added_msg = esc_html__('No tickets were added for the event.', 'event_espresso'); |
|
| 510 | + } |
|
| 511 | + if (! empty($this->sold_out_tickets)) { |
|
| 512 | + EE_Error::add_attention( |
|
| 513 | + sprintf( |
|
| 514 | + apply_filters( |
|
| 515 | + 'FHEE__EED_Ticket_Sales_Monitor___post_notices__sold_out_tickets_notice', |
|
| 516 | + esc_html__( |
|
| 517 | + 'We\'re sorry...%1$sThe following items have sold out since you first viewed this page, and can no longer be registered for:%1$s%1$s%2$s%1$s%1$sPlease note that availability can change at any time due to cancellations, so please check back again later if registration for this event(s) is important to you.%1$s%1$s%3$s%1$s%4$s%1$s', |
|
| 518 | + 'event_espresso' |
|
| 519 | + ) |
|
| 520 | + ), |
|
| 521 | + '<br />', |
|
| 522 | + implode('<br />', $this->sold_out_tickets), |
|
| 523 | + $none_added_msg, |
|
| 524 | + $refresh_msg |
|
| 525 | + ) |
|
| 526 | + ); |
|
| 527 | + // alter code flow in the Ticket Selector for better UX |
|
| 528 | + add_filter('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', '__return_true'); |
|
| 529 | + add_filter('FHEE__EED_Ticket_Selector__process_ticket_selections__success', '__return_false'); |
|
| 530 | + $this->sold_out_tickets = array(); |
|
| 531 | + // and reset the cart |
|
| 532 | + EED_Ticket_Sales_Monitor::session_cart_reset(EE_Registry::instance()->SSN); |
|
| 533 | + } |
|
| 534 | + if (! empty($this->decremented_tickets)) { |
|
| 535 | + EE_Error::add_attention( |
|
| 536 | + sprintf( |
|
| 537 | + apply_filters( |
|
| 538 | + 'FHEE__EED_Ticket_Sales_Monitor___ticket_quantity_decremented__notice', |
|
| 539 | + esc_html__( |
|
| 540 | + 'We\'re sorry...%1$sDue to sales that have occurred since you first viewed the last page, the following items have had their quantities adjusted to match the current available amount:%1$s%1$s%2$s%1$s%1$sPlease note that availability can change at any time due to cancellations, so please check back again later if registration for this event(s) is important to you.%1$s%1$s%3$s%1$s%4$s%1$s', |
|
| 541 | + 'event_espresso' |
|
| 542 | + ) |
|
| 543 | + ), |
|
| 544 | + '<br />', |
|
| 545 | + implode('<br />', $this->decremented_tickets), |
|
| 546 | + $none_added_msg, |
|
| 547 | + $refresh_msg |
|
| 548 | + ) |
|
| 549 | + ); |
|
| 550 | + $this->decremented_tickets = array(); |
|
| 551 | + } |
|
| 552 | + } |
|
| 553 | + |
|
| 554 | + |
|
| 555 | + |
|
| 556 | + /********************************** RELEASE_ALL_RESERVED_TICKETS_FOR_TRANSACTION **********************************/ |
|
| 557 | + |
|
| 558 | + |
|
| 559 | + /** |
|
| 560 | + * releases reserved tickets for all registrations of an EE_Transaction |
|
| 561 | + * by default, will NOT release tickets for finalized transactions |
|
| 562 | + * |
|
| 563 | + * @param EE_Transaction $transaction |
|
| 564 | + * @return int |
|
| 565 | + * @throws EE_Error |
|
| 566 | + * @throws InvalidSessionDataException |
|
| 567 | + */ |
|
| 568 | + protected function _release_all_reserved_tickets_for_transaction(EE_Transaction $transaction) |
|
| 569 | + { |
|
| 570 | + // self::debug hardcoded to false |
|
| 571 | + if (self::debug) { |
|
| 572 | + echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() '; |
|
| 573 | + echo self::$nl . ' . transaction->ID: ' . $transaction->ID(); |
|
| 574 | + echo self::$nl . ' . TXN status_ID: ' . $transaction->status_ID(); |
|
| 575 | + } |
|
| 576 | + // check if 'finalize_registration' step has been completed... |
|
| 577 | + $finalized = $transaction->reg_step_completed('finalize_registration'); |
|
| 578 | + if (self::debug) { |
|
| 579 | + // DEBUG LOG |
|
| 580 | + EEH_Debug_Tools::log( |
|
| 581 | + __CLASS__, |
|
| 582 | + __FUNCTION__, |
|
| 583 | + __LINE__, |
|
| 584 | + array('finalized' => $finalized), |
|
| 585 | + false, |
|
| 586 | + 'EE_Transaction: ' . $transaction->ID() |
|
| 587 | + ); |
|
| 588 | + } |
|
| 589 | + // how many tickets were released |
|
| 590 | + $count = 0; |
|
| 591 | + if (self::debug) { |
|
| 592 | + echo self::$nl . ' . . . TXN finalized: ' . $finalized; |
|
| 593 | + } |
|
| 594 | + $release_tickets_with_TXN_status = array( |
|
| 595 | + EEM_Transaction::failed_status_code, |
|
| 596 | + EEM_Transaction::abandoned_status_code, |
|
| 597 | + EEM_Transaction::incomplete_status_code, |
|
| 598 | + ); |
|
| 599 | + $events = array(); |
|
| 600 | + // if the session is getting cleared BEFORE the TXN has been finalized or the transaction is not completed |
|
| 601 | + if (! $finalized || in_array($transaction->status_ID(), $release_tickets_with_TXN_status, true)) { |
|
| 602 | + // cancel any reserved tickets for registrations that were not approved |
|
| 603 | + $registrations = $transaction->registrations(); |
|
| 604 | + if (self::debug) { |
|
| 605 | + echo self::$nl . ' . . . # registrations: ' . count($registrations); |
|
| 606 | + $reg = reset($registrations); |
|
| 607 | + $ticket = $reg->ticket(); |
|
| 608 | + if ($ticket instanceof EE_Ticket) { |
|
| 609 | + $ticket->add_extra_meta( |
|
| 610 | + EE_Ticket::META_KEY_TICKET_RESERVATIONS, |
|
| 611 | + __LINE__ . ') Release All Tickets TXN:' . $transaction->ID() |
|
| 612 | + ); |
|
| 613 | + } |
|
| 614 | + } |
|
| 615 | + if (! empty($registrations)) { |
|
| 616 | + foreach ($registrations as $registration) { |
|
| 617 | + if ( |
|
| 618 | + $registration instanceof EE_Registration |
|
| 619 | + && $this->_release_reserved_ticket_for_registration($registration, $transaction) |
|
| 620 | + ) { |
|
| 621 | + $count++; |
|
| 622 | + $events[ $registration->event_ID() ] = $registration->event(); |
|
| 623 | + } |
|
| 624 | + } |
|
| 625 | + } |
|
| 626 | + } |
|
| 627 | + if ($events !== array()) { |
|
| 628 | + foreach ($events as $event) { |
|
| 629 | + /** @var EE_Event $event */ |
|
| 630 | + $event->perform_sold_out_status_check(); |
|
| 631 | + } |
|
| 632 | + } |
|
| 633 | + return $count; |
|
| 634 | + } |
|
| 635 | + |
|
| 636 | + |
|
| 637 | + /** |
|
| 638 | + * releases reserved tickets for an EE_Registration |
|
| 639 | + * by default, will NOT release tickets for APPROVED registrations |
|
| 640 | + * |
|
| 641 | + * @param EE_Registration $registration |
|
| 642 | + * @param EE_Transaction $transaction |
|
| 643 | + * @return int |
|
| 644 | + * @throws EE_Error |
|
| 645 | + */ |
|
| 646 | + protected function _release_reserved_ticket_for_registration( |
|
| 647 | + EE_Registration $registration, |
|
| 648 | + EE_Transaction $transaction |
|
| 649 | + ) { |
|
| 650 | + $STS_ID = $transaction->status_ID(); |
|
| 651 | + // self::debug hardcoded to false |
|
| 652 | + if (self::debug) { |
|
| 653 | + echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() '; |
|
| 654 | + echo self::$nl . ' . . registration->ID: ' . $registration->ID(); |
|
| 655 | + echo self::$nl . ' . . registration->status_ID: ' . $registration->status_ID(); |
|
| 656 | + echo self::$nl . ' . . transaction->status_ID(): ' . $STS_ID; |
|
| 657 | + } |
|
| 658 | + if ( |
|
| 659 | 659 | // release Tickets for Failed Transactions and Abandoned Transactions |
| 660 | - $STS_ID === EEM_Transaction::failed_status_code |
|
| 661 | - || $STS_ID === EEM_Transaction::abandoned_status_code |
|
| 662 | - || ( |
|
| 663 | - // also release Tickets for Incomplete Transactions, but ONLY if the Registrations are NOT Approved |
|
| 664 | - $STS_ID === EEM_Transaction::incomplete_status_code |
|
| 665 | - && $registration->status_ID() !== EEM_Registration::status_id_approved |
|
| 666 | - ) |
|
| 667 | - ) { |
|
| 668 | - if (self::debug) { |
|
| 669 | - echo self::$nl . self::$nl . ' . . RELEASE RESERVED TICKET'; |
|
| 670 | - $rsrvd = $registration->get_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true); |
|
| 671 | - echo self::$nl . ' . . . registration HAS_RESERVED_TICKET_KEY: '; |
|
| 672 | - var_dump($rsrvd); |
|
| 673 | - } |
|
| 674 | - $registration->release_reserved_ticket(true, 'TicketSalesMonitor:' . __LINE__); |
|
| 675 | - return 1; |
|
| 676 | - } |
|
| 677 | - return 0; |
|
| 678 | - } |
|
| 679 | - |
|
| 680 | - |
|
| 681 | - |
|
| 682 | - /********************************** SESSION_CART_RESET **********************************/ |
|
| 683 | - |
|
| 684 | - |
|
| 685 | - /** |
|
| 686 | - * callback hooked into 'AHEE__EE_Session__reset_cart__before_reset' |
|
| 687 | - * |
|
| 688 | - * @param EE_Session $session |
|
| 689 | - * @return void |
|
| 690 | - * @throws EE_Error |
|
| 691 | - * @throws InvalidArgumentException |
|
| 692 | - * @throws ReflectionException |
|
| 693 | - * @throws InvalidDataTypeException |
|
| 694 | - * @throws InvalidInterfaceException |
|
| 695 | - */ |
|
| 696 | - public static function session_cart_reset(EE_Session $session) |
|
| 697 | - { |
|
| 698 | - // don't release tickets if checkout was already reset |
|
| 699 | - if (did_action('AHEE__EE_Session__reset_checkout__before_reset')) { |
|
| 700 | - return; |
|
| 701 | - } |
|
| 702 | - // self::debug hardcoded to false |
|
| 703 | - if (self::debug) { |
|
| 704 | - echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() '; |
|
| 705 | - } |
|
| 706 | - // first check of the session has a valid Checkout object |
|
| 707 | - $checkout = $session->checkout(); |
|
| 708 | - if ($checkout instanceof EE_Checkout) { |
|
| 709 | - // and use that to clear ticket reservations because it will update the associated registration meta data |
|
| 710 | - EED_Ticket_Sales_Monitor::instance()->_session_checkout_reset($checkout); |
|
| 711 | - return; |
|
| 712 | - } |
|
| 713 | - $cart = $session->cart(); |
|
| 714 | - if ($cart instanceof EE_Cart) { |
|
| 715 | - if (self::debug) { |
|
| 716 | - echo self::$nl . self::$nl . ' cart instance of EE_Cart: '; |
|
| 717 | - } |
|
| 718 | - EED_Ticket_Sales_Monitor::instance()->_session_cart_reset($cart, $session); |
|
| 719 | - } else { |
|
| 720 | - if (self::debug) { |
|
| 721 | - echo self::$nl . self::$nl . ' invalid EE_Cart: '; |
|
| 722 | - var_export($cart, true); |
|
| 723 | - } |
|
| 724 | - } |
|
| 725 | - } |
|
| 726 | - |
|
| 727 | - |
|
| 728 | - /** |
|
| 729 | - * releases reserved tickets in the EE_Cart |
|
| 730 | - * |
|
| 731 | - * @param EE_Cart $cart |
|
| 732 | - * @return void |
|
| 733 | - * @throws EE_Error |
|
| 734 | - * @throws InvalidArgumentException |
|
| 735 | - * @throws ReflectionException |
|
| 736 | - * @throws InvalidDataTypeException |
|
| 737 | - * @throws InvalidInterfaceException |
|
| 738 | - */ |
|
| 739 | - protected function _session_cart_reset(EE_Cart $cart, EE_Session $session) |
|
| 740 | - { |
|
| 741 | - // self::debug hardcoded to false |
|
| 742 | - if (self::debug) { |
|
| 743 | - echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() '; |
|
| 744 | - } |
|
| 745 | - $ticket_line_items = $cart->get_tickets(); |
|
| 746 | - if (empty($ticket_line_items)) { |
|
| 747 | - return; |
|
| 748 | - } |
|
| 749 | - if (self::debug) { |
|
| 750 | - echo '<br /> . ticket_line_item count: ' . count($ticket_line_items); |
|
| 751 | - } |
|
| 752 | - foreach ($ticket_line_items as $ticket_line_item) { |
|
| 753 | - if (self::debug) { |
|
| 754 | - echo self::$nl . ' . ticket_line_item->ID(): ' . $ticket_line_item->ID(); |
|
| 755 | - } |
|
| 756 | - if ($ticket_line_item instanceof EE_Line_Item && $ticket_line_item->OBJ_type() === 'Ticket') { |
|
| 757 | - if (self::debug) { |
|
| 758 | - echo self::$nl . ' . . ticket_line_item->OBJ_ID(): ' . $ticket_line_item->OBJ_ID(); |
|
| 759 | - } |
|
| 760 | - $ticket = EEM_Ticket::instance()->get_one_by_ID($ticket_line_item->OBJ_ID()); |
|
| 761 | - if ($ticket instanceof EE_Ticket) { |
|
| 762 | - if (self::debug) { |
|
| 763 | - echo self::$nl . ' . . ticket->ID(): ' . $ticket->ID(); |
|
| 764 | - echo self::$nl . ' . . ticket_line_item->quantity(): ' . $ticket_line_item->quantity(); |
|
| 765 | - } |
|
| 766 | - $ticket->add_extra_meta( |
|
| 767 | - EE_Ticket::META_KEY_TICKET_RESERVATIONS, |
|
| 768 | - __LINE__ . ') ' . __METHOD__ . '() SID = ' . $session->id() |
|
| 769 | - ); |
|
| 770 | - $this->_release_reserved_ticket($ticket, $ticket_line_item->quantity()); |
|
| 771 | - } |
|
| 772 | - } |
|
| 773 | - } |
|
| 774 | - if (self::debug) { |
|
| 775 | - echo self::$nl . self::$nl . ' RESET COMPLETED '; |
|
| 776 | - } |
|
| 777 | - } |
|
| 778 | - |
|
| 779 | - |
|
| 780 | - |
|
| 781 | - /********************************** SESSION_CHECKOUT_RESET **********************************/ |
|
| 782 | - |
|
| 783 | - |
|
| 784 | - /** |
|
| 785 | - * callback hooked into 'AHEE__EE_Session__reset_checkout__before_reset' |
|
| 786 | - * |
|
| 787 | - * @param EE_Session $session |
|
| 788 | - * @return void |
|
| 789 | - * @throws EE_Error |
|
| 790 | - * @throws InvalidSessionDataException |
|
| 791 | - */ |
|
| 792 | - public static function session_checkout_reset(EE_Session $session) |
|
| 793 | - { |
|
| 794 | - // don't release tickets if cart was already reset |
|
| 795 | - if (did_action('AHEE__EE_Session__reset_cart__before_reset')) { |
|
| 796 | - return; |
|
| 797 | - } |
|
| 798 | - $checkout = $session->checkout(); |
|
| 799 | - if ($checkout instanceof EE_Checkout) { |
|
| 800 | - EED_Ticket_Sales_Monitor::instance()->_session_checkout_reset($checkout); |
|
| 801 | - } |
|
| 802 | - } |
|
| 803 | - |
|
| 804 | - |
|
| 805 | - /** |
|
| 806 | - * releases reserved tickets for the EE_Checkout->transaction |
|
| 807 | - * |
|
| 808 | - * @param EE_Checkout $checkout |
|
| 809 | - * @return void |
|
| 810 | - * @throws EE_Error |
|
| 811 | - * @throws InvalidSessionDataException |
|
| 812 | - */ |
|
| 813 | - protected function _session_checkout_reset(EE_Checkout $checkout) |
|
| 814 | - { |
|
| 815 | - // self::debug hardcoded to false |
|
| 816 | - if (self::debug) { |
|
| 817 | - echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() '; |
|
| 818 | - } |
|
| 819 | - // we want to release the each registration's reserved tickets if the session was cleared, but not if this is a revisit |
|
| 820 | - if ($checkout->revisit || ! $checkout->transaction instanceof EE_Transaction) { |
|
| 821 | - return; |
|
| 822 | - } |
|
| 823 | - $this->_release_all_reserved_tickets_for_transaction($checkout->transaction); |
|
| 824 | - } |
|
| 825 | - |
|
| 826 | - |
|
| 827 | - |
|
| 828 | - /********************************** SESSION_EXPIRED_RESET **********************************/ |
|
| 829 | - |
|
| 830 | - |
|
| 831 | - /** |
|
| 832 | - * @param EE_Session $session |
|
| 833 | - * @return void |
|
| 834 | - */ |
|
| 835 | - public static function session_expired_reset(EE_Session $session) |
|
| 836 | - { |
|
| 837 | - } |
|
| 838 | - |
|
| 839 | - |
|
| 840 | - |
|
| 841 | - /********************************** PROCESS_ABANDONED_TRANSACTIONS **********************************/ |
|
| 842 | - |
|
| 843 | - |
|
| 844 | - /** |
|
| 845 | - * releases reserved tickets for all registrations of an ABANDONED EE_Transaction |
|
| 846 | - * by default, will NOT release tickets for free transactions, or any that have received a payment |
|
| 847 | - * |
|
| 848 | - * @param EE_Transaction $transaction |
|
| 849 | - * @return void |
|
| 850 | - * @throws EE_Error |
|
| 851 | - * @throws InvalidSessionDataException |
|
| 852 | - */ |
|
| 853 | - public static function process_abandoned_transactions(EE_Transaction $transaction) |
|
| 854 | - { |
|
| 855 | - // is this TXN free or has any money been paid towards this TXN? If so, then leave it alone |
|
| 856 | - if ($transaction->is_free() || $transaction->paid() > 0) { |
|
| 857 | - // self::debug hardcoded to false |
|
| 858 | - if (self::debug) { |
|
| 859 | - // DEBUG LOG |
|
| 860 | - EEH_Debug_Tools::log( |
|
| 861 | - __CLASS__, |
|
| 862 | - __FUNCTION__, |
|
| 863 | - __LINE__, |
|
| 864 | - array($transaction), |
|
| 865 | - false, |
|
| 866 | - 'EE_Transaction: ' . $transaction->ID() |
|
| 867 | - ); |
|
| 868 | - } |
|
| 869 | - return; |
|
| 870 | - } |
|
| 871 | - // have their been any successful payments made ? |
|
| 872 | - $payments = $transaction->payments(); |
|
| 873 | - foreach ($payments as $payment) { |
|
| 874 | - if ($payment instanceof EE_Payment && $payment->status() === EEM_Payment::status_id_approved) { |
|
| 875 | - if (self::debug) { |
|
| 876 | - // DEBUG LOG |
|
| 877 | - EEH_Debug_Tools::log( |
|
| 878 | - __CLASS__, |
|
| 879 | - __FUNCTION__, |
|
| 880 | - __LINE__, |
|
| 881 | - array($payment), |
|
| 882 | - false, |
|
| 883 | - 'EE_Transaction: ' . $transaction->ID() |
|
| 884 | - ); |
|
| 885 | - } |
|
| 886 | - return; |
|
| 887 | - } |
|
| 888 | - } |
|
| 889 | - // since you haven't even attempted to pay for your ticket... |
|
| 890 | - EED_Ticket_Sales_Monitor::instance()->_release_all_reserved_tickets_for_transaction($transaction); |
|
| 891 | - } |
|
| 892 | - |
|
| 893 | - |
|
| 894 | - |
|
| 895 | - /********************************** PROCESS_FAILED_TRANSACTIONS **********************************/ |
|
| 896 | - |
|
| 897 | - |
|
| 898 | - /** |
|
| 899 | - * releases reserved tickets for absolutely ALL registrations of a FAILED EE_Transaction |
|
| 900 | - * |
|
| 901 | - * @param EE_Transaction $transaction |
|
| 902 | - * @return void |
|
| 903 | - * @throws EE_Error |
|
| 904 | - * @throws InvalidSessionDataException |
|
| 905 | - */ |
|
| 906 | - public static function process_failed_transactions(EE_Transaction $transaction) |
|
| 907 | - { |
|
| 908 | - // since you haven't even attempted to pay for your ticket... |
|
| 909 | - EED_Ticket_Sales_Monitor::instance()->_release_all_reserved_tickets_for_transaction($transaction); |
|
| 910 | - } |
|
| 911 | - |
|
| 912 | - |
|
| 913 | - |
|
| 914 | - /********************************** RESET RESERVATION COUNTS *********************************/ |
|
| 915 | - |
|
| 916 | - |
|
| 917 | - /** |
|
| 918 | - * Resets the ticket and datetime reserved counts. |
|
| 919 | - * |
|
| 920 | - * For all the tickets with reservations, recalculates what their actual reserved counts should be based |
|
| 921 | - * on the valid transactions. |
|
| 922 | - * |
|
| 923 | - * @return int number of tickets whose reservations were released. |
|
| 924 | - * @throws EE_Error |
|
| 925 | - * @throws DomainException |
|
| 926 | - * @throws InvalidDataTypeException |
|
| 927 | - * @throws InvalidInterfaceException |
|
| 928 | - * @throws InvalidArgumentException |
|
| 929 | - * @throws UnexpectedEntityException |
|
| 930 | - * @throws ReflectionException |
|
| 931 | - */ |
|
| 932 | - public static function reset_reservation_counts() |
|
| 933 | - { |
|
| 934 | - /** @var EE_Line_Item[] $valid_reserved_tickets */ |
|
| 935 | - $valid_reserved_tickets = array(); |
|
| 936 | - /** @var EE_Transaction[] $transactions_in_progress */ |
|
| 937 | - $transactions_in_progress = EEM_Transaction::instance()->get_transactions_in_progress(); |
|
| 938 | - foreach ($transactions_in_progress as $transaction) { |
|
| 939 | - // if this TXN has been fully completed, then skip it |
|
| 940 | - if ($transaction->reg_step_completed('finalize_registration')) { |
|
| 941 | - continue; |
|
| 942 | - } |
|
| 943 | - $total_line_item = $transaction->total_line_item(); |
|
| 944 | - // $transaction_in_progress->line |
|
| 945 | - if (! $total_line_item instanceof EE_Line_Item) { |
|
| 946 | - throw new DomainException( |
|
| 947 | - esc_html__( |
|
| 948 | - 'Transaction does not have a valid Total Line Item associated with it.', |
|
| 949 | - 'event_espresso' |
|
| 950 | - ) |
|
| 951 | - ); |
|
| 952 | - } |
|
| 953 | - $valid_reserved_tickets += EED_Ticket_Sales_Monitor::get_ticket_line_items_for_grand_total( |
|
| 954 | - $total_line_item |
|
| 955 | - ); |
|
| 956 | - } |
|
| 957 | - $total_line_items = EEM_Line_Item::instance()->get_total_line_items_for_active_carts(); |
|
| 958 | - foreach ($total_line_items as $total_line_item) { |
|
| 959 | - $valid_reserved_tickets += EED_Ticket_Sales_Monitor::get_ticket_line_items_for_grand_total( |
|
| 960 | - $total_line_item |
|
| 961 | - ); |
|
| 962 | - } |
|
| 963 | - $tickets_with_reservations = EEM_Ticket::instance()->get_tickets_with_reservations(); |
|
| 964 | - return EED_Ticket_Sales_Monitor::release_reservations_for_tickets( |
|
| 965 | - $tickets_with_reservations, |
|
| 966 | - $valid_reserved_tickets, |
|
| 967 | - __FUNCTION__ |
|
| 968 | - ); |
|
| 969 | - } |
|
| 970 | - |
|
| 971 | - |
|
| 972 | - /** |
|
| 973 | - * @param EE_Line_Item $total_line_item |
|
| 974 | - * @return EE_Line_Item[] |
|
| 975 | - */ |
|
| 976 | - private static function get_ticket_line_items_for_grand_total(EE_Line_Item $total_line_item) |
|
| 977 | - { |
|
| 978 | - /** @var EE_Line_Item[] $valid_reserved_tickets */ |
|
| 979 | - $valid_reserved_tickets = array(); |
|
| 980 | - $ticket_line_items = EEH_Line_Item::get_ticket_line_items($total_line_item); |
|
| 981 | - foreach ($ticket_line_items as $ticket_line_item) { |
|
| 982 | - if ($ticket_line_item instanceof EE_Line_Item) { |
|
| 983 | - $valid_reserved_tickets[ $ticket_line_item->ID() ] = $ticket_line_item; |
|
| 984 | - } |
|
| 985 | - } |
|
| 986 | - return $valid_reserved_tickets; |
|
| 987 | - } |
|
| 988 | - |
|
| 989 | - |
|
| 990 | - /** |
|
| 991 | - * Releases ticket and datetime reservations (ie, reduces the number of reserved spots on them). |
|
| 992 | - * |
|
| 993 | - * Given the list of tickets which have reserved spots on them, uses the complete list of line items for tickets |
|
| 994 | - * whose transactions aren't complete and also aren't yet expired (ie, they're incomplete and younger than the |
|
| 995 | - * session's expiry time) to update the ticket (and their datetimes') reserved counts. |
|
| 996 | - * |
|
| 997 | - * @param EE_Ticket[] $tickets_with_reservations all tickets with TKT_reserved > 0 |
|
| 998 | - * @param EE_Line_Item[] $valid_reserved_ticket_line_items all line items for tickets and incomplete transactions |
|
| 999 | - * whose session has NOT expired. We will use these to determine the number of ticket |
|
| 1000 | - * reservations are now invalid. We don't use the list of invalid ticket line items because |
|
| 1001 | - * we don't know which of those have already been taken into account when reducing ticket |
|
| 1002 | - * reservation counts, and which haven't. |
|
| 1003 | - * @return int |
|
| 1004 | - * @throws UnexpectedEntityException |
|
| 1005 | - * @throws DomainException |
|
| 1006 | - * @throws EE_Error |
|
| 1007 | - */ |
|
| 1008 | - protected static function release_reservations_for_tickets( |
|
| 1009 | - array $tickets_with_reservations, |
|
| 1010 | - array $valid_reserved_ticket_line_items = array(), |
|
| 1011 | - $source |
|
| 1012 | - ) { |
|
| 1013 | - $total_tickets_released = 0; |
|
| 1014 | - $sold_out_events = array(); |
|
| 1015 | - foreach ($tickets_with_reservations as $ticket_with_reservations) { |
|
| 1016 | - if (! $ticket_with_reservations instanceof EE_Ticket) { |
|
| 1017 | - continue; |
|
| 1018 | - } |
|
| 1019 | - // The $valid_reserved_ticket_line_items tells us what the reserved count on their tickets (and datetimes) |
|
| 1020 | - // SHOULD be. Instead of just directly updating the list, we're going to use EE_Ticket::decreaseReserved() |
|
| 1021 | - // to try to avoid race conditions, so instead of just finding the number to update TO, we're going to find |
|
| 1022 | - // the number to RELEASE. It's the same end result, just different path. |
|
| 1023 | - // Begin by assuming we're going to release all the reservations on this ticket. |
|
| 1024 | - $expired_reservations_count = $ticket_with_reservations->reserved(); |
|
| 1025 | - // Now reduce that number using the list of current valid reservations. |
|
| 1026 | - foreach ($valid_reserved_ticket_line_items as $valid_reserved_ticket_line_item) { |
|
| 1027 | - if ( |
|
| 1028 | - $valid_reserved_ticket_line_item instanceof EE_Line_Item |
|
| 1029 | - && $valid_reserved_ticket_line_item->OBJ_ID() === $ticket_with_reservations->ID() |
|
| 1030 | - ) { |
|
| 1031 | - $expired_reservations_count -= $valid_reserved_ticket_line_item->quantity(); |
|
| 1032 | - } |
|
| 1033 | - } |
|
| 1034 | - // Only bother saving the tickets and datetimes if we're actually going to release some spots. |
|
| 1035 | - if ($expired_reservations_count > 0) { |
|
| 1036 | - $ticket_with_reservations->add_extra_meta( |
|
| 1037 | - EE_Ticket::META_KEY_TICKET_RESERVATIONS, |
|
| 1038 | - __LINE__ . ') ' . $source . '()' |
|
| 1039 | - ); |
|
| 1040 | - $ticket_with_reservations->decreaseReserved($expired_reservations_count, true, 'TicketSalesMonitor:' . __LINE__); |
|
| 1041 | - $total_tickets_released += $expired_reservations_count; |
|
| 1042 | - $event = $ticket_with_reservations->get_related_event(); |
|
| 1043 | - // track sold out events |
|
| 1044 | - if ($event instanceof EE_Event && $event->is_sold_out()) { |
|
| 1045 | - $sold_out_events[] = $event; |
|
| 1046 | - } |
|
| 1047 | - } |
|
| 1048 | - } |
|
| 1049 | - // Double check whether sold out events should remain sold out after releasing tickets |
|
| 1050 | - if ($sold_out_events !== array()) { |
|
| 1051 | - foreach ($sold_out_events as $sold_out_event) { |
|
| 1052 | - /** @var EE_Event $sold_out_event */ |
|
| 1053 | - $sold_out_event->perform_sold_out_status_check(); |
|
| 1054 | - } |
|
| 1055 | - } |
|
| 1056 | - return $total_tickets_released; |
|
| 1057 | - } |
|
| 1058 | - |
|
| 1059 | - |
|
| 1060 | - |
|
| 1061 | - /********************************** SHUTDOWN **********************************/ |
|
| 1062 | - |
|
| 1063 | - |
|
| 1064 | - /** |
|
| 1065 | - * @param int $timestamp |
|
| 1066 | - * @return false|int |
|
| 1067 | - * @throws EE_Error |
|
| 1068 | - * @throws InvalidArgumentException |
|
| 1069 | - * @throws InvalidDataTypeException |
|
| 1070 | - * @throws InvalidInterfaceException |
|
| 1071 | - */ |
|
| 1072 | - public static function clear_expired_line_items_with_no_transaction($timestamp = 0) |
|
| 1073 | - { |
|
| 1074 | - /** @type WPDB $wpdb */ |
|
| 1075 | - global $wpdb; |
|
| 1076 | - if (! absint($timestamp)) { |
|
| 1077 | - /** @var EventEspresso\core\domain\values\session\SessionLifespan $session_lifespan */ |
|
| 1078 | - $session_lifespan = LoaderFactory::getLoader()->getShared( |
|
| 1079 | - 'EventEspresso\core\domain\values\session\SessionLifespan' |
|
| 1080 | - ); |
|
| 1081 | - $timestamp = $session_lifespan->expiration(); |
|
| 1082 | - } |
|
| 1083 | - return $wpdb->query( |
|
| 1084 | - $wpdb->prepare( |
|
| 1085 | - 'DELETE FROM ' . EEM_Line_Item::instance()->table() . ' |
|
| 660 | + $STS_ID === EEM_Transaction::failed_status_code |
|
| 661 | + || $STS_ID === EEM_Transaction::abandoned_status_code |
|
| 662 | + || ( |
|
| 663 | + // also release Tickets for Incomplete Transactions, but ONLY if the Registrations are NOT Approved |
|
| 664 | + $STS_ID === EEM_Transaction::incomplete_status_code |
|
| 665 | + && $registration->status_ID() !== EEM_Registration::status_id_approved |
|
| 666 | + ) |
|
| 667 | + ) { |
|
| 668 | + if (self::debug) { |
|
| 669 | + echo self::$nl . self::$nl . ' . . RELEASE RESERVED TICKET'; |
|
| 670 | + $rsrvd = $registration->get_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true); |
|
| 671 | + echo self::$nl . ' . . . registration HAS_RESERVED_TICKET_KEY: '; |
|
| 672 | + var_dump($rsrvd); |
|
| 673 | + } |
|
| 674 | + $registration->release_reserved_ticket(true, 'TicketSalesMonitor:' . __LINE__); |
|
| 675 | + return 1; |
|
| 676 | + } |
|
| 677 | + return 0; |
|
| 678 | + } |
|
| 679 | + |
|
| 680 | + |
|
| 681 | + |
|
| 682 | + /********************************** SESSION_CART_RESET **********************************/ |
|
| 683 | + |
|
| 684 | + |
|
| 685 | + /** |
|
| 686 | + * callback hooked into 'AHEE__EE_Session__reset_cart__before_reset' |
|
| 687 | + * |
|
| 688 | + * @param EE_Session $session |
|
| 689 | + * @return void |
|
| 690 | + * @throws EE_Error |
|
| 691 | + * @throws InvalidArgumentException |
|
| 692 | + * @throws ReflectionException |
|
| 693 | + * @throws InvalidDataTypeException |
|
| 694 | + * @throws InvalidInterfaceException |
|
| 695 | + */ |
|
| 696 | + public static function session_cart_reset(EE_Session $session) |
|
| 697 | + { |
|
| 698 | + // don't release tickets if checkout was already reset |
|
| 699 | + if (did_action('AHEE__EE_Session__reset_checkout__before_reset')) { |
|
| 700 | + return; |
|
| 701 | + } |
|
| 702 | + // self::debug hardcoded to false |
|
| 703 | + if (self::debug) { |
|
| 704 | + echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() '; |
|
| 705 | + } |
|
| 706 | + // first check of the session has a valid Checkout object |
|
| 707 | + $checkout = $session->checkout(); |
|
| 708 | + if ($checkout instanceof EE_Checkout) { |
|
| 709 | + // and use that to clear ticket reservations because it will update the associated registration meta data |
|
| 710 | + EED_Ticket_Sales_Monitor::instance()->_session_checkout_reset($checkout); |
|
| 711 | + return; |
|
| 712 | + } |
|
| 713 | + $cart = $session->cart(); |
|
| 714 | + if ($cart instanceof EE_Cart) { |
|
| 715 | + if (self::debug) { |
|
| 716 | + echo self::$nl . self::$nl . ' cart instance of EE_Cart: '; |
|
| 717 | + } |
|
| 718 | + EED_Ticket_Sales_Monitor::instance()->_session_cart_reset($cart, $session); |
|
| 719 | + } else { |
|
| 720 | + if (self::debug) { |
|
| 721 | + echo self::$nl . self::$nl . ' invalid EE_Cart: '; |
|
| 722 | + var_export($cart, true); |
|
| 723 | + } |
|
| 724 | + } |
|
| 725 | + } |
|
| 726 | + |
|
| 727 | + |
|
| 728 | + /** |
|
| 729 | + * releases reserved tickets in the EE_Cart |
|
| 730 | + * |
|
| 731 | + * @param EE_Cart $cart |
|
| 732 | + * @return void |
|
| 733 | + * @throws EE_Error |
|
| 734 | + * @throws InvalidArgumentException |
|
| 735 | + * @throws ReflectionException |
|
| 736 | + * @throws InvalidDataTypeException |
|
| 737 | + * @throws InvalidInterfaceException |
|
| 738 | + */ |
|
| 739 | + protected function _session_cart_reset(EE_Cart $cart, EE_Session $session) |
|
| 740 | + { |
|
| 741 | + // self::debug hardcoded to false |
|
| 742 | + if (self::debug) { |
|
| 743 | + echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() '; |
|
| 744 | + } |
|
| 745 | + $ticket_line_items = $cart->get_tickets(); |
|
| 746 | + if (empty($ticket_line_items)) { |
|
| 747 | + return; |
|
| 748 | + } |
|
| 749 | + if (self::debug) { |
|
| 750 | + echo '<br /> . ticket_line_item count: ' . count($ticket_line_items); |
|
| 751 | + } |
|
| 752 | + foreach ($ticket_line_items as $ticket_line_item) { |
|
| 753 | + if (self::debug) { |
|
| 754 | + echo self::$nl . ' . ticket_line_item->ID(): ' . $ticket_line_item->ID(); |
|
| 755 | + } |
|
| 756 | + if ($ticket_line_item instanceof EE_Line_Item && $ticket_line_item->OBJ_type() === 'Ticket') { |
|
| 757 | + if (self::debug) { |
|
| 758 | + echo self::$nl . ' . . ticket_line_item->OBJ_ID(): ' . $ticket_line_item->OBJ_ID(); |
|
| 759 | + } |
|
| 760 | + $ticket = EEM_Ticket::instance()->get_one_by_ID($ticket_line_item->OBJ_ID()); |
|
| 761 | + if ($ticket instanceof EE_Ticket) { |
|
| 762 | + if (self::debug) { |
|
| 763 | + echo self::$nl . ' . . ticket->ID(): ' . $ticket->ID(); |
|
| 764 | + echo self::$nl . ' . . ticket_line_item->quantity(): ' . $ticket_line_item->quantity(); |
|
| 765 | + } |
|
| 766 | + $ticket->add_extra_meta( |
|
| 767 | + EE_Ticket::META_KEY_TICKET_RESERVATIONS, |
|
| 768 | + __LINE__ . ') ' . __METHOD__ . '() SID = ' . $session->id() |
|
| 769 | + ); |
|
| 770 | + $this->_release_reserved_ticket($ticket, $ticket_line_item->quantity()); |
|
| 771 | + } |
|
| 772 | + } |
|
| 773 | + } |
|
| 774 | + if (self::debug) { |
|
| 775 | + echo self::$nl . self::$nl . ' RESET COMPLETED '; |
|
| 776 | + } |
|
| 777 | + } |
|
| 778 | + |
|
| 779 | + |
|
| 780 | + |
|
| 781 | + /********************************** SESSION_CHECKOUT_RESET **********************************/ |
|
| 782 | + |
|
| 783 | + |
|
| 784 | + /** |
|
| 785 | + * callback hooked into 'AHEE__EE_Session__reset_checkout__before_reset' |
|
| 786 | + * |
|
| 787 | + * @param EE_Session $session |
|
| 788 | + * @return void |
|
| 789 | + * @throws EE_Error |
|
| 790 | + * @throws InvalidSessionDataException |
|
| 791 | + */ |
|
| 792 | + public static function session_checkout_reset(EE_Session $session) |
|
| 793 | + { |
|
| 794 | + // don't release tickets if cart was already reset |
|
| 795 | + if (did_action('AHEE__EE_Session__reset_cart__before_reset')) { |
|
| 796 | + return; |
|
| 797 | + } |
|
| 798 | + $checkout = $session->checkout(); |
|
| 799 | + if ($checkout instanceof EE_Checkout) { |
|
| 800 | + EED_Ticket_Sales_Monitor::instance()->_session_checkout_reset($checkout); |
|
| 801 | + } |
|
| 802 | + } |
|
| 803 | + |
|
| 804 | + |
|
| 805 | + /** |
|
| 806 | + * releases reserved tickets for the EE_Checkout->transaction |
|
| 807 | + * |
|
| 808 | + * @param EE_Checkout $checkout |
|
| 809 | + * @return void |
|
| 810 | + * @throws EE_Error |
|
| 811 | + * @throws InvalidSessionDataException |
|
| 812 | + */ |
|
| 813 | + protected function _session_checkout_reset(EE_Checkout $checkout) |
|
| 814 | + { |
|
| 815 | + // self::debug hardcoded to false |
|
| 816 | + if (self::debug) { |
|
| 817 | + echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() '; |
|
| 818 | + } |
|
| 819 | + // we want to release the each registration's reserved tickets if the session was cleared, but not if this is a revisit |
|
| 820 | + if ($checkout->revisit || ! $checkout->transaction instanceof EE_Transaction) { |
|
| 821 | + return; |
|
| 822 | + } |
|
| 823 | + $this->_release_all_reserved_tickets_for_transaction($checkout->transaction); |
|
| 824 | + } |
|
| 825 | + |
|
| 826 | + |
|
| 827 | + |
|
| 828 | + /********************************** SESSION_EXPIRED_RESET **********************************/ |
|
| 829 | + |
|
| 830 | + |
|
| 831 | + /** |
|
| 832 | + * @param EE_Session $session |
|
| 833 | + * @return void |
|
| 834 | + */ |
|
| 835 | + public static function session_expired_reset(EE_Session $session) |
|
| 836 | + { |
|
| 837 | + } |
|
| 838 | + |
|
| 839 | + |
|
| 840 | + |
|
| 841 | + /********************************** PROCESS_ABANDONED_TRANSACTIONS **********************************/ |
|
| 842 | + |
|
| 843 | + |
|
| 844 | + /** |
|
| 845 | + * releases reserved tickets for all registrations of an ABANDONED EE_Transaction |
|
| 846 | + * by default, will NOT release tickets for free transactions, or any that have received a payment |
|
| 847 | + * |
|
| 848 | + * @param EE_Transaction $transaction |
|
| 849 | + * @return void |
|
| 850 | + * @throws EE_Error |
|
| 851 | + * @throws InvalidSessionDataException |
|
| 852 | + */ |
|
| 853 | + public static function process_abandoned_transactions(EE_Transaction $transaction) |
|
| 854 | + { |
|
| 855 | + // is this TXN free or has any money been paid towards this TXN? If so, then leave it alone |
|
| 856 | + if ($transaction->is_free() || $transaction->paid() > 0) { |
|
| 857 | + // self::debug hardcoded to false |
|
| 858 | + if (self::debug) { |
|
| 859 | + // DEBUG LOG |
|
| 860 | + EEH_Debug_Tools::log( |
|
| 861 | + __CLASS__, |
|
| 862 | + __FUNCTION__, |
|
| 863 | + __LINE__, |
|
| 864 | + array($transaction), |
|
| 865 | + false, |
|
| 866 | + 'EE_Transaction: ' . $transaction->ID() |
|
| 867 | + ); |
|
| 868 | + } |
|
| 869 | + return; |
|
| 870 | + } |
|
| 871 | + // have their been any successful payments made ? |
|
| 872 | + $payments = $transaction->payments(); |
|
| 873 | + foreach ($payments as $payment) { |
|
| 874 | + if ($payment instanceof EE_Payment && $payment->status() === EEM_Payment::status_id_approved) { |
|
| 875 | + if (self::debug) { |
|
| 876 | + // DEBUG LOG |
|
| 877 | + EEH_Debug_Tools::log( |
|
| 878 | + __CLASS__, |
|
| 879 | + __FUNCTION__, |
|
| 880 | + __LINE__, |
|
| 881 | + array($payment), |
|
| 882 | + false, |
|
| 883 | + 'EE_Transaction: ' . $transaction->ID() |
|
| 884 | + ); |
|
| 885 | + } |
|
| 886 | + return; |
|
| 887 | + } |
|
| 888 | + } |
|
| 889 | + // since you haven't even attempted to pay for your ticket... |
|
| 890 | + EED_Ticket_Sales_Monitor::instance()->_release_all_reserved_tickets_for_transaction($transaction); |
|
| 891 | + } |
|
| 892 | + |
|
| 893 | + |
|
| 894 | + |
|
| 895 | + /********************************** PROCESS_FAILED_TRANSACTIONS **********************************/ |
|
| 896 | + |
|
| 897 | + |
|
| 898 | + /** |
|
| 899 | + * releases reserved tickets for absolutely ALL registrations of a FAILED EE_Transaction |
|
| 900 | + * |
|
| 901 | + * @param EE_Transaction $transaction |
|
| 902 | + * @return void |
|
| 903 | + * @throws EE_Error |
|
| 904 | + * @throws InvalidSessionDataException |
|
| 905 | + */ |
|
| 906 | + public static function process_failed_transactions(EE_Transaction $transaction) |
|
| 907 | + { |
|
| 908 | + // since you haven't even attempted to pay for your ticket... |
|
| 909 | + EED_Ticket_Sales_Monitor::instance()->_release_all_reserved_tickets_for_transaction($transaction); |
|
| 910 | + } |
|
| 911 | + |
|
| 912 | + |
|
| 913 | + |
|
| 914 | + /********************************** RESET RESERVATION COUNTS *********************************/ |
|
| 915 | + |
|
| 916 | + |
|
| 917 | + /** |
|
| 918 | + * Resets the ticket and datetime reserved counts. |
|
| 919 | + * |
|
| 920 | + * For all the tickets with reservations, recalculates what their actual reserved counts should be based |
|
| 921 | + * on the valid transactions. |
|
| 922 | + * |
|
| 923 | + * @return int number of tickets whose reservations were released. |
|
| 924 | + * @throws EE_Error |
|
| 925 | + * @throws DomainException |
|
| 926 | + * @throws InvalidDataTypeException |
|
| 927 | + * @throws InvalidInterfaceException |
|
| 928 | + * @throws InvalidArgumentException |
|
| 929 | + * @throws UnexpectedEntityException |
|
| 930 | + * @throws ReflectionException |
|
| 931 | + */ |
|
| 932 | + public static function reset_reservation_counts() |
|
| 933 | + { |
|
| 934 | + /** @var EE_Line_Item[] $valid_reserved_tickets */ |
|
| 935 | + $valid_reserved_tickets = array(); |
|
| 936 | + /** @var EE_Transaction[] $transactions_in_progress */ |
|
| 937 | + $transactions_in_progress = EEM_Transaction::instance()->get_transactions_in_progress(); |
|
| 938 | + foreach ($transactions_in_progress as $transaction) { |
|
| 939 | + // if this TXN has been fully completed, then skip it |
|
| 940 | + if ($transaction->reg_step_completed('finalize_registration')) { |
|
| 941 | + continue; |
|
| 942 | + } |
|
| 943 | + $total_line_item = $transaction->total_line_item(); |
|
| 944 | + // $transaction_in_progress->line |
|
| 945 | + if (! $total_line_item instanceof EE_Line_Item) { |
|
| 946 | + throw new DomainException( |
|
| 947 | + esc_html__( |
|
| 948 | + 'Transaction does not have a valid Total Line Item associated with it.', |
|
| 949 | + 'event_espresso' |
|
| 950 | + ) |
|
| 951 | + ); |
|
| 952 | + } |
|
| 953 | + $valid_reserved_tickets += EED_Ticket_Sales_Monitor::get_ticket_line_items_for_grand_total( |
|
| 954 | + $total_line_item |
|
| 955 | + ); |
|
| 956 | + } |
|
| 957 | + $total_line_items = EEM_Line_Item::instance()->get_total_line_items_for_active_carts(); |
|
| 958 | + foreach ($total_line_items as $total_line_item) { |
|
| 959 | + $valid_reserved_tickets += EED_Ticket_Sales_Monitor::get_ticket_line_items_for_grand_total( |
|
| 960 | + $total_line_item |
|
| 961 | + ); |
|
| 962 | + } |
|
| 963 | + $tickets_with_reservations = EEM_Ticket::instance()->get_tickets_with_reservations(); |
|
| 964 | + return EED_Ticket_Sales_Monitor::release_reservations_for_tickets( |
|
| 965 | + $tickets_with_reservations, |
|
| 966 | + $valid_reserved_tickets, |
|
| 967 | + __FUNCTION__ |
|
| 968 | + ); |
|
| 969 | + } |
|
| 970 | + |
|
| 971 | + |
|
| 972 | + /** |
|
| 973 | + * @param EE_Line_Item $total_line_item |
|
| 974 | + * @return EE_Line_Item[] |
|
| 975 | + */ |
|
| 976 | + private static function get_ticket_line_items_for_grand_total(EE_Line_Item $total_line_item) |
|
| 977 | + { |
|
| 978 | + /** @var EE_Line_Item[] $valid_reserved_tickets */ |
|
| 979 | + $valid_reserved_tickets = array(); |
|
| 980 | + $ticket_line_items = EEH_Line_Item::get_ticket_line_items($total_line_item); |
|
| 981 | + foreach ($ticket_line_items as $ticket_line_item) { |
|
| 982 | + if ($ticket_line_item instanceof EE_Line_Item) { |
|
| 983 | + $valid_reserved_tickets[ $ticket_line_item->ID() ] = $ticket_line_item; |
|
| 984 | + } |
|
| 985 | + } |
|
| 986 | + return $valid_reserved_tickets; |
|
| 987 | + } |
|
| 988 | + |
|
| 989 | + |
|
| 990 | + /** |
|
| 991 | + * Releases ticket and datetime reservations (ie, reduces the number of reserved spots on them). |
|
| 992 | + * |
|
| 993 | + * Given the list of tickets which have reserved spots on them, uses the complete list of line items for tickets |
|
| 994 | + * whose transactions aren't complete and also aren't yet expired (ie, they're incomplete and younger than the |
|
| 995 | + * session's expiry time) to update the ticket (and their datetimes') reserved counts. |
|
| 996 | + * |
|
| 997 | + * @param EE_Ticket[] $tickets_with_reservations all tickets with TKT_reserved > 0 |
|
| 998 | + * @param EE_Line_Item[] $valid_reserved_ticket_line_items all line items for tickets and incomplete transactions |
|
| 999 | + * whose session has NOT expired. We will use these to determine the number of ticket |
|
| 1000 | + * reservations are now invalid. We don't use the list of invalid ticket line items because |
|
| 1001 | + * we don't know which of those have already been taken into account when reducing ticket |
|
| 1002 | + * reservation counts, and which haven't. |
|
| 1003 | + * @return int |
|
| 1004 | + * @throws UnexpectedEntityException |
|
| 1005 | + * @throws DomainException |
|
| 1006 | + * @throws EE_Error |
|
| 1007 | + */ |
|
| 1008 | + protected static function release_reservations_for_tickets( |
|
| 1009 | + array $tickets_with_reservations, |
|
| 1010 | + array $valid_reserved_ticket_line_items = array(), |
|
| 1011 | + $source |
|
| 1012 | + ) { |
|
| 1013 | + $total_tickets_released = 0; |
|
| 1014 | + $sold_out_events = array(); |
|
| 1015 | + foreach ($tickets_with_reservations as $ticket_with_reservations) { |
|
| 1016 | + if (! $ticket_with_reservations instanceof EE_Ticket) { |
|
| 1017 | + continue; |
|
| 1018 | + } |
|
| 1019 | + // The $valid_reserved_ticket_line_items tells us what the reserved count on their tickets (and datetimes) |
|
| 1020 | + // SHOULD be. Instead of just directly updating the list, we're going to use EE_Ticket::decreaseReserved() |
|
| 1021 | + // to try to avoid race conditions, so instead of just finding the number to update TO, we're going to find |
|
| 1022 | + // the number to RELEASE. It's the same end result, just different path. |
|
| 1023 | + // Begin by assuming we're going to release all the reservations on this ticket. |
|
| 1024 | + $expired_reservations_count = $ticket_with_reservations->reserved(); |
|
| 1025 | + // Now reduce that number using the list of current valid reservations. |
|
| 1026 | + foreach ($valid_reserved_ticket_line_items as $valid_reserved_ticket_line_item) { |
|
| 1027 | + if ( |
|
| 1028 | + $valid_reserved_ticket_line_item instanceof EE_Line_Item |
|
| 1029 | + && $valid_reserved_ticket_line_item->OBJ_ID() === $ticket_with_reservations->ID() |
|
| 1030 | + ) { |
|
| 1031 | + $expired_reservations_count -= $valid_reserved_ticket_line_item->quantity(); |
|
| 1032 | + } |
|
| 1033 | + } |
|
| 1034 | + // Only bother saving the tickets and datetimes if we're actually going to release some spots. |
|
| 1035 | + if ($expired_reservations_count > 0) { |
|
| 1036 | + $ticket_with_reservations->add_extra_meta( |
|
| 1037 | + EE_Ticket::META_KEY_TICKET_RESERVATIONS, |
|
| 1038 | + __LINE__ . ') ' . $source . '()' |
|
| 1039 | + ); |
|
| 1040 | + $ticket_with_reservations->decreaseReserved($expired_reservations_count, true, 'TicketSalesMonitor:' . __LINE__); |
|
| 1041 | + $total_tickets_released += $expired_reservations_count; |
|
| 1042 | + $event = $ticket_with_reservations->get_related_event(); |
|
| 1043 | + // track sold out events |
|
| 1044 | + if ($event instanceof EE_Event && $event->is_sold_out()) { |
|
| 1045 | + $sold_out_events[] = $event; |
|
| 1046 | + } |
|
| 1047 | + } |
|
| 1048 | + } |
|
| 1049 | + // Double check whether sold out events should remain sold out after releasing tickets |
|
| 1050 | + if ($sold_out_events !== array()) { |
|
| 1051 | + foreach ($sold_out_events as $sold_out_event) { |
|
| 1052 | + /** @var EE_Event $sold_out_event */ |
|
| 1053 | + $sold_out_event->perform_sold_out_status_check(); |
|
| 1054 | + } |
|
| 1055 | + } |
|
| 1056 | + return $total_tickets_released; |
|
| 1057 | + } |
|
| 1058 | + |
|
| 1059 | + |
|
| 1060 | + |
|
| 1061 | + /********************************** SHUTDOWN **********************************/ |
|
| 1062 | + |
|
| 1063 | + |
|
| 1064 | + /** |
|
| 1065 | + * @param int $timestamp |
|
| 1066 | + * @return false|int |
|
| 1067 | + * @throws EE_Error |
|
| 1068 | + * @throws InvalidArgumentException |
|
| 1069 | + * @throws InvalidDataTypeException |
|
| 1070 | + * @throws InvalidInterfaceException |
|
| 1071 | + */ |
|
| 1072 | + public static function clear_expired_line_items_with_no_transaction($timestamp = 0) |
|
| 1073 | + { |
|
| 1074 | + /** @type WPDB $wpdb */ |
|
| 1075 | + global $wpdb; |
|
| 1076 | + if (! absint($timestamp)) { |
|
| 1077 | + /** @var EventEspresso\core\domain\values\session\SessionLifespan $session_lifespan */ |
|
| 1078 | + $session_lifespan = LoaderFactory::getLoader()->getShared( |
|
| 1079 | + 'EventEspresso\core\domain\values\session\SessionLifespan' |
|
| 1080 | + ); |
|
| 1081 | + $timestamp = $session_lifespan->expiration(); |
|
| 1082 | + } |
|
| 1083 | + return $wpdb->query( |
|
| 1084 | + $wpdb->prepare( |
|
| 1085 | + 'DELETE FROM ' . EEM_Line_Item::instance()->table() . ' |
|
| 1086 | 1086 | WHERE TXN_ID = 0 AND LIN_timestamp <= %s', |
| 1087 | - // use GMT time because that's what LIN_timestamps are in |
|
| 1088 | - date('Y-m-d H:i:s', $timestamp) |
|
| 1089 | - ) |
|
| 1090 | - ); |
|
| 1091 | - } |
|
| 1087 | + // use GMT time because that's what LIN_timestamps are in |
|
| 1088 | + date('Y-m-d H:i:s', $timestamp) |
|
| 1089 | + ) |
|
| 1090 | + ); |
|
| 1091 | + } |
|
| 1092 | 1092 | } |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | { |
| 184 | 184 | // self::debug hardcoded to false |
| 185 | 185 | if (self::debug) { |
| 186 | - echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '()'; |
|
| 186 | + echo self::$nl.self::$nl.__LINE__.') '.__METHOD__.'()'; |
|
| 187 | 187 | } |
| 188 | 188 | do_action('AHEE__EED_Ticket_Sales_Monitor__release_tickets_for_expired_carts__begin'); |
| 189 | 189 | $expired_ticket_IDs = array(); |
@@ -194,29 +194,29 @@ discard block |
||
| 194 | 194 | $timestamp = $session_lifespan->expiration(); |
| 195 | 195 | $expired_ticket_line_items = EEM_Line_Item::instance()->getTicketLineItemsForExpiredCarts($timestamp); |
| 196 | 196 | if (self::debug) { |
| 197 | - echo self::$nl . ' . time(): ' . time(); |
|
| 198 | - echo self::$nl . ' . time() as date: ' . date('Y-m-d H:i a'); |
|
| 199 | - echo self::$nl . ' . session expiration: ' . $session_lifespan->expiration(); |
|
| 200 | - echo self::$nl . ' . session expiration as date: ' . date('Y-m-d H:i a', $session_lifespan->expiration()); |
|
| 201 | - echo self::$nl . ' . timestamp: ' . $timestamp; |
|
| 202 | - echo self::$nl . ' . $expired_ticket_line_items: ' . count($expired_ticket_line_items); |
|
| 197 | + echo self::$nl.' . time(): '.time(); |
|
| 198 | + echo self::$nl.' . time() as date: '.date('Y-m-d H:i a'); |
|
| 199 | + echo self::$nl.' . session expiration: '.$session_lifespan->expiration(); |
|
| 200 | + echo self::$nl.' . session expiration as date: '.date('Y-m-d H:i a', $session_lifespan->expiration()); |
|
| 201 | + echo self::$nl.' . timestamp: '.$timestamp; |
|
| 202 | + echo self::$nl.' . $expired_ticket_line_items: '.count($expired_ticket_line_items); |
|
| 203 | 203 | } |
| 204 | - if (! empty($expired_ticket_line_items)) { |
|
| 204 | + if ( ! empty($expired_ticket_line_items)) { |
|
| 205 | 205 | foreach ($expired_ticket_line_items as $expired_ticket_line_item) { |
| 206 | - if (! $expired_ticket_line_item instanceof EE_Line_Item) { |
|
| 206 | + if ( ! $expired_ticket_line_item instanceof EE_Line_Item) { |
|
| 207 | 207 | continue; |
| 208 | 208 | } |
| 209 | - $expired_ticket_IDs[ $expired_ticket_line_item->OBJ_ID() ] = $expired_ticket_line_item->OBJ_ID(); |
|
| 209 | + $expired_ticket_IDs[$expired_ticket_line_item->OBJ_ID()] = $expired_ticket_line_item->OBJ_ID(); |
|
| 210 | 210 | if (self::debug) { |
| 211 | - echo self::$nl . ' . $expired_ticket_line_item->OBJ_ID(): ' . $expired_ticket_line_item->OBJ_ID(); |
|
| 212 | - echo self::$nl . ' . $expired_ticket_line_item->timestamp(): ' |
|
| 211 | + echo self::$nl.' . $expired_ticket_line_item->OBJ_ID(): '.$expired_ticket_line_item->OBJ_ID(); |
|
| 212 | + echo self::$nl.' . $expired_ticket_line_item->timestamp(): ' |
|
| 213 | 213 | . date( |
| 214 | 214 | 'Y-m-d h:i a', |
| 215 | 215 | $expired_ticket_line_item->timestamp(true) |
| 216 | 216 | ); |
| 217 | 217 | } |
| 218 | 218 | } |
| 219 | - if (! empty($expired_ticket_IDs)) { |
|
| 219 | + if ( ! empty($expired_ticket_IDs)) { |
|
| 220 | 220 | EED_Ticket_Sales_Monitor::release_reservations_for_tickets( |
| 221 | 221 | \EEM_Ticket::instance()->get_tickets_with_IDs($expired_ticket_IDs), |
| 222 | 222 | array(), |
@@ -255,8 +255,8 @@ discard block |
||
| 255 | 255 | } |
| 256 | 256 | // self::debug hardcoded to false |
| 257 | 257 | if (self::debug) { |
| 258 | - echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '()'; |
|
| 259 | - echo self::$nl . self::$nl . '<b> RETURNED QTY: ' . $qty . '</b>'; |
|
| 258 | + echo self::$nl.self::$nl.__LINE__.') '.__METHOD__.'()'; |
|
| 259 | + echo self::$nl.self::$nl.'<b> RETURNED QTY: '.$qty.'</b>'; |
|
| 260 | 260 | } |
| 261 | 261 | return $qty; |
| 262 | 262 | } |
@@ -275,36 +275,36 @@ discard block |
||
| 275 | 275 | { |
| 276 | 276 | // self::debug hardcoded to false |
| 277 | 277 | if (self::debug) { |
| 278 | - echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() '; |
|
| 278 | + echo self::$nl.self::$nl.__LINE__.') '.__METHOD__.'() '; |
|
| 279 | 279 | } |
| 280 | - if (! $ticket instanceof EE_Ticket) { |
|
| 280 | + if ( ! $ticket instanceof EE_Ticket) { |
|
| 281 | 281 | return 0; |
| 282 | 282 | } |
| 283 | 283 | if (self::debug) { |
| 284 | - echo self::$nl . '<b> . ticket->ID: ' . $ticket->ID() . '</b>'; |
|
| 285 | - echo self::$nl . ' . original ticket->reserved: ' . $ticket->reserved(); |
|
| 284 | + echo self::$nl.'<b> . ticket->ID: '.$ticket->ID().'</b>'; |
|
| 285 | + echo self::$nl.' . original ticket->reserved: '.$ticket->reserved(); |
|
| 286 | 286 | } |
| 287 | 287 | $ticket->refresh_from_db(); |
| 288 | 288 | // first let's determine the ticket availability based on sales |
| 289 | 289 | $available = $ticket->qty('saleable'); |
| 290 | 290 | if (self::debug) { |
| 291 | - echo self::$nl . ' . . . ticket->qty: ' . $ticket->qty(); |
|
| 292 | - echo self::$nl . ' . . . ticket->sold: ' . $ticket->sold(); |
|
| 293 | - echo self::$nl . ' . . . ticket->reserved: ' . $ticket->reserved(); |
|
| 294 | - echo self::$nl . ' . . . ticket->qty(saleable): ' . $ticket->qty('saleable'); |
|
| 295 | - echo self::$nl . ' . . . available: ' . $available; |
|
| 291 | + echo self::$nl.' . . . ticket->qty: '.$ticket->qty(); |
|
| 292 | + echo self::$nl.' . . . ticket->sold: '.$ticket->sold(); |
|
| 293 | + echo self::$nl.' . . . ticket->reserved: '.$ticket->reserved(); |
|
| 294 | + echo self::$nl.' . . . ticket->qty(saleable): '.$ticket->qty('saleable'); |
|
| 295 | + echo self::$nl.' . . . available: '.$available; |
|
| 296 | 296 | } |
| 297 | 297 | if ($available < 1) { |
| 298 | 298 | $this->_ticket_sold_out($ticket); |
| 299 | 299 | return 0; |
| 300 | 300 | } |
| 301 | 301 | if (self::debug) { |
| 302 | - echo self::$nl . ' . . . qty: ' . $qty; |
|
| 302 | + echo self::$nl.' . . . qty: '.$qty; |
|
| 303 | 303 | } |
| 304 | 304 | if ($available < $qty) { |
| 305 | 305 | $qty = $available; |
| 306 | 306 | if (self::debug) { |
| 307 | - echo self::$nl . ' . . . QTY ADJUSTED: ' . $qty; |
|
| 307 | + echo self::$nl.' . . . QTY ADJUSTED: '.$qty; |
|
| 308 | 308 | } |
| 309 | 309 | $this->_ticket_quantity_decremented($ticket); |
| 310 | 310 | } |
@@ -328,9 +328,9 @@ discard block |
||
| 328 | 328 | { |
| 329 | 329 | // self::debug hardcoded to false |
| 330 | 330 | if (self::debug) { |
| 331 | - echo self::$nl . self::$nl . ' . . . INCREASE RESERVED: ' . $quantity; |
|
| 331 | + echo self::$nl.self::$nl.' . . . INCREASE RESERVED: '.$quantity; |
|
| 332 | 332 | } |
| 333 | - return $ticket->increaseReserved($quantity, 'TicketSalesMonitor:' . __LINE__); |
|
| 333 | + return $ticket->increaseReserved($quantity, 'TicketSalesMonitor:'.__LINE__); |
|
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | |
@@ -344,12 +344,12 @@ discard block |
||
| 344 | 344 | { |
| 345 | 345 | // self::debug hardcoded to false |
| 346 | 346 | if (self::debug) { |
| 347 | - echo self::$nl . ' . . . ticket->ID: ' . $ticket->ID(); |
|
| 348 | - echo self::$nl . ' . . . ticket->reserved before: ' . $ticket->reserved(); |
|
| 347 | + echo self::$nl.' . . . ticket->ID: '.$ticket->ID(); |
|
| 348 | + echo self::$nl.' . . . ticket->reserved before: '.$ticket->reserved(); |
|
| 349 | 349 | } |
| 350 | - $ticket->decreaseReserved($quantity, true, 'TicketSalesMonitor:' . __LINE__); |
|
| 350 | + $ticket->decreaseReserved($quantity, true, 'TicketSalesMonitor:'.__LINE__); |
|
| 351 | 351 | if (self::debug) { |
| 352 | - echo self::$nl . ' . . . ticket->reserved after: ' . $ticket->reserved(); |
|
| 352 | + echo self::$nl.' . . . ticket->reserved after: '.$ticket->reserved(); |
|
| 353 | 353 | } |
| 354 | 354 | return $ticket->save() ? 1 : 0; |
| 355 | 355 | } |
@@ -367,8 +367,8 @@ discard block |
||
| 367 | 367 | { |
| 368 | 368 | // self::debug hardcoded to false |
| 369 | 369 | if (self::debug) { |
| 370 | - echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() '; |
|
| 371 | - echo self::$nl . ' . . ticket->name: ' . $this->_get_ticket_and_event_name($ticket); |
|
| 370 | + echo self::$nl.self::$nl.__LINE__.') '.__METHOD__.'() '; |
|
| 371 | + echo self::$nl.' . . ticket->name: '.$this->_get_ticket_and_event_name($ticket); |
|
| 372 | 372 | } |
| 373 | 373 | $this->sold_out_tickets[] = $this->_get_ticket_and_event_name($ticket); |
| 374 | 374 | } |
@@ -386,8 +386,8 @@ discard block |
||
| 386 | 386 | { |
| 387 | 387 | // self::debug hardcoded to false |
| 388 | 388 | if (self::debug) { |
| 389 | - echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() '; |
|
| 390 | - echo self::$nl . ' . . ticket->name: ' . $this->_get_ticket_and_event_name($ticket); |
|
| 389 | + echo self::$nl.self::$nl.__LINE__.') '.__METHOD__.'() '; |
|
| 390 | + echo self::$nl.' . . ticket->name: '.$this->_get_ticket_and_event_name($ticket); |
|
| 391 | 391 | } |
| 392 | 392 | $this->decremented_tickets[] = $this->_get_ticket_and_event_name($ticket); |
| 393 | 393 | } |
@@ -438,7 +438,7 @@ discard block |
||
| 438 | 438 | if ($ticket instanceof EE_Ticket) { |
| 439 | 439 | $ticket->add_extra_meta( |
| 440 | 440 | EE_Ticket::META_KEY_TICKET_RESERVATIONS, |
| 441 | - __LINE__ . ') ' . __METHOD__ . '()' |
|
| 441 | + __LINE__.') '.__METHOD__.'()' |
|
| 442 | 442 | ); |
| 443 | 443 | if ($quantity > 0) { |
| 444 | 444 | EED_Ticket_Sales_Monitor::instance()->_reserve_ticket($ticket, $quantity); |
@@ -461,7 +461,7 @@ discard block |
||
| 461 | 461 | { |
| 462 | 462 | $ticket->add_extra_meta( |
| 463 | 463 | EE_Ticket::META_KEY_TICKET_RESERVATIONS, |
| 464 | - __LINE__ . ') ' . __METHOD__ . '()' |
|
| 464 | + __LINE__.') '.__METHOD__.'()' |
|
| 465 | 465 | ); |
| 466 | 466 | EED_Ticket_Sales_Monitor::instance()->_release_reserved_ticket($ticket, $quantity); |
| 467 | 467 | } |
@@ -497,7 +497,7 @@ discard block |
||
| 497 | 497 | { |
| 498 | 498 | // self::debug hardcoded to false |
| 499 | 499 | if (self::debug) { |
| 500 | - echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() '; |
|
| 500 | + echo self::$nl.self::$nl.__LINE__.') '.__METHOD__.'() '; |
|
| 501 | 501 | } |
| 502 | 502 | $refresh_msg = ''; |
| 503 | 503 | $none_added_msg = ''; |
@@ -508,7 +508,7 @@ discard block |
||
| 508 | 508 | ); |
| 509 | 509 | $none_added_msg = esc_html__('No tickets were added for the event.', 'event_espresso'); |
| 510 | 510 | } |
| 511 | - if (! empty($this->sold_out_tickets)) { |
|
| 511 | + if ( ! empty($this->sold_out_tickets)) { |
|
| 512 | 512 | EE_Error::add_attention( |
| 513 | 513 | sprintf( |
| 514 | 514 | apply_filters( |
@@ -531,7 +531,7 @@ discard block |
||
| 531 | 531 | // and reset the cart |
| 532 | 532 | EED_Ticket_Sales_Monitor::session_cart_reset(EE_Registry::instance()->SSN); |
| 533 | 533 | } |
| 534 | - if (! empty($this->decremented_tickets)) { |
|
| 534 | + if ( ! empty($this->decremented_tickets)) { |
|
| 535 | 535 | EE_Error::add_attention( |
| 536 | 536 | sprintf( |
| 537 | 537 | apply_filters( |
@@ -569,9 +569,9 @@ discard block |
||
| 569 | 569 | { |
| 570 | 570 | // self::debug hardcoded to false |
| 571 | 571 | if (self::debug) { |
| 572 | - echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() '; |
|
| 573 | - echo self::$nl . ' . transaction->ID: ' . $transaction->ID(); |
|
| 574 | - echo self::$nl . ' . TXN status_ID: ' . $transaction->status_ID(); |
|
| 572 | + echo self::$nl.self::$nl.__LINE__.') '.__METHOD__.'() '; |
|
| 573 | + echo self::$nl.' . transaction->ID: '.$transaction->ID(); |
|
| 574 | + echo self::$nl.' . TXN status_ID: '.$transaction->status_ID(); |
|
| 575 | 575 | } |
| 576 | 576 | // check if 'finalize_registration' step has been completed... |
| 577 | 577 | $finalized = $transaction->reg_step_completed('finalize_registration'); |
@@ -583,13 +583,13 @@ discard block |
||
| 583 | 583 | __LINE__, |
| 584 | 584 | array('finalized' => $finalized), |
| 585 | 585 | false, |
| 586 | - 'EE_Transaction: ' . $transaction->ID() |
|
| 586 | + 'EE_Transaction: '.$transaction->ID() |
|
| 587 | 587 | ); |
| 588 | 588 | } |
| 589 | 589 | // how many tickets were released |
| 590 | 590 | $count = 0; |
| 591 | 591 | if (self::debug) { |
| 592 | - echo self::$nl . ' . . . TXN finalized: ' . $finalized; |
|
| 592 | + echo self::$nl.' . . . TXN finalized: '.$finalized; |
|
| 593 | 593 | } |
| 594 | 594 | $release_tickets_with_TXN_status = array( |
| 595 | 595 | EEM_Transaction::failed_status_code, |
@@ -598,28 +598,28 @@ discard block |
||
| 598 | 598 | ); |
| 599 | 599 | $events = array(); |
| 600 | 600 | // if the session is getting cleared BEFORE the TXN has been finalized or the transaction is not completed |
| 601 | - if (! $finalized || in_array($transaction->status_ID(), $release_tickets_with_TXN_status, true)) { |
|
| 601 | + if ( ! $finalized || in_array($transaction->status_ID(), $release_tickets_with_TXN_status, true)) { |
|
| 602 | 602 | // cancel any reserved tickets for registrations that were not approved |
| 603 | 603 | $registrations = $transaction->registrations(); |
| 604 | 604 | if (self::debug) { |
| 605 | - echo self::$nl . ' . . . # registrations: ' . count($registrations); |
|
| 605 | + echo self::$nl.' . . . # registrations: '.count($registrations); |
|
| 606 | 606 | $reg = reset($registrations); |
| 607 | 607 | $ticket = $reg->ticket(); |
| 608 | 608 | if ($ticket instanceof EE_Ticket) { |
| 609 | 609 | $ticket->add_extra_meta( |
| 610 | 610 | EE_Ticket::META_KEY_TICKET_RESERVATIONS, |
| 611 | - __LINE__ . ') Release All Tickets TXN:' . $transaction->ID() |
|
| 611 | + __LINE__.') Release All Tickets TXN:'.$transaction->ID() |
|
| 612 | 612 | ); |
| 613 | 613 | } |
| 614 | 614 | } |
| 615 | - if (! empty($registrations)) { |
|
| 615 | + if ( ! empty($registrations)) { |
|
| 616 | 616 | foreach ($registrations as $registration) { |
| 617 | 617 | if ( |
| 618 | 618 | $registration instanceof EE_Registration |
| 619 | 619 | && $this->_release_reserved_ticket_for_registration($registration, $transaction) |
| 620 | 620 | ) { |
| 621 | 621 | $count++; |
| 622 | - $events[ $registration->event_ID() ] = $registration->event(); |
|
| 622 | + $events[$registration->event_ID()] = $registration->event(); |
|
| 623 | 623 | } |
| 624 | 624 | } |
| 625 | 625 | } |
@@ -650,10 +650,10 @@ discard block |
||
| 650 | 650 | $STS_ID = $transaction->status_ID(); |
| 651 | 651 | // self::debug hardcoded to false |
| 652 | 652 | if (self::debug) { |
| 653 | - echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() '; |
|
| 654 | - echo self::$nl . ' . . registration->ID: ' . $registration->ID(); |
|
| 655 | - echo self::$nl . ' . . registration->status_ID: ' . $registration->status_ID(); |
|
| 656 | - echo self::$nl . ' . . transaction->status_ID(): ' . $STS_ID; |
|
| 653 | + echo self::$nl.self::$nl.__LINE__.') '.__METHOD__.'() '; |
|
| 654 | + echo self::$nl.' . . registration->ID: '.$registration->ID(); |
|
| 655 | + echo self::$nl.' . . registration->status_ID: '.$registration->status_ID(); |
|
| 656 | + echo self::$nl.' . . transaction->status_ID(): '.$STS_ID; |
|
| 657 | 657 | } |
| 658 | 658 | if ( |
| 659 | 659 | // release Tickets for Failed Transactions and Abandoned Transactions |
@@ -666,12 +666,12 @@ discard block |
||
| 666 | 666 | ) |
| 667 | 667 | ) { |
| 668 | 668 | if (self::debug) { |
| 669 | - echo self::$nl . self::$nl . ' . . RELEASE RESERVED TICKET'; |
|
| 669 | + echo self::$nl.self::$nl.' . . RELEASE RESERVED TICKET'; |
|
| 670 | 670 | $rsrvd = $registration->get_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true); |
| 671 | - echo self::$nl . ' . . . registration HAS_RESERVED_TICKET_KEY: '; |
|
| 671 | + echo self::$nl.' . . . registration HAS_RESERVED_TICKET_KEY: '; |
|
| 672 | 672 | var_dump($rsrvd); |
| 673 | 673 | } |
| 674 | - $registration->release_reserved_ticket(true, 'TicketSalesMonitor:' . __LINE__); |
|
| 674 | + $registration->release_reserved_ticket(true, 'TicketSalesMonitor:'.__LINE__); |
|
| 675 | 675 | return 1; |
| 676 | 676 | } |
| 677 | 677 | return 0; |
@@ -701,7 +701,7 @@ discard block |
||
| 701 | 701 | } |
| 702 | 702 | // self::debug hardcoded to false |
| 703 | 703 | if (self::debug) { |
| 704 | - echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() '; |
|
| 704 | + echo self::$nl.self::$nl.__LINE__.') '.__METHOD__.'() '; |
|
| 705 | 705 | } |
| 706 | 706 | // first check of the session has a valid Checkout object |
| 707 | 707 | $checkout = $session->checkout(); |
@@ -713,12 +713,12 @@ discard block |
||
| 713 | 713 | $cart = $session->cart(); |
| 714 | 714 | if ($cart instanceof EE_Cart) { |
| 715 | 715 | if (self::debug) { |
| 716 | - echo self::$nl . self::$nl . ' cart instance of EE_Cart: '; |
|
| 716 | + echo self::$nl.self::$nl.' cart instance of EE_Cart: '; |
|
| 717 | 717 | } |
| 718 | 718 | EED_Ticket_Sales_Monitor::instance()->_session_cart_reset($cart, $session); |
| 719 | 719 | } else { |
| 720 | 720 | if (self::debug) { |
| 721 | - echo self::$nl . self::$nl . ' invalid EE_Cart: '; |
|
| 721 | + echo self::$nl.self::$nl.' invalid EE_Cart: '; |
|
| 722 | 722 | var_export($cart, true); |
| 723 | 723 | } |
| 724 | 724 | } |
@@ -740,39 +740,39 @@ discard block |
||
| 740 | 740 | { |
| 741 | 741 | // self::debug hardcoded to false |
| 742 | 742 | if (self::debug) { |
| 743 | - echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() '; |
|
| 743 | + echo self::$nl.self::$nl.__LINE__.') '.__METHOD__.'() '; |
|
| 744 | 744 | } |
| 745 | 745 | $ticket_line_items = $cart->get_tickets(); |
| 746 | 746 | if (empty($ticket_line_items)) { |
| 747 | 747 | return; |
| 748 | 748 | } |
| 749 | 749 | if (self::debug) { |
| 750 | - echo '<br /> . ticket_line_item count: ' . count($ticket_line_items); |
|
| 750 | + echo '<br /> . ticket_line_item count: '.count($ticket_line_items); |
|
| 751 | 751 | } |
| 752 | 752 | foreach ($ticket_line_items as $ticket_line_item) { |
| 753 | 753 | if (self::debug) { |
| 754 | - echo self::$nl . ' . ticket_line_item->ID(): ' . $ticket_line_item->ID(); |
|
| 754 | + echo self::$nl.' . ticket_line_item->ID(): '.$ticket_line_item->ID(); |
|
| 755 | 755 | } |
| 756 | 756 | if ($ticket_line_item instanceof EE_Line_Item && $ticket_line_item->OBJ_type() === 'Ticket') { |
| 757 | 757 | if (self::debug) { |
| 758 | - echo self::$nl . ' . . ticket_line_item->OBJ_ID(): ' . $ticket_line_item->OBJ_ID(); |
|
| 758 | + echo self::$nl.' . . ticket_line_item->OBJ_ID(): '.$ticket_line_item->OBJ_ID(); |
|
| 759 | 759 | } |
| 760 | 760 | $ticket = EEM_Ticket::instance()->get_one_by_ID($ticket_line_item->OBJ_ID()); |
| 761 | 761 | if ($ticket instanceof EE_Ticket) { |
| 762 | 762 | if (self::debug) { |
| 763 | - echo self::$nl . ' . . ticket->ID(): ' . $ticket->ID(); |
|
| 764 | - echo self::$nl . ' . . ticket_line_item->quantity(): ' . $ticket_line_item->quantity(); |
|
| 763 | + echo self::$nl.' . . ticket->ID(): '.$ticket->ID(); |
|
| 764 | + echo self::$nl.' . . ticket_line_item->quantity(): '.$ticket_line_item->quantity(); |
|
| 765 | 765 | } |
| 766 | 766 | $ticket->add_extra_meta( |
| 767 | 767 | EE_Ticket::META_KEY_TICKET_RESERVATIONS, |
| 768 | - __LINE__ . ') ' . __METHOD__ . '() SID = ' . $session->id() |
|
| 768 | + __LINE__.') '.__METHOD__.'() SID = '.$session->id() |
|
| 769 | 769 | ); |
| 770 | 770 | $this->_release_reserved_ticket($ticket, $ticket_line_item->quantity()); |
| 771 | 771 | } |
| 772 | 772 | } |
| 773 | 773 | } |
| 774 | 774 | if (self::debug) { |
| 775 | - echo self::$nl . self::$nl . ' RESET COMPLETED '; |
|
| 775 | + echo self::$nl.self::$nl.' RESET COMPLETED '; |
|
| 776 | 776 | } |
| 777 | 777 | } |
| 778 | 778 | |
@@ -814,7 +814,7 @@ discard block |
||
| 814 | 814 | { |
| 815 | 815 | // self::debug hardcoded to false |
| 816 | 816 | if (self::debug) { |
| 817 | - echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() '; |
|
| 817 | + echo self::$nl.self::$nl.__LINE__.') '.__METHOD__.'() '; |
|
| 818 | 818 | } |
| 819 | 819 | // we want to release the each registration's reserved tickets if the session was cleared, but not if this is a revisit |
| 820 | 820 | if ($checkout->revisit || ! $checkout->transaction instanceof EE_Transaction) { |
@@ -863,7 +863,7 @@ discard block |
||
| 863 | 863 | __LINE__, |
| 864 | 864 | array($transaction), |
| 865 | 865 | false, |
| 866 | - 'EE_Transaction: ' . $transaction->ID() |
|
| 866 | + 'EE_Transaction: '.$transaction->ID() |
|
| 867 | 867 | ); |
| 868 | 868 | } |
| 869 | 869 | return; |
@@ -880,7 +880,7 @@ discard block |
||
| 880 | 880 | __LINE__, |
| 881 | 881 | array($payment), |
| 882 | 882 | false, |
| 883 | - 'EE_Transaction: ' . $transaction->ID() |
|
| 883 | + 'EE_Transaction: '.$transaction->ID() |
|
| 884 | 884 | ); |
| 885 | 885 | } |
| 886 | 886 | return; |
@@ -942,7 +942,7 @@ discard block |
||
| 942 | 942 | } |
| 943 | 943 | $total_line_item = $transaction->total_line_item(); |
| 944 | 944 | // $transaction_in_progress->line |
| 945 | - if (! $total_line_item instanceof EE_Line_Item) { |
|
| 945 | + if ( ! $total_line_item instanceof EE_Line_Item) { |
|
| 946 | 946 | throw new DomainException( |
| 947 | 947 | esc_html__( |
| 948 | 948 | 'Transaction does not have a valid Total Line Item associated with it.', |
@@ -980,7 +980,7 @@ discard block |
||
| 980 | 980 | $ticket_line_items = EEH_Line_Item::get_ticket_line_items($total_line_item); |
| 981 | 981 | foreach ($ticket_line_items as $ticket_line_item) { |
| 982 | 982 | if ($ticket_line_item instanceof EE_Line_Item) { |
| 983 | - $valid_reserved_tickets[ $ticket_line_item->ID() ] = $ticket_line_item; |
|
| 983 | + $valid_reserved_tickets[$ticket_line_item->ID()] = $ticket_line_item; |
|
| 984 | 984 | } |
| 985 | 985 | } |
| 986 | 986 | return $valid_reserved_tickets; |
@@ -1013,7 +1013,7 @@ discard block |
||
| 1013 | 1013 | $total_tickets_released = 0; |
| 1014 | 1014 | $sold_out_events = array(); |
| 1015 | 1015 | foreach ($tickets_with_reservations as $ticket_with_reservations) { |
| 1016 | - if (! $ticket_with_reservations instanceof EE_Ticket) { |
|
| 1016 | + if ( ! $ticket_with_reservations instanceof EE_Ticket) { |
|
| 1017 | 1017 | continue; |
| 1018 | 1018 | } |
| 1019 | 1019 | // The $valid_reserved_ticket_line_items tells us what the reserved count on their tickets (and datetimes) |
@@ -1035,9 +1035,9 @@ discard block |
||
| 1035 | 1035 | if ($expired_reservations_count > 0) { |
| 1036 | 1036 | $ticket_with_reservations->add_extra_meta( |
| 1037 | 1037 | EE_Ticket::META_KEY_TICKET_RESERVATIONS, |
| 1038 | - __LINE__ . ') ' . $source . '()' |
|
| 1038 | + __LINE__.') '.$source.'()' |
|
| 1039 | 1039 | ); |
| 1040 | - $ticket_with_reservations->decreaseReserved($expired_reservations_count, true, 'TicketSalesMonitor:' . __LINE__); |
|
| 1040 | + $ticket_with_reservations->decreaseReserved($expired_reservations_count, true, 'TicketSalesMonitor:'.__LINE__); |
|
| 1041 | 1041 | $total_tickets_released += $expired_reservations_count; |
| 1042 | 1042 | $event = $ticket_with_reservations->get_related_event(); |
| 1043 | 1043 | // track sold out events |
@@ -1073,7 +1073,7 @@ discard block |
||
| 1073 | 1073 | { |
| 1074 | 1074 | /** @type WPDB $wpdb */ |
| 1075 | 1075 | global $wpdb; |
| 1076 | - if (! absint($timestamp)) { |
|
| 1076 | + if ( ! absint($timestamp)) { |
|
| 1077 | 1077 | /** @var EventEspresso\core\domain\values\session\SessionLifespan $session_lifespan */ |
| 1078 | 1078 | $session_lifespan = LoaderFactory::getLoader()->getShared( |
| 1079 | 1079 | 'EventEspresso\core\domain\values\session\SessionLifespan' |
@@ -1082,7 +1082,7 @@ discard block |
||
| 1082 | 1082 | } |
| 1083 | 1083 | return $wpdb->query( |
| 1084 | 1084 | $wpdb->prepare( |
| 1085 | - 'DELETE FROM ' . EEM_Line_Item::instance()->table() . ' |
|
| 1085 | + 'DELETE FROM '.EEM_Line_Item::instance()->table().' |
|
| 1086 | 1086 | WHERE TXN_ID = 0 AND LIN_timestamp <= %s', |
| 1087 | 1087 | // use GMT time because that's what LIN_timestamps are in |
| 1088 | 1088 | date('Y-m-d H:i:s', $timestamp) |
@@ -74,20 +74,20 @@ discard block |
||
| 74 | 74 | </thead> |
| 75 | 75 | <tbody> |
| 76 | 76 | <?php |
| 77 | - /** |
|
| 78 | - * Recursive function for traversing all the sub-items of each line item |
|
| 79 | - * and displaying them in the table |
|
| 80 | - * |
|
| 81 | - * @param EE_Line_Item $line_item |
|
| 82 | - * @param boolean $odd for indicating whether to style this line item as an 'odd' or 'even' |
|
| 83 | - */ |
|
| 84 | - function ee_invoice_display_line_item(EE_Line_Item $line_item, $show_line_item_description, $odd = false) |
|
| 85 | - { |
|
| 86 | - switch ($line_item->type()) { |
|
| 87 | - case EEM_Line_Item::type_total: |
|
| 88 | - foreach ($line_item->children() as $child_line_item) { |
|
| 89 | - ee_invoice_display_line_item($child_line_item, $show_line_item_description); |
|
| 90 | - } ?> |
|
| 77 | + /** |
|
| 78 | + * Recursive function for traversing all the sub-items of each line item |
|
| 79 | + * and displaying them in the table |
|
| 80 | + * |
|
| 81 | + * @param EE_Line_Item $line_item |
|
| 82 | + * @param boolean $odd for indicating whether to style this line item as an 'odd' or 'even' |
|
| 83 | + */ |
|
| 84 | + function ee_invoice_display_line_item(EE_Line_Item $line_item, $show_line_item_description, $odd = false) |
|
| 85 | + { |
|
| 86 | + switch ($line_item->type()) { |
|
| 87 | + case EEM_Line_Item::type_total: |
|
| 88 | + foreach ($line_item->children() as $child_line_item) { |
|
| 89 | + ee_invoice_display_line_item($child_line_item, $show_line_item_description); |
|
| 90 | + } ?> |
|
| 91 | 91 | <tr> |
| 92 | 92 | <td colspan="<?php echo $show_line_item_description ? 5 : 4 ?>"> |
| 93 | 93 | <hr> |
@@ -99,50 +99,50 @@ discard block |
||
| 99 | 99 | <td class="total"><?php echo $line_item->total_no_code(); // already escaped ?></td> |
| 100 | 100 | </tr> |
| 101 | 101 | <?php |
| 102 | - break; |
|
| 102 | + break; |
|
| 103 | 103 | |
| 104 | 104 | |
| 105 | - case EEM_Line_Item::type_sub_total: |
|
| 106 | - foreach ($line_item->children() as $child_line_item) { |
|
| 107 | - // $odd = !$odd; |
|
| 108 | - ee_invoice_display_line_item($child_line_item, $show_line_item_description, $odd); |
|
| 109 | - } ?> |
|
| 105 | + case EEM_Line_Item::type_sub_total: |
|
| 106 | + foreach ($line_item->children() as $child_line_item) { |
|
| 107 | + // $odd = !$odd; |
|
| 108 | + ee_invoice_display_line_item($child_line_item, $show_line_item_description, $odd); |
|
| 109 | + } ?> |
|
| 110 | 110 | <tr class="total_tr odd"> |
| 111 | 111 | <td colspan="<?php echo $show_line_item_description ? 2 : 1 ?>"> </td> |
| 112 | 112 | <td colspan="2" class="total" id="total_currency"> |
| 113 | 113 | <?php esc_html_e( |
| 114 | - 'Sub-Total', |
|
| 115 | - 'event_espresso' |
|
| 116 | - ); ?></td> |
|
| 114 | + 'Sub-Total', |
|
| 115 | + 'event_espresso' |
|
| 116 | + ); ?></td> |
|
| 117 | 117 | <td class="total"><?php echo $line_item->total_no_code(); // already escaped ?></td> |
| 118 | 118 | </tr> |
| 119 | 119 | <?php |
| 120 | - break; |
|
| 120 | + break; |
|
| 121 | 121 | |
| 122 | 122 | |
| 123 | - case EEM_Line_Item::type_tax_sub_total: |
|
| 124 | - foreach ($line_item->children() as $child_line_item) { |
|
| 125 | - $odd = ! $odd; |
|
| 126 | - ee_invoice_display_line_item($child_line_item, $show_line_item_description, $odd); |
|
| 127 | - } ?> |
|
| 123 | + case EEM_Line_Item::type_tax_sub_total: |
|
| 124 | + foreach ($line_item->children() as $child_line_item) { |
|
| 125 | + $odd = ! $odd; |
|
| 126 | + ee_invoice_display_line_item($child_line_item, $show_line_item_description, $odd); |
|
| 127 | + } ?> |
|
| 128 | 128 | <tr class="total_tr odd"> |
| 129 | 129 | <td colspan="<?php echo $show_line_item_description ? 2 : 1 ?>"> </td> |
| 130 | 130 | <td colspan="2" class="total" id="total_currency"> |
| 131 | 131 | <?php esc_html_e( |
| 132 | - 'Tax Total', |
|
| 133 | - 'event_espresso' |
|
| 134 | - ); ?></td> |
|
| 132 | + 'Tax Total', |
|
| 133 | + 'event_espresso' |
|
| 134 | + ); ?></td> |
|
| 135 | 135 | <td class="total"><?php echo $line_item->total_no_code(); // already escaped ?></td> |
| 136 | 136 | </tr> |
| 137 | 137 | <?php |
| 138 | - break; |
|
| 138 | + break; |
|
| 139 | 139 | |
| 140 | 140 | |
| 141 | - case EEM_Line_Item::type_line_item: |
|
| 142 | - $subitems = $line_item->children(); |
|
| 143 | - $has_subitems = count($subitems) > 1; |
|
| 144 | - if ($has_subitems) { |
|
| 145 | - ?> |
|
| 141 | + case EEM_Line_Item::type_line_item: |
|
| 142 | + $subitems = $line_item->children(); |
|
| 143 | + $has_subitems = count($subitems) > 1; |
|
| 144 | + if ($has_subitems) { |
|
| 145 | + ?> |
|
| 146 | 146 | <tr class="item <?php echo $odd ? 'odd' : ''; ?>"> |
| 147 | 147 | <td class="item_l"><?php echo esc_html($line_item->name()) ?></td> |
| 148 | 148 | <?php if ($show_line_item_description) { ?> |
@@ -153,18 +153,18 @@ discard block |
||
| 153 | 153 | <td class="item_c"><?php echo esc_html($line_item->unit_price_no_code()) ?></td> |
| 154 | 154 | |
| 155 | 155 | <td class="item_r"> <?php echo $line_item->total_no_code(); // already escaped |
| 156 | - echo $line_item->is_taxable() ? '*' : '' ?> </td> |
|
| 156 | + echo $line_item->is_taxable() ? '*' : '' ?> </td> |
|
| 157 | 157 | <?php // <td class="item_l"><?php $datetimes_strings = array(); foreach($datetimes as $datetime){ $datetimes_strings[]= $datetime->start_date_and_time();} echo implode(", ",$datetimes_strings); |
| 158 | - ?> |
|
| 158 | + ?> |
|
| 159 | 159 | </tr> |
| 160 | 160 | <?php |
| 161 | - if ($has_subitems) { |
|
| 162 | - foreach ($line_item->children() as $child_line_item) { |
|
| 163 | - ee_invoice_display_line_item($child_line_item, $show_line_item_description, $odd); |
|
| 164 | - } |
|
| 165 | - } |
|
| 166 | - } else {// no subitems - just show this line item |
|
| 167 | - ?> |
|
| 161 | + if ($has_subitems) { |
|
| 162 | + foreach ($line_item->children() as $child_line_item) { |
|
| 163 | + ee_invoice_display_line_item($child_line_item, $show_line_item_description, $odd); |
|
| 164 | + } |
|
| 165 | + } |
|
| 166 | + } else {// no subitems - just show this line item |
|
| 167 | + ?> |
|
| 168 | 168 | <tr class="item <?php echo $odd ? 'odd' : ''; ?>"> |
| 169 | 169 | <td class="item_l"><?php echo esc_html($line_item->name()); ?></td> |
| 170 | 170 | <?php if ($show_line_item_description) { ?> |
@@ -173,15 +173,15 @@ discard block |
||
| 173 | 173 | <td class="item_l"><?php echo esc_html($line_item->quantity()); ?></td> |
| 174 | 174 | <td class="item_c"><?php echo $line_item->unit_price_no_code(); // already escaped ?></td> |
| 175 | 175 | <td class="item_r"> <?php echo $line_item->total_no_code(); // already escaped; |
| 176 | - echo $line_item->is_taxable() ? '*' : '' ?> </td> |
|
| 176 | + echo $line_item->is_taxable() ? '*' : '' ?> </td> |
|
| 177 | 177 | <?php // <td class="item_l"><?php $datetimes_strings = array(); foreach($datetimes as $datetime){ $datetimes_strings[]= $datetime->start_date_and_time();} echo implode(", ",$datetimes_strings); |
| 178 | - ?> |
|
| 178 | + ?> |
|
| 179 | 179 | </tr> |
| 180 | 180 | <?php } |
| 181 | 181 | |
| 182 | - break; |
|
| 183 | - case EEM_Line_Item::type_sub_line_item: |
|
| 184 | - ?> |
|
| 182 | + break; |
|
| 183 | + case EEM_Line_Item::type_sub_line_item: |
|
| 184 | + ?> |
|
| 185 | 185 | <tr class="item subitem-row"> |
| 186 | 186 | <td class="item_l subitem"><?php echo esc_html($line_item->name()); ?></td> |
| 187 | 187 | <?php if ($show_line_item_description) { ?> |
@@ -197,9 +197,9 @@ discard block |
||
| 197 | 197 | <td class="item_r"><?php echo $line_item->total_no_code(); // already escaped ?></td> |
| 198 | 198 | </tr> |
| 199 | 199 | <?php |
| 200 | - break; |
|
| 201 | - case EEM_Line_Item::type_tax: |
|
| 202 | - ?> |
|
| 200 | + break; |
|
| 201 | + case EEM_Line_Item::type_tax: |
|
| 202 | + ?> |
|
| 203 | 203 | <tr class="item sub-item tax-total"> |
| 204 | 204 | <td class="item_l"><?php echo esc_html($line_item->name()); ?></td> |
| 205 | 205 | <?php if ($show_line_item_description) { ?> |
@@ -209,15 +209,15 @@ discard block |
||
| 209 | 209 | |
| 210 | 210 | <td class="item_r"><?php echo $line_item->total_no_code(); // already escaped ?></td> |
| 211 | 211 | </tr><?php |
| 212 | - break; |
|
| 213 | - } |
|
| 214 | - } |
|
| 212 | + break; |
|
| 213 | + } |
|
| 214 | + } |
|
| 215 | 215 | |
| 216 | - $c = false; |
|
| 217 | - /* @var $transaction EE_Transaction */ |
|
| 218 | - $total_line_item = $transaction->total_line_item(); |
|
| 219 | - ee_invoice_display_line_item($total_line_item, $show_line_item_description); |
|
| 220 | - /* foreach($transaction->registrations() as $registration){ |
|
| 216 | + $c = false; |
|
| 217 | + /* @var $transaction EE_Transaction */ |
|
| 218 | + $total_line_item = $transaction->total_line_item(); |
|
| 219 | + ee_invoice_display_line_item($total_line_item, $show_line_item_description); |
|
| 220 | + /* foreach($transaction->registrations() as $registration){ |
|
| 221 | 221 | ?> |
| 222 | 222 | <tr class="item <?php echo ($c = !$c) ? ' odd' : ''; ?>"> |
| 223 | 223 | <td class="item_l">1</td> |
@@ -246,11 +246,11 @@ discard block |
||
| 246 | 246 | </thead> |
| 247 | 247 | <tbody> |
| 248 | 248 | <?php |
| 249 | - $c = false; |
|
| 250 | - if (! empty($payments)) { |
|
| 251 | - foreach ($payments as $payment) { |
|
| 252 | - /* @var $payment EE_Payment */ |
|
| 253 | - ?> |
|
| 249 | + $c = false; |
|
| 250 | + if (! empty($payments)) { |
|
| 251 | + foreach ($payments as $payment) { |
|
| 252 | + /* @var $payment EE_Payment */ |
|
| 253 | + ?> |
|
| 254 | 254 | <tr class='item <?php echo(($c = ! $c) ? ' odd' : '') ?>'> |
| 255 | 255 | <td><?php $payment->e('PAY_gateway') ?></td> |
| 256 | 256 | <td><?php echo $payment->timestamp('D M j, Y'); // already escaped ?></td> |
@@ -260,17 +260,17 @@ discard block |
||
| 260 | 260 | <td class='item_r'><?php echo EEH_Template::format_currency($payment->amount()); ?></td> |
| 261 | 261 | </tr> |
| 262 | 262 | <?php } |
| 263 | - } else { |
|
| 264 | - ?> |
|
| 263 | + } else { |
|
| 264 | + ?> |
|
| 265 | 265 | <tr class='item'> |
| 266 | 266 | <td class='aln-cntr' colspan=6> |
| 267 | 267 | <?php esc_html_e( |
| 268 | - "No approved payments have been received", |
|
| 269 | - 'event_espresso' |
|
| 270 | - ) ?></td> |
|
| 268 | + "No approved payments have been received", |
|
| 269 | + 'event_espresso' |
|
| 270 | + ) ?></td> |
|
| 271 | 271 | </tr> |
| 272 | 272 | <?php } |
| 273 | - ?> |
|
| 273 | + ?> |
|
| 274 | 274 | </tbody> |
| 275 | 275 | <tfoot> |
| 276 | 276 | <tr class='total_tr'> |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | <div class="fn">[name]</div> |
| 53 | 53 | <div class="adr"> |
| 54 | 54 | <div class="street-address"><?php echo $attendee_address; // already escaped ?></div> |
| 55 | - <div class="locality"><?php echo $attendee_city . ' ' . $attendee_state; // already escaped ?></div> |
|
| 55 | + <div class="locality"><?php echo $attendee_city.' '.$attendee_state; // already escaped ?></div> |
|
| 56 | 56 | <div id="client-postcode"><?php echo $attendee_zip; // already escaped ?></div> |
| 57 | 57 | </div> |
| 58 | 58 | </div> |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | <tbody> |
| 248 | 248 | <?php |
| 249 | 249 | $c = false; |
| 250 | - if (! empty($payments)) { |
|
| 250 | + if ( ! empty($payments)) { |
|
| 251 | 251 | foreach ($payments as $payment) { |
| 252 | 252 | /* @var $payment EE_Payment */ |
| 253 | 253 | ?> |
@@ -60,10 +60,10 @@ discard block |
||
| 60 | 60 | <h3 class="section-title event-name"> |
| 61 | 61 | <img class="icon" src="<?php echo EE_IMAGES_URL . 'calendar_year-24x24.png'; ?>"> |
| 62 | 62 | <?php |
| 63 | - esc_html_e( |
|
| 64 | - "Event Name:", |
|
| 65 | - "event_espresso" |
|
| 66 | - ) ?> |
|
| 63 | + esc_html_e( |
|
| 64 | + "Event Name:", |
|
| 65 | + "event_espresso" |
|
| 66 | + ) ?> |
|
| 67 | 67 | <span class="plain-text"><?php echo $event->name(); ?></span> |
| 68 | 68 | <span class="small-text link"> |
| 69 | 69 | [ <a href='<?php echo esc_url_raw($event->get_permalink()) ?>'><?php esc_html_e('view', 'event_espresso'); ?></a> ] |
@@ -74,14 +74,14 @@ discard block |
||
| 74 | 74 | <?php } ?> |
| 75 | 75 | <ul class="tickets-per-event"> |
| 76 | 76 | <?php |
| 77 | - foreach ($ticket_line_items_per_event[ $event_id ] as $line_item_id => $line_item) { |
|
| 78 | - $ticket = $line_item->ticket(); |
|
| 79 | - $taxable_html = $ticket->taxable() |
|
| 80 | - ? '*' |
|
| 81 | - : ''; |
|
| 82 | - $subitems = $line_item->children(); |
|
| 83 | - $ticket_uses = $ticket->get_pretty('TKT_uses', esc_html__("any", "event_espresso")); |
|
| 84 | - ?> |
|
| 77 | + foreach ($ticket_line_items_per_event[ $event_id ] as $line_item_id => $line_item) { |
|
| 78 | + $ticket = $line_item->ticket(); |
|
| 79 | + $taxable_html = $ticket->taxable() |
|
| 80 | + ? '*' |
|
| 81 | + : ''; |
|
| 82 | + $subitems = $line_item->children(); |
|
| 83 | + $ticket_uses = $ticket->get_pretty('TKT_uses', esc_html__("any", "event_espresso")); |
|
| 84 | + ?> |
|
| 85 | 85 | <li class="event-ticket"> |
| 86 | 86 | <div class="ticket-details"> |
| 87 | 87 | <table class="invoice-amount"> |
@@ -90,10 +90,10 @@ discard block |
||
| 90 | 90 | <th class="name-column"><?php esc_html_e("Ticket", "event_espresso"); ?></th> |
| 91 | 91 | <th colspan="2" class="desc-column"> |
| 92 | 92 | <?php |
| 93 | - esc_html_e( |
|
| 94 | - "Description", |
|
| 95 | - "event_espresso" |
|
| 96 | - ); ?></th> |
|
| 93 | + esc_html_e( |
|
| 94 | + "Description", |
|
| 95 | + "event_espresso" |
|
| 96 | + ); ?></th> |
|
| 97 | 97 | <th class="number-column item_c"><?php esc_html_e("Quantity", "event_espresso"); ?></th> |
| 98 | 98 | <th class="number-column item_c"><?php esc_html_e("Price", "event_espresso"); ?></th> |
| 99 | 99 | <th class="number-column item_r"><?php esc_html_e("Total", "event_espresso"); ?></th> |
@@ -101,20 +101,20 @@ discard block |
||
| 101 | 101 | </thead> |
| 102 | 102 | <tbody> |
| 103 | 103 | <?php |
| 104 | - if (count($subitems) < 2) { ?> |
|
| 104 | + if (count($subitems) < 2) { ?> |
|
| 105 | 105 | <tr class="item"> |
| 106 | 106 | <td><?php echo esc_html($line_item->name() . $taxable_html); ?></td> |
| 107 | 107 | <td colspan="2"> |
| 108 | 108 | <?php echo esc_html($line_item->desc()); ?> |
| 109 | 109 | <p class="ticket-note"> |
| 110 | 110 | <?php |
| 111 | - echo sprintf( |
|
| 112 | - esc_html__( |
|
| 113 | - 'This ticket can be used once at %s of the dates/times below.', |
|
| 114 | - 'event_espresso' |
|
| 115 | - ), |
|
| 116 | - $ticket_uses |
|
| 117 | - ); ?> |
|
| 111 | + echo sprintf( |
|
| 112 | + esc_html__( |
|
| 113 | + 'This ticket can be used once at %s of the dates/times below.', |
|
| 114 | + 'event_espresso' |
|
| 115 | + ), |
|
| 116 | + $ticket_uses |
|
| 117 | + ); ?> |
|
| 118 | 118 | </p> |
| 119 | 119 | </td> |
| 120 | 120 | <td class="item_c"><?php echo esc_html($line_item->quantity()); ?></td> |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | <td class="item_r"><?php echo $line_item->total_no_code() // already escaped ?></td> |
| 123 | 123 | </tr> |
| 124 | 124 | <?php |
| 125 | - } else { ?> |
|
| 125 | + } else { ?> |
|
| 126 | 126 | <tr class="item"> |
| 127 | 127 | <td class="aln-left"> |
| 128 | 128 | <?php echo esc_html($line_item->name() . $taxable_html); ?> |
@@ -130,13 +130,13 @@ discard block |
||
| 130 | 130 | <td colspan="2"><?php echo esc_html($line_item->desc()); ?> |
| 131 | 131 | <p class="ticket-note"> |
| 132 | 132 | <?php |
| 133 | - echo sprintf( |
|
| 134 | - esc_html__( |
|
| 135 | - 'This ticket can be used once at %s of the dates/times below.', |
|
| 136 | - 'event_espresso' |
|
| 137 | - ), |
|
| 138 | - $ticket_uses |
|
| 139 | - ); ?> |
|
| 133 | + echo sprintf( |
|
| 134 | + esc_html__( |
|
| 135 | + 'This ticket can be used once at %s of the dates/times below.', |
|
| 136 | + 'event_espresso' |
|
| 137 | + ), |
|
| 138 | + $ticket_uses |
|
| 139 | + ); ?> |
|
| 140 | 140 | </p> |
| 141 | 141 | </td> |
| 142 | 142 | <td class="item_c"> |
@@ -150,8 +150,8 @@ discard block |
||
| 150 | 150 | </td> |
| 151 | 151 | </tr> |
| 152 | 152 | <?php |
| 153 | - foreach ($subitems as $sub_line_item) { |
|
| 154 | - $is_percent = $sub_line_item->is_percent(); ?> |
|
| 153 | + foreach ($subitems as $sub_line_item) { |
|
| 154 | + $is_percent = $sub_line_item->is_percent(); ?> |
|
| 155 | 155 | <tr class="subitem-row"> |
| 156 | 156 | <td class="subitem"> |
| 157 | 157 | <?php echo esc_html($sub_line_item->name()); ?> |
@@ -163,14 +163,14 @@ discard block |
||
| 163 | 163 | <?php // echo $is_percent ? '' : $sub_line_item->quantity()?> |
| 164 | 164 | </td> |
| 165 | 165 | <td class="item_c"><?php |
| 166 | - echo $is_percent |
|
| 167 | - ? $sub_line_item->percent() . "%" |
|
| 168 | - : $sub_line_item->unit_price_no_code(); // already escaped ?> |
|
| 166 | + echo $is_percent |
|
| 167 | + ? $sub_line_item->percent() . "%" |
|
| 168 | + : $sub_line_item->unit_price_no_code(); // already escaped ?> |
|
| 169 | 169 | </td> |
| 170 | 170 | <td class="item_r"><?php echo $sub_line_item->total_no_code() ?></td> |
| 171 | 171 | </tr> |
| 172 | 172 | <?php |
| 173 | - } ?> |
|
| 173 | + } ?> |
|
| 174 | 174 | <tr class="total_tr odd"> |
| 175 | 175 | <td colspan="4"></td> |
| 176 | 176 | <td class="total" nowrap="nowrap"> |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | </td> |
| 182 | 182 | </tr> |
| 183 | 183 | <?php |
| 184 | - } ?> |
|
| 184 | + } ?> |
|
| 185 | 185 | </tbody> |
| 186 | 186 | </table> |
| 187 | 187 | |
@@ -192,49 +192,49 @@ discard block |
||
| 192 | 192 | <h4 class="sub-section-title no-bottom-margin"> |
| 193 | 193 | <img class="icon" src="<?php echo esc_url_raw(EE_IMAGES_URL . 'clock-16x16.png'); ?>"> |
| 194 | 194 | <?php |
| 195 | - echo _n( |
|
| 196 | - "Date/Time:", |
|
| 197 | - "Dates/Times:", |
|
| 198 | - count($ticket->datetimes()), |
|
| 199 | - "event_espresso" |
|
| 200 | - ); ?></h4> |
|
| 195 | + echo _n( |
|
| 196 | + "Date/Time:", |
|
| 197 | + "Dates/Times:", |
|
| 198 | + count($ticket->datetimes()), |
|
| 199 | + "event_espresso" |
|
| 200 | + ); ?></h4> |
|
| 201 | 201 | <ul class="event-dates"> |
| 202 | 202 | <?php |
| 203 | - foreach ($ticket->datetimes_ordered() as $datetime) { |
|
| 204 | - /* @var $datetime EE_Datetime */ ?> |
|
| 203 | + foreach ($ticket->datetimes_ordered() as $datetime) { |
|
| 204 | + /* @var $datetime EE_Datetime */ ?> |
|
| 205 | 205 | <li><?php |
| 206 | - echo $datetime->name() |
|
| 207 | - ? '<b>' . esc_html($datetime->name()) . ' </b>' |
|
| 208 | - : ''; |
|
| 209 | - echo sprintf( |
|
| 210 | - esc_html__("%s - %s (%s)", "event_espresso"), |
|
| 211 | - $datetime->start_date_and_time(), |
|
| 212 | - $datetime->end_date_and_time(), |
|
| 213 | - $datetime->get_timezone() |
|
| 214 | - ); |
|
| 215 | - echo $datetime->description() |
|
| 216 | - ? '<p class="ticket-note">' . $datetime->description() . '</p>' |
|
| 217 | - : '' ?></li> |
|
| 206 | + echo $datetime->name() |
|
| 207 | + ? '<b>' . esc_html($datetime->name()) . ' </b>' |
|
| 208 | + : ''; |
|
| 209 | + echo sprintf( |
|
| 210 | + esc_html__("%s - %s (%s)", "event_espresso"), |
|
| 211 | + $datetime->start_date_and_time(), |
|
| 212 | + $datetime->end_date_and_time(), |
|
| 213 | + $datetime->get_timezone() |
|
| 214 | + ); |
|
| 215 | + echo $datetime->description() |
|
| 216 | + ? '<p class="ticket-note">' . $datetime->description() . '</p>' |
|
| 217 | + : '' ?></li> |
|
| 218 | 218 | <?php |
| 219 | - } ?> |
|
| 219 | + } ?> |
|
| 220 | 220 | </ul> |
| 221 | 221 | </div> |
| 222 | 222 | <?php |
| 223 | - if ($event->venues()) { ?> |
|
| 223 | + if ($event->venues()) { ?> |
|
| 224 | 224 | <div class="ticket-place-details"> |
| 225 | 225 | <h4 class="sub-section-title no-bottom-margin"> |
| 226 | 226 | <img class="icon" src="<?php |
| 227 | - echo esc_url_raw(EE_IMAGES_URL . 'location-pin-16x16.png'); ?>"> |
|
| 227 | + echo esc_url_raw(EE_IMAGES_URL . 'location-pin-16x16.png'); ?>"> |
|
| 228 | 228 | <?php |
| 229 | - echo _n( |
|
| 230 | - "Venue:", |
|
| 231 | - "Venues:", |
|
| 232 | - count($event->venues()), |
|
| 233 | - "event_espresso" |
|
| 234 | - ); ?></h4> |
|
| 229 | + echo _n( |
|
| 230 | + "Venue:", |
|
| 231 | + "Venues:", |
|
| 232 | + count($event->venues()), |
|
| 233 | + "event_espresso" |
|
| 234 | + ); ?></h4> |
|
| 235 | 235 | <ul class="event-venues"> |
| 236 | 236 | <?php |
| 237 | - foreach ($event->venues() as $venue) { ?> |
|
| 237 | + foreach ($event->venues() as $venue) { ?> |
|
| 238 | 238 | <li><?php echo esc_html($venue->name()) ?> |
| 239 | 239 | <span class="small-text"> |
| 240 | 240 | [ |
@@ -245,18 +245,18 @@ discard block |
||
| 245 | 245 | </span> |
| 246 | 246 | </li> |
| 247 | 247 | <?php |
| 248 | - } ?> |
|
| 248 | + } ?> |
|
| 249 | 249 | </ul> |
| 250 | 250 | </div> |
| 251 | 251 | <?php |
| 252 | - } ?> |
|
| 252 | + } ?> |
|
| 253 | 253 | </div> |
| 254 | 254 | <div class="ticket-registrations-area"> |
| 255 | 255 | <h4 class="sub-section-title"> |
| 256 | 256 | <img class="icon" src="<?php |
| 257 | - echo esc_url_raw(EE_IMAGES_URL . 'users-16x16.png'); ?>"> |
|
| 257 | + echo esc_url_raw(EE_IMAGES_URL . 'users-16x16.png'); ?>"> |
|
| 258 | 258 | <?php |
| 259 | - echo esc_html__("Registration Details", "event_espresso"); ?> |
|
| 259 | + echo esc_html__("Registration Details", "event_espresso"); ?> |
|
| 260 | 260 | <span class="small-text link">[ |
| 261 | 261 | <a class="print_button noPrint" href="<?php echo $edit_reg_info_url; ?>"> |
| 262 | 262 | <?php esc_html_e('edit', 'event_espresso'); ?> |
@@ -266,12 +266,12 @@ discard block |
||
| 266 | 266 | </h4> |
| 267 | 267 | <ul class="ticket-registrations-list"> |
| 268 | 268 | <?php |
| 269 | - foreach ($registrations_per_line_item[ $line_item_id ] as $registration) { |
|
| 270 | - /* @var $registration EE_Registration */ |
|
| 271 | - $attendee = $registration->attendee(); |
|
| 272 | - $answers = $registration->answers( |
|
| 273 | - ['order_by' => ['Question.Question_Group_Question.QGQ_order' => 'ASC']] |
|
| 274 | - ); ?> |
|
| 269 | + foreach ($registrations_per_line_item[ $line_item_id ] as $registration) { |
|
| 270 | + /* @var $registration EE_Registration */ |
|
| 271 | + $attendee = $registration->attendee(); |
|
| 272 | + $answers = $registration->answers( |
|
| 273 | + ['order_by' => ['Question.Question_Group_Question.QGQ_order' => 'ASC']] |
|
| 274 | + ); ?> |
|
| 275 | 275 | <li class="ticket-registration"> |
| 276 | 276 | <table class="registration-details"> |
| 277 | 277 | <tr class="odd"> |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | </td> |
| 287 | 287 | </tr> |
| 288 | 288 | <?php |
| 289 | - foreach ($event->question_groups() as $question_group) { ?> |
|
| 289 | + foreach ($event->question_groups() as $question_group) { ?> |
|
| 290 | 290 | <tr> |
| 291 | 291 | <th> |
| 292 | 292 | <?php $question_group->e('QSG_name'); ?> |
@@ -294,12 +294,12 @@ discard block |
||
| 294 | 294 | <td></td> |
| 295 | 295 | </tr> |
| 296 | 296 | <?php $has_personal_info = false; |
| 297 | - foreach ($question_group->questions() as $question) { |
|
| 298 | - if (in_array($question->system_ID(), $questions_to_skip)) { |
|
| 299 | - $has_personal_info = true; |
|
| 300 | - continue; |
|
| 301 | - } |
|
| 302 | - ?> |
|
| 297 | + foreach ($question_group->questions() as $question) { |
|
| 298 | + if (in_array($question->system_ID(), $questions_to_skip)) { |
|
| 299 | + $has_personal_info = true; |
|
| 300 | + continue; |
|
| 301 | + } |
|
| 302 | + ?> |
|
| 303 | 303 | <tr> |
| 304 | 304 | <th> |
| 305 | 305 | <?php echo $question->display_text(); // already escaped ?> |
@@ -309,26 +309,26 @@ discard block |
||
| 309 | 309 | </td> |
| 310 | 310 | </tr> |
| 311 | 311 | <?php } |
| 312 | - if ($has_personal_info) { ?> |
|
| 312 | + if ($has_personal_info) { ?> |
|
| 313 | 313 | <tr> |
| 314 | 314 | <th><?php esc_html_e('Attendee', 'event_espresso'); ?></th> |
| 315 | 315 | <td> |
| 316 | 316 | <?php |
| 317 | - echo sprintf( |
|
| 318 | - esc_html__('%s (%s)', "event_espresso"), |
|
| 319 | - esc_html($attendee->full_name()), |
|
| 320 | - sanitize_email($attendee->email()) |
|
| 321 | - ) ?> |
|
| 317 | + echo sprintf( |
|
| 318 | + esc_html__('%s (%s)', "event_espresso"), |
|
| 319 | + esc_html($attendee->full_name()), |
|
| 320 | + sanitize_email($attendee->email()) |
|
| 321 | + ) ?> |
|
| 322 | 322 | </td> |
| 323 | 323 | </tr> |
| 324 | 324 | <?php |
| 325 | - } |
|
| 326 | - } |
|
| 327 | - ?> |
|
| 325 | + } |
|
| 326 | + } |
|
| 327 | + ?> |
|
| 328 | 328 | </table> |
| 329 | 329 | </li> |
| 330 | 330 | <?php |
| 331 | - } ?> |
|
| 331 | + } ?> |
|
| 332 | 332 | </ul> |
| 333 | 333 | </div> |
| 334 | 334 | </div> |
@@ -372,10 +372,10 @@ discard block |
||
| 372 | 372 | <div class="grand-total-dv"> |
| 373 | 373 | <h2 class="grand-total"> |
| 374 | 374 | <?php |
| 375 | - printf( |
|
| 376 | - esc_html__("Grand Total: %s", "event_espresso"), |
|
| 377 | - EEH_Template::format_currency($total_cost) |
|
| 378 | - ); ?> |
|
| 375 | + printf( |
|
| 376 | + esc_html__("Grand Total: %s", "event_espresso"), |
|
| 377 | + EEH_Template::format_currency($total_cost) |
|
| 378 | + ); ?> |
|
| 379 | 379 | </h2> |
| 380 | 380 | </div> |
| 381 | 381 | <div class="payment-dv"> |
@@ -394,13 +394,13 @@ discard block |
||
| 394 | 394 | </thead> |
| 395 | 395 | <tbody> |
| 396 | 396 | <?php |
| 397 | - $c = false; |
|
| 398 | - if (! empty($payments)) { |
|
| 399 | - foreach ($payments as $payment) { |
|
| 400 | - /* @var $payment EE_Payment */ ?> |
|
| 397 | + $c = false; |
|
| 398 | + if (! empty($payments)) { |
|
| 399 | + foreach ($payments as $payment) { |
|
| 400 | + /* @var $payment EE_Payment */ ?> |
|
| 401 | 401 | <tr class='item <?php echo(($c = ! $c) |
| 402 | - ? ' odd' |
|
| 403 | - : '') ?>'> |
|
| 402 | + ? ' odd' |
|
| 403 | + : '') ?>'> |
|
| 404 | 404 | <td><?php $payment->e('PAY_gateway') ?></td> |
| 405 | 405 | <td><?php echo esc_html($payment->timestamp()); ?></td> |
| 406 | 406 | <td><?php $payment->e('PAY_txn_id_chq_nmbr') ?></td> |
@@ -409,14 +409,14 @@ discard block |
||
| 409 | 409 | <td class='item_r'><?php echo $payment->amount_no_code(); // already escaped ?></td> |
| 410 | 410 | </tr> |
| 411 | 411 | <?php } |
| 412 | - } else { ?> |
|
| 412 | + } else { ?> |
|
| 413 | 413 | <tr class='item'> |
| 414 | 414 | <td class='aln-cntr' colspan="6"> |
| 415 | 415 | <?php |
| 416 | - esc_html_e( |
|
| 417 | - "No approved payments have been received.", |
|
| 418 | - 'event_espresso' |
|
| 419 | - ) ?> |
|
| 416 | + esc_html_e( |
|
| 417 | + "No approved payments have been received.", |
|
| 418 | + 'event_espresso' |
|
| 419 | + ) ?> |
|
| 420 | 420 | </td> |
| 421 | 421 | </tr> |
| 422 | 422 | <?php } ?> |
@@ -453,7 +453,7 @@ discard block |
||
| 453 | 453 | <?php if ($venues_for_events) { ?> |
| 454 | 454 | <h2> |
| 455 | 455 | <?php |
| 456 | - echo _n("Venue Details:", "Venues Details:", count($venues_for_events), "event_espresso"); ?> |
|
| 456 | + echo _n("Venue Details:", "Venues Details:", count($venues_for_events), "event_espresso"); ?> |
|
| 457 | 457 | </h2> |
| 458 | 458 | <table class="venue-list"> |
| 459 | 459 | <?php foreach ($venues_for_events as $venue) { ?> |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | <div class="events"> |
| 59 | 59 | <?php foreach ($events_for_txn as $event_id => $event) { ?> |
| 60 | 60 | <h3 class="section-title event-name"> |
| 61 | - <img class="icon" src="<?php echo EE_IMAGES_URL . 'calendar_year-24x24.png'; ?>"> |
|
| 61 | + <img class="icon" src="<?php echo EE_IMAGES_URL.'calendar_year-24x24.png'; ?>"> |
|
| 62 | 62 | <?php |
| 63 | 63 | esc_html_e( |
| 64 | 64 | "Event Name:", |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | <?php } ?> |
| 75 | 75 | <ul class="tickets-per-event"> |
| 76 | 76 | <?php |
| 77 | - foreach ($ticket_line_items_per_event[ $event_id ] as $line_item_id => $line_item) { |
|
| 77 | + foreach ($ticket_line_items_per_event[$event_id] as $line_item_id => $line_item) { |
|
| 78 | 78 | $ticket = $line_item->ticket(); |
| 79 | 79 | $taxable_html = $ticket->taxable() |
| 80 | 80 | ? '*' |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | <?php |
| 104 | 104 | if (count($subitems) < 2) { ?> |
| 105 | 105 | <tr class="item"> |
| 106 | - <td><?php echo esc_html($line_item->name() . $taxable_html); ?></td> |
|
| 106 | + <td><?php echo esc_html($line_item->name().$taxable_html); ?></td> |
|
| 107 | 107 | <td colspan="2"> |
| 108 | 108 | <?php echo esc_html($line_item->desc()); ?> |
| 109 | 109 | <p class="ticket-note"> |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | } else { ?> |
| 126 | 126 | <tr class="item"> |
| 127 | 127 | <td class="aln-left"> |
| 128 | - <?php echo esc_html($line_item->name() . $taxable_html); ?> |
|
| 128 | + <?php echo esc_html($line_item->name().$taxable_html); ?> |
|
| 129 | 129 | </td> |
| 130 | 130 | <td colspan="2"><?php echo esc_html($line_item->desc()); ?> |
| 131 | 131 | <p class="ticket-note"> |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | </td> |
| 165 | 165 | <td class="item_c"><?php |
| 166 | 166 | echo $is_percent |
| 167 | - ? $sub_line_item->percent() . "%" |
|
| 167 | + ? $sub_line_item->percent()."%" |
|
| 168 | 168 | : $sub_line_item->unit_price_no_code(); // already escaped ?> |
| 169 | 169 | </td> |
| 170 | 170 | <td class="item_r"><?php echo $sub_line_item->total_no_code() ?></td> |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | <div class="ticket-time-and-place-details"> |
| 191 | 191 | <div class="ticket-time-details"> |
| 192 | 192 | <h4 class="sub-section-title no-bottom-margin"> |
| 193 | - <img class="icon" src="<?php echo esc_url_raw(EE_IMAGES_URL . 'clock-16x16.png'); ?>"> |
|
| 193 | + <img class="icon" src="<?php echo esc_url_raw(EE_IMAGES_URL.'clock-16x16.png'); ?>"> |
|
| 194 | 194 | <?php |
| 195 | 195 | echo _n( |
| 196 | 196 | "Date/Time:", |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | /* @var $datetime EE_Datetime */ ?> |
| 205 | 205 | <li><?php |
| 206 | 206 | echo $datetime->name() |
| 207 | - ? '<b>' . esc_html($datetime->name()) . ' </b>' |
|
| 207 | + ? '<b>'.esc_html($datetime->name()).' </b>' |
|
| 208 | 208 | : ''; |
| 209 | 209 | echo sprintf( |
| 210 | 210 | esc_html__("%s - %s (%s)", "event_espresso"), |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | $datetime->get_timezone() |
| 214 | 214 | ); |
| 215 | 215 | echo $datetime->description() |
| 216 | - ? '<p class="ticket-note">' . $datetime->description() . '</p>' |
|
| 216 | + ? '<p class="ticket-note">'.$datetime->description().'</p>' |
|
| 217 | 217 | : '' ?></li> |
| 218 | 218 | <?php |
| 219 | 219 | } ?> |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | <div class="ticket-place-details"> |
| 225 | 225 | <h4 class="sub-section-title no-bottom-margin"> |
| 226 | 226 | <img class="icon" src="<?php |
| 227 | - echo esc_url_raw(EE_IMAGES_URL . 'location-pin-16x16.png'); ?>"> |
|
| 227 | + echo esc_url_raw(EE_IMAGES_URL.'location-pin-16x16.png'); ?>"> |
|
| 228 | 228 | <?php |
| 229 | 229 | echo _n( |
| 230 | 230 | "Venue:", |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | <div class="ticket-registrations-area"> |
| 255 | 255 | <h4 class="sub-section-title"> |
| 256 | 256 | <img class="icon" src="<?php |
| 257 | - echo esc_url_raw(EE_IMAGES_URL . 'users-16x16.png'); ?>"> |
|
| 257 | + echo esc_url_raw(EE_IMAGES_URL.'users-16x16.png'); ?>"> |
|
| 258 | 258 | <?php |
| 259 | 259 | echo esc_html__("Registration Details", "event_espresso"); ?> |
| 260 | 260 | <span class="small-text link">[ |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | </h4> |
| 267 | 267 | <ul class="ticket-registrations-list"> |
| 268 | 268 | <?php |
| 269 | - foreach ($registrations_per_line_item[ $line_item_id ] as $registration) { |
|
| 269 | + foreach ($registrations_per_line_item[$line_item_id] as $registration) { |
|
| 270 | 270 | /* @var $registration EE_Registration */ |
| 271 | 271 | $attendee = $registration->attendee(); |
| 272 | 272 | $answers = $registration->answers( |
@@ -395,7 +395,7 @@ discard block |
||
| 395 | 395 | <tbody> |
| 396 | 396 | <?php |
| 397 | 397 | $c = false; |
| 398 | - if (! empty($payments)) { |
|
| 398 | + if ( ! empty($payments)) { |
|
| 399 | 399 | foreach ($payments as $payment) { |
| 400 | 400 | /* @var $payment EE_Payment */ ?> |
| 401 | 401 | <tr class='item <?php echo(($c = ! $c) |
@@ -13,235 +13,235 @@ |
||
| 13 | 13 | class EED_Ical extends EED_Module |
| 14 | 14 | { |
| 15 | 15 | |
| 16 | - const iCal_datetime_format = 'Ymd\THis\Z'; |
|
| 17 | - |
|
| 18 | - |
|
| 19 | - /** |
|
| 20 | - * @return EED_Ical|EED_Module |
|
| 21 | - * @throws EE_Error |
|
| 22 | - * @throws ReflectionException |
|
| 23 | - */ |
|
| 24 | - public static function instance() |
|
| 25 | - { |
|
| 26 | - return parent::get_instance(__CLASS__); |
|
| 27 | - } |
|
| 28 | - |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
| 32 | - * |
|
| 33 | - * @return void |
|
| 34 | - */ |
|
| 35 | - public static function set_hooks() |
|
| 36 | - { |
|
| 37 | - // create download buttons |
|
| 38 | - add_filter( |
|
| 39 | - 'FHEE__espresso_list_of_event_dates__datetime_html', |
|
| 40 | - ['EED_Ical', 'generate_add_to_iCal_button'], |
|
| 41 | - 10, |
|
| 42 | - 2 |
|
| 43 | - ); |
|
| 44 | - // process ics download request |
|
| 45 | - EE_Config::register_route('download_ics_file', 'EED_Ical', 'download_ics_file'); |
|
| 46 | - } |
|
| 47 | - |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
| 51 | - * |
|
| 52 | - * @return void |
|
| 53 | - */ |
|
| 54 | - public static function set_hooks_admin() |
|
| 55 | - { |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * run - initial module setup |
|
| 61 | - * |
|
| 62 | - * @param WP $WP |
|
| 63 | - * @return void |
|
| 64 | - */ |
|
| 65 | - public function run($WP) |
|
| 66 | - { |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * @param $html |
|
| 72 | - * @param $datetime |
|
| 73 | - * @return string |
|
| 74 | - * @throws EE_Error |
|
| 75 | - * @throws ReflectionException |
|
| 76 | - */ |
|
| 77 | - public static function generate_add_to_iCal_button($html, $datetime) |
|
| 78 | - { |
|
| 79 | - // first verify a proper datetime object has been received |
|
| 80 | - if ($datetime instanceof EE_Datetime) { |
|
| 81 | - // set whether a link or submit button is shown |
|
| 82 | - $iCal_type = apply_filters('FHEE__EED_Ical__generate_add_to_iCal_button__iCal_type', 'submit'); |
|
| 83 | - // generate a link to the route we registered in set_hooks() |
|
| 84 | - $URL = add_query_arg(['ee' => 'download_ics_file', 'ics_id' => $datetime->ID()], site_url()); |
|
| 85 | - $URL = esc_url_Raw($URL); |
|
| 86 | - // what type ? |
|
| 87 | - switch ($iCal_type) { |
|
| 88 | - // submit buttons appear as buttons and are very compatible with a theme's style |
|
| 89 | - case 'submit': |
|
| 90 | - $html .= '<form id="download-iCal-frm-' . $datetime->ID(); |
|
| 91 | - $html .= '" class="download-iCal-frm" action="' . $URL . '" method="post" >'; |
|
| 92 | - $html .= '<input type="submit" class="ee-ical-sbmt" value="" title="'; |
|
| 93 | - $html .= esc_html__('Add to iCal Calendar', 'event_espresso') . '"/>'; |
|
| 94 | - $html .= '</form>'; |
|
| 95 | - break; |
|
| 96 | - // buttons are just links that have been styled to appear as buttons, |
|
| 97 | - // but may not be blend with a theme as well as submit buttons |
|
| 98 | - case 'button': |
|
| 99 | - $html .= '<a class="ee-ical-btn small ee-button ee-roundish" href="' . $URL; |
|
| 100 | - $html .= '" title="' . esc_html__('Add to iCal Calendar', 'event_espresso') . '">'; |
|
| 101 | - $html .= ' <span class="dashicons dashicons-calendar"></span>'; |
|
| 102 | - $html .= '</a>'; |
|
| 103 | - break; |
|
| 104 | - // links are just links that use the calendar dashicon |
|
| 105 | - case 'icon': |
|
| 106 | - $html .= '<a class="ee-ical-lnk" href="' . $URL . '" title="'; |
|
| 107 | - $html .= esc_html__('Add to iCal Calendar', 'event_espresso') . '">'; |
|
| 108 | - $html .= ' <span class="dashicons dashicons-calendar"></span>'; |
|
| 109 | - $html .= '</a>'; |
|
| 110 | - break; |
|
| 111 | - } |
|
| 112 | - } |
|
| 113 | - return $html; |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - |
|
| 117 | - /** |
|
| 118 | - * @return void |
|
| 119 | - * @throws EE_Error |
|
| 120 | - * @throws ReflectionException |
|
| 121 | - */ |
|
| 122 | - public static function download_ics_file() |
|
| 123 | - { |
|
| 124 | - $request = self::getRequest(); |
|
| 125 | - if ($request->requestParamIsSet('ics_id')) { |
|
| 126 | - $DTT_ID = $request->getRequestParam('ics_id', 0, 'int'); |
|
| 127 | - $datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
|
| 128 | - if ($datetime instanceof EE_Datetime) { |
|
| 129 | - // get related event, venues, and event categories |
|
| 130 | - $event = $datetime->event(); |
|
| 131 | - if ($event instanceof EE_Event) { |
|
| 132 | - // get related category Term object and it's name |
|
| 133 | - $category = $event->first_event_category(); |
|
| 134 | - if ($category instanceof EE_Term) { |
|
| 135 | - $category = $category->name(); |
|
| 136 | - } |
|
| 137 | - $location = ''; |
|
| 138 | - // get first related venue and convert to CSV string |
|
| 139 | - $venue = $event->venues(['limit' => 1]); |
|
| 140 | - if (is_array($venue) && ! empty($venue)) { |
|
| 141 | - $venue = array_shift($venue); |
|
| 142 | - if ($venue instanceof EE_Venue) { |
|
| 143 | - $location = espresso_venue_raw_address('inline', $venue->ID(), false); |
|
| 144 | - } |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - // Generate filename |
|
| 148 | - $filename = $event->slug() . '-' . $datetime->start_date('Y-m-d') . '.ics'; |
|
| 149 | - |
|
| 150 | - // Check the datetime status has not been cancelled and set the ics value accordingly |
|
| 151 | - $status = $datetime->get_active_status(); |
|
| 152 | - $status = $status === EE_Datetime::cancelled ? 'CANCELLED' : 'CONFIRMED'; |
|
| 153 | - |
|
| 154 | - // Create array of ics details, escape strings, convert timestamps to ics format, etc |
|
| 155 | - $ics_data = [ |
|
| 156 | - 'ORGANIZER_NAME' => EE_Registry::instance()->CFG->organization->name, |
|
| 157 | - 'UID' => md5($event->name() . $event->ID() . $datetime->ID()), |
|
| 158 | - 'ORGANIZER' => EE_Registry::instance()->CFG->organization->email, |
|
| 159 | - 'DTSTAMP' => date(EED_Ical::iCal_datetime_format), |
|
| 160 | - 'LOCATION' => $location, |
|
| 161 | - 'SUMMARY' => $event->name(), |
|
| 162 | - 'DESCRIPTION' => wp_strip_all_tags($event->description()), |
|
| 163 | - 'STATUS' => $status, |
|
| 164 | - 'CATEGORIES' => $category, |
|
| 165 | - 'URL;VALUE=URI' => get_permalink($event->ID()), |
|
| 166 | - 'DTSTART' => date(EED_Ical::iCal_datetime_format, $datetime->start()), |
|
| 167 | - 'DTEND' => date(EED_Ical::iCal_datetime_format, $datetime->end()), |
|
| 168 | - ]; |
|
| 169 | - |
|
| 170 | - // Filter the values used within the ics output. |
|
| 171 | - // NOTE - all values within ics_data will be escaped automatically. |
|
| 172 | - $ics_data = apply_filters('FHEE__EED_Ical__download_ics_file_ics_data', $ics_data, $datetime); |
|
| 173 | - |
|
| 174 | - // Escape all ics data |
|
| 175 | - foreach ($ics_data as $key => $value) { |
|
| 176 | - // Description is escaped differently from all all values |
|
| 177 | - if ($key === 'DESCRIPTION') { |
|
| 178 | - $ics_data[ $key ] = EED_Ical::_escape_ICal_description(wp_strip_all_tags($value)); |
|
| 179 | - } else { |
|
| 180 | - $ics_data[ $key ] = EED_Ical::_escape_ICal_data($value); |
|
| 181 | - } |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - // Pull the organizer name from ics_data and remove it from the array. |
|
| 185 | - $organizer_name = isset($ics_data['ORGANIZER_NAME']) |
|
| 186 | - ? $ics_data['ORGANIZER_NAME'] |
|
| 187 | - : ''; |
|
| 188 | - unset($ics_data['ORGANIZER_NAME']); |
|
| 189 | - |
|
| 190 | - // set headers |
|
| 191 | - header('Content-type: text/calendar; charset=utf-8'); |
|
| 192 | - header('Content-Disposition: attachment; filename="' . $filename . '"'); |
|
| 193 | - header('Cache-Control: private, max-age=0, must-revalidate'); |
|
| 194 | - header('Pragma: public'); |
|
| 195 | - header('Content-Type: application/octet-stream'); |
|
| 196 | - header('Content-Type: application/force-download'); |
|
| 197 | - header('Cache-Control: no-cache, must-revalidate'); |
|
| 198 | - header('Content-Transfer-Encoding: binary'); |
|
| 199 | - header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // past date |
|
| 200 | - ini_set('zlib.output_compression', '0'); |
|
| 201 | - // echo the output |
|
| 202 | - echo "BEGIN:VCALENDAR\r\n"; |
|
| 203 | - echo "VERSION:2.0\r\n"; |
|
| 204 | - echo "PRODID:-//{$organizer_name}//NONSGML PDA Calendar Version 1.0//EN\r\n"; |
|
| 205 | - echo "CALSCALE:GREGORIAN\r\n"; |
|
| 206 | - echo "BEGIN:VEVENT\r\n"; |
|
| 207 | - |
|
| 208 | - // Output all remaining values from ics_data. |
|
| 209 | - foreach ($ics_data as $key => $value) { |
|
| 210 | - echo $key . ':' . $value . "\r\n"; // already escaped |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - echo "END:VEVENT\r\n"; |
|
| 214 | - echo "END:VCALENDAR\r\n"; |
|
| 215 | - } |
|
| 216 | - } |
|
| 217 | - } |
|
| 218 | - die(); |
|
| 219 | - } |
|
| 220 | - |
|
| 221 | - |
|
| 222 | - /** |
|
| 223 | - * _escape_ICal_data |
|
| 224 | - * |
|
| 225 | - * @param string $string |
|
| 226 | - * @return string |
|
| 227 | - */ |
|
| 228 | - private static function _escape_ICal_data($string = '') |
|
| 229 | - { |
|
| 230 | - return preg_replace('/([\,;])/', '\\\$1', $string); |
|
| 231 | - } |
|
| 232 | - |
|
| 233 | - |
|
| 234 | - /** |
|
| 235 | - * _escape_ICal_description |
|
| 236 | - * |
|
| 237 | - * @param string $description |
|
| 238 | - * @return string |
|
| 239 | - */ |
|
| 240 | - private static function _escape_ICal_description($description = '') |
|
| 241 | - { |
|
| 242 | - // Escape special chars within the description |
|
| 243 | - $description = EED_Ical::_escape_ICal_data($description); |
|
| 244 | - // Remove line breaks and output in iCal format |
|
| 245 | - return str_replace(["\r\n", "\n"], '\n', $description); |
|
| 246 | - } |
|
| 16 | + const iCal_datetime_format = 'Ymd\THis\Z'; |
|
| 17 | + |
|
| 18 | + |
|
| 19 | + /** |
|
| 20 | + * @return EED_Ical|EED_Module |
|
| 21 | + * @throws EE_Error |
|
| 22 | + * @throws ReflectionException |
|
| 23 | + */ |
|
| 24 | + public static function instance() |
|
| 25 | + { |
|
| 26 | + return parent::get_instance(__CLASS__); |
|
| 27 | + } |
|
| 28 | + |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
| 32 | + * |
|
| 33 | + * @return void |
|
| 34 | + */ |
|
| 35 | + public static function set_hooks() |
|
| 36 | + { |
|
| 37 | + // create download buttons |
|
| 38 | + add_filter( |
|
| 39 | + 'FHEE__espresso_list_of_event_dates__datetime_html', |
|
| 40 | + ['EED_Ical', 'generate_add_to_iCal_button'], |
|
| 41 | + 10, |
|
| 42 | + 2 |
|
| 43 | + ); |
|
| 44 | + // process ics download request |
|
| 45 | + EE_Config::register_route('download_ics_file', 'EED_Ical', 'download_ics_file'); |
|
| 46 | + } |
|
| 47 | + |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
| 51 | + * |
|
| 52 | + * @return void |
|
| 53 | + */ |
|
| 54 | + public static function set_hooks_admin() |
|
| 55 | + { |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * run - initial module setup |
|
| 61 | + * |
|
| 62 | + * @param WP $WP |
|
| 63 | + * @return void |
|
| 64 | + */ |
|
| 65 | + public function run($WP) |
|
| 66 | + { |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * @param $html |
|
| 72 | + * @param $datetime |
|
| 73 | + * @return string |
|
| 74 | + * @throws EE_Error |
|
| 75 | + * @throws ReflectionException |
|
| 76 | + */ |
|
| 77 | + public static function generate_add_to_iCal_button($html, $datetime) |
|
| 78 | + { |
|
| 79 | + // first verify a proper datetime object has been received |
|
| 80 | + if ($datetime instanceof EE_Datetime) { |
|
| 81 | + // set whether a link or submit button is shown |
|
| 82 | + $iCal_type = apply_filters('FHEE__EED_Ical__generate_add_to_iCal_button__iCal_type', 'submit'); |
|
| 83 | + // generate a link to the route we registered in set_hooks() |
|
| 84 | + $URL = add_query_arg(['ee' => 'download_ics_file', 'ics_id' => $datetime->ID()], site_url()); |
|
| 85 | + $URL = esc_url_Raw($URL); |
|
| 86 | + // what type ? |
|
| 87 | + switch ($iCal_type) { |
|
| 88 | + // submit buttons appear as buttons and are very compatible with a theme's style |
|
| 89 | + case 'submit': |
|
| 90 | + $html .= '<form id="download-iCal-frm-' . $datetime->ID(); |
|
| 91 | + $html .= '" class="download-iCal-frm" action="' . $URL . '" method="post" >'; |
|
| 92 | + $html .= '<input type="submit" class="ee-ical-sbmt" value="" title="'; |
|
| 93 | + $html .= esc_html__('Add to iCal Calendar', 'event_espresso') . '"/>'; |
|
| 94 | + $html .= '</form>'; |
|
| 95 | + break; |
|
| 96 | + // buttons are just links that have been styled to appear as buttons, |
|
| 97 | + // but may not be blend with a theme as well as submit buttons |
|
| 98 | + case 'button': |
|
| 99 | + $html .= '<a class="ee-ical-btn small ee-button ee-roundish" href="' . $URL; |
|
| 100 | + $html .= '" title="' . esc_html__('Add to iCal Calendar', 'event_espresso') . '">'; |
|
| 101 | + $html .= ' <span class="dashicons dashicons-calendar"></span>'; |
|
| 102 | + $html .= '</a>'; |
|
| 103 | + break; |
|
| 104 | + // links are just links that use the calendar dashicon |
|
| 105 | + case 'icon': |
|
| 106 | + $html .= '<a class="ee-ical-lnk" href="' . $URL . '" title="'; |
|
| 107 | + $html .= esc_html__('Add to iCal Calendar', 'event_espresso') . '">'; |
|
| 108 | + $html .= ' <span class="dashicons dashicons-calendar"></span>'; |
|
| 109 | + $html .= '</a>'; |
|
| 110 | + break; |
|
| 111 | + } |
|
| 112 | + } |
|
| 113 | + return $html; |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + |
|
| 117 | + /** |
|
| 118 | + * @return void |
|
| 119 | + * @throws EE_Error |
|
| 120 | + * @throws ReflectionException |
|
| 121 | + */ |
|
| 122 | + public static function download_ics_file() |
|
| 123 | + { |
|
| 124 | + $request = self::getRequest(); |
|
| 125 | + if ($request->requestParamIsSet('ics_id')) { |
|
| 126 | + $DTT_ID = $request->getRequestParam('ics_id', 0, 'int'); |
|
| 127 | + $datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
|
| 128 | + if ($datetime instanceof EE_Datetime) { |
|
| 129 | + // get related event, venues, and event categories |
|
| 130 | + $event = $datetime->event(); |
|
| 131 | + if ($event instanceof EE_Event) { |
|
| 132 | + // get related category Term object and it's name |
|
| 133 | + $category = $event->first_event_category(); |
|
| 134 | + if ($category instanceof EE_Term) { |
|
| 135 | + $category = $category->name(); |
|
| 136 | + } |
|
| 137 | + $location = ''; |
|
| 138 | + // get first related venue and convert to CSV string |
|
| 139 | + $venue = $event->venues(['limit' => 1]); |
|
| 140 | + if (is_array($venue) && ! empty($venue)) { |
|
| 141 | + $venue = array_shift($venue); |
|
| 142 | + if ($venue instanceof EE_Venue) { |
|
| 143 | + $location = espresso_venue_raw_address('inline', $venue->ID(), false); |
|
| 144 | + } |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + // Generate filename |
|
| 148 | + $filename = $event->slug() . '-' . $datetime->start_date('Y-m-d') . '.ics'; |
|
| 149 | + |
|
| 150 | + // Check the datetime status has not been cancelled and set the ics value accordingly |
|
| 151 | + $status = $datetime->get_active_status(); |
|
| 152 | + $status = $status === EE_Datetime::cancelled ? 'CANCELLED' : 'CONFIRMED'; |
|
| 153 | + |
|
| 154 | + // Create array of ics details, escape strings, convert timestamps to ics format, etc |
|
| 155 | + $ics_data = [ |
|
| 156 | + 'ORGANIZER_NAME' => EE_Registry::instance()->CFG->organization->name, |
|
| 157 | + 'UID' => md5($event->name() . $event->ID() . $datetime->ID()), |
|
| 158 | + 'ORGANIZER' => EE_Registry::instance()->CFG->organization->email, |
|
| 159 | + 'DTSTAMP' => date(EED_Ical::iCal_datetime_format), |
|
| 160 | + 'LOCATION' => $location, |
|
| 161 | + 'SUMMARY' => $event->name(), |
|
| 162 | + 'DESCRIPTION' => wp_strip_all_tags($event->description()), |
|
| 163 | + 'STATUS' => $status, |
|
| 164 | + 'CATEGORIES' => $category, |
|
| 165 | + 'URL;VALUE=URI' => get_permalink($event->ID()), |
|
| 166 | + 'DTSTART' => date(EED_Ical::iCal_datetime_format, $datetime->start()), |
|
| 167 | + 'DTEND' => date(EED_Ical::iCal_datetime_format, $datetime->end()), |
|
| 168 | + ]; |
|
| 169 | + |
|
| 170 | + // Filter the values used within the ics output. |
|
| 171 | + // NOTE - all values within ics_data will be escaped automatically. |
|
| 172 | + $ics_data = apply_filters('FHEE__EED_Ical__download_ics_file_ics_data', $ics_data, $datetime); |
|
| 173 | + |
|
| 174 | + // Escape all ics data |
|
| 175 | + foreach ($ics_data as $key => $value) { |
|
| 176 | + // Description is escaped differently from all all values |
|
| 177 | + if ($key === 'DESCRIPTION') { |
|
| 178 | + $ics_data[ $key ] = EED_Ical::_escape_ICal_description(wp_strip_all_tags($value)); |
|
| 179 | + } else { |
|
| 180 | + $ics_data[ $key ] = EED_Ical::_escape_ICal_data($value); |
|
| 181 | + } |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + // Pull the organizer name from ics_data and remove it from the array. |
|
| 185 | + $organizer_name = isset($ics_data['ORGANIZER_NAME']) |
|
| 186 | + ? $ics_data['ORGANIZER_NAME'] |
|
| 187 | + : ''; |
|
| 188 | + unset($ics_data['ORGANIZER_NAME']); |
|
| 189 | + |
|
| 190 | + // set headers |
|
| 191 | + header('Content-type: text/calendar; charset=utf-8'); |
|
| 192 | + header('Content-Disposition: attachment; filename="' . $filename . '"'); |
|
| 193 | + header('Cache-Control: private, max-age=0, must-revalidate'); |
|
| 194 | + header('Pragma: public'); |
|
| 195 | + header('Content-Type: application/octet-stream'); |
|
| 196 | + header('Content-Type: application/force-download'); |
|
| 197 | + header('Cache-Control: no-cache, must-revalidate'); |
|
| 198 | + header('Content-Transfer-Encoding: binary'); |
|
| 199 | + header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // past date |
|
| 200 | + ini_set('zlib.output_compression', '0'); |
|
| 201 | + // echo the output |
|
| 202 | + echo "BEGIN:VCALENDAR\r\n"; |
|
| 203 | + echo "VERSION:2.0\r\n"; |
|
| 204 | + echo "PRODID:-//{$organizer_name}//NONSGML PDA Calendar Version 1.0//EN\r\n"; |
|
| 205 | + echo "CALSCALE:GREGORIAN\r\n"; |
|
| 206 | + echo "BEGIN:VEVENT\r\n"; |
|
| 207 | + |
|
| 208 | + // Output all remaining values from ics_data. |
|
| 209 | + foreach ($ics_data as $key => $value) { |
|
| 210 | + echo $key . ':' . $value . "\r\n"; // already escaped |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + echo "END:VEVENT\r\n"; |
|
| 214 | + echo "END:VCALENDAR\r\n"; |
|
| 215 | + } |
|
| 216 | + } |
|
| 217 | + } |
|
| 218 | + die(); |
|
| 219 | + } |
|
| 220 | + |
|
| 221 | + |
|
| 222 | + /** |
|
| 223 | + * _escape_ICal_data |
|
| 224 | + * |
|
| 225 | + * @param string $string |
|
| 226 | + * @return string |
|
| 227 | + */ |
|
| 228 | + private static function _escape_ICal_data($string = '') |
|
| 229 | + { |
|
| 230 | + return preg_replace('/([\,;])/', '\\\$1', $string); |
|
| 231 | + } |
|
| 232 | + |
|
| 233 | + |
|
| 234 | + /** |
|
| 235 | + * _escape_ICal_description |
|
| 236 | + * |
|
| 237 | + * @param string $description |
|
| 238 | + * @return string |
|
| 239 | + */ |
|
| 240 | + private static function _escape_ICal_description($description = '') |
|
| 241 | + { |
|
| 242 | + // Escape special chars within the description |
|
| 243 | + $description = EED_Ical::_escape_ICal_data($description); |
|
| 244 | + // Remove line breaks and output in iCal format |
|
| 245 | + return str_replace(["\r\n", "\n"], '\n', $description); |
|
| 246 | + } |
|
| 247 | 247 | } |
@@ -87,24 +87,24 @@ discard block |
||
| 87 | 87 | switch ($iCal_type) { |
| 88 | 88 | // submit buttons appear as buttons and are very compatible with a theme's style |
| 89 | 89 | case 'submit': |
| 90 | - $html .= '<form id="download-iCal-frm-' . $datetime->ID(); |
|
| 91 | - $html .= '" class="download-iCal-frm" action="' . $URL . '" method="post" >'; |
|
| 90 | + $html .= '<form id="download-iCal-frm-'.$datetime->ID(); |
|
| 91 | + $html .= '" class="download-iCal-frm" action="'.$URL.'" method="post" >'; |
|
| 92 | 92 | $html .= '<input type="submit" class="ee-ical-sbmt" value="" title="'; |
| 93 | - $html .= esc_html__('Add to iCal Calendar', 'event_espresso') . '"/>'; |
|
| 93 | + $html .= esc_html__('Add to iCal Calendar', 'event_espresso').'"/>'; |
|
| 94 | 94 | $html .= '</form>'; |
| 95 | 95 | break; |
| 96 | 96 | // buttons are just links that have been styled to appear as buttons, |
| 97 | 97 | // but may not be blend with a theme as well as submit buttons |
| 98 | 98 | case 'button': |
| 99 | - $html .= '<a class="ee-ical-btn small ee-button ee-roundish" href="' . $URL; |
|
| 100 | - $html .= '" title="' . esc_html__('Add to iCal Calendar', 'event_espresso') . '">'; |
|
| 99 | + $html .= '<a class="ee-ical-btn small ee-button ee-roundish" href="'.$URL; |
|
| 100 | + $html .= '" title="'.esc_html__('Add to iCal Calendar', 'event_espresso').'">'; |
|
| 101 | 101 | $html .= ' <span class="dashicons dashicons-calendar"></span>'; |
| 102 | 102 | $html .= '</a>'; |
| 103 | 103 | break; |
| 104 | 104 | // links are just links that use the calendar dashicon |
| 105 | 105 | case 'icon': |
| 106 | - $html .= '<a class="ee-ical-lnk" href="' . $URL . '" title="'; |
|
| 107 | - $html .= esc_html__('Add to iCal Calendar', 'event_espresso') . '">'; |
|
| 106 | + $html .= '<a class="ee-ical-lnk" href="'.$URL.'" title="'; |
|
| 107 | + $html .= esc_html__('Add to iCal Calendar', 'event_espresso').'">'; |
|
| 108 | 108 | $html .= ' <span class="dashicons dashicons-calendar"></span>'; |
| 109 | 109 | $html .= '</a>'; |
| 110 | 110 | break; |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | // Generate filename |
| 148 | - $filename = $event->slug() . '-' . $datetime->start_date('Y-m-d') . '.ics'; |
|
| 148 | + $filename = $event->slug().'-'.$datetime->start_date('Y-m-d').'.ics'; |
|
| 149 | 149 | |
| 150 | 150 | // Check the datetime status has not been cancelled and set the ics value accordingly |
| 151 | 151 | $status = $datetime->get_active_status(); |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | // Create array of ics details, escape strings, convert timestamps to ics format, etc |
| 155 | 155 | $ics_data = [ |
| 156 | 156 | 'ORGANIZER_NAME' => EE_Registry::instance()->CFG->organization->name, |
| 157 | - 'UID' => md5($event->name() . $event->ID() . $datetime->ID()), |
|
| 157 | + 'UID' => md5($event->name().$event->ID().$datetime->ID()), |
|
| 158 | 158 | 'ORGANIZER' => EE_Registry::instance()->CFG->organization->email, |
| 159 | 159 | 'DTSTAMP' => date(EED_Ical::iCal_datetime_format), |
| 160 | 160 | 'LOCATION' => $location, |
@@ -175,9 +175,9 @@ discard block |
||
| 175 | 175 | foreach ($ics_data as $key => $value) { |
| 176 | 176 | // Description is escaped differently from all all values |
| 177 | 177 | if ($key === 'DESCRIPTION') { |
| 178 | - $ics_data[ $key ] = EED_Ical::_escape_ICal_description(wp_strip_all_tags($value)); |
|
| 178 | + $ics_data[$key] = EED_Ical::_escape_ICal_description(wp_strip_all_tags($value)); |
|
| 179 | 179 | } else { |
| 180 | - $ics_data[ $key ] = EED_Ical::_escape_ICal_data($value); |
|
| 180 | + $ics_data[$key] = EED_Ical::_escape_ICal_data($value); |
|
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | |
| 190 | 190 | // set headers |
| 191 | 191 | header('Content-type: text/calendar; charset=utf-8'); |
| 192 | - header('Content-Disposition: attachment; filename="' . $filename . '"'); |
|
| 192 | + header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
| 193 | 193 | header('Cache-Control: private, max-age=0, must-revalidate'); |
| 194 | 194 | header('Pragma: public'); |
| 195 | 195 | header('Content-Type: application/octet-stream'); |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | |
| 208 | 208 | // Output all remaining values from ics_data. |
| 209 | 209 | foreach ($ics_data as $key => $value) { |
| 210 | - echo $key . ':' . $value . "\r\n"; // already escaped |
|
| 210 | + echo $key.':'.$value."\r\n"; // already escaped |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | echo "END:VEVENT\r\n"; |
@@ -14,24 +14,24 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | <div class="ee-registration-details-dv"> |
| 16 | 16 | <?php |
| 17 | - $registrations = $transaction->registrations(); |
|
| 18 | - $registrations = is_array($registrations) ? $registrations : []; |
|
| 19 | - $reg_count = count($registrations); |
|
| 20 | - $reg_cntr = 0; |
|
| 21 | - $event_name = ''; |
|
| 22 | - $wait_list = false; |
|
| 23 | - foreach ($registrations as $registration) { |
|
| 24 | - if (! $registration instanceof EE_Registration) { |
|
| 25 | - continue; |
|
| 26 | - } |
|
| 27 | - if ($event_name != $registration->event_name() && ! empty($event_name)) { ?> |
|
| 17 | + $registrations = $transaction->registrations(); |
|
| 18 | + $registrations = is_array($registrations) ? $registrations : []; |
|
| 19 | + $reg_count = count($registrations); |
|
| 20 | + $reg_cntr = 0; |
|
| 21 | + $event_name = ''; |
|
| 22 | + $wait_list = false; |
|
| 23 | + foreach ($registrations as $registration) { |
|
| 24 | + if (! $registration instanceof EE_Registration) { |
|
| 25 | + continue; |
|
| 26 | + } |
|
| 27 | + if ($event_name != $registration->event_name() && ! empty($event_name)) { ?> |
|
| 28 | 28 | </tbody> |
| 29 | 29 | </table> |
| 30 | 30 | <?php |
| 31 | - } |
|
| 32 | - $reg_cntr++; |
|
| 33 | - if ($event_name != $registration->event_name()) { |
|
| 34 | - ?> |
|
| 31 | + } |
|
| 32 | + $reg_cntr++; |
|
| 33 | + if ($event_name != $registration->event_name()) { |
|
| 34 | + ?> |
|
| 35 | 35 | <h5> |
| 36 | 36 | <span class="smaller-text grey-text"> |
| 37 | 37 | <?php esc_html_e('for', 'event_espresso'); ?> : |
@@ -54,23 +54,23 @@ discard block |
||
| 54 | 54 | </thead> |
| 55 | 55 | <tbody> |
| 56 | 56 | <?php |
| 57 | - } |
|
| 58 | - if ($is_primary || (! $is_primary && $reg_url_link == $registration->reg_url_link())) { ?> |
|
| 57 | + } |
|
| 58 | + if ($is_primary || (! $is_primary && $reg_url_link == $registration->reg_url_link())) { ?> |
|
| 59 | 59 | <tr> |
| 60 | 60 | <td width="40%"> |
| 61 | 61 | <?php |
| 62 | - if ($registration->attendee() instanceof EE_Attendee) { |
|
| 63 | - echo $registration->attendee()->full_name(true); |
|
| 64 | - } |
|
| 65 | - ?> |
|
| 62 | + if ($registration->attendee() instanceof EE_Attendee) { |
|
| 63 | + echo $registration->attendee()->full_name(true); |
|
| 64 | + } |
|
| 65 | + ?> |
|
| 66 | 66 | <p class="tiny-text" style="margin: .75em 0 0;"> |
| 67 | 67 | <?php if ($registration->count_question_groups()) { ?> |
| 68 | 68 | <a class="ee-icon-only-lnk" |
| 69 | 69 | href="<?php echo esc_url_raw($registration->edit_attendee_information_url()); ?>" |
| 70 | 70 | title="<?php esc_attr_e( |
| 71 | - 'Click here to edit Attendee Information', |
|
| 72 | - 'event_espresso' |
|
| 73 | - ); ?>" |
|
| 71 | + 'Click here to edit Attendee Information', |
|
| 72 | + 'event_espresso' |
|
| 73 | + ); ?>" |
|
| 74 | 74 | > |
| 75 | 75 | <span class="ee-icon ee-icon-user-edit"></span> |
| 76 | 76 | <?php esc_html_e('edit info', 'event_espresso'); ?> |
@@ -78,15 +78,15 @@ discard block |
||
| 78 | 78 | <?php } ?> |
| 79 | 79 | <a class="ee-resend-reg-confirmation-email ee-icon-only-lnk" |
| 80 | 80 | href="<?php echo esc_url_raw( |
| 81 | - add_query_arg( |
|
| 82 | - ['token' => $registration->reg_url_link(), 'resend_reg_confirmation' => 'true'], |
|
| 83 | - EE_Registry::instance()->CFG->core->thank_you_page_url() |
|
| 84 | - ) |
|
| 85 | - ); ?>" |
|
| 81 | + add_query_arg( |
|
| 82 | + ['token' => $registration->reg_url_link(), 'resend_reg_confirmation' => 'true'], |
|
| 83 | + EE_Registry::instance()->CFG->core->thank_you_page_url() |
|
| 84 | + ) |
|
| 85 | + ); ?>" |
|
| 86 | 86 | title="<?php esc_attr_e( |
| 87 | - 'Click here to resend the Registration Confirmation email', |
|
| 88 | - 'event_espresso' |
|
| 89 | - ); ?>" |
|
| 87 | + 'Click here to resend the Registration Confirmation email', |
|
| 88 | + 'event_espresso' |
|
| 89 | + ); ?>" |
|
| 90 | 90 | rel="<?php echo esc_url_raw($registration->reg_url_link()); ?>" |
| 91 | 91 | > |
| 92 | 92 | <span class="dashicons dashicons-email-alt"></span> |
@@ -100,27 +100,27 @@ discard block |
||
| 100 | 100 | <td width="35%" class="jst-left"> |
| 101 | 101 | <?php $registration->e_pretty_status(true) ?> |
| 102 | 102 | <?php |
| 103 | - if ($registration->status_ID() === EEM_Registration::status_id_wait_list) { |
|
| 104 | - $wait_list = true; |
|
| 105 | - } |
|
| 106 | - ?> |
|
| 103 | + if ($registration->status_ID() === EEM_Registration::status_id_wait_list) { |
|
| 104 | + $wait_list = true; |
|
| 105 | + } |
|
| 106 | + ?> |
|
| 107 | 107 | </td> |
| 108 | 108 | </tr> |
| 109 | 109 | <?php do_action( |
| 110 | - 'AHEE__thank_you_page_registration_details_template__after_registration_table_row', |
|
| 111 | - $registration |
|
| 112 | - ); ?> |
|
| 110 | + 'AHEE__thank_you_page_registration_details_template__after_registration_table_row', |
|
| 111 | + $registration |
|
| 112 | + ); ?> |
|
| 113 | 113 | <?php |
| 114 | - $event_name = $registration->event_name(); |
|
| 115 | - } |
|
| 116 | - if ($reg_cntr >= $reg_count) { |
|
| 117 | - ?> |
|
| 114 | + $event_name = $registration->event_name(); |
|
| 115 | + } |
|
| 116 | + if ($reg_cntr >= $reg_count) { |
|
| 117 | + ?> |
|
| 118 | 118 | </tbody> |
| 119 | 119 | </table> |
| 120 | 120 | <?php |
| 121 | - } |
|
| 122 | - } |
|
| 123 | - ?> |
|
| 121 | + } |
|
| 122 | + } |
|
| 123 | + ?> |
|
| 124 | 124 | <?php if ($is_primary && $SPCO_attendee_information_url) { ?> |
| 125 | 125 | <p class="small-text jst-rght"> |
| 126 | 126 | <a href='<?php echo esc_url_raw($SPCO_attendee_information_url) ?>'> |
@@ -129,22 +129,22 @@ discard block |
||
| 129 | 129 | </p> |
| 130 | 130 | <?php } ?> |
| 131 | 131 | <?php |
| 132 | - if ($wait_list) { |
|
| 133 | - echo apply_filters( |
|
| 134 | - 'AFEE__thank_you_page_registration_details_template__wait_list_notice', |
|
| 135 | - sprintf( |
|
| 136 | - esc_html__( |
|
| 137 | - '%1$sre: Wait List Registrations%2$sPlease note that the total cost listed below in the Transaction Details is for ALL registrations, including those that are on the wait list, even though they can not be currently paid for. If any spaces become available however, you may be notified by the Event admin and have the opportunity to secure the remaining tickets by making a payment for them.%3$s', |
|
| 138 | - 'event_espresso' |
|
| 139 | - ), |
|
| 140 | - '<h6 class="" style="margin-bottom:.25em;"><span class="dashicons dashicons-clipboard ee-icon-size-16 purple-text"></span>', |
|
| 141 | - '</h6 ><p class="ee-wait-list-notice">', |
|
| 142 | - '</p ><br />' |
|
| 143 | - ) |
|
| 144 | - ); |
|
| 145 | - } |
|
| 146 | - do_action('AHEE__thank_you_page_registration_details_template__after_registration_details'); |
|
| 147 | - ?> |
|
| 132 | + if ($wait_list) { |
|
| 133 | + echo apply_filters( |
|
| 134 | + 'AFEE__thank_you_page_registration_details_template__wait_list_notice', |
|
| 135 | + sprintf( |
|
| 136 | + esc_html__( |
|
| 137 | + '%1$sre: Wait List Registrations%2$sPlease note that the total cost listed below in the Transaction Details is for ALL registrations, including those that are on the wait list, even though they can not be currently paid for. If any spaces become available however, you may be notified by the Event admin and have the opportunity to secure the remaining tickets by making a payment for them.%3$s', |
|
| 138 | + 'event_espresso' |
|
| 139 | + ), |
|
| 140 | + '<h6 class="" style="margin-bottom:.25em;"><span class="dashicons dashicons-clipboard ee-icon-size-16 purple-text"></span>', |
|
| 141 | + '</h6 ><p class="ee-wait-list-notice">', |
|
| 142 | + '</p ><br />' |
|
| 143 | + ) |
|
| 144 | + ); |
|
| 145 | + } |
|
| 146 | + do_action('AHEE__thank_you_page_registration_details_template__after_registration_details'); |
|
| 147 | + ?> |
|
| 148 | 148 | |
| 149 | 149 | </div> |
| 150 | 150 | <!-- end of .registration-details --> |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | $event_name = ''; |
| 22 | 22 | $wait_list = false; |
| 23 | 23 | foreach ($registrations as $registration) { |
| 24 | - if (! $registration instanceof EE_Registration) { |
|
| 24 | + if ( ! $registration instanceof EE_Registration) { |
|
| 25 | 25 | continue; |
| 26 | 26 | } |
| 27 | 27 | if ($event_name != $registration->event_name() && ! empty($event_name)) { ?> |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | <tbody> |
| 56 | 56 | <?php |
| 57 | 57 | } |
| 58 | - if ($is_primary || (! $is_primary && $reg_url_link == $registration->reg_url_link())) { ?> |
|
| 58 | + if ($is_primary || ( ! $is_primary && $reg_url_link == $registration->reg_url_link())) { ?> |
|
| 59 | 59 | <tr> |
| 60 | 60 | <td width="40%"> |
| 61 | 61 | <?php |
@@ -28,8 +28,8 @@ discard block |
||
| 28 | 28 | <label><?php esc_html_e('Amount Owing: ', 'event_espresso'); ?></label> |
| 29 | 29 | </td> |
| 30 | 30 | <td class="<?php echo ($transaction->paid() == $transaction->total()) |
| 31 | - ? 'ee-transaction-paid' |
|
| 32 | - : 'ee-transaction-unpaid' ?>"> |
|
| 31 | + ? 'ee-transaction-paid' |
|
| 32 | + : 'ee-transaction-unpaid' ?>"> |
|
| 33 | 33 | <?php echo EEH_Template::format_currency($transaction->remaining()); // already escaped ?> |
| 34 | 34 | </td> |
| 35 | 35 | </tr> |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | </td> |
| 40 | 40 | <td> |
| 41 | 41 | <?php $transaction->e_pretty_status(true); |
| 42 | - if ($show_try_pay_again_link && ! $transaction->is_completed()) { ?> |
|
| 42 | + if ($show_try_pay_again_link && ! $transaction->is_completed()) { ?> |
|
| 43 | 43 | <span class="small-text"> |
| 44 | 44 | <a href='<?php echo esc_url_raw($SPCO_payment_options_url) ?>'> |
| 45 | 45 | <?php esc_html_e('View Payment Options', 'event_espresso'); ?> |
@@ -57,9 +57,9 @@ discard block |
||
| 57 | 57 | </td> |
| 58 | 58 | </tr> |
| 59 | 59 | <?php do_action( |
| 60 | - 'AHEE__thank_you_page_transaction_details_template__after_transaction_table_row', |
|
| 61 | - $transaction |
|
| 62 | - ); ?> |
|
| 60 | + 'AHEE__thank_you_page_transaction_details_template__after_transaction_table_row', |
|
| 61 | + $transaction |
|
| 62 | + ); ?> |
|
| 63 | 63 | </tbody> |
| 64 | 64 | </table> |
| 65 | 65 | |
@@ -11,613 +11,613 @@ discard block |
||
| 11 | 11 | class EED_Thank_You_Page extends EED_Module |
| 12 | 12 | { |
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * time in seconds to wait for the IPN to arrive before telling the registrant to bugger off ( 1200s = 20 minutes ) |
|
| 16 | - */ |
|
| 17 | - const IPN_wait_time = 1200; |
|
| 18 | - |
|
| 19 | - /** |
|
| 20 | - * The transaction specified by the reg_url_link passed from the Request, or from the Session |
|
| 21 | - * |
|
| 22 | - * @var EE_Transaction $_current_txn |
|
| 23 | - */ |
|
| 24 | - private $_current_txn; |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * @var EE_Registration $_primary_registrant |
|
| 28 | - */ |
|
| 29 | - private $_primary_registrant; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * The reg_url_link passed from the Request, or from the Session |
|
| 33 | - * |
|
| 34 | - * @var string $_reg_url_link |
|
| 35 | - */ |
|
| 36 | - private $_reg_url_link; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * whether the incoming reg_url_link is for the primary registrant or not |
|
| 40 | - * |
|
| 41 | - * @var boolean $_is_primary |
|
| 42 | - */ |
|
| 43 | - private $_is_primary; |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * The URL for revisiting the SPCO attendee information step |
|
| 47 | - * |
|
| 48 | - * @var string $_SPCO_attendee_information_url |
|
| 49 | - */ |
|
| 50 | - private $_SPCO_attendee_information_url; |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * The URL for revisiting the SPCO payment options step |
|
| 54 | - * |
|
| 55 | - * @var string $_SPCO_payment_options_url |
|
| 56 | - */ |
|
| 57 | - private $_SPCO_payment_options_url; |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * whether to display the Payment Options link |
|
| 61 | - * |
|
| 62 | - * @var boolean $_show_try_pay_again_link |
|
| 63 | - */ |
|
| 64 | - private $_show_try_pay_again_link = false; |
|
| 65 | - |
|
| 66 | - /** |
|
| 67 | - * whether payments are allowed at this time |
|
| 68 | - * |
|
| 69 | - * @var boolean $_payments_closed |
|
| 70 | - */ |
|
| 71 | - private $_payments_closed = false; |
|
| 72 | - |
|
| 73 | - /** |
|
| 74 | - * whether the selected payment method is Bank, Check , Invoice, etc |
|
| 75 | - * |
|
| 76 | - * @var boolean $_is_offline_payment_method |
|
| 77 | - */ |
|
| 78 | - private $_is_offline_payment_method = true; |
|
| 79 | - |
|
| 80 | - |
|
| 81 | - /** |
|
| 82 | - * @return EED_Module|EED_Thank_You_Page |
|
| 83 | - * @throws EE_Error |
|
| 84 | - * @throws ReflectionException |
|
| 85 | - */ |
|
| 86 | - public static function instance() |
|
| 87 | - { |
|
| 88 | - return parent::get_instance(__CLASS__); |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * set_hooks - for hooking into EE Core, modules, etc |
|
| 94 | - * |
|
| 95 | - * @return void |
|
| 96 | - */ |
|
| 97 | - public static function set_hooks() |
|
| 98 | - { |
|
| 99 | - add_action('wp_loaded', array('EED_Thank_You_Page', 'set_definitions'), 2); |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * set_hooks_admin - for hooking into EE Admin Core, modules, etc |
|
| 105 | - * |
|
| 106 | - * @return void |
|
| 107 | - */ |
|
| 108 | - public static function set_hooks_admin() |
|
| 109 | - { |
|
| 110 | - add_action( |
|
| 111 | - 'wp_ajax_espresso_resend_reg_confirmation_email', |
|
| 112 | - array('EED_Thank_You_Page', 'resend_reg_confirmation_email'), |
|
| 113 | - 10, |
|
| 114 | - 2 |
|
| 115 | - ); |
|
| 116 | - add_action( |
|
| 117 | - 'wp_ajax_nopriv_espresso_resend_reg_confirmation_email', |
|
| 118 | - array('EED_Thank_You_Page', 'resend_reg_confirmation_email'), |
|
| 119 | - 10, |
|
| 120 | - 2 |
|
| 121 | - ); |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - |
|
| 125 | - /** |
|
| 126 | - * set_definitions |
|
| 127 | - * |
|
| 128 | - * @return void |
|
| 129 | - */ |
|
| 130 | - public static function set_definitions() |
|
| 131 | - { |
|
| 132 | - define('THANK_YOU_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/'); |
|
| 133 | - define('THANK_YOU_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/'); |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - |
|
| 137 | - /** |
|
| 138 | - * get_txn |
|
| 139 | - * |
|
| 140 | - * @return EE_Transaction |
|
| 141 | - * @throws EE_Error |
|
| 142 | - * @throws ReflectionException |
|
| 143 | - */ |
|
| 144 | - public function get_txn() |
|
| 145 | - { |
|
| 146 | - if ($this->_current_txn instanceof EE_Transaction) { |
|
| 147 | - return $this->_current_txn; |
|
| 148 | - } |
|
| 149 | - $TXN_model = EE_Registry::instance()->load_model('Transaction'); |
|
| 150 | - if (! $TXN_model instanceof EEM_Transaction) { |
|
| 151 | - EE_Error::add_error( |
|
| 152 | - esc_html__('The transaction model could not be established.', 'event_espresso'), |
|
| 153 | - __FILE__, |
|
| 154 | - __FUNCTION__, |
|
| 155 | - __LINE__ |
|
| 156 | - ); |
|
| 157 | - return null; |
|
| 158 | - } |
|
| 159 | - // get the transaction. yes, we may have just loaded it, but it may have been updated, or this may be via an ajax request |
|
| 160 | - $this->_current_txn = $TXN_model->get_transaction_from_reg_url_link($this->_reg_url_link); |
|
| 161 | - // verify TXN |
|
| 162 | - if (WP_DEBUG && ! $this->_current_txn instanceof EE_Transaction) { |
|
| 163 | - EE_Error::add_error( |
|
| 164 | - esc_html__( |
|
| 165 | - 'No transaction information could be retrieved or the transaction data is not of the correct type.', |
|
| 166 | - 'event_espresso' |
|
| 167 | - ), |
|
| 168 | - __FILE__, |
|
| 169 | - __FUNCTION__, |
|
| 170 | - __LINE__ |
|
| 171 | - ); |
|
| 172 | - return null; |
|
| 173 | - } |
|
| 174 | - return $this->_current_txn; |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - |
|
| 178 | - /** |
|
| 179 | - * get_txn_payments |
|
| 180 | - * |
|
| 181 | - * @param int $since |
|
| 182 | - * @return EE_Payment[] |
|
| 183 | - * @throws EE_Error |
|
| 184 | - * @throws ReflectionException |
|
| 185 | - */ |
|
| 186 | - public function get_txn_payments($since = 0) |
|
| 187 | - { |
|
| 188 | - if (! $this->get_txn()) { |
|
| 189 | - return []; |
|
| 190 | - } |
|
| 191 | - $args = array('order_by' => array('PAY_timestamp' => 'ASC')); |
|
| 192 | - if ($since > 0) { |
|
| 193 | - $args[0] = array('PAY_timestamp' => array('>', $since)); |
|
| 194 | - } |
|
| 195 | - // get array of payments with most recent first |
|
| 196 | - return $this->_current_txn->payments($args); |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - |
|
| 200 | - /** |
|
| 201 | - * @return bool |
|
| 202 | - */ |
|
| 203 | - public function isOfflinePaymentMethod() |
|
| 204 | - { |
|
| 205 | - return $this->_is_offline_payment_method; |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - |
|
| 209 | - |
|
| 210 | - |
|
| 211 | - /** |
|
| 212 | - * get_reg_url_link |
|
| 213 | - * |
|
| 214 | - * @return void |
|
| 215 | - */ |
|
| 216 | - private function _get_reg_url_link() |
|
| 217 | - { |
|
| 218 | - if ($this->_reg_url_link) { |
|
| 219 | - return; |
|
| 220 | - } |
|
| 221 | - // check for reg_url_link |
|
| 222 | - $reg_url_link = self::getRequest()->getRequestParam('e_reg_url_link'); |
|
| 223 | - // only do thank you page stuff if we have a REG_url_link in the url |
|
| 224 | - if (WP_DEBUG && ! $reg_url_link) { |
|
| 225 | - EE_Error::add_error( |
|
| 226 | - esc_html__( |
|
| 227 | - 'No transaction information could be retrieved because the registration URL link is missing or invalid.', |
|
| 228 | - 'event_espresso' |
|
| 229 | - ), |
|
| 230 | - __FILE__, |
|
| 231 | - __FUNCTION__, |
|
| 232 | - __LINE__ |
|
| 233 | - ); |
|
| 234 | - } |
|
| 235 | - $this->set_reg_url_link($reg_url_link); |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - |
|
| 239 | - /** |
|
| 240 | - * set_reg_url_link |
|
| 241 | - * |
|
| 242 | - * @param string $reg_url_link |
|
| 243 | - */ |
|
| 244 | - public function set_reg_url_link($reg_url_link = null) |
|
| 245 | - { |
|
| 246 | - $this->_reg_url_link = ! empty($reg_url_link) ? $reg_url_link : $this->_reg_url_link; |
|
| 247 | - } |
|
| 248 | - |
|
| 249 | - |
|
| 250 | - /** |
|
| 251 | - * run - initial module setup |
|
| 252 | - * this method is primarily used for activating resources in the EE_Front_Controller thru the use of filters |
|
| 253 | - * |
|
| 254 | - * @param WP $WP |
|
| 255 | - * @return void |
|
| 256 | - */ |
|
| 257 | - public function run($WP) |
|
| 258 | - { |
|
| 259 | - } |
|
| 260 | - |
|
| 261 | - |
|
| 262 | - /** |
|
| 263 | - * load_resources |
|
| 264 | - * |
|
| 265 | - * @return void |
|
| 266 | - * @throws EE_Error |
|
| 267 | - * @throws ReflectionException |
|
| 268 | - */ |
|
| 269 | - public function load_resources() |
|
| 270 | - { |
|
| 271 | - $this->_get_reg_url_link(); |
|
| 272 | - // resend_reg_confirmation_email ? |
|
| 273 | - if (self::getRequest()->requestParamIsSet('resend')) { |
|
| 274 | - EED_Thank_You_Page::resend_reg_confirmation_email(); |
|
| 275 | - } |
|
| 276 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
| 277 | - $this->_translate_strings(); |
|
| 278 | - // load assets |
|
| 279 | - add_action('wp_enqueue_scripts', array($this, 'load_js'), 10); |
|
| 280 | - } |
|
| 281 | - |
|
| 282 | - |
|
| 283 | - /** |
|
| 284 | - * load_js |
|
| 285 | - * |
|
| 286 | - * @return void |
|
| 287 | - */ |
|
| 288 | - protected function _translate_strings() |
|
| 289 | - { |
|
| 290 | - EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->_reg_url_link; |
|
| 291 | - EE_Registry::$i18n_js_strings['initial_access'] = time(); |
|
| 292 | - EE_Registry::$i18n_js_strings['IPN_wait_time'] = EED_Thank_You_Page::IPN_wait_time; |
|
| 293 | - EE_Registry::$i18n_js_strings['TXN_complete'] = EEM_Transaction::complete_status_code; |
|
| 294 | - EE_Registry::$i18n_js_strings['TXN_incomplete'] = EEM_Transaction::incomplete_status_code; |
|
| 295 | - EE_Registry::$i18n_js_strings['checking_for_new_payments'] = __( |
|
| 296 | - 'checking for new payments...', |
|
| 297 | - 'event_espresso' |
|
| 298 | - ); |
|
| 299 | - EE_Registry::$i18n_js_strings['loading_payment_info'] = __( |
|
| 300 | - 'loading payment information...', |
|
| 301 | - 'event_espresso' |
|
| 302 | - ); |
|
| 303 | - EE_Registry::$i18n_js_strings['server_error'] = __( |
|
| 304 | - 'An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again.', |
|
| 305 | - 'event_espresso' |
|
| 306 | - ); |
|
| 307 | - EE_Registry::$i18n_js_strings['slow_IPN'] = apply_filters( |
|
| 308 | - 'EED_Thank_You_Page__load_js__slow_IPN', |
|
| 309 | - sprintf( |
|
| 310 | - __( |
|
| 311 | - '%sThe Payment Notification appears to be taking longer than usual to arrive. Maybe check back later or just wait for your payment and registration confirmation results to be sent to you via email. We apologize for any inconvenience this may have caused.%s', |
|
| 312 | - 'event_espresso' |
|
| 313 | - ), |
|
| 314 | - '<div id="espresso-thank-you-page-slow-IPN-dv" class="ee-attention jst-left">', |
|
| 315 | - '</div>' |
|
| 316 | - ) |
|
| 317 | - ); |
|
| 318 | - } |
|
| 319 | - |
|
| 320 | - |
|
| 321 | - /** |
|
| 322 | - * load_js |
|
| 323 | - * |
|
| 324 | - * @return void |
|
| 325 | - */ |
|
| 326 | - public function load_js() |
|
| 327 | - { |
|
| 328 | - wp_register_script( |
|
| 329 | - 'thank_you_page', |
|
| 330 | - THANK_YOU_ASSETS_URL . 'thank_you_page.js', |
|
| 331 | - array('espresso_core', 'heartbeat'), |
|
| 332 | - EVENT_ESPRESSO_VERSION, |
|
| 333 | - true |
|
| 334 | - ); |
|
| 335 | - wp_enqueue_script('thank_you_page'); |
|
| 336 | - wp_enqueue_style('espresso_default'); |
|
| 337 | - } |
|
| 338 | - |
|
| 339 | - |
|
| 340 | - /** |
|
| 341 | - * init |
|
| 342 | - * |
|
| 343 | - * @return void |
|
| 344 | - * @throws EE_Error |
|
| 345 | - * @throws ReflectionException |
|
| 346 | - */ |
|
| 347 | - public function init() |
|
| 348 | - { |
|
| 349 | - $this->_get_reg_url_link(); |
|
| 350 | - if (! $this->get_txn()) { |
|
| 351 | - echo EEH_HTML::div( |
|
| 352 | - EEH_HTML::h4(esc_html__('We\'re sorry...', 'event_espresso')) . |
|
| 353 | - sprintf( |
|
| 354 | - esc_html__( |
|
| 355 | - 'This is a system page for displaying transaction information after a purchase.%1$sYou are most likely seeing this notice because you have navigated to this page%1$sthrough some means other than completing a transaction.%1$sSorry for the disappointment, but you will most likely find nothing of interest here.%1$s%1$s', |
|
| 356 | - 'event_espresso' |
|
| 357 | - ), |
|
| 358 | - '<br/>' |
|
| 359 | - ), |
|
| 360 | - '', |
|
| 361 | - 'ee-attention' |
|
| 362 | - ); |
|
| 363 | - return; |
|
| 364 | - } |
|
| 365 | - // if we've made it to the Thank You page, then let's toggle any "Failed" transactions to "Incomplete" |
|
| 366 | - if ($this->_current_txn->status_ID() === EEM_Transaction::failed_status_code) { |
|
| 367 | - $this->_current_txn->set_status(EEM_Transaction::incomplete_status_code); |
|
| 368 | - $this->_current_txn->save(); |
|
| 369 | - } |
|
| 370 | - $this->_primary_registrant = $this->_current_txn->primary_registration() instanceof EE_Registration |
|
| 371 | - ? $this->_current_txn->primary_registration() |
|
| 372 | - : null; |
|
| 373 | - $this->_is_primary = $this->_primary_registrant->reg_url_link() === $this->_reg_url_link; |
|
| 374 | - $show_try_pay_again_link_default = apply_filters( |
|
| 375 | - 'AFEE__EED_Thank_You_Page__init__show_try_pay_again_link_default', |
|
| 376 | - true |
|
| 377 | - ); |
|
| 378 | - $this->_show_try_pay_again_link = $show_try_pay_again_link_default; |
|
| 379 | - // txn status ? |
|
| 380 | - if ($this->_current_txn->is_completed()) { |
|
| 381 | - $this->_show_try_pay_again_link = $show_try_pay_again_link_default; |
|
| 382 | - } elseif ( |
|
| 383 | - $this->_current_txn->is_incomplete() |
|
| 384 | - && ($this->_primary_registrant->is_approved() |
|
| 385 | - || $this->_primary_registrant->is_pending_payment()) |
|
| 386 | - ) { |
|
| 387 | - $this->_show_try_pay_again_link = true; |
|
| 388 | - } elseif ($this->_primary_registrant->is_approved() || $this->_primary_registrant->is_pending_payment()) { |
|
| 389 | - // its pending |
|
| 390 | - $this->_show_try_pay_again_link = isset( |
|
| 391 | - EE_Registry::instance()->CFG->registration->show_pending_payment_options |
|
| 392 | - ) |
|
| 393 | - && EE_Registry::instance()->CFG |
|
| 394 | - ->registration->show_pending_payment_options |
|
| 395 | - ? true |
|
| 396 | - : $show_try_pay_again_link_default; |
|
| 397 | - } |
|
| 398 | - $this->_payments_closed = ! $this->_current_txn->payment_method() instanceof EE_Payment_Method; |
|
| 399 | - $this->_is_offline_payment_method = false; |
|
| 400 | - if ( |
|
| 14 | + /** |
|
| 15 | + * time in seconds to wait for the IPN to arrive before telling the registrant to bugger off ( 1200s = 20 minutes ) |
|
| 16 | + */ |
|
| 17 | + const IPN_wait_time = 1200; |
|
| 18 | + |
|
| 19 | + /** |
|
| 20 | + * The transaction specified by the reg_url_link passed from the Request, or from the Session |
|
| 21 | + * |
|
| 22 | + * @var EE_Transaction $_current_txn |
|
| 23 | + */ |
|
| 24 | + private $_current_txn; |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * @var EE_Registration $_primary_registrant |
|
| 28 | + */ |
|
| 29 | + private $_primary_registrant; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * The reg_url_link passed from the Request, or from the Session |
|
| 33 | + * |
|
| 34 | + * @var string $_reg_url_link |
|
| 35 | + */ |
|
| 36 | + private $_reg_url_link; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * whether the incoming reg_url_link is for the primary registrant or not |
|
| 40 | + * |
|
| 41 | + * @var boolean $_is_primary |
|
| 42 | + */ |
|
| 43 | + private $_is_primary; |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * The URL for revisiting the SPCO attendee information step |
|
| 47 | + * |
|
| 48 | + * @var string $_SPCO_attendee_information_url |
|
| 49 | + */ |
|
| 50 | + private $_SPCO_attendee_information_url; |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * The URL for revisiting the SPCO payment options step |
|
| 54 | + * |
|
| 55 | + * @var string $_SPCO_payment_options_url |
|
| 56 | + */ |
|
| 57 | + private $_SPCO_payment_options_url; |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * whether to display the Payment Options link |
|
| 61 | + * |
|
| 62 | + * @var boolean $_show_try_pay_again_link |
|
| 63 | + */ |
|
| 64 | + private $_show_try_pay_again_link = false; |
|
| 65 | + |
|
| 66 | + /** |
|
| 67 | + * whether payments are allowed at this time |
|
| 68 | + * |
|
| 69 | + * @var boolean $_payments_closed |
|
| 70 | + */ |
|
| 71 | + private $_payments_closed = false; |
|
| 72 | + |
|
| 73 | + /** |
|
| 74 | + * whether the selected payment method is Bank, Check , Invoice, etc |
|
| 75 | + * |
|
| 76 | + * @var boolean $_is_offline_payment_method |
|
| 77 | + */ |
|
| 78 | + private $_is_offline_payment_method = true; |
|
| 79 | + |
|
| 80 | + |
|
| 81 | + /** |
|
| 82 | + * @return EED_Module|EED_Thank_You_Page |
|
| 83 | + * @throws EE_Error |
|
| 84 | + * @throws ReflectionException |
|
| 85 | + */ |
|
| 86 | + public static function instance() |
|
| 87 | + { |
|
| 88 | + return parent::get_instance(__CLASS__); |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * set_hooks - for hooking into EE Core, modules, etc |
|
| 94 | + * |
|
| 95 | + * @return void |
|
| 96 | + */ |
|
| 97 | + public static function set_hooks() |
|
| 98 | + { |
|
| 99 | + add_action('wp_loaded', array('EED_Thank_You_Page', 'set_definitions'), 2); |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * set_hooks_admin - for hooking into EE Admin Core, modules, etc |
|
| 105 | + * |
|
| 106 | + * @return void |
|
| 107 | + */ |
|
| 108 | + public static function set_hooks_admin() |
|
| 109 | + { |
|
| 110 | + add_action( |
|
| 111 | + 'wp_ajax_espresso_resend_reg_confirmation_email', |
|
| 112 | + array('EED_Thank_You_Page', 'resend_reg_confirmation_email'), |
|
| 113 | + 10, |
|
| 114 | + 2 |
|
| 115 | + ); |
|
| 116 | + add_action( |
|
| 117 | + 'wp_ajax_nopriv_espresso_resend_reg_confirmation_email', |
|
| 118 | + array('EED_Thank_You_Page', 'resend_reg_confirmation_email'), |
|
| 119 | + 10, |
|
| 120 | + 2 |
|
| 121 | + ); |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + |
|
| 125 | + /** |
|
| 126 | + * set_definitions |
|
| 127 | + * |
|
| 128 | + * @return void |
|
| 129 | + */ |
|
| 130 | + public static function set_definitions() |
|
| 131 | + { |
|
| 132 | + define('THANK_YOU_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/'); |
|
| 133 | + define('THANK_YOU_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/'); |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + |
|
| 137 | + /** |
|
| 138 | + * get_txn |
|
| 139 | + * |
|
| 140 | + * @return EE_Transaction |
|
| 141 | + * @throws EE_Error |
|
| 142 | + * @throws ReflectionException |
|
| 143 | + */ |
|
| 144 | + public function get_txn() |
|
| 145 | + { |
|
| 146 | + if ($this->_current_txn instanceof EE_Transaction) { |
|
| 147 | + return $this->_current_txn; |
|
| 148 | + } |
|
| 149 | + $TXN_model = EE_Registry::instance()->load_model('Transaction'); |
|
| 150 | + if (! $TXN_model instanceof EEM_Transaction) { |
|
| 151 | + EE_Error::add_error( |
|
| 152 | + esc_html__('The transaction model could not be established.', 'event_espresso'), |
|
| 153 | + __FILE__, |
|
| 154 | + __FUNCTION__, |
|
| 155 | + __LINE__ |
|
| 156 | + ); |
|
| 157 | + return null; |
|
| 158 | + } |
|
| 159 | + // get the transaction. yes, we may have just loaded it, but it may have been updated, or this may be via an ajax request |
|
| 160 | + $this->_current_txn = $TXN_model->get_transaction_from_reg_url_link($this->_reg_url_link); |
|
| 161 | + // verify TXN |
|
| 162 | + if (WP_DEBUG && ! $this->_current_txn instanceof EE_Transaction) { |
|
| 163 | + EE_Error::add_error( |
|
| 164 | + esc_html__( |
|
| 165 | + 'No transaction information could be retrieved or the transaction data is not of the correct type.', |
|
| 166 | + 'event_espresso' |
|
| 167 | + ), |
|
| 168 | + __FILE__, |
|
| 169 | + __FUNCTION__, |
|
| 170 | + __LINE__ |
|
| 171 | + ); |
|
| 172 | + return null; |
|
| 173 | + } |
|
| 174 | + return $this->_current_txn; |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + |
|
| 178 | + /** |
|
| 179 | + * get_txn_payments |
|
| 180 | + * |
|
| 181 | + * @param int $since |
|
| 182 | + * @return EE_Payment[] |
|
| 183 | + * @throws EE_Error |
|
| 184 | + * @throws ReflectionException |
|
| 185 | + */ |
|
| 186 | + public function get_txn_payments($since = 0) |
|
| 187 | + { |
|
| 188 | + if (! $this->get_txn()) { |
|
| 189 | + return []; |
|
| 190 | + } |
|
| 191 | + $args = array('order_by' => array('PAY_timestamp' => 'ASC')); |
|
| 192 | + if ($since > 0) { |
|
| 193 | + $args[0] = array('PAY_timestamp' => array('>', $since)); |
|
| 194 | + } |
|
| 195 | + // get array of payments with most recent first |
|
| 196 | + return $this->_current_txn->payments($args); |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + |
|
| 200 | + /** |
|
| 201 | + * @return bool |
|
| 202 | + */ |
|
| 203 | + public function isOfflinePaymentMethod() |
|
| 204 | + { |
|
| 205 | + return $this->_is_offline_payment_method; |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + |
|
| 209 | + |
|
| 210 | + |
|
| 211 | + /** |
|
| 212 | + * get_reg_url_link |
|
| 213 | + * |
|
| 214 | + * @return void |
|
| 215 | + */ |
|
| 216 | + private function _get_reg_url_link() |
|
| 217 | + { |
|
| 218 | + if ($this->_reg_url_link) { |
|
| 219 | + return; |
|
| 220 | + } |
|
| 221 | + // check for reg_url_link |
|
| 222 | + $reg_url_link = self::getRequest()->getRequestParam('e_reg_url_link'); |
|
| 223 | + // only do thank you page stuff if we have a REG_url_link in the url |
|
| 224 | + if (WP_DEBUG && ! $reg_url_link) { |
|
| 225 | + EE_Error::add_error( |
|
| 226 | + esc_html__( |
|
| 227 | + 'No transaction information could be retrieved because the registration URL link is missing or invalid.', |
|
| 228 | + 'event_espresso' |
|
| 229 | + ), |
|
| 230 | + __FILE__, |
|
| 231 | + __FUNCTION__, |
|
| 232 | + __LINE__ |
|
| 233 | + ); |
|
| 234 | + } |
|
| 235 | + $this->set_reg_url_link($reg_url_link); |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + |
|
| 239 | + /** |
|
| 240 | + * set_reg_url_link |
|
| 241 | + * |
|
| 242 | + * @param string $reg_url_link |
|
| 243 | + */ |
|
| 244 | + public function set_reg_url_link($reg_url_link = null) |
|
| 245 | + { |
|
| 246 | + $this->_reg_url_link = ! empty($reg_url_link) ? $reg_url_link : $this->_reg_url_link; |
|
| 247 | + } |
|
| 248 | + |
|
| 249 | + |
|
| 250 | + /** |
|
| 251 | + * run - initial module setup |
|
| 252 | + * this method is primarily used for activating resources in the EE_Front_Controller thru the use of filters |
|
| 253 | + * |
|
| 254 | + * @param WP $WP |
|
| 255 | + * @return void |
|
| 256 | + */ |
|
| 257 | + public function run($WP) |
|
| 258 | + { |
|
| 259 | + } |
|
| 260 | + |
|
| 261 | + |
|
| 262 | + /** |
|
| 263 | + * load_resources |
|
| 264 | + * |
|
| 265 | + * @return void |
|
| 266 | + * @throws EE_Error |
|
| 267 | + * @throws ReflectionException |
|
| 268 | + */ |
|
| 269 | + public function load_resources() |
|
| 270 | + { |
|
| 271 | + $this->_get_reg_url_link(); |
|
| 272 | + // resend_reg_confirmation_email ? |
|
| 273 | + if (self::getRequest()->requestParamIsSet('resend')) { |
|
| 274 | + EED_Thank_You_Page::resend_reg_confirmation_email(); |
|
| 275 | + } |
|
| 276 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
| 277 | + $this->_translate_strings(); |
|
| 278 | + // load assets |
|
| 279 | + add_action('wp_enqueue_scripts', array($this, 'load_js'), 10); |
|
| 280 | + } |
|
| 281 | + |
|
| 282 | + |
|
| 283 | + /** |
|
| 284 | + * load_js |
|
| 285 | + * |
|
| 286 | + * @return void |
|
| 287 | + */ |
|
| 288 | + protected function _translate_strings() |
|
| 289 | + { |
|
| 290 | + EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->_reg_url_link; |
|
| 291 | + EE_Registry::$i18n_js_strings['initial_access'] = time(); |
|
| 292 | + EE_Registry::$i18n_js_strings['IPN_wait_time'] = EED_Thank_You_Page::IPN_wait_time; |
|
| 293 | + EE_Registry::$i18n_js_strings['TXN_complete'] = EEM_Transaction::complete_status_code; |
|
| 294 | + EE_Registry::$i18n_js_strings['TXN_incomplete'] = EEM_Transaction::incomplete_status_code; |
|
| 295 | + EE_Registry::$i18n_js_strings['checking_for_new_payments'] = __( |
|
| 296 | + 'checking for new payments...', |
|
| 297 | + 'event_espresso' |
|
| 298 | + ); |
|
| 299 | + EE_Registry::$i18n_js_strings['loading_payment_info'] = __( |
|
| 300 | + 'loading payment information...', |
|
| 301 | + 'event_espresso' |
|
| 302 | + ); |
|
| 303 | + EE_Registry::$i18n_js_strings['server_error'] = __( |
|
| 304 | + 'An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again.', |
|
| 305 | + 'event_espresso' |
|
| 306 | + ); |
|
| 307 | + EE_Registry::$i18n_js_strings['slow_IPN'] = apply_filters( |
|
| 308 | + 'EED_Thank_You_Page__load_js__slow_IPN', |
|
| 309 | + sprintf( |
|
| 310 | + __( |
|
| 311 | + '%sThe Payment Notification appears to be taking longer than usual to arrive. Maybe check back later or just wait for your payment and registration confirmation results to be sent to you via email. We apologize for any inconvenience this may have caused.%s', |
|
| 312 | + 'event_espresso' |
|
| 313 | + ), |
|
| 314 | + '<div id="espresso-thank-you-page-slow-IPN-dv" class="ee-attention jst-left">', |
|
| 315 | + '</div>' |
|
| 316 | + ) |
|
| 317 | + ); |
|
| 318 | + } |
|
| 319 | + |
|
| 320 | + |
|
| 321 | + /** |
|
| 322 | + * load_js |
|
| 323 | + * |
|
| 324 | + * @return void |
|
| 325 | + */ |
|
| 326 | + public function load_js() |
|
| 327 | + { |
|
| 328 | + wp_register_script( |
|
| 329 | + 'thank_you_page', |
|
| 330 | + THANK_YOU_ASSETS_URL . 'thank_you_page.js', |
|
| 331 | + array('espresso_core', 'heartbeat'), |
|
| 332 | + EVENT_ESPRESSO_VERSION, |
|
| 333 | + true |
|
| 334 | + ); |
|
| 335 | + wp_enqueue_script('thank_you_page'); |
|
| 336 | + wp_enqueue_style('espresso_default'); |
|
| 337 | + } |
|
| 338 | + |
|
| 339 | + |
|
| 340 | + /** |
|
| 341 | + * init |
|
| 342 | + * |
|
| 343 | + * @return void |
|
| 344 | + * @throws EE_Error |
|
| 345 | + * @throws ReflectionException |
|
| 346 | + */ |
|
| 347 | + public function init() |
|
| 348 | + { |
|
| 349 | + $this->_get_reg_url_link(); |
|
| 350 | + if (! $this->get_txn()) { |
|
| 351 | + echo EEH_HTML::div( |
|
| 352 | + EEH_HTML::h4(esc_html__('We\'re sorry...', 'event_espresso')) . |
|
| 353 | + sprintf( |
|
| 354 | + esc_html__( |
|
| 355 | + 'This is a system page for displaying transaction information after a purchase.%1$sYou are most likely seeing this notice because you have navigated to this page%1$sthrough some means other than completing a transaction.%1$sSorry for the disappointment, but you will most likely find nothing of interest here.%1$s%1$s', |
|
| 356 | + 'event_espresso' |
|
| 357 | + ), |
|
| 358 | + '<br/>' |
|
| 359 | + ), |
|
| 360 | + '', |
|
| 361 | + 'ee-attention' |
|
| 362 | + ); |
|
| 363 | + return; |
|
| 364 | + } |
|
| 365 | + // if we've made it to the Thank You page, then let's toggle any "Failed" transactions to "Incomplete" |
|
| 366 | + if ($this->_current_txn->status_ID() === EEM_Transaction::failed_status_code) { |
|
| 367 | + $this->_current_txn->set_status(EEM_Transaction::incomplete_status_code); |
|
| 368 | + $this->_current_txn->save(); |
|
| 369 | + } |
|
| 370 | + $this->_primary_registrant = $this->_current_txn->primary_registration() instanceof EE_Registration |
|
| 371 | + ? $this->_current_txn->primary_registration() |
|
| 372 | + : null; |
|
| 373 | + $this->_is_primary = $this->_primary_registrant->reg_url_link() === $this->_reg_url_link; |
|
| 374 | + $show_try_pay_again_link_default = apply_filters( |
|
| 375 | + 'AFEE__EED_Thank_You_Page__init__show_try_pay_again_link_default', |
|
| 376 | + true |
|
| 377 | + ); |
|
| 378 | + $this->_show_try_pay_again_link = $show_try_pay_again_link_default; |
|
| 379 | + // txn status ? |
|
| 380 | + if ($this->_current_txn->is_completed()) { |
|
| 381 | + $this->_show_try_pay_again_link = $show_try_pay_again_link_default; |
|
| 382 | + } elseif ( |
|
| 383 | + $this->_current_txn->is_incomplete() |
|
| 384 | + && ($this->_primary_registrant->is_approved() |
|
| 385 | + || $this->_primary_registrant->is_pending_payment()) |
|
| 386 | + ) { |
|
| 387 | + $this->_show_try_pay_again_link = true; |
|
| 388 | + } elseif ($this->_primary_registrant->is_approved() || $this->_primary_registrant->is_pending_payment()) { |
|
| 389 | + // its pending |
|
| 390 | + $this->_show_try_pay_again_link = isset( |
|
| 391 | + EE_Registry::instance()->CFG->registration->show_pending_payment_options |
|
| 392 | + ) |
|
| 393 | + && EE_Registry::instance()->CFG |
|
| 394 | + ->registration->show_pending_payment_options |
|
| 395 | + ? true |
|
| 396 | + : $show_try_pay_again_link_default; |
|
| 397 | + } |
|
| 398 | + $this->_payments_closed = ! $this->_current_txn->payment_method() instanceof EE_Payment_Method; |
|
| 399 | + $this->_is_offline_payment_method = false; |
|
| 400 | + if ( |
|
| 401 | 401 | // if payment method is unknown |
| 402 | - ! $this->_current_txn->payment_method() instanceof EE_Payment_Method |
|
| 403 | - || ( |
|
| 404 | - // or is an offline payment method |
|
| 405 | - $this->_current_txn->payment_method() instanceof EE_Payment_Method |
|
| 406 | - && $this->_current_txn->payment_method()->is_off_line() |
|
| 407 | - ) |
|
| 408 | - ) { |
|
| 409 | - $this->_is_offline_payment_method = true; |
|
| 410 | - } |
|
| 411 | - // link to SPCO |
|
| 412 | - $revisit_spco_url = add_query_arg( |
|
| 413 | - array('ee' => '_register', 'revisit' => true, 'e_reg_url_link' => $this->_reg_url_link), |
|
| 414 | - EE_Registry::instance()->CFG->core->reg_page_url() |
|
| 415 | - ); |
|
| 416 | - // link to SPCO payment_options |
|
| 417 | - $this->_SPCO_payment_options_url = $this->_primary_registrant instanceof EE_Registration |
|
| 418 | - ? $this->_primary_registrant->payment_overview_url() |
|
| 419 | - : add_query_arg( |
|
| 420 | - array('step' => 'payment_options'), |
|
| 421 | - $revisit_spco_url |
|
| 422 | - ); |
|
| 423 | - // link to SPCO attendee_information |
|
| 424 | - $this->_SPCO_attendee_information_url = $this->_primary_registrant instanceof EE_Registration |
|
| 425 | - ? $this->_primary_registrant->edit_attendee_information_url() |
|
| 426 | - : false; |
|
| 427 | - do_action('AHEE__EED_Thank_You_Page__init_end', $this->_current_txn); |
|
| 428 | - // set no cache headers and constants |
|
| 429 | - EE_System::do_not_cache(); |
|
| 430 | - } |
|
| 431 | - |
|
| 432 | - |
|
| 433 | - /** |
|
| 434 | - * display_thank_you_page_results |
|
| 435 | - * |
|
| 436 | - * @return string |
|
| 437 | - * @throws EE_Error |
|
| 438 | - * @throws ReflectionException |
|
| 439 | - */ |
|
| 440 | - public function thank_you_page_results() |
|
| 441 | - { |
|
| 442 | - $this->init(); |
|
| 443 | - if (! $this->_current_txn instanceof EE_Transaction) { |
|
| 444 | - return EE_Error::get_notices(); |
|
| 445 | - } |
|
| 446 | - // link to receipt |
|
| 447 | - $template_args['TXN_receipt_url'] = $this->_current_txn->receipt_url(); |
|
| 448 | - if (! empty($template_args['TXN_receipt_url'])) { |
|
| 449 | - $template_args['order_conf_desc'] = esc_html__( |
|
| 450 | - '%1$sCongratulations%2$sYour registration has been successfully processed.%3$sCheck your email for your registration confirmation or click the button below to view / download / print a full description of your purchases and registration information.', |
|
| 451 | - 'event_espresso' |
|
| 452 | - ); |
|
| 453 | - } else { |
|
| 454 | - $template_args['order_conf_desc'] = esc_html__( |
|
| 455 | - '%1$sCongratulations%2$sYour registration has been successfully processed.%3$sCheck your email for your registration confirmation.', |
|
| 456 | - 'event_espresso' |
|
| 457 | - ); |
|
| 458 | - } |
|
| 459 | - $template_args['transaction'] = $this->_current_txn; |
|
| 460 | - $template_args['revisit'] = self::getRequest()->getRequestParam('revisit', false, 'bool'); |
|
| 461 | - add_action('AHEE__thank_you_page_overview_template__content', array($this, 'get_registration_details')); |
|
| 462 | - if ($this->_is_primary && ! $this->_current_txn->is_free()) { |
|
| 463 | - add_action('AHEE__thank_you_page_overview_template__content', array($this, 'get_ajax_content')); |
|
| 464 | - } |
|
| 465 | - return EEH_Template::locate_template( |
|
| 466 | - THANK_YOU_TEMPLATES_PATH . 'thank-you-page-overview.template.php', |
|
| 467 | - $template_args |
|
| 468 | - ); |
|
| 469 | - } |
|
| 470 | - |
|
| 471 | - |
|
| 472 | - /** |
|
| 473 | - * _update_server_wait_time |
|
| 474 | - * |
|
| 475 | - * @param array $thank_you_page_data thank you page portion of the incoming JSON array from the WP heartbeat data |
|
| 476 | - * @return array |
|
| 477 | - * @throws EE_Error |
|
| 478 | - * @throws ReflectionException |
|
| 479 | - */ |
|
| 480 | - private function _update_server_wait_time($thank_you_page_data = array()) |
|
| 481 | - { |
|
| 482 | - $response['espresso_thank_you_page'] = array( |
|
| 483 | - 'still_waiting' => isset($thank_you_page_data['initial_access']) |
|
| 484 | - ? time() - $thank_you_page_data['initial_access'] |
|
| 485 | - : 0, |
|
| 486 | - 'txn_status' => $this->_current_txn->status_ID(), |
|
| 487 | - ); |
|
| 488 | - return $response; |
|
| 489 | - } |
|
| 490 | - |
|
| 491 | - |
|
| 492 | - /** |
|
| 493 | - * get_registration_details |
|
| 494 | - * |
|
| 495 | - * @throws EE_Error |
|
| 496 | - */ |
|
| 497 | - public function get_registration_details() |
|
| 498 | - { |
|
| 499 | - // prepare variables for displaying |
|
| 500 | - $template_args = array(); |
|
| 501 | - $template_args['transaction'] = $this->_current_txn; |
|
| 502 | - $template_args['reg_url_link'] = $this->_reg_url_link; |
|
| 503 | - $template_args['is_primary'] = $this->_is_primary; |
|
| 504 | - $template_args['SPCO_attendee_information_url'] = $this->_SPCO_attendee_information_url; |
|
| 505 | - $template_args['resend_reg_confirmation_url'] = add_query_arg( |
|
| 506 | - array('token' => $this->_reg_url_link, 'resend_reg_confirmation' => 'true'), |
|
| 507 | - EE_Registry::instance()->CFG->core->thank_you_page_url() |
|
| 508 | - ); |
|
| 509 | - // verify template arguments |
|
| 510 | - EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction'); |
|
| 511 | - EEH_Template_Validator::verify_isnt_null( |
|
| 512 | - $template_args['SPCO_attendee_information_url'], |
|
| 513 | - '$SPCO_attendee_information_url' |
|
| 514 | - ); |
|
| 515 | - echo EEH_Template::locate_template( |
|
| 516 | - THANK_YOU_TEMPLATES_PATH . 'thank-you-page-registration-details.template.php', |
|
| 517 | - $template_args |
|
| 518 | - ); |
|
| 519 | - } |
|
| 520 | - |
|
| 521 | - |
|
| 522 | - /** |
|
| 523 | - * resend_reg_confirmation_email |
|
| 524 | - * |
|
| 525 | - * @throws EE_Error |
|
| 526 | - * @throws ReflectionException |
|
| 527 | - */ |
|
| 528 | - public static function resend_reg_confirmation_email() |
|
| 529 | - { |
|
| 530 | - $reg_url_link = self::getRequest()->getRequestParam('token'); |
|
| 531 | - // was a REG_ID passed ? |
|
| 532 | - if ($reg_url_link) { |
|
| 533 | - $registration = EEM_Registration::instance()->get_one( |
|
| 534 | - array(array('REG_url_link' => $reg_url_link)) |
|
| 535 | - ); |
|
| 536 | - if ($registration instanceof EE_Registration) { |
|
| 537 | - // resend email |
|
| 538 | - EED_Messages::process_resend(array('_REG_ID' => $registration->ID())); |
|
| 539 | - } else { |
|
| 540 | - EE_Error::add_error( |
|
| 541 | - esc_html__( |
|
| 542 | - 'The Registration Confirmation email could not be sent because a valid Registration could not be retrieved from the database.', |
|
| 543 | - 'event_espresso' |
|
| 544 | - ), |
|
| 545 | - __FILE__, |
|
| 546 | - __FUNCTION__, |
|
| 547 | - __LINE__ |
|
| 548 | - ); |
|
| 549 | - } |
|
| 550 | - } else { |
|
| 551 | - EE_Error::add_error( |
|
| 552 | - esc_html__( |
|
| 553 | - 'The Registration Confirmation email could not be sent because a registration token is missing or invalid.', |
|
| 554 | - 'event_espresso' |
|
| 555 | - ), |
|
| 556 | - __FILE__, |
|
| 557 | - __FUNCTION__, |
|
| 558 | - __LINE__ |
|
| 559 | - ); |
|
| 560 | - } |
|
| 561 | - // request sent via AJAX ? |
|
| 562 | - if (EE_FRONT_AJAX) { |
|
| 563 | - echo wp_json_encode(EE_Error::get_notices(false)); |
|
| 564 | - die(); |
|
| 565 | - // or was JS disabled ? |
|
| 566 | - } else { |
|
| 567 | - // save errors so that they get picked up on the next request |
|
| 568 | - EE_Error::get_notices(true, true); |
|
| 569 | - wp_safe_redirect( |
|
| 570 | - add_query_arg( |
|
| 571 | - array('e_reg_url_link' => $reg_url_link), |
|
| 572 | - EE_Registry::instance()->CFG->core->thank_you_page_url() |
|
| 573 | - ) |
|
| 574 | - ); |
|
| 575 | - } |
|
| 576 | - } |
|
| 577 | - |
|
| 578 | - |
|
| 579 | - /** |
|
| 580 | - * get_ajax_content |
|
| 581 | - * |
|
| 582 | - * @return void |
|
| 583 | - * @throws EE_Error |
|
| 584 | - * @throws ReflectionException |
|
| 585 | - */ |
|
| 586 | - public function get_ajax_content() |
|
| 587 | - { |
|
| 588 | - if (! $this->get_txn()) { |
|
| 589 | - return; |
|
| 590 | - } |
|
| 591 | - // first determine which event(s) require pre-approval or not |
|
| 592 | - $events = array(); |
|
| 593 | - $events_requiring_pre_approval = array(); |
|
| 594 | - foreach ($this->_current_txn->registrations() as $registration) { |
|
| 595 | - if ($registration instanceof EE_Registration) { |
|
| 596 | - $event = $registration->event(); |
|
| 597 | - if ($event instanceof EE_Event) { |
|
| 598 | - if ($registration->is_not_approved() && $registration->event() instanceof EE_Event) { |
|
| 599 | - $events_requiring_pre_approval[ $event->ID() ] = $event; |
|
| 600 | - } else { |
|
| 601 | - $events[ $event->ID() ] = $event; |
|
| 602 | - } |
|
| 603 | - } |
|
| 604 | - } |
|
| 605 | - } |
|
| 606 | - $this->display_details_for_events_requiring_pre_approval($events_requiring_pre_approval); |
|
| 607 | - $this->display_details_for_events($events); |
|
| 608 | - } |
|
| 609 | - |
|
| 610 | - |
|
| 611 | - /** |
|
| 612 | - * display_details_for_events |
|
| 613 | - * |
|
| 614 | - * @param EE_Event[] $events |
|
| 615 | - * @return void |
|
| 616 | - */ |
|
| 617 | - public function display_details_for_events($events = array()) |
|
| 618 | - { |
|
| 619 | - if (! empty($events)) { |
|
| 620 | - ?> |
|
| 402 | + ! $this->_current_txn->payment_method() instanceof EE_Payment_Method |
|
| 403 | + || ( |
|
| 404 | + // or is an offline payment method |
|
| 405 | + $this->_current_txn->payment_method() instanceof EE_Payment_Method |
|
| 406 | + && $this->_current_txn->payment_method()->is_off_line() |
|
| 407 | + ) |
|
| 408 | + ) { |
|
| 409 | + $this->_is_offline_payment_method = true; |
|
| 410 | + } |
|
| 411 | + // link to SPCO |
|
| 412 | + $revisit_spco_url = add_query_arg( |
|
| 413 | + array('ee' => '_register', 'revisit' => true, 'e_reg_url_link' => $this->_reg_url_link), |
|
| 414 | + EE_Registry::instance()->CFG->core->reg_page_url() |
|
| 415 | + ); |
|
| 416 | + // link to SPCO payment_options |
|
| 417 | + $this->_SPCO_payment_options_url = $this->_primary_registrant instanceof EE_Registration |
|
| 418 | + ? $this->_primary_registrant->payment_overview_url() |
|
| 419 | + : add_query_arg( |
|
| 420 | + array('step' => 'payment_options'), |
|
| 421 | + $revisit_spco_url |
|
| 422 | + ); |
|
| 423 | + // link to SPCO attendee_information |
|
| 424 | + $this->_SPCO_attendee_information_url = $this->_primary_registrant instanceof EE_Registration |
|
| 425 | + ? $this->_primary_registrant->edit_attendee_information_url() |
|
| 426 | + : false; |
|
| 427 | + do_action('AHEE__EED_Thank_You_Page__init_end', $this->_current_txn); |
|
| 428 | + // set no cache headers and constants |
|
| 429 | + EE_System::do_not_cache(); |
|
| 430 | + } |
|
| 431 | + |
|
| 432 | + |
|
| 433 | + /** |
|
| 434 | + * display_thank_you_page_results |
|
| 435 | + * |
|
| 436 | + * @return string |
|
| 437 | + * @throws EE_Error |
|
| 438 | + * @throws ReflectionException |
|
| 439 | + */ |
|
| 440 | + public function thank_you_page_results() |
|
| 441 | + { |
|
| 442 | + $this->init(); |
|
| 443 | + if (! $this->_current_txn instanceof EE_Transaction) { |
|
| 444 | + return EE_Error::get_notices(); |
|
| 445 | + } |
|
| 446 | + // link to receipt |
|
| 447 | + $template_args['TXN_receipt_url'] = $this->_current_txn->receipt_url(); |
|
| 448 | + if (! empty($template_args['TXN_receipt_url'])) { |
|
| 449 | + $template_args['order_conf_desc'] = esc_html__( |
|
| 450 | + '%1$sCongratulations%2$sYour registration has been successfully processed.%3$sCheck your email for your registration confirmation or click the button below to view / download / print a full description of your purchases and registration information.', |
|
| 451 | + 'event_espresso' |
|
| 452 | + ); |
|
| 453 | + } else { |
|
| 454 | + $template_args['order_conf_desc'] = esc_html__( |
|
| 455 | + '%1$sCongratulations%2$sYour registration has been successfully processed.%3$sCheck your email for your registration confirmation.', |
|
| 456 | + 'event_espresso' |
|
| 457 | + ); |
|
| 458 | + } |
|
| 459 | + $template_args['transaction'] = $this->_current_txn; |
|
| 460 | + $template_args['revisit'] = self::getRequest()->getRequestParam('revisit', false, 'bool'); |
|
| 461 | + add_action('AHEE__thank_you_page_overview_template__content', array($this, 'get_registration_details')); |
|
| 462 | + if ($this->_is_primary && ! $this->_current_txn->is_free()) { |
|
| 463 | + add_action('AHEE__thank_you_page_overview_template__content', array($this, 'get_ajax_content')); |
|
| 464 | + } |
|
| 465 | + return EEH_Template::locate_template( |
|
| 466 | + THANK_YOU_TEMPLATES_PATH . 'thank-you-page-overview.template.php', |
|
| 467 | + $template_args |
|
| 468 | + ); |
|
| 469 | + } |
|
| 470 | + |
|
| 471 | + |
|
| 472 | + /** |
|
| 473 | + * _update_server_wait_time |
|
| 474 | + * |
|
| 475 | + * @param array $thank_you_page_data thank you page portion of the incoming JSON array from the WP heartbeat data |
|
| 476 | + * @return array |
|
| 477 | + * @throws EE_Error |
|
| 478 | + * @throws ReflectionException |
|
| 479 | + */ |
|
| 480 | + private function _update_server_wait_time($thank_you_page_data = array()) |
|
| 481 | + { |
|
| 482 | + $response['espresso_thank_you_page'] = array( |
|
| 483 | + 'still_waiting' => isset($thank_you_page_data['initial_access']) |
|
| 484 | + ? time() - $thank_you_page_data['initial_access'] |
|
| 485 | + : 0, |
|
| 486 | + 'txn_status' => $this->_current_txn->status_ID(), |
|
| 487 | + ); |
|
| 488 | + return $response; |
|
| 489 | + } |
|
| 490 | + |
|
| 491 | + |
|
| 492 | + /** |
|
| 493 | + * get_registration_details |
|
| 494 | + * |
|
| 495 | + * @throws EE_Error |
|
| 496 | + */ |
|
| 497 | + public function get_registration_details() |
|
| 498 | + { |
|
| 499 | + // prepare variables for displaying |
|
| 500 | + $template_args = array(); |
|
| 501 | + $template_args['transaction'] = $this->_current_txn; |
|
| 502 | + $template_args['reg_url_link'] = $this->_reg_url_link; |
|
| 503 | + $template_args['is_primary'] = $this->_is_primary; |
|
| 504 | + $template_args['SPCO_attendee_information_url'] = $this->_SPCO_attendee_information_url; |
|
| 505 | + $template_args['resend_reg_confirmation_url'] = add_query_arg( |
|
| 506 | + array('token' => $this->_reg_url_link, 'resend_reg_confirmation' => 'true'), |
|
| 507 | + EE_Registry::instance()->CFG->core->thank_you_page_url() |
|
| 508 | + ); |
|
| 509 | + // verify template arguments |
|
| 510 | + EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction'); |
|
| 511 | + EEH_Template_Validator::verify_isnt_null( |
|
| 512 | + $template_args['SPCO_attendee_information_url'], |
|
| 513 | + '$SPCO_attendee_information_url' |
|
| 514 | + ); |
|
| 515 | + echo EEH_Template::locate_template( |
|
| 516 | + THANK_YOU_TEMPLATES_PATH . 'thank-you-page-registration-details.template.php', |
|
| 517 | + $template_args |
|
| 518 | + ); |
|
| 519 | + } |
|
| 520 | + |
|
| 521 | + |
|
| 522 | + /** |
|
| 523 | + * resend_reg_confirmation_email |
|
| 524 | + * |
|
| 525 | + * @throws EE_Error |
|
| 526 | + * @throws ReflectionException |
|
| 527 | + */ |
|
| 528 | + public static function resend_reg_confirmation_email() |
|
| 529 | + { |
|
| 530 | + $reg_url_link = self::getRequest()->getRequestParam('token'); |
|
| 531 | + // was a REG_ID passed ? |
|
| 532 | + if ($reg_url_link) { |
|
| 533 | + $registration = EEM_Registration::instance()->get_one( |
|
| 534 | + array(array('REG_url_link' => $reg_url_link)) |
|
| 535 | + ); |
|
| 536 | + if ($registration instanceof EE_Registration) { |
|
| 537 | + // resend email |
|
| 538 | + EED_Messages::process_resend(array('_REG_ID' => $registration->ID())); |
|
| 539 | + } else { |
|
| 540 | + EE_Error::add_error( |
|
| 541 | + esc_html__( |
|
| 542 | + 'The Registration Confirmation email could not be sent because a valid Registration could not be retrieved from the database.', |
|
| 543 | + 'event_espresso' |
|
| 544 | + ), |
|
| 545 | + __FILE__, |
|
| 546 | + __FUNCTION__, |
|
| 547 | + __LINE__ |
|
| 548 | + ); |
|
| 549 | + } |
|
| 550 | + } else { |
|
| 551 | + EE_Error::add_error( |
|
| 552 | + esc_html__( |
|
| 553 | + 'The Registration Confirmation email could not be sent because a registration token is missing or invalid.', |
|
| 554 | + 'event_espresso' |
|
| 555 | + ), |
|
| 556 | + __FILE__, |
|
| 557 | + __FUNCTION__, |
|
| 558 | + __LINE__ |
|
| 559 | + ); |
|
| 560 | + } |
|
| 561 | + // request sent via AJAX ? |
|
| 562 | + if (EE_FRONT_AJAX) { |
|
| 563 | + echo wp_json_encode(EE_Error::get_notices(false)); |
|
| 564 | + die(); |
|
| 565 | + // or was JS disabled ? |
|
| 566 | + } else { |
|
| 567 | + // save errors so that they get picked up on the next request |
|
| 568 | + EE_Error::get_notices(true, true); |
|
| 569 | + wp_safe_redirect( |
|
| 570 | + add_query_arg( |
|
| 571 | + array('e_reg_url_link' => $reg_url_link), |
|
| 572 | + EE_Registry::instance()->CFG->core->thank_you_page_url() |
|
| 573 | + ) |
|
| 574 | + ); |
|
| 575 | + } |
|
| 576 | + } |
|
| 577 | + |
|
| 578 | + |
|
| 579 | + /** |
|
| 580 | + * get_ajax_content |
|
| 581 | + * |
|
| 582 | + * @return void |
|
| 583 | + * @throws EE_Error |
|
| 584 | + * @throws ReflectionException |
|
| 585 | + */ |
|
| 586 | + public function get_ajax_content() |
|
| 587 | + { |
|
| 588 | + if (! $this->get_txn()) { |
|
| 589 | + return; |
|
| 590 | + } |
|
| 591 | + // first determine which event(s) require pre-approval or not |
|
| 592 | + $events = array(); |
|
| 593 | + $events_requiring_pre_approval = array(); |
|
| 594 | + foreach ($this->_current_txn->registrations() as $registration) { |
|
| 595 | + if ($registration instanceof EE_Registration) { |
|
| 596 | + $event = $registration->event(); |
|
| 597 | + if ($event instanceof EE_Event) { |
|
| 598 | + if ($registration->is_not_approved() && $registration->event() instanceof EE_Event) { |
|
| 599 | + $events_requiring_pre_approval[ $event->ID() ] = $event; |
|
| 600 | + } else { |
|
| 601 | + $events[ $event->ID() ] = $event; |
|
| 602 | + } |
|
| 603 | + } |
|
| 604 | + } |
|
| 605 | + } |
|
| 606 | + $this->display_details_for_events_requiring_pre_approval($events_requiring_pre_approval); |
|
| 607 | + $this->display_details_for_events($events); |
|
| 608 | + } |
|
| 609 | + |
|
| 610 | + |
|
| 611 | + /** |
|
| 612 | + * display_details_for_events |
|
| 613 | + * |
|
| 614 | + * @param EE_Event[] $events |
|
| 615 | + * @return void |
|
| 616 | + */ |
|
| 617 | + public function display_details_for_events($events = array()) |
|
| 618 | + { |
|
| 619 | + if (! empty($events)) { |
|
| 620 | + ?> |
|
| 621 | 621 | <div id="espresso-thank-you-page-ajax-content-dv"> |
| 622 | 622 | <div id="espresso-thank-you-page-ajax-transaction-dv"></div> |
| 623 | 623 | <div id="espresso-thank-you-page-ajax-payment-dv"></div> |
@@ -625,19 +625,19 @@ discard block |
||
| 625 | 625 | <div id="ee-ajax-loading-dv" class="float-left lt-blue-text"> |
| 626 | 626 | <span class="dashicons dashicons-upload"></span><span id="ee-ajax-loading-msg-spn"> |
| 627 | 627 | <?php esc_html_e( |
| 628 | - 'loading transaction and payment information...', |
|
| 629 | - 'event_espresso' |
|
| 630 | - ); ?></span> |
|
| 628 | + 'loading transaction and payment information...', |
|
| 629 | + 'event_espresso' |
|
| 630 | + ); ?></span> |
|
| 631 | 631 | </div> |
| 632 | 632 | <?php if (! $this->_is_offline_payment_method && ! $this->_payments_closed) : ?> |
| 633 | 633 | <p id="ee-ajax-loading-pg" class="highlight-bg small-text clear"> |
| 634 | 634 | <?php echo apply_filters( |
| 635 | - 'EED_Thank_You_Page__get_ajax_content__waiting_for_IPN_msg', |
|
| 636 | - esc_html__( |
|
| 637 | - 'Some payment gateways can take 15 minutes or more to return their payment notification, so please be patient if you require payment confirmation as soon as possible. Please note that as soon as everything is finalized, we will send your full payment and registration confirmation results to you via email.', |
|
| 638 | - 'event_espresso' |
|
| 639 | - ) |
|
| 640 | - ); ?> |
|
| 635 | + 'EED_Thank_You_Page__get_ajax_content__waiting_for_IPN_msg', |
|
| 636 | + esc_html__( |
|
| 637 | + 'Some payment gateways can take 15 minutes or more to return their payment notification, so please be patient if you require payment confirmation as soon as possible. Please note that as soon as everything is finalized, we will send your full payment and registration confirmation results to you via email.', |
|
| 638 | + 'event_espresso' |
|
| 639 | + ) |
|
| 640 | + ); ?> |
|
| 641 | 641 | <br/> |
| 642 | 642 | <span class="jst-rght ee-block small-text lt-grey-text"> |
| 643 | 643 | <?php esc_html_e('current wait time ', 'event_espresso'); ?> |
@@ -648,120 +648,120 @@ discard block |
||
| 648 | 648 | <div class="clear"></div> |
| 649 | 649 | </div> |
| 650 | 650 | <?php |
| 651 | - } |
|
| 652 | - } |
|
| 653 | - |
|
| 654 | - |
|
| 655 | - /** |
|
| 656 | - * display_details_for_events_requiring_pre_approval |
|
| 657 | - * |
|
| 658 | - * @param EE_Event[] $events |
|
| 659 | - * @return void |
|
| 660 | - * @throws EE_Error |
|
| 661 | - * @throws EE_Error |
|
| 662 | - */ |
|
| 663 | - public function display_details_for_events_requiring_pre_approval($events = array()) |
|
| 664 | - { |
|
| 665 | - if (! empty($events)) { |
|
| 666 | - ?> |
|
| 651 | + } |
|
| 652 | + } |
|
| 653 | + |
|
| 654 | + |
|
| 655 | + /** |
|
| 656 | + * display_details_for_events_requiring_pre_approval |
|
| 657 | + * |
|
| 658 | + * @param EE_Event[] $events |
|
| 659 | + * @return void |
|
| 660 | + * @throws EE_Error |
|
| 661 | + * @throws EE_Error |
|
| 662 | + */ |
|
| 663 | + public function display_details_for_events_requiring_pre_approval($events = array()) |
|
| 664 | + { |
|
| 665 | + if (! empty($events)) { |
|
| 666 | + ?> |
|
| 667 | 667 | <div id="espresso-thank-you-page-not-approved-message-dv"> |
| 668 | 668 | <h4 class="orange-text"><?php esc_html_e('Important Notice:', 'event_espresso'); ?></h4> |
| 669 | 669 | <p id="events-requiring-pre-approval-pg" class="small-text"> |
| 670 | 670 | <?php echo apply_filters( |
| 671 | - 'AHEE__EED_Thank_You_Page__get_ajax_content__not_approved_message', |
|
| 672 | - esc_html__( |
|
| 673 | - 'The following Event(s) you have registered for do not require payment at this time and will not be billed for during this transaction. Billing will only occur after all attendees have been approved by the event organizer. You will be notified when your registration has been processed. If this is a free event, then no billing will occur.', |
|
| 674 | - 'event_espresso' |
|
| 675 | - ) |
|
| 676 | - ); ?> |
|
| 671 | + 'AHEE__EED_Thank_You_Page__get_ajax_content__not_approved_message', |
|
| 672 | + esc_html__( |
|
| 673 | + 'The following Event(s) you have registered for do not require payment at this time and will not be billed for during this transaction. Billing will only occur after all attendees have been approved by the event organizer. You will be notified when your registration has been processed. If this is a free event, then no billing will occur.', |
|
| 674 | + 'event_espresso' |
|
| 675 | + ) |
|
| 676 | + ); ?> |
|
| 677 | 677 | </p> |
| 678 | 678 | <ul class="events-requiring-pre-approval-ul"> |
| 679 | 679 | <?php |
| 680 | - foreach ($events as $event) { |
|
| 681 | - if ($event instanceof EE_Event) { |
|
| 682 | - echo '<li><span class="dashicons dashicons-marker ee-icon-size-16 orange-text"></span>', |
|
| 683 | - esc_html($event->name()), |
|
| 684 | - '</li>'; |
|
| 685 | - } |
|
| 686 | - } ?> |
|
| 680 | + foreach ($events as $event) { |
|
| 681 | + if ($event instanceof EE_Event) { |
|
| 682 | + echo '<li><span class="dashicons dashicons-marker ee-icon-size-16 orange-text"></span>', |
|
| 683 | + esc_html($event->name()), |
|
| 684 | + '</li>'; |
|
| 685 | + } |
|
| 686 | + } ?> |
|
| 687 | 687 | </ul> |
| 688 | 688 | <div class="clear"></div> |
| 689 | 689 | </div> |
| 690 | 690 | <?php |
| 691 | - } |
|
| 692 | - } |
|
| 693 | - |
|
| 694 | - |
|
| 695 | - /** |
|
| 696 | - * get_transaction_details |
|
| 697 | - * |
|
| 698 | - * @return string |
|
| 699 | - * @throws EE_Error |
|
| 700 | - */ |
|
| 701 | - public function get_transaction_details() |
|
| 702 | - { |
|
| 703 | - // prepare variables for displaying |
|
| 704 | - $template_args = array(); |
|
| 705 | - $template_args['transaction'] = $this->_current_txn; |
|
| 706 | - $template_args['reg_url_link'] = $this->_reg_url_link; |
|
| 707 | - $template_args['primary_registrant_name'] = $this->_primary_registrant->attendee()->full_name(true); |
|
| 708 | - // link to SPCO payment_options |
|
| 709 | - $template_args['show_try_pay_again_link'] = $this->_show_try_pay_again_link; |
|
| 710 | - $template_args['SPCO_payment_options_url'] = $this->_SPCO_payment_options_url; |
|
| 711 | - // verify template arguments |
|
| 712 | - EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction'); |
|
| 713 | - EEH_Template_Validator::verify_isnt_null( |
|
| 714 | - $template_args['show_try_pay_again_link'], |
|
| 715 | - '$show_try_pay_again_link' |
|
| 716 | - ); |
|
| 717 | - EEH_Template_Validator::verify_isnt_null( |
|
| 718 | - $template_args['SPCO_payment_options_url'], |
|
| 719 | - '$SPCO_payment_options_url' |
|
| 720 | - ); |
|
| 721 | - return EEH_Template::locate_template( |
|
| 722 | - THANK_YOU_TEMPLATES_PATH . 'thank-you-page-transaction-details.template.php', |
|
| 723 | - $template_args |
|
| 724 | - ); |
|
| 725 | - } |
|
| 726 | - |
|
| 727 | - |
|
| 728 | - /** |
|
| 729 | - * get_payment_row_html |
|
| 730 | - * |
|
| 731 | - * @param EE_Payment $payment |
|
| 732 | - * @return string |
|
| 733 | - * @throws EE_Error |
|
| 734 | - */ |
|
| 735 | - public function get_payment_row_html(EE_Payment $payment = null) |
|
| 736 | - { |
|
| 737 | - $html = ''; |
|
| 738 | - if (! $payment instanceof EE_Payment) { |
|
| 739 | - return ''; |
|
| 740 | - } |
|
| 741 | - if ( |
|
| 742 | - $payment->payment_method() instanceof EE_Payment_Method |
|
| 743 | - && $payment->status() === EEM_Payment::status_id_failed |
|
| 744 | - && $payment->payment_method()->is_off_site() |
|
| 745 | - ) { |
|
| 746 | - // considering the registrant has made it to the Thank You page, |
|
| 747 | - // any failed payments may actually be pending and the IPN is just slow |
|
| 748 | - // so let's |
|
| 749 | - $payment->set_status(EEM_Payment::status_id_pending); |
|
| 750 | - } |
|
| 751 | - $payment_declined_msg = $payment->STS_ID() === EEM_Payment::status_id_declined |
|
| 752 | - ? '<br /><span class="small-text">' . esc_html($payment->gateway_response()) . '</span>' |
|
| 753 | - : ''; |
|
| 754 | - $html .= ' |
|
| 691 | + } |
|
| 692 | + } |
|
| 693 | + |
|
| 694 | + |
|
| 695 | + /** |
|
| 696 | + * get_transaction_details |
|
| 697 | + * |
|
| 698 | + * @return string |
|
| 699 | + * @throws EE_Error |
|
| 700 | + */ |
|
| 701 | + public function get_transaction_details() |
|
| 702 | + { |
|
| 703 | + // prepare variables for displaying |
|
| 704 | + $template_args = array(); |
|
| 705 | + $template_args['transaction'] = $this->_current_txn; |
|
| 706 | + $template_args['reg_url_link'] = $this->_reg_url_link; |
|
| 707 | + $template_args['primary_registrant_name'] = $this->_primary_registrant->attendee()->full_name(true); |
|
| 708 | + // link to SPCO payment_options |
|
| 709 | + $template_args['show_try_pay_again_link'] = $this->_show_try_pay_again_link; |
|
| 710 | + $template_args['SPCO_payment_options_url'] = $this->_SPCO_payment_options_url; |
|
| 711 | + // verify template arguments |
|
| 712 | + EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction'); |
|
| 713 | + EEH_Template_Validator::verify_isnt_null( |
|
| 714 | + $template_args['show_try_pay_again_link'], |
|
| 715 | + '$show_try_pay_again_link' |
|
| 716 | + ); |
|
| 717 | + EEH_Template_Validator::verify_isnt_null( |
|
| 718 | + $template_args['SPCO_payment_options_url'], |
|
| 719 | + '$SPCO_payment_options_url' |
|
| 720 | + ); |
|
| 721 | + return EEH_Template::locate_template( |
|
| 722 | + THANK_YOU_TEMPLATES_PATH . 'thank-you-page-transaction-details.template.php', |
|
| 723 | + $template_args |
|
| 724 | + ); |
|
| 725 | + } |
|
| 726 | + |
|
| 727 | + |
|
| 728 | + /** |
|
| 729 | + * get_payment_row_html |
|
| 730 | + * |
|
| 731 | + * @param EE_Payment $payment |
|
| 732 | + * @return string |
|
| 733 | + * @throws EE_Error |
|
| 734 | + */ |
|
| 735 | + public function get_payment_row_html(EE_Payment $payment = null) |
|
| 736 | + { |
|
| 737 | + $html = ''; |
|
| 738 | + if (! $payment instanceof EE_Payment) { |
|
| 739 | + return ''; |
|
| 740 | + } |
|
| 741 | + if ( |
|
| 742 | + $payment->payment_method() instanceof EE_Payment_Method |
|
| 743 | + && $payment->status() === EEM_Payment::status_id_failed |
|
| 744 | + && $payment->payment_method()->is_off_site() |
|
| 745 | + ) { |
|
| 746 | + // considering the registrant has made it to the Thank You page, |
|
| 747 | + // any failed payments may actually be pending and the IPN is just slow |
|
| 748 | + // so let's |
|
| 749 | + $payment->set_status(EEM_Payment::status_id_pending); |
|
| 750 | + } |
|
| 751 | + $payment_declined_msg = $payment->STS_ID() === EEM_Payment::status_id_declined |
|
| 752 | + ? '<br /><span class="small-text">' . esc_html($payment->gateway_response()) . '</span>' |
|
| 753 | + : ''; |
|
| 754 | + $html .= ' |
|
| 755 | 755 | <tr> |
| 756 | 756 | <td> |
| 757 | 757 | ' . esc_html($payment->timestamp()) . ' |
| 758 | 758 | </td> |
| 759 | 759 | <td> |
| 760 | 760 | ' . ( |
| 761 | - $payment->payment_method() instanceof EE_Payment_Method |
|
| 762 | - ? esc_html($payment->payment_method()->name()) |
|
| 763 | - : esc_html__('Unknown', 'event_espresso') |
|
| 764 | - ) . ' |
|
| 761 | + $payment->payment_method() instanceof EE_Payment_Method |
|
| 762 | + ? esc_html($payment->payment_method()->name()) |
|
| 763 | + : esc_html__('Unknown', 'event_espresso') |
|
| 764 | + ) . ' |
|
| 765 | 765 | </td> |
| 766 | 766 | <td class="jst-rght"> |
| 767 | 767 | ' . EEH_Template::format_currency($payment->amount()) . ' |
@@ -770,81 +770,81 @@ discard block |
||
| 770 | 770 | ' . $payment->pretty_status(true) . $payment_declined_msg . ' |
| 771 | 771 | </td> |
| 772 | 772 | </tr>'; |
| 773 | - do_action('AHEE__thank_you_page_payment_details_template__after_each_payment', $payment); |
|
| 774 | - return $html; |
|
| 775 | - } |
|
| 776 | - |
|
| 777 | - |
|
| 778 | - /** |
|
| 779 | - * get_payment_details |
|
| 780 | - * |
|
| 781 | - * @param EE_Payment[] $payments |
|
| 782 | - * @return string |
|
| 783 | - * @throws EE_Error |
|
| 784 | - * @throws ReflectionException |
|
| 785 | - */ |
|
| 786 | - public function get_payment_details($payments = array()) |
|
| 787 | - { |
|
| 788 | - // prepare variables for displaying |
|
| 789 | - $template_args = array(); |
|
| 790 | - $template_args['transaction'] = $this->_current_txn; |
|
| 791 | - $template_args['reg_url_link'] = $this->_reg_url_link; |
|
| 792 | - $template_args['payments'] = array(); |
|
| 793 | - foreach ($payments as $payment) { |
|
| 794 | - $template_args['payments'][] = $this->get_payment_row_html($payment); |
|
| 795 | - } |
|
| 796 | - // create a hacky payment object, but dont save it |
|
| 797 | - $payment = EE_Payment::new_instance( |
|
| 798 | - array( |
|
| 799 | - 'TXN_ID' => $this->_current_txn->ID(), |
|
| 800 | - 'STS_ID' => EEM_Payment::status_id_pending, |
|
| 801 | - 'PAY_timestamp' => time(), |
|
| 802 | - 'PAY_amount' => $this->_current_txn->total(), |
|
| 803 | - 'PMD_ID' => $this->_current_txn->payment_method_ID(), |
|
| 804 | - ) |
|
| 805 | - ); |
|
| 806 | - $payment_method = $this->_current_txn->payment_method(); |
|
| 807 | - if ($payment_method instanceof EE_Payment_Method && $payment_method->type_obj() instanceof EE_PMT_Base) { |
|
| 808 | - $template_args['gateway_content'] = $payment_method->type_obj()->payment_overview_content($payment); |
|
| 809 | - } else { |
|
| 810 | - $template_args['gateway_content'] = ''; |
|
| 811 | - } |
|
| 812 | - // link to SPCO payment_options |
|
| 813 | - $template_args['show_try_pay_again_link'] = $this->_show_try_pay_again_link; |
|
| 814 | - $template_args['SPCO_payment_options_url'] = $this->_SPCO_payment_options_url; |
|
| 815 | - // verify template arguments |
|
| 816 | - EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction'); |
|
| 817 | - EEH_Template_Validator::verify_isnt_null($template_args['payments'], '$payments'); |
|
| 818 | - EEH_Template_Validator::verify_isnt_null( |
|
| 819 | - $template_args['show_try_pay_again_link'], |
|
| 820 | - '$show_try_pay_again_link' |
|
| 821 | - ); |
|
| 822 | - EEH_Template_Validator::verify_isnt_null($template_args['gateway_content'], '$gateway_content'); |
|
| 823 | - EEH_Template_Validator::verify_isnt_null( |
|
| 824 | - $template_args['SPCO_payment_options_url'], |
|
| 825 | - '$SPCO_payment_options_url' |
|
| 826 | - ); |
|
| 827 | - return EEH_Template::locate_template( |
|
| 828 | - THANK_YOU_TEMPLATES_PATH . 'thank-you-page-payment-details.template.php', |
|
| 829 | - $template_args |
|
| 830 | - ); |
|
| 831 | - } |
|
| 832 | - |
|
| 833 | - |
|
| 834 | - /** |
|
| 835 | - * get_payment_details |
|
| 836 | - * |
|
| 837 | - * @param array $payments |
|
| 838 | - * @return string |
|
| 839 | - * @throws EE_Error |
|
| 840 | - */ |
|
| 841 | - public function get_new_payments($payments = array()) |
|
| 842 | - { |
|
| 843 | - $payments_html = ''; |
|
| 844 | - // prepare variables for displaying |
|
| 845 | - foreach ($payments as $payment) { |
|
| 846 | - $payments_html .= $this->get_payment_row_html($payment); |
|
| 847 | - } |
|
| 848 | - return $payments_html; |
|
| 849 | - } |
|
| 773 | + do_action('AHEE__thank_you_page_payment_details_template__after_each_payment', $payment); |
|
| 774 | + return $html; |
|
| 775 | + } |
|
| 776 | + |
|
| 777 | + |
|
| 778 | + /** |
|
| 779 | + * get_payment_details |
|
| 780 | + * |
|
| 781 | + * @param EE_Payment[] $payments |
|
| 782 | + * @return string |
|
| 783 | + * @throws EE_Error |
|
| 784 | + * @throws ReflectionException |
|
| 785 | + */ |
|
| 786 | + public function get_payment_details($payments = array()) |
|
| 787 | + { |
|
| 788 | + // prepare variables for displaying |
|
| 789 | + $template_args = array(); |
|
| 790 | + $template_args['transaction'] = $this->_current_txn; |
|
| 791 | + $template_args['reg_url_link'] = $this->_reg_url_link; |
|
| 792 | + $template_args['payments'] = array(); |
|
| 793 | + foreach ($payments as $payment) { |
|
| 794 | + $template_args['payments'][] = $this->get_payment_row_html($payment); |
|
| 795 | + } |
|
| 796 | + // create a hacky payment object, but dont save it |
|
| 797 | + $payment = EE_Payment::new_instance( |
|
| 798 | + array( |
|
| 799 | + 'TXN_ID' => $this->_current_txn->ID(), |
|
| 800 | + 'STS_ID' => EEM_Payment::status_id_pending, |
|
| 801 | + 'PAY_timestamp' => time(), |
|
| 802 | + 'PAY_amount' => $this->_current_txn->total(), |
|
| 803 | + 'PMD_ID' => $this->_current_txn->payment_method_ID(), |
|
| 804 | + ) |
|
| 805 | + ); |
|
| 806 | + $payment_method = $this->_current_txn->payment_method(); |
|
| 807 | + if ($payment_method instanceof EE_Payment_Method && $payment_method->type_obj() instanceof EE_PMT_Base) { |
|
| 808 | + $template_args['gateway_content'] = $payment_method->type_obj()->payment_overview_content($payment); |
|
| 809 | + } else { |
|
| 810 | + $template_args['gateway_content'] = ''; |
|
| 811 | + } |
|
| 812 | + // link to SPCO payment_options |
|
| 813 | + $template_args['show_try_pay_again_link'] = $this->_show_try_pay_again_link; |
|
| 814 | + $template_args['SPCO_payment_options_url'] = $this->_SPCO_payment_options_url; |
|
| 815 | + // verify template arguments |
|
| 816 | + EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction'); |
|
| 817 | + EEH_Template_Validator::verify_isnt_null($template_args['payments'], '$payments'); |
|
| 818 | + EEH_Template_Validator::verify_isnt_null( |
|
| 819 | + $template_args['show_try_pay_again_link'], |
|
| 820 | + '$show_try_pay_again_link' |
|
| 821 | + ); |
|
| 822 | + EEH_Template_Validator::verify_isnt_null($template_args['gateway_content'], '$gateway_content'); |
|
| 823 | + EEH_Template_Validator::verify_isnt_null( |
|
| 824 | + $template_args['SPCO_payment_options_url'], |
|
| 825 | + '$SPCO_payment_options_url' |
|
| 826 | + ); |
|
| 827 | + return EEH_Template::locate_template( |
|
| 828 | + THANK_YOU_TEMPLATES_PATH . 'thank-you-page-payment-details.template.php', |
|
| 829 | + $template_args |
|
| 830 | + ); |
|
| 831 | + } |
|
| 832 | + |
|
| 833 | + |
|
| 834 | + /** |
|
| 835 | + * get_payment_details |
|
| 836 | + * |
|
| 837 | + * @param array $payments |
|
| 838 | + * @return string |
|
| 839 | + * @throws EE_Error |
|
| 840 | + */ |
|
| 841 | + public function get_new_payments($payments = array()) |
|
| 842 | + { |
|
| 843 | + $payments_html = ''; |
|
| 844 | + // prepare variables for displaying |
|
| 845 | + foreach ($payments as $payment) { |
|
| 846 | + $payments_html .= $this->get_payment_row_html($payment); |
|
| 847 | + } |
|
| 848 | + return $payments_html; |
|
| 849 | + } |
|
| 850 | 850 | } |
@@ -129,8 +129,8 @@ discard block |
||
| 129 | 129 | */ |
| 130 | 130 | public static function set_definitions() |
| 131 | 131 | { |
| 132 | - define('THANK_YOU_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/'); |
|
| 133 | - define('THANK_YOU_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/'); |
|
| 132 | + define('THANK_YOU_ASSETS_URL', plugin_dir_url(__FILE__).'assets/'); |
|
| 133 | + define('THANK_YOU_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)).'templates/'); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | return $this->_current_txn; |
| 148 | 148 | } |
| 149 | 149 | $TXN_model = EE_Registry::instance()->load_model('Transaction'); |
| 150 | - if (! $TXN_model instanceof EEM_Transaction) { |
|
| 150 | + if ( ! $TXN_model instanceof EEM_Transaction) { |
|
| 151 | 151 | EE_Error::add_error( |
| 152 | 152 | esc_html__('The transaction model could not be established.', 'event_espresso'), |
| 153 | 153 | __FILE__, |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | */ |
| 186 | 186 | public function get_txn_payments($since = 0) |
| 187 | 187 | { |
| 188 | - if (! $this->get_txn()) { |
|
| 188 | + if ( ! $this->get_txn()) { |
|
| 189 | 189 | return []; |
| 190 | 190 | } |
| 191 | 191 | $args = array('order_by' => array('PAY_timestamp' => 'ASC')); |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | { |
| 328 | 328 | wp_register_script( |
| 329 | 329 | 'thank_you_page', |
| 330 | - THANK_YOU_ASSETS_URL . 'thank_you_page.js', |
|
| 330 | + THANK_YOU_ASSETS_URL.'thank_you_page.js', |
|
| 331 | 331 | array('espresso_core', 'heartbeat'), |
| 332 | 332 | EVENT_ESPRESSO_VERSION, |
| 333 | 333 | true |
@@ -347,9 +347,9 @@ discard block |
||
| 347 | 347 | public function init() |
| 348 | 348 | { |
| 349 | 349 | $this->_get_reg_url_link(); |
| 350 | - if (! $this->get_txn()) { |
|
| 350 | + if ( ! $this->get_txn()) { |
|
| 351 | 351 | echo EEH_HTML::div( |
| 352 | - EEH_HTML::h4(esc_html__('We\'re sorry...', 'event_espresso')) . |
|
| 352 | + EEH_HTML::h4(esc_html__('We\'re sorry...', 'event_espresso')). |
|
| 353 | 353 | sprintf( |
| 354 | 354 | esc_html__( |
| 355 | 355 | 'This is a system page for displaying transaction information after a purchase.%1$sYou are most likely seeing this notice because you have navigated to this page%1$sthrough some means other than completing a transaction.%1$sSorry for the disappointment, but you will most likely find nothing of interest here.%1$s%1$s', |
@@ -440,12 +440,12 @@ discard block |
||
| 440 | 440 | public function thank_you_page_results() |
| 441 | 441 | { |
| 442 | 442 | $this->init(); |
| 443 | - if (! $this->_current_txn instanceof EE_Transaction) { |
|
| 443 | + if ( ! $this->_current_txn instanceof EE_Transaction) { |
|
| 444 | 444 | return EE_Error::get_notices(); |
| 445 | 445 | } |
| 446 | 446 | // link to receipt |
| 447 | 447 | $template_args['TXN_receipt_url'] = $this->_current_txn->receipt_url(); |
| 448 | - if (! empty($template_args['TXN_receipt_url'])) { |
|
| 448 | + if ( ! empty($template_args['TXN_receipt_url'])) { |
|
| 449 | 449 | $template_args['order_conf_desc'] = esc_html__( |
| 450 | 450 | '%1$sCongratulations%2$sYour registration has been successfully processed.%3$sCheck your email for your registration confirmation or click the button below to view / download / print a full description of your purchases and registration information.', |
| 451 | 451 | 'event_espresso' |
@@ -463,7 +463,7 @@ discard block |
||
| 463 | 463 | add_action('AHEE__thank_you_page_overview_template__content', array($this, 'get_ajax_content')); |
| 464 | 464 | } |
| 465 | 465 | return EEH_Template::locate_template( |
| 466 | - THANK_YOU_TEMPLATES_PATH . 'thank-you-page-overview.template.php', |
|
| 466 | + THANK_YOU_TEMPLATES_PATH.'thank-you-page-overview.template.php', |
|
| 467 | 467 | $template_args |
| 468 | 468 | ); |
| 469 | 469 | } |
@@ -513,7 +513,7 @@ discard block |
||
| 513 | 513 | '$SPCO_attendee_information_url' |
| 514 | 514 | ); |
| 515 | 515 | echo EEH_Template::locate_template( |
| 516 | - THANK_YOU_TEMPLATES_PATH . 'thank-you-page-registration-details.template.php', |
|
| 516 | + THANK_YOU_TEMPLATES_PATH.'thank-you-page-registration-details.template.php', |
|
| 517 | 517 | $template_args |
| 518 | 518 | ); |
| 519 | 519 | } |
@@ -585,7 +585,7 @@ discard block |
||
| 585 | 585 | */ |
| 586 | 586 | public function get_ajax_content() |
| 587 | 587 | { |
| 588 | - if (! $this->get_txn()) { |
|
| 588 | + if ( ! $this->get_txn()) { |
|
| 589 | 589 | return; |
| 590 | 590 | } |
| 591 | 591 | // first determine which event(s) require pre-approval or not |
@@ -596,9 +596,9 @@ discard block |
||
| 596 | 596 | $event = $registration->event(); |
| 597 | 597 | if ($event instanceof EE_Event) { |
| 598 | 598 | if ($registration->is_not_approved() && $registration->event() instanceof EE_Event) { |
| 599 | - $events_requiring_pre_approval[ $event->ID() ] = $event; |
|
| 599 | + $events_requiring_pre_approval[$event->ID()] = $event; |
|
| 600 | 600 | } else { |
| 601 | - $events[ $event->ID() ] = $event; |
|
| 601 | + $events[$event->ID()] = $event; |
|
| 602 | 602 | } |
| 603 | 603 | } |
| 604 | 604 | } |
@@ -616,7 +616,7 @@ discard block |
||
| 616 | 616 | */ |
| 617 | 617 | public function display_details_for_events($events = array()) |
| 618 | 618 | { |
| 619 | - if (! empty($events)) { |
|
| 619 | + if ( ! empty($events)) { |
|
| 620 | 620 | ?> |
| 621 | 621 | <div id="espresso-thank-you-page-ajax-content-dv"> |
| 622 | 622 | <div id="espresso-thank-you-page-ajax-transaction-dv"></div> |
@@ -629,7 +629,7 @@ discard block |
||
| 629 | 629 | 'event_espresso' |
| 630 | 630 | ); ?></span> |
| 631 | 631 | </div> |
| 632 | - <?php if (! $this->_is_offline_payment_method && ! $this->_payments_closed) : ?> |
|
| 632 | + <?php if ( ! $this->_is_offline_payment_method && ! $this->_payments_closed) : ?> |
|
| 633 | 633 | <p id="ee-ajax-loading-pg" class="highlight-bg small-text clear"> |
| 634 | 634 | <?php echo apply_filters( |
| 635 | 635 | 'EED_Thank_You_Page__get_ajax_content__waiting_for_IPN_msg', |
@@ -662,7 +662,7 @@ discard block |
||
| 662 | 662 | */ |
| 663 | 663 | public function display_details_for_events_requiring_pre_approval($events = array()) |
| 664 | 664 | { |
| 665 | - if (! empty($events)) { |
|
| 665 | + if ( ! empty($events)) { |
|
| 666 | 666 | ?> |
| 667 | 667 | <div id="espresso-thank-you-page-not-approved-message-dv"> |
| 668 | 668 | <h4 class="orange-text"><?php esc_html_e('Important Notice:', 'event_espresso'); ?></h4> |
@@ -719,7 +719,7 @@ discard block |
||
| 719 | 719 | '$SPCO_payment_options_url' |
| 720 | 720 | ); |
| 721 | 721 | return EEH_Template::locate_template( |
| 722 | - THANK_YOU_TEMPLATES_PATH . 'thank-you-page-transaction-details.template.php', |
|
| 722 | + THANK_YOU_TEMPLATES_PATH.'thank-you-page-transaction-details.template.php', |
|
| 723 | 723 | $template_args |
| 724 | 724 | ); |
| 725 | 725 | } |
@@ -735,7 +735,7 @@ discard block |
||
| 735 | 735 | public function get_payment_row_html(EE_Payment $payment = null) |
| 736 | 736 | { |
| 737 | 737 | $html = ''; |
| 738 | - if (! $payment instanceof EE_Payment) { |
|
| 738 | + if ( ! $payment instanceof EE_Payment) { |
|
| 739 | 739 | return ''; |
| 740 | 740 | } |
| 741 | 741 | if ( |
@@ -749,25 +749,25 @@ discard block |
||
| 749 | 749 | $payment->set_status(EEM_Payment::status_id_pending); |
| 750 | 750 | } |
| 751 | 751 | $payment_declined_msg = $payment->STS_ID() === EEM_Payment::status_id_declined |
| 752 | - ? '<br /><span class="small-text">' . esc_html($payment->gateway_response()) . '</span>' |
|
| 752 | + ? '<br /><span class="small-text">'.esc_html($payment->gateway_response()).'</span>' |
|
| 753 | 753 | : ''; |
| 754 | 754 | $html .= ' |
| 755 | 755 | <tr> |
| 756 | 756 | <td> |
| 757 | - ' . esc_html($payment->timestamp()) . ' |
|
| 757 | + ' . esc_html($payment->timestamp()).' |
|
| 758 | 758 | </td> |
| 759 | 759 | <td> |
| 760 | 760 | ' . ( |
| 761 | 761 | $payment->payment_method() instanceof EE_Payment_Method |
| 762 | 762 | ? esc_html($payment->payment_method()->name()) |
| 763 | 763 | : esc_html__('Unknown', 'event_espresso') |
| 764 | - ) . ' |
|
| 764 | + ).' |
|
| 765 | 765 | </td> |
| 766 | 766 | <td class="jst-rght"> |
| 767 | - ' . EEH_Template::format_currency($payment->amount()) . ' |
|
| 767 | + ' . EEH_Template::format_currency($payment->amount()).' |
|
| 768 | 768 | </td> |
| 769 | 769 | <td class="jst-rght" style="line-height:1;"> |
| 770 | - ' . $payment->pretty_status(true) . $payment_declined_msg . ' |
|
| 770 | + ' . $payment->pretty_status(true).$payment_declined_msg.' |
|
| 771 | 771 | </td> |
| 772 | 772 | </tr>'; |
| 773 | 773 | do_action('AHEE__thank_you_page_payment_details_template__after_each_payment', $payment); |
@@ -825,7 +825,7 @@ discard block |
||
| 825 | 825 | '$SPCO_payment_options_url' |
| 826 | 826 | ); |
| 827 | 827 | return EEH_Template::locate_template( |
| 828 | - THANK_YOU_TEMPLATES_PATH . 'thank-you-page-payment-details.template.php', |
|
| 828 | + THANK_YOU_TEMPLATES_PATH.'thank-you-page-payment-details.template.php', |
|
| 829 | 829 | $template_args |
| 830 | 830 | ); |
| 831 | 831 | } |