@@ -14,1264 +14,1264 @@ |
||
14 | 14 | { |
15 | 15 | |
16 | 16 | |
17 | - /** |
|
18 | - * Extend_Events_Admin_Page constructor. |
|
19 | - * |
|
20 | - * @param bool $routing |
|
21 | - */ |
|
22 | - public function __construct($routing = true) |
|
23 | - { |
|
24 | - parent::__construct($routing); |
|
25 | - if (! defined('EVENTS_CAF_TEMPLATE_PATH')) { |
|
26 | - define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/'); |
|
27 | - define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/'); |
|
28 | - define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/'); |
|
29 | - } |
|
30 | - } |
|
31 | - |
|
32 | - |
|
33 | - /** |
|
34 | - * Sets routes. |
|
35 | - */ |
|
36 | - protected function _extend_page_config() |
|
37 | - { |
|
38 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events'; |
|
39 | - //is there a evt_id in the request? |
|
40 | - $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) |
|
41 | - ? $this->_req_data['EVT_ID'] |
|
42 | - : 0; |
|
43 | - $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id; |
|
44 | - //tkt_id? |
|
45 | - $tkt_id = ! empty($this->_req_data['TKT_ID']) && ! is_array($this->_req_data['TKT_ID']) |
|
46 | - ? $this->_req_data['TKT_ID'] |
|
47 | - : 0; |
|
48 | - $new_page_routes = array( |
|
49 | - 'duplicate_event' => array( |
|
50 | - 'func' => '_duplicate_event', |
|
51 | - 'capability' => 'ee_edit_event', |
|
52 | - 'obj_id' => $evt_id, |
|
53 | - 'noheader' => true, |
|
54 | - ), |
|
55 | - 'ticket_list_table' => array( |
|
56 | - 'func' => '_tickets_overview_list_table', |
|
57 | - 'capability' => 'ee_read_default_tickets', |
|
58 | - ), |
|
59 | - 'trash_ticket' => array( |
|
60 | - 'func' => '_trash_or_restore_ticket', |
|
61 | - 'capability' => 'ee_delete_default_ticket', |
|
62 | - 'obj_id' => $tkt_id, |
|
63 | - 'noheader' => true, |
|
64 | - 'args' => array('trash' => true), |
|
65 | - ), |
|
66 | - 'trash_tickets' => array( |
|
67 | - 'func' => '_trash_or_restore_ticket', |
|
68 | - 'capability' => 'ee_delete_default_tickets', |
|
69 | - 'noheader' => true, |
|
70 | - 'args' => array('trash' => true), |
|
71 | - ), |
|
72 | - 'restore_ticket' => array( |
|
73 | - 'func' => '_trash_or_restore_ticket', |
|
74 | - 'capability' => 'ee_delete_default_ticket', |
|
75 | - 'obj_id' => $tkt_id, |
|
76 | - 'noheader' => true, |
|
77 | - ), |
|
78 | - 'restore_tickets' => array( |
|
79 | - 'func' => '_trash_or_restore_ticket', |
|
80 | - 'capability' => 'ee_delete_default_tickets', |
|
81 | - 'noheader' => true, |
|
82 | - ), |
|
83 | - 'delete_ticket' => array( |
|
84 | - 'func' => '_delete_ticket', |
|
85 | - 'capability' => 'ee_delete_default_ticket', |
|
86 | - 'obj_id' => $tkt_id, |
|
87 | - 'noheader' => true, |
|
88 | - ), |
|
89 | - 'delete_tickets' => array( |
|
90 | - 'func' => '_delete_ticket', |
|
91 | - 'capability' => 'ee_delete_default_tickets', |
|
92 | - 'noheader' => true, |
|
93 | - ), |
|
94 | - 'import_page' => array( |
|
95 | - 'func' => '_import_page', |
|
96 | - 'capability' => 'import', |
|
97 | - ), |
|
98 | - 'import' => array( |
|
99 | - 'func' => '_import_events', |
|
100 | - 'capability' => 'import', |
|
101 | - 'noheader' => true, |
|
102 | - ), |
|
103 | - 'import_events' => array( |
|
104 | - 'func' => '_import_events', |
|
105 | - 'capability' => 'import', |
|
106 | - 'noheader' => true, |
|
107 | - ), |
|
108 | - 'export_events' => array( |
|
109 | - 'func' => '_events_export', |
|
110 | - 'capability' => 'export', |
|
111 | - 'noheader' => true, |
|
112 | - ), |
|
113 | - 'export_categories' => array( |
|
114 | - 'func' => '_categories_export', |
|
115 | - 'capability' => 'export', |
|
116 | - 'noheader' => true, |
|
117 | - ), |
|
118 | - 'sample_export_file' => array( |
|
119 | - 'func' => '_sample_export_file', |
|
120 | - 'capability' => 'export', |
|
121 | - 'noheader' => true, |
|
122 | - ), |
|
123 | - 'update_template_settings' => array( |
|
124 | - 'func' => '_update_template_settings', |
|
125 | - 'capability' => 'manage_options', |
|
126 | - 'noheader' => true, |
|
127 | - ), |
|
128 | - ); |
|
129 | - $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
130 | - //partial route/config override |
|
131 | - $this->_page_config['import_events']['metaboxes'] = $this->_default_espresso_metaboxes; |
|
132 | - $this->_page_config['create_new']['metaboxes'][] = '_premium_event_editor_meta_boxes'; |
|
133 | - $this->_page_config['create_new']['qtips'][] = 'EE_Event_Editor_Tips'; |
|
134 | - $this->_page_config['edit']['qtips'][] = 'EE_Event_Editor_Tips'; |
|
135 | - $this->_page_config['edit']['metaboxes'][] = '_premium_event_editor_meta_boxes'; |
|
136 | - $this->_page_config['default']['list_table'] = 'Extend_Events_Admin_List_Table'; |
|
137 | - //add tickets tab but only if there are more than one default ticket! |
|
138 | - $tkt_count = EEM_Ticket::instance()->count_deleted_and_undeleted( |
|
139 | - array(array('TKT_is_default' => 1)), |
|
140 | - 'TKT_ID', |
|
141 | - true |
|
142 | - ); |
|
143 | - if ($tkt_count > 1) { |
|
144 | - $new_page_config = array( |
|
145 | - 'ticket_list_table' => array( |
|
146 | - 'nav' => array( |
|
147 | - 'label' => esc_html__('Default Tickets', 'event_espresso'), |
|
148 | - 'order' => 60, |
|
149 | - ), |
|
150 | - 'list_table' => 'Tickets_List_Table', |
|
151 | - 'require_nonce' => false, |
|
152 | - ), |
|
153 | - ); |
|
154 | - } |
|
155 | - //template settings |
|
156 | - $new_page_config['template_settings'] = array( |
|
157 | - 'nav' => array( |
|
158 | - 'label' => esc_html__('Templates', 'event_espresso'), |
|
159 | - 'order' => 30, |
|
160 | - ), |
|
161 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
162 | - 'help_tabs' => array( |
|
163 | - 'general_settings_templates_help_tab' => array( |
|
164 | - 'title' => esc_html__('Templates', 'event_espresso'), |
|
165 | - 'filename' => 'general_settings_templates', |
|
166 | - ), |
|
167 | - ), |
|
168 | - 'help_tour' => array('Templates_Help_Tour'), |
|
169 | - 'require_nonce' => false, |
|
170 | - ); |
|
171 | - $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
172 | - //add filters and actions |
|
173 | - //modifying _views |
|
174 | - add_filter( |
|
175 | - 'FHEE_event_datetime_metabox_add_additional_date_time_template', |
|
176 | - array($this, 'add_additional_datetime_button'), |
|
177 | - 10, |
|
178 | - 2 |
|
179 | - ); |
|
180 | - add_filter( |
|
181 | - 'FHEE_event_datetime_metabox_clone_button_template', |
|
182 | - array($this, 'add_datetime_clone_button'), |
|
183 | - 10, |
|
184 | - 2 |
|
185 | - ); |
|
186 | - add_filter( |
|
187 | - 'FHEE_event_datetime_metabox_timezones_template', |
|
188 | - array($this, 'datetime_timezones_template'), |
|
189 | - 10, |
|
190 | - 2 |
|
191 | - ); |
|
192 | - //filters for event list table |
|
193 | - add_filter('FHEE__Extend_Events_Admin_List_Table__filters', array($this, 'list_table_filters'), 10, 2); |
|
194 | - add_filter( |
|
195 | - 'FHEE__Events_Admin_List_Table__column_actions__action_links', |
|
196 | - array($this, 'extra_list_table_actions'), |
|
197 | - 10, |
|
198 | - 2 |
|
199 | - ); |
|
200 | - //legend item |
|
201 | - add_filter('FHEE__Events_Admin_Page___event_legend_items__items', array($this, 'additional_legend_items')); |
|
202 | - add_action('admin_init', array($this, 'admin_init')); |
|
203 | - //heartbeat stuff |
|
204 | - add_filter('heartbeat_received', array($this, 'heartbeat_response'), 10, 2); |
|
205 | - } |
|
206 | - |
|
207 | - |
|
208 | - /** |
|
209 | - * admin_init |
|
210 | - */ |
|
211 | - public function admin_init() |
|
212 | - { |
|
213 | - EE_Registry::$i18n_js_strings = array_merge( |
|
214 | - EE_Registry::$i18n_js_strings, |
|
215 | - array( |
|
216 | - 'image_confirm' => esc_html__( |
|
217 | - 'Do you really want to delete this image? Please remember to update your event to complete the removal.', |
|
218 | - 'event_espresso' |
|
219 | - ), |
|
220 | - 'event_starts_on' => esc_html__('Event Starts on', 'event_espresso'), |
|
221 | - 'event_ends_on' => esc_html__('Event Ends on', 'event_espresso'), |
|
222 | - 'event_datetime_actions' => esc_html__('Actions', 'event_espresso'), |
|
223 | - 'event_clone_dt_msg' => esc_html__('Clone this Event Date and Time', 'event_espresso'), |
|
224 | - 'remove_event_dt_msg' => esc_html__('Remove this Event Time', 'event_espresso'), |
|
225 | - ) |
|
226 | - ); |
|
227 | - } |
|
228 | - |
|
229 | - |
|
230 | - /** |
|
231 | - * This will be used to listen for any heartbeat data packages coming via the WordPress heartbeat API and handle |
|
232 | - * accordingly. |
|
233 | - * |
|
234 | - * @param array $response The existing heartbeat response array. |
|
235 | - * @param array $data The incoming data package. |
|
236 | - * @return array possibly appended response. |
|
237 | - */ |
|
238 | - public function heartbeat_response($response, $data) |
|
239 | - { |
|
240 | - /** |
|
241 | - * check whether count of tickets is approaching the potential |
|
242 | - * limits for the server. |
|
243 | - */ |
|
244 | - if (! empty($data['input_count'])) { |
|
245 | - $response['max_input_vars_check'] = EE_Registry::instance()->CFG->environment->max_input_vars_limit_check( |
|
246 | - $data['input_count'] |
|
247 | - ); |
|
248 | - } |
|
249 | - return $response; |
|
250 | - } |
|
251 | - |
|
252 | - |
|
253 | - /** |
|
254 | - * Add per page screen options to the default ticket list table view. |
|
255 | - */ |
|
256 | - protected function _add_screen_options_ticket_list_table() |
|
257 | - { |
|
258 | - $this->_per_page_screen_option(); |
|
259 | - } |
|
260 | - |
|
261 | - |
|
262 | - /** |
|
263 | - * @param string $return |
|
264 | - * @param int $id |
|
265 | - * @param string $new_title |
|
266 | - * @param string $new_slug |
|
267 | - * @return string |
|
268 | - */ |
|
269 | - public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) |
|
270 | - { |
|
271 | - $return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug); |
|
272 | - //make sure this is only when editing |
|
273 | - if (! empty($id)) { |
|
274 | - $href = EE_Admin_Page::add_query_args_and_nonce( |
|
275 | - array('action' => 'duplicate_event', 'EVT_ID' => $id), |
|
276 | - $this->_admin_base_url |
|
277 | - ); |
|
278 | - $title = esc_attr__('Duplicate Event', 'event_espresso'); |
|
279 | - $return .= '<a href="' |
|
280 | - . $href |
|
281 | - . '" title="' |
|
282 | - . $title |
|
283 | - . '" id="ee-duplicate-event-button" class="button button-small" value="duplicate_event">' |
|
284 | - . $title |
|
285 | - . '</a>'; |
|
286 | - } |
|
287 | - return $return; |
|
288 | - } |
|
289 | - |
|
290 | - |
|
291 | - /** |
|
292 | - * Set the list table views for the default ticket list table view. |
|
293 | - */ |
|
294 | - public function _set_list_table_views_ticket_list_table() |
|
295 | - { |
|
296 | - $this->_views = array( |
|
297 | - 'all' => array( |
|
298 | - 'slug' => 'all', |
|
299 | - 'label' => esc_html__('All', 'event_espresso'), |
|
300 | - 'count' => 0, |
|
301 | - 'bulk_action' => array( |
|
302 | - 'trash_tickets' => esc_html__('Move to Trash', 'event_espresso'), |
|
303 | - ), |
|
304 | - ), |
|
305 | - 'trashed' => array( |
|
306 | - 'slug' => 'trashed', |
|
307 | - 'label' => esc_html__('Trash', 'event_espresso'), |
|
308 | - 'count' => 0, |
|
309 | - 'bulk_action' => array( |
|
310 | - 'restore_tickets' => esc_html__('Restore from Trash', 'event_espresso'), |
|
311 | - 'delete_tickets' => esc_html__('Delete Permanently', 'event_espresso'), |
|
312 | - ), |
|
313 | - ), |
|
314 | - ); |
|
315 | - } |
|
316 | - |
|
317 | - |
|
318 | - /** |
|
319 | - * Enqueue scripts and styles for the event editor. |
|
320 | - */ |
|
321 | - public function load_scripts_styles_edit() |
|
322 | - { |
|
323 | - wp_register_script( |
|
324 | - 'ee-event-editor-heartbeat', |
|
325 | - EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js', |
|
326 | - array('ee_admin_js', 'heartbeat'), |
|
327 | - EVENT_ESPRESSO_VERSION, |
|
328 | - true |
|
329 | - ); |
|
330 | - wp_enqueue_script('ee-accounting'); |
|
331 | - //styles |
|
332 | - wp_enqueue_style('espresso-ui-theme'); |
|
333 | - wp_enqueue_script('event_editor_js'); |
|
334 | - wp_enqueue_script('ee-event-editor-heartbeat'); |
|
335 | - } |
|
336 | - |
|
337 | - |
|
338 | - /** |
|
339 | - * Returns template for the additional datetime. |
|
340 | - * @param $template |
|
341 | - * @param $template_args |
|
342 | - * @return mixed |
|
343 | - * @throws DomainException |
|
344 | - */ |
|
345 | - public function add_additional_datetime_button($template, $template_args) |
|
346 | - { |
|
347 | - return EEH_Template::display_template( |
|
348 | - EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php', |
|
349 | - $template_args, |
|
350 | - true |
|
351 | - ); |
|
352 | - } |
|
353 | - |
|
354 | - |
|
355 | - /** |
|
356 | - * Returns the template for cloning a datetime. |
|
357 | - * @param $template |
|
358 | - * @param $template_args |
|
359 | - * @return mixed |
|
360 | - * @throws DomainException |
|
361 | - */ |
|
362 | - public function add_datetime_clone_button($template, $template_args) |
|
363 | - { |
|
364 | - return EEH_Template::display_template( |
|
365 | - EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php', |
|
366 | - $template_args, |
|
367 | - true |
|
368 | - ); |
|
369 | - } |
|
370 | - |
|
371 | - |
|
372 | - /** |
|
373 | - * Returns the template for datetime timezones. |
|
374 | - * @param $template |
|
375 | - * @param $template_args |
|
376 | - * @return mixed |
|
377 | - * @throws DomainException |
|
378 | - */ |
|
379 | - public function datetime_timezones_template($template, $template_args) |
|
380 | - { |
|
381 | - return EEH_Template::display_template( |
|
382 | - EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php', |
|
383 | - $template_args, |
|
384 | - true |
|
385 | - ); |
|
386 | - } |
|
387 | - |
|
388 | - |
|
389 | - /** |
|
390 | - * Sets the views for the default list table view. |
|
391 | - */ |
|
392 | - protected function _set_list_table_views_default() |
|
393 | - { |
|
394 | - parent::_set_list_table_views_default(); |
|
395 | - $new_views = array( |
|
396 | - 'today' => array( |
|
397 | - 'slug' => 'today', |
|
398 | - 'label' => esc_html__('Today', 'event_espresso'), |
|
399 | - 'count' => $this->total_events_today(), |
|
400 | - 'bulk_action' => array( |
|
401 | - 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
402 | - ), |
|
403 | - ), |
|
404 | - 'month' => array( |
|
405 | - 'slug' => 'month', |
|
406 | - 'label' => esc_html__('This Month', 'event_espresso'), |
|
407 | - 'count' => $this->total_events_this_month(), |
|
408 | - 'bulk_action' => array( |
|
409 | - 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
410 | - ), |
|
411 | - ), |
|
412 | - ); |
|
413 | - $this->_views = array_merge($this->_views, $new_views); |
|
414 | - } |
|
415 | - |
|
416 | - |
|
417 | - /** |
|
418 | - * Returns the extra action links for the default list table view. |
|
419 | - * @param array $action_links |
|
420 | - * @param \EE_Event $event |
|
421 | - * @return array |
|
422 | - * @throws EE_Error |
|
423 | - */ |
|
424 | - public function extra_list_table_actions(array $action_links, \EE_Event $event) |
|
425 | - { |
|
426 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
427 | - 'ee_read_registrations', |
|
428 | - 'espresso_registrations_reports', |
|
429 | - $event->ID() |
|
430 | - ) |
|
431 | - ) { |
|
432 | - $reports_query_args = array( |
|
433 | - 'action' => 'reports', |
|
434 | - 'EVT_ID' => $event->ID(), |
|
435 | - ); |
|
436 | - $reports_link = EE_Admin_Page::add_query_args_and_nonce($reports_query_args, REG_ADMIN_URL); |
|
437 | - $action_links[] = '<a href="' |
|
438 | - . $reports_link |
|
439 | - . '" title="' |
|
440 | - . esc_attr__('View Report', 'event_espresso') |
|
441 | - . '"><div class="dashicons dashicons-chart-bar"></div></a>' |
|
442 | - . "\n\t"; |
|
443 | - } |
|
444 | - if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
445 | - EE_Registry::instance()->load_helper('MSG_Template'); |
|
446 | - $action_links[] = EEH_MSG_Template::get_message_action_link( |
|
447 | - 'see_notifications_for', |
|
448 | - null, |
|
449 | - array('EVT_ID' => $event->ID()) |
|
450 | - ); |
|
451 | - } |
|
452 | - return $action_links; |
|
453 | - } |
|
454 | - |
|
455 | - |
|
456 | - /** |
|
457 | - * @param $items |
|
458 | - * @return mixed |
|
459 | - */ |
|
460 | - public function additional_legend_items($items) |
|
461 | - { |
|
462 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
463 | - 'ee_read_registrations', |
|
464 | - 'espresso_registrations_reports' |
|
465 | - ) |
|
466 | - ) { |
|
467 | - $items['reports'] = array( |
|
468 | - 'class' => 'dashicons dashicons-chart-bar', |
|
469 | - 'desc' => esc_html__('Event Reports', 'event_espresso'), |
|
470 | - ); |
|
471 | - } |
|
472 | - if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
473 | - $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for'); |
|
474 | - if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) { |
|
475 | - $items['view_related_messages'] = array( |
|
476 | - 'class' => $related_for_icon['css_class'], |
|
477 | - 'desc' => $related_for_icon['label'], |
|
478 | - ); |
|
479 | - } |
|
480 | - } |
|
481 | - return $items; |
|
482 | - } |
|
483 | - |
|
484 | - |
|
485 | - /** |
|
486 | - * This is the callback method for the duplicate event route |
|
487 | - * Method looks for 'EVT_ID' in the request and retrieves that event and its details and duplicates them |
|
488 | - * into a new event. We add a hook so that any plugins that add extra event details can hook into this |
|
489 | - * action. Note that the dupe will have **DUPLICATE** as its title and slug. |
|
490 | - * After duplication the redirect is to the new event edit page. |
|
491 | - * |
|
492 | - * @return void |
|
493 | - * @access protected |
|
494 | - * @throws EE_Error If EE_Event is not available with given ID |
|
495 | - */ |
|
496 | - protected function _duplicate_event() |
|
497 | - { |
|
498 | - // first make sure the ID for the event is in the request. |
|
499 | - // If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?) |
|
500 | - if (! isset($this->_req_data['EVT_ID'])) { |
|
501 | - EE_Error::add_error( |
|
502 | - esc_html__( |
|
503 | - 'In order to duplicate an event an Event ID is required. None was given.', |
|
504 | - 'event_espresso' |
|
505 | - ), |
|
506 | - __FILE__, |
|
507 | - __FUNCTION__, |
|
508 | - __LINE__ |
|
509 | - ); |
|
510 | - $this->_redirect_after_action(false, '', '', array(), true); |
|
511 | - return; |
|
512 | - } |
|
513 | - //k we've got EVT_ID so let's use that to get the event we'll duplicate |
|
514 | - $orig_event = EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']); |
|
515 | - if (! $orig_event instanceof EE_Event) { |
|
516 | - throw new EE_Error( |
|
517 | - sprintf( |
|
518 | - esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'), |
|
519 | - $this->_req_data['EVT_ID'] |
|
520 | - ) |
|
521 | - ); |
|
522 | - } |
|
523 | - //k now let's clone the $orig_event before getting relations |
|
524 | - $new_event = clone $orig_event; |
|
525 | - //original datetimes |
|
526 | - $orig_datetimes = $orig_event->get_many_related('Datetime'); |
|
527 | - //other original relations |
|
528 | - $orig_ven = $orig_event->get_many_related('Venue'); |
|
529 | - //reset the ID and modify other details to make it clear this is a dupe |
|
530 | - $new_event->set('EVT_ID', 0); |
|
531 | - $new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso'); |
|
532 | - $new_event->set('EVT_name', $new_name); |
|
533 | - $new_event->set( |
|
534 | - 'EVT_slug', |
|
535 | - wp_unique_post_slug( |
|
536 | - sanitize_title($orig_event->name()), |
|
537 | - 0, |
|
538 | - 'publish', |
|
539 | - 'espresso_events', |
|
540 | - 0 |
|
541 | - ) |
|
542 | - ); |
|
543 | - $new_event->set('status', 'draft'); |
|
544 | - //duplicate discussion settings |
|
545 | - $new_event->set('comment_status', $orig_event->get('comment_status')); |
|
546 | - $new_event->set('ping_status', $orig_event->get('ping_status')); |
|
547 | - //save the new event |
|
548 | - $new_event->save(); |
|
549 | - //venues |
|
550 | - foreach ($orig_ven as $ven) { |
|
551 | - $new_event->_add_relation_to($ven, 'Venue'); |
|
552 | - } |
|
553 | - $new_event->save(); |
|
554 | - //now we need to get the question group relations and handle that |
|
555 | - //first primary question groups |
|
556 | - $orig_primary_qgs = $orig_event->get_many_related( |
|
557 | - 'Question_Group', |
|
558 | - array(array('Event_Question_Group.EQG_primary' => 1)) |
|
559 | - ); |
|
560 | - if (! empty($orig_primary_qgs)) { |
|
561 | - foreach ($orig_primary_qgs as $id => $obj) { |
|
562 | - if ($obj instanceof EE_Question_Group) { |
|
563 | - $new_event->_add_relation_to($obj, 'Question_Group', array('EQG_primary' => 1)); |
|
564 | - } |
|
565 | - } |
|
566 | - } |
|
567 | - //next additional attendee question groups |
|
568 | - $orig_additional_qgs = $orig_event->get_many_related( |
|
569 | - 'Question_Group', |
|
570 | - array(array('Event_Question_Group.EQG_primary' => 0)) |
|
571 | - ); |
|
572 | - if (! empty($orig_additional_qgs)) { |
|
573 | - foreach ($orig_additional_qgs as $id => $obj) { |
|
574 | - if ($obj instanceof EE_Question_Group) { |
|
575 | - $new_event->_add_relation_to($obj, 'Question_Group', array('EQG_primary' => 0)); |
|
576 | - } |
|
577 | - } |
|
578 | - } |
|
579 | - |
|
580 | - $new_event->save(); |
|
581 | - |
|
582 | - //k now that we have the new event saved we can loop through the datetimes and start adding relations. |
|
583 | - $cloned_tickets = array(); |
|
584 | - foreach ($orig_datetimes as $orig_dtt) { |
|
585 | - if (! $orig_dtt instanceof EE_Datetime) { |
|
586 | - continue; |
|
587 | - } |
|
588 | - $new_dtt = clone $orig_dtt; |
|
589 | - $orig_tkts = $orig_dtt->tickets(); |
|
590 | - //save new dtt then add to event |
|
591 | - $new_dtt->set('DTT_ID', 0); |
|
592 | - $new_dtt->set('DTT_sold', 0); |
|
593 | - $new_dtt->set_reserved(0); |
|
594 | - $new_dtt->save(); |
|
595 | - $new_event->_add_relation_to($new_dtt, 'Datetime'); |
|
596 | - $new_event->save(); |
|
597 | - //now let's get the ticket relations setup. |
|
598 | - foreach ((array)$orig_tkts as $orig_tkt) { |
|
599 | - //it's possible a datetime will have no tickets so let's verify we HAVE a ticket first. |
|
600 | - if (! $orig_tkt instanceof EE_Ticket) { |
|
601 | - continue; |
|
602 | - } |
|
603 | - //is this ticket archived? If it is then let's skip |
|
604 | - if ($orig_tkt->get('TKT_deleted')) { |
|
605 | - continue; |
|
606 | - } |
|
607 | - // does this original ticket already exist in the clone_tickets cache? |
|
608 | - // If so we'll just use the new ticket from it. |
|
609 | - if (isset($cloned_tickets[$orig_tkt->ID()])) { |
|
610 | - $new_tkt = $cloned_tickets[$orig_tkt->ID()]; |
|
611 | - } else { |
|
612 | - $new_tkt = clone $orig_tkt; |
|
613 | - //get relations on the $orig_tkt that we need to setup. |
|
614 | - $orig_prices = $orig_tkt->prices(); |
|
615 | - $new_tkt->set('TKT_ID', 0); |
|
616 | - $new_tkt->set('TKT_sold', 0); |
|
617 | - $new_tkt->set('TKT_reserved', 0); |
|
618 | - $new_tkt->save(); //make sure new ticket has ID. |
|
619 | - //price relations on new ticket need to be setup. |
|
620 | - foreach ($orig_prices as $orig_price) { |
|
621 | - $new_price = clone $orig_price; |
|
622 | - $new_price->set('PRC_ID', 0); |
|
623 | - $new_price->save(); |
|
624 | - $new_tkt->_add_relation_to($new_price, 'Price'); |
|
625 | - $new_tkt->save(); |
|
626 | - } |
|
627 | - |
|
628 | - do_action( |
|
629 | - 'AHEE__Extend_Events_Admin_Page___duplicate_event__duplicate_ticket__after', |
|
630 | - $orig_tkt, |
|
631 | - $new_tkt, |
|
632 | - $orig_prices, |
|
633 | - $orig_event, |
|
634 | - $orig_dtt, |
|
635 | - $new_dtt |
|
636 | - ); |
|
637 | - } |
|
638 | - // k now we can add the new ticket as a relation to the new datetime |
|
639 | - // and make sure its added to our cached $cloned_tickets array |
|
640 | - // for use with later datetimes that have the same ticket. |
|
641 | - $new_dtt->_add_relation_to($new_tkt, 'Ticket'); |
|
642 | - $new_dtt->save(); |
|
643 | - $cloned_tickets[$orig_tkt->ID()] = $new_tkt; |
|
644 | - } |
|
645 | - } |
|
646 | - //clone taxonomy information |
|
647 | - $taxonomies_to_clone_with = apply_filters( |
|
648 | - 'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone', |
|
649 | - array('espresso_event_categories', 'espresso_event_type', 'post_tag') |
|
650 | - ); |
|
651 | - //get terms for original event (notice) |
|
652 | - $orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with); |
|
653 | - //loop through terms and add them to new event. |
|
654 | - foreach ($orig_terms as $term) { |
|
655 | - wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true); |
|
656 | - } |
|
657 | - |
|
658 | - //duplicate other core WP_Post items for this event. |
|
659 | - //post thumbnail (feature image). |
|
660 | - $feature_image_id = get_post_thumbnail_id($orig_event->ID()); |
|
661 | - if ($feature_image_id) { |
|
662 | - update_post_meta($new_event->ID(), '_thumbnail_id', $feature_image_id); |
|
663 | - } |
|
664 | - |
|
665 | - //duplicate page_template setting |
|
666 | - $page_template = get_post_meta($orig_event->ID(), '_wp_page_template', true); |
|
667 | - if ($page_template) { |
|
668 | - update_post_meta($new_event->ID(), '_wp_page_template', $page_template); |
|
669 | - } |
|
670 | - |
|
671 | - do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event); |
|
672 | - //now let's redirect to the edit page for this duplicated event if we have a new event id. |
|
673 | - if ($new_event->ID()) { |
|
674 | - $redirect_args = array( |
|
675 | - 'post' => $new_event->ID(), |
|
676 | - 'action' => 'edit', |
|
677 | - ); |
|
678 | - EE_Error::add_success( |
|
679 | - esc_html__( |
|
680 | - 'Event successfully duplicated. Please review the details below and make any necessary edits', |
|
681 | - 'event_espresso' |
|
682 | - ) |
|
683 | - ); |
|
684 | - } else { |
|
685 | - $redirect_args = array( |
|
686 | - 'action' => 'default', |
|
687 | - ); |
|
688 | - EE_Error::add_error( |
|
689 | - esc_html__('Not able to duplicate event. Something went wrong.', 'event_espresso'), |
|
690 | - __FILE__, |
|
691 | - __FUNCTION__, |
|
692 | - __LINE__ |
|
693 | - ); |
|
694 | - } |
|
695 | - $this->_redirect_after_action(false, '', '', $redirect_args, true); |
|
696 | - } |
|
697 | - |
|
698 | - |
|
699 | - /** |
|
700 | - * Generates output for the import page. |
|
701 | - * @throws DomainException |
|
702 | - */ |
|
703 | - protected function _import_page() |
|
704 | - { |
|
705 | - $title = esc_html__('Import', 'event_espresso'); |
|
706 | - $intro = esc_html__( |
|
707 | - 'If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ', |
|
708 | - 'event_espresso' |
|
709 | - ); |
|
710 | - $form_url = EVENTS_ADMIN_URL; |
|
711 | - $action = 'import_events'; |
|
712 | - $type = 'csv'; |
|
713 | - $this->_template_args['form'] = EE_Import::instance()->upload_form( |
|
714 | - $title, $intro, $form_url, $action, $type |
|
715 | - ); |
|
716 | - $this->_template_args['sample_file_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
717 | - array('action' => 'sample_export_file'), |
|
718 | - $this->_admin_base_url |
|
719 | - ); |
|
720 | - $content = EEH_Template::display_template( |
|
721 | - EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php', |
|
722 | - $this->_template_args, |
|
723 | - true |
|
724 | - ); |
|
725 | - $this->_template_args['admin_page_content'] = $content; |
|
726 | - $this->display_admin_page_with_sidebar(); |
|
727 | - } |
|
728 | - |
|
729 | - |
|
730 | - /** |
|
731 | - * _import_events |
|
732 | - * This handles displaying the screen and running imports for importing events. |
|
733 | - * |
|
734 | - * @return void |
|
735 | - */ |
|
736 | - protected function _import_events() |
|
737 | - { |
|
738 | - require_once(EE_CLASSES . 'EE_Import.class.php'); |
|
739 | - $success = EE_Import::instance()->import(); |
|
740 | - $this->_redirect_after_action($success, 'Import File', 'ran', array('action' => 'import_page'), true); |
|
741 | - } |
|
742 | - |
|
743 | - |
|
744 | - /** |
|
745 | - * _events_export |
|
746 | - * Will export all (or just the given event) to a Excel compatible file. |
|
747 | - * |
|
748 | - * @access protected |
|
749 | - * @return void |
|
750 | - */ |
|
751 | - protected function _events_export() |
|
752 | - { |
|
753 | - if (isset($this->_req_data['EVT_ID'])) { |
|
754 | - $event_ids = $this->_req_data['EVT_ID']; |
|
755 | - } elseif (isset($this->_req_data['EVT_IDs'])) { |
|
756 | - $event_ids = $this->_req_data['EVT_IDs']; |
|
757 | - } else { |
|
758 | - $event_ids = null; |
|
759 | - } |
|
760 | - //todo: I don't like doing this but it'll do until we modify EE_Export Class. |
|
761 | - $new_request_args = array( |
|
762 | - 'export' => 'report', |
|
763 | - 'action' => 'all_event_data', |
|
764 | - 'EVT_ID' => $event_ids, |
|
765 | - ); |
|
766 | - $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
767 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
768 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
769 | - $EE_Export = EE_Export::instance($this->_req_data); |
|
770 | - $EE_Export->export(); |
|
771 | - } |
|
772 | - } |
|
773 | - |
|
774 | - |
|
775 | - /** |
|
776 | - * handle category exports() |
|
777 | - * |
|
778 | - * @return void |
|
779 | - */ |
|
780 | - protected function _categories_export() |
|
781 | - { |
|
782 | - //todo: I don't like doing this but it'll do until we modify EE_Export Class. |
|
783 | - $new_request_args = array( |
|
784 | - 'export' => 'report', |
|
785 | - 'action' => 'categories', |
|
786 | - 'category_ids' => $this->_req_data['EVT_CAT_ID'], |
|
787 | - ); |
|
788 | - $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
789 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
790 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
791 | - $EE_Export = EE_Export::instance($this->_req_data); |
|
792 | - $EE_Export->export(); |
|
793 | - } |
|
794 | - } |
|
795 | - |
|
796 | - |
|
797 | - /** |
|
798 | - * Creates a sample CSV file for importing |
|
799 | - */ |
|
800 | - protected function _sample_export_file() |
|
801 | - { |
|
802 | - // require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
803 | - EE_Export::instance()->export_sample(); |
|
804 | - } |
|
805 | - |
|
806 | - |
|
807 | - /************* Template Settings *************/ |
|
808 | - /** |
|
809 | - * Generates template settings page output |
|
810 | - * @throws DomainException |
|
811 | - * @throws EE_Error |
|
812 | - */ |
|
813 | - protected function _template_settings() |
|
814 | - { |
|
815 | - $this->_template_args['values'] = $this->_yes_no_values; |
|
816 | - /** |
|
817 | - * Note leaving this filter in for backward compatibility this was moved in 4.6.x |
|
818 | - * from General_Settings_Admin_Page to here. |
|
819 | - */ |
|
820 | - $this->_template_args = apply_filters( |
|
821 | - 'FHEE__General_Settings_Admin_Page__template_settings__template_args', |
|
822 | - $this->_template_args |
|
823 | - ); |
|
824 | - $this->_set_add_edit_form_tags('update_template_settings'); |
|
825 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
826 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
827 | - EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php', |
|
828 | - $this->_template_args, |
|
829 | - true |
|
830 | - ); |
|
831 | - $this->display_admin_page_with_sidebar(); |
|
832 | - } |
|
833 | - |
|
834 | - |
|
835 | - /** |
|
836 | - * Handler for updating template settings. |
|
837 | - */ |
|
838 | - protected function _update_template_settings() |
|
839 | - { |
|
840 | - /** |
|
841 | - * Note leaving this filter in for backward compatibility this was moved in 4.6.x |
|
842 | - * from General_Settings_Admin_Page to here. |
|
843 | - */ |
|
844 | - EE_Registry::instance()->CFG->template_settings = apply_filters( |
|
845 | - 'FHEE__General_Settings_Admin_Page__update_template_settings__data', |
|
846 | - EE_Registry::instance()->CFG->template_settings, |
|
847 | - $this->_req_data |
|
848 | - ); |
|
849 | - //update custom post type slugs and detect if we need to flush rewrite rules |
|
850 | - $old_slug = EE_Registry::instance()->CFG->core->event_cpt_slug; |
|
851 | - EE_Registry::instance()->CFG->core->event_cpt_slug = empty($this->_req_data['event_cpt_slug']) |
|
852 | - ? EE_Registry::instance()->CFG->core->event_cpt_slug |
|
853 | - : sanitize_title_with_dashes($this->_req_data['event_cpt_slug']); |
|
854 | - $what = 'Template Settings'; |
|
855 | - $success = $this->_update_espresso_configuration( |
|
856 | - $what, |
|
857 | - EE_Registry::instance()->CFG->template_settings, |
|
858 | - __FILE__, |
|
859 | - __FUNCTION__, |
|
860 | - __LINE__ |
|
861 | - ); |
|
862 | - if (EE_Registry::instance()->CFG->core->event_cpt_slug != $old_slug) { |
|
863 | - update_option('ee_flush_rewrite_rules', true); |
|
864 | - } |
|
865 | - $this->_redirect_after_action($success, $what, 'updated', array('action' => 'template_settings')); |
|
866 | - } |
|
867 | - |
|
868 | - |
|
869 | - /** |
|
870 | - * _premium_event_editor_meta_boxes |
|
871 | - * add all metaboxes related to the event_editor |
|
872 | - * |
|
873 | - * @access protected |
|
874 | - * @return void |
|
875 | - * @throws EE_Error |
|
876 | - */ |
|
877 | - protected function _premium_event_editor_meta_boxes() |
|
878 | - { |
|
879 | - $this->verify_cpt_object(); |
|
880 | - add_meta_box( |
|
881 | - 'espresso_event_editor_event_options', |
|
882 | - esc_html__('Event Registration Options', 'event_espresso'), |
|
883 | - array($this, 'registration_options_meta_box'), |
|
884 | - $this->page_slug, |
|
885 | - 'side', |
|
886 | - 'core' |
|
887 | - ); |
|
888 | - } |
|
889 | - |
|
890 | - |
|
891 | - /** |
|
892 | - * override caf metabox |
|
893 | - * |
|
894 | - * @return void |
|
895 | - * @throws DomainException |
|
896 | - */ |
|
897 | - public function registration_options_meta_box() |
|
898 | - { |
|
899 | - $yes_no_values = array( |
|
900 | - array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')), |
|
901 | - array('id' => false, 'text' => esc_html__('No', 'event_espresso')), |
|
902 | - ); |
|
903 | - $default_reg_status_values = EEM_Registration::reg_status_array( |
|
904 | - array( |
|
905 | - EEM_Registration::status_id_cancelled, |
|
906 | - EEM_Registration::status_id_declined, |
|
907 | - EEM_Registration::status_id_incomplete, |
|
908 | - EEM_Registration::status_id_wait_list, |
|
909 | - ), |
|
910 | - true |
|
911 | - ); |
|
912 | - $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false); |
|
913 | - $template_args['_event'] = $this->_cpt_model_obj; |
|
914 | - $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit(); |
|
915 | - $template_args['default_registration_status'] = EEH_Form_Fields::select_input( |
|
916 | - 'default_reg_status', |
|
917 | - $default_reg_status_values, |
|
918 | - $this->_cpt_model_obj->default_registration_status() |
|
919 | - ); |
|
920 | - $template_args['display_description'] = EEH_Form_Fields::select_input( |
|
921 | - 'display_desc', |
|
922 | - $yes_no_values, |
|
923 | - $this->_cpt_model_obj->display_description() |
|
924 | - ); |
|
925 | - $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input( |
|
926 | - 'display_ticket_selector', |
|
927 | - $yes_no_values, |
|
928 | - $this->_cpt_model_obj->display_ticket_selector(), |
|
929 | - '', |
|
930 | - '', |
|
931 | - false |
|
932 | - ); |
|
933 | - $template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input( |
|
934 | - 'EVT_default_registration_status', |
|
935 | - $default_reg_status_values, |
|
936 | - $this->_cpt_model_obj->default_registration_status() |
|
937 | - ); |
|
938 | - $template_args['additional_registration_options'] = apply_filters( |
|
939 | - 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', |
|
940 | - '', |
|
941 | - $template_args, |
|
942 | - $yes_no_values, |
|
943 | - $default_reg_status_values |
|
944 | - ); |
|
945 | - EEH_Template::display_template( |
|
946 | - EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
947 | - $template_args |
|
948 | - ); |
|
949 | - } |
|
950 | - |
|
951 | - |
|
952 | - |
|
953 | - /** |
|
954 | - * wp_list_table_mods for caf |
|
955 | - * ============================ |
|
956 | - */ |
|
957 | - /** |
|
958 | - * hook into list table filters and provide filters for caffeinated list table |
|
959 | - * |
|
960 | - * @param array $old_filters any existing filters present |
|
961 | - * @param array $list_table_obj the list table object |
|
962 | - * @return array new filters |
|
963 | - */ |
|
964 | - public function list_table_filters($old_filters, $list_table_obj) |
|
965 | - { |
|
966 | - $filters = array(); |
|
967 | - //first month/year filters |
|
968 | - $filters[] = $this->espresso_event_months_dropdown(); |
|
969 | - $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null; |
|
970 | - //active status dropdown |
|
971 | - if ($status !== 'draft') { |
|
972 | - $filters[] = $this->active_status_dropdown( |
|
973 | - isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : '' |
|
974 | - ); |
|
975 | - } |
|
976 | - //category filter |
|
977 | - $filters[] = $this->category_dropdown(); |
|
978 | - return array_merge($old_filters, $filters); |
|
979 | - } |
|
980 | - |
|
981 | - |
|
982 | - /** |
|
983 | - * espresso_event_months_dropdown |
|
984 | - * |
|
985 | - * @access public |
|
986 | - * @return string dropdown listing month/year selections for events. |
|
987 | - */ |
|
988 | - public function espresso_event_months_dropdown() |
|
989 | - { |
|
990 | - // what we need to do is get all PRIMARY datetimes for all events to filter on. |
|
991 | - // Note we need to include any other filters that are set! |
|
992 | - $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null; |
|
993 | - //categories? |
|
994 | - $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 |
|
995 | - ? $this->_req_data['EVT_CAT'] |
|
996 | - : null; |
|
997 | - //active status? |
|
998 | - $active_status = isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : null; |
|
999 | - $cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : ''; |
|
1000 | - return EEH_Form_Fields::generate_event_months_dropdown($cur_date, $status, $category, $active_status); |
|
1001 | - } |
|
1002 | - |
|
1003 | - |
|
1004 | - /** |
|
1005 | - * returns a list of "active" statuses on the event |
|
1006 | - * |
|
1007 | - * @param string $current_value whatever the current active status is |
|
1008 | - * @return string |
|
1009 | - */ |
|
1010 | - public function active_status_dropdown($current_value = '') |
|
1011 | - { |
|
1012 | - $select_name = 'active_status'; |
|
1013 | - $values = array( |
|
1014 | - 'none' => esc_html__('Show Active/Inactive', 'event_espresso'), |
|
1015 | - 'active' => esc_html__('Active', 'event_espresso'), |
|
1016 | - 'upcoming' => esc_html__('Upcoming', 'event_espresso'), |
|
1017 | - 'expired' => esc_html__('Expired', 'event_espresso'), |
|
1018 | - 'inactive' => esc_html__('Inactive', 'event_espresso'), |
|
1019 | - ); |
|
1020 | - $id = 'id="espresso-active-status-dropdown-filter"'; |
|
1021 | - $class = 'wide'; |
|
1022 | - return EEH_Form_Fields::select_input($select_name, $values, $current_value, $id, $class); |
|
1023 | - } |
|
1024 | - |
|
1025 | - |
|
1026 | - /** |
|
1027 | - * output a dropdown of the categories for the category filter on the event admin list table |
|
1028 | - * |
|
1029 | - * @access public |
|
1030 | - * @return string html |
|
1031 | - */ |
|
1032 | - public function category_dropdown() |
|
1033 | - { |
|
1034 | - $cur_cat = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1; |
|
1035 | - return EEH_Form_Fields::generate_event_category_dropdown($cur_cat); |
|
1036 | - } |
|
1037 | - |
|
1038 | - |
|
1039 | - /** |
|
1040 | - * get total number of events today |
|
1041 | - * |
|
1042 | - * @access public |
|
1043 | - * @return int |
|
1044 | - * @throws EE_Error |
|
1045 | - */ |
|
1046 | - public function total_events_today() |
|
1047 | - { |
|
1048 | - $start = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1049 | - 'DTT_EVT_start', |
|
1050 | - date('Y-m-d') . ' 00:00:00', |
|
1051 | - 'Y-m-d H:i:s', |
|
1052 | - 'UTC' |
|
1053 | - ); |
|
1054 | - $end = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1055 | - 'DTT_EVT_start', |
|
1056 | - date('Y-m-d') . ' 23:59:59', |
|
1057 | - 'Y-m-d H:i:s', |
|
1058 | - 'UTC' |
|
1059 | - ); |
|
1060 | - $where = array( |
|
1061 | - 'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)), |
|
1062 | - ); |
|
1063 | - $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
1064 | - return $count; |
|
1065 | - } |
|
1066 | - |
|
1067 | - |
|
1068 | - /** |
|
1069 | - * get total number of events this month |
|
1070 | - * |
|
1071 | - * @access public |
|
1072 | - * @return int |
|
1073 | - * @throws EE_Error |
|
1074 | - */ |
|
1075 | - public function total_events_this_month() |
|
1076 | - { |
|
1077 | - //Dates |
|
1078 | - $this_year_r = date('Y'); |
|
1079 | - $this_month_r = date('m'); |
|
1080 | - $days_this_month = date('t'); |
|
1081 | - $start = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1082 | - 'DTT_EVT_start', |
|
1083 | - $this_year_r . '-' . $this_month_r . '-01 00:00:00', |
|
1084 | - 'Y-m-d H:i:s', |
|
1085 | - 'UTC' |
|
1086 | - ); |
|
1087 | - $end = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1088 | - 'DTT_EVT_start', |
|
1089 | - $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59', |
|
1090 | - 'Y-m-d H:i:s', |
|
1091 | - 'UTC' |
|
1092 | - ); |
|
1093 | - $where = array( |
|
1094 | - 'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)), |
|
1095 | - ); |
|
1096 | - $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
1097 | - return $count; |
|
1098 | - } |
|
1099 | - |
|
1100 | - |
|
1101 | - /** DEFAULT TICKETS STUFF **/ |
|
1102 | - |
|
1103 | - /** |
|
1104 | - * Output default tickets list table view. |
|
1105 | - */ |
|
1106 | - public function _tickets_overview_list_table() |
|
1107 | - { |
|
1108 | - $this->_search_btn_label = esc_html__('Tickets', 'event_espresso'); |
|
1109 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
1110 | - } |
|
1111 | - |
|
1112 | - |
|
1113 | - /** |
|
1114 | - * @param int $per_page |
|
1115 | - * @param bool $count |
|
1116 | - * @param bool $trashed |
|
1117 | - * @return \EE_Soft_Delete_Base_Class[]|int |
|
1118 | - */ |
|
1119 | - public function get_default_tickets($per_page = 10, $count = false, $trashed = false) |
|
1120 | - { |
|
1121 | - $orderby = empty($this->_req_data['orderby']) ? 'TKT_name' : $this->_req_data['orderby']; |
|
1122 | - $order = empty($this->_req_data['order']) ? 'ASC' : $this->_req_data['order']; |
|
1123 | - switch ($orderby) { |
|
1124 | - case 'TKT_name': |
|
1125 | - $orderby = array('TKT_name' => $order); |
|
1126 | - break; |
|
1127 | - case 'TKT_price': |
|
1128 | - $orderby = array('TKT_price' => $order); |
|
1129 | - break; |
|
1130 | - case 'TKT_uses': |
|
1131 | - $orderby = array('TKT_uses' => $order); |
|
1132 | - break; |
|
1133 | - case 'TKT_min': |
|
1134 | - $orderby = array('TKT_min' => $order); |
|
1135 | - break; |
|
1136 | - case 'TKT_max': |
|
1137 | - $orderby = array('TKT_max' => $order); |
|
1138 | - break; |
|
1139 | - case 'TKT_qty': |
|
1140 | - $orderby = array('TKT_qty' => $order); |
|
1141 | - break; |
|
1142 | - } |
|
1143 | - $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) |
|
1144 | - ? $this->_req_data['paged'] |
|
1145 | - : 1; |
|
1146 | - $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) |
|
1147 | - ? $this->_req_data['perpage'] |
|
1148 | - : $per_page; |
|
1149 | - $_where = array( |
|
1150 | - 'TKT_is_default' => 1, |
|
1151 | - 'TKT_deleted' => $trashed, |
|
1152 | - ); |
|
1153 | - $offset = ($current_page - 1) * $per_page; |
|
1154 | - $limit = array($offset, $per_page); |
|
1155 | - if (isset($this->_req_data['s'])) { |
|
1156 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
1157 | - $_where['OR'] = array( |
|
1158 | - 'TKT_name' => array('LIKE', $sstr), |
|
1159 | - 'TKT_description' => array('LIKE', $sstr), |
|
1160 | - ); |
|
1161 | - } |
|
1162 | - $query_params = array( |
|
1163 | - $_where, |
|
1164 | - 'order_by' => $orderby, |
|
1165 | - 'limit' => $limit, |
|
1166 | - 'group_by' => 'TKT_ID', |
|
1167 | - ); |
|
1168 | - if ($count) { |
|
1169 | - return EEM_Ticket::instance()->count_deleted_and_undeleted(array($_where)); |
|
1170 | - } else { |
|
1171 | - return EEM_Ticket::instance()->get_all_deleted_and_undeleted($query_params); |
|
1172 | - } |
|
1173 | - } |
|
1174 | - |
|
1175 | - |
|
1176 | - /** |
|
1177 | - * @param bool $trash |
|
1178 | - * @throws EE_Error |
|
1179 | - */ |
|
1180 | - protected function _trash_or_restore_ticket($trash = false) |
|
1181 | - { |
|
1182 | - $success = 1; |
|
1183 | - $TKT = EEM_Ticket::instance(); |
|
1184 | - //checkboxes? |
|
1185 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1186 | - //if array has more than one element then success message should be plural |
|
1187 | - $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
1188 | - //cycle thru the boxes |
|
1189 | - while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) { |
|
1190 | - if ($trash) { |
|
1191 | - if (! $TKT->delete_by_ID($TKT_ID)) { |
|
1192 | - $success = 0; |
|
1193 | - } |
|
1194 | - } else { |
|
1195 | - if (! $TKT->restore_by_ID($TKT_ID)) { |
|
1196 | - $success = 0; |
|
1197 | - } |
|
1198 | - } |
|
1199 | - } |
|
1200 | - } else { |
|
1201 | - //grab single id and trash |
|
1202 | - $TKT_ID = absint($this->_req_data['TKT_ID']); |
|
1203 | - if ($trash) { |
|
1204 | - if (! $TKT->delete_by_ID($TKT_ID)) { |
|
1205 | - $success = 0; |
|
1206 | - } |
|
1207 | - } else { |
|
1208 | - if (! $TKT->restore_by_ID($TKT_ID)) { |
|
1209 | - $success = 0; |
|
1210 | - } |
|
1211 | - } |
|
1212 | - } |
|
1213 | - $action_desc = $trash ? 'moved to the trash' : 'restored'; |
|
1214 | - $query_args = array( |
|
1215 | - 'action' => 'ticket_list_table', |
|
1216 | - 'status' => $trash ? '' : 'trashed', |
|
1217 | - ); |
|
1218 | - $this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args); |
|
1219 | - } |
|
1220 | - |
|
1221 | - |
|
1222 | - /** |
|
1223 | - * Handles trashing default ticket. |
|
1224 | - */ |
|
1225 | - protected function _delete_ticket() |
|
1226 | - { |
|
1227 | - $success = 1; |
|
1228 | - //checkboxes? |
|
1229 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1230 | - //if array has more than one element then success message should be plural |
|
1231 | - $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
1232 | - //cycle thru the boxes |
|
1233 | - while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) { |
|
1234 | - //delete |
|
1235 | - if (! $this->_delete_the_ticket($TKT_ID)) { |
|
1236 | - $success = 0; |
|
1237 | - } |
|
1238 | - } |
|
1239 | - } else { |
|
1240 | - //grab single id and trash |
|
1241 | - $TKT_ID = absint($this->_req_data['TKT_ID']); |
|
1242 | - if (! $this->_delete_the_ticket($TKT_ID)) { |
|
1243 | - $success = 0; |
|
1244 | - } |
|
1245 | - } |
|
1246 | - $action_desc = 'deleted'; |
|
1247 | - $query_args = array( |
|
1248 | - 'action' => 'ticket_list_table', |
|
1249 | - 'status' => 'trashed', |
|
1250 | - ); |
|
1251 | - //fail safe. If the default ticket count === 1 then we need to redirect to event overview. |
|
1252 | - if (EEM_Ticket::instance()->count_deleted_and_undeleted( |
|
1253 | - array(array('TKT_is_default' => 1)), |
|
1254 | - 'TKT_ID', |
|
1255 | - true |
|
1256 | - ) |
|
1257 | - ) { |
|
1258 | - $query_args = array(); |
|
1259 | - } |
|
1260 | - $this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args); |
|
1261 | - } |
|
1262 | - |
|
1263 | - |
|
1264 | - /** |
|
1265 | - * @param int $TKT_ID |
|
1266 | - * @return bool|int |
|
1267 | - * @throws EE_Error |
|
1268 | - */ |
|
1269 | - protected function _delete_the_ticket($TKT_ID) |
|
1270 | - { |
|
1271 | - $tkt = EEM_Ticket::instance()->get_one_by_ID($TKT_ID); |
|
1272 | - $tkt->_remove_relations('Datetime'); |
|
1273 | - //delete all related prices first |
|
1274 | - $tkt->delete_related_permanently('Price'); |
|
1275 | - return $tkt->delete_permanently(); |
|
1276 | - } |
|
17 | + /** |
|
18 | + * Extend_Events_Admin_Page constructor. |
|
19 | + * |
|
20 | + * @param bool $routing |
|
21 | + */ |
|
22 | + public function __construct($routing = true) |
|
23 | + { |
|
24 | + parent::__construct($routing); |
|
25 | + if (! defined('EVENTS_CAF_TEMPLATE_PATH')) { |
|
26 | + define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/'); |
|
27 | + define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/'); |
|
28 | + define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/'); |
|
29 | + } |
|
30 | + } |
|
31 | + |
|
32 | + |
|
33 | + /** |
|
34 | + * Sets routes. |
|
35 | + */ |
|
36 | + protected function _extend_page_config() |
|
37 | + { |
|
38 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events'; |
|
39 | + //is there a evt_id in the request? |
|
40 | + $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) |
|
41 | + ? $this->_req_data['EVT_ID'] |
|
42 | + : 0; |
|
43 | + $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id; |
|
44 | + //tkt_id? |
|
45 | + $tkt_id = ! empty($this->_req_data['TKT_ID']) && ! is_array($this->_req_data['TKT_ID']) |
|
46 | + ? $this->_req_data['TKT_ID'] |
|
47 | + : 0; |
|
48 | + $new_page_routes = array( |
|
49 | + 'duplicate_event' => array( |
|
50 | + 'func' => '_duplicate_event', |
|
51 | + 'capability' => 'ee_edit_event', |
|
52 | + 'obj_id' => $evt_id, |
|
53 | + 'noheader' => true, |
|
54 | + ), |
|
55 | + 'ticket_list_table' => array( |
|
56 | + 'func' => '_tickets_overview_list_table', |
|
57 | + 'capability' => 'ee_read_default_tickets', |
|
58 | + ), |
|
59 | + 'trash_ticket' => array( |
|
60 | + 'func' => '_trash_or_restore_ticket', |
|
61 | + 'capability' => 'ee_delete_default_ticket', |
|
62 | + 'obj_id' => $tkt_id, |
|
63 | + 'noheader' => true, |
|
64 | + 'args' => array('trash' => true), |
|
65 | + ), |
|
66 | + 'trash_tickets' => array( |
|
67 | + 'func' => '_trash_or_restore_ticket', |
|
68 | + 'capability' => 'ee_delete_default_tickets', |
|
69 | + 'noheader' => true, |
|
70 | + 'args' => array('trash' => true), |
|
71 | + ), |
|
72 | + 'restore_ticket' => array( |
|
73 | + 'func' => '_trash_or_restore_ticket', |
|
74 | + 'capability' => 'ee_delete_default_ticket', |
|
75 | + 'obj_id' => $tkt_id, |
|
76 | + 'noheader' => true, |
|
77 | + ), |
|
78 | + 'restore_tickets' => array( |
|
79 | + 'func' => '_trash_or_restore_ticket', |
|
80 | + 'capability' => 'ee_delete_default_tickets', |
|
81 | + 'noheader' => true, |
|
82 | + ), |
|
83 | + 'delete_ticket' => array( |
|
84 | + 'func' => '_delete_ticket', |
|
85 | + 'capability' => 'ee_delete_default_ticket', |
|
86 | + 'obj_id' => $tkt_id, |
|
87 | + 'noheader' => true, |
|
88 | + ), |
|
89 | + 'delete_tickets' => array( |
|
90 | + 'func' => '_delete_ticket', |
|
91 | + 'capability' => 'ee_delete_default_tickets', |
|
92 | + 'noheader' => true, |
|
93 | + ), |
|
94 | + 'import_page' => array( |
|
95 | + 'func' => '_import_page', |
|
96 | + 'capability' => 'import', |
|
97 | + ), |
|
98 | + 'import' => array( |
|
99 | + 'func' => '_import_events', |
|
100 | + 'capability' => 'import', |
|
101 | + 'noheader' => true, |
|
102 | + ), |
|
103 | + 'import_events' => array( |
|
104 | + 'func' => '_import_events', |
|
105 | + 'capability' => 'import', |
|
106 | + 'noheader' => true, |
|
107 | + ), |
|
108 | + 'export_events' => array( |
|
109 | + 'func' => '_events_export', |
|
110 | + 'capability' => 'export', |
|
111 | + 'noheader' => true, |
|
112 | + ), |
|
113 | + 'export_categories' => array( |
|
114 | + 'func' => '_categories_export', |
|
115 | + 'capability' => 'export', |
|
116 | + 'noheader' => true, |
|
117 | + ), |
|
118 | + 'sample_export_file' => array( |
|
119 | + 'func' => '_sample_export_file', |
|
120 | + 'capability' => 'export', |
|
121 | + 'noheader' => true, |
|
122 | + ), |
|
123 | + 'update_template_settings' => array( |
|
124 | + 'func' => '_update_template_settings', |
|
125 | + 'capability' => 'manage_options', |
|
126 | + 'noheader' => true, |
|
127 | + ), |
|
128 | + ); |
|
129 | + $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
130 | + //partial route/config override |
|
131 | + $this->_page_config['import_events']['metaboxes'] = $this->_default_espresso_metaboxes; |
|
132 | + $this->_page_config['create_new']['metaboxes'][] = '_premium_event_editor_meta_boxes'; |
|
133 | + $this->_page_config['create_new']['qtips'][] = 'EE_Event_Editor_Tips'; |
|
134 | + $this->_page_config['edit']['qtips'][] = 'EE_Event_Editor_Tips'; |
|
135 | + $this->_page_config['edit']['metaboxes'][] = '_premium_event_editor_meta_boxes'; |
|
136 | + $this->_page_config['default']['list_table'] = 'Extend_Events_Admin_List_Table'; |
|
137 | + //add tickets tab but only if there are more than one default ticket! |
|
138 | + $tkt_count = EEM_Ticket::instance()->count_deleted_and_undeleted( |
|
139 | + array(array('TKT_is_default' => 1)), |
|
140 | + 'TKT_ID', |
|
141 | + true |
|
142 | + ); |
|
143 | + if ($tkt_count > 1) { |
|
144 | + $new_page_config = array( |
|
145 | + 'ticket_list_table' => array( |
|
146 | + 'nav' => array( |
|
147 | + 'label' => esc_html__('Default Tickets', 'event_espresso'), |
|
148 | + 'order' => 60, |
|
149 | + ), |
|
150 | + 'list_table' => 'Tickets_List_Table', |
|
151 | + 'require_nonce' => false, |
|
152 | + ), |
|
153 | + ); |
|
154 | + } |
|
155 | + //template settings |
|
156 | + $new_page_config['template_settings'] = array( |
|
157 | + 'nav' => array( |
|
158 | + 'label' => esc_html__('Templates', 'event_espresso'), |
|
159 | + 'order' => 30, |
|
160 | + ), |
|
161 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
162 | + 'help_tabs' => array( |
|
163 | + 'general_settings_templates_help_tab' => array( |
|
164 | + 'title' => esc_html__('Templates', 'event_espresso'), |
|
165 | + 'filename' => 'general_settings_templates', |
|
166 | + ), |
|
167 | + ), |
|
168 | + 'help_tour' => array('Templates_Help_Tour'), |
|
169 | + 'require_nonce' => false, |
|
170 | + ); |
|
171 | + $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
172 | + //add filters and actions |
|
173 | + //modifying _views |
|
174 | + add_filter( |
|
175 | + 'FHEE_event_datetime_metabox_add_additional_date_time_template', |
|
176 | + array($this, 'add_additional_datetime_button'), |
|
177 | + 10, |
|
178 | + 2 |
|
179 | + ); |
|
180 | + add_filter( |
|
181 | + 'FHEE_event_datetime_metabox_clone_button_template', |
|
182 | + array($this, 'add_datetime_clone_button'), |
|
183 | + 10, |
|
184 | + 2 |
|
185 | + ); |
|
186 | + add_filter( |
|
187 | + 'FHEE_event_datetime_metabox_timezones_template', |
|
188 | + array($this, 'datetime_timezones_template'), |
|
189 | + 10, |
|
190 | + 2 |
|
191 | + ); |
|
192 | + //filters for event list table |
|
193 | + add_filter('FHEE__Extend_Events_Admin_List_Table__filters', array($this, 'list_table_filters'), 10, 2); |
|
194 | + add_filter( |
|
195 | + 'FHEE__Events_Admin_List_Table__column_actions__action_links', |
|
196 | + array($this, 'extra_list_table_actions'), |
|
197 | + 10, |
|
198 | + 2 |
|
199 | + ); |
|
200 | + //legend item |
|
201 | + add_filter('FHEE__Events_Admin_Page___event_legend_items__items', array($this, 'additional_legend_items')); |
|
202 | + add_action('admin_init', array($this, 'admin_init')); |
|
203 | + //heartbeat stuff |
|
204 | + add_filter('heartbeat_received', array($this, 'heartbeat_response'), 10, 2); |
|
205 | + } |
|
206 | + |
|
207 | + |
|
208 | + /** |
|
209 | + * admin_init |
|
210 | + */ |
|
211 | + public function admin_init() |
|
212 | + { |
|
213 | + EE_Registry::$i18n_js_strings = array_merge( |
|
214 | + EE_Registry::$i18n_js_strings, |
|
215 | + array( |
|
216 | + 'image_confirm' => esc_html__( |
|
217 | + 'Do you really want to delete this image? Please remember to update your event to complete the removal.', |
|
218 | + 'event_espresso' |
|
219 | + ), |
|
220 | + 'event_starts_on' => esc_html__('Event Starts on', 'event_espresso'), |
|
221 | + 'event_ends_on' => esc_html__('Event Ends on', 'event_espresso'), |
|
222 | + 'event_datetime_actions' => esc_html__('Actions', 'event_espresso'), |
|
223 | + 'event_clone_dt_msg' => esc_html__('Clone this Event Date and Time', 'event_espresso'), |
|
224 | + 'remove_event_dt_msg' => esc_html__('Remove this Event Time', 'event_espresso'), |
|
225 | + ) |
|
226 | + ); |
|
227 | + } |
|
228 | + |
|
229 | + |
|
230 | + /** |
|
231 | + * This will be used to listen for any heartbeat data packages coming via the WordPress heartbeat API and handle |
|
232 | + * accordingly. |
|
233 | + * |
|
234 | + * @param array $response The existing heartbeat response array. |
|
235 | + * @param array $data The incoming data package. |
|
236 | + * @return array possibly appended response. |
|
237 | + */ |
|
238 | + public function heartbeat_response($response, $data) |
|
239 | + { |
|
240 | + /** |
|
241 | + * check whether count of tickets is approaching the potential |
|
242 | + * limits for the server. |
|
243 | + */ |
|
244 | + if (! empty($data['input_count'])) { |
|
245 | + $response['max_input_vars_check'] = EE_Registry::instance()->CFG->environment->max_input_vars_limit_check( |
|
246 | + $data['input_count'] |
|
247 | + ); |
|
248 | + } |
|
249 | + return $response; |
|
250 | + } |
|
251 | + |
|
252 | + |
|
253 | + /** |
|
254 | + * Add per page screen options to the default ticket list table view. |
|
255 | + */ |
|
256 | + protected function _add_screen_options_ticket_list_table() |
|
257 | + { |
|
258 | + $this->_per_page_screen_option(); |
|
259 | + } |
|
260 | + |
|
261 | + |
|
262 | + /** |
|
263 | + * @param string $return |
|
264 | + * @param int $id |
|
265 | + * @param string $new_title |
|
266 | + * @param string $new_slug |
|
267 | + * @return string |
|
268 | + */ |
|
269 | + public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) |
|
270 | + { |
|
271 | + $return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug); |
|
272 | + //make sure this is only when editing |
|
273 | + if (! empty($id)) { |
|
274 | + $href = EE_Admin_Page::add_query_args_and_nonce( |
|
275 | + array('action' => 'duplicate_event', 'EVT_ID' => $id), |
|
276 | + $this->_admin_base_url |
|
277 | + ); |
|
278 | + $title = esc_attr__('Duplicate Event', 'event_espresso'); |
|
279 | + $return .= '<a href="' |
|
280 | + . $href |
|
281 | + . '" title="' |
|
282 | + . $title |
|
283 | + . '" id="ee-duplicate-event-button" class="button button-small" value="duplicate_event">' |
|
284 | + . $title |
|
285 | + . '</a>'; |
|
286 | + } |
|
287 | + return $return; |
|
288 | + } |
|
289 | + |
|
290 | + |
|
291 | + /** |
|
292 | + * Set the list table views for the default ticket list table view. |
|
293 | + */ |
|
294 | + public function _set_list_table_views_ticket_list_table() |
|
295 | + { |
|
296 | + $this->_views = array( |
|
297 | + 'all' => array( |
|
298 | + 'slug' => 'all', |
|
299 | + 'label' => esc_html__('All', 'event_espresso'), |
|
300 | + 'count' => 0, |
|
301 | + 'bulk_action' => array( |
|
302 | + 'trash_tickets' => esc_html__('Move to Trash', 'event_espresso'), |
|
303 | + ), |
|
304 | + ), |
|
305 | + 'trashed' => array( |
|
306 | + 'slug' => 'trashed', |
|
307 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
308 | + 'count' => 0, |
|
309 | + 'bulk_action' => array( |
|
310 | + 'restore_tickets' => esc_html__('Restore from Trash', 'event_espresso'), |
|
311 | + 'delete_tickets' => esc_html__('Delete Permanently', 'event_espresso'), |
|
312 | + ), |
|
313 | + ), |
|
314 | + ); |
|
315 | + } |
|
316 | + |
|
317 | + |
|
318 | + /** |
|
319 | + * Enqueue scripts and styles for the event editor. |
|
320 | + */ |
|
321 | + public function load_scripts_styles_edit() |
|
322 | + { |
|
323 | + wp_register_script( |
|
324 | + 'ee-event-editor-heartbeat', |
|
325 | + EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js', |
|
326 | + array('ee_admin_js', 'heartbeat'), |
|
327 | + EVENT_ESPRESSO_VERSION, |
|
328 | + true |
|
329 | + ); |
|
330 | + wp_enqueue_script('ee-accounting'); |
|
331 | + //styles |
|
332 | + wp_enqueue_style('espresso-ui-theme'); |
|
333 | + wp_enqueue_script('event_editor_js'); |
|
334 | + wp_enqueue_script('ee-event-editor-heartbeat'); |
|
335 | + } |
|
336 | + |
|
337 | + |
|
338 | + /** |
|
339 | + * Returns template for the additional datetime. |
|
340 | + * @param $template |
|
341 | + * @param $template_args |
|
342 | + * @return mixed |
|
343 | + * @throws DomainException |
|
344 | + */ |
|
345 | + public function add_additional_datetime_button($template, $template_args) |
|
346 | + { |
|
347 | + return EEH_Template::display_template( |
|
348 | + EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php', |
|
349 | + $template_args, |
|
350 | + true |
|
351 | + ); |
|
352 | + } |
|
353 | + |
|
354 | + |
|
355 | + /** |
|
356 | + * Returns the template for cloning a datetime. |
|
357 | + * @param $template |
|
358 | + * @param $template_args |
|
359 | + * @return mixed |
|
360 | + * @throws DomainException |
|
361 | + */ |
|
362 | + public function add_datetime_clone_button($template, $template_args) |
|
363 | + { |
|
364 | + return EEH_Template::display_template( |
|
365 | + EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php', |
|
366 | + $template_args, |
|
367 | + true |
|
368 | + ); |
|
369 | + } |
|
370 | + |
|
371 | + |
|
372 | + /** |
|
373 | + * Returns the template for datetime timezones. |
|
374 | + * @param $template |
|
375 | + * @param $template_args |
|
376 | + * @return mixed |
|
377 | + * @throws DomainException |
|
378 | + */ |
|
379 | + public function datetime_timezones_template($template, $template_args) |
|
380 | + { |
|
381 | + return EEH_Template::display_template( |
|
382 | + EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php', |
|
383 | + $template_args, |
|
384 | + true |
|
385 | + ); |
|
386 | + } |
|
387 | + |
|
388 | + |
|
389 | + /** |
|
390 | + * Sets the views for the default list table view. |
|
391 | + */ |
|
392 | + protected function _set_list_table_views_default() |
|
393 | + { |
|
394 | + parent::_set_list_table_views_default(); |
|
395 | + $new_views = array( |
|
396 | + 'today' => array( |
|
397 | + 'slug' => 'today', |
|
398 | + 'label' => esc_html__('Today', 'event_espresso'), |
|
399 | + 'count' => $this->total_events_today(), |
|
400 | + 'bulk_action' => array( |
|
401 | + 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
402 | + ), |
|
403 | + ), |
|
404 | + 'month' => array( |
|
405 | + 'slug' => 'month', |
|
406 | + 'label' => esc_html__('This Month', 'event_espresso'), |
|
407 | + 'count' => $this->total_events_this_month(), |
|
408 | + 'bulk_action' => array( |
|
409 | + 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
410 | + ), |
|
411 | + ), |
|
412 | + ); |
|
413 | + $this->_views = array_merge($this->_views, $new_views); |
|
414 | + } |
|
415 | + |
|
416 | + |
|
417 | + /** |
|
418 | + * Returns the extra action links for the default list table view. |
|
419 | + * @param array $action_links |
|
420 | + * @param \EE_Event $event |
|
421 | + * @return array |
|
422 | + * @throws EE_Error |
|
423 | + */ |
|
424 | + public function extra_list_table_actions(array $action_links, \EE_Event $event) |
|
425 | + { |
|
426 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
427 | + 'ee_read_registrations', |
|
428 | + 'espresso_registrations_reports', |
|
429 | + $event->ID() |
|
430 | + ) |
|
431 | + ) { |
|
432 | + $reports_query_args = array( |
|
433 | + 'action' => 'reports', |
|
434 | + 'EVT_ID' => $event->ID(), |
|
435 | + ); |
|
436 | + $reports_link = EE_Admin_Page::add_query_args_and_nonce($reports_query_args, REG_ADMIN_URL); |
|
437 | + $action_links[] = '<a href="' |
|
438 | + . $reports_link |
|
439 | + . '" title="' |
|
440 | + . esc_attr__('View Report', 'event_espresso') |
|
441 | + . '"><div class="dashicons dashicons-chart-bar"></div></a>' |
|
442 | + . "\n\t"; |
|
443 | + } |
|
444 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
445 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
446 | + $action_links[] = EEH_MSG_Template::get_message_action_link( |
|
447 | + 'see_notifications_for', |
|
448 | + null, |
|
449 | + array('EVT_ID' => $event->ID()) |
|
450 | + ); |
|
451 | + } |
|
452 | + return $action_links; |
|
453 | + } |
|
454 | + |
|
455 | + |
|
456 | + /** |
|
457 | + * @param $items |
|
458 | + * @return mixed |
|
459 | + */ |
|
460 | + public function additional_legend_items($items) |
|
461 | + { |
|
462 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
463 | + 'ee_read_registrations', |
|
464 | + 'espresso_registrations_reports' |
|
465 | + ) |
|
466 | + ) { |
|
467 | + $items['reports'] = array( |
|
468 | + 'class' => 'dashicons dashicons-chart-bar', |
|
469 | + 'desc' => esc_html__('Event Reports', 'event_espresso'), |
|
470 | + ); |
|
471 | + } |
|
472 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
473 | + $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for'); |
|
474 | + if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) { |
|
475 | + $items['view_related_messages'] = array( |
|
476 | + 'class' => $related_for_icon['css_class'], |
|
477 | + 'desc' => $related_for_icon['label'], |
|
478 | + ); |
|
479 | + } |
|
480 | + } |
|
481 | + return $items; |
|
482 | + } |
|
483 | + |
|
484 | + |
|
485 | + /** |
|
486 | + * This is the callback method for the duplicate event route |
|
487 | + * Method looks for 'EVT_ID' in the request and retrieves that event and its details and duplicates them |
|
488 | + * into a new event. We add a hook so that any plugins that add extra event details can hook into this |
|
489 | + * action. Note that the dupe will have **DUPLICATE** as its title and slug. |
|
490 | + * After duplication the redirect is to the new event edit page. |
|
491 | + * |
|
492 | + * @return void |
|
493 | + * @access protected |
|
494 | + * @throws EE_Error If EE_Event is not available with given ID |
|
495 | + */ |
|
496 | + protected function _duplicate_event() |
|
497 | + { |
|
498 | + // first make sure the ID for the event is in the request. |
|
499 | + // If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?) |
|
500 | + if (! isset($this->_req_data['EVT_ID'])) { |
|
501 | + EE_Error::add_error( |
|
502 | + esc_html__( |
|
503 | + 'In order to duplicate an event an Event ID is required. None was given.', |
|
504 | + 'event_espresso' |
|
505 | + ), |
|
506 | + __FILE__, |
|
507 | + __FUNCTION__, |
|
508 | + __LINE__ |
|
509 | + ); |
|
510 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
511 | + return; |
|
512 | + } |
|
513 | + //k we've got EVT_ID so let's use that to get the event we'll duplicate |
|
514 | + $orig_event = EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']); |
|
515 | + if (! $orig_event instanceof EE_Event) { |
|
516 | + throw new EE_Error( |
|
517 | + sprintf( |
|
518 | + esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'), |
|
519 | + $this->_req_data['EVT_ID'] |
|
520 | + ) |
|
521 | + ); |
|
522 | + } |
|
523 | + //k now let's clone the $orig_event before getting relations |
|
524 | + $new_event = clone $orig_event; |
|
525 | + //original datetimes |
|
526 | + $orig_datetimes = $orig_event->get_many_related('Datetime'); |
|
527 | + //other original relations |
|
528 | + $orig_ven = $orig_event->get_many_related('Venue'); |
|
529 | + //reset the ID and modify other details to make it clear this is a dupe |
|
530 | + $new_event->set('EVT_ID', 0); |
|
531 | + $new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso'); |
|
532 | + $new_event->set('EVT_name', $new_name); |
|
533 | + $new_event->set( |
|
534 | + 'EVT_slug', |
|
535 | + wp_unique_post_slug( |
|
536 | + sanitize_title($orig_event->name()), |
|
537 | + 0, |
|
538 | + 'publish', |
|
539 | + 'espresso_events', |
|
540 | + 0 |
|
541 | + ) |
|
542 | + ); |
|
543 | + $new_event->set('status', 'draft'); |
|
544 | + //duplicate discussion settings |
|
545 | + $new_event->set('comment_status', $orig_event->get('comment_status')); |
|
546 | + $new_event->set('ping_status', $orig_event->get('ping_status')); |
|
547 | + //save the new event |
|
548 | + $new_event->save(); |
|
549 | + //venues |
|
550 | + foreach ($orig_ven as $ven) { |
|
551 | + $new_event->_add_relation_to($ven, 'Venue'); |
|
552 | + } |
|
553 | + $new_event->save(); |
|
554 | + //now we need to get the question group relations and handle that |
|
555 | + //first primary question groups |
|
556 | + $orig_primary_qgs = $orig_event->get_many_related( |
|
557 | + 'Question_Group', |
|
558 | + array(array('Event_Question_Group.EQG_primary' => 1)) |
|
559 | + ); |
|
560 | + if (! empty($orig_primary_qgs)) { |
|
561 | + foreach ($orig_primary_qgs as $id => $obj) { |
|
562 | + if ($obj instanceof EE_Question_Group) { |
|
563 | + $new_event->_add_relation_to($obj, 'Question_Group', array('EQG_primary' => 1)); |
|
564 | + } |
|
565 | + } |
|
566 | + } |
|
567 | + //next additional attendee question groups |
|
568 | + $orig_additional_qgs = $orig_event->get_many_related( |
|
569 | + 'Question_Group', |
|
570 | + array(array('Event_Question_Group.EQG_primary' => 0)) |
|
571 | + ); |
|
572 | + if (! empty($orig_additional_qgs)) { |
|
573 | + foreach ($orig_additional_qgs as $id => $obj) { |
|
574 | + if ($obj instanceof EE_Question_Group) { |
|
575 | + $new_event->_add_relation_to($obj, 'Question_Group', array('EQG_primary' => 0)); |
|
576 | + } |
|
577 | + } |
|
578 | + } |
|
579 | + |
|
580 | + $new_event->save(); |
|
581 | + |
|
582 | + //k now that we have the new event saved we can loop through the datetimes and start adding relations. |
|
583 | + $cloned_tickets = array(); |
|
584 | + foreach ($orig_datetimes as $orig_dtt) { |
|
585 | + if (! $orig_dtt instanceof EE_Datetime) { |
|
586 | + continue; |
|
587 | + } |
|
588 | + $new_dtt = clone $orig_dtt; |
|
589 | + $orig_tkts = $orig_dtt->tickets(); |
|
590 | + //save new dtt then add to event |
|
591 | + $new_dtt->set('DTT_ID', 0); |
|
592 | + $new_dtt->set('DTT_sold', 0); |
|
593 | + $new_dtt->set_reserved(0); |
|
594 | + $new_dtt->save(); |
|
595 | + $new_event->_add_relation_to($new_dtt, 'Datetime'); |
|
596 | + $new_event->save(); |
|
597 | + //now let's get the ticket relations setup. |
|
598 | + foreach ((array)$orig_tkts as $orig_tkt) { |
|
599 | + //it's possible a datetime will have no tickets so let's verify we HAVE a ticket first. |
|
600 | + if (! $orig_tkt instanceof EE_Ticket) { |
|
601 | + continue; |
|
602 | + } |
|
603 | + //is this ticket archived? If it is then let's skip |
|
604 | + if ($orig_tkt->get('TKT_deleted')) { |
|
605 | + continue; |
|
606 | + } |
|
607 | + // does this original ticket already exist in the clone_tickets cache? |
|
608 | + // If so we'll just use the new ticket from it. |
|
609 | + if (isset($cloned_tickets[$orig_tkt->ID()])) { |
|
610 | + $new_tkt = $cloned_tickets[$orig_tkt->ID()]; |
|
611 | + } else { |
|
612 | + $new_tkt = clone $orig_tkt; |
|
613 | + //get relations on the $orig_tkt that we need to setup. |
|
614 | + $orig_prices = $orig_tkt->prices(); |
|
615 | + $new_tkt->set('TKT_ID', 0); |
|
616 | + $new_tkt->set('TKT_sold', 0); |
|
617 | + $new_tkt->set('TKT_reserved', 0); |
|
618 | + $new_tkt->save(); //make sure new ticket has ID. |
|
619 | + //price relations on new ticket need to be setup. |
|
620 | + foreach ($orig_prices as $orig_price) { |
|
621 | + $new_price = clone $orig_price; |
|
622 | + $new_price->set('PRC_ID', 0); |
|
623 | + $new_price->save(); |
|
624 | + $new_tkt->_add_relation_to($new_price, 'Price'); |
|
625 | + $new_tkt->save(); |
|
626 | + } |
|
627 | + |
|
628 | + do_action( |
|
629 | + 'AHEE__Extend_Events_Admin_Page___duplicate_event__duplicate_ticket__after', |
|
630 | + $orig_tkt, |
|
631 | + $new_tkt, |
|
632 | + $orig_prices, |
|
633 | + $orig_event, |
|
634 | + $orig_dtt, |
|
635 | + $new_dtt |
|
636 | + ); |
|
637 | + } |
|
638 | + // k now we can add the new ticket as a relation to the new datetime |
|
639 | + // and make sure its added to our cached $cloned_tickets array |
|
640 | + // for use with later datetimes that have the same ticket. |
|
641 | + $new_dtt->_add_relation_to($new_tkt, 'Ticket'); |
|
642 | + $new_dtt->save(); |
|
643 | + $cloned_tickets[$orig_tkt->ID()] = $new_tkt; |
|
644 | + } |
|
645 | + } |
|
646 | + //clone taxonomy information |
|
647 | + $taxonomies_to_clone_with = apply_filters( |
|
648 | + 'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone', |
|
649 | + array('espresso_event_categories', 'espresso_event_type', 'post_tag') |
|
650 | + ); |
|
651 | + //get terms for original event (notice) |
|
652 | + $orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with); |
|
653 | + //loop through terms and add them to new event. |
|
654 | + foreach ($orig_terms as $term) { |
|
655 | + wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true); |
|
656 | + } |
|
657 | + |
|
658 | + //duplicate other core WP_Post items for this event. |
|
659 | + //post thumbnail (feature image). |
|
660 | + $feature_image_id = get_post_thumbnail_id($orig_event->ID()); |
|
661 | + if ($feature_image_id) { |
|
662 | + update_post_meta($new_event->ID(), '_thumbnail_id', $feature_image_id); |
|
663 | + } |
|
664 | + |
|
665 | + //duplicate page_template setting |
|
666 | + $page_template = get_post_meta($orig_event->ID(), '_wp_page_template', true); |
|
667 | + if ($page_template) { |
|
668 | + update_post_meta($new_event->ID(), '_wp_page_template', $page_template); |
|
669 | + } |
|
670 | + |
|
671 | + do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event); |
|
672 | + //now let's redirect to the edit page for this duplicated event if we have a new event id. |
|
673 | + if ($new_event->ID()) { |
|
674 | + $redirect_args = array( |
|
675 | + 'post' => $new_event->ID(), |
|
676 | + 'action' => 'edit', |
|
677 | + ); |
|
678 | + EE_Error::add_success( |
|
679 | + esc_html__( |
|
680 | + 'Event successfully duplicated. Please review the details below and make any necessary edits', |
|
681 | + 'event_espresso' |
|
682 | + ) |
|
683 | + ); |
|
684 | + } else { |
|
685 | + $redirect_args = array( |
|
686 | + 'action' => 'default', |
|
687 | + ); |
|
688 | + EE_Error::add_error( |
|
689 | + esc_html__('Not able to duplicate event. Something went wrong.', 'event_espresso'), |
|
690 | + __FILE__, |
|
691 | + __FUNCTION__, |
|
692 | + __LINE__ |
|
693 | + ); |
|
694 | + } |
|
695 | + $this->_redirect_after_action(false, '', '', $redirect_args, true); |
|
696 | + } |
|
697 | + |
|
698 | + |
|
699 | + /** |
|
700 | + * Generates output for the import page. |
|
701 | + * @throws DomainException |
|
702 | + */ |
|
703 | + protected function _import_page() |
|
704 | + { |
|
705 | + $title = esc_html__('Import', 'event_espresso'); |
|
706 | + $intro = esc_html__( |
|
707 | + 'If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ', |
|
708 | + 'event_espresso' |
|
709 | + ); |
|
710 | + $form_url = EVENTS_ADMIN_URL; |
|
711 | + $action = 'import_events'; |
|
712 | + $type = 'csv'; |
|
713 | + $this->_template_args['form'] = EE_Import::instance()->upload_form( |
|
714 | + $title, $intro, $form_url, $action, $type |
|
715 | + ); |
|
716 | + $this->_template_args['sample_file_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
717 | + array('action' => 'sample_export_file'), |
|
718 | + $this->_admin_base_url |
|
719 | + ); |
|
720 | + $content = EEH_Template::display_template( |
|
721 | + EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php', |
|
722 | + $this->_template_args, |
|
723 | + true |
|
724 | + ); |
|
725 | + $this->_template_args['admin_page_content'] = $content; |
|
726 | + $this->display_admin_page_with_sidebar(); |
|
727 | + } |
|
728 | + |
|
729 | + |
|
730 | + /** |
|
731 | + * _import_events |
|
732 | + * This handles displaying the screen and running imports for importing events. |
|
733 | + * |
|
734 | + * @return void |
|
735 | + */ |
|
736 | + protected function _import_events() |
|
737 | + { |
|
738 | + require_once(EE_CLASSES . 'EE_Import.class.php'); |
|
739 | + $success = EE_Import::instance()->import(); |
|
740 | + $this->_redirect_after_action($success, 'Import File', 'ran', array('action' => 'import_page'), true); |
|
741 | + } |
|
742 | + |
|
743 | + |
|
744 | + /** |
|
745 | + * _events_export |
|
746 | + * Will export all (or just the given event) to a Excel compatible file. |
|
747 | + * |
|
748 | + * @access protected |
|
749 | + * @return void |
|
750 | + */ |
|
751 | + protected function _events_export() |
|
752 | + { |
|
753 | + if (isset($this->_req_data['EVT_ID'])) { |
|
754 | + $event_ids = $this->_req_data['EVT_ID']; |
|
755 | + } elseif (isset($this->_req_data['EVT_IDs'])) { |
|
756 | + $event_ids = $this->_req_data['EVT_IDs']; |
|
757 | + } else { |
|
758 | + $event_ids = null; |
|
759 | + } |
|
760 | + //todo: I don't like doing this but it'll do until we modify EE_Export Class. |
|
761 | + $new_request_args = array( |
|
762 | + 'export' => 'report', |
|
763 | + 'action' => 'all_event_data', |
|
764 | + 'EVT_ID' => $event_ids, |
|
765 | + ); |
|
766 | + $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
767 | + if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
768 | + require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
769 | + $EE_Export = EE_Export::instance($this->_req_data); |
|
770 | + $EE_Export->export(); |
|
771 | + } |
|
772 | + } |
|
773 | + |
|
774 | + |
|
775 | + /** |
|
776 | + * handle category exports() |
|
777 | + * |
|
778 | + * @return void |
|
779 | + */ |
|
780 | + protected function _categories_export() |
|
781 | + { |
|
782 | + //todo: I don't like doing this but it'll do until we modify EE_Export Class. |
|
783 | + $new_request_args = array( |
|
784 | + 'export' => 'report', |
|
785 | + 'action' => 'categories', |
|
786 | + 'category_ids' => $this->_req_data['EVT_CAT_ID'], |
|
787 | + ); |
|
788 | + $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
789 | + if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
790 | + require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
791 | + $EE_Export = EE_Export::instance($this->_req_data); |
|
792 | + $EE_Export->export(); |
|
793 | + } |
|
794 | + } |
|
795 | + |
|
796 | + |
|
797 | + /** |
|
798 | + * Creates a sample CSV file for importing |
|
799 | + */ |
|
800 | + protected function _sample_export_file() |
|
801 | + { |
|
802 | + // require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
803 | + EE_Export::instance()->export_sample(); |
|
804 | + } |
|
805 | + |
|
806 | + |
|
807 | + /************* Template Settings *************/ |
|
808 | + /** |
|
809 | + * Generates template settings page output |
|
810 | + * @throws DomainException |
|
811 | + * @throws EE_Error |
|
812 | + */ |
|
813 | + protected function _template_settings() |
|
814 | + { |
|
815 | + $this->_template_args['values'] = $this->_yes_no_values; |
|
816 | + /** |
|
817 | + * Note leaving this filter in for backward compatibility this was moved in 4.6.x |
|
818 | + * from General_Settings_Admin_Page to here. |
|
819 | + */ |
|
820 | + $this->_template_args = apply_filters( |
|
821 | + 'FHEE__General_Settings_Admin_Page__template_settings__template_args', |
|
822 | + $this->_template_args |
|
823 | + ); |
|
824 | + $this->_set_add_edit_form_tags('update_template_settings'); |
|
825 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
826 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
827 | + EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php', |
|
828 | + $this->_template_args, |
|
829 | + true |
|
830 | + ); |
|
831 | + $this->display_admin_page_with_sidebar(); |
|
832 | + } |
|
833 | + |
|
834 | + |
|
835 | + /** |
|
836 | + * Handler for updating template settings. |
|
837 | + */ |
|
838 | + protected function _update_template_settings() |
|
839 | + { |
|
840 | + /** |
|
841 | + * Note leaving this filter in for backward compatibility this was moved in 4.6.x |
|
842 | + * from General_Settings_Admin_Page to here. |
|
843 | + */ |
|
844 | + EE_Registry::instance()->CFG->template_settings = apply_filters( |
|
845 | + 'FHEE__General_Settings_Admin_Page__update_template_settings__data', |
|
846 | + EE_Registry::instance()->CFG->template_settings, |
|
847 | + $this->_req_data |
|
848 | + ); |
|
849 | + //update custom post type slugs and detect if we need to flush rewrite rules |
|
850 | + $old_slug = EE_Registry::instance()->CFG->core->event_cpt_slug; |
|
851 | + EE_Registry::instance()->CFG->core->event_cpt_slug = empty($this->_req_data['event_cpt_slug']) |
|
852 | + ? EE_Registry::instance()->CFG->core->event_cpt_slug |
|
853 | + : sanitize_title_with_dashes($this->_req_data['event_cpt_slug']); |
|
854 | + $what = 'Template Settings'; |
|
855 | + $success = $this->_update_espresso_configuration( |
|
856 | + $what, |
|
857 | + EE_Registry::instance()->CFG->template_settings, |
|
858 | + __FILE__, |
|
859 | + __FUNCTION__, |
|
860 | + __LINE__ |
|
861 | + ); |
|
862 | + if (EE_Registry::instance()->CFG->core->event_cpt_slug != $old_slug) { |
|
863 | + update_option('ee_flush_rewrite_rules', true); |
|
864 | + } |
|
865 | + $this->_redirect_after_action($success, $what, 'updated', array('action' => 'template_settings')); |
|
866 | + } |
|
867 | + |
|
868 | + |
|
869 | + /** |
|
870 | + * _premium_event_editor_meta_boxes |
|
871 | + * add all metaboxes related to the event_editor |
|
872 | + * |
|
873 | + * @access protected |
|
874 | + * @return void |
|
875 | + * @throws EE_Error |
|
876 | + */ |
|
877 | + protected function _premium_event_editor_meta_boxes() |
|
878 | + { |
|
879 | + $this->verify_cpt_object(); |
|
880 | + add_meta_box( |
|
881 | + 'espresso_event_editor_event_options', |
|
882 | + esc_html__('Event Registration Options', 'event_espresso'), |
|
883 | + array($this, 'registration_options_meta_box'), |
|
884 | + $this->page_slug, |
|
885 | + 'side', |
|
886 | + 'core' |
|
887 | + ); |
|
888 | + } |
|
889 | + |
|
890 | + |
|
891 | + /** |
|
892 | + * override caf metabox |
|
893 | + * |
|
894 | + * @return void |
|
895 | + * @throws DomainException |
|
896 | + */ |
|
897 | + public function registration_options_meta_box() |
|
898 | + { |
|
899 | + $yes_no_values = array( |
|
900 | + array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')), |
|
901 | + array('id' => false, 'text' => esc_html__('No', 'event_espresso')), |
|
902 | + ); |
|
903 | + $default_reg_status_values = EEM_Registration::reg_status_array( |
|
904 | + array( |
|
905 | + EEM_Registration::status_id_cancelled, |
|
906 | + EEM_Registration::status_id_declined, |
|
907 | + EEM_Registration::status_id_incomplete, |
|
908 | + EEM_Registration::status_id_wait_list, |
|
909 | + ), |
|
910 | + true |
|
911 | + ); |
|
912 | + $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false); |
|
913 | + $template_args['_event'] = $this->_cpt_model_obj; |
|
914 | + $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit(); |
|
915 | + $template_args['default_registration_status'] = EEH_Form_Fields::select_input( |
|
916 | + 'default_reg_status', |
|
917 | + $default_reg_status_values, |
|
918 | + $this->_cpt_model_obj->default_registration_status() |
|
919 | + ); |
|
920 | + $template_args['display_description'] = EEH_Form_Fields::select_input( |
|
921 | + 'display_desc', |
|
922 | + $yes_no_values, |
|
923 | + $this->_cpt_model_obj->display_description() |
|
924 | + ); |
|
925 | + $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input( |
|
926 | + 'display_ticket_selector', |
|
927 | + $yes_no_values, |
|
928 | + $this->_cpt_model_obj->display_ticket_selector(), |
|
929 | + '', |
|
930 | + '', |
|
931 | + false |
|
932 | + ); |
|
933 | + $template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input( |
|
934 | + 'EVT_default_registration_status', |
|
935 | + $default_reg_status_values, |
|
936 | + $this->_cpt_model_obj->default_registration_status() |
|
937 | + ); |
|
938 | + $template_args['additional_registration_options'] = apply_filters( |
|
939 | + 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', |
|
940 | + '', |
|
941 | + $template_args, |
|
942 | + $yes_no_values, |
|
943 | + $default_reg_status_values |
|
944 | + ); |
|
945 | + EEH_Template::display_template( |
|
946 | + EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
947 | + $template_args |
|
948 | + ); |
|
949 | + } |
|
950 | + |
|
951 | + |
|
952 | + |
|
953 | + /** |
|
954 | + * wp_list_table_mods for caf |
|
955 | + * ============================ |
|
956 | + */ |
|
957 | + /** |
|
958 | + * hook into list table filters and provide filters for caffeinated list table |
|
959 | + * |
|
960 | + * @param array $old_filters any existing filters present |
|
961 | + * @param array $list_table_obj the list table object |
|
962 | + * @return array new filters |
|
963 | + */ |
|
964 | + public function list_table_filters($old_filters, $list_table_obj) |
|
965 | + { |
|
966 | + $filters = array(); |
|
967 | + //first month/year filters |
|
968 | + $filters[] = $this->espresso_event_months_dropdown(); |
|
969 | + $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null; |
|
970 | + //active status dropdown |
|
971 | + if ($status !== 'draft') { |
|
972 | + $filters[] = $this->active_status_dropdown( |
|
973 | + isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : '' |
|
974 | + ); |
|
975 | + } |
|
976 | + //category filter |
|
977 | + $filters[] = $this->category_dropdown(); |
|
978 | + return array_merge($old_filters, $filters); |
|
979 | + } |
|
980 | + |
|
981 | + |
|
982 | + /** |
|
983 | + * espresso_event_months_dropdown |
|
984 | + * |
|
985 | + * @access public |
|
986 | + * @return string dropdown listing month/year selections for events. |
|
987 | + */ |
|
988 | + public function espresso_event_months_dropdown() |
|
989 | + { |
|
990 | + // what we need to do is get all PRIMARY datetimes for all events to filter on. |
|
991 | + // Note we need to include any other filters that are set! |
|
992 | + $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null; |
|
993 | + //categories? |
|
994 | + $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 |
|
995 | + ? $this->_req_data['EVT_CAT'] |
|
996 | + : null; |
|
997 | + //active status? |
|
998 | + $active_status = isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : null; |
|
999 | + $cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : ''; |
|
1000 | + return EEH_Form_Fields::generate_event_months_dropdown($cur_date, $status, $category, $active_status); |
|
1001 | + } |
|
1002 | + |
|
1003 | + |
|
1004 | + /** |
|
1005 | + * returns a list of "active" statuses on the event |
|
1006 | + * |
|
1007 | + * @param string $current_value whatever the current active status is |
|
1008 | + * @return string |
|
1009 | + */ |
|
1010 | + public function active_status_dropdown($current_value = '') |
|
1011 | + { |
|
1012 | + $select_name = 'active_status'; |
|
1013 | + $values = array( |
|
1014 | + 'none' => esc_html__('Show Active/Inactive', 'event_espresso'), |
|
1015 | + 'active' => esc_html__('Active', 'event_espresso'), |
|
1016 | + 'upcoming' => esc_html__('Upcoming', 'event_espresso'), |
|
1017 | + 'expired' => esc_html__('Expired', 'event_espresso'), |
|
1018 | + 'inactive' => esc_html__('Inactive', 'event_espresso'), |
|
1019 | + ); |
|
1020 | + $id = 'id="espresso-active-status-dropdown-filter"'; |
|
1021 | + $class = 'wide'; |
|
1022 | + return EEH_Form_Fields::select_input($select_name, $values, $current_value, $id, $class); |
|
1023 | + } |
|
1024 | + |
|
1025 | + |
|
1026 | + /** |
|
1027 | + * output a dropdown of the categories for the category filter on the event admin list table |
|
1028 | + * |
|
1029 | + * @access public |
|
1030 | + * @return string html |
|
1031 | + */ |
|
1032 | + public function category_dropdown() |
|
1033 | + { |
|
1034 | + $cur_cat = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1; |
|
1035 | + return EEH_Form_Fields::generate_event_category_dropdown($cur_cat); |
|
1036 | + } |
|
1037 | + |
|
1038 | + |
|
1039 | + /** |
|
1040 | + * get total number of events today |
|
1041 | + * |
|
1042 | + * @access public |
|
1043 | + * @return int |
|
1044 | + * @throws EE_Error |
|
1045 | + */ |
|
1046 | + public function total_events_today() |
|
1047 | + { |
|
1048 | + $start = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1049 | + 'DTT_EVT_start', |
|
1050 | + date('Y-m-d') . ' 00:00:00', |
|
1051 | + 'Y-m-d H:i:s', |
|
1052 | + 'UTC' |
|
1053 | + ); |
|
1054 | + $end = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1055 | + 'DTT_EVT_start', |
|
1056 | + date('Y-m-d') . ' 23:59:59', |
|
1057 | + 'Y-m-d H:i:s', |
|
1058 | + 'UTC' |
|
1059 | + ); |
|
1060 | + $where = array( |
|
1061 | + 'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)), |
|
1062 | + ); |
|
1063 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
1064 | + return $count; |
|
1065 | + } |
|
1066 | + |
|
1067 | + |
|
1068 | + /** |
|
1069 | + * get total number of events this month |
|
1070 | + * |
|
1071 | + * @access public |
|
1072 | + * @return int |
|
1073 | + * @throws EE_Error |
|
1074 | + */ |
|
1075 | + public function total_events_this_month() |
|
1076 | + { |
|
1077 | + //Dates |
|
1078 | + $this_year_r = date('Y'); |
|
1079 | + $this_month_r = date('m'); |
|
1080 | + $days_this_month = date('t'); |
|
1081 | + $start = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1082 | + 'DTT_EVT_start', |
|
1083 | + $this_year_r . '-' . $this_month_r . '-01 00:00:00', |
|
1084 | + 'Y-m-d H:i:s', |
|
1085 | + 'UTC' |
|
1086 | + ); |
|
1087 | + $end = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1088 | + 'DTT_EVT_start', |
|
1089 | + $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59', |
|
1090 | + 'Y-m-d H:i:s', |
|
1091 | + 'UTC' |
|
1092 | + ); |
|
1093 | + $where = array( |
|
1094 | + 'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)), |
|
1095 | + ); |
|
1096 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
1097 | + return $count; |
|
1098 | + } |
|
1099 | + |
|
1100 | + |
|
1101 | + /** DEFAULT TICKETS STUFF **/ |
|
1102 | + |
|
1103 | + /** |
|
1104 | + * Output default tickets list table view. |
|
1105 | + */ |
|
1106 | + public function _tickets_overview_list_table() |
|
1107 | + { |
|
1108 | + $this->_search_btn_label = esc_html__('Tickets', 'event_espresso'); |
|
1109 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
1110 | + } |
|
1111 | + |
|
1112 | + |
|
1113 | + /** |
|
1114 | + * @param int $per_page |
|
1115 | + * @param bool $count |
|
1116 | + * @param bool $trashed |
|
1117 | + * @return \EE_Soft_Delete_Base_Class[]|int |
|
1118 | + */ |
|
1119 | + public function get_default_tickets($per_page = 10, $count = false, $trashed = false) |
|
1120 | + { |
|
1121 | + $orderby = empty($this->_req_data['orderby']) ? 'TKT_name' : $this->_req_data['orderby']; |
|
1122 | + $order = empty($this->_req_data['order']) ? 'ASC' : $this->_req_data['order']; |
|
1123 | + switch ($orderby) { |
|
1124 | + case 'TKT_name': |
|
1125 | + $orderby = array('TKT_name' => $order); |
|
1126 | + break; |
|
1127 | + case 'TKT_price': |
|
1128 | + $orderby = array('TKT_price' => $order); |
|
1129 | + break; |
|
1130 | + case 'TKT_uses': |
|
1131 | + $orderby = array('TKT_uses' => $order); |
|
1132 | + break; |
|
1133 | + case 'TKT_min': |
|
1134 | + $orderby = array('TKT_min' => $order); |
|
1135 | + break; |
|
1136 | + case 'TKT_max': |
|
1137 | + $orderby = array('TKT_max' => $order); |
|
1138 | + break; |
|
1139 | + case 'TKT_qty': |
|
1140 | + $orderby = array('TKT_qty' => $order); |
|
1141 | + break; |
|
1142 | + } |
|
1143 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) |
|
1144 | + ? $this->_req_data['paged'] |
|
1145 | + : 1; |
|
1146 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) |
|
1147 | + ? $this->_req_data['perpage'] |
|
1148 | + : $per_page; |
|
1149 | + $_where = array( |
|
1150 | + 'TKT_is_default' => 1, |
|
1151 | + 'TKT_deleted' => $trashed, |
|
1152 | + ); |
|
1153 | + $offset = ($current_page - 1) * $per_page; |
|
1154 | + $limit = array($offset, $per_page); |
|
1155 | + if (isset($this->_req_data['s'])) { |
|
1156 | + $sstr = '%' . $this->_req_data['s'] . '%'; |
|
1157 | + $_where['OR'] = array( |
|
1158 | + 'TKT_name' => array('LIKE', $sstr), |
|
1159 | + 'TKT_description' => array('LIKE', $sstr), |
|
1160 | + ); |
|
1161 | + } |
|
1162 | + $query_params = array( |
|
1163 | + $_where, |
|
1164 | + 'order_by' => $orderby, |
|
1165 | + 'limit' => $limit, |
|
1166 | + 'group_by' => 'TKT_ID', |
|
1167 | + ); |
|
1168 | + if ($count) { |
|
1169 | + return EEM_Ticket::instance()->count_deleted_and_undeleted(array($_where)); |
|
1170 | + } else { |
|
1171 | + return EEM_Ticket::instance()->get_all_deleted_and_undeleted($query_params); |
|
1172 | + } |
|
1173 | + } |
|
1174 | + |
|
1175 | + |
|
1176 | + /** |
|
1177 | + * @param bool $trash |
|
1178 | + * @throws EE_Error |
|
1179 | + */ |
|
1180 | + protected function _trash_or_restore_ticket($trash = false) |
|
1181 | + { |
|
1182 | + $success = 1; |
|
1183 | + $TKT = EEM_Ticket::instance(); |
|
1184 | + //checkboxes? |
|
1185 | + if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1186 | + //if array has more than one element then success message should be plural |
|
1187 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
1188 | + //cycle thru the boxes |
|
1189 | + while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) { |
|
1190 | + if ($trash) { |
|
1191 | + if (! $TKT->delete_by_ID($TKT_ID)) { |
|
1192 | + $success = 0; |
|
1193 | + } |
|
1194 | + } else { |
|
1195 | + if (! $TKT->restore_by_ID($TKT_ID)) { |
|
1196 | + $success = 0; |
|
1197 | + } |
|
1198 | + } |
|
1199 | + } |
|
1200 | + } else { |
|
1201 | + //grab single id and trash |
|
1202 | + $TKT_ID = absint($this->_req_data['TKT_ID']); |
|
1203 | + if ($trash) { |
|
1204 | + if (! $TKT->delete_by_ID($TKT_ID)) { |
|
1205 | + $success = 0; |
|
1206 | + } |
|
1207 | + } else { |
|
1208 | + if (! $TKT->restore_by_ID($TKT_ID)) { |
|
1209 | + $success = 0; |
|
1210 | + } |
|
1211 | + } |
|
1212 | + } |
|
1213 | + $action_desc = $trash ? 'moved to the trash' : 'restored'; |
|
1214 | + $query_args = array( |
|
1215 | + 'action' => 'ticket_list_table', |
|
1216 | + 'status' => $trash ? '' : 'trashed', |
|
1217 | + ); |
|
1218 | + $this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args); |
|
1219 | + } |
|
1220 | + |
|
1221 | + |
|
1222 | + /** |
|
1223 | + * Handles trashing default ticket. |
|
1224 | + */ |
|
1225 | + protected function _delete_ticket() |
|
1226 | + { |
|
1227 | + $success = 1; |
|
1228 | + //checkboxes? |
|
1229 | + if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1230 | + //if array has more than one element then success message should be plural |
|
1231 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
1232 | + //cycle thru the boxes |
|
1233 | + while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) { |
|
1234 | + //delete |
|
1235 | + if (! $this->_delete_the_ticket($TKT_ID)) { |
|
1236 | + $success = 0; |
|
1237 | + } |
|
1238 | + } |
|
1239 | + } else { |
|
1240 | + //grab single id and trash |
|
1241 | + $TKT_ID = absint($this->_req_data['TKT_ID']); |
|
1242 | + if (! $this->_delete_the_ticket($TKT_ID)) { |
|
1243 | + $success = 0; |
|
1244 | + } |
|
1245 | + } |
|
1246 | + $action_desc = 'deleted'; |
|
1247 | + $query_args = array( |
|
1248 | + 'action' => 'ticket_list_table', |
|
1249 | + 'status' => 'trashed', |
|
1250 | + ); |
|
1251 | + //fail safe. If the default ticket count === 1 then we need to redirect to event overview. |
|
1252 | + if (EEM_Ticket::instance()->count_deleted_and_undeleted( |
|
1253 | + array(array('TKT_is_default' => 1)), |
|
1254 | + 'TKT_ID', |
|
1255 | + true |
|
1256 | + ) |
|
1257 | + ) { |
|
1258 | + $query_args = array(); |
|
1259 | + } |
|
1260 | + $this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args); |
|
1261 | + } |
|
1262 | + |
|
1263 | + |
|
1264 | + /** |
|
1265 | + * @param int $TKT_ID |
|
1266 | + * @return bool|int |
|
1267 | + * @throws EE_Error |
|
1268 | + */ |
|
1269 | + protected function _delete_the_ticket($TKT_ID) |
|
1270 | + { |
|
1271 | + $tkt = EEM_Ticket::instance()->get_one_by_ID($TKT_ID); |
|
1272 | + $tkt->_remove_relations('Datetime'); |
|
1273 | + //delete all related prices first |
|
1274 | + $tkt->delete_related_permanently('Price'); |
|
1275 | + return $tkt->delete_permanently(); |
|
1276 | + } |
|
1277 | 1277 | } |
@@ -38,217 +38,217 @@ |
||
38 | 38 | * @since 4.0 |
39 | 39 | */ |
40 | 40 | if (function_exists('espresso_version')) { |
41 | - if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | - /** |
|
43 | - * espresso_duplicate_plugin_error |
|
44 | - * displays if more than one version of EE is activated at the same time |
|
45 | - */ |
|
46 | - function espresso_duplicate_plugin_error() |
|
47 | - { |
|
48 | - ?> |
|
41 | + if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | + /** |
|
43 | + * espresso_duplicate_plugin_error |
|
44 | + * displays if more than one version of EE is activated at the same time |
|
45 | + */ |
|
46 | + function espresso_duplicate_plugin_error() |
|
47 | + { |
|
48 | + ?> |
|
49 | 49 | <div class="error"> |
50 | 50 | <p> |
51 | 51 | <?php |
52 | - 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 | - ); ?> |
|
52 | + 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 | + ); ?> |
|
56 | 56 | </p> |
57 | 57 | </div> |
58 | 58 | <?php |
59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | - } |
|
61 | - } |
|
62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | + } |
|
61 | + } |
|
62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
63 | 63 | |
64 | 64 | } else { |
65 | - define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
66 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
67 | - /** |
|
68 | - * espresso_minimum_php_version_error |
|
69 | - * |
|
70 | - * @return void |
|
71 | - */ |
|
72 | - function espresso_minimum_php_version_error() |
|
73 | - { |
|
74 | - ?> |
|
65 | + define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
66 | + if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
67 | + /** |
|
68 | + * espresso_minimum_php_version_error |
|
69 | + * |
|
70 | + * @return void |
|
71 | + */ |
|
72 | + function espresso_minimum_php_version_error() |
|
73 | + { |
|
74 | + ?> |
|
75 | 75 | <div class="error"> |
76 | 76 | <p> |
77 | 77 | <?php |
78 | - printf( |
|
79 | - esc_html__( |
|
80 | - '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.', |
|
81 | - 'event_espresso' |
|
82 | - ), |
|
83 | - EE_MIN_PHP_VER_REQUIRED, |
|
84 | - PHP_VERSION, |
|
85 | - '<br/>', |
|
86 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
87 | - ); |
|
88 | - ?> |
|
78 | + printf( |
|
79 | + esc_html__( |
|
80 | + '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.', |
|
81 | + 'event_espresso' |
|
82 | + ), |
|
83 | + EE_MIN_PHP_VER_REQUIRED, |
|
84 | + PHP_VERSION, |
|
85 | + '<br/>', |
|
86 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
87 | + ); |
|
88 | + ?> |
|
89 | 89 | </p> |
90 | 90 | </div> |
91 | 91 | <?php |
92 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
93 | - } |
|
92 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
93 | + } |
|
94 | 94 | |
95 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
96 | - } else { |
|
97 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
98 | - /** |
|
99 | - * espresso_version |
|
100 | - * Returns the plugin version |
|
101 | - * |
|
102 | - * @return string |
|
103 | - */ |
|
104 | - function espresso_version() |
|
105 | - { |
|
106 | - return apply_filters('FHEE__espresso__espresso_version', '4.9.50.rc.014'); |
|
107 | - } |
|
95 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
96 | + } else { |
|
97 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
98 | + /** |
|
99 | + * espresso_version |
|
100 | + * Returns the plugin version |
|
101 | + * |
|
102 | + * @return string |
|
103 | + */ |
|
104 | + function espresso_version() |
|
105 | + { |
|
106 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.50.rc.014'); |
|
107 | + } |
|
108 | 108 | |
109 | - /** |
|
110 | - * espresso_plugin_activation |
|
111 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
112 | - */ |
|
113 | - function espresso_plugin_activation() |
|
114 | - { |
|
115 | - update_option('ee_espresso_activation', true); |
|
116 | - } |
|
109 | + /** |
|
110 | + * espresso_plugin_activation |
|
111 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
112 | + */ |
|
113 | + function espresso_plugin_activation() |
|
114 | + { |
|
115 | + update_option('ee_espresso_activation', true); |
|
116 | + } |
|
117 | 117 | |
118 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
119 | - /** |
|
120 | - * espresso_load_error_handling |
|
121 | - * this function loads EE's class for handling exceptions and errors |
|
122 | - */ |
|
123 | - function espresso_load_error_handling() |
|
124 | - { |
|
125 | - static $error_handling_loaded = false; |
|
126 | - if ($error_handling_loaded) { |
|
127 | - return; |
|
128 | - } |
|
129 | - // load debugging tools |
|
130 | - if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
131 | - require_once EE_HELPERS . 'EEH_Debug_Tools.helper.php'; |
|
132 | - \EEH_Debug_Tools::instance(); |
|
133 | - } |
|
134 | - // load error handling |
|
135 | - if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
136 | - require_once EE_CORE . 'EE_Error.core.php'; |
|
137 | - } else { |
|
138 | - wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
139 | - } |
|
140 | - $error_handling_loaded = true; |
|
141 | - } |
|
118 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
119 | + /** |
|
120 | + * espresso_load_error_handling |
|
121 | + * this function loads EE's class for handling exceptions and errors |
|
122 | + */ |
|
123 | + function espresso_load_error_handling() |
|
124 | + { |
|
125 | + static $error_handling_loaded = false; |
|
126 | + if ($error_handling_loaded) { |
|
127 | + return; |
|
128 | + } |
|
129 | + // load debugging tools |
|
130 | + if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
131 | + require_once EE_HELPERS . 'EEH_Debug_Tools.helper.php'; |
|
132 | + \EEH_Debug_Tools::instance(); |
|
133 | + } |
|
134 | + // load error handling |
|
135 | + if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
136 | + require_once EE_CORE . 'EE_Error.core.php'; |
|
137 | + } else { |
|
138 | + wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
139 | + } |
|
140 | + $error_handling_loaded = true; |
|
141 | + } |
|
142 | 142 | |
143 | - /** |
|
144 | - * espresso_load_required |
|
145 | - * given a class name and path, this function will load that file or throw an exception |
|
146 | - * |
|
147 | - * @param string $classname |
|
148 | - * @param string $full_path_to_file |
|
149 | - * @throws EE_Error |
|
150 | - */ |
|
151 | - function espresso_load_required($classname, $full_path_to_file) |
|
152 | - { |
|
153 | - if (is_readable($full_path_to_file)) { |
|
154 | - require_once $full_path_to_file; |
|
155 | - } else { |
|
156 | - throw new \EE_Error ( |
|
157 | - sprintf( |
|
158 | - esc_html__( |
|
159 | - 'The %s class file could not be located or is not readable due to file permissions.', |
|
160 | - 'event_espresso' |
|
161 | - ), |
|
162 | - $classname |
|
163 | - ) |
|
164 | - ); |
|
165 | - } |
|
166 | - } |
|
143 | + /** |
|
144 | + * espresso_load_required |
|
145 | + * given a class name and path, this function will load that file or throw an exception |
|
146 | + * |
|
147 | + * @param string $classname |
|
148 | + * @param string $full_path_to_file |
|
149 | + * @throws EE_Error |
|
150 | + */ |
|
151 | + function espresso_load_required($classname, $full_path_to_file) |
|
152 | + { |
|
153 | + if (is_readable($full_path_to_file)) { |
|
154 | + require_once $full_path_to_file; |
|
155 | + } else { |
|
156 | + throw new \EE_Error ( |
|
157 | + sprintf( |
|
158 | + esc_html__( |
|
159 | + 'The %s class file could not be located or is not readable due to file permissions.', |
|
160 | + 'event_espresso' |
|
161 | + ), |
|
162 | + $classname |
|
163 | + ) |
|
164 | + ); |
|
165 | + } |
|
166 | + } |
|
167 | 167 | |
168 | - /** |
|
169 | - * @since 4.9.27 |
|
170 | - * @throws \EE_Error |
|
171 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
172 | - * @throws \EventEspresso\core\exceptions\InvalidEntityException |
|
173 | - * @throws \EventEspresso\core\exceptions\InvalidIdentifierException |
|
174 | - * @throws \EventEspresso\core\exceptions\InvalidClassException |
|
175 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
176 | - * @throws \EventEspresso\core\services\container\exceptions\ServiceExistsException |
|
177 | - * @throws \EventEspresso\core\services\container\exceptions\ServiceNotFoundException |
|
178 | - * @throws \OutOfBoundsException |
|
179 | - */ |
|
180 | - function bootstrap_espresso() |
|
181 | - { |
|
182 | - require_once __DIR__ . '/core/espresso_definitions.php'; |
|
183 | - try { |
|
184 | - espresso_load_error_handling(); |
|
185 | - espresso_load_required( |
|
186 | - 'EEH_Base', |
|
187 | - EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php' |
|
188 | - ); |
|
189 | - espresso_load_required( |
|
190 | - 'EEH_File', |
|
191 | - EE_CORE . 'interfaces' . DS . 'EEHI_File.interface.php' |
|
192 | - ); |
|
193 | - espresso_load_required( |
|
194 | - 'EEH_File', |
|
195 | - EE_CORE . 'helpers' . DS . 'EEH_File.helper.php' |
|
196 | - ); |
|
197 | - espresso_load_required( |
|
198 | - 'EEH_Array', |
|
199 | - EE_CORE . 'helpers' . DS . 'EEH_Array.helper.php' |
|
200 | - ); |
|
201 | - // instantiate and configure PSR4 autoloader |
|
202 | - espresso_load_required( |
|
203 | - 'Psr4Autoloader', |
|
204 | - EE_CORE . 'Psr4Autoloader.php' |
|
205 | - ); |
|
206 | - espresso_load_required( |
|
207 | - 'EE_Psr4AutoloaderInit', |
|
208 | - EE_CORE . 'EE_Psr4AutoloaderInit.core.php' |
|
209 | - ); |
|
210 | - $AutoloaderInit = new EE_Psr4AutoloaderInit(); |
|
211 | - $AutoloaderInit->initializeAutoloader(); |
|
212 | - espresso_load_required( |
|
213 | - 'EE_Request', |
|
214 | - EE_CORE . 'request_stack' . DS . 'EE_Request.core.php' |
|
215 | - ); |
|
216 | - espresso_load_required( |
|
217 | - 'EE_Response', |
|
218 | - EE_CORE . 'request_stack' . DS . 'EE_Response.core.php' |
|
219 | - ); |
|
220 | - espresso_load_required( |
|
221 | - 'EE_Bootstrap', |
|
222 | - EE_CORE . 'EE_Bootstrap.core.php' |
|
223 | - ); |
|
224 | - // bootstrap EE and the request stack |
|
225 | - new EE_Bootstrap( |
|
226 | - new EE_Request($_GET, $_POST, $_COOKIE), |
|
227 | - new EE_Response() |
|
228 | - ); |
|
229 | - } catch (Exception $e) { |
|
230 | - require_once EE_CORE . 'exceptions' . DS . 'ExceptionStackTraceDisplay.php'; |
|
231 | - new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e); |
|
232 | - } |
|
233 | - } |
|
234 | - bootstrap_espresso(); |
|
235 | - } |
|
168 | + /** |
|
169 | + * @since 4.9.27 |
|
170 | + * @throws \EE_Error |
|
171 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
172 | + * @throws \EventEspresso\core\exceptions\InvalidEntityException |
|
173 | + * @throws \EventEspresso\core\exceptions\InvalidIdentifierException |
|
174 | + * @throws \EventEspresso\core\exceptions\InvalidClassException |
|
175 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
176 | + * @throws \EventEspresso\core\services\container\exceptions\ServiceExistsException |
|
177 | + * @throws \EventEspresso\core\services\container\exceptions\ServiceNotFoundException |
|
178 | + * @throws \OutOfBoundsException |
|
179 | + */ |
|
180 | + function bootstrap_espresso() |
|
181 | + { |
|
182 | + require_once __DIR__ . '/core/espresso_definitions.php'; |
|
183 | + try { |
|
184 | + espresso_load_error_handling(); |
|
185 | + espresso_load_required( |
|
186 | + 'EEH_Base', |
|
187 | + EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php' |
|
188 | + ); |
|
189 | + espresso_load_required( |
|
190 | + 'EEH_File', |
|
191 | + EE_CORE . 'interfaces' . DS . 'EEHI_File.interface.php' |
|
192 | + ); |
|
193 | + espresso_load_required( |
|
194 | + 'EEH_File', |
|
195 | + EE_CORE . 'helpers' . DS . 'EEH_File.helper.php' |
|
196 | + ); |
|
197 | + espresso_load_required( |
|
198 | + 'EEH_Array', |
|
199 | + EE_CORE . 'helpers' . DS . 'EEH_Array.helper.php' |
|
200 | + ); |
|
201 | + // instantiate and configure PSR4 autoloader |
|
202 | + espresso_load_required( |
|
203 | + 'Psr4Autoloader', |
|
204 | + EE_CORE . 'Psr4Autoloader.php' |
|
205 | + ); |
|
206 | + espresso_load_required( |
|
207 | + 'EE_Psr4AutoloaderInit', |
|
208 | + EE_CORE . 'EE_Psr4AutoloaderInit.core.php' |
|
209 | + ); |
|
210 | + $AutoloaderInit = new EE_Psr4AutoloaderInit(); |
|
211 | + $AutoloaderInit->initializeAutoloader(); |
|
212 | + espresso_load_required( |
|
213 | + 'EE_Request', |
|
214 | + EE_CORE . 'request_stack' . DS . 'EE_Request.core.php' |
|
215 | + ); |
|
216 | + espresso_load_required( |
|
217 | + 'EE_Response', |
|
218 | + EE_CORE . 'request_stack' . DS . 'EE_Response.core.php' |
|
219 | + ); |
|
220 | + espresso_load_required( |
|
221 | + 'EE_Bootstrap', |
|
222 | + EE_CORE . 'EE_Bootstrap.core.php' |
|
223 | + ); |
|
224 | + // bootstrap EE and the request stack |
|
225 | + new EE_Bootstrap( |
|
226 | + new EE_Request($_GET, $_POST, $_COOKIE), |
|
227 | + new EE_Response() |
|
228 | + ); |
|
229 | + } catch (Exception $e) { |
|
230 | + require_once EE_CORE . 'exceptions' . DS . 'ExceptionStackTraceDisplay.php'; |
|
231 | + new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e); |
|
232 | + } |
|
233 | + } |
|
234 | + bootstrap_espresso(); |
|
235 | + } |
|
236 | 236 | } |
237 | 237 | if (! function_exists('espresso_deactivate_plugin')) { |
238 | - /** |
|
239 | - * deactivate_plugin |
|
240 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
241 | - * |
|
242 | - * @access public |
|
243 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
244 | - * @return void |
|
245 | - */ |
|
246 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
247 | - { |
|
248 | - if (! function_exists('deactivate_plugins')) { |
|
249 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
250 | - } |
|
251 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
252 | - deactivate_plugins($plugin_basename); |
|
253 | - } |
|
238 | + /** |
|
239 | + * deactivate_plugin |
|
240 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
241 | + * |
|
242 | + * @access public |
|
243 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
244 | + * @return void |
|
245 | + */ |
|
246 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
247 | + { |
|
248 | + if (! function_exists('deactivate_plugins')) { |
|
249 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
250 | + } |
|
251 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
252 | + deactivate_plugins($plugin_basename); |
|
253 | + } |
|
254 | 254 | } |