@@ -3,79 +3,79 @@ |
||
3 | 3 | </p> |
4 | 4 | <p> |
5 | 5 | <?php esc_html_e( |
6 | - 'You can select Messengers via the tabs across the top of the settings page. The available messengers you see depends on what version of Event Espresso you have and what addons are installed. Every install include an "Email" messenger tab. When you click one of those tabs it will display that messenger.', |
|
7 | - 'event_espresso' |
|
8 | - ); ?> |
|
6 | + 'You can select Messengers via the tabs across the top of the settings page. The available messengers you see depends on what version of Event Espresso you have and what addons are installed. Every install include an "Email" messenger tab. When you click one of those tabs it will display that messenger.', |
|
7 | + 'event_espresso' |
|
8 | + ); ?> |
|
9 | 9 | </p> |
10 | 10 | <p> |
11 | 11 | <?php esc_html_e( |
12 | - 'There are two ways to determine whether a messenger is active or not. The first way is via the messenger tab itself.', |
|
13 | - 'event_espresso' |
|
14 | - ); ?> |
|
12 | + 'There are two ways to determine whether a messenger is active or not. The first way is via the messenger tab itself.', |
|
13 | + 'event_espresso' |
|
14 | + ); ?> |
|
15 | 15 | </p> |
16 | 16 | <p> |
17 | 17 | <?php printf( |
18 | - esc_html__( |
|
19 | - 'The green colored gear %s indicates that this messenger is currently active.', |
|
20 | - 'event_espresso' |
|
21 | - ), |
|
22 | - '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-active.png' . '"' |
|
23 | - . ' alt="' . esc_attr__('Active Email Tab', 'event_espresso') . '" />' |
|
24 | - ); |
|
25 | - printf( |
|
26 | - esc_html__( |
|
27 | - ' The white colored gear %s indicates the messenger is inactive. This is very helpful for seeing at a glance all the messengers that are active when you first view the page.', |
|
28 | - 'event_espresso' |
|
29 | - ), |
|
30 | - '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-inactive.png' |
|
31 | - . '" alt="' . esc_attr__('Inactive Email Tab', 'event_espresso') . '" />' |
|
32 | - ); ?> |
|
18 | + esc_html__( |
|
19 | + 'The green colored gear %s indicates that this messenger is currently active.', |
|
20 | + 'event_espresso' |
|
21 | + ), |
|
22 | + '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-active.png' . '"' |
|
23 | + . ' alt="' . esc_attr__('Active Email Tab', 'event_espresso') . '" />' |
|
24 | + ); |
|
25 | + printf( |
|
26 | + esc_html__( |
|
27 | + ' The white colored gear %s indicates the messenger is inactive. This is very helpful for seeing at a glance all the messengers that are active when you first view the page.', |
|
28 | + 'event_espresso' |
|
29 | + ), |
|
30 | + '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-inactive.png' |
|
31 | + . '" alt="' . esc_attr__('Inactive Email Tab', 'event_espresso') . '" />' |
|
32 | + ); ?> |
|
33 | 33 | </p> |
34 | 34 | <p> |
35 | 35 | <?php esc_html_e( |
36 | - 'The second way to determine whether a messenger is active or not is via the "on/off" button in the top right corner of the active messenger displayed content:', |
|
37 | - 'event_espresso' |
|
38 | - ); ?> |
|
36 | + 'The second way to determine whether a messenger is active or not is via the "on/off" button in the top right corner of the active messenger displayed content:', |
|
37 | + 'event_espresso' |
|
38 | + ); ?> |
|
39 | 39 | </p> |
40 | 40 | <p> |
41 | 41 | <?php printf( |
42 | - esc_html__( |
|
43 | - '%1$s means of course that the messenger is active and %2$s means the messenger is inactive.', |
|
44 | - 'event_espresso' |
|
45 | - ), |
|
46 | - '<div class="switch">' |
|
47 | - . '<input class="ee-on-off-toggle ee-toggle-round-flat" type="checkbox" checked="checked" disabled>' |
|
48 | - . '<label for="ee-on-off-toggle-on"></label>' |
|
49 | - . '</div>', |
|
50 | - '<div class="switch">' |
|
51 | - . '<input class="ee-on-off-toggle ee-toggle-round-flat" type="checkbox" disabled>' |
|
52 | - . '<label for="ee-on-off-toggle-on"></label>' |
|
53 | - . '</div>' |
|
54 | - ); ?> |
|
42 | + esc_html__( |
|
43 | + '%1$s means of course that the messenger is active and %2$s means the messenger is inactive.', |
|
44 | + 'event_espresso' |
|
45 | + ), |
|
46 | + '<div class="switch">' |
|
47 | + . '<input class="ee-on-off-toggle ee-toggle-round-flat" type="checkbox" checked="checked" disabled>' |
|
48 | + . '<label for="ee-on-off-toggle-on"></label>' |
|
49 | + . '</div>', |
|
50 | + '<div class="switch">' |
|
51 | + . '<input class="ee-on-off-toggle ee-toggle-round-flat" type="checkbox" disabled>' |
|
52 | + . '<label for="ee-on-off-toggle-on"></label>' |
|
53 | + . '</div>' |
|
54 | + ); ?> |
|
55 | 55 | </p> |
56 | 56 | <p> |
57 | 57 | <?php |
58 | - esc_html_e( |
|
59 | - 'The on/off toggle is also what you use to activate or deactivate a messenger.', |
|
60 | - 'event_espresso' |
|
61 | - ); ?> |
|
58 | + esc_html_e( |
|
59 | + 'The on/off toggle is also what you use to activate or deactivate a messenger.', |
|
60 | + 'event_espresso' |
|
61 | + ); ?> |
|
62 | 62 | </p> |
63 | 63 | <p> |
64 | 64 | <?php esc_html_e( |
65 | - 'What happens when you click the toggle to activate is the messenger is activated and the system determines what default message types are activated with the messenger. Then, if there are any default settings for either the messenger or message types those settings are saved. Next, the system will generate any default templates (if none have been generated before, if there are previously generated templates then they are reactivated). Finally, you will see the display change to reflect that the messenger is active. If the messenger has settings you can modify them then. Any message types that have settings will also automatically expand so you can see the default settings and make any changes as necessary to fit your needs. Usually the defaults are sufficient however.', |
|
66 | - 'event_espresso' |
|
67 | - ); ?> |
|
65 | + 'What happens when you click the toggle to activate is the messenger is activated and the system determines what default message types are activated with the messenger. Then, if there are any default settings for either the messenger or message types those settings are saved. Next, the system will generate any default templates (if none have been generated before, if there are previously generated templates then they are reactivated). Finally, you will see the display change to reflect that the messenger is active. If the messenger has settings you can modify them then. Any message types that have settings will also automatically expand so you can see the default settings and make any changes as necessary to fit your needs. Usually the defaults are sufficient however.', |
|
66 | + 'event_espresso' |
|
67 | + ); ?> |
|
68 | 68 | </p> |
69 | 69 | <p> |
70 | 70 | <?php esc_html_e( |
71 | - 'When you deactivate a messenger, the system will first check if there are any custom event templates for that messenger. If there are you will be unable to deactivate the messenger. This is a fail safe to make sure you know that no messages will go out for those specific events so you don\'t accidentally deactivate. If this check passes, then the system will deactivate any global templates for that messenger (note the templates are not erased, they just become inactive, so if you decide to reactivate the messenger later all your customizations are preserved). Then the display will change to reflect the deactivation.', |
|
72 | - 'event_espresso' |
|
73 | - ); ?> |
|
71 | + 'When you deactivate a messenger, the system will first check if there are any custom event templates for that messenger. If there are you will be unable to deactivate the messenger. This is a fail safe to make sure you know that no messages will go out for those specific events so you don\'t accidentally deactivate. If this check passes, then the system will deactivate any global templates for that messenger (note the templates are not erased, they just become inactive, so if you decide to reactivate the messenger later all your customizations are preserved). Then the display will change to reflect the deactivation.', |
|
72 | + 'event_espresso' |
|
73 | + ); ?> |
|
74 | 74 | </p> |
75 | 75 | <p> |
76 | 76 | <strong><?php esc_html_e('Important', 'event_espresso'); ?></strong><br/> |
77 | 77 | <?php esc_html_e( |
78 | - 'Although customizations made to global templates are preserved when a messenger is deactivated, any settings for that messenger (or the message types that were attached to it) are lost on deactivation. Also, once you deactivate a messenger, no more messages will be delivered using that messenger for any of your events.', |
|
79 | - 'event_espresso' |
|
80 | - ); ?> |
|
78 | + 'Although customizations made to global templates are preserved when a messenger is deactivated, any settings for that messenger (or the message types that were attached to it) are lost on deactivation. Also, once you deactivate a messenger, no more messages will be delivered using that messenger for any of your events.', |
|
79 | + 'event_espresso' |
|
80 | + ); ?> |
|
81 | 81 | </p> |
@@ -19,16 +19,16 @@ |
||
19 | 19 | 'The green colored gear %s indicates that this messenger is currently active.', |
20 | 20 | 'event_espresso' |
21 | 21 | ), |
22 | - '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-active.png' . '"' |
|
23 | - . ' alt="' . esc_attr__('Active Email Tab', 'event_espresso') . '" />' |
|
22 | + '<img class="inline-text" src="'.EE_MSG_ASSETS_URL.'images/email-tab-active.png'.'"' |
|
23 | + . ' alt="'.esc_attr__('Active Email Tab', 'event_espresso').'" />' |
|
24 | 24 | ); |
25 | 25 | printf( |
26 | 26 | esc_html__( |
27 | 27 | ' The white colored gear %s indicates the messenger is inactive. This is very helpful for seeing at a glance all the messengers that are active when you first view the page.', |
28 | 28 | 'event_espresso' |
29 | 29 | ), |
30 | - '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-inactive.png' |
|
31 | - . '" alt="' . esc_attr__('Inactive Email Tab', 'event_espresso') . '" />' |
|
30 | + '<img class="inline-text" src="'.EE_MSG_ASSETS_URL.'images/email-tab-inactive.png' |
|
31 | + . '" alt="'.esc_attr__('Inactive Email Tab', 'event_espresso').'" />' |
|
32 | 32 | ); ?> |
33 | 33 | </p> |
34 | 34 | <p> |
@@ -176,7 +176,7 @@ |
||
176 | 176 | /** |
177 | 177 | * This retrieves the EE_Venue from the available data object. |
178 | 178 | * |
179 | - * @return EE_Venue|null |
|
179 | + * @return EE_Base_Class|null |
|
180 | 180 | * @throws EE_Error |
181 | 181 | * @throws EntityNotFoundException |
182 | 182 | */ |
@@ -17,315 +17,315 @@ |
||
17 | 17 | { |
18 | 18 | |
19 | 19 | |
20 | - /** |
|
21 | - * Will hold the EE_Event if available |
|
22 | - * |
|
23 | - * @var EE_Event |
|
24 | - */ |
|
25 | - protected $_event; |
|
26 | - |
|
27 | - /** |
|
28 | - * Will hold the EE_Venue if available |
|
29 | - * |
|
30 | - * @var EE_Venue |
|
31 | - */ |
|
32 | - protected $_venue; |
|
33 | - |
|
34 | - |
|
35 | - /** |
|
36 | - * Initialize properties |
|
37 | - */ |
|
38 | - protected function _init_props() |
|
39 | - { |
|
40 | - $this->label = esc_html__('Venue Shortcodes', 'event_espresso'); |
|
41 | - $this->description = esc_html__('All shortcodes specific to venue related data', 'event_espresso'); |
|
42 | - $this->_shortcodes = array( |
|
43 | - '[VENUE_TITLE]' => esc_html__('The title for the event venue', 'event_espresso'), |
|
44 | - '[VENUE_DESCRIPTION]' => esc_html__('The description for the event venue', 'event_espresso'), |
|
45 | - '[VENUE_URL]' => esc_html__('A url to a webpage for the venue', 'event_espresso'), |
|
46 | - '[VENUE_DETAILS_URL]' => sprintf( |
|
47 | - esc_html__( |
|
48 | - 'This shortcode outputs the url or website address to the venue details page on this website. This differs from %s which outputs what is entered in the "url" field in the venue details page.', |
|
49 | - 'event_espresso' |
|
50 | - ), |
|
51 | - '[VENUE_URL]' |
|
52 | - ), |
|
53 | - '[VENUE_IMAGE]' => esc_html__('An image representing the event venue', 'event_espresso'), |
|
54 | - '[VENUE_PHONE]' => esc_html__('The phone number for the venue', 'event_espresso'), |
|
55 | - '[VENUE_ADDRESS]' => esc_html__('The address for the venue', 'event_espresso'), |
|
56 | - '[VENUE_ADDRESS2]' => esc_html__('Address 2 for the venue', 'event_espresso'), |
|
57 | - '[VENUE_CITY]' => esc_html__('The city the venue is in', 'event_espresso'), |
|
58 | - '[VENUE_STATE]' => esc_html__('The state the venue is located in', 'event_espresso'), |
|
59 | - '[VENUE_COUNTRY]' => esc_html__('The country the venue is located in', 'event_espresso'), |
|
60 | - '[VENUE_FORMATTED_ADDRESS]' => esc_html__( |
|
61 | - 'This just outputs the venue address in a semantic address format.', |
|
62 | - 'event_espresso' |
|
63 | - ), |
|
64 | - '[VENUE_ZIP]' => esc_html__('The zip code for the venue address', 'event_espresso'), |
|
65 | - '[VENUE_META_*]' => esc_html__( |
|
66 | - 'This is a special dynamic shortcode. After the "*", add the exact name for your custom field, if there is a value set for that custom field within the venue then it will be output in place of this shortcode.', |
|
67 | - 'event_espresso' |
|
68 | - ), |
|
69 | - '[GOOGLE_MAP_URL]' => esc_html__( |
|
70 | - 'URL for the google map associated with the venue.', |
|
71 | - 'event_espresso' |
|
72 | - ), |
|
73 | - '[GOOGLE_MAP_LINK]' => esc_html__('Link to a google map for the venue', 'event_espresso'), |
|
74 | - '[GOOGLE_MAP_IMAGE]' => esc_html__('Google map for venue wrapped in image tags', 'event_espresso'), |
|
75 | - ); |
|
76 | - } |
|
77 | - |
|
78 | - |
|
79 | - /** |
|
80 | - * Parse incoming shortcode |
|
81 | - * |
|
82 | - * @param string $shortcode |
|
83 | - * @return string |
|
84 | - * @throws EE_Error |
|
85 | - * @throws EntityNotFoundException |
|
86 | - */ |
|
87 | - protected function _parser($shortcode) |
|
88 | - { |
|
89 | - $this->_venue = $this->_get_venue(); |
|
90 | - // If there is no venue object by now then get out. |
|
91 | - if (! $this->_venue instanceof EE_Venue) { |
|
92 | - return ''; |
|
93 | - } |
|
94 | - |
|
95 | - switch ($shortcode) { |
|
96 | - case '[VENUE_TITLE]': |
|
97 | - return $this->_venue('title'); |
|
98 | - break; |
|
99 | - |
|
100 | - case '[VENUE_DESCRIPTION]': |
|
101 | - return $this->_venue('description'); |
|
102 | - break; |
|
103 | - |
|
104 | - case '[VENUE_URL]': |
|
105 | - return $this->_venue('url'); |
|
106 | - break; |
|
107 | - |
|
108 | - case '[VENUE_IMAGE]': |
|
109 | - return $this->_venue('image'); |
|
110 | - break; |
|
111 | - |
|
112 | - case '[VENUE_PHONE]': |
|
113 | - return $this->_venue('phone'); |
|
114 | - break; |
|
115 | - |
|
116 | - case '[VENUE_ADDRESS]': |
|
117 | - return $this->_venue('address'); |
|
118 | - break; |
|
119 | - |
|
120 | - case '[VENUE_ADDRESS2]': |
|
121 | - return $this->_venue('address2'); |
|
122 | - break; |
|
123 | - |
|
124 | - case '[VENUE_CITY]': |
|
125 | - return $this->_venue('city'); |
|
126 | - break; |
|
127 | - |
|
128 | - case '[VENUE_COUNTRY]': |
|
129 | - return $this->_venue('country'); |
|
130 | - break; |
|
131 | - |
|
132 | - case '[VENUE_STATE]': |
|
133 | - return $this->_venue('state'); |
|
134 | - break; |
|
135 | - |
|
136 | - case '[VENUE_ZIP]': |
|
137 | - return $this->_venue('zip'); |
|
138 | - break; |
|
139 | - |
|
140 | - case '[VENUE_FORMATTED_ADDRESS]': |
|
141 | - return $this->_venue('formatted_address'); |
|
142 | - break; |
|
143 | - |
|
144 | - case '[GOOGLE_MAP_URL]': |
|
145 | - return $this->_venue('gmap_url'); |
|
146 | - break; |
|
147 | - |
|
148 | - case '[GOOGLE_MAP_LINK]': |
|
149 | - return $this->_venue('gmap_link'); |
|
150 | - break; |
|
151 | - |
|
152 | - case '[GOOGLE_MAP_IMAGE]': |
|
153 | - return $this->_venue('gmap_link_img'); |
|
154 | - break; |
|
155 | - |
|
156 | - case '[VENUE_DETAILS_URL]': |
|
157 | - return $this->_venue('permalink'); |
|
158 | - break; |
|
159 | - } |
|
160 | - |
|
161 | - if (strpos($shortcode, '[VENUE_META_*') !== false) { |
|
162 | - $shortcode = str_replace('[VENUE_META_*', '', $shortcode); |
|
163 | - $shortcode = trim(str_replace(']', '', $shortcode)); |
|
164 | - |
|
165 | - // pull the meta value from the venue post |
|
166 | - $venue_meta = $this->_venue->get_post_meta($shortcode, true); |
|
167 | - |
|
168 | - return ! empty($venue_meta) ? $venue_meta : ''; |
|
169 | - } |
|
170 | - } |
|
171 | - |
|
172 | - /** |
|
173 | - * This retrieves the EE_Venue from the available data object. |
|
174 | - * |
|
175 | - * @return EE_Venue|null |
|
176 | - * @throws EE_Error |
|
177 | - * @throws EntityNotFoundException |
|
178 | - */ |
|
179 | - private function _get_venue() |
|
180 | - { |
|
181 | - |
|
182 | - // we need the EE_Event object to get the venue. |
|
183 | - $this->_event = $this->_data instanceof EE_Event ? $this->_data : null; |
|
184 | - |
|
185 | - // if no event, then let's see if there is a reg_obj. If there IS, then we'll try and grab the event from the |
|
186 | - // reg_obj instead. |
|
187 | - if (! $this->_event instanceof EE_Event) { |
|
188 | - $aee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
|
189 | - $aee = $this->_extra_data instanceof EE_Messages_Addressee ? $this->_extra_data : $aee; |
|
190 | - |
|
191 | - $this->_event = $aee instanceof EE_Messages_Addressee && $aee->reg_obj instanceof EE_Registration |
|
192 | - ? $aee->reg_obj->event() |
|
193 | - : null; |
|
194 | - |
|
195 | - // if still empty do we have a ticket data item? |
|
196 | - $this->_event = ! $this->_event instanceof EE_Event |
|
197 | - && $this->_data instanceof EE_Ticket |
|
198 | - && $this->_extra_data['data'] instanceof EE_Messages_Addressee |
|
199 | - ? $this->_extra_data['data']->tickets[ $this->_data->ID() ]['EE_Event'] |
|
200 | - : $this->_event; |
|
201 | - |
|
202 | - // if STILL empty event, let's try to get the first event in the list of events via EE_Messages_Addressee |
|
203 | - // and use that. |
|
204 | - $this->_event = ! $this->_event instanceof EE_Event && $aee instanceof EE_Messages_Addressee |
|
205 | - ? reset($aee->events) |
|
206 | - : $this->_event; |
|
207 | - } |
|
208 | - |
|
209 | - // If we have an event object use it to pull the venue. |
|
210 | - if ($this->_event instanceof EE_Event) { |
|
211 | - return $this->_event->get_first_related('Venue'); |
|
212 | - } |
|
213 | - |
|
214 | - return null; |
|
215 | - } |
|
216 | - |
|
217 | - /** |
|
218 | - * This retrieves the specified venue information |
|
219 | - * |
|
220 | - * @param string $field What Venue field to retrieve |
|
221 | - * @return string What was retrieved! |
|
222 | - * @throws EE_Error |
|
223 | - * @throws EntityNotFoundException |
|
224 | - */ |
|
225 | - private function _venue($field) |
|
226 | - { |
|
227 | - |
|
228 | - if (! $this->_venue instanceof EE_Venue) { |
|
229 | - return ''; |
|
230 | - } //no venue so get out. |
|
231 | - |
|
232 | - switch ($field) { |
|
233 | - case 'title': |
|
234 | - return $this->_venue->get('VNU_name'); |
|
235 | - break; |
|
236 | - |
|
237 | - case 'description': |
|
238 | - return $this->_venue->get('VNU_desc'); |
|
239 | - break; |
|
240 | - |
|
241 | - case 'url': |
|
242 | - $url = $this->_venue->get('VNU_url'); |
|
243 | - return empty($url) ? $this->_venue->get_permalink() : $url; |
|
244 | - break; |
|
245 | - |
|
246 | - case 'permalink': |
|
247 | - return $this->_venue->get_permalink(); |
|
248 | - break; |
|
249 | - |
|
250 | - case 'image': |
|
251 | - return '<img src="' . $this->_venue->feature_image_url(array(200, 200,)) |
|
252 | - . '" alt="' . sprintf( |
|
253 | - esc_attr__('%s Feature Image', 'event_espresso'), |
|
254 | - $this->_venue->get('VNU_name') |
|
255 | - ) . '" />'; |
|
256 | - break; |
|
257 | - |
|
258 | - case 'phone': |
|
259 | - return $this->_venue->get('VNU_phone'); |
|
260 | - break; |
|
261 | - |
|
262 | - case 'address': |
|
263 | - return $this->_venue->get('VNU_address'); |
|
264 | - break; |
|
265 | - |
|
266 | - case 'address2': |
|
267 | - return $this->_venue->get('VNU_address2'); |
|
268 | - break; |
|
269 | - |
|
270 | - case 'city': |
|
271 | - return $this->_venue->get('VNU_city'); |
|
272 | - break; |
|
273 | - |
|
274 | - case 'state': |
|
275 | - $state = $this->_venue->state_obj(); |
|
276 | - return is_object($state) ? $state->get('STA_name') : ''; |
|
277 | - break; |
|
278 | - |
|
279 | - case 'country': |
|
280 | - $country = $this->_venue->country_obj(); |
|
281 | - return is_object($country) ? $country->get('CNT_name') : ''; |
|
282 | - break; |
|
283 | - |
|
284 | - case 'zip': |
|
285 | - return $this->_venue->get('VNU_zip'); |
|
286 | - break; |
|
287 | - |
|
288 | - case 'formatted_address': |
|
289 | - return EEH_Address::format($this->_venue); |
|
290 | - break; |
|
291 | - |
|
292 | - case 'gmap_link': |
|
293 | - case 'gmap_url': |
|
294 | - case 'gmap_link_img': |
|
295 | - $atts = $this->get_map_attributes($this->_venue, $field); |
|
296 | - return EEH_Maps::google_map_link($atts); |
|
297 | - break; |
|
298 | - } |
|
299 | - return ''; |
|
300 | - } |
|
301 | - |
|
302 | - |
|
303 | - /** |
|
304 | - * Generates the attributes for retrieving a google_map artifact. |
|
305 | - * |
|
306 | - * @param EE_Venue $venue |
|
307 | - * @param string $field |
|
308 | - * @return array |
|
309 | - * @throws EE_Error |
|
310 | - */ |
|
311 | - protected function get_map_attributes(EE_Venue $venue, $field = 'gmap_link') |
|
312 | - { |
|
313 | - $state = $venue->state_obj(); |
|
314 | - $country = $venue->country_obj(); |
|
315 | - $atts = array( |
|
316 | - 'id' => $venue->ID(), |
|
317 | - 'address' => $venue->get('VNU_address'), |
|
318 | - 'city' => $venue->get('VNU_city'), |
|
319 | - 'state' => is_object($state) ? $state->get('STA_name') : '', |
|
320 | - 'zip' => $venue->get('VNU_zip'), |
|
321 | - 'country' => is_object($country) ? $country->get('CNT_name') : '', |
|
322 | - 'type' => $field === 'gmap_link' ? 'url' : 'map', |
|
323 | - 'map_w' => 200, |
|
324 | - 'map_h' => 200, |
|
325 | - ); |
|
326 | - if ($field === 'gmap_url') { |
|
327 | - $atts['type'] = 'url_only'; |
|
328 | - } |
|
329 | - return $atts; |
|
330 | - } |
|
20 | + /** |
|
21 | + * Will hold the EE_Event if available |
|
22 | + * |
|
23 | + * @var EE_Event |
|
24 | + */ |
|
25 | + protected $_event; |
|
26 | + |
|
27 | + /** |
|
28 | + * Will hold the EE_Venue if available |
|
29 | + * |
|
30 | + * @var EE_Venue |
|
31 | + */ |
|
32 | + protected $_venue; |
|
33 | + |
|
34 | + |
|
35 | + /** |
|
36 | + * Initialize properties |
|
37 | + */ |
|
38 | + protected function _init_props() |
|
39 | + { |
|
40 | + $this->label = esc_html__('Venue Shortcodes', 'event_espresso'); |
|
41 | + $this->description = esc_html__('All shortcodes specific to venue related data', 'event_espresso'); |
|
42 | + $this->_shortcodes = array( |
|
43 | + '[VENUE_TITLE]' => esc_html__('The title for the event venue', 'event_espresso'), |
|
44 | + '[VENUE_DESCRIPTION]' => esc_html__('The description for the event venue', 'event_espresso'), |
|
45 | + '[VENUE_URL]' => esc_html__('A url to a webpage for the venue', 'event_espresso'), |
|
46 | + '[VENUE_DETAILS_URL]' => sprintf( |
|
47 | + esc_html__( |
|
48 | + 'This shortcode outputs the url or website address to the venue details page on this website. This differs from %s which outputs what is entered in the "url" field in the venue details page.', |
|
49 | + 'event_espresso' |
|
50 | + ), |
|
51 | + '[VENUE_URL]' |
|
52 | + ), |
|
53 | + '[VENUE_IMAGE]' => esc_html__('An image representing the event venue', 'event_espresso'), |
|
54 | + '[VENUE_PHONE]' => esc_html__('The phone number for the venue', 'event_espresso'), |
|
55 | + '[VENUE_ADDRESS]' => esc_html__('The address for the venue', 'event_espresso'), |
|
56 | + '[VENUE_ADDRESS2]' => esc_html__('Address 2 for the venue', 'event_espresso'), |
|
57 | + '[VENUE_CITY]' => esc_html__('The city the venue is in', 'event_espresso'), |
|
58 | + '[VENUE_STATE]' => esc_html__('The state the venue is located in', 'event_espresso'), |
|
59 | + '[VENUE_COUNTRY]' => esc_html__('The country the venue is located in', 'event_espresso'), |
|
60 | + '[VENUE_FORMATTED_ADDRESS]' => esc_html__( |
|
61 | + 'This just outputs the venue address in a semantic address format.', |
|
62 | + 'event_espresso' |
|
63 | + ), |
|
64 | + '[VENUE_ZIP]' => esc_html__('The zip code for the venue address', 'event_espresso'), |
|
65 | + '[VENUE_META_*]' => esc_html__( |
|
66 | + 'This is a special dynamic shortcode. After the "*", add the exact name for your custom field, if there is a value set for that custom field within the venue then it will be output in place of this shortcode.', |
|
67 | + 'event_espresso' |
|
68 | + ), |
|
69 | + '[GOOGLE_MAP_URL]' => esc_html__( |
|
70 | + 'URL for the google map associated with the venue.', |
|
71 | + 'event_espresso' |
|
72 | + ), |
|
73 | + '[GOOGLE_MAP_LINK]' => esc_html__('Link to a google map for the venue', 'event_espresso'), |
|
74 | + '[GOOGLE_MAP_IMAGE]' => esc_html__('Google map for venue wrapped in image tags', 'event_espresso'), |
|
75 | + ); |
|
76 | + } |
|
77 | + |
|
78 | + |
|
79 | + /** |
|
80 | + * Parse incoming shortcode |
|
81 | + * |
|
82 | + * @param string $shortcode |
|
83 | + * @return string |
|
84 | + * @throws EE_Error |
|
85 | + * @throws EntityNotFoundException |
|
86 | + */ |
|
87 | + protected function _parser($shortcode) |
|
88 | + { |
|
89 | + $this->_venue = $this->_get_venue(); |
|
90 | + // If there is no venue object by now then get out. |
|
91 | + if (! $this->_venue instanceof EE_Venue) { |
|
92 | + return ''; |
|
93 | + } |
|
94 | + |
|
95 | + switch ($shortcode) { |
|
96 | + case '[VENUE_TITLE]': |
|
97 | + return $this->_venue('title'); |
|
98 | + break; |
|
99 | + |
|
100 | + case '[VENUE_DESCRIPTION]': |
|
101 | + return $this->_venue('description'); |
|
102 | + break; |
|
103 | + |
|
104 | + case '[VENUE_URL]': |
|
105 | + return $this->_venue('url'); |
|
106 | + break; |
|
107 | + |
|
108 | + case '[VENUE_IMAGE]': |
|
109 | + return $this->_venue('image'); |
|
110 | + break; |
|
111 | + |
|
112 | + case '[VENUE_PHONE]': |
|
113 | + return $this->_venue('phone'); |
|
114 | + break; |
|
115 | + |
|
116 | + case '[VENUE_ADDRESS]': |
|
117 | + return $this->_venue('address'); |
|
118 | + break; |
|
119 | + |
|
120 | + case '[VENUE_ADDRESS2]': |
|
121 | + return $this->_venue('address2'); |
|
122 | + break; |
|
123 | + |
|
124 | + case '[VENUE_CITY]': |
|
125 | + return $this->_venue('city'); |
|
126 | + break; |
|
127 | + |
|
128 | + case '[VENUE_COUNTRY]': |
|
129 | + return $this->_venue('country'); |
|
130 | + break; |
|
131 | + |
|
132 | + case '[VENUE_STATE]': |
|
133 | + return $this->_venue('state'); |
|
134 | + break; |
|
135 | + |
|
136 | + case '[VENUE_ZIP]': |
|
137 | + return $this->_venue('zip'); |
|
138 | + break; |
|
139 | + |
|
140 | + case '[VENUE_FORMATTED_ADDRESS]': |
|
141 | + return $this->_venue('formatted_address'); |
|
142 | + break; |
|
143 | + |
|
144 | + case '[GOOGLE_MAP_URL]': |
|
145 | + return $this->_venue('gmap_url'); |
|
146 | + break; |
|
147 | + |
|
148 | + case '[GOOGLE_MAP_LINK]': |
|
149 | + return $this->_venue('gmap_link'); |
|
150 | + break; |
|
151 | + |
|
152 | + case '[GOOGLE_MAP_IMAGE]': |
|
153 | + return $this->_venue('gmap_link_img'); |
|
154 | + break; |
|
155 | + |
|
156 | + case '[VENUE_DETAILS_URL]': |
|
157 | + return $this->_venue('permalink'); |
|
158 | + break; |
|
159 | + } |
|
160 | + |
|
161 | + if (strpos($shortcode, '[VENUE_META_*') !== false) { |
|
162 | + $shortcode = str_replace('[VENUE_META_*', '', $shortcode); |
|
163 | + $shortcode = trim(str_replace(']', '', $shortcode)); |
|
164 | + |
|
165 | + // pull the meta value from the venue post |
|
166 | + $venue_meta = $this->_venue->get_post_meta($shortcode, true); |
|
167 | + |
|
168 | + return ! empty($venue_meta) ? $venue_meta : ''; |
|
169 | + } |
|
170 | + } |
|
171 | + |
|
172 | + /** |
|
173 | + * This retrieves the EE_Venue from the available data object. |
|
174 | + * |
|
175 | + * @return EE_Venue|null |
|
176 | + * @throws EE_Error |
|
177 | + * @throws EntityNotFoundException |
|
178 | + */ |
|
179 | + private function _get_venue() |
|
180 | + { |
|
181 | + |
|
182 | + // we need the EE_Event object to get the venue. |
|
183 | + $this->_event = $this->_data instanceof EE_Event ? $this->_data : null; |
|
184 | + |
|
185 | + // if no event, then let's see if there is a reg_obj. If there IS, then we'll try and grab the event from the |
|
186 | + // reg_obj instead. |
|
187 | + if (! $this->_event instanceof EE_Event) { |
|
188 | + $aee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
|
189 | + $aee = $this->_extra_data instanceof EE_Messages_Addressee ? $this->_extra_data : $aee; |
|
190 | + |
|
191 | + $this->_event = $aee instanceof EE_Messages_Addressee && $aee->reg_obj instanceof EE_Registration |
|
192 | + ? $aee->reg_obj->event() |
|
193 | + : null; |
|
194 | + |
|
195 | + // if still empty do we have a ticket data item? |
|
196 | + $this->_event = ! $this->_event instanceof EE_Event |
|
197 | + && $this->_data instanceof EE_Ticket |
|
198 | + && $this->_extra_data['data'] instanceof EE_Messages_Addressee |
|
199 | + ? $this->_extra_data['data']->tickets[ $this->_data->ID() ]['EE_Event'] |
|
200 | + : $this->_event; |
|
201 | + |
|
202 | + // if STILL empty event, let's try to get the first event in the list of events via EE_Messages_Addressee |
|
203 | + // and use that. |
|
204 | + $this->_event = ! $this->_event instanceof EE_Event && $aee instanceof EE_Messages_Addressee |
|
205 | + ? reset($aee->events) |
|
206 | + : $this->_event; |
|
207 | + } |
|
208 | + |
|
209 | + // If we have an event object use it to pull the venue. |
|
210 | + if ($this->_event instanceof EE_Event) { |
|
211 | + return $this->_event->get_first_related('Venue'); |
|
212 | + } |
|
213 | + |
|
214 | + return null; |
|
215 | + } |
|
216 | + |
|
217 | + /** |
|
218 | + * This retrieves the specified venue information |
|
219 | + * |
|
220 | + * @param string $field What Venue field to retrieve |
|
221 | + * @return string What was retrieved! |
|
222 | + * @throws EE_Error |
|
223 | + * @throws EntityNotFoundException |
|
224 | + */ |
|
225 | + private function _venue($field) |
|
226 | + { |
|
227 | + |
|
228 | + if (! $this->_venue instanceof EE_Venue) { |
|
229 | + return ''; |
|
230 | + } //no venue so get out. |
|
231 | + |
|
232 | + switch ($field) { |
|
233 | + case 'title': |
|
234 | + return $this->_venue->get('VNU_name'); |
|
235 | + break; |
|
236 | + |
|
237 | + case 'description': |
|
238 | + return $this->_venue->get('VNU_desc'); |
|
239 | + break; |
|
240 | + |
|
241 | + case 'url': |
|
242 | + $url = $this->_venue->get('VNU_url'); |
|
243 | + return empty($url) ? $this->_venue->get_permalink() : $url; |
|
244 | + break; |
|
245 | + |
|
246 | + case 'permalink': |
|
247 | + return $this->_venue->get_permalink(); |
|
248 | + break; |
|
249 | + |
|
250 | + case 'image': |
|
251 | + return '<img src="' . $this->_venue->feature_image_url(array(200, 200,)) |
|
252 | + . '" alt="' . sprintf( |
|
253 | + esc_attr__('%s Feature Image', 'event_espresso'), |
|
254 | + $this->_venue->get('VNU_name') |
|
255 | + ) . '" />'; |
|
256 | + break; |
|
257 | + |
|
258 | + case 'phone': |
|
259 | + return $this->_venue->get('VNU_phone'); |
|
260 | + break; |
|
261 | + |
|
262 | + case 'address': |
|
263 | + return $this->_venue->get('VNU_address'); |
|
264 | + break; |
|
265 | + |
|
266 | + case 'address2': |
|
267 | + return $this->_venue->get('VNU_address2'); |
|
268 | + break; |
|
269 | + |
|
270 | + case 'city': |
|
271 | + return $this->_venue->get('VNU_city'); |
|
272 | + break; |
|
273 | + |
|
274 | + case 'state': |
|
275 | + $state = $this->_venue->state_obj(); |
|
276 | + return is_object($state) ? $state->get('STA_name') : ''; |
|
277 | + break; |
|
278 | + |
|
279 | + case 'country': |
|
280 | + $country = $this->_venue->country_obj(); |
|
281 | + return is_object($country) ? $country->get('CNT_name') : ''; |
|
282 | + break; |
|
283 | + |
|
284 | + case 'zip': |
|
285 | + return $this->_venue->get('VNU_zip'); |
|
286 | + break; |
|
287 | + |
|
288 | + case 'formatted_address': |
|
289 | + return EEH_Address::format($this->_venue); |
|
290 | + break; |
|
291 | + |
|
292 | + case 'gmap_link': |
|
293 | + case 'gmap_url': |
|
294 | + case 'gmap_link_img': |
|
295 | + $atts = $this->get_map_attributes($this->_venue, $field); |
|
296 | + return EEH_Maps::google_map_link($atts); |
|
297 | + break; |
|
298 | + } |
|
299 | + return ''; |
|
300 | + } |
|
301 | + |
|
302 | + |
|
303 | + /** |
|
304 | + * Generates the attributes for retrieving a google_map artifact. |
|
305 | + * |
|
306 | + * @param EE_Venue $venue |
|
307 | + * @param string $field |
|
308 | + * @return array |
|
309 | + * @throws EE_Error |
|
310 | + */ |
|
311 | + protected function get_map_attributes(EE_Venue $venue, $field = 'gmap_link') |
|
312 | + { |
|
313 | + $state = $venue->state_obj(); |
|
314 | + $country = $venue->country_obj(); |
|
315 | + $atts = array( |
|
316 | + 'id' => $venue->ID(), |
|
317 | + 'address' => $venue->get('VNU_address'), |
|
318 | + 'city' => $venue->get('VNU_city'), |
|
319 | + 'state' => is_object($state) ? $state->get('STA_name') : '', |
|
320 | + 'zip' => $venue->get('VNU_zip'), |
|
321 | + 'country' => is_object($country) ? $country->get('CNT_name') : '', |
|
322 | + 'type' => $field === 'gmap_link' ? 'url' : 'map', |
|
323 | + 'map_w' => 200, |
|
324 | + 'map_h' => 200, |
|
325 | + ); |
|
326 | + if ($field === 'gmap_url') { |
|
327 | + $atts['type'] = 'url_only'; |
|
328 | + } |
|
329 | + return $atts; |
|
330 | + } |
|
331 | 331 | } |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | { |
89 | 89 | $this->_venue = $this->_get_venue(); |
90 | 90 | // If there is no venue object by now then get out. |
91 | - if (! $this->_venue instanceof EE_Venue) { |
|
91 | + if ( ! $this->_venue instanceof EE_Venue) { |
|
92 | 92 | return ''; |
93 | 93 | } |
94 | 94 | |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | |
185 | 185 | // if no event, then let's see if there is a reg_obj. If there IS, then we'll try and grab the event from the |
186 | 186 | // reg_obj instead. |
187 | - if (! $this->_event instanceof EE_Event) { |
|
187 | + if ( ! $this->_event instanceof EE_Event) { |
|
188 | 188 | $aee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
189 | 189 | $aee = $this->_extra_data instanceof EE_Messages_Addressee ? $this->_extra_data : $aee; |
190 | 190 | |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | $this->_event = ! $this->_event instanceof EE_Event |
197 | 197 | && $this->_data instanceof EE_Ticket |
198 | 198 | && $this->_extra_data['data'] instanceof EE_Messages_Addressee |
199 | - ? $this->_extra_data['data']->tickets[ $this->_data->ID() ]['EE_Event'] |
|
199 | + ? $this->_extra_data['data']->tickets[$this->_data->ID()]['EE_Event'] |
|
200 | 200 | : $this->_event; |
201 | 201 | |
202 | 202 | // if STILL empty event, let's try to get the first event in the list of events via EE_Messages_Addressee |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | private function _venue($field) |
226 | 226 | { |
227 | 227 | |
228 | - if (! $this->_venue instanceof EE_Venue) { |
|
228 | + if ( ! $this->_venue instanceof EE_Venue) { |
|
229 | 229 | return ''; |
230 | 230 | } //no venue so get out. |
231 | 231 | |
@@ -248,11 +248,11 @@ discard block |
||
248 | 248 | break; |
249 | 249 | |
250 | 250 | case 'image': |
251 | - return '<img src="' . $this->_venue->feature_image_url(array(200, 200,)) |
|
252 | - . '" alt="' . sprintf( |
|
251 | + return '<img src="'.$this->_venue->feature_image_url(array(200, 200,)) |
|
252 | + . '" alt="'.sprintf( |
|
253 | 253 | esc_attr__('%s Feature Image', 'event_espresso'), |
254 | 254 | $this->_venue->get('VNU_name') |
255 | - ) . '" />'; |
|
255 | + ).'" />'; |
|
256 | 256 | break; |
257 | 257 | |
258 | 258 | case 'phone': |
@@ -15,22 +15,22 @@ |
||
15 | 15 | class EE_Radio_Button_Input extends EE_Form_Input_With_Options_Base |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * @param array $answer_options |
|
20 | - * @param array $input_settings |
|
21 | - */ |
|
22 | - public function __construct($answer_options, $input_settings = array()) |
|
23 | - { |
|
24 | - $this->_set_display_strategy(new EE_Radio_Button_Display_Strategy()); |
|
25 | - $this->_add_validation_strategy( |
|
26 | - new EE_Enum_Validation_Strategy( |
|
27 | - isset($input_settings['validation_error_message']) |
|
28 | - ? $input_settings['validation_error_message'] |
|
29 | - : null |
|
30 | - ) |
|
31 | - ); |
|
32 | - $this->_multiple_selections = false; |
|
33 | - parent::__construct($answer_options, $input_settings); |
|
34 | - } |
|
18 | + /** |
|
19 | + * @param array $answer_options |
|
20 | + * @param array $input_settings |
|
21 | + */ |
|
22 | + public function __construct($answer_options, $input_settings = array()) |
|
23 | + { |
|
24 | + $this->_set_display_strategy(new EE_Radio_Button_Display_Strategy()); |
|
25 | + $this->_add_validation_strategy( |
|
26 | + new EE_Enum_Validation_Strategy( |
|
27 | + isset($input_settings['validation_error_message']) |
|
28 | + ? $input_settings['validation_error_message'] |
|
29 | + : null |
|
30 | + ) |
|
31 | + ); |
|
32 | + $this->_multiple_selections = false; |
|
33 | + parent::__construct($answer_options, $input_settings); |
|
34 | + } |
|
35 | 35 | |
36 | 36 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | ) |
30 | 30 | ); |
31 | 31 | parent::__construct($input_settings); |
32 | - $this->set_html_class($this->html_class() . ' datepicker'); |
|
32 | + $this->set_html_class($this->html_class().' datepicker'); |
|
33 | 33 | // add some style and make it dance |
34 | 34 | add_action('wp_enqueue_scripts', array('EE_Datepicker_Input', 'enqueue_styles_and_scripts')); |
35 | 35 | add_action('admin_enqueue_scripts', array('EE_Datepicker_Input', 'enqueue_styles_and_scripts')); |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | // load css |
49 | 49 | wp_register_style( |
50 | 50 | 'espresso-ui-theme', |
51 | - EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', |
|
51 | + EE_GLOBAL_ASSETS_URL.'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', |
|
52 | 52 | array(), |
53 | 53 | EVENT_ESPRESSO_VERSION |
54 | 54 | ); |
@@ -10,45 +10,45 @@ |
||
10 | 10 | class EE_Datepicker_Input extends EE_Form_Input_Base |
11 | 11 | { |
12 | 12 | |
13 | - /** |
|
14 | - * @param array $input_settings |
|
15 | - */ |
|
16 | - public function __construct($input_settings = array()) |
|
17 | - { |
|
18 | - $this->_set_display_strategy(new EE_Text_Input_Display_Strategy('datepicker')); |
|
19 | - $this->_set_normalization_strategy(new EE_Text_Normalization()); |
|
20 | - // we could do better for validation, but at least verify its plaintext |
|
21 | - $this->_add_validation_strategy( |
|
22 | - new EE_Plaintext_Validation_Strategy( |
|
23 | - isset($input_settings['validation_error_message']) |
|
24 | - ? $input_settings['validation_error_message'] |
|
25 | - : null |
|
26 | - ) |
|
27 | - ); |
|
28 | - parent::__construct($input_settings); |
|
29 | - $this->set_html_class($this->html_class() . ' datepicker'); |
|
30 | - // add some style and make it dance |
|
31 | - add_action('wp_enqueue_scripts', array('EE_Datepicker_Input', 'enqueue_styles_and_scripts')); |
|
32 | - add_action('admin_enqueue_scripts', array('EE_Datepicker_Input', 'enqueue_styles_and_scripts')); |
|
33 | - } |
|
13 | + /** |
|
14 | + * @param array $input_settings |
|
15 | + */ |
|
16 | + public function __construct($input_settings = array()) |
|
17 | + { |
|
18 | + $this->_set_display_strategy(new EE_Text_Input_Display_Strategy('datepicker')); |
|
19 | + $this->_set_normalization_strategy(new EE_Text_Normalization()); |
|
20 | + // we could do better for validation, but at least verify its plaintext |
|
21 | + $this->_add_validation_strategy( |
|
22 | + new EE_Plaintext_Validation_Strategy( |
|
23 | + isset($input_settings['validation_error_message']) |
|
24 | + ? $input_settings['validation_error_message'] |
|
25 | + : null |
|
26 | + ) |
|
27 | + ); |
|
28 | + parent::__construct($input_settings); |
|
29 | + $this->set_html_class($this->html_class() . ' datepicker'); |
|
30 | + // add some style and make it dance |
|
31 | + add_action('wp_enqueue_scripts', array('EE_Datepicker_Input', 'enqueue_styles_and_scripts')); |
|
32 | + add_action('admin_enqueue_scripts', array('EE_Datepicker_Input', 'enqueue_styles_and_scripts')); |
|
33 | + } |
|
34 | 34 | |
35 | 35 | |
36 | 36 | |
37 | - /** |
|
38 | - * enqueue_styles_and_scripts |
|
39 | - * |
|
40 | - * @access public |
|
41 | - * @return void |
|
42 | - */ |
|
43 | - public static function enqueue_styles_and_scripts() |
|
44 | - { |
|
45 | - // load css |
|
46 | - wp_register_style( |
|
47 | - 'espresso-ui-theme', |
|
48 | - EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', |
|
49 | - array(), |
|
50 | - EVENT_ESPRESSO_VERSION |
|
51 | - ); |
|
52 | - wp_enqueue_style('espresso-ui-theme'); |
|
53 | - } |
|
37 | + /** |
|
38 | + * enqueue_styles_and_scripts |
|
39 | + * |
|
40 | + * @access public |
|
41 | + * @return void |
|
42 | + */ |
|
43 | + public static function enqueue_styles_and_scripts() |
|
44 | + { |
|
45 | + // load css |
|
46 | + wp_register_style( |
|
47 | + 'espresso-ui-theme', |
|
48 | + EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', |
|
49 | + array(), |
|
50 | + EVENT_ESPRESSO_VERSION |
|
51 | + ); |
|
52 | + wp_enqueue_style('espresso-ui-theme'); |
|
53 | + } |
|
54 | 54 | } |
@@ -22,15 +22,15 @@ discard block |
||
22 | 22 | |
23 | 23 | <div class="event-attendees"> |
24 | 24 | <?php do_action_ref_array( |
25 | - 'AHEE__loop-espresso_event_attendees__before', |
|
26 | - array( |
|
27 | - $contacts, |
|
28 | - $event, |
|
29 | - $datetime, |
|
30 | - $ticket, |
|
31 | - $show_gravatar, |
|
32 | - ) |
|
33 | - ); ?> |
|
25 | + 'AHEE__loop-espresso_event_attendees__before', |
|
26 | + array( |
|
27 | + $contacts, |
|
28 | + $event, |
|
29 | + $datetime, |
|
30 | + $ticket, |
|
31 | + $show_gravatar, |
|
32 | + ) |
|
33 | + ); ?> |
|
34 | 34 | <?php if ( $contacts ) : ?> |
35 | 35 | <ul class="event-attendees-list"> |
36 | 36 | <?php foreach( $contacts as $contact ) : |
@@ -47,13 +47,13 @@ discard block |
||
47 | 47 | <p><?php echo $no_attendees_message; ?></p> |
48 | 48 | <?php endif; ?> |
49 | 49 | <?php do_action_ref_array( |
50 | - 'AHEE__loop-espresso_event_attendees__after', |
|
51 | - array( |
|
52 | - $contacts, |
|
53 | - $event, |
|
54 | - $datetime, |
|
55 | - $ticket, |
|
56 | - $show_gravatar, |
|
57 | - ) |
|
58 | - ); ?> |
|
50 | + 'AHEE__loop-espresso_event_attendees__after', |
|
51 | + array( |
|
52 | + $contacts, |
|
53 | + $event, |
|
54 | + $datetime, |
|
55 | + $ticket, |
|
56 | + $show_gravatar, |
|
57 | + ) |
|
58 | + ); ?> |
|
59 | 59 | </div> |
60 | 60 | \ No newline at end of file |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * @type bool $show_gravatar whether to show gravatar or not. |
16 | 16 | */ |
17 | 17 | |
18 | -$no_attendees_message = apply_filters( 'FHEE__loop-espresso_attendees-shortcode__template__no_attendees_message', __('No Attendees Yet', 'event_espresso' ) ); |
|
18 | +$no_attendees_message = apply_filters('FHEE__loop-espresso_attendees-shortcode__template__no_attendees_message', __('No Attendees Yet', 'event_espresso')); |
|
19 | 19 | |
20 | 20 | |
21 | 21 | ?> |
@@ -31,16 +31,16 @@ discard block |
||
31 | 31 | $show_gravatar, |
32 | 32 | ) |
33 | 33 | ); ?> |
34 | - <?php if ( $contacts ) : ?> |
|
34 | + <?php if ($contacts) : ?> |
|
35 | 35 | <ul class="event-attendees-list"> |
36 | - <?php foreach( $contacts as $contact ) : |
|
37 | - EEH_Template::get_template_part( 'content', 'espresso_event_attendees', array( |
|
36 | + <?php foreach ($contacts as $contact) : |
|
37 | + EEH_Template::get_template_part('content', 'espresso_event_attendees', array( |
|
38 | 38 | 'contact' => $contact, |
39 | 39 | 'event' => $event, |
40 | 40 | 'datetime' => $datetime, |
41 | 41 | 'ticket' => $ticket, |
42 | 42 | 'show_gravatar' => $show_gravatar |
43 | - ) ); |
|
43 | + )); |
|
44 | 44 | endforeach; ?> |
45 | 45 | </ul> |
46 | 46 | <?php else : ?> |
@@ -43,8 +43,11 @@ |
||
43 | 43 | ) ); |
44 | 44 | endforeach; ?> |
45 | 45 | </ul> |
46 | - <?php else : ?> |
|
47 | - <p><?php echo $no_attendees_message; ?></p> |
|
46 | + <?php else { |
|
47 | + : ?> |
|
48 | + <p><?php echo $no_attendees_message; |
|
49 | +} |
|
50 | +?></p> |
|
48 | 51 | <?php endif; ?> |
49 | 52 | <?php do_action_ref_array( |
50 | 53 | 'AHEE__loop-espresso_event_attendees__after', |
@@ -13,72 +13,72 @@ |
||
13 | 13 | trait BaseCoreAdmin |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * Core method for going to an Event Espresso Admin page. |
|
18 | - * @param string $page |
|
19 | - * @param string $action |
|
20 | - * @param string $additional_params |
|
21 | - */ |
|
22 | - public function amOnEventEspressoAdminPage($page = '', $action = '', $additional_params = '') |
|
23 | - { |
|
24 | - $this->actor()->amOnAdminPage(CoreAdmin::adminUrl($page, $action, $additional_params)); |
|
25 | - } |
|
16 | + /** |
|
17 | + * Core method for going to an Event Espresso Admin page. |
|
18 | + * @param string $page |
|
19 | + * @param string $action |
|
20 | + * @param string $additional_params |
|
21 | + */ |
|
22 | + public function amOnEventEspressoAdminPage($page = '', $action = '', $additional_params = '') |
|
23 | + { |
|
24 | + $this->actor()->amOnAdminPage(CoreAdmin::adminUrl($page, $action, $additional_params)); |
|
25 | + } |
|
26 | 26 | |
27 | 27 | |
28 | - /** |
|
29 | - * Helper method for returning an instance of the Actor. Intended to help with IDE fill out of methods. |
|
30 | - * @return \EventEspressoAcceptanceTester; |
|
31 | - */ |
|
32 | - protected function actor() |
|
33 | - { |
|
34 | - /** @var \EventEspressoAcceptanceTester $this */ |
|
35 | - return $this; |
|
36 | - } |
|
28 | + /** |
|
29 | + * Helper method for returning an instance of the Actor. Intended to help with IDE fill out of methods. |
|
30 | + * @return \EventEspressoAcceptanceTester; |
|
31 | + */ |
|
32 | + protected function actor() |
|
33 | + { |
|
34 | + /** @var \EventEspressoAcceptanceTester $this */ |
|
35 | + return $this; |
|
36 | + } |
|
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * Use this to set the per page option for a list table page. |
|
41 | - * Assumes you are on a page that has this field exposed. |
|
42 | - * |
|
43 | - * @param int|string $per_page_value |
|
44 | - * @throws \Codeception\Exception\TestRuntimeException |
|
45 | - */ |
|
46 | - public function setPerPageOptionForScreen($per_page_value) |
|
47 | - { |
|
48 | - $this->actor()->click(CoreAdmin::WP_SCREEN_SETTINGS_LINK_SELECTOR); |
|
49 | - $this->actor()->fillField(CoreAdmin::WP_SCREEN_SETTINGS_PER_PAGE_FIELD_SELECTOR, $per_page_value); |
|
50 | - $this->actor()->click(CoreAdmin::WP_SCREEN_OPTIONS_APPLY_SETTINGS_BUTTON_SELECTOR); |
|
51 | - $this->actor()->wait(8); |
|
52 | - } |
|
39 | + /** |
|
40 | + * Use this to set the per page option for a list table page. |
|
41 | + * Assumes you are on a page that has this field exposed. |
|
42 | + * |
|
43 | + * @param int|string $per_page_value |
|
44 | + * @throws \Codeception\Exception\TestRuntimeException |
|
45 | + */ |
|
46 | + public function setPerPageOptionForScreen($per_page_value) |
|
47 | + { |
|
48 | + $this->actor()->click(CoreAdmin::WP_SCREEN_SETTINGS_LINK_SELECTOR); |
|
49 | + $this->actor()->fillField(CoreAdmin::WP_SCREEN_SETTINGS_PER_PAGE_FIELD_SELECTOR, $per_page_value); |
|
50 | + $this->actor()->click(CoreAdmin::WP_SCREEN_OPTIONS_APPLY_SETTINGS_BUTTON_SELECTOR); |
|
51 | + $this->actor()->wait(8); |
|
52 | + } |
|
53 | 53 | |
54 | 54 | |
55 | 55 | |
56 | - /** |
|
57 | - * Use this to append a given value to a wpEditor instance. |
|
58 | - * How it works is it first switched the instance to the text (or html) view so that the textarea is exposed and |
|
59 | - * the value is added to the text area. |
|
60 | - * |
|
61 | - * @param $field_reference |
|
62 | - * @param $value |
|
63 | - * @throws \Codeception\Exception\ElementNotFound |
|
64 | - */ |
|
65 | - public function appendToWPEditorField($field_reference, $value) |
|
66 | - { |
|
67 | - $this->actor()->click(CoreAdmin::wpEditorTextTabSelector($field_reference)); |
|
68 | - $this->actor()->appendField(CoreAdmin::wpEditorTextAreaSelector($field_reference), $value); |
|
69 | - } |
|
56 | + /** |
|
57 | + * Use this to append a given value to a wpEditor instance. |
|
58 | + * How it works is it first switched the instance to the text (or html) view so that the textarea is exposed and |
|
59 | + * the value is added to the text area. |
|
60 | + * |
|
61 | + * @param $field_reference |
|
62 | + * @param $value |
|
63 | + * @throws \Codeception\Exception\ElementNotFound |
|
64 | + */ |
|
65 | + public function appendToWPEditorField($field_reference, $value) |
|
66 | + { |
|
67 | + $this->actor()->click(CoreAdmin::wpEditorTextTabSelector($field_reference)); |
|
68 | + $this->actor()->appendField(CoreAdmin::wpEditorTextAreaSelector($field_reference), $value); |
|
69 | + } |
|
70 | 70 | |
71 | 71 | |
72 | - /** |
|
73 | - * Use to select and submit the given bulk action. |
|
74 | - * @param string $bulk_action_option |
|
75 | - */ |
|
76 | - public function submitBulkActionOnListTable($bulk_action_option) |
|
77 | - { |
|
78 | - $this->actor()->selectOption( |
|
79 | - CoreAdmin::SELECTOR_LIST_TABLE_BULK_ACTION_FIELD, |
|
80 | - $bulk_action_option |
|
81 | - ); |
|
82 | - $this->actor()->click(CoreAdmin::SELECTOR_LIST_TABLE_BULK_ACTTION_APPLY); |
|
83 | - } |
|
72 | + /** |
|
73 | + * Use to select and submit the given bulk action. |
|
74 | + * @param string $bulk_action_option |
|
75 | + */ |
|
76 | + public function submitBulkActionOnListTable($bulk_action_option) |
|
77 | + { |
|
78 | + $this->actor()->selectOption( |
|
79 | + CoreAdmin::SELECTOR_LIST_TABLE_BULK_ACTION_FIELD, |
|
80 | + $bulk_action_option |
|
81 | + ); |
|
82 | + $this->actor()->click(CoreAdmin::SELECTOR_LIST_TABLE_BULK_ACTTION_APPLY); |
|
83 | + } |
|
84 | 84 | } |
@@ -632,7 +632,7 @@ |
||
632 | 632 | * @deprecated 4.9.0 Use EEH_MSG_Template::payment_status_to_message_type_array |
633 | 633 | * or EEH_MSG_Template::convert_payment_status_to_message_type |
634 | 634 | * @param string $payment_status The payment status being matched. |
635 | - * @return bool|string The payment message type slug matching the status or false if no match. |
|
635 | + * @return string|false The payment message type slug matching the status or false if no match. |
|
636 | 636 | * @throws EE_Error |
637 | 637 | * @throws InvalidArgumentException |
638 | 638 | * @throws ReflectionException |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | 'event_espresso' |
203 | 203 | ); |
204 | 204 | // add specific message for developers if WP_DEBUG in on |
205 | - $error_msg .= '||' . $e->getMessage(); |
|
205 | + $error_msg .= '||'.$e->getMessage(); |
|
206 | 206 | EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
207 | 207 | } |
208 | 208 | } |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | 'event_espresso' |
290 | 290 | ); |
291 | 291 | // add specific message for developers if WP_DEBUG in on |
292 | - $error_msg .= '||' . $e->getMessage(); |
|
292 | + $error_msg .= '||'.$e->getMessage(); |
|
293 | 293 | EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
294 | 294 | } |
295 | 295 | } |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | $transient_key = EE_Registry::instance()->REQ->get('key'); |
321 | 321 | |
322 | 322 | // now let's verify transient, if not valid exit immediately |
323 | - if (! get_transient($transient_key)) { |
|
323 | + if ( ! get_transient($transient_key)) { |
|
324 | 324 | /** |
325 | 325 | * trigger error so this gets in the error logs. This is important because it happens on a non-user |
326 | 326 | * request. |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | delete_transient($transient_key); |
333 | 333 | |
334 | 334 | if (apply_filters('FHEE__EED_Messages__run_cron__use_wp_cron', true)) { |
335 | - $method = 'batch_' . $cron_type . '_from_queue'; |
|
335 | + $method = 'batch_'.$cron_type.'_from_queue'; |
|
336 | 336 | if (method_exists(self::$_MSG_PROCESSOR, $method)) { |
337 | 337 | self::$_MSG_PROCESSOR->$method(); |
338 | 338 | } else { |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | $template_pack_collection->rewind(); |
400 | 400 | $template_packs = array(); |
401 | 401 | while ($template_pack_collection->valid()) { |
402 | - $template_packs[ $template_pack_collection->current()->dbref ] = $template_pack_collection->current(); |
|
402 | + $template_packs[$template_pack_collection->current()->dbref] = $template_pack_collection->current(); |
|
403 | 403 | $template_pack_collection->next(); |
404 | 404 | } |
405 | 405 | return $template_packs; |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | ); |
450 | 450 | $paths = array(); |
451 | 451 | foreach ($dir_ref as $index => $dir) { |
452 | - $paths[ $index ] = EE_LIBRARIES . $dir; |
|
452 | + $paths[$index] = EE_LIBRARIES.$dir; |
|
453 | 453 | } |
454 | 454 | self::$_MSG_PATHS = apply_filters('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', $paths); |
455 | 455 | } |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | */ |
469 | 469 | protected static function _load_controller() |
470 | 470 | { |
471 | - if (! self::$_MSG_PROCESSOR instanceof EE_Messages_Processor) { |
|
471 | + if ( ! self::$_MSG_PROCESSOR instanceof EE_Messages_Processor) { |
|
472 | 472 | EE_Registry::instance()->load_core('Request_Handler'); |
473 | 473 | self::set_autoloaders(); |
474 | 474 | self::$_EEMSG = EE_Registry::instance()->load_lib('messages'); |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | public static function payment(EE_Transaction $transaction, EE_Payment $payment = null) |
510 | 510 | { |
511 | 511 | // if there's no payment object, then we cannot do a payment type message! |
512 | - if (! $payment instanceof EE_Payment) { |
|
512 | + if ( ! $payment instanceof EE_Payment) { |
|
513 | 513 | return; |
514 | 514 | } |
515 | 515 | self::_load_controller(); |
@@ -556,7 +556,7 @@ discard block |
||
556 | 556 | public static function maybe_registration(EE_Registration $registration, $extra_details = array()) |
557 | 557 | { |
558 | 558 | |
559 | - if (! self::_verify_registration_notification_send($registration, $extra_details)) { |
|
559 | + if ( ! self::_verify_registration_notification_send($registration, $extra_details)) { |
|
560 | 560 | // no messages please |
561 | 561 | return; |
562 | 562 | } |
@@ -623,7 +623,7 @@ discard block |
||
623 | 623 | EE_Registration $registration, |
624 | 624 | $extra_details = array() |
625 | 625 | ) { |
626 | - if (! $registration->is_primary_registrant()) { |
|
626 | + if ( ! $registration->is_primary_registrant()) { |
|
627 | 627 | return false; |
628 | 628 | } |
629 | 629 | // first we check if we're in admin and not doing front ajax |
@@ -638,7 +638,7 @@ discard block |
||
638 | 638 | } else { |
639 | 639 | // frontend request (either regular or via AJAX) |
640 | 640 | // TXN is NOT finalized ? |
641 | - if (! isset($extra_details['finalized']) || $extra_details['finalized'] === false) { |
|
641 | + if ( ! isset($extra_details['finalized']) || $extra_details['finalized'] === false) { |
|
642 | 642 | return false; |
643 | 643 | } |
644 | 644 | // return visit but nothing changed ??? |
@@ -648,7 +648,7 @@ discard block |
||
648 | 648 | return false; |
649 | 649 | } |
650 | 650 | // NOT sending messages && reg status is something other than "Not-Approved" |
651 | - if (! apply_filters('FHEE__EED_Messages___maybe_registration__deliver_notifications', false) && |
|
651 | + if ( ! apply_filters('FHEE__EED_Messages___maybe_registration__deliver_notifications', false) && |
|
652 | 652 | $registration->status_ID() !== EEM_Registration::status_id_not_approved |
653 | 653 | ) { |
654 | 654 | return false; |
@@ -731,7 +731,7 @@ discard block |
||
731 | 731 | EE_Registry::instance()->REQ->set($request_key, $request_value); |
732 | 732 | } |
733 | 733 | |
734 | - if (! $messages_to_send = self::$_MSG_PROCESSOR->setup_messages_to_generate_from_registration_ids_in_request( |
|
734 | + if ( ! $messages_to_send = self::$_MSG_PROCESSOR->setup_messages_to_generate_from_registration_ids_in_request( |
|
735 | 735 | )) { |
736 | 736 | return false; |
737 | 737 | } |
@@ -765,7 +765,7 @@ discard block |
||
765 | 765 | self::_load_controller(); |
766 | 766 | |
767 | 767 | $msgID = EE_Registry::instance()->REQ->get('MSG_ID'); |
768 | - if (! $msgID) { |
|
768 | + if ( ! $msgID) { |
|
769 | 769 | EE_Error::add_error( |
770 | 770 | __( |
771 | 771 | 'Something went wrong because there is no "MSG_ID" value in the request', |
@@ -957,14 +957,14 @@ discard block |
||
957 | 957 | // get the message template group. |
958 | 958 | $msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params)); |
959 | 959 | // if we don't have an EE_Message_Template_Group then return |
960 | - if (! $msg_template_group instanceof EE_Message_Template_Group) { |
|
960 | + if ( ! $msg_template_group instanceof EE_Message_Template_Group) { |
|
961 | 961 | // remove EVT_ID from query params so that global templates get picked up |
962 | 962 | unset($template_query_params['Event.EVT_ID']); |
963 | 963 | // get global template as the fallback |
964 | 964 | $msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params)); |
965 | 965 | } |
966 | 966 | // if we don't have an EE_Message_Template_Group then return |
967 | - if (! $msg_template_group instanceof EE_Message_Template_Group) { |
|
967 | + if ( ! $msg_template_group instanceof EE_Message_Template_Group) { |
|
968 | 968 | return ''; |
969 | 969 | } |
970 | 970 | // generate the URL |
@@ -1095,7 +1095,7 @@ discard block |
||
1095 | 1095 | $generated_queue = self::$_MSG_PROCESSOR->batch_generate_from_queue($messages); |
1096 | 1096 | } |
1097 | 1097 | |
1098 | - if (! $generated_queue instanceof EE_Messages_Queue) { |
|
1098 | + if ( ! $generated_queue instanceof EE_Messages_Queue) { |
|
1099 | 1099 | EE_Error::add_error( |
1100 | 1100 | __( |
1101 | 1101 | '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 | $sent_queue = self::$_MSG_PROCESSOR->batch_send_from_queue($messages); |
1143 | 1143 | } |
1144 | 1144 | |
1145 | - if (! $sent_queue instanceof EE_Messages_Queue) { |
|
1145 | + if ( ! $sent_queue instanceof EE_Messages_Queue) { |
|
1146 | 1146 | EE_Error::add_error( |
1147 | 1147 | __( |
1148 | 1148 | '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.', |
@@ -1328,7 +1328,7 @@ discard block |
||
1328 | 1328 | $info['TXN_status'] = $transaction->status_ID(); |
1329 | 1329 | $info['TXN_reg_steps'] = $transaction->reg_steps(); |
1330 | 1330 | if ($transaction->ID()) { |
1331 | - $index = 'EE_Transaction: ' . $transaction->ID(); |
|
1331 | + $index = 'EE_Transaction: '.$transaction->ID(); |
|
1332 | 1332 | EEH_Debug_Tools::log($class, $func, $line, $info, $display_request, $index); |
1333 | 1333 | } |
1334 | 1334 | } |
@@ -16,1335 +16,1335 @@ |
||
16 | 16 | class EED_Messages extends EED_Module |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * This holds the EE_messages controller |
|
21 | - * |
|
22 | - * @deprecated 4.9.0 |
|
23 | - * @var EE_messages $_EEMSG |
|
24 | - */ |
|
25 | - protected static $_EEMSG; |
|
26 | - |
|
27 | - /** |
|
28 | - * @type EE_Message_Resource_Manager $_message_resource_manager |
|
29 | - */ |
|
30 | - protected static $_message_resource_manager; |
|
31 | - |
|
32 | - /** |
|
33 | - * This holds the EE_Messages_Processor business class. |
|
34 | - * |
|
35 | - * @type EE_Messages_Processor |
|
36 | - */ |
|
37 | - protected static $_MSG_PROCESSOR; |
|
38 | - |
|
39 | - /** |
|
40 | - * holds all the paths for various messages components. |
|
41 | - * Utilized by autoloader registry |
|
42 | - * |
|
43 | - * @var array |
|
44 | - */ |
|
45 | - protected static $_MSG_PATHS; |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * This will hold an array of messages template packs that are registered in the messages system. |
|
50 | - * Format is: |
|
51 | - * array( |
|
52 | - * 'template_pack_dbref' => EE_Messages_Template_Pack (instance) |
|
53 | - * ) |
|
54 | - * |
|
55 | - * @var EE_Messages_Template_Pack[] |
|
56 | - */ |
|
57 | - protected static $_TMP_PACKS = array(); |
|
58 | - |
|
59 | - |
|
60 | - /** |
|
61 | - * @return EED_Messages |
|
62 | - */ |
|
63 | - public static function instance() |
|
64 | - { |
|
65 | - return parent::get_instance(__CLASS__); |
|
66 | - } |
|
67 | - |
|
68 | - |
|
69 | - /** |
|
70 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
71 | - * |
|
72 | - * @since 4.5.0 |
|
73 | - * @return void |
|
74 | - */ |
|
75 | - public static function set_hooks() |
|
76 | - { |
|
77 | - // actions |
|
78 | - add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', array('EED_Messages', 'payment'), 10, 2); |
|
79 | - add_action( |
|
80 | - 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', |
|
81 | - array('EED_Messages', 'maybe_registration'), |
|
82 | - 10, |
|
83 | - 2 |
|
84 | - ); |
|
85 | - // filters |
|
86 | - add_filter( |
|
87 | - 'FHEE__EE_Registration__receipt_url__receipt_url', |
|
88 | - array('EED_Messages', 'registration_message_trigger_url'), |
|
89 | - 10, |
|
90 | - 4 |
|
91 | - ); |
|
92 | - add_filter( |
|
93 | - 'FHEE__EE_Registration__invoice_url__invoice_url', |
|
94 | - array('EED_Messages', 'registration_message_trigger_url'), |
|
95 | - 10, |
|
96 | - 4 |
|
97 | - ); |
|
98 | - // register routes |
|
99 | - self::_register_routes(); |
|
100 | - } |
|
101 | - |
|
102 | - /** |
|
103 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
104 | - * |
|
105 | - * @access public |
|
106 | - * @return void |
|
107 | - */ |
|
108 | - public static function set_hooks_admin() |
|
109 | - { |
|
110 | - // actions |
|
111 | - add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', array('EED_Messages', 'payment'), 10, 2); |
|
112 | - add_action( |
|
113 | - 'AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', |
|
114 | - array('EED_Messages', 'payment_reminder'), |
|
115 | - 10 |
|
116 | - ); |
|
117 | - add_action( |
|
118 | - 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', |
|
119 | - array('EED_Messages', 'maybe_registration'), |
|
120 | - 10, |
|
121 | - 3 |
|
122 | - ); |
|
123 | - add_action( |
|
124 | - 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations', |
|
125 | - array('EED_Messages', 'send_newsletter_message'), |
|
126 | - 10, |
|
127 | - 2 |
|
128 | - ); |
|
129 | - add_action( |
|
130 | - 'AHEE__EES_Espresso_Cancelled__process_shortcode__transaction', |
|
131 | - array('EED_Messages', 'cancelled_registration'), |
|
132 | - 10 |
|
133 | - ); |
|
134 | - add_action( |
|
135 | - 'AHEE__EE_Admin_Page___process_admin_payment_notification', |
|
136 | - array('EED_Messages', 'process_admin_payment'), |
|
137 | - 10, |
|
138 | - 1 |
|
139 | - ); |
|
140 | - // filters |
|
141 | - add_filter( |
|
142 | - 'FHEE__EE_Admin_Page___process_resend_registration__success', |
|
143 | - array('EED_Messages', 'process_resend'), |
|
144 | - 10, |
|
145 | - 2 |
|
146 | - ); |
|
147 | - add_filter( |
|
148 | - 'FHEE__EE_Registration__receipt_url__receipt_url', |
|
149 | - array('EED_Messages', 'registration_message_trigger_url'), |
|
150 | - 10, |
|
151 | - 4 |
|
152 | - ); |
|
153 | - add_filter( |
|
154 | - 'FHEE__EE_Registration__invoice_url__invoice_url', |
|
155 | - array('EED_Messages', 'registration_message_trigger_url'), |
|
156 | - 10, |
|
157 | - 4 |
|
158 | - ); |
|
159 | - } |
|
160 | - |
|
161 | - |
|
162 | - /** |
|
163 | - * All the message triggers done by route go in here. |
|
164 | - * |
|
165 | - * @since 4.5.0 |
|
166 | - * @return void |
|
167 | - */ |
|
168 | - protected static function _register_routes() |
|
169 | - { |
|
170 | - EE_Config::register_route('msg_url_trigger', 'Messages', 'run'); |
|
171 | - EE_Config::register_route('msg_cron_trigger', 'Messages', 'execute_batch_request'); |
|
172 | - EE_Config::register_route('msg_browser_trigger', 'Messages', 'browser_trigger'); |
|
173 | - EE_Config::register_route('msg_browser_error_trigger', 'Messages', 'browser_error_trigger'); |
|
174 | - do_action('AHEE__EED_Messages___register_routes'); |
|
175 | - } |
|
176 | - |
|
177 | - |
|
178 | - /** |
|
179 | - * This is called when a browser display trigger is executed. |
|
180 | - * The browser display trigger is typically used when a already generated message is displayed directly in the |
|
181 | - * browser. |
|
182 | - * |
|
183 | - * @since 4.9.0 |
|
184 | - * @param WP $WP |
|
185 | - * @throws EE_Error |
|
186 | - * @throws InvalidArgumentException |
|
187 | - * @throws ReflectionException |
|
188 | - * @throws InvalidDataTypeException |
|
189 | - * @throws InvalidInterfaceException |
|
190 | - */ |
|
191 | - public function browser_trigger($WP) |
|
192 | - { |
|
193 | - // ensure controller is loaded |
|
194 | - self::_load_controller(); |
|
195 | - $token = EE_Registry::instance()->REQ->get('token'); |
|
196 | - try { |
|
197 | - $mtg = new EE_Message_Generated_From_Token($token, 'html', self::$_message_resource_manager); |
|
198 | - self::$_MSG_PROCESSOR->generate_and_send_now($mtg); |
|
199 | - } catch (EE_Error $e) { |
|
200 | - $error_msg = __( |
|
201 | - 'Please note that a system message failed to send due to a technical issue.', |
|
202 | - 'event_espresso' |
|
203 | - ); |
|
204 | - // add specific message for developers if WP_DEBUG in on |
|
205 | - $error_msg .= '||' . $e->getMessage(); |
|
206 | - EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
207 | - } |
|
208 | - } |
|
209 | - |
|
210 | - |
|
211 | - /** |
|
212 | - * This is called when a browser error trigger is executed. |
|
213 | - * When triggered this will grab the EE_Message matching the token in the request and use that to get the error |
|
214 | - * message and display it. |
|
215 | - * |
|
216 | - * @since 4.9.0 |
|
217 | - * @param $WP |
|
218 | - * @throws EE_Error |
|
219 | - * @throws InvalidArgumentException |
|
220 | - * @throws InvalidDataTypeException |
|
221 | - * @throws InvalidInterfaceException |
|
222 | - */ |
|
223 | - public function browser_error_trigger($WP) |
|
224 | - { |
|
225 | - $token = EE_Registry::instance()->REQ->get('token'); |
|
226 | - if ($token) { |
|
227 | - $message = EEM_Message::instance()->get_one_by_token($token); |
|
228 | - if ($message instanceof EE_Message) { |
|
229 | - header('HTTP/1.1 200 OK'); |
|
230 | - $error_msg = nl2br($message->error_message()); |
|
231 | - ?> |
|
19 | + /** |
|
20 | + * This holds the EE_messages controller |
|
21 | + * |
|
22 | + * @deprecated 4.9.0 |
|
23 | + * @var EE_messages $_EEMSG |
|
24 | + */ |
|
25 | + protected static $_EEMSG; |
|
26 | + |
|
27 | + /** |
|
28 | + * @type EE_Message_Resource_Manager $_message_resource_manager |
|
29 | + */ |
|
30 | + protected static $_message_resource_manager; |
|
31 | + |
|
32 | + /** |
|
33 | + * This holds the EE_Messages_Processor business class. |
|
34 | + * |
|
35 | + * @type EE_Messages_Processor |
|
36 | + */ |
|
37 | + protected static $_MSG_PROCESSOR; |
|
38 | + |
|
39 | + /** |
|
40 | + * holds all the paths for various messages components. |
|
41 | + * Utilized by autoloader registry |
|
42 | + * |
|
43 | + * @var array |
|
44 | + */ |
|
45 | + protected static $_MSG_PATHS; |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * This will hold an array of messages template packs that are registered in the messages system. |
|
50 | + * Format is: |
|
51 | + * array( |
|
52 | + * 'template_pack_dbref' => EE_Messages_Template_Pack (instance) |
|
53 | + * ) |
|
54 | + * |
|
55 | + * @var EE_Messages_Template_Pack[] |
|
56 | + */ |
|
57 | + protected static $_TMP_PACKS = array(); |
|
58 | + |
|
59 | + |
|
60 | + /** |
|
61 | + * @return EED_Messages |
|
62 | + */ |
|
63 | + public static function instance() |
|
64 | + { |
|
65 | + return parent::get_instance(__CLASS__); |
|
66 | + } |
|
67 | + |
|
68 | + |
|
69 | + /** |
|
70 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
71 | + * |
|
72 | + * @since 4.5.0 |
|
73 | + * @return void |
|
74 | + */ |
|
75 | + public static function set_hooks() |
|
76 | + { |
|
77 | + // actions |
|
78 | + add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', array('EED_Messages', 'payment'), 10, 2); |
|
79 | + add_action( |
|
80 | + 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', |
|
81 | + array('EED_Messages', 'maybe_registration'), |
|
82 | + 10, |
|
83 | + 2 |
|
84 | + ); |
|
85 | + // filters |
|
86 | + add_filter( |
|
87 | + 'FHEE__EE_Registration__receipt_url__receipt_url', |
|
88 | + array('EED_Messages', 'registration_message_trigger_url'), |
|
89 | + 10, |
|
90 | + 4 |
|
91 | + ); |
|
92 | + add_filter( |
|
93 | + 'FHEE__EE_Registration__invoice_url__invoice_url', |
|
94 | + array('EED_Messages', 'registration_message_trigger_url'), |
|
95 | + 10, |
|
96 | + 4 |
|
97 | + ); |
|
98 | + // register routes |
|
99 | + self::_register_routes(); |
|
100 | + } |
|
101 | + |
|
102 | + /** |
|
103 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
104 | + * |
|
105 | + * @access public |
|
106 | + * @return void |
|
107 | + */ |
|
108 | + public static function set_hooks_admin() |
|
109 | + { |
|
110 | + // actions |
|
111 | + add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', array('EED_Messages', 'payment'), 10, 2); |
|
112 | + add_action( |
|
113 | + 'AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', |
|
114 | + array('EED_Messages', 'payment_reminder'), |
|
115 | + 10 |
|
116 | + ); |
|
117 | + add_action( |
|
118 | + 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', |
|
119 | + array('EED_Messages', 'maybe_registration'), |
|
120 | + 10, |
|
121 | + 3 |
|
122 | + ); |
|
123 | + add_action( |
|
124 | + 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations', |
|
125 | + array('EED_Messages', 'send_newsletter_message'), |
|
126 | + 10, |
|
127 | + 2 |
|
128 | + ); |
|
129 | + add_action( |
|
130 | + 'AHEE__EES_Espresso_Cancelled__process_shortcode__transaction', |
|
131 | + array('EED_Messages', 'cancelled_registration'), |
|
132 | + 10 |
|
133 | + ); |
|
134 | + add_action( |
|
135 | + 'AHEE__EE_Admin_Page___process_admin_payment_notification', |
|
136 | + array('EED_Messages', 'process_admin_payment'), |
|
137 | + 10, |
|
138 | + 1 |
|
139 | + ); |
|
140 | + // filters |
|
141 | + add_filter( |
|
142 | + 'FHEE__EE_Admin_Page___process_resend_registration__success', |
|
143 | + array('EED_Messages', 'process_resend'), |
|
144 | + 10, |
|
145 | + 2 |
|
146 | + ); |
|
147 | + add_filter( |
|
148 | + 'FHEE__EE_Registration__receipt_url__receipt_url', |
|
149 | + array('EED_Messages', 'registration_message_trigger_url'), |
|
150 | + 10, |
|
151 | + 4 |
|
152 | + ); |
|
153 | + add_filter( |
|
154 | + 'FHEE__EE_Registration__invoice_url__invoice_url', |
|
155 | + array('EED_Messages', 'registration_message_trigger_url'), |
|
156 | + 10, |
|
157 | + 4 |
|
158 | + ); |
|
159 | + } |
|
160 | + |
|
161 | + |
|
162 | + /** |
|
163 | + * All the message triggers done by route go in here. |
|
164 | + * |
|
165 | + * @since 4.5.0 |
|
166 | + * @return void |
|
167 | + */ |
|
168 | + protected static function _register_routes() |
|
169 | + { |
|
170 | + EE_Config::register_route('msg_url_trigger', 'Messages', 'run'); |
|
171 | + EE_Config::register_route('msg_cron_trigger', 'Messages', 'execute_batch_request'); |
|
172 | + EE_Config::register_route('msg_browser_trigger', 'Messages', 'browser_trigger'); |
|
173 | + EE_Config::register_route('msg_browser_error_trigger', 'Messages', 'browser_error_trigger'); |
|
174 | + do_action('AHEE__EED_Messages___register_routes'); |
|
175 | + } |
|
176 | + |
|
177 | + |
|
178 | + /** |
|
179 | + * This is called when a browser display trigger is executed. |
|
180 | + * The browser display trigger is typically used when a already generated message is displayed directly in the |
|
181 | + * browser. |
|
182 | + * |
|
183 | + * @since 4.9.0 |
|
184 | + * @param WP $WP |
|
185 | + * @throws EE_Error |
|
186 | + * @throws InvalidArgumentException |
|
187 | + * @throws ReflectionException |
|
188 | + * @throws InvalidDataTypeException |
|
189 | + * @throws InvalidInterfaceException |
|
190 | + */ |
|
191 | + public function browser_trigger($WP) |
|
192 | + { |
|
193 | + // ensure controller is loaded |
|
194 | + self::_load_controller(); |
|
195 | + $token = EE_Registry::instance()->REQ->get('token'); |
|
196 | + try { |
|
197 | + $mtg = new EE_Message_Generated_From_Token($token, 'html', self::$_message_resource_manager); |
|
198 | + self::$_MSG_PROCESSOR->generate_and_send_now($mtg); |
|
199 | + } catch (EE_Error $e) { |
|
200 | + $error_msg = __( |
|
201 | + 'Please note that a system message failed to send due to a technical issue.', |
|
202 | + 'event_espresso' |
|
203 | + ); |
|
204 | + // add specific message for developers if WP_DEBUG in on |
|
205 | + $error_msg .= '||' . $e->getMessage(); |
|
206 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
207 | + } |
|
208 | + } |
|
209 | + |
|
210 | + |
|
211 | + /** |
|
212 | + * This is called when a browser error trigger is executed. |
|
213 | + * When triggered this will grab the EE_Message matching the token in the request and use that to get the error |
|
214 | + * message and display it. |
|
215 | + * |
|
216 | + * @since 4.9.0 |
|
217 | + * @param $WP |
|
218 | + * @throws EE_Error |
|
219 | + * @throws InvalidArgumentException |
|
220 | + * @throws InvalidDataTypeException |
|
221 | + * @throws InvalidInterfaceException |
|
222 | + */ |
|
223 | + public function browser_error_trigger($WP) |
|
224 | + { |
|
225 | + $token = EE_Registry::instance()->REQ->get('token'); |
|
226 | + if ($token) { |
|
227 | + $message = EEM_Message::instance()->get_one_by_token($token); |
|
228 | + if ($message instanceof EE_Message) { |
|
229 | + header('HTTP/1.1 200 OK'); |
|
230 | + $error_msg = nl2br($message->error_message()); |
|
231 | + ?> |
|
232 | 232 | <!DOCTYPE html> |
233 | 233 | <html> |
234 | 234 | <head></head> |
235 | 235 | <body> |
236 | 236 | <?php echo empty($error_msg) |
237 | - ? esc_html__( |
|
238 | - 'Unfortunately, we were unable to capture the error message for this message.', |
|
239 | - 'event_espresso' |
|
240 | - ) |
|
241 | - : wp_kses( |
|
242 | - $error_msg, |
|
243 | - array( |
|
244 | - 'a' => array( |
|
245 | - 'href' => array(), |
|
246 | - 'title' => array(), |
|
247 | - ), |
|
248 | - 'span' => array(), |
|
249 | - 'div' => array(), |
|
250 | - 'p' => array(), |
|
251 | - 'strong' => array(), |
|
252 | - 'em' => array(), |
|
253 | - 'br' => array(), |
|
254 | - ) |
|
255 | - ); ?> |
|
237 | + ? esc_html__( |
|
238 | + 'Unfortunately, we were unable to capture the error message for this message.', |
|
239 | + 'event_espresso' |
|
240 | + ) |
|
241 | + : wp_kses( |
|
242 | + $error_msg, |
|
243 | + array( |
|
244 | + 'a' => array( |
|
245 | + 'href' => array(), |
|
246 | + 'title' => array(), |
|
247 | + ), |
|
248 | + 'span' => array(), |
|
249 | + 'div' => array(), |
|
250 | + 'p' => array(), |
|
251 | + 'strong' => array(), |
|
252 | + 'em' => array(), |
|
253 | + 'br' => array(), |
|
254 | + ) |
|
255 | + ); ?> |
|
256 | 256 | </body> |
257 | 257 | </html> |
258 | 258 | <?php |
259 | - exit; |
|
260 | - } |
|
261 | - } |
|
262 | - return; |
|
263 | - } |
|
264 | - |
|
265 | - |
|
266 | - /** |
|
267 | - * This runs when the msg_url_trigger route has initiated. |
|
268 | - * |
|
269 | - * @since 4.5.0 |
|
270 | - * @param WP $WP |
|
271 | - * @throws EE_Error |
|
272 | - * @throws InvalidArgumentException |
|
273 | - * @throws ReflectionException |
|
274 | - * @throws InvalidDataTypeException |
|
275 | - * @throws InvalidInterfaceException |
|
276 | - */ |
|
277 | - public function run($WP) |
|
278 | - { |
|
279 | - // ensure controller is loaded |
|
280 | - self::_load_controller(); |
|
281 | - // attempt to process message |
|
282 | - try { |
|
283 | - /** @type EE_Message_To_Generate_From_Request $message_to_generate */ |
|
284 | - $message_to_generate = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request'); |
|
285 | - self::$_MSG_PROCESSOR->generate_and_send_now($message_to_generate); |
|
286 | - } catch (EE_Error $e) { |
|
287 | - $error_msg = __( |
|
288 | - 'Please note that a system message failed to send due to a technical issue.', |
|
289 | - 'event_espresso' |
|
290 | - ); |
|
291 | - // add specific message for developers if WP_DEBUG in on |
|
292 | - $error_msg .= '||' . $e->getMessage(); |
|
293 | - EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
294 | - } |
|
295 | - } |
|
296 | - |
|
297 | - |
|
298 | - /** |
|
299 | - * This is triggered by the 'msg_cron_trigger' route. |
|
300 | - * |
|
301 | - * @param WP $WP |
|
302 | - */ |
|
303 | - public function execute_batch_request($WP) |
|
304 | - { |
|
305 | - $this->run_cron(); |
|
306 | - header('HTTP/1.1 200 OK'); |
|
307 | - exit(); |
|
308 | - } |
|
309 | - |
|
310 | - |
|
311 | - /** |
|
312 | - * This gets executed on wp_cron jobs or when a batch request is initiated on its own separate non regular wp |
|
313 | - * request. |
|
314 | - */ |
|
315 | - public function run_cron() |
|
316 | - { |
|
317 | - self::_load_controller(); |
|
318 | - // get required vars |
|
319 | - $cron_type = EE_Registry::instance()->REQ->get('type'); |
|
320 | - $transient_key = EE_Registry::instance()->REQ->get('key'); |
|
321 | - |
|
322 | - // now let's verify transient, if not valid exit immediately |
|
323 | - if (! get_transient($transient_key)) { |
|
324 | - /** |
|
325 | - * trigger error so this gets in the error logs. This is important because it happens on a non-user |
|
326 | - * request. |
|
327 | - */ |
|
328 | - trigger_error(esc_attr__('Invalid Request (Transient does not exist)', 'event_espresso')); |
|
329 | - } |
|
330 | - |
|
331 | - // if made it here, lets' delete the transient to keep the db clean |
|
332 | - delete_transient($transient_key); |
|
333 | - |
|
334 | - if (apply_filters('FHEE__EED_Messages__run_cron__use_wp_cron', true)) { |
|
335 | - $method = 'batch_' . $cron_type . '_from_queue'; |
|
336 | - if (method_exists(self::$_MSG_PROCESSOR, $method)) { |
|
337 | - self::$_MSG_PROCESSOR->$method(); |
|
338 | - } else { |
|
339 | - // no matching task |
|
340 | - /** |
|
341 | - * trigger error so this gets in the error logs. This is important because it happens on a non user |
|
342 | - * request. |
|
343 | - */ |
|
344 | - trigger_error( |
|
345 | - esc_attr( |
|
346 | - sprintf( |
|
347 | - __('There is no task corresponding to this route %s', 'event_espresso'), |
|
348 | - $cron_type |
|
349 | - ) |
|
350 | - ) |
|
351 | - ); |
|
352 | - } |
|
353 | - } |
|
354 | - |
|
355 | - do_action('FHEE__EED_Messages__run_cron__end'); |
|
356 | - } |
|
357 | - |
|
358 | - |
|
359 | - /** |
|
360 | - * This is used to retrieve the template pack for the given name. |
|
361 | - * Retrieved packs are cached on the static $_TMP_PACKS array. If there is no class matching the given name then |
|
362 | - * the default template pack is returned. |
|
363 | - * |
|
364 | - * @deprecated 4.9.0 @see EEH_MSG_Template::get_template_pack() |
|
365 | - * @param string $template_pack_name This should correspond to the dbref of the template pack (which is also used |
|
366 | - * in generating the Pack class name). |
|
367 | - * @return EE_Messages_Template_Pack |
|
368 | - * @throws EE_Error |
|
369 | - * @throws InvalidArgumentException |
|
370 | - * @throws ReflectionException |
|
371 | - * @throws InvalidDataTypeException |
|
372 | - * @throws InvalidInterfaceException |
|
373 | - */ |
|
374 | - public static function get_template_pack($template_pack_name) |
|
375 | - { |
|
376 | - EE_Registry::instance()->load_helper('MSG_Template'); |
|
377 | - return EEH_MSG_Template::get_template_pack($template_pack_name); |
|
378 | - } |
|
379 | - |
|
380 | - |
|
381 | - /** |
|
382 | - * Retrieves an array of all template packs. |
|
383 | - * Array is in the format array( 'dbref' => EE_Messages_Template_Pack ) |
|
384 | - * |
|
385 | - * @deprecated 4.9.0 @see EEH_MSG_Template_Pack::get_template_pack_collection |
|
386 | - * @return EE_Messages_Template_Pack[] |
|
387 | - * @throws EE_Error |
|
388 | - * @throws InvalidArgumentException |
|
389 | - * @throws ReflectionException |
|
390 | - * @throws InvalidDataTypeException |
|
391 | - * @throws InvalidInterfaceException |
|
392 | - */ |
|
393 | - public static function get_template_packs() |
|
394 | - { |
|
395 | - EE_Registry::instance()->load_helper('MSG_Template'); |
|
396 | - |
|
397 | - // for backward compat, let's make sure this returns in the same format as originally. |
|
398 | - $template_pack_collection = EEH_MSG_Template::get_template_pack_collection(); |
|
399 | - $template_pack_collection->rewind(); |
|
400 | - $template_packs = array(); |
|
401 | - while ($template_pack_collection->valid()) { |
|
402 | - $template_packs[ $template_pack_collection->current()->dbref ] = $template_pack_collection->current(); |
|
403 | - $template_pack_collection->next(); |
|
404 | - } |
|
405 | - return $template_packs; |
|
406 | - } |
|
407 | - |
|
408 | - |
|
409 | - /** |
|
410 | - * This simply makes sure the autoloaders are registered for the EE_messages system. |
|
411 | - * |
|
412 | - * @since 4.5.0 |
|
413 | - * @return void |
|
414 | - * @throws EE_Error |
|
415 | - */ |
|
416 | - public static function set_autoloaders() |
|
417 | - { |
|
418 | - if (empty(self::$_MSG_PATHS)) { |
|
419 | - self::_set_messages_paths(); |
|
420 | - foreach (self::$_MSG_PATHS as $path) { |
|
421 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder($path); |
|
422 | - } |
|
423 | - // add aliases |
|
424 | - EEH_Autoloader::add_alias('EE_messages', 'EE_messages'); |
|
425 | - EEH_Autoloader::add_alias('EE_messenger', 'EE_messenger'); |
|
426 | - } |
|
427 | - } |
|
428 | - |
|
429 | - |
|
430 | - /** |
|
431 | - * Take care of adding all the paths for the messages components to the $_MSG_PATHS property |
|
432 | - * for use by the Messages Autoloaders |
|
433 | - * |
|
434 | - * @since 4.5.0 |
|
435 | - * @return void. |
|
436 | - */ |
|
437 | - protected static function _set_messages_paths() |
|
438 | - { |
|
439 | - $dir_ref = array( |
|
440 | - 'messages/message_type', |
|
441 | - 'messages/messenger', |
|
442 | - 'messages/defaults', |
|
443 | - 'messages/defaults/email', |
|
444 | - 'messages/data_class', |
|
445 | - 'messages/validators', |
|
446 | - 'messages/validators/email', |
|
447 | - 'messages/validators/html', |
|
448 | - 'shortcodes', |
|
449 | - ); |
|
450 | - $paths = array(); |
|
451 | - foreach ($dir_ref as $index => $dir) { |
|
452 | - $paths[ $index ] = EE_LIBRARIES . $dir; |
|
453 | - } |
|
454 | - self::$_MSG_PATHS = apply_filters('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', $paths); |
|
455 | - } |
|
456 | - |
|
457 | - |
|
458 | - /** |
|
459 | - * Takes care of loading dependencies |
|
460 | - * |
|
461 | - * @since 4.5.0 |
|
462 | - * @return void |
|
463 | - * @throws EE_Error |
|
464 | - * @throws InvalidArgumentException |
|
465 | - * @throws ReflectionException |
|
466 | - * @throws InvalidDataTypeException |
|
467 | - * @throws InvalidInterfaceException |
|
468 | - */ |
|
469 | - protected static function _load_controller() |
|
470 | - { |
|
471 | - if (! self::$_MSG_PROCESSOR instanceof EE_Messages_Processor) { |
|
472 | - EE_Registry::instance()->load_core('Request_Handler'); |
|
473 | - self::set_autoloaders(); |
|
474 | - self::$_EEMSG = EE_Registry::instance()->load_lib('messages'); |
|
475 | - self::$_MSG_PROCESSOR = EE_Registry::instance()->load_lib('Messages_Processor'); |
|
476 | - self::$_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
477 | - } |
|
478 | - } |
|
479 | - |
|
480 | - |
|
481 | - /** |
|
482 | - * @param EE_Transaction $transaction |
|
483 | - * @throws EE_Error |
|
484 | - * @throws InvalidArgumentException |
|
485 | - * @throws InvalidDataTypeException |
|
486 | - * @throws InvalidInterfaceException |
|
487 | - * @throws ReflectionException |
|
488 | - */ |
|
489 | - public static function payment_reminder(EE_Transaction $transaction) |
|
490 | - { |
|
491 | - self::_load_controller(); |
|
492 | - $data = array($transaction, null); |
|
493 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers('payment_reminder', $data); |
|
494 | - } |
|
495 | - |
|
496 | - |
|
497 | - /** |
|
498 | - * Any messages triggers for after successful gateway payments should go in here. |
|
499 | - * |
|
500 | - * @param EE_Transaction $transaction object |
|
501 | - * @param EE_Payment|null $payment object |
|
502 | - * @return void |
|
503 | - * @throws EE_Error |
|
504 | - * @throws InvalidArgumentException |
|
505 | - * @throws ReflectionException |
|
506 | - * @throws InvalidDataTypeException |
|
507 | - * @throws InvalidInterfaceException |
|
508 | - */ |
|
509 | - public static function payment(EE_Transaction $transaction, EE_Payment $payment = null) |
|
510 | - { |
|
511 | - // if there's no payment object, then we cannot do a payment type message! |
|
512 | - if (! $payment instanceof EE_Payment) { |
|
513 | - return; |
|
514 | - } |
|
515 | - self::_load_controller(); |
|
516 | - $data = array($transaction, $payment); |
|
517 | - EE_Registry::instance()->load_helper('MSG_Template'); |
|
518 | - $message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID()); |
|
519 | - // if payment amount is less than 0 then switch to payment_refund message type. |
|
520 | - $message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type; |
|
521 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data); |
|
522 | - } |
|
523 | - |
|
524 | - |
|
525 | - /** |
|
526 | - * @param EE_Transaction $transaction |
|
527 | - * @throws EE_Error |
|
528 | - * @throws InvalidArgumentException |
|
529 | - * @throws InvalidDataTypeException |
|
530 | - * @throws InvalidInterfaceException |
|
531 | - * @throws ReflectionException |
|
532 | - */ |
|
533 | - public static function cancelled_registration(EE_Transaction $transaction) |
|
534 | - { |
|
535 | - self::_load_controller(); |
|
536 | - $data = array($transaction, null); |
|
537 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers('cancelled_registration', $data); |
|
538 | - } |
|
539 | - |
|
540 | - |
|
541 | - /** |
|
542 | - * Trigger for Registration messages |
|
543 | - * Note that what registration message type is sent depends on what the reg status is for the registrations on the |
|
544 | - * incoming transaction. |
|
545 | - * |
|
546 | - * @param EE_Registration $registration |
|
547 | - * @param array $extra_details |
|
548 | - * @return void |
|
549 | - * @throws EE_Error |
|
550 | - * @throws InvalidArgumentException |
|
551 | - * @throws InvalidDataTypeException |
|
552 | - * @throws InvalidInterfaceException |
|
553 | - * @throws ReflectionException |
|
554 | - * @throws EntityNotFoundException |
|
555 | - */ |
|
556 | - public static function maybe_registration(EE_Registration $registration, $extra_details = array()) |
|
557 | - { |
|
558 | - |
|
559 | - if (! self::_verify_registration_notification_send($registration, $extra_details)) { |
|
560 | - // no messages please |
|
561 | - return; |
|
562 | - } |
|
563 | - |
|
564 | - // get all non-trashed registrations so we make sure we send messages for the right status. |
|
565 | - $all_registrations = $registration->transaction()->registrations( |
|
566 | - array( |
|
567 | - array('REG_deleted' => false), |
|
568 | - 'order_by' => array( |
|
569 | - 'Event.EVT_name' => 'ASC', |
|
570 | - 'Attendee.ATT_lname' => 'ASC', |
|
571 | - 'Attendee.ATT_fname' => 'ASC', |
|
572 | - ), |
|
573 | - ) |
|
574 | - ); |
|
575 | - // cached array of statuses so we only trigger messages once per status. |
|
576 | - $statuses_sent = array(); |
|
577 | - self::_load_controller(); |
|
578 | - $mtgs = array(); |
|
579 | - |
|
580 | - // loop through registrations and trigger messages once per status. |
|
581 | - foreach ($all_registrations as $reg) { |
|
582 | - // already triggered? |
|
583 | - if (in_array($reg->status_ID(), $statuses_sent)) { |
|
584 | - continue; |
|
585 | - } |
|
586 | - |
|
587 | - $message_type = EEH_MSG_Template::convert_reg_status_to_message_type($reg->status_ID()); |
|
588 | - $mtgs = array_merge( |
|
589 | - $mtgs, |
|
590 | - self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers( |
|
591 | - $message_type, |
|
592 | - array($registration->transaction(), null, $reg->status_ID()) |
|
593 | - ) |
|
594 | - ); |
|
595 | - $statuses_sent[] = $reg->status_ID(); |
|
596 | - } |
|
597 | - |
|
598 | - if (count($statuses_sent) > 1) { |
|
599 | - $mtgs = array_merge( |
|
600 | - $mtgs, |
|
601 | - self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers( |
|
602 | - 'registration_summary', |
|
603 | - array($registration->transaction(), null) |
|
604 | - ) |
|
605 | - ); |
|
606 | - } |
|
607 | - |
|
608 | - // batch queue and initiate request |
|
609 | - self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($mtgs); |
|
610 | - self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority(); |
|
611 | - } |
|
612 | - |
|
613 | - |
|
614 | - /** |
|
615 | - * This is a helper method used to very whether a registration notification should be sent or |
|
616 | - * not. Prevents duplicate notifications going out for registration context notifications. |
|
617 | - * |
|
618 | - * @param EE_Registration $registration [description] |
|
619 | - * @param array $extra_details [description] |
|
620 | - * @return bool true = send away, false = nope halt the presses. |
|
621 | - */ |
|
622 | - protected static function _verify_registration_notification_send( |
|
623 | - EE_Registration $registration, |
|
624 | - $extra_details = array() |
|
625 | - ) { |
|
626 | - if (! $registration->is_primary_registrant()) { |
|
627 | - return false; |
|
628 | - } |
|
629 | - // first we check if we're in admin and not doing front ajax |
|
630 | - if (is_admin() && ! EE_FRONT_AJAX) { |
|
631 | - // make sure appropriate admin params are set for sending messages |
|
632 | - if (empty($_REQUEST['txn_reg_status_change']['send_notifications']) |
|
633 | - || ! absint($_REQUEST['txn_reg_status_change']['send_notifications']) |
|
634 | - ) { |
|
635 | - // no messages sent please. |
|
636 | - return false; |
|
637 | - } |
|
638 | - } else { |
|
639 | - // frontend request (either regular or via AJAX) |
|
640 | - // TXN is NOT finalized ? |
|
641 | - if (! isset($extra_details['finalized']) || $extra_details['finalized'] === false) { |
|
642 | - return false; |
|
643 | - } |
|
644 | - // return visit but nothing changed ??? |
|
645 | - if (isset($extra_details['revisit'], $extra_details['status_updates']) && |
|
646 | - $extra_details['revisit'] && ! $extra_details['status_updates'] |
|
647 | - ) { |
|
648 | - return false; |
|
649 | - } |
|
650 | - // NOT sending messages && reg status is something other than "Not-Approved" |
|
651 | - if (! apply_filters('FHEE__EED_Messages___maybe_registration__deliver_notifications', false) && |
|
652 | - $registration->status_ID() !== EEM_Registration::status_id_not_approved |
|
653 | - ) { |
|
654 | - return false; |
|
655 | - } |
|
656 | - } |
|
657 | - // release the kraken |
|
658 | - return true; |
|
659 | - } |
|
660 | - |
|
661 | - |
|
662 | - /** |
|
663 | - * Simply returns an array indexed by Registration Status ID and the related message_type name associated with that |
|
664 | - * status id. |
|
665 | - * |
|
666 | - * @deprecated 4.9.0 Use EEH_MSG_Template::reg_status_to_message_type_array() |
|
667 | - * or EEH_MSG_Template::convert_reg_status_to_message_type |
|
668 | - * @param string $reg_status |
|
669 | - * @return array |
|
670 | - * @throws EE_Error |
|
671 | - * @throws InvalidArgumentException |
|
672 | - * @throws ReflectionException |
|
673 | - * @throws InvalidDataTypeException |
|
674 | - * @throws InvalidInterfaceException |
|
675 | - */ |
|
676 | - protected static function _get_reg_status_array($reg_status = '') |
|
677 | - { |
|
678 | - EE_Registry::instance()->load_helper('MSG_Template'); |
|
679 | - return EEH_MSG_Template::convert_reg_status_to_message_type($reg_status) |
|
680 | - ? EEH_MSG_Template::convert_reg_status_to_message_type($reg_status) |
|
681 | - : EEH_MSG_Template::reg_status_to_message_type_array(); |
|
682 | - } |
|
683 | - |
|
684 | - |
|
685 | - /** |
|
686 | - * Simply returns the payment message type for the given payment status. |
|
687 | - * |
|
688 | - * @deprecated 4.9.0 Use EEH_MSG_Template::payment_status_to_message_type_array |
|
689 | - * or EEH_MSG_Template::convert_payment_status_to_message_type |
|
690 | - * @param string $payment_status The payment status being matched. |
|
691 | - * @return bool|string The payment message type slug matching the status or false if no match. |
|
692 | - * @throws EE_Error |
|
693 | - * @throws InvalidArgumentException |
|
694 | - * @throws ReflectionException |
|
695 | - * @throws InvalidDataTypeException |
|
696 | - * @throws InvalidInterfaceException |
|
697 | - */ |
|
698 | - protected static function _get_payment_message_type($payment_status) |
|
699 | - { |
|
700 | - EE_Registry::instance()->load_helper('MSG_Template'); |
|
701 | - return EEH_MSG_Template::convert_payment_status_to_message_type($payment_status) |
|
702 | - ? EEH_MSG_Template::convert_payment_status_to_message_type($payment_status) |
|
703 | - : false; |
|
704 | - } |
|
705 | - |
|
706 | - |
|
707 | - /** |
|
708 | - * Message triggers for a resending already sent message(s) (via EE_Message list table) |
|
709 | - * |
|
710 | - * @access public |
|
711 | - * @param array $req_data This is the $_POST & $_GET data sent from EE_Admin Pages |
|
712 | - * @return bool success/fail |
|
713 | - * @throws EE_Error |
|
714 | - * @throws InvalidArgumentException |
|
715 | - * @throws InvalidDataTypeException |
|
716 | - * @throws InvalidInterfaceException |
|
717 | - * @throws ReflectionException |
|
718 | - */ |
|
719 | - public static function process_resend($req_data) |
|
720 | - { |
|
721 | - self::_load_controller(); |
|
722 | - |
|
723 | - // if $msgID in this request then skip to the new resend_message |
|
724 | - if (EE_Registry::instance()->REQ->get('MSG_ID')) { |
|
725 | - return self::resend_message(); |
|
726 | - } |
|
727 | - |
|
728 | - // make sure any incoming request data is set on the REQ so that it gets picked up later. |
|
729 | - $req_data = (array) $req_data; |
|
730 | - foreach ($req_data as $request_key => $request_value) { |
|
731 | - EE_Registry::instance()->REQ->set($request_key, $request_value); |
|
732 | - } |
|
733 | - |
|
734 | - if (! $messages_to_send = self::$_MSG_PROCESSOR->setup_messages_to_generate_from_registration_ids_in_request( |
|
735 | - )) { |
|
736 | - return false; |
|
737 | - } |
|
738 | - |
|
739 | - try { |
|
740 | - self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($messages_to_send); |
|
741 | - self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority(); |
|
742 | - } catch (EE_Error $e) { |
|
743 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
744 | - return false; |
|
745 | - } |
|
746 | - EE_Error::add_success( |
|
747 | - __('Messages have been successfully queued for generation and sending.', 'event_espresso') |
|
748 | - ); |
|
749 | - return true; // everything got queued. |
|
750 | - } |
|
751 | - |
|
752 | - |
|
753 | - /** |
|
754 | - * Message triggers for a resending already sent message(s) (via EE_Message list table) |
|
755 | - * |
|
756 | - * @return bool |
|
757 | - * @throws EE_Error |
|
758 | - * @throws InvalidArgumentException |
|
759 | - * @throws InvalidDataTypeException |
|
760 | - * @throws InvalidInterfaceException |
|
761 | - * @throws ReflectionException |
|
762 | - */ |
|
763 | - public static function resend_message() |
|
764 | - { |
|
765 | - self::_load_controller(); |
|
766 | - |
|
767 | - $msgID = EE_Registry::instance()->REQ->get('MSG_ID'); |
|
768 | - if (! $msgID) { |
|
769 | - EE_Error::add_error( |
|
770 | - __( |
|
771 | - 'Something went wrong because there is no "MSG_ID" value in the request', |
|
772 | - 'event_espresso' |
|
773 | - ), |
|
774 | - __FILE__, |
|
775 | - __FUNCTION__, |
|
776 | - __LINE__ |
|
777 | - ); |
|
778 | - return false; |
|
779 | - } |
|
780 | - |
|
781 | - self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send((array) $msgID); |
|
782 | - |
|
783 | - // setup success message. |
|
784 | - $count_ready_for_resend = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend); |
|
785 | - EE_Error::add_success( |
|
786 | - sprintf( |
|
787 | - _n( |
|
788 | - 'There was %d message queued for resending.', |
|
789 | - 'There were %d messages queued for resending.', |
|
790 | - $count_ready_for_resend, |
|
791 | - 'event_espresso' |
|
792 | - ), |
|
793 | - $count_ready_for_resend |
|
794 | - ) |
|
795 | - ); |
|
796 | - return true; |
|
797 | - } |
|
798 | - |
|
799 | - |
|
800 | - /** |
|
801 | - * Message triggers for manual payment applied by admin |
|
802 | - * |
|
803 | - * @param EE_Payment $payment EE_payment object |
|
804 | - * @return bool success/fail |
|
805 | - * @throws EE_Error |
|
806 | - * @throws InvalidArgumentException |
|
807 | - * @throws ReflectionException |
|
808 | - * @throws InvalidDataTypeException |
|
809 | - * @throws InvalidInterfaceException |
|
810 | - */ |
|
811 | - public static function process_admin_payment(EE_Payment $payment) |
|
812 | - { |
|
813 | - EE_Registry::instance()->load_helper('MSG_Template'); |
|
814 | - // we need to get the transaction object |
|
815 | - $transaction = $payment->transaction(); |
|
816 | - if ($transaction instanceof EE_Transaction) { |
|
817 | - $data = array($transaction, $payment); |
|
818 | - $message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID()); |
|
819 | - |
|
820 | - // if payment amount is less than 0 then switch to payment_refund message type. |
|
821 | - $message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type; |
|
822 | - |
|
823 | - // if payment_refund is selected, but the status is NOT accepted. Then change message type to false so NO message notification goes out. |
|
824 | - $message_type = $message_type == 'payment_refund' && $payment->STS_ID() != EEM_Payment::status_id_approved |
|
825 | - ? false : $message_type; |
|
826 | - |
|
827 | - self::_load_controller(); |
|
828 | - |
|
829 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data); |
|
830 | - |
|
831 | - // get count of queued for generation |
|
832 | - $count_to_generate = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue( |
|
833 | - array( |
|
834 | - EEM_Message::status_incomplete, |
|
835 | - EEM_Message::status_idle, |
|
836 | - ) |
|
837 | - ); |
|
838 | - |
|
839 | - if ($count_to_generate > 0 && self::$_MSG_PROCESSOR->get_queue()->get_message_repository()->count() !== 0) { |
|
840 | - add_filter('FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true'); |
|
841 | - return true; |
|
842 | - } else { |
|
843 | - $count_failed = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue( |
|
844 | - EEM_Message::instance()->stati_indicating_failed_sending() |
|
845 | - ); |
|
846 | - /** |
|
847 | - * Verify that there are actually errors. If not then we return a success message because the queue might have been emptied due to successful |
|
848 | - * IMMEDIATE generation. |
|
849 | - */ |
|
850 | - if ($count_failed > 0) { |
|
851 | - EE_Error::add_error( |
|
852 | - sprintf( |
|
853 | - _n( |
|
854 | - 'The payment notification generation failed.', |
|
855 | - '%d payment notifications failed being sent.', |
|
856 | - $count_failed, |
|
857 | - 'event_espresso' |
|
858 | - ), |
|
859 | - $count_failed |
|
860 | - ), |
|
861 | - __FILE__, |
|
862 | - __FUNCTION__, |
|
863 | - __LINE__ |
|
864 | - ); |
|
865 | - |
|
866 | - return false; |
|
867 | - } else { |
|
868 | - add_filter('FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true'); |
|
869 | - return true; |
|
870 | - } |
|
871 | - } |
|
872 | - } else { |
|
873 | - EE_Error::add_error( |
|
874 | - 'Unable to generate the payment notification because the given value for the transaction is invalid.', |
|
875 | - 'event_espresso' |
|
876 | - ); |
|
877 | - return false; |
|
878 | - } |
|
879 | - } |
|
880 | - |
|
881 | - |
|
882 | - /** |
|
883 | - * Callback for AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send_with_registrations trigger |
|
884 | - * |
|
885 | - * @since 4.3.0 |
|
886 | - * @param EE_Registration[] $registrations an array of EE_Registration objects |
|
887 | - * @param int $grp_id a specific message template group id. |
|
888 | - * @return void |
|
889 | - * @throws EE_Error |
|
890 | - * @throws InvalidArgumentException |
|
891 | - * @throws InvalidDataTypeException |
|
892 | - * @throws InvalidInterfaceException |
|
893 | - * @throws ReflectionException |
|
894 | - */ |
|
895 | - public static function send_newsletter_message($registrations, $grp_id) |
|
896 | - { |
|
897 | - // make sure mtp is id and set it in the EE_Request Handler later messages setup. |
|
898 | - EE_Registry::instance()->REQ->set('GRP_ID', (int) $grp_id); |
|
899 | - self::_load_controller(); |
|
900 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers('newsletter', $registrations); |
|
901 | - } |
|
902 | - |
|
903 | - |
|
904 | - /** |
|
905 | - * Callback for FHEE__EE_Registration__invoice_url__invoice_url or FHEE__EE_Registration__receipt_url__receipt_url |
|
906 | - * |
|
907 | - * @since 4.3.0 |
|
908 | - * @param string $registration_message_trigger_url |
|
909 | - * @param EE_Registration $registration |
|
910 | - * @param string $messenger |
|
911 | - * @param string $message_type |
|
912 | - * @return string |
|
913 | - * @throws EE_Error |
|
914 | - * @throws InvalidArgumentException |
|
915 | - * @throws InvalidDataTypeException |
|
916 | - * @throws InvalidInterfaceException |
|
917 | - */ |
|
918 | - public static function registration_message_trigger_url( |
|
919 | - $registration_message_trigger_url, |
|
920 | - EE_Registration $registration, |
|
921 | - $messenger = 'html', |
|
922 | - $message_type = 'invoice' |
|
923 | - ) { |
|
924 | - // whitelist $messenger |
|
925 | - switch ($messenger) { |
|
926 | - case 'pdf': |
|
927 | - $sending_messenger = 'pdf'; |
|
928 | - $generating_messenger = 'html'; |
|
929 | - break; |
|
930 | - case 'html': |
|
931 | - default: |
|
932 | - $sending_messenger = 'html'; |
|
933 | - $generating_messenger = 'html'; |
|
934 | - break; |
|
935 | - } |
|
936 | - // whitelist $message_type |
|
937 | - switch ($message_type) { |
|
938 | - case 'receipt': |
|
939 | - $message_type = 'receipt'; |
|
940 | - break; |
|
941 | - case 'invoice': |
|
942 | - default: |
|
943 | - $message_type = 'invoice'; |
|
944 | - break; |
|
945 | - } |
|
946 | - // verify that both the messenger AND the message type are active |
|
947 | - if (EEH_MSG_Template::is_messenger_active($sending_messenger) |
|
948 | - && EEH_MSG_Template::is_mt_active($message_type) |
|
949 | - ) { |
|
950 | - // 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?) |
|
951 | - $template_query_params = array( |
|
952 | - 'MTP_is_active' => true, |
|
953 | - 'MTP_messenger' => $generating_messenger, |
|
954 | - 'MTP_message_type' => $message_type, |
|
955 | - 'Event.EVT_ID' => $registration->event_ID(), |
|
956 | - ); |
|
957 | - // get the message template group. |
|
958 | - $msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params)); |
|
959 | - // if we don't have an EE_Message_Template_Group then return |
|
960 | - if (! $msg_template_group instanceof EE_Message_Template_Group) { |
|
961 | - // remove EVT_ID from query params so that global templates get picked up |
|
962 | - unset($template_query_params['Event.EVT_ID']); |
|
963 | - // get global template as the fallback |
|
964 | - $msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params)); |
|
965 | - } |
|
966 | - // if we don't have an EE_Message_Template_Group then return |
|
967 | - if (! $msg_template_group instanceof EE_Message_Template_Group) { |
|
968 | - return ''; |
|
969 | - } |
|
970 | - // generate the URL |
|
971 | - $registration_message_trigger_url = EEH_MSG_Template::generate_url_trigger( |
|
972 | - $sending_messenger, |
|
973 | - $generating_messenger, |
|
974 | - 'purchaser', |
|
975 | - $message_type, |
|
976 | - $registration, |
|
977 | - $msg_template_group->ID(), |
|
978 | - $registration->transaction_ID() |
|
979 | - ); |
|
980 | - } |
|
981 | - return $registration_message_trigger_url; |
|
982 | - } |
|
983 | - |
|
984 | - |
|
985 | - /** |
|
986 | - * Use to generate and return a message preview! |
|
987 | - * |
|
988 | - * @param string $type This should correspond with a valid message type |
|
989 | - * @param string $context This should correspond with a valid context for the message type |
|
990 | - * @param string $messenger This should correspond with a valid messenger. |
|
991 | - * @param bool $send true we will do a test send using the messenger delivery, false we just do a regular |
|
992 | - * preview |
|
993 | - * @return bool|string The body of the message or if send is requested, sends. |
|
994 | - * @throws EE_Error |
|
995 | - * @throws InvalidArgumentException |
|
996 | - * @throws InvalidDataTypeException |
|
997 | - * @throws InvalidInterfaceException |
|
998 | - * @throws ReflectionException |
|
999 | - */ |
|
1000 | - public static function preview_message($type, $context, $messenger, $send = false) |
|
1001 | - { |
|
1002 | - self::_load_controller(); |
|
1003 | - $mtg = new EE_Message_To_Generate( |
|
1004 | - $messenger, |
|
1005 | - $type, |
|
1006 | - array(), |
|
1007 | - $context, |
|
1008 | - true |
|
1009 | - ); |
|
1010 | - $generated_preview_queue = self::$_MSG_PROCESSOR->generate_for_preview($mtg, $send); |
|
1011 | - if ($generated_preview_queue instanceof EE_Messages_Queue) { |
|
1012 | - // loop through all content for the preview and remove any persisted records. |
|
1013 | - $content = ''; |
|
1014 | - foreach ($generated_preview_queue->get_message_repository() as $message) { |
|
1015 | - $content = $message->content(); |
|
1016 | - if ($message->ID() > 0 && $message->STS_ID() !== EEM_Message::status_failed) { |
|
1017 | - $message->delete(); |
|
1018 | - } |
|
1019 | - } |
|
1020 | - return $content; |
|
1021 | - } else { |
|
1022 | - return $generated_preview_queue; |
|
1023 | - } |
|
1024 | - } |
|
1025 | - |
|
1026 | - |
|
1027 | - /** |
|
1028 | - * This is a method that allows for sending a message using a messenger matching the string given and the provided |
|
1029 | - * EE_Message_Queue object. The EE_Message_Queue object is used to create a single aggregate EE_Message via the |
|
1030 | - * content found in the EE_Message objects in the queue. |
|
1031 | - * |
|
1032 | - * @since 4.9.0 |
|
1033 | - * @param string $messenger a string matching a valid active messenger in the system |
|
1034 | - * @param string $message_type Although it seems contrary to the name of the method, a message |
|
1035 | - * type name is still required to send along the message type to the |
|
1036 | - * messenger because this is used for determining what specific |
|
1037 | - * variations might be loaded for the generated message. |
|
1038 | - * @param EE_Messages_Queue $queue |
|
1039 | - * @param string $custom_subject Can be used to set what the custom subject string will be on the |
|
1040 | - * aggregate EE_Message object. |
|
1041 | - * @return bool success or fail. |
|
1042 | - * @throws EE_Error |
|
1043 | - * @throws InvalidArgumentException |
|
1044 | - * @throws ReflectionException |
|
1045 | - * @throws InvalidDataTypeException |
|
1046 | - * @throws InvalidInterfaceException |
|
1047 | - */ |
|
1048 | - public static function send_message_with_messenger_only( |
|
1049 | - $messenger, |
|
1050 | - $message_type, |
|
1051 | - EE_Messages_Queue $queue, |
|
1052 | - $custom_subject = '' |
|
1053 | - ) { |
|
1054 | - self::_load_controller(); |
|
1055 | - /** @type EE_Message_To_Generate_From_Queue $message_to_generate */ |
|
1056 | - $message_to_generate = EE_Registry::instance()->load_lib( |
|
1057 | - 'Message_To_Generate_From_Queue', |
|
1058 | - array( |
|
1059 | - $messenger, |
|
1060 | - $message_type, |
|
1061 | - $queue, |
|
1062 | - $custom_subject, |
|
1063 | - ) |
|
1064 | - ); |
|
1065 | - return self::$_MSG_PROCESSOR->queue_for_sending($message_to_generate); |
|
1066 | - } |
|
1067 | - |
|
1068 | - |
|
1069 | - /** |
|
1070 | - * Generates Messages immediately for EE_Message IDs (but only for the correct status for generation) |
|
1071 | - * |
|
1072 | - * @since 4.9.0 |
|
1073 | - * @param array $message_ids An array of message ids |
|
1074 | - * @return bool|EE_Messages_Queue false if nothing was generated, EE_Messages_Queue containing generated |
|
1075 | - * messages. |
|
1076 | - * @throws EE_Error |
|
1077 | - * @throws InvalidArgumentException |
|
1078 | - * @throws InvalidDataTypeException |
|
1079 | - * @throws InvalidInterfaceException |
|
1080 | - * @throws ReflectionException |
|
1081 | - */ |
|
1082 | - public static function generate_now($message_ids) |
|
1083 | - { |
|
1084 | - self::_load_controller(); |
|
1085 | - $messages = EEM_Message::instance()->get_all( |
|
1086 | - array( |
|
1087 | - 0 => array( |
|
1088 | - 'MSG_ID' => array('IN', $message_ids), |
|
1089 | - 'STS_ID' => EEM_Message::status_incomplete, |
|
1090 | - ), |
|
1091 | - ) |
|
1092 | - ); |
|
1093 | - $generated_queue = false; |
|
1094 | - if ($messages) { |
|
1095 | - $generated_queue = self::$_MSG_PROCESSOR->batch_generate_from_queue($messages); |
|
1096 | - } |
|
1097 | - |
|
1098 | - if (! $generated_queue instanceof EE_Messages_Queue) { |
|
1099 | - EE_Error::add_error( |
|
1100 | - __( |
|
1101 | - '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.', |
|
1102 | - 'event_espresso' |
|
1103 | - ), |
|
1104 | - __FILE__, |
|
1105 | - __FUNCTION__, |
|
1106 | - __LINE__ |
|
1107 | - ); |
|
1108 | - } |
|
1109 | - return $generated_queue; |
|
1110 | - } |
|
1111 | - |
|
1112 | - |
|
1113 | - /** |
|
1114 | - * Sends messages immediately for the incoming message_ids that have the status of EEM_Message::status_resend or, |
|
1115 | - * EEM_Message::status_idle |
|
1116 | - * |
|
1117 | - * @since 4.9.0 |
|
1118 | - * @param $message_ids |
|
1119 | - * @return bool|EE_Messages_Queue false if no messages sent. |
|
1120 | - * @throws EE_Error |
|
1121 | - * @throws InvalidArgumentException |
|
1122 | - * @throws InvalidDataTypeException |
|
1123 | - * @throws InvalidInterfaceException |
|
1124 | - * @throws ReflectionException |
|
1125 | - */ |
|
1126 | - public static function send_now($message_ids) |
|
1127 | - { |
|
1128 | - self::_load_controller(); |
|
1129 | - $messages = EEM_Message::instance()->get_all( |
|
1130 | - array( |
|
1131 | - 0 => array( |
|
1132 | - 'MSG_ID' => array('IN', $message_ids), |
|
1133 | - 'STS_ID' => array( |
|
1134 | - 'IN', |
|
1135 | - array(EEM_Message::status_idle, EEM_Message::status_resend, EEM_Message::status_retry), |
|
1136 | - ), |
|
1137 | - ), |
|
1138 | - ) |
|
1139 | - ); |
|
1140 | - $sent_queue = false; |
|
1141 | - if ($messages) { |
|
1142 | - $sent_queue = self::$_MSG_PROCESSOR->batch_send_from_queue($messages); |
|
1143 | - } |
|
1144 | - |
|
1145 | - if (! $sent_queue instanceof EE_Messages_Queue) { |
|
1146 | - EE_Error::add_error( |
|
1147 | - __( |
|
1148 | - '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.', |
|
1149 | - 'event_espresso' |
|
1150 | - ), |
|
1151 | - __FILE__, |
|
1152 | - __FUNCTION__, |
|
1153 | - __LINE__ |
|
1154 | - ); |
|
1155 | - } else { |
|
1156 | - // can count how many sent by using the messages in the queue |
|
1157 | - $sent_count = $sent_queue->count_STS_in_queue(EEM_Message::instance()->stati_indicating_sent()); |
|
1158 | - if ($sent_count > 0) { |
|
1159 | - EE_Error::add_success( |
|
1160 | - sprintf( |
|
1161 | - _n( |
|
1162 | - 'There was %d message successfully sent.', |
|
1163 | - 'There were %d messages successfully sent.', |
|
1164 | - $sent_count, |
|
1165 | - 'event_espresso' |
|
1166 | - ), |
|
1167 | - $sent_count |
|
1168 | - ) |
|
1169 | - ); |
|
1170 | - } else { |
|
1171 | - EE_Error::overwrite_errors(); |
|
1172 | - EE_Error::add_error( |
|
1173 | - __( |
|
1174 | - '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. |
|
259 | + exit; |
|
260 | + } |
|
261 | + } |
|
262 | + return; |
|
263 | + } |
|
264 | + |
|
265 | + |
|
266 | + /** |
|
267 | + * This runs when the msg_url_trigger route has initiated. |
|
268 | + * |
|
269 | + * @since 4.5.0 |
|
270 | + * @param WP $WP |
|
271 | + * @throws EE_Error |
|
272 | + * @throws InvalidArgumentException |
|
273 | + * @throws ReflectionException |
|
274 | + * @throws InvalidDataTypeException |
|
275 | + * @throws InvalidInterfaceException |
|
276 | + */ |
|
277 | + public function run($WP) |
|
278 | + { |
|
279 | + // ensure controller is loaded |
|
280 | + self::_load_controller(); |
|
281 | + // attempt to process message |
|
282 | + try { |
|
283 | + /** @type EE_Message_To_Generate_From_Request $message_to_generate */ |
|
284 | + $message_to_generate = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request'); |
|
285 | + self::$_MSG_PROCESSOR->generate_and_send_now($message_to_generate); |
|
286 | + } catch (EE_Error $e) { |
|
287 | + $error_msg = __( |
|
288 | + 'Please note that a system message failed to send due to a technical issue.', |
|
289 | + 'event_espresso' |
|
290 | + ); |
|
291 | + // add specific message for developers if WP_DEBUG in on |
|
292 | + $error_msg .= '||' . $e->getMessage(); |
|
293 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
294 | + } |
|
295 | + } |
|
296 | + |
|
297 | + |
|
298 | + /** |
|
299 | + * This is triggered by the 'msg_cron_trigger' route. |
|
300 | + * |
|
301 | + * @param WP $WP |
|
302 | + */ |
|
303 | + public function execute_batch_request($WP) |
|
304 | + { |
|
305 | + $this->run_cron(); |
|
306 | + header('HTTP/1.1 200 OK'); |
|
307 | + exit(); |
|
308 | + } |
|
309 | + |
|
310 | + |
|
311 | + /** |
|
312 | + * This gets executed on wp_cron jobs or when a batch request is initiated on its own separate non regular wp |
|
313 | + * request. |
|
314 | + */ |
|
315 | + public function run_cron() |
|
316 | + { |
|
317 | + self::_load_controller(); |
|
318 | + // get required vars |
|
319 | + $cron_type = EE_Registry::instance()->REQ->get('type'); |
|
320 | + $transient_key = EE_Registry::instance()->REQ->get('key'); |
|
321 | + |
|
322 | + // now let's verify transient, if not valid exit immediately |
|
323 | + if (! get_transient($transient_key)) { |
|
324 | + /** |
|
325 | + * trigger error so this gets in the error logs. This is important because it happens on a non-user |
|
326 | + * request. |
|
327 | + */ |
|
328 | + trigger_error(esc_attr__('Invalid Request (Transient does not exist)', 'event_espresso')); |
|
329 | + } |
|
330 | + |
|
331 | + // if made it here, lets' delete the transient to keep the db clean |
|
332 | + delete_transient($transient_key); |
|
333 | + |
|
334 | + if (apply_filters('FHEE__EED_Messages__run_cron__use_wp_cron', true)) { |
|
335 | + $method = 'batch_' . $cron_type . '_from_queue'; |
|
336 | + if (method_exists(self::$_MSG_PROCESSOR, $method)) { |
|
337 | + self::$_MSG_PROCESSOR->$method(); |
|
338 | + } else { |
|
339 | + // no matching task |
|
340 | + /** |
|
341 | + * trigger error so this gets in the error logs. This is important because it happens on a non user |
|
342 | + * request. |
|
343 | + */ |
|
344 | + trigger_error( |
|
345 | + esc_attr( |
|
346 | + sprintf( |
|
347 | + __('There is no task corresponding to this route %s', 'event_espresso'), |
|
348 | + $cron_type |
|
349 | + ) |
|
350 | + ) |
|
351 | + ); |
|
352 | + } |
|
353 | + } |
|
354 | + |
|
355 | + do_action('FHEE__EED_Messages__run_cron__end'); |
|
356 | + } |
|
357 | + |
|
358 | + |
|
359 | + /** |
|
360 | + * This is used to retrieve the template pack for the given name. |
|
361 | + * Retrieved packs are cached on the static $_TMP_PACKS array. If there is no class matching the given name then |
|
362 | + * the default template pack is returned. |
|
363 | + * |
|
364 | + * @deprecated 4.9.0 @see EEH_MSG_Template::get_template_pack() |
|
365 | + * @param string $template_pack_name This should correspond to the dbref of the template pack (which is also used |
|
366 | + * in generating the Pack class name). |
|
367 | + * @return EE_Messages_Template_Pack |
|
368 | + * @throws EE_Error |
|
369 | + * @throws InvalidArgumentException |
|
370 | + * @throws ReflectionException |
|
371 | + * @throws InvalidDataTypeException |
|
372 | + * @throws InvalidInterfaceException |
|
373 | + */ |
|
374 | + public static function get_template_pack($template_pack_name) |
|
375 | + { |
|
376 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
377 | + return EEH_MSG_Template::get_template_pack($template_pack_name); |
|
378 | + } |
|
379 | + |
|
380 | + |
|
381 | + /** |
|
382 | + * Retrieves an array of all template packs. |
|
383 | + * Array is in the format array( 'dbref' => EE_Messages_Template_Pack ) |
|
384 | + * |
|
385 | + * @deprecated 4.9.0 @see EEH_MSG_Template_Pack::get_template_pack_collection |
|
386 | + * @return EE_Messages_Template_Pack[] |
|
387 | + * @throws EE_Error |
|
388 | + * @throws InvalidArgumentException |
|
389 | + * @throws ReflectionException |
|
390 | + * @throws InvalidDataTypeException |
|
391 | + * @throws InvalidInterfaceException |
|
392 | + */ |
|
393 | + public static function get_template_packs() |
|
394 | + { |
|
395 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
396 | + |
|
397 | + // for backward compat, let's make sure this returns in the same format as originally. |
|
398 | + $template_pack_collection = EEH_MSG_Template::get_template_pack_collection(); |
|
399 | + $template_pack_collection->rewind(); |
|
400 | + $template_packs = array(); |
|
401 | + while ($template_pack_collection->valid()) { |
|
402 | + $template_packs[ $template_pack_collection->current()->dbref ] = $template_pack_collection->current(); |
|
403 | + $template_pack_collection->next(); |
|
404 | + } |
|
405 | + return $template_packs; |
|
406 | + } |
|
407 | + |
|
408 | + |
|
409 | + /** |
|
410 | + * This simply makes sure the autoloaders are registered for the EE_messages system. |
|
411 | + * |
|
412 | + * @since 4.5.0 |
|
413 | + * @return void |
|
414 | + * @throws EE_Error |
|
415 | + */ |
|
416 | + public static function set_autoloaders() |
|
417 | + { |
|
418 | + if (empty(self::$_MSG_PATHS)) { |
|
419 | + self::_set_messages_paths(); |
|
420 | + foreach (self::$_MSG_PATHS as $path) { |
|
421 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder($path); |
|
422 | + } |
|
423 | + // add aliases |
|
424 | + EEH_Autoloader::add_alias('EE_messages', 'EE_messages'); |
|
425 | + EEH_Autoloader::add_alias('EE_messenger', 'EE_messenger'); |
|
426 | + } |
|
427 | + } |
|
428 | + |
|
429 | + |
|
430 | + /** |
|
431 | + * Take care of adding all the paths for the messages components to the $_MSG_PATHS property |
|
432 | + * for use by the Messages Autoloaders |
|
433 | + * |
|
434 | + * @since 4.5.0 |
|
435 | + * @return void. |
|
436 | + */ |
|
437 | + protected static function _set_messages_paths() |
|
438 | + { |
|
439 | + $dir_ref = array( |
|
440 | + 'messages/message_type', |
|
441 | + 'messages/messenger', |
|
442 | + 'messages/defaults', |
|
443 | + 'messages/defaults/email', |
|
444 | + 'messages/data_class', |
|
445 | + 'messages/validators', |
|
446 | + 'messages/validators/email', |
|
447 | + 'messages/validators/html', |
|
448 | + 'shortcodes', |
|
449 | + ); |
|
450 | + $paths = array(); |
|
451 | + foreach ($dir_ref as $index => $dir) { |
|
452 | + $paths[ $index ] = EE_LIBRARIES . $dir; |
|
453 | + } |
|
454 | + self::$_MSG_PATHS = apply_filters('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', $paths); |
|
455 | + } |
|
456 | + |
|
457 | + |
|
458 | + /** |
|
459 | + * Takes care of loading dependencies |
|
460 | + * |
|
461 | + * @since 4.5.0 |
|
462 | + * @return void |
|
463 | + * @throws EE_Error |
|
464 | + * @throws InvalidArgumentException |
|
465 | + * @throws ReflectionException |
|
466 | + * @throws InvalidDataTypeException |
|
467 | + * @throws InvalidInterfaceException |
|
468 | + */ |
|
469 | + protected static function _load_controller() |
|
470 | + { |
|
471 | + if (! self::$_MSG_PROCESSOR instanceof EE_Messages_Processor) { |
|
472 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
473 | + self::set_autoloaders(); |
|
474 | + self::$_EEMSG = EE_Registry::instance()->load_lib('messages'); |
|
475 | + self::$_MSG_PROCESSOR = EE_Registry::instance()->load_lib('Messages_Processor'); |
|
476 | + self::$_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
477 | + } |
|
478 | + } |
|
479 | + |
|
480 | + |
|
481 | + /** |
|
482 | + * @param EE_Transaction $transaction |
|
483 | + * @throws EE_Error |
|
484 | + * @throws InvalidArgumentException |
|
485 | + * @throws InvalidDataTypeException |
|
486 | + * @throws InvalidInterfaceException |
|
487 | + * @throws ReflectionException |
|
488 | + */ |
|
489 | + public static function payment_reminder(EE_Transaction $transaction) |
|
490 | + { |
|
491 | + self::_load_controller(); |
|
492 | + $data = array($transaction, null); |
|
493 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers('payment_reminder', $data); |
|
494 | + } |
|
495 | + |
|
496 | + |
|
497 | + /** |
|
498 | + * Any messages triggers for after successful gateway payments should go in here. |
|
499 | + * |
|
500 | + * @param EE_Transaction $transaction object |
|
501 | + * @param EE_Payment|null $payment object |
|
502 | + * @return void |
|
503 | + * @throws EE_Error |
|
504 | + * @throws InvalidArgumentException |
|
505 | + * @throws ReflectionException |
|
506 | + * @throws InvalidDataTypeException |
|
507 | + * @throws InvalidInterfaceException |
|
508 | + */ |
|
509 | + public static function payment(EE_Transaction $transaction, EE_Payment $payment = null) |
|
510 | + { |
|
511 | + // if there's no payment object, then we cannot do a payment type message! |
|
512 | + if (! $payment instanceof EE_Payment) { |
|
513 | + return; |
|
514 | + } |
|
515 | + self::_load_controller(); |
|
516 | + $data = array($transaction, $payment); |
|
517 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
518 | + $message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID()); |
|
519 | + // if payment amount is less than 0 then switch to payment_refund message type. |
|
520 | + $message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type; |
|
521 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data); |
|
522 | + } |
|
523 | + |
|
524 | + |
|
525 | + /** |
|
526 | + * @param EE_Transaction $transaction |
|
527 | + * @throws EE_Error |
|
528 | + * @throws InvalidArgumentException |
|
529 | + * @throws InvalidDataTypeException |
|
530 | + * @throws InvalidInterfaceException |
|
531 | + * @throws ReflectionException |
|
532 | + */ |
|
533 | + public static function cancelled_registration(EE_Transaction $transaction) |
|
534 | + { |
|
535 | + self::_load_controller(); |
|
536 | + $data = array($transaction, null); |
|
537 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers('cancelled_registration', $data); |
|
538 | + } |
|
539 | + |
|
540 | + |
|
541 | + /** |
|
542 | + * Trigger for Registration messages |
|
543 | + * Note that what registration message type is sent depends on what the reg status is for the registrations on the |
|
544 | + * incoming transaction. |
|
545 | + * |
|
546 | + * @param EE_Registration $registration |
|
547 | + * @param array $extra_details |
|
548 | + * @return void |
|
549 | + * @throws EE_Error |
|
550 | + * @throws InvalidArgumentException |
|
551 | + * @throws InvalidDataTypeException |
|
552 | + * @throws InvalidInterfaceException |
|
553 | + * @throws ReflectionException |
|
554 | + * @throws EntityNotFoundException |
|
555 | + */ |
|
556 | + public static function maybe_registration(EE_Registration $registration, $extra_details = array()) |
|
557 | + { |
|
558 | + |
|
559 | + if (! self::_verify_registration_notification_send($registration, $extra_details)) { |
|
560 | + // no messages please |
|
561 | + return; |
|
562 | + } |
|
563 | + |
|
564 | + // get all non-trashed registrations so we make sure we send messages for the right status. |
|
565 | + $all_registrations = $registration->transaction()->registrations( |
|
566 | + array( |
|
567 | + array('REG_deleted' => false), |
|
568 | + 'order_by' => array( |
|
569 | + 'Event.EVT_name' => 'ASC', |
|
570 | + 'Attendee.ATT_lname' => 'ASC', |
|
571 | + 'Attendee.ATT_fname' => 'ASC', |
|
572 | + ), |
|
573 | + ) |
|
574 | + ); |
|
575 | + // cached array of statuses so we only trigger messages once per status. |
|
576 | + $statuses_sent = array(); |
|
577 | + self::_load_controller(); |
|
578 | + $mtgs = array(); |
|
579 | + |
|
580 | + // loop through registrations and trigger messages once per status. |
|
581 | + foreach ($all_registrations as $reg) { |
|
582 | + // already triggered? |
|
583 | + if (in_array($reg->status_ID(), $statuses_sent)) { |
|
584 | + continue; |
|
585 | + } |
|
586 | + |
|
587 | + $message_type = EEH_MSG_Template::convert_reg_status_to_message_type($reg->status_ID()); |
|
588 | + $mtgs = array_merge( |
|
589 | + $mtgs, |
|
590 | + self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers( |
|
591 | + $message_type, |
|
592 | + array($registration->transaction(), null, $reg->status_ID()) |
|
593 | + ) |
|
594 | + ); |
|
595 | + $statuses_sent[] = $reg->status_ID(); |
|
596 | + } |
|
597 | + |
|
598 | + if (count($statuses_sent) > 1) { |
|
599 | + $mtgs = array_merge( |
|
600 | + $mtgs, |
|
601 | + self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers( |
|
602 | + 'registration_summary', |
|
603 | + array($registration->transaction(), null) |
|
604 | + ) |
|
605 | + ); |
|
606 | + } |
|
607 | + |
|
608 | + // batch queue and initiate request |
|
609 | + self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($mtgs); |
|
610 | + self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority(); |
|
611 | + } |
|
612 | + |
|
613 | + |
|
614 | + /** |
|
615 | + * This is a helper method used to very whether a registration notification should be sent or |
|
616 | + * not. Prevents duplicate notifications going out for registration context notifications. |
|
617 | + * |
|
618 | + * @param EE_Registration $registration [description] |
|
619 | + * @param array $extra_details [description] |
|
620 | + * @return bool true = send away, false = nope halt the presses. |
|
621 | + */ |
|
622 | + protected static function _verify_registration_notification_send( |
|
623 | + EE_Registration $registration, |
|
624 | + $extra_details = array() |
|
625 | + ) { |
|
626 | + if (! $registration->is_primary_registrant()) { |
|
627 | + return false; |
|
628 | + } |
|
629 | + // first we check if we're in admin and not doing front ajax |
|
630 | + if (is_admin() && ! EE_FRONT_AJAX) { |
|
631 | + // make sure appropriate admin params are set for sending messages |
|
632 | + if (empty($_REQUEST['txn_reg_status_change']['send_notifications']) |
|
633 | + || ! absint($_REQUEST['txn_reg_status_change']['send_notifications']) |
|
634 | + ) { |
|
635 | + // no messages sent please. |
|
636 | + return false; |
|
637 | + } |
|
638 | + } else { |
|
639 | + // frontend request (either regular or via AJAX) |
|
640 | + // TXN is NOT finalized ? |
|
641 | + if (! isset($extra_details['finalized']) || $extra_details['finalized'] === false) { |
|
642 | + return false; |
|
643 | + } |
|
644 | + // return visit but nothing changed ??? |
|
645 | + if (isset($extra_details['revisit'], $extra_details['status_updates']) && |
|
646 | + $extra_details['revisit'] && ! $extra_details['status_updates'] |
|
647 | + ) { |
|
648 | + return false; |
|
649 | + } |
|
650 | + // NOT sending messages && reg status is something other than "Not-Approved" |
|
651 | + if (! apply_filters('FHEE__EED_Messages___maybe_registration__deliver_notifications', false) && |
|
652 | + $registration->status_ID() !== EEM_Registration::status_id_not_approved |
|
653 | + ) { |
|
654 | + return false; |
|
655 | + } |
|
656 | + } |
|
657 | + // release the kraken |
|
658 | + return true; |
|
659 | + } |
|
660 | + |
|
661 | + |
|
662 | + /** |
|
663 | + * Simply returns an array indexed by Registration Status ID and the related message_type name associated with that |
|
664 | + * status id. |
|
665 | + * |
|
666 | + * @deprecated 4.9.0 Use EEH_MSG_Template::reg_status_to_message_type_array() |
|
667 | + * or EEH_MSG_Template::convert_reg_status_to_message_type |
|
668 | + * @param string $reg_status |
|
669 | + * @return array |
|
670 | + * @throws EE_Error |
|
671 | + * @throws InvalidArgumentException |
|
672 | + * @throws ReflectionException |
|
673 | + * @throws InvalidDataTypeException |
|
674 | + * @throws InvalidInterfaceException |
|
675 | + */ |
|
676 | + protected static function _get_reg_status_array($reg_status = '') |
|
677 | + { |
|
678 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
679 | + return EEH_MSG_Template::convert_reg_status_to_message_type($reg_status) |
|
680 | + ? EEH_MSG_Template::convert_reg_status_to_message_type($reg_status) |
|
681 | + : EEH_MSG_Template::reg_status_to_message_type_array(); |
|
682 | + } |
|
683 | + |
|
684 | + |
|
685 | + /** |
|
686 | + * Simply returns the payment message type for the given payment status. |
|
687 | + * |
|
688 | + * @deprecated 4.9.0 Use EEH_MSG_Template::payment_status_to_message_type_array |
|
689 | + * or EEH_MSG_Template::convert_payment_status_to_message_type |
|
690 | + * @param string $payment_status The payment status being matched. |
|
691 | + * @return bool|string The payment message type slug matching the status or false if no match. |
|
692 | + * @throws EE_Error |
|
693 | + * @throws InvalidArgumentException |
|
694 | + * @throws ReflectionException |
|
695 | + * @throws InvalidDataTypeException |
|
696 | + * @throws InvalidInterfaceException |
|
697 | + */ |
|
698 | + protected static function _get_payment_message_type($payment_status) |
|
699 | + { |
|
700 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
701 | + return EEH_MSG_Template::convert_payment_status_to_message_type($payment_status) |
|
702 | + ? EEH_MSG_Template::convert_payment_status_to_message_type($payment_status) |
|
703 | + : false; |
|
704 | + } |
|
705 | + |
|
706 | + |
|
707 | + /** |
|
708 | + * Message triggers for a resending already sent message(s) (via EE_Message list table) |
|
709 | + * |
|
710 | + * @access public |
|
711 | + * @param array $req_data This is the $_POST & $_GET data sent from EE_Admin Pages |
|
712 | + * @return bool success/fail |
|
713 | + * @throws EE_Error |
|
714 | + * @throws InvalidArgumentException |
|
715 | + * @throws InvalidDataTypeException |
|
716 | + * @throws InvalidInterfaceException |
|
717 | + * @throws ReflectionException |
|
718 | + */ |
|
719 | + public static function process_resend($req_data) |
|
720 | + { |
|
721 | + self::_load_controller(); |
|
722 | + |
|
723 | + // if $msgID in this request then skip to the new resend_message |
|
724 | + if (EE_Registry::instance()->REQ->get('MSG_ID')) { |
|
725 | + return self::resend_message(); |
|
726 | + } |
|
727 | + |
|
728 | + // make sure any incoming request data is set on the REQ so that it gets picked up later. |
|
729 | + $req_data = (array) $req_data; |
|
730 | + foreach ($req_data as $request_key => $request_value) { |
|
731 | + EE_Registry::instance()->REQ->set($request_key, $request_value); |
|
732 | + } |
|
733 | + |
|
734 | + if (! $messages_to_send = self::$_MSG_PROCESSOR->setup_messages_to_generate_from_registration_ids_in_request( |
|
735 | + )) { |
|
736 | + return false; |
|
737 | + } |
|
738 | + |
|
739 | + try { |
|
740 | + self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($messages_to_send); |
|
741 | + self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority(); |
|
742 | + } catch (EE_Error $e) { |
|
743 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
744 | + return false; |
|
745 | + } |
|
746 | + EE_Error::add_success( |
|
747 | + __('Messages have been successfully queued for generation and sending.', 'event_espresso') |
|
748 | + ); |
|
749 | + return true; // everything got queued. |
|
750 | + } |
|
751 | + |
|
752 | + |
|
753 | + /** |
|
754 | + * Message triggers for a resending already sent message(s) (via EE_Message list table) |
|
755 | + * |
|
756 | + * @return bool |
|
757 | + * @throws EE_Error |
|
758 | + * @throws InvalidArgumentException |
|
759 | + * @throws InvalidDataTypeException |
|
760 | + * @throws InvalidInterfaceException |
|
761 | + * @throws ReflectionException |
|
762 | + */ |
|
763 | + public static function resend_message() |
|
764 | + { |
|
765 | + self::_load_controller(); |
|
766 | + |
|
767 | + $msgID = EE_Registry::instance()->REQ->get('MSG_ID'); |
|
768 | + if (! $msgID) { |
|
769 | + EE_Error::add_error( |
|
770 | + __( |
|
771 | + 'Something went wrong because there is no "MSG_ID" value in the request', |
|
772 | + 'event_espresso' |
|
773 | + ), |
|
774 | + __FILE__, |
|
775 | + __FUNCTION__, |
|
776 | + __LINE__ |
|
777 | + ); |
|
778 | + return false; |
|
779 | + } |
|
780 | + |
|
781 | + self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send((array) $msgID); |
|
782 | + |
|
783 | + // setup success message. |
|
784 | + $count_ready_for_resend = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend); |
|
785 | + EE_Error::add_success( |
|
786 | + sprintf( |
|
787 | + _n( |
|
788 | + 'There was %d message queued for resending.', |
|
789 | + 'There were %d messages queued for resending.', |
|
790 | + $count_ready_for_resend, |
|
791 | + 'event_espresso' |
|
792 | + ), |
|
793 | + $count_ready_for_resend |
|
794 | + ) |
|
795 | + ); |
|
796 | + return true; |
|
797 | + } |
|
798 | + |
|
799 | + |
|
800 | + /** |
|
801 | + * Message triggers for manual payment applied by admin |
|
802 | + * |
|
803 | + * @param EE_Payment $payment EE_payment object |
|
804 | + * @return bool success/fail |
|
805 | + * @throws EE_Error |
|
806 | + * @throws InvalidArgumentException |
|
807 | + * @throws ReflectionException |
|
808 | + * @throws InvalidDataTypeException |
|
809 | + * @throws InvalidInterfaceException |
|
810 | + */ |
|
811 | + public static function process_admin_payment(EE_Payment $payment) |
|
812 | + { |
|
813 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
814 | + // we need to get the transaction object |
|
815 | + $transaction = $payment->transaction(); |
|
816 | + if ($transaction instanceof EE_Transaction) { |
|
817 | + $data = array($transaction, $payment); |
|
818 | + $message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID()); |
|
819 | + |
|
820 | + // if payment amount is less than 0 then switch to payment_refund message type. |
|
821 | + $message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type; |
|
822 | + |
|
823 | + // if payment_refund is selected, but the status is NOT accepted. Then change message type to false so NO message notification goes out. |
|
824 | + $message_type = $message_type == 'payment_refund' && $payment->STS_ID() != EEM_Payment::status_id_approved |
|
825 | + ? false : $message_type; |
|
826 | + |
|
827 | + self::_load_controller(); |
|
828 | + |
|
829 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data); |
|
830 | + |
|
831 | + // get count of queued for generation |
|
832 | + $count_to_generate = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue( |
|
833 | + array( |
|
834 | + EEM_Message::status_incomplete, |
|
835 | + EEM_Message::status_idle, |
|
836 | + ) |
|
837 | + ); |
|
838 | + |
|
839 | + if ($count_to_generate > 0 && self::$_MSG_PROCESSOR->get_queue()->get_message_repository()->count() !== 0) { |
|
840 | + add_filter('FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true'); |
|
841 | + return true; |
|
842 | + } else { |
|
843 | + $count_failed = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue( |
|
844 | + EEM_Message::instance()->stati_indicating_failed_sending() |
|
845 | + ); |
|
846 | + /** |
|
847 | + * Verify that there are actually errors. If not then we return a success message because the queue might have been emptied due to successful |
|
848 | + * IMMEDIATE generation. |
|
849 | + */ |
|
850 | + if ($count_failed > 0) { |
|
851 | + EE_Error::add_error( |
|
852 | + sprintf( |
|
853 | + _n( |
|
854 | + 'The payment notification generation failed.', |
|
855 | + '%d payment notifications failed being sent.', |
|
856 | + $count_failed, |
|
857 | + 'event_espresso' |
|
858 | + ), |
|
859 | + $count_failed |
|
860 | + ), |
|
861 | + __FILE__, |
|
862 | + __FUNCTION__, |
|
863 | + __LINE__ |
|
864 | + ); |
|
865 | + |
|
866 | + return false; |
|
867 | + } else { |
|
868 | + add_filter('FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true'); |
|
869 | + return true; |
|
870 | + } |
|
871 | + } |
|
872 | + } else { |
|
873 | + EE_Error::add_error( |
|
874 | + 'Unable to generate the payment notification because the given value for the transaction is invalid.', |
|
875 | + 'event_espresso' |
|
876 | + ); |
|
877 | + return false; |
|
878 | + } |
|
879 | + } |
|
880 | + |
|
881 | + |
|
882 | + /** |
|
883 | + * Callback for AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send_with_registrations trigger |
|
884 | + * |
|
885 | + * @since 4.3.0 |
|
886 | + * @param EE_Registration[] $registrations an array of EE_Registration objects |
|
887 | + * @param int $grp_id a specific message template group id. |
|
888 | + * @return void |
|
889 | + * @throws EE_Error |
|
890 | + * @throws InvalidArgumentException |
|
891 | + * @throws InvalidDataTypeException |
|
892 | + * @throws InvalidInterfaceException |
|
893 | + * @throws ReflectionException |
|
894 | + */ |
|
895 | + public static function send_newsletter_message($registrations, $grp_id) |
|
896 | + { |
|
897 | + // make sure mtp is id and set it in the EE_Request Handler later messages setup. |
|
898 | + EE_Registry::instance()->REQ->set('GRP_ID', (int) $grp_id); |
|
899 | + self::_load_controller(); |
|
900 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers('newsletter', $registrations); |
|
901 | + } |
|
902 | + |
|
903 | + |
|
904 | + /** |
|
905 | + * Callback for FHEE__EE_Registration__invoice_url__invoice_url or FHEE__EE_Registration__receipt_url__receipt_url |
|
906 | + * |
|
907 | + * @since 4.3.0 |
|
908 | + * @param string $registration_message_trigger_url |
|
909 | + * @param EE_Registration $registration |
|
910 | + * @param string $messenger |
|
911 | + * @param string $message_type |
|
912 | + * @return string |
|
913 | + * @throws EE_Error |
|
914 | + * @throws InvalidArgumentException |
|
915 | + * @throws InvalidDataTypeException |
|
916 | + * @throws InvalidInterfaceException |
|
917 | + */ |
|
918 | + public static function registration_message_trigger_url( |
|
919 | + $registration_message_trigger_url, |
|
920 | + EE_Registration $registration, |
|
921 | + $messenger = 'html', |
|
922 | + $message_type = 'invoice' |
|
923 | + ) { |
|
924 | + // whitelist $messenger |
|
925 | + switch ($messenger) { |
|
926 | + case 'pdf': |
|
927 | + $sending_messenger = 'pdf'; |
|
928 | + $generating_messenger = 'html'; |
|
929 | + break; |
|
930 | + case 'html': |
|
931 | + default: |
|
932 | + $sending_messenger = 'html'; |
|
933 | + $generating_messenger = 'html'; |
|
934 | + break; |
|
935 | + } |
|
936 | + // whitelist $message_type |
|
937 | + switch ($message_type) { |
|
938 | + case 'receipt': |
|
939 | + $message_type = 'receipt'; |
|
940 | + break; |
|
941 | + case 'invoice': |
|
942 | + default: |
|
943 | + $message_type = 'invoice'; |
|
944 | + break; |
|
945 | + } |
|
946 | + // verify that both the messenger AND the message type are active |
|
947 | + if (EEH_MSG_Template::is_messenger_active($sending_messenger) |
|
948 | + && EEH_MSG_Template::is_mt_active($message_type) |
|
949 | + ) { |
|
950 | + // 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?) |
|
951 | + $template_query_params = array( |
|
952 | + 'MTP_is_active' => true, |
|
953 | + 'MTP_messenger' => $generating_messenger, |
|
954 | + 'MTP_message_type' => $message_type, |
|
955 | + 'Event.EVT_ID' => $registration->event_ID(), |
|
956 | + ); |
|
957 | + // get the message template group. |
|
958 | + $msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params)); |
|
959 | + // if we don't have an EE_Message_Template_Group then return |
|
960 | + if (! $msg_template_group instanceof EE_Message_Template_Group) { |
|
961 | + // remove EVT_ID from query params so that global templates get picked up |
|
962 | + unset($template_query_params['Event.EVT_ID']); |
|
963 | + // get global template as the fallback |
|
964 | + $msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params)); |
|
965 | + } |
|
966 | + // if we don't have an EE_Message_Template_Group then return |
|
967 | + if (! $msg_template_group instanceof EE_Message_Template_Group) { |
|
968 | + return ''; |
|
969 | + } |
|
970 | + // generate the URL |
|
971 | + $registration_message_trigger_url = EEH_MSG_Template::generate_url_trigger( |
|
972 | + $sending_messenger, |
|
973 | + $generating_messenger, |
|
974 | + 'purchaser', |
|
975 | + $message_type, |
|
976 | + $registration, |
|
977 | + $msg_template_group->ID(), |
|
978 | + $registration->transaction_ID() |
|
979 | + ); |
|
980 | + } |
|
981 | + return $registration_message_trigger_url; |
|
982 | + } |
|
983 | + |
|
984 | + |
|
985 | + /** |
|
986 | + * Use to generate and return a message preview! |
|
987 | + * |
|
988 | + * @param string $type This should correspond with a valid message type |
|
989 | + * @param string $context This should correspond with a valid context for the message type |
|
990 | + * @param string $messenger This should correspond with a valid messenger. |
|
991 | + * @param bool $send true we will do a test send using the messenger delivery, false we just do a regular |
|
992 | + * preview |
|
993 | + * @return bool|string The body of the message or if send is requested, sends. |
|
994 | + * @throws EE_Error |
|
995 | + * @throws InvalidArgumentException |
|
996 | + * @throws InvalidDataTypeException |
|
997 | + * @throws InvalidInterfaceException |
|
998 | + * @throws ReflectionException |
|
999 | + */ |
|
1000 | + public static function preview_message($type, $context, $messenger, $send = false) |
|
1001 | + { |
|
1002 | + self::_load_controller(); |
|
1003 | + $mtg = new EE_Message_To_Generate( |
|
1004 | + $messenger, |
|
1005 | + $type, |
|
1006 | + array(), |
|
1007 | + $context, |
|
1008 | + true |
|
1009 | + ); |
|
1010 | + $generated_preview_queue = self::$_MSG_PROCESSOR->generate_for_preview($mtg, $send); |
|
1011 | + if ($generated_preview_queue instanceof EE_Messages_Queue) { |
|
1012 | + // loop through all content for the preview and remove any persisted records. |
|
1013 | + $content = ''; |
|
1014 | + foreach ($generated_preview_queue->get_message_repository() as $message) { |
|
1015 | + $content = $message->content(); |
|
1016 | + if ($message->ID() > 0 && $message->STS_ID() !== EEM_Message::status_failed) { |
|
1017 | + $message->delete(); |
|
1018 | + } |
|
1019 | + } |
|
1020 | + return $content; |
|
1021 | + } else { |
|
1022 | + return $generated_preview_queue; |
|
1023 | + } |
|
1024 | + } |
|
1025 | + |
|
1026 | + |
|
1027 | + /** |
|
1028 | + * This is a method that allows for sending a message using a messenger matching the string given and the provided |
|
1029 | + * EE_Message_Queue object. The EE_Message_Queue object is used to create a single aggregate EE_Message via the |
|
1030 | + * content found in the EE_Message objects in the queue. |
|
1031 | + * |
|
1032 | + * @since 4.9.0 |
|
1033 | + * @param string $messenger a string matching a valid active messenger in the system |
|
1034 | + * @param string $message_type Although it seems contrary to the name of the method, a message |
|
1035 | + * type name is still required to send along the message type to the |
|
1036 | + * messenger because this is used for determining what specific |
|
1037 | + * variations might be loaded for the generated message. |
|
1038 | + * @param EE_Messages_Queue $queue |
|
1039 | + * @param string $custom_subject Can be used to set what the custom subject string will be on the |
|
1040 | + * aggregate EE_Message object. |
|
1041 | + * @return bool success or fail. |
|
1042 | + * @throws EE_Error |
|
1043 | + * @throws InvalidArgumentException |
|
1044 | + * @throws ReflectionException |
|
1045 | + * @throws InvalidDataTypeException |
|
1046 | + * @throws InvalidInterfaceException |
|
1047 | + */ |
|
1048 | + public static function send_message_with_messenger_only( |
|
1049 | + $messenger, |
|
1050 | + $message_type, |
|
1051 | + EE_Messages_Queue $queue, |
|
1052 | + $custom_subject = '' |
|
1053 | + ) { |
|
1054 | + self::_load_controller(); |
|
1055 | + /** @type EE_Message_To_Generate_From_Queue $message_to_generate */ |
|
1056 | + $message_to_generate = EE_Registry::instance()->load_lib( |
|
1057 | + 'Message_To_Generate_From_Queue', |
|
1058 | + array( |
|
1059 | + $messenger, |
|
1060 | + $message_type, |
|
1061 | + $queue, |
|
1062 | + $custom_subject, |
|
1063 | + ) |
|
1064 | + ); |
|
1065 | + return self::$_MSG_PROCESSOR->queue_for_sending($message_to_generate); |
|
1066 | + } |
|
1067 | + |
|
1068 | + |
|
1069 | + /** |
|
1070 | + * Generates Messages immediately for EE_Message IDs (but only for the correct status for generation) |
|
1071 | + * |
|
1072 | + * @since 4.9.0 |
|
1073 | + * @param array $message_ids An array of message ids |
|
1074 | + * @return bool|EE_Messages_Queue false if nothing was generated, EE_Messages_Queue containing generated |
|
1075 | + * messages. |
|
1076 | + * @throws EE_Error |
|
1077 | + * @throws InvalidArgumentException |
|
1078 | + * @throws InvalidDataTypeException |
|
1079 | + * @throws InvalidInterfaceException |
|
1080 | + * @throws ReflectionException |
|
1081 | + */ |
|
1082 | + public static function generate_now($message_ids) |
|
1083 | + { |
|
1084 | + self::_load_controller(); |
|
1085 | + $messages = EEM_Message::instance()->get_all( |
|
1086 | + array( |
|
1087 | + 0 => array( |
|
1088 | + 'MSG_ID' => array('IN', $message_ids), |
|
1089 | + 'STS_ID' => EEM_Message::status_incomplete, |
|
1090 | + ), |
|
1091 | + ) |
|
1092 | + ); |
|
1093 | + $generated_queue = false; |
|
1094 | + if ($messages) { |
|
1095 | + $generated_queue = self::$_MSG_PROCESSOR->batch_generate_from_queue($messages); |
|
1096 | + } |
|
1097 | + |
|
1098 | + if (! $generated_queue instanceof EE_Messages_Queue) { |
|
1099 | + EE_Error::add_error( |
|
1100 | + __( |
|
1101 | + '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.', |
|
1102 | + 'event_espresso' |
|
1103 | + ), |
|
1104 | + __FILE__, |
|
1105 | + __FUNCTION__, |
|
1106 | + __LINE__ |
|
1107 | + ); |
|
1108 | + } |
|
1109 | + return $generated_queue; |
|
1110 | + } |
|
1111 | + |
|
1112 | + |
|
1113 | + /** |
|
1114 | + * Sends messages immediately for the incoming message_ids that have the status of EEM_Message::status_resend or, |
|
1115 | + * EEM_Message::status_idle |
|
1116 | + * |
|
1117 | + * @since 4.9.0 |
|
1118 | + * @param $message_ids |
|
1119 | + * @return bool|EE_Messages_Queue false if no messages sent. |
|
1120 | + * @throws EE_Error |
|
1121 | + * @throws InvalidArgumentException |
|
1122 | + * @throws InvalidDataTypeException |
|
1123 | + * @throws InvalidInterfaceException |
|
1124 | + * @throws ReflectionException |
|
1125 | + */ |
|
1126 | + public static function send_now($message_ids) |
|
1127 | + { |
|
1128 | + self::_load_controller(); |
|
1129 | + $messages = EEM_Message::instance()->get_all( |
|
1130 | + array( |
|
1131 | + 0 => array( |
|
1132 | + 'MSG_ID' => array('IN', $message_ids), |
|
1133 | + 'STS_ID' => array( |
|
1134 | + 'IN', |
|
1135 | + array(EEM_Message::status_idle, EEM_Message::status_resend, EEM_Message::status_retry), |
|
1136 | + ), |
|
1137 | + ), |
|
1138 | + ) |
|
1139 | + ); |
|
1140 | + $sent_queue = false; |
|
1141 | + if ($messages) { |
|
1142 | + $sent_queue = self::$_MSG_PROCESSOR->batch_send_from_queue($messages); |
|
1143 | + } |
|
1144 | + |
|
1145 | + if (! $sent_queue instanceof EE_Messages_Queue) { |
|
1146 | + EE_Error::add_error( |
|
1147 | + __( |
|
1148 | + '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.', |
|
1149 | + 'event_espresso' |
|
1150 | + ), |
|
1151 | + __FILE__, |
|
1152 | + __FUNCTION__, |
|
1153 | + __LINE__ |
|
1154 | + ); |
|
1155 | + } else { |
|
1156 | + // can count how many sent by using the messages in the queue |
|
1157 | + $sent_count = $sent_queue->count_STS_in_queue(EEM_Message::instance()->stati_indicating_sent()); |
|
1158 | + if ($sent_count > 0) { |
|
1159 | + EE_Error::add_success( |
|
1160 | + sprintf( |
|
1161 | + _n( |
|
1162 | + 'There was %d message successfully sent.', |
|
1163 | + 'There were %d messages successfully sent.', |
|
1164 | + $sent_count, |
|
1165 | + 'event_espresso' |
|
1166 | + ), |
|
1167 | + $sent_count |
|
1168 | + ) |
|
1169 | + ); |
|
1170 | + } else { |
|
1171 | + EE_Error::overwrite_errors(); |
|
1172 | + EE_Error::add_error( |
|
1173 | + __( |
|
1174 | + '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. |
|
1175 | 1175 | If there was an error, you can look at the messages in the message activity list table for any error messages.', |
1176 | - 'event_espresso' |
|
1177 | - ), |
|
1178 | - __FILE__, |
|
1179 | - __FUNCTION__, |
|
1180 | - __LINE__ |
|
1181 | - ); |
|
1182 | - } |
|
1183 | - } |
|
1184 | - return $sent_queue; |
|
1185 | - } |
|
1186 | - |
|
1187 | - |
|
1188 | - /** |
|
1189 | - * Generate and send immediately from the given $message_ids |
|
1190 | - * |
|
1191 | - * @param array $message_ids EE_Message entity ids. |
|
1192 | - * @throws EE_Error |
|
1193 | - * @throws InvalidArgumentException |
|
1194 | - * @throws InvalidDataTypeException |
|
1195 | - * @throws InvalidInterfaceException |
|
1196 | - * @throws ReflectionException |
|
1197 | - */ |
|
1198 | - public static function generate_and_send_now(array $message_ids) |
|
1199 | - { |
|
1200 | - $generated_queue = self::generate_now($message_ids); |
|
1201 | - // now let's just trigger sending immediately from this queue. |
|
1202 | - $messages_sent = $generated_queue instanceof EE_Messages_Queue |
|
1203 | - ? $generated_queue->execute() |
|
1204 | - : 0; |
|
1205 | - if ($messages_sent) { |
|
1206 | - EE_Error::add_success( |
|
1207 | - esc_html( |
|
1208 | - sprintf( |
|
1209 | - _n( |
|
1210 | - 'There was %d message successfully generated and sent.', |
|
1211 | - 'There were %d messages successfully generated and sent.', |
|
1212 | - $messages_sent, |
|
1213 | - 'event_espresso' |
|
1214 | - ), |
|
1215 | - $messages_sent |
|
1216 | - ) |
|
1217 | - ) |
|
1218 | - ); |
|
1219 | - // errors would be added via the generate_now method. |
|
1220 | - } |
|
1221 | - } |
|
1222 | - |
|
1223 | - |
|
1224 | - /** |
|
1225 | - * This will queue the incoming message ids for resending. |
|
1226 | - * Note, only message_ids corresponding to messages with the status of EEM_Message::sent will be queued. |
|
1227 | - * |
|
1228 | - * @since 4.9.0 |
|
1229 | - * @param array $message_ids An array of EE_Message IDs |
|
1230 | - * @return bool true means messages were successfully queued for resending, false means none were queued for |
|
1231 | - * resending. |
|
1232 | - * @throws EE_Error |
|
1233 | - * @throws InvalidArgumentException |
|
1234 | - * @throws InvalidDataTypeException |
|
1235 | - * @throws InvalidInterfaceException |
|
1236 | - * @throws ReflectionException |
|
1237 | - */ |
|
1238 | - public static function queue_for_resending($message_ids) |
|
1239 | - { |
|
1240 | - self::_load_controller(); |
|
1241 | - self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send($message_ids); |
|
1242 | - |
|
1243 | - // get queue and count |
|
1244 | - $queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend); |
|
1245 | - |
|
1246 | - if ($queue_count > 0 |
|
1247 | - ) { |
|
1248 | - EE_Error::add_success( |
|
1249 | - sprintf( |
|
1250 | - _n( |
|
1251 | - '%d message successfully queued for resending.', |
|
1252 | - '%d messages successfully queued for resending.', |
|
1253 | - $queue_count, |
|
1254 | - 'event_espresso' |
|
1255 | - ), |
|
1256 | - $queue_count |
|
1257 | - ) |
|
1258 | - ); |
|
1259 | - /** |
|
1260 | - * @see filter usage in EE_Messages_Queue::initiate_request_by_priority |
|
1261 | - */ |
|
1262 | - } elseif (apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', true) |
|
1263 | - || EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request |
|
1264 | - ) { |
|
1265 | - $queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_sent); |
|
1266 | - if ($queue_count > 0) { |
|
1267 | - EE_Error::add_success( |
|
1268 | - sprintf( |
|
1269 | - _n( |
|
1270 | - '%d message successfully sent.', |
|
1271 | - '%d messages successfully sent.', |
|
1272 | - $queue_count, |
|
1273 | - 'event_espresso' |
|
1274 | - ), |
|
1275 | - $queue_count |
|
1276 | - ) |
|
1277 | - ); |
|
1278 | - } else { |
|
1279 | - EE_Error::add_error( |
|
1280 | - __( |
|
1281 | - '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.', |
|
1282 | - 'event_espresso' |
|
1283 | - ), |
|
1284 | - __FILE__, |
|
1285 | - __FUNCTION__, |
|
1286 | - __LINE__ |
|
1287 | - ); |
|
1288 | - } |
|
1289 | - } else { |
|
1290 | - EE_Error::add_error( |
|
1291 | - __( |
|
1292 | - '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.', |
|
1293 | - 'event_espresso' |
|
1294 | - ), |
|
1295 | - __FILE__, |
|
1296 | - __FUNCTION__, |
|
1297 | - __LINE__ |
|
1298 | - ); |
|
1299 | - } |
|
1300 | - return (bool) $queue_count; |
|
1301 | - } |
|
1302 | - |
|
1303 | - |
|
1304 | - /** |
|
1305 | - * debug |
|
1306 | - * |
|
1307 | - * @param string $class |
|
1308 | - * @param string $func |
|
1309 | - * @param string $line |
|
1310 | - * @param \EE_Transaction $transaction |
|
1311 | - * @param array $info |
|
1312 | - * @param bool $display_request |
|
1313 | - * @throws EE_Error |
|
1314 | - * @throws \EventEspresso\core\exceptions\InvalidSessionDataException |
|
1315 | - */ |
|
1316 | - protected static function log( |
|
1317 | - $class = '', |
|
1318 | - $func = '', |
|
1319 | - $line = '', |
|
1320 | - EE_Transaction $transaction, |
|
1321 | - $info = array(), |
|
1322 | - $display_request = false |
|
1323 | - ) { |
|
1324 | - if (defined('EE_DEBUG') && EE_DEBUG) { |
|
1325 | - if ($transaction instanceof EE_Transaction) { |
|
1326 | - // don't serialize objects |
|
1327 | - $info = EEH_Debug_Tools::strip_objects($info); |
|
1328 | - $info['TXN_status'] = $transaction->status_ID(); |
|
1329 | - $info['TXN_reg_steps'] = $transaction->reg_steps(); |
|
1330 | - if ($transaction->ID()) { |
|
1331 | - $index = 'EE_Transaction: ' . $transaction->ID(); |
|
1332 | - EEH_Debug_Tools::log($class, $func, $line, $info, $display_request, $index); |
|
1333 | - } |
|
1334 | - } |
|
1335 | - } |
|
1336 | - } |
|
1337 | - |
|
1338 | - |
|
1339 | - /** |
|
1340 | - * Resets all the static properties in this class when called. |
|
1341 | - */ |
|
1342 | - public static function reset() |
|
1343 | - { |
|
1344 | - self::$_EEMSG = null; |
|
1345 | - self::$_message_resource_manager = null; |
|
1346 | - self::$_MSG_PROCESSOR = null; |
|
1347 | - self::$_MSG_PATHS = null; |
|
1348 | - self::$_TMP_PACKS = array(); |
|
1349 | - } |
|
1176 | + 'event_espresso' |
|
1177 | + ), |
|
1178 | + __FILE__, |
|
1179 | + __FUNCTION__, |
|
1180 | + __LINE__ |
|
1181 | + ); |
|
1182 | + } |
|
1183 | + } |
|
1184 | + return $sent_queue; |
|
1185 | + } |
|
1186 | + |
|
1187 | + |
|
1188 | + /** |
|
1189 | + * Generate and send immediately from the given $message_ids |
|
1190 | + * |
|
1191 | + * @param array $message_ids EE_Message entity ids. |
|
1192 | + * @throws EE_Error |
|
1193 | + * @throws InvalidArgumentException |
|
1194 | + * @throws InvalidDataTypeException |
|
1195 | + * @throws InvalidInterfaceException |
|
1196 | + * @throws ReflectionException |
|
1197 | + */ |
|
1198 | + public static function generate_and_send_now(array $message_ids) |
|
1199 | + { |
|
1200 | + $generated_queue = self::generate_now($message_ids); |
|
1201 | + // now let's just trigger sending immediately from this queue. |
|
1202 | + $messages_sent = $generated_queue instanceof EE_Messages_Queue |
|
1203 | + ? $generated_queue->execute() |
|
1204 | + : 0; |
|
1205 | + if ($messages_sent) { |
|
1206 | + EE_Error::add_success( |
|
1207 | + esc_html( |
|
1208 | + sprintf( |
|
1209 | + _n( |
|
1210 | + 'There was %d message successfully generated and sent.', |
|
1211 | + 'There were %d messages successfully generated and sent.', |
|
1212 | + $messages_sent, |
|
1213 | + 'event_espresso' |
|
1214 | + ), |
|
1215 | + $messages_sent |
|
1216 | + ) |
|
1217 | + ) |
|
1218 | + ); |
|
1219 | + // errors would be added via the generate_now method. |
|
1220 | + } |
|
1221 | + } |
|
1222 | + |
|
1223 | + |
|
1224 | + /** |
|
1225 | + * This will queue the incoming message ids for resending. |
|
1226 | + * Note, only message_ids corresponding to messages with the status of EEM_Message::sent will be queued. |
|
1227 | + * |
|
1228 | + * @since 4.9.0 |
|
1229 | + * @param array $message_ids An array of EE_Message IDs |
|
1230 | + * @return bool true means messages were successfully queued for resending, false means none were queued for |
|
1231 | + * resending. |
|
1232 | + * @throws EE_Error |
|
1233 | + * @throws InvalidArgumentException |
|
1234 | + * @throws InvalidDataTypeException |
|
1235 | + * @throws InvalidInterfaceException |
|
1236 | + * @throws ReflectionException |
|
1237 | + */ |
|
1238 | + public static function queue_for_resending($message_ids) |
|
1239 | + { |
|
1240 | + self::_load_controller(); |
|
1241 | + self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send($message_ids); |
|
1242 | + |
|
1243 | + // get queue and count |
|
1244 | + $queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend); |
|
1245 | + |
|
1246 | + if ($queue_count > 0 |
|
1247 | + ) { |
|
1248 | + EE_Error::add_success( |
|
1249 | + sprintf( |
|
1250 | + _n( |
|
1251 | + '%d message successfully queued for resending.', |
|
1252 | + '%d messages successfully queued for resending.', |
|
1253 | + $queue_count, |
|
1254 | + 'event_espresso' |
|
1255 | + ), |
|
1256 | + $queue_count |
|
1257 | + ) |
|
1258 | + ); |
|
1259 | + /** |
|
1260 | + * @see filter usage in EE_Messages_Queue::initiate_request_by_priority |
|
1261 | + */ |
|
1262 | + } elseif (apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', true) |
|
1263 | + || EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request |
|
1264 | + ) { |
|
1265 | + $queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_sent); |
|
1266 | + if ($queue_count > 0) { |
|
1267 | + EE_Error::add_success( |
|
1268 | + sprintf( |
|
1269 | + _n( |
|
1270 | + '%d message successfully sent.', |
|
1271 | + '%d messages successfully sent.', |
|
1272 | + $queue_count, |
|
1273 | + 'event_espresso' |
|
1274 | + ), |
|
1275 | + $queue_count |
|
1276 | + ) |
|
1277 | + ); |
|
1278 | + } else { |
|
1279 | + EE_Error::add_error( |
|
1280 | + __( |
|
1281 | + '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.', |
|
1282 | + 'event_espresso' |
|
1283 | + ), |
|
1284 | + __FILE__, |
|
1285 | + __FUNCTION__, |
|
1286 | + __LINE__ |
|
1287 | + ); |
|
1288 | + } |
|
1289 | + } else { |
|
1290 | + EE_Error::add_error( |
|
1291 | + __( |
|
1292 | + '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.', |
|
1293 | + 'event_espresso' |
|
1294 | + ), |
|
1295 | + __FILE__, |
|
1296 | + __FUNCTION__, |
|
1297 | + __LINE__ |
|
1298 | + ); |
|
1299 | + } |
|
1300 | + return (bool) $queue_count; |
|
1301 | + } |
|
1302 | + |
|
1303 | + |
|
1304 | + /** |
|
1305 | + * debug |
|
1306 | + * |
|
1307 | + * @param string $class |
|
1308 | + * @param string $func |
|
1309 | + * @param string $line |
|
1310 | + * @param \EE_Transaction $transaction |
|
1311 | + * @param array $info |
|
1312 | + * @param bool $display_request |
|
1313 | + * @throws EE_Error |
|
1314 | + * @throws \EventEspresso\core\exceptions\InvalidSessionDataException |
|
1315 | + */ |
|
1316 | + protected static function log( |
|
1317 | + $class = '', |
|
1318 | + $func = '', |
|
1319 | + $line = '', |
|
1320 | + EE_Transaction $transaction, |
|
1321 | + $info = array(), |
|
1322 | + $display_request = false |
|
1323 | + ) { |
|
1324 | + if (defined('EE_DEBUG') && EE_DEBUG) { |
|
1325 | + if ($transaction instanceof EE_Transaction) { |
|
1326 | + // don't serialize objects |
|
1327 | + $info = EEH_Debug_Tools::strip_objects($info); |
|
1328 | + $info['TXN_status'] = $transaction->status_ID(); |
|
1329 | + $info['TXN_reg_steps'] = $transaction->reg_steps(); |
|
1330 | + if ($transaction->ID()) { |
|
1331 | + $index = 'EE_Transaction: ' . $transaction->ID(); |
|
1332 | + EEH_Debug_Tools::log($class, $func, $line, $info, $display_request, $index); |
|
1333 | + } |
|
1334 | + } |
|
1335 | + } |
|
1336 | + } |
|
1337 | + |
|
1338 | + |
|
1339 | + /** |
|
1340 | + * Resets all the static properties in this class when called. |
|
1341 | + */ |
|
1342 | + public static function reset() |
|
1343 | + { |
|
1344 | + self::$_EEMSG = null; |
|
1345 | + self::$_message_resource_manager = null; |
|
1346 | + self::$_MSG_PROCESSOR = null; |
|
1347 | + self::$_MSG_PATHS = null; |
|
1348 | + self::$_TMP_PACKS = array(); |
|
1349 | + } |
|
1350 | 1350 | } |
@@ -16,129 +16,129 @@ |
||
16 | 16 | interface NoticesContainerInterface |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @param string $notice |
|
21 | - * @param bool $dismissible |
|
22 | - * @param string $file |
|
23 | - * @param string $func |
|
24 | - * @param string $line |
|
25 | - */ |
|
26 | - public function addInformation($notice, $dismissible = true, $file = '', $func = '', $line = ''); |
|
19 | + /** |
|
20 | + * @param string $notice |
|
21 | + * @param bool $dismissible |
|
22 | + * @param string $file |
|
23 | + * @param string $func |
|
24 | + * @param string $line |
|
25 | + */ |
|
26 | + public function addInformation($notice, $dismissible = true, $file = '', $func = '', $line = ''); |
|
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * @param string $notice |
|
31 | - * @param bool $dismissible |
|
32 | - * @param string $file |
|
33 | - * @param string $func |
|
34 | - * @param string $line |
|
35 | - * @return |
|
36 | - */ |
|
37 | - public function addAttention($notice, $dismissible = true, $file = '', $func = '', $line = ''); |
|
29 | + /** |
|
30 | + * @param string $notice |
|
31 | + * @param bool $dismissible |
|
32 | + * @param string $file |
|
33 | + * @param string $func |
|
34 | + * @param string $line |
|
35 | + * @return |
|
36 | + */ |
|
37 | + public function addAttention($notice, $dismissible = true, $file = '', $func = '', $line = ''); |
|
38 | 38 | |
39 | 39 | |
40 | 40 | |
41 | - /** |
|
42 | - * @param string $notice |
|
43 | - * @param bool $dismissible |
|
44 | - * @param string $file |
|
45 | - * @param string $func |
|
46 | - * @param string $line |
|
47 | - */ |
|
48 | - public function addError($notice, $dismissible = true, $file, $func, $line); |
|
41 | + /** |
|
42 | + * @param string $notice |
|
43 | + * @param bool $dismissible |
|
44 | + * @param string $file |
|
45 | + * @param string $func |
|
46 | + * @param string $line |
|
47 | + */ |
|
48 | + public function addError($notice, $dismissible = true, $file, $func, $line); |
|
49 | 49 | |
50 | 50 | |
51 | 51 | |
52 | - /** |
|
53 | - * @param string $notice |
|
54 | - * @param bool $dismissible |
|
55 | - * @param string $file |
|
56 | - * @param string $func |
|
57 | - * @param string $line |
|
58 | - */ |
|
59 | - public function addSuccess($notice, $dismissible = true, $file = '', $func = '', $line = ''); |
|
52 | + /** |
|
53 | + * @param string $notice |
|
54 | + * @param bool $dismissible |
|
55 | + * @param string $file |
|
56 | + * @param string $func |
|
57 | + * @param string $line |
|
58 | + */ |
|
59 | + public function addSuccess($notice, $dismissible = true, $file = '', $func = '', $line = ''); |
|
60 | 60 | |
61 | 61 | |
62 | 62 | |
63 | - /** |
|
64 | - * @return boolean |
|
65 | - */ |
|
66 | - public function hasInformation(); |
|
63 | + /** |
|
64 | + * @return boolean |
|
65 | + */ |
|
66 | + public function hasInformation(); |
|
67 | 67 | |
68 | 68 | |
69 | 69 | |
70 | - /** |
|
71 | - * @return boolean |
|
72 | - */ |
|
73 | - public function hasAttention(); |
|
70 | + /** |
|
71 | + * @return boolean |
|
72 | + */ |
|
73 | + public function hasAttention(); |
|
74 | 74 | |
75 | 75 | |
76 | 76 | |
77 | - /** |
|
78 | - * @return boolean |
|
79 | - */ |
|
80 | - public function hasError(); |
|
77 | + /** |
|
78 | + * @return boolean |
|
79 | + */ |
|
80 | + public function hasError(); |
|
81 | 81 | |
82 | 82 | |
83 | 83 | |
84 | - /** |
|
85 | - * @return boolean |
|
86 | - */ |
|
87 | - public function hasSuccess(); |
|
84 | + /** |
|
85 | + * @return boolean |
|
86 | + */ |
|
87 | + public function hasSuccess(); |
|
88 | 88 | |
89 | 89 | |
90 | 90 | |
91 | - /** |
|
92 | - * @return int |
|
93 | - */ |
|
94 | - public function countInformation(); |
|
91 | + /** |
|
92 | + * @return int |
|
93 | + */ |
|
94 | + public function countInformation(); |
|
95 | 95 | |
96 | 96 | |
97 | 97 | |
98 | - /** |
|
99 | - * @return int |
|
100 | - */ |
|
101 | - public function countAttention(); |
|
98 | + /** |
|
99 | + * @return int |
|
100 | + */ |
|
101 | + public function countAttention(); |
|
102 | 102 | |
103 | 103 | |
104 | 104 | |
105 | - /** |
|
106 | - * @return int |
|
107 | - */ |
|
108 | - public function countError(); |
|
105 | + /** |
|
106 | + * @return int |
|
107 | + */ |
|
108 | + public function countError(); |
|
109 | 109 | |
110 | 110 | |
111 | 111 | |
112 | - /** |
|
113 | - * @return int |
|
114 | - */ |
|
115 | - public function countSuccess(); |
|
112 | + /** |
|
113 | + * @return int |
|
114 | + */ |
|
115 | + public function countSuccess(); |
|
116 | 116 | |
117 | 117 | |
118 | 118 | |
119 | - /** |
|
120 | - * @return NoticeInterface[] |
|
121 | - */ |
|
122 | - public function getInformation(); |
|
119 | + /** |
|
120 | + * @return NoticeInterface[] |
|
121 | + */ |
|
122 | + public function getInformation(); |
|
123 | 123 | |
124 | 124 | |
125 | 125 | |
126 | - /** |
|
127 | - * @return NoticeInterface[] |
|
128 | - */ |
|
129 | - public function getAttention(); |
|
126 | + /** |
|
127 | + * @return NoticeInterface[] |
|
128 | + */ |
|
129 | + public function getAttention(); |
|
130 | 130 | |
131 | 131 | |
132 | 132 | |
133 | - /** |
|
134 | - * @return NoticeInterface[] |
|
135 | - */ |
|
136 | - public function getError(); |
|
133 | + /** |
|
134 | + * @return NoticeInterface[] |
|
135 | + */ |
|
136 | + public function getError(); |
|
137 | 137 | |
138 | 138 | |
139 | 139 | |
140 | - /** |
|
141 | - * @return NoticeInterface[] |
|
142 | - */ |
|
143 | - public function getSuccess(); |
|
140 | + /** |
|
141 | + * @return NoticeInterface[] |
|
142 | + */ |
|
143 | + public function getSuccess(); |
|
144 | 144 | } |
@@ -36,7 +36,7 @@ |
||
36 | 36 | $error_string = esc_html__('The following errors occurred:', 'event_espresso'); |
37 | 37 | foreach ($notices->getError() as $notice) { |
38 | 38 | if ($this->getThrowExceptions()) { |
39 | - $error_string .= '<br />' . $notice->message(); |
|
39 | + $error_string .= '<br />'.$notice->message(); |
|
40 | 40 | } else { |
41 | 41 | new AdminNotice($notice); |
42 | 42 | } |
@@ -14,42 +14,42 @@ |
||
14 | 14 | class ConvertNoticesToAdminNotices extends NoticeConverter |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * Converts Notice objects into AdminNotice notifications |
|
19 | - * |
|
20 | - * @param NoticesContainerInterface $notices |
|
21 | - * @throws DomainException |
|
22 | - */ |
|
23 | - public function process(NoticesContainerInterface $notices) |
|
24 | - { |
|
25 | - if ($notices->hasAttention()) { |
|
26 | - foreach ($notices->getAttention() as $notice) { |
|
27 | - new AdminNotice($notice); |
|
28 | - } |
|
29 | - } |
|
30 | - if ($notices->hasError()) { |
|
31 | - $error_string = esc_html__('The following errors occurred:', 'event_espresso'); |
|
32 | - foreach ($notices->getError() as $notice) { |
|
33 | - if ($this->getThrowExceptions()) { |
|
34 | - $error_string .= '<br />' . $notice->message(); |
|
35 | - } else { |
|
36 | - new AdminNotice($notice); |
|
37 | - } |
|
38 | - } |
|
39 | - if ($this->getThrowExceptions()) { |
|
40 | - throw new DomainException($error_string); |
|
41 | - } |
|
42 | - } |
|
43 | - if ($notices->hasSuccess()) { |
|
44 | - foreach ($notices->getSuccess() as $notice) { |
|
45 | - new AdminNotice($notice); |
|
46 | - } |
|
47 | - } |
|
48 | - if ($notices->hasInformation()) { |
|
49 | - foreach ($notices->getInformation() as $notice) { |
|
50 | - new AdminNotice($notice); |
|
51 | - } |
|
52 | - } |
|
53 | - $this->clearNotices(); |
|
54 | - } |
|
17 | + /** |
|
18 | + * Converts Notice objects into AdminNotice notifications |
|
19 | + * |
|
20 | + * @param NoticesContainerInterface $notices |
|
21 | + * @throws DomainException |
|
22 | + */ |
|
23 | + public function process(NoticesContainerInterface $notices) |
|
24 | + { |
|
25 | + if ($notices->hasAttention()) { |
|
26 | + foreach ($notices->getAttention() as $notice) { |
|
27 | + new AdminNotice($notice); |
|
28 | + } |
|
29 | + } |
|
30 | + if ($notices->hasError()) { |
|
31 | + $error_string = esc_html__('The following errors occurred:', 'event_espresso'); |
|
32 | + foreach ($notices->getError() as $notice) { |
|
33 | + if ($this->getThrowExceptions()) { |
|
34 | + $error_string .= '<br />' . $notice->message(); |
|
35 | + } else { |
|
36 | + new AdminNotice($notice); |
|
37 | + } |
|
38 | + } |
|
39 | + if ($this->getThrowExceptions()) { |
|
40 | + throw new DomainException($error_string); |
|
41 | + } |
|
42 | + } |
|
43 | + if ($notices->hasSuccess()) { |
|
44 | + foreach ($notices->getSuccess() as $notice) { |
|
45 | + new AdminNotice($notice); |
|
46 | + } |
|
47 | + } |
|
48 | + if ($notices->hasInformation()) { |
|
49 | + foreach ($notices->getInformation() as $notice) { |
|
50 | + new AdminNotice($notice); |
|
51 | + } |
|
52 | + } |
|
53 | + $this->clearNotices(); |
|
54 | + } |
|
55 | 55 | } |