@@ -16,13 +16,13 @@ discard block |
||
16 | 16 | */ |
17 | 17 | function is_espresso_event($event = null) |
18 | 18 | { |
19 | - if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
20 | - // extract EE_Event object from passed param regardless of what it is (within reason of course) |
|
21 | - $event = EEH_Event_View::get_event($event); |
|
22 | - // do we have a valid event ? |
|
23 | - return $event instanceof EE_Event; |
|
24 | - } |
|
25 | - return false; |
|
19 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
20 | + // extract EE_Event object from passed param regardless of what it is (within reason of course) |
|
21 | + $event = EEH_Event_View::get_event($event); |
|
22 | + // do we have a valid event ? |
|
23 | + return $event instanceof EE_Event; |
|
24 | + } |
|
25 | + return false; |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | /** |
@@ -33,12 +33,12 @@ discard block |
||
33 | 33 | */ |
34 | 34 | function is_espresso_event_single() |
35 | 35 | { |
36 | - if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
37 | - global $wp_query; |
|
38 | - // return conditionals set by CPTs |
|
39 | - return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_single : false; |
|
40 | - } |
|
41 | - return false; |
|
36 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
37 | + global $wp_query; |
|
38 | + // return conditionals set by CPTs |
|
39 | + return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_single : false; |
|
40 | + } |
|
41 | + return false; |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -49,11 +49,11 @@ discard block |
||
49 | 49 | */ |
50 | 50 | function is_espresso_event_archive() |
51 | 51 | { |
52 | - if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
53 | - global $wp_query; |
|
54 | - return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_archive : false; |
|
55 | - } |
|
56 | - return false; |
|
52 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
53 | + global $wp_query; |
|
54 | + return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_archive : false; |
|
55 | + } |
|
56 | + return false; |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | */ |
65 | 65 | function is_espresso_event_taxonomy() |
66 | 66 | { |
67 | - if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
68 | - global $wp_query; |
|
69 | - return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_taxonomy : false; |
|
70 | - } |
|
71 | - return false; |
|
67 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
68 | + global $wp_query; |
|
69 | + return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_taxonomy : false; |
|
70 | + } |
|
71 | + return false; |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -82,13 +82,13 @@ discard block |
||
82 | 82 | */ |
83 | 83 | function is_espresso_venue($venue = null) |
84 | 84 | { |
85 | - if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
86 | - // extract EE_Venue object from passed param regardless of what it is (within reason of course) |
|
87 | - $venue = EEH_Venue_View::get_venue($venue, false); |
|
88 | - // do we have a valid event ? |
|
89 | - return $venue instanceof EE_Venue; |
|
90 | - } |
|
91 | - return false; |
|
85 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
86 | + // extract EE_Venue object from passed param regardless of what it is (within reason of course) |
|
87 | + $venue = EEH_Venue_View::get_venue($venue, false); |
|
88 | + // do we have a valid event ? |
|
89 | + return $venue instanceof EE_Venue; |
|
90 | + } |
|
91 | + return false; |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -99,11 +99,11 @@ discard block |
||
99 | 99 | */ |
100 | 100 | function is_espresso_venue_single() |
101 | 101 | { |
102 | - if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
103 | - global $wp_query; |
|
104 | - return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_single : false; |
|
105 | - } |
|
106 | - return false; |
|
102 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
103 | + global $wp_query; |
|
104 | + return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_single : false; |
|
105 | + } |
|
106 | + return false; |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -114,11 +114,11 @@ discard block |
||
114 | 114 | */ |
115 | 115 | function is_espresso_venue_archive() |
116 | 116 | { |
117 | - if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
118 | - global $wp_query; |
|
119 | - return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_archive : false; |
|
120 | - } |
|
121 | - return false; |
|
117 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
118 | + global $wp_query; |
|
119 | + return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_archive : false; |
|
120 | + } |
|
121 | + return false; |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -129,11 +129,11 @@ discard block |
||
129 | 129 | */ |
130 | 130 | function is_espresso_venue_taxonomy() |
131 | 131 | { |
132 | - if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
133 | - global $wp_query; |
|
134 | - return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_taxonomy : false; |
|
135 | - } |
|
136 | - return false; |
|
132 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
133 | + global $wp_query; |
|
134 | + return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_taxonomy : false; |
|
135 | + } |
|
136 | + return false; |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -145,62 +145,62 @@ discard block |
||
145 | 145 | */ |
146 | 146 | function can_use_espresso_conditionals($conditional_tag) |
147 | 147 | { |
148 | - if (! did_action('AHEE__EE_System__initialize')) { |
|
149 | - EE_Error::doing_it_wrong( |
|
150 | - __FUNCTION__, |
|
151 | - sprintf( |
|
152 | - esc_html__( |
|
153 | - 'The "%s" conditional tag can not be used until after the "init" hook has run, but works best when used within a theme\'s template files.', |
|
154 | - 'event_espresso' |
|
155 | - ), |
|
156 | - $conditional_tag |
|
157 | - ), |
|
158 | - '4.4.0' |
|
159 | - ); |
|
160 | - return false; |
|
161 | - } |
|
162 | - return true; |
|
148 | + if (! did_action('AHEE__EE_System__initialize')) { |
|
149 | + EE_Error::doing_it_wrong( |
|
150 | + __FUNCTION__, |
|
151 | + sprintf( |
|
152 | + esc_html__( |
|
153 | + 'The "%s" conditional tag can not be used until after the "init" hook has run, but works best when used within a theme\'s template files.', |
|
154 | + 'event_espresso' |
|
155 | + ), |
|
156 | + $conditional_tag |
|
157 | + ), |
|
158 | + '4.4.0' |
|
159 | + ); |
|
160 | + return false; |
|
161 | + } |
|
162 | + return true; |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | |
166 | 166 | /*************************** Event Queries ***************************/ |
167 | 167 | |
168 | 168 | if (! function_exists('espresso_get_events')) { |
169 | - /** |
|
170 | - * espresso_get_events |
|
171 | - * |
|
172 | - * @param array $params |
|
173 | - * @return array |
|
174 | - */ |
|
175 | - function espresso_get_events($params = []) |
|
176 | - { |
|
177 | - //set default params |
|
178 | - $default_espresso_events_params = [ |
|
179 | - 'limit' => 10, |
|
180 | - 'show_expired' => false, |
|
181 | - 'month' => null, |
|
182 | - 'category_slug' => null, |
|
183 | - 'order_by' => 'start_date', |
|
184 | - 'sort' => 'ASC', |
|
185 | - ]; |
|
186 | - // allow the defaults to be filtered |
|
187 | - $default_espresso_events_params = apply_filters( |
|
188 | - 'espresso_get_events__default_espresso_events_params', |
|
189 | - $default_espresso_events_params |
|
190 | - ); |
|
191 | - // grab params and merge with defaults, then extract |
|
192 | - $params = array_merge($default_espresso_events_params, $params); |
|
193 | - // run the query |
|
194 | - $events_query = new EventEspresso\core\domain\services\wp_queries\EventListQuery($params); |
|
195 | - // assign results to a variable so we can return it |
|
196 | - $events = $events_query->have_posts() ? $events_query->posts : []; |
|
197 | - // but first reset the query and postdata |
|
198 | - wp_reset_query(); |
|
199 | - wp_reset_postdata(); |
|
200 | - EED_Events_Archive::remove_all_events_archive_filters(); |
|
201 | - unset($events_query); |
|
202 | - return $events; |
|
203 | - } |
|
169 | + /** |
|
170 | + * espresso_get_events |
|
171 | + * |
|
172 | + * @param array $params |
|
173 | + * @return array |
|
174 | + */ |
|
175 | + function espresso_get_events($params = []) |
|
176 | + { |
|
177 | + //set default params |
|
178 | + $default_espresso_events_params = [ |
|
179 | + 'limit' => 10, |
|
180 | + 'show_expired' => false, |
|
181 | + 'month' => null, |
|
182 | + 'category_slug' => null, |
|
183 | + 'order_by' => 'start_date', |
|
184 | + 'sort' => 'ASC', |
|
185 | + ]; |
|
186 | + // allow the defaults to be filtered |
|
187 | + $default_espresso_events_params = apply_filters( |
|
188 | + 'espresso_get_events__default_espresso_events_params', |
|
189 | + $default_espresso_events_params |
|
190 | + ); |
|
191 | + // grab params and merge with defaults, then extract |
|
192 | + $params = array_merge($default_espresso_events_params, $params); |
|
193 | + // run the query |
|
194 | + $events_query = new EventEspresso\core\domain\services\wp_queries\EventListQuery($params); |
|
195 | + // assign results to a variable so we can return it |
|
196 | + $events = $events_query->have_posts() ? $events_query->posts : []; |
|
197 | + // but first reset the query and postdata |
|
198 | + wp_reset_query(); |
|
199 | + wp_reset_postdata(); |
|
200 | + EED_Events_Archive::remove_all_events_archive_filters(); |
|
201 | + unset($events_query); |
|
202 | + return $events; |
|
203 | + } |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | |
@@ -215,357 +215,357 @@ discard block |
||
215 | 215 | */ |
216 | 216 | function espresso_load_ticket_selector() |
217 | 217 | { |
218 | - EE_Registry::instance()->load_file(EE_MODULES . 'ticket_selector', 'EED_Ticket_Selector', 'module'); |
|
218 | + EE_Registry::instance()->load_file(EE_MODULES . 'ticket_selector', 'EED_Ticket_Selector', 'module'); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | if (! function_exists('espresso_ticket_selector')) { |
222 | - /** |
|
223 | - * espresso_ticket_selector |
|
224 | - * |
|
225 | - * @param null $event |
|
226 | - * @throws EE_Error |
|
227 | - * @throws ReflectionException |
|
228 | - */ |
|
229 | - function espresso_ticket_selector($event = null) |
|
230 | - { |
|
231 | - if (! apply_filters('FHEE_disable_espresso_ticket_selector', false)) { |
|
232 | - espresso_load_ticket_selector(); |
|
233 | - EED_Ticket_Selector::set_definitions(); |
|
234 | - echo EED_Ticket_Selector::display_ticket_selector($event); // already escaped |
|
235 | - } |
|
236 | - } |
|
222 | + /** |
|
223 | + * espresso_ticket_selector |
|
224 | + * |
|
225 | + * @param null $event |
|
226 | + * @throws EE_Error |
|
227 | + * @throws ReflectionException |
|
228 | + */ |
|
229 | + function espresso_ticket_selector($event = null) |
|
230 | + { |
|
231 | + if (! apply_filters('FHEE_disable_espresso_ticket_selector', false)) { |
|
232 | + espresso_load_ticket_selector(); |
|
233 | + EED_Ticket_Selector::set_definitions(); |
|
234 | + echo EED_Ticket_Selector::display_ticket_selector($event); // already escaped |
|
235 | + } |
|
236 | + } |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | |
240 | 240 | if (! function_exists('espresso_view_details_btn')) { |
241 | - /** |
|
242 | - * espresso_view_details_btn |
|
243 | - * |
|
244 | - * @param null $event |
|
245 | - * @throws EE_Error |
|
246 | - * @throws ReflectionException |
|
247 | - */ |
|
248 | - function espresso_view_details_btn($event = null) |
|
249 | - { |
|
250 | - if (! apply_filters('FHEE_disable_espresso_view_details_btn', false)) { |
|
251 | - espresso_load_ticket_selector(); |
|
252 | - echo EED_Ticket_Selector::display_ticket_selector($event, true); // already escaped |
|
253 | - } |
|
254 | - } |
|
241 | + /** |
|
242 | + * espresso_view_details_btn |
|
243 | + * |
|
244 | + * @param null $event |
|
245 | + * @throws EE_Error |
|
246 | + * @throws ReflectionException |
|
247 | + */ |
|
248 | + function espresso_view_details_btn($event = null) |
|
249 | + { |
|
250 | + if (! apply_filters('FHEE_disable_espresso_view_details_btn', false)) { |
|
251 | + espresso_load_ticket_selector(); |
|
252 | + echo EED_Ticket_Selector::display_ticket_selector($event, true); // already escaped |
|
253 | + } |
|
254 | + } |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | |
258 | 258 | /*************************** EEH_Event_View ***************************/ |
259 | 259 | |
260 | 260 | if (! function_exists('espresso_load_event_list_assets')) { |
261 | - /** |
|
262 | - * espresso_load_event_list_assets |
|
263 | - * ensures that event list styles and scripts are loaded |
|
264 | - * |
|
265 | - * @return void |
|
266 | - */ |
|
267 | - function espresso_load_event_list_assets() |
|
268 | - { |
|
269 | - $event_list = EED_Events_Archive::instance(); |
|
270 | - add_action('AHEE__EE_System__initialize_last', [$event_list, 'load_event_list_assets'], 10); |
|
271 | - add_filter('FHEE_enable_default_espresso_css', '__return_true'); |
|
272 | - } |
|
261 | + /** |
|
262 | + * espresso_load_event_list_assets |
|
263 | + * ensures that event list styles and scripts are loaded |
|
264 | + * |
|
265 | + * @return void |
|
266 | + */ |
|
267 | + function espresso_load_event_list_assets() |
|
268 | + { |
|
269 | + $event_list = EED_Events_Archive::instance(); |
|
270 | + add_action('AHEE__EE_System__initialize_last', [$event_list, 'load_event_list_assets'], 10); |
|
271 | + add_filter('FHEE_enable_default_espresso_css', '__return_true'); |
|
272 | + } |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | |
276 | 276 | if (! function_exists('espresso_event_reg_button')) { |
277 | - /** |
|
278 | - * espresso_event_reg_button |
|
279 | - * returns the "Register Now" button if event is active, |
|
280 | - * an inactive button like status banner if the event is not active |
|
281 | - * or a "Read More" button if so desired |
|
282 | - * |
|
283 | - * @param null $btn_text_if_active |
|
284 | - * @param bool $btn_text_if_inactive |
|
285 | - * @param bool $EVT_ID |
|
286 | - * @return void |
|
287 | - * @throws EE_Error |
|
288 | - * @throws ReflectionException |
|
289 | - */ |
|
290 | - function espresso_event_reg_button($btn_text_if_active = null, $btn_text_if_inactive = false, $EVT_ID = false) |
|
291 | - { |
|
292 | - $event = EEH_Event_View::get_event($EVT_ID); |
|
293 | - if (! $event instanceof EE_Event) { |
|
294 | - return; |
|
295 | - } |
|
296 | - $event_status = $event->get_active_status(); |
|
297 | - switch ($event_status) { |
|
298 | - case EE_Datetime::sold_out : |
|
299 | - $btn_text = __('Sold Out', 'event_espresso'); |
|
300 | - $class = 'ee-pink'; |
|
301 | - break; |
|
302 | - case EE_Datetime::expired : |
|
303 | - $btn_text = __('Event is Over', 'event_espresso'); |
|
304 | - $class = 'ee-grey'; |
|
305 | - break; |
|
306 | - case EE_Datetime::inactive : |
|
307 | - $btn_text = __('Event Not Active', 'event_espresso'); |
|
308 | - $class = 'ee-grey'; |
|
309 | - break; |
|
310 | - case EE_Datetime::cancelled : |
|
311 | - $btn_text = __('Event was Cancelled', 'event_espresso'); |
|
312 | - $class = 'ee-red'; |
|
313 | - break; |
|
314 | - case EE_Datetime::upcoming : |
|
315 | - case EE_Datetime::active : |
|
316 | - default : |
|
317 | - $btn_text = ! empty($btn_text_if_active) |
|
318 | - ? $btn_text_if_active |
|
319 | - : __('Register Now', 'event_espresso'); |
|
320 | - $class = 'ee-green'; |
|
321 | - } |
|
322 | - if ($event_status < 1 && ! empty($btn_text_if_inactive)) { |
|
323 | - $btn_text = $btn_text_if_inactive; |
|
324 | - $class = 'ee-grey'; |
|
325 | - } |
|
326 | - ?> |
|
277 | + /** |
|
278 | + * espresso_event_reg_button |
|
279 | + * returns the "Register Now" button if event is active, |
|
280 | + * an inactive button like status banner if the event is not active |
|
281 | + * or a "Read More" button if so desired |
|
282 | + * |
|
283 | + * @param null $btn_text_if_active |
|
284 | + * @param bool $btn_text_if_inactive |
|
285 | + * @param bool $EVT_ID |
|
286 | + * @return void |
|
287 | + * @throws EE_Error |
|
288 | + * @throws ReflectionException |
|
289 | + */ |
|
290 | + function espresso_event_reg_button($btn_text_if_active = null, $btn_text_if_inactive = false, $EVT_ID = false) |
|
291 | + { |
|
292 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
293 | + if (! $event instanceof EE_Event) { |
|
294 | + return; |
|
295 | + } |
|
296 | + $event_status = $event->get_active_status(); |
|
297 | + switch ($event_status) { |
|
298 | + case EE_Datetime::sold_out : |
|
299 | + $btn_text = __('Sold Out', 'event_espresso'); |
|
300 | + $class = 'ee-pink'; |
|
301 | + break; |
|
302 | + case EE_Datetime::expired : |
|
303 | + $btn_text = __('Event is Over', 'event_espresso'); |
|
304 | + $class = 'ee-grey'; |
|
305 | + break; |
|
306 | + case EE_Datetime::inactive : |
|
307 | + $btn_text = __('Event Not Active', 'event_espresso'); |
|
308 | + $class = 'ee-grey'; |
|
309 | + break; |
|
310 | + case EE_Datetime::cancelled : |
|
311 | + $btn_text = __('Event was Cancelled', 'event_espresso'); |
|
312 | + $class = 'ee-red'; |
|
313 | + break; |
|
314 | + case EE_Datetime::upcoming : |
|
315 | + case EE_Datetime::active : |
|
316 | + default : |
|
317 | + $btn_text = ! empty($btn_text_if_active) |
|
318 | + ? $btn_text_if_active |
|
319 | + : __('Register Now', 'event_espresso'); |
|
320 | + $class = 'ee-green'; |
|
321 | + } |
|
322 | + if ($event_status < 1 && ! empty($btn_text_if_inactive)) { |
|
323 | + $btn_text = $btn_text_if_inactive; |
|
324 | + $class = 'ee-grey'; |
|
325 | + } |
|
326 | + ?> |
|
327 | 327 | <a class="ee-button ee-register-button <?php echo esc_attr($class); ?>" |
328 | 328 | href="<?php espresso_event_link_url($EVT_ID); ?>" |
329 | 329 | <?php echo EED_Events_Archive::link_target(); // already escaped |
330 | - ?> |
|
330 | + ?> |
|
331 | 331 | > |
332 | 332 | <?php echo esc_html($btn_text); ?> |
333 | 333 | </a> |
334 | 334 | <?php |
335 | - } |
|
335 | + } |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | |
339 | 339 | if (! function_exists('espresso_display_ticket_selector')) { |
340 | - /** |
|
341 | - * espresso_display_ticket_selector |
|
342 | - * whether or not to display the Ticket Selector for an event |
|
343 | - * |
|
344 | - * @param bool $EVT_ID |
|
345 | - * @return boolean |
|
346 | - * @throws EE_Error |
|
347 | - * @throws ReflectionException |
|
348 | - */ |
|
349 | - function espresso_display_ticket_selector($EVT_ID = false) |
|
350 | - { |
|
351 | - return EEH_Event_View::display_ticket_selector($EVT_ID); |
|
352 | - } |
|
340 | + /** |
|
341 | + * espresso_display_ticket_selector |
|
342 | + * whether or not to display the Ticket Selector for an event |
|
343 | + * |
|
344 | + * @param bool $EVT_ID |
|
345 | + * @return boolean |
|
346 | + * @throws EE_Error |
|
347 | + * @throws ReflectionException |
|
348 | + */ |
|
349 | + function espresso_display_ticket_selector($EVT_ID = false) |
|
350 | + { |
|
351 | + return EEH_Event_View::display_ticket_selector($EVT_ID); |
|
352 | + } |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | |
356 | 356 | if (! function_exists('espresso_event_status_banner')) { |
357 | - /** |
|
358 | - * espresso_event_status |
|
359 | - * returns a banner showing the event status if it is sold out, expired, or inactive |
|
360 | - * |
|
361 | - * @param bool $EVT_ID |
|
362 | - * @return string |
|
363 | - * @throws EE_Error |
|
364 | - * @throws ReflectionException |
|
365 | - */ |
|
366 | - function espresso_event_status_banner($EVT_ID = false) |
|
367 | - { |
|
368 | - return EEH_Event_View::event_status($EVT_ID); |
|
369 | - } |
|
357 | + /** |
|
358 | + * espresso_event_status |
|
359 | + * returns a banner showing the event status if it is sold out, expired, or inactive |
|
360 | + * |
|
361 | + * @param bool $EVT_ID |
|
362 | + * @return string |
|
363 | + * @throws EE_Error |
|
364 | + * @throws ReflectionException |
|
365 | + */ |
|
366 | + function espresso_event_status_banner($EVT_ID = false) |
|
367 | + { |
|
368 | + return EEH_Event_View::event_status($EVT_ID); |
|
369 | + } |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | |
373 | 373 | if (! function_exists('espresso_event_status')) { |
374 | - /** |
|
375 | - * espresso_event_status |
|
376 | - * returns the event status if it is sold out, expired, or inactive |
|
377 | - * |
|
378 | - * @param int $EVT_ID |
|
379 | - * @param bool $echo |
|
380 | - * @return string |
|
381 | - * @throws EE_Error |
|
382 | - * @throws ReflectionException |
|
383 | - */ |
|
384 | - function espresso_event_status($EVT_ID = 0, $echo = true) |
|
385 | - { |
|
386 | - return EEH_Event_View::event_active_status($EVT_ID, $echo); |
|
387 | - } |
|
374 | + /** |
|
375 | + * espresso_event_status |
|
376 | + * returns the event status if it is sold out, expired, or inactive |
|
377 | + * |
|
378 | + * @param int $EVT_ID |
|
379 | + * @param bool $echo |
|
380 | + * @return string |
|
381 | + * @throws EE_Error |
|
382 | + * @throws ReflectionException |
|
383 | + */ |
|
384 | + function espresso_event_status($EVT_ID = 0, $echo = true) |
|
385 | + { |
|
386 | + return EEH_Event_View::event_active_status($EVT_ID, $echo); |
|
387 | + } |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | |
391 | 391 | if (! function_exists('espresso_event_categories')) { |
392 | - /** |
|
393 | - * espresso_event_categories |
|
394 | - * returns the terms associated with an event |
|
395 | - * |
|
396 | - * @param int $EVT_ID |
|
397 | - * @param bool $hide_uncategorized |
|
398 | - * @param bool $echo |
|
399 | - * @return string |
|
400 | - * @throws EE_Error |
|
401 | - * @throws ReflectionException |
|
402 | - */ |
|
403 | - function espresso_event_categories($EVT_ID = 0, $hide_uncategorized = true, $echo = true) |
|
404 | - { |
|
405 | - if ($echo) { |
|
406 | - echo EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized); // already escaped |
|
407 | - return ''; |
|
408 | - } |
|
409 | - return EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized); |
|
410 | - } |
|
392 | + /** |
|
393 | + * espresso_event_categories |
|
394 | + * returns the terms associated with an event |
|
395 | + * |
|
396 | + * @param int $EVT_ID |
|
397 | + * @param bool $hide_uncategorized |
|
398 | + * @param bool $echo |
|
399 | + * @return string |
|
400 | + * @throws EE_Error |
|
401 | + * @throws ReflectionException |
|
402 | + */ |
|
403 | + function espresso_event_categories($EVT_ID = 0, $hide_uncategorized = true, $echo = true) |
|
404 | + { |
|
405 | + if ($echo) { |
|
406 | + echo EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized); // already escaped |
|
407 | + return ''; |
|
408 | + } |
|
409 | + return EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized); |
|
410 | + } |
|
411 | 411 | } |
412 | 412 | |
413 | 413 | |
414 | 414 | if (! function_exists('espresso_event_tickets_available')) { |
415 | - /** |
|
416 | - * espresso_event_tickets_available |
|
417 | - * returns the ticket types available for purchase for an event |
|
418 | - * |
|
419 | - * @param int $EVT_ID |
|
420 | - * @param bool $echo |
|
421 | - * @param bool $format |
|
422 | - * @return string |
|
423 | - * @throws EE_Error |
|
424 | - * @throws ReflectionException |
|
425 | - */ |
|
426 | - function espresso_event_tickets_available($EVT_ID = 0, $echo = true, $format = true) |
|
427 | - { |
|
428 | - $tickets = EEH_Event_View::event_tickets_available($EVT_ID); |
|
429 | - if (is_array($tickets) && ! empty($tickets)) { |
|
430 | - // if formatting then $html will be a string, else it will be an array of ticket objects |
|
431 | - $html = |
|
432 | - $format ? '<ul id="ee-event-tickets-ul-' . esc_attr($EVT_ID) . '" class="ee-event-tickets-ul">' : []; |
|
433 | - foreach ($tickets as $ticket) { |
|
434 | - if ($ticket instanceof EE_Ticket) { |
|
435 | - if ($format) { |
|
436 | - $html .= '<li id="ee-event-tickets-li-' |
|
437 | - . esc_attr($ticket->ID()) |
|
438 | - . '" class="ee-event-tickets-li">'; |
|
439 | - $html .= esc_html($ticket->name()) . ' '; |
|
440 | - $html .= EEH_Template::format_currency( |
|
441 | - $ticket->get_ticket_total_with_taxes() |
|
442 | - ); // already escaped |
|
443 | - $html .= '</li>'; |
|
444 | - } else { |
|
445 | - $html[] = $ticket; |
|
446 | - } |
|
447 | - } |
|
448 | - } |
|
449 | - if ($format) { |
|
450 | - $html .= '</ul>'; |
|
451 | - } |
|
452 | - if ($echo && $format) { |
|
453 | - echo $html; // already escaped |
|
454 | - return ''; |
|
455 | - } |
|
456 | - return $html; |
|
457 | - } |
|
458 | - return ''; |
|
459 | - } |
|
415 | + /** |
|
416 | + * espresso_event_tickets_available |
|
417 | + * returns the ticket types available for purchase for an event |
|
418 | + * |
|
419 | + * @param int $EVT_ID |
|
420 | + * @param bool $echo |
|
421 | + * @param bool $format |
|
422 | + * @return string |
|
423 | + * @throws EE_Error |
|
424 | + * @throws ReflectionException |
|
425 | + */ |
|
426 | + function espresso_event_tickets_available($EVT_ID = 0, $echo = true, $format = true) |
|
427 | + { |
|
428 | + $tickets = EEH_Event_View::event_tickets_available($EVT_ID); |
|
429 | + if (is_array($tickets) && ! empty($tickets)) { |
|
430 | + // if formatting then $html will be a string, else it will be an array of ticket objects |
|
431 | + $html = |
|
432 | + $format ? '<ul id="ee-event-tickets-ul-' . esc_attr($EVT_ID) . '" class="ee-event-tickets-ul">' : []; |
|
433 | + foreach ($tickets as $ticket) { |
|
434 | + if ($ticket instanceof EE_Ticket) { |
|
435 | + if ($format) { |
|
436 | + $html .= '<li id="ee-event-tickets-li-' |
|
437 | + . esc_attr($ticket->ID()) |
|
438 | + . '" class="ee-event-tickets-li">'; |
|
439 | + $html .= esc_html($ticket->name()) . ' '; |
|
440 | + $html .= EEH_Template::format_currency( |
|
441 | + $ticket->get_ticket_total_with_taxes() |
|
442 | + ); // already escaped |
|
443 | + $html .= '</li>'; |
|
444 | + } else { |
|
445 | + $html[] = $ticket; |
|
446 | + } |
|
447 | + } |
|
448 | + } |
|
449 | + if ($format) { |
|
450 | + $html .= '</ul>'; |
|
451 | + } |
|
452 | + if ($echo && $format) { |
|
453 | + echo $html; // already escaped |
|
454 | + return ''; |
|
455 | + } |
|
456 | + return $html; |
|
457 | + } |
|
458 | + return ''; |
|
459 | + } |
|
460 | 460 | } |
461 | 461 | |
462 | 462 | if (! function_exists('espresso_event_date_obj')) { |
463 | - /** |
|
464 | - * espresso_event_date_obj |
|
465 | - * returns the primary date object for an event |
|
466 | - * |
|
467 | - * @param bool $EVT_ID |
|
468 | - * @return EE_Datetime|null |
|
469 | - * @throws EE_Error |
|
470 | - * @throws ReflectionException |
|
471 | - */ |
|
472 | - function espresso_event_date_obj($EVT_ID = false) |
|
473 | - { |
|
474 | - return EEH_Event_View::get_primary_date_obj($EVT_ID); |
|
475 | - } |
|
463 | + /** |
|
464 | + * espresso_event_date_obj |
|
465 | + * returns the primary date object for an event |
|
466 | + * |
|
467 | + * @param bool $EVT_ID |
|
468 | + * @return EE_Datetime|null |
|
469 | + * @throws EE_Error |
|
470 | + * @throws ReflectionException |
|
471 | + */ |
|
472 | + function espresso_event_date_obj($EVT_ID = false) |
|
473 | + { |
|
474 | + return EEH_Event_View::get_primary_date_obj($EVT_ID); |
|
475 | + } |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | |
479 | 479 | if (! function_exists('espresso_event_date')) { |
480 | - /** |
|
481 | - * espresso_event_date |
|
482 | - * returns the primary date for an event |
|
483 | - * |
|
484 | - * @param string $date_format |
|
485 | - * @param string $time_format |
|
486 | - * @param bool $EVT_ID |
|
487 | - * @param bool $echo |
|
488 | - * @return string |
|
489 | - * @throws EE_Error |
|
490 | - * @throws ReflectionException |
|
491 | - */ |
|
492 | - function espresso_event_date($date_format = '', $time_format = '', $EVT_ID = false, $echo = true) |
|
493 | - { |
|
494 | - $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
495 | - $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
496 | - $date_format = apply_filters('FHEE__espresso_event_date__date_format', $date_format); |
|
497 | - $time_format = apply_filters('FHEE__espresso_event_date__time_format', $time_format); |
|
498 | - if ($echo) { |
|
499 | - echo EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID); // already escaped |
|
500 | - return ''; |
|
501 | - } |
|
502 | - return EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID); |
|
503 | - |
|
504 | - } |
|
480 | + /** |
|
481 | + * espresso_event_date |
|
482 | + * returns the primary date for an event |
|
483 | + * |
|
484 | + * @param string $date_format |
|
485 | + * @param string $time_format |
|
486 | + * @param bool $EVT_ID |
|
487 | + * @param bool $echo |
|
488 | + * @return string |
|
489 | + * @throws EE_Error |
|
490 | + * @throws ReflectionException |
|
491 | + */ |
|
492 | + function espresso_event_date($date_format = '', $time_format = '', $EVT_ID = false, $echo = true) |
|
493 | + { |
|
494 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
495 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
496 | + $date_format = apply_filters('FHEE__espresso_event_date__date_format', $date_format); |
|
497 | + $time_format = apply_filters('FHEE__espresso_event_date__time_format', $time_format); |
|
498 | + if ($echo) { |
|
499 | + echo EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID); // already escaped |
|
500 | + return ''; |
|
501 | + } |
|
502 | + return EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID); |
|
503 | + |
|
504 | + } |
|
505 | 505 | } |
506 | 506 | |
507 | 507 | |
508 | 508 | if (! function_exists('espresso_list_of_event_dates')) { |
509 | - /** |
|
510 | - * espresso_list_of_event_dates |
|
511 | - * returns a unordered list of dates for an event |
|
512 | - * |
|
513 | - * @param int $EVT_ID |
|
514 | - * @param string $date_format |
|
515 | - * @param string $time_format |
|
516 | - * @param bool $echo |
|
517 | - * @param null $show_expired |
|
518 | - * @param bool $format |
|
519 | - * @param bool $add_breaks |
|
520 | - * @param null $limit |
|
521 | - * @return string |
|
522 | - * @throws EE_Error |
|
523 | - * @throws ReflectionException |
|
524 | - */ |
|
525 | - function espresso_list_of_event_dates( |
|
526 | - $EVT_ID = 0, |
|
527 | - $date_format = '', |
|
528 | - $time_format = '', |
|
529 | - $echo = true, |
|
530 | - $show_expired = null, |
|
531 | - $format = true, |
|
532 | - $add_breaks = true, |
|
533 | - $limit = null |
|
534 | - ) { |
|
535 | - global $allowedtags; |
|
536 | - $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
537 | - $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
538 | - $date_format = apply_filters('FHEE__espresso_list_of_event_dates__date_format', $date_format); |
|
539 | - $time_format = apply_filters('FHEE__espresso_list_of_event_dates__time_format', $time_format); |
|
540 | - $datetimes = EEH_Event_View::get_all_date_obj($EVT_ID, $show_expired, false, $limit); |
|
541 | - if (! $format) { |
|
542 | - return apply_filters('FHEE__espresso_list_of_event_dates__datetimes', $datetimes); |
|
543 | - } |
|
544 | - $newline = $add_breaks ? '<br />' : ''; |
|
545 | - if (is_array($datetimes) && ! empty($datetimes)) { |
|
546 | - global $post; |
|
547 | - $html = |
|
548 | - '<ul id="ee-event-datetimes-ul-' . esc_attr($post->ID) . '" class="ee-event-datetimes-ul ee-clearfix">'; |
|
549 | - foreach ($datetimes as $datetime) { |
|
550 | - if ($datetime instanceof EE_Datetime) { |
|
551 | - |
|
552 | - $datetime_name = $datetime->name(); |
|
553 | - $datetime_html = ! empty($datetime_name) |
|
554 | - ? ' |
|
509 | + /** |
|
510 | + * espresso_list_of_event_dates |
|
511 | + * returns a unordered list of dates for an event |
|
512 | + * |
|
513 | + * @param int $EVT_ID |
|
514 | + * @param string $date_format |
|
515 | + * @param string $time_format |
|
516 | + * @param bool $echo |
|
517 | + * @param null $show_expired |
|
518 | + * @param bool $format |
|
519 | + * @param bool $add_breaks |
|
520 | + * @param null $limit |
|
521 | + * @return string |
|
522 | + * @throws EE_Error |
|
523 | + * @throws ReflectionException |
|
524 | + */ |
|
525 | + function espresso_list_of_event_dates( |
|
526 | + $EVT_ID = 0, |
|
527 | + $date_format = '', |
|
528 | + $time_format = '', |
|
529 | + $echo = true, |
|
530 | + $show_expired = null, |
|
531 | + $format = true, |
|
532 | + $add_breaks = true, |
|
533 | + $limit = null |
|
534 | + ) { |
|
535 | + global $allowedtags; |
|
536 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
537 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
538 | + $date_format = apply_filters('FHEE__espresso_list_of_event_dates__date_format', $date_format); |
|
539 | + $time_format = apply_filters('FHEE__espresso_list_of_event_dates__time_format', $time_format); |
|
540 | + $datetimes = EEH_Event_View::get_all_date_obj($EVT_ID, $show_expired, false, $limit); |
|
541 | + if (! $format) { |
|
542 | + return apply_filters('FHEE__espresso_list_of_event_dates__datetimes', $datetimes); |
|
543 | + } |
|
544 | + $newline = $add_breaks ? '<br />' : ''; |
|
545 | + if (is_array($datetimes) && ! empty($datetimes)) { |
|
546 | + global $post; |
|
547 | + $html = |
|
548 | + '<ul id="ee-event-datetimes-ul-' . esc_attr($post->ID) . '" class="ee-event-datetimes-ul ee-clearfix">'; |
|
549 | + foreach ($datetimes as $datetime) { |
|
550 | + if ($datetime instanceof EE_Datetime) { |
|
551 | + |
|
552 | + $datetime_name = $datetime->name(); |
|
553 | + $datetime_html = ! empty($datetime_name) |
|
554 | + ? ' |
|
555 | 555 | <strong class="ee-event-datetimes-li-date-name"> |
556 | 556 | ' . esc_html($datetime_name) . ' |
557 | 557 | </strong>' . $newline |
558 | - : ''; |
|
558 | + : ''; |
|
559 | 559 | |
560 | - $datetime_description = $datetime->description(); |
|
561 | - $datetime_html .= ! empty($datetime_description) |
|
562 | - ? ' |
|
560 | + $datetime_description = $datetime->description(); |
|
561 | + $datetime_html .= ! empty($datetime_description) |
|
562 | + ? ' |
|
563 | 563 | <span class="ee-event-datetimes-li-date-desc"> |
564 | 564 | ' . wp_kses($datetime_description, $allowedtags) . ' |
565 | 565 | </span>' . $newline |
566 | - : ''; |
|
566 | + : ''; |
|
567 | 567 | |
568 | - $datetime_html .= ' |
|
568 | + $datetime_html .= ' |
|
569 | 569 | <span class="dashicons dashicons-calendar"></span> |
570 | 570 | <span class="ee-event-datetimes-li-daterange">' . $datetime->date_range($date_format) . '</span> |
571 | 571 | <br/> |
@@ -573,482 +573,482 @@ discard block |
||
573 | 573 | <span class="ee-event-datetimes-li-timerange">' . $datetime->time_range($time_format) . '</span> |
574 | 574 | '; |
575 | 575 | |
576 | - $datetime_html = apply_filters( |
|
577 | - 'FHEE__espresso_list_of_event_dates__datetime_html', |
|
578 | - $datetime_html, |
|
579 | - $datetime |
|
580 | - ); |
|
576 | + $datetime_html = apply_filters( |
|
577 | + 'FHEE__espresso_list_of_event_dates__datetime_html', |
|
578 | + $datetime_html, |
|
579 | + $datetime |
|
580 | + ); |
|
581 | 581 | |
582 | - $DTD_ID = esc_attr($datetime->ID()); |
|
583 | - $active_status = esc_attr(' ee-event-datetimes-li-' . $datetime->get_active_status()); |
|
582 | + $DTD_ID = esc_attr($datetime->ID()); |
|
583 | + $active_status = esc_attr(' ee-event-datetimes-li-' . $datetime->get_active_status()); |
|
584 | 584 | |
585 | - $html .= ' |
|
585 | + $html .= ' |
|
586 | 586 | <li id="ee-event-datetimes-li-' . $DTD_ID . '" class="ee-event-datetimes-li' . $active_status . '"> |
587 | 587 | ' . $datetime_html . ' |
588 | 588 | </li>'; |
589 | - } |
|
590 | - } |
|
591 | - $html .= '</ul>'; |
|
592 | - } else { |
|
593 | - $html = |
|
594 | - ' |
|
589 | + } |
|
590 | + } |
|
591 | + $html .= '</ul>'; |
|
592 | + } else { |
|
593 | + $html = |
|
594 | + ' |
|
595 | 595 | <p> |
596 | 596 | <span class="dashicons dashicons-marker pink-text"></span> |
597 | 597 | ' . esc_html__( |
598 | - 'There are no upcoming dates for this event.', |
|
599 | - 'event_espresso' |
|
600 | - ) . ' |
|
598 | + 'There are no upcoming dates for this event.', |
|
599 | + 'event_espresso' |
|
600 | + ) . ' |
|
601 | 601 | </p> |
602 | 602 | <br/>'; |
603 | - } |
|
604 | - if ($echo) { |
|
605 | - echo $html; // already escaped |
|
606 | - return ''; |
|
607 | - } |
|
608 | - return $html; |
|
609 | - } |
|
603 | + } |
|
604 | + if ($echo) { |
|
605 | + echo $html; // already escaped |
|
606 | + return ''; |
|
607 | + } |
|
608 | + return $html; |
|
609 | + } |
|
610 | 610 | } |
611 | 611 | |
612 | 612 | |
613 | 613 | if (! function_exists('espresso_event_end_date')) { |
614 | - /** |
|
615 | - * espresso_event_end_date |
|
616 | - * returns the last date for an event |
|
617 | - * |
|
618 | - * @param string $date_format |
|
619 | - * @param string $time_format |
|
620 | - * @param bool $EVT_ID |
|
621 | - * @param bool $echo |
|
622 | - * @return string |
|
623 | - * @throws EE_Error |
|
624 | - * @throws ReflectionException |
|
625 | - */ |
|
626 | - function espresso_event_end_date($date_format = '', $time_format = '', $EVT_ID = false, $echo = true) |
|
627 | - { |
|
628 | - $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
629 | - $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
630 | - $date_format = apply_filters('FHEE__espresso_event_end_date__date_format', $date_format); |
|
631 | - $time_format = apply_filters('FHEE__espresso_event_end_date__time_format', $time_format); |
|
632 | - if ($echo) { |
|
633 | - echo EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID); // already escaped |
|
634 | - return ''; |
|
635 | - } |
|
636 | - return EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID); |
|
637 | - } |
|
614 | + /** |
|
615 | + * espresso_event_end_date |
|
616 | + * returns the last date for an event |
|
617 | + * |
|
618 | + * @param string $date_format |
|
619 | + * @param string $time_format |
|
620 | + * @param bool $EVT_ID |
|
621 | + * @param bool $echo |
|
622 | + * @return string |
|
623 | + * @throws EE_Error |
|
624 | + * @throws ReflectionException |
|
625 | + */ |
|
626 | + function espresso_event_end_date($date_format = '', $time_format = '', $EVT_ID = false, $echo = true) |
|
627 | + { |
|
628 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
629 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
630 | + $date_format = apply_filters('FHEE__espresso_event_end_date__date_format', $date_format); |
|
631 | + $time_format = apply_filters('FHEE__espresso_event_end_date__time_format', $time_format); |
|
632 | + if ($echo) { |
|
633 | + echo EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID); // already escaped |
|
634 | + return ''; |
|
635 | + } |
|
636 | + return EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID); |
|
637 | + } |
|
638 | 638 | } |
639 | 639 | |
640 | 640 | if (! function_exists('espresso_event_date_range')) { |
641 | - /** |
|
642 | - * espresso_event_date_range |
|
643 | - * returns the first and last chronologically ordered dates for an event (if different) |
|
644 | - * |
|
645 | - * @param string $date_format |
|
646 | - * @param string $time_format |
|
647 | - * @param string $single_date_format |
|
648 | - * @param string $single_time_format |
|
649 | - * @param bool $EVT_ID |
|
650 | - * @param bool $echo |
|
651 | - * @return string |
|
652 | - * @throws EE_Error |
|
653 | - * @throws ReflectionException |
|
654 | - */ |
|
655 | - function espresso_event_date_range( |
|
656 | - $date_format = '', |
|
657 | - $time_format = '', |
|
658 | - $single_date_format = '', |
|
659 | - $single_time_format = '', |
|
660 | - $EVT_ID = false, |
|
661 | - $echo = true |
|
662 | - ) { |
|
663 | - // set and filter date and time formats when a range is returned |
|
664 | - $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
665 | - $date_format = apply_filters('FHEE__espresso_event_date_range__date_format', $date_format); |
|
666 | - // get the start and end date with NO time portion |
|
667 | - $the_event_date = EEH_Event_View::the_earliest_event_date($date_format, '', $EVT_ID); |
|
668 | - $the_event_end_date = EEH_Event_View::the_latest_event_date($date_format, '', $EVT_ID); |
|
669 | - // now we can determine if date range spans more than one day |
|
670 | - if ($the_event_date != $the_event_end_date) { |
|
671 | - $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
672 | - $time_format = apply_filters('FHEE__espresso_event_date_range__time_format', $time_format); |
|
673 | - $html = sprintf( |
|
674 | - /* translators: 1: first event date, 2: last event date */ |
|
675 | - esc_html__('%1$s - %2$s', 'event_espresso'), |
|
676 | - EEH_Event_View::the_earliest_event_date($date_format, $time_format, $EVT_ID), |
|
677 | - EEH_Event_View::the_latest_event_date($date_format, $time_format, $EVT_ID) |
|
678 | - ); |
|
679 | - } else { |
|
680 | - // set and filter date and time formats when only a single datetime is returned |
|
681 | - $single_date_format = ! empty($single_date_format) ? $single_date_format : get_option('date_format'); |
|
682 | - $single_time_format = ! empty($single_time_format) ? $single_time_format : get_option('time_format'); |
|
683 | - $single_date_format = |
|
684 | - apply_filters('FHEE__espresso_event_date_range__single_date_format', $single_date_format); |
|
685 | - $single_time_format = |
|
686 | - apply_filters('FHEE__espresso_event_date_range__single_time_format', $single_time_format); |
|
687 | - $html = |
|
688 | - EEH_Event_View::the_earliest_event_date($single_date_format, $single_time_format, $EVT_ID); |
|
689 | - } |
|
690 | - if ($echo) { |
|
691 | - echo $html; // already escaped |
|
692 | - return ''; |
|
693 | - } |
|
694 | - return $html; |
|
695 | - } |
|
641 | + /** |
|
642 | + * espresso_event_date_range |
|
643 | + * returns the first and last chronologically ordered dates for an event (if different) |
|
644 | + * |
|
645 | + * @param string $date_format |
|
646 | + * @param string $time_format |
|
647 | + * @param string $single_date_format |
|
648 | + * @param string $single_time_format |
|
649 | + * @param bool $EVT_ID |
|
650 | + * @param bool $echo |
|
651 | + * @return string |
|
652 | + * @throws EE_Error |
|
653 | + * @throws ReflectionException |
|
654 | + */ |
|
655 | + function espresso_event_date_range( |
|
656 | + $date_format = '', |
|
657 | + $time_format = '', |
|
658 | + $single_date_format = '', |
|
659 | + $single_time_format = '', |
|
660 | + $EVT_ID = false, |
|
661 | + $echo = true |
|
662 | + ) { |
|
663 | + // set and filter date and time formats when a range is returned |
|
664 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
665 | + $date_format = apply_filters('FHEE__espresso_event_date_range__date_format', $date_format); |
|
666 | + // get the start and end date with NO time portion |
|
667 | + $the_event_date = EEH_Event_View::the_earliest_event_date($date_format, '', $EVT_ID); |
|
668 | + $the_event_end_date = EEH_Event_View::the_latest_event_date($date_format, '', $EVT_ID); |
|
669 | + // now we can determine if date range spans more than one day |
|
670 | + if ($the_event_date != $the_event_end_date) { |
|
671 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
672 | + $time_format = apply_filters('FHEE__espresso_event_date_range__time_format', $time_format); |
|
673 | + $html = sprintf( |
|
674 | + /* translators: 1: first event date, 2: last event date */ |
|
675 | + esc_html__('%1$s - %2$s', 'event_espresso'), |
|
676 | + EEH_Event_View::the_earliest_event_date($date_format, $time_format, $EVT_ID), |
|
677 | + EEH_Event_View::the_latest_event_date($date_format, $time_format, $EVT_ID) |
|
678 | + ); |
|
679 | + } else { |
|
680 | + // set and filter date and time formats when only a single datetime is returned |
|
681 | + $single_date_format = ! empty($single_date_format) ? $single_date_format : get_option('date_format'); |
|
682 | + $single_time_format = ! empty($single_time_format) ? $single_time_format : get_option('time_format'); |
|
683 | + $single_date_format = |
|
684 | + apply_filters('FHEE__espresso_event_date_range__single_date_format', $single_date_format); |
|
685 | + $single_time_format = |
|
686 | + apply_filters('FHEE__espresso_event_date_range__single_time_format', $single_time_format); |
|
687 | + $html = |
|
688 | + EEH_Event_View::the_earliest_event_date($single_date_format, $single_time_format, $EVT_ID); |
|
689 | + } |
|
690 | + if ($echo) { |
|
691 | + echo $html; // already escaped |
|
692 | + return ''; |
|
693 | + } |
|
694 | + return $html; |
|
695 | + } |
|
696 | 696 | } |
697 | 697 | |
698 | 698 | if (! function_exists('espresso_next_upcoming_datetime_obj')) { |
699 | - /** |
|
700 | - * espresso_next_upcoming_datetime_obj |
|
701 | - * returns the next upcoming datetime object for an event |
|
702 | - * |
|
703 | - * @param int $EVT_ID |
|
704 | - * @return EE_Datetime|null |
|
705 | - * @throws EE_Error |
|
706 | - */ |
|
707 | - function espresso_next_upcoming_datetime_obj($EVT_ID = 0) |
|
708 | - { |
|
709 | - return EEH_Event_View::get_next_upcoming_date_obj($EVT_ID); |
|
710 | - } |
|
699 | + /** |
|
700 | + * espresso_next_upcoming_datetime_obj |
|
701 | + * returns the next upcoming datetime object for an event |
|
702 | + * |
|
703 | + * @param int $EVT_ID |
|
704 | + * @return EE_Datetime|null |
|
705 | + * @throws EE_Error |
|
706 | + */ |
|
707 | + function espresso_next_upcoming_datetime_obj($EVT_ID = 0) |
|
708 | + { |
|
709 | + return EEH_Event_View::get_next_upcoming_date_obj($EVT_ID); |
|
710 | + } |
|
711 | 711 | } |
712 | 712 | |
713 | 713 | if (! function_exists('espresso_next_upcoming_datetime')) { |
714 | - /** |
|
715 | - * espresso_next_upcoming_datetime |
|
716 | - * returns the start date and time for the next upcoming event. |
|
717 | - * |
|
718 | - * @param string $date_format |
|
719 | - * @param string $time_format |
|
720 | - * @param int $EVT_ID |
|
721 | - * @param bool $echo |
|
722 | - * @return string |
|
723 | - * @throws EE_Error |
|
724 | - * @throws ReflectionException |
|
725 | - */ |
|
726 | - function espresso_next_upcoming_datetime($date_format = '', $time_format = '', $EVT_ID = 0, $echo = true) |
|
727 | - { |
|
728 | - |
|
729 | - $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
730 | - $date_format = apply_filters('FHEE__espresso_next_upcoming_datetime__date_format', $date_format); |
|
731 | - |
|
732 | - $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
733 | - $time_format = apply_filters('FHEE__espresso_next_upcoming_datetime__time_format', $time_format); |
|
734 | - |
|
735 | - $datetime_format = trim($date_format . ' ' . $time_format); |
|
736 | - |
|
737 | - $datetime = espresso_next_upcoming_datetime_obj($EVT_ID); |
|
738 | - |
|
739 | - if (! $datetime instanceof EE_Datetime) { |
|
740 | - return ''; |
|
741 | - } |
|
742 | - if ($echo) { |
|
743 | - echo $datetime->get_i18n_datetime('DTT_EVT_start', $datetime_format); // already escaped |
|
744 | - return ''; |
|
745 | - } |
|
746 | - return $datetime->get_i18n_datetime('DTT_EVT_start', $datetime_format); |
|
747 | - } |
|
714 | + /** |
|
715 | + * espresso_next_upcoming_datetime |
|
716 | + * returns the start date and time for the next upcoming event. |
|
717 | + * |
|
718 | + * @param string $date_format |
|
719 | + * @param string $time_format |
|
720 | + * @param int $EVT_ID |
|
721 | + * @param bool $echo |
|
722 | + * @return string |
|
723 | + * @throws EE_Error |
|
724 | + * @throws ReflectionException |
|
725 | + */ |
|
726 | + function espresso_next_upcoming_datetime($date_format = '', $time_format = '', $EVT_ID = 0, $echo = true) |
|
727 | + { |
|
728 | + |
|
729 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
730 | + $date_format = apply_filters('FHEE__espresso_next_upcoming_datetime__date_format', $date_format); |
|
731 | + |
|
732 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
733 | + $time_format = apply_filters('FHEE__espresso_next_upcoming_datetime__time_format', $time_format); |
|
734 | + |
|
735 | + $datetime_format = trim($date_format . ' ' . $time_format); |
|
736 | + |
|
737 | + $datetime = espresso_next_upcoming_datetime_obj($EVT_ID); |
|
738 | + |
|
739 | + if (! $datetime instanceof EE_Datetime) { |
|
740 | + return ''; |
|
741 | + } |
|
742 | + if ($echo) { |
|
743 | + echo $datetime->get_i18n_datetime('DTT_EVT_start', $datetime_format); // already escaped |
|
744 | + return ''; |
|
745 | + } |
|
746 | + return $datetime->get_i18n_datetime('DTT_EVT_start', $datetime_format); |
|
747 | + } |
|
748 | 748 | } |
749 | 749 | |
750 | 750 | if (! function_exists('espresso_event_date_as_calendar_page')) { |
751 | - /** |
|
752 | - * espresso_event_date_as_calendar_page |
|
753 | - * returns the primary date for an event, stylized to appear as the page of a calendar |
|
754 | - * |
|
755 | - * @param bool $EVT_ID |
|
756 | - * @return void |
|
757 | - * @throws EE_Error |
|
758 | - * @throws ReflectionException |
|
759 | - */ |
|
760 | - function espresso_event_date_as_calendar_page($EVT_ID = false) |
|
761 | - { |
|
762 | - EEH_Event_View::event_date_as_calendar_page($EVT_ID); |
|
763 | - } |
|
751 | + /** |
|
752 | + * espresso_event_date_as_calendar_page |
|
753 | + * returns the primary date for an event, stylized to appear as the page of a calendar |
|
754 | + * |
|
755 | + * @param bool $EVT_ID |
|
756 | + * @return void |
|
757 | + * @throws EE_Error |
|
758 | + * @throws ReflectionException |
|
759 | + */ |
|
760 | + function espresso_event_date_as_calendar_page($EVT_ID = false) |
|
761 | + { |
|
762 | + EEH_Event_View::event_date_as_calendar_page($EVT_ID); |
|
763 | + } |
|
764 | 764 | } |
765 | 765 | |
766 | 766 | |
767 | 767 | if (! function_exists('espresso_event_link_url')) { |
768 | - /** |
|
769 | - * espresso_event_link_url |
|
770 | - * |
|
771 | - * @param int $EVT_ID |
|
772 | - * @param bool $echo |
|
773 | - * @return string |
|
774 | - * @throws EE_Error |
|
775 | - * @throws ReflectionException |
|
776 | - */ |
|
777 | - function espresso_event_link_url($EVT_ID = 0, $echo = true) |
|
778 | - { |
|
779 | - if ($echo) { |
|
780 | - echo EEH_Event_View::event_link_url($EVT_ID); // already escaped |
|
781 | - return ''; |
|
782 | - } |
|
783 | - return EEH_Event_View::event_link_url($EVT_ID); |
|
784 | - } |
|
768 | + /** |
|
769 | + * espresso_event_link_url |
|
770 | + * |
|
771 | + * @param int $EVT_ID |
|
772 | + * @param bool $echo |
|
773 | + * @return string |
|
774 | + * @throws EE_Error |
|
775 | + * @throws ReflectionException |
|
776 | + */ |
|
777 | + function espresso_event_link_url($EVT_ID = 0, $echo = true) |
|
778 | + { |
|
779 | + if ($echo) { |
|
780 | + echo EEH_Event_View::event_link_url($EVT_ID); // already escaped |
|
781 | + return ''; |
|
782 | + } |
|
783 | + return EEH_Event_View::event_link_url($EVT_ID); |
|
784 | + } |
|
785 | 785 | } |
786 | 786 | |
787 | 787 | |
788 | 788 | if (! function_exists('espresso_event_has_content_or_excerpt')) { |
789 | - /** |
|
790 | - * espresso_event_has_content_or_excerpt |
|
791 | - * |
|
792 | - * @access public |
|
793 | - * @param bool $EVT_ID |
|
794 | - * @return boolean |
|
795 | - * @throws EE_Error |
|
796 | - * @throws ReflectionException |
|
797 | - */ |
|
798 | - function espresso_event_has_content_or_excerpt($EVT_ID = false) |
|
799 | - { |
|
800 | - return EEH_Event_View::event_has_content_or_excerpt($EVT_ID); |
|
801 | - } |
|
789 | + /** |
|
790 | + * espresso_event_has_content_or_excerpt |
|
791 | + * |
|
792 | + * @access public |
|
793 | + * @param bool $EVT_ID |
|
794 | + * @return boolean |
|
795 | + * @throws EE_Error |
|
796 | + * @throws ReflectionException |
|
797 | + */ |
|
798 | + function espresso_event_has_content_or_excerpt($EVT_ID = false) |
|
799 | + { |
|
800 | + return EEH_Event_View::event_has_content_or_excerpt($EVT_ID); |
|
801 | + } |
|
802 | 802 | } |
803 | 803 | |
804 | 804 | |
805 | 805 | if (! function_exists('espresso_event_content_or_excerpt')) { |
806 | - /** |
|
807 | - * espresso_event_content_or_excerpt |
|
808 | - * |
|
809 | - * @param int $num_words |
|
810 | - * @param null $more |
|
811 | - * @param bool $echo |
|
812 | - * @return string |
|
813 | - */ |
|
814 | - function espresso_event_content_or_excerpt($num_words = 55, $more = null, $echo = true) |
|
815 | - { |
|
816 | - if ($echo) { |
|
817 | - echo EEH_Event_View::event_content_or_excerpt($num_words, $more); // already escaped |
|
818 | - return ''; |
|
819 | - } |
|
820 | - return EEH_Event_View::event_content_or_excerpt($num_words, $more); |
|
821 | - } |
|
806 | + /** |
|
807 | + * espresso_event_content_or_excerpt |
|
808 | + * |
|
809 | + * @param int $num_words |
|
810 | + * @param null $more |
|
811 | + * @param bool $echo |
|
812 | + * @return string |
|
813 | + */ |
|
814 | + function espresso_event_content_or_excerpt($num_words = 55, $more = null, $echo = true) |
|
815 | + { |
|
816 | + if ($echo) { |
|
817 | + echo EEH_Event_View::event_content_or_excerpt($num_words, $more); // already escaped |
|
818 | + return ''; |
|
819 | + } |
|
820 | + return EEH_Event_View::event_content_or_excerpt($num_words, $more); |
|
821 | + } |
|
822 | 822 | } |
823 | 823 | |
824 | 824 | |
825 | 825 | if (! function_exists('espresso_event_phone')) { |
826 | - /** |
|
827 | - * espresso_event_phone |
|
828 | - * |
|
829 | - * @param int $EVT_ID |
|
830 | - * @param bool $echo |
|
831 | - * @return string |
|
832 | - * @throws EE_Error |
|
833 | - * @throws ReflectionException |
|
834 | - */ |
|
835 | - function espresso_event_phone($EVT_ID = 0, $echo = true) |
|
836 | - { |
|
837 | - if ($echo) { |
|
838 | - echo EEH_Event_View::event_phone($EVT_ID); // already escaped |
|
839 | - return ''; |
|
840 | - } |
|
841 | - return EEH_Event_View::event_phone($EVT_ID); |
|
842 | - } |
|
826 | + /** |
|
827 | + * espresso_event_phone |
|
828 | + * |
|
829 | + * @param int $EVT_ID |
|
830 | + * @param bool $echo |
|
831 | + * @return string |
|
832 | + * @throws EE_Error |
|
833 | + * @throws ReflectionException |
|
834 | + */ |
|
835 | + function espresso_event_phone($EVT_ID = 0, $echo = true) |
|
836 | + { |
|
837 | + if ($echo) { |
|
838 | + echo EEH_Event_View::event_phone($EVT_ID); // already escaped |
|
839 | + return ''; |
|
840 | + } |
|
841 | + return EEH_Event_View::event_phone($EVT_ID); |
|
842 | + } |
|
843 | 843 | } |
844 | 844 | |
845 | 845 | |
846 | 846 | if (! function_exists('espresso_edit_event_link')) { |
847 | - /** |
|
848 | - * espresso_edit_event_link |
|
849 | - * returns a link to edit an event |
|
850 | - * |
|
851 | - * @param int $EVT_ID |
|
852 | - * @param bool $echo |
|
853 | - * @return string |
|
854 | - * @throws EE_Error |
|
855 | - * @throws ReflectionException |
|
856 | - */ |
|
857 | - function espresso_edit_event_link($EVT_ID = 0, $echo = true) |
|
858 | - { |
|
859 | - if ($echo) { |
|
860 | - echo EEH_Event_View::edit_event_link($EVT_ID); // already escaped |
|
861 | - return ''; |
|
862 | - } |
|
863 | - return EEH_Event_View::edit_event_link($EVT_ID); |
|
864 | - } |
|
847 | + /** |
|
848 | + * espresso_edit_event_link |
|
849 | + * returns a link to edit an event |
|
850 | + * |
|
851 | + * @param int $EVT_ID |
|
852 | + * @param bool $echo |
|
853 | + * @return string |
|
854 | + * @throws EE_Error |
|
855 | + * @throws ReflectionException |
|
856 | + */ |
|
857 | + function espresso_edit_event_link($EVT_ID = 0, $echo = true) |
|
858 | + { |
|
859 | + if ($echo) { |
|
860 | + echo EEH_Event_View::edit_event_link($EVT_ID); // already escaped |
|
861 | + return ''; |
|
862 | + } |
|
863 | + return EEH_Event_View::edit_event_link($EVT_ID); |
|
864 | + } |
|
865 | 865 | } |
866 | 866 | |
867 | 867 | |
868 | 868 | if (! function_exists('espresso_organization_name')) { |
869 | - /** |
|
870 | - * espresso_organization_name |
|
871 | - * |
|
872 | - * @param bool $echo |
|
873 | - * @return string |
|
874 | - * @throws EE_Error |
|
875 | - */ |
|
876 | - function espresso_organization_name($echo = true) |
|
877 | - { |
|
878 | - if ($echo) { |
|
879 | - echo EE_Registry::instance()->CFG->organization->get_pretty('name'); // already escaped |
|
880 | - return ''; |
|
881 | - } |
|
882 | - return EE_Registry::instance()->CFG->organization->get_pretty('name'); |
|
883 | - } |
|
869 | + /** |
|
870 | + * espresso_organization_name |
|
871 | + * |
|
872 | + * @param bool $echo |
|
873 | + * @return string |
|
874 | + * @throws EE_Error |
|
875 | + */ |
|
876 | + function espresso_organization_name($echo = true) |
|
877 | + { |
|
878 | + if ($echo) { |
|
879 | + echo EE_Registry::instance()->CFG->organization->get_pretty('name'); // already escaped |
|
880 | + return ''; |
|
881 | + } |
|
882 | + return EE_Registry::instance()->CFG->organization->get_pretty('name'); |
|
883 | + } |
|
884 | 884 | } |
885 | 885 | |
886 | 886 | if (! function_exists('espresso_organization_address')) { |
887 | - /** |
|
888 | - * espresso_organization_address |
|
889 | - * |
|
890 | - * @param string $type |
|
891 | - * @return string |
|
892 | - */ |
|
893 | - function espresso_organization_address($type = 'inline') |
|
894 | - { |
|
895 | - if (EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config) { |
|
896 | - $address = new EventEspresso\core\domain\entities\GenericAddress( |
|
897 | - EE_Registry::instance()->CFG->organization->address_1, |
|
898 | - EE_Registry::instance()->CFG->organization->address_2, |
|
899 | - EE_Registry::instance()->CFG->organization->city, |
|
900 | - EE_Registry::instance()->CFG->organization->STA_ID, |
|
901 | - EE_Registry::instance()->CFG->organization->zip, |
|
902 | - EE_Registry::instance()->CFG->organization->CNT_ISO |
|
903 | - ); |
|
904 | - return EEH_Address::format($address, $type); |
|
905 | - } |
|
906 | - return ''; |
|
907 | - } |
|
887 | + /** |
|
888 | + * espresso_organization_address |
|
889 | + * |
|
890 | + * @param string $type |
|
891 | + * @return string |
|
892 | + */ |
|
893 | + function espresso_organization_address($type = 'inline') |
|
894 | + { |
|
895 | + if (EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config) { |
|
896 | + $address = new EventEspresso\core\domain\entities\GenericAddress( |
|
897 | + EE_Registry::instance()->CFG->organization->address_1, |
|
898 | + EE_Registry::instance()->CFG->organization->address_2, |
|
899 | + EE_Registry::instance()->CFG->organization->city, |
|
900 | + EE_Registry::instance()->CFG->organization->STA_ID, |
|
901 | + EE_Registry::instance()->CFG->organization->zip, |
|
902 | + EE_Registry::instance()->CFG->organization->CNT_ISO |
|
903 | + ); |
|
904 | + return EEH_Address::format($address, $type); |
|
905 | + } |
|
906 | + return ''; |
|
907 | + } |
|
908 | 908 | } |
909 | 909 | |
910 | 910 | if (! function_exists('espresso_organization_email')) { |
911 | - /** |
|
912 | - * espresso_organization_email |
|
913 | - * |
|
914 | - * @param bool $echo |
|
915 | - * @return string |
|
916 | - * @throws EE_Error |
|
917 | - */ |
|
918 | - function espresso_organization_email($echo = true) |
|
919 | - { |
|
920 | - if ($echo) { |
|
921 | - echo EE_Registry::instance()->CFG->organization->get_pretty('email'); // already escaped |
|
922 | - return ''; |
|
923 | - } |
|
924 | - return EE_Registry::instance()->CFG->organization->get_pretty('email'); |
|
925 | - } |
|
911 | + /** |
|
912 | + * espresso_organization_email |
|
913 | + * |
|
914 | + * @param bool $echo |
|
915 | + * @return string |
|
916 | + * @throws EE_Error |
|
917 | + */ |
|
918 | + function espresso_organization_email($echo = true) |
|
919 | + { |
|
920 | + if ($echo) { |
|
921 | + echo EE_Registry::instance()->CFG->organization->get_pretty('email'); // already escaped |
|
922 | + return ''; |
|
923 | + } |
|
924 | + return EE_Registry::instance()->CFG->organization->get_pretty('email'); |
|
925 | + } |
|
926 | 926 | } |
927 | 927 | |
928 | 928 | if (! function_exists('espresso_organization_logo_url')) { |
929 | - /** |
|
930 | - * espresso_organization_logo_url |
|
931 | - * |
|
932 | - * @param bool $echo |
|
933 | - * @return string |
|
934 | - * @throws EE_Error |
|
935 | - */ |
|
936 | - function espresso_organization_logo_url($echo = true) |
|
937 | - { |
|
938 | - if ($echo) { |
|
939 | - echo EE_Registry::instance()->CFG->organization->get_pretty('logo_url'); // already escaped |
|
940 | - return ''; |
|
941 | - } |
|
942 | - return EE_Registry::instance()->CFG->organization->get_pretty('logo_url'); |
|
943 | - } |
|
929 | + /** |
|
930 | + * espresso_organization_logo_url |
|
931 | + * |
|
932 | + * @param bool $echo |
|
933 | + * @return string |
|
934 | + * @throws EE_Error |
|
935 | + */ |
|
936 | + function espresso_organization_logo_url($echo = true) |
|
937 | + { |
|
938 | + if ($echo) { |
|
939 | + echo EE_Registry::instance()->CFG->organization->get_pretty('logo_url'); // already escaped |
|
940 | + return ''; |
|
941 | + } |
|
942 | + return EE_Registry::instance()->CFG->organization->get_pretty('logo_url'); |
|
943 | + } |
|
944 | 944 | } |
945 | 945 | |
946 | 946 | if (! function_exists('espresso_organization_facebook')) { |
947 | - /** |
|
948 | - * espresso_organization_facebook |
|
949 | - * |
|
950 | - * @param bool $echo |
|
951 | - * @return string |
|
952 | - * @throws EE_Error |
|
953 | - */ |
|
954 | - function espresso_organization_facebook($echo = true) |
|
955 | - { |
|
956 | - if ($echo) { |
|
957 | - echo EE_Registry::instance()->CFG->organization->get_pretty('facebook'); // already escaped |
|
958 | - return ''; |
|
959 | - } |
|
960 | - return EE_Registry::instance()->CFG->organization->get_pretty('facebook'); |
|
961 | - } |
|
947 | + /** |
|
948 | + * espresso_organization_facebook |
|
949 | + * |
|
950 | + * @param bool $echo |
|
951 | + * @return string |
|
952 | + * @throws EE_Error |
|
953 | + */ |
|
954 | + function espresso_organization_facebook($echo = true) |
|
955 | + { |
|
956 | + if ($echo) { |
|
957 | + echo EE_Registry::instance()->CFG->organization->get_pretty('facebook'); // already escaped |
|
958 | + return ''; |
|
959 | + } |
|
960 | + return EE_Registry::instance()->CFG->organization->get_pretty('facebook'); |
|
961 | + } |
|
962 | 962 | } |
963 | 963 | |
964 | 964 | if (! function_exists('espresso_organization_twitter')) { |
965 | - /** |
|
966 | - * espresso_organization_twitter |
|
967 | - * |
|
968 | - * @param bool $echo |
|
969 | - * @return string |
|
970 | - * @throws EE_Error |
|
971 | - */ |
|
972 | - function espresso_organization_twitter($echo = true) |
|
973 | - { |
|
974 | - if ($echo) { |
|
975 | - echo EE_Registry::instance()->CFG->organization->get_pretty('twitter'); // already escaped |
|
976 | - return ''; |
|
977 | - } |
|
978 | - return EE_Registry::instance()->CFG->organization->get_pretty('twitter'); |
|
979 | - } |
|
965 | + /** |
|
966 | + * espresso_organization_twitter |
|
967 | + * |
|
968 | + * @param bool $echo |
|
969 | + * @return string |
|
970 | + * @throws EE_Error |
|
971 | + */ |
|
972 | + function espresso_organization_twitter($echo = true) |
|
973 | + { |
|
974 | + if ($echo) { |
|
975 | + echo EE_Registry::instance()->CFG->organization->get_pretty('twitter'); // already escaped |
|
976 | + return ''; |
|
977 | + } |
|
978 | + return EE_Registry::instance()->CFG->organization->get_pretty('twitter'); |
|
979 | + } |
|
980 | 980 | } |
981 | 981 | |
982 | 982 | if (! function_exists('espresso_organization_linkedin')) { |
983 | - /** |
|
984 | - * espresso_organization_linkedin |
|
985 | - * |
|
986 | - * @param bool $echo |
|
987 | - * @return string |
|
988 | - * @throws EE_Error |
|
989 | - */ |
|
990 | - function espresso_organization_linkedin($echo = true) |
|
991 | - { |
|
992 | - if ($echo) { |
|
993 | - echo EE_Registry::instance()->CFG->organization->get_pretty('linkedin'); // already escaped |
|
994 | - return ''; |
|
995 | - } |
|
996 | - return EE_Registry::instance()->CFG->organization->get_pretty('linkedin'); |
|
997 | - } |
|
983 | + /** |
|
984 | + * espresso_organization_linkedin |
|
985 | + * |
|
986 | + * @param bool $echo |
|
987 | + * @return string |
|
988 | + * @throws EE_Error |
|
989 | + */ |
|
990 | + function espresso_organization_linkedin($echo = true) |
|
991 | + { |
|
992 | + if ($echo) { |
|
993 | + echo EE_Registry::instance()->CFG->organization->get_pretty('linkedin'); // already escaped |
|
994 | + return ''; |
|
995 | + } |
|
996 | + return EE_Registry::instance()->CFG->organization->get_pretty('linkedin'); |
|
997 | + } |
|
998 | 998 | } |
999 | 999 | |
1000 | 1000 | if (! function_exists('espresso_organization_pinterest')) { |
1001 | - /** |
|
1002 | - * espresso_organization_pinterest |
|
1003 | - * |
|
1004 | - * @param bool $echo |
|
1005 | - * @return string |
|
1006 | - * @throws EE_Error |
|
1007 | - */ |
|
1008 | - function espresso_organization_pinterest($echo = true) |
|
1009 | - { |
|
1010 | - if ($echo) { |
|
1011 | - echo EE_Registry::instance()->CFG->organization->get_pretty('pinterest'); // already escaped |
|
1012 | - return ''; |
|
1013 | - } |
|
1014 | - return EE_Registry::instance()->CFG->organization->get_pretty('pinterest'); |
|
1015 | - } |
|
1001 | + /** |
|
1002 | + * espresso_organization_pinterest |
|
1003 | + * |
|
1004 | + * @param bool $echo |
|
1005 | + * @return string |
|
1006 | + * @throws EE_Error |
|
1007 | + */ |
|
1008 | + function espresso_organization_pinterest($echo = true) |
|
1009 | + { |
|
1010 | + if ($echo) { |
|
1011 | + echo EE_Registry::instance()->CFG->organization->get_pretty('pinterest'); // already escaped |
|
1012 | + return ''; |
|
1013 | + } |
|
1014 | + return EE_Registry::instance()->CFG->organization->get_pretty('pinterest'); |
|
1015 | + } |
|
1016 | 1016 | } |
1017 | 1017 | |
1018 | 1018 | if (! function_exists('espresso_organization_google')) { |
1019 | - /** |
|
1020 | - * espresso_organization_google |
|
1021 | - * |
|
1022 | - * @param bool $echo |
|
1023 | - * @return string |
|
1024 | - * @throws EE_Error |
|
1025 | - */ |
|
1026 | - function espresso_organization_google($echo = true) |
|
1027 | - { |
|
1028 | - if ($echo) { |
|
1029 | - echo EE_Registry::instance()->CFG->organization->get_pretty('google'); // already escaped |
|
1030 | - return ''; |
|
1031 | - } |
|
1032 | - return EE_Registry::instance()->CFG->organization->get_pretty('google'); |
|
1033 | - } |
|
1019 | + /** |
|
1020 | + * espresso_organization_google |
|
1021 | + * |
|
1022 | + * @param bool $echo |
|
1023 | + * @return string |
|
1024 | + * @throws EE_Error |
|
1025 | + */ |
|
1026 | + function espresso_organization_google($echo = true) |
|
1027 | + { |
|
1028 | + if ($echo) { |
|
1029 | + echo EE_Registry::instance()->CFG->organization->get_pretty('google'); // already escaped |
|
1030 | + return ''; |
|
1031 | + } |
|
1032 | + return EE_Registry::instance()->CFG->organization->get_pretty('google'); |
|
1033 | + } |
|
1034 | 1034 | } |
1035 | 1035 | |
1036 | 1036 | if (! function_exists('espresso_organization_instagram')) { |
1037 | - /** |
|
1038 | - * espresso_organization_instagram |
|
1039 | - * |
|
1040 | - * @param bool $echo |
|
1041 | - * @return string |
|
1042 | - * @throws EE_Error |
|
1043 | - */ |
|
1044 | - function espresso_organization_instagram($echo = true) |
|
1045 | - { |
|
1046 | - if ($echo) { |
|
1047 | - echo EE_Registry::instance()->CFG->organization->get_pretty('instagram'); // already escaped |
|
1048 | - return ''; |
|
1049 | - } |
|
1050 | - return EE_Registry::instance()->CFG->organization->get_pretty('instagram'); |
|
1051 | - } |
|
1037 | + /** |
|
1038 | + * espresso_organization_instagram |
|
1039 | + * |
|
1040 | + * @param bool $echo |
|
1041 | + * @return string |
|
1042 | + * @throws EE_Error |
|
1043 | + */ |
|
1044 | + function espresso_organization_instagram($echo = true) |
|
1045 | + { |
|
1046 | + if ($echo) { |
|
1047 | + echo EE_Registry::instance()->CFG->organization->get_pretty('instagram'); // already escaped |
|
1048 | + return ''; |
|
1049 | + } |
|
1050 | + return EE_Registry::instance()->CFG->organization->get_pretty('instagram'); |
|
1051 | + } |
|
1052 | 1052 | } |
1053 | 1053 | |
1054 | 1054 | |
@@ -1056,345 +1056,345 @@ discard block |
||
1056 | 1056 | |
1057 | 1057 | |
1058 | 1058 | if (! function_exists('espresso_event_venues')) { |
1059 | - /** |
|
1060 | - * espresso_event_venues |
|
1061 | - * |
|
1062 | - * @return array all venues related to an event |
|
1063 | - * @throws EE_Error |
|
1064 | - * @throws ReflectionException |
|
1065 | - */ |
|
1066 | - function espresso_event_venues() |
|
1067 | - { |
|
1068 | - return EEH_Venue_View::get_event_venues(); |
|
1069 | - } |
|
1059 | + /** |
|
1060 | + * espresso_event_venues |
|
1061 | + * |
|
1062 | + * @return array all venues related to an event |
|
1063 | + * @throws EE_Error |
|
1064 | + * @throws ReflectionException |
|
1065 | + */ |
|
1066 | + function espresso_event_venues() |
|
1067 | + { |
|
1068 | + return EEH_Venue_View::get_event_venues(); |
|
1069 | + } |
|
1070 | 1070 | } |
1071 | 1071 | |
1072 | 1072 | |
1073 | 1073 | if (! function_exists('espresso_venue_id')) { |
1074 | - /** |
|
1075 | - * espresso_venue_name |
|
1076 | - * |
|
1077 | - * @access public |
|
1078 | - * @param int $EVT_ID |
|
1079 | - * @return string |
|
1080 | - * @throws EE_Error |
|
1081 | - * @throws ReflectionException |
|
1082 | - */ |
|
1083 | - function espresso_venue_id($EVT_ID = 0) |
|
1084 | - { |
|
1085 | - $venue = EEH_Venue_View::get_venue($EVT_ID); |
|
1086 | - return $venue instanceof EE_Venue ? $venue->ID() : 0; |
|
1087 | - } |
|
1074 | + /** |
|
1075 | + * espresso_venue_name |
|
1076 | + * |
|
1077 | + * @access public |
|
1078 | + * @param int $EVT_ID |
|
1079 | + * @return string |
|
1080 | + * @throws EE_Error |
|
1081 | + * @throws ReflectionException |
|
1082 | + */ |
|
1083 | + function espresso_venue_id($EVT_ID = 0) |
|
1084 | + { |
|
1085 | + $venue = EEH_Venue_View::get_venue($EVT_ID); |
|
1086 | + return $venue instanceof EE_Venue ? $venue->ID() : 0; |
|
1087 | + } |
|
1088 | 1088 | } |
1089 | 1089 | |
1090 | 1090 | |
1091 | 1091 | if (! function_exists('espresso_is_venue_private')) { |
1092 | - /** |
|
1093 | - * Return whether a venue is private or not. |
|
1094 | - * |
|
1095 | - * @param int $VNU_ID optional, the venue id to check. |
|
1096 | - * |
|
1097 | - * @return bool | null |
|
1098 | - * @throws EE_Error |
|
1099 | - * @throws ReflectionException |
|
1100 | - * @see EEH_Venue_View::get_venue() for more info on expected return results. |
|
1101 | - */ |
|
1102 | - function espresso_is_venue_private($VNU_ID = 0) |
|
1103 | - { |
|
1104 | - return EEH_Venue_View::is_venue_private($VNU_ID); |
|
1105 | - } |
|
1092 | + /** |
|
1093 | + * Return whether a venue is private or not. |
|
1094 | + * |
|
1095 | + * @param int $VNU_ID optional, the venue id to check. |
|
1096 | + * |
|
1097 | + * @return bool | null |
|
1098 | + * @throws EE_Error |
|
1099 | + * @throws ReflectionException |
|
1100 | + * @see EEH_Venue_View::get_venue() for more info on expected return results. |
|
1101 | + */ |
|
1102 | + function espresso_is_venue_private($VNU_ID = 0) |
|
1103 | + { |
|
1104 | + return EEH_Venue_View::is_venue_private($VNU_ID); |
|
1105 | + } |
|
1106 | 1106 | } |
1107 | 1107 | |
1108 | 1108 | |
1109 | 1109 | if (! function_exists('espresso_venue_is_password_protected')) { |
1110 | - /** |
|
1111 | - * returns true or false if a venue is password protected or not |
|
1112 | - * |
|
1113 | - * @param int $VNU_ID optional, the venue id to check. |
|
1114 | - * @return bool |
|
1115 | - * @throws EE_Error |
|
1116 | - * @throws ReflectionException |
|
1117 | - */ |
|
1118 | - function espresso_venue_is_password_protected($VNU_ID = 0) |
|
1119 | - { |
|
1120 | - EE_Registry::instance()->load_helper('Venue_View'); |
|
1121 | - return EEH_Venue_View::is_venue_password_protected($VNU_ID); |
|
1122 | - } |
|
1110 | + /** |
|
1111 | + * returns true or false if a venue is password protected or not |
|
1112 | + * |
|
1113 | + * @param int $VNU_ID optional, the venue id to check. |
|
1114 | + * @return bool |
|
1115 | + * @throws EE_Error |
|
1116 | + * @throws ReflectionException |
|
1117 | + */ |
|
1118 | + function espresso_venue_is_password_protected($VNU_ID = 0) |
|
1119 | + { |
|
1120 | + EE_Registry::instance()->load_helper('Venue_View'); |
|
1121 | + return EEH_Venue_View::is_venue_password_protected($VNU_ID); |
|
1122 | + } |
|
1123 | 1123 | } |
1124 | 1124 | |
1125 | 1125 | |
1126 | 1126 | if (! function_exists('espresso_password_protected_venue_form')) { |
1127 | - /** |
|
1128 | - * Returns a password form if venue is password protected. |
|
1129 | - * |
|
1130 | - * @param int $VNU_ID optional, the venue id to check. |
|
1131 | - * @return string |
|
1132 | - * @throws EE_Error |
|
1133 | - * @throws ReflectionException |
|
1134 | - */ |
|
1135 | - function espresso_password_protected_venue_form($VNU_ID = 0) |
|
1136 | - { |
|
1137 | - EE_Registry::instance()->load_helper('Venue_View'); |
|
1138 | - return EEH_Venue_View::password_protected_venue_form($VNU_ID); |
|
1139 | - } |
|
1127 | + /** |
|
1128 | + * Returns a password form if venue is password protected. |
|
1129 | + * |
|
1130 | + * @param int $VNU_ID optional, the venue id to check. |
|
1131 | + * @return string |
|
1132 | + * @throws EE_Error |
|
1133 | + * @throws ReflectionException |
|
1134 | + */ |
|
1135 | + function espresso_password_protected_venue_form($VNU_ID = 0) |
|
1136 | + { |
|
1137 | + EE_Registry::instance()->load_helper('Venue_View'); |
|
1138 | + return EEH_Venue_View::password_protected_venue_form($VNU_ID); |
|
1139 | + } |
|
1140 | 1140 | } |
1141 | 1141 | |
1142 | 1142 | |
1143 | 1143 | if (! function_exists('espresso_venue_name')) { |
1144 | - /** |
|
1145 | - * espresso_venue_name |
|
1146 | - * |
|
1147 | - * @access public |
|
1148 | - * @param int $VNU_ID |
|
1149 | - * @param string $link_to - options( details, website, none ) whether to turn Venue name into a clickable link to the Venue's details page or website |
|
1150 | - * @param bool $echo |
|
1151 | - * @return string |
|
1152 | - * @throws EE_Error |
|
1153 | - * @throws ReflectionException |
|
1154 | - */ |
|
1155 | - function espresso_venue_name($VNU_ID = 0, $link_to = 'details', $echo = true) |
|
1156 | - { |
|
1157 | - if ($echo) { |
|
1158 | - echo EEH_Venue_View::venue_name($link_to, $VNU_ID); // already escaped |
|
1159 | - return ''; |
|
1160 | - } |
|
1161 | - return EEH_Venue_View::venue_name($link_to, $VNU_ID); |
|
1162 | - } |
|
1144 | + /** |
|
1145 | + * espresso_venue_name |
|
1146 | + * |
|
1147 | + * @access public |
|
1148 | + * @param int $VNU_ID |
|
1149 | + * @param string $link_to - options( details, website, none ) whether to turn Venue name into a clickable link to the Venue's details page or website |
|
1150 | + * @param bool $echo |
|
1151 | + * @return string |
|
1152 | + * @throws EE_Error |
|
1153 | + * @throws ReflectionException |
|
1154 | + */ |
|
1155 | + function espresso_venue_name($VNU_ID = 0, $link_to = 'details', $echo = true) |
|
1156 | + { |
|
1157 | + if ($echo) { |
|
1158 | + echo EEH_Venue_View::venue_name($link_to, $VNU_ID); // already escaped |
|
1159 | + return ''; |
|
1160 | + } |
|
1161 | + return EEH_Venue_View::venue_name($link_to, $VNU_ID); |
|
1162 | + } |
|
1163 | 1163 | } |
1164 | 1164 | |
1165 | 1165 | |
1166 | 1166 | if (! function_exists('espresso_venue_link')) { |
1167 | - /** |
|
1168 | - * espresso_venue_link |
|
1169 | - * |
|
1170 | - * @access public |
|
1171 | - * @param int $VNU_ID |
|
1172 | - * @param string $text |
|
1173 | - * @return string |
|
1174 | - * @throws EE_Error |
|
1175 | - * @throws ReflectionException |
|
1176 | - */ |
|
1177 | - function espresso_venue_link($VNU_ID = 0, $text = '') |
|
1178 | - { |
|
1179 | - return EEH_Venue_View::venue_details_link($VNU_ID, $text); |
|
1180 | - } |
|
1167 | + /** |
|
1168 | + * espresso_venue_link |
|
1169 | + * |
|
1170 | + * @access public |
|
1171 | + * @param int $VNU_ID |
|
1172 | + * @param string $text |
|
1173 | + * @return string |
|
1174 | + * @throws EE_Error |
|
1175 | + * @throws ReflectionException |
|
1176 | + */ |
|
1177 | + function espresso_venue_link($VNU_ID = 0, $text = '') |
|
1178 | + { |
|
1179 | + return EEH_Venue_View::venue_details_link($VNU_ID, $text); |
|
1180 | + } |
|
1181 | 1181 | } |
1182 | 1182 | |
1183 | 1183 | |
1184 | 1184 | if (! function_exists('espresso_venue_description')) { |
1185 | - /** |
|
1186 | - * espresso_venue_description |
|
1187 | - * |
|
1188 | - * @access public |
|
1189 | - * @param bool $VNU_ID |
|
1190 | - * @param bool $echo |
|
1191 | - * @return string |
|
1192 | - * @throws EE_Error |
|
1193 | - * @throws ReflectionException |
|
1194 | - */ |
|
1195 | - function espresso_venue_description($VNU_ID = false, $echo = true) |
|
1196 | - { |
|
1197 | - if ($echo) { |
|
1198 | - echo EEH_Venue_View::venue_description($VNU_ID); // already escaped |
|
1199 | - return ''; |
|
1200 | - } |
|
1201 | - return EEH_Venue_View::venue_description($VNU_ID); |
|
1202 | - } |
|
1185 | + /** |
|
1186 | + * espresso_venue_description |
|
1187 | + * |
|
1188 | + * @access public |
|
1189 | + * @param bool $VNU_ID |
|
1190 | + * @param bool $echo |
|
1191 | + * @return string |
|
1192 | + * @throws EE_Error |
|
1193 | + * @throws ReflectionException |
|
1194 | + */ |
|
1195 | + function espresso_venue_description($VNU_ID = false, $echo = true) |
|
1196 | + { |
|
1197 | + if ($echo) { |
|
1198 | + echo EEH_Venue_View::venue_description($VNU_ID); // already escaped |
|
1199 | + return ''; |
|
1200 | + } |
|
1201 | + return EEH_Venue_View::venue_description($VNU_ID); |
|
1202 | + } |
|
1203 | 1203 | } |
1204 | 1204 | |
1205 | 1205 | |
1206 | 1206 | if (! function_exists('espresso_venue_excerpt')) { |
1207 | - /** |
|
1208 | - * espresso_venue_excerpt |
|
1209 | - * |
|
1210 | - * @access public |
|
1211 | - * @param int $VNU_ID |
|
1212 | - * @param bool $echo |
|
1213 | - * @return string |
|
1214 | - * @throws EE_Error |
|
1215 | - * @throws ReflectionException |
|
1216 | - */ |
|
1217 | - function espresso_venue_excerpt($VNU_ID = 0, $echo = true) |
|
1218 | - { |
|
1219 | - if ($echo) { |
|
1220 | - echo EEH_Venue_View::venue_excerpt($VNU_ID); // already escaped |
|
1221 | - return ''; |
|
1222 | - } |
|
1223 | - return EEH_Venue_View::venue_excerpt($VNU_ID); |
|
1224 | - } |
|
1207 | + /** |
|
1208 | + * espresso_venue_excerpt |
|
1209 | + * |
|
1210 | + * @access public |
|
1211 | + * @param int $VNU_ID |
|
1212 | + * @param bool $echo |
|
1213 | + * @return string |
|
1214 | + * @throws EE_Error |
|
1215 | + * @throws ReflectionException |
|
1216 | + */ |
|
1217 | + function espresso_venue_excerpt($VNU_ID = 0, $echo = true) |
|
1218 | + { |
|
1219 | + if ($echo) { |
|
1220 | + echo EEH_Venue_View::venue_excerpt($VNU_ID); // already escaped |
|
1221 | + return ''; |
|
1222 | + } |
|
1223 | + return EEH_Venue_View::venue_excerpt($VNU_ID); |
|
1224 | + } |
|
1225 | 1225 | } |
1226 | 1226 | |
1227 | 1227 | |
1228 | 1228 | if (! function_exists('espresso_venue_categories')) { |
1229 | - /** |
|
1230 | - * espresso_venue_categories |
|
1231 | - * returns the terms associated with a venue |
|
1232 | - * |
|
1233 | - * @param int $VNU_ID |
|
1234 | - * @param bool $hide_uncategorized |
|
1235 | - * @param bool $echo |
|
1236 | - * @return string |
|
1237 | - * @throws EE_Error |
|
1238 | - * @throws ReflectionException |
|
1239 | - */ |
|
1240 | - function espresso_venue_categories($VNU_ID = 0, $hide_uncategorized = true, $echo = true) |
|
1241 | - { |
|
1242 | - if ($echo) { |
|
1243 | - echo EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized); // already escaped |
|
1244 | - return ''; |
|
1245 | - } |
|
1246 | - return EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized); |
|
1247 | - } |
|
1229 | + /** |
|
1230 | + * espresso_venue_categories |
|
1231 | + * returns the terms associated with a venue |
|
1232 | + * |
|
1233 | + * @param int $VNU_ID |
|
1234 | + * @param bool $hide_uncategorized |
|
1235 | + * @param bool $echo |
|
1236 | + * @return string |
|
1237 | + * @throws EE_Error |
|
1238 | + * @throws ReflectionException |
|
1239 | + */ |
|
1240 | + function espresso_venue_categories($VNU_ID = 0, $hide_uncategorized = true, $echo = true) |
|
1241 | + { |
|
1242 | + if ($echo) { |
|
1243 | + echo EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized); // already escaped |
|
1244 | + return ''; |
|
1245 | + } |
|
1246 | + return EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized); |
|
1247 | + } |
|
1248 | 1248 | } |
1249 | 1249 | |
1250 | 1250 | |
1251 | 1251 | if (! function_exists('espresso_venue_address')) { |
1252 | - /** |
|
1253 | - * espresso_venue_address |
|
1254 | - * returns a formatted block of html for displaying a venue's address |
|
1255 | - * |
|
1256 | - * @param string $type 'inline' or 'multiline' |
|
1257 | - * @param int $VNU_ID |
|
1258 | - * @param bool $echo |
|
1259 | - * @return string |
|
1260 | - * @throws EE_Error |
|
1261 | - * @throws ReflectionException |
|
1262 | - */ |
|
1263 | - function espresso_venue_address($type = 'multiline', $VNU_ID = 0, $echo = true) |
|
1264 | - { |
|
1265 | - if ($echo) { |
|
1266 | - echo EEH_Venue_View::venue_address($type, $VNU_ID); // already escaped |
|
1267 | - return ''; |
|
1268 | - } |
|
1269 | - return EEH_Venue_View::venue_address($type, $VNU_ID); |
|
1270 | - } |
|
1252 | + /** |
|
1253 | + * espresso_venue_address |
|
1254 | + * returns a formatted block of html for displaying a venue's address |
|
1255 | + * |
|
1256 | + * @param string $type 'inline' or 'multiline' |
|
1257 | + * @param int $VNU_ID |
|
1258 | + * @param bool $echo |
|
1259 | + * @return string |
|
1260 | + * @throws EE_Error |
|
1261 | + * @throws ReflectionException |
|
1262 | + */ |
|
1263 | + function espresso_venue_address($type = 'multiline', $VNU_ID = 0, $echo = true) |
|
1264 | + { |
|
1265 | + if ($echo) { |
|
1266 | + echo EEH_Venue_View::venue_address($type, $VNU_ID); // already escaped |
|
1267 | + return ''; |
|
1268 | + } |
|
1269 | + return EEH_Venue_View::venue_address($type, $VNU_ID); |
|
1270 | + } |
|
1271 | 1271 | } |
1272 | 1272 | |
1273 | 1273 | |
1274 | 1274 | if (! function_exists('espresso_venue_raw_address')) { |
1275 | - /** |
|
1276 | - * espresso_venue_address |
|
1277 | - * returns an UN-formatted string containing a venue's address |
|
1278 | - * |
|
1279 | - * @param string $type 'inline' or 'multiline' |
|
1280 | - * @param int $VNU_ID |
|
1281 | - * @param bool $echo |
|
1282 | - * @return string |
|
1283 | - * @throws EE_Error |
|
1284 | - * @throws ReflectionException |
|
1285 | - */ |
|
1286 | - function espresso_venue_raw_address($type = 'multiline', $VNU_ID = 0, $echo = true) |
|
1287 | - { |
|
1288 | - if ($echo) { |
|
1289 | - echo EEH_Venue_View::venue_address($type, $VNU_ID, false, false); // already escaped |
|
1290 | - return ''; |
|
1291 | - } |
|
1292 | - return EEH_Venue_View::venue_address($type, $VNU_ID, false, false); |
|
1293 | - } |
|
1275 | + /** |
|
1276 | + * espresso_venue_address |
|
1277 | + * returns an UN-formatted string containing a venue's address |
|
1278 | + * |
|
1279 | + * @param string $type 'inline' or 'multiline' |
|
1280 | + * @param int $VNU_ID |
|
1281 | + * @param bool $echo |
|
1282 | + * @return string |
|
1283 | + * @throws EE_Error |
|
1284 | + * @throws ReflectionException |
|
1285 | + */ |
|
1286 | + function espresso_venue_raw_address($type = 'multiline', $VNU_ID = 0, $echo = true) |
|
1287 | + { |
|
1288 | + if ($echo) { |
|
1289 | + echo EEH_Venue_View::venue_address($type, $VNU_ID, false, false); // already escaped |
|
1290 | + return ''; |
|
1291 | + } |
|
1292 | + return EEH_Venue_View::venue_address($type, $VNU_ID, false, false); |
|
1293 | + } |
|
1294 | 1294 | } |
1295 | 1295 | |
1296 | 1296 | |
1297 | 1297 | if (! function_exists('espresso_venue_has_address')) { |
1298 | - /** |
|
1299 | - * espresso_venue_has_address |
|
1300 | - * returns TRUE or FALSE if a Venue has address information |
|
1301 | - * |
|
1302 | - * @param int $VNU_ID |
|
1303 | - * @return bool |
|
1304 | - * @throws EE_Error |
|
1305 | - * @throws ReflectionException |
|
1306 | - */ |
|
1307 | - function espresso_venue_has_address($VNU_ID = 0) |
|
1308 | - { |
|
1309 | - return EEH_Venue_View::venue_has_address($VNU_ID); |
|
1310 | - } |
|
1298 | + /** |
|
1299 | + * espresso_venue_has_address |
|
1300 | + * returns TRUE or FALSE if a Venue has address information |
|
1301 | + * |
|
1302 | + * @param int $VNU_ID |
|
1303 | + * @return bool |
|
1304 | + * @throws EE_Error |
|
1305 | + * @throws ReflectionException |
|
1306 | + */ |
|
1307 | + function espresso_venue_has_address($VNU_ID = 0) |
|
1308 | + { |
|
1309 | + return EEH_Venue_View::venue_has_address($VNU_ID); |
|
1310 | + } |
|
1311 | 1311 | } |
1312 | 1312 | |
1313 | 1313 | |
1314 | 1314 | if (! function_exists('espresso_venue_gmap')) { |
1315 | - /** |
|
1316 | - * espresso_venue_gmap |
|
1317 | - * returns a google map for the venue address |
|
1318 | - * |
|
1319 | - * @param int $VNU_ID |
|
1320 | - * @param bool $map_ID |
|
1321 | - * @param array $gmap |
|
1322 | - * @param bool $echo |
|
1323 | - * @return string |
|
1324 | - * @throws EE_Error |
|
1325 | - * @throws ReflectionException |
|
1326 | - */ |
|
1327 | - function espresso_venue_gmap($VNU_ID = 0, $map_ID = false, $gmap = [], $echo = true) |
|
1328 | - { |
|
1329 | - if ($echo) { |
|
1330 | - echo EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap); // already escaped |
|
1331 | - return ''; |
|
1332 | - } |
|
1333 | - return EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap); |
|
1334 | - } |
|
1315 | + /** |
|
1316 | + * espresso_venue_gmap |
|
1317 | + * returns a google map for the venue address |
|
1318 | + * |
|
1319 | + * @param int $VNU_ID |
|
1320 | + * @param bool $map_ID |
|
1321 | + * @param array $gmap |
|
1322 | + * @param bool $echo |
|
1323 | + * @return string |
|
1324 | + * @throws EE_Error |
|
1325 | + * @throws ReflectionException |
|
1326 | + */ |
|
1327 | + function espresso_venue_gmap($VNU_ID = 0, $map_ID = false, $gmap = [], $echo = true) |
|
1328 | + { |
|
1329 | + if ($echo) { |
|
1330 | + echo EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap); // already escaped |
|
1331 | + return ''; |
|
1332 | + } |
|
1333 | + return EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap); |
|
1334 | + } |
|
1335 | 1335 | } |
1336 | 1336 | |
1337 | 1337 | |
1338 | 1338 | if (! function_exists('espresso_venue_phone')) { |
1339 | - /** |
|
1340 | - * espresso_venue_phone |
|
1341 | - * |
|
1342 | - * @param int $VNU_ID |
|
1343 | - * @param bool $echo |
|
1344 | - * @return string |
|
1345 | - * @throws EE_Error |
|
1346 | - * @throws ReflectionException |
|
1347 | - */ |
|
1348 | - function espresso_venue_phone($VNU_ID = 0, $echo = true) |
|
1349 | - { |
|
1350 | - if ($echo) { |
|
1351 | - echo EEH_Venue_View::venue_phone($VNU_ID); // already escaped |
|
1352 | - return ''; |
|
1353 | - } |
|
1354 | - return EEH_Venue_View::venue_phone($VNU_ID); |
|
1355 | - } |
|
1339 | + /** |
|
1340 | + * espresso_venue_phone |
|
1341 | + * |
|
1342 | + * @param int $VNU_ID |
|
1343 | + * @param bool $echo |
|
1344 | + * @return string |
|
1345 | + * @throws EE_Error |
|
1346 | + * @throws ReflectionException |
|
1347 | + */ |
|
1348 | + function espresso_venue_phone($VNU_ID = 0, $echo = true) |
|
1349 | + { |
|
1350 | + if ($echo) { |
|
1351 | + echo EEH_Venue_View::venue_phone($VNU_ID); // already escaped |
|
1352 | + return ''; |
|
1353 | + } |
|
1354 | + return EEH_Venue_View::venue_phone($VNU_ID); |
|
1355 | + } |
|
1356 | 1356 | } |
1357 | 1357 | |
1358 | 1358 | |
1359 | 1359 | if (! function_exists('espresso_venue_website')) { |
1360 | - /** |
|
1361 | - * espresso_venue_website |
|
1362 | - * |
|
1363 | - * @param int $VNU_ID |
|
1364 | - * @param bool $echo |
|
1365 | - * @return string |
|
1366 | - * @throws EE_Error |
|
1367 | - * @throws ReflectionException |
|
1368 | - */ |
|
1369 | - function espresso_venue_website($VNU_ID = 0, $echo = true) |
|
1370 | - { |
|
1371 | - if ($echo) { |
|
1372 | - echo EEH_Venue_View::venue_website_link($VNU_ID); // already escaped |
|
1373 | - return ''; |
|
1374 | - } |
|
1375 | - return EEH_Venue_View::venue_website_link($VNU_ID); |
|
1376 | - } |
|
1360 | + /** |
|
1361 | + * espresso_venue_website |
|
1362 | + * |
|
1363 | + * @param int $VNU_ID |
|
1364 | + * @param bool $echo |
|
1365 | + * @return string |
|
1366 | + * @throws EE_Error |
|
1367 | + * @throws ReflectionException |
|
1368 | + */ |
|
1369 | + function espresso_venue_website($VNU_ID = 0, $echo = true) |
|
1370 | + { |
|
1371 | + if ($echo) { |
|
1372 | + echo EEH_Venue_View::venue_website_link($VNU_ID); // already escaped |
|
1373 | + return ''; |
|
1374 | + } |
|
1375 | + return EEH_Venue_View::venue_website_link($VNU_ID); |
|
1376 | + } |
|
1377 | 1377 | } |
1378 | 1378 | |
1379 | 1379 | |
1380 | 1380 | if (! function_exists('espresso_edit_venue_link')) { |
1381 | - /** |
|
1382 | - * espresso_edit_venue_link |
|
1383 | - * |
|
1384 | - * @param int $VNU_ID |
|
1385 | - * @param bool $echo |
|
1386 | - * @return string |
|
1387 | - * @throws EE_Error |
|
1388 | - * @throws ReflectionException |
|
1389 | - */ |
|
1390 | - function espresso_edit_venue_link($VNU_ID = 0, $echo = true) |
|
1391 | - { |
|
1392 | - if ($echo) { |
|
1393 | - echo EEH_Venue_View::edit_venue_link($VNU_ID); // already escaped |
|
1394 | - return ''; |
|
1395 | - } |
|
1396 | - return EEH_Venue_View::edit_venue_link($VNU_ID); |
|
1397 | - } |
|
1381 | + /** |
|
1382 | + * espresso_edit_venue_link |
|
1383 | + * |
|
1384 | + * @param int $VNU_ID |
|
1385 | + * @param bool $echo |
|
1386 | + * @return string |
|
1387 | + * @throws EE_Error |
|
1388 | + * @throws ReflectionException |
|
1389 | + */ |
|
1390 | + function espresso_edit_venue_link($VNU_ID = 0, $echo = true) |
|
1391 | + { |
|
1392 | + if ($echo) { |
|
1393 | + echo EEH_Venue_View::edit_venue_link($VNU_ID); // already escaped |
|
1394 | + return ''; |
|
1395 | + } |
|
1396 | + return EEH_Venue_View::edit_venue_link($VNU_ID); |
|
1397 | + } |
|
1398 | 1398 | } |
1399 | 1399 | |
1400 | 1400 |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | */ |
146 | 146 | function can_use_espresso_conditionals($conditional_tag) |
147 | 147 | { |
148 | - if (! did_action('AHEE__EE_System__initialize')) { |
|
148 | + if ( ! did_action('AHEE__EE_System__initialize')) { |
|
149 | 149 | EE_Error::doing_it_wrong( |
150 | 150 | __FUNCTION__, |
151 | 151 | sprintf( |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | |
166 | 166 | /*************************** Event Queries ***************************/ |
167 | 167 | |
168 | -if (! function_exists('espresso_get_events')) { |
|
168 | +if ( ! function_exists('espresso_get_events')) { |
|
169 | 169 | /** |
170 | 170 | * espresso_get_events |
171 | 171 | * |
@@ -215,10 +215,10 @@ discard block |
||
215 | 215 | */ |
216 | 216 | function espresso_load_ticket_selector() |
217 | 217 | { |
218 | - EE_Registry::instance()->load_file(EE_MODULES . 'ticket_selector', 'EED_Ticket_Selector', 'module'); |
|
218 | + EE_Registry::instance()->load_file(EE_MODULES.'ticket_selector', 'EED_Ticket_Selector', 'module'); |
|
219 | 219 | } |
220 | 220 | |
221 | -if (! function_exists('espresso_ticket_selector')) { |
|
221 | +if ( ! function_exists('espresso_ticket_selector')) { |
|
222 | 222 | /** |
223 | 223 | * espresso_ticket_selector |
224 | 224 | * |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | */ |
229 | 229 | function espresso_ticket_selector($event = null) |
230 | 230 | { |
231 | - if (! apply_filters('FHEE_disable_espresso_ticket_selector', false)) { |
|
231 | + if ( ! apply_filters('FHEE_disable_espresso_ticket_selector', false)) { |
|
232 | 232 | espresso_load_ticket_selector(); |
233 | 233 | EED_Ticket_Selector::set_definitions(); |
234 | 234 | echo EED_Ticket_Selector::display_ticket_selector($event); // already escaped |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | } |
238 | 238 | |
239 | 239 | |
240 | -if (! function_exists('espresso_view_details_btn')) { |
|
240 | +if ( ! function_exists('espresso_view_details_btn')) { |
|
241 | 241 | /** |
242 | 242 | * espresso_view_details_btn |
243 | 243 | * |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | */ |
248 | 248 | function espresso_view_details_btn($event = null) |
249 | 249 | { |
250 | - if (! apply_filters('FHEE_disable_espresso_view_details_btn', false)) { |
|
250 | + if ( ! apply_filters('FHEE_disable_espresso_view_details_btn', false)) { |
|
251 | 251 | espresso_load_ticket_selector(); |
252 | 252 | echo EED_Ticket_Selector::display_ticket_selector($event, true); // already escaped |
253 | 253 | } |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | |
258 | 258 | /*************************** EEH_Event_View ***************************/ |
259 | 259 | |
260 | -if (! function_exists('espresso_load_event_list_assets')) { |
|
260 | +if ( ! function_exists('espresso_load_event_list_assets')) { |
|
261 | 261 | /** |
262 | 262 | * espresso_load_event_list_assets |
263 | 263 | * ensures that event list styles and scripts are loaded |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | } |
274 | 274 | |
275 | 275 | |
276 | -if (! function_exists('espresso_event_reg_button')) { |
|
276 | +if ( ! function_exists('espresso_event_reg_button')) { |
|
277 | 277 | /** |
278 | 278 | * espresso_event_reg_button |
279 | 279 | * returns the "Register Now" button if event is active, |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | function espresso_event_reg_button($btn_text_if_active = null, $btn_text_if_inactive = false, $EVT_ID = false) |
291 | 291 | { |
292 | 292 | $event = EEH_Event_View::get_event($EVT_ID); |
293 | - if (! $event instanceof EE_Event) { |
|
293 | + if ( ! $event instanceof EE_Event) { |
|
294 | 294 | return; |
295 | 295 | } |
296 | 296 | $event_status = $event->get_active_status(); |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | } |
337 | 337 | |
338 | 338 | |
339 | -if (! function_exists('espresso_display_ticket_selector')) { |
|
339 | +if ( ! function_exists('espresso_display_ticket_selector')) { |
|
340 | 340 | /** |
341 | 341 | * espresso_display_ticket_selector |
342 | 342 | * whether or not to display the Ticket Selector for an event |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | } |
354 | 354 | |
355 | 355 | |
356 | -if (! function_exists('espresso_event_status_banner')) { |
|
356 | +if ( ! function_exists('espresso_event_status_banner')) { |
|
357 | 357 | /** |
358 | 358 | * espresso_event_status |
359 | 359 | * returns a banner showing the event status if it is sold out, expired, or inactive |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | } |
371 | 371 | |
372 | 372 | |
373 | -if (! function_exists('espresso_event_status')) { |
|
373 | +if ( ! function_exists('espresso_event_status')) { |
|
374 | 374 | /** |
375 | 375 | * espresso_event_status |
376 | 376 | * returns the event status if it is sold out, expired, or inactive |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | } |
389 | 389 | |
390 | 390 | |
391 | -if (! function_exists('espresso_event_categories')) { |
|
391 | +if ( ! function_exists('espresso_event_categories')) { |
|
392 | 392 | /** |
393 | 393 | * espresso_event_categories |
394 | 394 | * returns the terms associated with an event |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | } |
412 | 412 | |
413 | 413 | |
414 | -if (! function_exists('espresso_event_tickets_available')) { |
|
414 | +if ( ! function_exists('espresso_event_tickets_available')) { |
|
415 | 415 | /** |
416 | 416 | * espresso_event_tickets_available |
417 | 417 | * returns the ticket types available for purchase for an event |
@@ -429,14 +429,14 @@ discard block |
||
429 | 429 | if (is_array($tickets) && ! empty($tickets)) { |
430 | 430 | // if formatting then $html will be a string, else it will be an array of ticket objects |
431 | 431 | $html = |
432 | - $format ? '<ul id="ee-event-tickets-ul-' . esc_attr($EVT_ID) . '" class="ee-event-tickets-ul">' : []; |
|
432 | + $format ? '<ul id="ee-event-tickets-ul-'.esc_attr($EVT_ID).'" class="ee-event-tickets-ul">' : []; |
|
433 | 433 | foreach ($tickets as $ticket) { |
434 | 434 | if ($ticket instanceof EE_Ticket) { |
435 | 435 | if ($format) { |
436 | 436 | $html .= '<li id="ee-event-tickets-li-' |
437 | 437 | . esc_attr($ticket->ID()) |
438 | 438 | . '" class="ee-event-tickets-li">'; |
439 | - $html .= esc_html($ticket->name()) . ' '; |
|
439 | + $html .= esc_html($ticket->name()).' '; |
|
440 | 440 | $html .= EEH_Template::format_currency( |
441 | 441 | $ticket->get_ticket_total_with_taxes() |
442 | 442 | ); // already escaped |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | } |
460 | 460 | } |
461 | 461 | |
462 | -if (! function_exists('espresso_event_date_obj')) { |
|
462 | +if ( ! function_exists('espresso_event_date_obj')) { |
|
463 | 463 | /** |
464 | 464 | * espresso_event_date_obj |
465 | 465 | * returns the primary date object for an event |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | } |
477 | 477 | |
478 | 478 | |
479 | -if (! function_exists('espresso_event_date')) { |
|
479 | +if ( ! function_exists('espresso_event_date')) { |
|
480 | 480 | /** |
481 | 481 | * espresso_event_date |
482 | 482 | * returns the primary date for an event |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | } |
506 | 506 | |
507 | 507 | |
508 | -if (! function_exists('espresso_list_of_event_dates')) { |
|
508 | +if ( ! function_exists('espresso_list_of_event_dates')) { |
|
509 | 509 | /** |
510 | 510 | * espresso_list_of_event_dates |
511 | 511 | * returns a unordered list of dates for an event |
@@ -538,14 +538,14 @@ discard block |
||
538 | 538 | $date_format = apply_filters('FHEE__espresso_list_of_event_dates__date_format', $date_format); |
539 | 539 | $time_format = apply_filters('FHEE__espresso_list_of_event_dates__time_format', $time_format); |
540 | 540 | $datetimes = EEH_Event_View::get_all_date_obj($EVT_ID, $show_expired, false, $limit); |
541 | - if (! $format) { |
|
541 | + if ( ! $format) { |
|
542 | 542 | return apply_filters('FHEE__espresso_list_of_event_dates__datetimes', $datetimes); |
543 | 543 | } |
544 | 544 | $newline = $add_breaks ? '<br />' : ''; |
545 | 545 | if (is_array($datetimes) && ! empty($datetimes)) { |
546 | 546 | global $post; |
547 | 547 | $html = |
548 | - '<ul id="ee-event-datetimes-ul-' . esc_attr($post->ID) . '" class="ee-event-datetimes-ul ee-clearfix">'; |
|
548 | + '<ul id="ee-event-datetimes-ul-'.esc_attr($post->ID).'" class="ee-event-datetimes-ul ee-clearfix">'; |
|
549 | 549 | foreach ($datetimes as $datetime) { |
550 | 550 | if ($datetime instanceof EE_Datetime) { |
551 | 551 | |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | $datetime_html = ! empty($datetime_name) |
554 | 554 | ? ' |
555 | 555 | <strong class="ee-event-datetimes-li-date-name"> |
556 | - ' . esc_html($datetime_name) . ' |
|
556 | + ' . esc_html($datetime_name).' |
|
557 | 557 | </strong>' . $newline |
558 | 558 | : ''; |
559 | 559 | |
@@ -561,16 +561,16 @@ discard block |
||
561 | 561 | $datetime_html .= ! empty($datetime_description) |
562 | 562 | ? ' |
563 | 563 | <span class="ee-event-datetimes-li-date-desc"> |
564 | - ' . wp_kses($datetime_description, $allowedtags) . ' |
|
564 | + ' . wp_kses($datetime_description, $allowedtags).' |
|
565 | 565 | </span>' . $newline |
566 | 566 | : ''; |
567 | 567 | |
568 | 568 | $datetime_html .= ' |
569 | 569 | <span class="dashicons dashicons-calendar"></span> |
570 | - <span class="ee-event-datetimes-li-daterange">' . $datetime->date_range($date_format) . '</span> |
|
570 | + <span class="ee-event-datetimes-li-daterange">' . $datetime->date_range($date_format).'</span> |
|
571 | 571 | <br/> |
572 | 572 | <span class="dashicons dashicons-clock"></span> |
573 | - <span class="ee-event-datetimes-li-timerange">' . $datetime->time_range($time_format) . '</span> |
|
573 | + <span class="ee-event-datetimes-li-timerange">' . $datetime->time_range($time_format).'</span> |
|
574 | 574 | '; |
575 | 575 | |
576 | 576 | $datetime_html = apply_filters( |
@@ -580,11 +580,11 @@ discard block |
||
580 | 580 | ); |
581 | 581 | |
582 | 582 | $DTD_ID = esc_attr($datetime->ID()); |
583 | - $active_status = esc_attr(' ee-event-datetimes-li-' . $datetime->get_active_status()); |
|
583 | + $active_status = esc_attr(' ee-event-datetimes-li-'.$datetime->get_active_status()); |
|
584 | 584 | |
585 | 585 | $html .= ' |
586 | - <li id="ee-event-datetimes-li-' . $DTD_ID . '" class="ee-event-datetimes-li' . $active_status . '"> |
|
587 | - ' . $datetime_html . ' |
|
586 | + <li id="ee-event-datetimes-li-' . $DTD_ID.'" class="ee-event-datetimes-li'.$active_status.'"> |
|
587 | + ' . $datetime_html.' |
|
588 | 588 | </li>'; |
589 | 589 | } |
590 | 590 | } |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | ' . esc_html__( |
598 | 598 | 'There are no upcoming dates for this event.', |
599 | 599 | 'event_espresso' |
600 | - ) . ' |
|
600 | + ).' |
|
601 | 601 | </p> |
602 | 602 | <br/>'; |
603 | 603 | } |
@@ -610,7 +610,7 @@ discard block |
||
610 | 610 | } |
611 | 611 | |
612 | 612 | |
613 | -if (! function_exists('espresso_event_end_date')) { |
|
613 | +if ( ! function_exists('espresso_event_end_date')) { |
|
614 | 614 | /** |
615 | 615 | * espresso_event_end_date |
616 | 616 | * returns the last date for an event |
@@ -637,7 +637,7 @@ discard block |
||
637 | 637 | } |
638 | 638 | } |
639 | 639 | |
640 | -if (! function_exists('espresso_event_date_range')) { |
|
640 | +if ( ! function_exists('espresso_event_date_range')) { |
|
641 | 641 | /** |
642 | 642 | * espresso_event_date_range |
643 | 643 | * returns the first and last chronologically ordered dates for an event (if different) |
@@ -695,7 +695,7 @@ discard block |
||
695 | 695 | } |
696 | 696 | } |
697 | 697 | |
698 | -if (! function_exists('espresso_next_upcoming_datetime_obj')) { |
|
698 | +if ( ! function_exists('espresso_next_upcoming_datetime_obj')) { |
|
699 | 699 | /** |
700 | 700 | * espresso_next_upcoming_datetime_obj |
701 | 701 | * returns the next upcoming datetime object for an event |
@@ -710,7 +710,7 @@ discard block |
||
710 | 710 | } |
711 | 711 | } |
712 | 712 | |
713 | -if (! function_exists('espresso_next_upcoming_datetime')) { |
|
713 | +if ( ! function_exists('espresso_next_upcoming_datetime')) { |
|
714 | 714 | /** |
715 | 715 | * espresso_next_upcoming_datetime |
716 | 716 | * returns the start date and time for the next upcoming event. |
@@ -732,11 +732,11 @@ discard block |
||
732 | 732 | $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
733 | 733 | $time_format = apply_filters('FHEE__espresso_next_upcoming_datetime__time_format', $time_format); |
734 | 734 | |
735 | - $datetime_format = trim($date_format . ' ' . $time_format); |
|
735 | + $datetime_format = trim($date_format.' '.$time_format); |
|
736 | 736 | |
737 | 737 | $datetime = espresso_next_upcoming_datetime_obj($EVT_ID); |
738 | 738 | |
739 | - if (! $datetime instanceof EE_Datetime) { |
|
739 | + if ( ! $datetime instanceof EE_Datetime) { |
|
740 | 740 | return ''; |
741 | 741 | } |
742 | 742 | if ($echo) { |
@@ -747,7 +747,7 @@ discard block |
||
747 | 747 | } |
748 | 748 | } |
749 | 749 | |
750 | -if (! function_exists('espresso_event_date_as_calendar_page')) { |
|
750 | +if ( ! function_exists('espresso_event_date_as_calendar_page')) { |
|
751 | 751 | /** |
752 | 752 | * espresso_event_date_as_calendar_page |
753 | 753 | * returns the primary date for an event, stylized to appear as the page of a calendar |
@@ -764,7 +764,7 @@ discard block |
||
764 | 764 | } |
765 | 765 | |
766 | 766 | |
767 | -if (! function_exists('espresso_event_link_url')) { |
|
767 | +if ( ! function_exists('espresso_event_link_url')) { |
|
768 | 768 | /** |
769 | 769 | * espresso_event_link_url |
770 | 770 | * |
@@ -785,7 +785,7 @@ discard block |
||
785 | 785 | } |
786 | 786 | |
787 | 787 | |
788 | -if (! function_exists('espresso_event_has_content_or_excerpt')) { |
|
788 | +if ( ! function_exists('espresso_event_has_content_or_excerpt')) { |
|
789 | 789 | /** |
790 | 790 | * espresso_event_has_content_or_excerpt |
791 | 791 | * |
@@ -802,7 +802,7 @@ discard block |
||
802 | 802 | } |
803 | 803 | |
804 | 804 | |
805 | -if (! function_exists('espresso_event_content_or_excerpt')) { |
|
805 | +if ( ! function_exists('espresso_event_content_or_excerpt')) { |
|
806 | 806 | /** |
807 | 807 | * espresso_event_content_or_excerpt |
808 | 808 | * |
@@ -822,7 +822,7 @@ discard block |
||
822 | 822 | } |
823 | 823 | |
824 | 824 | |
825 | -if (! function_exists('espresso_event_phone')) { |
|
825 | +if ( ! function_exists('espresso_event_phone')) { |
|
826 | 826 | /** |
827 | 827 | * espresso_event_phone |
828 | 828 | * |
@@ -843,7 +843,7 @@ discard block |
||
843 | 843 | } |
844 | 844 | |
845 | 845 | |
846 | -if (! function_exists('espresso_edit_event_link')) { |
|
846 | +if ( ! function_exists('espresso_edit_event_link')) { |
|
847 | 847 | /** |
848 | 848 | * espresso_edit_event_link |
849 | 849 | * returns a link to edit an event |
@@ -865,7 +865,7 @@ discard block |
||
865 | 865 | } |
866 | 866 | |
867 | 867 | |
868 | -if (! function_exists('espresso_organization_name')) { |
|
868 | +if ( ! function_exists('espresso_organization_name')) { |
|
869 | 869 | /** |
870 | 870 | * espresso_organization_name |
871 | 871 | * |
@@ -883,7 +883,7 @@ discard block |
||
883 | 883 | } |
884 | 884 | } |
885 | 885 | |
886 | -if (! function_exists('espresso_organization_address')) { |
|
886 | +if ( ! function_exists('espresso_organization_address')) { |
|
887 | 887 | /** |
888 | 888 | * espresso_organization_address |
889 | 889 | * |
@@ -907,7 +907,7 @@ discard block |
||
907 | 907 | } |
908 | 908 | } |
909 | 909 | |
910 | -if (! function_exists('espresso_organization_email')) { |
|
910 | +if ( ! function_exists('espresso_organization_email')) { |
|
911 | 911 | /** |
912 | 912 | * espresso_organization_email |
913 | 913 | * |
@@ -925,7 +925,7 @@ discard block |
||
925 | 925 | } |
926 | 926 | } |
927 | 927 | |
928 | -if (! function_exists('espresso_organization_logo_url')) { |
|
928 | +if ( ! function_exists('espresso_organization_logo_url')) { |
|
929 | 929 | /** |
930 | 930 | * espresso_organization_logo_url |
931 | 931 | * |
@@ -943,7 +943,7 @@ discard block |
||
943 | 943 | } |
944 | 944 | } |
945 | 945 | |
946 | -if (! function_exists('espresso_organization_facebook')) { |
|
946 | +if ( ! function_exists('espresso_organization_facebook')) { |
|
947 | 947 | /** |
948 | 948 | * espresso_organization_facebook |
949 | 949 | * |
@@ -961,7 +961,7 @@ discard block |
||
961 | 961 | } |
962 | 962 | } |
963 | 963 | |
964 | -if (! function_exists('espresso_organization_twitter')) { |
|
964 | +if ( ! function_exists('espresso_organization_twitter')) { |
|
965 | 965 | /** |
966 | 966 | * espresso_organization_twitter |
967 | 967 | * |
@@ -979,7 +979,7 @@ discard block |
||
979 | 979 | } |
980 | 980 | } |
981 | 981 | |
982 | -if (! function_exists('espresso_organization_linkedin')) { |
|
982 | +if ( ! function_exists('espresso_organization_linkedin')) { |
|
983 | 983 | /** |
984 | 984 | * espresso_organization_linkedin |
985 | 985 | * |
@@ -997,7 +997,7 @@ discard block |
||
997 | 997 | } |
998 | 998 | } |
999 | 999 | |
1000 | -if (! function_exists('espresso_organization_pinterest')) { |
|
1000 | +if ( ! function_exists('espresso_organization_pinterest')) { |
|
1001 | 1001 | /** |
1002 | 1002 | * espresso_organization_pinterest |
1003 | 1003 | * |
@@ -1015,7 +1015,7 @@ discard block |
||
1015 | 1015 | } |
1016 | 1016 | } |
1017 | 1017 | |
1018 | -if (! function_exists('espresso_organization_google')) { |
|
1018 | +if ( ! function_exists('espresso_organization_google')) { |
|
1019 | 1019 | /** |
1020 | 1020 | * espresso_organization_google |
1021 | 1021 | * |
@@ -1033,7 +1033,7 @@ discard block |
||
1033 | 1033 | } |
1034 | 1034 | } |
1035 | 1035 | |
1036 | -if (! function_exists('espresso_organization_instagram')) { |
|
1036 | +if ( ! function_exists('espresso_organization_instagram')) { |
|
1037 | 1037 | /** |
1038 | 1038 | * espresso_organization_instagram |
1039 | 1039 | * |
@@ -1055,7 +1055,7 @@ discard block |
||
1055 | 1055 | /*************************** EEH_Venue_View ***************************/ |
1056 | 1056 | |
1057 | 1057 | |
1058 | -if (! function_exists('espresso_event_venues')) { |
|
1058 | +if ( ! function_exists('espresso_event_venues')) { |
|
1059 | 1059 | /** |
1060 | 1060 | * espresso_event_venues |
1061 | 1061 | * |
@@ -1070,7 +1070,7 @@ discard block |
||
1070 | 1070 | } |
1071 | 1071 | |
1072 | 1072 | |
1073 | -if (! function_exists('espresso_venue_id')) { |
|
1073 | +if ( ! function_exists('espresso_venue_id')) { |
|
1074 | 1074 | /** |
1075 | 1075 | * espresso_venue_name |
1076 | 1076 | * |
@@ -1088,7 +1088,7 @@ discard block |
||
1088 | 1088 | } |
1089 | 1089 | |
1090 | 1090 | |
1091 | -if (! function_exists('espresso_is_venue_private')) { |
|
1091 | +if ( ! function_exists('espresso_is_venue_private')) { |
|
1092 | 1092 | /** |
1093 | 1093 | * Return whether a venue is private or not. |
1094 | 1094 | * |
@@ -1106,7 +1106,7 @@ discard block |
||
1106 | 1106 | } |
1107 | 1107 | |
1108 | 1108 | |
1109 | -if (! function_exists('espresso_venue_is_password_protected')) { |
|
1109 | +if ( ! function_exists('espresso_venue_is_password_protected')) { |
|
1110 | 1110 | /** |
1111 | 1111 | * returns true or false if a venue is password protected or not |
1112 | 1112 | * |
@@ -1123,7 +1123,7 @@ discard block |
||
1123 | 1123 | } |
1124 | 1124 | |
1125 | 1125 | |
1126 | -if (! function_exists('espresso_password_protected_venue_form')) { |
|
1126 | +if ( ! function_exists('espresso_password_protected_venue_form')) { |
|
1127 | 1127 | /** |
1128 | 1128 | * Returns a password form if venue is password protected. |
1129 | 1129 | * |
@@ -1140,7 +1140,7 @@ discard block |
||
1140 | 1140 | } |
1141 | 1141 | |
1142 | 1142 | |
1143 | -if (! function_exists('espresso_venue_name')) { |
|
1143 | +if ( ! function_exists('espresso_venue_name')) { |
|
1144 | 1144 | /** |
1145 | 1145 | * espresso_venue_name |
1146 | 1146 | * |
@@ -1163,7 +1163,7 @@ discard block |
||
1163 | 1163 | } |
1164 | 1164 | |
1165 | 1165 | |
1166 | -if (! function_exists('espresso_venue_link')) { |
|
1166 | +if ( ! function_exists('espresso_venue_link')) { |
|
1167 | 1167 | /** |
1168 | 1168 | * espresso_venue_link |
1169 | 1169 | * |
@@ -1181,7 +1181,7 @@ discard block |
||
1181 | 1181 | } |
1182 | 1182 | |
1183 | 1183 | |
1184 | -if (! function_exists('espresso_venue_description')) { |
|
1184 | +if ( ! function_exists('espresso_venue_description')) { |
|
1185 | 1185 | /** |
1186 | 1186 | * espresso_venue_description |
1187 | 1187 | * |
@@ -1203,7 +1203,7 @@ discard block |
||
1203 | 1203 | } |
1204 | 1204 | |
1205 | 1205 | |
1206 | -if (! function_exists('espresso_venue_excerpt')) { |
|
1206 | +if ( ! function_exists('espresso_venue_excerpt')) { |
|
1207 | 1207 | /** |
1208 | 1208 | * espresso_venue_excerpt |
1209 | 1209 | * |
@@ -1225,7 +1225,7 @@ discard block |
||
1225 | 1225 | } |
1226 | 1226 | |
1227 | 1227 | |
1228 | -if (! function_exists('espresso_venue_categories')) { |
|
1228 | +if ( ! function_exists('espresso_venue_categories')) { |
|
1229 | 1229 | /** |
1230 | 1230 | * espresso_venue_categories |
1231 | 1231 | * returns the terms associated with a venue |
@@ -1248,7 +1248,7 @@ discard block |
||
1248 | 1248 | } |
1249 | 1249 | |
1250 | 1250 | |
1251 | -if (! function_exists('espresso_venue_address')) { |
|
1251 | +if ( ! function_exists('espresso_venue_address')) { |
|
1252 | 1252 | /** |
1253 | 1253 | * espresso_venue_address |
1254 | 1254 | * returns a formatted block of html for displaying a venue's address |
@@ -1271,7 +1271,7 @@ discard block |
||
1271 | 1271 | } |
1272 | 1272 | |
1273 | 1273 | |
1274 | -if (! function_exists('espresso_venue_raw_address')) { |
|
1274 | +if ( ! function_exists('espresso_venue_raw_address')) { |
|
1275 | 1275 | /** |
1276 | 1276 | * espresso_venue_address |
1277 | 1277 | * returns an UN-formatted string containing a venue's address |
@@ -1294,7 +1294,7 @@ discard block |
||
1294 | 1294 | } |
1295 | 1295 | |
1296 | 1296 | |
1297 | -if (! function_exists('espresso_venue_has_address')) { |
|
1297 | +if ( ! function_exists('espresso_venue_has_address')) { |
|
1298 | 1298 | /** |
1299 | 1299 | * espresso_venue_has_address |
1300 | 1300 | * returns TRUE or FALSE if a Venue has address information |
@@ -1311,7 +1311,7 @@ discard block |
||
1311 | 1311 | } |
1312 | 1312 | |
1313 | 1313 | |
1314 | -if (! function_exists('espresso_venue_gmap')) { |
|
1314 | +if ( ! function_exists('espresso_venue_gmap')) { |
|
1315 | 1315 | /** |
1316 | 1316 | * espresso_venue_gmap |
1317 | 1317 | * returns a google map for the venue address |
@@ -1335,7 +1335,7 @@ discard block |
||
1335 | 1335 | } |
1336 | 1336 | |
1337 | 1337 | |
1338 | -if (! function_exists('espresso_venue_phone')) { |
|
1338 | +if ( ! function_exists('espresso_venue_phone')) { |
|
1339 | 1339 | /** |
1340 | 1340 | * espresso_venue_phone |
1341 | 1341 | * |
@@ -1356,7 +1356,7 @@ discard block |
||
1356 | 1356 | } |
1357 | 1357 | |
1358 | 1358 | |
1359 | -if (! function_exists('espresso_venue_website')) { |
|
1359 | +if ( ! function_exists('espresso_venue_website')) { |
|
1360 | 1360 | /** |
1361 | 1361 | * espresso_venue_website |
1362 | 1362 | * |
@@ -1377,7 +1377,7 @@ discard block |
||
1377 | 1377 | } |
1378 | 1378 | |
1379 | 1379 | |
1380 | -if (! function_exists('espresso_edit_venue_link')) { |
|
1380 | +if ( ! function_exists('espresso_edit_venue_link')) { |
|
1381 | 1381 | /** |
1382 | 1382 | * espresso_edit_venue_link |
1383 | 1383 | * |
@@ -13,649 +13,649 @@ |
||
13 | 13 | class EEM_Message extends EEM_Base implements EEI_Query_Filter |
14 | 14 | { |
15 | 15 | |
16 | - // private instance of the Message object |
|
17 | - protected static $_instance = null; |
|
18 | - |
|
19 | - |
|
20 | - /** |
|
21 | - * This priority indicates a message should be generated and sent ASAP |
|
22 | - * |
|
23 | - * @type int |
|
24 | - */ |
|
25 | - const priority_high = 10; |
|
26 | - |
|
27 | - |
|
28 | - /** |
|
29 | - * This priority indicates a message should be generated ASAP and queued for sending. |
|
30 | - * |
|
31 | - * @type |
|
32 | - */ |
|
33 | - const priority_medium = 20; |
|
34 | - |
|
35 | - |
|
36 | - /** |
|
37 | - * This priority indicates a message should be queued for generating. |
|
38 | - * |
|
39 | - * @type int |
|
40 | - */ |
|
41 | - const priority_low = 30; |
|
42 | - |
|
43 | - |
|
44 | - /** |
|
45 | - * indicates this message was sent at the time modified |
|
46 | - */ |
|
47 | - const status_sent = 'MSN'; |
|
48 | - |
|
49 | - |
|
50 | - /** |
|
51 | - * indicates this message is waiting to be sent |
|
52 | - */ |
|
53 | - const status_idle = 'MID'; |
|
54 | - |
|
55 | - |
|
56 | - /** |
|
57 | - * indicates an attempt was a made to send this message |
|
58 | - * at the scheduled time, but it failed at the time modified. This differs from MDO status in that it will ALWAYS |
|
59 | - * appear to the end user. |
|
60 | - */ |
|
61 | - const status_failed = 'MFL'; |
|
62 | - |
|
63 | - |
|
64 | - /** |
|
65 | - * indicates the message has been flagged for resending (at the time modified). |
|
66 | - */ |
|
67 | - const status_resend = 'MRS'; |
|
68 | - |
|
69 | - |
|
70 | - /** |
|
71 | - * indicates the message has been flagged for generation but has not been generated yet. Messages always start as |
|
72 | - * this status when added to the queue. |
|
73 | - */ |
|
74 | - const status_incomplete = 'MIC'; |
|
75 | - |
|
76 | - |
|
77 | - /** |
|
78 | - * Indicates everything was generated fine for the message, however, the messenger was unable to send. |
|
79 | - * This status means that its possible to retry sending the message. |
|
80 | - */ |
|
81 | - const status_retry = 'MRT'; |
|
82 | - |
|
83 | - |
|
84 | - /** |
|
85 | - * This is used for more informational messages that may not indicate anything is broken but still cannot be |
|
86 | - * generated or sent correctly. An example of a message that would get flagged this way would be when a not |
|
87 | - * approved message was queued for generation, but at time of generation, the attached registration(s) are |
|
88 | - * approved. So the message queued for generation is no longer valid. Messages for this status will only persist |
|
89 | - * in the db and be viewable in the message activity list table when the messages system is in debug mode. |
|
90 | - * |
|
91 | - * @see EEM_Message::debug() |
|
92 | - */ |
|
93 | - const status_debug_only = 'MDO'; |
|
94 | - |
|
95 | - |
|
96 | - /** |
|
97 | - * This status is given to messages it is processed by the messenger send method. |
|
98 | - * Messages with this status should rarely be seen in the Message List table, but if they are, that's usually |
|
99 | - * indicative of a PHP timeout or memory limit issue. |
|
100 | - */ |
|
101 | - const status_messenger_executing = 'MEX'; |
|
102 | - |
|
103 | - |
|
104 | - /** |
|
105 | - * Private constructor to prevent direct creation. |
|
106 | - * |
|
107 | - * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and |
|
108 | - * any incoming timezone data that gets saved). Note this just sends the timezone info to |
|
109 | - * the date time model field objects. Default is null (and will be assumed using the set |
|
110 | - * timezone in the 'timezone_string' wp option) |
|
111 | - * @throws EE_Error |
|
112 | - * @throws EE_Error |
|
113 | - * @throws EE_Error |
|
114 | - */ |
|
115 | - protected function __construct($timezone = null) |
|
116 | - { |
|
117 | - $this->singular_item = esc_html__('Message', 'event_espresso'); |
|
118 | - $this->plural_item = esc_html__('Messages', 'event_espresso'); |
|
119 | - |
|
120 | - $this->_tables = array( |
|
121 | - 'Message' => new EE_Primary_Table('esp_message', 'MSG_ID'), |
|
122 | - ); |
|
123 | - |
|
124 | - $allowed_priority = array( |
|
125 | - self::priority_high => esc_html__('high', 'event_espresso'), |
|
126 | - self::priority_medium => esc_html__('medium', 'event_espresso'), |
|
127 | - self::priority_low => esc_html__('low', 'event_espresso'), |
|
128 | - ); |
|
129 | - |
|
130 | - $this->_fields = array( |
|
131 | - 'Message' => array( |
|
132 | - 'MSG_ID' => new EE_Primary_Key_Int_Field('MSG_ID', esc_html__('Message ID', 'event_espresso')), |
|
133 | - 'MSG_token' => new EE_Plain_Text_Field( |
|
134 | - 'MSG_token', |
|
135 | - esc_html__( |
|
136 | - 'Unique Token used to represent this row in publicly viewable contexts (eg. a url).', |
|
137 | - 'event_espresso' |
|
138 | - ), |
|
139 | - false, |
|
140 | - EEH_URL::generate_unique_token() |
|
141 | - ), |
|
142 | - 'GRP_ID' => new EE_Foreign_Key_Int_Field( |
|
143 | - 'GRP_ID', |
|
144 | - esc_html__('Foreign key to the EEM_Message_Template_Group table.', 'event_espresso'), |
|
145 | - true, |
|
146 | - 0, |
|
147 | - 'Message_Template_Group' |
|
148 | - ), |
|
149 | - 'TXN_ID' => new EE_Foreign_Key_Int_Field( |
|
150 | - 'TXN_ID', |
|
151 | - esc_html__( |
|
152 | - 'Foreign key to the related EE_Transaction. This is required to give context for regenerating the specific message', |
|
153 | - 'event_espresso' |
|
154 | - ), |
|
155 | - true, |
|
156 | - 0, |
|
157 | - 'Transaction' |
|
158 | - ), |
|
159 | - 'MSG_messenger' => new EE_Plain_Text_Field( |
|
160 | - 'MSG_messenger', |
|
161 | - esc_html__( |
|
162 | - 'Corresponds to the EE_messenger::name used to send this message. This will also be used to attempt any resending of the message.', |
|
163 | - 'event_espresso' |
|
164 | - ), |
|
165 | - false, |
|
166 | - 'email' |
|
167 | - ), |
|
168 | - 'MSG_message_type' => new EE_Plain_Text_Field( |
|
169 | - 'MSG_message_type', |
|
170 | - esc_html__('Corresponds to the EE_message_type::name used to generate this message.', 'event_espresso'), |
|
171 | - false, |
|
172 | - 'receipt' |
|
173 | - ), |
|
174 | - 'MSG_context' => new EE_Plain_Text_Field('MSG_context', esc_html__('Context', 'event_espresso'), false), |
|
175 | - 'MSG_recipient_ID' => new EE_Foreign_Key_Int_Field( |
|
176 | - 'MSG_recipient_ID', |
|
177 | - esc_html__('Recipient ID', 'event_espresso'), |
|
178 | - true, |
|
179 | - null, |
|
180 | - array('Registration', 'Attendee', 'WP_User') |
|
181 | - ), |
|
182 | - 'MSG_recipient_type' => new EE_Any_Foreign_Model_Name_Field( |
|
183 | - 'MSG_recipient_type', |
|
184 | - esc_html__('Recipient Type', 'event_espresso'), |
|
185 | - true, |
|
186 | - null, |
|
187 | - array('Registration', 'Attendee', 'WP_User') |
|
188 | - ), |
|
189 | - 'MSG_content' => new EE_Maybe_Serialized_Text_Field( |
|
190 | - 'MSG_content', |
|
191 | - esc_html__('Content', 'event_espresso'), |
|
192 | - true, |
|
193 | - '' |
|
194 | - ), |
|
195 | - 'MSG_to' => new EE_Maybe_Serialized_Text_Field( |
|
196 | - 'MSG_to', |
|
197 | - esc_html__('Address To', 'event_espresso'), |
|
198 | - true |
|
199 | - ), |
|
200 | - 'MSG_from' => new EE_Maybe_Serialized_Text_Field( |
|
201 | - 'MSG_from', |
|
202 | - esc_html__('Address From', 'event_espresso'), |
|
203 | - true |
|
204 | - ), |
|
205 | - 'MSG_subject' => new EE_Maybe_Serialized_Text_Field( |
|
206 | - 'MSG_subject', |
|
207 | - esc_html__('Subject', 'event_espresso'), |
|
208 | - true, |
|
209 | - '' |
|
210 | - ), |
|
211 | - 'MSG_priority' => new EE_Enum_Integer_Field( |
|
212 | - 'MSG_priority', |
|
213 | - esc_html__('Priority', 'event_espresso'), |
|
214 | - false, |
|
215 | - self::priority_low, |
|
216 | - $allowed_priority |
|
217 | - ), |
|
218 | - 'STS_ID' => new EE_Foreign_Key_String_Field( |
|
219 | - 'STS_ID', |
|
220 | - esc_html__('Status', 'event_espresso'), |
|
221 | - false, |
|
222 | - self::status_incomplete, |
|
223 | - 'Status' |
|
224 | - ), |
|
225 | - 'MSG_created' => new EE_Datetime_Field( |
|
226 | - 'MSG_created', |
|
227 | - esc_html__('Created', 'event_espresso'), |
|
228 | - false, |
|
229 | - EE_Datetime_Field::now |
|
230 | - ), |
|
231 | - 'MSG_modified' => new EE_Datetime_Field( |
|
232 | - 'MSG_modified', |
|
233 | - esc_html__('Modified', 'event_espresso'), |
|
234 | - true, |
|
235 | - EE_Datetime_Field::now |
|
236 | - ), |
|
237 | - ), |
|
238 | - ); |
|
239 | - $this->_model_relations = array( |
|
240 | - 'Attendee' => new EE_Belongs_To_Any_Relation(), |
|
241 | - 'Registration' => new EE_Belongs_To_Any_Relation(), |
|
242 | - 'WP_User' => new EE_Belongs_To_Any_Relation(), |
|
243 | - 'Message_Template_Group' => new EE_Belongs_To_Relation(), |
|
244 | - 'Transaction' => new EE_Belongs_To_Relation(), |
|
245 | - ); |
|
246 | - parent::__construct($timezone); |
|
247 | - } |
|
248 | - |
|
249 | - |
|
250 | - /** |
|
251 | - * @return EE_Message |
|
252 | - * @throws EE_Error |
|
253 | - */ |
|
254 | - public function create_default_object() |
|
255 | - { |
|
256 | - /** @type EE_Message $message */ |
|
257 | - $message = parent::create_default_object(); |
|
258 | - if ($message instanceof EE_Message) { |
|
259 | - return EE_Message_Factory::set_messenger_and_message_type($message); |
|
260 | - } |
|
261 | - return null; |
|
262 | - } |
|
263 | - |
|
264 | - |
|
265 | - /** |
|
266 | - * @param mixed $cols_n_values |
|
267 | - * @return EE_Message |
|
268 | - * @throws EE_Error |
|
269 | - * @throws EE_Error |
|
270 | - */ |
|
271 | - public function instantiate_class_from_array_or_object($cols_n_values) |
|
272 | - { |
|
273 | - /** @type EE_Message $message */ |
|
274 | - $message = parent::instantiate_class_from_array_or_object($cols_n_values); |
|
275 | - if ($message instanceof EE_Message) { |
|
276 | - return EE_Message_Factory::set_messenger_and_message_type($message); |
|
277 | - } |
|
278 | - return null; |
|
279 | - } |
|
280 | - |
|
281 | - |
|
282 | - /** |
|
283 | - * Returns whether or not a message of that type was sent for a given attendee. |
|
284 | - * |
|
285 | - * @param EE_Attendee|int $attendee |
|
286 | - * @param string $message_type the message type slug |
|
287 | - * @return boolean |
|
288 | - * @throws EE_Error |
|
289 | - * @throws EE_Error |
|
290 | - * @throws EE_Error |
|
291 | - */ |
|
292 | - public function message_sent_for_attendee($attendee, $message_type) |
|
293 | - { |
|
294 | - $attendee_ID = EEM_Attendee::instance()->ensure_is_ID($attendee); |
|
295 | - return $this->exists(array( |
|
296 | - array( |
|
297 | - 'Attendee.ATT_ID' => $attendee_ID, |
|
298 | - 'MSG_message_type' => $message_type, |
|
299 | - 'STS_ID' => array('IN', $this->stati_indicating_sent()), |
|
300 | - ), |
|
301 | - )); |
|
302 | - } |
|
303 | - |
|
304 | - |
|
305 | - /** |
|
306 | - * Returns whether or not a message of that type was sent for a given registration |
|
307 | - * |
|
308 | - * @param EE_Registration|int $registration |
|
309 | - * @param string $message_type the message type slug |
|
310 | - * @return boolean |
|
311 | - * @throws EE_Error |
|
312 | - * @throws EE_Error |
|
313 | - * @throws EE_Error |
|
314 | - */ |
|
315 | - public function message_sent_for_registration($registration, $message_type) |
|
316 | - { |
|
317 | - $registrationID = EEM_Registration::instance()->ensure_is_ID($registration); |
|
318 | - return $this->exists(array( |
|
319 | - array( |
|
320 | - 'Registration.REG_ID' => $registrationID, |
|
321 | - 'MSG_message_type' => $message_type, |
|
322 | - 'STS_ID' => array('IN', $this->stati_indicating_sent()), |
|
323 | - ), |
|
324 | - )); |
|
325 | - } |
|
326 | - |
|
327 | - |
|
328 | - /** |
|
329 | - * This retrieves an EE_Message object from the db matching the given token string. |
|
330 | - * |
|
331 | - * @param string $token |
|
332 | - * @return EE_Message |
|
333 | - * @throws EE_Error |
|
334 | - */ |
|
335 | - public function get_one_by_token($token) |
|
336 | - { |
|
337 | - return $this->get_one(array( |
|
338 | - array( |
|
339 | - 'MSG_token' => $token, |
|
340 | - ), |
|
341 | - )); |
|
342 | - } |
|
343 | - |
|
344 | - |
|
345 | - /** |
|
346 | - * Returns stati that indicate the message HAS been sent |
|
347 | - * |
|
348 | - * @return array of strings for possible stati |
|
349 | - */ |
|
350 | - public function stati_indicating_sent() |
|
351 | - { |
|
352 | - return apply_filters('FHEE__EEM_Message__stati_indicating_sent', array(self::status_sent)); |
|
353 | - } |
|
354 | - |
|
355 | - |
|
356 | - /** |
|
357 | - * Returns stati that indicate the message is waiting to be sent. |
|
358 | - * |
|
359 | - * @return array of strings for possible stati. |
|
360 | - */ |
|
361 | - public function stati_indicating_to_send() |
|
362 | - { |
|
363 | - return apply_filters( |
|
364 | - 'FHEE__EEM_Message__stati_indicating_to_send', |
|
365 | - array(self::status_idle, self::status_resend) |
|
366 | - ); |
|
367 | - } |
|
368 | - |
|
369 | - |
|
370 | - /** |
|
371 | - * Returns stati that indicate the message has failed sending |
|
372 | - * |
|
373 | - * @return array array of strings for possible stati. |
|
374 | - */ |
|
375 | - public function stati_indicating_failed_sending() |
|
376 | - { |
|
377 | - $failed_stati = array( |
|
378 | - self::status_failed, |
|
379 | - self::status_retry, |
|
380 | - self::status_messenger_executing, |
|
381 | - ); |
|
382 | - // if WP_DEBUG is set, then let's include debug_only fails |
|
383 | - if (WP_DEBUG) { |
|
384 | - $failed_stati[] = self::status_debug_only; |
|
385 | - } |
|
386 | - return apply_filters('FHEE__EEM_Message__stati_indicating_failed_sending', $failed_stati); |
|
387 | - } |
|
388 | - |
|
389 | - |
|
390 | - /** |
|
391 | - * Returns filterable array of all EEM_Message statuses. |
|
392 | - * |
|
393 | - * @return array |
|
394 | - */ |
|
395 | - public function all_statuses() |
|
396 | - { |
|
397 | - return apply_filters( |
|
398 | - 'FHEE__EEM_Message__all_statuses', |
|
399 | - array( |
|
400 | - EEM_Message::status_sent, |
|
401 | - EEM_Message::status_incomplete, |
|
402 | - EEM_Message::status_idle, |
|
403 | - EEM_Message::status_resend, |
|
404 | - EEM_Message::status_retry, |
|
405 | - EEM_Message::status_failed, |
|
406 | - EEM_Message::status_messenger_executing, |
|
407 | - EEM_Message::status_debug_only, |
|
408 | - ) |
|
409 | - ); |
|
410 | - } |
|
411 | - |
|
412 | - /** |
|
413 | - * Detects any specific query variables in the request and uses those to setup appropriate |
|
414 | - * filter for any queries. |
|
415 | - * |
|
416 | - * @return array |
|
417 | - */ |
|
418 | - public function filter_by_query_params() |
|
419 | - { |
|
420 | - /** @var RequestInterface $request */ |
|
421 | - $request = EEM_Base::$loader->getShared(RequestInterface::class); |
|
422 | - // expected possible query_vars, the key in this array matches an expected key in the request, |
|
423 | - // the value, matches the corresponding EEM_Base child reference. |
|
424 | - $expected_vars = $this->_expected_vars_for_query_inject(); |
|
425 | - $query_params[0] = array(); |
|
426 | - foreach ($expected_vars as $request_key => $model_name) { |
|
427 | - $request_value = $request->getRequestParam($request_key); |
|
428 | - if ($request_value) { |
|
429 | - // special case |
|
430 | - switch ($request_key) { |
|
431 | - case '_REG_ID': |
|
432 | - $query_params[0]['AND**filter_by']['OR**filter_by_REG_ID'] = array( |
|
433 | - 'Transaction.Registration.REG_ID' => $request_value, |
|
434 | - ); |
|
435 | - break; |
|
436 | - case 'EVT_ID': |
|
437 | - $query_params[0]['AND**filter_by']['OR**filter_by_EVT_ID'] = array( |
|
438 | - 'Transaction.Registration.EVT_ID' => $request_value, |
|
439 | - ); |
|
440 | - break; |
|
441 | - default: |
|
442 | - $query_params[0]['AND**filter_by'][ 'OR**filter_by_' . $request_key ][ $model_name . '.' . $request_key ] = $request_value; |
|
443 | - break; |
|
444 | - } |
|
445 | - } |
|
446 | - } |
|
447 | - return $query_params; |
|
448 | - } |
|
449 | - |
|
450 | - |
|
451 | - /** |
|
452 | - * @return string |
|
453 | - * @throws EE_Error |
|
454 | - * @throws ReflectionException |
|
455 | - */ |
|
456 | - public function get_pretty_label_for_results() |
|
457 | - { |
|
458 | - /** @var RequestInterface $request */ |
|
459 | - $request = EEM_Base::$loader->getShared(RequestInterface::class); |
|
460 | - $expected_vars = $this->_expected_vars_for_query_inject(); |
|
461 | - $pretty_label = ''; |
|
462 | - $label_parts = array(); |
|
463 | - foreach ($expected_vars as $request_key => $model_name) { |
|
464 | - $model_name = strpos($model_name, 'EEM_', true) === 0 ? $model_name : "EEM_{$model_name}"; |
|
465 | - $model = EEM_Base::$loader->getShared($model_name); |
|
466 | - $model_field_value = $request->getRequestParam($request_key); |
|
467 | - if ($model instanceof EEM_Base && $model_field_value !== '') { |
|
468 | - switch ($request_key) { |
|
469 | - case '_REG_ID': |
|
470 | - $label_parts[] = sprintf( |
|
471 | - esc_html__('Registration with the ID: %s', 'event_espresso'), |
|
472 | - $model_field_value |
|
473 | - ); |
|
474 | - break; |
|
475 | - case 'ATT_ID': |
|
476 | - /** @var EE_Attendee $attendee */ |
|
477 | - $attendee = $model->get_one_by_ID($model_field_value); |
|
478 | - $label_parts[] = $attendee instanceof EE_Attendee |
|
479 | - ? sprintf(esc_html__('Attendee %s', 'event_espresso'), $attendee->full_name()) |
|
480 | - : sprintf(esc_html__('Attendee ID: %s', 'event_espresso'), $model_field_value); |
|
481 | - break; |
|
482 | - case 'ID': |
|
483 | - /** @var EE_WP_User $wpUser */ |
|
484 | - $wpUser = $model->get_one_by_ID($model_field_value); |
|
485 | - $label_parts[] = $wpUser instanceof EE_WP_User |
|
486 | - ? sprintf(esc_html__('WP User: %s', 'event_espresso'), $wpUser->name()) |
|
487 | - : sprintf(esc_html__('WP User ID: %s', 'event_espresso'), $model_field_value); |
|
488 | - break; |
|
489 | - case 'TXN_ID': |
|
490 | - $label_parts[] = sprintf( |
|
491 | - esc_html__('Transaction with the ID: %s', 'event_espresso'), |
|
492 | - $model_field_value |
|
493 | - ); |
|
494 | - break; |
|
495 | - case 'EVT_ID': |
|
496 | - /** @var EE_Event $Event */ |
|
497 | - $Event = $model->get_one_by_ID($model_field_value); |
|
498 | - $label_parts[] = $Event instanceof EE_Event |
|
499 | - ? sprintf(esc_html__('for the Event: %s', 'event_espresso'), $Event->name()) |
|
500 | - : sprintf(esc_html__('for the Event with ID: %s', 'event_espresso'), $model_field_value); |
|
501 | - break; |
|
502 | - } |
|
503 | - } |
|
504 | - } |
|
505 | - |
|
506 | - if ($label_parts) { |
|
507 | - // prepend to the last element of $label_parts an "and". |
|
508 | - if (count($label_parts) > 1) { |
|
509 | - $label_parts_index_to_prepend = count($label_parts) - 1; |
|
510 | - $label_parts[ $label_parts_index_to_prepend ] = 'and' . $label_parts[ $label_parts_index_to_prepend ]; |
|
511 | - } |
|
512 | - |
|
513 | - $pretty_label .= sprintf( |
|
514 | - esc_html_x( |
|
515 | - 'Showing messages for %s', |
|
516 | - 'A label for the messages returned in a query that are filtered by items in the query. This could be Transaction, Event, Attendee, Registration, or WP_User.', |
|
517 | - 'event_espresso' |
|
518 | - ), |
|
519 | - implode(', ', $label_parts) |
|
520 | - ); |
|
521 | - } |
|
522 | - return $pretty_label; |
|
523 | - } |
|
524 | - |
|
525 | - |
|
526 | - /** |
|
527 | - * This returns the array of expected variables for the EEI_Query_Filter methods being implemented |
|
528 | - * The array is in the format: |
|
529 | - * array( |
|
530 | - * {$field_name} => {$model_name} |
|
531 | - * ); |
|
532 | - * |
|
533 | - * @since 4.9.0 |
|
534 | - * @return array |
|
535 | - */ |
|
536 | - protected function _expected_vars_for_query_inject() |
|
537 | - { |
|
538 | - return array( |
|
539 | - '_REG_ID' => 'Registration', |
|
540 | - 'ATT_ID' => 'Attendee', |
|
541 | - 'ID' => 'WP_User', |
|
542 | - 'TXN_ID' => 'Transaction', |
|
543 | - 'EVT_ID' => 'Event', |
|
544 | - ); |
|
545 | - } |
|
546 | - |
|
547 | - |
|
548 | - /** |
|
549 | - * This returns whether EEM_Message is in debug mode or not. |
|
550 | - * Currently "debug mode" is used to control the handling of the EEM_Message::debug_only status when |
|
551 | - * generating/sending messages. Debug mode can be set by either: |
|
552 | - * 1. Sending in a value for the $set_debug argument |
|
553 | - * 2. Defining `EE_DEBUG_MESSAGES` constant in wp-config.php |
|
554 | - * 3. Overriding the above via the provided filter. |
|
555 | - * |
|
556 | - * @param bool|null $set_debug If provided, then the debug mode will be set internally until reset via the |
|
557 | - * provided boolean. When no argument is provided (default null) then the debug |
|
558 | - * mode will be returned. |
|
559 | - * @return bool true means Messages is in debug mode. false means messages system is not in debug mode. |
|
560 | - */ |
|
561 | - public static function debug($set_debug = null) |
|
562 | - { |
|
563 | - static $is_debugging = null; |
|
564 | - |
|
565 | - // initialize (use constant if set). |
|
566 | - if (is_null($set_debug) && is_null($is_debugging)) { |
|
567 | - $is_debugging = defined('EE_DEBUG_MESSAGES') && EE_DEBUG_MESSAGES; |
|
568 | - } |
|
569 | - |
|
570 | - if (! is_null($set_debug)) { |
|
571 | - $is_debugging = filter_var($set_debug, FILTER_VALIDATE_BOOLEAN); |
|
572 | - } |
|
573 | - |
|
574 | - // return filtered value |
|
575 | - return apply_filters('FHEE__EEM_Message__debug', $is_debugging); |
|
576 | - } |
|
577 | - |
|
578 | - |
|
579 | - /** |
|
580 | - * Deletes old messages meeting certain criteria for removal from the database. |
|
581 | - * By default, this will delete messages that: |
|
582 | - * - are older than the value of the delete_threshold in months. |
|
583 | - * - have a STS_ID other than EEM_Message::status_idle |
|
584 | - * |
|
585 | - * @param int $delete_threshold This integer will be used to set the boundary for what messages are deleted in |
|
586 | - * months. |
|
587 | - * @return bool|false|int Either the number of records affected or false if there was an error (you can call |
|
588 | - * $wpdb->last_error to find out what the error was. |
|
589 | - * @throws EE_Error |
|
590 | - * @throws EE_Error |
|
591 | - * @throws EE_Error |
|
592 | - */ |
|
593 | - public function delete_old_messages($delete_threshold = 6) |
|
594 | - { |
|
595 | - $number_deleted = 0; |
|
596 | - /** |
|
597 | - * Allows code to change the boundary for what messages are kept. |
|
598 | - * Uses the value of the `delete_threshold` variable by default. |
|
599 | - * |
|
600 | - * @param int $seconds seconds that will be subtracted from the timestamp for now. |
|
601 | - * @return int |
|
602 | - */ |
|
603 | - $time_to_leave_alone = absint( |
|
604 | - apply_filters( |
|
605 | - 'FHEE__EEM_Message__delete_old_messages__time_to_leave_alone', |
|
606 | - ((int) $delete_threshold) * MONTH_IN_SECONDS |
|
607 | - ) |
|
608 | - ); |
|
609 | - |
|
610 | - |
|
611 | - /** |
|
612 | - * Allows code to change what message stati are ignored when deleting. |
|
613 | - * Defaults to only ignore EEM_Message::status_idle messages. |
|
614 | - * |
|
615 | - * @param string $message_stati_to_keep An array of message statuses that will be ignored when deleting. |
|
616 | - */ |
|
617 | - $message_stati_to_keep = (array) apply_filters( |
|
618 | - 'FHEE__EEM_Message__delete_old_messages__message_stati_to_keep', |
|
619 | - array( |
|
620 | - EEM_Message::status_idle |
|
621 | - ) |
|
622 | - ); |
|
623 | - |
|
624 | - // first get all the ids of messages being deleted |
|
625 | - $message_ids_to_delete = EEM_Message::instance()->get_col( |
|
626 | - array( |
|
627 | - 0 => array( |
|
628 | - 'STS_ID' => array('NOT_IN', $message_stati_to_keep), |
|
629 | - 'MSG_modified' => array('<', time() - $time_to_leave_alone) |
|
630 | - ), |
|
631 | - 'limit' => apply_filters( |
|
632 | - 'EEM_Message__delete_old_messages__limit', |
|
633 | - 2000, |
|
634 | - $delete_threshold |
|
635 | - ) |
|
636 | - ) |
|
637 | - ); |
|
638 | - |
|
639 | - if (! empty($message_ids_to_delete) && is_array($message_ids_to_delete)) { |
|
640 | - global $wpdb; |
|
641 | - $number_deleted = $wpdb->query(' |
|
16 | + // private instance of the Message object |
|
17 | + protected static $_instance = null; |
|
18 | + |
|
19 | + |
|
20 | + /** |
|
21 | + * This priority indicates a message should be generated and sent ASAP |
|
22 | + * |
|
23 | + * @type int |
|
24 | + */ |
|
25 | + const priority_high = 10; |
|
26 | + |
|
27 | + |
|
28 | + /** |
|
29 | + * This priority indicates a message should be generated ASAP and queued for sending. |
|
30 | + * |
|
31 | + * @type |
|
32 | + */ |
|
33 | + const priority_medium = 20; |
|
34 | + |
|
35 | + |
|
36 | + /** |
|
37 | + * This priority indicates a message should be queued for generating. |
|
38 | + * |
|
39 | + * @type int |
|
40 | + */ |
|
41 | + const priority_low = 30; |
|
42 | + |
|
43 | + |
|
44 | + /** |
|
45 | + * indicates this message was sent at the time modified |
|
46 | + */ |
|
47 | + const status_sent = 'MSN'; |
|
48 | + |
|
49 | + |
|
50 | + /** |
|
51 | + * indicates this message is waiting to be sent |
|
52 | + */ |
|
53 | + const status_idle = 'MID'; |
|
54 | + |
|
55 | + |
|
56 | + /** |
|
57 | + * indicates an attempt was a made to send this message |
|
58 | + * at the scheduled time, but it failed at the time modified. This differs from MDO status in that it will ALWAYS |
|
59 | + * appear to the end user. |
|
60 | + */ |
|
61 | + const status_failed = 'MFL'; |
|
62 | + |
|
63 | + |
|
64 | + /** |
|
65 | + * indicates the message has been flagged for resending (at the time modified). |
|
66 | + */ |
|
67 | + const status_resend = 'MRS'; |
|
68 | + |
|
69 | + |
|
70 | + /** |
|
71 | + * indicates the message has been flagged for generation but has not been generated yet. Messages always start as |
|
72 | + * this status when added to the queue. |
|
73 | + */ |
|
74 | + const status_incomplete = 'MIC'; |
|
75 | + |
|
76 | + |
|
77 | + /** |
|
78 | + * Indicates everything was generated fine for the message, however, the messenger was unable to send. |
|
79 | + * This status means that its possible to retry sending the message. |
|
80 | + */ |
|
81 | + const status_retry = 'MRT'; |
|
82 | + |
|
83 | + |
|
84 | + /** |
|
85 | + * This is used for more informational messages that may not indicate anything is broken but still cannot be |
|
86 | + * generated or sent correctly. An example of a message that would get flagged this way would be when a not |
|
87 | + * approved message was queued for generation, but at time of generation, the attached registration(s) are |
|
88 | + * approved. So the message queued for generation is no longer valid. Messages for this status will only persist |
|
89 | + * in the db and be viewable in the message activity list table when the messages system is in debug mode. |
|
90 | + * |
|
91 | + * @see EEM_Message::debug() |
|
92 | + */ |
|
93 | + const status_debug_only = 'MDO'; |
|
94 | + |
|
95 | + |
|
96 | + /** |
|
97 | + * This status is given to messages it is processed by the messenger send method. |
|
98 | + * Messages with this status should rarely be seen in the Message List table, but if they are, that's usually |
|
99 | + * indicative of a PHP timeout or memory limit issue. |
|
100 | + */ |
|
101 | + const status_messenger_executing = 'MEX'; |
|
102 | + |
|
103 | + |
|
104 | + /** |
|
105 | + * Private constructor to prevent direct creation. |
|
106 | + * |
|
107 | + * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and |
|
108 | + * any incoming timezone data that gets saved). Note this just sends the timezone info to |
|
109 | + * the date time model field objects. Default is null (and will be assumed using the set |
|
110 | + * timezone in the 'timezone_string' wp option) |
|
111 | + * @throws EE_Error |
|
112 | + * @throws EE_Error |
|
113 | + * @throws EE_Error |
|
114 | + */ |
|
115 | + protected function __construct($timezone = null) |
|
116 | + { |
|
117 | + $this->singular_item = esc_html__('Message', 'event_espresso'); |
|
118 | + $this->plural_item = esc_html__('Messages', 'event_espresso'); |
|
119 | + |
|
120 | + $this->_tables = array( |
|
121 | + 'Message' => new EE_Primary_Table('esp_message', 'MSG_ID'), |
|
122 | + ); |
|
123 | + |
|
124 | + $allowed_priority = array( |
|
125 | + self::priority_high => esc_html__('high', 'event_espresso'), |
|
126 | + self::priority_medium => esc_html__('medium', 'event_espresso'), |
|
127 | + self::priority_low => esc_html__('low', 'event_espresso'), |
|
128 | + ); |
|
129 | + |
|
130 | + $this->_fields = array( |
|
131 | + 'Message' => array( |
|
132 | + 'MSG_ID' => new EE_Primary_Key_Int_Field('MSG_ID', esc_html__('Message ID', 'event_espresso')), |
|
133 | + 'MSG_token' => new EE_Plain_Text_Field( |
|
134 | + 'MSG_token', |
|
135 | + esc_html__( |
|
136 | + 'Unique Token used to represent this row in publicly viewable contexts (eg. a url).', |
|
137 | + 'event_espresso' |
|
138 | + ), |
|
139 | + false, |
|
140 | + EEH_URL::generate_unique_token() |
|
141 | + ), |
|
142 | + 'GRP_ID' => new EE_Foreign_Key_Int_Field( |
|
143 | + 'GRP_ID', |
|
144 | + esc_html__('Foreign key to the EEM_Message_Template_Group table.', 'event_espresso'), |
|
145 | + true, |
|
146 | + 0, |
|
147 | + 'Message_Template_Group' |
|
148 | + ), |
|
149 | + 'TXN_ID' => new EE_Foreign_Key_Int_Field( |
|
150 | + 'TXN_ID', |
|
151 | + esc_html__( |
|
152 | + 'Foreign key to the related EE_Transaction. This is required to give context for regenerating the specific message', |
|
153 | + 'event_espresso' |
|
154 | + ), |
|
155 | + true, |
|
156 | + 0, |
|
157 | + 'Transaction' |
|
158 | + ), |
|
159 | + 'MSG_messenger' => new EE_Plain_Text_Field( |
|
160 | + 'MSG_messenger', |
|
161 | + esc_html__( |
|
162 | + 'Corresponds to the EE_messenger::name used to send this message. This will also be used to attempt any resending of the message.', |
|
163 | + 'event_espresso' |
|
164 | + ), |
|
165 | + false, |
|
166 | + 'email' |
|
167 | + ), |
|
168 | + 'MSG_message_type' => new EE_Plain_Text_Field( |
|
169 | + 'MSG_message_type', |
|
170 | + esc_html__('Corresponds to the EE_message_type::name used to generate this message.', 'event_espresso'), |
|
171 | + false, |
|
172 | + 'receipt' |
|
173 | + ), |
|
174 | + 'MSG_context' => new EE_Plain_Text_Field('MSG_context', esc_html__('Context', 'event_espresso'), false), |
|
175 | + 'MSG_recipient_ID' => new EE_Foreign_Key_Int_Field( |
|
176 | + 'MSG_recipient_ID', |
|
177 | + esc_html__('Recipient ID', 'event_espresso'), |
|
178 | + true, |
|
179 | + null, |
|
180 | + array('Registration', 'Attendee', 'WP_User') |
|
181 | + ), |
|
182 | + 'MSG_recipient_type' => new EE_Any_Foreign_Model_Name_Field( |
|
183 | + 'MSG_recipient_type', |
|
184 | + esc_html__('Recipient Type', 'event_espresso'), |
|
185 | + true, |
|
186 | + null, |
|
187 | + array('Registration', 'Attendee', 'WP_User') |
|
188 | + ), |
|
189 | + 'MSG_content' => new EE_Maybe_Serialized_Text_Field( |
|
190 | + 'MSG_content', |
|
191 | + esc_html__('Content', 'event_espresso'), |
|
192 | + true, |
|
193 | + '' |
|
194 | + ), |
|
195 | + 'MSG_to' => new EE_Maybe_Serialized_Text_Field( |
|
196 | + 'MSG_to', |
|
197 | + esc_html__('Address To', 'event_espresso'), |
|
198 | + true |
|
199 | + ), |
|
200 | + 'MSG_from' => new EE_Maybe_Serialized_Text_Field( |
|
201 | + 'MSG_from', |
|
202 | + esc_html__('Address From', 'event_espresso'), |
|
203 | + true |
|
204 | + ), |
|
205 | + 'MSG_subject' => new EE_Maybe_Serialized_Text_Field( |
|
206 | + 'MSG_subject', |
|
207 | + esc_html__('Subject', 'event_espresso'), |
|
208 | + true, |
|
209 | + '' |
|
210 | + ), |
|
211 | + 'MSG_priority' => new EE_Enum_Integer_Field( |
|
212 | + 'MSG_priority', |
|
213 | + esc_html__('Priority', 'event_espresso'), |
|
214 | + false, |
|
215 | + self::priority_low, |
|
216 | + $allowed_priority |
|
217 | + ), |
|
218 | + 'STS_ID' => new EE_Foreign_Key_String_Field( |
|
219 | + 'STS_ID', |
|
220 | + esc_html__('Status', 'event_espresso'), |
|
221 | + false, |
|
222 | + self::status_incomplete, |
|
223 | + 'Status' |
|
224 | + ), |
|
225 | + 'MSG_created' => new EE_Datetime_Field( |
|
226 | + 'MSG_created', |
|
227 | + esc_html__('Created', 'event_espresso'), |
|
228 | + false, |
|
229 | + EE_Datetime_Field::now |
|
230 | + ), |
|
231 | + 'MSG_modified' => new EE_Datetime_Field( |
|
232 | + 'MSG_modified', |
|
233 | + esc_html__('Modified', 'event_espresso'), |
|
234 | + true, |
|
235 | + EE_Datetime_Field::now |
|
236 | + ), |
|
237 | + ), |
|
238 | + ); |
|
239 | + $this->_model_relations = array( |
|
240 | + 'Attendee' => new EE_Belongs_To_Any_Relation(), |
|
241 | + 'Registration' => new EE_Belongs_To_Any_Relation(), |
|
242 | + 'WP_User' => new EE_Belongs_To_Any_Relation(), |
|
243 | + 'Message_Template_Group' => new EE_Belongs_To_Relation(), |
|
244 | + 'Transaction' => new EE_Belongs_To_Relation(), |
|
245 | + ); |
|
246 | + parent::__construct($timezone); |
|
247 | + } |
|
248 | + |
|
249 | + |
|
250 | + /** |
|
251 | + * @return EE_Message |
|
252 | + * @throws EE_Error |
|
253 | + */ |
|
254 | + public function create_default_object() |
|
255 | + { |
|
256 | + /** @type EE_Message $message */ |
|
257 | + $message = parent::create_default_object(); |
|
258 | + if ($message instanceof EE_Message) { |
|
259 | + return EE_Message_Factory::set_messenger_and_message_type($message); |
|
260 | + } |
|
261 | + return null; |
|
262 | + } |
|
263 | + |
|
264 | + |
|
265 | + /** |
|
266 | + * @param mixed $cols_n_values |
|
267 | + * @return EE_Message |
|
268 | + * @throws EE_Error |
|
269 | + * @throws EE_Error |
|
270 | + */ |
|
271 | + public function instantiate_class_from_array_or_object($cols_n_values) |
|
272 | + { |
|
273 | + /** @type EE_Message $message */ |
|
274 | + $message = parent::instantiate_class_from_array_or_object($cols_n_values); |
|
275 | + if ($message instanceof EE_Message) { |
|
276 | + return EE_Message_Factory::set_messenger_and_message_type($message); |
|
277 | + } |
|
278 | + return null; |
|
279 | + } |
|
280 | + |
|
281 | + |
|
282 | + /** |
|
283 | + * Returns whether or not a message of that type was sent for a given attendee. |
|
284 | + * |
|
285 | + * @param EE_Attendee|int $attendee |
|
286 | + * @param string $message_type the message type slug |
|
287 | + * @return boolean |
|
288 | + * @throws EE_Error |
|
289 | + * @throws EE_Error |
|
290 | + * @throws EE_Error |
|
291 | + */ |
|
292 | + public function message_sent_for_attendee($attendee, $message_type) |
|
293 | + { |
|
294 | + $attendee_ID = EEM_Attendee::instance()->ensure_is_ID($attendee); |
|
295 | + return $this->exists(array( |
|
296 | + array( |
|
297 | + 'Attendee.ATT_ID' => $attendee_ID, |
|
298 | + 'MSG_message_type' => $message_type, |
|
299 | + 'STS_ID' => array('IN', $this->stati_indicating_sent()), |
|
300 | + ), |
|
301 | + )); |
|
302 | + } |
|
303 | + |
|
304 | + |
|
305 | + /** |
|
306 | + * Returns whether or not a message of that type was sent for a given registration |
|
307 | + * |
|
308 | + * @param EE_Registration|int $registration |
|
309 | + * @param string $message_type the message type slug |
|
310 | + * @return boolean |
|
311 | + * @throws EE_Error |
|
312 | + * @throws EE_Error |
|
313 | + * @throws EE_Error |
|
314 | + */ |
|
315 | + public function message_sent_for_registration($registration, $message_type) |
|
316 | + { |
|
317 | + $registrationID = EEM_Registration::instance()->ensure_is_ID($registration); |
|
318 | + return $this->exists(array( |
|
319 | + array( |
|
320 | + 'Registration.REG_ID' => $registrationID, |
|
321 | + 'MSG_message_type' => $message_type, |
|
322 | + 'STS_ID' => array('IN', $this->stati_indicating_sent()), |
|
323 | + ), |
|
324 | + )); |
|
325 | + } |
|
326 | + |
|
327 | + |
|
328 | + /** |
|
329 | + * This retrieves an EE_Message object from the db matching the given token string. |
|
330 | + * |
|
331 | + * @param string $token |
|
332 | + * @return EE_Message |
|
333 | + * @throws EE_Error |
|
334 | + */ |
|
335 | + public function get_one_by_token($token) |
|
336 | + { |
|
337 | + return $this->get_one(array( |
|
338 | + array( |
|
339 | + 'MSG_token' => $token, |
|
340 | + ), |
|
341 | + )); |
|
342 | + } |
|
343 | + |
|
344 | + |
|
345 | + /** |
|
346 | + * Returns stati that indicate the message HAS been sent |
|
347 | + * |
|
348 | + * @return array of strings for possible stati |
|
349 | + */ |
|
350 | + public function stati_indicating_sent() |
|
351 | + { |
|
352 | + return apply_filters('FHEE__EEM_Message__stati_indicating_sent', array(self::status_sent)); |
|
353 | + } |
|
354 | + |
|
355 | + |
|
356 | + /** |
|
357 | + * Returns stati that indicate the message is waiting to be sent. |
|
358 | + * |
|
359 | + * @return array of strings for possible stati. |
|
360 | + */ |
|
361 | + public function stati_indicating_to_send() |
|
362 | + { |
|
363 | + return apply_filters( |
|
364 | + 'FHEE__EEM_Message__stati_indicating_to_send', |
|
365 | + array(self::status_idle, self::status_resend) |
|
366 | + ); |
|
367 | + } |
|
368 | + |
|
369 | + |
|
370 | + /** |
|
371 | + * Returns stati that indicate the message has failed sending |
|
372 | + * |
|
373 | + * @return array array of strings for possible stati. |
|
374 | + */ |
|
375 | + public function stati_indicating_failed_sending() |
|
376 | + { |
|
377 | + $failed_stati = array( |
|
378 | + self::status_failed, |
|
379 | + self::status_retry, |
|
380 | + self::status_messenger_executing, |
|
381 | + ); |
|
382 | + // if WP_DEBUG is set, then let's include debug_only fails |
|
383 | + if (WP_DEBUG) { |
|
384 | + $failed_stati[] = self::status_debug_only; |
|
385 | + } |
|
386 | + return apply_filters('FHEE__EEM_Message__stati_indicating_failed_sending', $failed_stati); |
|
387 | + } |
|
388 | + |
|
389 | + |
|
390 | + /** |
|
391 | + * Returns filterable array of all EEM_Message statuses. |
|
392 | + * |
|
393 | + * @return array |
|
394 | + */ |
|
395 | + public function all_statuses() |
|
396 | + { |
|
397 | + return apply_filters( |
|
398 | + 'FHEE__EEM_Message__all_statuses', |
|
399 | + array( |
|
400 | + EEM_Message::status_sent, |
|
401 | + EEM_Message::status_incomplete, |
|
402 | + EEM_Message::status_idle, |
|
403 | + EEM_Message::status_resend, |
|
404 | + EEM_Message::status_retry, |
|
405 | + EEM_Message::status_failed, |
|
406 | + EEM_Message::status_messenger_executing, |
|
407 | + EEM_Message::status_debug_only, |
|
408 | + ) |
|
409 | + ); |
|
410 | + } |
|
411 | + |
|
412 | + /** |
|
413 | + * Detects any specific query variables in the request and uses those to setup appropriate |
|
414 | + * filter for any queries. |
|
415 | + * |
|
416 | + * @return array |
|
417 | + */ |
|
418 | + public function filter_by_query_params() |
|
419 | + { |
|
420 | + /** @var RequestInterface $request */ |
|
421 | + $request = EEM_Base::$loader->getShared(RequestInterface::class); |
|
422 | + // expected possible query_vars, the key in this array matches an expected key in the request, |
|
423 | + // the value, matches the corresponding EEM_Base child reference. |
|
424 | + $expected_vars = $this->_expected_vars_for_query_inject(); |
|
425 | + $query_params[0] = array(); |
|
426 | + foreach ($expected_vars as $request_key => $model_name) { |
|
427 | + $request_value = $request->getRequestParam($request_key); |
|
428 | + if ($request_value) { |
|
429 | + // special case |
|
430 | + switch ($request_key) { |
|
431 | + case '_REG_ID': |
|
432 | + $query_params[0]['AND**filter_by']['OR**filter_by_REG_ID'] = array( |
|
433 | + 'Transaction.Registration.REG_ID' => $request_value, |
|
434 | + ); |
|
435 | + break; |
|
436 | + case 'EVT_ID': |
|
437 | + $query_params[0]['AND**filter_by']['OR**filter_by_EVT_ID'] = array( |
|
438 | + 'Transaction.Registration.EVT_ID' => $request_value, |
|
439 | + ); |
|
440 | + break; |
|
441 | + default: |
|
442 | + $query_params[0]['AND**filter_by'][ 'OR**filter_by_' . $request_key ][ $model_name . '.' . $request_key ] = $request_value; |
|
443 | + break; |
|
444 | + } |
|
445 | + } |
|
446 | + } |
|
447 | + return $query_params; |
|
448 | + } |
|
449 | + |
|
450 | + |
|
451 | + /** |
|
452 | + * @return string |
|
453 | + * @throws EE_Error |
|
454 | + * @throws ReflectionException |
|
455 | + */ |
|
456 | + public function get_pretty_label_for_results() |
|
457 | + { |
|
458 | + /** @var RequestInterface $request */ |
|
459 | + $request = EEM_Base::$loader->getShared(RequestInterface::class); |
|
460 | + $expected_vars = $this->_expected_vars_for_query_inject(); |
|
461 | + $pretty_label = ''; |
|
462 | + $label_parts = array(); |
|
463 | + foreach ($expected_vars as $request_key => $model_name) { |
|
464 | + $model_name = strpos($model_name, 'EEM_', true) === 0 ? $model_name : "EEM_{$model_name}"; |
|
465 | + $model = EEM_Base::$loader->getShared($model_name); |
|
466 | + $model_field_value = $request->getRequestParam($request_key); |
|
467 | + if ($model instanceof EEM_Base && $model_field_value !== '') { |
|
468 | + switch ($request_key) { |
|
469 | + case '_REG_ID': |
|
470 | + $label_parts[] = sprintf( |
|
471 | + esc_html__('Registration with the ID: %s', 'event_espresso'), |
|
472 | + $model_field_value |
|
473 | + ); |
|
474 | + break; |
|
475 | + case 'ATT_ID': |
|
476 | + /** @var EE_Attendee $attendee */ |
|
477 | + $attendee = $model->get_one_by_ID($model_field_value); |
|
478 | + $label_parts[] = $attendee instanceof EE_Attendee |
|
479 | + ? sprintf(esc_html__('Attendee %s', 'event_espresso'), $attendee->full_name()) |
|
480 | + : sprintf(esc_html__('Attendee ID: %s', 'event_espresso'), $model_field_value); |
|
481 | + break; |
|
482 | + case 'ID': |
|
483 | + /** @var EE_WP_User $wpUser */ |
|
484 | + $wpUser = $model->get_one_by_ID($model_field_value); |
|
485 | + $label_parts[] = $wpUser instanceof EE_WP_User |
|
486 | + ? sprintf(esc_html__('WP User: %s', 'event_espresso'), $wpUser->name()) |
|
487 | + : sprintf(esc_html__('WP User ID: %s', 'event_espresso'), $model_field_value); |
|
488 | + break; |
|
489 | + case 'TXN_ID': |
|
490 | + $label_parts[] = sprintf( |
|
491 | + esc_html__('Transaction with the ID: %s', 'event_espresso'), |
|
492 | + $model_field_value |
|
493 | + ); |
|
494 | + break; |
|
495 | + case 'EVT_ID': |
|
496 | + /** @var EE_Event $Event */ |
|
497 | + $Event = $model->get_one_by_ID($model_field_value); |
|
498 | + $label_parts[] = $Event instanceof EE_Event |
|
499 | + ? sprintf(esc_html__('for the Event: %s', 'event_espresso'), $Event->name()) |
|
500 | + : sprintf(esc_html__('for the Event with ID: %s', 'event_espresso'), $model_field_value); |
|
501 | + break; |
|
502 | + } |
|
503 | + } |
|
504 | + } |
|
505 | + |
|
506 | + if ($label_parts) { |
|
507 | + // prepend to the last element of $label_parts an "and". |
|
508 | + if (count($label_parts) > 1) { |
|
509 | + $label_parts_index_to_prepend = count($label_parts) - 1; |
|
510 | + $label_parts[ $label_parts_index_to_prepend ] = 'and' . $label_parts[ $label_parts_index_to_prepend ]; |
|
511 | + } |
|
512 | + |
|
513 | + $pretty_label .= sprintf( |
|
514 | + esc_html_x( |
|
515 | + 'Showing messages for %s', |
|
516 | + 'A label for the messages returned in a query that are filtered by items in the query. This could be Transaction, Event, Attendee, Registration, or WP_User.', |
|
517 | + 'event_espresso' |
|
518 | + ), |
|
519 | + implode(', ', $label_parts) |
|
520 | + ); |
|
521 | + } |
|
522 | + return $pretty_label; |
|
523 | + } |
|
524 | + |
|
525 | + |
|
526 | + /** |
|
527 | + * This returns the array of expected variables for the EEI_Query_Filter methods being implemented |
|
528 | + * The array is in the format: |
|
529 | + * array( |
|
530 | + * {$field_name} => {$model_name} |
|
531 | + * ); |
|
532 | + * |
|
533 | + * @since 4.9.0 |
|
534 | + * @return array |
|
535 | + */ |
|
536 | + protected function _expected_vars_for_query_inject() |
|
537 | + { |
|
538 | + return array( |
|
539 | + '_REG_ID' => 'Registration', |
|
540 | + 'ATT_ID' => 'Attendee', |
|
541 | + 'ID' => 'WP_User', |
|
542 | + 'TXN_ID' => 'Transaction', |
|
543 | + 'EVT_ID' => 'Event', |
|
544 | + ); |
|
545 | + } |
|
546 | + |
|
547 | + |
|
548 | + /** |
|
549 | + * This returns whether EEM_Message is in debug mode or not. |
|
550 | + * Currently "debug mode" is used to control the handling of the EEM_Message::debug_only status when |
|
551 | + * generating/sending messages. Debug mode can be set by either: |
|
552 | + * 1. Sending in a value for the $set_debug argument |
|
553 | + * 2. Defining `EE_DEBUG_MESSAGES` constant in wp-config.php |
|
554 | + * 3. Overriding the above via the provided filter. |
|
555 | + * |
|
556 | + * @param bool|null $set_debug If provided, then the debug mode will be set internally until reset via the |
|
557 | + * provided boolean. When no argument is provided (default null) then the debug |
|
558 | + * mode will be returned. |
|
559 | + * @return bool true means Messages is in debug mode. false means messages system is not in debug mode. |
|
560 | + */ |
|
561 | + public static function debug($set_debug = null) |
|
562 | + { |
|
563 | + static $is_debugging = null; |
|
564 | + |
|
565 | + // initialize (use constant if set). |
|
566 | + if (is_null($set_debug) && is_null($is_debugging)) { |
|
567 | + $is_debugging = defined('EE_DEBUG_MESSAGES') && EE_DEBUG_MESSAGES; |
|
568 | + } |
|
569 | + |
|
570 | + if (! is_null($set_debug)) { |
|
571 | + $is_debugging = filter_var($set_debug, FILTER_VALIDATE_BOOLEAN); |
|
572 | + } |
|
573 | + |
|
574 | + // return filtered value |
|
575 | + return apply_filters('FHEE__EEM_Message__debug', $is_debugging); |
|
576 | + } |
|
577 | + |
|
578 | + |
|
579 | + /** |
|
580 | + * Deletes old messages meeting certain criteria for removal from the database. |
|
581 | + * By default, this will delete messages that: |
|
582 | + * - are older than the value of the delete_threshold in months. |
|
583 | + * - have a STS_ID other than EEM_Message::status_idle |
|
584 | + * |
|
585 | + * @param int $delete_threshold This integer will be used to set the boundary for what messages are deleted in |
|
586 | + * months. |
|
587 | + * @return bool|false|int Either the number of records affected or false if there was an error (you can call |
|
588 | + * $wpdb->last_error to find out what the error was. |
|
589 | + * @throws EE_Error |
|
590 | + * @throws EE_Error |
|
591 | + * @throws EE_Error |
|
592 | + */ |
|
593 | + public function delete_old_messages($delete_threshold = 6) |
|
594 | + { |
|
595 | + $number_deleted = 0; |
|
596 | + /** |
|
597 | + * Allows code to change the boundary for what messages are kept. |
|
598 | + * Uses the value of the `delete_threshold` variable by default. |
|
599 | + * |
|
600 | + * @param int $seconds seconds that will be subtracted from the timestamp for now. |
|
601 | + * @return int |
|
602 | + */ |
|
603 | + $time_to_leave_alone = absint( |
|
604 | + apply_filters( |
|
605 | + 'FHEE__EEM_Message__delete_old_messages__time_to_leave_alone', |
|
606 | + ((int) $delete_threshold) * MONTH_IN_SECONDS |
|
607 | + ) |
|
608 | + ); |
|
609 | + |
|
610 | + |
|
611 | + /** |
|
612 | + * Allows code to change what message stati are ignored when deleting. |
|
613 | + * Defaults to only ignore EEM_Message::status_idle messages. |
|
614 | + * |
|
615 | + * @param string $message_stati_to_keep An array of message statuses that will be ignored when deleting. |
|
616 | + */ |
|
617 | + $message_stati_to_keep = (array) apply_filters( |
|
618 | + 'FHEE__EEM_Message__delete_old_messages__message_stati_to_keep', |
|
619 | + array( |
|
620 | + EEM_Message::status_idle |
|
621 | + ) |
|
622 | + ); |
|
623 | + |
|
624 | + // first get all the ids of messages being deleted |
|
625 | + $message_ids_to_delete = EEM_Message::instance()->get_col( |
|
626 | + array( |
|
627 | + 0 => array( |
|
628 | + 'STS_ID' => array('NOT_IN', $message_stati_to_keep), |
|
629 | + 'MSG_modified' => array('<', time() - $time_to_leave_alone) |
|
630 | + ), |
|
631 | + 'limit' => apply_filters( |
|
632 | + 'EEM_Message__delete_old_messages__limit', |
|
633 | + 2000, |
|
634 | + $delete_threshold |
|
635 | + ) |
|
636 | + ) |
|
637 | + ); |
|
638 | + |
|
639 | + if (! empty($message_ids_to_delete) && is_array($message_ids_to_delete)) { |
|
640 | + global $wpdb; |
|
641 | + $number_deleted = $wpdb->query(' |
|
642 | 642 | DELETE |
643 | 643 | FROM ' . $this->table() . ' |
644 | 644 | WHERE |
645 | 645 | MSG_ID IN (' . implode(",", $message_ids_to_delete) . ') |
646 | 646 | '); |
647 | - } |
|
648 | - |
|
649 | - /** |
|
650 | - * This will get called if the number of records deleted 0 or greater. So a successful deletion is one where |
|
651 | - * there were no errors. An unsuccessful deletion is where there were errors. Keep that in mind for the actions |
|
652 | - * below. |
|
653 | - */ |
|
654 | - if ($number_deleted !== false) { |
|
655 | - do_action('AHEE__EEM_Message__delete_old_messages__after_successful_deletion', $message_ids_to_delete, $number_deleted); |
|
656 | - } else { |
|
657 | - do_action('AHEE__EEM_Message__delete_old_messages__after_deletion_fail', $message_ids_to_delete, $number_deleted); |
|
658 | - } |
|
659 | - return $number_deleted; |
|
660 | - } |
|
647 | + } |
|
648 | + |
|
649 | + /** |
|
650 | + * This will get called if the number of records deleted 0 or greater. So a successful deletion is one where |
|
651 | + * there were no errors. An unsuccessful deletion is where there were errors. Keep that in mind for the actions |
|
652 | + * below. |
|
653 | + */ |
|
654 | + if ($number_deleted !== false) { |
|
655 | + do_action('AHEE__EEM_Message__delete_old_messages__after_successful_deletion', $message_ids_to_delete, $number_deleted); |
|
656 | + } else { |
|
657 | + do_action('AHEE__EEM_Message__delete_old_messages__after_deletion_fail', $message_ids_to_delete, $number_deleted); |
|
658 | + } |
|
659 | + return $number_deleted; |
|
660 | + } |
|
661 | 661 | } |
@@ -11,8 +11,8 @@ discard block |
||
11 | 11 | // if you're a dev and want to receive all errors via email |
12 | 12 | // add this to your wp-config.php: define( 'EE_ERROR_EMAILS', TRUE ); |
13 | 13 | if (defined('WP_DEBUG') && WP_DEBUG === true && defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS === true) { |
14 | - set_error_handler(array('EE_Error', 'error_handler')); |
|
15 | - register_shutdown_function(array('EE_Error', 'fatal_error_handler')); |
|
14 | + set_error_handler(array('EE_Error', 'error_handler')); |
|
15 | + register_shutdown_function(array('EE_Error', 'fatal_error_handler')); |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | |
@@ -26,251 +26,251 @@ discard block |
||
26 | 26 | class EE_Error extends Exception |
27 | 27 | { |
28 | 28 | |
29 | - const OPTIONS_KEY_NOTICES = 'ee_notices'; |
|
30 | - |
|
31 | - |
|
32 | - /** |
|
33 | - * name of the file to log exceptions to |
|
34 | - * |
|
35 | - * @var string |
|
36 | - */ |
|
37 | - private static $_exception_log_file = 'espresso_error_log.txt'; |
|
38 | - |
|
39 | - /** |
|
40 | - * stores details for all exception |
|
41 | - * |
|
42 | - * @var array |
|
43 | - */ |
|
44 | - private static $_all_exceptions = array(); |
|
45 | - |
|
46 | - /** |
|
47 | - * tracks number of errors |
|
48 | - * |
|
49 | - * @var int |
|
50 | - */ |
|
51 | - private static $_error_count = 0; |
|
52 | - |
|
53 | - /** |
|
54 | - * @var array $_espresso_notices |
|
55 | - */ |
|
56 | - private static $_espresso_notices = array('success' => false, 'errors' => false, 'attention' => false); |
|
57 | - |
|
58 | - |
|
59 | - /** |
|
60 | - * @override default exception handling |
|
61 | - * @param string $message |
|
62 | - * @param int $code |
|
63 | - * @param Exception|null $previous |
|
64 | - */ |
|
65 | - public function __construct($message, $code = 0, Exception $previous = null) |
|
66 | - { |
|
67 | - if (version_compare(PHP_VERSION, '5.3.0', '<')) { |
|
68 | - parent::__construct($message, $code); |
|
69 | - } else { |
|
70 | - parent::__construct($message, $code, $previous); |
|
71 | - } |
|
72 | - } |
|
73 | - |
|
74 | - |
|
75 | - /** |
|
76 | - * error_handler |
|
77 | - * |
|
78 | - * @param $code |
|
79 | - * @param $message |
|
80 | - * @param $file |
|
81 | - * @param $line |
|
82 | - * @return void |
|
83 | - */ |
|
84 | - public static function error_handler($code, $message, $file, $line) |
|
85 | - { |
|
86 | - $type = EE_Error::error_type($code); |
|
87 | - $site = site_url(); |
|
88 | - switch ($site) { |
|
89 | - case 'http://ee4.eventespresso.com/': |
|
90 | - case 'http://ee4decaf.eventespresso.com/': |
|
91 | - case 'http://ee4hf.eventespresso.com/': |
|
92 | - case 'http://ee4a.eventespresso.com/': |
|
93 | - case 'http://ee4ad.eventespresso.com/': |
|
94 | - case 'http://ee4b.eventespresso.com/': |
|
95 | - case 'http://ee4bd.eventespresso.com/': |
|
96 | - case 'http://ee4d.eventespresso.com/': |
|
97 | - case 'http://ee4dd.eventespresso.com/': |
|
98 | - $to = '[email protected]'; |
|
99 | - break; |
|
100 | - default: |
|
101 | - $to = get_option('admin_email'); |
|
102 | - } |
|
103 | - $subject = $type . ' ' . $message . ' in ' . EVENT_ESPRESSO_VERSION . ' on ' . site_url(); |
|
104 | - $msg = EE_Error::_format_error($type, $message, $file, $line); |
|
105 | - if (function_exists('wp_mail')) { |
|
106 | - add_filter('wp_mail_content_type', array('EE_Error', 'set_content_type')); |
|
107 | - wp_mail($to, $subject, $msg); |
|
108 | - } |
|
109 | - echo '<div id="message" class="espresso-notices error"><p>'; |
|
110 | - echo $type . ': ' . $message . '<br />' . $file . ' line ' . $line; |
|
111 | - echo '<br /></p></div>'; |
|
112 | - } |
|
113 | - |
|
114 | - |
|
115 | - /** |
|
116 | - * error_type |
|
117 | - * http://www.php.net/manual/en/errorfunc.constants.php#109430 |
|
118 | - * |
|
119 | - * @param $code |
|
120 | - * @return string |
|
121 | - */ |
|
122 | - public static function error_type($code) |
|
123 | - { |
|
124 | - switch ($code) { |
|
125 | - case E_ERROR: // 1 // |
|
126 | - return 'E_ERROR'; |
|
127 | - case E_WARNING: // 2 // |
|
128 | - return 'E_WARNING'; |
|
129 | - case E_PARSE: // 4 // |
|
130 | - return 'E_PARSE'; |
|
131 | - case E_NOTICE: // 8 // |
|
132 | - return 'E_NOTICE'; |
|
133 | - case E_CORE_ERROR: // 16 // |
|
134 | - return 'E_CORE_ERROR'; |
|
135 | - case E_CORE_WARNING: // 32 // |
|
136 | - return 'E_CORE_WARNING'; |
|
137 | - case E_COMPILE_ERROR: // 64 // |
|
138 | - return 'E_COMPILE_ERROR'; |
|
139 | - case E_COMPILE_WARNING: // 128 // |
|
140 | - return 'E_COMPILE_WARNING'; |
|
141 | - case E_USER_ERROR: // 256 // |
|
142 | - return 'E_USER_ERROR'; |
|
143 | - case E_USER_WARNING: // 512 // |
|
144 | - return 'E_USER_WARNING'; |
|
145 | - case E_USER_NOTICE: // 1024 // |
|
146 | - return 'E_USER_NOTICE'; |
|
147 | - case E_STRICT: // 2048 // |
|
148 | - return 'E_STRICT'; |
|
149 | - case E_RECOVERABLE_ERROR: // 4096 // |
|
150 | - return 'E_RECOVERABLE_ERROR'; |
|
151 | - case E_DEPRECATED: // 8192 // |
|
152 | - return 'E_DEPRECATED'; |
|
153 | - case E_USER_DEPRECATED: // 16384 // |
|
154 | - return 'E_USER_DEPRECATED'; |
|
155 | - case E_ALL: // 16384 // |
|
156 | - return 'E_ALL'; |
|
157 | - } |
|
158 | - return ''; |
|
159 | - } |
|
160 | - |
|
161 | - |
|
162 | - /** |
|
163 | - * fatal_error_handler |
|
164 | - * |
|
165 | - * @return void |
|
166 | - */ |
|
167 | - public static function fatal_error_handler() |
|
168 | - { |
|
169 | - $last_error = error_get_last(); |
|
170 | - if ($last_error['type'] === E_ERROR) { |
|
171 | - EE_Error::error_handler(E_ERROR, $last_error['message'], $last_error['file'], $last_error['line']); |
|
172 | - } |
|
173 | - } |
|
174 | - |
|
175 | - |
|
176 | - /** |
|
177 | - * _format_error |
|
178 | - * |
|
179 | - * @param $code |
|
180 | - * @param $message |
|
181 | - * @param $file |
|
182 | - * @param $line |
|
183 | - * @return string |
|
184 | - */ |
|
185 | - private static function _format_error($code, $message, $file, $line) |
|
186 | - { |
|
187 | - $html = "<table cellpadding='5'><thead bgcolor='#f8f8f8'><th>Item</th><th align='left'>Details</th></thead><tbody>"; |
|
188 | - $html .= "<tr valign='top'><td><b>Code</b></td><td>$code</td></tr>"; |
|
189 | - $html .= "<tr valign='top'><td><b>Error</b></td><td>$message</td></tr>"; |
|
190 | - $html .= "<tr valign='top'><td><b>File</b></td><td>$file</td></tr>"; |
|
191 | - $html .= "<tr valign='top'><td><b>Line</b></td><td>$line</td></tr>"; |
|
192 | - $html .= '</tbody></table>'; |
|
193 | - return $html; |
|
194 | - } |
|
195 | - |
|
196 | - |
|
197 | - /** |
|
198 | - * set_content_type |
|
199 | - * |
|
200 | - * @param $content_type |
|
201 | - * @return string |
|
202 | - */ |
|
203 | - public static function set_content_type($content_type) |
|
204 | - { |
|
205 | - return 'text/html'; |
|
206 | - } |
|
207 | - |
|
208 | - |
|
209 | - /** |
|
210 | - * @return void |
|
211 | - * @throws EE_Error |
|
212 | - * @throws ReflectionException |
|
213 | - */ |
|
214 | - public function get_error() |
|
215 | - { |
|
216 | - if (apply_filters('FHEE__EE_Error__get_error__show_normal_exceptions', false)) { |
|
217 | - throw $this; |
|
218 | - } |
|
219 | - // get separate user and developer messages if they exist |
|
220 | - $msg = explode('||', $this->getMessage()); |
|
221 | - $user_msg = $msg[0]; |
|
222 | - $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0]; |
|
223 | - $msg = WP_DEBUG ? $dev_msg : $user_msg; |
|
224 | - // add details to _all_exceptions array |
|
225 | - $x_time = time(); |
|
226 | - self::$_all_exceptions[ $x_time ]['name'] = get_class($this); |
|
227 | - self::$_all_exceptions[ $x_time ]['file'] = $this->getFile(); |
|
228 | - self::$_all_exceptions[ $x_time ]['line'] = $this->getLine(); |
|
229 | - self::$_all_exceptions[ $x_time ]['msg'] = $msg; |
|
230 | - self::$_all_exceptions[ $x_time ]['code'] = $this->getCode(); |
|
231 | - self::$_all_exceptions[ $x_time ]['trace'] = $this->getTrace(); |
|
232 | - self::$_all_exceptions[ $x_time ]['string'] = $this->getTraceAsString(); |
|
233 | - self::$_error_count++; |
|
234 | - // add_action( 'shutdown', array( $this, 'display_errors' )); |
|
235 | - $this->display_errors(); |
|
236 | - } |
|
237 | - |
|
238 | - |
|
239 | - /** |
|
240 | - * @param bool $check_stored |
|
241 | - * @param string $type_to_check |
|
242 | - * @return bool |
|
243 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
244 | - * @throws \InvalidArgumentException |
|
245 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
246 | - * @throws InvalidInterfaceException |
|
247 | - */ |
|
248 | - public static function has_error($check_stored = false, $type_to_check = 'errors') |
|
249 | - { |
|
250 | - $has_error = isset(self::$_espresso_notices[ $type_to_check ]) |
|
251 | - && ! empty(self::$_espresso_notices[ $type_to_check ]) |
|
252 | - ? true |
|
253 | - : false; |
|
254 | - if ($check_stored && ! $has_error) { |
|
255 | - $notices = EE_Error::getStoredNotices(); |
|
256 | - foreach ($notices as $type => $notice) { |
|
257 | - if ($type === $type_to_check && $notice) { |
|
258 | - return true; |
|
259 | - } |
|
260 | - } |
|
261 | - } |
|
262 | - return $has_error; |
|
263 | - } |
|
264 | - |
|
265 | - |
|
266 | - /** |
|
267 | - * @echo string |
|
268 | - * @throws \ReflectionException |
|
269 | - */ |
|
270 | - public function display_errors() |
|
271 | - { |
|
272 | - $trace_details = ''; |
|
273 | - $output = ' |
|
29 | + const OPTIONS_KEY_NOTICES = 'ee_notices'; |
|
30 | + |
|
31 | + |
|
32 | + /** |
|
33 | + * name of the file to log exceptions to |
|
34 | + * |
|
35 | + * @var string |
|
36 | + */ |
|
37 | + private static $_exception_log_file = 'espresso_error_log.txt'; |
|
38 | + |
|
39 | + /** |
|
40 | + * stores details for all exception |
|
41 | + * |
|
42 | + * @var array |
|
43 | + */ |
|
44 | + private static $_all_exceptions = array(); |
|
45 | + |
|
46 | + /** |
|
47 | + * tracks number of errors |
|
48 | + * |
|
49 | + * @var int |
|
50 | + */ |
|
51 | + private static $_error_count = 0; |
|
52 | + |
|
53 | + /** |
|
54 | + * @var array $_espresso_notices |
|
55 | + */ |
|
56 | + private static $_espresso_notices = array('success' => false, 'errors' => false, 'attention' => false); |
|
57 | + |
|
58 | + |
|
59 | + /** |
|
60 | + * @override default exception handling |
|
61 | + * @param string $message |
|
62 | + * @param int $code |
|
63 | + * @param Exception|null $previous |
|
64 | + */ |
|
65 | + public function __construct($message, $code = 0, Exception $previous = null) |
|
66 | + { |
|
67 | + if (version_compare(PHP_VERSION, '5.3.0', '<')) { |
|
68 | + parent::__construct($message, $code); |
|
69 | + } else { |
|
70 | + parent::__construct($message, $code, $previous); |
|
71 | + } |
|
72 | + } |
|
73 | + |
|
74 | + |
|
75 | + /** |
|
76 | + * error_handler |
|
77 | + * |
|
78 | + * @param $code |
|
79 | + * @param $message |
|
80 | + * @param $file |
|
81 | + * @param $line |
|
82 | + * @return void |
|
83 | + */ |
|
84 | + public static function error_handler($code, $message, $file, $line) |
|
85 | + { |
|
86 | + $type = EE_Error::error_type($code); |
|
87 | + $site = site_url(); |
|
88 | + switch ($site) { |
|
89 | + case 'http://ee4.eventespresso.com/': |
|
90 | + case 'http://ee4decaf.eventespresso.com/': |
|
91 | + case 'http://ee4hf.eventespresso.com/': |
|
92 | + case 'http://ee4a.eventespresso.com/': |
|
93 | + case 'http://ee4ad.eventespresso.com/': |
|
94 | + case 'http://ee4b.eventespresso.com/': |
|
95 | + case 'http://ee4bd.eventespresso.com/': |
|
96 | + case 'http://ee4d.eventespresso.com/': |
|
97 | + case 'http://ee4dd.eventespresso.com/': |
|
98 | + $to = '[email protected]'; |
|
99 | + break; |
|
100 | + default: |
|
101 | + $to = get_option('admin_email'); |
|
102 | + } |
|
103 | + $subject = $type . ' ' . $message . ' in ' . EVENT_ESPRESSO_VERSION . ' on ' . site_url(); |
|
104 | + $msg = EE_Error::_format_error($type, $message, $file, $line); |
|
105 | + if (function_exists('wp_mail')) { |
|
106 | + add_filter('wp_mail_content_type', array('EE_Error', 'set_content_type')); |
|
107 | + wp_mail($to, $subject, $msg); |
|
108 | + } |
|
109 | + echo '<div id="message" class="espresso-notices error"><p>'; |
|
110 | + echo $type . ': ' . $message . '<br />' . $file . ' line ' . $line; |
|
111 | + echo '<br /></p></div>'; |
|
112 | + } |
|
113 | + |
|
114 | + |
|
115 | + /** |
|
116 | + * error_type |
|
117 | + * http://www.php.net/manual/en/errorfunc.constants.php#109430 |
|
118 | + * |
|
119 | + * @param $code |
|
120 | + * @return string |
|
121 | + */ |
|
122 | + public static function error_type($code) |
|
123 | + { |
|
124 | + switch ($code) { |
|
125 | + case E_ERROR: // 1 // |
|
126 | + return 'E_ERROR'; |
|
127 | + case E_WARNING: // 2 // |
|
128 | + return 'E_WARNING'; |
|
129 | + case E_PARSE: // 4 // |
|
130 | + return 'E_PARSE'; |
|
131 | + case E_NOTICE: // 8 // |
|
132 | + return 'E_NOTICE'; |
|
133 | + case E_CORE_ERROR: // 16 // |
|
134 | + return 'E_CORE_ERROR'; |
|
135 | + case E_CORE_WARNING: // 32 // |
|
136 | + return 'E_CORE_WARNING'; |
|
137 | + case E_COMPILE_ERROR: // 64 // |
|
138 | + return 'E_COMPILE_ERROR'; |
|
139 | + case E_COMPILE_WARNING: // 128 // |
|
140 | + return 'E_COMPILE_WARNING'; |
|
141 | + case E_USER_ERROR: // 256 // |
|
142 | + return 'E_USER_ERROR'; |
|
143 | + case E_USER_WARNING: // 512 // |
|
144 | + return 'E_USER_WARNING'; |
|
145 | + case E_USER_NOTICE: // 1024 // |
|
146 | + return 'E_USER_NOTICE'; |
|
147 | + case E_STRICT: // 2048 // |
|
148 | + return 'E_STRICT'; |
|
149 | + case E_RECOVERABLE_ERROR: // 4096 // |
|
150 | + return 'E_RECOVERABLE_ERROR'; |
|
151 | + case E_DEPRECATED: // 8192 // |
|
152 | + return 'E_DEPRECATED'; |
|
153 | + case E_USER_DEPRECATED: // 16384 // |
|
154 | + return 'E_USER_DEPRECATED'; |
|
155 | + case E_ALL: // 16384 // |
|
156 | + return 'E_ALL'; |
|
157 | + } |
|
158 | + return ''; |
|
159 | + } |
|
160 | + |
|
161 | + |
|
162 | + /** |
|
163 | + * fatal_error_handler |
|
164 | + * |
|
165 | + * @return void |
|
166 | + */ |
|
167 | + public static function fatal_error_handler() |
|
168 | + { |
|
169 | + $last_error = error_get_last(); |
|
170 | + if ($last_error['type'] === E_ERROR) { |
|
171 | + EE_Error::error_handler(E_ERROR, $last_error['message'], $last_error['file'], $last_error['line']); |
|
172 | + } |
|
173 | + } |
|
174 | + |
|
175 | + |
|
176 | + /** |
|
177 | + * _format_error |
|
178 | + * |
|
179 | + * @param $code |
|
180 | + * @param $message |
|
181 | + * @param $file |
|
182 | + * @param $line |
|
183 | + * @return string |
|
184 | + */ |
|
185 | + private static function _format_error($code, $message, $file, $line) |
|
186 | + { |
|
187 | + $html = "<table cellpadding='5'><thead bgcolor='#f8f8f8'><th>Item</th><th align='left'>Details</th></thead><tbody>"; |
|
188 | + $html .= "<tr valign='top'><td><b>Code</b></td><td>$code</td></tr>"; |
|
189 | + $html .= "<tr valign='top'><td><b>Error</b></td><td>$message</td></tr>"; |
|
190 | + $html .= "<tr valign='top'><td><b>File</b></td><td>$file</td></tr>"; |
|
191 | + $html .= "<tr valign='top'><td><b>Line</b></td><td>$line</td></tr>"; |
|
192 | + $html .= '</tbody></table>'; |
|
193 | + return $html; |
|
194 | + } |
|
195 | + |
|
196 | + |
|
197 | + /** |
|
198 | + * set_content_type |
|
199 | + * |
|
200 | + * @param $content_type |
|
201 | + * @return string |
|
202 | + */ |
|
203 | + public static function set_content_type($content_type) |
|
204 | + { |
|
205 | + return 'text/html'; |
|
206 | + } |
|
207 | + |
|
208 | + |
|
209 | + /** |
|
210 | + * @return void |
|
211 | + * @throws EE_Error |
|
212 | + * @throws ReflectionException |
|
213 | + */ |
|
214 | + public function get_error() |
|
215 | + { |
|
216 | + if (apply_filters('FHEE__EE_Error__get_error__show_normal_exceptions', false)) { |
|
217 | + throw $this; |
|
218 | + } |
|
219 | + // get separate user and developer messages if they exist |
|
220 | + $msg = explode('||', $this->getMessage()); |
|
221 | + $user_msg = $msg[0]; |
|
222 | + $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0]; |
|
223 | + $msg = WP_DEBUG ? $dev_msg : $user_msg; |
|
224 | + // add details to _all_exceptions array |
|
225 | + $x_time = time(); |
|
226 | + self::$_all_exceptions[ $x_time ]['name'] = get_class($this); |
|
227 | + self::$_all_exceptions[ $x_time ]['file'] = $this->getFile(); |
|
228 | + self::$_all_exceptions[ $x_time ]['line'] = $this->getLine(); |
|
229 | + self::$_all_exceptions[ $x_time ]['msg'] = $msg; |
|
230 | + self::$_all_exceptions[ $x_time ]['code'] = $this->getCode(); |
|
231 | + self::$_all_exceptions[ $x_time ]['trace'] = $this->getTrace(); |
|
232 | + self::$_all_exceptions[ $x_time ]['string'] = $this->getTraceAsString(); |
|
233 | + self::$_error_count++; |
|
234 | + // add_action( 'shutdown', array( $this, 'display_errors' )); |
|
235 | + $this->display_errors(); |
|
236 | + } |
|
237 | + |
|
238 | + |
|
239 | + /** |
|
240 | + * @param bool $check_stored |
|
241 | + * @param string $type_to_check |
|
242 | + * @return bool |
|
243 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
244 | + * @throws \InvalidArgumentException |
|
245 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
246 | + * @throws InvalidInterfaceException |
|
247 | + */ |
|
248 | + public static function has_error($check_stored = false, $type_to_check = 'errors') |
|
249 | + { |
|
250 | + $has_error = isset(self::$_espresso_notices[ $type_to_check ]) |
|
251 | + && ! empty(self::$_espresso_notices[ $type_to_check ]) |
|
252 | + ? true |
|
253 | + : false; |
|
254 | + if ($check_stored && ! $has_error) { |
|
255 | + $notices = EE_Error::getStoredNotices(); |
|
256 | + foreach ($notices as $type => $notice) { |
|
257 | + if ($type === $type_to_check && $notice) { |
|
258 | + return true; |
|
259 | + } |
|
260 | + } |
|
261 | + } |
|
262 | + return $has_error; |
|
263 | + } |
|
264 | + |
|
265 | + |
|
266 | + /** |
|
267 | + * @echo string |
|
268 | + * @throws \ReflectionException |
|
269 | + */ |
|
270 | + public function display_errors() |
|
271 | + { |
|
272 | + $trace_details = ''; |
|
273 | + $output = ' |
|
274 | 274 | <style type="text/css"> |
275 | 275 | #ee-error-message { |
276 | 276 | max-width:90% !important; |
@@ -326,21 +326,21 @@ discard block |
||
326 | 326 | } |
327 | 327 | </style> |
328 | 328 | <div id="ee-error-message" class="error">'; |
329 | - if (! WP_DEBUG) { |
|
330 | - $output .= ' |
|
329 | + if (! WP_DEBUG) { |
|
330 | + $output .= ' |
|
331 | 331 | <p>'; |
332 | - } |
|
333 | - // cycle thru errors |
|
334 | - foreach (self::$_all_exceptions as $time => $ex) { |
|
335 | - $error_code = ''; |
|
336 | - // process trace info |
|
337 | - if (empty($ex['trace'])) { |
|
338 | - $trace_details .= esc_html__( |
|
339 | - 'Sorry, but no trace information was available for this exception.', |
|
340 | - 'event_espresso' |
|
341 | - ); |
|
342 | - } else { |
|
343 | - $trace_details .= ' |
|
332 | + } |
|
333 | + // cycle thru errors |
|
334 | + foreach (self::$_all_exceptions as $time => $ex) { |
|
335 | + $error_code = ''; |
|
336 | + // process trace info |
|
337 | + if (empty($ex['trace'])) { |
|
338 | + $trace_details .= esc_html__( |
|
339 | + 'Sorry, but no trace information was available for this exception.', |
|
340 | + 'event_espresso' |
|
341 | + ); |
|
342 | + } else { |
|
343 | + $trace_details .= ' |
|
344 | 344 | <div id="ee-trace-details"> |
345 | 345 | <table width="100%" border="0" cellpadding="5" cellspacing="0"> |
346 | 346 | <tr> |
@@ -350,43 +350,43 @@ discard block |
||
350 | 350 | <th scope="col" align="left">Class</th> |
351 | 351 | <th scope="col" align="left">Method( arguments )</th> |
352 | 352 | </tr>'; |
353 | - $last_on_stack = count($ex['trace']) - 1; |
|
354 | - // reverse array so that stack is in proper chronological order |
|
355 | - $sorted_trace = array_reverse($ex['trace']); |
|
356 | - foreach ($sorted_trace as $nmbr => $trace) { |
|
357 | - $file = isset($trace['file']) ? $trace['file'] : ''; |
|
358 | - $class = isset($trace['class']) ? $trace['class'] : ''; |
|
359 | - $type = isset($trace['type']) ? $trace['type'] : ''; |
|
360 | - $function = isset($trace['function']) ? $trace['function'] : ''; |
|
361 | - $args = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : ''; |
|
362 | - $line = isset($trace['line']) ? $trace['line'] : ''; |
|
363 | - $zebra = ($nmbr % 2) ? ' odd' : ''; |
|
364 | - if (empty($file) && ! empty($class)) { |
|
365 | - $a = new ReflectionClass($class); |
|
366 | - $file = $a->getFileName(); |
|
367 | - if (empty($line) && ! empty($function)) { |
|
368 | - try { |
|
369 | - // if $function is a closure, this throws an exception |
|
370 | - $b = new ReflectionMethod($class, $function); |
|
371 | - $line = $b->getStartLine(); |
|
372 | - } catch (Exception $closure_exception) { |
|
373 | - $line = 'unknown'; |
|
374 | - } |
|
375 | - } |
|
376 | - } |
|
377 | - if ($nmbr === $last_on_stack) { |
|
378 | - $file = $ex['file'] !== '' ? $ex['file'] : $file; |
|
379 | - $line = $ex['line'] !== '' ? $ex['line'] : $line; |
|
380 | - $error_code = self::generate_error_code($file, $trace['function'], $line); |
|
381 | - } |
|
382 | - $nmbr_dsply = ! empty($nmbr) ? $nmbr : ' '; |
|
383 | - $line_dsply = ! empty($line) ? $line : ' '; |
|
384 | - $file_dsply = ! empty($file) ? $file : ' '; |
|
385 | - $class_dsply = ! empty($class) ? $class : ' '; |
|
386 | - $type_dsply = ! empty($type) ? $type : ' '; |
|
387 | - $function_dsply = ! empty($function) ? $function : ' '; |
|
388 | - $args_dsply = ! empty($args) ? '( ' . $args . ' )' : ''; |
|
389 | - $trace_details .= ' |
|
353 | + $last_on_stack = count($ex['trace']) - 1; |
|
354 | + // reverse array so that stack is in proper chronological order |
|
355 | + $sorted_trace = array_reverse($ex['trace']); |
|
356 | + foreach ($sorted_trace as $nmbr => $trace) { |
|
357 | + $file = isset($trace['file']) ? $trace['file'] : ''; |
|
358 | + $class = isset($trace['class']) ? $trace['class'] : ''; |
|
359 | + $type = isset($trace['type']) ? $trace['type'] : ''; |
|
360 | + $function = isset($trace['function']) ? $trace['function'] : ''; |
|
361 | + $args = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : ''; |
|
362 | + $line = isset($trace['line']) ? $trace['line'] : ''; |
|
363 | + $zebra = ($nmbr % 2) ? ' odd' : ''; |
|
364 | + if (empty($file) && ! empty($class)) { |
|
365 | + $a = new ReflectionClass($class); |
|
366 | + $file = $a->getFileName(); |
|
367 | + if (empty($line) && ! empty($function)) { |
|
368 | + try { |
|
369 | + // if $function is a closure, this throws an exception |
|
370 | + $b = new ReflectionMethod($class, $function); |
|
371 | + $line = $b->getStartLine(); |
|
372 | + } catch (Exception $closure_exception) { |
|
373 | + $line = 'unknown'; |
|
374 | + } |
|
375 | + } |
|
376 | + } |
|
377 | + if ($nmbr === $last_on_stack) { |
|
378 | + $file = $ex['file'] !== '' ? $ex['file'] : $file; |
|
379 | + $line = $ex['line'] !== '' ? $ex['line'] : $line; |
|
380 | + $error_code = self::generate_error_code($file, $trace['function'], $line); |
|
381 | + } |
|
382 | + $nmbr_dsply = ! empty($nmbr) ? $nmbr : ' '; |
|
383 | + $line_dsply = ! empty($line) ? $line : ' '; |
|
384 | + $file_dsply = ! empty($file) ? $file : ' '; |
|
385 | + $class_dsply = ! empty($class) ? $class : ' '; |
|
386 | + $type_dsply = ! empty($type) ? $type : ' '; |
|
387 | + $function_dsply = ! empty($function) ? $function : ' '; |
|
388 | + $args_dsply = ! empty($args) ? '( ' . $args . ' )' : ''; |
|
389 | + $trace_details .= ' |
|
390 | 390 | <tr> |
391 | 391 | <td align="right" class="' . $zebra . '">' . $nmbr_dsply . '</td> |
392 | 392 | <td align="right" class="' . $zebra . '">' . $line_dsply . '</td> |
@@ -394,628 +394,628 @@ discard block |
||
394 | 394 | <td align="left" class="' . $zebra . '">' . $class_dsply . '</td> |
395 | 395 | <td align="left" class="' . $zebra . '">' . $type_dsply . $function_dsply . $args_dsply . '</td> |
396 | 396 | </tr>'; |
397 | - } |
|
398 | - $trace_details .= ' |
|
397 | + } |
|
398 | + $trace_details .= ' |
|
399 | 399 | </table> |
400 | 400 | </div>'; |
401 | - } |
|
402 | - $ex['code'] = $ex['code'] ? $ex['code'] : $error_code; |
|
403 | - // add generic non-identifying messages for non-privileged users |
|
404 | - if (! WP_DEBUG) { |
|
405 | - $output .= '<span class="ee-error-user-msg-spn">' |
|
406 | - . trim($ex['msg']) |
|
407 | - . '</span> <sup>' |
|
408 | - . $ex['code'] |
|
409 | - . '</sup><br />'; |
|
410 | - } else { |
|
411 | - // or helpful developer messages if debugging is on |
|
412 | - $output .= ' |
|
401 | + } |
|
402 | + $ex['code'] = $ex['code'] ? $ex['code'] : $error_code; |
|
403 | + // add generic non-identifying messages for non-privileged users |
|
404 | + if (! WP_DEBUG) { |
|
405 | + $output .= '<span class="ee-error-user-msg-spn">' |
|
406 | + . trim($ex['msg']) |
|
407 | + . '</span> <sup>' |
|
408 | + . $ex['code'] |
|
409 | + . '</sup><br />'; |
|
410 | + } else { |
|
411 | + // or helpful developer messages if debugging is on |
|
412 | + $output .= ' |
|
413 | 413 | <div class="ee-error-dev-msg-dv"> |
414 | 414 | <p class="ee-error-dev-msg-pg"> |
415 | 415 | <strong class="ee-error-dev-msg-str">An ' |
416 | - . $ex['name'] |
|
417 | - . ' exception was thrown!</strong> <span>code: ' |
|
418 | - . $ex['code'] |
|
419 | - . '</span><br /> |
|
416 | + . $ex['name'] |
|
417 | + . ' exception was thrown!</strong> <span>code: ' |
|
418 | + . $ex['code'] |
|
419 | + . '</span><br /> |
|
420 | 420 | <span class="big-text">"' |
421 | - . trim($ex['msg']) |
|
422 | - . '"</span><br/> |
|
421 | + . trim($ex['msg']) |
|
422 | + . '"</span><br/> |
|
423 | 423 | <a id="display-ee-error-trace-' |
424 | - . self::$_error_count |
|
425 | - . $time |
|
426 | - . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-' |
|
427 | - . self::$_error_count |
|
428 | - . $time |
|
429 | - . '"> |
|
424 | + . self::$_error_count |
|
425 | + . $time |
|
426 | + . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-' |
|
427 | + . self::$_error_count |
|
428 | + . $time |
|
429 | + . '"> |
|
430 | 430 | ' |
431 | - . esc_html__('click to view backtrace and class/method details', 'event_espresso') |
|
432 | - . ' |
|
431 | + . esc_html__('click to view backtrace and class/method details', 'event_espresso') |
|
432 | + . ' |
|
433 | 433 | </a><br /> |
434 | 434 | <span class="small-text lt-grey-text">' |
435 | - . $ex['file'] |
|
436 | - . ' ( line no: ' |
|
437 | - . $ex['line'] |
|
438 | - . ' )</span> |
|
435 | + . $ex['file'] |
|
436 | + . ' ( line no: ' |
|
437 | + . $ex['line'] |
|
438 | + . ' )</span> |
|
439 | 439 | </p> |
440 | 440 | <div id="ee-error-trace-' |
441 | - . self::$_error_count |
|
442 | - . $time |
|
443 | - . '-dv" class="ee-error-trace-dv" style="display: none;"> |
|
441 | + . self::$_error_count |
|
442 | + . $time |
|
443 | + . '-dv" class="ee-error-trace-dv" style="display: none;"> |
|
444 | 444 | ' |
445 | - . $trace_details; |
|
446 | - if (! empty($class)) { |
|
447 | - $output .= ' |
|
445 | + . $trace_details; |
|
446 | + if (! empty($class)) { |
|
447 | + $output .= ' |
|
448 | 448 | <div style="padding:3px; margin:0 0 1em; border:1px solid #666; background:#fff; border-radius:3px;"> |
449 | 449 | <div style="padding:1em 2em; border:1px solid #666; background:#f9f9f9;"> |
450 | 450 | <h3>Class Details</h3>'; |
451 | - $a = new ReflectionClass($class); |
|
452 | - $output .= ' |
|
451 | + $a = new ReflectionClass($class); |
|
452 | + $output .= ' |
|
453 | 453 | <pre>' . $a . '</pre> |
454 | 454 | </div> |
455 | 455 | </div>'; |
456 | - } |
|
457 | - $output .= ' |
|
456 | + } |
|
457 | + $output .= ' |
|
458 | 458 | </div> |
459 | 459 | </div> |
460 | 460 | <br />'; |
461 | - } |
|
462 | - $this->write_to_error_log($time, $ex); |
|
463 | - } |
|
464 | - // remove last linebreak |
|
465 | - $output = substr($output, 0, -6); |
|
466 | - if (! WP_DEBUG) { |
|
467 | - $output .= ' |
|
461 | + } |
|
462 | + $this->write_to_error_log($time, $ex); |
|
463 | + } |
|
464 | + // remove last linebreak |
|
465 | + $output = substr($output, 0, -6); |
|
466 | + if (! WP_DEBUG) { |
|
467 | + $output .= ' |
|
468 | 468 | </p>'; |
469 | - } |
|
470 | - $output .= ' |
|
469 | + } |
|
470 | + $output .= ' |
|
471 | 471 | </div>'; |
472 | - $output .= self::_print_scripts(true); |
|
473 | - if (defined('DOING_AJAX')) { |
|
474 | - echo wp_json_encode(array('error' => $output)); |
|
475 | - exit(); |
|
476 | - } |
|
477 | - echo $output; |
|
478 | - die(); |
|
479 | - } |
|
480 | - |
|
481 | - |
|
482 | - /** |
|
483 | - * generate string from exception trace args |
|
484 | - * |
|
485 | - * @param array $arguments |
|
486 | - * @param bool $array |
|
487 | - * @return string |
|
488 | - */ |
|
489 | - private function _convert_args_to_string($arguments = array(), $array = false) |
|
490 | - { |
|
491 | - $arg_string = ''; |
|
492 | - if (! empty($arguments)) { |
|
493 | - $args = array(); |
|
494 | - foreach ($arguments as $arg) { |
|
495 | - if (! empty($arg)) { |
|
496 | - if (is_string($arg)) { |
|
497 | - $args[] = " '" . $arg . "'"; |
|
498 | - } elseif (is_array($arg)) { |
|
499 | - $args[] = 'ARRAY(' . $this->_convert_args_to_string($arg, true); |
|
500 | - } elseif ($arg === null) { |
|
501 | - $args[] = ' NULL'; |
|
502 | - } elseif (is_bool($arg)) { |
|
503 | - $args[] = ($arg) ? ' TRUE' : ' FALSE'; |
|
504 | - } elseif (is_object($arg)) { |
|
505 | - $args[] = ' OBJECT ' . get_class($arg); |
|
506 | - } elseif (is_resource($arg)) { |
|
507 | - $args[] = get_resource_type($arg); |
|
508 | - } else { |
|
509 | - $args[] = $arg; |
|
510 | - } |
|
511 | - } |
|
512 | - } |
|
513 | - $arg_string = implode(', ', $args); |
|
514 | - } |
|
515 | - if ($array) { |
|
516 | - $arg_string .= ' )'; |
|
517 | - } |
|
518 | - return $arg_string; |
|
519 | - } |
|
520 | - |
|
521 | - |
|
522 | - /** |
|
523 | - * add error message |
|
524 | - * |
|
525 | - * @param string $msg the message to display to users or developers - adding a double pipe || (OR) creates |
|
526 | - * separate messages for user || dev |
|
527 | - * @param string $file the file that the error occurred in - just use __FILE__ |
|
528 | - * @param string $func the function/method that the error occurred in - just use __FUNCTION__ |
|
529 | - * @param string $line the line number where the error occurred - just use __LINE__ |
|
530 | - * @return void |
|
531 | - */ |
|
532 | - public static function add_error($msg = null, $file = null, $func = null, $line = null) |
|
533 | - { |
|
534 | - self::_add_notice('errors', $msg, $file, $func, $line); |
|
535 | - self::$_error_count++; |
|
536 | - } |
|
537 | - |
|
538 | - |
|
539 | - /** |
|
540 | - * If WP_DEBUG is active, throws an exception. If WP_DEBUG is off, just |
|
541 | - * adds an error |
|
542 | - * |
|
543 | - * @param string $msg |
|
544 | - * @param string $file |
|
545 | - * @param string $func |
|
546 | - * @param string $line |
|
547 | - * @throws EE_Error |
|
548 | - */ |
|
549 | - public static function throw_exception_if_debugging($msg = null, $file = null, $func = null, $line = null) |
|
550 | - { |
|
551 | - if (WP_DEBUG) { |
|
552 | - throw new EE_Error($msg); |
|
553 | - } |
|
554 | - EE_Error::add_error($msg, $file, $func, $line); |
|
555 | - } |
|
556 | - |
|
557 | - |
|
558 | - /** |
|
559 | - * add success message |
|
560 | - * |
|
561 | - * @param string $msg the message to display to users or developers - adding a double pipe || (OR) creates |
|
562 | - * separate messages for user || dev |
|
563 | - * @param string $file the file that the error occurred in - just use __FILE__ |
|
564 | - * @param string $func the function/method that the error occurred in - just use __FUNCTION__ |
|
565 | - * @param string $line the line number where the error occurred - just use __LINE__ |
|
566 | - * @return void |
|
567 | - */ |
|
568 | - public static function add_success($msg = null, $file = null, $func = null, $line = null) |
|
569 | - { |
|
570 | - self::_add_notice('success', $msg, $file, $func, $line); |
|
571 | - } |
|
572 | - |
|
573 | - |
|
574 | - /** |
|
575 | - * add attention message |
|
576 | - * |
|
577 | - * @param string $msg the message to display to users or developers - adding a double pipe || (OR) creates |
|
578 | - * separate messages for user || dev |
|
579 | - * @param string $file the file that the error occurred in - just use __FILE__ |
|
580 | - * @param string $func the function/method that the error occurred in - just use __FUNCTION__ |
|
581 | - * @param string $line the line number where the error occurred - just use __LINE__ |
|
582 | - * @return void |
|
583 | - */ |
|
584 | - public static function add_attention($msg = null, $file = null, $func = null, $line = null) |
|
585 | - { |
|
586 | - self::_add_notice('attention', $msg, $file, $func, $line); |
|
587 | - } |
|
588 | - |
|
589 | - |
|
590 | - /** |
|
591 | - * @param string $type whether the message is for a success or error notification |
|
592 | - * @param string $msg the message to display to users or developers |
|
593 | - * - adding a double pipe || (OR) creates separate messages for user || dev |
|
594 | - * @param string $file the file that the error occurred in - just use __FILE__ |
|
595 | - * @param string $func the function/method that the error occurred in - just use __FUNCTION__ |
|
596 | - * @param string $line the line number where the error occurred - just use __LINE__ |
|
597 | - * @return void |
|
598 | - */ |
|
599 | - private static function _add_notice($type = 'success', $msg = '', $file = '', $func = '', $line = '') |
|
600 | - { |
|
601 | - if (empty($msg)) { |
|
602 | - EE_Error::doing_it_wrong( |
|
603 | - 'EE_Error::add_' . $type . '()', |
|
604 | - sprintf( |
|
605 | - esc_html__( |
|
606 | - 'Notifications are not much use without a message! Please add a message to the EE_Error::add_%s() call made in %s on line %d', |
|
607 | - 'event_espresso' |
|
608 | - ), |
|
609 | - $type, |
|
610 | - $file, |
|
611 | - $line |
|
612 | - ), |
|
613 | - EVENT_ESPRESSO_VERSION |
|
614 | - ); |
|
615 | - } |
|
616 | - if ($type === 'errors' && (empty($file) || empty($func) || empty($line))) { |
|
617 | - EE_Error::doing_it_wrong( |
|
618 | - 'EE_Error::add_error()', |
|
619 | - esc_html__( |
|
620 | - 'You need to provide the file name, function name, and line number that the error occurred on in order to better assist with debugging.', |
|
621 | - 'event_espresso' |
|
622 | - ), |
|
623 | - EVENT_ESPRESSO_VERSION |
|
624 | - ); |
|
625 | - } |
|
626 | - // get separate user and developer messages if they exist |
|
627 | - $msg = explode('||', $msg); |
|
628 | - $user_msg = $msg[0]; |
|
629 | - $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0]; |
|
630 | - /** |
|
631 | - * Do an action so other code can be triggered when a notice is created |
|
632 | - * |
|
633 | - * @param string $type can be 'errors', 'attention', or 'success' |
|
634 | - * @param string $user_msg message displayed to user when WP_DEBUG is off |
|
635 | - * @param string $user_msg message displayed to user when WP_DEBUG is on |
|
636 | - * @param string $file file where error was generated |
|
637 | - * @param string $func function where error was generated |
|
638 | - * @param string $line line where error was generated |
|
639 | - */ |
|
640 | - do_action('AHEE__EE_Error___add_notice', $type, $user_msg, $dev_msg, $file, $func, $line); |
|
641 | - $msg = WP_DEBUG ? $dev_msg : $user_msg; |
|
642 | - // add notice if message exists |
|
643 | - if (! empty($msg)) { |
|
644 | - // get error code |
|
645 | - $notice_code = EE_Error::generate_error_code($file, $func, $line); |
|
646 | - if (WP_DEBUG && $type === 'errors') { |
|
647 | - $msg .= '<br/><span class="tiny-text">' . $notice_code . '</span>'; |
|
648 | - } |
|
649 | - // add notice. Index by code if it's not blank |
|
650 | - if ($notice_code) { |
|
651 | - self::$_espresso_notices[ $type ][ $notice_code ] = $msg; |
|
652 | - } else { |
|
653 | - self::$_espresso_notices[ $type ][] = $msg; |
|
654 | - } |
|
655 | - add_action('wp_footer', array('EE_Error', 'enqueue_error_scripts'), 1); |
|
656 | - } |
|
657 | - } |
|
658 | - |
|
659 | - |
|
660 | - /** |
|
661 | - * in some case it may be necessary to overwrite the existing success messages |
|
662 | - * |
|
663 | - * @return void |
|
664 | - */ |
|
665 | - public static function overwrite_success() |
|
666 | - { |
|
667 | - self::$_espresso_notices['success'] = false; |
|
668 | - } |
|
669 | - |
|
670 | - |
|
671 | - /** |
|
672 | - * in some case it may be necessary to overwrite the existing attention messages |
|
673 | - * |
|
674 | - * @return void |
|
675 | - */ |
|
676 | - public static function overwrite_attention() |
|
677 | - { |
|
678 | - self::$_espresso_notices['attention'] = false; |
|
679 | - } |
|
680 | - |
|
681 | - |
|
682 | - /** |
|
683 | - * in some case it may be necessary to overwrite the existing error messages |
|
684 | - * |
|
685 | - * @return void |
|
686 | - */ |
|
687 | - public static function overwrite_errors() |
|
688 | - { |
|
689 | - self::$_espresso_notices['errors'] = false; |
|
690 | - } |
|
691 | - |
|
692 | - |
|
693 | - /** |
|
694 | - * @return void |
|
695 | - */ |
|
696 | - public static function reset_notices() |
|
697 | - { |
|
698 | - self::$_espresso_notices['success'] = false; |
|
699 | - self::$_espresso_notices['attention'] = false; |
|
700 | - self::$_espresso_notices['errors'] = false; |
|
701 | - } |
|
702 | - |
|
703 | - |
|
704 | - /** |
|
705 | - * @return int |
|
706 | - */ |
|
707 | - public static function has_notices() |
|
708 | - { |
|
709 | - $has_notices = 0; |
|
710 | - // check for success messages |
|
711 | - $has_notices = self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success']) |
|
712 | - ? 3 |
|
713 | - : $has_notices; |
|
714 | - // check for attention messages |
|
715 | - $has_notices = self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention']) |
|
716 | - ? 2 |
|
717 | - : $has_notices; |
|
718 | - // check for error messages |
|
719 | - $has_notices = self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors']) |
|
720 | - ? 1 |
|
721 | - : $has_notices; |
|
722 | - return $has_notices; |
|
723 | - } |
|
724 | - |
|
725 | - |
|
726 | - /** |
|
727 | - * This simply returns non formatted error notices as they were sent into the EE_Error object. |
|
728 | - * |
|
729 | - * @since 4.9.0 |
|
730 | - * @return array |
|
731 | - */ |
|
732 | - public static function get_vanilla_notices() |
|
733 | - { |
|
734 | - return array( |
|
735 | - 'success' => isset(self::$_espresso_notices['success']) |
|
736 | - ? self::$_espresso_notices['success'] |
|
737 | - : array(), |
|
738 | - 'attention' => isset(self::$_espresso_notices['attention']) |
|
739 | - ? self::$_espresso_notices['attention'] |
|
740 | - : array(), |
|
741 | - 'errors' => isset(self::$_espresso_notices['errors']) |
|
742 | - ? self::$_espresso_notices['errors'] |
|
743 | - : array(), |
|
744 | - ); |
|
745 | - } |
|
746 | - |
|
747 | - |
|
748 | - /** |
|
749 | - * @return array |
|
750 | - * @throws InvalidArgumentException |
|
751 | - * @throws InvalidDataTypeException |
|
752 | - * @throws InvalidInterfaceException |
|
753 | - */ |
|
754 | - public static function getStoredNotices() |
|
755 | - { |
|
756 | - if ($user_id = get_current_user_id()) { |
|
757 | - // get notices for logged in user |
|
758 | - $notices = get_user_option(EE_Error::OPTIONS_KEY_NOTICES, $user_id); |
|
759 | - return is_array($notices) ? $notices : array(); |
|
760 | - } |
|
761 | - if (EE_Session::isLoadedAndActive()) { |
|
762 | - // get notices for user currently engaged in a session |
|
763 | - $session_data = EE_Session::instance()->get_session_data(EE_Error::OPTIONS_KEY_NOTICES); |
|
764 | - return is_array($session_data) ? $session_data : array(); |
|
765 | - } |
|
766 | - // get global notices and hope they apply to the current site visitor |
|
767 | - $notices = get_option(EE_Error::OPTIONS_KEY_NOTICES, array()); |
|
768 | - return is_array($notices) ? $notices : array(); |
|
769 | - } |
|
770 | - |
|
771 | - |
|
772 | - /** |
|
773 | - * @param array $notices |
|
774 | - * @return bool |
|
775 | - * @throws InvalidArgumentException |
|
776 | - * @throws InvalidDataTypeException |
|
777 | - * @throws InvalidInterfaceException |
|
778 | - */ |
|
779 | - public static function storeNotices(array $notices) |
|
780 | - { |
|
781 | - if ($user_id = get_current_user_id()) { |
|
782 | - // store notices for logged in user |
|
783 | - return (bool) update_user_option( |
|
784 | - $user_id, |
|
785 | - EE_Error::OPTIONS_KEY_NOTICES, |
|
786 | - $notices |
|
787 | - ); |
|
788 | - } |
|
789 | - if (EE_Session::isLoadedAndActive()) { |
|
790 | - // store notices for user currently engaged in a session |
|
791 | - return EE_Session::instance()->set_session_data( |
|
792 | - array(EE_Error::OPTIONS_KEY_NOTICES => $notices) |
|
793 | - ); |
|
794 | - } |
|
795 | - // store global notices and hope they apply to the same site visitor on the next request |
|
796 | - return update_option(EE_Error::OPTIONS_KEY_NOTICES, $notices); |
|
797 | - } |
|
798 | - |
|
799 | - |
|
800 | - /** |
|
801 | - * @return bool|TRUE |
|
802 | - * @throws InvalidArgumentException |
|
803 | - * @throws InvalidDataTypeException |
|
804 | - * @throws InvalidInterfaceException |
|
805 | - */ |
|
806 | - public static function clearNotices() |
|
807 | - { |
|
808 | - if ($user_id = get_current_user_id()) { |
|
809 | - // clear notices for logged in user |
|
810 | - return (bool) update_user_option( |
|
811 | - $user_id, |
|
812 | - EE_Error::OPTIONS_KEY_NOTICES, |
|
813 | - array() |
|
814 | - ); |
|
815 | - } |
|
816 | - if (EE_Session::isLoadedAndActive()) { |
|
817 | - // clear notices for user currently engaged in a session |
|
818 | - return EE_Session::instance()->reset_data(EE_Error::OPTIONS_KEY_NOTICES); |
|
819 | - } |
|
820 | - // clear global notices and hope none belonged to some for some other site visitor |
|
821 | - return update_option(EE_Error::OPTIONS_KEY_NOTICES, array()); |
|
822 | - } |
|
823 | - |
|
824 | - |
|
825 | - /** |
|
826 | - * saves notices to the db for retrieval on next request |
|
827 | - * |
|
828 | - * @return void |
|
829 | - * @throws InvalidArgumentException |
|
830 | - * @throws InvalidDataTypeException |
|
831 | - * @throws InvalidInterfaceException |
|
832 | - */ |
|
833 | - public static function stashNoticesBeforeRedirect() |
|
834 | - { |
|
835 | - EE_Error::get_notices(false, true); |
|
836 | - } |
|
837 | - |
|
838 | - |
|
839 | - /** |
|
840 | - * compile all error or success messages into one string |
|
841 | - * |
|
842 | - * @see EE_Error::get_raw_notices if you want the raw notices without any preparations made to them |
|
843 | - * @param boolean $format_output whether or not to format the messages for display in the WP admin |
|
844 | - * @param boolean $save_to_transient whether or not to save notices to the db for retrieval on next request |
|
845 | - * - ONLY do this just before redirecting |
|
846 | - * @param boolean $remove_empty whether or not to unset empty messages |
|
847 | - * @return array |
|
848 | - * @throws InvalidArgumentException |
|
849 | - * @throws InvalidDataTypeException |
|
850 | - * @throws InvalidInterfaceException |
|
851 | - */ |
|
852 | - public static function get_notices($format_output = true, $save_to_transient = false, $remove_empty = true) |
|
853 | - { |
|
854 | - $success_messages = ''; |
|
855 | - $attention_messages = ''; |
|
856 | - $error_messages = ''; |
|
857 | - /** @var RequestInterface $request */ |
|
858 | - $request = LoaderFactory::getLoader()->getShared(RequestInterface::class); |
|
859 | - // either save notices to the db |
|
860 | - if ($save_to_transient || $request->requestParamIsSet('activate-selected')) { |
|
861 | - self::$_espresso_notices = array_merge( |
|
862 | - EE_Error::getStoredNotices(), |
|
863 | - self::$_espresso_notices |
|
864 | - ); |
|
865 | - EE_Error::storeNotices(self::$_espresso_notices); |
|
866 | - return array(); |
|
867 | - } |
|
868 | - $print_scripts = EE_Error::combineExistingAndNewNotices(); |
|
869 | - // check for success messages |
|
870 | - if (self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success'])) { |
|
871 | - // combine messages |
|
872 | - $success_messages .= implode('<br />', self::$_espresso_notices['success']); |
|
873 | - $print_scripts = true; |
|
874 | - } |
|
875 | - // check for attention messages |
|
876 | - if (self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention'])) { |
|
877 | - // combine messages |
|
878 | - $attention_messages .= implode('<br />', self::$_espresso_notices['attention']); |
|
879 | - $print_scripts = true; |
|
880 | - } |
|
881 | - // check for error messages |
|
882 | - if (self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors'])) { |
|
883 | - $error_messages .= count(self::$_espresso_notices['errors']) > 1 |
|
884 | - ? esc_html__('The following errors have occurred:', 'event_espresso') |
|
885 | - : esc_html__('An error has occurred:', 'event_espresso'); |
|
886 | - // combine messages |
|
887 | - $error_messages .= '<br />' . implode('<br />', self::$_espresso_notices['errors']); |
|
888 | - $print_scripts = true; |
|
889 | - } |
|
890 | - if ($format_output) { |
|
891 | - $notices = EE_Error::formatNoticesOutput( |
|
892 | - $success_messages, |
|
893 | - $attention_messages, |
|
894 | - $error_messages |
|
895 | - ); |
|
896 | - } else { |
|
897 | - $notices = array( |
|
898 | - 'success' => $success_messages, |
|
899 | - 'attention' => $attention_messages, |
|
900 | - 'errors' => $error_messages, |
|
901 | - ); |
|
902 | - if ($remove_empty) { |
|
903 | - // remove empty notices |
|
904 | - foreach ($notices as $type => $notice) { |
|
905 | - if (empty($notice)) { |
|
906 | - unset($notices[ $type ]); |
|
907 | - } |
|
908 | - } |
|
909 | - } |
|
910 | - } |
|
911 | - if ($print_scripts) { |
|
912 | - self::_print_scripts(); |
|
913 | - } |
|
914 | - return $notices; |
|
915 | - } |
|
916 | - |
|
917 | - |
|
918 | - /** |
|
919 | - * @return bool |
|
920 | - * @throws InvalidArgumentException |
|
921 | - * @throws InvalidDataTypeException |
|
922 | - * @throws InvalidInterfaceException |
|
923 | - */ |
|
924 | - private static function combineExistingAndNewNotices() |
|
925 | - { |
|
926 | - $print_scripts = false; |
|
927 | - // grab any notices that have been previously saved |
|
928 | - $notices = EE_Error::getStoredNotices(); |
|
929 | - if (! empty($notices)) { |
|
930 | - foreach ($notices as $type => $notice) { |
|
931 | - if (is_array($notice) && ! empty($notice)) { |
|
932 | - // make sure that existing notice type is an array |
|
933 | - self::$_espresso_notices[ $type ] = is_array(self::$_espresso_notices[ $type ]) |
|
934 | - && ! empty(self::$_espresso_notices[ $type ]) |
|
935 | - ? self::$_espresso_notices[ $type ] |
|
936 | - : array(); |
|
937 | - // add newly created notices to existing ones |
|
938 | - self::$_espresso_notices[ $type ] += $notice; |
|
939 | - $print_scripts = true; |
|
940 | - } |
|
941 | - } |
|
942 | - // now clear any stored notices |
|
943 | - EE_Error::clearNotices(); |
|
944 | - } |
|
945 | - return $print_scripts; |
|
946 | - } |
|
947 | - |
|
948 | - |
|
949 | - /** |
|
950 | - * @param string $success_messages |
|
951 | - * @param string $attention_messages |
|
952 | - * @param string $error_messages |
|
953 | - * @return string |
|
954 | - */ |
|
955 | - private static function formatNoticesOutput($success_messages, $attention_messages, $error_messages) |
|
956 | - { |
|
957 | - $notices = '<div id="espresso-notices">'; |
|
958 | - $close = is_admin() |
|
959 | - ? '' |
|
960 | - : '<a class="close-espresso-notice hide-if-no-js"><span class="dashicons dashicons-no"/></a>'; |
|
961 | - if ($success_messages !== '') { |
|
962 | - $css_id = is_admin() ? 'ee-success-message' : 'espresso-notices-success'; |
|
963 | - $css_class = is_admin() ? 'updated fade' : 'success fade-away'; |
|
964 | - // showMessage( $success_messages ); |
|
965 | - $notices .= '<div id="' . $css_id . '" ' |
|
966 | - . 'class="espresso-notices ' . $css_class . '" ' |
|
967 | - . 'style="display:none;">' |
|
968 | - . '<p>' . $success_messages . '</p>' |
|
969 | - . $close |
|
970 | - . '</div>'; |
|
971 | - } |
|
972 | - if ($attention_messages !== '') { |
|
973 | - $css_id = is_admin() ? 'ee-attention-message' : 'espresso-notices-attention'; |
|
974 | - $css_class = is_admin() ? 'updated ee-notices-attention' : 'attention fade-away'; |
|
975 | - // showMessage( $error_messages, TRUE ); |
|
976 | - $notices .= '<div id="' . $css_id . '" ' |
|
977 | - . 'class="espresso-notices ' . $css_class . '" ' |
|
978 | - . 'style="display:none;">' |
|
979 | - . '<p>' . $attention_messages . '</p>' |
|
980 | - . $close |
|
981 | - . '</div>'; |
|
982 | - } |
|
983 | - if ($error_messages !== '') { |
|
984 | - $css_id = is_admin() ? 'ee-error-message' : 'espresso-notices-error'; |
|
985 | - $css_class = is_admin() ? 'error' : 'error fade-away'; |
|
986 | - // showMessage( $error_messages, TRUE ); |
|
987 | - $notices .= '<div id="' . $css_id . '" ' |
|
988 | - . 'class="espresso-notices ' . $css_class . '" ' |
|
989 | - . 'style="display:none;">' |
|
990 | - . '<p>' . $error_messages . '</p>' |
|
991 | - . $close |
|
992 | - . '</div>'; |
|
993 | - } |
|
994 | - $notices .= '</div>'; |
|
995 | - return $notices; |
|
996 | - } |
|
997 | - |
|
998 | - |
|
999 | - /** |
|
1000 | - * _print_scripts |
|
1001 | - * |
|
1002 | - * @param bool $force_print |
|
1003 | - * @return string |
|
1004 | - */ |
|
1005 | - private static function _print_scripts($force_print = false) |
|
1006 | - { |
|
1007 | - if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) { |
|
1008 | - if (wp_script_is('ee_error_js', 'registered')) { |
|
1009 | - wp_enqueue_style('espresso_default'); |
|
1010 | - wp_enqueue_style('espresso_custom_css'); |
|
1011 | - wp_enqueue_script('ee_error_js'); |
|
1012 | - } |
|
1013 | - if (wp_script_is('ee_error_js', 'enqueued')) { |
|
1014 | - wp_localize_script('ee_error_js', 'ee_settings', array('wp_debug' => WP_DEBUG)); |
|
1015 | - return ''; |
|
1016 | - } |
|
1017 | - } else { |
|
1018 | - return ' |
|
472 | + $output .= self::_print_scripts(true); |
|
473 | + if (defined('DOING_AJAX')) { |
|
474 | + echo wp_json_encode(array('error' => $output)); |
|
475 | + exit(); |
|
476 | + } |
|
477 | + echo $output; |
|
478 | + die(); |
|
479 | + } |
|
480 | + |
|
481 | + |
|
482 | + /** |
|
483 | + * generate string from exception trace args |
|
484 | + * |
|
485 | + * @param array $arguments |
|
486 | + * @param bool $array |
|
487 | + * @return string |
|
488 | + */ |
|
489 | + private function _convert_args_to_string($arguments = array(), $array = false) |
|
490 | + { |
|
491 | + $arg_string = ''; |
|
492 | + if (! empty($arguments)) { |
|
493 | + $args = array(); |
|
494 | + foreach ($arguments as $arg) { |
|
495 | + if (! empty($arg)) { |
|
496 | + if (is_string($arg)) { |
|
497 | + $args[] = " '" . $arg . "'"; |
|
498 | + } elseif (is_array($arg)) { |
|
499 | + $args[] = 'ARRAY(' . $this->_convert_args_to_string($arg, true); |
|
500 | + } elseif ($arg === null) { |
|
501 | + $args[] = ' NULL'; |
|
502 | + } elseif (is_bool($arg)) { |
|
503 | + $args[] = ($arg) ? ' TRUE' : ' FALSE'; |
|
504 | + } elseif (is_object($arg)) { |
|
505 | + $args[] = ' OBJECT ' . get_class($arg); |
|
506 | + } elseif (is_resource($arg)) { |
|
507 | + $args[] = get_resource_type($arg); |
|
508 | + } else { |
|
509 | + $args[] = $arg; |
|
510 | + } |
|
511 | + } |
|
512 | + } |
|
513 | + $arg_string = implode(', ', $args); |
|
514 | + } |
|
515 | + if ($array) { |
|
516 | + $arg_string .= ' )'; |
|
517 | + } |
|
518 | + return $arg_string; |
|
519 | + } |
|
520 | + |
|
521 | + |
|
522 | + /** |
|
523 | + * add error message |
|
524 | + * |
|
525 | + * @param string $msg the message to display to users or developers - adding a double pipe || (OR) creates |
|
526 | + * separate messages for user || dev |
|
527 | + * @param string $file the file that the error occurred in - just use __FILE__ |
|
528 | + * @param string $func the function/method that the error occurred in - just use __FUNCTION__ |
|
529 | + * @param string $line the line number where the error occurred - just use __LINE__ |
|
530 | + * @return void |
|
531 | + */ |
|
532 | + public static function add_error($msg = null, $file = null, $func = null, $line = null) |
|
533 | + { |
|
534 | + self::_add_notice('errors', $msg, $file, $func, $line); |
|
535 | + self::$_error_count++; |
|
536 | + } |
|
537 | + |
|
538 | + |
|
539 | + /** |
|
540 | + * If WP_DEBUG is active, throws an exception. If WP_DEBUG is off, just |
|
541 | + * adds an error |
|
542 | + * |
|
543 | + * @param string $msg |
|
544 | + * @param string $file |
|
545 | + * @param string $func |
|
546 | + * @param string $line |
|
547 | + * @throws EE_Error |
|
548 | + */ |
|
549 | + public static function throw_exception_if_debugging($msg = null, $file = null, $func = null, $line = null) |
|
550 | + { |
|
551 | + if (WP_DEBUG) { |
|
552 | + throw new EE_Error($msg); |
|
553 | + } |
|
554 | + EE_Error::add_error($msg, $file, $func, $line); |
|
555 | + } |
|
556 | + |
|
557 | + |
|
558 | + /** |
|
559 | + * add success message |
|
560 | + * |
|
561 | + * @param string $msg the message to display to users or developers - adding a double pipe || (OR) creates |
|
562 | + * separate messages for user || dev |
|
563 | + * @param string $file the file that the error occurred in - just use __FILE__ |
|
564 | + * @param string $func the function/method that the error occurred in - just use __FUNCTION__ |
|
565 | + * @param string $line the line number where the error occurred - just use __LINE__ |
|
566 | + * @return void |
|
567 | + */ |
|
568 | + public static function add_success($msg = null, $file = null, $func = null, $line = null) |
|
569 | + { |
|
570 | + self::_add_notice('success', $msg, $file, $func, $line); |
|
571 | + } |
|
572 | + |
|
573 | + |
|
574 | + /** |
|
575 | + * add attention message |
|
576 | + * |
|
577 | + * @param string $msg the message to display to users or developers - adding a double pipe || (OR) creates |
|
578 | + * separate messages for user || dev |
|
579 | + * @param string $file the file that the error occurred in - just use __FILE__ |
|
580 | + * @param string $func the function/method that the error occurred in - just use __FUNCTION__ |
|
581 | + * @param string $line the line number where the error occurred - just use __LINE__ |
|
582 | + * @return void |
|
583 | + */ |
|
584 | + public static function add_attention($msg = null, $file = null, $func = null, $line = null) |
|
585 | + { |
|
586 | + self::_add_notice('attention', $msg, $file, $func, $line); |
|
587 | + } |
|
588 | + |
|
589 | + |
|
590 | + /** |
|
591 | + * @param string $type whether the message is for a success or error notification |
|
592 | + * @param string $msg the message to display to users or developers |
|
593 | + * - adding a double pipe || (OR) creates separate messages for user || dev |
|
594 | + * @param string $file the file that the error occurred in - just use __FILE__ |
|
595 | + * @param string $func the function/method that the error occurred in - just use __FUNCTION__ |
|
596 | + * @param string $line the line number where the error occurred - just use __LINE__ |
|
597 | + * @return void |
|
598 | + */ |
|
599 | + private static function _add_notice($type = 'success', $msg = '', $file = '', $func = '', $line = '') |
|
600 | + { |
|
601 | + if (empty($msg)) { |
|
602 | + EE_Error::doing_it_wrong( |
|
603 | + 'EE_Error::add_' . $type . '()', |
|
604 | + sprintf( |
|
605 | + esc_html__( |
|
606 | + 'Notifications are not much use without a message! Please add a message to the EE_Error::add_%s() call made in %s on line %d', |
|
607 | + 'event_espresso' |
|
608 | + ), |
|
609 | + $type, |
|
610 | + $file, |
|
611 | + $line |
|
612 | + ), |
|
613 | + EVENT_ESPRESSO_VERSION |
|
614 | + ); |
|
615 | + } |
|
616 | + if ($type === 'errors' && (empty($file) || empty($func) || empty($line))) { |
|
617 | + EE_Error::doing_it_wrong( |
|
618 | + 'EE_Error::add_error()', |
|
619 | + esc_html__( |
|
620 | + 'You need to provide the file name, function name, and line number that the error occurred on in order to better assist with debugging.', |
|
621 | + 'event_espresso' |
|
622 | + ), |
|
623 | + EVENT_ESPRESSO_VERSION |
|
624 | + ); |
|
625 | + } |
|
626 | + // get separate user and developer messages if they exist |
|
627 | + $msg = explode('||', $msg); |
|
628 | + $user_msg = $msg[0]; |
|
629 | + $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0]; |
|
630 | + /** |
|
631 | + * Do an action so other code can be triggered when a notice is created |
|
632 | + * |
|
633 | + * @param string $type can be 'errors', 'attention', or 'success' |
|
634 | + * @param string $user_msg message displayed to user when WP_DEBUG is off |
|
635 | + * @param string $user_msg message displayed to user when WP_DEBUG is on |
|
636 | + * @param string $file file where error was generated |
|
637 | + * @param string $func function where error was generated |
|
638 | + * @param string $line line where error was generated |
|
639 | + */ |
|
640 | + do_action('AHEE__EE_Error___add_notice', $type, $user_msg, $dev_msg, $file, $func, $line); |
|
641 | + $msg = WP_DEBUG ? $dev_msg : $user_msg; |
|
642 | + // add notice if message exists |
|
643 | + if (! empty($msg)) { |
|
644 | + // get error code |
|
645 | + $notice_code = EE_Error::generate_error_code($file, $func, $line); |
|
646 | + if (WP_DEBUG && $type === 'errors') { |
|
647 | + $msg .= '<br/><span class="tiny-text">' . $notice_code . '</span>'; |
|
648 | + } |
|
649 | + // add notice. Index by code if it's not blank |
|
650 | + if ($notice_code) { |
|
651 | + self::$_espresso_notices[ $type ][ $notice_code ] = $msg; |
|
652 | + } else { |
|
653 | + self::$_espresso_notices[ $type ][] = $msg; |
|
654 | + } |
|
655 | + add_action('wp_footer', array('EE_Error', 'enqueue_error_scripts'), 1); |
|
656 | + } |
|
657 | + } |
|
658 | + |
|
659 | + |
|
660 | + /** |
|
661 | + * in some case it may be necessary to overwrite the existing success messages |
|
662 | + * |
|
663 | + * @return void |
|
664 | + */ |
|
665 | + public static function overwrite_success() |
|
666 | + { |
|
667 | + self::$_espresso_notices['success'] = false; |
|
668 | + } |
|
669 | + |
|
670 | + |
|
671 | + /** |
|
672 | + * in some case it may be necessary to overwrite the existing attention messages |
|
673 | + * |
|
674 | + * @return void |
|
675 | + */ |
|
676 | + public static function overwrite_attention() |
|
677 | + { |
|
678 | + self::$_espresso_notices['attention'] = false; |
|
679 | + } |
|
680 | + |
|
681 | + |
|
682 | + /** |
|
683 | + * in some case it may be necessary to overwrite the existing error messages |
|
684 | + * |
|
685 | + * @return void |
|
686 | + */ |
|
687 | + public static function overwrite_errors() |
|
688 | + { |
|
689 | + self::$_espresso_notices['errors'] = false; |
|
690 | + } |
|
691 | + |
|
692 | + |
|
693 | + /** |
|
694 | + * @return void |
|
695 | + */ |
|
696 | + public static function reset_notices() |
|
697 | + { |
|
698 | + self::$_espresso_notices['success'] = false; |
|
699 | + self::$_espresso_notices['attention'] = false; |
|
700 | + self::$_espresso_notices['errors'] = false; |
|
701 | + } |
|
702 | + |
|
703 | + |
|
704 | + /** |
|
705 | + * @return int |
|
706 | + */ |
|
707 | + public static function has_notices() |
|
708 | + { |
|
709 | + $has_notices = 0; |
|
710 | + // check for success messages |
|
711 | + $has_notices = self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success']) |
|
712 | + ? 3 |
|
713 | + : $has_notices; |
|
714 | + // check for attention messages |
|
715 | + $has_notices = self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention']) |
|
716 | + ? 2 |
|
717 | + : $has_notices; |
|
718 | + // check for error messages |
|
719 | + $has_notices = self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors']) |
|
720 | + ? 1 |
|
721 | + : $has_notices; |
|
722 | + return $has_notices; |
|
723 | + } |
|
724 | + |
|
725 | + |
|
726 | + /** |
|
727 | + * This simply returns non formatted error notices as they were sent into the EE_Error object. |
|
728 | + * |
|
729 | + * @since 4.9.0 |
|
730 | + * @return array |
|
731 | + */ |
|
732 | + public static function get_vanilla_notices() |
|
733 | + { |
|
734 | + return array( |
|
735 | + 'success' => isset(self::$_espresso_notices['success']) |
|
736 | + ? self::$_espresso_notices['success'] |
|
737 | + : array(), |
|
738 | + 'attention' => isset(self::$_espresso_notices['attention']) |
|
739 | + ? self::$_espresso_notices['attention'] |
|
740 | + : array(), |
|
741 | + 'errors' => isset(self::$_espresso_notices['errors']) |
|
742 | + ? self::$_espresso_notices['errors'] |
|
743 | + : array(), |
|
744 | + ); |
|
745 | + } |
|
746 | + |
|
747 | + |
|
748 | + /** |
|
749 | + * @return array |
|
750 | + * @throws InvalidArgumentException |
|
751 | + * @throws InvalidDataTypeException |
|
752 | + * @throws InvalidInterfaceException |
|
753 | + */ |
|
754 | + public static function getStoredNotices() |
|
755 | + { |
|
756 | + if ($user_id = get_current_user_id()) { |
|
757 | + // get notices for logged in user |
|
758 | + $notices = get_user_option(EE_Error::OPTIONS_KEY_NOTICES, $user_id); |
|
759 | + return is_array($notices) ? $notices : array(); |
|
760 | + } |
|
761 | + if (EE_Session::isLoadedAndActive()) { |
|
762 | + // get notices for user currently engaged in a session |
|
763 | + $session_data = EE_Session::instance()->get_session_data(EE_Error::OPTIONS_KEY_NOTICES); |
|
764 | + return is_array($session_data) ? $session_data : array(); |
|
765 | + } |
|
766 | + // get global notices and hope they apply to the current site visitor |
|
767 | + $notices = get_option(EE_Error::OPTIONS_KEY_NOTICES, array()); |
|
768 | + return is_array($notices) ? $notices : array(); |
|
769 | + } |
|
770 | + |
|
771 | + |
|
772 | + /** |
|
773 | + * @param array $notices |
|
774 | + * @return bool |
|
775 | + * @throws InvalidArgumentException |
|
776 | + * @throws InvalidDataTypeException |
|
777 | + * @throws InvalidInterfaceException |
|
778 | + */ |
|
779 | + public static function storeNotices(array $notices) |
|
780 | + { |
|
781 | + if ($user_id = get_current_user_id()) { |
|
782 | + // store notices for logged in user |
|
783 | + return (bool) update_user_option( |
|
784 | + $user_id, |
|
785 | + EE_Error::OPTIONS_KEY_NOTICES, |
|
786 | + $notices |
|
787 | + ); |
|
788 | + } |
|
789 | + if (EE_Session::isLoadedAndActive()) { |
|
790 | + // store notices for user currently engaged in a session |
|
791 | + return EE_Session::instance()->set_session_data( |
|
792 | + array(EE_Error::OPTIONS_KEY_NOTICES => $notices) |
|
793 | + ); |
|
794 | + } |
|
795 | + // store global notices and hope they apply to the same site visitor on the next request |
|
796 | + return update_option(EE_Error::OPTIONS_KEY_NOTICES, $notices); |
|
797 | + } |
|
798 | + |
|
799 | + |
|
800 | + /** |
|
801 | + * @return bool|TRUE |
|
802 | + * @throws InvalidArgumentException |
|
803 | + * @throws InvalidDataTypeException |
|
804 | + * @throws InvalidInterfaceException |
|
805 | + */ |
|
806 | + public static function clearNotices() |
|
807 | + { |
|
808 | + if ($user_id = get_current_user_id()) { |
|
809 | + // clear notices for logged in user |
|
810 | + return (bool) update_user_option( |
|
811 | + $user_id, |
|
812 | + EE_Error::OPTIONS_KEY_NOTICES, |
|
813 | + array() |
|
814 | + ); |
|
815 | + } |
|
816 | + if (EE_Session::isLoadedAndActive()) { |
|
817 | + // clear notices for user currently engaged in a session |
|
818 | + return EE_Session::instance()->reset_data(EE_Error::OPTIONS_KEY_NOTICES); |
|
819 | + } |
|
820 | + // clear global notices and hope none belonged to some for some other site visitor |
|
821 | + return update_option(EE_Error::OPTIONS_KEY_NOTICES, array()); |
|
822 | + } |
|
823 | + |
|
824 | + |
|
825 | + /** |
|
826 | + * saves notices to the db for retrieval on next request |
|
827 | + * |
|
828 | + * @return void |
|
829 | + * @throws InvalidArgumentException |
|
830 | + * @throws InvalidDataTypeException |
|
831 | + * @throws InvalidInterfaceException |
|
832 | + */ |
|
833 | + public static function stashNoticesBeforeRedirect() |
|
834 | + { |
|
835 | + EE_Error::get_notices(false, true); |
|
836 | + } |
|
837 | + |
|
838 | + |
|
839 | + /** |
|
840 | + * compile all error or success messages into one string |
|
841 | + * |
|
842 | + * @see EE_Error::get_raw_notices if you want the raw notices without any preparations made to them |
|
843 | + * @param boolean $format_output whether or not to format the messages for display in the WP admin |
|
844 | + * @param boolean $save_to_transient whether or not to save notices to the db for retrieval on next request |
|
845 | + * - ONLY do this just before redirecting |
|
846 | + * @param boolean $remove_empty whether or not to unset empty messages |
|
847 | + * @return array |
|
848 | + * @throws InvalidArgumentException |
|
849 | + * @throws InvalidDataTypeException |
|
850 | + * @throws InvalidInterfaceException |
|
851 | + */ |
|
852 | + public static function get_notices($format_output = true, $save_to_transient = false, $remove_empty = true) |
|
853 | + { |
|
854 | + $success_messages = ''; |
|
855 | + $attention_messages = ''; |
|
856 | + $error_messages = ''; |
|
857 | + /** @var RequestInterface $request */ |
|
858 | + $request = LoaderFactory::getLoader()->getShared(RequestInterface::class); |
|
859 | + // either save notices to the db |
|
860 | + if ($save_to_transient || $request->requestParamIsSet('activate-selected')) { |
|
861 | + self::$_espresso_notices = array_merge( |
|
862 | + EE_Error::getStoredNotices(), |
|
863 | + self::$_espresso_notices |
|
864 | + ); |
|
865 | + EE_Error::storeNotices(self::$_espresso_notices); |
|
866 | + return array(); |
|
867 | + } |
|
868 | + $print_scripts = EE_Error::combineExistingAndNewNotices(); |
|
869 | + // check for success messages |
|
870 | + if (self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success'])) { |
|
871 | + // combine messages |
|
872 | + $success_messages .= implode('<br />', self::$_espresso_notices['success']); |
|
873 | + $print_scripts = true; |
|
874 | + } |
|
875 | + // check for attention messages |
|
876 | + if (self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention'])) { |
|
877 | + // combine messages |
|
878 | + $attention_messages .= implode('<br />', self::$_espresso_notices['attention']); |
|
879 | + $print_scripts = true; |
|
880 | + } |
|
881 | + // check for error messages |
|
882 | + if (self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors'])) { |
|
883 | + $error_messages .= count(self::$_espresso_notices['errors']) > 1 |
|
884 | + ? esc_html__('The following errors have occurred:', 'event_espresso') |
|
885 | + : esc_html__('An error has occurred:', 'event_espresso'); |
|
886 | + // combine messages |
|
887 | + $error_messages .= '<br />' . implode('<br />', self::$_espresso_notices['errors']); |
|
888 | + $print_scripts = true; |
|
889 | + } |
|
890 | + if ($format_output) { |
|
891 | + $notices = EE_Error::formatNoticesOutput( |
|
892 | + $success_messages, |
|
893 | + $attention_messages, |
|
894 | + $error_messages |
|
895 | + ); |
|
896 | + } else { |
|
897 | + $notices = array( |
|
898 | + 'success' => $success_messages, |
|
899 | + 'attention' => $attention_messages, |
|
900 | + 'errors' => $error_messages, |
|
901 | + ); |
|
902 | + if ($remove_empty) { |
|
903 | + // remove empty notices |
|
904 | + foreach ($notices as $type => $notice) { |
|
905 | + if (empty($notice)) { |
|
906 | + unset($notices[ $type ]); |
|
907 | + } |
|
908 | + } |
|
909 | + } |
|
910 | + } |
|
911 | + if ($print_scripts) { |
|
912 | + self::_print_scripts(); |
|
913 | + } |
|
914 | + return $notices; |
|
915 | + } |
|
916 | + |
|
917 | + |
|
918 | + /** |
|
919 | + * @return bool |
|
920 | + * @throws InvalidArgumentException |
|
921 | + * @throws InvalidDataTypeException |
|
922 | + * @throws InvalidInterfaceException |
|
923 | + */ |
|
924 | + private static function combineExistingAndNewNotices() |
|
925 | + { |
|
926 | + $print_scripts = false; |
|
927 | + // grab any notices that have been previously saved |
|
928 | + $notices = EE_Error::getStoredNotices(); |
|
929 | + if (! empty($notices)) { |
|
930 | + foreach ($notices as $type => $notice) { |
|
931 | + if (is_array($notice) && ! empty($notice)) { |
|
932 | + // make sure that existing notice type is an array |
|
933 | + self::$_espresso_notices[ $type ] = is_array(self::$_espresso_notices[ $type ]) |
|
934 | + && ! empty(self::$_espresso_notices[ $type ]) |
|
935 | + ? self::$_espresso_notices[ $type ] |
|
936 | + : array(); |
|
937 | + // add newly created notices to existing ones |
|
938 | + self::$_espresso_notices[ $type ] += $notice; |
|
939 | + $print_scripts = true; |
|
940 | + } |
|
941 | + } |
|
942 | + // now clear any stored notices |
|
943 | + EE_Error::clearNotices(); |
|
944 | + } |
|
945 | + return $print_scripts; |
|
946 | + } |
|
947 | + |
|
948 | + |
|
949 | + /** |
|
950 | + * @param string $success_messages |
|
951 | + * @param string $attention_messages |
|
952 | + * @param string $error_messages |
|
953 | + * @return string |
|
954 | + */ |
|
955 | + private static function formatNoticesOutput($success_messages, $attention_messages, $error_messages) |
|
956 | + { |
|
957 | + $notices = '<div id="espresso-notices">'; |
|
958 | + $close = is_admin() |
|
959 | + ? '' |
|
960 | + : '<a class="close-espresso-notice hide-if-no-js"><span class="dashicons dashicons-no"/></a>'; |
|
961 | + if ($success_messages !== '') { |
|
962 | + $css_id = is_admin() ? 'ee-success-message' : 'espresso-notices-success'; |
|
963 | + $css_class = is_admin() ? 'updated fade' : 'success fade-away'; |
|
964 | + // showMessage( $success_messages ); |
|
965 | + $notices .= '<div id="' . $css_id . '" ' |
|
966 | + . 'class="espresso-notices ' . $css_class . '" ' |
|
967 | + . 'style="display:none;">' |
|
968 | + . '<p>' . $success_messages . '</p>' |
|
969 | + . $close |
|
970 | + . '</div>'; |
|
971 | + } |
|
972 | + if ($attention_messages !== '') { |
|
973 | + $css_id = is_admin() ? 'ee-attention-message' : 'espresso-notices-attention'; |
|
974 | + $css_class = is_admin() ? 'updated ee-notices-attention' : 'attention fade-away'; |
|
975 | + // showMessage( $error_messages, TRUE ); |
|
976 | + $notices .= '<div id="' . $css_id . '" ' |
|
977 | + . 'class="espresso-notices ' . $css_class . '" ' |
|
978 | + . 'style="display:none;">' |
|
979 | + . '<p>' . $attention_messages . '</p>' |
|
980 | + . $close |
|
981 | + . '</div>'; |
|
982 | + } |
|
983 | + if ($error_messages !== '') { |
|
984 | + $css_id = is_admin() ? 'ee-error-message' : 'espresso-notices-error'; |
|
985 | + $css_class = is_admin() ? 'error' : 'error fade-away'; |
|
986 | + // showMessage( $error_messages, TRUE ); |
|
987 | + $notices .= '<div id="' . $css_id . '" ' |
|
988 | + . 'class="espresso-notices ' . $css_class . '" ' |
|
989 | + . 'style="display:none;">' |
|
990 | + . '<p>' . $error_messages . '</p>' |
|
991 | + . $close |
|
992 | + . '</div>'; |
|
993 | + } |
|
994 | + $notices .= '</div>'; |
|
995 | + return $notices; |
|
996 | + } |
|
997 | + |
|
998 | + |
|
999 | + /** |
|
1000 | + * _print_scripts |
|
1001 | + * |
|
1002 | + * @param bool $force_print |
|
1003 | + * @return string |
|
1004 | + */ |
|
1005 | + private static function _print_scripts($force_print = false) |
|
1006 | + { |
|
1007 | + if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) { |
|
1008 | + if (wp_script_is('ee_error_js', 'registered')) { |
|
1009 | + wp_enqueue_style('espresso_default'); |
|
1010 | + wp_enqueue_style('espresso_custom_css'); |
|
1011 | + wp_enqueue_script('ee_error_js'); |
|
1012 | + } |
|
1013 | + if (wp_script_is('ee_error_js', 'enqueued')) { |
|
1014 | + wp_localize_script('ee_error_js', 'ee_settings', array('wp_debug' => WP_DEBUG)); |
|
1015 | + return ''; |
|
1016 | + } |
|
1017 | + } else { |
|
1018 | + return ' |
|
1019 | 1019 | <script> |
1020 | 1020 | /* <![CDATA[ */ |
1021 | 1021 | var ee_settings = {"wp_debug":"' . WP_DEBUG . '"}; |
@@ -1025,221 +1025,221 @@ discard block |
||
1025 | 1025 | <script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script> |
1026 | 1026 | <script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script> |
1027 | 1027 | '; |
1028 | - } |
|
1029 | - return ''; |
|
1030 | - } |
|
1031 | - |
|
1032 | - |
|
1033 | - /** |
|
1034 | - * @return void |
|
1035 | - */ |
|
1036 | - public static function enqueue_error_scripts() |
|
1037 | - { |
|
1038 | - self::_print_scripts(); |
|
1039 | - } |
|
1040 | - |
|
1041 | - |
|
1042 | - /** |
|
1043 | - * create error code from filepath, function name, |
|
1044 | - * and line number where exception or error was thrown |
|
1045 | - * |
|
1046 | - * @param string $file |
|
1047 | - * @param string $func |
|
1048 | - * @param string $line |
|
1049 | - * @return string |
|
1050 | - */ |
|
1051 | - public static function generate_error_code($file = '', $func = '', $line = '') |
|
1052 | - { |
|
1053 | - $file = explode('.', basename($file)); |
|
1054 | - $error_code = ! empty($file[0]) ? $file[0] : ''; |
|
1055 | - $error_code .= ! empty($func) ? ' - ' . $func : ''; |
|
1056 | - $error_code .= ! empty($line) ? ' - ' . $line : ''; |
|
1057 | - return $error_code; |
|
1058 | - } |
|
1059 | - |
|
1060 | - |
|
1061 | - /** |
|
1062 | - * write exception details to log file |
|
1063 | - * Since 4.9.53.rc.006 this writes to the standard PHP log file, not EE's custom log file |
|
1064 | - * |
|
1065 | - * @param int $time |
|
1066 | - * @param array $ex |
|
1067 | - * @param bool $clear |
|
1068 | - * @return void |
|
1069 | - */ |
|
1070 | - public function write_to_error_log($time = 0, $ex = array(), $clear = false) |
|
1071 | - { |
|
1072 | - if (empty($ex)) { |
|
1073 | - return; |
|
1074 | - } |
|
1075 | - if (! $time) { |
|
1076 | - $time = time(); |
|
1077 | - } |
|
1078 | - $exception_log = '----------------------------------------------------------------------------------------' |
|
1079 | - . PHP_EOL; |
|
1080 | - $exception_log .= '[' . date('Y-m-d H:i:s', $time) . '] Exception Details' . PHP_EOL; |
|
1081 | - $exception_log .= 'Message: ' . $ex['msg'] . PHP_EOL; |
|
1082 | - $exception_log .= 'Code: ' . $ex['code'] . PHP_EOL; |
|
1083 | - $exception_log .= 'File: ' . $ex['file'] . PHP_EOL; |
|
1084 | - $exception_log .= 'Line No: ' . $ex['line'] . PHP_EOL; |
|
1085 | - $exception_log .= 'Stack trace: ' . PHP_EOL; |
|
1086 | - $exception_log .= $ex['string'] . PHP_EOL; |
|
1087 | - $exception_log .= '----------------------------------------------------------------------------------------' |
|
1088 | - . PHP_EOL; |
|
1089 | - try { |
|
1090 | - error_log($exception_log); |
|
1091 | - } catch (EE_Error $e) { |
|
1092 | - EE_Error::add_error( |
|
1093 | - sprintf( |
|
1094 | - esc_html__( |
|
1095 | - 'Event Espresso error logging could not be setup because: %s', |
|
1096 | - 'event_espresso' |
|
1097 | - ), |
|
1098 | - $e->getMessage() |
|
1099 | - ) |
|
1100 | - ); |
|
1101 | - } |
|
1102 | - } |
|
1103 | - |
|
1104 | - |
|
1105 | - /** |
|
1106 | - * This is just a wrapper for the EEH_Debug_Tools::instance()->doing_it_wrong() method. |
|
1107 | - * doing_it_wrong() is used in those cases where a normal PHP error won't get thrown, |
|
1108 | - * but the code execution is done in a manner that could lead to unexpected results |
|
1109 | - * (i.e. running to early, or too late in WP or EE loading process). |
|
1110 | - * A good test for knowing whether to use this method is: |
|
1111 | - * 1. Is there going to be a PHP error if something isn't setup/used correctly? |
|
1112 | - * Yes -> use EE_Error::add_error() or throw new EE_Error() |
|
1113 | - * 2. If this is loaded before something else, it won't break anything, |
|
1114 | - * but just wont' do what its supposed to do? Yes -> use EE_Error::doing_it_wrong() |
|
1115 | - * |
|
1116 | - * @uses constant WP_DEBUG test if wp_debug is on or not |
|
1117 | - * @param string $function The function that was called |
|
1118 | - * @param string $message A message explaining what has been done incorrectly |
|
1119 | - * @param string $version The version of Event Espresso where the error was added |
|
1120 | - * @param string $applies_when a version string for when you want the doing_it_wrong notice to begin appearing |
|
1121 | - * for a deprecated function. This allows deprecation to occur during one version, |
|
1122 | - * but not have any notices appear until a later version. This allows developers |
|
1123 | - * extra time to update their code before notices appear. |
|
1124 | - * @param int $error_type |
|
1125 | - */ |
|
1126 | - public static function doing_it_wrong( |
|
1127 | - $function, |
|
1128 | - $message, |
|
1129 | - $version, |
|
1130 | - $applies_when = '', |
|
1131 | - $error_type = null |
|
1132 | - ) { |
|
1133 | - if (defined('WP_DEBUG') && WP_DEBUG) { |
|
1134 | - EEH_Debug_Tools::instance()->doing_it_wrong($function, $message, $version, $applies_when, $error_type); |
|
1135 | - } |
|
1136 | - } |
|
1137 | - |
|
1138 | - |
|
1139 | - /** |
|
1140 | - * Like get_notices, but returns an array of all the notices of the given type. |
|
1141 | - * |
|
1142 | - * @return array { |
|
1143 | - * @type array $success all the success messages |
|
1144 | - * @type array $errors all the error messages |
|
1145 | - * @type array $attention all the attention messages |
|
1146 | - * } |
|
1147 | - */ |
|
1148 | - public static function get_raw_notices() |
|
1149 | - { |
|
1150 | - return self::$_espresso_notices; |
|
1151 | - } |
|
1152 | - |
|
1153 | - |
|
1154 | - /** |
|
1155 | - * @deprecated 4.9.27 |
|
1156 | - * @param string $pan_name the name, or key of the Persistent Admin Notice to be stored |
|
1157 | - * @param string $pan_message the message to be stored persistently until dismissed |
|
1158 | - * @param bool $force_update allows one to enforce the reappearance of a persistent message. |
|
1159 | - * @return void |
|
1160 | - * @throws InvalidDataTypeException |
|
1161 | - */ |
|
1162 | - public static function add_persistent_admin_notice($pan_name = '', $pan_message, $force_update = false) |
|
1163 | - { |
|
1164 | - new PersistentAdminNotice( |
|
1165 | - $pan_name, |
|
1166 | - $pan_message, |
|
1167 | - $force_update |
|
1168 | - ); |
|
1169 | - EE_Error::doing_it_wrong( |
|
1170 | - __METHOD__, |
|
1171 | - sprintf( |
|
1172 | - esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'), |
|
1173 | - '\EventEspresso\core\domain\entities\notifications\PersistentAdminNotice' |
|
1174 | - ), |
|
1175 | - '4.9.27' |
|
1176 | - ); |
|
1177 | - } |
|
1178 | - |
|
1179 | - |
|
1180 | - /** |
|
1181 | - * @deprecated 4.9.27 |
|
1182 | - * @param string $pan_name the name, or key of the Persistent Admin Notice to be dismissed |
|
1183 | - * @param bool $purge |
|
1184 | - * @param bool $return |
|
1185 | - * @throws DomainException |
|
1186 | - * @throws InvalidInterfaceException |
|
1187 | - * @throws InvalidDataTypeException |
|
1188 | - * @throws ServiceNotFoundException |
|
1189 | - * @throws InvalidArgumentException |
|
1190 | - */ |
|
1191 | - public static function dismiss_persistent_admin_notice($pan_name = '', $purge = false, $return = false) |
|
1192 | - { |
|
1193 | - /** @var PersistentAdminNoticeManager $persistent_admin_notice_manager */ |
|
1194 | - $persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared( |
|
1195 | - 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
1196 | - ); |
|
1197 | - $persistent_admin_notice_manager->dismissNotice($pan_name, $purge, $return); |
|
1198 | - EE_Error::doing_it_wrong( |
|
1199 | - __METHOD__, |
|
1200 | - sprintf( |
|
1201 | - esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'), |
|
1202 | - '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
1203 | - ), |
|
1204 | - '4.9.27' |
|
1205 | - ); |
|
1206 | - } |
|
1207 | - |
|
1208 | - |
|
1209 | - /** |
|
1210 | - * @deprecated 4.9.27 |
|
1211 | - * @param string $pan_name the name, or key of the Persistent Admin Notice to be stored |
|
1212 | - * @param string $pan_message the message to be stored persistently until dismissed |
|
1213 | - * @param string $return_url URL to go back to after nag notice is dismissed |
|
1214 | - */ |
|
1215 | - public static function display_persistent_admin_notices($pan_name = '', $pan_message = '', $return_url = '') |
|
1216 | - { |
|
1217 | - EE_Error::doing_it_wrong( |
|
1218 | - __METHOD__, |
|
1219 | - sprintf( |
|
1220 | - esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'), |
|
1221 | - '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
1222 | - ), |
|
1223 | - '4.9.27' |
|
1224 | - ); |
|
1225 | - } |
|
1226 | - |
|
1227 | - |
|
1228 | - /** |
|
1229 | - * @deprecated 4.9.27 |
|
1230 | - * @param string $return_url |
|
1231 | - */ |
|
1232 | - public static function get_persistent_admin_notices($return_url = '') |
|
1233 | - { |
|
1234 | - EE_Error::doing_it_wrong( |
|
1235 | - __METHOD__, |
|
1236 | - sprintf( |
|
1237 | - esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'), |
|
1238 | - '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
1239 | - ), |
|
1240 | - '4.9.27' |
|
1241 | - ); |
|
1242 | - } |
|
1028 | + } |
|
1029 | + return ''; |
|
1030 | + } |
|
1031 | + |
|
1032 | + |
|
1033 | + /** |
|
1034 | + * @return void |
|
1035 | + */ |
|
1036 | + public static function enqueue_error_scripts() |
|
1037 | + { |
|
1038 | + self::_print_scripts(); |
|
1039 | + } |
|
1040 | + |
|
1041 | + |
|
1042 | + /** |
|
1043 | + * create error code from filepath, function name, |
|
1044 | + * and line number where exception or error was thrown |
|
1045 | + * |
|
1046 | + * @param string $file |
|
1047 | + * @param string $func |
|
1048 | + * @param string $line |
|
1049 | + * @return string |
|
1050 | + */ |
|
1051 | + public static function generate_error_code($file = '', $func = '', $line = '') |
|
1052 | + { |
|
1053 | + $file = explode('.', basename($file)); |
|
1054 | + $error_code = ! empty($file[0]) ? $file[0] : ''; |
|
1055 | + $error_code .= ! empty($func) ? ' - ' . $func : ''; |
|
1056 | + $error_code .= ! empty($line) ? ' - ' . $line : ''; |
|
1057 | + return $error_code; |
|
1058 | + } |
|
1059 | + |
|
1060 | + |
|
1061 | + /** |
|
1062 | + * write exception details to log file |
|
1063 | + * Since 4.9.53.rc.006 this writes to the standard PHP log file, not EE's custom log file |
|
1064 | + * |
|
1065 | + * @param int $time |
|
1066 | + * @param array $ex |
|
1067 | + * @param bool $clear |
|
1068 | + * @return void |
|
1069 | + */ |
|
1070 | + public function write_to_error_log($time = 0, $ex = array(), $clear = false) |
|
1071 | + { |
|
1072 | + if (empty($ex)) { |
|
1073 | + return; |
|
1074 | + } |
|
1075 | + if (! $time) { |
|
1076 | + $time = time(); |
|
1077 | + } |
|
1078 | + $exception_log = '----------------------------------------------------------------------------------------' |
|
1079 | + . PHP_EOL; |
|
1080 | + $exception_log .= '[' . date('Y-m-d H:i:s', $time) . '] Exception Details' . PHP_EOL; |
|
1081 | + $exception_log .= 'Message: ' . $ex['msg'] . PHP_EOL; |
|
1082 | + $exception_log .= 'Code: ' . $ex['code'] . PHP_EOL; |
|
1083 | + $exception_log .= 'File: ' . $ex['file'] . PHP_EOL; |
|
1084 | + $exception_log .= 'Line No: ' . $ex['line'] . PHP_EOL; |
|
1085 | + $exception_log .= 'Stack trace: ' . PHP_EOL; |
|
1086 | + $exception_log .= $ex['string'] . PHP_EOL; |
|
1087 | + $exception_log .= '----------------------------------------------------------------------------------------' |
|
1088 | + . PHP_EOL; |
|
1089 | + try { |
|
1090 | + error_log($exception_log); |
|
1091 | + } catch (EE_Error $e) { |
|
1092 | + EE_Error::add_error( |
|
1093 | + sprintf( |
|
1094 | + esc_html__( |
|
1095 | + 'Event Espresso error logging could not be setup because: %s', |
|
1096 | + 'event_espresso' |
|
1097 | + ), |
|
1098 | + $e->getMessage() |
|
1099 | + ) |
|
1100 | + ); |
|
1101 | + } |
|
1102 | + } |
|
1103 | + |
|
1104 | + |
|
1105 | + /** |
|
1106 | + * This is just a wrapper for the EEH_Debug_Tools::instance()->doing_it_wrong() method. |
|
1107 | + * doing_it_wrong() is used in those cases where a normal PHP error won't get thrown, |
|
1108 | + * but the code execution is done in a manner that could lead to unexpected results |
|
1109 | + * (i.e. running to early, or too late in WP or EE loading process). |
|
1110 | + * A good test for knowing whether to use this method is: |
|
1111 | + * 1. Is there going to be a PHP error if something isn't setup/used correctly? |
|
1112 | + * Yes -> use EE_Error::add_error() or throw new EE_Error() |
|
1113 | + * 2. If this is loaded before something else, it won't break anything, |
|
1114 | + * but just wont' do what its supposed to do? Yes -> use EE_Error::doing_it_wrong() |
|
1115 | + * |
|
1116 | + * @uses constant WP_DEBUG test if wp_debug is on or not |
|
1117 | + * @param string $function The function that was called |
|
1118 | + * @param string $message A message explaining what has been done incorrectly |
|
1119 | + * @param string $version The version of Event Espresso where the error was added |
|
1120 | + * @param string $applies_when a version string for when you want the doing_it_wrong notice to begin appearing |
|
1121 | + * for a deprecated function. This allows deprecation to occur during one version, |
|
1122 | + * but not have any notices appear until a later version. This allows developers |
|
1123 | + * extra time to update their code before notices appear. |
|
1124 | + * @param int $error_type |
|
1125 | + */ |
|
1126 | + public static function doing_it_wrong( |
|
1127 | + $function, |
|
1128 | + $message, |
|
1129 | + $version, |
|
1130 | + $applies_when = '', |
|
1131 | + $error_type = null |
|
1132 | + ) { |
|
1133 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
1134 | + EEH_Debug_Tools::instance()->doing_it_wrong($function, $message, $version, $applies_when, $error_type); |
|
1135 | + } |
|
1136 | + } |
|
1137 | + |
|
1138 | + |
|
1139 | + /** |
|
1140 | + * Like get_notices, but returns an array of all the notices of the given type. |
|
1141 | + * |
|
1142 | + * @return array { |
|
1143 | + * @type array $success all the success messages |
|
1144 | + * @type array $errors all the error messages |
|
1145 | + * @type array $attention all the attention messages |
|
1146 | + * } |
|
1147 | + */ |
|
1148 | + public static function get_raw_notices() |
|
1149 | + { |
|
1150 | + return self::$_espresso_notices; |
|
1151 | + } |
|
1152 | + |
|
1153 | + |
|
1154 | + /** |
|
1155 | + * @deprecated 4.9.27 |
|
1156 | + * @param string $pan_name the name, or key of the Persistent Admin Notice to be stored |
|
1157 | + * @param string $pan_message the message to be stored persistently until dismissed |
|
1158 | + * @param bool $force_update allows one to enforce the reappearance of a persistent message. |
|
1159 | + * @return void |
|
1160 | + * @throws InvalidDataTypeException |
|
1161 | + */ |
|
1162 | + public static function add_persistent_admin_notice($pan_name = '', $pan_message, $force_update = false) |
|
1163 | + { |
|
1164 | + new PersistentAdminNotice( |
|
1165 | + $pan_name, |
|
1166 | + $pan_message, |
|
1167 | + $force_update |
|
1168 | + ); |
|
1169 | + EE_Error::doing_it_wrong( |
|
1170 | + __METHOD__, |
|
1171 | + sprintf( |
|
1172 | + esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'), |
|
1173 | + '\EventEspresso\core\domain\entities\notifications\PersistentAdminNotice' |
|
1174 | + ), |
|
1175 | + '4.9.27' |
|
1176 | + ); |
|
1177 | + } |
|
1178 | + |
|
1179 | + |
|
1180 | + /** |
|
1181 | + * @deprecated 4.9.27 |
|
1182 | + * @param string $pan_name the name, or key of the Persistent Admin Notice to be dismissed |
|
1183 | + * @param bool $purge |
|
1184 | + * @param bool $return |
|
1185 | + * @throws DomainException |
|
1186 | + * @throws InvalidInterfaceException |
|
1187 | + * @throws InvalidDataTypeException |
|
1188 | + * @throws ServiceNotFoundException |
|
1189 | + * @throws InvalidArgumentException |
|
1190 | + */ |
|
1191 | + public static function dismiss_persistent_admin_notice($pan_name = '', $purge = false, $return = false) |
|
1192 | + { |
|
1193 | + /** @var PersistentAdminNoticeManager $persistent_admin_notice_manager */ |
|
1194 | + $persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared( |
|
1195 | + 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
1196 | + ); |
|
1197 | + $persistent_admin_notice_manager->dismissNotice($pan_name, $purge, $return); |
|
1198 | + EE_Error::doing_it_wrong( |
|
1199 | + __METHOD__, |
|
1200 | + sprintf( |
|
1201 | + esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'), |
|
1202 | + '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
1203 | + ), |
|
1204 | + '4.9.27' |
|
1205 | + ); |
|
1206 | + } |
|
1207 | + |
|
1208 | + |
|
1209 | + /** |
|
1210 | + * @deprecated 4.9.27 |
|
1211 | + * @param string $pan_name the name, or key of the Persistent Admin Notice to be stored |
|
1212 | + * @param string $pan_message the message to be stored persistently until dismissed |
|
1213 | + * @param string $return_url URL to go back to after nag notice is dismissed |
|
1214 | + */ |
|
1215 | + public static function display_persistent_admin_notices($pan_name = '', $pan_message = '', $return_url = '') |
|
1216 | + { |
|
1217 | + EE_Error::doing_it_wrong( |
|
1218 | + __METHOD__, |
|
1219 | + sprintf( |
|
1220 | + esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'), |
|
1221 | + '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
1222 | + ), |
|
1223 | + '4.9.27' |
|
1224 | + ); |
|
1225 | + } |
|
1226 | + |
|
1227 | + |
|
1228 | + /** |
|
1229 | + * @deprecated 4.9.27 |
|
1230 | + * @param string $return_url |
|
1231 | + */ |
|
1232 | + public static function get_persistent_admin_notices($return_url = '') |
|
1233 | + { |
|
1234 | + EE_Error::doing_it_wrong( |
|
1235 | + __METHOD__, |
|
1236 | + sprintf( |
|
1237 | + esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'), |
|
1238 | + '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
1239 | + ), |
|
1240 | + '4.9.27' |
|
1241 | + ); |
|
1242 | + } |
|
1243 | 1243 | } |
1244 | 1244 | |
1245 | 1245 | // end of Class EE_Exceptions |
@@ -1252,27 +1252,27 @@ discard block |
||
1252 | 1252 | */ |
1253 | 1253 | function espresso_error_enqueue_scripts() |
1254 | 1254 | { |
1255 | - // js for error handling |
|
1256 | - wp_register_script( |
|
1257 | - 'espresso_core', |
|
1258 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
1259 | - array('jquery'), |
|
1260 | - EVENT_ESPRESSO_VERSION, |
|
1261 | - false |
|
1262 | - ); |
|
1263 | - wp_register_script( |
|
1264 | - 'ee_error_js', |
|
1265 | - EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js', |
|
1266 | - array('espresso_core'), |
|
1267 | - EVENT_ESPRESSO_VERSION, |
|
1268 | - false |
|
1269 | - ); |
|
1255 | + // js for error handling |
|
1256 | + wp_register_script( |
|
1257 | + 'espresso_core', |
|
1258 | + EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
1259 | + array('jquery'), |
|
1260 | + EVENT_ESPRESSO_VERSION, |
|
1261 | + false |
|
1262 | + ); |
|
1263 | + wp_register_script( |
|
1264 | + 'ee_error_js', |
|
1265 | + EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js', |
|
1266 | + array('espresso_core'), |
|
1267 | + EVENT_ESPRESSO_VERSION, |
|
1268 | + false |
|
1269 | + ); |
|
1270 | 1270 | } |
1271 | 1271 | |
1272 | 1272 | if (is_admin()) { |
1273 | - add_action('admin_enqueue_scripts', 'espresso_error_enqueue_scripts', 5); |
|
1273 | + add_action('admin_enqueue_scripts', 'espresso_error_enqueue_scripts', 5); |
|
1274 | 1274 | } else { |
1275 | - add_action('wp_enqueue_scripts', 'espresso_error_enqueue_scripts', 5); |
|
1275 | + add_action('wp_enqueue_scripts', 'espresso_error_enqueue_scripts', 5); |
|
1276 | 1276 | } |
1277 | 1277 | |
1278 | 1278 |
@@ -100,14 +100,14 @@ discard block |
||
100 | 100 | default: |
101 | 101 | $to = get_option('admin_email'); |
102 | 102 | } |
103 | - $subject = $type . ' ' . $message . ' in ' . EVENT_ESPRESSO_VERSION . ' on ' . site_url(); |
|
103 | + $subject = $type.' '.$message.' in '.EVENT_ESPRESSO_VERSION.' on '.site_url(); |
|
104 | 104 | $msg = EE_Error::_format_error($type, $message, $file, $line); |
105 | 105 | if (function_exists('wp_mail')) { |
106 | 106 | add_filter('wp_mail_content_type', array('EE_Error', 'set_content_type')); |
107 | 107 | wp_mail($to, $subject, $msg); |
108 | 108 | } |
109 | 109 | echo '<div id="message" class="espresso-notices error"><p>'; |
110 | - echo $type . ': ' . $message . '<br />' . $file . ' line ' . $line; |
|
110 | + echo $type.': '.$message.'<br />'.$file.' line '.$line; |
|
111 | 111 | echo '<br /></p></div>'; |
112 | 112 | } |
113 | 113 | |
@@ -223,13 +223,13 @@ discard block |
||
223 | 223 | $msg = WP_DEBUG ? $dev_msg : $user_msg; |
224 | 224 | // add details to _all_exceptions array |
225 | 225 | $x_time = time(); |
226 | - self::$_all_exceptions[ $x_time ]['name'] = get_class($this); |
|
227 | - self::$_all_exceptions[ $x_time ]['file'] = $this->getFile(); |
|
228 | - self::$_all_exceptions[ $x_time ]['line'] = $this->getLine(); |
|
229 | - self::$_all_exceptions[ $x_time ]['msg'] = $msg; |
|
230 | - self::$_all_exceptions[ $x_time ]['code'] = $this->getCode(); |
|
231 | - self::$_all_exceptions[ $x_time ]['trace'] = $this->getTrace(); |
|
232 | - self::$_all_exceptions[ $x_time ]['string'] = $this->getTraceAsString(); |
|
226 | + self::$_all_exceptions[$x_time]['name'] = get_class($this); |
|
227 | + self::$_all_exceptions[$x_time]['file'] = $this->getFile(); |
|
228 | + self::$_all_exceptions[$x_time]['line'] = $this->getLine(); |
|
229 | + self::$_all_exceptions[$x_time]['msg'] = $msg; |
|
230 | + self::$_all_exceptions[$x_time]['code'] = $this->getCode(); |
|
231 | + self::$_all_exceptions[$x_time]['trace'] = $this->getTrace(); |
|
232 | + self::$_all_exceptions[$x_time]['string'] = $this->getTraceAsString(); |
|
233 | 233 | self::$_error_count++; |
234 | 234 | // add_action( 'shutdown', array( $this, 'display_errors' )); |
235 | 235 | $this->display_errors(); |
@@ -247,8 +247,8 @@ discard block |
||
247 | 247 | */ |
248 | 248 | public static function has_error($check_stored = false, $type_to_check = 'errors') |
249 | 249 | { |
250 | - $has_error = isset(self::$_espresso_notices[ $type_to_check ]) |
|
251 | - && ! empty(self::$_espresso_notices[ $type_to_check ]) |
|
250 | + $has_error = isset(self::$_espresso_notices[$type_to_check]) |
|
251 | + && ! empty(self::$_espresso_notices[$type_to_check]) |
|
252 | 252 | ? true |
253 | 253 | : false; |
254 | 254 | if ($check_stored && ! $has_error) { |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | } |
327 | 327 | </style> |
328 | 328 | <div id="ee-error-message" class="error">'; |
329 | - if (! WP_DEBUG) { |
|
329 | + if ( ! WP_DEBUG) { |
|
330 | 330 | $output .= ' |
331 | 331 | <p>'; |
332 | 332 | } |
@@ -385,14 +385,14 @@ discard block |
||
385 | 385 | $class_dsply = ! empty($class) ? $class : ' '; |
386 | 386 | $type_dsply = ! empty($type) ? $type : ' '; |
387 | 387 | $function_dsply = ! empty($function) ? $function : ' '; |
388 | - $args_dsply = ! empty($args) ? '( ' . $args . ' )' : ''; |
|
388 | + $args_dsply = ! empty($args) ? '( '.$args.' )' : ''; |
|
389 | 389 | $trace_details .= ' |
390 | 390 | <tr> |
391 | - <td align="right" class="' . $zebra . '">' . $nmbr_dsply . '</td> |
|
392 | - <td align="right" class="' . $zebra . '">' . $line_dsply . '</td> |
|
393 | - <td align="left" class="' . $zebra . '">' . $file_dsply . '</td> |
|
394 | - <td align="left" class="' . $zebra . '">' . $class_dsply . '</td> |
|
395 | - <td align="left" class="' . $zebra . '">' . $type_dsply . $function_dsply . $args_dsply . '</td> |
|
391 | + <td align="right" class="' . $zebra.'">'.$nmbr_dsply.'</td> |
|
392 | + <td align="right" class="' . $zebra.'">'.$line_dsply.'</td> |
|
393 | + <td align="left" class="' . $zebra.'">'.$file_dsply.'</td> |
|
394 | + <td align="left" class="' . $zebra.'">'.$class_dsply.'</td> |
|
395 | + <td align="left" class="' . $zebra.'">'.$type_dsply.$function_dsply.$args_dsply.'</td> |
|
396 | 396 | </tr>'; |
397 | 397 | } |
398 | 398 | $trace_details .= ' |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | } |
402 | 402 | $ex['code'] = $ex['code'] ? $ex['code'] : $error_code; |
403 | 403 | // add generic non-identifying messages for non-privileged users |
404 | - if (! WP_DEBUG) { |
|
404 | + if ( ! WP_DEBUG) { |
|
405 | 405 | $output .= '<span class="ee-error-user-msg-spn">' |
406 | 406 | . trim($ex['msg']) |
407 | 407 | . '</span> <sup>' |
@@ -443,14 +443,14 @@ discard block |
||
443 | 443 | . '-dv" class="ee-error-trace-dv" style="display: none;"> |
444 | 444 | ' |
445 | 445 | . $trace_details; |
446 | - if (! empty($class)) { |
|
446 | + if ( ! empty($class)) { |
|
447 | 447 | $output .= ' |
448 | 448 | <div style="padding:3px; margin:0 0 1em; border:1px solid #666; background:#fff; border-radius:3px;"> |
449 | 449 | <div style="padding:1em 2em; border:1px solid #666; background:#f9f9f9;"> |
450 | 450 | <h3>Class Details</h3>'; |
451 | 451 | $a = new ReflectionClass($class); |
452 | 452 | $output .= ' |
453 | - <pre>' . $a . '</pre> |
|
453 | + <pre>' . $a.'</pre> |
|
454 | 454 | </div> |
455 | 455 | </div>'; |
456 | 456 | } |
@@ -463,7 +463,7 @@ discard block |
||
463 | 463 | } |
464 | 464 | // remove last linebreak |
465 | 465 | $output = substr($output, 0, -6); |
466 | - if (! WP_DEBUG) { |
|
466 | + if ( ! WP_DEBUG) { |
|
467 | 467 | $output .= ' |
468 | 468 | </p>'; |
469 | 469 | } |
@@ -489,20 +489,20 @@ discard block |
||
489 | 489 | private function _convert_args_to_string($arguments = array(), $array = false) |
490 | 490 | { |
491 | 491 | $arg_string = ''; |
492 | - if (! empty($arguments)) { |
|
492 | + if ( ! empty($arguments)) { |
|
493 | 493 | $args = array(); |
494 | 494 | foreach ($arguments as $arg) { |
495 | - if (! empty($arg)) { |
|
495 | + if ( ! empty($arg)) { |
|
496 | 496 | if (is_string($arg)) { |
497 | - $args[] = " '" . $arg . "'"; |
|
497 | + $args[] = " '".$arg."'"; |
|
498 | 498 | } elseif (is_array($arg)) { |
499 | - $args[] = 'ARRAY(' . $this->_convert_args_to_string($arg, true); |
|
499 | + $args[] = 'ARRAY('.$this->_convert_args_to_string($arg, true); |
|
500 | 500 | } elseif ($arg === null) { |
501 | 501 | $args[] = ' NULL'; |
502 | 502 | } elseif (is_bool($arg)) { |
503 | 503 | $args[] = ($arg) ? ' TRUE' : ' FALSE'; |
504 | 504 | } elseif (is_object($arg)) { |
505 | - $args[] = ' OBJECT ' . get_class($arg); |
|
505 | + $args[] = ' OBJECT '.get_class($arg); |
|
506 | 506 | } elseif (is_resource($arg)) { |
507 | 507 | $args[] = get_resource_type($arg); |
508 | 508 | } else { |
@@ -600,7 +600,7 @@ discard block |
||
600 | 600 | { |
601 | 601 | if (empty($msg)) { |
602 | 602 | EE_Error::doing_it_wrong( |
603 | - 'EE_Error::add_' . $type . '()', |
|
603 | + 'EE_Error::add_'.$type.'()', |
|
604 | 604 | sprintf( |
605 | 605 | esc_html__( |
606 | 606 | 'Notifications are not much use without a message! Please add a message to the EE_Error::add_%s() call made in %s on line %d', |
@@ -640,17 +640,17 @@ discard block |
||
640 | 640 | do_action('AHEE__EE_Error___add_notice', $type, $user_msg, $dev_msg, $file, $func, $line); |
641 | 641 | $msg = WP_DEBUG ? $dev_msg : $user_msg; |
642 | 642 | // add notice if message exists |
643 | - if (! empty($msg)) { |
|
643 | + if ( ! empty($msg)) { |
|
644 | 644 | // get error code |
645 | 645 | $notice_code = EE_Error::generate_error_code($file, $func, $line); |
646 | 646 | if (WP_DEBUG && $type === 'errors') { |
647 | - $msg .= '<br/><span class="tiny-text">' . $notice_code . '</span>'; |
|
647 | + $msg .= '<br/><span class="tiny-text">'.$notice_code.'</span>'; |
|
648 | 648 | } |
649 | 649 | // add notice. Index by code if it's not blank |
650 | 650 | if ($notice_code) { |
651 | - self::$_espresso_notices[ $type ][ $notice_code ] = $msg; |
|
651 | + self::$_espresso_notices[$type][$notice_code] = $msg; |
|
652 | 652 | } else { |
653 | - self::$_espresso_notices[ $type ][] = $msg; |
|
653 | + self::$_espresso_notices[$type][] = $msg; |
|
654 | 654 | } |
655 | 655 | add_action('wp_footer', array('EE_Error', 'enqueue_error_scripts'), 1); |
656 | 656 | } |
@@ -884,7 +884,7 @@ discard block |
||
884 | 884 | ? esc_html__('The following errors have occurred:', 'event_espresso') |
885 | 885 | : esc_html__('An error has occurred:', 'event_espresso'); |
886 | 886 | // combine messages |
887 | - $error_messages .= '<br />' . implode('<br />', self::$_espresso_notices['errors']); |
|
887 | + $error_messages .= '<br />'.implode('<br />', self::$_espresso_notices['errors']); |
|
888 | 888 | $print_scripts = true; |
889 | 889 | } |
890 | 890 | if ($format_output) { |
@@ -903,7 +903,7 @@ discard block |
||
903 | 903 | // remove empty notices |
904 | 904 | foreach ($notices as $type => $notice) { |
905 | 905 | if (empty($notice)) { |
906 | - unset($notices[ $type ]); |
|
906 | + unset($notices[$type]); |
|
907 | 907 | } |
908 | 908 | } |
909 | 909 | } |
@@ -926,16 +926,16 @@ discard block |
||
926 | 926 | $print_scripts = false; |
927 | 927 | // grab any notices that have been previously saved |
928 | 928 | $notices = EE_Error::getStoredNotices(); |
929 | - if (! empty($notices)) { |
|
929 | + if ( ! empty($notices)) { |
|
930 | 930 | foreach ($notices as $type => $notice) { |
931 | 931 | if (is_array($notice) && ! empty($notice)) { |
932 | 932 | // make sure that existing notice type is an array |
933 | - self::$_espresso_notices[ $type ] = is_array(self::$_espresso_notices[ $type ]) |
|
934 | - && ! empty(self::$_espresso_notices[ $type ]) |
|
935 | - ? self::$_espresso_notices[ $type ] |
|
933 | + self::$_espresso_notices[$type] = is_array(self::$_espresso_notices[$type]) |
|
934 | + && ! empty(self::$_espresso_notices[$type]) |
|
935 | + ? self::$_espresso_notices[$type] |
|
936 | 936 | : array(); |
937 | 937 | // add newly created notices to existing ones |
938 | - self::$_espresso_notices[ $type ] += $notice; |
|
938 | + self::$_espresso_notices[$type] += $notice; |
|
939 | 939 | $print_scripts = true; |
940 | 940 | } |
941 | 941 | } |
@@ -962,10 +962,10 @@ discard block |
||
962 | 962 | $css_id = is_admin() ? 'ee-success-message' : 'espresso-notices-success'; |
963 | 963 | $css_class = is_admin() ? 'updated fade' : 'success fade-away'; |
964 | 964 | // showMessage( $success_messages ); |
965 | - $notices .= '<div id="' . $css_id . '" ' |
|
966 | - . 'class="espresso-notices ' . $css_class . '" ' |
|
965 | + $notices .= '<div id="'.$css_id.'" ' |
|
966 | + . 'class="espresso-notices '.$css_class.'" ' |
|
967 | 967 | . 'style="display:none;">' |
968 | - . '<p>' . $success_messages . '</p>' |
|
968 | + . '<p>'.$success_messages.'</p>' |
|
969 | 969 | . $close |
970 | 970 | . '</div>'; |
971 | 971 | } |
@@ -973,10 +973,10 @@ discard block |
||
973 | 973 | $css_id = is_admin() ? 'ee-attention-message' : 'espresso-notices-attention'; |
974 | 974 | $css_class = is_admin() ? 'updated ee-notices-attention' : 'attention fade-away'; |
975 | 975 | // showMessage( $error_messages, TRUE ); |
976 | - $notices .= '<div id="' . $css_id . '" ' |
|
977 | - . 'class="espresso-notices ' . $css_class . '" ' |
|
976 | + $notices .= '<div id="'.$css_id.'" ' |
|
977 | + . 'class="espresso-notices '.$css_class.'" ' |
|
978 | 978 | . 'style="display:none;">' |
979 | - . '<p>' . $attention_messages . '</p>' |
|
979 | + . '<p>'.$attention_messages.'</p>' |
|
980 | 980 | . $close |
981 | 981 | . '</div>'; |
982 | 982 | } |
@@ -984,10 +984,10 @@ discard block |
||
984 | 984 | $css_id = is_admin() ? 'ee-error-message' : 'espresso-notices-error'; |
985 | 985 | $css_class = is_admin() ? 'error' : 'error fade-away'; |
986 | 986 | // showMessage( $error_messages, TRUE ); |
987 | - $notices .= '<div id="' . $css_id . '" ' |
|
988 | - . 'class="espresso-notices ' . $css_class . '" ' |
|
987 | + $notices .= '<div id="'.$css_id.'" ' |
|
988 | + . 'class="espresso-notices '.$css_class.'" ' |
|
989 | 989 | . 'style="display:none;">' |
990 | - . '<p>' . $error_messages . '</p>' |
|
990 | + . '<p>'.$error_messages.'</p>' |
|
991 | 991 | . $close |
992 | 992 | . '</div>'; |
993 | 993 | } |
@@ -1004,7 +1004,7 @@ discard block |
||
1004 | 1004 | */ |
1005 | 1005 | private static function _print_scripts($force_print = false) |
1006 | 1006 | { |
1007 | - if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) { |
|
1007 | + if ( ! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) { |
|
1008 | 1008 | if (wp_script_is('ee_error_js', 'registered')) { |
1009 | 1009 | wp_enqueue_style('espresso_default'); |
1010 | 1010 | wp_enqueue_style('espresso_custom_css'); |
@@ -1018,12 +1018,12 @@ discard block |
||
1018 | 1018 | return ' |
1019 | 1019 | <script> |
1020 | 1020 | /* <![CDATA[ */ |
1021 | -var ee_settings = {"wp_debug":"' . WP_DEBUG . '"}; |
|
1021 | +var ee_settings = {"wp_debug":"' . WP_DEBUG.'"}; |
|
1022 | 1022 | /* ]]> */ |
1023 | 1023 | </script> |
1024 | -<script src="' . includes_url() . 'js/jquery/jquery.js" type="text/javascript"></script> |
|
1025 | -<script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script> |
|
1026 | -<script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script> |
|
1024 | +<script src="' . includes_url().'js/jquery/jquery.js" type="text/javascript"></script> |
|
1025 | +<script src="' . EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js'.'?ver='.espresso_version().'" type="text/javascript"></script> |
|
1026 | +<script src="' . EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js'.'?ver='.espresso_version().'" type="text/javascript"></script> |
|
1027 | 1027 | '; |
1028 | 1028 | } |
1029 | 1029 | return ''; |
@@ -1052,8 +1052,8 @@ discard block |
||
1052 | 1052 | { |
1053 | 1053 | $file = explode('.', basename($file)); |
1054 | 1054 | $error_code = ! empty($file[0]) ? $file[0] : ''; |
1055 | - $error_code .= ! empty($func) ? ' - ' . $func : ''; |
|
1056 | - $error_code .= ! empty($line) ? ' - ' . $line : ''; |
|
1055 | + $error_code .= ! empty($func) ? ' - '.$func : ''; |
|
1056 | + $error_code .= ! empty($line) ? ' - '.$line : ''; |
|
1057 | 1057 | return $error_code; |
1058 | 1058 | } |
1059 | 1059 | |
@@ -1072,18 +1072,18 @@ discard block |
||
1072 | 1072 | if (empty($ex)) { |
1073 | 1073 | return; |
1074 | 1074 | } |
1075 | - if (! $time) { |
|
1075 | + if ( ! $time) { |
|
1076 | 1076 | $time = time(); |
1077 | 1077 | } |
1078 | 1078 | $exception_log = '----------------------------------------------------------------------------------------' |
1079 | 1079 | . PHP_EOL; |
1080 | - $exception_log .= '[' . date('Y-m-d H:i:s', $time) . '] Exception Details' . PHP_EOL; |
|
1081 | - $exception_log .= 'Message: ' . $ex['msg'] . PHP_EOL; |
|
1082 | - $exception_log .= 'Code: ' . $ex['code'] . PHP_EOL; |
|
1083 | - $exception_log .= 'File: ' . $ex['file'] . PHP_EOL; |
|
1084 | - $exception_log .= 'Line No: ' . $ex['line'] . PHP_EOL; |
|
1085 | - $exception_log .= 'Stack trace: ' . PHP_EOL; |
|
1086 | - $exception_log .= $ex['string'] . PHP_EOL; |
|
1080 | + $exception_log .= '['.date('Y-m-d H:i:s', $time).'] Exception Details'.PHP_EOL; |
|
1081 | + $exception_log .= 'Message: '.$ex['msg'].PHP_EOL; |
|
1082 | + $exception_log .= 'Code: '.$ex['code'].PHP_EOL; |
|
1083 | + $exception_log .= 'File: '.$ex['file'].PHP_EOL; |
|
1084 | + $exception_log .= 'Line No: '.$ex['line'].PHP_EOL; |
|
1085 | + $exception_log .= 'Stack trace: '.PHP_EOL; |
|
1086 | + $exception_log .= $ex['string'].PHP_EOL; |
|
1087 | 1087 | $exception_log .= '----------------------------------------------------------------------------------------' |
1088 | 1088 | . PHP_EOL; |
1089 | 1089 | try { |
@@ -1255,14 +1255,14 @@ discard block |
||
1255 | 1255 | // js for error handling |
1256 | 1256 | wp_register_script( |
1257 | 1257 | 'espresso_core', |
1258 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
1258 | + EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', |
|
1259 | 1259 | array('jquery'), |
1260 | 1260 | EVENT_ESPRESSO_VERSION, |
1261 | 1261 | false |
1262 | 1262 | ); |
1263 | 1263 | wp_register_script( |
1264 | 1264 | 'ee_error_js', |
1265 | - EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js', |
|
1265 | + EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js', |
|
1266 | 1266 | array('espresso_core'), |
1267 | 1267 | EVENT_ESPRESSO_VERSION, |
1268 | 1268 | false |