@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | use EventEspresso\ui\browser\checkins\entities\CheckinStatusDashicon; |
4 | 4 | |
5 | 5 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
6 | - exit('NO direct script access allowed'); |
|
6 | + exit('NO direct script access allowed'); |
|
7 | 7 | } |
8 | 8 | |
9 | 9 | |
@@ -20,1186 +20,1186 @@ discard block |
||
20 | 20 | { |
21 | 21 | |
22 | 22 | |
23 | - /** |
|
24 | - * This is used to hold the reports template data which is setup early in the request. |
|
25 | - * |
|
26 | - * @type array |
|
27 | - */ |
|
28 | - protected $_reports_template_data = array(); |
|
29 | - |
|
30 | - |
|
31 | - |
|
32 | - /** |
|
33 | - * Extend_Registrations_Admin_Page constructor. |
|
34 | - * |
|
35 | - * @param bool $routing |
|
36 | - */ |
|
37 | - public function __construct($routing = true) |
|
38 | - { |
|
39 | - parent::__construct($routing); |
|
40 | - if ( ! defined('REG_CAF_TEMPLATE_PATH')) { |
|
41 | - define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/'); |
|
42 | - define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/'); |
|
43 | - define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/'); |
|
44 | - } |
|
45 | - } |
|
46 | - |
|
47 | - |
|
48 | - |
|
49 | - protected function _extend_page_config() |
|
50 | - { |
|
51 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations'; |
|
52 | - $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) |
|
53 | - ? $this->_req_data['_REG_ID'] |
|
54 | - : 0; |
|
55 | - // $att_id = ! empty( $this->_req_data['ATT_ID'] ) ? ! is_array( $this->_req_data['ATT_ID'] ) : 0; |
|
56 | - // $att_id = ! empty( $this->_req_data['post'] ) && ! is_array( $this->_req_data['post'] ) |
|
57 | - // ? $this->_req_data['post'] : $att_id; |
|
58 | - $new_page_routes = array( |
|
59 | - 'reports' => array( |
|
60 | - 'func' => '_registration_reports', |
|
61 | - 'capability' => 'ee_read_registrations', |
|
62 | - ), |
|
63 | - 'registration_checkins' => array( |
|
64 | - 'func' => '_registration_checkin_list_table', |
|
65 | - 'capability' => 'ee_read_checkins', |
|
66 | - ), |
|
67 | - 'newsletter_selected_send' => array( |
|
68 | - 'func' => '_newsletter_selected_send', |
|
69 | - 'noheader' => true, |
|
70 | - 'capability' => 'ee_send_message', |
|
71 | - ), |
|
72 | - 'delete_checkin_rows' => array( |
|
73 | - 'func' => '_delete_checkin_rows', |
|
74 | - 'noheader' => true, |
|
75 | - 'capability' => 'ee_delete_checkins', |
|
76 | - ), |
|
77 | - 'delete_checkin_row' => array( |
|
78 | - 'func' => '_delete_checkin_row', |
|
79 | - 'noheader' => true, |
|
80 | - 'capability' => 'ee_delete_checkin', |
|
81 | - 'obj_id' => $reg_id, |
|
82 | - ), |
|
83 | - 'toggle_checkin_status' => array( |
|
84 | - 'func' => '_toggle_checkin_status', |
|
85 | - 'noheader' => true, |
|
86 | - 'capability' => 'ee_edit_checkin', |
|
87 | - 'obj_id' => $reg_id, |
|
88 | - ), |
|
89 | - 'toggle_checkin_status_bulk' => array( |
|
90 | - 'func' => '_toggle_checkin_status', |
|
91 | - 'noheader' => true, |
|
92 | - 'capability' => 'ee_edit_checkins' |
|
93 | - ), |
|
94 | - 'event_registrations' => array( |
|
95 | - 'func' => '_event_registrations_list_table', |
|
96 | - 'capability' => 'ee_read_checkins', |
|
97 | - ), |
|
98 | - 'registrations_checkin_report' => array( |
|
99 | - 'func' => '_registrations_checkin_report', |
|
100 | - 'noheader' => true, |
|
101 | - 'capability' => 'ee_read_registrations', |
|
102 | - ), |
|
103 | - ); |
|
104 | - $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
105 | - $new_page_config = array( |
|
106 | - 'reports' => array( |
|
107 | - 'nav' => array( |
|
108 | - 'label' => __('Reports', 'event_espresso'), |
|
109 | - 'order' => 30, |
|
110 | - ), |
|
111 | - 'help_tabs' => array( |
|
112 | - 'registrations_reports_help_tab' => array( |
|
113 | - 'title' => __('Registration Reports', 'event_espresso'), |
|
114 | - 'filename' => 'registrations_reports', |
|
115 | - ), |
|
116 | - ), |
|
117 | - /*'help_tour' => array( 'Registration_Reports_Help_Tour' ),*/ |
|
118 | - 'require_nonce' => false, |
|
119 | - ), |
|
120 | - 'event_registrations' => array( |
|
121 | - 'nav' => array( |
|
122 | - 'label' => __('Event Check-In', 'event_espresso'), |
|
123 | - 'order' => 10, |
|
124 | - 'persistent' => true, |
|
125 | - ), |
|
126 | - 'help_tabs' => array( |
|
127 | - 'registrations_event_checkin_help_tab' => array( |
|
128 | - 'title' => __('Registrations Event Check-In', 'event_espresso'), |
|
129 | - 'filename' => 'registrations_event_checkin', |
|
130 | - ), |
|
131 | - 'registrations_event_checkin_table_column_headings_help_tab' => array( |
|
132 | - 'title' => __('Event Check-In Table Column Headings', 'event_espresso'), |
|
133 | - 'filename' => 'registrations_event_checkin_table_column_headings', |
|
134 | - ), |
|
135 | - 'registrations_event_checkin_filters_help_tab' => array( |
|
136 | - 'title' => __('Event Check-In Filters', 'event_espresso'), |
|
137 | - 'filename' => 'registrations_event_checkin_filters', |
|
138 | - ), |
|
139 | - 'registrations_event_checkin_views_help_tab' => array( |
|
140 | - 'title' => __('Event Check-In Views', 'event_espresso'), |
|
141 | - 'filename' => 'registrations_event_checkin_views', |
|
142 | - ), |
|
143 | - 'registrations_event_checkin_other_help_tab' => array( |
|
144 | - 'title' => __('Event Check-In Other', 'event_espresso'), |
|
145 | - 'filename' => 'registrations_event_checkin_other', |
|
146 | - ), |
|
147 | - ), |
|
148 | - 'help_tour' => array('Event_Checkin_Help_Tour'), |
|
149 | - 'qtips' => array('Registration_List_Table_Tips'), |
|
150 | - 'list_table' => 'EE_Event_Registrations_List_Table', |
|
151 | - 'metaboxes' => array(), |
|
152 | - 'require_nonce' => false, |
|
153 | - ), |
|
154 | - 'registration_checkins' => array( |
|
155 | - 'nav' => array( |
|
156 | - 'label' => __('Check-In Records', 'event_espresso'), |
|
157 | - 'order' => 15, |
|
158 | - 'persistent' => false, |
|
159 | - ), |
|
160 | - 'list_table' => 'EE_Registration_CheckIn_List_Table', |
|
161 | - //'help_tour' => array( 'Checkin_Toggle_View_Help_Tour' ), |
|
162 | - 'metaboxes' => array(), |
|
163 | - 'require_nonce' => false, |
|
164 | - ), |
|
165 | - ); |
|
166 | - $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
167 | - $this->_page_config['contact_list']['list_table'] = 'Extend_EE_Attendee_Contact_List_Table'; |
|
168 | - $this->_page_config['default']['list_table'] = 'Extend_EE_Registrations_List_Table'; |
|
169 | - } |
|
170 | - |
|
171 | - |
|
172 | - |
|
173 | - protected function _ajax_hooks() |
|
174 | - { |
|
175 | - parent::_ajax_hooks(); |
|
176 | - add_action('wp_ajax_get_newsletter_form_content', array($this, 'get_newsletter_form_content')); |
|
177 | - } |
|
178 | - |
|
179 | - |
|
180 | - |
|
181 | - public function load_scripts_styles() |
|
182 | - { |
|
183 | - parent::load_scripts_styles(); |
|
184 | - //if newsletter message type is active then let's add filter and load js for it. |
|
185 | - if (EEH_MSG_Template::is_mt_active('newsletter')) { |
|
186 | - //enqueue newsletter js |
|
187 | - wp_enqueue_script( |
|
188 | - 'ee-newsletter-trigger', |
|
189 | - REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js', |
|
190 | - array('ee-dialog'), |
|
191 | - EVENT_ESPRESSO_VERSION, |
|
192 | - true |
|
193 | - ); |
|
194 | - wp_enqueue_style( |
|
195 | - 'ee-newsletter-trigger-css', |
|
196 | - REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css', |
|
197 | - array(), |
|
198 | - EVENT_ESPRESSO_VERSION |
|
199 | - ); |
|
200 | - //hook in buttons for newsletter message type trigger. |
|
201 | - add_action( |
|
202 | - 'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', |
|
203 | - array($this, 'add_newsletter_action_buttons'), |
|
204 | - 10 |
|
205 | - ); |
|
206 | - } |
|
207 | - } |
|
208 | - |
|
209 | - |
|
210 | - |
|
211 | - public function load_scripts_styles_reports() |
|
212 | - { |
|
213 | - wp_register_script( |
|
214 | - 'ee-reg-reports-js', |
|
215 | - REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js', |
|
216 | - array('google-charts'), |
|
217 | - EVENT_ESPRESSO_VERSION, |
|
218 | - true |
|
219 | - ); |
|
220 | - wp_enqueue_script('ee-reg-reports-js'); |
|
221 | - $this->_registration_reports_js_setup(); |
|
222 | - } |
|
223 | - |
|
224 | - |
|
225 | - |
|
226 | - protected function _add_screen_options_event_registrations() |
|
227 | - { |
|
228 | - $this->_per_page_screen_option(); |
|
229 | - } |
|
230 | - |
|
231 | - |
|
232 | - |
|
233 | - protected function _add_screen_options_registration_checkins() |
|
234 | - { |
|
235 | - $page_title = $this->_admin_page_title; |
|
236 | - $this->_admin_page_title = __('Check-In Records', 'event_espresso'); |
|
237 | - $this->_per_page_screen_option(); |
|
238 | - $this->_admin_page_title = $page_title; |
|
239 | - } |
|
240 | - |
|
241 | - |
|
242 | - |
|
243 | - protected function _set_list_table_views_event_registrations() |
|
244 | - { |
|
245 | - $this->_views = array( |
|
246 | - 'all' => array( |
|
247 | - 'slug' => 'all', |
|
248 | - 'label' => __('All', 'event_espresso'), |
|
249 | - 'count' => 0, |
|
250 | - 'bulk_action' => ! isset($this->_req_data['event_id']) |
|
251 | - ? array() |
|
252 | - : array( |
|
253 | - 'toggle_checkin_status_bulk' => __('Toggle Check-In', 'event_espresso'), |
|
254 | - ), |
|
255 | - ), |
|
256 | - ); |
|
257 | - } |
|
258 | - |
|
259 | - |
|
260 | - |
|
261 | - protected function _set_list_table_views_registration_checkins() |
|
262 | - { |
|
263 | - $this->_views = array( |
|
264 | - 'all' => array( |
|
265 | - 'slug' => 'all', |
|
266 | - 'label' => __('All', 'event_espresso'), |
|
267 | - 'count' => 0, |
|
268 | - 'bulk_action' => array('delete_checkin_rows' => __('Delete Check-In Rows', 'event_espresso')), |
|
269 | - ), |
|
270 | - ); |
|
271 | - } |
|
272 | - |
|
273 | - |
|
274 | - |
|
275 | - /** |
|
276 | - * callback for ajax action. |
|
277 | - * |
|
278 | - * @since 4.3.0 |
|
279 | - * @return void (JSON) |
|
280 | - * @throws \EE_Error |
|
281 | - */ |
|
282 | - public function get_newsletter_form_content() |
|
283 | - { |
|
284 | - //do a nonce check cause we're not coming in from an normal route here. |
|
285 | - $nonce = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field( |
|
286 | - $this->_req_data['get_newsletter_form_content_nonce'] |
|
287 | - ) : ''; |
|
288 | - $nonce_ref = 'get_newsletter_form_content_nonce'; |
|
289 | - $this->_verify_nonce($nonce, $nonce_ref); |
|
290 | - //let's get the mtp for the incoming MTP_ ID |
|
291 | - if ( ! isset($this->_req_data['GRP_ID'])) { |
|
292 | - EE_Error::add_error( |
|
293 | - __( |
|
294 | - 'There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).', |
|
295 | - 'event_espresso' |
|
296 | - ), |
|
297 | - __FILE__, |
|
298 | - __FUNCTION__, |
|
299 | - __LINE__ |
|
300 | - ); |
|
301 | - $this->_template_args['success'] = false; |
|
302 | - $this->_template_args['error'] = true; |
|
303 | - $this->_return_json(); |
|
304 | - } |
|
305 | - $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']); |
|
306 | - if ( ! $MTPG instanceof EE_Message_Template_Group) { |
|
307 | - EE_Error::add_error( |
|
308 | - sprintf( |
|
309 | - __( |
|
310 | - 'The GRP_ID given (%d) does not appear to have a corresponding row in the database.', |
|
311 | - 'event_espresso' |
|
312 | - ), |
|
313 | - $this->_req_data['GRP_ID'] |
|
314 | - ), |
|
315 | - __FILE__, |
|
316 | - __FUNCTION__, |
|
317 | - __LINE__ |
|
318 | - ); |
|
319 | - $this->_template_args['success'] = false; |
|
320 | - $this->_template_args['error'] = true; |
|
321 | - $this->_return_json(); |
|
322 | - } |
|
323 | - $MTPs = $MTPG->context_templates(); |
|
324 | - $MTPs = $MTPs['attendee']; |
|
325 | - $template_fields = array(); |
|
326 | - /** @var EE_Message_Template $MTP */ |
|
327 | - foreach ($MTPs as $MTP) { |
|
328 | - $field = $MTP->get('MTP_template_field'); |
|
329 | - if ($field === 'content') { |
|
330 | - $content = $MTP->get('MTP_content'); |
|
331 | - if ( ! empty($content['newsletter_content'])) { |
|
332 | - $template_fields['newsletter_content'] = $content['newsletter_content']; |
|
333 | - } |
|
334 | - continue; |
|
335 | - } |
|
336 | - $template_fields[$MTP->get('MTP_template_field')] = $MTP->get('MTP_content'); |
|
337 | - } |
|
338 | - $this->_template_args['success'] = true; |
|
339 | - $this->_template_args['error'] = false; |
|
340 | - $this->_template_args['data'] = array( |
|
341 | - 'batch_message_from' => isset($template_fields['from']) |
|
342 | - ? $template_fields['from'] |
|
343 | - : '', |
|
344 | - 'batch_message_subject' => isset($template_fields['subject']) |
|
345 | - ? $template_fields['subject'] |
|
346 | - : '', |
|
347 | - 'batch_message_content' => isset($template_fields['newsletter_content']) |
|
348 | - ? $template_fields['newsletter_content'] |
|
349 | - : '', |
|
350 | - ); |
|
351 | - $this->_return_json(); |
|
352 | - } |
|
353 | - |
|
354 | - |
|
355 | - |
|
356 | - /** |
|
357 | - * callback for AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons action |
|
358 | - * |
|
359 | - * @since 4.3.0 |
|
360 | - * @param EE_Admin_List_Table $list_table |
|
361 | - * @return void |
|
362 | - */ |
|
363 | - public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table) |
|
364 | - { |
|
365 | - if ( ! EE_Registry::instance()->CAP->current_user_can( |
|
366 | - 'ee_send_message', |
|
367 | - 'espresso_registrations_newsletter_selected_send' |
|
368 | - ) |
|
369 | - ) { |
|
370 | - return; |
|
371 | - } |
|
372 | - $routes_to_add_to = array( |
|
373 | - 'contact_list', |
|
374 | - 'event_registrations', |
|
375 | - 'default', |
|
376 | - ); |
|
377 | - if ($this->_current_page === 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) { |
|
378 | - if (($this->_req_action === 'event_registrations' && empty($this->_req_data['event_id'])) |
|
379 | - || (isset($this->_req_data['status']) && $this->_req_data['status'] === 'trash') |
|
380 | - ) { |
|
381 | - echo ''; |
|
382 | - } else { |
|
383 | - $button_text = sprintf( |
|
384 | - __('Send Batch Message (%s selected)', 'event_espresso'), |
|
385 | - '<span class="send-selected-newsletter-count">0</span>' |
|
386 | - ); |
|
387 | - echo '<button id="selected-batch-send-trigger" class="button secondary-button"><span class="dashicons dashicons-email "></span>' |
|
388 | - . $button_text |
|
389 | - . '</button>'; |
|
390 | - add_action('admin_footer', array($this, 'newsletter_send_form_skeleton')); |
|
391 | - } |
|
392 | - } |
|
393 | - } |
|
394 | - |
|
395 | - |
|
396 | - |
|
397 | - public function newsletter_send_form_skeleton() |
|
398 | - { |
|
399 | - $list_table = $this->_list_table_object; |
|
400 | - $codes = array(); |
|
401 | - //need to templates for the newsletter message type for the template selector. |
|
402 | - $values[] = array('text' => __('Select Template to Use', 'event_espresso'), 'id' => 0); |
|
403 | - $mtps = EEM_Message_Template_Group::instance()->get_all( |
|
404 | - array(array('MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email')) |
|
405 | - ); |
|
406 | - foreach ($mtps as $mtp) { |
|
407 | - $name = $mtp->name(); |
|
408 | - $values[] = array( |
|
409 | - 'text' => empty($name) ? __('Global', 'event_espresso') : $name, |
|
410 | - 'id' => $mtp->ID(), |
|
411 | - ); |
|
412 | - } |
|
413 | - //need to get a list of shortcodes that are available for the newsletter message type. |
|
414 | - $shortcodes = EEH_MSG_Template::get_shortcodes('newsletter', 'email', array(), 'attendee', false); |
|
415 | - foreach ($shortcodes as $field => $shortcode_array) { |
|
416 | - $codes[$field] = implode(', ', array_keys($shortcode_array)); |
|
417 | - } |
|
418 | - $shortcodes = $codes; |
|
419 | - $form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php'; |
|
420 | - $form_template_args = array( |
|
421 | - 'form_action' => admin_url('admin.php?page=espresso_registrations'), |
|
422 | - 'form_route' => 'newsletter_selected_send', |
|
423 | - 'form_nonce_name' => 'newsletter_selected_send_nonce', |
|
424 | - 'form_nonce' => wp_create_nonce('newsletter_selected_send_nonce'), |
|
425 | - 'redirect_back_to' => $this->_req_action, |
|
426 | - 'ajax_nonce' => wp_create_nonce('get_newsletter_form_content_nonce'), |
|
427 | - 'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values), |
|
428 | - 'shortcodes' => $shortcodes, |
|
429 | - 'id_type' => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration', |
|
430 | - ); |
|
431 | - EEH_Template::display_template($form_template, $form_template_args); |
|
432 | - } |
|
433 | - |
|
434 | - |
|
435 | - |
|
436 | - /** |
|
437 | - * Handles sending selected registrations/contacts a newsletter. |
|
438 | - * |
|
439 | - * @since 4.3.0 |
|
440 | - * @return void |
|
441 | - * @throws \EE_Error |
|
442 | - */ |
|
443 | - protected function _newsletter_selected_send() |
|
444 | - { |
|
445 | - $success = true; |
|
446 | - //first we need to make sure we have a GRP_ID so we know what template we're sending and updating! |
|
447 | - if (empty($this->_req_data['newsletter_mtp_selected'])) { |
|
448 | - EE_Error::add_error( |
|
449 | - __( |
|
450 | - 'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.', |
|
451 | - 'event_espresso' |
|
452 | - ), |
|
453 | - __FILE__, |
|
454 | - __FUNCTION__, |
|
455 | - __LINE__ |
|
456 | - ); |
|
457 | - $success = false; |
|
458 | - } |
|
459 | - if ($success) { |
|
460 | - //update Message template in case there are any changes |
|
461 | - $Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID( |
|
462 | - $this->_req_data['newsletter_mtp_selected'] |
|
463 | - ); |
|
464 | - $Message_Templates = $Message_Template_Group instanceof EE_Message_Template_Group |
|
465 | - ? $Message_Template_Group->context_templates() |
|
466 | - : array(); |
|
467 | - if (empty($Message_Templates)) { |
|
468 | - EE_Error::add_error( |
|
469 | - __( |
|
470 | - 'Unable to retrieve message template fields from the db. Messages not sent.', |
|
471 | - 'event_espresso' |
|
472 | - ), |
|
473 | - __FILE__, |
|
474 | - __FUNCTION__, |
|
475 | - __LINE__ |
|
476 | - ); |
|
477 | - } |
|
478 | - //let's just update the specific fields |
|
479 | - foreach ($Message_Templates['attendee'] as $Message_Template) { |
|
480 | - if ($Message_Template instanceof EE_Message_Template) { |
|
481 | - $field = $Message_Template->get('MTP_template_field'); |
|
482 | - $content = $Message_Template->get('MTP_content'); |
|
483 | - $new_content = $content; |
|
484 | - switch ($field) { |
|
485 | - case 'from' : |
|
486 | - $new_content = ! empty($this->_req_data['batch_message']['from']) |
|
487 | - ? $this->_req_data['batch_message']['from'] |
|
488 | - : $content; |
|
489 | - break; |
|
490 | - case 'subject' : |
|
491 | - $new_content = ! empty($this->_req_data['batch_message']['subject']) |
|
492 | - ? $this->_req_data['batch_message']['subject'] |
|
493 | - : $content; |
|
494 | - break; |
|
495 | - case 'content' : |
|
496 | - $new_content = $content; |
|
497 | - $new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content']) |
|
498 | - ? $this->_req_data['batch_message']['content'] |
|
499 | - : $content['newsletter_content']; |
|
500 | - break; |
|
501 | - default : |
|
502 | - //continue the foreach loop, we don't want to set $new_content nor save. |
|
503 | - continue 2; |
|
504 | - } |
|
505 | - $Message_Template->set('MTP_content', $new_content); |
|
506 | - $Message_Template->save(); |
|
507 | - } |
|
508 | - } |
|
509 | - //great fields are updated! now let's make sure we just have contact objects (EE_Attendee). |
|
510 | - $id_type = ! empty($this->_req_data['batch_message']['id_type']) |
|
511 | - ? $this->_req_data['batch_message']['id_type'] |
|
512 | - : 'registration'; |
|
513 | - //id_type will affect how we assemble the ids. |
|
514 | - $ids = ! empty($this->_req_data['batch_message']['ids']) |
|
515 | - ? json_decode(stripslashes($this->_req_data['batch_message']['ids'])) |
|
516 | - : array(); |
|
517 | - $registrations_used_for_contact_data = array(); |
|
518 | - //using switch because eventually we'll have other contexts that will be used for generating messages. |
|
519 | - switch ($id_type) { |
|
520 | - case 'registration' : |
|
521 | - $registrations_used_for_contact_data = EEM_Registration::instance()->get_all( |
|
522 | - array( |
|
523 | - array( |
|
524 | - 'REG_ID' => array('IN', $ids), |
|
525 | - ), |
|
526 | - ) |
|
527 | - ); |
|
528 | - break; |
|
529 | - case 'contact' : |
|
530 | - $registrations_used_for_contact_data = EEM_Registration::instance() |
|
531 | - ->get_latest_registration_for_each_of_given_contacts($ids); |
|
532 | - break; |
|
533 | - } |
|
534 | - do_action_ref_array( |
|
535 | - 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations', |
|
536 | - array( |
|
537 | - $registrations_used_for_contact_data, |
|
538 | - $Message_Template_Group->ID() |
|
539 | - ) |
|
540 | - ); |
|
541 | - //kept for backward compat, internally we no longer use this action. |
|
542 | - //@deprecated 4.8.36.rc.002 |
|
543 | - $contacts = $id_type === 'registration' |
|
544 | - ? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids) |
|
545 | - : EEM_Attendee::instance()->get_all(array(array('ATT_ID' => array('in', $ids)))); |
|
546 | - do_action_ref_array( |
|
547 | - 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send', |
|
548 | - array( |
|
549 | - $contacts, |
|
550 | - $Message_Template_Group->ID() |
|
551 | - ) |
|
552 | - ); |
|
553 | - } |
|
554 | - $query_args = array( |
|
555 | - 'action' => ! empty($this->_req_data['redirect_back_to']) |
|
556 | - ? $this->_req_data['redirect_back_to'] |
|
557 | - : 'default', |
|
558 | - ); |
|
559 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
560 | - } |
|
561 | - |
|
562 | - |
|
563 | - |
|
564 | - /** |
|
565 | - * This is called when javascript is being enqueued to setup the various data needed for the reports js. |
|
566 | - * Also $this->{$_reports_template_data} property is set for later usage by the _registration_reports method. |
|
567 | - */ |
|
568 | - protected function _registration_reports_js_setup() |
|
569 | - { |
|
570 | - $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_day_report(); |
|
571 | - $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_event_report(); |
|
572 | - } |
|
573 | - |
|
574 | - |
|
575 | - |
|
576 | - /** |
|
577 | - * generates Business Reports regarding Registrations |
|
578 | - * |
|
579 | - * @access protected |
|
580 | - * @return void |
|
581 | - */ |
|
582 | - protected function _registration_reports() |
|
583 | - { |
|
584 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php'; |
|
585 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
586 | - $template_path, |
|
587 | - $this->_reports_template_data, |
|
588 | - true |
|
589 | - ); |
|
590 | - // the final template wrapper |
|
591 | - $this->display_admin_page_with_no_sidebar(); |
|
592 | - } |
|
593 | - |
|
594 | - |
|
595 | - |
|
596 | - /** |
|
597 | - * Generates Business Report showing total registrations per day. |
|
598 | - * |
|
599 | - * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
600 | - * @return string |
|
601 | - */ |
|
602 | - private function _registrations_per_day_report($period = '-1 month') |
|
603 | - { |
|
604 | - $report_ID = 'reg-admin-registrations-per-day-report-dv'; |
|
605 | - $results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period); |
|
606 | - $results = (array)$results; |
|
607 | - $regs = array(); |
|
608 | - $subtitle = ''; |
|
609 | - if ($results) { |
|
610 | - $column_titles = array(); |
|
611 | - $tracker = 0; |
|
612 | - foreach ($results as $result) { |
|
613 | - $report_column_values = array(); |
|
614 | - foreach ($result as $property_name => $property_value) { |
|
615 | - $property_value = $property_name === 'Registration_REG_date' ? $property_value |
|
616 | - : (int)$property_value; |
|
617 | - $report_column_values[] = $property_value; |
|
618 | - if ($tracker === 0) { |
|
619 | - if ($property_name === 'Registration_REG_date') { |
|
620 | - $column_titles[] = __('Date (only days with registrations are shown)', 'event_espresso'); |
|
621 | - } else { |
|
622 | - $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
623 | - } |
|
624 | - } |
|
625 | - } |
|
626 | - $tracker++; |
|
627 | - $regs[] = $report_column_values; |
|
628 | - } |
|
629 | - //make sure the column_titles is pushed to the beginning of the array |
|
630 | - array_unshift($regs, $column_titles); |
|
631 | - //setup the date range. |
|
632 | - $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
633 | - $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
634 | - $ending_date = new DateTime("now", $DateTimeZone); |
|
635 | - $subtitle = sprintf( |
|
636 | - _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'), |
|
637 | - $beginning_date->format('Y-m-d'), |
|
638 | - $ending_date->format('Y-m-d') |
|
639 | - ); |
|
640 | - } |
|
641 | - $report_title = __('Total Registrations per Day', 'event_espresso'); |
|
642 | - $report_params = array( |
|
643 | - 'title' => $report_title, |
|
644 | - 'subtitle' => $subtitle, |
|
645 | - 'id' => $report_ID, |
|
646 | - 'regs' => $regs, |
|
647 | - 'noResults' => empty($regs), |
|
648 | - 'noRegsMsg' => sprintf( |
|
649 | - __( |
|
650 | - '%sThere are currently no registration records in the last month for this report.%s', |
|
651 | - 'event_espresso' |
|
652 | - ), |
|
653 | - '<h2>' . $report_title . '</h2><p>', |
|
654 | - '</p>' |
|
655 | - ), |
|
656 | - ); |
|
657 | - wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params); |
|
658 | - return $report_ID; |
|
659 | - } |
|
660 | - |
|
661 | - |
|
662 | - |
|
663 | - /** |
|
664 | - * Generates Business Report showing total registrations per event. |
|
665 | - * |
|
666 | - * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
667 | - * @return string |
|
668 | - */ |
|
669 | - private function _registrations_per_event_report($period = '-1 month') |
|
670 | - { |
|
671 | - $report_ID = 'reg-admin-registrations-per-event-report-dv'; |
|
672 | - $results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period); |
|
673 | - $results = (array)$results; |
|
674 | - $regs = array(); |
|
675 | - $subtitle = ''; |
|
676 | - if ($results) { |
|
677 | - $column_titles = array(); |
|
678 | - $tracker = 0; |
|
679 | - foreach ($results as $result) { |
|
680 | - $report_column_values = array(); |
|
681 | - foreach ($result as $property_name => $property_value) { |
|
682 | - $property_value = $property_name === 'Registration_Event' ? wp_trim_words( |
|
683 | - $property_value, |
|
684 | - 4, |
|
685 | - '...' |
|
686 | - ) : (int)$property_value; |
|
687 | - $report_column_values[] = $property_value; |
|
688 | - if ($tracker === 0) { |
|
689 | - if ($property_name === 'Registration_Event') { |
|
690 | - $column_titles[] = __('Event', 'event_espresso'); |
|
691 | - } else { |
|
692 | - $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
693 | - } |
|
694 | - } |
|
695 | - } |
|
696 | - $tracker++; |
|
697 | - $regs[] = $report_column_values; |
|
698 | - } |
|
699 | - //make sure the column_titles is pushed to the beginning of the array |
|
700 | - array_unshift($regs, $column_titles); |
|
701 | - //setup the date range. |
|
702 | - $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
703 | - $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
704 | - $ending_date = new DateTime("now", $DateTimeZone); |
|
705 | - $subtitle = sprintf( |
|
706 | - _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'), |
|
707 | - $beginning_date->format('Y-m-d'), |
|
708 | - $ending_date->format('Y-m-d') |
|
709 | - ); |
|
710 | - } |
|
711 | - $report_title = __('Total Registrations per Event', 'event_espresso'); |
|
712 | - $report_params = array( |
|
713 | - 'title' => $report_title, |
|
714 | - 'subtitle' => $subtitle, |
|
715 | - 'id' => $report_ID, |
|
716 | - 'regs' => $regs, |
|
717 | - 'noResults' => empty($regs), |
|
718 | - 'noRegsMsg' => sprintf( |
|
719 | - __( |
|
720 | - '%sThere are currently no registration records in the last month for this report.%s', |
|
721 | - 'event_espresso' |
|
722 | - ), |
|
723 | - '<h2>' . $report_title . '</h2><p>', |
|
724 | - '</p>' |
|
725 | - ), |
|
726 | - ); |
|
727 | - wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params); |
|
728 | - return $report_ID; |
|
729 | - } |
|
730 | - |
|
731 | - |
|
732 | - |
|
733 | - /** |
|
734 | - * generates HTML for the Registration Check-in list table (showing all Check-ins for a specific registration) |
|
735 | - * |
|
736 | - * @access protected |
|
737 | - * @return void |
|
738 | - * @throws \EE_Error |
|
739 | - */ |
|
740 | - protected function _registration_checkin_list_table() |
|
741 | - { |
|
742 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
743 | - $reg_id = isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : null; |
|
744 | - /** @var EE_Registration $registration */ |
|
745 | - $registration = EEM_Registration::instance()->get_one_by_ID($reg_id); |
|
746 | - $attendee = $registration->attendee(); |
|
747 | - $this->_admin_page_title .= $this->get_action_link_or_button( |
|
748 | - 'new_registration', |
|
749 | - 'add-registrant', |
|
750 | - array('event_id' => $registration->event_ID()), |
|
751 | - 'add-new-h2' |
|
752 | - ); |
|
753 | - $checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in); |
|
754 | - $checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out); |
|
755 | - $legend_items = array( |
|
756 | - 'checkin' => array( |
|
757 | - 'class' => $checked_in->cssClasses(), |
|
758 | - 'desc' => $checked_in->legendLabel(), |
|
759 | - ), |
|
760 | - 'checkout' => array( |
|
761 | - 'class' => $checked_out->cssClasses(), |
|
762 | - 'desc' => $checked_out->legendLabel(), |
|
763 | - ), |
|
764 | - ); |
|
765 | - $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
766 | - $dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
|
767 | - /** @var EE_Datetime $datetime */ |
|
768 | - $datetime = EEM_Datetime::instance()->get_one_by_ID($dtt_id); |
|
769 | - $datetime_label = ''; |
|
770 | - if ($datetime instanceof EE_Datetime) { |
|
771 | - $datetime_label = $datetime->get_dtt_display_name(true); |
|
772 | - $datetime_label .= ! empty($datetime_label) |
|
773 | - ? ' (' . $datetime->get_dtt_display_name() . ')' |
|
774 | - : $datetime->get_dtt_display_name(); |
|
775 | - } |
|
776 | - $datetime_link = ! empty($dtt_id) && $registration instanceof EE_Registration |
|
777 | - ? EE_Admin_Page::add_query_args_and_nonce( |
|
778 | - array( |
|
779 | - 'action' => 'event_registrations', |
|
780 | - 'event_id' => $registration->event_ID(), |
|
781 | - 'DTT_ID' => $dtt_id, |
|
782 | - ), |
|
783 | - $this->_admin_base_url |
|
784 | - ) |
|
785 | - : ''; |
|
786 | - $datetime_link = ! empty($datetime_link) |
|
787 | - ? '<a href="' . $datetime_link . '">' |
|
788 | - . '<span id="checkin-dtt">' |
|
789 | - . $datetime_label |
|
790 | - . '</span></a>' |
|
791 | - : $datetime_label; |
|
792 | - $attendee_name = $attendee instanceof EE_Attendee |
|
793 | - ? $attendee->full_name() |
|
794 | - : ''; |
|
795 | - $attendee_link = $attendee instanceof EE_Attendee |
|
796 | - ? $attendee->get_admin_details_link() |
|
797 | - : ''; |
|
798 | - $attendee_link = ! empty($attendee_link) |
|
799 | - ? '<a href="' . $attendee->get_admin_details_link() . '"' |
|
800 | - . ' title="' . esc_html__('Click for attendee details', 'event_espresso') . '">' |
|
801 | - . '<span id="checkin-attendee-name">' |
|
802 | - . $attendee_name |
|
803 | - . '</span></a>' |
|
804 | - : ''; |
|
805 | - $event_link = $registration->event() instanceof EE_Event |
|
806 | - ? $registration->event()->get_admin_details_link() |
|
807 | - : ''; |
|
808 | - $event_link = ! empty($event_link) |
|
809 | - ? '<a href="' . $event_link . '"' |
|
810 | - . ' title="' . esc_html__('Click here to edit event.', 'event_espresso') . '">' |
|
811 | - . '<span id="checkin-event-name">' |
|
812 | - . $registration->event_name() |
|
813 | - . '</span>' |
|
814 | - . '</a>' |
|
815 | - : ''; |
|
816 | - $this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id) |
|
817 | - ? '<h2>' . sprintf( |
|
818 | - esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'), |
|
819 | - $attendee_link, |
|
820 | - $datetime_link, |
|
821 | - $event_link |
|
822 | - ) . '</h2>' |
|
823 | - : ''; |
|
824 | - $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id) |
|
825 | - ? '<input type="hidden" name="_REGID" value="' . $reg_id . '">' : ''; |
|
826 | - $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id) |
|
827 | - ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : ''; |
|
828 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
829 | - } |
|
830 | - |
|
831 | - |
|
832 | - |
|
833 | - /** |
|
834 | - * toggle the Check-in status for the given registration (coming from ajax) |
|
835 | - * |
|
836 | - * @return void (JSON) |
|
837 | - */ |
|
838 | - public function toggle_checkin_status() |
|
839 | - { |
|
840 | - //first make sure we have the necessary data |
|
841 | - if ( ! isset($this->_req_data['_regid'])) { |
|
842 | - EE_Error::add_error( |
|
843 | - __( |
|
844 | - 'There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax', |
|
845 | - 'event_espresso' |
|
846 | - ), |
|
847 | - __FILE__, |
|
848 | - __FUNCTION__, |
|
849 | - __LINE__ |
|
850 | - ); |
|
851 | - $this->_template_args['success'] = false; |
|
852 | - $this->_template_args['error'] = true; |
|
853 | - $this->_return_json(); |
|
854 | - }; |
|
855 | - //do a nonce check cause we're not coming in from an normal route here. |
|
856 | - $nonce = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce']) |
|
857 | - : ''; |
|
858 | - $nonce_ref = 'checkin_nonce'; |
|
859 | - $this->_verify_nonce($nonce, $nonce_ref); |
|
860 | - //beautiful! Made it this far so let's get the status. |
|
861 | - $new_status = new CheckinStatusDashicon($this->_toggle_checkin_status()); |
|
862 | - //setup new class to return via ajax |
|
863 | - $this->_template_args['admin_page_content'] = 'clickable trigger-checkin ' . $new_status->cssClasses(); |
|
864 | - $this->_template_args['success'] = true; |
|
865 | - $this->_return_json(); |
|
866 | - } |
|
867 | - |
|
868 | - |
|
869 | - |
|
870 | - /** |
|
871 | - * handles toggling the checkin status for the registration, |
|
872 | - * |
|
873 | - * @access protected |
|
874 | - * @return int|void |
|
875 | - */ |
|
876 | - protected function _toggle_checkin_status() |
|
877 | - { |
|
878 | - //first let's get the query args out of the way for the redirect |
|
879 | - $query_args = array( |
|
880 | - 'action' => 'event_registrations', |
|
881 | - 'event_id' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null, |
|
882 | - 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null, |
|
883 | - ); |
|
884 | - $new_status = false; |
|
885 | - // bulk action check in toggle |
|
886 | - if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
887 | - // cycle thru checkboxes |
|
888 | - while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) { |
|
889 | - $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
|
890 | - $new_status = $this->_toggle_checkin($REG_ID, $DTT_ID); |
|
891 | - } |
|
892 | - } elseif (isset($this->_req_data['_regid'])) { |
|
893 | - //coming from ajax request |
|
894 | - $DTT_ID = isset($this->_req_data['dttid']) ? $this->_req_data['dttid'] : null; |
|
895 | - $query_args['DTT_ID'] = $DTT_ID; |
|
896 | - $new_status = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID); |
|
897 | - } else { |
|
898 | - EE_Error::add_error( |
|
899 | - __('Missing some required data to toggle the Check-in', 'event_espresso'), |
|
900 | - __FILE__, |
|
901 | - __FUNCTION__, |
|
902 | - __LINE__ |
|
903 | - ); |
|
904 | - } |
|
905 | - if (defined('DOING_AJAX')) { |
|
906 | - return $new_status; |
|
907 | - } |
|
908 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
909 | - } |
|
910 | - |
|
911 | - |
|
912 | - |
|
913 | - /** |
|
914 | - * This is toggles a single Check-in for the given registration and datetime. |
|
915 | - * |
|
916 | - * @param int $REG_ID The registration we're toggling |
|
917 | - * @param int $DTT_ID The datetime we're toggling |
|
918 | - * @return int The new status toggled to. |
|
919 | - * @throws \EE_Error |
|
920 | - */ |
|
921 | - private function _toggle_checkin($REG_ID, $DTT_ID) |
|
922 | - { |
|
923 | - /** @var EE_Registration $REG */ |
|
924 | - $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
925 | - $new_status = $REG->toggle_checkin_status($DTT_ID); |
|
926 | - if ($new_status !== false) { |
|
927 | - EE_Error::add_success($REG->get_checkin_msg($DTT_ID)); |
|
928 | - } else { |
|
929 | - EE_Error::add_error($REG->get_checkin_msg($DTT_ID, true), __FILE__, __FUNCTION__, __LINE__); |
|
930 | - $new_status = false; |
|
931 | - } |
|
932 | - return $new_status; |
|
933 | - } |
|
934 | - |
|
935 | - |
|
936 | - |
|
937 | - /** |
|
938 | - * Takes care of deleting multiple EE_Checkin table rows |
|
939 | - * |
|
940 | - * @access protected |
|
941 | - * @return void |
|
942 | - * @throws \EE_Error |
|
943 | - */ |
|
944 | - protected function _delete_checkin_rows() |
|
945 | - { |
|
946 | - $query_args = array( |
|
947 | - 'action' => 'registration_checkins', |
|
948 | - 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
|
949 | - '_REGID' => isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : 0, |
|
950 | - ); |
|
951 | - $errors = 0; |
|
952 | - if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
953 | - while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) { |
|
954 | - if ( ! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) { |
|
955 | - $errors++; |
|
956 | - } |
|
957 | - } |
|
958 | - } else { |
|
959 | - EE_Error::add_error( |
|
960 | - __( |
|
961 | - 'So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!', |
|
962 | - 'event_espresso' |
|
963 | - ), |
|
964 | - __FILE__, |
|
965 | - __FUNCTION__, |
|
966 | - __LINE__ |
|
967 | - ); |
|
968 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
969 | - } |
|
970 | - if ($errors > 0) { |
|
971 | - EE_Error::add_error( |
|
972 | - sprintf(__('There were %d records that did not delete successfully', 'event_espresso'), $errors), |
|
973 | - __FILE__, |
|
974 | - __FUNCTION__, |
|
975 | - __LINE__ |
|
976 | - ); |
|
977 | - } else { |
|
978 | - EE_Error::add_success(__('Records were successfully deleted', 'event_espresso')); |
|
979 | - } |
|
980 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
981 | - } |
|
982 | - |
|
983 | - |
|
984 | - |
|
985 | - /** |
|
986 | - * Deletes a single EE_Checkin row |
|
987 | - * |
|
988 | - * @return void |
|
989 | - * @throws \EE_Error |
|
990 | - */ |
|
991 | - protected function _delete_checkin_row() |
|
992 | - { |
|
993 | - $query_args = array( |
|
994 | - 'action' => 'registration_checkins', |
|
995 | - 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
|
996 | - '_REGID' => isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : 0, |
|
997 | - ); |
|
998 | - if ( ! empty($this->_req_data['CHK_ID'])) { |
|
999 | - if ( ! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) { |
|
1000 | - EE_Error::add_error( |
|
1001 | - __('Something went wrong and this check-in record was not deleted', 'event_espresso'), |
|
1002 | - __FILE__, |
|
1003 | - __FUNCTION__, |
|
1004 | - __LINE__ |
|
1005 | - ); |
|
1006 | - } else { |
|
1007 | - EE_Error::add_success(__('Check-In record successfully deleted', 'event_espresso')); |
|
1008 | - } |
|
1009 | - } else { |
|
1010 | - EE_Error::add_error( |
|
1011 | - __( |
|
1012 | - 'In order to delete a Check-in record, there must be a Check-In ID available. There is not. It is not your fault, there is just a gremlin living in the code', |
|
1013 | - 'event_espresso' |
|
1014 | - ), |
|
1015 | - __FILE__, |
|
1016 | - __FUNCTION__, |
|
1017 | - __LINE__ |
|
1018 | - ); |
|
1019 | - } |
|
1020 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
1021 | - } |
|
1022 | - |
|
1023 | - |
|
1024 | - |
|
1025 | - /** |
|
1026 | - * generates HTML for the Event Registrations List Table |
|
1027 | - * |
|
1028 | - * @access protected |
|
1029 | - * @return void |
|
1030 | - * @throws \EE_Error |
|
1031 | - */ |
|
1032 | - protected function _event_registrations_list_table() |
|
1033 | - { |
|
1034 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1035 | - $this->_admin_page_title .= isset($this->_req_data['event_id']) |
|
1036 | - ? $this->get_action_link_or_button( |
|
1037 | - 'new_registration', |
|
1038 | - 'add-registrant', |
|
1039 | - array('event_id' => $this->_req_data['event_id']), |
|
1040 | - 'add-new-h2', |
|
1041 | - '', |
|
1042 | - false |
|
1043 | - ) |
|
1044 | - : ''; |
|
1045 | - $checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in); |
|
1046 | - $checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out); |
|
1047 | - $checked_never = new CheckinStatusDashicon(EE_Checkin::status_checked_never); |
|
1048 | - $legend_items = array( |
|
1049 | - 'star-icon' => array( |
|
1050 | - 'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8', |
|
1051 | - 'desc' => __('This Registrant is the Primary Registrant', 'event_espresso'), |
|
1052 | - ), |
|
1053 | - 'checkin' => array( |
|
1054 | - 'class' => $checked_in->cssClasses(), |
|
1055 | - 'desc' => $checked_in->legendLabel(), |
|
1056 | - ), |
|
1057 | - 'checkout' => array( |
|
1058 | - 'class' => $checked_out->cssClasses(), |
|
1059 | - 'desc' => $checked_out->legendLabel(), |
|
1060 | - ), |
|
1061 | - 'nocheckinrecord' => array( |
|
1062 | - 'class' => $checked_never->cssClasses(), |
|
1063 | - 'desc' => $checked_never->legendLabel(), |
|
1064 | - ), |
|
1065 | - 'view_details' => array( |
|
1066 | - 'class' => 'dashicons dashicons-search', |
|
1067 | - 'desc' => __('View All Check-in Records for this Registrant', 'event_espresso'), |
|
1068 | - ), |
|
1069 | - 'approved_status' => array( |
|
1070 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved, |
|
1071 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'), |
|
1072 | - ), |
|
1073 | - 'cancelled_status' => array( |
|
1074 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled, |
|
1075 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'), |
|
1076 | - ), |
|
1077 | - 'declined_status' => array( |
|
1078 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined, |
|
1079 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'), |
|
1080 | - ), |
|
1081 | - 'not_approved' => array( |
|
1082 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved, |
|
1083 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'), |
|
1084 | - ), |
|
1085 | - 'pending_status' => array( |
|
1086 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment, |
|
1087 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'), |
|
1088 | - ), |
|
1089 | - 'wait_list' => array( |
|
1090 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list, |
|
1091 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'), |
|
1092 | - ), |
|
1093 | - ); |
|
1094 | - $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
1095 | - $event_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null; |
|
1096 | - $this->_template_args['before_list_table'] = ! empty($event_id) |
|
1097 | - ? '<h2>' . sprintf( |
|
1098 | - __('Viewing Registrations for Event: %s', 'event_espresso'), |
|
1099 | - EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name') |
|
1100 | - ) . '</h2>' |
|
1101 | - : ''; |
|
1102 | - //need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on the event. |
|
1103 | - /** @var EE_Event $event */ |
|
1104 | - $event = EEM_Event::instance()->get_one_by_ID($event_id); |
|
1105 | - $DTT_ID = ! empty($this->_req_data['DTT_ID']) ? absint($this->_req_data['DTT_ID']) : 0; |
|
1106 | - $datetime = null; |
|
1107 | - if ($event instanceof EE_Event) { |
|
1108 | - $datetimes_on_event = $event->datetimes(); |
|
1109 | - if (count($datetimes_on_event) === 1) { |
|
1110 | - $datetime = reset($datetimes_on_event); |
|
1111 | - } |
|
1112 | - } |
|
1113 | - $datetime = $datetime instanceof EE_Datetime ? $datetime : EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
|
1114 | - if ($datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '') { |
|
1115 | - $this->_template_args['before_list_table'] = substr($this->_template_args['before_list_table'], 0, -5); |
|
1116 | - $this->_template_args['before_list_table'] .= ' <span class="drk-grey-text">'; |
|
1117 | - $this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar"></span>'; |
|
1118 | - $this->_template_args['before_list_table'] .= $datetime->name(); |
|
1119 | - $this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )'; |
|
1120 | - $this->_template_args['before_list_table'] .= '</span></h2>'; |
|
1121 | - } |
|
1122 | - //if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status column |
|
1123 | - //represents |
|
1124 | - if ( ! $datetime instanceof EE_Datetime) { |
|
1125 | - $this->_template_args['before_list_table'] .= '<br><p class="description">' |
|
1126 | - . __('In this view, the check-in status represents the latest check-in record for the registration in that row.', |
|
1127 | - 'event_espresso') |
|
1128 | - . '</p>'; |
|
1129 | - } |
|
1130 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
1131 | - } |
|
1132 | - |
|
1133 | - /** |
|
1134 | - * Download the registrations check-in report (same as the normal registration report, but with different where |
|
1135 | - * conditions) |
|
1136 | - * |
|
1137 | - * @return void ends the request by a redirect or download |
|
1138 | - */ |
|
1139 | - public function _registrations_checkin_report() |
|
1140 | - { |
|
1141 | - $this->_registrations_report_base('_get_checkin_query_params_from_request'); |
|
1142 | - } |
|
1143 | - |
|
1144 | - /** |
|
1145 | - * Gets the query params from the request, plus adds a where condition for the registration status, |
|
1146 | - * because on the checkin page we only ever want to see approved and pending-approval registrations |
|
1147 | - * |
|
1148 | - * @param array $request |
|
1149 | - * @param int $per_page |
|
1150 | - * @param bool $count |
|
1151 | - * @return array |
|
1152 | - */ |
|
1153 | - protected function _get_checkin_query_params_from_request( |
|
1154 | - $request, |
|
1155 | - $per_page = 10, |
|
1156 | - $count = false |
|
1157 | - ) { |
|
1158 | - $query_params = $this->_get_registration_query_parameters($request, $per_page, $count); |
|
1159 | - //unlike the regular registrations list table, |
|
1160 | - $status_ids_array = apply_filters( |
|
1161 | - 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', |
|
1162 | - array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved) |
|
1163 | - ); |
|
1164 | - $query_params[0]['STS_ID'] = array('IN', $status_ids_array); |
|
1165 | - return $query_params; |
|
1166 | - } |
|
1167 | - |
|
1168 | - |
|
1169 | - |
|
1170 | - |
|
1171 | - /** |
|
1172 | - * Gets registrations for an event |
|
1173 | - * |
|
1174 | - * @param int $per_page |
|
1175 | - * @param bool $count whether to return count or data. |
|
1176 | - * @param bool $trash |
|
1177 | - * @param string $orderby |
|
1178 | - * @return EE_Registration[]|int |
|
1179 | - * @throws \EE_Error |
|
1180 | - */ |
|
1181 | - public function get_event_attendees($per_page = 10, $count = false, $trash = false, $orderby = 'ATT_fname') |
|
1182 | - { |
|
1183 | - //normalize some request params that get setup by the parent `get_registrations` method. |
|
1184 | - $request = $this->_req_data; |
|
1185 | - $request['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : $orderby; |
|
1186 | - $request['order'] = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC'; |
|
1187 | - if($trash){ |
|
1188 | - $request['status'] = 'trash'; |
|
1189 | - } |
|
1190 | - $query_params = $this->_get_checkin_query_params_from_request( $request, $per_page, $count ); |
|
1191 | - /** |
|
1192 | - * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected |
|
1193 | - * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093 |
|
1194 | - * @see EEM_Base::get_all() |
|
1195 | - */ |
|
1196 | - $query_params['group_by'] = ''; |
|
1197 | - |
|
1198 | - return $count |
|
1199 | - ? EEM_Registration::instance()->count($query_params) |
|
1200 | - /** @type EE_Registration[] */ |
|
1201 | - : EEM_Registration::instance()->get_all($query_params); |
|
1202 | - } |
|
23 | + /** |
|
24 | + * This is used to hold the reports template data which is setup early in the request. |
|
25 | + * |
|
26 | + * @type array |
|
27 | + */ |
|
28 | + protected $_reports_template_data = array(); |
|
29 | + |
|
30 | + |
|
31 | + |
|
32 | + /** |
|
33 | + * Extend_Registrations_Admin_Page constructor. |
|
34 | + * |
|
35 | + * @param bool $routing |
|
36 | + */ |
|
37 | + public function __construct($routing = true) |
|
38 | + { |
|
39 | + parent::__construct($routing); |
|
40 | + if ( ! defined('REG_CAF_TEMPLATE_PATH')) { |
|
41 | + define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/'); |
|
42 | + define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/'); |
|
43 | + define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/'); |
|
44 | + } |
|
45 | + } |
|
46 | + |
|
47 | + |
|
48 | + |
|
49 | + protected function _extend_page_config() |
|
50 | + { |
|
51 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations'; |
|
52 | + $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) |
|
53 | + ? $this->_req_data['_REG_ID'] |
|
54 | + : 0; |
|
55 | + // $att_id = ! empty( $this->_req_data['ATT_ID'] ) ? ! is_array( $this->_req_data['ATT_ID'] ) : 0; |
|
56 | + // $att_id = ! empty( $this->_req_data['post'] ) && ! is_array( $this->_req_data['post'] ) |
|
57 | + // ? $this->_req_data['post'] : $att_id; |
|
58 | + $new_page_routes = array( |
|
59 | + 'reports' => array( |
|
60 | + 'func' => '_registration_reports', |
|
61 | + 'capability' => 'ee_read_registrations', |
|
62 | + ), |
|
63 | + 'registration_checkins' => array( |
|
64 | + 'func' => '_registration_checkin_list_table', |
|
65 | + 'capability' => 'ee_read_checkins', |
|
66 | + ), |
|
67 | + 'newsletter_selected_send' => array( |
|
68 | + 'func' => '_newsletter_selected_send', |
|
69 | + 'noheader' => true, |
|
70 | + 'capability' => 'ee_send_message', |
|
71 | + ), |
|
72 | + 'delete_checkin_rows' => array( |
|
73 | + 'func' => '_delete_checkin_rows', |
|
74 | + 'noheader' => true, |
|
75 | + 'capability' => 'ee_delete_checkins', |
|
76 | + ), |
|
77 | + 'delete_checkin_row' => array( |
|
78 | + 'func' => '_delete_checkin_row', |
|
79 | + 'noheader' => true, |
|
80 | + 'capability' => 'ee_delete_checkin', |
|
81 | + 'obj_id' => $reg_id, |
|
82 | + ), |
|
83 | + 'toggle_checkin_status' => array( |
|
84 | + 'func' => '_toggle_checkin_status', |
|
85 | + 'noheader' => true, |
|
86 | + 'capability' => 'ee_edit_checkin', |
|
87 | + 'obj_id' => $reg_id, |
|
88 | + ), |
|
89 | + 'toggle_checkin_status_bulk' => array( |
|
90 | + 'func' => '_toggle_checkin_status', |
|
91 | + 'noheader' => true, |
|
92 | + 'capability' => 'ee_edit_checkins' |
|
93 | + ), |
|
94 | + 'event_registrations' => array( |
|
95 | + 'func' => '_event_registrations_list_table', |
|
96 | + 'capability' => 'ee_read_checkins', |
|
97 | + ), |
|
98 | + 'registrations_checkin_report' => array( |
|
99 | + 'func' => '_registrations_checkin_report', |
|
100 | + 'noheader' => true, |
|
101 | + 'capability' => 'ee_read_registrations', |
|
102 | + ), |
|
103 | + ); |
|
104 | + $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
105 | + $new_page_config = array( |
|
106 | + 'reports' => array( |
|
107 | + 'nav' => array( |
|
108 | + 'label' => __('Reports', 'event_espresso'), |
|
109 | + 'order' => 30, |
|
110 | + ), |
|
111 | + 'help_tabs' => array( |
|
112 | + 'registrations_reports_help_tab' => array( |
|
113 | + 'title' => __('Registration Reports', 'event_espresso'), |
|
114 | + 'filename' => 'registrations_reports', |
|
115 | + ), |
|
116 | + ), |
|
117 | + /*'help_tour' => array( 'Registration_Reports_Help_Tour' ),*/ |
|
118 | + 'require_nonce' => false, |
|
119 | + ), |
|
120 | + 'event_registrations' => array( |
|
121 | + 'nav' => array( |
|
122 | + 'label' => __('Event Check-In', 'event_espresso'), |
|
123 | + 'order' => 10, |
|
124 | + 'persistent' => true, |
|
125 | + ), |
|
126 | + 'help_tabs' => array( |
|
127 | + 'registrations_event_checkin_help_tab' => array( |
|
128 | + 'title' => __('Registrations Event Check-In', 'event_espresso'), |
|
129 | + 'filename' => 'registrations_event_checkin', |
|
130 | + ), |
|
131 | + 'registrations_event_checkin_table_column_headings_help_tab' => array( |
|
132 | + 'title' => __('Event Check-In Table Column Headings', 'event_espresso'), |
|
133 | + 'filename' => 'registrations_event_checkin_table_column_headings', |
|
134 | + ), |
|
135 | + 'registrations_event_checkin_filters_help_tab' => array( |
|
136 | + 'title' => __('Event Check-In Filters', 'event_espresso'), |
|
137 | + 'filename' => 'registrations_event_checkin_filters', |
|
138 | + ), |
|
139 | + 'registrations_event_checkin_views_help_tab' => array( |
|
140 | + 'title' => __('Event Check-In Views', 'event_espresso'), |
|
141 | + 'filename' => 'registrations_event_checkin_views', |
|
142 | + ), |
|
143 | + 'registrations_event_checkin_other_help_tab' => array( |
|
144 | + 'title' => __('Event Check-In Other', 'event_espresso'), |
|
145 | + 'filename' => 'registrations_event_checkin_other', |
|
146 | + ), |
|
147 | + ), |
|
148 | + 'help_tour' => array('Event_Checkin_Help_Tour'), |
|
149 | + 'qtips' => array('Registration_List_Table_Tips'), |
|
150 | + 'list_table' => 'EE_Event_Registrations_List_Table', |
|
151 | + 'metaboxes' => array(), |
|
152 | + 'require_nonce' => false, |
|
153 | + ), |
|
154 | + 'registration_checkins' => array( |
|
155 | + 'nav' => array( |
|
156 | + 'label' => __('Check-In Records', 'event_espresso'), |
|
157 | + 'order' => 15, |
|
158 | + 'persistent' => false, |
|
159 | + ), |
|
160 | + 'list_table' => 'EE_Registration_CheckIn_List_Table', |
|
161 | + //'help_tour' => array( 'Checkin_Toggle_View_Help_Tour' ), |
|
162 | + 'metaboxes' => array(), |
|
163 | + 'require_nonce' => false, |
|
164 | + ), |
|
165 | + ); |
|
166 | + $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
167 | + $this->_page_config['contact_list']['list_table'] = 'Extend_EE_Attendee_Contact_List_Table'; |
|
168 | + $this->_page_config['default']['list_table'] = 'Extend_EE_Registrations_List_Table'; |
|
169 | + } |
|
170 | + |
|
171 | + |
|
172 | + |
|
173 | + protected function _ajax_hooks() |
|
174 | + { |
|
175 | + parent::_ajax_hooks(); |
|
176 | + add_action('wp_ajax_get_newsletter_form_content', array($this, 'get_newsletter_form_content')); |
|
177 | + } |
|
178 | + |
|
179 | + |
|
180 | + |
|
181 | + public function load_scripts_styles() |
|
182 | + { |
|
183 | + parent::load_scripts_styles(); |
|
184 | + //if newsletter message type is active then let's add filter and load js for it. |
|
185 | + if (EEH_MSG_Template::is_mt_active('newsletter')) { |
|
186 | + //enqueue newsletter js |
|
187 | + wp_enqueue_script( |
|
188 | + 'ee-newsletter-trigger', |
|
189 | + REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js', |
|
190 | + array('ee-dialog'), |
|
191 | + EVENT_ESPRESSO_VERSION, |
|
192 | + true |
|
193 | + ); |
|
194 | + wp_enqueue_style( |
|
195 | + 'ee-newsletter-trigger-css', |
|
196 | + REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css', |
|
197 | + array(), |
|
198 | + EVENT_ESPRESSO_VERSION |
|
199 | + ); |
|
200 | + //hook in buttons for newsletter message type trigger. |
|
201 | + add_action( |
|
202 | + 'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', |
|
203 | + array($this, 'add_newsletter_action_buttons'), |
|
204 | + 10 |
|
205 | + ); |
|
206 | + } |
|
207 | + } |
|
208 | + |
|
209 | + |
|
210 | + |
|
211 | + public function load_scripts_styles_reports() |
|
212 | + { |
|
213 | + wp_register_script( |
|
214 | + 'ee-reg-reports-js', |
|
215 | + REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js', |
|
216 | + array('google-charts'), |
|
217 | + EVENT_ESPRESSO_VERSION, |
|
218 | + true |
|
219 | + ); |
|
220 | + wp_enqueue_script('ee-reg-reports-js'); |
|
221 | + $this->_registration_reports_js_setup(); |
|
222 | + } |
|
223 | + |
|
224 | + |
|
225 | + |
|
226 | + protected function _add_screen_options_event_registrations() |
|
227 | + { |
|
228 | + $this->_per_page_screen_option(); |
|
229 | + } |
|
230 | + |
|
231 | + |
|
232 | + |
|
233 | + protected function _add_screen_options_registration_checkins() |
|
234 | + { |
|
235 | + $page_title = $this->_admin_page_title; |
|
236 | + $this->_admin_page_title = __('Check-In Records', 'event_espresso'); |
|
237 | + $this->_per_page_screen_option(); |
|
238 | + $this->_admin_page_title = $page_title; |
|
239 | + } |
|
240 | + |
|
241 | + |
|
242 | + |
|
243 | + protected function _set_list_table_views_event_registrations() |
|
244 | + { |
|
245 | + $this->_views = array( |
|
246 | + 'all' => array( |
|
247 | + 'slug' => 'all', |
|
248 | + 'label' => __('All', 'event_espresso'), |
|
249 | + 'count' => 0, |
|
250 | + 'bulk_action' => ! isset($this->_req_data['event_id']) |
|
251 | + ? array() |
|
252 | + : array( |
|
253 | + 'toggle_checkin_status_bulk' => __('Toggle Check-In', 'event_espresso'), |
|
254 | + ), |
|
255 | + ), |
|
256 | + ); |
|
257 | + } |
|
258 | + |
|
259 | + |
|
260 | + |
|
261 | + protected function _set_list_table_views_registration_checkins() |
|
262 | + { |
|
263 | + $this->_views = array( |
|
264 | + 'all' => array( |
|
265 | + 'slug' => 'all', |
|
266 | + 'label' => __('All', 'event_espresso'), |
|
267 | + 'count' => 0, |
|
268 | + 'bulk_action' => array('delete_checkin_rows' => __('Delete Check-In Rows', 'event_espresso')), |
|
269 | + ), |
|
270 | + ); |
|
271 | + } |
|
272 | + |
|
273 | + |
|
274 | + |
|
275 | + /** |
|
276 | + * callback for ajax action. |
|
277 | + * |
|
278 | + * @since 4.3.0 |
|
279 | + * @return void (JSON) |
|
280 | + * @throws \EE_Error |
|
281 | + */ |
|
282 | + public function get_newsletter_form_content() |
|
283 | + { |
|
284 | + //do a nonce check cause we're not coming in from an normal route here. |
|
285 | + $nonce = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field( |
|
286 | + $this->_req_data['get_newsletter_form_content_nonce'] |
|
287 | + ) : ''; |
|
288 | + $nonce_ref = 'get_newsletter_form_content_nonce'; |
|
289 | + $this->_verify_nonce($nonce, $nonce_ref); |
|
290 | + //let's get the mtp for the incoming MTP_ ID |
|
291 | + if ( ! isset($this->_req_data['GRP_ID'])) { |
|
292 | + EE_Error::add_error( |
|
293 | + __( |
|
294 | + 'There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).', |
|
295 | + 'event_espresso' |
|
296 | + ), |
|
297 | + __FILE__, |
|
298 | + __FUNCTION__, |
|
299 | + __LINE__ |
|
300 | + ); |
|
301 | + $this->_template_args['success'] = false; |
|
302 | + $this->_template_args['error'] = true; |
|
303 | + $this->_return_json(); |
|
304 | + } |
|
305 | + $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']); |
|
306 | + if ( ! $MTPG instanceof EE_Message_Template_Group) { |
|
307 | + EE_Error::add_error( |
|
308 | + sprintf( |
|
309 | + __( |
|
310 | + 'The GRP_ID given (%d) does not appear to have a corresponding row in the database.', |
|
311 | + 'event_espresso' |
|
312 | + ), |
|
313 | + $this->_req_data['GRP_ID'] |
|
314 | + ), |
|
315 | + __FILE__, |
|
316 | + __FUNCTION__, |
|
317 | + __LINE__ |
|
318 | + ); |
|
319 | + $this->_template_args['success'] = false; |
|
320 | + $this->_template_args['error'] = true; |
|
321 | + $this->_return_json(); |
|
322 | + } |
|
323 | + $MTPs = $MTPG->context_templates(); |
|
324 | + $MTPs = $MTPs['attendee']; |
|
325 | + $template_fields = array(); |
|
326 | + /** @var EE_Message_Template $MTP */ |
|
327 | + foreach ($MTPs as $MTP) { |
|
328 | + $field = $MTP->get('MTP_template_field'); |
|
329 | + if ($field === 'content') { |
|
330 | + $content = $MTP->get('MTP_content'); |
|
331 | + if ( ! empty($content['newsletter_content'])) { |
|
332 | + $template_fields['newsletter_content'] = $content['newsletter_content']; |
|
333 | + } |
|
334 | + continue; |
|
335 | + } |
|
336 | + $template_fields[$MTP->get('MTP_template_field')] = $MTP->get('MTP_content'); |
|
337 | + } |
|
338 | + $this->_template_args['success'] = true; |
|
339 | + $this->_template_args['error'] = false; |
|
340 | + $this->_template_args['data'] = array( |
|
341 | + 'batch_message_from' => isset($template_fields['from']) |
|
342 | + ? $template_fields['from'] |
|
343 | + : '', |
|
344 | + 'batch_message_subject' => isset($template_fields['subject']) |
|
345 | + ? $template_fields['subject'] |
|
346 | + : '', |
|
347 | + 'batch_message_content' => isset($template_fields['newsletter_content']) |
|
348 | + ? $template_fields['newsletter_content'] |
|
349 | + : '', |
|
350 | + ); |
|
351 | + $this->_return_json(); |
|
352 | + } |
|
353 | + |
|
354 | + |
|
355 | + |
|
356 | + /** |
|
357 | + * callback for AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons action |
|
358 | + * |
|
359 | + * @since 4.3.0 |
|
360 | + * @param EE_Admin_List_Table $list_table |
|
361 | + * @return void |
|
362 | + */ |
|
363 | + public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table) |
|
364 | + { |
|
365 | + if ( ! EE_Registry::instance()->CAP->current_user_can( |
|
366 | + 'ee_send_message', |
|
367 | + 'espresso_registrations_newsletter_selected_send' |
|
368 | + ) |
|
369 | + ) { |
|
370 | + return; |
|
371 | + } |
|
372 | + $routes_to_add_to = array( |
|
373 | + 'contact_list', |
|
374 | + 'event_registrations', |
|
375 | + 'default', |
|
376 | + ); |
|
377 | + if ($this->_current_page === 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) { |
|
378 | + if (($this->_req_action === 'event_registrations' && empty($this->_req_data['event_id'])) |
|
379 | + || (isset($this->_req_data['status']) && $this->_req_data['status'] === 'trash') |
|
380 | + ) { |
|
381 | + echo ''; |
|
382 | + } else { |
|
383 | + $button_text = sprintf( |
|
384 | + __('Send Batch Message (%s selected)', 'event_espresso'), |
|
385 | + '<span class="send-selected-newsletter-count">0</span>' |
|
386 | + ); |
|
387 | + echo '<button id="selected-batch-send-trigger" class="button secondary-button"><span class="dashicons dashicons-email "></span>' |
|
388 | + . $button_text |
|
389 | + . '</button>'; |
|
390 | + add_action('admin_footer', array($this, 'newsletter_send_form_skeleton')); |
|
391 | + } |
|
392 | + } |
|
393 | + } |
|
394 | + |
|
395 | + |
|
396 | + |
|
397 | + public function newsletter_send_form_skeleton() |
|
398 | + { |
|
399 | + $list_table = $this->_list_table_object; |
|
400 | + $codes = array(); |
|
401 | + //need to templates for the newsletter message type for the template selector. |
|
402 | + $values[] = array('text' => __('Select Template to Use', 'event_espresso'), 'id' => 0); |
|
403 | + $mtps = EEM_Message_Template_Group::instance()->get_all( |
|
404 | + array(array('MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email')) |
|
405 | + ); |
|
406 | + foreach ($mtps as $mtp) { |
|
407 | + $name = $mtp->name(); |
|
408 | + $values[] = array( |
|
409 | + 'text' => empty($name) ? __('Global', 'event_espresso') : $name, |
|
410 | + 'id' => $mtp->ID(), |
|
411 | + ); |
|
412 | + } |
|
413 | + //need to get a list of shortcodes that are available for the newsletter message type. |
|
414 | + $shortcodes = EEH_MSG_Template::get_shortcodes('newsletter', 'email', array(), 'attendee', false); |
|
415 | + foreach ($shortcodes as $field => $shortcode_array) { |
|
416 | + $codes[$field] = implode(', ', array_keys($shortcode_array)); |
|
417 | + } |
|
418 | + $shortcodes = $codes; |
|
419 | + $form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php'; |
|
420 | + $form_template_args = array( |
|
421 | + 'form_action' => admin_url('admin.php?page=espresso_registrations'), |
|
422 | + 'form_route' => 'newsletter_selected_send', |
|
423 | + 'form_nonce_name' => 'newsletter_selected_send_nonce', |
|
424 | + 'form_nonce' => wp_create_nonce('newsletter_selected_send_nonce'), |
|
425 | + 'redirect_back_to' => $this->_req_action, |
|
426 | + 'ajax_nonce' => wp_create_nonce('get_newsletter_form_content_nonce'), |
|
427 | + 'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values), |
|
428 | + 'shortcodes' => $shortcodes, |
|
429 | + 'id_type' => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration', |
|
430 | + ); |
|
431 | + EEH_Template::display_template($form_template, $form_template_args); |
|
432 | + } |
|
433 | + |
|
434 | + |
|
435 | + |
|
436 | + /** |
|
437 | + * Handles sending selected registrations/contacts a newsletter. |
|
438 | + * |
|
439 | + * @since 4.3.0 |
|
440 | + * @return void |
|
441 | + * @throws \EE_Error |
|
442 | + */ |
|
443 | + protected function _newsletter_selected_send() |
|
444 | + { |
|
445 | + $success = true; |
|
446 | + //first we need to make sure we have a GRP_ID so we know what template we're sending and updating! |
|
447 | + if (empty($this->_req_data['newsletter_mtp_selected'])) { |
|
448 | + EE_Error::add_error( |
|
449 | + __( |
|
450 | + 'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.', |
|
451 | + 'event_espresso' |
|
452 | + ), |
|
453 | + __FILE__, |
|
454 | + __FUNCTION__, |
|
455 | + __LINE__ |
|
456 | + ); |
|
457 | + $success = false; |
|
458 | + } |
|
459 | + if ($success) { |
|
460 | + //update Message template in case there are any changes |
|
461 | + $Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID( |
|
462 | + $this->_req_data['newsletter_mtp_selected'] |
|
463 | + ); |
|
464 | + $Message_Templates = $Message_Template_Group instanceof EE_Message_Template_Group |
|
465 | + ? $Message_Template_Group->context_templates() |
|
466 | + : array(); |
|
467 | + if (empty($Message_Templates)) { |
|
468 | + EE_Error::add_error( |
|
469 | + __( |
|
470 | + 'Unable to retrieve message template fields from the db. Messages not sent.', |
|
471 | + 'event_espresso' |
|
472 | + ), |
|
473 | + __FILE__, |
|
474 | + __FUNCTION__, |
|
475 | + __LINE__ |
|
476 | + ); |
|
477 | + } |
|
478 | + //let's just update the specific fields |
|
479 | + foreach ($Message_Templates['attendee'] as $Message_Template) { |
|
480 | + if ($Message_Template instanceof EE_Message_Template) { |
|
481 | + $field = $Message_Template->get('MTP_template_field'); |
|
482 | + $content = $Message_Template->get('MTP_content'); |
|
483 | + $new_content = $content; |
|
484 | + switch ($field) { |
|
485 | + case 'from' : |
|
486 | + $new_content = ! empty($this->_req_data['batch_message']['from']) |
|
487 | + ? $this->_req_data['batch_message']['from'] |
|
488 | + : $content; |
|
489 | + break; |
|
490 | + case 'subject' : |
|
491 | + $new_content = ! empty($this->_req_data['batch_message']['subject']) |
|
492 | + ? $this->_req_data['batch_message']['subject'] |
|
493 | + : $content; |
|
494 | + break; |
|
495 | + case 'content' : |
|
496 | + $new_content = $content; |
|
497 | + $new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content']) |
|
498 | + ? $this->_req_data['batch_message']['content'] |
|
499 | + : $content['newsletter_content']; |
|
500 | + break; |
|
501 | + default : |
|
502 | + //continue the foreach loop, we don't want to set $new_content nor save. |
|
503 | + continue 2; |
|
504 | + } |
|
505 | + $Message_Template->set('MTP_content', $new_content); |
|
506 | + $Message_Template->save(); |
|
507 | + } |
|
508 | + } |
|
509 | + //great fields are updated! now let's make sure we just have contact objects (EE_Attendee). |
|
510 | + $id_type = ! empty($this->_req_data['batch_message']['id_type']) |
|
511 | + ? $this->_req_data['batch_message']['id_type'] |
|
512 | + : 'registration'; |
|
513 | + //id_type will affect how we assemble the ids. |
|
514 | + $ids = ! empty($this->_req_data['batch_message']['ids']) |
|
515 | + ? json_decode(stripslashes($this->_req_data['batch_message']['ids'])) |
|
516 | + : array(); |
|
517 | + $registrations_used_for_contact_data = array(); |
|
518 | + //using switch because eventually we'll have other contexts that will be used for generating messages. |
|
519 | + switch ($id_type) { |
|
520 | + case 'registration' : |
|
521 | + $registrations_used_for_contact_data = EEM_Registration::instance()->get_all( |
|
522 | + array( |
|
523 | + array( |
|
524 | + 'REG_ID' => array('IN', $ids), |
|
525 | + ), |
|
526 | + ) |
|
527 | + ); |
|
528 | + break; |
|
529 | + case 'contact' : |
|
530 | + $registrations_used_for_contact_data = EEM_Registration::instance() |
|
531 | + ->get_latest_registration_for_each_of_given_contacts($ids); |
|
532 | + break; |
|
533 | + } |
|
534 | + do_action_ref_array( |
|
535 | + 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations', |
|
536 | + array( |
|
537 | + $registrations_used_for_contact_data, |
|
538 | + $Message_Template_Group->ID() |
|
539 | + ) |
|
540 | + ); |
|
541 | + //kept for backward compat, internally we no longer use this action. |
|
542 | + //@deprecated 4.8.36.rc.002 |
|
543 | + $contacts = $id_type === 'registration' |
|
544 | + ? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids) |
|
545 | + : EEM_Attendee::instance()->get_all(array(array('ATT_ID' => array('in', $ids)))); |
|
546 | + do_action_ref_array( |
|
547 | + 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send', |
|
548 | + array( |
|
549 | + $contacts, |
|
550 | + $Message_Template_Group->ID() |
|
551 | + ) |
|
552 | + ); |
|
553 | + } |
|
554 | + $query_args = array( |
|
555 | + 'action' => ! empty($this->_req_data['redirect_back_to']) |
|
556 | + ? $this->_req_data['redirect_back_to'] |
|
557 | + : 'default', |
|
558 | + ); |
|
559 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
560 | + } |
|
561 | + |
|
562 | + |
|
563 | + |
|
564 | + /** |
|
565 | + * This is called when javascript is being enqueued to setup the various data needed for the reports js. |
|
566 | + * Also $this->{$_reports_template_data} property is set for later usage by the _registration_reports method. |
|
567 | + */ |
|
568 | + protected function _registration_reports_js_setup() |
|
569 | + { |
|
570 | + $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_day_report(); |
|
571 | + $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_event_report(); |
|
572 | + } |
|
573 | + |
|
574 | + |
|
575 | + |
|
576 | + /** |
|
577 | + * generates Business Reports regarding Registrations |
|
578 | + * |
|
579 | + * @access protected |
|
580 | + * @return void |
|
581 | + */ |
|
582 | + protected function _registration_reports() |
|
583 | + { |
|
584 | + $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php'; |
|
585 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
586 | + $template_path, |
|
587 | + $this->_reports_template_data, |
|
588 | + true |
|
589 | + ); |
|
590 | + // the final template wrapper |
|
591 | + $this->display_admin_page_with_no_sidebar(); |
|
592 | + } |
|
593 | + |
|
594 | + |
|
595 | + |
|
596 | + /** |
|
597 | + * Generates Business Report showing total registrations per day. |
|
598 | + * |
|
599 | + * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
600 | + * @return string |
|
601 | + */ |
|
602 | + private function _registrations_per_day_report($period = '-1 month') |
|
603 | + { |
|
604 | + $report_ID = 'reg-admin-registrations-per-day-report-dv'; |
|
605 | + $results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period); |
|
606 | + $results = (array)$results; |
|
607 | + $regs = array(); |
|
608 | + $subtitle = ''; |
|
609 | + if ($results) { |
|
610 | + $column_titles = array(); |
|
611 | + $tracker = 0; |
|
612 | + foreach ($results as $result) { |
|
613 | + $report_column_values = array(); |
|
614 | + foreach ($result as $property_name => $property_value) { |
|
615 | + $property_value = $property_name === 'Registration_REG_date' ? $property_value |
|
616 | + : (int)$property_value; |
|
617 | + $report_column_values[] = $property_value; |
|
618 | + if ($tracker === 0) { |
|
619 | + if ($property_name === 'Registration_REG_date') { |
|
620 | + $column_titles[] = __('Date (only days with registrations are shown)', 'event_espresso'); |
|
621 | + } else { |
|
622 | + $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
623 | + } |
|
624 | + } |
|
625 | + } |
|
626 | + $tracker++; |
|
627 | + $regs[] = $report_column_values; |
|
628 | + } |
|
629 | + //make sure the column_titles is pushed to the beginning of the array |
|
630 | + array_unshift($regs, $column_titles); |
|
631 | + //setup the date range. |
|
632 | + $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
633 | + $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
634 | + $ending_date = new DateTime("now", $DateTimeZone); |
|
635 | + $subtitle = sprintf( |
|
636 | + _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'), |
|
637 | + $beginning_date->format('Y-m-d'), |
|
638 | + $ending_date->format('Y-m-d') |
|
639 | + ); |
|
640 | + } |
|
641 | + $report_title = __('Total Registrations per Day', 'event_espresso'); |
|
642 | + $report_params = array( |
|
643 | + 'title' => $report_title, |
|
644 | + 'subtitle' => $subtitle, |
|
645 | + 'id' => $report_ID, |
|
646 | + 'regs' => $regs, |
|
647 | + 'noResults' => empty($regs), |
|
648 | + 'noRegsMsg' => sprintf( |
|
649 | + __( |
|
650 | + '%sThere are currently no registration records in the last month for this report.%s', |
|
651 | + 'event_espresso' |
|
652 | + ), |
|
653 | + '<h2>' . $report_title . '</h2><p>', |
|
654 | + '</p>' |
|
655 | + ), |
|
656 | + ); |
|
657 | + wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params); |
|
658 | + return $report_ID; |
|
659 | + } |
|
660 | + |
|
661 | + |
|
662 | + |
|
663 | + /** |
|
664 | + * Generates Business Report showing total registrations per event. |
|
665 | + * |
|
666 | + * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
667 | + * @return string |
|
668 | + */ |
|
669 | + private function _registrations_per_event_report($period = '-1 month') |
|
670 | + { |
|
671 | + $report_ID = 'reg-admin-registrations-per-event-report-dv'; |
|
672 | + $results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period); |
|
673 | + $results = (array)$results; |
|
674 | + $regs = array(); |
|
675 | + $subtitle = ''; |
|
676 | + if ($results) { |
|
677 | + $column_titles = array(); |
|
678 | + $tracker = 0; |
|
679 | + foreach ($results as $result) { |
|
680 | + $report_column_values = array(); |
|
681 | + foreach ($result as $property_name => $property_value) { |
|
682 | + $property_value = $property_name === 'Registration_Event' ? wp_trim_words( |
|
683 | + $property_value, |
|
684 | + 4, |
|
685 | + '...' |
|
686 | + ) : (int)$property_value; |
|
687 | + $report_column_values[] = $property_value; |
|
688 | + if ($tracker === 0) { |
|
689 | + if ($property_name === 'Registration_Event') { |
|
690 | + $column_titles[] = __('Event', 'event_espresso'); |
|
691 | + } else { |
|
692 | + $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
693 | + } |
|
694 | + } |
|
695 | + } |
|
696 | + $tracker++; |
|
697 | + $regs[] = $report_column_values; |
|
698 | + } |
|
699 | + //make sure the column_titles is pushed to the beginning of the array |
|
700 | + array_unshift($regs, $column_titles); |
|
701 | + //setup the date range. |
|
702 | + $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
703 | + $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
704 | + $ending_date = new DateTime("now", $DateTimeZone); |
|
705 | + $subtitle = sprintf( |
|
706 | + _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'), |
|
707 | + $beginning_date->format('Y-m-d'), |
|
708 | + $ending_date->format('Y-m-d') |
|
709 | + ); |
|
710 | + } |
|
711 | + $report_title = __('Total Registrations per Event', 'event_espresso'); |
|
712 | + $report_params = array( |
|
713 | + 'title' => $report_title, |
|
714 | + 'subtitle' => $subtitle, |
|
715 | + 'id' => $report_ID, |
|
716 | + 'regs' => $regs, |
|
717 | + 'noResults' => empty($regs), |
|
718 | + 'noRegsMsg' => sprintf( |
|
719 | + __( |
|
720 | + '%sThere are currently no registration records in the last month for this report.%s', |
|
721 | + 'event_espresso' |
|
722 | + ), |
|
723 | + '<h2>' . $report_title . '</h2><p>', |
|
724 | + '</p>' |
|
725 | + ), |
|
726 | + ); |
|
727 | + wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params); |
|
728 | + return $report_ID; |
|
729 | + } |
|
730 | + |
|
731 | + |
|
732 | + |
|
733 | + /** |
|
734 | + * generates HTML for the Registration Check-in list table (showing all Check-ins for a specific registration) |
|
735 | + * |
|
736 | + * @access protected |
|
737 | + * @return void |
|
738 | + * @throws \EE_Error |
|
739 | + */ |
|
740 | + protected function _registration_checkin_list_table() |
|
741 | + { |
|
742 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
743 | + $reg_id = isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : null; |
|
744 | + /** @var EE_Registration $registration */ |
|
745 | + $registration = EEM_Registration::instance()->get_one_by_ID($reg_id); |
|
746 | + $attendee = $registration->attendee(); |
|
747 | + $this->_admin_page_title .= $this->get_action_link_or_button( |
|
748 | + 'new_registration', |
|
749 | + 'add-registrant', |
|
750 | + array('event_id' => $registration->event_ID()), |
|
751 | + 'add-new-h2' |
|
752 | + ); |
|
753 | + $checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in); |
|
754 | + $checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out); |
|
755 | + $legend_items = array( |
|
756 | + 'checkin' => array( |
|
757 | + 'class' => $checked_in->cssClasses(), |
|
758 | + 'desc' => $checked_in->legendLabel(), |
|
759 | + ), |
|
760 | + 'checkout' => array( |
|
761 | + 'class' => $checked_out->cssClasses(), |
|
762 | + 'desc' => $checked_out->legendLabel(), |
|
763 | + ), |
|
764 | + ); |
|
765 | + $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
766 | + $dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
|
767 | + /** @var EE_Datetime $datetime */ |
|
768 | + $datetime = EEM_Datetime::instance()->get_one_by_ID($dtt_id); |
|
769 | + $datetime_label = ''; |
|
770 | + if ($datetime instanceof EE_Datetime) { |
|
771 | + $datetime_label = $datetime->get_dtt_display_name(true); |
|
772 | + $datetime_label .= ! empty($datetime_label) |
|
773 | + ? ' (' . $datetime->get_dtt_display_name() . ')' |
|
774 | + : $datetime->get_dtt_display_name(); |
|
775 | + } |
|
776 | + $datetime_link = ! empty($dtt_id) && $registration instanceof EE_Registration |
|
777 | + ? EE_Admin_Page::add_query_args_and_nonce( |
|
778 | + array( |
|
779 | + 'action' => 'event_registrations', |
|
780 | + 'event_id' => $registration->event_ID(), |
|
781 | + 'DTT_ID' => $dtt_id, |
|
782 | + ), |
|
783 | + $this->_admin_base_url |
|
784 | + ) |
|
785 | + : ''; |
|
786 | + $datetime_link = ! empty($datetime_link) |
|
787 | + ? '<a href="' . $datetime_link . '">' |
|
788 | + . '<span id="checkin-dtt">' |
|
789 | + . $datetime_label |
|
790 | + . '</span></a>' |
|
791 | + : $datetime_label; |
|
792 | + $attendee_name = $attendee instanceof EE_Attendee |
|
793 | + ? $attendee->full_name() |
|
794 | + : ''; |
|
795 | + $attendee_link = $attendee instanceof EE_Attendee |
|
796 | + ? $attendee->get_admin_details_link() |
|
797 | + : ''; |
|
798 | + $attendee_link = ! empty($attendee_link) |
|
799 | + ? '<a href="' . $attendee->get_admin_details_link() . '"' |
|
800 | + . ' title="' . esc_html__('Click for attendee details', 'event_espresso') . '">' |
|
801 | + . '<span id="checkin-attendee-name">' |
|
802 | + . $attendee_name |
|
803 | + . '</span></a>' |
|
804 | + : ''; |
|
805 | + $event_link = $registration->event() instanceof EE_Event |
|
806 | + ? $registration->event()->get_admin_details_link() |
|
807 | + : ''; |
|
808 | + $event_link = ! empty($event_link) |
|
809 | + ? '<a href="' . $event_link . '"' |
|
810 | + . ' title="' . esc_html__('Click here to edit event.', 'event_espresso') . '">' |
|
811 | + . '<span id="checkin-event-name">' |
|
812 | + . $registration->event_name() |
|
813 | + . '</span>' |
|
814 | + . '</a>' |
|
815 | + : ''; |
|
816 | + $this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id) |
|
817 | + ? '<h2>' . sprintf( |
|
818 | + esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'), |
|
819 | + $attendee_link, |
|
820 | + $datetime_link, |
|
821 | + $event_link |
|
822 | + ) . '</h2>' |
|
823 | + : ''; |
|
824 | + $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id) |
|
825 | + ? '<input type="hidden" name="_REGID" value="' . $reg_id . '">' : ''; |
|
826 | + $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id) |
|
827 | + ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : ''; |
|
828 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
829 | + } |
|
830 | + |
|
831 | + |
|
832 | + |
|
833 | + /** |
|
834 | + * toggle the Check-in status for the given registration (coming from ajax) |
|
835 | + * |
|
836 | + * @return void (JSON) |
|
837 | + */ |
|
838 | + public function toggle_checkin_status() |
|
839 | + { |
|
840 | + //first make sure we have the necessary data |
|
841 | + if ( ! isset($this->_req_data['_regid'])) { |
|
842 | + EE_Error::add_error( |
|
843 | + __( |
|
844 | + 'There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax', |
|
845 | + 'event_espresso' |
|
846 | + ), |
|
847 | + __FILE__, |
|
848 | + __FUNCTION__, |
|
849 | + __LINE__ |
|
850 | + ); |
|
851 | + $this->_template_args['success'] = false; |
|
852 | + $this->_template_args['error'] = true; |
|
853 | + $this->_return_json(); |
|
854 | + }; |
|
855 | + //do a nonce check cause we're not coming in from an normal route here. |
|
856 | + $nonce = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce']) |
|
857 | + : ''; |
|
858 | + $nonce_ref = 'checkin_nonce'; |
|
859 | + $this->_verify_nonce($nonce, $nonce_ref); |
|
860 | + //beautiful! Made it this far so let's get the status. |
|
861 | + $new_status = new CheckinStatusDashicon($this->_toggle_checkin_status()); |
|
862 | + //setup new class to return via ajax |
|
863 | + $this->_template_args['admin_page_content'] = 'clickable trigger-checkin ' . $new_status->cssClasses(); |
|
864 | + $this->_template_args['success'] = true; |
|
865 | + $this->_return_json(); |
|
866 | + } |
|
867 | + |
|
868 | + |
|
869 | + |
|
870 | + /** |
|
871 | + * handles toggling the checkin status for the registration, |
|
872 | + * |
|
873 | + * @access protected |
|
874 | + * @return int|void |
|
875 | + */ |
|
876 | + protected function _toggle_checkin_status() |
|
877 | + { |
|
878 | + //first let's get the query args out of the way for the redirect |
|
879 | + $query_args = array( |
|
880 | + 'action' => 'event_registrations', |
|
881 | + 'event_id' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null, |
|
882 | + 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null, |
|
883 | + ); |
|
884 | + $new_status = false; |
|
885 | + // bulk action check in toggle |
|
886 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
887 | + // cycle thru checkboxes |
|
888 | + while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) { |
|
889 | + $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
|
890 | + $new_status = $this->_toggle_checkin($REG_ID, $DTT_ID); |
|
891 | + } |
|
892 | + } elseif (isset($this->_req_data['_regid'])) { |
|
893 | + //coming from ajax request |
|
894 | + $DTT_ID = isset($this->_req_data['dttid']) ? $this->_req_data['dttid'] : null; |
|
895 | + $query_args['DTT_ID'] = $DTT_ID; |
|
896 | + $new_status = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID); |
|
897 | + } else { |
|
898 | + EE_Error::add_error( |
|
899 | + __('Missing some required data to toggle the Check-in', 'event_espresso'), |
|
900 | + __FILE__, |
|
901 | + __FUNCTION__, |
|
902 | + __LINE__ |
|
903 | + ); |
|
904 | + } |
|
905 | + if (defined('DOING_AJAX')) { |
|
906 | + return $new_status; |
|
907 | + } |
|
908 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
909 | + } |
|
910 | + |
|
911 | + |
|
912 | + |
|
913 | + /** |
|
914 | + * This is toggles a single Check-in for the given registration and datetime. |
|
915 | + * |
|
916 | + * @param int $REG_ID The registration we're toggling |
|
917 | + * @param int $DTT_ID The datetime we're toggling |
|
918 | + * @return int The new status toggled to. |
|
919 | + * @throws \EE_Error |
|
920 | + */ |
|
921 | + private function _toggle_checkin($REG_ID, $DTT_ID) |
|
922 | + { |
|
923 | + /** @var EE_Registration $REG */ |
|
924 | + $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
925 | + $new_status = $REG->toggle_checkin_status($DTT_ID); |
|
926 | + if ($new_status !== false) { |
|
927 | + EE_Error::add_success($REG->get_checkin_msg($DTT_ID)); |
|
928 | + } else { |
|
929 | + EE_Error::add_error($REG->get_checkin_msg($DTT_ID, true), __FILE__, __FUNCTION__, __LINE__); |
|
930 | + $new_status = false; |
|
931 | + } |
|
932 | + return $new_status; |
|
933 | + } |
|
934 | + |
|
935 | + |
|
936 | + |
|
937 | + /** |
|
938 | + * Takes care of deleting multiple EE_Checkin table rows |
|
939 | + * |
|
940 | + * @access protected |
|
941 | + * @return void |
|
942 | + * @throws \EE_Error |
|
943 | + */ |
|
944 | + protected function _delete_checkin_rows() |
|
945 | + { |
|
946 | + $query_args = array( |
|
947 | + 'action' => 'registration_checkins', |
|
948 | + 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
|
949 | + '_REGID' => isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : 0, |
|
950 | + ); |
|
951 | + $errors = 0; |
|
952 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
953 | + while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) { |
|
954 | + if ( ! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) { |
|
955 | + $errors++; |
|
956 | + } |
|
957 | + } |
|
958 | + } else { |
|
959 | + EE_Error::add_error( |
|
960 | + __( |
|
961 | + 'So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!', |
|
962 | + 'event_espresso' |
|
963 | + ), |
|
964 | + __FILE__, |
|
965 | + __FUNCTION__, |
|
966 | + __LINE__ |
|
967 | + ); |
|
968 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
969 | + } |
|
970 | + if ($errors > 0) { |
|
971 | + EE_Error::add_error( |
|
972 | + sprintf(__('There were %d records that did not delete successfully', 'event_espresso'), $errors), |
|
973 | + __FILE__, |
|
974 | + __FUNCTION__, |
|
975 | + __LINE__ |
|
976 | + ); |
|
977 | + } else { |
|
978 | + EE_Error::add_success(__('Records were successfully deleted', 'event_espresso')); |
|
979 | + } |
|
980 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
981 | + } |
|
982 | + |
|
983 | + |
|
984 | + |
|
985 | + /** |
|
986 | + * Deletes a single EE_Checkin row |
|
987 | + * |
|
988 | + * @return void |
|
989 | + * @throws \EE_Error |
|
990 | + */ |
|
991 | + protected function _delete_checkin_row() |
|
992 | + { |
|
993 | + $query_args = array( |
|
994 | + 'action' => 'registration_checkins', |
|
995 | + 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
|
996 | + '_REGID' => isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : 0, |
|
997 | + ); |
|
998 | + if ( ! empty($this->_req_data['CHK_ID'])) { |
|
999 | + if ( ! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) { |
|
1000 | + EE_Error::add_error( |
|
1001 | + __('Something went wrong and this check-in record was not deleted', 'event_espresso'), |
|
1002 | + __FILE__, |
|
1003 | + __FUNCTION__, |
|
1004 | + __LINE__ |
|
1005 | + ); |
|
1006 | + } else { |
|
1007 | + EE_Error::add_success(__('Check-In record successfully deleted', 'event_espresso')); |
|
1008 | + } |
|
1009 | + } else { |
|
1010 | + EE_Error::add_error( |
|
1011 | + __( |
|
1012 | + 'In order to delete a Check-in record, there must be a Check-In ID available. There is not. It is not your fault, there is just a gremlin living in the code', |
|
1013 | + 'event_espresso' |
|
1014 | + ), |
|
1015 | + __FILE__, |
|
1016 | + __FUNCTION__, |
|
1017 | + __LINE__ |
|
1018 | + ); |
|
1019 | + } |
|
1020 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
1021 | + } |
|
1022 | + |
|
1023 | + |
|
1024 | + |
|
1025 | + /** |
|
1026 | + * generates HTML for the Event Registrations List Table |
|
1027 | + * |
|
1028 | + * @access protected |
|
1029 | + * @return void |
|
1030 | + * @throws \EE_Error |
|
1031 | + */ |
|
1032 | + protected function _event_registrations_list_table() |
|
1033 | + { |
|
1034 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1035 | + $this->_admin_page_title .= isset($this->_req_data['event_id']) |
|
1036 | + ? $this->get_action_link_or_button( |
|
1037 | + 'new_registration', |
|
1038 | + 'add-registrant', |
|
1039 | + array('event_id' => $this->_req_data['event_id']), |
|
1040 | + 'add-new-h2', |
|
1041 | + '', |
|
1042 | + false |
|
1043 | + ) |
|
1044 | + : ''; |
|
1045 | + $checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in); |
|
1046 | + $checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out); |
|
1047 | + $checked_never = new CheckinStatusDashicon(EE_Checkin::status_checked_never); |
|
1048 | + $legend_items = array( |
|
1049 | + 'star-icon' => array( |
|
1050 | + 'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8', |
|
1051 | + 'desc' => __('This Registrant is the Primary Registrant', 'event_espresso'), |
|
1052 | + ), |
|
1053 | + 'checkin' => array( |
|
1054 | + 'class' => $checked_in->cssClasses(), |
|
1055 | + 'desc' => $checked_in->legendLabel(), |
|
1056 | + ), |
|
1057 | + 'checkout' => array( |
|
1058 | + 'class' => $checked_out->cssClasses(), |
|
1059 | + 'desc' => $checked_out->legendLabel(), |
|
1060 | + ), |
|
1061 | + 'nocheckinrecord' => array( |
|
1062 | + 'class' => $checked_never->cssClasses(), |
|
1063 | + 'desc' => $checked_never->legendLabel(), |
|
1064 | + ), |
|
1065 | + 'view_details' => array( |
|
1066 | + 'class' => 'dashicons dashicons-search', |
|
1067 | + 'desc' => __('View All Check-in Records for this Registrant', 'event_espresso'), |
|
1068 | + ), |
|
1069 | + 'approved_status' => array( |
|
1070 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved, |
|
1071 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'), |
|
1072 | + ), |
|
1073 | + 'cancelled_status' => array( |
|
1074 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled, |
|
1075 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'), |
|
1076 | + ), |
|
1077 | + 'declined_status' => array( |
|
1078 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined, |
|
1079 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'), |
|
1080 | + ), |
|
1081 | + 'not_approved' => array( |
|
1082 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved, |
|
1083 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'), |
|
1084 | + ), |
|
1085 | + 'pending_status' => array( |
|
1086 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment, |
|
1087 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'), |
|
1088 | + ), |
|
1089 | + 'wait_list' => array( |
|
1090 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list, |
|
1091 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'), |
|
1092 | + ), |
|
1093 | + ); |
|
1094 | + $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
1095 | + $event_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null; |
|
1096 | + $this->_template_args['before_list_table'] = ! empty($event_id) |
|
1097 | + ? '<h2>' . sprintf( |
|
1098 | + __('Viewing Registrations for Event: %s', 'event_espresso'), |
|
1099 | + EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name') |
|
1100 | + ) . '</h2>' |
|
1101 | + : ''; |
|
1102 | + //need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on the event. |
|
1103 | + /** @var EE_Event $event */ |
|
1104 | + $event = EEM_Event::instance()->get_one_by_ID($event_id); |
|
1105 | + $DTT_ID = ! empty($this->_req_data['DTT_ID']) ? absint($this->_req_data['DTT_ID']) : 0; |
|
1106 | + $datetime = null; |
|
1107 | + if ($event instanceof EE_Event) { |
|
1108 | + $datetimes_on_event = $event->datetimes(); |
|
1109 | + if (count($datetimes_on_event) === 1) { |
|
1110 | + $datetime = reset($datetimes_on_event); |
|
1111 | + } |
|
1112 | + } |
|
1113 | + $datetime = $datetime instanceof EE_Datetime ? $datetime : EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
|
1114 | + if ($datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '') { |
|
1115 | + $this->_template_args['before_list_table'] = substr($this->_template_args['before_list_table'], 0, -5); |
|
1116 | + $this->_template_args['before_list_table'] .= ' <span class="drk-grey-text">'; |
|
1117 | + $this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar"></span>'; |
|
1118 | + $this->_template_args['before_list_table'] .= $datetime->name(); |
|
1119 | + $this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )'; |
|
1120 | + $this->_template_args['before_list_table'] .= '</span></h2>'; |
|
1121 | + } |
|
1122 | + //if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status column |
|
1123 | + //represents |
|
1124 | + if ( ! $datetime instanceof EE_Datetime) { |
|
1125 | + $this->_template_args['before_list_table'] .= '<br><p class="description">' |
|
1126 | + . __('In this view, the check-in status represents the latest check-in record for the registration in that row.', |
|
1127 | + 'event_espresso') |
|
1128 | + . '</p>'; |
|
1129 | + } |
|
1130 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
1131 | + } |
|
1132 | + |
|
1133 | + /** |
|
1134 | + * Download the registrations check-in report (same as the normal registration report, but with different where |
|
1135 | + * conditions) |
|
1136 | + * |
|
1137 | + * @return void ends the request by a redirect or download |
|
1138 | + */ |
|
1139 | + public function _registrations_checkin_report() |
|
1140 | + { |
|
1141 | + $this->_registrations_report_base('_get_checkin_query_params_from_request'); |
|
1142 | + } |
|
1143 | + |
|
1144 | + /** |
|
1145 | + * Gets the query params from the request, plus adds a where condition for the registration status, |
|
1146 | + * because on the checkin page we only ever want to see approved and pending-approval registrations |
|
1147 | + * |
|
1148 | + * @param array $request |
|
1149 | + * @param int $per_page |
|
1150 | + * @param bool $count |
|
1151 | + * @return array |
|
1152 | + */ |
|
1153 | + protected function _get_checkin_query_params_from_request( |
|
1154 | + $request, |
|
1155 | + $per_page = 10, |
|
1156 | + $count = false |
|
1157 | + ) { |
|
1158 | + $query_params = $this->_get_registration_query_parameters($request, $per_page, $count); |
|
1159 | + //unlike the regular registrations list table, |
|
1160 | + $status_ids_array = apply_filters( |
|
1161 | + 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', |
|
1162 | + array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved) |
|
1163 | + ); |
|
1164 | + $query_params[0]['STS_ID'] = array('IN', $status_ids_array); |
|
1165 | + return $query_params; |
|
1166 | + } |
|
1167 | + |
|
1168 | + |
|
1169 | + |
|
1170 | + |
|
1171 | + /** |
|
1172 | + * Gets registrations for an event |
|
1173 | + * |
|
1174 | + * @param int $per_page |
|
1175 | + * @param bool $count whether to return count or data. |
|
1176 | + * @param bool $trash |
|
1177 | + * @param string $orderby |
|
1178 | + * @return EE_Registration[]|int |
|
1179 | + * @throws \EE_Error |
|
1180 | + */ |
|
1181 | + public function get_event_attendees($per_page = 10, $count = false, $trash = false, $orderby = 'ATT_fname') |
|
1182 | + { |
|
1183 | + //normalize some request params that get setup by the parent `get_registrations` method. |
|
1184 | + $request = $this->_req_data; |
|
1185 | + $request['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : $orderby; |
|
1186 | + $request['order'] = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC'; |
|
1187 | + if($trash){ |
|
1188 | + $request['status'] = 'trash'; |
|
1189 | + } |
|
1190 | + $query_params = $this->_get_checkin_query_params_from_request( $request, $per_page, $count ); |
|
1191 | + /** |
|
1192 | + * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected |
|
1193 | + * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093 |
|
1194 | + * @see EEM_Base::get_all() |
|
1195 | + */ |
|
1196 | + $query_params['group_by'] = ''; |
|
1197 | + |
|
1198 | + return $count |
|
1199 | + ? EEM_Registration::instance()->count($query_params) |
|
1200 | + /** @type EE_Registration[] */ |
|
1201 | + : EEM_Registration::instance()->get_all($query_params); |
|
1202 | + } |
|
1203 | 1203 | |
1204 | 1204 | |
1205 | 1205 | } //end class Registrations Admin Page |
@@ -22,15 +22,15 @@ discard block |
||
22 | 22 | |
23 | 23 | <div class="event-attendees"> |
24 | 24 | <?php do_action_ref_array( |
25 | - 'AHEE__loop-espresso_event_attendees__before', |
|
26 | - array( |
|
27 | - $contacts, |
|
28 | - $event, |
|
29 | - $datetime, |
|
30 | - $ticket, |
|
31 | - $show_gravatar, |
|
32 | - ) |
|
33 | - ); ?> |
|
25 | + 'AHEE__loop-espresso_event_attendees__before', |
|
26 | + array( |
|
27 | + $contacts, |
|
28 | + $event, |
|
29 | + $datetime, |
|
30 | + $ticket, |
|
31 | + $show_gravatar, |
|
32 | + ) |
|
33 | + ); ?> |
|
34 | 34 | <?php if ( $contacts ) : ?> |
35 | 35 | <ul class="event-attendees-list"> |
36 | 36 | <?php foreach( $contacts as $contact ) : |
@@ -47,13 +47,13 @@ discard block |
||
47 | 47 | <p><?php echo $no_attendees_message; ?></p> |
48 | 48 | <?php endif; ?> |
49 | 49 | <?php do_action_ref_array( |
50 | - 'AHEE__loop-espresso_event_attendees__after', |
|
51 | - array( |
|
52 | - $contacts, |
|
53 | - $event, |
|
54 | - $datetime, |
|
55 | - $ticket, |
|
56 | - $show_gravatar, |
|
57 | - ) |
|
58 | - ); ?> |
|
50 | + 'AHEE__loop-espresso_event_attendees__after', |
|
51 | + array( |
|
52 | + $contacts, |
|
53 | + $event, |
|
54 | + $datetime, |
|
55 | + $ticket, |
|
56 | + $show_gravatar, |
|
57 | + ) |
|
58 | + ); ?> |
|
59 | 59 | </div> |
60 | 60 | \ No newline at end of file |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * @type bool $show_gravatar whether to show gravatar or not. |
16 | 16 | */ |
17 | 17 | |
18 | -$no_attendees_message = apply_filters( 'FHEE__loop-espresso_attendees-shortcode__template__no_attendees_message', __('No Attendees Yet', 'event_espresso' ) ); |
|
18 | +$no_attendees_message = apply_filters('FHEE__loop-espresso_attendees-shortcode__template__no_attendees_message', __('No Attendees Yet', 'event_espresso')); |
|
19 | 19 | |
20 | 20 | |
21 | 21 | ?> |
@@ -31,16 +31,16 @@ discard block |
||
31 | 31 | $show_gravatar, |
32 | 32 | ) |
33 | 33 | ); ?> |
34 | - <?php if ( $contacts ) : ?> |
|
34 | + <?php if ($contacts) : ?> |
|
35 | 35 | <ul class="event-attendees-list"> |
36 | - <?php foreach( $contacts as $contact ) : |
|
37 | - EEH_Template::get_template_part( 'content', 'espresso_event_attendees', array( |
|
36 | + <?php foreach ($contacts as $contact) : |
|
37 | + EEH_Template::get_template_part('content', 'espresso_event_attendees', array( |
|
38 | 38 | 'contact' => $contact, |
39 | 39 | 'event' => $event, |
40 | 40 | 'datetime' => $datetime, |
41 | 41 | 'ticket' => $ticket, |
42 | 42 | 'show_gravatar' => $show_gravatar |
43 | - ) ); |
|
43 | + )); |
|
44 | 44 | endforeach; ?> |
45 | 45 | </ul> |
46 | 46 | <?php else : ?> |
@@ -43,8 +43,11 @@ |
||
43 | 43 | ) ); |
44 | 44 | endforeach; ?> |
45 | 45 | </ul> |
46 | - <?php else : ?> |
|
47 | - <p><?php echo $no_attendees_message; ?></p> |
|
46 | + <?php else { |
|
47 | + : ?> |
|
48 | + <p><?php echo $no_attendees_message; |
|
49 | +} |
|
50 | +?></p> |
|
48 | 51 | <?php endif; ?> |
49 | 52 | <?php do_action_ref_array( |
50 | 53 | 'AHEE__loop-espresso_event_attendees__after', |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('ABSPATH')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /* |
5 | 5 | Plugin Name: Event Espresso |
@@ -40,243 +40,243 @@ discard block |
||
40 | 40 | * @since 4.0 |
41 | 41 | */ |
42 | 42 | if (function_exists('espresso_version')) { |
43 | - /** |
|
44 | - * espresso_duplicate_plugin_error |
|
45 | - * displays if more than one version of EE is activated at the same time |
|
46 | - */ |
|
47 | - function espresso_duplicate_plugin_error() |
|
48 | - { |
|
49 | - ?> |
|
43 | + /** |
|
44 | + * espresso_duplicate_plugin_error |
|
45 | + * displays if more than one version of EE is activated at the same time |
|
46 | + */ |
|
47 | + function espresso_duplicate_plugin_error() |
|
48 | + { |
|
49 | + ?> |
|
50 | 50 | <div class="error"> |
51 | 51 | <p> |
52 | 52 | <?php echo esc_html__( |
53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | - 'event_espresso' |
|
55 | - ); ?> |
|
53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | + 'event_espresso' |
|
55 | + ); ?> |
|
56 | 56 | </p> |
57 | 57 | </div> |
58 | 58 | <?php |
59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | - } |
|
59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | + } |
|
61 | 61 | |
62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
63 | 63 | } else { |
64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
65 | - if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | - /** |
|
67 | - * espresso_minimum_php_version_error |
|
68 | - * |
|
69 | - * @return void |
|
70 | - */ |
|
71 | - function espresso_minimum_php_version_error() |
|
72 | - { |
|
73 | - ?> |
|
64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
65 | + if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | + /** |
|
67 | + * espresso_minimum_php_version_error |
|
68 | + * |
|
69 | + * @return void |
|
70 | + */ |
|
71 | + function espresso_minimum_php_version_error() |
|
72 | + { |
|
73 | + ?> |
|
74 | 74 | <div class="error"> |
75 | 75 | <p> |
76 | 76 | <?php |
77 | - printf( |
|
78 | - esc_html__( |
|
79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | - 'event_espresso' |
|
81 | - ), |
|
82 | - EE_MIN_PHP_VER_REQUIRED, |
|
83 | - PHP_VERSION, |
|
84 | - '<br/>', |
|
85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | - ); |
|
87 | - ?> |
|
77 | + printf( |
|
78 | + esc_html__( |
|
79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | + 'event_espresso' |
|
81 | + ), |
|
82 | + EE_MIN_PHP_VER_REQUIRED, |
|
83 | + PHP_VERSION, |
|
84 | + '<br/>', |
|
85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | + ); |
|
87 | + ?> |
|
88 | 88 | </p> |
89 | 89 | </div> |
90 | 90 | <?php |
91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | - } |
|
91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | + } |
|
93 | 93 | |
94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | - } else { |
|
96 | - /** |
|
97 | - * espresso_version |
|
98 | - * Returns the plugin version |
|
99 | - * |
|
100 | - * @return string |
|
101 | - */ |
|
102 | - function espresso_version() |
|
103 | - { |
|
104 | - return apply_filters('FHEE__espresso__espresso_version', '4.9.47.rc.011'); |
|
105 | - } |
|
94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | + } else { |
|
96 | + /** |
|
97 | + * espresso_version |
|
98 | + * Returns the plugin version |
|
99 | + * |
|
100 | + * @return string |
|
101 | + */ |
|
102 | + function espresso_version() |
|
103 | + { |
|
104 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.47.rc.011'); |
|
105 | + } |
|
106 | 106 | |
107 | - // define versions |
|
108 | - define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
109 | - define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
110 | - define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
111 | - define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
112 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
113 | - //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
|
114 | - if ( ! defined('DS')) { |
|
115 | - define('DS', '/'); |
|
116 | - } |
|
117 | - if ( ! defined('PS')) { |
|
118 | - define('PS', PATH_SEPARATOR); |
|
119 | - } |
|
120 | - if ( ! defined('SP')) { |
|
121 | - define('SP', ' '); |
|
122 | - } |
|
123 | - if ( ! defined('EENL')) { |
|
124 | - define('EENL', "\n"); |
|
125 | - } |
|
126 | - define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
127 | - // define the plugin directory and URL |
|
128 | - define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
129 | - define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
130 | - define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
131 | - // main root folder paths |
|
132 | - define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS); |
|
133 | - define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS); |
|
134 | - define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS); |
|
135 | - define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS); |
|
136 | - define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS); |
|
137 | - define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS); |
|
138 | - define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS); |
|
139 | - define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS); |
|
140 | - // core system paths |
|
141 | - define('EE_ADMIN', EE_CORE . 'admin' . DS); |
|
142 | - define('EE_CPTS', EE_CORE . 'CPTs' . DS); |
|
143 | - define('EE_CLASSES', EE_CORE . 'db_classes' . DS); |
|
144 | - define('EE_INTERFACES', EE_CORE . 'interfaces' . DS); |
|
145 | - define('EE_BUSINESS', EE_CORE . 'business' . DS); |
|
146 | - define('EE_MODELS', EE_CORE . 'db_models' . DS); |
|
147 | - define('EE_HELPERS', EE_CORE . 'helpers' . DS); |
|
148 | - define('EE_LIBRARIES', EE_CORE . 'libraries' . DS); |
|
149 | - define('EE_TEMPLATES', EE_CORE . 'templates' . DS); |
|
150 | - define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS); |
|
151 | - define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS); |
|
152 | - define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS); |
|
153 | - // gateways |
|
154 | - define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS); |
|
155 | - define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS); |
|
156 | - // asset URL paths |
|
157 | - define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS); |
|
158 | - define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS); |
|
159 | - define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS); |
|
160 | - define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS); |
|
161 | - define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/'); |
|
162 | - define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/'); |
|
163 | - // define upload paths |
|
164 | - $uploads = wp_upload_dir(); |
|
165 | - // define the uploads directory and URL |
|
166 | - define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS); |
|
167 | - define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS); |
|
168 | - // define the templates directory and URL |
|
169 | - define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS); |
|
170 | - define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS); |
|
171 | - // define the gateway directory and URL |
|
172 | - define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
173 | - define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
174 | - // languages folder/path |
|
175 | - define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS); |
|
176 | - define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS); |
|
177 | - //check for dompdf fonts in uploads |
|
178 | - if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) { |
|
179 | - define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS); |
|
180 | - } |
|
181 | - //ajax constants |
|
182 | - define( |
|
183 | - 'EE_FRONT_AJAX', |
|
184 | - isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false |
|
185 | - ); |
|
186 | - define( |
|
187 | - 'EE_ADMIN_AJAX', |
|
188 | - isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false |
|
189 | - ); |
|
190 | - //just a handy constant occasionally needed for finding values representing infinity in the DB |
|
191 | - //you're better to use this than its straight value (currently -1) in case you ever |
|
192 | - //want to change its default value! or find when -1 means infinity |
|
193 | - define('EE_INF_IN_DB', -1); |
|
194 | - define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
195 | - define('EE_DEBUG', false); |
|
196 | - // for older WP versions |
|
197 | - if ( ! defined('MONTH_IN_SECONDS')) { |
|
198 | - define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30); |
|
199 | - } |
|
200 | - /** |
|
201 | - * espresso_plugin_activation |
|
202 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
203 | - */ |
|
204 | - function espresso_plugin_activation() |
|
205 | - { |
|
206 | - update_option('ee_espresso_activation', true); |
|
207 | - } |
|
107 | + // define versions |
|
108 | + define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
109 | + define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
110 | + define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
111 | + define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
112 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
113 | + //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
|
114 | + if ( ! defined('DS')) { |
|
115 | + define('DS', '/'); |
|
116 | + } |
|
117 | + if ( ! defined('PS')) { |
|
118 | + define('PS', PATH_SEPARATOR); |
|
119 | + } |
|
120 | + if ( ! defined('SP')) { |
|
121 | + define('SP', ' '); |
|
122 | + } |
|
123 | + if ( ! defined('EENL')) { |
|
124 | + define('EENL', "\n"); |
|
125 | + } |
|
126 | + define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
127 | + // define the plugin directory and URL |
|
128 | + define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
129 | + define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
130 | + define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
131 | + // main root folder paths |
|
132 | + define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS); |
|
133 | + define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS); |
|
134 | + define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS); |
|
135 | + define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS); |
|
136 | + define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS); |
|
137 | + define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS); |
|
138 | + define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS); |
|
139 | + define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS); |
|
140 | + // core system paths |
|
141 | + define('EE_ADMIN', EE_CORE . 'admin' . DS); |
|
142 | + define('EE_CPTS', EE_CORE . 'CPTs' . DS); |
|
143 | + define('EE_CLASSES', EE_CORE . 'db_classes' . DS); |
|
144 | + define('EE_INTERFACES', EE_CORE . 'interfaces' . DS); |
|
145 | + define('EE_BUSINESS', EE_CORE . 'business' . DS); |
|
146 | + define('EE_MODELS', EE_CORE . 'db_models' . DS); |
|
147 | + define('EE_HELPERS', EE_CORE . 'helpers' . DS); |
|
148 | + define('EE_LIBRARIES', EE_CORE . 'libraries' . DS); |
|
149 | + define('EE_TEMPLATES', EE_CORE . 'templates' . DS); |
|
150 | + define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS); |
|
151 | + define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS); |
|
152 | + define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS); |
|
153 | + // gateways |
|
154 | + define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS); |
|
155 | + define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS); |
|
156 | + // asset URL paths |
|
157 | + define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS); |
|
158 | + define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS); |
|
159 | + define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS); |
|
160 | + define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS); |
|
161 | + define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/'); |
|
162 | + define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/'); |
|
163 | + // define upload paths |
|
164 | + $uploads = wp_upload_dir(); |
|
165 | + // define the uploads directory and URL |
|
166 | + define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS); |
|
167 | + define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS); |
|
168 | + // define the templates directory and URL |
|
169 | + define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS); |
|
170 | + define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS); |
|
171 | + // define the gateway directory and URL |
|
172 | + define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
173 | + define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
174 | + // languages folder/path |
|
175 | + define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS); |
|
176 | + define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS); |
|
177 | + //check for dompdf fonts in uploads |
|
178 | + if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) { |
|
179 | + define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS); |
|
180 | + } |
|
181 | + //ajax constants |
|
182 | + define( |
|
183 | + 'EE_FRONT_AJAX', |
|
184 | + isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false |
|
185 | + ); |
|
186 | + define( |
|
187 | + 'EE_ADMIN_AJAX', |
|
188 | + isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false |
|
189 | + ); |
|
190 | + //just a handy constant occasionally needed for finding values representing infinity in the DB |
|
191 | + //you're better to use this than its straight value (currently -1) in case you ever |
|
192 | + //want to change its default value! or find when -1 means infinity |
|
193 | + define('EE_INF_IN_DB', -1); |
|
194 | + define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
195 | + define('EE_DEBUG', false); |
|
196 | + // for older WP versions |
|
197 | + if ( ! defined('MONTH_IN_SECONDS')) { |
|
198 | + define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30); |
|
199 | + } |
|
200 | + /** |
|
201 | + * espresso_plugin_activation |
|
202 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
203 | + */ |
|
204 | + function espresso_plugin_activation() |
|
205 | + { |
|
206 | + update_option('ee_espresso_activation', true); |
|
207 | + } |
|
208 | 208 | |
209 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
210 | - /** |
|
211 | - * espresso_load_error_handling |
|
212 | - * this function loads EE's class for handling exceptions and errors |
|
213 | - */ |
|
214 | - function espresso_load_error_handling() |
|
215 | - { |
|
216 | - // load debugging tools |
|
217 | - if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
218 | - require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php'); |
|
219 | - EEH_Debug_Tools::instance(); |
|
220 | - } |
|
221 | - // load error handling |
|
222 | - if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
223 | - require_once(EE_CORE . 'EE_Error.core.php'); |
|
224 | - } else { |
|
225 | - wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
226 | - } |
|
227 | - } |
|
209 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
210 | + /** |
|
211 | + * espresso_load_error_handling |
|
212 | + * this function loads EE's class for handling exceptions and errors |
|
213 | + */ |
|
214 | + function espresso_load_error_handling() |
|
215 | + { |
|
216 | + // load debugging tools |
|
217 | + if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
218 | + require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php'); |
|
219 | + EEH_Debug_Tools::instance(); |
|
220 | + } |
|
221 | + // load error handling |
|
222 | + if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
223 | + require_once(EE_CORE . 'EE_Error.core.php'); |
|
224 | + } else { |
|
225 | + wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
226 | + } |
|
227 | + } |
|
228 | 228 | |
229 | - /** |
|
230 | - * espresso_load_required |
|
231 | - * given a class name and path, this function will load that file or throw an exception |
|
232 | - * |
|
233 | - * @param string $classname |
|
234 | - * @param string $full_path_to_file |
|
235 | - * @throws EE_Error |
|
236 | - */ |
|
237 | - function espresso_load_required($classname, $full_path_to_file) |
|
238 | - { |
|
239 | - static $error_handling_loaded = false; |
|
240 | - if ( ! $error_handling_loaded) { |
|
241 | - espresso_load_error_handling(); |
|
242 | - $error_handling_loaded = true; |
|
243 | - } |
|
244 | - if (is_readable($full_path_to_file)) { |
|
245 | - require_once($full_path_to_file); |
|
246 | - } else { |
|
247 | - throw new EE_Error ( |
|
248 | - sprintf( |
|
249 | - esc_html__( |
|
250 | - 'The %s class file could not be located or is not readable due to file permissions.', |
|
251 | - 'event_espresso' |
|
252 | - ), |
|
253 | - $classname |
|
254 | - ) |
|
255 | - ); |
|
256 | - } |
|
257 | - } |
|
229 | + /** |
|
230 | + * espresso_load_required |
|
231 | + * given a class name and path, this function will load that file or throw an exception |
|
232 | + * |
|
233 | + * @param string $classname |
|
234 | + * @param string $full_path_to_file |
|
235 | + * @throws EE_Error |
|
236 | + */ |
|
237 | + function espresso_load_required($classname, $full_path_to_file) |
|
238 | + { |
|
239 | + static $error_handling_loaded = false; |
|
240 | + if ( ! $error_handling_loaded) { |
|
241 | + espresso_load_error_handling(); |
|
242 | + $error_handling_loaded = true; |
|
243 | + } |
|
244 | + if (is_readable($full_path_to_file)) { |
|
245 | + require_once($full_path_to_file); |
|
246 | + } else { |
|
247 | + throw new EE_Error ( |
|
248 | + sprintf( |
|
249 | + esc_html__( |
|
250 | + 'The %s class file could not be located or is not readable due to file permissions.', |
|
251 | + 'event_espresso' |
|
252 | + ), |
|
253 | + $classname |
|
254 | + ) |
|
255 | + ); |
|
256 | + } |
|
257 | + } |
|
258 | 258 | |
259 | - espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'); |
|
260 | - espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'); |
|
261 | - espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php'); |
|
262 | - new EE_Bootstrap(); |
|
263 | - } |
|
259 | + espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'); |
|
260 | + espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'); |
|
261 | + espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php'); |
|
262 | + new EE_Bootstrap(); |
|
263 | + } |
|
264 | 264 | } |
265 | 265 | if ( ! function_exists('espresso_deactivate_plugin')) { |
266 | - /** |
|
267 | - * deactivate_plugin |
|
268 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
269 | - * |
|
270 | - * @access public |
|
271 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
272 | - * @return void |
|
273 | - */ |
|
274 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
275 | - { |
|
276 | - if ( ! function_exists('deactivate_plugins')) { |
|
277 | - require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
278 | - } |
|
279 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
280 | - deactivate_plugins($plugin_basename); |
|
281 | - } |
|
266 | + /** |
|
267 | + * deactivate_plugin |
|
268 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
269 | + * |
|
270 | + * @access public |
|
271 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
272 | + * @return void |
|
273 | + */ |
|
274 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
275 | + { |
|
276 | + if ( ! function_exists('deactivate_plugins')) { |
|
277 | + require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
278 | + } |
|
279 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
280 | + deactivate_plugins($plugin_basename); |
|
281 | + } |
|
282 | 282 | } |
283 | 283 | \ No newline at end of file |