@@ -6,25 +6,25 @@ discard block |
||
6 | 6 | <p><strong><?php esc_html_e('ID', 'event_espresso'); ?></strong> |
7 | 7 | <br /> |
8 | 8 | <?php esc_html_e( |
9 | - 'This is the transaction ID is that is used throughout the payment process.', |
|
10 | - 'event_espresso' |
|
11 | - ); ?> |
|
9 | + 'This is the transaction ID is that is used throughout the payment process.', |
|
10 | + 'event_espresso' |
|
11 | + ); ?> |
|
12 | 12 | </p> |
13 | 13 | </li> |
14 | 14 | <li><strong><?php esc_html_e('Transaction Date', 'event_espresso'); ?></strong> |
15 | 15 | <br /> |
16 | 16 | <?php esc_html_e( |
17 | - 'This is the date that the transaction occurred on. Clicking the date will take you to another page where you can view the transaction details.', |
|
18 | - 'event_espresso' |
|
19 | - ); ?> |
|
17 | + 'This is the date that the transaction occurred on. Clicking the date will take you to another page where you can view the transaction details.', |
|
18 | + 'event_espresso' |
|
19 | + ); ?> |
|
20 | 20 | </li> |
21 | 21 | <li> |
22 | 22 | <strong><?php esc_html_e('Status', 'event_espresso'); ?></strong> |
23 | 23 | <br /> |
24 | 24 | <?php esc_html_e( |
25 | - 'The status helps you understand if the transaction was successful or not. Below are available statuses for transactions.', |
|
26 | - 'event_espresso' |
|
27 | - ); ?> |
|
25 | + 'The status helps you understand if the transaction was successful or not. Below are available statuses for transactions.', |
|
26 | + 'event_espresso' |
|
27 | + ); ?> |
|
28 | 28 | <ul> |
29 | 29 | <li style="list-style-type: none;"> |
30 | 30 | <strong><?php esc_html_e('Overpaid', 'event_espresso'); ?></strong> |
@@ -40,9 +40,9 @@ discard block |
||
40 | 40 | <strong><?php esc_html_e('Incomplete', 'event_espresso'); ?></strong> |
41 | 41 | <br /> |
42 | 42 | <?php esc_html_e( |
43 | - 'The payment has not yet been completed. This is the status for online payments that have yet to be processed.', |
|
44 | - 'event_espresso' |
|
45 | - ); ?> |
|
43 | + 'The payment has not yet been completed. This is the status for online payments that have yet to be processed.', |
|
44 | + 'event_espresso' |
|
45 | + ); ?> |
|
46 | 46 | </li> |
47 | 47 | <li style="list-style-type: none;"> |
48 | 48 | <strong><?php esc_html_e('Failed', 'event_espresso'); ?></strong> |
@@ -55,69 +55,69 @@ discard block |
||
55 | 55 | <strong><?php esc_html_e('Total', 'event_espresso'); ?></strong> |
56 | 56 | <br /> |
57 | 57 | <?php esc_html_e( |
58 | - 'This is the total amount for that transaction. It will include the total of every ticket purchased even if from separate events.', |
|
59 | - 'event_espresso' |
|
60 | - ); ?> |
|
58 | + 'This is the total amount for that transaction. It will include the total of every ticket purchased even if from separate events.', |
|
59 | + 'event_espresso' |
|
60 | + ); ?> |
|
61 | 61 | </li> |
62 | 62 | <li> |
63 | 63 | <strong><?php esc_html_e('Paid', 'event_espresso'); ?></strong> |
64 | 64 | <br /> |
65 | 65 | <?php esc_html_e( |
66 | - 'This shows much has been paid. If this column matches the amount in the total column, then the transaction has been paid in full.', |
|
67 | - 'event_espresso' |
|
68 | - ); ?> |
|
66 | + 'This shows much has been paid. If this column matches the amount in the total column, then the transaction has been paid in full.', |
|
67 | + 'event_espresso' |
|
68 | + ); ?> |
|
69 | 69 | </li> |
70 | 70 | <li> |
71 | 71 | <strong><?php esc_html_e('Primary Registrant', 'event_espresso'); ?></strong> |
72 | 72 | <br /> |
73 | 73 | <?php esc_html_e( |
74 | - 'The name of the primary registrant. Clicking the name will take you to the registration details page.', |
|
75 | - 'event_espresso' |
|
76 | - ); ?> |
|
74 | + 'The name of the primary registrant. Clicking the name will take you to the registration details page.', |
|
75 | + 'event_espresso' |
|
76 | + ); ?> |
|
77 | 77 | </li> |
78 | 78 | <li> |
79 | 79 | <strong><?php esc_html_e('Email Address', 'event_espresso'); ?></strong> |
80 | 80 | <br /> |
81 | 81 | <?php esc_html_e( |
82 | - 'This is the email address for the primary registrant. Clicking the email address will open your default email client.', |
|
83 | - 'event_espresso' |
|
84 | - ); ?> |
|
82 | + 'This is the email address for the primary registrant. Clicking the email address will open your default email client.', |
|
83 | + 'event_espresso' |
|
84 | + ); ?> |
|
85 | 85 | </li> |
86 | 86 | <li> |
87 | 87 | <strong><?php esc_html_e('Event', 'event_espresso'); ?></strong> |
88 | 88 | <br /> |
89 | 89 | <?php esc_html_e( |
90 | - 'The name of the events are shown here. Clicking the name will take you the edit event page.', |
|
91 | - 'event_espresso' |
|
92 | - ); ?> |
|
90 | + 'The name of the events are shown here. Clicking the name will take you the edit event page.', |
|
91 | + 'event_espresso' |
|
92 | + ); ?> |
|
93 | 93 | </li> |
94 | 94 | <li> |
95 | 95 | <strong><?php esc_html_e('Actions', 'event_espresso'); ?></strong> |
96 | 96 | <br /> |
97 | 97 | <?php esc_html_e( |
98 | - 'There are several actions that can be done by clicking the icons. These are explained below.', |
|
99 | - 'event_espresso' |
|
100 | - ); ?> |
|
98 | + 'There are several actions that can be done by clicking the icons. These are explained below.', |
|
99 | + 'event_espresso' |
|
100 | + ); ?> |
|
101 | 101 | <ul> |
102 | 102 | <li style="list-style-type: none;"> |
103 | 103 | <strong> |
104 | 104 | <?php printf( |
105 | - esc_html__('View Transaction Details %1$s', 'event_espresso'), |
|
106 | - '<span class="dashicons dashicons-cart"></span>' |
|
107 | - ); ?> |
|
105 | + esc_html__('View Transaction Details %1$s', 'event_espresso'), |
|
106 | + '<span class="dashicons dashicons-cart"></span>' |
|
107 | + ); ?> |
|
108 | 108 | </strong> |
109 | 109 | <br /> |
110 | 110 | <?php esc_html_e( |
111 | - 'Takes you to the individual transaction page. Clicking the date also takes you to the individual transaction page.', |
|
112 | - 'event_espresso' |
|
113 | - ); ?> |
|
111 | + 'Takes you to the individual transaction page. Clicking the date also takes you to the individual transaction page.', |
|
112 | + 'event_espresso' |
|
113 | + ); ?> |
|
114 | 114 | </li> |
115 | 115 | <li style="list-style-type: none;"> |
116 | 116 | <strong> |
117 | 117 | <?php printf( |
118 | - esc_html__('View Invoice for Transaction %1$s', 'event_espresso'), |
|
119 | - '<span class="dashicons dashicons-media-spreadsheet"></span>' |
|
120 | - ); ?> |
|
118 | + esc_html__('View Invoice for Transaction %1$s', 'event_espresso'), |
|
119 | + '<span class="dashicons dashicons-media-spreadsheet"></span>' |
|
120 | + ); ?> |
|
121 | 121 | </strong> |
122 | 122 | <br /> |
123 | 123 | <?php esc_html_e('Takes you to the invoice for the transaction.', 'event_espresso'); ?> |
@@ -125,9 +125,9 @@ discard block |
||
125 | 125 | <li style="list-style-type: none;"> |
126 | 126 | <strong> |
127 | 127 | <?php printf( |
128 | - esc_html__('View Receipt for Transaction %1$s', 'event_espresso'), |
|
129 | - '<span class="dashicons dashicons-text-page"></span>' |
|
130 | - ); ?> |
|
128 | + esc_html__('View Receipt for Transaction %1$s', 'event_espresso'), |
|
129 | + '<span class="dashicons dashicons-text-page"></span>' |
|
130 | + ); ?> |
|
131 | 131 | </strong> |
132 | 132 | <br /> |
133 | 133 | <?php esc_html_e('Takes you to the receipt for the transaction.', 'event_espresso'); ?> |
@@ -135,36 +135,36 @@ discard block |
||
135 | 135 | <li style="list-style-type: none;"> |
136 | 136 | <strong> |
137 | 137 | <?php printf( |
138 | - esc_html__('View Registration Details %1$s', 'event_espresso'), |
|
139 | - '<span class="dashicons dashicons-clipboard"></span>' |
|
140 | - ); ?> |
|
138 | + esc_html__('View Registration Details %1$s', 'event_espresso'), |
|
139 | + '<span class="dashicons dashicons-clipboard"></span>' |
|
140 | + ); ?> |
|
141 | 141 | </strong> |
142 | 142 | <br /> |
143 | 143 | <?php printf( |
144 | - esc_html__( |
|
145 | - 'Clicking this icon will take you to the registration page for this transaction. You can also get there via the %sRegistrations page%s.', |
|
146 | - 'event_espresso' |
|
147 | - ), |
|
148 | - '<a href="admin.php?page=espresso_registrations">', |
|
149 | - '</a>' |
|
150 | - ); ?> |
|
144 | + esc_html__( |
|
145 | + 'Clicking this icon will take you to the registration page for this transaction. You can also get there via the %sRegistrations page%s.', |
|
146 | + 'event_espresso' |
|
147 | + ), |
|
148 | + '<a href="admin.php?page=espresso_registrations">', |
|
149 | + '</a>' |
|
150 | + ); ?> |
|
151 | 151 | </li> |
152 | 152 | <li style="list-style-type: none;"> |
153 | 153 | <strong> |
154 | 154 | <?php printf( |
155 | - esc_html__('Send Payment Reminder %1$s', 'event_espresso'), |
|
156 | - '<span class="dashicons dashicons-email-alt"></span>' |
|
157 | - ); ?> |
|
155 | + esc_html__('Send Payment Reminder %1$s', 'event_espresso'), |
|
156 | + '<span class="dashicons dashicons-email-alt"></span>' |
|
157 | + ); ?> |
|
158 | 158 | </strong> |
159 | 159 | <br /> |
160 | 160 | <?php printf( |
161 | - esc_html__( |
|
162 | - 'Emails the primary registrant the Payment Reminder message. This is set up in the %sMessages page%s.', |
|
163 | - 'event_espresso' |
|
164 | - ), |
|
165 | - '<a href="admin.php?page=espresso_messages">', |
|
166 | - '</a>' |
|
167 | - ); ?> |
|
161 | + esc_html__( |
|
162 | + 'Emails the primary registrant the Payment Reminder message. This is set up in the %sMessages page%s.', |
|
163 | + 'event_espresso' |
|
164 | + ), |
|
165 | + '<a href="admin.php?page=espresso_messages">', |
|
166 | + '</a>' |
|
167 | + ); ?> |
|
168 | 168 | </li> |
169 | 169 | </ul> |
170 | 170 | </li> |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | </thead> |
27 | 27 | <tbody> |
28 | 28 | <?php |
29 | - foreach ($attendees as $att_nmbr => $attendee) : ?> |
|
29 | + foreach ($attendees as $att_nmbr => $attendee) : ?> |
|
30 | 30 | <tr> |
31 | 31 | <th class='jst-cntr no-pad'> |
32 | 32 | <span class="ee-status-dot ee-status-bg--<?php echo esc_attr($attendee['STS_ID']); ?> ee-aria-tooltip" |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | </td> |
46 | 46 | <td class="jst-rght"> |
47 | 47 | <?php |
48 | - $final_price = number_format((float) $attendee['final_price'], 2); |
|
49 | - echo esc_html("$currency_sign $final_price"); |
|
50 | - ?> |
|
48 | + $final_price = number_format((float) $attendee['final_price'], 2); |
|
49 | + echo esc_html("$currency_sign $final_price"); |
|
50 | + ?> |
|
51 | 51 | </td> |
52 | 52 | <td class="jst-left"><?php echo esc_html($attendee['email']); ?></td> |
53 | 53 | <td class="jst-left"><?php echo esc_html($attendee['address']); ?></td> |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | <div id="admin-primary-mbox-dv" class="admin-primary-mbox-dv"> |
11 | 11 | <br /> |
12 | 12 | <?php echo esc_html($attendee_notice); ?> |
13 | - <?php if (! empty($attendees)) : ?> |
|
13 | + <?php if ( ! empty($attendees)) : ?> |
|
14 | 14 | <div class="admin-primary-mbox-tbl-wrap"> |
15 | 15 | <table id="reg-admin-transaction-attendees-table" class="admin-primary-mbox-tbl striped"> |
16 | 16 | <thead> |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | <tr> |
31 | 31 | <th class='jst-cntr no-pad'> |
32 | 32 | <span class="ee-status-dot ee-status-bg--<?php echo esc_attr($attendee['STS_ID']); ?> ee-aria-tooltip" |
33 | - aria-label="<?php echo esc_attr(EEH_Template::pretty_status($attendee['STS_ID'], false, "sentence"));?>"> |
|
33 | + aria-label="<?php echo esc_attr(EEH_Template::pretty_status($attendee['STS_ID'], false, "sentence")); ?>"> |
|
34 | 34 | </span> |
35 | 35 | </th> |
36 | 36 | <td class="jst-left"><?php echo esc_html($att_nmbr); ?></td> |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | aria-label="<?php esc_attr_e('View details for this attendee', 'event_espresso'); ?>" |
41 | 41 | class="ee-aria-tooltip" |
42 | 42 | > |
43 | - <?php echo esc_html($attendee['fname'] . ' ' . $attendee['lname']); ?> |
|
43 | + <?php echo esc_html($attendee['fname'].' '.$attendee['lname']); ?> |
|
44 | 44 | </a> |
45 | 45 | </td> |
46 | 46 | <td class="jst-rght"> |
@@ -22,7 +22,7 @@ |
||
22 | 22 | <?php foreach ($event_attendees as $registration => $attendee) : ?> |
23 | 23 | <tr style="display: table-row;" > |
24 | 24 | <td class="jst-cntr no-pad"> |
25 | - <span class="ee-status-dot ee-status-bg--<?php echo esc_attr($attendee['STS_ID']);?>"> |
|
25 | + <span class="ee-status-dot ee-status-bg--<?php echo esc_attr($attendee['STS_ID']); ?>"> |
|
26 | 26 | </span> |
27 | 27 | </td> |
28 | 28 | <td class='jst-left'><?php echo esc_html($attendee['event_ticket_name']); ?></td> |
@@ -33,11 +33,11 @@ |
||
33 | 33 | <td class="jst-rght"><?php echo wp_kses($attendee['ticket_price'], AllowedTags::getAllowedTags()); ?></td> |
34 | 34 | <td class="jst-left"> |
35 | 35 | <?php |
36 | - $att_link = EE_Admin_Page::add_query_args_and_nonce( |
|
37 | - ['action' => 'view_registration', '_REG_ID' => $registration], |
|
38 | - REG_ADMIN_URL |
|
39 | - ); |
|
40 | - ?> |
|
36 | + $att_link = EE_Admin_Page::add_query_args_and_nonce( |
|
37 | + ['action' => 'view_registration', '_REG_ID' => $registration], |
|
38 | + REG_ADMIN_URL |
|
39 | + ); |
|
40 | + ?> |
|
41 | 41 | <a href="<?php echo esc_url_raw($att_link); ?>" |
42 | 42 | aria-label="<?php esc_attr_e('View details for this registrant', 'event_espresso'); ?>" |
43 | 43 | > |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | 'event_espresso' |
206 | 206 | ); |
207 | 207 | // add specific message for developers if WP_DEBUG in on |
208 | - $error_msg .= '||' . $e->getMessage(); |
|
208 | + $error_msg .= '||'.$e->getMessage(); |
|
209 | 209 | EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
210 | 210 | } |
211 | 211 | } |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | 'event_espresso' |
292 | 292 | ); |
293 | 293 | // add specific message for developers if WP_DEBUG in on |
294 | - $error_msg .= '||' . $e->getMessage(); |
|
294 | + $error_msg .= '||'.$e->getMessage(); |
|
295 | 295 | EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
296 | 296 | } |
297 | 297 | } |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | $transient_key = $request->getRequestParam('key'); |
324 | 324 | |
325 | 325 | // now let's verify transient, if not valid exit immediately |
326 | - if (! get_transient($transient_key)) { |
|
326 | + if ( ! get_transient($transient_key)) { |
|
327 | 327 | /** |
328 | 328 | * trigger error so this gets in the error logs. This is important because it happens on a non-user |
329 | 329 | * request. |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | delete_transient($transient_key); |
336 | 336 | |
337 | 337 | if (apply_filters('FHEE__EED_Messages__run_cron__use_wp_cron', true)) { |
338 | - $method = 'batch_' . $cron_type . '_from_queue'; |
|
338 | + $method = 'batch_'.$cron_type.'_from_queue'; |
|
339 | 339 | if (method_exists(self::$_MSG_PROCESSOR, $method)) { |
340 | 340 | self::$_MSG_PROCESSOR->$method(); |
341 | 341 | } else { |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | $template_pack_collection->rewind(); |
403 | 403 | $template_packs = []; |
404 | 404 | while ($template_pack_collection->valid()) { |
405 | - $template_packs[ $template_pack_collection->current()->dbref ] = $template_pack_collection->current(); |
|
405 | + $template_packs[$template_pack_collection->current()->dbref] = $template_pack_collection->current(); |
|
406 | 406 | $template_pack_collection->next(); |
407 | 407 | } |
408 | 408 | return $template_packs; |
@@ -442,15 +442,15 @@ discard block |
||
442 | 442 | self::$_MSG_PATHS = apply_filters( |
443 | 443 | 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', |
444 | 444 | [ |
445 | - EE_LIBRARIES . 'messages/message_type', |
|
446 | - EE_LIBRARIES . 'messages/messenger', |
|
447 | - EE_LIBRARIES . 'messages/defaults', |
|
448 | - EE_LIBRARIES . 'messages/defaults/email', |
|
449 | - EE_LIBRARIES . 'messages/data_class', |
|
450 | - EE_LIBRARIES . 'messages/validators', |
|
451 | - EE_LIBRARIES . 'messages/validators/email', |
|
452 | - EE_LIBRARIES . 'messages/validators/html', |
|
453 | - EE_LIBRARIES . 'shortcodes', |
|
445 | + EE_LIBRARIES.'messages/message_type', |
|
446 | + EE_LIBRARIES.'messages/messenger', |
|
447 | + EE_LIBRARIES.'messages/defaults', |
|
448 | + EE_LIBRARIES.'messages/defaults/email', |
|
449 | + EE_LIBRARIES.'messages/data_class', |
|
450 | + EE_LIBRARIES.'messages/validators', |
|
451 | + EE_LIBRARIES.'messages/validators/email', |
|
452 | + EE_LIBRARIES.'messages/validators/html', |
|
453 | + EE_LIBRARIES.'shortcodes', |
|
454 | 454 | ] |
455 | 455 | ); |
456 | 456 | } |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | */ |
470 | 470 | protected static function _load_controller() |
471 | 471 | { |
472 | - if (! self::$_MSG_PROCESSOR instanceof EE_Messages_Processor) { |
|
472 | + if ( ! self::$_MSG_PROCESSOR instanceof EE_Messages_Processor) { |
|
473 | 473 | EE_Registry::instance()->load_core('Request_Handler'); |
474 | 474 | self::set_autoloaders(); |
475 | 475 | self::$_EEMSG = EE_Registry::instance()->load_lib('messages'); |
@@ -510,7 +510,7 @@ discard block |
||
510 | 510 | public static function payment(EE_Transaction $transaction, EE_Payment $payment = null) |
511 | 511 | { |
512 | 512 | // if there's no payment object, then we cannot do a payment type message! |
513 | - if (! $payment instanceof EE_Payment) { |
|
513 | + if ( ! $payment instanceof EE_Payment) { |
|
514 | 514 | return; |
515 | 515 | } |
516 | 516 | self::_load_controller(); |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | public static function maybe_registration(EE_Registration $registration, $extra_details = []) |
558 | 558 | { |
559 | 559 | |
560 | - if (! self::_verify_registration_notification_send($registration, $extra_details)) { |
|
560 | + if ( ! self::_verify_registration_notification_send($registration, $extra_details)) { |
|
561 | 561 | // no messages please |
562 | 562 | return; |
563 | 563 | } |
@@ -648,7 +648,7 @@ discard block |
||
648 | 648 | } else { |
649 | 649 | // frontend request (either regular or via AJAX) |
650 | 650 | // TXN is NOT finalized ? |
651 | - if (! isset($extra_details['finalized']) || $extra_details['finalized'] === false) { |
|
651 | + if ( ! isset($extra_details['finalized']) || $extra_details['finalized'] === false) { |
|
652 | 652 | return false; |
653 | 653 | } |
654 | 654 | // return visit but nothing changed ??? |
@@ -740,7 +740,7 @@ discard block |
||
740 | 740 | |
741 | 741 | // make sure any incoming request data is set on the request so that it gets picked up later. |
742 | 742 | foreach ((array) $req_data as $request_key => $request_value) { |
743 | - if (! $request->requestParamIsSet($request_key)) { |
|
743 | + if ( ! $request->requestParamIsSet($request_key)) { |
|
744 | 744 | $request->setRequestParam($request_key, $request_value); |
745 | 745 | } |
746 | 746 | } |
@@ -780,7 +780,7 @@ discard block |
||
780 | 780 | self::_load_controller(); |
781 | 781 | |
782 | 782 | $msgID = self::getRequest()->getRequestParam('MSG_ID', 0, 'int'); |
783 | - if (! $msgID) { |
|
783 | + if ( ! $msgID) { |
|
784 | 784 | EE_Error::add_error( |
785 | 785 | esc_html__( |
786 | 786 | 'Something went wrong because there is no "MSG_ID" value in the request', |
@@ -973,14 +973,14 @@ discard block |
||
973 | 973 | // get the message template group. |
974 | 974 | $msg_template_group = EEM_Message_Template_Group::instance()->get_one([$template_query_params]); |
975 | 975 | // if we don't have an EE_Message_Template_Group then return |
976 | - if (! $msg_template_group instanceof EE_Message_Template_Group) { |
|
976 | + if ( ! $msg_template_group instanceof EE_Message_Template_Group) { |
|
977 | 977 | // remove EVT_ID from query params so that global templates get picked up |
978 | 978 | unset($template_query_params['Event.EVT_ID']); |
979 | 979 | // get global template as the fallback |
980 | 980 | $msg_template_group = EEM_Message_Template_Group::instance()->get_one([$template_query_params]); |
981 | 981 | } |
982 | 982 | // if we don't have an EE_Message_Template_Group then return |
983 | - if (! $msg_template_group instanceof EE_Message_Template_Group) { |
|
983 | + if ( ! $msg_template_group instanceof EE_Message_Template_Group) { |
|
984 | 984 | return ''; |
985 | 985 | } |
986 | 986 | // generate the URL |
@@ -1016,7 +1016,7 @@ discard block |
||
1016 | 1016 | public static function preview_message($type, $context, $messenger, $send = false) |
1017 | 1017 | { |
1018 | 1018 | self::_load_controller(); |
1019 | - $message_to_generate = new EE_Message_To_Generate( |
|
1019 | + $message_to_generate = new EE_Message_To_Generate( |
|
1020 | 1020 | $messenger, |
1021 | 1021 | $type, |
1022 | 1022 | [], |
@@ -1098,7 +1098,7 @@ discard block |
||
1098 | 1098 | public static function generate_now($message_ids) |
1099 | 1099 | { |
1100 | 1100 | self::_load_controller(); |
1101 | - $messages = EEM_Message::instance()->get_all( |
|
1101 | + $messages = EEM_Message::instance()->get_all( |
|
1102 | 1102 | [ |
1103 | 1103 | 0 => [ |
1104 | 1104 | 'MSG_ID' => ['IN', $message_ids], |
@@ -1111,7 +1111,7 @@ discard block |
||
1111 | 1111 | $generated_queue = self::$_MSG_PROCESSOR->batch_generate_from_queue($messages); |
1112 | 1112 | } |
1113 | 1113 | |
1114 | - if (! $generated_queue instanceof EE_Messages_Queue) { |
|
1114 | + if ( ! $generated_queue instanceof EE_Messages_Queue) { |
|
1115 | 1115 | EE_Error::add_error( |
1116 | 1116 | esc_html__( |
1117 | 1117 | 'The messages were not generated. This could mean there is already a batch being generated on a separate request, or because the selected messages are not ready for generation. Please wait a minute or two and try again.', |
@@ -1142,7 +1142,7 @@ discard block |
||
1142 | 1142 | public static function send_now($message_ids) |
1143 | 1143 | { |
1144 | 1144 | self::_load_controller(); |
1145 | - $messages = EEM_Message::instance()->get_all( |
|
1145 | + $messages = EEM_Message::instance()->get_all( |
|
1146 | 1146 | [ |
1147 | 1147 | 0 => [ |
1148 | 1148 | 'MSG_ID' => ['IN', $message_ids], |
@@ -1158,7 +1158,7 @@ discard block |
||
1158 | 1158 | $sent_queue = self::$_MSG_PROCESSOR->batch_send_from_queue($messages); |
1159 | 1159 | } |
1160 | 1160 | |
1161 | - if (! $sent_queue instanceof EE_Messages_Queue) { |
|
1161 | + if ( ! $sent_queue instanceof EE_Messages_Queue) { |
|
1162 | 1162 | EE_Error::add_error( |
1163 | 1163 | esc_html__( |
1164 | 1164 | 'The messages were not sent. This could mean there is already a batch being sent on a separate request, or because the selected messages are not sendable. Please wait a minute or two and try again.', |
@@ -1346,7 +1346,7 @@ discard block |
||
1346 | 1346 | $info['TXN_status'] = $transaction->status_ID(); |
1347 | 1347 | $info['TXN_reg_steps'] = $transaction->reg_steps(); |
1348 | 1348 | if ($transaction->ID()) { |
1349 | - $index = 'EE_Transaction: ' . $transaction->ID(); |
|
1349 | + $index = 'EE_Transaction: '.$transaction->ID(); |
|
1350 | 1350 | EEH_Debug_Tools::log($class, $func, $line, $info, $display_request, $index); |
1351 | 1351 | } |
1352 | 1352 | } |
@@ -17,1365 +17,1365 @@ |
||
17 | 17 | */ |
18 | 18 | class EED_Messages extends EED_Module |
19 | 19 | { |
20 | - /** |
|
21 | - * This holds the EE_messages controller |
|
22 | - * |
|
23 | - * @deprecated 4.9.0 |
|
24 | - * @var EE_messages $_EEMSG |
|
25 | - */ |
|
26 | - protected static $_EEMSG; |
|
27 | - |
|
28 | - /** |
|
29 | - * @type EE_Message_Resource_Manager $_message_resource_manager |
|
30 | - */ |
|
31 | - protected static $_message_resource_manager; |
|
32 | - |
|
33 | - /** |
|
34 | - * This holds the EE_Messages_Processor business class. |
|
35 | - * |
|
36 | - * @type EE_Messages_Processor |
|
37 | - */ |
|
38 | - protected static $_MSG_PROCESSOR; |
|
39 | - |
|
40 | - /** |
|
41 | - * holds all the paths for various messages components. |
|
42 | - * Utilized by autoloader registry |
|
43 | - * |
|
44 | - * @var array |
|
45 | - */ |
|
46 | - protected static $_MSG_PATHS; |
|
47 | - |
|
48 | - |
|
49 | - /** |
|
50 | - * This will hold an array of messages template packs that are registered in the messages system. |
|
51 | - * Format is: |
|
52 | - * array( |
|
53 | - * 'template_pack_dbref' => EE_Messages_Template_Pack (instance) |
|
54 | - * ) |
|
55 | - * |
|
56 | - * @var EE_Messages_Template_Pack[] |
|
57 | - */ |
|
58 | - protected static $_TMP_PACKS = []; |
|
59 | - |
|
60 | - |
|
61 | - /** |
|
62 | - * @return EED_Messages|EED_Module |
|
63 | - * @throws EE_Error |
|
64 | - * @throws ReflectionException |
|
65 | - */ |
|
66 | - public static function instance() |
|
67 | - { |
|
68 | - return parent::get_instance(__CLASS__); |
|
69 | - } |
|
70 | - |
|
71 | - |
|
72 | - /** |
|
73 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
74 | - * |
|
75 | - * @return void |
|
76 | - * @since 4.5.0 |
|
77 | - */ |
|
78 | - public static function set_hooks() |
|
79 | - { |
|
80 | - // actions |
|
81 | - add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', ['EED_Messages', 'payment'], 10, 2); |
|
82 | - add_action( |
|
83 | - 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', |
|
84 | - ['EED_Messages', 'maybe_registration'], |
|
85 | - 10, |
|
86 | - 2 |
|
87 | - ); |
|
88 | - // filters |
|
89 | - add_filter( |
|
90 | - 'FHEE__EE_Registration__receipt_url__receipt_url', |
|
91 | - ['EED_Messages', 'registration_message_trigger_url'], |
|
92 | - 10, |
|
93 | - 4 |
|
94 | - ); |
|
95 | - add_filter( |
|
96 | - 'FHEE__EE_Registration__invoice_url__invoice_url', |
|
97 | - ['EED_Messages', 'registration_message_trigger_url'], |
|
98 | - 10, |
|
99 | - 4 |
|
100 | - ); |
|
101 | - // register routes |
|
102 | - self::_register_routes(); |
|
103 | - } |
|
104 | - |
|
105 | - |
|
106 | - /** |
|
107 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
108 | - * |
|
109 | - * @access public |
|
110 | - * @return void |
|
111 | - */ |
|
112 | - public static function set_hooks_admin() |
|
113 | - { |
|
114 | - // actions |
|
115 | - add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', ['EED_Messages', 'payment'], 10, 2); |
|
116 | - add_action( |
|
117 | - 'AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', |
|
118 | - ['EED_Messages', 'payment_reminder'], |
|
119 | - 10 |
|
120 | - ); |
|
121 | - add_action( |
|
122 | - 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', |
|
123 | - ['EED_Messages', 'maybe_registration'], |
|
124 | - 10, |
|
125 | - 3 |
|
126 | - ); |
|
127 | - add_action( |
|
128 | - 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations', |
|
129 | - ['EED_Messages', 'send_newsletter_message'], |
|
130 | - 10, |
|
131 | - 2 |
|
132 | - ); |
|
133 | - add_action( |
|
134 | - 'AHEE__EES_Espresso_Cancelled__process_shortcode__transaction', |
|
135 | - ['EED_Messages', 'cancelled_registration'], |
|
136 | - 10 |
|
137 | - ); |
|
138 | - add_action( |
|
139 | - 'AHEE__EE_Admin_Page___process_admin_payment_notification', |
|
140 | - ['EED_Messages', 'process_admin_payment'], |
|
141 | - 10, |
|
142 | - 1 |
|
143 | - ); |
|
144 | - // filters |
|
145 | - add_filter( |
|
146 | - 'FHEE__EE_Admin_Page___process_resend_registration__success', |
|
147 | - ['EED_Messages', 'process_resend'], |
|
148 | - 10, |
|
149 | - 2 |
|
150 | - ); |
|
151 | - add_filter( |
|
152 | - 'FHEE__EE_Registration__receipt_url__receipt_url', |
|
153 | - ['EED_Messages', 'registration_message_trigger_url'], |
|
154 | - 10, |
|
155 | - 4 |
|
156 | - ); |
|
157 | - add_filter( |
|
158 | - 'FHEE__EE_Registration__invoice_url__invoice_url', |
|
159 | - ['EED_Messages', 'registration_message_trigger_url'], |
|
160 | - 10, |
|
161 | - 4 |
|
162 | - ); |
|
163 | - } |
|
164 | - |
|
165 | - |
|
166 | - /** |
|
167 | - * All the message triggers done by route go in here. |
|
168 | - * |
|
169 | - * @return void |
|
170 | - * @since 4.5.0 |
|
171 | - */ |
|
172 | - protected static function _register_routes() |
|
173 | - { |
|
174 | - EED_Module::registerRoute('msg_url_trigger', 'Messages', 'run'); |
|
175 | - EED_Module::registerRoute('msg_cron_trigger', 'Messages', 'execute_batch_request'); |
|
176 | - EED_Module::registerRoute('msg_browser_trigger', 'Messages', 'browser_trigger'); |
|
177 | - EED_Module::registerRoute('msg_browser_error_trigger', 'Messages', 'browser_error_trigger'); |
|
178 | - do_action('AHEE__EED_Messages___register_routes'); |
|
179 | - } |
|
180 | - |
|
181 | - |
|
182 | - /** |
|
183 | - * This is called when a browser display trigger is executed. |
|
184 | - * The browser display trigger is typically used when a already generated message is displayed directly in the |
|
185 | - * browser. |
|
186 | - * |
|
187 | - * @param WP $WP |
|
188 | - * @throws EE_Error |
|
189 | - * @throws InvalidArgumentException |
|
190 | - * @throws ReflectionException |
|
191 | - * @throws InvalidDataTypeException |
|
192 | - * @throws InvalidInterfaceException |
|
193 | - * @since 4.9.0 |
|
194 | - */ |
|
195 | - public function browser_trigger($WP) |
|
196 | - { |
|
197 | - // ensure controller is loaded |
|
198 | - self::_load_controller(); |
|
199 | - $token = self::getRequest()->getRequestParam('token'); |
|
200 | - try { |
|
201 | - $mtg = new EE_Message_Generated_From_Token($token, 'html', self::$_message_resource_manager); |
|
202 | - self::$_MSG_PROCESSOR->generate_and_send_now($mtg); |
|
203 | - } catch (EE_Error $e) { |
|
204 | - $error_msg = esc_html__( |
|
205 | - 'Please note that a system message failed to send due to a technical issue.', |
|
206 | - 'event_espresso' |
|
207 | - ); |
|
208 | - // add specific message for developers if WP_DEBUG in on |
|
209 | - $error_msg .= '||' . $e->getMessage(); |
|
210 | - EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
211 | - } |
|
212 | - } |
|
213 | - |
|
214 | - |
|
215 | - /** |
|
216 | - * This is called when a browser error trigger is executed. |
|
217 | - * When triggered this will grab the EE_Message matching the token in the request and use that to get the error |
|
218 | - * message and display it. |
|
219 | - * |
|
220 | - * @param $WP |
|
221 | - * @throws EE_Error |
|
222 | - * @throws InvalidArgumentException |
|
223 | - * @throws InvalidDataTypeException |
|
224 | - * @throws InvalidInterfaceException |
|
225 | - * @throws ReflectionException |
|
226 | - * @since 4.9.0 |
|
227 | - */ |
|
228 | - public function browser_error_trigger($WP) |
|
229 | - { |
|
230 | - $token = self::getRequest()->getRequestParam('token'); |
|
231 | - if ($token) { |
|
232 | - $message = EEM_Message::instance()->get_one_by_token($token); |
|
233 | - if ($message instanceof EE_Message) { |
|
234 | - header('HTTP/1.1 200 OK'); |
|
235 | - $error_msg = nl2br($message->error_message()); |
|
236 | - ?> |
|
20 | + /** |
|
21 | + * This holds the EE_messages controller |
|
22 | + * |
|
23 | + * @deprecated 4.9.0 |
|
24 | + * @var EE_messages $_EEMSG |
|
25 | + */ |
|
26 | + protected static $_EEMSG; |
|
27 | + |
|
28 | + /** |
|
29 | + * @type EE_Message_Resource_Manager $_message_resource_manager |
|
30 | + */ |
|
31 | + protected static $_message_resource_manager; |
|
32 | + |
|
33 | + /** |
|
34 | + * This holds the EE_Messages_Processor business class. |
|
35 | + * |
|
36 | + * @type EE_Messages_Processor |
|
37 | + */ |
|
38 | + protected static $_MSG_PROCESSOR; |
|
39 | + |
|
40 | + /** |
|
41 | + * holds all the paths for various messages components. |
|
42 | + * Utilized by autoloader registry |
|
43 | + * |
|
44 | + * @var array |
|
45 | + */ |
|
46 | + protected static $_MSG_PATHS; |
|
47 | + |
|
48 | + |
|
49 | + /** |
|
50 | + * This will hold an array of messages template packs that are registered in the messages system. |
|
51 | + * Format is: |
|
52 | + * array( |
|
53 | + * 'template_pack_dbref' => EE_Messages_Template_Pack (instance) |
|
54 | + * ) |
|
55 | + * |
|
56 | + * @var EE_Messages_Template_Pack[] |
|
57 | + */ |
|
58 | + protected static $_TMP_PACKS = []; |
|
59 | + |
|
60 | + |
|
61 | + /** |
|
62 | + * @return EED_Messages|EED_Module |
|
63 | + * @throws EE_Error |
|
64 | + * @throws ReflectionException |
|
65 | + */ |
|
66 | + public static function instance() |
|
67 | + { |
|
68 | + return parent::get_instance(__CLASS__); |
|
69 | + } |
|
70 | + |
|
71 | + |
|
72 | + /** |
|
73 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
74 | + * |
|
75 | + * @return void |
|
76 | + * @since 4.5.0 |
|
77 | + */ |
|
78 | + public static function set_hooks() |
|
79 | + { |
|
80 | + // actions |
|
81 | + add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', ['EED_Messages', 'payment'], 10, 2); |
|
82 | + add_action( |
|
83 | + 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', |
|
84 | + ['EED_Messages', 'maybe_registration'], |
|
85 | + 10, |
|
86 | + 2 |
|
87 | + ); |
|
88 | + // filters |
|
89 | + add_filter( |
|
90 | + 'FHEE__EE_Registration__receipt_url__receipt_url', |
|
91 | + ['EED_Messages', 'registration_message_trigger_url'], |
|
92 | + 10, |
|
93 | + 4 |
|
94 | + ); |
|
95 | + add_filter( |
|
96 | + 'FHEE__EE_Registration__invoice_url__invoice_url', |
|
97 | + ['EED_Messages', 'registration_message_trigger_url'], |
|
98 | + 10, |
|
99 | + 4 |
|
100 | + ); |
|
101 | + // register routes |
|
102 | + self::_register_routes(); |
|
103 | + } |
|
104 | + |
|
105 | + |
|
106 | + /** |
|
107 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
108 | + * |
|
109 | + * @access public |
|
110 | + * @return void |
|
111 | + */ |
|
112 | + public static function set_hooks_admin() |
|
113 | + { |
|
114 | + // actions |
|
115 | + add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', ['EED_Messages', 'payment'], 10, 2); |
|
116 | + add_action( |
|
117 | + 'AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', |
|
118 | + ['EED_Messages', 'payment_reminder'], |
|
119 | + 10 |
|
120 | + ); |
|
121 | + add_action( |
|
122 | + 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', |
|
123 | + ['EED_Messages', 'maybe_registration'], |
|
124 | + 10, |
|
125 | + 3 |
|
126 | + ); |
|
127 | + add_action( |
|
128 | + 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations', |
|
129 | + ['EED_Messages', 'send_newsletter_message'], |
|
130 | + 10, |
|
131 | + 2 |
|
132 | + ); |
|
133 | + add_action( |
|
134 | + 'AHEE__EES_Espresso_Cancelled__process_shortcode__transaction', |
|
135 | + ['EED_Messages', 'cancelled_registration'], |
|
136 | + 10 |
|
137 | + ); |
|
138 | + add_action( |
|
139 | + 'AHEE__EE_Admin_Page___process_admin_payment_notification', |
|
140 | + ['EED_Messages', 'process_admin_payment'], |
|
141 | + 10, |
|
142 | + 1 |
|
143 | + ); |
|
144 | + // filters |
|
145 | + add_filter( |
|
146 | + 'FHEE__EE_Admin_Page___process_resend_registration__success', |
|
147 | + ['EED_Messages', 'process_resend'], |
|
148 | + 10, |
|
149 | + 2 |
|
150 | + ); |
|
151 | + add_filter( |
|
152 | + 'FHEE__EE_Registration__receipt_url__receipt_url', |
|
153 | + ['EED_Messages', 'registration_message_trigger_url'], |
|
154 | + 10, |
|
155 | + 4 |
|
156 | + ); |
|
157 | + add_filter( |
|
158 | + 'FHEE__EE_Registration__invoice_url__invoice_url', |
|
159 | + ['EED_Messages', 'registration_message_trigger_url'], |
|
160 | + 10, |
|
161 | + 4 |
|
162 | + ); |
|
163 | + } |
|
164 | + |
|
165 | + |
|
166 | + /** |
|
167 | + * All the message triggers done by route go in here. |
|
168 | + * |
|
169 | + * @return void |
|
170 | + * @since 4.5.0 |
|
171 | + */ |
|
172 | + protected static function _register_routes() |
|
173 | + { |
|
174 | + EED_Module::registerRoute('msg_url_trigger', 'Messages', 'run'); |
|
175 | + EED_Module::registerRoute('msg_cron_trigger', 'Messages', 'execute_batch_request'); |
|
176 | + EED_Module::registerRoute('msg_browser_trigger', 'Messages', 'browser_trigger'); |
|
177 | + EED_Module::registerRoute('msg_browser_error_trigger', 'Messages', 'browser_error_trigger'); |
|
178 | + do_action('AHEE__EED_Messages___register_routes'); |
|
179 | + } |
|
180 | + |
|
181 | + |
|
182 | + /** |
|
183 | + * This is called when a browser display trigger is executed. |
|
184 | + * The browser display trigger is typically used when a already generated message is displayed directly in the |
|
185 | + * browser. |
|
186 | + * |
|
187 | + * @param WP $WP |
|
188 | + * @throws EE_Error |
|
189 | + * @throws InvalidArgumentException |
|
190 | + * @throws ReflectionException |
|
191 | + * @throws InvalidDataTypeException |
|
192 | + * @throws InvalidInterfaceException |
|
193 | + * @since 4.9.0 |
|
194 | + */ |
|
195 | + public function browser_trigger($WP) |
|
196 | + { |
|
197 | + // ensure controller is loaded |
|
198 | + self::_load_controller(); |
|
199 | + $token = self::getRequest()->getRequestParam('token'); |
|
200 | + try { |
|
201 | + $mtg = new EE_Message_Generated_From_Token($token, 'html', self::$_message_resource_manager); |
|
202 | + self::$_MSG_PROCESSOR->generate_and_send_now($mtg); |
|
203 | + } catch (EE_Error $e) { |
|
204 | + $error_msg = esc_html__( |
|
205 | + 'Please note that a system message failed to send due to a technical issue.', |
|
206 | + 'event_espresso' |
|
207 | + ); |
|
208 | + // add specific message for developers if WP_DEBUG in on |
|
209 | + $error_msg .= '||' . $e->getMessage(); |
|
210 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
211 | + } |
|
212 | + } |
|
213 | + |
|
214 | + |
|
215 | + /** |
|
216 | + * This is called when a browser error trigger is executed. |
|
217 | + * When triggered this will grab the EE_Message matching the token in the request and use that to get the error |
|
218 | + * message and display it. |
|
219 | + * |
|
220 | + * @param $WP |
|
221 | + * @throws EE_Error |
|
222 | + * @throws InvalidArgumentException |
|
223 | + * @throws InvalidDataTypeException |
|
224 | + * @throws InvalidInterfaceException |
|
225 | + * @throws ReflectionException |
|
226 | + * @since 4.9.0 |
|
227 | + */ |
|
228 | + public function browser_error_trigger($WP) |
|
229 | + { |
|
230 | + $token = self::getRequest()->getRequestParam('token'); |
|
231 | + if ($token) { |
|
232 | + $message = EEM_Message::instance()->get_one_by_token($token); |
|
233 | + if ($message instanceof EE_Message) { |
|
234 | + header('HTTP/1.1 200 OK'); |
|
235 | + $error_msg = nl2br($message->error_message()); |
|
236 | + ?> |
|
237 | 237 | <!DOCTYPE html> |
238 | 238 | <html> |
239 | 239 | <head></head> |
240 | 240 | <body> |
241 | 241 | <?php echo empty($error_msg) |
242 | - ? esc_html__( |
|
243 | - 'Unfortunately, we were unable to capture the error message for this message.', |
|
244 | - 'event_espresso' |
|
245 | - ) |
|
246 | - : wp_kses( |
|
247 | - $error_msg, |
|
248 | - [ |
|
249 | - 'a' => [ |
|
250 | - 'href' => [], |
|
251 | - 'title' => [], |
|
252 | - ], |
|
253 | - 'span' => [], |
|
254 | - 'div' => [], |
|
255 | - 'p' => [], |
|
256 | - 'strong' => [], |
|
257 | - 'em' => [], |
|
258 | - 'br' => [], |
|
259 | - ] |
|
260 | - ); ?> |
|
242 | + ? esc_html__( |
|
243 | + 'Unfortunately, we were unable to capture the error message for this message.', |
|
244 | + 'event_espresso' |
|
245 | + ) |
|
246 | + : wp_kses( |
|
247 | + $error_msg, |
|
248 | + [ |
|
249 | + 'a' => [ |
|
250 | + 'href' => [], |
|
251 | + 'title' => [], |
|
252 | + ], |
|
253 | + 'span' => [], |
|
254 | + 'div' => [], |
|
255 | + 'p' => [], |
|
256 | + 'strong' => [], |
|
257 | + 'em' => [], |
|
258 | + 'br' => [], |
|
259 | + ] |
|
260 | + ); ?> |
|
261 | 261 | </body> |
262 | 262 | </html> |
263 | 263 | <?php |
264 | - exit; |
|
265 | - } |
|
266 | - } |
|
267 | - } |
|
268 | - |
|
269 | - |
|
270 | - /** |
|
271 | - * This runs when the msg_url_trigger route has initiated. |
|
272 | - * |
|
273 | - * @param WP $WP |
|
274 | - * @throws EE_Error |
|
275 | - * @throws InvalidArgumentException |
|
276 | - * @throws ReflectionException |
|
277 | - * @throws InvalidDataTypeException |
|
278 | - * @throws InvalidInterfaceException |
|
279 | - * @since 4.5.0 |
|
280 | - */ |
|
281 | - public function run($WP) |
|
282 | - { |
|
283 | - // ensure controller is loaded |
|
284 | - self::_load_controller(); |
|
285 | - // attempt to process message |
|
286 | - try { |
|
287 | - /** @type EE_Message_To_Generate_From_Request $message_to_generate */ |
|
288 | - $message_to_generate = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request'); |
|
289 | - self::$_MSG_PROCESSOR->generate_and_send_now($message_to_generate); |
|
290 | - } catch (EE_Error $e) { |
|
291 | - $error_msg = esc_html__( |
|
292 | - 'Please note that a system message failed to send due to a technical issue.', |
|
293 | - 'event_espresso' |
|
294 | - ); |
|
295 | - // add specific message for developers if WP_DEBUG in on |
|
296 | - $error_msg .= '||' . $e->getMessage(); |
|
297 | - EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
298 | - } |
|
299 | - } |
|
300 | - |
|
301 | - |
|
302 | - /** |
|
303 | - * This is triggered by the 'msg_cron_trigger' route. |
|
304 | - * |
|
305 | - * @param WP $WP |
|
306 | - * @throws EE_Error |
|
307 | - */ |
|
308 | - public function execute_batch_request($WP) |
|
309 | - { |
|
310 | - $this->run_cron(); |
|
311 | - header('HTTP/1.1 200 OK'); |
|
312 | - exit(); |
|
313 | - } |
|
314 | - |
|
315 | - |
|
316 | - /** |
|
317 | - * This gets executed on wp_cron jobs or when a batch request is initiated on its own separate non regular wp |
|
318 | - * request. |
|
319 | - * |
|
320 | - * @throws EE_Error |
|
321 | - * @throws ReflectionException |
|
322 | - */ |
|
323 | - public function run_cron() |
|
324 | - { |
|
325 | - self::_load_controller(); |
|
326 | - $request = self::getRequest(); |
|
327 | - // get required vars |
|
328 | - $cron_type = $request->getRequestParam('type'); |
|
329 | - $transient_key = $request->getRequestParam('key'); |
|
330 | - |
|
331 | - // now let's verify transient, if not valid exit immediately |
|
332 | - if (! get_transient($transient_key)) { |
|
333 | - /** |
|
334 | - * trigger error so this gets in the error logs. This is important because it happens on a non-user |
|
335 | - * request. |
|
336 | - */ |
|
337 | - trigger_error(esc_attr__('Invalid Request (Transient does not exist)', 'event_espresso')); |
|
338 | - } |
|
339 | - |
|
340 | - // if made it here, lets' delete the transient to keep the db clean |
|
341 | - delete_transient($transient_key); |
|
342 | - |
|
343 | - if (apply_filters('FHEE__EED_Messages__run_cron__use_wp_cron', true)) { |
|
344 | - $method = 'batch_' . $cron_type . '_from_queue'; |
|
345 | - if (method_exists(self::$_MSG_PROCESSOR, $method)) { |
|
346 | - self::$_MSG_PROCESSOR->$method(); |
|
347 | - } else { |
|
348 | - // no matching task |
|
349 | - /** |
|
350 | - * trigger error so this gets in the error logs. This is important because it happens on a non user |
|
351 | - * request. |
|
352 | - */ |
|
353 | - trigger_error( |
|
354 | - esc_attr( |
|
355 | - sprintf( |
|
356 | - esc_html__('There is no task corresponding to this route %s', 'event_espresso'), |
|
357 | - $cron_type |
|
358 | - ) |
|
359 | - ) |
|
360 | - ); |
|
361 | - } |
|
362 | - } |
|
363 | - |
|
364 | - do_action('FHEE__EED_Messages__run_cron__end'); |
|
365 | - } |
|
366 | - |
|
367 | - |
|
368 | - /** |
|
369 | - * This is used to retrieve the template pack for the given name. |
|
370 | - * Retrieved packs are cached on the static $_TMP_PACKS array. If there is no class matching the given name then |
|
371 | - * the default template pack is returned. |
|
372 | - * |
|
373 | - * @param string $template_pack_name This should correspond to the dbref of the template pack (which is also used |
|
374 | - * in generating the Pack class name). |
|
375 | - * @return EE_Messages_Template_Pack |
|
376 | - * @throws EE_Error |
|
377 | - * @throws InvalidArgumentException |
|
378 | - * @throws ReflectionException |
|
379 | - * @throws InvalidDataTypeException |
|
380 | - * @throws InvalidInterfaceException |
|
381 | - * @deprecated 4.9.0 @see EEH_MSG_Template::get_template_pack() |
|
382 | - */ |
|
383 | - public static function get_template_pack($template_pack_name) |
|
384 | - { |
|
385 | - EE_Registry::instance()->load_helper('MSG_Template'); |
|
386 | - return EEH_MSG_Template::get_template_pack($template_pack_name); |
|
387 | - } |
|
388 | - |
|
389 | - |
|
390 | - /** |
|
391 | - * Retrieves an array of all template packs. |
|
392 | - * Array is in the format array( 'dbref' => EE_Messages_Template_Pack ) |
|
393 | - * |
|
394 | - * @return EE_Messages_Template_Pack[] |
|
395 | - * @throws EE_Error |
|
396 | - * @throws InvalidArgumentException |
|
397 | - * @throws ReflectionException |
|
398 | - * @throws InvalidDataTypeException |
|
399 | - * @throws InvalidInterfaceException |
|
400 | - * @deprecated 4.9.0 @see EEH_MSG_Template_Pack::get_template_pack_collection |
|
401 | - */ |
|
402 | - public static function get_template_packs() |
|
403 | - { |
|
404 | - EE_Registry::instance()->load_helper('MSG_Template'); |
|
405 | - |
|
406 | - // for backward compat, let's make sure this returns in the same format as originally. |
|
407 | - $template_pack_collection = EEH_MSG_Template::get_template_pack_collection(); |
|
408 | - $template_pack_collection->rewind(); |
|
409 | - $template_packs = []; |
|
410 | - while ($template_pack_collection->valid()) { |
|
411 | - $template_packs[ $template_pack_collection->current()->dbref ] = $template_pack_collection->current(); |
|
412 | - $template_pack_collection->next(); |
|
413 | - } |
|
414 | - return $template_packs; |
|
415 | - } |
|
416 | - |
|
417 | - |
|
418 | - /** |
|
419 | - * This simply makes sure the autoloaders are registered for the EE_messages system. |
|
420 | - * |
|
421 | - * @return void |
|
422 | - * @throws EE_Error |
|
423 | - * @since 4.5.0 |
|
424 | - */ |
|
425 | - public static function set_autoloaders() |
|
426 | - { |
|
427 | - if (empty(self::$_MSG_PATHS)) { |
|
428 | - self::_set_messages_paths(); |
|
429 | - foreach (self::$_MSG_PATHS as $path) { |
|
430 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder($path); |
|
431 | - } |
|
432 | - // add aliases |
|
433 | - EEH_Autoloader::add_alias('EE_messages', 'EE_messages'); |
|
434 | - EEH_Autoloader::add_alias('EE_messenger', 'EE_messenger'); |
|
435 | - } |
|
436 | - } |
|
437 | - |
|
438 | - |
|
439 | - /** |
|
440 | - * Take care of adding all the paths for the messages components to the $_MSG_PATHS property |
|
441 | - * for use by the Messages Autoloaders |
|
442 | - * |
|
443 | - * @return void. |
|
444 | - * @since 4.5.0 |
|
445 | - */ |
|
446 | - protected static function _set_messages_paths() |
|
447 | - { |
|
448 | - self::$_MSG_PATHS = apply_filters( |
|
449 | - 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', |
|
450 | - [ |
|
451 | - EE_LIBRARIES . 'messages/message_type', |
|
452 | - EE_LIBRARIES . 'messages/messenger', |
|
453 | - EE_LIBRARIES . 'messages/defaults', |
|
454 | - EE_LIBRARIES . 'messages/defaults/email', |
|
455 | - EE_LIBRARIES . 'messages/data_class', |
|
456 | - EE_LIBRARIES . 'messages/validators', |
|
457 | - EE_LIBRARIES . 'messages/validators/email', |
|
458 | - EE_LIBRARIES . 'messages/validators/html', |
|
459 | - EE_LIBRARIES . 'shortcodes', |
|
460 | - ] |
|
461 | - ); |
|
462 | - } |
|
463 | - |
|
464 | - |
|
465 | - /** |
|
466 | - * Takes care of loading dependencies |
|
467 | - * |
|
468 | - * @return void |
|
469 | - * @throws EE_Error |
|
470 | - * @throws InvalidArgumentException |
|
471 | - * @throws ReflectionException |
|
472 | - * @throws InvalidDataTypeException |
|
473 | - * @throws InvalidInterfaceException |
|
474 | - * @since 4.5.0 |
|
475 | - */ |
|
476 | - protected static function _load_controller() |
|
477 | - { |
|
478 | - if (! self::$_MSG_PROCESSOR instanceof EE_Messages_Processor) { |
|
479 | - EE_Registry::instance()->load_core('Request_Handler'); |
|
480 | - self::set_autoloaders(); |
|
481 | - self::$_EEMSG = EE_Registry::instance()->load_lib('messages'); |
|
482 | - self::$_MSG_PROCESSOR = EE_Registry::instance()->load_lib('Messages_Processor'); |
|
483 | - self::$_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
484 | - } |
|
485 | - } |
|
486 | - |
|
487 | - |
|
488 | - /** |
|
489 | - * @param EE_Transaction $transaction |
|
490 | - * @throws EE_Error |
|
491 | - * @throws InvalidArgumentException |
|
492 | - * @throws InvalidDataTypeException |
|
493 | - * @throws InvalidInterfaceException |
|
494 | - * @throws ReflectionException |
|
495 | - */ |
|
496 | - public static function payment_reminder(EE_Transaction $transaction) |
|
497 | - { |
|
498 | - self::_load_controller(); |
|
499 | - $data = [$transaction, null]; |
|
500 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers('payment_reminder', $data); |
|
501 | - } |
|
502 | - |
|
503 | - |
|
504 | - /** |
|
505 | - * Any messages triggers for after successful gateway payments should go in here. |
|
506 | - * |
|
507 | - * @param EE_Transaction $transaction object |
|
508 | - * @param EE_Payment|null $payment object |
|
509 | - * @return void |
|
510 | - * @throws EE_Error |
|
511 | - * @throws InvalidArgumentException |
|
512 | - * @throws ReflectionException |
|
513 | - * @throws InvalidDataTypeException |
|
514 | - * @throws InvalidInterfaceException |
|
515 | - */ |
|
516 | - public static function payment(EE_Transaction $transaction, EE_Payment $payment = null) |
|
517 | - { |
|
518 | - // if there's no payment object, then we cannot do a payment type message! |
|
519 | - if (! $payment instanceof EE_Payment) { |
|
520 | - return; |
|
521 | - } |
|
522 | - self::_load_controller(); |
|
523 | - $data = [$transaction, $payment]; |
|
524 | - EE_Registry::instance()->load_helper('MSG_Template'); |
|
525 | - $message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID()); |
|
526 | - // if payment amount is less than 0 then switch to payment_refund message type. |
|
527 | - $message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type; |
|
528 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data); |
|
529 | - } |
|
530 | - |
|
531 | - |
|
532 | - /** |
|
533 | - * @param EE_Transaction $transaction |
|
534 | - * @throws EE_Error |
|
535 | - * @throws InvalidArgumentException |
|
536 | - * @throws InvalidDataTypeException |
|
537 | - * @throws InvalidInterfaceException |
|
538 | - * @throws ReflectionException |
|
539 | - */ |
|
540 | - public static function cancelled_registration(EE_Transaction $transaction) |
|
541 | - { |
|
542 | - self::_load_controller(); |
|
543 | - $data = [$transaction, null]; |
|
544 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers('cancelled_registration', $data); |
|
545 | - } |
|
546 | - |
|
547 | - |
|
548 | - /** |
|
549 | - * Trigger for Registration messages |
|
550 | - * Note that what registration message type is sent depends on what the reg status is for the registrations on the |
|
551 | - * incoming transaction. |
|
552 | - * |
|
553 | - * @param EE_Registration $registration |
|
554 | - * @param array $extra_details |
|
555 | - * @return void |
|
556 | - * @throws EE_Error |
|
557 | - * @throws InvalidArgumentException |
|
558 | - * @throws InvalidDataTypeException |
|
559 | - * @throws InvalidInterfaceException |
|
560 | - * @throws ReflectionException |
|
561 | - * @throws EntityNotFoundException |
|
562 | - */ |
|
563 | - public static function maybe_registration(EE_Registration $registration, $extra_details = []) |
|
564 | - { |
|
565 | - |
|
566 | - if (! self::_verify_registration_notification_send($registration, $extra_details)) { |
|
567 | - // no messages please |
|
568 | - return; |
|
569 | - } |
|
570 | - |
|
571 | - // get all non-trashed registrations so we make sure we send messages for the right status. |
|
572 | - $all_registrations = $registration->transaction()->registrations( |
|
573 | - [ |
|
574 | - ['REG_deleted' => false], |
|
575 | - 'order_by' => [ |
|
576 | - 'Event.EVT_name' => 'ASC', |
|
577 | - 'Attendee.ATT_lname' => 'ASC', |
|
578 | - 'Attendee.ATT_fname' => 'ASC', |
|
579 | - ], |
|
580 | - ] |
|
581 | - ); |
|
582 | - // cached array of statuses so we only trigger messages once per status. |
|
583 | - $statuses_sent = []; |
|
584 | - self::_load_controller(); |
|
585 | - $mtgs = []; |
|
586 | - |
|
587 | - // loop through registrations and trigger messages once per status. |
|
588 | - foreach ($all_registrations as $reg) { |
|
589 | - // already triggered? |
|
590 | - if (in_array($reg->status_ID(), $statuses_sent)) { |
|
591 | - continue; |
|
592 | - } |
|
593 | - |
|
594 | - $message_type = EEH_MSG_Template::convert_reg_status_to_message_type($reg->status_ID()); |
|
595 | - $mtgs = array_merge( |
|
596 | - $mtgs, |
|
597 | - self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers( |
|
598 | - $message_type, |
|
599 | - [$registration->transaction(), null, $reg->status_ID()] |
|
600 | - ) |
|
601 | - ); |
|
602 | - $statuses_sent[] = $reg->status_ID(); |
|
603 | - } |
|
604 | - |
|
605 | - if (count($statuses_sent) > 1) { |
|
606 | - $mtgs = array_merge( |
|
607 | - $mtgs, |
|
608 | - self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers( |
|
609 | - 'registration_summary', |
|
610 | - [$registration->transaction(), null] |
|
611 | - ) |
|
612 | - ); |
|
613 | - } |
|
614 | - |
|
615 | - // batch queue and initiate request |
|
616 | - self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($mtgs); |
|
617 | - self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority(); |
|
618 | - } |
|
619 | - |
|
620 | - |
|
621 | - /** |
|
622 | - * This is a helper method used to very whether a registration notification should be sent or |
|
623 | - * not. Prevents duplicate notifications going out for registration context notifications. |
|
624 | - * |
|
625 | - * @param EE_Registration $registration [description] |
|
626 | - * @param array $extra_details [description] |
|
627 | - * @return bool true = send away, false = nope halt the presses. |
|
628 | - */ |
|
629 | - protected static function _verify_registration_notification_send( |
|
630 | - EE_Registration $registration, |
|
631 | - $extra_details = [] |
|
632 | - ) { |
|
633 | - $request = self::getRequest(); |
|
634 | - if ( |
|
635 | - ! $request->getRequestParam('non_primary_reg_notification', 0, 'int') |
|
636 | - && ! $registration->is_primary_registrant() |
|
637 | - ) { |
|
638 | - return false; |
|
639 | - } |
|
640 | - // first we check if we're in admin and not doing front ajax |
|
641 | - if ( |
|
642 | - ($request->isAdmin() || $request->isAdminAjax()) |
|
643 | - && ! $request->isFrontAjax() |
|
644 | - ) { |
|
645 | - $status_change = $request->getRequestParam('txn_reg_status_change', [], 'int', true); |
|
646 | - // make sure appropriate admin params are set for sending messages |
|
647 | - if ( |
|
648 | - ! isset($status_change['send_notifications']) |
|
649 | - || (isset($status_change['send_notifications']) && ! $status_change['send_notifications']) |
|
650 | - ) { |
|
651 | - // no messages sent please. |
|
652 | - return false; |
|
653 | - } |
|
654 | - } else { |
|
655 | - // frontend request (either regular or via AJAX) |
|
656 | - // TXN is NOT finalized ? |
|
657 | - if (! isset($extra_details['finalized']) || $extra_details['finalized'] === false) { |
|
658 | - return false; |
|
659 | - } |
|
660 | - // return visit but nothing changed ??? |
|
661 | - if ( |
|
662 | - isset($extra_details['revisit'], $extra_details['status_updates']) |
|
663 | - && $extra_details['revisit'] |
|
664 | - && ! $extra_details['status_updates'] |
|
665 | - ) { |
|
666 | - return false; |
|
667 | - } |
|
668 | - // NOT sending messages && reg status is something other than "Not-Approved" |
|
669 | - if ( |
|
670 | - ! apply_filters('FHEE__EED_Messages___maybe_registration__deliver_notifications', false) |
|
671 | - && $registration->status_ID() !== RegStatus::AWAITING_REVIEW |
|
672 | - ) { |
|
673 | - return false; |
|
674 | - } |
|
675 | - } |
|
676 | - // release the kraken |
|
677 | - return true; |
|
678 | - } |
|
679 | - |
|
680 | - |
|
681 | - /** |
|
682 | - * Simply returns an array indexed by Registration Status ID and the related message_type name associated with that |
|
683 | - * status id. |
|
684 | - * |
|
685 | - * @param string $reg_status |
|
686 | - * @return array |
|
687 | - * @throws EE_Error |
|
688 | - * @throws InvalidArgumentException |
|
689 | - * @throws ReflectionException |
|
690 | - * @throws InvalidDataTypeException |
|
691 | - * @throws InvalidInterfaceException |
|
692 | - * @deprecated 4.9.0 Use EEH_MSG_Template::reg_status_to_message_type_array() |
|
693 | - * or EEH_MSG_Template::convert_reg_status_to_message_type |
|
694 | - */ |
|
695 | - protected static function _get_reg_status_array($reg_status = '') |
|
696 | - { |
|
697 | - EE_Registry::instance()->load_helper('MSG_Template'); |
|
698 | - return EEH_MSG_Template::convert_reg_status_to_message_type($reg_status) |
|
699 | - ? EEH_MSG_Template::convert_reg_status_to_message_type($reg_status) |
|
700 | - : EEH_MSG_Template::reg_status_to_message_type_array(); |
|
701 | - } |
|
702 | - |
|
703 | - |
|
704 | - /** |
|
705 | - * Simply returns the payment message type for the given payment status. |
|
706 | - * |
|
707 | - * @param string $payment_status The payment status being matched. |
|
708 | - * @return bool|string The payment message type slug matching the status or false if no match. |
|
709 | - * @throws EE_Error |
|
710 | - * @throws InvalidArgumentException |
|
711 | - * @throws ReflectionException |
|
712 | - * @throws InvalidDataTypeException |
|
713 | - * @throws InvalidInterfaceException |
|
714 | - * @deprecated 4.9.0 Use EEH_MSG_Template::payment_status_to_message_type_array |
|
715 | - * or EEH_MSG_Template::convert_payment_status_to_message_type |
|
716 | - */ |
|
717 | - protected static function _get_payment_message_type($payment_status) |
|
718 | - { |
|
719 | - EE_Registry::instance()->load_helper('MSG_Template'); |
|
720 | - return EEH_MSG_Template::convert_payment_status_to_message_type($payment_status) |
|
721 | - ? EEH_MSG_Template::convert_payment_status_to_message_type($payment_status) |
|
722 | - : false; |
|
723 | - } |
|
724 | - |
|
725 | - |
|
726 | - /** |
|
727 | - * Message triggers for a resending already sent message(s) (via EE_Message list table) |
|
728 | - * |
|
729 | - * @access public |
|
730 | - * @param array $req_data This is the $_POST & $_GET data sent from EE_Admin Pages |
|
731 | - * @return bool success/fail |
|
732 | - * @throws EE_Error |
|
733 | - * @throws InvalidArgumentException |
|
734 | - * @throws InvalidDataTypeException |
|
735 | - * @throws InvalidInterfaceException |
|
736 | - * @throws ReflectionException |
|
737 | - */ |
|
738 | - public static function process_resend(array $req_data = []) |
|
739 | - { |
|
740 | - self::_load_controller(); |
|
741 | - $request = self::getRequest(); |
|
742 | - // if $msgID in this request then skip to the new resend_message |
|
743 | - if ($request->getRequestParam('MSG_ID')) { |
|
744 | - return self::resend_message(); |
|
745 | - } |
|
746 | - |
|
747 | - // make sure any incoming request data is set on the request so that it gets picked up later. |
|
748 | - foreach ((array) $req_data as $request_key => $request_value) { |
|
749 | - if (! $request->requestParamIsSet($request_key)) { |
|
750 | - $request->setRequestParam($request_key, $request_value); |
|
751 | - } |
|
752 | - } |
|
753 | - |
|
754 | - if ( |
|
755 | - ! $messages_to_send = self::$_MSG_PROCESSOR->setup_messages_to_generate_from_registration_ids_in_request() |
|
756 | - ) { |
|
757 | - return false; |
|
758 | - } |
|
759 | - |
|
760 | - try { |
|
761 | - self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($messages_to_send); |
|
762 | - self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority(); |
|
763 | - } catch (EE_Error $e) { |
|
764 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
765 | - return false; |
|
766 | - } |
|
767 | - EE_Error::add_success( |
|
768 | - esc_html__('Messages have been successfully queued for generation and sending.', 'event_espresso') |
|
769 | - ); |
|
770 | - return true; // everything got queued. |
|
771 | - } |
|
772 | - |
|
773 | - |
|
774 | - /** |
|
775 | - * Message triggers for a resending already sent message(s) (via EE_Message list table) |
|
776 | - * |
|
777 | - * @return bool |
|
778 | - * @throws EE_Error |
|
779 | - * @throws InvalidArgumentException |
|
780 | - * @throws InvalidDataTypeException |
|
781 | - * @throws InvalidInterfaceException |
|
782 | - * @throws ReflectionException |
|
783 | - */ |
|
784 | - public static function resend_message() |
|
785 | - { |
|
786 | - self::_load_controller(); |
|
787 | - |
|
788 | - $msgID = self::getRequest()->getRequestParam('MSG_ID', 0, 'int'); |
|
789 | - if (! $msgID) { |
|
790 | - EE_Error::add_error( |
|
791 | - esc_html__( |
|
792 | - 'Something went wrong because there is no "MSG_ID" value in the request', |
|
793 | - 'event_espresso' |
|
794 | - ), |
|
795 | - __FILE__, |
|
796 | - __FUNCTION__, |
|
797 | - __LINE__ |
|
798 | - ); |
|
799 | - return false; |
|
800 | - } |
|
801 | - |
|
802 | - self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send((array) $msgID); |
|
803 | - |
|
804 | - // setup success message. |
|
805 | - $count_ready_for_resend = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend); |
|
806 | - EE_Error::add_success( |
|
807 | - sprintf( |
|
808 | - _n( |
|
809 | - 'There was %d message queued for resending.', |
|
810 | - 'There were %d messages queued for resending.', |
|
811 | - $count_ready_for_resend, |
|
812 | - 'event_espresso' |
|
813 | - ), |
|
814 | - $count_ready_for_resend |
|
815 | - ) |
|
816 | - ); |
|
817 | - return true; |
|
818 | - } |
|
819 | - |
|
820 | - |
|
821 | - /** |
|
822 | - * Message triggers for manual payment applied by admin |
|
823 | - * |
|
824 | - * @param EE_Payment $payment EE_payment object |
|
825 | - * @return bool success/fail |
|
826 | - * @throws EE_Error |
|
827 | - * @throws InvalidArgumentException |
|
828 | - * @throws ReflectionException |
|
829 | - * @throws InvalidDataTypeException |
|
830 | - * @throws InvalidInterfaceException |
|
831 | - */ |
|
832 | - public static function process_admin_payment(EE_Payment $payment) |
|
833 | - { |
|
834 | - EE_Registry::instance()->load_helper('MSG_Template'); |
|
835 | - // we need to get the transaction object |
|
836 | - $transaction = $payment->transaction(); |
|
837 | - if ($transaction instanceof EE_Transaction) { |
|
838 | - $data = [$transaction, $payment]; |
|
839 | - $message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID()); |
|
840 | - |
|
841 | - // if payment amount is less than 0 then switch to payment_refund message type. |
|
842 | - $message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type; |
|
843 | - |
|
844 | - // if payment_refund is selected, but the status is NOT accepted. Then change message type to false so NO message notification goes out. |
|
845 | - $message_type = $message_type == 'payment_refund' && $payment->STS_ID() != EEM_Payment::status_id_approved |
|
846 | - ? false : $message_type; |
|
847 | - |
|
848 | - self::_load_controller(); |
|
849 | - |
|
850 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data); |
|
851 | - |
|
852 | - // get count of queued for generation |
|
853 | - $count_to_generate = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue( |
|
854 | - [ |
|
855 | - EEM_Message::status_incomplete, |
|
856 | - EEM_Message::status_idle, |
|
857 | - ] |
|
858 | - ); |
|
859 | - |
|
860 | - if ($count_to_generate > 0 && self::$_MSG_PROCESSOR->get_queue()->get_message_repository()->count() !== 0) { |
|
861 | - add_filter('FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true'); |
|
862 | - return true; |
|
863 | - } else { |
|
864 | - $count_failed = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue( |
|
865 | - EEM_Message::instance()->stati_indicating_failed_sending() |
|
866 | - ); |
|
867 | - /** |
|
868 | - * Verify that there are actually errors. If not then we return a success message because the queue might have been emptied due to successful |
|
869 | - * IMMEDIATE generation. |
|
870 | - */ |
|
871 | - if ($count_failed > 0) { |
|
872 | - EE_Error::add_error( |
|
873 | - sprintf( |
|
874 | - _n( |
|
875 | - 'The payment notification generation failed.', |
|
876 | - '%d payment notifications failed being sent.', |
|
877 | - $count_failed, |
|
878 | - 'event_espresso' |
|
879 | - ), |
|
880 | - $count_failed |
|
881 | - ), |
|
882 | - __FILE__, |
|
883 | - __FUNCTION__, |
|
884 | - __LINE__ |
|
885 | - ); |
|
886 | - |
|
887 | - return false; |
|
888 | - } else { |
|
889 | - add_filter('FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true'); |
|
890 | - return true; |
|
891 | - } |
|
892 | - } |
|
893 | - } else { |
|
894 | - EE_Error::add_error( |
|
895 | - esc_html__( |
|
896 | - 'Unable to generate the payment notification because the given value for the transaction is invalid.', |
|
897 | - 'event_espresso' |
|
898 | - ), |
|
899 | - __FILE__, |
|
900 | - __FUNCTION__, |
|
901 | - __LINE__ |
|
902 | - ); |
|
903 | - return false; |
|
904 | - } |
|
905 | - } |
|
906 | - |
|
907 | - |
|
908 | - /** |
|
909 | - * Callback for AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send_with_registrations trigger |
|
910 | - * |
|
911 | - * @param EE_Registration[] $registrations an array of EE_Registration objects |
|
912 | - * @param int $grp_id a specific message template group id. |
|
913 | - * @return void |
|
914 | - * @throws EE_Error |
|
915 | - * @throws InvalidArgumentException |
|
916 | - * @throws InvalidDataTypeException |
|
917 | - * @throws InvalidInterfaceException |
|
918 | - * @throws ReflectionException |
|
919 | - * @since 4.3.0 |
|
920 | - */ |
|
921 | - public static function send_newsletter_message($registrations, $grp_id) |
|
922 | - { |
|
923 | - // make sure mtp is id and set it in the request later messages setup. |
|
924 | - self::getRequest()->setRequestParam('GRP_ID', (int) $grp_id); |
|
925 | - self::_load_controller(); |
|
926 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers('newsletter', $registrations); |
|
927 | - } |
|
928 | - |
|
929 | - |
|
930 | - /** |
|
931 | - * Callback for FHEE__EE_Registration__invoice_url__invoice_url or FHEE__EE_Registration__receipt_url__receipt_url |
|
932 | - * |
|
933 | - * @param string $registration_message_trigger_url |
|
934 | - * @param EE_Registration $registration |
|
935 | - * @param string $messenger |
|
936 | - * @param string $message_type |
|
937 | - * @return string |
|
938 | - * @throws EE_Error |
|
939 | - * @throws InvalidArgumentException |
|
940 | - * @throws InvalidDataTypeException |
|
941 | - * @throws InvalidInterfaceException |
|
942 | - * @throws ReflectionException |
|
943 | - * @since 4.3.0 |
|
944 | - */ |
|
945 | - public static function registration_message_trigger_url( |
|
946 | - $registration_message_trigger_url, |
|
947 | - EE_Registration $registration, |
|
948 | - $messenger = 'html', |
|
949 | - $message_type = 'invoice' |
|
950 | - ) { |
|
951 | - // whitelist $messenger |
|
952 | - switch ($messenger) { |
|
953 | - case 'pdf': |
|
954 | - $sending_messenger = 'pdf'; |
|
955 | - $generating_messenger = 'html'; |
|
956 | - break; |
|
957 | - case 'html': |
|
958 | - default: |
|
959 | - $sending_messenger = 'html'; |
|
960 | - $generating_messenger = 'html'; |
|
961 | - break; |
|
962 | - } |
|
963 | - // whitelist $message_type |
|
964 | - switch ($message_type) { |
|
965 | - case 'receipt': |
|
966 | - $message_type = 'receipt'; |
|
967 | - break; |
|
968 | - case 'invoice': |
|
969 | - default: |
|
970 | - $message_type = 'invoice'; |
|
971 | - break; |
|
972 | - } |
|
973 | - // verify that both the messenger AND the message type are active |
|
974 | - if ( |
|
975 | - EEH_MSG_Template::is_messenger_active($sending_messenger) |
|
976 | - && EEH_MSG_Template::is_mt_active($message_type) |
|
977 | - ) { |
|
978 | - // need to get the correct message template group for this (i.e. is there a custom invoice for the event this registration is registered for?) |
|
979 | - $template_query_params = [ |
|
980 | - 'MTP_is_active' => true, |
|
981 | - 'MTP_messenger' => $generating_messenger, |
|
982 | - 'MTP_message_type' => $message_type, |
|
983 | - 'Event.EVT_ID' => $registration->event_ID(), |
|
984 | - ]; |
|
985 | - // get the message template group. |
|
986 | - $msg_template_group = EEM_Message_Template_Group::instance()->get_one([$template_query_params]); |
|
987 | - // if we don't have an EE_Message_Template_Group then return |
|
988 | - if (! $msg_template_group instanceof EE_Message_Template_Group) { |
|
989 | - // remove EVT_ID from query params so that global templates get picked up |
|
990 | - unset($template_query_params['Event.EVT_ID']); |
|
991 | - // get global template as the fallback |
|
992 | - $msg_template_group = EEM_Message_Template_Group::instance()->get_one([$template_query_params]); |
|
993 | - } |
|
994 | - // if we don't have an EE_Message_Template_Group then return |
|
995 | - if (! $msg_template_group instanceof EE_Message_Template_Group) { |
|
996 | - return ''; |
|
997 | - } |
|
998 | - // generate the URL |
|
999 | - $registration_message_trigger_url = EEH_MSG_Template::generate_url_trigger( |
|
1000 | - $sending_messenger, |
|
1001 | - $generating_messenger, |
|
1002 | - 'purchaser', |
|
1003 | - $message_type, |
|
1004 | - $registration, |
|
1005 | - $msg_template_group->ID(), |
|
1006 | - $registration->transaction_ID() |
|
1007 | - ); |
|
1008 | - } |
|
1009 | - return $registration_message_trigger_url; |
|
1010 | - } |
|
1011 | - |
|
1012 | - |
|
1013 | - /** |
|
1014 | - * Use to generate and return a message preview! |
|
1015 | - * |
|
1016 | - * @param string $type This should correspond with a valid message type |
|
1017 | - * @param string $context This should correspond with a valid context for the message type |
|
1018 | - * @param string $messenger This should correspond with a valid messenger. |
|
1019 | - * @param bool $send true we will do a test send using the messenger delivery, false we just do a regular |
|
1020 | - * preview |
|
1021 | - * @return bool|string The body of the message or if send is requested, sends. |
|
1022 | - * @throws EE_Error |
|
1023 | - * @throws InvalidArgumentException |
|
1024 | - * @throws InvalidDataTypeException |
|
1025 | - * @throws InvalidInterfaceException |
|
1026 | - * @throws ReflectionException |
|
1027 | - */ |
|
1028 | - public static function preview_message($type, $context, $messenger, $send = false) |
|
1029 | - { |
|
1030 | - self::_load_controller(); |
|
1031 | - $message_to_generate = new EE_Message_To_Generate( |
|
1032 | - $messenger, |
|
1033 | - $type, |
|
1034 | - [], |
|
1035 | - $context, |
|
1036 | - true |
|
1037 | - ); |
|
1038 | - $generated_preview_queue = self::$_MSG_PROCESSOR->generate_for_preview($message_to_generate, $send); |
|
1039 | - |
|
1040 | - if ($generated_preview_queue instanceof EE_Messages_Queue) { |
|
1041 | - // loop through all content for the preview and remove any persisted records. |
|
1042 | - $content = ''; |
|
1043 | - foreach ($generated_preview_queue->get_message_repository() as $message) { |
|
1044 | - $content = $message->content(); |
|
1045 | - if ($message->ID() > 0 && $message->STS_ID() !== EEM_Message::status_failed) { |
|
1046 | - $message->delete(); |
|
1047 | - } |
|
1048 | - } |
|
1049 | - return $content; |
|
1050 | - } |
|
1051 | - return $generated_preview_queue; |
|
1052 | - } |
|
1053 | - |
|
1054 | - |
|
1055 | - /** |
|
1056 | - * This is a method that allows for sending a message using a messenger matching the string given and the provided |
|
1057 | - * EE_Message_Queue object. The EE_Message_Queue object is used to create a single aggregate EE_Message via the |
|
1058 | - * content found in the EE_Message objects in the queue. |
|
1059 | - * |
|
1060 | - * @param string $messenger a string matching a valid active messenger in the system |
|
1061 | - * @param string $message_type Although it seems contrary to the name of the method, a message |
|
1062 | - * type name is still required to send along the message type to the |
|
1063 | - * messenger because this is used for determining what specific |
|
1064 | - * variations might be loaded for the generated message. |
|
1065 | - * @param EE_Messages_Queue $queue |
|
1066 | - * @param string $custom_subject Can be used to set what the custom subject string will be on the |
|
1067 | - * aggregate EE_Message object. |
|
1068 | - * @return bool success or fail. |
|
1069 | - * @throws EE_Error |
|
1070 | - * @throws InvalidArgumentException |
|
1071 | - * @throws ReflectionException |
|
1072 | - * @throws InvalidDataTypeException |
|
1073 | - * @throws InvalidInterfaceException |
|
1074 | - * @since 4.9.0 |
|
1075 | - */ |
|
1076 | - public static function send_message_with_messenger_only( |
|
1077 | - $messenger, |
|
1078 | - $message_type, |
|
1079 | - EE_Messages_Queue $queue, |
|
1080 | - $custom_subject = '' |
|
1081 | - ) { |
|
1082 | - self::_load_controller(); |
|
1083 | - /** @type EE_Message_To_Generate_From_Queue $message_to_generate */ |
|
1084 | - $message_to_generate = EE_Registry::instance()->load_lib( |
|
1085 | - 'Message_To_Generate_From_Queue', |
|
1086 | - [ |
|
1087 | - $messenger, |
|
1088 | - $message_type, |
|
1089 | - $queue, |
|
1090 | - $custom_subject, |
|
1091 | - ] |
|
1092 | - ); |
|
1093 | - return self::$_MSG_PROCESSOR->queue_for_sending($message_to_generate); |
|
1094 | - } |
|
1095 | - |
|
1096 | - |
|
1097 | - /** |
|
1098 | - * Generates Messages immediately for EE_Message IDs (but only for the correct status for generation) |
|
1099 | - * |
|
1100 | - * @param array $message_ids An array of message ids |
|
1101 | - * @return bool|EE_Messages_Queue false if nothing was generated, EE_Messages_Queue containing generated |
|
1102 | - * messages. |
|
1103 | - * @throws EE_Error |
|
1104 | - * @throws InvalidArgumentException |
|
1105 | - * @throws InvalidDataTypeException |
|
1106 | - * @throws InvalidInterfaceException |
|
1107 | - * @throws ReflectionException |
|
1108 | - * @since 4.9.0 |
|
1109 | - */ |
|
1110 | - public static function generate_now($message_ids) |
|
1111 | - { |
|
1112 | - self::_load_controller(); |
|
1113 | - $messages = EEM_Message::instance()->get_all( |
|
1114 | - [ |
|
1115 | - 0 => [ |
|
1116 | - 'MSG_ID' => ['IN', $message_ids], |
|
1117 | - 'STS_ID' => EEM_Message::status_incomplete, |
|
1118 | - ], |
|
1119 | - ] |
|
1120 | - ); |
|
1121 | - $generated_queue = false; |
|
1122 | - if ($messages) { |
|
1123 | - $generated_queue = self::$_MSG_PROCESSOR->batch_generate_from_queue($messages); |
|
1124 | - } |
|
1125 | - |
|
1126 | - if (! $generated_queue instanceof EE_Messages_Queue) { |
|
1127 | - EE_Error::add_error( |
|
1128 | - esc_html__( |
|
1129 | - 'The messages were not generated. This could mean there is already a batch being generated on a separate request, or because the selected messages are not ready for generation. Please wait a minute or two and try again.', |
|
1130 | - 'event_espresso' |
|
1131 | - ), |
|
1132 | - __FILE__, |
|
1133 | - __FUNCTION__, |
|
1134 | - __LINE__ |
|
1135 | - ); |
|
1136 | - } |
|
1137 | - return $generated_queue; |
|
1138 | - } |
|
1139 | - |
|
1140 | - |
|
1141 | - /** |
|
1142 | - * Sends messages immediately for the incoming message_ids that have the status of EEM_Message::status_resend or, |
|
1143 | - * EEM_Message::status_idle |
|
1144 | - * |
|
1145 | - * @param $message_ids |
|
1146 | - * @return bool|EE_Messages_Queue false if no messages sent. |
|
1147 | - * @throws EE_Error |
|
1148 | - * @throws InvalidArgumentException |
|
1149 | - * @throws InvalidDataTypeException |
|
1150 | - * @throws InvalidInterfaceException |
|
1151 | - * @throws ReflectionException |
|
1152 | - * @since 4.9.0 |
|
1153 | - */ |
|
1154 | - public static function send_now($message_ids) |
|
1155 | - { |
|
1156 | - self::_load_controller(); |
|
1157 | - $messages = EEM_Message::instance()->get_all( |
|
1158 | - [ |
|
1159 | - 0 => [ |
|
1160 | - 'MSG_ID' => ['IN', $message_ids], |
|
1161 | - 'STS_ID' => [ |
|
1162 | - 'IN', |
|
1163 | - [EEM_Message::status_idle, EEM_Message::status_resend, EEM_Message::status_retry], |
|
1164 | - ], |
|
1165 | - ], |
|
1166 | - ] |
|
1167 | - ); |
|
1168 | - $sent_queue = false; |
|
1169 | - if ($messages) { |
|
1170 | - $sent_queue = self::$_MSG_PROCESSOR->batch_send_from_queue($messages); |
|
1171 | - } |
|
1172 | - |
|
1173 | - if (! $sent_queue instanceof EE_Messages_Queue) { |
|
1174 | - EE_Error::add_error( |
|
1175 | - esc_html__( |
|
1176 | - 'The messages were not sent. This could mean there is already a batch being sent on a separate request, or because the selected messages are not sendable. Please wait a minute or two and try again.', |
|
1177 | - 'event_espresso' |
|
1178 | - ), |
|
1179 | - __FILE__, |
|
1180 | - __FUNCTION__, |
|
1181 | - __LINE__ |
|
1182 | - ); |
|
1183 | - } else { |
|
1184 | - // can count how many sent by using the messages in the queue |
|
1185 | - $sent_count = $sent_queue->count_STS_in_queue(EEM_Message::instance()->stati_indicating_sent()); |
|
1186 | - if ($sent_count > 0) { |
|
1187 | - EE_Error::add_success( |
|
1188 | - sprintf( |
|
1189 | - _n( |
|
1190 | - 'There was %d message successfully sent.', |
|
1191 | - 'There were %d messages successfully sent.', |
|
1192 | - $sent_count, |
|
1193 | - 'event_espresso' |
|
1194 | - ), |
|
1195 | - $sent_count |
|
1196 | - ) |
|
1197 | - ); |
|
1198 | - } else { |
|
1199 | - EE_Error::overwrite_errors(); |
|
1200 | - EE_Error::add_error( |
|
1201 | - esc_html__( |
|
1202 | - 'No message was sent because of problems with sending. Either all the messages you selected were not a sendable message, they were ALREADY sent on a different scheduled task, or there was an error. |
|
264 | + exit; |
|
265 | + } |
|
266 | + } |
|
267 | + } |
|
268 | + |
|
269 | + |
|
270 | + /** |
|
271 | + * This runs when the msg_url_trigger route has initiated. |
|
272 | + * |
|
273 | + * @param WP $WP |
|
274 | + * @throws EE_Error |
|
275 | + * @throws InvalidArgumentException |
|
276 | + * @throws ReflectionException |
|
277 | + * @throws InvalidDataTypeException |
|
278 | + * @throws InvalidInterfaceException |
|
279 | + * @since 4.5.0 |
|
280 | + */ |
|
281 | + public function run($WP) |
|
282 | + { |
|
283 | + // ensure controller is loaded |
|
284 | + self::_load_controller(); |
|
285 | + // attempt to process message |
|
286 | + try { |
|
287 | + /** @type EE_Message_To_Generate_From_Request $message_to_generate */ |
|
288 | + $message_to_generate = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request'); |
|
289 | + self::$_MSG_PROCESSOR->generate_and_send_now($message_to_generate); |
|
290 | + } catch (EE_Error $e) { |
|
291 | + $error_msg = esc_html__( |
|
292 | + 'Please note that a system message failed to send due to a technical issue.', |
|
293 | + 'event_espresso' |
|
294 | + ); |
|
295 | + // add specific message for developers if WP_DEBUG in on |
|
296 | + $error_msg .= '||' . $e->getMessage(); |
|
297 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
298 | + } |
|
299 | + } |
|
300 | + |
|
301 | + |
|
302 | + /** |
|
303 | + * This is triggered by the 'msg_cron_trigger' route. |
|
304 | + * |
|
305 | + * @param WP $WP |
|
306 | + * @throws EE_Error |
|
307 | + */ |
|
308 | + public function execute_batch_request($WP) |
|
309 | + { |
|
310 | + $this->run_cron(); |
|
311 | + header('HTTP/1.1 200 OK'); |
|
312 | + exit(); |
|
313 | + } |
|
314 | + |
|
315 | + |
|
316 | + /** |
|
317 | + * This gets executed on wp_cron jobs or when a batch request is initiated on its own separate non regular wp |
|
318 | + * request. |
|
319 | + * |
|
320 | + * @throws EE_Error |
|
321 | + * @throws ReflectionException |
|
322 | + */ |
|
323 | + public function run_cron() |
|
324 | + { |
|
325 | + self::_load_controller(); |
|
326 | + $request = self::getRequest(); |
|
327 | + // get required vars |
|
328 | + $cron_type = $request->getRequestParam('type'); |
|
329 | + $transient_key = $request->getRequestParam('key'); |
|
330 | + |
|
331 | + // now let's verify transient, if not valid exit immediately |
|
332 | + if (! get_transient($transient_key)) { |
|
333 | + /** |
|
334 | + * trigger error so this gets in the error logs. This is important because it happens on a non-user |
|
335 | + * request. |
|
336 | + */ |
|
337 | + trigger_error(esc_attr__('Invalid Request (Transient does not exist)', 'event_espresso')); |
|
338 | + } |
|
339 | + |
|
340 | + // if made it here, lets' delete the transient to keep the db clean |
|
341 | + delete_transient($transient_key); |
|
342 | + |
|
343 | + if (apply_filters('FHEE__EED_Messages__run_cron__use_wp_cron', true)) { |
|
344 | + $method = 'batch_' . $cron_type . '_from_queue'; |
|
345 | + if (method_exists(self::$_MSG_PROCESSOR, $method)) { |
|
346 | + self::$_MSG_PROCESSOR->$method(); |
|
347 | + } else { |
|
348 | + // no matching task |
|
349 | + /** |
|
350 | + * trigger error so this gets in the error logs. This is important because it happens on a non user |
|
351 | + * request. |
|
352 | + */ |
|
353 | + trigger_error( |
|
354 | + esc_attr( |
|
355 | + sprintf( |
|
356 | + esc_html__('There is no task corresponding to this route %s', 'event_espresso'), |
|
357 | + $cron_type |
|
358 | + ) |
|
359 | + ) |
|
360 | + ); |
|
361 | + } |
|
362 | + } |
|
363 | + |
|
364 | + do_action('FHEE__EED_Messages__run_cron__end'); |
|
365 | + } |
|
366 | + |
|
367 | + |
|
368 | + /** |
|
369 | + * This is used to retrieve the template pack for the given name. |
|
370 | + * Retrieved packs are cached on the static $_TMP_PACKS array. If there is no class matching the given name then |
|
371 | + * the default template pack is returned. |
|
372 | + * |
|
373 | + * @param string $template_pack_name This should correspond to the dbref of the template pack (which is also used |
|
374 | + * in generating the Pack class name). |
|
375 | + * @return EE_Messages_Template_Pack |
|
376 | + * @throws EE_Error |
|
377 | + * @throws InvalidArgumentException |
|
378 | + * @throws ReflectionException |
|
379 | + * @throws InvalidDataTypeException |
|
380 | + * @throws InvalidInterfaceException |
|
381 | + * @deprecated 4.9.0 @see EEH_MSG_Template::get_template_pack() |
|
382 | + */ |
|
383 | + public static function get_template_pack($template_pack_name) |
|
384 | + { |
|
385 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
386 | + return EEH_MSG_Template::get_template_pack($template_pack_name); |
|
387 | + } |
|
388 | + |
|
389 | + |
|
390 | + /** |
|
391 | + * Retrieves an array of all template packs. |
|
392 | + * Array is in the format array( 'dbref' => EE_Messages_Template_Pack ) |
|
393 | + * |
|
394 | + * @return EE_Messages_Template_Pack[] |
|
395 | + * @throws EE_Error |
|
396 | + * @throws InvalidArgumentException |
|
397 | + * @throws ReflectionException |
|
398 | + * @throws InvalidDataTypeException |
|
399 | + * @throws InvalidInterfaceException |
|
400 | + * @deprecated 4.9.0 @see EEH_MSG_Template_Pack::get_template_pack_collection |
|
401 | + */ |
|
402 | + public static function get_template_packs() |
|
403 | + { |
|
404 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
405 | + |
|
406 | + // for backward compat, let's make sure this returns in the same format as originally. |
|
407 | + $template_pack_collection = EEH_MSG_Template::get_template_pack_collection(); |
|
408 | + $template_pack_collection->rewind(); |
|
409 | + $template_packs = []; |
|
410 | + while ($template_pack_collection->valid()) { |
|
411 | + $template_packs[ $template_pack_collection->current()->dbref ] = $template_pack_collection->current(); |
|
412 | + $template_pack_collection->next(); |
|
413 | + } |
|
414 | + return $template_packs; |
|
415 | + } |
|
416 | + |
|
417 | + |
|
418 | + /** |
|
419 | + * This simply makes sure the autoloaders are registered for the EE_messages system. |
|
420 | + * |
|
421 | + * @return void |
|
422 | + * @throws EE_Error |
|
423 | + * @since 4.5.0 |
|
424 | + */ |
|
425 | + public static function set_autoloaders() |
|
426 | + { |
|
427 | + if (empty(self::$_MSG_PATHS)) { |
|
428 | + self::_set_messages_paths(); |
|
429 | + foreach (self::$_MSG_PATHS as $path) { |
|
430 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder($path); |
|
431 | + } |
|
432 | + // add aliases |
|
433 | + EEH_Autoloader::add_alias('EE_messages', 'EE_messages'); |
|
434 | + EEH_Autoloader::add_alias('EE_messenger', 'EE_messenger'); |
|
435 | + } |
|
436 | + } |
|
437 | + |
|
438 | + |
|
439 | + /** |
|
440 | + * Take care of adding all the paths for the messages components to the $_MSG_PATHS property |
|
441 | + * for use by the Messages Autoloaders |
|
442 | + * |
|
443 | + * @return void. |
|
444 | + * @since 4.5.0 |
|
445 | + */ |
|
446 | + protected static function _set_messages_paths() |
|
447 | + { |
|
448 | + self::$_MSG_PATHS = apply_filters( |
|
449 | + 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', |
|
450 | + [ |
|
451 | + EE_LIBRARIES . 'messages/message_type', |
|
452 | + EE_LIBRARIES . 'messages/messenger', |
|
453 | + EE_LIBRARIES . 'messages/defaults', |
|
454 | + EE_LIBRARIES . 'messages/defaults/email', |
|
455 | + EE_LIBRARIES . 'messages/data_class', |
|
456 | + EE_LIBRARIES . 'messages/validators', |
|
457 | + EE_LIBRARIES . 'messages/validators/email', |
|
458 | + EE_LIBRARIES . 'messages/validators/html', |
|
459 | + EE_LIBRARIES . 'shortcodes', |
|
460 | + ] |
|
461 | + ); |
|
462 | + } |
|
463 | + |
|
464 | + |
|
465 | + /** |
|
466 | + * Takes care of loading dependencies |
|
467 | + * |
|
468 | + * @return void |
|
469 | + * @throws EE_Error |
|
470 | + * @throws InvalidArgumentException |
|
471 | + * @throws ReflectionException |
|
472 | + * @throws InvalidDataTypeException |
|
473 | + * @throws InvalidInterfaceException |
|
474 | + * @since 4.5.0 |
|
475 | + */ |
|
476 | + protected static function _load_controller() |
|
477 | + { |
|
478 | + if (! self::$_MSG_PROCESSOR instanceof EE_Messages_Processor) { |
|
479 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
480 | + self::set_autoloaders(); |
|
481 | + self::$_EEMSG = EE_Registry::instance()->load_lib('messages'); |
|
482 | + self::$_MSG_PROCESSOR = EE_Registry::instance()->load_lib('Messages_Processor'); |
|
483 | + self::$_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
484 | + } |
|
485 | + } |
|
486 | + |
|
487 | + |
|
488 | + /** |
|
489 | + * @param EE_Transaction $transaction |
|
490 | + * @throws EE_Error |
|
491 | + * @throws InvalidArgumentException |
|
492 | + * @throws InvalidDataTypeException |
|
493 | + * @throws InvalidInterfaceException |
|
494 | + * @throws ReflectionException |
|
495 | + */ |
|
496 | + public static function payment_reminder(EE_Transaction $transaction) |
|
497 | + { |
|
498 | + self::_load_controller(); |
|
499 | + $data = [$transaction, null]; |
|
500 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers('payment_reminder', $data); |
|
501 | + } |
|
502 | + |
|
503 | + |
|
504 | + /** |
|
505 | + * Any messages triggers for after successful gateway payments should go in here. |
|
506 | + * |
|
507 | + * @param EE_Transaction $transaction object |
|
508 | + * @param EE_Payment|null $payment object |
|
509 | + * @return void |
|
510 | + * @throws EE_Error |
|
511 | + * @throws InvalidArgumentException |
|
512 | + * @throws ReflectionException |
|
513 | + * @throws InvalidDataTypeException |
|
514 | + * @throws InvalidInterfaceException |
|
515 | + */ |
|
516 | + public static function payment(EE_Transaction $transaction, EE_Payment $payment = null) |
|
517 | + { |
|
518 | + // if there's no payment object, then we cannot do a payment type message! |
|
519 | + if (! $payment instanceof EE_Payment) { |
|
520 | + return; |
|
521 | + } |
|
522 | + self::_load_controller(); |
|
523 | + $data = [$transaction, $payment]; |
|
524 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
525 | + $message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID()); |
|
526 | + // if payment amount is less than 0 then switch to payment_refund message type. |
|
527 | + $message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type; |
|
528 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data); |
|
529 | + } |
|
530 | + |
|
531 | + |
|
532 | + /** |
|
533 | + * @param EE_Transaction $transaction |
|
534 | + * @throws EE_Error |
|
535 | + * @throws InvalidArgumentException |
|
536 | + * @throws InvalidDataTypeException |
|
537 | + * @throws InvalidInterfaceException |
|
538 | + * @throws ReflectionException |
|
539 | + */ |
|
540 | + public static function cancelled_registration(EE_Transaction $transaction) |
|
541 | + { |
|
542 | + self::_load_controller(); |
|
543 | + $data = [$transaction, null]; |
|
544 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers('cancelled_registration', $data); |
|
545 | + } |
|
546 | + |
|
547 | + |
|
548 | + /** |
|
549 | + * Trigger for Registration messages |
|
550 | + * Note that what registration message type is sent depends on what the reg status is for the registrations on the |
|
551 | + * incoming transaction. |
|
552 | + * |
|
553 | + * @param EE_Registration $registration |
|
554 | + * @param array $extra_details |
|
555 | + * @return void |
|
556 | + * @throws EE_Error |
|
557 | + * @throws InvalidArgumentException |
|
558 | + * @throws InvalidDataTypeException |
|
559 | + * @throws InvalidInterfaceException |
|
560 | + * @throws ReflectionException |
|
561 | + * @throws EntityNotFoundException |
|
562 | + */ |
|
563 | + public static function maybe_registration(EE_Registration $registration, $extra_details = []) |
|
564 | + { |
|
565 | + |
|
566 | + if (! self::_verify_registration_notification_send($registration, $extra_details)) { |
|
567 | + // no messages please |
|
568 | + return; |
|
569 | + } |
|
570 | + |
|
571 | + // get all non-trashed registrations so we make sure we send messages for the right status. |
|
572 | + $all_registrations = $registration->transaction()->registrations( |
|
573 | + [ |
|
574 | + ['REG_deleted' => false], |
|
575 | + 'order_by' => [ |
|
576 | + 'Event.EVT_name' => 'ASC', |
|
577 | + 'Attendee.ATT_lname' => 'ASC', |
|
578 | + 'Attendee.ATT_fname' => 'ASC', |
|
579 | + ], |
|
580 | + ] |
|
581 | + ); |
|
582 | + // cached array of statuses so we only trigger messages once per status. |
|
583 | + $statuses_sent = []; |
|
584 | + self::_load_controller(); |
|
585 | + $mtgs = []; |
|
586 | + |
|
587 | + // loop through registrations and trigger messages once per status. |
|
588 | + foreach ($all_registrations as $reg) { |
|
589 | + // already triggered? |
|
590 | + if (in_array($reg->status_ID(), $statuses_sent)) { |
|
591 | + continue; |
|
592 | + } |
|
593 | + |
|
594 | + $message_type = EEH_MSG_Template::convert_reg_status_to_message_type($reg->status_ID()); |
|
595 | + $mtgs = array_merge( |
|
596 | + $mtgs, |
|
597 | + self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers( |
|
598 | + $message_type, |
|
599 | + [$registration->transaction(), null, $reg->status_ID()] |
|
600 | + ) |
|
601 | + ); |
|
602 | + $statuses_sent[] = $reg->status_ID(); |
|
603 | + } |
|
604 | + |
|
605 | + if (count($statuses_sent) > 1) { |
|
606 | + $mtgs = array_merge( |
|
607 | + $mtgs, |
|
608 | + self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers( |
|
609 | + 'registration_summary', |
|
610 | + [$registration->transaction(), null] |
|
611 | + ) |
|
612 | + ); |
|
613 | + } |
|
614 | + |
|
615 | + // batch queue and initiate request |
|
616 | + self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($mtgs); |
|
617 | + self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority(); |
|
618 | + } |
|
619 | + |
|
620 | + |
|
621 | + /** |
|
622 | + * This is a helper method used to very whether a registration notification should be sent or |
|
623 | + * not. Prevents duplicate notifications going out for registration context notifications. |
|
624 | + * |
|
625 | + * @param EE_Registration $registration [description] |
|
626 | + * @param array $extra_details [description] |
|
627 | + * @return bool true = send away, false = nope halt the presses. |
|
628 | + */ |
|
629 | + protected static function _verify_registration_notification_send( |
|
630 | + EE_Registration $registration, |
|
631 | + $extra_details = [] |
|
632 | + ) { |
|
633 | + $request = self::getRequest(); |
|
634 | + if ( |
|
635 | + ! $request->getRequestParam('non_primary_reg_notification', 0, 'int') |
|
636 | + && ! $registration->is_primary_registrant() |
|
637 | + ) { |
|
638 | + return false; |
|
639 | + } |
|
640 | + // first we check if we're in admin and not doing front ajax |
|
641 | + if ( |
|
642 | + ($request->isAdmin() || $request->isAdminAjax()) |
|
643 | + && ! $request->isFrontAjax() |
|
644 | + ) { |
|
645 | + $status_change = $request->getRequestParam('txn_reg_status_change', [], 'int', true); |
|
646 | + // make sure appropriate admin params are set for sending messages |
|
647 | + if ( |
|
648 | + ! isset($status_change['send_notifications']) |
|
649 | + || (isset($status_change['send_notifications']) && ! $status_change['send_notifications']) |
|
650 | + ) { |
|
651 | + // no messages sent please. |
|
652 | + return false; |
|
653 | + } |
|
654 | + } else { |
|
655 | + // frontend request (either regular or via AJAX) |
|
656 | + // TXN is NOT finalized ? |
|
657 | + if (! isset($extra_details['finalized']) || $extra_details['finalized'] === false) { |
|
658 | + return false; |
|
659 | + } |
|
660 | + // return visit but nothing changed ??? |
|
661 | + if ( |
|
662 | + isset($extra_details['revisit'], $extra_details['status_updates']) |
|
663 | + && $extra_details['revisit'] |
|
664 | + && ! $extra_details['status_updates'] |
|
665 | + ) { |
|
666 | + return false; |
|
667 | + } |
|
668 | + // NOT sending messages && reg status is something other than "Not-Approved" |
|
669 | + if ( |
|
670 | + ! apply_filters('FHEE__EED_Messages___maybe_registration__deliver_notifications', false) |
|
671 | + && $registration->status_ID() !== RegStatus::AWAITING_REVIEW |
|
672 | + ) { |
|
673 | + return false; |
|
674 | + } |
|
675 | + } |
|
676 | + // release the kraken |
|
677 | + return true; |
|
678 | + } |
|
679 | + |
|
680 | + |
|
681 | + /** |
|
682 | + * Simply returns an array indexed by Registration Status ID and the related message_type name associated with that |
|
683 | + * status id. |
|
684 | + * |
|
685 | + * @param string $reg_status |
|
686 | + * @return array |
|
687 | + * @throws EE_Error |
|
688 | + * @throws InvalidArgumentException |
|
689 | + * @throws ReflectionException |
|
690 | + * @throws InvalidDataTypeException |
|
691 | + * @throws InvalidInterfaceException |
|
692 | + * @deprecated 4.9.0 Use EEH_MSG_Template::reg_status_to_message_type_array() |
|
693 | + * or EEH_MSG_Template::convert_reg_status_to_message_type |
|
694 | + */ |
|
695 | + protected static function _get_reg_status_array($reg_status = '') |
|
696 | + { |
|
697 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
698 | + return EEH_MSG_Template::convert_reg_status_to_message_type($reg_status) |
|
699 | + ? EEH_MSG_Template::convert_reg_status_to_message_type($reg_status) |
|
700 | + : EEH_MSG_Template::reg_status_to_message_type_array(); |
|
701 | + } |
|
702 | + |
|
703 | + |
|
704 | + /** |
|
705 | + * Simply returns the payment message type for the given payment status. |
|
706 | + * |
|
707 | + * @param string $payment_status The payment status being matched. |
|
708 | + * @return bool|string The payment message type slug matching the status or false if no match. |
|
709 | + * @throws EE_Error |
|
710 | + * @throws InvalidArgumentException |
|
711 | + * @throws ReflectionException |
|
712 | + * @throws InvalidDataTypeException |
|
713 | + * @throws InvalidInterfaceException |
|
714 | + * @deprecated 4.9.0 Use EEH_MSG_Template::payment_status_to_message_type_array |
|
715 | + * or EEH_MSG_Template::convert_payment_status_to_message_type |
|
716 | + */ |
|
717 | + protected static function _get_payment_message_type($payment_status) |
|
718 | + { |
|
719 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
720 | + return EEH_MSG_Template::convert_payment_status_to_message_type($payment_status) |
|
721 | + ? EEH_MSG_Template::convert_payment_status_to_message_type($payment_status) |
|
722 | + : false; |
|
723 | + } |
|
724 | + |
|
725 | + |
|
726 | + /** |
|
727 | + * Message triggers for a resending already sent message(s) (via EE_Message list table) |
|
728 | + * |
|
729 | + * @access public |
|
730 | + * @param array $req_data This is the $_POST & $_GET data sent from EE_Admin Pages |
|
731 | + * @return bool success/fail |
|
732 | + * @throws EE_Error |
|
733 | + * @throws InvalidArgumentException |
|
734 | + * @throws InvalidDataTypeException |
|
735 | + * @throws InvalidInterfaceException |
|
736 | + * @throws ReflectionException |
|
737 | + */ |
|
738 | + public static function process_resend(array $req_data = []) |
|
739 | + { |
|
740 | + self::_load_controller(); |
|
741 | + $request = self::getRequest(); |
|
742 | + // if $msgID in this request then skip to the new resend_message |
|
743 | + if ($request->getRequestParam('MSG_ID')) { |
|
744 | + return self::resend_message(); |
|
745 | + } |
|
746 | + |
|
747 | + // make sure any incoming request data is set on the request so that it gets picked up later. |
|
748 | + foreach ((array) $req_data as $request_key => $request_value) { |
|
749 | + if (! $request->requestParamIsSet($request_key)) { |
|
750 | + $request->setRequestParam($request_key, $request_value); |
|
751 | + } |
|
752 | + } |
|
753 | + |
|
754 | + if ( |
|
755 | + ! $messages_to_send = self::$_MSG_PROCESSOR->setup_messages_to_generate_from_registration_ids_in_request() |
|
756 | + ) { |
|
757 | + return false; |
|
758 | + } |
|
759 | + |
|
760 | + try { |
|
761 | + self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($messages_to_send); |
|
762 | + self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority(); |
|
763 | + } catch (EE_Error $e) { |
|
764 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
765 | + return false; |
|
766 | + } |
|
767 | + EE_Error::add_success( |
|
768 | + esc_html__('Messages have been successfully queued for generation and sending.', 'event_espresso') |
|
769 | + ); |
|
770 | + return true; // everything got queued. |
|
771 | + } |
|
772 | + |
|
773 | + |
|
774 | + /** |
|
775 | + * Message triggers for a resending already sent message(s) (via EE_Message list table) |
|
776 | + * |
|
777 | + * @return bool |
|
778 | + * @throws EE_Error |
|
779 | + * @throws InvalidArgumentException |
|
780 | + * @throws InvalidDataTypeException |
|
781 | + * @throws InvalidInterfaceException |
|
782 | + * @throws ReflectionException |
|
783 | + */ |
|
784 | + public static function resend_message() |
|
785 | + { |
|
786 | + self::_load_controller(); |
|
787 | + |
|
788 | + $msgID = self::getRequest()->getRequestParam('MSG_ID', 0, 'int'); |
|
789 | + if (! $msgID) { |
|
790 | + EE_Error::add_error( |
|
791 | + esc_html__( |
|
792 | + 'Something went wrong because there is no "MSG_ID" value in the request', |
|
793 | + 'event_espresso' |
|
794 | + ), |
|
795 | + __FILE__, |
|
796 | + __FUNCTION__, |
|
797 | + __LINE__ |
|
798 | + ); |
|
799 | + return false; |
|
800 | + } |
|
801 | + |
|
802 | + self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send((array) $msgID); |
|
803 | + |
|
804 | + // setup success message. |
|
805 | + $count_ready_for_resend = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend); |
|
806 | + EE_Error::add_success( |
|
807 | + sprintf( |
|
808 | + _n( |
|
809 | + 'There was %d message queued for resending.', |
|
810 | + 'There were %d messages queued for resending.', |
|
811 | + $count_ready_for_resend, |
|
812 | + 'event_espresso' |
|
813 | + ), |
|
814 | + $count_ready_for_resend |
|
815 | + ) |
|
816 | + ); |
|
817 | + return true; |
|
818 | + } |
|
819 | + |
|
820 | + |
|
821 | + /** |
|
822 | + * Message triggers for manual payment applied by admin |
|
823 | + * |
|
824 | + * @param EE_Payment $payment EE_payment object |
|
825 | + * @return bool success/fail |
|
826 | + * @throws EE_Error |
|
827 | + * @throws InvalidArgumentException |
|
828 | + * @throws ReflectionException |
|
829 | + * @throws InvalidDataTypeException |
|
830 | + * @throws InvalidInterfaceException |
|
831 | + */ |
|
832 | + public static function process_admin_payment(EE_Payment $payment) |
|
833 | + { |
|
834 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
835 | + // we need to get the transaction object |
|
836 | + $transaction = $payment->transaction(); |
|
837 | + if ($transaction instanceof EE_Transaction) { |
|
838 | + $data = [$transaction, $payment]; |
|
839 | + $message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID()); |
|
840 | + |
|
841 | + // if payment amount is less than 0 then switch to payment_refund message type. |
|
842 | + $message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type; |
|
843 | + |
|
844 | + // if payment_refund is selected, but the status is NOT accepted. Then change message type to false so NO message notification goes out. |
|
845 | + $message_type = $message_type == 'payment_refund' && $payment->STS_ID() != EEM_Payment::status_id_approved |
|
846 | + ? false : $message_type; |
|
847 | + |
|
848 | + self::_load_controller(); |
|
849 | + |
|
850 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data); |
|
851 | + |
|
852 | + // get count of queued for generation |
|
853 | + $count_to_generate = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue( |
|
854 | + [ |
|
855 | + EEM_Message::status_incomplete, |
|
856 | + EEM_Message::status_idle, |
|
857 | + ] |
|
858 | + ); |
|
859 | + |
|
860 | + if ($count_to_generate > 0 && self::$_MSG_PROCESSOR->get_queue()->get_message_repository()->count() !== 0) { |
|
861 | + add_filter('FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true'); |
|
862 | + return true; |
|
863 | + } else { |
|
864 | + $count_failed = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue( |
|
865 | + EEM_Message::instance()->stati_indicating_failed_sending() |
|
866 | + ); |
|
867 | + /** |
|
868 | + * Verify that there are actually errors. If not then we return a success message because the queue might have been emptied due to successful |
|
869 | + * IMMEDIATE generation. |
|
870 | + */ |
|
871 | + if ($count_failed > 0) { |
|
872 | + EE_Error::add_error( |
|
873 | + sprintf( |
|
874 | + _n( |
|
875 | + 'The payment notification generation failed.', |
|
876 | + '%d payment notifications failed being sent.', |
|
877 | + $count_failed, |
|
878 | + 'event_espresso' |
|
879 | + ), |
|
880 | + $count_failed |
|
881 | + ), |
|
882 | + __FILE__, |
|
883 | + __FUNCTION__, |
|
884 | + __LINE__ |
|
885 | + ); |
|
886 | + |
|
887 | + return false; |
|
888 | + } else { |
|
889 | + add_filter('FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true'); |
|
890 | + return true; |
|
891 | + } |
|
892 | + } |
|
893 | + } else { |
|
894 | + EE_Error::add_error( |
|
895 | + esc_html__( |
|
896 | + 'Unable to generate the payment notification because the given value for the transaction is invalid.', |
|
897 | + 'event_espresso' |
|
898 | + ), |
|
899 | + __FILE__, |
|
900 | + __FUNCTION__, |
|
901 | + __LINE__ |
|
902 | + ); |
|
903 | + return false; |
|
904 | + } |
|
905 | + } |
|
906 | + |
|
907 | + |
|
908 | + /** |
|
909 | + * Callback for AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send_with_registrations trigger |
|
910 | + * |
|
911 | + * @param EE_Registration[] $registrations an array of EE_Registration objects |
|
912 | + * @param int $grp_id a specific message template group id. |
|
913 | + * @return void |
|
914 | + * @throws EE_Error |
|
915 | + * @throws InvalidArgumentException |
|
916 | + * @throws InvalidDataTypeException |
|
917 | + * @throws InvalidInterfaceException |
|
918 | + * @throws ReflectionException |
|
919 | + * @since 4.3.0 |
|
920 | + */ |
|
921 | + public static function send_newsletter_message($registrations, $grp_id) |
|
922 | + { |
|
923 | + // make sure mtp is id and set it in the request later messages setup. |
|
924 | + self::getRequest()->setRequestParam('GRP_ID', (int) $grp_id); |
|
925 | + self::_load_controller(); |
|
926 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers('newsletter', $registrations); |
|
927 | + } |
|
928 | + |
|
929 | + |
|
930 | + /** |
|
931 | + * Callback for FHEE__EE_Registration__invoice_url__invoice_url or FHEE__EE_Registration__receipt_url__receipt_url |
|
932 | + * |
|
933 | + * @param string $registration_message_trigger_url |
|
934 | + * @param EE_Registration $registration |
|
935 | + * @param string $messenger |
|
936 | + * @param string $message_type |
|
937 | + * @return string |
|
938 | + * @throws EE_Error |
|
939 | + * @throws InvalidArgumentException |
|
940 | + * @throws InvalidDataTypeException |
|
941 | + * @throws InvalidInterfaceException |
|
942 | + * @throws ReflectionException |
|
943 | + * @since 4.3.0 |
|
944 | + */ |
|
945 | + public static function registration_message_trigger_url( |
|
946 | + $registration_message_trigger_url, |
|
947 | + EE_Registration $registration, |
|
948 | + $messenger = 'html', |
|
949 | + $message_type = 'invoice' |
|
950 | + ) { |
|
951 | + // whitelist $messenger |
|
952 | + switch ($messenger) { |
|
953 | + case 'pdf': |
|
954 | + $sending_messenger = 'pdf'; |
|
955 | + $generating_messenger = 'html'; |
|
956 | + break; |
|
957 | + case 'html': |
|
958 | + default: |
|
959 | + $sending_messenger = 'html'; |
|
960 | + $generating_messenger = 'html'; |
|
961 | + break; |
|
962 | + } |
|
963 | + // whitelist $message_type |
|
964 | + switch ($message_type) { |
|
965 | + case 'receipt': |
|
966 | + $message_type = 'receipt'; |
|
967 | + break; |
|
968 | + case 'invoice': |
|
969 | + default: |
|
970 | + $message_type = 'invoice'; |
|
971 | + break; |
|
972 | + } |
|
973 | + // verify that both the messenger AND the message type are active |
|
974 | + if ( |
|
975 | + EEH_MSG_Template::is_messenger_active($sending_messenger) |
|
976 | + && EEH_MSG_Template::is_mt_active($message_type) |
|
977 | + ) { |
|
978 | + // need to get the correct message template group for this (i.e. is there a custom invoice for the event this registration is registered for?) |
|
979 | + $template_query_params = [ |
|
980 | + 'MTP_is_active' => true, |
|
981 | + 'MTP_messenger' => $generating_messenger, |
|
982 | + 'MTP_message_type' => $message_type, |
|
983 | + 'Event.EVT_ID' => $registration->event_ID(), |
|
984 | + ]; |
|
985 | + // get the message template group. |
|
986 | + $msg_template_group = EEM_Message_Template_Group::instance()->get_one([$template_query_params]); |
|
987 | + // if we don't have an EE_Message_Template_Group then return |
|
988 | + if (! $msg_template_group instanceof EE_Message_Template_Group) { |
|
989 | + // remove EVT_ID from query params so that global templates get picked up |
|
990 | + unset($template_query_params['Event.EVT_ID']); |
|
991 | + // get global template as the fallback |
|
992 | + $msg_template_group = EEM_Message_Template_Group::instance()->get_one([$template_query_params]); |
|
993 | + } |
|
994 | + // if we don't have an EE_Message_Template_Group then return |
|
995 | + if (! $msg_template_group instanceof EE_Message_Template_Group) { |
|
996 | + return ''; |
|
997 | + } |
|
998 | + // generate the URL |
|
999 | + $registration_message_trigger_url = EEH_MSG_Template::generate_url_trigger( |
|
1000 | + $sending_messenger, |
|
1001 | + $generating_messenger, |
|
1002 | + 'purchaser', |
|
1003 | + $message_type, |
|
1004 | + $registration, |
|
1005 | + $msg_template_group->ID(), |
|
1006 | + $registration->transaction_ID() |
|
1007 | + ); |
|
1008 | + } |
|
1009 | + return $registration_message_trigger_url; |
|
1010 | + } |
|
1011 | + |
|
1012 | + |
|
1013 | + /** |
|
1014 | + * Use to generate and return a message preview! |
|
1015 | + * |
|
1016 | + * @param string $type This should correspond with a valid message type |
|
1017 | + * @param string $context This should correspond with a valid context for the message type |
|
1018 | + * @param string $messenger This should correspond with a valid messenger. |
|
1019 | + * @param bool $send true we will do a test send using the messenger delivery, false we just do a regular |
|
1020 | + * preview |
|
1021 | + * @return bool|string The body of the message or if send is requested, sends. |
|
1022 | + * @throws EE_Error |
|
1023 | + * @throws InvalidArgumentException |
|
1024 | + * @throws InvalidDataTypeException |
|
1025 | + * @throws InvalidInterfaceException |
|
1026 | + * @throws ReflectionException |
|
1027 | + */ |
|
1028 | + public static function preview_message($type, $context, $messenger, $send = false) |
|
1029 | + { |
|
1030 | + self::_load_controller(); |
|
1031 | + $message_to_generate = new EE_Message_To_Generate( |
|
1032 | + $messenger, |
|
1033 | + $type, |
|
1034 | + [], |
|
1035 | + $context, |
|
1036 | + true |
|
1037 | + ); |
|
1038 | + $generated_preview_queue = self::$_MSG_PROCESSOR->generate_for_preview($message_to_generate, $send); |
|
1039 | + |
|
1040 | + if ($generated_preview_queue instanceof EE_Messages_Queue) { |
|
1041 | + // loop through all content for the preview and remove any persisted records. |
|
1042 | + $content = ''; |
|
1043 | + foreach ($generated_preview_queue->get_message_repository() as $message) { |
|
1044 | + $content = $message->content(); |
|
1045 | + if ($message->ID() > 0 && $message->STS_ID() !== EEM_Message::status_failed) { |
|
1046 | + $message->delete(); |
|
1047 | + } |
|
1048 | + } |
|
1049 | + return $content; |
|
1050 | + } |
|
1051 | + return $generated_preview_queue; |
|
1052 | + } |
|
1053 | + |
|
1054 | + |
|
1055 | + /** |
|
1056 | + * This is a method that allows for sending a message using a messenger matching the string given and the provided |
|
1057 | + * EE_Message_Queue object. The EE_Message_Queue object is used to create a single aggregate EE_Message via the |
|
1058 | + * content found in the EE_Message objects in the queue. |
|
1059 | + * |
|
1060 | + * @param string $messenger a string matching a valid active messenger in the system |
|
1061 | + * @param string $message_type Although it seems contrary to the name of the method, a message |
|
1062 | + * type name is still required to send along the message type to the |
|
1063 | + * messenger because this is used for determining what specific |
|
1064 | + * variations might be loaded for the generated message. |
|
1065 | + * @param EE_Messages_Queue $queue |
|
1066 | + * @param string $custom_subject Can be used to set what the custom subject string will be on the |
|
1067 | + * aggregate EE_Message object. |
|
1068 | + * @return bool success or fail. |
|
1069 | + * @throws EE_Error |
|
1070 | + * @throws InvalidArgumentException |
|
1071 | + * @throws ReflectionException |
|
1072 | + * @throws InvalidDataTypeException |
|
1073 | + * @throws InvalidInterfaceException |
|
1074 | + * @since 4.9.0 |
|
1075 | + */ |
|
1076 | + public static function send_message_with_messenger_only( |
|
1077 | + $messenger, |
|
1078 | + $message_type, |
|
1079 | + EE_Messages_Queue $queue, |
|
1080 | + $custom_subject = '' |
|
1081 | + ) { |
|
1082 | + self::_load_controller(); |
|
1083 | + /** @type EE_Message_To_Generate_From_Queue $message_to_generate */ |
|
1084 | + $message_to_generate = EE_Registry::instance()->load_lib( |
|
1085 | + 'Message_To_Generate_From_Queue', |
|
1086 | + [ |
|
1087 | + $messenger, |
|
1088 | + $message_type, |
|
1089 | + $queue, |
|
1090 | + $custom_subject, |
|
1091 | + ] |
|
1092 | + ); |
|
1093 | + return self::$_MSG_PROCESSOR->queue_for_sending($message_to_generate); |
|
1094 | + } |
|
1095 | + |
|
1096 | + |
|
1097 | + /** |
|
1098 | + * Generates Messages immediately for EE_Message IDs (but only for the correct status for generation) |
|
1099 | + * |
|
1100 | + * @param array $message_ids An array of message ids |
|
1101 | + * @return bool|EE_Messages_Queue false if nothing was generated, EE_Messages_Queue containing generated |
|
1102 | + * messages. |
|
1103 | + * @throws EE_Error |
|
1104 | + * @throws InvalidArgumentException |
|
1105 | + * @throws InvalidDataTypeException |
|
1106 | + * @throws InvalidInterfaceException |
|
1107 | + * @throws ReflectionException |
|
1108 | + * @since 4.9.0 |
|
1109 | + */ |
|
1110 | + public static function generate_now($message_ids) |
|
1111 | + { |
|
1112 | + self::_load_controller(); |
|
1113 | + $messages = EEM_Message::instance()->get_all( |
|
1114 | + [ |
|
1115 | + 0 => [ |
|
1116 | + 'MSG_ID' => ['IN', $message_ids], |
|
1117 | + 'STS_ID' => EEM_Message::status_incomplete, |
|
1118 | + ], |
|
1119 | + ] |
|
1120 | + ); |
|
1121 | + $generated_queue = false; |
|
1122 | + if ($messages) { |
|
1123 | + $generated_queue = self::$_MSG_PROCESSOR->batch_generate_from_queue($messages); |
|
1124 | + } |
|
1125 | + |
|
1126 | + if (! $generated_queue instanceof EE_Messages_Queue) { |
|
1127 | + EE_Error::add_error( |
|
1128 | + esc_html__( |
|
1129 | + 'The messages were not generated. This could mean there is already a batch being generated on a separate request, or because the selected messages are not ready for generation. Please wait a minute or two and try again.', |
|
1130 | + 'event_espresso' |
|
1131 | + ), |
|
1132 | + __FILE__, |
|
1133 | + __FUNCTION__, |
|
1134 | + __LINE__ |
|
1135 | + ); |
|
1136 | + } |
|
1137 | + return $generated_queue; |
|
1138 | + } |
|
1139 | + |
|
1140 | + |
|
1141 | + /** |
|
1142 | + * Sends messages immediately for the incoming message_ids that have the status of EEM_Message::status_resend or, |
|
1143 | + * EEM_Message::status_idle |
|
1144 | + * |
|
1145 | + * @param $message_ids |
|
1146 | + * @return bool|EE_Messages_Queue false if no messages sent. |
|
1147 | + * @throws EE_Error |
|
1148 | + * @throws InvalidArgumentException |
|
1149 | + * @throws InvalidDataTypeException |
|
1150 | + * @throws InvalidInterfaceException |
|
1151 | + * @throws ReflectionException |
|
1152 | + * @since 4.9.0 |
|
1153 | + */ |
|
1154 | + public static function send_now($message_ids) |
|
1155 | + { |
|
1156 | + self::_load_controller(); |
|
1157 | + $messages = EEM_Message::instance()->get_all( |
|
1158 | + [ |
|
1159 | + 0 => [ |
|
1160 | + 'MSG_ID' => ['IN', $message_ids], |
|
1161 | + 'STS_ID' => [ |
|
1162 | + 'IN', |
|
1163 | + [EEM_Message::status_idle, EEM_Message::status_resend, EEM_Message::status_retry], |
|
1164 | + ], |
|
1165 | + ], |
|
1166 | + ] |
|
1167 | + ); |
|
1168 | + $sent_queue = false; |
|
1169 | + if ($messages) { |
|
1170 | + $sent_queue = self::$_MSG_PROCESSOR->batch_send_from_queue($messages); |
|
1171 | + } |
|
1172 | + |
|
1173 | + if (! $sent_queue instanceof EE_Messages_Queue) { |
|
1174 | + EE_Error::add_error( |
|
1175 | + esc_html__( |
|
1176 | + 'The messages were not sent. This could mean there is already a batch being sent on a separate request, or because the selected messages are not sendable. Please wait a minute or two and try again.', |
|
1177 | + 'event_espresso' |
|
1178 | + ), |
|
1179 | + __FILE__, |
|
1180 | + __FUNCTION__, |
|
1181 | + __LINE__ |
|
1182 | + ); |
|
1183 | + } else { |
|
1184 | + // can count how many sent by using the messages in the queue |
|
1185 | + $sent_count = $sent_queue->count_STS_in_queue(EEM_Message::instance()->stati_indicating_sent()); |
|
1186 | + if ($sent_count > 0) { |
|
1187 | + EE_Error::add_success( |
|
1188 | + sprintf( |
|
1189 | + _n( |
|
1190 | + 'There was %d message successfully sent.', |
|
1191 | + 'There were %d messages successfully sent.', |
|
1192 | + $sent_count, |
|
1193 | + 'event_espresso' |
|
1194 | + ), |
|
1195 | + $sent_count |
|
1196 | + ) |
|
1197 | + ); |
|
1198 | + } else { |
|
1199 | + EE_Error::overwrite_errors(); |
|
1200 | + EE_Error::add_error( |
|
1201 | + esc_html__( |
|
1202 | + 'No message was sent because of problems with sending. Either all the messages you selected were not a sendable message, they were ALREADY sent on a different scheduled task, or there was an error. |
|
1203 | 1203 | If there was an error, you can look at the messages in the message activity list table for any error messages.', |
1204 | - 'event_espresso' |
|
1205 | - ), |
|
1206 | - __FILE__, |
|
1207 | - __FUNCTION__, |
|
1208 | - __LINE__ |
|
1209 | - ); |
|
1210 | - } |
|
1211 | - } |
|
1212 | - return $sent_queue; |
|
1213 | - } |
|
1214 | - |
|
1215 | - |
|
1216 | - /** |
|
1217 | - * Generate and send immediately from the given $message_ids |
|
1218 | - * |
|
1219 | - * @param array $message_ids EE_Message entity ids. |
|
1220 | - * @throws EE_Error |
|
1221 | - * @throws InvalidArgumentException |
|
1222 | - * @throws InvalidDataTypeException |
|
1223 | - * @throws InvalidInterfaceException |
|
1224 | - * @throws ReflectionException |
|
1225 | - */ |
|
1226 | - public static function generate_and_send_now(array $message_ids) |
|
1227 | - { |
|
1228 | - $generated_queue = self::generate_now($message_ids); |
|
1229 | - // now let's just trigger sending immediately from this queue. |
|
1230 | - $messages_sent = $generated_queue instanceof EE_Messages_Queue |
|
1231 | - ? $generated_queue->execute() |
|
1232 | - : 0; |
|
1233 | - if ($messages_sent) { |
|
1234 | - EE_Error::add_success( |
|
1235 | - esc_html( |
|
1236 | - sprintf( |
|
1237 | - _n( |
|
1238 | - 'There was %d message successfully generated and sent.', |
|
1239 | - 'There were %d messages successfully generated and sent.', |
|
1240 | - $messages_sent, |
|
1241 | - 'event_espresso' |
|
1242 | - ), |
|
1243 | - $messages_sent |
|
1244 | - ) |
|
1245 | - ) |
|
1246 | - ); |
|
1247 | - // errors would be added via the generate_now method. |
|
1248 | - } |
|
1249 | - } |
|
1250 | - |
|
1251 | - |
|
1252 | - /** |
|
1253 | - * This will queue the incoming message ids for resending. |
|
1254 | - * Note, only message_ids corresponding to messages with the status of EEM_Message::sent will be queued. |
|
1255 | - * |
|
1256 | - * @param array $message_ids An array of EE_Message IDs |
|
1257 | - * @return bool true means messages were successfully queued for resending, false means none were queued for |
|
1258 | - * resending. |
|
1259 | - * @throws EE_Error |
|
1260 | - * @throws InvalidArgumentException |
|
1261 | - * @throws InvalidDataTypeException |
|
1262 | - * @throws InvalidInterfaceException |
|
1263 | - * @throws ReflectionException |
|
1264 | - * @since 4.9.0 |
|
1265 | - */ |
|
1266 | - public static function queue_for_resending($message_ids) |
|
1267 | - { |
|
1268 | - self::_load_controller(); |
|
1269 | - self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send($message_ids); |
|
1270 | - |
|
1271 | - // get queue and count |
|
1272 | - $queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend); |
|
1273 | - |
|
1274 | - if ( |
|
1275 | - $queue_count > 0 |
|
1276 | - ) { |
|
1277 | - EE_Error::add_success( |
|
1278 | - sprintf( |
|
1279 | - _n( |
|
1280 | - '%d message successfully queued for resending.', |
|
1281 | - '%d messages successfully queued for resending.', |
|
1282 | - $queue_count, |
|
1283 | - 'event_espresso' |
|
1284 | - ), |
|
1285 | - $queue_count |
|
1286 | - ) |
|
1287 | - ); |
|
1288 | - /** |
|
1289 | - * @see filter usage in EE_Messages_Queue::initiate_request_by_priority |
|
1290 | - */ |
|
1291 | - } elseif ( |
|
1292 | - apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', true) |
|
1293 | - || EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request |
|
1294 | - ) { |
|
1295 | - $queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_sent); |
|
1296 | - if ($queue_count > 0) { |
|
1297 | - EE_Error::add_success( |
|
1298 | - sprintf( |
|
1299 | - _n( |
|
1300 | - '%d message successfully sent.', |
|
1301 | - '%d messages successfully sent.', |
|
1302 | - $queue_count, |
|
1303 | - 'event_espresso' |
|
1304 | - ), |
|
1305 | - $queue_count |
|
1306 | - ) |
|
1307 | - ); |
|
1308 | - } else { |
|
1309 | - EE_Error::add_error( |
|
1310 | - esc_html__( |
|
1311 | - 'No messages were queued for resending. This usually only happens when all the messages flagged for resending are not a status that can be resent.', |
|
1312 | - 'event_espresso' |
|
1313 | - ), |
|
1314 | - __FILE__, |
|
1315 | - __FUNCTION__, |
|
1316 | - __LINE__ |
|
1317 | - ); |
|
1318 | - } |
|
1319 | - } else { |
|
1320 | - EE_Error::add_error( |
|
1321 | - esc_html__( |
|
1322 | - 'No messages were queued for resending. This usually only happens when all the messages flagged for resending are not a status that can be resent.', |
|
1323 | - 'event_espresso' |
|
1324 | - ), |
|
1325 | - __FILE__, |
|
1326 | - __FUNCTION__, |
|
1327 | - __LINE__ |
|
1328 | - ); |
|
1329 | - } |
|
1330 | - return (bool) $queue_count; |
|
1331 | - } |
|
1332 | - |
|
1333 | - |
|
1334 | - /** |
|
1335 | - * debug |
|
1336 | - * |
|
1337 | - * @param string $class |
|
1338 | - * @param string $func |
|
1339 | - * @param string $line |
|
1340 | - * @param EE_Transaction|null $transaction |
|
1341 | - * @param array $info |
|
1342 | - * @param bool $display_request |
|
1343 | - * @throws EE_Error |
|
1344 | - * @throws ReflectionException |
|
1345 | - * @throws InvalidSessionDataException |
|
1346 | - */ |
|
1347 | - protected static function log( |
|
1348 | - $class = '', |
|
1349 | - $func = '', |
|
1350 | - $line = '', |
|
1351 | - EE_Transaction $transaction = null, |
|
1352 | - $info = [], |
|
1353 | - $display_request = false |
|
1354 | - ) { |
|
1355 | - if (defined('EE_DEBUG') && EE_DEBUG) { |
|
1356 | - if ($transaction instanceof EE_Transaction) { |
|
1357 | - // don't serialize objects |
|
1358 | - $info = EEH_Debug_Tools::strip_objects($info); |
|
1359 | - $info['TXN_status'] = $transaction->status_ID(); |
|
1360 | - $info['TXN_reg_steps'] = $transaction->reg_steps(); |
|
1361 | - if ($transaction->ID()) { |
|
1362 | - $index = 'EE_Transaction: ' . $transaction->ID(); |
|
1363 | - EEH_Debug_Tools::log($class, $func, $line, $info, $display_request, $index); |
|
1364 | - } |
|
1365 | - } |
|
1366 | - } |
|
1367 | - } |
|
1368 | - |
|
1369 | - |
|
1370 | - /** |
|
1371 | - * Resets all the static properties in this class when called. |
|
1372 | - */ |
|
1373 | - public static function reset() |
|
1374 | - { |
|
1375 | - self::$_EEMSG = null; |
|
1376 | - self::$_message_resource_manager = null; |
|
1377 | - self::$_MSG_PROCESSOR = null; |
|
1378 | - self::$_MSG_PATHS = null; |
|
1379 | - self::$_TMP_PACKS = []; |
|
1380 | - } |
|
1204 | + 'event_espresso' |
|
1205 | + ), |
|
1206 | + __FILE__, |
|
1207 | + __FUNCTION__, |
|
1208 | + __LINE__ |
|
1209 | + ); |
|
1210 | + } |
|
1211 | + } |
|
1212 | + return $sent_queue; |
|
1213 | + } |
|
1214 | + |
|
1215 | + |
|
1216 | + /** |
|
1217 | + * Generate and send immediately from the given $message_ids |
|
1218 | + * |
|
1219 | + * @param array $message_ids EE_Message entity ids. |
|
1220 | + * @throws EE_Error |
|
1221 | + * @throws InvalidArgumentException |
|
1222 | + * @throws InvalidDataTypeException |
|
1223 | + * @throws InvalidInterfaceException |
|
1224 | + * @throws ReflectionException |
|
1225 | + */ |
|
1226 | + public static function generate_and_send_now(array $message_ids) |
|
1227 | + { |
|
1228 | + $generated_queue = self::generate_now($message_ids); |
|
1229 | + // now let's just trigger sending immediately from this queue. |
|
1230 | + $messages_sent = $generated_queue instanceof EE_Messages_Queue |
|
1231 | + ? $generated_queue->execute() |
|
1232 | + : 0; |
|
1233 | + if ($messages_sent) { |
|
1234 | + EE_Error::add_success( |
|
1235 | + esc_html( |
|
1236 | + sprintf( |
|
1237 | + _n( |
|
1238 | + 'There was %d message successfully generated and sent.', |
|
1239 | + 'There were %d messages successfully generated and sent.', |
|
1240 | + $messages_sent, |
|
1241 | + 'event_espresso' |
|
1242 | + ), |
|
1243 | + $messages_sent |
|
1244 | + ) |
|
1245 | + ) |
|
1246 | + ); |
|
1247 | + // errors would be added via the generate_now method. |
|
1248 | + } |
|
1249 | + } |
|
1250 | + |
|
1251 | + |
|
1252 | + /** |
|
1253 | + * This will queue the incoming message ids for resending. |
|
1254 | + * Note, only message_ids corresponding to messages with the status of EEM_Message::sent will be queued. |
|
1255 | + * |
|
1256 | + * @param array $message_ids An array of EE_Message IDs |
|
1257 | + * @return bool true means messages were successfully queued for resending, false means none were queued for |
|
1258 | + * resending. |
|
1259 | + * @throws EE_Error |
|
1260 | + * @throws InvalidArgumentException |
|
1261 | + * @throws InvalidDataTypeException |
|
1262 | + * @throws InvalidInterfaceException |
|
1263 | + * @throws ReflectionException |
|
1264 | + * @since 4.9.0 |
|
1265 | + */ |
|
1266 | + public static function queue_for_resending($message_ids) |
|
1267 | + { |
|
1268 | + self::_load_controller(); |
|
1269 | + self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send($message_ids); |
|
1270 | + |
|
1271 | + // get queue and count |
|
1272 | + $queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend); |
|
1273 | + |
|
1274 | + if ( |
|
1275 | + $queue_count > 0 |
|
1276 | + ) { |
|
1277 | + EE_Error::add_success( |
|
1278 | + sprintf( |
|
1279 | + _n( |
|
1280 | + '%d message successfully queued for resending.', |
|
1281 | + '%d messages successfully queued for resending.', |
|
1282 | + $queue_count, |
|
1283 | + 'event_espresso' |
|
1284 | + ), |
|
1285 | + $queue_count |
|
1286 | + ) |
|
1287 | + ); |
|
1288 | + /** |
|
1289 | + * @see filter usage in EE_Messages_Queue::initiate_request_by_priority |
|
1290 | + */ |
|
1291 | + } elseif ( |
|
1292 | + apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', true) |
|
1293 | + || EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request |
|
1294 | + ) { |
|
1295 | + $queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_sent); |
|
1296 | + if ($queue_count > 0) { |
|
1297 | + EE_Error::add_success( |
|
1298 | + sprintf( |
|
1299 | + _n( |
|
1300 | + '%d message successfully sent.', |
|
1301 | + '%d messages successfully sent.', |
|
1302 | + $queue_count, |
|
1303 | + 'event_espresso' |
|
1304 | + ), |
|
1305 | + $queue_count |
|
1306 | + ) |
|
1307 | + ); |
|
1308 | + } else { |
|
1309 | + EE_Error::add_error( |
|
1310 | + esc_html__( |
|
1311 | + 'No messages were queued for resending. This usually only happens when all the messages flagged for resending are not a status that can be resent.', |
|
1312 | + 'event_espresso' |
|
1313 | + ), |
|
1314 | + __FILE__, |
|
1315 | + __FUNCTION__, |
|
1316 | + __LINE__ |
|
1317 | + ); |
|
1318 | + } |
|
1319 | + } else { |
|
1320 | + EE_Error::add_error( |
|
1321 | + esc_html__( |
|
1322 | + 'No messages were queued for resending. This usually only happens when all the messages flagged for resending are not a status that can be resent.', |
|
1323 | + 'event_espresso' |
|
1324 | + ), |
|
1325 | + __FILE__, |
|
1326 | + __FUNCTION__, |
|
1327 | + __LINE__ |
|
1328 | + ); |
|
1329 | + } |
|
1330 | + return (bool) $queue_count; |
|
1331 | + } |
|
1332 | + |
|
1333 | + |
|
1334 | + /** |
|
1335 | + * debug |
|
1336 | + * |
|
1337 | + * @param string $class |
|
1338 | + * @param string $func |
|
1339 | + * @param string $line |
|
1340 | + * @param EE_Transaction|null $transaction |
|
1341 | + * @param array $info |
|
1342 | + * @param bool $display_request |
|
1343 | + * @throws EE_Error |
|
1344 | + * @throws ReflectionException |
|
1345 | + * @throws InvalidSessionDataException |
|
1346 | + */ |
|
1347 | + protected static function log( |
|
1348 | + $class = '', |
|
1349 | + $func = '', |
|
1350 | + $line = '', |
|
1351 | + EE_Transaction $transaction = null, |
|
1352 | + $info = [], |
|
1353 | + $display_request = false |
|
1354 | + ) { |
|
1355 | + if (defined('EE_DEBUG') && EE_DEBUG) { |
|
1356 | + if ($transaction instanceof EE_Transaction) { |
|
1357 | + // don't serialize objects |
|
1358 | + $info = EEH_Debug_Tools::strip_objects($info); |
|
1359 | + $info['TXN_status'] = $transaction->status_ID(); |
|
1360 | + $info['TXN_reg_steps'] = $transaction->reg_steps(); |
|
1361 | + if ($transaction->ID()) { |
|
1362 | + $index = 'EE_Transaction: ' . $transaction->ID(); |
|
1363 | + EEH_Debug_Tools::log($class, $func, $line, $info, $display_request, $index); |
|
1364 | + } |
|
1365 | + } |
|
1366 | + } |
|
1367 | + } |
|
1368 | + |
|
1369 | + |
|
1370 | + /** |
|
1371 | + * Resets all the static properties in this class when called. |
|
1372 | + */ |
|
1373 | + public static function reset() |
|
1374 | + { |
|
1375 | + self::$_EEMSG = null; |
|
1376 | + self::$_message_resource_manager = null; |
|
1377 | + self::$_MSG_PROCESSOR = null; |
|
1378 | + self::$_MSG_PATHS = null; |
|
1379 | + self::$_TMP_PACKS = []; |
|
1380 | + } |
|
1381 | 1381 | } |
@@ -11,20 +11,20 @@ discard block |
||
11 | 11 | <strong><?php esc_html_e('ID', 'event_espresso'); ?></strong> |
12 | 12 | <br /> |
13 | 13 | <?php printf( |
14 | - esc_html__( |
|
15 | - 'The is the numerical ID of an registration. This value is used internally for %s.', |
|
16 | - 'event_espresso' |
|
17 | - ), |
|
18 | - Domain::brandName() |
|
19 | - ); ?> |
|
14 | + esc_html__( |
|
15 | + 'The is the numerical ID of an registration. This value is used internally for %s.', |
|
16 | + 'event_espresso' |
|
17 | + ), |
|
18 | + Domain::brandName() |
|
19 | + ); ?> |
|
20 | 20 | </li> |
21 | 21 | <li> |
22 | 22 | <strong><?php esc_html_e('Name', 'event_espresso'); ?></strong> |
23 | 23 | <br /> |
24 | 24 | <?php esc_html_e( |
25 | - 'This is the name of a registrant. The primary registrant will have a star to the right of their name.', |
|
26 | - 'event_espresso' |
|
27 | - ); ?> |
|
25 | + 'This is the name of a registrant. The primary registrant will have a star to the right of their name.', |
|
26 | + 'event_espresso' |
|
27 | + ); ?> |
|
28 | 28 | </li> |
29 | 29 | <li> |
30 | 30 | <strong><?php esc_html_e('TXN Date', 'event_espresso'); ?></strong> |
@@ -55,14 +55,14 @@ discard block |
||
55 | 55 | <strong><?php esc_html_e('Actions', 'event_espresso'); ?></strong> |
56 | 56 | <br /> |
57 | 57 | <?php printf( |
58 | - esc_html__( |
|
59 | - 'Using the action buttons you can View Registration Details %1$s, Edit Contact Details %2$s, Resend Registration Details %3$s, and View Transaction Details %4$s.', |
|
60 | - 'event_espresso' |
|
61 | - ), |
|
62 | - '<span class="dashicons dashicons-clipboard"></span>', |
|
63 | - '<span class="dashicons dashicons-admin-users"></span>', |
|
64 | - '<span class="dashicons dashicons-email-alt"></span>', |
|
65 | - '<span class="dashicons dashicons-cart"></span>' |
|
66 | - ); ?> |
|
58 | + esc_html__( |
|
59 | + 'Using the action buttons you can View Registration Details %1$s, Edit Contact Details %2$s, Resend Registration Details %3$s, and View Transaction Details %4$s.', |
|
60 | + 'event_espresso' |
|
61 | + ), |
|
62 | + '<span class="dashicons dashicons-clipboard"></span>', |
|
63 | + '<span class="dashicons dashicons-admin-users"></span>', |
|
64 | + '<span class="dashicons dashicons-email-alt"></span>', |
|
65 | + '<span class="dashicons dashicons-cart"></span>' |
|
66 | + ); ?> |
|
67 | 67 | </li> |
68 | 68 | </ul> |
69 | 69 | \ No newline at end of file |
@@ -8,15 +8,15 @@ |
||
8 | 8 | <strong><?php esc_html_e('Recommendations', 'event_espresso'); ?></strong> |
9 | 9 | <br /> |
10 | 10 | <?php esc_html_e( |
11 | - 'To learn more about the options on this page, take a look at the different tabs that appear on the left side of the page.', |
|
12 | - 'event_espresso' |
|
13 | - ); ?> |
|
11 | + 'To learn more about the options on this page, take a look at the different tabs that appear on the left side of the page.', |
|
12 | + 'event_espresso' |
|
13 | + ); ?> |
|
14 | 14 | </p> |
15 | 15 | <p> |
16 | 16 | <strong><?php esc_html_e('Screen Options', 'event_espresso'); ?></strong> |
17 | 17 | <br /> |
18 | 18 | <?php esc_html_e( |
19 | - 'You can customize the information that is shown on this page by toggling the Screen Options tab. Then you can add or remove checkmarks to hide or show certain content and even adjust the pagination for venues.', |
|
20 | - 'event_espresso' |
|
21 | - ); ?> |
|
19 | + 'You can customize the information that is shown on this page by toggling the Screen Options tab. Then you can add or remove checkmarks to hide or show certain content and even adjust the pagination for venues.', |
|
20 | + 'event_espresso' |
|
21 | + ); ?> |
|
22 | 22 | </p> |
23 | 23 | \ No newline at end of file |
@@ -3,15 +3,15 @@ |
||
3 | 3 | </p> |
4 | 4 | <p> |
5 | 5 | <?php esc_html_e( |
6 | - 'This page shows all venue categories that have been created with Event Espresso.', |
|
7 | - 'event_espresso' |
|
8 | - ); ?> |
|
6 | + 'This page shows all venue categories that have been created with Event Espresso.', |
|
7 | + 'event_espresso' |
|
8 | + ); ?> |
|
9 | 9 | </p> |
10 | 10 | <p> |
11 | 11 | <strong><?php esc_html_e('Screen Options', 'event_espresso'); ?></strong> |
12 | 12 | <br /> |
13 | 13 | <?php esc_html_e( |
14 | - 'You can customize the information that is shown on this page by toggling the Screen Options tab. Then you can add or remove checkmarks to hide or show certain content and even adjust the pagination for venue categories.', |
|
15 | - 'event_espresso' |
|
16 | - ); ?> |
|
14 | + 'You can customize the information that is shown on this page by toggling the Screen Options tab. Then you can add or remove checkmarks to hide or show certain content and even adjust the pagination for venue categories.', |
|
15 | + 'event_espresso' |
|
16 | + ); ?> |
|
17 | 17 | </p> |
18 | 18 | \ No newline at end of file |
@@ -3,15 +3,15 @@ discard block |
||
3 | 3 | </p> |
4 | 4 | <p> |
5 | 5 | <?php esc_html_e( |
6 | - 'This page shows options for Google Maps. You can activate Google Maps by setting the toggle to Yes and clicking on the Save button to update settings.', |
|
7 | - 'event_espresso' |
|
8 | - ); ?> |
|
6 | + 'This page shows options for Google Maps. You can activate Google Maps by setting the toggle to Yes and clicking on the Save button to update settings.', |
|
7 | + 'event_espresso' |
|
8 | + ); ?> |
|
9 | 9 | </p> |
10 | 10 | <p> |
11 | 11 | <?php esc_html_e( |
12 | - 'The map options allow you to configure how your event map is displayed. You may configure your events lists and event registration pages independently of each other. For an event to display a Google Map you must have it enabled in the event editor or in the venue metabox. This allows you to select which events you would like to display with a map.', |
|
13 | - 'event_espresso' |
|
14 | - ); ?> |
|
12 | + 'The map options allow you to configure how your event map is displayed. You may configure your events lists and event registration pages independently of each other. For an event to display a Google Map you must have it enabled in the event editor or in the venue metabox. This allows you to select which events you would like to display with a map.', |
|
13 | + 'event_espresso' |
|
14 | + ); ?> |
|
15 | 15 | </p> |
16 | 16 | <p> |
17 | 17 | <strong><?php esc_html_e('Map Settings for Registration Page & Event List Options', 'event_espresso'); ?></strong> |
@@ -21,72 +21,72 @@ discard block |
||
21 | 21 | <strong><?php esc_html_e('Set Map Width', 'event_espresso'); ?></strong> |
22 | 22 | <br /> |
23 | 23 | <?php esc_html_e( |
24 | - 'You may set a pixel width for your map. This should be entered as a numeric value with no other characters. If a value is not set then default ones are used -- registration page single maps are set to 500 pixels and events list maps are set to 200 pixels.', |
|
25 | - 'event_espresso' |
|
26 | - ); ?> |
|
24 | + 'You may set a pixel width for your map. This should be entered as a numeric value with no other characters. If a value is not set then default ones are used -- registration page single maps are set to 500 pixels and events list maps are set to 200 pixels.', |
|
25 | + 'event_espresso' |
|
26 | + ); ?> |
|
27 | 27 | </li> |
28 | 28 | <li> |
29 | 29 | <strong><?php esc_html_e('Set Map Height', 'event_espresso'); ?></strong> |
30 | 30 | <br /> |
31 | 31 | <?php esc_html_e( |
32 | - 'This setting is similar to set map width except it is for the map height. Maps will display best when matching dimensions are used.', |
|
33 | - 'event_espresso' |
|
34 | - ); ?> |
|
32 | + 'This setting is similar to set map width except it is for the map height. Maps will display best when matching dimensions are used.', |
|
33 | + 'event_espresso' |
|
34 | + ); ?> |
|
35 | 35 | </li> |
36 | 36 | <li> |
37 | 37 | <strong><?php esc_html_e('Set Map Zoom', 'event_espresso'); ?></strong> |
38 | 38 | <br /> |
39 | 39 | <?php esc_html_e( |
40 | - 'Zoom level is the level of detail that is shown when the map first renders. A smaller value means you zoom out and therefore see a wider area. A higher value means that you zoom in and see the actual address in finer detail. A default value of 12 is recommended.', |
|
41 | - 'event_espresso' |
|
42 | - ); ?> |
|
40 | + 'Zoom level is the level of detail that is shown when the map first renders. A smaller value means you zoom out and therefore see a wider area. A higher value means that you zoom in and see the actual address in finer detail. A default value of 12 is recommended.', |
|
41 | + 'event_espresso' |
|
42 | + ); ?> |
|
43 | 43 | </li> |
44 | 44 | <li> |
45 | 45 | <strong><?php esc_html_e('Set Map Navigation Overlay', 'event_espresso'); ?></strong> |
46 | 46 | <br /> |
47 | 47 | <?php esc_html_e( |
48 | - 'The navigation overlay are the controls for panning and zooming the map.', |
|
49 | - 'event_espresso' |
|
50 | - ); ?> |
|
48 | + 'The navigation overlay are the controls for panning and zooming the map.', |
|
49 | + 'event_espresso' |
|
50 | + ); ?> |
|
51 | 51 | </li> |
52 | 52 | <li> |
53 | 53 | <strong><?php esc_html_e('Keep Map Navigation Small', 'event_espresso'); ?></strong> |
54 | 54 | <br /> |
55 | 55 | <?php esc_html_e( |
56 | - 'Keep map navigation small tells Google to only load the smaller map overlay regardless of map size. Google changes various options according to the size of a map. If you want to stop this change from happening, you can set this option to yes.', |
|
57 | - 'event_espresso' |
|
58 | - ); ?> |
|
56 | + 'Keep map navigation small tells Google to only load the smaller map overlay regardless of map size. Google changes various options according to the size of a map. If you want to stop this change from happening, you can set this option to yes.', |
|
57 | + 'event_espresso' |
|
58 | + ); ?> |
|
59 | 59 | </li> |
60 | 60 | <li> |
61 | 61 | <strong><?php esc_html_e('Set Map Type Control', 'event_espresso'); ?></strong> |
62 | 62 | <br /> |
63 | 63 | <?php esc_html_e( |
64 | - 'The map type control is the options bar that Google sets in the top right corner. This can appear as a dropdown or horizontal bar.', |
|
65 | - 'event_espresso' |
|
66 | - ); ?> |
|
64 | + 'The map type control is the options bar that Google sets in the top right corner. This can appear as a dropdown or horizontal bar.', |
|
65 | + 'event_espresso' |
|
66 | + ); ?> |
|
67 | 67 | </li> |
68 | 68 | <li> |
69 | 69 | <strong><?php esc_html_e('Set Map Alignment', 'event_espresso'); ?></strong> |
70 | 70 | <br /> |
71 | 71 | <?php esc_html_e( |
72 | - 'Alignment allows you to move the map left, center, or right within the parent event structure. The default alignment is left.', |
|
73 | - 'event_espresso' |
|
74 | - ); ?> |
|
72 | + 'Alignment allows you to move the map left, center, or right within the parent event structure. The default alignment is left.', |
|
73 | + 'event_espresso' |
|
74 | + ); ?> |
|
75 | 75 | </li> |
76 | 76 | </ul> |
77 | 77 | <p> |
78 | 78 | <strong><?php esc_html_e('Recommendations', 'event_espresso'); ?></strong> |
79 | 79 | <br /> |
80 | 80 | <?php esc_html_e( |
81 | - 'To learn more about the options on this page, take a look at the different tabs that appear on the left side of the page.', |
|
82 | - 'event_espresso' |
|
83 | - ); ?> |
|
81 | + 'To learn more about the options on this page, take a look at the different tabs that appear on the left side of the page.', |
|
82 | + 'event_espresso' |
|
83 | + ); ?> |
|
84 | 84 | </p> |
85 | 85 | <p> |
86 | 86 | <strong><?php esc_html_e('Screen Options', 'event_espresso'); ?></strong> |
87 | 87 | <br /> |
88 | 88 | <?php esc_html_e( |
89 | - 'You can customize the information that is shown on this page by toggling the Screen Options tab. Then you can add or remove checkmarks to hide or show certain content.', |
|
90 | - 'event_espresso' |
|
91 | - ); ?> |
|
89 | + 'You can customize the information that is shown on this page by toggling the Screen Options tab. Then you can add or remove checkmarks to hide or show certain content.', |
|
90 | + 'event_espresso' |
|
91 | + ); ?> |
|
92 | 92 | </p> |
93 | 93 | \ No newline at end of file |
@@ -19,16 +19,16 @@ |
||
19 | 19 | <strong><?php esc_html_e('Category Description', 'event_espresso'); ?></strong> |
20 | 20 | <br /> |
21 | 21 | <?php esc_html_e( |
22 | - 'The rich text editor can be used to create a description for your venue category.', |
|
23 | - 'event_espresso' |
|
24 | - ); ?> |
|
22 | + 'The rich text editor can be used to create a description for your venue category.', |
|
23 | + 'event_espresso' |
|
24 | + ); ?> |
|
25 | 25 | </li> |
26 | 26 | </ul> |
27 | 27 | <p> |
28 | 28 | <strong><?php esc_html_e('Screen Options', 'event_espresso'); ?></strong> |
29 | 29 | <br /> |
30 | 30 | <?php esc_html_e( |
31 | - 'You can customize the information that is shown on this page by toggling the screen options tab. Then you can add or remove checkmarks to hide or show certain content.', |
|
32 | - 'event_espresso' |
|
33 | - ); ?> |
|
31 | + 'You can customize the information that is shown on this page by toggling the screen options tab. Then you can add or remove checkmarks to hide or show certain content.', |
|
32 | + 'event_espresso' |
|
33 | + ); ?> |
|
34 | 34 | </p> |