@@ -16,1403 +16,1403 @@ |
||
16 | 16 | class Extend_Events_Admin_Page extends Events_Admin_Page |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @var EE_Admin_Config |
|
21 | - */ |
|
22 | - protected $admin_config; |
|
23 | - |
|
24 | - /** |
|
25 | - * @var AdvancedEditorAdminFormSection |
|
26 | - */ |
|
27 | - protected $advanced_editor_admin_form; |
|
28 | - |
|
29 | - |
|
30 | - /** |
|
31 | - * Extend_Events_Admin_Page constructor. |
|
32 | - * |
|
33 | - * @param bool $routing |
|
34 | - * @throws ReflectionException |
|
35 | - */ |
|
36 | - public function __construct($routing = true) |
|
37 | - { |
|
38 | - if (! defined('EVENTS_CAF_TEMPLATE_PATH')) { |
|
39 | - define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/'); |
|
40 | - define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/'); |
|
41 | - define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/'); |
|
42 | - } |
|
43 | - parent::__construct($routing); |
|
44 | - $this->admin_config = $this->loader->getShared('EE_Admin_Config'); |
|
45 | - } |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * Sets routes. |
|
50 | - * |
|
51 | - * @throws EE_Error |
|
52 | - * @throws InvalidArgumentException |
|
53 | - * @throws InvalidDataTypeException |
|
54 | - * @throws InvalidInterfaceException |
|
55 | - * @throws Exception |
|
56 | - */ |
|
57 | - protected function _extend_page_config() |
|
58 | - { |
|
59 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events'; |
|
60 | - // is there a evt_id in the request? |
|
61 | - $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) |
|
62 | - ? $this->_req_data['EVT_ID'] |
|
63 | - : 0; |
|
64 | - $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id; |
|
65 | - // tkt_id? |
|
66 | - $tkt_id = ! empty($this->_req_data['TKT_ID']) && ! is_array($this->_req_data['TKT_ID']) |
|
67 | - ? $this->_req_data['TKT_ID'] |
|
68 | - : 0; |
|
69 | - $new_page_routes = array( |
|
70 | - 'duplicate_event' => array( |
|
71 | - 'func' => '_duplicate_event', |
|
72 | - 'capability' => 'ee_edit_event', |
|
73 | - 'obj_id' => $evt_id, |
|
74 | - 'noheader' => true, |
|
75 | - ), |
|
76 | - 'ticket_list_table' => array( |
|
77 | - 'func' => '_tickets_overview_list_table', |
|
78 | - 'capability' => 'ee_read_default_tickets', |
|
79 | - ), |
|
80 | - 'trash_ticket' => array( |
|
81 | - 'func' => '_trash_or_restore_ticket', |
|
82 | - 'capability' => 'ee_delete_default_ticket', |
|
83 | - 'obj_id' => $tkt_id, |
|
84 | - 'noheader' => true, |
|
85 | - 'args' => array('trash' => true), |
|
86 | - ), |
|
87 | - 'trash_tickets' => array( |
|
88 | - 'func' => '_trash_or_restore_ticket', |
|
89 | - 'capability' => 'ee_delete_default_tickets', |
|
90 | - 'noheader' => true, |
|
91 | - 'args' => array('trash' => true), |
|
92 | - ), |
|
93 | - 'restore_ticket' => array( |
|
94 | - 'func' => '_trash_or_restore_ticket', |
|
95 | - 'capability' => 'ee_delete_default_ticket', |
|
96 | - 'obj_id' => $tkt_id, |
|
97 | - 'noheader' => true, |
|
98 | - ), |
|
99 | - 'restore_tickets' => array( |
|
100 | - 'func' => '_trash_or_restore_ticket', |
|
101 | - 'capability' => 'ee_delete_default_tickets', |
|
102 | - 'noheader' => true, |
|
103 | - ), |
|
104 | - 'delete_ticket' => array( |
|
105 | - 'func' => '_delete_ticket', |
|
106 | - 'capability' => 'ee_delete_default_ticket', |
|
107 | - 'obj_id' => $tkt_id, |
|
108 | - 'noheader' => true, |
|
109 | - ), |
|
110 | - 'delete_tickets' => array( |
|
111 | - 'func' => '_delete_ticket', |
|
112 | - 'capability' => 'ee_delete_default_tickets', |
|
113 | - 'noheader' => true, |
|
114 | - ), |
|
115 | - 'import_page' => array( |
|
116 | - 'func' => '_import_page', |
|
117 | - 'capability' => 'import', |
|
118 | - ), |
|
119 | - 'import' => array( |
|
120 | - 'func' => '_import_events', |
|
121 | - 'capability' => 'import', |
|
122 | - 'noheader' => true, |
|
123 | - ), |
|
124 | - 'import_events' => array( |
|
125 | - 'func' => '_import_events', |
|
126 | - 'capability' => 'import', |
|
127 | - 'noheader' => true, |
|
128 | - ), |
|
129 | - 'export_events' => array( |
|
130 | - 'func' => '_events_export', |
|
131 | - 'capability' => 'export', |
|
132 | - 'noheader' => true, |
|
133 | - ), |
|
134 | - 'export_categories' => array( |
|
135 | - 'func' => '_categories_export', |
|
136 | - 'capability' => 'export', |
|
137 | - 'noheader' => true, |
|
138 | - ), |
|
139 | - 'sample_export_file' => array( |
|
140 | - 'func' => '_sample_export_file', |
|
141 | - 'capability' => 'export', |
|
142 | - 'noheader' => true, |
|
143 | - ), |
|
144 | - 'update_template_settings' => array( |
|
145 | - 'func' => '_update_template_settings', |
|
146 | - 'capability' => 'manage_options', |
|
147 | - 'noheader' => true, |
|
148 | - ), |
|
149 | - ); |
|
150 | - $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
151 | - // partial route/config override |
|
152 | - $this->_page_config['import_events']['metaboxes'] = $this->_default_espresso_metaboxes; |
|
153 | - $this->_page_config['create_new']['metaboxes'][] = '_premium_event_editor_meta_boxes'; |
|
154 | - // don't load qTips if using the advanced editor |
|
155 | - if (! $this->admin_config->useAdvancedEditor()) { |
|
156 | - $this->_page_config['create_new']['qtips'][] = 'EE_Event_Editor_Tips'; |
|
157 | - $this->_page_config['edit']['qtips'][] = 'EE_Event_Editor_Tips'; |
|
158 | - } |
|
159 | - $this->_page_config['edit']['metaboxes'][] = '_premium_event_editor_meta_boxes'; |
|
160 | - $this->_page_config['default']['list_table'] = 'Extend_Events_Admin_List_Table'; |
|
161 | - // add tickets tab but only if there are more than one default ticket! |
|
162 | - $tkt_count = EEM_Ticket::instance()->count_deleted_and_undeleted( |
|
163 | - array(array('TKT_is_default' => 1)), |
|
164 | - 'TKT_ID', |
|
165 | - true |
|
166 | - ); |
|
167 | - if ($tkt_count > 1) { |
|
168 | - $new_page_config = array( |
|
169 | - 'ticket_list_table' => array( |
|
170 | - 'nav' => array( |
|
171 | - 'label' => esc_html__('Default Tickets', 'event_espresso'), |
|
172 | - 'order' => 60, |
|
173 | - ), |
|
174 | - 'list_table' => 'Tickets_List_Table', |
|
175 | - 'require_nonce' => false, |
|
176 | - ), |
|
177 | - ); |
|
178 | - } |
|
179 | - // template settings |
|
180 | - $new_page_config['template_settings'] = array( |
|
181 | - 'nav' => array( |
|
182 | - 'label' => esc_html__('Templates', 'event_espresso'), |
|
183 | - 'order' => 30, |
|
184 | - ), |
|
185 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
186 | - 'help_tabs' => array( |
|
187 | - 'general_settings_templates_help_tab' => array( |
|
188 | - 'title' => esc_html__('Templates', 'event_espresso'), |
|
189 | - 'filename' => 'general_settings_templates', |
|
190 | - ), |
|
191 | - ), |
|
192 | - 'help_tour' => array('Templates_Help_Tour'), |
|
193 | - 'require_nonce' => false, |
|
194 | - ); |
|
195 | - $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
196 | - // add filters and actions |
|
197 | - // modifying _views |
|
198 | - add_filter( |
|
199 | - 'FHEE_event_datetime_metabox_add_additional_date_time_template', |
|
200 | - array($this, 'add_additional_datetime_button'), |
|
201 | - 10, |
|
202 | - 2 |
|
203 | - ); |
|
204 | - add_filter( |
|
205 | - 'FHEE_event_datetime_metabox_clone_button_template', |
|
206 | - array($this, 'add_datetime_clone_button'), |
|
207 | - 10, |
|
208 | - 2 |
|
209 | - ); |
|
210 | - add_filter( |
|
211 | - 'FHEE_event_datetime_metabox_timezones_template', |
|
212 | - array($this, 'datetime_timezones_template'), |
|
213 | - 10, |
|
214 | - 2 |
|
215 | - ); |
|
216 | - // filters for event list table |
|
217 | - add_filter('FHEE__Extend_Events_Admin_List_Table__filters', array($this, 'list_table_filters'), 10, 2); |
|
218 | - add_filter( |
|
219 | - 'FHEE__Events_Admin_List_Table__column_actions__action_links', |
|
220 | - array($this, 'extra_list_table_actions'), |
|
221 | - 10, |
|
222 | - 2 |
|
223 | - ); |
|
224 | - // legend item |
|
225 | - add_filter('FHEE__Events_Admin_Page___event_legend_items__items', array($this, 'additional_legend_items')); |
|
226 | - add_action('admin_init', array($this, 'admin_init')); |
|
227 | - // load additional handlers |
|
228 | - $this->handleActionRequest(); |
|
229 | - } |
|
230 | - |
|
231 | - |
|
232 | - private function getRequestAction() |
|
233 | - { |
|
234 | - return isset($this->_req_data['action']) ? sanitize_key($this->_req_data['action']) : null; |
|
235 | - } |
|
236 | - |
|
237 | - |
|
238 | - /** |
|
239 | - * @throws Exception |
|
240 | - */ |
|
241 | - private function handleActionRequest() |
|
242 | - { |
|
243 | - $action = $this->getRequestAction(); |
|
244 | - if ($action) { |
|
245 | - // setup Advanced Editor ??? |
|
246 | - if ($action === 'default_event_settings' || $action === 'update_default_event_settings') { |
|
247 | - $this->advanced_editor_admin_form = $this->loader->getShared( |
|
248 | - 'EventEspresso\core\domain\services\admin\events\default_settings\AdvancedEditorAdminFormSection' |
|
249 | - ); |
|
250 | - } |
|
251 | - } |
|
252 | - } |
|
253 | - |
|
254 | - |
|
255 | - /** |
|
256 | - * admin_init |
|
257 | - */ |
|
258 | - public function admin_init() |
|
259 | - { |
|
260 | - EE_Registry::$i18n_js_strings = array_merge( |
|
261 | - EE_Registry::$i18n_js_strings, |
|
262 | - array( |
|
263 | - 'image_confirm' => esc_html__( |
|
264 | - 'Do you really want to delete this image? Please remember to update your event to complete the removal.', |
|
265 | - 'event_espresso' |
|
266 | - ), |
|
267 | - 'event_starts_on' => esc_html__('Event Starts on', 'event_espresso'), |
|
268 | - 'event_ends_on' => esc_html__('Event Ends on', 'event_espresso'), |
|
269 | - 'event_datetime_actions' => esc_html__('Actions', 'event_espresso'), |
|
270 | - 'event_clone_dt_msg' => esc_html__('Clone this Event Date and Time', 'event_espresso'), |
|
271 | - 'remove_event_dt_msg' => esc_html__('Remove this Event Time', 'event_espresso'), |
|
272 | - ) |
|
273 | - ); |
|
274 | - } |
|
275 | - |
|
276 | - |
|
277 | - /** |
|
278 | - * Add per page screen options to the default ticket list table view. |
|
279 | - * |
|
280 | - * @throws InvalidArgumentException |
|
281 | - * @throws InvalidDataTypeException |
|
282 | - * @throws InvalidInterfaceException |
|
283 | - */ |
|
284 | - protected function _add_screen_options_ticket_list_table() |
|
285 | - { |
|
286 | - $this->_per_page_screen_option(); |
|
287 | - } |
|
288 | - |
|
289 | - |
|
290 | - /** |
|
291 | - * @param string $return |
|
292 | - * @param int $id |
|
293 | - * @param string $new_title |
|
294 | - * @param string $new_slug |
|
295 | - * @return string |
|
296 | - */ |
|
297 | - public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) |
|
298 | - { |
|
299 | - $return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug); |
|
300 | - // make sure this is only when editing |
|
301 | - if (! empty($id)) { |
|
302 | - $href = EE_Admin_Page::add_query_args_and_nonce( |
|
303 | - array('action' => 'duplicate_event', 'EVT_ID' => $id), |
|
304 | - $this->_admin_base_url |
|
305 | - ); |
|
306 | - $title = esc_attr__('Duplicate Event', 'event_espresso'); |
|
307 | - $return .= '<a href="' |
|
308 | - . $href |
|
309 | - . '" title="' |
|
310 | - . $title |
|
311 | - . '" id="ee-duplicate-event-button" class="button button-small" value="duplicate_event">' |
|
312 | - . $title |
|
313 | - . '</a>'; |
|
314 | - } |
|
315 | - return $return; |
|
316 | - } |
|
317 | - |
|
318 | - |
|
319 | - /** |
|
320 | - * Set the list table views for the default ticket list table view. |
|
321 | - */ |
|
322 | - public function _set_list_table_views_ticket_list_table() |
|
323 | - { |
|
324 | - $this->_views = array( |
|
325 | - 'all' => array( |
|
326 | - 'slug' => 'all', |
|
327 | - 'label' => esc_html__('All', 'event_espresso'), |
|
328 | - 'count' => 0, |
|
329 | - 'bulk_action' => array( |
|
330 | - 'trash_tickets' => esc_html__('Move to Trash', 'event_espresso'), |
|
331 | - ), |
|
332 | - ), |
|
333 | - 'trashed' => array( |
|
334 | - 'slug' => 'trashed', |
|
335 | - 'label' => esc_html__('Trash', 'event_espresso'), |
|
336 | - 'count' => 0, |
|
337 | - 'bulk_action' => array( |
|
338 | - 'restore_tickets' => esc_html__('Restore from Trash', 'event_espresso'), |
|
339 | - 'delete_tickets' => esc_html__('Delete Permanently', 'event_espresso'), |
|
340 | - ), |
|
341 | - ), |
|
342 | - ); |
|
343 | - } |
|
344 | - |
|
345 | - |
|
346 | - /** |
|
347 | - * Enqueue scripts and styles for the event editor. |
|
348 | - */ |
|
349 | - public function load_scripts_styles_edit() |
|
350 | - { |
|
351 | - wp_register_script( |
|
352 | - 'ee-event-editor-heartbeat', |
|
353 | - EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js', |
|
354 | - array('ee_admin_js', 'heartbeat'), |
|
355 | - EVENT_ESPRESSO_VERSION, |
|
356 | - true |
|
357 | - ); |
|
358 | - wp_enqueue_script('ee-accounting'); |
|
359 | - // styles |
|
360 | - wp_enqueue_style('espresso-ui-theme'); |
|
361 | - wp_enqueue_script('event_editor_js'); |
|
362 | - wp_enqueue_script('ee-event-editor-heartbeat'); |
|
363 | - } |
|
364 | - |
|
365 | - |
|
366 | - /** |
|
367 | - * Returns template for the additional datetime. |
|
368 | - * |
|
369 | - * @param $template |
|
370 | - * @param $template_args |
|
371 | - * @return mixed |
|
372 | - * @throws DomainException |
|
373 | - */ |
|
374 | - public function add_additional_datetime_button($template, $template_args) |
|
375 | - { |
|
376 | - return EEH_Template::display_template( |
|
377 | - EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php', |
|
378 | - $template_args, |
|
379 | - true |
|
380 | - ); |
|
381 | - } |
|
382 | - |
|
383 | - |
|
384 | - /** |
|
385 | - * Returns the template for cloning a datetime. |
|
386 | - * |
|
387 | - * @param $template |
|
388 | - * @param $template_args |
|
389 | - * @return mixed |
|
390 | - * @throws DomainException |
|
391 | - */ |
|
392 | - public function add_datetime_clone_button($template, $template_args) |
|
393 | - { |
|
394 | - return EEH_Template::display_template( |
|
395 | - EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php', |
|
396 | - $template_args, |
|
397 | - true |
|
398 | - ); |
|
399 | - } |
|
400 | - |
|
401 | - |
|
402 | - /** |
|
403 | - * Returns the template for datetime timezones. |
|
404 | - * |
|
405 | - * @param $template |
|
406 | - * @param $template_args |
|
407 | - * @return mixed |
|
408 | - * @throws DomainException |
|
409 | - */ |
|
410 | - public function datetime_timezones_template($template, $template_args) |
|
411 | - { |
|
412 | - return EEH_Template::display_template( |
|
413 | - EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php', |
|
414 | - $template_args, |
|
415 | - true |
|
416 | - ); |
|
417 | - } |
|
418 | - |
|
419 | - |
|
420 | - /** |
|
421 | - * Sets the views for the default list table view. |
|
422 | - * |
|
423 | - * @throws EE_Error |
|
424 | - */ |
|
425 | - protected function _set_list_table_views_default() |
|
426 | - { |
|
427 | - parent::_set_list_table_views_default(); |
|
428 | - $new_views = array( |
|
429 | - 'today' => array( |
|
430 | - 'slug' => 'today', |
|
431 | - 'label' => esc_html__('Today', 'event_espresso'), |
|
432 | - 'count' => $this->total_events_today(), |
|
433 | - 'bulk_action' => array( |
|
434 | - 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
435 | - ), |
|
436 | - ), |
|
437 | - 'month' => array( |
|
438 | - 'slug' => 'month', |
|
439 | - 'label' => esc_html__('This Month', 'event_espresso'), |
|
440 | - 'count' => $this->total_events_this_month(), |
|
441 | - 'bulk_action' => array( |
|
442 | - 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
443 | - ), |
|
444 | - ), |
|
445 | - ); |
|
446 | - $this->_views = array_merge($this->_views, $new_views); |
|
447 | - } |
|
448 | - |
|
449 | - |
|
450 | - /** |
|
451 | - * Returns the extra action links for the default list table view. |
|
452 | - * |
|
453 | - * @param array $action_links |
|
454 | - * @param EE_Event $event |
|
455 | - * @return array |
|
456 | - * @throws EE_Error |
|
457 | - * @throws InvalidArgumentException |
|
458 | - * @throws InvalidDataTypeException |
|
459 | - * @throws InvalidInterfaceException |
|
460 | - * @throws ReflectionException |
|
461 | - */ |
|
462 | - public function extra_list_table_actions(array $action_links, EE_Event $event) |
|
463 | - { |
|
464 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
465 | - 'ee_read_registrations', |
|
466 | - 'espresso_registrations_reports', |
|
467 | - $event->ID() |
|
468 | - ) |
|
469 | - ) { |
|
470 | - $reports_query_args = array( |
|
471 | - 'action' => 'reports', |
|
472 | - 'EVT_ID' => $event->ID(), |
|
473 | - ); |
|
474 | - $reports_link = EE_Admin_Page::add_query_args_and_nonce($reports_query_args, REG_ADMIN_URL); |
|
475 | - $action_links[] = '<a href="' |
|
476 | - . $reports_link |
|
477 | - . '" title="' |
|
478 | - . esc_attr__('View Report', 'event_espresso') |
|
479 | - . '"><div class="dashicons dashicons-chart-bar"></div></a>' |
|
480 | - . "\n\t"; |
|
481 | - } |
|
482 | - if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
483 | - EE_Registry::instance()->load_helper('MSG_Template'); |
|
484 | - $action_links[] = EEH_MSG_Template::get_message_action_link( |
|
485 | - 'see_notifications_for', |
|
486 | - null, |
|
487 | - array('EVT_ID' => $event->ID()) |
|
488 | - ); |
|
489 | - } |
|
490 | - return $action_links; |
|
491 | - } |
|
492 | - |
|
493 | - |
|
494 | - /** |
|
495 | - * @param $items |
|
496 | - * @return mixed |
|
497 | - */ |
|
498 | - public function additional_legend_items($items) |
|
499 | - { |
|
500 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
501 | - 'ee_read_registrations', |
|
502 | - 'espresso_registrations_reports' |
|
503 | - ) |
|
504 | - ) { |
|
505 | - $items['reports'] = array( |
|
506 | - 'class' => 'dashicons dashicons-chart-bar', |
|
507 | - 'desc' => esc_html__('Event Reports', 'event_espresso'), |
|
508 | - ); |
|
509 | - } |
|
510 | - if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
511 | - $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for'); |
|
512 | - // $related_for_icon can sometimes be a string so 'css_class' would be an illegal offset |
|
513 | - // (can only use numeric offsets when treating strings as arrays) |
|
514 | - if (is_array($related_for_icon) && isset($related_for_icon['css_class'], $related_for_icon['label'])) { |
|
515 | - $items['view_related_messages'] = array( |
|
516 | - 'class' => $related_for_icon['css_class'], |
|
517 | - 'desc' => $related_for_icon['label'], |
|
518 | - ); |
|
519 | - } |
|
520 | - } |
|
521 | - return $items; |
|
522 | - } |
|
523 | - |
|
524 | - |
|
525 | - /** |
|
526 | - * This is the callback method for the duplicate event route |
|
527 | - * Method looks for 'EVT_ID' in the request and retrieves that event and its details and duplicates them |
|
528 | - * into a new event. We add a hook so that any plugins that add extra event details can hook into this |
|
529 | - * action. Note that the dupe will have **DUPLICATE** as its title and slug. |
|
530 | - * After duplication the redirect is to the new event edit page. |
|
531 | - * |
|
532 | - * @return void |
|
533 | - * @throws EE_Error If EE_Event is not available with given ID |
|
534 | - * @throws InvalidArgumentException |
|
535 | - * @throws InvalidDataTypeException |
|
536 | - * @throws InvalidInterfaceException |
|
537 | - * @throws ReflectionException |
|
538 | - * @access protected |
|
539 | - */ |
|
540 | - protected function _duplicate_event() |
|
541 | - { |
|
542 | - // first make sure the ID for the event is in the request. |
|
543 | - // If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?) |
|
544 | - if (! isset($this->_req_data['EVT_ID'])) { |
|
545 | - EE_Error::add_error( |
|
546 | - esc_html__( |
|
547 | - 'In order to duplicate an event an Event ID is required. None was given.', |
|
548 | - 'event_espresso' |
|
549 | - ), |
|
550 | - __FILE__, |
|
551 | - __FUNCTION__, |
|
552 | - __LINE__ |
|
553 | - ); |
|
554 | - $this->_redirect_after_action(false, '', '', array(), true); |
|
555 | - return; |
|
556 | - } |
|
557 | - // k we've got EVT_ID so let's use that to get the event we'll duplicate |
|
558 | - $orig_event = EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']); |
|
559 | - if (! $orig_event instanceof EE_Event) { |
|
560 | - throw new EE_Error( |
|
561 | - sprintf( |
|
562 | - esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'), |
|
563 | - $this->_req_data['EVT_ID'] |
|
564 | - ) |
|
565 | - ); |
|
566 | - } |
|
567 | - // k now let's clone the $orig_event before getting relations |
|
568 | - $new_event = clone $orig_event; |
|
569 | - // original datetimes |
|
570 | - $orig_datetimes = $orig_event->get_many_related('Datetime'); |
|
571 | - // other original relations |
|
572 | - $orig_ven = $orig_event->get_many_related('Venue'); |
|
573 | - // reset the ID and modify other details to make it clear this is a dupe |
|
574 | - $new_event->set('EVT_ID', 0); |
|
575 | - $new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso'); |
|
576 | - $new_event->set('EVT_name', $new_name); |
|
577 | - $new_event->set( |
|
578 | - 'EVT_slug', |
|
579 | - wp_unique_post_slug( |
|
580 | - sanitize_title($orig_event->name()), |
|
581 | - 0, |
|
582 | - 'publish', |
|
583 | - 'espresso_events', |
|
584 | - 0 |
|
585 | - ) |
|
586 | - ); |
|
587 | - $new_event->set('status', 'draft'); |
|
588 | - // duplicate discussion settings |
|
589 | - $new_event->set('comment_status', $orig_event->get('comment_status')); |
|
590 | - $new_event->set('ping_status', $orig_event->get('ping_status')); |
|
591 | - // save the new event |
|
592 | - $new_event->save(); |
|
593 | - // venues |
|
594 | - foreach ($orig_ven as $ven) { |
|
595 | - $new_event->_add_relation_to($ven, 'Venue'); |
|
596 | - } |
|
597 | - $new_event->save(); |
|
598 | - // now we need to get the question group relations and handle that |
|
599 | - // first primary question groups |
|
600 | - $orig_primary_qgs = $orig_event->get_many_related( |
|
601 | - 'Question_Group', |
|
602 | - [['Event_Question_Group.EQG_primary' => true]] |
|
603 | - ); |
|
604 | - if (! empty($orig_primary_qgs)) { |
|
605 | - foreach ($orig_primary_qgs as $id => $obj) { |
|
606 | - if ($obj instanceof EE_Question_Group) { |
|
607 | - $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_primary' => true]); |
|
608 | - } |
|
609 | - } |
|
610 | - } |
|
611 | - // next additional attendee question groups |
|
612 | - $orig_additional_qgs = $orig_event->get_many_related( |
|
613 | - 'Question_Group', |
|
614 | - [['Event_Question_Group.EQG_additional' => true]] |
|
615 | - ); |
|
616 | - if (! empty($orig_additional_qgs)) { |
|
617 | - foreach ($orig_additional_qgs as $id => $obj) { |
|
618 | - if ($obj instanceof EE_Question_Group) { |
|
619 | - $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_additional' => true]); |
|
620 | - } |
|
621 | - } |
|
622 | - } |
|
623 | - |
|
624 | - $new_event->save(); |
|
625 | - |
|
626 | - // k now that we have the new event saved we can loop through the datetimes and start adding relations. |
|
627 | - $cloned_tickets = array(); |
|
628 | - foreach ($orig_datetimes as $orig_dtt) { |
|
629 | - if (! $orig_dtt instanceof EE_Datetime) { |
|
630 | - continue; |
|
631 | - } |
|
632 | - $new_dtt = clone $orig_dtt; |
|
633 | - $orig_tkts = $orig_dtt->tickets(); |
|
634 | - // save new dtt then add to event |
|
635 | - $new_dtt->set('DTT_ID', 0); |
|
636 | - $new_dtt->set('DTT_sold', 0); |
|
637 | - $new_dtt->set_reserved(0); |
|
638 | - $new_dtt->save(); |
|
639 | - $new_event->_add_relation_to($new_dtt, 'Datetime'); |
|
640 | - $new_event->save(); |
|
641 | - // now let's get the ticket relations setup. |
|
642 | - foreach ((array) $orig_tkts as $orig_tkt) { |
|
643 | - // it's possible a datetime will have no tickets so let's verify we HAVE a ticket first. |
|
644 | - if (! $orig_tkt instanceof EE_Ticket) { |
|
645 | - continue; |
|
646 | - } |
|
647 | - // is this ticket archived? If it is then let's skip |
|
648 | - if ($orig_tkt->get('TKT_deleted')) { |
|
649 | - continue; |
|
650 | - } |
|
651 | - // does this original ticket already exist in the clone_tickets cache? |
|
652 | - // If so we'll just use the new ticket from it. |
|
653 | - if (isset($cloned_tickets[ $orig_tkt->ID() ])) { |
|
654 | - $new_tkt = $cloned_tickets[ $orig_tkt->ID() ]; |
|
655 | - } else { |
|
656 | - $new_tkt = clone $orig_tkt; |
|
657 | - // get relations on the $orig_tkt that we need to setup. |
|
658 | - $orig_prices = $orig_tkt->prices(); |
|
659 | - $new_tkt->set('TKT_ID', 0); |
|
660 | - $new_tkt->set('TKT_sold', 0); |
|
661 | - $new_tkt->set('TKT_reserved', 0); |
|
662 | - $new_tkt->save(); // make sure new ticket has ID. |
|
663 | - // price relations on new ticket need to be setup. |
|
664 | - foreach ($orig_prices as $orig_price) { |
|
665 | - $new_price = clone $orig_price; |
|
666 | - $new_price->set('PRC_ID', 0); |
|
667 | - $new_price->save(); |
|
668 | - $new_tkt->_add_relation_to($new_price, 'Price'); |
|
669 | - $new_tkt->save(); |
|
670 | - } |
|
671 | - |
|
672 | - do_action( |
|
673 | - 'AHEE__Extend_Events_Admin_Page___duplicate_event__duplicate_ticket__after', |
|
674 | - $orig_tkt, |
|
675 | - $new_tkt, |
|
676 | - $orig_prices, |
|
677 | - $orig_event, |
|
678 | - $orig_dtt, |
|
679 | - $new_dtt |
|
680 | - ); |
|
681 | - } |
|
682 | - // k now we can add the new ticket as a relation to the new datetime |
|
683 | - // and make sure its added to our cached $cloned_tickets array |
|
684 | - // for use with later datetimes that have the same ticket. |
|
685 | - $new_dtt->_add_relation_to($new_tkt, 'Ticket'); |
|
686 | - $new_dtt->save(); |
|
687 | - $cloned_tickets[ $orig_tkt->ID() ] = $new_tkt; |
|
688 | - } |
|
689 | - } |
|
690 | - // clone taxonomy information |
|
691 | - $taxonomies_to_clone_with = apply_filters( |
|
692 | - 'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone', |
|
693 | - array('espresso_event_categories', 'espresso_event_type', 'post_tag') |
|
694 | - ); |
|
695 | - // get terms for original event (notice) |
|
696 | - $orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with); |
|
697 | - // loop through terms and add them to new event. |
|
698 | - foreach ($orig_terms as $term) { |
|
699 | - wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true); |
|
700 | - } |
|
701 | - |
|
702 | - // duplicate other core WP_Post items for this event. |
|
703 | - // post thumbnail (feature image). |
|
704 | - $feature_image_id = get_post_thumbnail_id($orig_event->ID()); |
|
705 | - if ($feature_image_id) { |
|
706 | - update_post_meta($new_event->ID(), '_thumbnail_id', $feature_image_id); |
|
707 | - } |
|
708 | - |
|
709 | - // duplicate page_template setting |
|
710 | - $page_template = get_post_meta($orig_event->ID(), '_wp_page_template', true); |
|
711 | - if ($page_template) { |
|
712 | - update_post_meta($new_event->ID(), '_wp_page_template', $page_template); |
|
713 | - } |
|
714 | - |
|
715 | - do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event); |
|
716 | - // now let's redirect to the edit page for this duplicated event if we have a new event id. |
|
717 | - if ($new_event->ID()) { |
|
718 | - $redirect_args = array( |
|
719 | - 'post' => $new_event->ID(), |
|
720 | - 'action' => 'edit', |
|
721 | - ); |
|
722 | - EE_Error::add_success( |
|
723 | - esc_html__( |
|
724 | - 'Event successfully duplicated. Please review the details below and make any necessary edits', |
|
725 | - 'event_espresso' |
|
726 | - ) |
|
727 | - ); |
|
728 | - } else { |
|
729 | - $redirect_args = array( |
|
730 | - 'action' => 'default', |
|
731 | - ); |
|
732 | - EE_Error::add_error( |
|
733 | - esc_html__('Not able to duplicate event. Something went wrong.', 'event_espresso'), |
|
734 | - __FILE__, |
|
735 | - __FUNCTION__, |
|
736 | - __LINE__ |
|
737 | - ); |
|
738 | - } |
|
739 | - $this->_redirect_after_action(false, '', '', $redirect_args, true); |
|
740 | - } |
|
741 | - |
|
742 | - |
|
743 | - /** |
|
744 | - * Generates output for the import page. |
|
745 | - * |
|
746 | - * @throws DomainException |
|
747 | - * @throws EE_Error |
|
748 | - * @throws InvalidArgumentException |
|
749 | - * @throws InvalidDataTypeException |
|
750 | - * @throws InvalidInterfaceException |
|
751 | - */ |
|
752 | - protected function _import_page() |
|
753 | - { |
|
754 | - $title = esc_html__('Import', 'event_espresso'); |
|
755 | - $intro = esc_html__( |
|
756 | - 'If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ', |
|
757 | - 'event_espresso' |
|
758 | - ); |
|
759 | - $form_url = EVENTS_ADMIN_URL; |
|
760 | - $action = 'import_events'; |
|
761 | - $type = 'csv'; |
|
762 | - $this->_template_args['form'] = EE_Import::instance()->upload_form( |
|
763 | - $title, |
|
764 | - $intro, |
|
765 | - $form_url, |
|
766 | - $action, |
|
767 | - $type |
|
768 | - ); |
|
769 | - $this->_template_args['sample_file_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
770 | - array('action' => 'sample_export_file'), |
|
771 | - $this->_admin_base_url |
|
772 | - ); |
|
773 | - $content = EEH_Template::display_template( |
|
774 | - EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php', |
|
775 | - $this->_template_args, |
|
776 | - true |
|
777 | - ); |
|
778 | - $this->_template_args['admin_page_content'] = $content; |
|
779 | - $this->display_admin_page_with_sidebar(); |
|
780 | - } |
|
781 | - |
|
782 | - |
|
783 | - /** |
|
784 | - * _import_events |
|
785 | - * This handles displaying the screen and running imports for importing events. |
|
786 | - * |
|
787 | - * @return void |
|
788 | - * @throws EE_Error |
|
789 | - * @throws InvalidArgumentException |
|
790 | - * @throws InvalidDataTypeException |
|
791 | - * @throws InvalidInterfaceException |
|
792 | - */ |
|
793 | - protected function _import_events() |
|
794 | - { |
|
795 | - require_once(EE_CLASSES . 'EE_Import.class.php'); |
|
796 | - $success = EE_Import::instance()->import(); |
|
797 | - $this->_redirect_after_action($success, 'Import File', 'ran', array('action' => 'import_page'), true); |
|
798 | - } |
|
799 | - |
|
800 | - |
|
801 | - /** |
|
802 | - * _events_export |
|
803 | - * Will export all (or just the given event) to a Excel compatible file. |
|
804 | - * |
|
805 | - * @access protected |
|
806 | - * @return void |
|
807 | - */ |
|
808 | - protected function _events_export() |
|
809 | - { |
|
810 | - if (isset($this->_req_data['EVT_ID'])) { |
|
811 | - $event_ids = $this->_req_data['EVT_ID']; |
|
812 | - } elseif (isset($this->_req_data['EVT_IDs'])) { |
|
813 | - $event_ids = $this->_req_data['EVT_IDs']; |
|
814 | - } else { |
|
815 | - $event_ids = null; |
|
816 | - } |
|
817 | - // todo: I don't like doing this but it'll do until we modify EE_Export Class. |
|
818 | - $new_request_args = array( |
|
819 | - 'export' => 'report', |
|
820 | - 'action' => 'all_event_data', |
|
821 | - 'EVT_ID' => $event_ids, |
|
822 | - ); |
|
823 | - $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
824 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
825 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
826 | - $EE_Export = EE_Export::instance($this->_req_data); |
|
827 | - if ($EE_Export instanceof EE_Export) { |
|
828 | - $EE_Export->export(); |
|
829 | - } |
|
830 | - } |
|
831 | - } |
|
832 | - |
|
833 | - |
|
834 | - /** |
|
835 | - * handle category exports() |
|
836 | - * |
|
837 | - * @return void |
|
838 | - */ |
|
839 | - protected function _categories_export() |
|
840 | - { |
|
841 | - // todo: I don't like doing this but it'll do until we modify EE_Export Class. |
|
842 | - $new_request_args = array( |
|
843 | - 'export' => 'report', |
|
844 | - 'action' => 'categories', |
|
845 | - 'category_ids' => $this->_req_data['EVT_CAT_ID'], |
|
846 | - ); |
|
847 | - $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
848 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
849 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
850 | - $EE_Export = EE_Export::instance($this->_req_data); |
|
851 | - if ($EE_Export instanceof EE_Export) { |
|
852 | - $EE_Export->export(); |
|
853 | - } |
|
854 | - } |
|
855 | - } |
|
856 | - |
|
857 | - |
|
858 | - /** |
|
859 | - * Creates a sample CSV file for importing |
|
860 | - */ |
|
861 | - protected function _sample_export_file() |
|
862 | - { |
|
863 | - $EE_Export = EE_Export::instance(); |
|
864 | - if ($EE_Export instanceof EE_Export) { |
|
865 | - $EE_Export->export(); |
|
866 | - } |
|
867 | - } |
|
868 | - |
|
869 | - |
|
870 | - /************* Template Settings *************/ |
|
871 | - /** |
|
872 | - * Generates template settings page output |
|
873 | - * |
|
874 | - * @throws DomainException |
|
875 | - * @throws EE_Error |
|
876 | - * @throws InvalidArgumentException |
|
877 | - * @throws InvalidDataTypeException |
|
878 | - * @throws InvalidInterfaceException |
|
879 | - */ |
|
880 | - protected function _template_settings() |
|
881 | - { |
|
882 | - $this->_template_args['values'] = $this->_yes_no_values; |
|
883 | - /** |
|
884 | - * Note leaving this filter in for backward compatibility this was moved in 4.6.x |
|
885 | - * from General_Settings_Admin_Page to here. |
|
886 | - */ |
|
887 | - $this->_template_args = apply_filters( |
|
888 | - 'FHEE__General_Settings_Admin_Page__template_settings__template_args', |
|
889 | - $this->_template_args |
|
890 | - ); |
|
891 | - $this->_set_add_edit_form_tags('update_template_settings'); |
|
892 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
893 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
894 | - EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php', |
|
895 | - $this->_template_args, |
|
896 | - true |
|
897 | - ); |
|
898 | - $this->display_admin_page_with_sidebar(); |
|
899 | - } |
|
900 | - |
|
901 | - |
|
902 | - /** |
|
903 | - * Handler for updating template settings. |
|
904 | - * |
|
905 | - * @throws EE_Error |
|
906 | - * @throws InvalidArgumentException |
|
907 | - * @throws InvalidDataTypeException |
|
908 | - * @throws InvalidInterfaceException |
|
909 | - */ |
|
910 | - protected function _update_template_settings() |
|
911 | - { |
|
912 | - /** |
|
913 | - * Note leaving this filter in for backward compatibility this was moved in 4.6.x |
|
914 | - * from General_Settings_Admin_Page to here. |
|
915 | - */ |
|
916 | - EE_Registry::instance()->CFG->template_settings = apply_filters( |
|
917 | - 'FHEE__General_Settings_Admin_Page__update_template_settings__data', |
|
918 | - EE_Registry::instance()->CFG->template_settings, |
|
919 | - $this->_req_data |
|
920 | - ); |
|
921 | - // update custom post type slugs and detect if we need to flush rewrite rules |
|
922 | - $old_slug = EE_Registry::instance()->CFG->core->event_cpt_slug; |
|
923 | - EE_Registry::instance()->CFG->core->event_cpt_slug = empty($this->_req_data['event_cpt_slug']) |
|
924 | - ? EE_Registry::instance()->CFG->core->event_cpt_slug |
|
925 | - : EEH_URL::slugify($this->_req_data['event_cpt_slug'], 'events'); |
|
926 | - $what = 'Template Settings'; |
|
927 | - $success = $this->_update_espresso_configuration( |
|
928 | - $what, |
|
929 | - EE_Registry::instance()->CFG->template_settings, |
|
930 | - __FILE__, |
|
931 | - __FUNCTION__, |
|
932 | - __LINE__ |
|
933 | - ); |
|
934 | - if (EE_Registry::instance()->CFG->core->event_cpt_slug !== $old_slug) { |
|
935 | - /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */ |
|
936 | - $rewrite_rules = LoaderFactory::getLoader()->getShared( |
|
937 | - 'EventEspresso\core\domain\services\custom_post_types\RewriteRules' |
|
938 | - ); |
|
939 | - $rewrite_rules->flush(); |
|
940 | - } |
|
941 | - $this->_redirect_after_action($success, $what, 'updated', array('action' => 'template_settings')); |
|
942 | - } |
|
943 | - |
|
944 | - |
|
945 | - /** |
|
946 | - * _premium_event_editor_meta_boxes |
|
947 | - * add all metaboxes related to the event_editor |
|
948 | - * |
|
949 | - * @access protected |
|
950 | - * @return void |
|
951 | - * @throws EE_Error |
|
952 | - * @throws InvalidArgumentException |
|
953 | - * @throws InvalidDataTypeException |
|
954 | - * @throws InvalidInterfaceException |
|
955 | - * @throws ReflectionException |
|
956 | - */ |
|
957 | - protected function _premium_event_editor_meta_boxes() |
|
958 | - { |
|
959 | - $this->verify_cpt_object(); |
|
960 | - add_meta_box( |
|
961 | - 'espresso_event_editor_event_options', |
|
962 | - esc_html__('Event Registration Options', 'event_espresso'), |
|
963 | - array($this, 'registration_options_meta_box'), |
|
964 | - $this->page_slug, |
|
965 | - 'side', |
|
966 | - 'core' |
|
967 | - ); |
|
968 | - } |
|
969 | - |
|
970 | - |
|
971 | - /** |
|
972 | - * override caf metabox |
|
973 | - * |
|
974 | - * @return void |
|
975 | - * @throws DomainException |
|
976 | - * @throws EE_Error |
|
977 | - */ |
|
978 | - public function registration_options_meta_box() |
|
979 | - { |
|
980 | - $yes_no_values = array( |
|
981 | - array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')), |
|
982 | - array('id' => false, 'text' => esc_html__('No', 'event_espresso')), |
|
983 | - ); |
|
984 | - $default_reg_status_values = EEM_Registration::reg_status_array( |
|
985 | - array( |
|
986 | - EEM_Registration::status_id_cancelled, |
|
987 | - EEM_Registration::status_id_declined, |
|
988 | - EEM_Registration::status_id_incomplete, |
|
989 | - EEM_Registration::status_id_wait_list, |
|
990 | - ), |
|
991 | - true |
|
992 | - ); |
|
993 | - $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false); |
|
994 | - $template_args['_event'] = $this->_cpt_model_obj; |
|
995 | - $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit(); |
|
996 | - $template_args['default_registration_status'] = EEH_Form_Fields::select_input( |
|
997 | - 'default_reg_status', |
|
998 | - $default_reg_status_values, |
|
999 | - $this->_cpt_model_obj->default_registration_status() |
|
1000 | - ); |
|
1001 | - $template_args['display_description'] = EEH_Form_Fields::select_input( |
|
1002 | - 'display_desc', |
|
1003 | - $yes_no_values, |
|
1004 | - $this->_cpt_model_obj->display_description() |
|
1005 | - ); |
|
1006 | - $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input( |
|
1007 | - 'display_ticket_selector', |
|
1008 | - $yes_no_values, |
|
1009 | - $this->_cpt_model_obj->display_ticket_selector(), |
|
1010 | - '', |
|
1011 | - '', |
|
1012 | - false |
|
1013 | - ); |
|
1014 | - $template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input( |
|
1015 | - 'EVT_default_registration_status', |
|
1016 | - $default_reg_status_values, |
|
1017 | - $this->_cpt_model_obj->default_registration_status() |
|
1018 | - ); |
|
1019 | - $template_args['additional_registration_options'] = apply_filters( |
|
1020 | - 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', |
|
1021 | - '', |
|
1022 | - $template_args, |
|
1023 | - $yes_no_values, |
|
1024 | - $default_reg_status_values |
|
1025 | - ); |
|
1026 | - EEH_Template::display_template( |
|
1027 | - EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
1028 | - $template_args |
|
1029 | - ); |
|
1030 | - } |
|
1031 | - |
|
1032 | - |
|
1033 | - |
|
1034 | - /** |
|
1035 | - * wp_list_table_mods for caf |
|
1036 | - * ============================ |
|
1037 | - */ |
|
1038 | - /** |
|
1039 | - * hook into list table filters and provide filters for caffeinated list table |
|
1040 | - * |
|
1041 | - * @param array $old_filters any existing filters present |
|
1042 | - * @param array $list_table_obj the list table object |
|
1043 | - * @return array new filters |
|
1044 | - * @throws EE_Error |
|
1045 | - * @throws InvalidArgumentException |
|
1046 | - * @throws InvalidDataTypeException |
|
1047 | - * @throws InvalidInterfaceException |
|
1048 | - * @throws ReflectionException |
|
1049 | - */ |
|
1050 | - public function list_table_filters($old_filters, $list_table_obj) |
|
1051 | - { |
|
1052 | - $filters = array(); |
|
1053 | - // first month/year filters |
|
1054 | - $filters[] = $this->espresso_event_months_dropdown(); |
|
1055 | - $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null; |
|
1056 | - // active status dropdown |
|
1057 | - if ($status !== 'draft') { |
|
1058 | - $filters[] = $this->active_status_dropdown( |
|
1059 | - isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : '' |
|
1060 | - ); |
|
1061 | - $filters[] = $this->venuesDropdown( |
|
1062 | - isset($this->_req_data['venue']) ? $this->_req_data['venue'] : '' |
|
1063 | - ); |
|
1064 | - } |
|
1065 | - // category filter |
|
1066 | - $filters[] = $this->category_dropdown(); |
|
1067 | - return array_merge($old_filters, $filters); |
|
1068 | - } |
|
1069 | - |
|
1070 | - |
|
1071 | - /** |
|
1072 | - * espresso_event_months_dropdown |
|
1073 | - * |
|
1074 | - * @access public |
|
1075 | - * @return string dropdown listing month/year selections for events. |
|
1076 | - */ |
|
1077 | - public function espresso_event_months_dropdown() |
|
1078 | - { |
|
1079 | - // what we need to do is get all PRIMARY datetimes for all events to filter on. |
|
1080 | - // Note we need to include any other filters that are set! |
|
1081 | - $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null; |
|
1082 | - // categories? |
|
1083 | - $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 |
|
1084 | - ? $this->_req_data['EVT_CAT'] |
|
1085 | - : null; |
|
1086 | - // active status? |
|
1087 | - $active_status = isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : null; |
|
1088 | - $cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : ''; |
|
1089 | - return EEH_Form_Fields::generate_event_months_dropdown($cur_date, $status, $category, $active_status); |
|
1090 | - } |
|
1091 | - |
|
1092 | - |
|
1093 | - /** |
|
1094 | - * returns a list of "active" statuses on the event |
|
1095 | - * |
|
1096 | - * @param string $current_value whatever the current active status is |
|
1097 | - * @return string |
|
1098 | - */ |
|
1099 | - public function active_status_dropdown($current_value = '') |
|
1100 | - { |
|
1101 | - $select_name = 'active_status'; |
|
1102 | - $values = array( |
|
1103 | - 'none' => esc_html__('Show Active/Inactive', 'event_espresso'), |
|
1104 | - 'active' => esc_html__('Active', 'event_espresso'), |
|
1105 | - 'upcoming' => esc_html__('Upcoming', 'event_espresso'), |
|
1106 | - 'expired' => esc_html__('Expired', 'event_espresso'), |
|
1107 | - 'inactive' => esc_html__('Inactive', 'event_espresso'), |
|
1108 | - ); |
|
1109 | - |
|
1110 | - return EEH_Form_Fields::select_input($select_name, $values, $current_value, '', 'wide'); |
|
1111 | - } |
|
1112 | - |
|
1113 | - |
|
1114 | - /** |
|
1115 | - * returns a list of "venues" |
|
1116 | - * |
|
1117 | - * @param string $current_value whatever the current active status is |
|
1118 | - * @return string |
|
1119 | - * @throws EE_Error |
|
1120 | - * @throws InvalidArgumentException |
|
1121 | - * @throws InvalidDataTypeException |
|
1122 | - * @throws InvalidInterfaceException |
|
1123 | - * @throws ReflectionException |
|
1124 | - */ |
|
1125 | - protected function venuesDropdown($current_value = '') |
|
1126 | - { |
|
1127 | - $select_name = 'venue'; |
|
1128 | - $values = array( |
|
1129 | - '' => esc_html__('All Venues', 'event_espresso'), |
|
1130 | - ); |
|
1131 | - // populate the list of venues. |
|
1132 | - $venue_model = EE_Registry::instance()->load_model('Venue'); |
|
1133 | - $venues = $venue_model->get_all(array('order_by' => array('VNU_name' => 'ASC'))); |
|
1134 | - |
|
1135 | - foreach ($venues as $venue) { |
|
1136 | - $values[ $venue->ID() ] = $venue->name(); |
|
1137 | - } |
|
1138 | - |
|
1139 | - return EEH_Form_Fields::select_input($select_name, $values, $current_value, '', 'wide'); |
|
1140 | - } |
|
1141 | - |
|
1142 | - |
|
1143 | - /** |
|
1144 | - * output a dropdown of the categories for the category filter on the event admin list table |
|
1145 | - * |
|
1146 | - * @access public |
|
1147 | - * @return string html |
|
1148 | - */ |
|
1149 | - public function category_dropdown() |
|
1150 | - { |
|
1151 | - $cur_cat = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1; |
|
1152 | - return EEH_Form_Fields::generate_event_category_dropdown($cur_cat); |
|
1153 | - } |
|
1154 | - |
|
1155 | - |
|
1156 | - /** |
|
1157 | - * get total number of events today |
|
1158 | - * |
|
1159 | - * @access public |
|
1160 | - * @return int |
|
1161 | - * @throws EE_Error |
|
1162 | - * @throws InvalidArgumentException |
|
1163 | - * @throws InvalidDataTypeException |
|
1164 | - * @throws InvalidInterfaceException |
|
1165 | - */ |
|
1166 | - public function total_events_today() |
|
1167 | - { |
|
1168 | - $start = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1169 | - 'DTT_EVT_start', |
|
1170 | - date('Y-m-d') . ' 00:00:00', |
|
1171 | - 'Y-m-d H:i:s', |
|
1172 | - 'UTC' |
|
1173 | - ); |
|
1174 | - $end = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1175 | - 'DTT_EVT_start', |
|
1176 | - date('Y-m-d') . ' 23:59:59', |
|
1177 | - 'Y-m-d H:i:s', |
|
1178 | - 'UTC' |
|
1179 | - ); |
|
1180 | - $where = array( |
|
1181 | - 'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)), |
|
1182 | - ); |
|
1183 | - return EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
1184 | - } |
|
1185 | - |
|
1186 | - |
|
1187 | - /** |
|
1188 | - * get total number of events this month |
|
1189 | - * |
|
1190 | - * @access public |
|
1191 | - * @return int |
|
1192 | - * @throws EE_Error |
|
1193 | - * @throws InvalidArgumentException |
|
1194 | - * @throws InvalidDataTypeException |
|
1195 | - * @throws InvalidInterfaceException |
|
1196 | - */ |
|
1197 | - public function total_events_this_month() |
|
1198 | - { |
|
1199 | - // Dates |
|
1200 | - $this_year_r = date('Y'); |
|
1201 | - $this_month_r = date('m'); |
|
1202 | - $days_this_month = date('t'); |
|
1203 | - $start = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1204 | - 'DTT_EVT_start', |
|
1205 | - $this_year_r . '-' . $this_month_r . '-01 00:00:00', |
|
1206 | - 'Y-m-d H:i:s', |
|
1207 | - 'UTC' |
|
1208 | - ); |
|
1209 | - $end = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1210 | - 'DTT_EVT_start', |
|
1211 | - $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59', |
|
1212 | - 'Y-m-d H:i:s', |
|
1213 | - 'UTC' |
|
1214 | - ); |
|
1215 | - $where = array( |
|
1216 | - 'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)), |
|
1217 | - ); |
|
1218 | - return EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
1219 | - } |
|
1220 | - |
|
1221 | - |
|
1222 | - /** DEFAULT TICKETS STUFF **/ |
|
1223 | - |
|
1224 | - /** |
|
1225 | - * Output default tickets list table view. |
|
1226 | - * |
|
1227 | - * @throws DomainException |
|
1228 | - * @throws EE_Error |
|
1229 | - * @throws InvalidArgumentException |
|
1230 | - * @throws InvalidDataTypeException |
|
1231 | - * @throws InvalidInterfaceException |
|
1232 | - */ |
|
1233 | - public function _tickets_overview_list_table() |
|
1234 | - { |
|
1235 | - $this->_search_btn_label = esc_html__('Tickets', 'event_espresso'); |
|
1236 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
1237 | - } |
|
1238 | - |
|
1239 | - |
|
1240 | - /** |
|
1241 | - * @param int $per_page |
|
1242 | - * @param bool $count |
|
1243 | - * @param bool $trashed |
|
1244 | - * @return EE_Soft_Delete_Base_Class[]|int |
|
1245 | - * @throws EE_Error |
|
1246 | - * @throws InvalidArgumentException |
|
1247 | - * @throws InvalidDataTypeException |
|
1248 | - * @throws InvalidInterfaceException |
|
1249 | - */ |
|
1250 | - public function get_default_tickets($per_page = 10, $count = false, $trashed = false) |
|
1251 | - { |
|
1252 | - $orderby = empty($this->_req_data['orderby']) ? 'TKT_name' : $this->_req_data['orderby']; |
|
1253 | - $order = empty($this->_req_data['order']) ? 'ASC' : $this->_req_data['order']; |
|
1254 | - switch ($orderby) { |
|
1255 | - case 'TKT_name': |
|
1256 | - $orderby = array('TKT_name' => $order); |
|
1257 | - break; |
|
1258 | - case 'TKT_price': |
|
1259 | - $orderby = array('TKT_price' => $order); |
|
1260 | - break; |
|
1261 | - case 'TKT_uses': |
|
1262 | - $orderby = array('TKT_uses' => $order); |
|
1263 | - break; |
|
1264 | - case 'TKT_min': |
|
1265 | - $orderby = array('TKT_min' => $order); |
|
1266 | - break; |
|
1267 | - case 'TKT_max': |
|
1268 | - $orderby = array('TKT_max' => $order); |
|
1269 | - break; |
|
1270 | - case 'TKT_qty': |
|
1271 | - $orderby = array('TKT_qty' => $order); |
|
1272 | - break; |
|
1273 | - } |
|
1274 | - $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) |
|
1275 | - ? $this->_req_data['paged'] |
|
1276 | - : 1; |
|
1277 | - $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) |
|
1278 | - ? $this->_req_data['perpage'] |
|
1279 | - : $per_page; |
|
1280 | - $_where = array( |
|
1281 | - 'TKT_is_default' => 1, |
|
1282 | - 'TKT_deleted' => $trashed, |
|
1283 | - ); |
|
1284 | - $offset = ($current_page - 1) * $per_page; |
|
1285 | - $limit = array($offset, $per_page); |
|
1286 | - if (isset($this->_req_data['s'])) { |
|
1287 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
1288 | - $_where['OR'] = array( |
|
1289 | - 'TKT_name' => array('LIKE', $sstr), |
|
1290 | - 'TKT_description' => array('LIKE', $sstr), |
|
1291 | - ); |
|
1292 | - } |
|
1293 | - $query_params = array( |
|
1294 | - $_where, |
|
1295 | - 'order_by' => $orderby, |
|
1296 | - 'limit' => $limit, |
|
1297 | - 'group_by' => 'TKT_ID', |
|
1298 | - ); |
|
1299 | - if ($count) { |
|
1300 | - return EEM_Ticket::instance()->count_deleted_and_undeleted(array($_where)); |
|
1301 | - } |
|
1302 | - return EEM_Ticket::instance()->get_all_deleted_and_undeleted($query_params); |
|
1303 | - } |
|
1304 | - |
|
1305 | - |
|
1306 | - /** |
|
1307 | - * @param bool $trash |
|
1308 | - * @throws EE_Error |
|
1309 | - * @throws InvalidArgumentException |
|
1310 | - * @throws InvalidDataTypeException |
|
1311 | - * @throws InvalidInterfaceException |
|
1312 | - */ |
|
1313 | - protected function _trash_or_restore_ticket($trash = false) |
|
1314 | - { |
|
1315 | - $success = 1; |
|
1316 | - $TKT = EEM_Ticket::instance(); |
|
1317 | - // checkboxes? |
|
1318 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1319 | - // if array has more than one element then success message should be plural |
|
1320 | - $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
1321 | - // cycle thru the boxes |
|
1322 | - foreach ($this->_req_data['checkbox'] as $TKT_ID) { |
|
1323 | - if ($trash) { |
|
1324 | - if (! $TKT->delete_by_ID($TKT_ID)) { |
|
1325 | - $success = 0; |
|
1326 | - } |
|
1327 | - } elseif (! $TKT->restore_by_ID($TKT_ID)) { |
|
1328 | - $success = 0; |
|
1329 | - } |
|
1330 | - } |
|
1331 | - } else { |
|
1332 | - // grab single id and trash |
|
1333 | - $TKT_ID = absint($this->_req_data['TKT_ID']); |
|
1334 | - if ($trash) { |
|
1335 | - if (! $TKT->delete_by_ID($TKT_ID)) { |
|
1336 | - $success = 0; |
|
1337 | - } |
|
1338 | - } elseif (! $TKT->restore_by_ID($TKT_ID)) { |
|
1339 | - $success = 0; |
|
1340 | - } |
|
1341 | - } |
|
1342 | - $action_desc = $trash ? 'moved to the trash' : 'restored'; |
|
1343 | - $query_args = array( |
|
1344 | - 'action' => 'ticket_list_table', |
|
1345 | - 'status' => $trash ? '' : 'trashed', |
|
1346 | - ); |
|
1347 | - $this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args); |
|
1348 | - } |
|
1349 | - |
|
1350 | - |
|
1351 | - /** |
|
1352 | - * Handles trashing default ticket. |
|
1353 | - * |
|
1354 | - * @throws EE_Error |
|
1355 | - * @throws InvalidArgumentException |
|
1356 | - * @throws InvalidDataTypeException |
|
1357 | - * @throws InvalidInterfaceException |
|
1358 | - * @throws ReflectionException |
|
1359 | - */ |
|
1360 | - protected function _delete_ticket() |
|
1361 | - { |
|
1362 | - $success = 1; |
|
1363 | - // checkboxes? |
|
1364 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1365 | - // if array has more than one element then success message should be plural |
|
1366 | - $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
1367 | - // cycle thru the boxes |
|
1368 | - foreach ($this->_req_data['checkbox'] as $TKT_ID) { |
|
1369 | - // delete |
|
1370 | - if (! $this->_delete_the_ticket($TKT_ID)) { |
|
1371 | - $success = 0; |
|
1372 | - } |
|
1373 | - } |
|
1374 | - } else { |
|
1375 | - // grab single id and trash |
|
1376 | - $TKT_ID = absint($this->_req_data['TKT_ID']); |
|
1377 | - if (! $this->_delete_the_ticket($TKT_ID)) { |
|
1378 | - $success = 0; |
|
1379 | - } |
|
1380 | - } |
|
1381 | - $action_desc = 'deleted'; |
|
1382 | - // fail safe. If the default ticket count === 1 then we need to redirect to event overview. |
|
1383 | - $ticket_count = EEM_Ticket::instance()->count_deleted_and_undeleted( |
|
1384 | - [['TKT_is_default' => 1]], |
|
1385 | - 'TKT_ID', |
|
1386 | - true |
|
1387 | - ); |
|
1388 | - $query_args = $ticket_count |
|
1389 | - ? [] |
|
1390 | - : [ |
|
1391 | - 'action' => 'ticket_list_table', |
|
1392 | - 'status' => 'trashed' |
|
1393 | - ]; |
|
1394 | - $this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args); |
|
1395 | - } |
|
1396 | - |
|
1397 | - |
|
1398 | - /** |
|
1399 | - * @param int $TKT_ID |
|
1400 | - * @return bool|int |
|
1401 | - * @throws EE_Error |
|
1402 | - * @throws InvalidArgumentException |
|
1403 | - * @throws InvalidDataTypeException |
|
1404 | - * @throws InvalidInterfaceException |
|
1405 | - * @throws ReflectionException |
|
1406 | - */ |
|
1407 | - protected function _delete_the_ticket($TKT_ID) |
|
1408 | - { |
|
1409 | - $ticket = EEM_Ticket::instance()->get_one_by_ID($TKT_ID); |
|
1410 | - if (! $ticket instanceof EE_Ticket) { |
|
1411 | - return false; |
|
1412 | - } |
|
1413 | - $ticket->_remove_relations('Datetime'); |
|
1414 | - // delete all related prices first |
|
1415 | - $ticket->delete_related_permanently('Price'); |
|
1416 | - return $ticket->delete_permanently(); |
|
1417 | - } |
|
19 | + /** |
|
20 | + * @var EE_Admin_Config |
|
21 | + */ |
|
22 | + protected $admin_config; |
|
23 | + |
|
24 | + /** |
|
25 | + * @var AdvancedEditorAdminFormSection |
|
26 | + */ |
|
27 | + protected $advanced_editor_admin_form; |
|
28 | + |
|
29 | + |
|
30 | + /** |
|
31 | + * Extend_Events_Admin_Page constructor. |
|
32 | + * |
|
33 | + * @param bool $routing |
|
34 | + * @throws ReflectionException |
|
35 | + */ |
|
36 | + public function __construct($routing = true) |
|
37 | + { |
|
38 | + if (! defined('EVENTS_CAF_TEMPLATE_PATH')) { |
|
39 | + define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/'); |
|
40 | + define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/'); |
|
41 | + define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/'); |
|
42 | + } |
|
43 | + parent::__construct($routing); |
|
44 | + $this->admin_config = $this->loader->getShared('EE_Admin_Config'); |
|
45 | + } |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * Sets routes. |
|
50 | + * |
|
51 | + * @throws EE_Error |
|
52 | + * @throws InvalidArgumentException |
|
53 | + * @throws InvalidDataTypeException |
|
54 | + * @throws InvalidInterfaceException |
|
55 | + * @throws Exception |
|
56 | + */ |
|
57 | + protected function _extend_page_config() |
|
58 | + { |
|
59 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events'; |
|
60 | + // is there a evt_id in the request? |
|
61 | + $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) |
|
62 | + ? $this->_req_data['EVT_ID'] |
|
63 | + : 0; |
|
64 | + $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id; |
|
65 | + // tkt_id? |
|
66 | + $tkt_id = ! empty($this->_req_data['TKT_ID']) && ! is_array($this->_req_data['TKT_ID']) |
|
67 | + ? $this->_req_data['TKT_ID'] |
|
68 | + : 0; |
|
69 | + $new_page_routes = array( |
|
70 | + 'duplicate_event' => array( |
|
71 | + 'func' => '_duplicate_event', |
|
72 | + 'capability' => 'ee_edit_event', |
|
73 | + 'obj_id' => $evt_id, |
|
74 | + 'noheader' => true, |
|
75 | + ), |
|
76 | + 'ticket_list_table' => array( |
|
77 | + 'func' => '_tickets_overview_list_table', |
|
78 | + 'capability' => 'ee_read_default_tickets', |
|
79 | + ), |
|
80 | + 'trash_ticket' => array( |
|
81 | + 'func' => '_trash_or_restore_ticket', |
|
82 | + 'capability' => 'ee_delete_default_ticket', |
|
83 | + 'obj_id' => $tkt_id, |
|
84 | + 'noheader' => true, |
|
85 | + 'args' => array('trash' => true), |
|
86 | + ), |
|
87 | + 'trash_tickets' => array( |
|
88 | + 'func' => '_trash_or_restore_ticket', |
|
89 | + 'capability' => 'ee_delete_default_tickets', |
|
90 | + 'noheader' => true, |
|
91 | + 'args' => array('trash' => true), |
|
92 | + ), |
|
93 | + 'restore_ticket' => array( |
|
94 | + 'func' => '_trash_or_restore_ticket', |
|
95 | + 'capability' => 'ee_delete_default_ticket', |
|
96 | + 'obj_id' => $tkt_id, |
|
97 | + 'noheader' => true, |
|
98 | + ), |
|
99 | + 'restore_tickets' => array( |
|
100 | + 'func' => '_trash_or_restore_ticket', |
|
101 | + 'capability' => 'ee_delete_default_tickets', |
|
102 | + 'noheader' => true, |
|
103 | + ), |
|
104 | + 'delete_ticket' => array( |
|
105 | + 'func' => '_delete_ticket', |
|
106 | + 'capability' => 'ee_delete_default_ticket', |
|
107 | + 'obj_id' => $tkt_id, |
|
108 | + 'noheader' => true, |
|
109 | + ), |
|
110 | + 'delete_tickets' => array( |
|
111 | + 'func' => '_delete_ticket', |
|
112 | + 'capability' => 'ee_delete_default_tickets', |
|
113 | + 'noheader' => true, |
|
114 | + ), |
|
115 | + 'import_page' => array( |
|
116 | + 'func' => '_import_page', |
|
117 | + 'capability' => 'import', |
|
118 | + ), |
|
119 | + 'import' => array( |
|
120 | + 'func' => '_import_events', |
|
121 | + 'capability' => 'import', |
|
122 | + 'noheader' => true, |
|
123 | + ), |
|
124 | + 'import_events' => array( |
|
125 | + 'func' => '_import_events', |
|
126 | + 'capability' => 'import', |
|
127 | + 'noheader' => true, |
|
128 | + ), |
|
129 | + 'export_events' => array( |
|
130 | + 'func' => '_events_export', |
|
131 | + 'capability' => 'export', |
|
132 | + 'noheader' => true, |
|
133 | + ), |
|
134 | + 'export_categories' => array( |
|
135 | + 'func' => '_categories_export', |
|
136 | + 'capability' => 'export', |
|
137 | + 'noheader' => true, |
|
138 | + ), |
|
139 | + 'sample_export_file' => array( |
|
140 | + 'func' => '_sample_export_file', |
|
141 | + 'capability' => 'export', |
|
142 | + 'noheader' => true, |
|
143 | + ), |
|
144 | + 'update_template_settings' => array( |
|
145 | + 'func' => '_update_template_settings', |
|
146 | + 'capability' => 'manage_options', |
|
147 | + 'noheader' => true, |
|
148 | + ), |
|
149 | + ); |
|
150 | + $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
151 | + // partial route/config override |
|
152 | + $this->_page_config['import_events']['metaboxes'] = $this->_default_espresso_metaboxes; |
|
153 | + $this->_page_config['create_new']['metaboxes'][] = '_premium_event_editor_meta_boxes'; |
|
154 | + // don't load qTips if using the advanced editor |
|
155 | + if (! $this->admin_config->useAdvancedEditor()) { |
|
156 | + $this->_page_config['create_new']['qtips'][] = 'EE_Event_Editor_Tips'; |
|
157 | + $this->_page_config['edit']['qtips'][] = 'EE_Event_Editor_Tips'; |
|
158 | + } |
|
159 | + $this->_page_config['edit']['metaboxes'][] = '_premium_event_editor_meta_boxes'; |
|
160 | + $this->_page_config['default']['list_table'] = 'Extend_Events_Admin_List_Table'; |
|
161 | + // add tickets tab but only if there are more than one default ticket! |
|
162 | + $tkt_count = EEM_Ticket::instance()->count_deleted_and_undeleted( |
|
163 | + array(array('TKT_is_default' => 1)), |
|
164 | + 'TKT_ID', |
|
165 | + true |
|
166 | + ); |
|
167 | + if ($tkt_count > 1) { |
|
168 | + $new_page_config = array( |
|
169 | + 'ticket_list_table' => array( |
|
170 | + 'nav' => array( |
|
171 | + 'label' => esc_html__('Default Tickets', 'event_espresso'), |
|
172 | + 'order' => 60, |
|
173 | + ), |
|
174 | + 'list_table' => 'Tickets_List_Table', |
|
175 | + 'require_nonce' => false, |
|
176 | + ), |
|
177 | + ); |
|
178 | + } |
|
179 | + // template settings |
|
180 | + $new_page_config['template_settings'] = array( |
|
181 | + 'nav' => array( |
|
182 | + 'label' => esc_html__('Templates', 'event_espresso'), |
|
183 | + 'order' => 30, |
|
184 | + ), |
|
185 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
186 | + 'help_tabs' => array( |
|
187 | + 'general_settings_templates_help_tab' => array( |
|
188 | + 'title' => esc_html__('Templates', 'event_espresso'), |
|
189 | + 'filename' => 'general_settings_templates', |
|
190 | + ), |
|
191 | + ), |
|
192 | + 'help_tour' => array('Templates_Help_Tour'), |
|
193 | + 'require_nonce' => false, |
|
194 | + ); |
|
195 | + $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
196 | + // add filters and actions |
|
197 | + // modifying _views |
|
198 | + add_filter( |
|
199 | + 'FHEE_event_datetime_metabox_add_additional_date_time_template', |
|
200 | + array($this, 'add_additional_datetime_button'), |
|
201 | + 10, |
|
202 | + 2 |
|
203 | + ); |
|
204 | + add_filter( |
|
205 | + 'FHEE_event_datetime_metabox_clone_button_template', |
|
206 | + array($this, 'add_datetime_clone_button'), |
|
207 | + 10, |
|
208 | + 2 |
|
209 | + ); |
|
210 | + add_filter( |
|
211 | + 'FHEE_event_datetime_metabox_timezones_template', |
|
212 | + array($this, 'datetime_timezones_template'), |
|
213 | + 10, |
|
214 | + 2 |
|
215 | + ); |
|
216 | + // filters for event list table |
|
217 | + add_filter('FHEE__Extend_Events_Admin_List_Table__filters', array($this, 'list_table_filters'), 10, 2); |
|
218 | + add_filter( |
|
219 | + 'FHEE__Events_Admin_List_Table__column_actions__action_links', |
|
220 | + array($this, 'extra_list_table_actions'), |
|
221 | + 10, |
|
222 | + 2 |
|
223 | + ); |
|
224 | + // legend item |
|
225 | + add_filter('FHEE__Events_Admin_Page___event_legend_items__items', array($this, 'additional_legend_items')); |
|
226 | + add_action('admin_init', array($this, 'admin_init')); |
|
227 | + // load additional handlers |
|
228 | + $this->handleActionRequest(); |
|
229 | + } |
|
230 | + |
|
231 | + |
|
232 | + private function getRequestAction() |
|
233 | + { |
|
234 | + return isset($this->_req_data['action']) ? sanitize_key($this->_req_data['action']) : null; |
|
235 | + } |
|
236 | + |
|
237 | + |
|
238 | + /** |
|
239 | + * @throws Exception |
|
240 | + */ |
|
241 | + private function handleActionRequest() |
|
242 | + { |
|
243 | + $action = $this->getRequestAction(); |
|
244 | + if ($action) { |
|
245 | + // setup Advanced Editor ??? |
|
246 | + if ($action === 'default_event_settings' || $action === 'update_default_event_settings') { |
|
247 | + $this->advanced_editor_admin_form = $this->loader->getShared( |
|
248 | + 'EventEspresso\core\domain\services\admin\events\default_settings\AdvancedEditorAdminFormSection' |
|
249 | + ); |
|
250 | + } |
|
251 | + } |
|
252 | + } |
|
253 | + |
|
254 | + |
|
255 | + /** |
|
256 | + * admin_init |
|
257 | + */ |
|
258 | + public function admin_init() |
|
259 | + { |
|
260 | + EE_Registry::$i18n_js_strings = array_merge( |
|
261 | + EE_Registry::$i18n_js_strings, |
|
262 | + array( |
|
263 | + 'image_confirm' => esc_html__( |
|
264 | + 'Do you really want to delete this image? Please remember to update your event to complete the removal.', |
|
265 | + 'event_espresso' |
|
266 | + ), |
|
267 | + 'event_starts_on' => esc_html__('Event Starts on', 'event_espresso'), |
|
268 | + 'event_ends_on' => esc_html__('Event Ends on', 'event_espresso'), |
|
269 | + 'event_datetime_actions' => esc_html__('Actions', 'event_espresso'), |
|
270 | + 'event_clone_dt_msg' => esc_html__('Clone this Event Date and Time', 'event_espresso'), |
|
271 | + 'remove_event_dt_msg' => esc_html__('Remove this Event Time', 'event_espresso'), |
|
272 | + ) |
|
273 | + ); |
|
274 | + } |
|
275 | + |
|
276 | + |
|
277 | + /** |
|
278 | + * Add per page screen options to the default ticket list table view. |
|
279 | + * |
|
280 | + * @throws InvalidArgumentException |
|
281 | + * @throws InvalidDataTypeException |
|
282 | + * @throws InvalidInterfaceException |
|
283 | + */ |
|
284 | + protected function _add_screen_options_ticket_list_table() |
|
285 | + { |
|
286 | + $this->_per_page_screen_option(); |
|
287 | + } |
|
288 | + |
|
289 | + |
|
290 | + /** |
|
291 | + * @param string $return |
|
292 | + * @param int $id |
|
293 | + * @param string $new_title |
|
294 | + * @param string $new_slug |
|
295 | + * @return string |
|
296 | + */ |
|
297 | + public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) |
|
298 | + { |
|
299 | + $return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug); |
|
300 | + // make sure this is only when editing |
|
301 | + if (! empty($id)) { |
|
302 | + $href = EE_Admin_Page::add_query_args_and_nonce( |
|
303 | + array('action' => 'duplicate_event', 'EVT_ID' => $id), |
|
304 | + $this->_admin_base_url |
|
305 | + ); |
|
306 | + $title = esc_attr__('Duplicate Event', 'event_espresso'); |
|
307 | + $return .= '<a href="' |
|
308 | + . $href |
|
309 | + . '" title="' |
|
310 | + . $title |
|
311 | + . '" id="ee-duplicate-event-button" class="button button-small" value="duplicate_event">' |
|
312 | + . $title |
|
313 | + . '</a>'; |
|
314 | + } |
|
315 | + return $return; |
|
316 | + } |
|
317 | + |
|
318 | + |
|
319 | + /** |
|
320 | + * Set the list table views for the default ticket list table view. |
|
321 | + */ |
|
322 | + public function _set_list_table_views_ticket_list_table() |
|
323 | + { |
|
324 | + $this->_views = array( |
|
325 | + 'all' => array( |
|
326 | + 'slug' => 'all', |
|
327 | + 'label' => esc_html__('All', 'event_espresso'), |
|
328 | + 'count' => 0, |
|
329 | + 'bulk_action' => array( |
|
330 | + 'trash_tickets' => esc_html__('Move to Trash', 'event_espresso'), |
|
331 | + ), |
|
332 | + ), |
|
333 | + 'trashed' => array( |
|
334 | + 'slug' => 'trashed', |
|
335 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
336 | + 'count' => 0, |
|
337 | + 'bulk_action' => array( |
|
338 | + 'restore_tickets' => esc_html__('Restore from Trash', 'event_espresso'), |
|
339 | + 'delete_tickets' => esc_html__('Delete Permanently', 'event_espresso'), |
|
340 | + ), |
|
341 | + ), |
|
342 | + ); |
|
343 | + } |
|
344 | + |
|
345 | + |
|
346 | + /** |
|
347 | + * Enqueue scripts and styles for the event editor. |
|
348 | + */ |
|
349 | + public function load_scripts_styles_edit() |
|
350 | + { |
|
351 | + wp_register_script( |
|
352 | + 'ee-event-editor-heartbeat', |
|
353 | + EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js', |
|
354 | + array('ee_admin_js', 'heartbeat'), |
|
355 | + EVENT_ESPRESSO_VERSION, |
|
356 | + true |
|
357 | + ); |
|
358 | + wp_enqueue_script('ee-accounting'); |
|
359 | + // styles |
|
360 | + wp_enqueue_style('espresso-ui-theme'); |
|
361 | + wp_enqueue_script('event_editor_js'); |
|
362 | + wp_enqueue_script('ee-event-editor-heartbeat'); |
|
363 | + } |
|
364 | + |
|
365 | + |
|
366 | + /** |
|
367 | + * Returns template for the additional datetime. |
|
368 | + * |
|
369 | + * @param $template |
|
370 | + * @param $template_args |
|
371 | + * @return mixed |
|
372 | + * @throws DomainException |
|
373 | + */ |
|
374 | + public function add_additional_datetime_button($template, $template_args) |
|
375 | + { |
|
376 | + return EEH_Template::display_template( |
|
377 | + EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php', |
|
378 | + $template_args, |
|
379 | + true |
|
380 | + ); |
|
381 | + } |
|
382 | + |
|
383 | + |
|
384 | + /** |
|
385 | + * Returns the template for cloning a datetime. |
|
386 | + * |
|
387 | + * @param $template |
|
388 | + * @param $template_args |
|
389 | + * @return mixed |
|
390 | + * @throws DomainException |
|
391 | + */ |
|
392 | + public function add_datetime_clone_button($template, $template_args) |
|
393 | + { |
|
394 | + return EEH_Template::display_template( |
|
395 | + EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php', |
|
396 | + $template_args, |
|
397 | + true |
|
398 | + ); |
|
399 | + } |
|
400 | + |
|
401 | + |
|
402 | + /** |
|
403 | + * Returns the template for datetime timezones. |
|
404 | + * |
|
405 | + * @param $template |
|
406 | + * @param $template_args |
|
407 | + * @return mixed |
|
408 | + * @throws DomainException |
|
409 | + */ |
|
410 | + public function datetime_timezones_template($template, $template_args) |
|
411 | + { |
|
412 | + return EEH_Template::display_template( |
|
413 | + EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php', |
|
414 | + $template_args, |
|
415 | + true |
|
416 | + ); |
|
417 | + } |
|
418 | + |
|
419 | + |
|
420 | + /** |
|
421 | + * Sets the views for the default list table view. |
|
422 | + * |
|
423 | + * @throws EE_Error |
|
424 | + */ |
|
425 | + protected function _set_list_table_views_default() |
|
426 | + { |
|
427 | + parent::_set_list_table_views_default(); |
|
428 | + $new_views = array( |
|
429 | + 'today' => array( |
|
430 | + 'slug' => 'today', |
|
431 | + 'label' => esc_html__('Today', 'event_espresso'), |
|
432 | + 'count' => $this->total_events_today(), |
|
433 | + 'bulk_action' => array( |
|
434 | + 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
435 | + ), |
|
436 | + ), |
|
437 | + 'month' => array( |
|
438 | + 'slug' => 'month', |
|
439 | + 'label' => esc_html__('This Month', 'event_espresso'), |
|
440 | + 'count' => $this->total_events_this_month(), |
|
441 | + 'bulk_action' => array( |
|
442 | + 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
443 | + ), |
|
444 | + ), |
|
445 | + ); |
|
446 | + $this->_views = array_merge($this->_views, $new_views); |
|
447 | + } |
|
448 | + |
|
449 | + |
|
450 | + /** |
|
451 | + * Returns the extra action links for the default list table view. |
|
452 | + * |
|
453 | + * @param array $action_links |
|
454 | + * @param EE_Event $event |
|
455 | + * @return array |
|
456 | + * @throws EE_Error |
|
457 | + * @throws InvalidArgumentException |
|
458 | + * @throws InvalidDataTypeException |
|
459 | + * @throws InvalidInterfaceException |
|
460 | + * @throws ReflectionException |
|
461 | + */ |
|
462 | + public function extra_list_table_actions(array $action_links, EE_Event $event) |
|
463 | + { |
|
464 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
465 | + 'ee_read_registrations', |
|
466 | + 'espresso_registrations_reports', |
|
467 | + $event->ID() |
|
468 | + ) |
|
469 | + ) { |
|
470 | + $reports_query_args = array( |
|
471 | + 'action' => 'reports', |
|
472 | + 'EVT_ID' => $event->ID(), |
|
473 | + ); |
|
474 | + $reports_link = EE_Admin_Page::add_query_args_and_nonce($reports_query_args, REG_ADMIN_URL); |
|
475 | + $action_links[] = '<a href="' |
|
476 | + . $reports_link |
|
477 | + . '" title="' |
|
478 | + . esc_attr__('View Report', 'event_espresso') |
|
479 | + . '"><div class="dashicons dashicons-chart-bar"></div></a>' |
|
480 | + . "\n\t"; |
|
481 | + } |
|
482 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
483 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
484 | + $action_links[] = EEH_MSG_Template::get_message_action_link( |
|
485 | + 'see_notifications_for', |
|
486 | + null, |
|
487 | + array('EVT_ID' => $event->ID()) |
|
488 | + ); |
|
489 | + } |
|
490 | + return $action_links; |
|
491 | + } |
|
492 | + |
|
493 | + |
|
494 | + /** |
|
495 | + * @param $items |
|
496 | + * @return mixed |
|
497 | + */ |
|
498 | + public function additional_legend_items($items) |
|
499 | + { |
|
500 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
501 | + 'ee_read_registrations', |
|
502 | + 'espresso_registrations_reports' |
|
503 | + ) |
|
504 | + ) { |
|
505 | + $items['reports'] = array( |
|
506 | + 'class' => 'dashicons dashicons-chart-bar', |
|
507 | + 'desc' => esc_html__('Event Reports', 'event_espresso'), |
|
508 | + ); |
|
509 | + } |
|
510 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
511 | + $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for'); |
|
512 | + // $related_for_icon can sometimes be a string so 'css_class' would be an illegal offset |
|
513 | + // (can only use numeric offsets when treating strings as arrays) |
|
514 | + if (is_array($related_for_icon) && isset($related_for_icon['css_class'], $related_for_icon['label'])) { |
|
515 | + $items['view_related_messages'] = array( |
|
516 | + 'class' => $related_for_icon['css_class'], |
|
517 | + 'desc' => $related_for_icon['label'], |
|
518 | + ); |
|
519 | + } |
|
520 | + } |
|
521 | + return $items; |
|
522 | + } |
|
523 | + |
|
524 | + |
|
525 | + /** |
|
526 | + * This is the callback method for the duplicate event route |
|
527 | + * Method looks for 'EVT_ID' in the request and retrieves that event and its details and duplicates them |
|
528 | + * into a new event. We add a hook so that any plugins that add extra event details can hook into this |
|
529 | + * action. Note that the dupe will have **DUPLICATE** as its title and slug. |
|
530 | + * After duplication the redirect is to the new event edit page. |
|
531 | + * |
|
532 | + * @return void |
|
533 | + * @throws EE_Error If EE_Event is not available with given ID |
|
534 | + * @throws InvalidArgumentException |
|
535 | + * @throws InvalidDataTypeException |
|
536 | + * @throws InvalidInterfaceException |
|
537 | + * @throws ReflectionException |
|
538 | + * @access protected |
|
539 | + */ |
|
540 | + protected function _duplicate_event() |
|
541 | + { |
|
542 | + // first make sure the ID for the event is in the request. |
|
543 | + // If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?) |
|
544 | + if (! isset($this->_req_data['EVT_ID'])) { |
|
545 | + EE_Error::add_error( |
|
546 | + esc_html__( |
|
547 | + 'In order to duplicate an event an Event ID is required. None was given.', |
|
548 | + 'event_espresso' |
|
549 | + ), |
|
550 | + __FILE__, |
|
551 | + __FUNCTION__, |
|
552 | + __LINE__ |
|
553 | + ); |
|
554 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
555 | + return; |
|
556 | + } |
|
557 | + // k we've got EVT_ID so let's use that to get the event we'll duplicate |
|
558 | + $orig_event = EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']); |
|
559 | + if (! $orig_event instanceof EE_Event) { |
|
560 | + throw new EE_Error( |
|
561 | + sprintf( |
|
562 | + esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'), |
|
563 | + $this->_req_data['EVT_ID'] |
|
564 | + ) |
|
565 | + ); |
|
566 | + } |
|
567 | + // k now let's clone the $orig_event before getting relations |
|
568 | + $new_event = clone $orig_event; |
|
569 | + // original datetimes |
|
570 | + $orig_datetimes = $orig_event->get_many_related('Datetime'); |
|
571 | + // other original relations |
|
572 | + $orig_ven = $orig_event->get_many_related('Venue'); |
|
573 | + // reset the ID and modify other details to make it clear this is a dupe |
|
574 | + $new_event->set('EVT_ID', 0); |
|
575 | + $new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso'); |
|
576 | + $new_event->set('EVT_name', $new_name); |
|
577 | + $new_event->set( |
|
578 | + 'EVT_slug', |
|
579 | + wp_unique_post_slug( |
|
580 | + sanitize_title($orig_event->name()), |
|
581 | + 0, |
|
582 | + 'publish', |
|
583 | + 'espresso_events', |
|
584 | + 0 |
|
585 | + ) |
|
586 | + ); |
|
587 | + $new_event->set('status', 'draft'); |
|
588 | + // duplicate discussion settings |
|
589 | + $new_event->set('comment_status', $orig_event->get('comment_status')); |
|
590 | + $new_event->set('ping_status', $orig_event->get('ping_status')); |
|
591 | + // save the new event |
|
592 | + $new_event->save(); |
|
593 | + // venues |
|
594 | + foreach ($orig_ven as $ven) { |
|
595 | + $new_event->_add_relation_to($ven, 'Venue'); |
|
596 | + } |
|
597 | + $new_event->save(); |
|
598 | + // now we need to get the question group relations and handle that |
|
599 | + // first primary question groups |
|
600 | + $orig_primary_qgs = $orig_event->get_many_related( |
|
601 | + 'Question_Group', |
|
602 | + [['Event_Question_Group.EQG_primary' => true]] |
|
603 | + ); |
|
604 | + if (! empty($orig_primary_qgs)) { |
|
605 | + foreach ($orig_primary_qgs as $id => $obj) { |
|
606 | + if ($obj instanceof EE_Question_Group) { |
|
607 | + $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_primary' => true]); |
|
608 | + } |
|
609 | + } |
|
610 | + } |
|
611 | + // next additional attendee question groups |
|
612 | + $orig_additional_qgs = $orig_event->get_many_related( |
|
613 | + 'Question_Group', |
|
614 | + [['Event_Question_Group.EQG_additional' => true]] |
|
615 | + ); |
|
616 | + if (! empty($orig_additional_qgs)) { |
|
617 | + foreach ($orig_additional_qgs as $id => $obj) { |
|
618 | + if ($obj instanceof EE_Question_Group) { |
|
619 | + $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_additional' => true]); |
|
620 | + } |
|
621 | + } |
|
622 | + } |
|
623 | + |
|
624 | + $new_event->save(); |
|
625 | + |
|
626 | + // k now that we have the new event saved we can loop through the datetimes and start adding relations. |
|
627 | + $cloned_tickets = array(); |
|
628 | + foreach ($orig_datetimes as $orig_dtt) { |
|
629 | + if (! $orig_dtt instanceof EE_Datetime) { |
|
630 | + continue; |
|
631 | + } |
|
632 | + $new_dtt = clone $orig_dtt; |
|
633 | + $orig_tkts = $orig_dtt->tickets(); |
|
634 | + // save new dtt then add to event |
|
635 | + $new_dtt->set('DTT_ID', 0); |
|
636 | + $new_dtt->set('DTT_sold', 0); |
|
637 | + $new_dtt->set_reserved(0); |
|
638 | + $new_dtt->save(); |
|
639 | + $new_event->_add_relation_to($new_dtt, 'Datetime'); |
|
640 | + $new_event->save(); |
|
641 | + // now let's get the ticket relations setup. |
|
642 | + foreach ((array) $orig_tkts as $orig_tkt) { |
|
643 | + // it's possible a datetime will have no tickets so let's verify we HAVE a ticket first. |
|
644 | + if (! $orig_tkt instanceof EE_Ticket) { |
|
645 | + continue; |
|
646 | + } |
|
647 | + // is this ticket archived? If it is then let's skip |
|
648 | + if ($orig_tkt->get('TKT_deleted')) { |
|
649 | + continue; |
|
650 | + } |
|
651 | + // does this original ticket already exist in the clone_tickets cache? |
|
652 | + // If so we'll just use the new ticket from it. |
|
653 | + if (isset($cloned_tickets[ $orig_tkt->ID() ])) { |
|
654 | + $new_tkt = $cloned_tickets[ $orig_tkt->ID() ]; |
|
655 | + } else { |
|
656 | + $new_tkt = clone $orig_tkt; |
|
657 | + // get relations on the $orig_tkt that we need to setup. |
|
658 | + $orig_prices = $orig_tkt->prices(); |
|
659 | + $new_tkt->set('TKT_ID', 0); |
|
660 | + $new_tkt->set('TKT_sold', 0); |
|
661 | + $new_tkt->set('TKT_reserved', 0); |
|
662 | + $new_tkt->save(); // make sure new ticket has ID. |
|
663 | + // price relations on new ticket need to be setup. |
|
664 | + foreach ($orig_prices as $orig_price) { |
|
665 | + $new_price = clone $orig_price; |
|
666 | + $new_price->set('PRC_ID', 0); |
|
667 | + $new_price->save(); |
|
668 | + $new_tkt->_add_relation_to($new_price, 'Price'); |
|
669 | + $new_tkt->save(); |
|
670 | + } |
|
671 | + |
|
672 | + do_action( |
|
673 | + 'AHEE__Extend_Events_Admin_Page___duplicate_event__duplicate_ticket__after', |
|
674 | + $orig_tkt, |
|
675 | + $new_tkt, |
|
676 | + $orig_prices, |
|
677 | + $orig_event, |
|
678 | + $orig_dtt, |
|
679 | + $new_dtt |
|
680 | + ); |
|
681 | + } |
|
682 | + // k now we can add the new ticket as a relation to the new datetime |
|
683 | + // and make sure its added to our cached $cloned_tickets array |
|
684 | + // for use with later datetimes that have the same ticket. |
|
685 | + $new_dtt->_add_relation_to($new_tkt, 'Ticket'); |
|
686 | + $new_dtt->save(); |
|
687 | + $cloned_tickets[ $orig_tkt->ID() ] = $new_tkt; |
|
688 | + } |
|
689 | + } |
|
690 | + // clone taxonomy information |
|
691 | + $taxonomies_to_clone_with = apply_filters( |
|
692 | + 'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone', |
|
693 | + array('espresso_event_categories', 'espresso_event_type', 'post_tag') |
|
694 | + ); |
|
695 | + // get terms for original event (notice) |
|
696 | + $orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with); |
|
697 | + // loop through terms and add them to new event. |
|
698 | + foreach ($orig_terms as $term) { |
|
699 | + wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true); |
|
700 | + } |
|
701 | + |
|
702 | + // duplicate other core WP_Post items for this event. |
|
703 | + // post thumbnail (feature image). |
|
704 | + $feature_image_id = get_post_thumbnail_id($orig_event->ID()); |
|
705 | + if ($feature_image_id) { |
|
706 | + update_post_meta($new_event->ID(), '_thumbnail_id', $feature_image_id); |
|
707 | + } |
|
708 | + |
|
709 | + // duplicate page_template setting |
|
710 | + $page_template = get_post_meta($orig_event->ID(), '_wp_page_template', true); |
|
711 | + if ($page_template) { |
|
712 | + update_post_meta($new_event->ID(), '_wp_page_template', $page_template); |
|
713 | + } |
|
714 | + |
|
715 | + do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event); |
|
716 | + // now let's redirect to the edit page for this duplicated event if we have a new event id. |
|
717 | + if ($new_event->ID()) { |
|
718 | + $redirect_args = array( |
|
719 | + 'post' => $new_event->ID(), |
|
720 | + 'action' => 'edit', |
|
721 | + ); |
|
722 | + EE_Error::add_success( |
|
723 | + esc_html__( |
|
724 | + 'Event successfully duplicated. Please review the details below and make any necessary edits', |
|
725 | + 'event_espresso' |
|
726 | + ) |
|
727 | + ); |
|
728 | + } else { |
|
729 | + $redirect_args = array( |
|
730 | + 'action' => 'default', |
|
731 | + ); |
|
732 | + EE_Error::add_error( |
|
733 | + esc_html__('Not able to duplicate event. Something went wrong.', 'event_espresso'), |
|
734 | + __FILE__, |
|
735 | + __FUNCTION__, |
|
736 | + __LINE__ |
|
737 | + ); |
|
738 | + } |
|
739 | + $this->_redirect_after_action(false, '', '', $redirect_args, true); |
|
740 | + } |
|
741 | + |
|
742 | + |
|
743 | + /** |
|
744 | + * Generates output for the import page. |
|
745 | + * |
|
746 | + * @throws DomainException |
|
747 | + * @throws EE_Error |
|
748 | + * @throws InvalidArgumentException |
|
749 | + * @throws InvalidDataTypeException |
|
750 | + * @throws InvalidInterfaceException |
|
751 | + */ |
|
752 | + protected function _import_page() |
|
753 | + { |
|
754 | + $title = esc_html__('Import', 'event_espresso'); |
|
755 | + $intro = esc_html__( |
|
756 | + 'If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ', |
|
757 | + 'event_espresso' |
|
758 | + ); |
|
759 | + $form_url = EVENTS_ADMIN_URL; |
|
760 | + $action = 'import_events'; |
|
761 | + $type = 'csv'; |
|
762 | + $this->_template_args['form'] = EE_Import::instance()->upload_form( |
|
763 | + $title, |
|
764 | + $intro, |
|
765 | + $form_url, |
|
766 | + $action, |
|
767 | + $type |
|
768 | + ); |
|
769 | + $this->_template_args['sample_file_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
770 | + array('action' => 'sample_export_file'), |
|
771 | + $this->_admin_base_url |
|
772 | + ); |
|
773 | + $content = EEH_Template::display_template( |
|
774 | + EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php', |
|
775 | + $this->_template_args, |
|
776 | + true |
|
777 | + ); |
|
778 | + $this->_template_args['admin_page_content'] = $content; |
|
779 | + $this->display_admin_page_with_sidebar(); |
|
780 | + } |
|
781 | + |
|
782 | + |
|
783 | + /** |
|
784 | + * _import_events |
|
785 | + * This handles displaying the screen and running imports for importing events. |
|
786 | + * |
|
787 | + * @return void |
|
788 | + * @throws EE_Error |
|
789 | + * @throws InvalidArgumentException |
|
790 | + * @throws InvalidDataTypeException |
|
791 | + * @throws InvalidInterfaceException |
|
792 | + */ |
|
793 | + protected function _import_events() |
|
794 | + { |
|
795 | + require_once(EE_CLASSES . 'EE_Import.class.php'); |
|
796 | + $success = EE_Import::instance()->import(); |
|
797 | + $this->_redirect_after_action($success, 'Import File', 'ran', array('action' => 'import_page'), true); |
|
798 | + } |
|
799 | + |
|
800 | + |
|
801 | + /** |
|
802 | + * _events_export |
|
803 | + * Will export all (or just the given event) to a Excel compatible file. |
|
804 | + * |
|
805 | + * @access protected |
|
806 | + * @return void |
|
807 | + */ |
|
808 | + protected function _events_export() |
|
809 | + { |
|
810 | + if (isset($this->_req_data['EVT_ID'])) { |
|
811 | + $event_ids = $this->_req_data['EVT_ID']; |
|
812 | + } elseif (isset($this->_req_data['EVT_IDs'])) { |
|
813 | + $event_ids = $this->_req_data['EVT_IDs']; |
|
814 | + } else { |
|
815 | + $event_ids = null; |
|
816 | + } |
|
817 | + // todo: I don't like doing this but it'll do until we modify EE_Export Class. |
|
818 | + $new_request_args = array( |
|
819 | + 'export' => 'report', |
|
820 | + 'action' => 'all_event_data', |
|
821 | + 'EVT_ID' => $event_ids, |
|
822 | + ); |
|
823 | + $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
824 | + if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
825 | + require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
826 | + $EE_Export = EE_Export::instance($this->_req_data); |
|
827 | + if ($EE_Export instanceof EE_Export) { |
|
828 | + $EE_Export->export(); |
|
829 | + } |
|
830 | + } |
|
831 | + } |
|
832 | + |
|
833 | + |
|
834 | + /** |
|
835 | + * handle category exports() |
|
836 | + * |
|
837 | + * @return void |
|
838 | + */ |
|
839 | + protected function _categories_export() |
|
840 | + { |
|
841 | + // todo: I don't like doing this but it'll do until we modify EE_Export Class. |
|
842 | + $new_request_args = array( |
|
843 | + 'export' => 'report', |
|
844 | + 'action' => 'categories', |
|
845 | + 'category_ids' => $this->_req_data['EVT_CAT_ID'], |
|
846 | + ); |
|
847 | + $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
848 | + if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
849 | + require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
850 | + $EE_Export = EE_Export::instance($this->_req_data); |
|
851 | + if ($EE_Export instanceof EE_Export) { |
|
852 | + $EE_Export->export(); |
|
853 | + } |
|
854 | + } |
|
855 | + } |
|
856 | + |
|
857 | + |
|
858 | + /** |
|
859 | + * Creates a sample CSV file for importing |
|
860 | + */ |
|
861 | + protected function _sample_export_file() |
|
862 | + { |
|
863 | + $EE_Export = EE_Export::instance(); |
|
864 | + if ($EE_Export instanceof EE_Export) { |
|
865 | + $EE_Export->export(); |
|
866 | + } |
|
867 | + } |
|
868 | + |
|
869 | + |
|
870 | + /************* Template Settings *************/ |
|
871 | + /** |
|
872 | + * Generates template settings page output |
|
873 | + * |
|
874 | + * @throws DomainException |
|
875 | + * @throws EE_Error |
|
876 | + * @throws InvalidArgumentException |
|
877 | + * @throws InvalidDataTypeException |
|
878 | + * @throws InvalidInterfaceException |
|
879 | + */ |
|
880 | + protected function _template_settings() |
|
881 | + { |
|
882 | + $this->_template_args['values'] = $this->_yes_no_values; |
|
883 | + /** |
|
884 | + * Note leaving this filter in for backward compatibility this was moved in 4.6.x |
|
885 | + * from General_Settings_Admin_Page to here. |
|
886 | + */ |
|
887 | + $this->_template_args = apply_filters( |
|
888 | + 'FHEE__General_Settings_Admin_Page__template_settings__template_args', |
|
889 | + $this->_template_args |
|
890 | + ); |
|
891 | + $this->_set_add_edit_form_tags('update_template_settings'); |
|
892 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
893 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
894 | + EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php', |
|
895 | + $this->_template_args, |
|
896 | + true |
|
897 | + ); |
|
898 | + $this->display_admin_page_with_sidebar(); |
|
899 | + } |
|
900 | + |
|
901 | + |
|
902 | + /** |
|
903 | + * Handler for updating template settings. |
|
904 | + * |
|
905 | + * @throws EE_Error |
|
906 | + * @throws InvalidArgumentException |
|
907 | + * @throws InvalidDataTypeException |
|
908 | + * @throws InvalidInterfaceException |
|
909 | + */ |
|
910 | + protected function _update_template_settings() |
|
911 | + { |
|
912 | + /** |
|
913 | + * Note leaving this filter in for backward compatibility this was moved in 4.6.x |
|
914 | + * from General_Settings_Admin_Page to here. |
|
915 | + */ |
|
916 | + EE_Registry::instance()->CFG->template_settings = apply_filters( |
|
917 | + 'FHEE__General_Settings_Admin_Page__update_template_settings__data', |
|
918 | + EE_Registry::instance()->CFG->template_settings, |
|
919 | + $this->_req_data |
|
920 | + ); |
|
921 | + // update custom post type slugs and detect if we need to flush rewrite rules |
|
922 | + $old_slug = EE_Registry::instance()->CFG->core->event_cpt_slug; |
|
923 | + EE_Registry::instance()->CFG->core->event_cpt_slug = empty($this->_req_data['event_cpt_slug']) |
|
924 | + ? EE_Registry::instance()->CFG->core->event_cpt_slug |
|
925 | + : EEH_URL::slugify($this->_req_data['event_cpt_slug'], 'events'); |
|
926 | + $what = 'Template Settings'; |
|
927 | + $success = $this->_update_espresso_configuration( |
|
928 | + $what, |
|
929 | + EE_Registry::instance()->CFG->template_settings, |
|
930 | + __FILE__, |
|
931 | + __FUNCTION__, |
|
932 | + __LINE__ |
|
933 | + ); |
|
934 | + if (EE_Registry::instance()->CFG->core->event_cpt_slug !== $old_slug) { |
|
935 | + /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */ |
|
936 | + $rewrite_rules = LoaderFactory::getLoader()->getShared( |
|
937 | + 'EventEspresso\core\domain\services\custom_post_types\RewriteRules' |
|
938 | + ); |
|
939 | + $rewrite_rules->flush(); |
|
940 | + } |
|
941 | + $this->_redirect_after_action($success, $what, 'updated', array('action' => 'template_settings')); |
|
942 | + } |
|
943 | + |
|
944 | + |
|
945 | + /** |
|
946 | + * _premium_event_editor_meta_boxes |
|
947 | + * add all metaboxes related to the event_editor |
|
948 | + * |
|
949 | + * @access protected |
|
950 | + * @return void |
|
951 | + * @throws EE_Error |
|
952 | + * @throws InvalidArgumentException |
|
953 | + * @throws InvalidDataTypeException |
|
954 | + * @throws InvalidInterfaceException |
|
955 | + * @throws ReflectionException |
|
956 | + */ |
|
957 | + protected function _premium_event_editor_meta_boxes() |
|
958 | + { |
|
959 | + $this->verify_cpt_object(); |
|
960 | + add_meta_box( |
|
961 | + 'espresso_event_editor_event_options', |
|
962 | + esc_html__('Event Registration Options', 'event_espresso'), |
|
963 | + array($this, 'registration_options_meta_box'), |
|
964 | + $this->page_slug, |
|
965 | + 'side', |
|
966 | + 'core' |
|
967 | + ); |
|
968 | + } |
|
969 | + |
|
970 | + |
|
971 | + /** |
|
972 | + * override caf metabox |
|
973 | + * |
|
974 | + * @return void |
|
975 | + * @throws DomainException |
|
976 | + * @throws EE_Error |
|
977 | + */ |
|
978 | + public function registration_options_meta_box() |
|
979 | + { |
|
980 | + $yes_no_values = array( |
|
981 | + array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')), |
|
982 | + array('id' => false, 'text' => esc_html__('No', 'event_espresso')), |
|
983 | + ); |
|
984 | + $default_reg_status_values = EEM_Registration::reg_status_array( |
|
985 | + array( |
|
986 | + EEM_Registration::status_id_cancelled, |
|
987 | + EEM_Registration::status_id_declined, |
|
988 | + EEM_Registration::status_id_incomplete, |
|
989 | + EEM_Registration::status_id_wait_list, |
|
990 | + ), |
|
991 | + true |
|
992 | + ); |
|
993 | + $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false); |
|
994 | + $template_args['_event'] = $this->_cpt_model_obj; |
|
995 | + $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit(); |
|
996 | + $template_args['default_registration_status'] = EEH_Form_Fields::select_input( |
|
997 | + 'default_reg_status', |
|
998 | + $default_reg_status_values, |
|
999 | + $this->_cpt_model_obj->default_registration_status() |
|
1000 | + ); |
|
1001 | + $template_args['display_description'] = EEH_Form_Fields::select_input( |
|
1002 | + 'display_desc', |
|
1003 | + $yes_no_values, |
|
1004 | + $this->_cpt_model_obj->display_description() |
|
1005 | + ); |
|
1006 | + $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input( |
|
1007 | + 'display_ticket_selector', |
|
1008 | + $yes_no_values, |
|
1009 | + $this->_cpt_model_obj->display_ticket_selector(), |
|
1010 | + '', |
|
1011 | + '', |
|
1012 | + false |
|
1013 | + ); |
|
1014 | + $template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input( |
|
1015 | + 'EVT_default_registration_status', |
|
1016 | + $default_reg_status_values, |
|
1017 | + $this->_cpt_model_obj->default_registration_status() |
|
1018 | + ); |
|
1019 | + $template_args['additional_registration_options'] = apply_filters( |
|
1020 | + 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', |
|
1021 | + '', |
|
1022 | + $template_args, |
|
1023 | + $yes_no_values, |
|
1024 | + $default_reg_status_values |
|
1025 | + ); |
|
1026 | + EEH_Template::display_template( |
|
1027 | + EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
1028 | + $template_args |
|
1029 | + ); |
|
1030 | + } |
|
1031 | + |
|
1032 | + |
|
1033 | + |
|
1034 | + /** |
|
1035 | + * wp_list_table_mods for caf |
|
1036 | + * ============================ |
|
1037 | + */ |
|
1038 | + /** |
|
1039 | + * hook into list table filters and provide filters for caffeinated list table |
|
1040 | + * |
|
1041 | + * @param array $old_filters any existing filters present |
|
1042 | + * @param array $list_table_obj the list table object |
|
1043 | + * @return array new filters |
|
1044 | + * @throws EE_Error |
|
1045 | + * @throws InvalidArgumentException |
|
1046 | + * @throws InvalidDataTypeException |
|
1047 | + * @throws InvalidInterfaceException |
|
1048 | + * @throws ReflectionException |
|
1049 | + */ |
|
1050 | + public function list_table_filters($old_filters, $list_table_obj) |
|
1051 | + { |
|
1052 | + $filters = array(); |
|
1053 | + // first month/year filters |
|
1054 | + $filters[] = $this->espresso_event_months_dropdown(); |
|
1055 | + $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null; |
|
1056 | + // active status dropdown |
|
1057 | + if ($status !== 'draft') { |
|
1058 | + $filters[] = $this->active_status_dropdown( |
|
1059 | + isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : '' |
|
1060 | + ); |
|
1061 | + $filters[] = $this->venuesDropdown( |
|
1062 | + isset($this->_req_data['venue']) ? $this->_req_data['venue'] : '' |
|
1063 | + ); |
|
1064 | + } |
|
1065 | + // category filter |
|
1066 | + $filters[] = $this->category_dropdown(); |
|
1067 | + return array_merge($old_filters, $filters); |
|
1068 | + } |
|
1069 | + |
|
1070 | + |
|
1071 | + /** |
|
1072 | + * espresso_event_months_dropdown |
|
1073 | + * |
|
1074 | + * @access public |
|
1075 | + * @return string dropdown listing month/year selections for events. |
|
1076 | + */ |
|
1077 | + public function espresso_event_months_dropdown() |
|
1078 | + { |
|
1079 | + // what we need to do is get all PRIMARY datetimes for all events to filter on. |
|
1080 | + // Note we need to include any other filters that are set! |
|
1081 | + $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null; |
|
1082 | + // categories? |
|
1083 | + $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 |
|
1084 | + ? $this->_req_data['EVT_CAT'] |
|
1085 | + : null; |
|
1086 | + // active status? |
|
1087 | + $active_status = isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : null; |
|
1088 | + $cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : ''; |
|
1089 | + return EEH_Form_Fields::generate_event_months_dropdown($cur_date, $status, $category, $active_status); |
|
1090 | + } |
|
1091 | + |
|
1092 | + |
|
1093 | + /** |
|
1094 | + * returns a list of "active" statuses on the event |
|
1095 | + * |
|
1096 | + * @param string $current_value whatever the current active status is |
|
1097 | + * @return string |
|
1098 | + */ |
|
1099 | + public function active_status_dropdown($current_value = '') |
|
1100 | + { |
|
1101 | + $select_name = 'active_status'; |
|
1102 | + $values = array( |
|
1103 | + 'none' => esc_html__('Show Active/Inactive', 'event_espresso'), |
|
1104 | + 'active' => esc_html__('Active', 'event_espresso'), |
|
1105 | + 'upcoming' => esc_html__('Upcoming', 'event_espresso'), |
|
1106 | + 'expired' => esc_html__('Expired', 'event_espresso'), |
|
1107 | + 'inactive' => esc_html__('Inactive', 'event_espresso'), |
|
1108 | + ); |
|
1109 | + |
|
1110 | + return EEH_Form_Fields::select_input($select_name, $values, $current_value, '', 'wide'); |
|
1111 | + } |
|
1112 | + |
|
1113 | + |
|
1114 | + /** |
|
1115 | + * returns a list of "venues" |
|
1116 | + * |
|
1117 | + * @param string $current_value whatever the current active status is |
|
1118 | + * @return string |
|
1119 | + * @throws EE_Error |
|
1120 | + * @throws InvalidArgumentException |
|
1121 | + * @throws InvalidDataTypeException |
|
1122 | + * @throws InvalidInterfaceException |
|
1123 | + * @throws ReflectionException |
|
1124 | + */ |
|
1125 | + protected function venuesDropdown($current_value = '') |
|
1126 | + { |
|
1127 | + $select_name = 'venue'; |
|
1128 | + $values = array( |
|
1129 | + '' => esc_html__('All Venues', 'event_espresso'), |
|
1130 | + ); |
|
1131 | + // populate the list of venues. |
|
1132 | + $venue_model = EE_Registry::instance()->load_model('Venue'); |
|
1133 | + $venues = $venue_model->get_all(array('order_by' => array('VNU_name' => 'ASC'))); |
|
1134 | + |
|
1135 | + foreach ($venues as $venue) { |
|
1136 | + $values[ $venue->ID() ] = $venue->name(); |
|
1137 | + } |
|
1138 | + |
|
1139 | + return EEH_Form_Fields::select_input($select_name, $values, $current_value, '', 'wide'); |
|
1140 | + } |
|
1141 | + |
|
1142 | + |
|
1143 | + /** |
|
1144 | + * output a dropdown of the categories for the category filter on the event admin list table |
|
1145 | + * |
|
1146 | + * @access public |
|
1147 | + * @return string html |
|
1148 | + */ |
|
1149 | + public function category_dropdown() |
|
1150 | + { |
|
1151 | + $cur_cat = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1; |
|
1152 | + return EEH_Form_Fields::generate_event_category_dropdown($cur_cat); |
|
1153 | + } |
|
1154 | + |
|
1155 | + |
|
1156 | + /** |
|
1157 | + * get total number of events today |
|
1158 | + * |
|
1159 | + * @access public |
|
1160 | + * @return int |
|
1161 | + * @throws EE_Error |
|
1162 | + * @throws InvalidArgumentException |
|
1163 | + * @throws InvalidDataTypeException |
|
1164 | + * @throws InvalidInterfaceException |
|
1165 | + */ |
|
1166 | + public function total_events_today() |
|
1167 | + { |
|
1168 | + $start = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1169 | + 'DTT_EVT_start', |
|
1170 | + date('Y-m-d') . ' 00:00:00', |
|
1171 | + 'Y-m-d H:i:s', |
|
1172 | + 'UTC' |
|
1173 | + ); |
|
1174 | + $end = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1175 | + 'DTT_EVT_start', |
|
1176 | + date('Y-m-d') . ' 23:59:59', |
|
1177 | + 'Y-m-d H:i:s', |
|
1178 | + 'UTC' |
|
1179 | + ); |
|
1180 | + $where = array( |
|
1181 | + 'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)), |
|
1182 | + ); |
|
1183 | + return EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
1184 | + } |
|
1185 | + |
|
1186 | + |
|
1187 | + /** |
|
1188 | + * get total number of events this month |
|
1189 | + * |
|
1190 | + * @access public |
|
1191 | + * @return int |
|
1192 | + * @throws EE_Error |
|
1193 | + * @throws InvalidArgumentException |
|
1194 | + * @throws InvalidDataTypeException |
|
1195 | + * @throws InvalidInterfaceException |
|
1196 | + */ |
|
1197 | + public function total_events_this_month() |
|
1198 | + { |
|
1199 | + // Dates |
|
1200 | + $this_year_r = date('Y'); |
|
1201 | + $this_month_r = date('m'); |
|
1202 | + $days_this_month = date('t'); |
|
1203 | + $start = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1204 | + 'DTT_EVT_start', |
|
1205 | + $this_year_r . '-' . $this_month_r . '-01 00:00:00', |
|
1206 | + 'Y-m-d H:i:s', |
|
1207 | + 'UTC' |
|
1208 | + ); |
|
1209 | + $end = EEM_Datetime::instance()->convert_datetime_for_query( |
|
1210 | + 'DTT_EVT_start', |
|
1211 | + $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59', |
|
1212 | + 'Y-m-d H:i:s', |
|
1213 | + 'UTC' |
|
1214 | + ); |
|
1215 | + $where = array( |
|
1216 | + 'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)), |
|
1217 | + ); |
|
1218 | + return EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
1219 | + } |
|
1220 | + |
|
1221 | + |
|
1222 | + /** DEFAULT TICKETS STUFF **/ |
|
1223 | + |
|
1224 | + /** |
|
1225 | + * Output default tickets list table view. |
|
1226 | + * |
|
1227 | + * @throws DomainException |
|
1228 | + * @throws EE_Error |
|
1229 | + * @throws InvalidArgumentException |
|
1230 | + * @throws InvalidDataTypeException |
|
1231 | + * @throws InvalidInterfaceException |
|
1232 | + */ |
|
1233 | + public function _tickets_overview_list_table() |
|
1234 | + { |
|
1235 | + $this->_search_btn_label = esc_html__('Tickets', 'event_espresso'); |
|
1236 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
1237 | + } |
|
1238 | + |
|
1239 | + |
|
1240 | + /** |
|
1241 | + * @param int $per_page |
|
1242 | + * @param bool $count |
|
1243 | + * @param bool $trashed |
|
1244 | + * @return EE_Soft_Delete_Base_Class[]|int |
|
1245 | + * @throws EE_Error |
|
1246 | + * @throws InvalidArgumentException |
|
1247 | + * @throws InvalidDataTypeException |
|
1248 | + * @throws InvalidInterfaceException |
|
1249 | + */ |
|
1250 | + public function get_default_tickets($per_page = 10, $count = false, $trashed = false) |
|
1251 | + { |
|
1252 | + $orderby = empty($this->_req_data['orderby']) ? 'TKT_name' : $this->_req_data['orderby']; |
|
1253 | + $order = empty($this->_req_data['order']) ? 'ASC' : $this->_req_data['order']; |
|
1254 | + switch ($orderby) { |
|
1255 | + case 'TKT_name': |
|
1256 | + $orderby = array('TKT_name' => $order); |
|
1257 | + break; |
|
1258 | + case 'TKT_price': |
|
1259 | + $orderby = array('TKT_price' => $order); |
|
1260 | + break; |
|
1261 | + case 'TKT_uses': |
|
1262 | + $orderby = array('TKT_uses' => $order); |
|
1263 | + break; |
|
1264 | + case 'TKT_min': |
|
1265 | + $orderby = array('TKT_min' => $order); |
|
1266 | + break; |
|
1267 | + case 'TKT_max': |
|
1268 | + $orderby = array('TKT_max' => $order); |
|
1269 | + break; |
|
1270 | + case 'TKT_qty': |
|
1271 | + $orderby = array('TKT_qty' => $order); |
|
1272 | + break; |
|
1273 | + } |
|
1274 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) |
|
1275 | + ? $this->_req_data['paged'] |
|
1276 | + : 1; |
|
1277 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) |
|
1278 | + ? $this->_req_data['perpage'] |
|
1279 | + : $per_page; |
|
1280 | + $_where = array( |
|
1281 | + 'TKT_is_default' => 1, |
|
1282 | + 'TKT_deleted' => $trashed, |
|
1283 | + ); |
|
1284 | + $offset = ($current_page - 1) * $per_page; |
|
1285 | + $limit = array($offset, $per_page); |
|
1286 | + if (isset($this->_req_data['s'])) { |
|
1287 | + $sstr = '%' . $this->_req_data['s'] . '%'; |
|
1288 | + $_where['OR'] = array( |
|
1289 | + 'TKT_name' => array('LIKE', $sstr), |
|
1290 | + 'TKT_description' => array('LIKE', $sstr), |
|
1291 | + ); |
|
1292 | + } |
|
1293 | + $query_params = array( |
|
1294 | + $_where, |
|
1295 | + 'order_by' => $orderby, |
|
1296 | + 'limit' => $limit, |
|
1297 | + 'group_by' => 'TKT_ID', |
|
1298 | + ); |
|
1299 | + if ($count) { |
|
1300 | + return EEM_Ticket::instance()->count_deleted_and_undeleted(array($_where)); |
|
1301 | + } |
|
1302 | + return EEM_Ticket::instance()->get_all_deleted_and_undeleted($query_params); |
|
1303 | + } |
|
1304 | + |
|
1305 | + |
|
1306 | + /** |
|
1307 | + * @param bool $trash |
|
1308 | + * @throws EE_Error |
|
1309 | + * @throws InvalidArgumentException |
|
1310 | + * @throws InvalidDataTypeException |
|
1311 | + * @throws InvalidInterfaceException |
|
1312 | + */ |
|
1313 | + protected function _trash_or_restore_ticket($trash = false) |
|
1314 | + { |
|
1315 | + $success = 1; |
|
1316 | + $TKT = EEM_Ticket::instance(); |
|
1317 | + // checkboxes? |
|
1318 | + if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1319 | + // if array has more than one element then success message should be plural |
|
1320 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
1321 | + // cycle thru the boxes |
|
1322 | + foreach ($this->_req_data['checkbox'] as $TKT_ID) { |
|
1323 | + if ($trash) { |
|
1324 | + if (! $TKT->delete_by_ID($TKT_ID)) { |
|
1325 | + $success = 0; |
|
1326 | + } |
|
1327 | + } elseif (! $TKT->restore_by_ID($TKT_ID)) { |
|
1328 | + $success = 0; |
|
1329 | + } |
|
1330 | + } |
|
1331 | + } else { |
|
1332 | + // grab single id and trash |
|
1333 | + $TKT_ID = absint($this->_req_data['TKT_ID']); |
|
1334 | + if ($trash) { |
|
1335 | + if (! $TKT->delete_by_ID($TKT_ID)) { |
|
1336 | + $success = 0; |
|
1337 | + } |
|
1338 | + } elseif (! $TKT->restore_by_ID($TKT_ID)) { |
|
1339 | + $success = 0; |
|
1340 | + } |
|
1341 | + } |
|
1342 | + $action_desc = $trash ? 'moved to the trash' : 'restored'; |
|
1343 | + $query_args = array( |
|
1344 | + 'action' => 'ticket_list_table', |
|
1345 | + 'status' => $trash ? '' : 'trashed', |
|
1346 | + ); |
|
1347 | + $this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args); |
|
1348 | + } |
|
1349 | + |
|
1350 | + |
|
1351 | + /** |
|
1352 | + * Handles trashing default ticket. |
|
1353 | + * |
|
1354 | + * @throws EE_Error |
|
1355 | + * @throws InvalidArgumentException |
|
1356 | + * @throws InvalidDataTypeException |
|
1357 | + * @throws InvalidInterfaceException |
|
1358 | + * @throws ReflectionException |
|
1359 | + */ |
|
1360 | + protected function _delete_ticket() |
|
1361 | + { |
|
1362 | + $success = 1; |
|
1363 | + // checkboxes? |
|
1364 | + if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1365 | + // if array has more than one element then success message should be plural |
|
1366 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
1367 | + // cycle thru the boxes |
|
1368 | + foreach ($this->_req_data['checkbox'] as $TKT_ID) { |
|
1369 | + // delete |
|
1370 | + if (! $this->_delete_the_ticket($TKT_ID)) { |
|
1371 | + $success = 0; |
|
1372 | + } |
|
1373 | + } |
|
1374 | + } else { |
|
1375 | + // grab single id and trash |
|
1376 | + $TKT_ID = absint($this->_req_data['TKT_ID']); |
|
1377 | + if (! $this->_delete_the_ticket($TKT_ID)) { |
|
1378 | + $success = 0; |
|
1379 | + } |
|
1380 | + } |
|
1381 | + $action_desc = 'deleted'; |
|
1382 | + // fail safe. If the default ticket count === 1 then we need to redirect to event overview. |
|
1383 | + $ticket_count = EEM_Ticket::instance()->count_deleted_and_undeleted( |
|
1384 | + [['TKT_is_default' => 1]], |
|
1385 | + 'TKT_ID', |
|
1386 | + true |
|
1387 | + ); |
|
1388 | + $query_args = $ticket_count |
|
1389 | + ? [] |
|
1390 | + : [ |
|
1391 | + 'action' => 'ticket_list_table', |
|
1392 | + 'status' => 'trashed' |
|
1393 | + ]; |
|
1394 | + $this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args); |
|
1395 | + } |
|
1396 | + |
|
1397 | + |
|
1398 | + /** |
|
1399 | + * @param int $TKT_ID |
|
1400 | + * @return bool|int |
|
1401 | + * @throws EE_Error |
|
1402 | + * @throws InvalidArgumentException |
|
1403 | + * @throws InvalidDataTypeException |
|
1404 | + * @throws InvalidInterfaceException |
|
1405 | + * @throws ReflectionException |
|
1406 | + */ |
|
1407 | + protected function _delete_the_ticket($TKT_ID) |
|
1408 | + { |
|
1409 | + $ticket = EEM_Ticket::instance()->get_one_by_ID($TKT_ID); |
|
1410 | + if (! $ticket instanceof EE_Ticket) { |
|
1411 | + return false; |
|
1412 | + } |
|
1413 | + $ticket->_remove_relations('Datetime'); |
|
1414 | + // delete all related prices first |
|
1415 | + $ticket->delete_related_permanently('Price'); |
|
1416 | + return $ticket->delete_permanently(); |
|
1417 | + } |
|
1418 | 1418 | } |
@@ -35,10 +35,10 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function __construct($routing = true) |
37 | 37 | { |
38 | - if (! defined('EVENTS_CAF_TEMPLATE_PATH')) { |
|
39 | - define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/'); |
|
40 | - define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/'); |
|
41 | - define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/'); |
|
38 | + if ( ! defined('EVENTS_CAF_TEMPLATE_PATH')) { |
|
39 | + define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'events/templates/'); |
|
40 | + define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND.'events/assets/'); |
|
41 | + define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'events/assets/'); |
|
42 | 42 | } |
43 | 43 | parent::__construct($routing); |
44 | 44 | $this->admin_config = $this->loader->getShared('EE_Admin_Config'); |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | */ |
57 | 57 | protected function _extend_page_config() |
58 | 58 | { |
59 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events'; |
|
59 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'events'; |
|
60 | 60 | // is there a evt_id in the request? |
61 | 61 | $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) |
62 | 62 | ? $this->_req_data['EVT_ID'] |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | $this->_page_config['import_events']['metaboxes'] = $this->_default_espresso_metaboxes; |
153 | 153 | $this->_page_config['create_new']['metaboxes'][] = '_premium_event_editor_meta_boxes'; |
154 | 154 | // don't load qTips if using the advanced editor |
155 | - if (! $this->admin_config->useAdvancedEditor()) { |
|
155 | + if ( ! $this->admin_config->useAdvancedEditor()) { |
|
156 | 156 | $this->_page_config['create_new']['qtips'][] = 'EE_Event_Editor_Tips'; |
157 | 157 | $this->_page_config['edit']['qtips'][] = 'EE_Event_Editor_Tips'; |
158 | 158 | } |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | { |
299 | 299 | $return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug); |
300 | 300 | // make sure this is only when editing |
301 | - if (! empty($id)) { |
|
301 | + if ( ! empty($id)) { |
|
302 | 302 | $href = EE_Admin_Page::add_query_args_and_nonce( |
303 | 303 | array('action' => 'duplicate_event', 'EVT_ID' => $id), |
304 | 304 | $this->_admin_base_url |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | { |
351 | 351 | wp_register_script( |
352 | 352 | 'ee-event-editor-heartbeat', |
353 | - EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js', |
|
353 | + EVENTS_CAF_ASSETS_URL.'event-editor-heartbeat.js', |
|
354 | 354 | array('ee_admin_js', 'heartbeat'), |
355 | 355 | EVENT_ESPRESSO_VERSION, |
356 | 356 | true |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | public function add_additional_datetime_button($template, $template_args) |
375 | 375 | { |
376 | 376 | return EEH_Template::display_template( |
377 | - EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php', |
|
377 | + EVENTS_CAF_TEMPLATE_PATH.'event_datetime_add_additional_time.template.php', |
|
378 | 378 | $template_args, |
379 | 379 | true |
380 | 380 | ); |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | public function add_datetime_clone_button($template, $template_args) |
393 | 393 | { |
394 | 394 | return EEH_Template::display_template( |
395 | - EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php', |
|
395 | + EVENTS_CAF_TEMPLATE_PATH.'event_datetime_metabox_clone_button.template.php', |
|
396 | 396 | $template_args, |
397 | 397 | true |
398 | 398 | ); |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | public function datetime_timezones_template($template, $template_args) |
411 | 411 | { |
412 | 412 | return EEH_Template::display_template( |
413 | - EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php', |
|
413 | + EVENTS_CAF_TEMPLATE_PATH.'event_datetime_timezones.template.php', |
|
414 | 414 | $template_args, |
415 | 415 | true |
416 | 416 | ); |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | { |
542 | 542 | // first make sure the ID for the event is in the request. |
543 | 543 | // If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?) |
544 | - if (! isset($this->_req_data['EVT_ID'])) { |
|
544 | + if ( ! isset($this->_req_data['EVT_ID'])) { |
|
545 | 545 | EE_Error::add_error( |
546 | 546 | esc_html__( |
547 | 547 | 'In order to duplicate an event an Event ID is required. None was given.', |
@@ -556,7 +556,7 @@ discard block |
||
556 | 556 | } |
557 | 557 | // k we've got EVT_ID so let's use that to get the event we'll duplicate |
558 | 558 | $orig_event = EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']); |
559 | - if (! $orig_event instanceof EE_Event) { |
|
559 | + if ( ! $orig_event instanceof EE_Event) { |
|
560 | 560 | throw new EE_Error( |
561 | 561 | sprintf( |
562 | 562 | esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'), |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | $orig_ven = $orig_event->get_many_related('Venue'); |
573 | 573 | // reset the ID and modify other details to make it clear this is a dupe |
574 | 574 | $new_event->set('EVT_ID', 0); |
575 | - $new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso'); |
|
575 | + $new_name = $new_event->name().' '.esc_html__('**DUPLICATE**', 'event_espresso'); |
|
576 | 576 | $new_event->set('EVT_name', $new_name); |
577 | 577 | $new_event->set( |
578 | 578 | 'EVT_slug', |
@@ -601,7 +601,7 @@ discard block |
||
601 | 601 | 'Question_Group', |
602 | 602 | [['Event_Question_Group.EQG_primary' => true]] |
603 | 603 | ); |
604 | - if (! empty($orig_primary_qgs)) { |
|
604 | + if ( ! empty($orig_primary_qgs)) { |
|
605 | 605 | foreach ($orig_primary_qgs as $id => $obj) { |
606 | 606 | if ($obj instanceof EE_Question_Group) { |
607 | 607 | $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_primary' => true]); |
@@ -613,7 +613,7 @@ discard block |
||
613 | 613 | 'Question_Group', |
614 | 614 | [['Event_Question_Group.EQG_additional' => true]] |
615 | 615 | ); |
616 | - if (! empty($orig_additional_qgs)) { |
|
616 | + if ( ! empty($orig_additional_qgs)) { |
|
617 | 617 | foreach ($orig_additional_qgs as $id => $obj) { |
618 | 618 | if ($obj instanceof EE_Question_Group) { |
619 | 619 | $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_additional' => true]); |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | // k now that we have the new event saved we can loop through the datetimes and start adding relations. |
627 | 627 | $cloned_tickets = array(); |
628 | 628 | foreach ($orig_datetimes as $orig_dtt) { |
629 | - if (! $orig_dtt instanceof EE_Datetime) { |
|
629 | + if ( ! $orig_dtt instanceof EE_Datetime) { |
|
630 | 630 | continue; |
631 | 631 | } |
632 | 632 | $new_dtt = clone $orig_dtt; |
@@ -641,7 +641,7 @@ discard block |
||
641 | 641 | // now let's get the ticket relations setup. |
642 | 642 | foreach ((array) $orig_tkts as $orig_tkt) { |
643 | 643 | // it's possible a datetime will have no tickets so let's verify we HAVE a ticket first. |
644 | - if (! $orig_tkt instanceof EE_Ticket) { |
|
644 | + if ( ! $orig_tkt instanceof EE_Ticket) { |
|
645 | 645 | continue; |
646 | 646 | } |
647 | 647 | // is this ticket archived? If it is then let's skip |
@@ -650,8 +650,8 @@ discard block |
||
650 | 650 | } |
651 | 651 | // does this original ticket already exist in the clone_tickets cache? |
652 | 652 | // If so we'll just use the new ticket from it. |
653 | - if (isset($cloned_tickets[ $orig_tkt->ID() ])) { |
|
654 | - $new_tkt = $cloned_tickets[ $orig_tkt->ID() ]; |
|
653 | + if (isset($cloned_tickets[$orig_tkt->ID()])) { |
|
654 | + $new_tkt = $cloned_tickets[$orig_tkt->ID()]; |
|
655 | 655 | } else { |
656 | 656 | $new_tkt = clone $orig_tkt; |
657 | 657 | // get relations on the $orig_tkt that we need to setup. |
@@ -684,7 +684,7 @@ discard block |
||
684 | 684 | // for use with later datetimes that have the same ticket. |
685 | 685 | $new_dtt->_add_relation_to($new_tkt, 'Ticket'); |
686 | 686 | $new_dtt->save(); |
687 | - $cloned_tickets[ $orig_tkt->ID() ] = $new_tkt; |
|
687 | + $cloned_tickets[$orig_tkt->ID()] = $new_tkt; |
|
688 | 688 | } |
689 | 689 | } |
690 | 690 | // clone taxonomy information |
@@ -771,7 +771,7 @@ discard block |
||
771 | 771 | $this->_admin_base_url |
772 | 772 | ); |
773 | 773 | $content = EEH_Template::display_template( |
774 | - EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php', |
|
774 | + EVENTS_CAF_TEMPLATE_PATH.'import_page.template.php', |
|
775 | 775 | $this->_template_args, |
776 | 776 | true |
777 | 777 | ); |
@@ -792,7 +792,7 @@ discard block |
||
792 | 792 | */ |
793 | 793 | protected function _import_events() |
794 | 794 | { |
795 | - require_once(EE_CLASSES . 'EE_Import.class.php'); |
|
795 | + require_once(EE_CLASSES.'EE_Import.class.php'); |
|
796 | 796 | $success = EE_Import::instance()->import(); |
797 | 797 | $this->_redirect_after_action($success, 'Import File', 'ran', array('action' => 'import_page'), true); |
798 | 798 | } |
@@ -821,8 +821,8 @@ discard block |
||
821 | 821 | 'EVT_ID' => $event_ids, |
822 | 822 | ); |
823 | 823 | $this->_req_data = array_merge($this->_req_data, $new_request_args); |
824 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
825 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
824 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
825 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
826 | 826 | $EE_Export = EE_Export::instance($this->_req_data); |
827 | 827 | if ($EE_Export instanceof EE_Export) { |
828 | 828 | $EE_Export->export(); |
@@ -845,8 +845,8 @@ discard block |
||
845 | 845 | 'category_ids' => $this->_req_data['EVT_CAT_ID'], |
846 | 846 | ); |
847 | 847 | $this->_req_data = array_merge($this->_req_data, $new_request_args); |
848 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
849 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
848 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
849 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
850 | 850 | $EE_Export = EE_Export::instance($this->_req_data); |
851 | 851 | if ($EE_Export instanceof EE_Export) { |
852 | 852 | $EE_Export->export(); |
@@ -891,7 +891,7 @@ discard block |
||
891 | 891 | $this->_set_add_edit_form_tags('update_template_settings'); |
892 | 892 | $this->_set_publish_post_box_vars(null, false, false, null, false); |
893 | 893 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
894 | - EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php', |
|
894 | + EVENTS_CAF_TEMPLATE_PATH.'template_settings.template.php', |
|
895 | 895 | $this->_template_args, |
896 | 896 | true |
897 | 897 | ); |
@@ -1024,7 +1024,7 @@ discard block |
||
1024 | 1024 | $default_reg_status_values |
1025 | 1025 | ); |
1026 | 1026 | EEH_Template::display_template( |
1027 | - EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
1027 | + EVENTS_CAF_TEMPLATE_PATH.'event_registration_options.template.php', |
|
1028 | 1028 | $template_args |
1029 | 1029 | ); |
1030 | 1030 | } |
@@ -1133,7 +1133,7 @@ discard block |
||
1133 | 1133 | $venues = $venue_model->get_all(array('order_by' => array('VNU_name' => 'ASC'))); |
1134 | 1134 | |
1135 | 1135 | foreach ($venues as $venue) { |
1136 | - $values[ $venue->ID() ] = $venue->name(); |
|
1136 | + $values[$venue->ID()] = $venue->name(); |
|
1137 | 1137 | } |
1138 | 1138 | |
1139 | 1139 | return EEH_Form_Fields::select_input($select_name, $values, $current_value, '', 'wide'); |
@@ -1167,13 +1167,13 @@ discard block |
||
1167 | 1167 | { |
1168 | 1168 | $start = EEM_Datetime::instance()->convert_datetime_for_query( |
1169 | 1169 | 'DTT_EVT_start', |
1170 | - date('Y-m-d') . ' 00:00:00', |
|
1170 | + date('Y-m-d').' 00:00:00', |
|
1171 | 1171 | 'Y-m-d H:i:s', |
1172 | 1172 | 'UTC' |
1173 | 1173 | ); |
1174 | 1174 | $end = EEM_Datetime::instance()->convert_datetime_for_query( |
1175 | 1175 | 'DTT_EVT_start', |
1176 | - date('Y-m-d') . ' 23:59:59', |
|
1176 | + date('Y-m-d').' 23:59:59', |
|
1177 | 1177 | 'Y-m-d H:i:s', |
1178 | 1178 | 'UTC' |
1179 | 1179 | ); |
@@ -1202,13 +1202,13 @@ discard block |
||
1202 | 1202 | $days_this_month = date('t'); |
1203 | 1203 | $start = EEM_Datetime::instance()->convert_datetime_for_query( |
1204 | 1204 | 'DTT_EVT_start', |
1205 | - $this_year_r . '-' . $this_month_r . '-01 00:00:00', |
|
1205 | + $this_year_r.'-'.$this_month_r.'-01 00:00:00', |
|
1206 | 1206 | 'Y-m-d H:i:s', |
1207 | 1207 | 'UTC' |
1208 | 1208 | ); |
1209 | 1209 | $end = EEM_Datetime::instance()->convert_datetime_for_query( |
1210 | 1210 | 'DTT_EVT_start', |
1211 | - $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59', |
|
1211 | + $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' 23:59:59', |
|
1212 | 1212 | 'Y-m-d H:i:s', |
1213 | 1213 | 'UTC' |
1214 | 1214 | ); |
@@ -1284,7 +1284,7 @@ discard block |
||
1284 | 1284 | $offset = ($current_page - 1) * $per_page; |
1285 | 1285 | $limit = array($offset, $per_page); |
1286 | 1286 | if (isset($this->_req_data['s'])) { |
1287 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
1287 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
1288 | 1288 | $_where['OR'] = array( |
1289 | 1289 | 'TKT_name' => array('LIKE', $sstr), |
1290 | 1290 | 'TKT_description' => array('LIKE', $sstr), |
@@ -1315,16 +1315,16 @@ discard block |
||
1315 | 1315 | $success = 1; |
1316 | 1316 | $TKT = EEM_Ticket::instance(); |
1317 | 1317 | // checkboxes? |
1318 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1318 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1319 | 1319 | // if array has more than one element then success message should be plural |
1320 | 1320 | $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
1321 | 1321 | // cycle thru the boxes |
1322 | 1322 | foreach ($this->_req_data['checkbox'] as $TKT_ID) { |
1323 | 1323 | if ($trash) { |
1324 | - if (! $TKT->delete_by_ID($TKT_ID)) { |
|
1324 | + if ( ! $TKT->delete_by_ID($TKT_ID)) { |
|
1325 | 1325 | $success = 0; |
1326 | 1326 | } |
1327 | - } elseif (! $TKT->restore_by_ID($TKT_ID)) { |
|
1327 | + } elseif ( ! $TKT->restore_by_ID($TKT_ID)) { |
|
1328 | 1328 | $success = 0; |
1329 | 1329 | } |
1330 | 1330 | } |
@@ -1332,10 +1332,10 @@ discard block |
||
1332 | 1332 | // grab single id and trash |
1333 | 1333 | $TKT_ID = absint($this->_req_data['TKT_ID']); |
1334 | 1334 | if ($trash) { |
1335 | - if (! $TKT->delete_by_ID($TKT_ID)) { |
|
1335 | + if ( ! $TKT->delete_by_ID($TKT_ID)) { |
|
1336 | 1336 | $success = 0; |
1337 | 1337 | } |
1338 | - } elseif (! $TKT->restore_by_ID($TKT_ID)) { |
|
1338 | + } elseif ( ! $TKT->restore_by_ID($TKT_ID)) { |
|
1339 | 1339 | $success = 0; |
1340 | 1340 | } |
1341 | 1341 | } |
@@ -1361,20 +1361,20 @@ discard block |
||
1361 | 1361 | { |
1362 | 1362 | $success = 1; |
1363 | 1363 | // checkboxes? |
1364 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1364 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
1365 | 1365 | // if array has more than one element then success message should be plural |
1366 | 1366 | $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
1367 | 1367 | // cycle thru the boxes |
1368 | 1368 | foreach ($this->_req_data['checkbox'] as $TKT_ID) { |
1369 | 1369 | // delete |
1370 | - if (! $this->_delete_the_ticket($TKT_ID)) { |
|
1370 | + if ( ! $this->_delete_the_ticket($TKT_ID)) { |
|
1371 | 1371 | $success = 0; |
1372 | 1372 | } |
1373 | 1373 | } |
1374 | 1374 | } else { |
1375 | 1375 | // grab single id and trash |
1376 | 1376 | $TKT_ID = absint($this->_req_data['TKT_ID']); |
1377 | - if (! $this->_delete_the_ticket($TKT_ID)) { |
|
1377 | + if ( ! $this->_delete_the_ticket($TKT_ID)) { |
|
1378 | 1378 | $success = 0; |
1379 | 1379 | } |
1380 | 1380 | } |
@@ -1407,7 +1407,7 @@ discard block |
||
1407 | 1407 | protected function _delete_the_ticket($TKT_ID) |
1408 | 1408 | { |
1409 | 1409 | $ticket = EEM_Ticket::instance()->get_one_by_ID($TKT_ID); |
1410 | - if (! $ticket instanceof EE_Ticket) { |
|
1410 | + if ( ! $ticket instanceof EE_Ticket) { |
|
1411 | 1411 | return false; |
1412 | 1412 | } |
1413 | 1413 | $ticket->_remove_relations('Datetime'); |
@@ -17,234 +17,234 @@ |
||
17 | 17 | abstract class BrowserAsset extends Asset |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * @var array $attributes |
|
22 | - */ |
|
23 | - private $attributes = []; |
|
24 | - |
|
25 | - /** |
|
26 | - * @var array $allowed_attributes |
|
27 | - */ |
|
28 | - private static $allowed_attributes = [ |
|
29 | - Asset::TYPE_CSS => [ |
|
30 | - 'crossorigin', |
|
31 | - 'media', |
|
32 | - 'referrerpolicy', |
|
33 | - 'sizes', |
|
34 | - 'type', |
|
35 | - ], |
|
36 | - Asset::TYPE_JS => [ |
|
37 | - 'async', |
|
38 | - 'charset', |
|
39 | - 'crossorigin', |
|
40 | - 'defer', |
|
41 | - 'type', |
|
42 | - ] |
|
43 | - ]; |
|
44 | - |
|
45 | - /** |
|
46 | - * @var array $dependencies |
|
47 | - */ |
|
48 | - private $dependencies; |
|
49 | - |
|
50 | - /** |
|
51 | - * @var string $source |
|
52 | - */ |
|
53 | - private $source; |
|
54 | - |
|
55 | - /** |
|
56 | - * @var string $version |
|
57 | - */ |
|
58 | - private $version; |
|
59 | - |
|
60 | - |
|
61 | - /** |
|
62 | - * Asset constructor. |
|
63 | - * |
|
64 | - * @param string $type |
|
65 | - * @param string $handle |
|
66 | - * @param string $source |
|
67 | - * @param array $dependencies |
|
68 | - * @param DomainInterface $domain |
|
69 | - * @param string $version |
|
70 | - * @throws DomainException |
|
71 | - * @throws InvalidDataTypeException |
|
72 | - */ |
|
73 | - public function __construct($type, $handle, $source, array $dependencies, DomainInterface $domain, $version = '') |
|
74 | - { |
|
75 | - parent::__construct($type, $handle, $domain); |
|
76 | - $this->setSource($source); |
|
77 | - $this->setDependencies($dependencies); |
|
78 | - $this->setVersion($version, false); |
|
79 | - } |
|
80 | - |
|
81 | - |
|
82 | - /** |
|
83 | - * @since 4.9.62.p |
|
84 | - */ |
|
85 | - abstract public function enqueueAsset(); |
|
86 | - |
|
87 | - |
|
88 | - /** |
|
89 | - * @return array |
|
90 | - */ |
|
91 | - public function getAttributes() |
|
92 | - { |
|
93 | - return $this->attributes; |
|
94 | - } |
|
95 | - |
|
96 | - |
|
97 | - /** |
|
98 | - * @param array $attributes |
|
99 | - * @throws DomainException |
|
100 | - * @since $VID:$ |
|
101 | - */ |
|
102 | - public function addAttributes(array $attributes) |
|
103 | - { |
|
104 | - if (empty($attributes)) { |
|
105 | - throw new DomainException( |
|
106 | - esc_html__('The attributes array needs at least one value.', 'event_espresso') |
|
107 | - ); |
|
108 | - } |
|
109 | - foreach ($attributes as $key => $value) { |
|
110 | - if (is_int($key) && $this->validateAttribute($value)) { |
|
111 | - $this->attributes[] = $value; |
|
112 | - } else if ($this->validateAttribute($key)) { |
|
113 | - $this->attributes[ $key ] = $value; |
|
114 | - } |
|
115 | - } |
|
116 | - } |
|
117 | - |
|
118 | - |
|
119 | - /** |
|
120 | - * @param string $attribute |
|
121 | - * @return bool |
|
122 | - * @throws DomainException |
|
123 | - * @since $VID:$ |
|
124 | - */ |
|
125 | - private function validateAttribute($attribute) |
|
126 | - { |
|
127 | - $allowed = BrowserAsset::$allowed_attributes[ $this->type() ]; |
|
128 | - if (! in_array($attribute, $allowed, true)) { |
|
129 | - throw new DomainException( |
|
130 | - sprintf( |
|
131 | - esc_html__('Invalid attribute! The only allowed attributes are: "%1$s"', 'event_espresso'), |
|
132 | - implode('", "', $allowed) |
|
133 | - ) |
|
134 | - ); |
|
135 | - } |
|
136 | - return true; |
|
137 | - } |
|
138 | - |
|
139 | - |
|
140 | - /** |
|
141 | - * @return array |
|
142 | - */ |
|
143 | - public function dependencies() |
|
144 | - { |
|
145 | - return $this->dependencies; |
|
146 | - } |
|
147 | - |
|
148 | - |
|
149 | - /** |
|
150 | - * @param array $dependencies |
|
151 | - */ |
|
152 | - public function addDependencies(array $dependencies) |
|
153 | - { |
|
154 | - $this->dependencies = array_merge($this->dependencies, $dependencies); |
|
155 | - } |
|
156 | - |
|
157 | - |
|
158 | - /** |
|
159 | - * @param array $dependencies |
|
160 | - */ |
|
161 | - protected function setDependencies(array $dependencies) |
|
162 | - { |
|
163 | - $this->dependencies = $dependencies; |
|
164 | - } |
|
165 | - |
|
166 | - |
|
167 | - /** |
|
168 | - * @since 4.9.62.p |
|
169 | - * @return bool |
|
170 | - */ |
|
171 | - public function hasDependencies() |
|
172 | - { |
|
173 | - return count($this->dependencies) > 0; |
|
174 | - } |
|
175 | - |
|
176 | - |
|
177 | - /** |
|
178 | - * @return string |
|
179 | - */ |
|
180 | - public function source() |
|
181 | - { |
|
182 | - return $this->source; |
|
183 | - } |
|
184 | - |
|
185 | - |
|
186 | - /** |
|
187 | - * @param string $source |
|
188 | - * @throws InvalidDataTypeException |
|
189 | - */ |
|
190 | - private function setSource($source) |
|
191 | - { |
|
192 | - if (! is_string($source)) { |
|
193 | - throw new InvalidDataTypeException( |
|
194 | - '$source', |
|
195 | - $source, |
|
196 | - 'string' |
|
197 | - ); |
|
198 | - } |
|
199 | - $this->source = $source; |
|
200 | - } |
|
201 | - |
|
202 | - |
|
203 | - /** |
|
204 | - * @return string |
|
205 | - * @throws InvalidDataTypeException |
|
206 | - * @throws DomainException |
|
207 | - */ |
|
208 | - public function version() |
|
209 | - { |
|
210 | - return $this->version; |
|
211 | - } |
|
212 | - |
|
213 | - |
|
214 | - /** |
|
215 | - * @param string $version |
|
216 | - * @param bool $fluent |
|
217 | - * @return BrowserAsset|null |
|
218 | - * @throws DomainException |
|
219 | - * @throws InvalidDataTypeException |
|
220 | - */ |
|
221 | - public function setVersion($version, $fluent = true) |
|
222 | - { |
|
223 | - // if version is NOT set and this asset was NOT built for distribution, |
|
224 | - // then set the version equal to the EE core plugin version |
|
225 | - if (empty($version) && ! $this->isBuiltDistributionSource()) { |
|
226 | - $version = $this->domain->version(); |
|
227 | - } |
|
228 | - if (! is_string($version)) { |
|
229 | - throw new InvalidDataTypeException( |
|
230 | - '$version', |
|
231 | - $version, |
|
232 | - 'string' |
|
233 | - ); |
|
234 | - } |
|
235 | - $this->version = $version; |
|
236 | - if ($fluent) { |
|
237 | - return $this; |
|
238 | - } |
|
239 | - return null; |
|
240 | - } |
|
241 | - |
|
242 | - |
|
243 | - /** |
|
244 | - * @return bool |
|
245 | - */ |
|
246 | - public function isBuiltDistributionSource() { |
|
247 | - return substr($this->source, -8) === Asset::FILE_EXTENSION_DISTRIBUTION_JS |
|
248 | - || substr($this->source, -9) === Asset::FILE_EXTENSION_DISTRIBUTION_CSS; |
|
249 | - } |
|
20 | + /** |
|
21 | + * @var array $attributes |
|
22 | + */ |
|
23 | + private $attributes = []; |
|
24 | + |
|
25 | + /** |
|
26 | + * @var array $allowed_attributes |
|
27 | + */ |
|
28 | + private static $allowed_attributes = [ |
|
29 | + Asset::TYPE_CSS => [ |
|
30 | + 'crossorigin', |
|
31 | + 'media', |
|
32 | + 'referrerpolicy', |
|
33 | + 'sizes', |
|
34 | + 'type', |
|
35 | + ], |
|
36 | + Asset::TYPE_JS => [ |
|
37 | + 'async', |
|
38 | + 'charset', |
|
39 | + 'crossorigin', |
|
40 | + 'defer', |
|
41 | + 'type', |
|
42 | + ] |
|
43 | + ]; |
|
44 | + |
|
45 | + /** |
|
46 | + * @var array $dependencies |
|
47 | + */ |
|
48 | + private $dependencies; |
|
49 | + |
|
50 | + /** |
|
51 | + * @var string $source |
|
52 | + */ |
|
53 | + private $source; |
|
54 | + |
|
55 | + /** |
|
56 | + * @var string $version |
|
57 | + */ |
|
58 | + private $version; |
|
59 | + |
|
60 | + |
|
61 | + /** |
|
62 | + * Asset constructor. |
|
63 | + * |
|
64 | + * @param string $type |
|
65 | + * @param string $handle |
|
66 | + * @param string $source |
|
67 | + * @param array $dependencies |
|
68 | + * @param DomainInterface $domain |
|
69 | + * @param string $version |
|
70 | + * @throws DomainException |
|
71 | + * @throws InvalidDataTypeException |
|
72 | + */ |
|
73 | + public function __construct($type, $handle, $source, array $dependencies, DomainInterface $domain, $version = '') |
|
74 | + { |
|
75 | + parent::__construct($type, $handle, $domain); |
|
76 | + $this->setSource($source); |
|
77 | + $this->setDependencies($dependencies); |
|
78 | + $this->setVersion($version, false); |
|
79 | + } |
|
80 | + |
|
81 | + |
|
82 | + /** |
|
83 | + * @since 4.9.62.p |
|
84 | + */ |
|
85 | + abstract public function enqueueAsset(); |
|
86 | + |
|
87 | + |
|
88 | + /** |
|
89 | + * @return array |
|
90 | + */ |
|
91 | + public function getAttributes() |
|
92 | + { |
|
93 | + return $this->attributes; |
|
94 | + } |
|
95 | + |
|
96 | + |
|
97 | + /** |
|
98 | + * @param array $attributes |
|
99 | + * @throws DomainException |
|
100 | + * @since $VID:$ |
|
101 | + */ |
|
102 | + public function addAttributes(array $attributes) |
|
103 | + { |
|
104 | + if (empty($attributes)) { |
|
105 | + throw new DomainException( |
|
106 | + esc_html__('The attributes array needs at least one value.', 'event_espresso') |
|
107 | + ); |
|
108 | + } |
|
109 | + foreach ($attributes as $key => $value) { |
|
110 | + if (is_int($key) && $this->validateAttribute($value)) { |
|
111 | + $this->attributes[] = $value; |
|
112 | + } else if ($this->validateAttribute($key)) { |
|
113 | + $this->attributes[ $key ] = $value; |
|
114 | + } |
|
115 | + } |
|
116 | + } |
|
117 | + |
|
118 | + |
|
119 | + /** |
|
120 | + * @param string $attribute |
|
121 | + * @return bool |
|
122 | + * @throws DomainException |
|
123 | + * @since $VID:$ |
|
124 | + */ |
|
125 | + private function validateAttribute($attribute) |
|
126 | + { |
|
127 | + $allowed = BrowserAsset::$allowed_attributes[ $this->type() ]; |
|
128 | + if (! in_array($attribute, $allowed, true)) { |
|
129 | + throw new DomainException( |
|
130 | + sprintf( |
|
131 | + esc_html__('Invalid attribute! The only allowed attributes are: "%1$s"', 'event_espresso'), |
|
132 | + implode('", "', $allowed) |
|
133 | + ) |
|
134 | + ); |
|
135 | + } |
|
136 | + return true; |
|
137 | + } |
|
138 | + |
|
139 | + |
|
140 | + /** |
|
141 | + * @return array |
|
142 | + */ |
|
143 | + public function dependencies() |
|
144 | + { |
|
145 | + return $this->dependencies; |
|
146 | + } |
|
147 | + |
|
148 | + |
|
149 | + /** |
|
150 | + * @param array $dependencies |
|
151 | + */ |
|
152 | + public function addDependencies(array $dependencies) |
|
153 | + { |
|
154 | + $this->dependencies = array_merge($this->dependencies, $dependencies); |
|
155 | + } |
|
156 | + |
|
157 | + |
|
158 | + /** |
|
159 | + * @param array $dependencies |
|
160 | + */ |
|
161 | + protected function setDependencies(array $dependencies) |
|
162 | + { |
|
163 | + $this->dependencies = $dependencies; |
|
164 | + } |
|
165 | + |
|
166 | + |
|
167 | + /** |
|
168 | + * @since 4.9.62.p |
|
169 | + * @return bool |
|
170 | + */ |
|
171 | + public function hasDependencies() |
|
172 | + { |
|
173 | + return count($this->dependencies) > 0; |
|
174 | + } |
|
175 | + |
|
176 | + |
|
177 | + /** |
|
178 | + * @return string |
|
179 | + */ |
|
180 | + public function source() |
|
181 | + { |
|
182 | + return $this->source; |
|
183 | + } |
|
184 | + |
|
185 | + |
|
186 | + /** |
|
187 | + * @param string $source |
|
188 | + * @throws InvalidDataTypeException |
|
189 | + */ |
|
190 | + private function setSource($source) |
|
191 | + { |
|
192 | + if (! is_string($source)) { |
|
193 | + throw new InvalidDataTypeException( |
|
194 | + '$source', |
|
195 | + $source, |
|
196 | + 'string' |
|
197 | + ); |
|
198 | + } |
|
199 | + $this->source = $source; |
|
200 | + } |
|
201 | + |
|
202 | + |
|
203 | + /** |
|
204 | + * @return string |
|
205 | + * @throws InvalidDataTypeException |
|
206 | + * @throws DomainException |
|
207 | + */ |
|
208 | + public function version() |
|
209 | + { |
|
210 | + return $this->version; |
|
211 | + } |
|
212 | + |
|
213 | + |
|
214 | + /** |
|
215 | + * @param string $version |
|
216 | + * @param bool $fluent |
|
217 | + * @return BrowserAsset|null |
|
218 | + * @throws DomainException |
|
219 | + * @throws InvalidDataTypeException |
|
220 | + */ |
|
221 | + public function setVersion($version, $fluent = true) |
|
222 | + { |
|
223 | + // if version is NOT set and this asset was NOT built for distribution, |
|
224 | + // then set the version equal to the EE core plugin version |
|
225 | + if (empty($version) && ! $this->isBuiltDistributionSource()) { |
|
226 | + $version = $this->domain->version(); |
|
227 | + } |
|
228 | + if (! is_string($version)) { |
|
229 | + throw new InvalidDataTypeException( |
|
230 | + '$version', |
|
231 | + $version, |
|
232 | + 'string' |
|
233 | + ); |
|
234 | + } |
|
235 | + $this->version = $version; |
|
236 | + if ($fluent) { |
|
237 | + return $this; |
|
238 | + } |
|
239 | + return null; |
|
240 | + } |
|
241 | + |
|
242 | + |
|
243 | + /** |
|
244 | + * @return bool |
|
245 | + */ |
|
246 | + public function isBuiltDistributionSource() { |
|
247 | + return substr($this->source, -8) === Asset::FILE_EXTENSION_DISTRIBUTION_JS |
|
248 | + || substr($this->source, -9) === Asset::FILE_EXTENSION_DISTRIBUTION_CSS; |
|
249 | + } |
|
250 | 250 | } |
@@ -16,238 +16,238 @@ |
||
16 | 16 | class RequestTypeContextChecker extends ContextChecker implements RequestTypeContextCheckerInterface |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @var RequestTypeContext $request_type |
|
21 | - */ |
|
22 | - private $request_type; |
|
23 | - |
|
24 | - |
|
25 | - /** |
|
26 | - * RequestTypeContextChecker constructor. |
|
27 | - * |
|
28 | - * @param RequestTypeContext $request_type |
|
29 | - */ |
|
30 | - public function __construct(RequestTypeContext $request_type) |
|
31 | - { |
|
32 | - $this->request_type = $request_type; |
|
33 | - parent::__construct( |
|
34 | - 'RequestTypeContextChecker', |
|
35 | - $this->request_type->validRequestTypes() |
|
36 | - ); |
|
37 | - } |
|
38 | - |
|
39 | - |
|
40 | - /** |
|
41 | - * true if the current request involves some form of activation |
|
42 | - * |
|
43 | - * @return bool |
|
44 | - */ |
|
45 | - public function isActivation() |
|
46 | - { |
|
47 | - return $this->request_type->isActivation(); |
|
48 | - } |
|
49 | - |
|
50 | - |
|
51 | - /** |
|
52 | - * @param $is_activation |
|
53 | - */ |
|
54 | - public function setIsActivation($is_activation) |
|
55 | - { |
|
56 | - $this->request_type->setIsActivation($is_activation); |
|
57 | - } |
|
58 | - |
|
59 | - |
|
60 | - /** |
|
61 | - * true if the current request is for the admin and is not being made via AJAX |
|
62 | - * |
|
63 | - * @return bool |
|
64 | - */ |
|
65 | - public function isAdmin() |
|
66 | - { |
|
67 | - return $this->request_type->slug() === RequestTypeContext::ADMIN; |
|
68 | - } |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * true if the current request is for the admin AND is being made via AJAX |
|
73 | - * |
|
74 | - * @return bool |
|
75 | - */ |
|
76 | - public function isAdminAjax() |
|
77 | - { |
|
78 | - return $this->request_type->slug() === RequestTypeContext::AJAX_ADMIN; |
|
79 | - } |
|
80 | - |
|
81 | - |
|
82 | - /** |
|
83 | - * true if the current request is being made via AJAX... any AJAX |
|
84 | - * |
|
85 | - * @return bool |
|
86 | - */ |
|
87 | - public function isAjax() |
|
88 | - { |
|
89 | - return $this->isEeAjax() || $this->isOtherAjax(); |
|
90 | - } |
|
91 | - |
|
92 | - |
|
93 | - /** |
|
94 | - * true if the current request is for either the EE admin or EE frontend AND is being made via AJAX |
|
95 | - * |
|
96 | - * @return bool |
|
97 | - */ |
|
98 | - public function isEeAjax() |
|
99 | - { |
|
100 | - return $this->isAdminAjax() || $this->isFrontAjax(); |
|
101 | - } |
|
102 | - |
|
103 | - |
|
104 | - /** |
|
105 | - * true if the current request is being made via AJAX but is NOT for EE related logic |
|
106 | - * |
|
107 | - * @return bool |
|
108 | - */ |
|
109 | - public function isOtherAjax() |
|
110 | - { |
|
111 | - return $this->request_type->slug() === RequestTypeContext::AJAX_OTHER && ! $this->isActivation(); |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * true if the current request is for the EE REST API |
|
116 | - * |
|
117 | - * @return bool |
|
118 | - */ |
|
119 | - public function isApi() |
|
120 | - { |
|
121 | - return $this->request_type->slug() === RequestTypeContext::API && ! $this->isActivation(); |
|
122 | - } |
|
123 | - |
|
124 | - |
|
125 | - /** |
|
126 | - * true if the current request is from the command line |
|
127 | - * |
|
128 | - * @return bool |
|
129 | - */ |
|
130 | - public function isCli() |
|
131 | - { |
|
132 | - return $this->request_type->slug() === RequestTypeContext::CLI && ! $this->isActivation(); |
|
133 | - } |
|
134 | - |
|
135 | - |
|
136 | - /** |
|
137 | - * true if the current request is for a WP_Cron |
|
138 | - * |
|
139 | - * @return bool |
|
140 | - */ |
|
141 | - public function isCron() |
|
142 | - { |
|
143 | - return $this->request_type->slug() === RequestTypeContext::CRON && ! $this->isActivation(); |
|
144 | - } |
|
145 | - |
|
146 | - |
|
147 | - /** |
|
148 | - * true if the current request is for a feed (ie: RSS) |
|
149 | - * |
|
150 | - * @return bool |
|
151 | - */ |
|
152 | - public function isFeed() |
|
153 | - { |
|
154 | - return $this->request_type->slug() === RequestTypeContext::FEED && ! $this->isActivation(); |
|
155 | - } |
|
156 | - |
|
157 | - |
|
158 | - /** |
|
159 | - * true if the current request is for the frontend and is not being made via AJAX |
|
160 | - * |
|
161 | - * @return bool |
|
162 | - */ |
|
163 | - public function isFrontend() |
|
164 | - { |
|
165 | - return $this->request_type->slug() === RequestTypeContext::FRONTEND && ! $this->isActivation(); |
|
166 | - } |
|
167 | - |
|
168 | - |
|
169 | - /** |
|
170 | - * true if the current request is for the frontend AND is being made via AJAX |
|
171 | - * |
|
172 | - * @return bool |
|
173 | - */ |
|
174 | - public function isFrontAjax() |
|
175 | - { |
|
176 | - return $this->request_type->slug() === RequestTypeContext::AJAX_FRONT && ! $this->isActivation(); |
|
177 | - } |
|
178 | - |
|
179 | - |
|
180 | - /** |
|
181 | - * true if the current request is for the EE GraphQL manager |
|
182 | - * |
|
183 | - * @return bool |
|
184 | - */ |
|
185 | - public function isGQL() |
|
186 | - { |
|
187 | - return $this->request_type->slug() === RequestTypeContext::GQL && ! $this->isActivation(); |
|
188 | - } |
|
189 | - |
|
190 | - |
|
191 | - /** |
|
192 | - * true if the current request is for content that is to be displayed within an iframe |
|
193 | - * |
|
194 | - * @return bool |
|
195 | - */ |
|
196 | - public function isIframe() |
|
197 | - { |
|
198 | - return $this->request_type->slug() === RequestTypeContext::IFRAME && ! $this->isActivation(); |
|
199 | - } |
|
200 | - |
|
201 | - |
|
202 | - /** |
|
203 | - * true if the current request is occurring while unit testing |
|
204 | - * |
|
205 | - * @return bool |
|
206 | - */ |
|
207 | - public function isUnitTesting() |
|
208 | - { |
|
209 | - return $this->request_type->isUnitTesting(); |
|
210 | - } |
|
211 | - |
|
212 | - |
|
213 | - /** |
|
214 | - * true if the current request is for the WP REST API |
|
215 | - * |
|
216 | - * @return bool |
|
217 | - */ |
|
218 | - public function isWordPressApi() |
|
219 | - { |
|
220 | - return $this->request_type->slug() === RequestTypeContext::WP_API && ! $this->isActivation(); |
|
221 | - } |
|
222 | - |
|
223 | - |
|
224 | - /** |
|
225 | - * true if the current request is being made via AJAX for the WP Heartbeat |
|
226 | - * |
|
227 | - * @return bool |
|
228 | - */ |
|
229 | - public function isWordPressHeartbeat() |
|
230 | - { |
|
231 | - return $this->request_type->slug() === RequestTypeContext::AJAX_HEARTBEAT && ! $this->isActivation(); |
|
232 | - } |
|
233 | - |
|
234 | - |
|
235 | - /** |
|
236 | - * true if the current request is a loopback sent from WP core to test for errors |
|
237 | - * |
|
238 | - * @return bool |
|
239 | - */ |
|
240 | - public function isWordPressScrape() |
|
241 | - { |
|
242 | - return $this->request_type->slug() === RequestTypeContext::WP_SCRAPE; |
|
243 | - } |
|
244 | - |
|
245 | - |
|
246 | - /** |
|
247 | - * @return string |
|
248 | - */ |
|
249 | - public function slug() |
|
250 | - { |
|
251 | - return $this->request_type->slug(); |
|
252 | - } |
|
19 | + /** |
|
20 | + * @var RequestTypeContext $request_type |
|
21 | + */ |
|
22 | + private $request_type; |
|
23 | + |
|
24 | + |
|
25 | + /** |
|
26 | + * RequestTypeContextChecker constructor. |
|
27 | + * |
|
28 | + * @param RequestTypeContext $request_type |
|
29 | + */ |
|
30 | + public function __construct(RequestTypeContext $request_type) |
|
31 | + { |
|
32 | + $this->request_type = $request_type; |
|
33 | + parent::__construct( |
|
34 | + 'RequestTypeContextChecker', |
|
35 | + $this->request_type->validRequestTypes() |
|
36 | + ); |
|
37 | + } |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * true if the current request involves some form of activation |
|
42 | + * |
|
43 | + * @return bool |
|
44 | + */ |
|
45 | + public function isActivation() |
|
46 | + { |
|
47 | + return $this->request_type->isActivation(); |
|
48 | + } |
|
49 | + |
|
50 | + |
|
51 | + /** |
|
52 | + * @param $is_activation |
|
53 | + */ |
|
54 | + public function setIsActivation($is_activation) |
|
55 | + { |
|
56 | + $this->request_type->setIsActivation($is_activation); |
|
57 | + } |
|
58 | + |
|
59 | + |
|
60 | + /** |
|
61 | + * true if the current request is for the admin and is not being made via AJAX |
|
62 | + * |
|
63 | + * @return bool |
|
64 | + */ |
|
65 | + public function isAdmin() |
|
66 | + { |
|
67 | + return $this->request_type->slug() === RequestTypeContext::ADMIN; |
|
68 | + } |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * true if the current request is for the admin AND is being made via AJAX |
|
73 | + * |
|
74 | + * @return bool |
|
75 | + */ |
|
76 | + public function isAdminAjax() |
|
77 | + { |
|
78 | + return $this->request_type->slug() === RequestTypeContext::AJAX_ADMIN; |
|
79 | + } |
|
80 | + |
|
81 | + |
|
82 | + /** |
|
83 | + * true if the current request is being made via AJAX... any AJAX |
|
84 | + * |
|
85 | + * @return bool |
|
86 | + */ |
|
87 | + public function isAjax() |
|
88 | + { |
|
89 | + return $this->isEeAjax() || $this->isOtherAjax(); |
|
90 | + } |
|
91 | + |
|
92 | + |
|
93 | + /** |
|
94 | + * true if the current request is for either the EE admin or EE frontend AND is being made via AJAX |
|
95 | + * |
|
96 | + * @return bool |
|
97 | + */ |
|
98 | + public function isEeAjax() |
|
99 | + { |
|
100 | + return $this->isAdminAjax() || $this->isFrontAjax(); |
|
101 | + } |
|
102 | + |
|
103 | + |
|
104 | + /** |
|
105 | + * true if the current request is being made via AJAX but is NOT for EE related logic |
|
106 | + * |
|
107 | + * @return bool |
|
108 | + */ |
|
109 | + public function isOtherAjax() |
|
110 | + { |
|
111 | + return $this->request_type->slug() === RequestTypeContext::AJAX_OTHER && ! $this->isActivation(); |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * true if the current request is for the EE REST API |
|
116 | + * |
|
117 | + * @return bool |
|
118 | + */ |
|
119 | + public function isApi() |
|
120 | + { |
|
121 | + return $this->request_type->slug() === RequestTypeContext::API && ! $this->isActivation(); |
|
122 | + } |
|
123 | + |
|
124 | + |
|
125 | + /** |
|
126 | + * true if the current request is from the command line |
|
127 | + * |
|
128 | + * @return bool |
|
129 | + */ |
|
130 | + public function isCli() |
|
131 | + { |
|
132 | + return $this->request_type->slug() === RequestTypeContext::CLI && ! $this->isActivation(); |
|
133 | + } |
|
134 | + |
|
135 | + |
|
136 | + /** |
|
137 | + * true if the current request is for a WP_Cron |
|
138 | + * |
|
139 | + * @return bool |
|
140 | + */ |
|
141 | + public function isCron() |
|
142 | + { |
|
143 | + return $this->request_type->slug() === RequestTypeContext::CRON && ! $this->isActivation(); |
|
144 | + } |
|
145 | + |
|
146 | + |
|
147 | + /** |
|
148 | + * true if the current request is for a feed (ie: RSS) |
|
149 | + * |
|
150 | + * @return bool |
|
151 | + */ |
|
152 | + public function isFeed() |
|
153 | + { |
|
154 | + return $this->request_type->slug() === RequestTypeContext::FEED && ! $this->isActivation(); |
|
155 | + } |
|
156 | + |
|
157 | + |
|
158 | + /** |
|
159 | + * true if the current request is for the frontend and is not being made via AJAX |
|
160 | + * |
|
161 | + * @return bool |
|
162 | + */ |
|
163 | + public function isFrontend() |
|
164 | + { |
|
165 | + return $this->request_type->slug() === RequestTypeContext::FRONTEND && ! $this->isActivation(); |
|
166 | + } |
|
167 | + |
|
168 | + |
|
169 | + /** |
|
170 | + * true if the current request is for the frontend AND is being made via AJAX |
|
171 | + * |
|
172 | + * @return bool |
|
173 | + */ |
|
174 | + public function isFrontAjax() |
|
175 | + { |
|
176 | + return $this->request_type->slug() === RequestTypeContext::AJAX_FRONT && ! $this->isActivation(); |
|
177 | + } |
|
178 | + |
|
179 | + |
|
180 | + /** |
|
181 | + * true if the current request is for the EE GraphQL manager |
|
182 | + * |
|
183 | + * @return bool |
|
184 | + */ |
|
185 | + public function isGQL() |
|
186 | + { |
|
187 | + return $this->request_type->slug() === RequestTypeContext::GQL && ! $this->isActivation(); |
|
188 | + } |
|
189 | + |
|
190 | + |
|
191 | + /** |
|
192 | + * true if the current request is for content that is to be displayed within an iframe |
|
193 | + * |
|
194 | + * @return bool |
|
195 | + */ |
|
196 | + public function isIframe() |
|
197 | + { |
|
198 | + return $this->request_type->slug() === RequestTypeContext::IFRAME && ! $this->isActivation(); |
|
199 | + } |
|
200 | + |
|
201 | + |
|
202 | + /** |
|
203 | + * true if the current request is occurring while unit testing |
|
204 | + * |
|
205 | + * @return bool |
|
206 | + */ |
|
207 | + public function isUnitTesting() |
|
208 | + { |
|
209 | + return $this->request_type->isUnitTesting(); |
|
210 | + } |
|
211 | + |
|
212 | + |
|
213 | + /** |
|
214 | + * true if the current request is for the WP REST API |
|
215 | + * |
|
216 | + * @return bool |
|
217 | + */ |
|
218 | + public function isWordPressApi() |
|
219 | + { |
|
220 | + return $this->request_type->slug() === RequestTypeContext::WP_API && ! $this->isActivation(); |
|
221 | + } |
|
222 | + |
|
223 | + |
|
224 | + /** |
|
225 | + * true if the current request is being made via AJAX for the WP Heartbeat |
|
226 | + * |
|
227 | + * @return bool |
|
228 | + */ |
|
229 | + public function isWordPressHeartbeat() |
|
230 | + { |
|
231 | + return $this->request_type->slug() === RequestTypeContext::AJAX_HEARTBEAT && ! $this->isActivation(); |
|
232 | + } |
|
233 | + |
|
234 | + |
|
235 | + /** |
|
236 | + * true if the current request is a loopback sent from WP core to test for errors |
|
237 | + * |
|
238 | + * @return bool |
|
239 | + */ |
|
240 | + public function isWordPressScrape() |
|
241 | + { |
|
242 | + return $this->request_type->slug() === RequestTypeContext::WP_SCRAPE; |
|
243 | + } |
|
244 | + |
|
245 | + |
|
246 | + /** |
|
247 | + * @return string |
|
248 | + */ |
|
249 | + public function slug() |
|
250 | + { |
|
251 | + return $this->request_type->slug(); |
|
252 | + } |
|
253 | 253 | } |
@@ -30,258 +30,258 @@ |
||
30 | 30 | class CoreAssetManager extends AssetManager |
31 | 31 | { |
32 | 32 | |
33 | - // WordPress core / Third party JS asset handles |
|
34 | - const JS_HANDLE_JQUERY = 'jquery'; |
|
35 | - |
|
36 | - const JS_HANDLE_JQUERY_VALIDATE = 'jquery-validate'; |
|
37 | - |
|
38 | - const JS_HANDLE_JQUERY_VALIDATE_EXTRA = 'jquery-validate-extra-methods'; |
|
39 | - |
|
40 | - const JS_HANDLE_JS_CORE = 'eejs-core'; |
|
41 | - |
|
42 | - const JS_HANDLE_CORE = 'espresso_core'; |
|
43 | - |
|
44 | - const JS_HANDLE_I18N = 'eei18n'; |
|
45 | - |
|
46 | - const JS_HANDLE_VENDOR = 'eventespresso-vendor'; |
|
47 | - |
|
48 | - // EE CSS assets handles |
|
49 | - const CSS_HANDLE_DEFAULT = 'espresso_default'; |
|
50 | - |
|
51 | - const CSS_HANDLE_CUSTOM = 'espresso_custom_css'; |
|
52 | - |
|
53 | - /** |
|
54 | - * @var EE_Currency_Config $currency_config |
|
55 | - */ |
|
56 | - protected $currency_config; |
|
57 | - |
|
58 | - /** |
|
59 | - * @var EE_Template_Config $template_config |
|
60 | - */ |
|
61 | - protected $template_config; |
|
62 | - |
|
63 | - |
|
64 | - /** |
|
65 | - * CoreAssetRegister constructor. |
|
66 | - * |
|
67 | - * @param AssetCollection $assets |
|
68 | - * @param EE_Currency_Config $currency_config |
|
69 | - * @param EE_Template_Config $template_config |
|
70 | - * @param DomainInterface $domain |
|
71 | - * @param Registry $registry |
|
72 | - */ |
|
73 | - public function __construct( |
|
74 | - AssetCollection $assets, |
|
75 | - EE_Currency_Config $currency_config, |
|
76 | - EE_Template_Config $template_config, |
|
77 | - DomainInterface $domain, |
|
78 | - Registry $registry |
|
79 | - ) { |
|
80 | - $this->currency_config = $currency_config; |
|
81 | - $this->template_config = $template_config; |
|
82 | - parent::__construct($domain, $assets, $registry); |
|
83 | - } |
|
84 | - |
|
85 | - |
|
86 | - /** |
|
87 | - * @since 4.9.62.p |
|
88 | - * @throws DomainException |
|
89 | - * @throws DuplicateCollectionIdentifierException |
|
90 | - * @throws InvalidArgumentException |
|
91 | - * @throws InvalidDataTypeException |
|
92 | - * @throws InvalidEntityException |
|
93 | - * @throws InvalidInterfaceException |
|
94 | - */ |
|
95 | - public function addAssets() |
|
96 | - { |
|
97 | - $this->addJavascriptFiles(); |
|
98 | - $this->addStylesheetFiles(); |
|
99 | - } |
|
100 | - |
|
101 | - |
|
102 | - /** |
|
103 | - * @since 4.9.62.p |
|
104 | - * @throws DomainException |
|
105 | - * @throws DuplicateCollectionIdentifierException |
|
106 | - * @throws InvalidArgumentException |
|
107 | - * @throws InvalidDataTypeException |
|
108 | - * @throws InvalidEntityException |
|
109 | - * @throws InvalidInterfaceException |
|
110 | - */ |
|
111 | - public function addJavascriptFiles() |
|
112 | - { |
|
113 | - $this->loadCoreJs(); |
|
114 | - $this->loadJqueryValidate(); |
|
115 | - } |
|
116 | - |
|
117 | - |
|
118 | - /** |
|
119 | - * @throws DuplicateCollectionIdentifierException |
|
120 | - * @throws InvalidDataTypeException |
|
121 | - * @throws InvalidEntityException |
|
122 | - * @throws DomainException |
|
123 | - * @since 4.9.62.p |
|
124 | - */ |
|
125 | - public function addStylesheetFiles() |
|
126 | - { |
|
127 | - $this->loadCoreCss(); |
|
128 | - } |
|
129 | - |
|
130 | - |
|
131 | - /** |
|
132 | - * core default javascript |
|
133 | - * |
|
134 | - * @since 4.9.62.p |
|
135 | - * @throws DomainException |
|
136 | - * @throws DuplicateCollectionIdentifierException |
|
137 | - * @throws InvalidArgumentException |
|
138 | - * @throws InvalidDataTypeException |
|
139 | - * @throws InvalidEntityException |
|
140 | - * @throws InvalidInterfaceException |
|
141 | - */ |
|
142 | - private function loadCoreJs() |
|
143 | - { |
|
144 | - $this->addJs(CoreAssetManager::JS_HANDLE_VENDOR); |
|
145 | - $this->addJs(CoreAssetManager::JS_HANDLE_JS_CORE)->setHasInlineData(); |
|
146 | - // todo verify that the following data is no longer being used anywhere and remove |
|
147 | - $this->registry->addData('eejs_api_nonce', wp_create_nonce('wp_rest')); |
|
148 | - $this->registry->addData( |
|
149 | - 'paths', |
|
150 | - array( |
|
151 | - 'base_rest_route' => rest_url(), |
|
152 | - 'rest_route' => rest_url('ee/v4.8.36/'), |
|
153 | - 'collection_endpoints' => EED_Core_Rest_Api::getCollectionRoutesIndexedByModelName(), |
|
154 | - 'primary_keys' => EED_Core_Rest_Api::getPrimaryKeyNamesIndexedByModelName(), |
|
155 | - 'site_url' => site_url('/'), |
|
156 | - 'admin_url' => admin_url('/'), |
|
157 | - ) |
|
158 | - ); |
|
159 | - // Event Espresso brand name |
|
160 | - $this->registry->addData('brandName', Domain::brandName()); |
|
161 | - /** site formatting values **/ |
|
162 | - $this->registry->addData( |
|
163 | - 'site_formats', |
|
164 | - array( |
|
165 | - 'date_formats' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats() |
|
166 | - ) |
|
167 | - ); |
|
168 | - /** currency data **/ |
|
169 | - $this->registry->addData( |
|
170 | - 'currency_config', |
|
171 | - $this->getCurrencySettings() |
|
172 | - ); |
|
173 | - /** site timezone */ |
|
174 | - $this->registry->addData( |
|
175 | - 'default_timezone', |
|
176 | - array( |
|
177 | - 'pretty' => EEH_DTT_Helper::get_timezone_string_for_display(), |
|
178 | - 'string' => get_option('timezone_string'), |
|
179 | - 'offset' => EEH_DTT_Helper::get_site_timezone_gmt_offset(), |
|
180 | - ) |
|
181 | - ); |
|
182 | - /** site locale (user locale if user logged in) */ |
|
183 | - $this->registry->addData( |
|
184 | - 'locale', |
|
185 | - array( |
|
186 | - 'user' => get_user_locale(), |
|
187 | - 'site' => get_locale() |
|
188 | - ) |
|
189 | - ); |
|
190 | - |
|
191 | - $this->addJavascript( |
|
192 | - CoreAssetManager::JS_HANDLE_CORE, |
|
193 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
194 | - array(CoreAssetManager::JS_HANDLE_JQUERY) |
|
195 | - ); |
|
196 | - } |
|
197 | - |
|
198 | - |
|
199 | - |
|
200 | - /** |
|
201 | - * Returns configuration data for the js Currency VO. |
|
202 | - * @since 4.9.71.p |
|
203 | - * @return array |
|
204 | - */ |
|
205 | - private function getCurrencySettings() |
|
206 | - { |
|
207 | - return array( |
|
208 | - 'code' => $this->currency_config->code, |
|
209 | - 'singularLabel' => $this->currency_config->name, |
|
210 | - 'pluralLabel' => $this->currency_config->plural, |
|
211 | - 'sign' => $this->currency_config->sign, |
|
212 | - 'signB4' => $this->currency_config->sign_b4, |
|
213 | - 'decimalPlaces' => $this->currency_config->dec_plc, |
|
214 | - 'decimalMark' => $this->currency_config->dec_mrk, |
|
215 | - 'thousandsSeparator' => $this->currency_config->thsnds, |
|
216 | - ); |
|
217 | - } |
|
218 | - |
|
219 | - |
|
220 | - /** |
|
221 | - * @throws DuplicateCollectionIdentifierException |
|
222 | - * @throws InvalidDataTypeException |
|
223 | - * @throws InvalidEntityException |
|
224 | - * @throws DomainException |
|
225 | - * @since 4.9.62.p |
|
226 | - */ |
|
227 | - private function loadCoreCss() |
|
228 | - { |
|
229 | - if ($this->template_config->enable_default_style && ! is_admin()) { |
|
230 | - $this->addStylesheet( |
|
231 | - CoreAssetManager::CSS_HANDLE_DEFAULT, |
|
232 | - is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css') |
|
233 | - ? EVENT_ESPRESSO_UPLOAD_URL . 'css/espresso_default.css' |
|
234 | - : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
235 | - array('dashicons') |
|
236 | - ); |
|
237 | - //Load custom style sheet if available |
|
238 | - if ($this->template_config->custom_style_sheet !== null) { |
|
239 | - $this->addStylesheet( |
|
240 | - CoreAssetManager::CSS_HANDLE_CUSTOM, |
|
241 | - EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
242 | - array(CoreAssetManager::CSS_HANDLE_DEFAULT) |
|
243 | - ); |
|
244 | - } |
|
245 | - } |
|
246 | - } |
|
247 | - |
|
248 | - |
|
249 | - /** |
|
250 | - * jQuery Validate for form validation |
|
251 | - * |
|
252 | - * @since 4.9.62.p |
|
253 | - * @throws DomainException |
|
254 | - * @throws DuplicateCollectionIdentifierException |
|
255 | - * @throws InvalidDataTypeException |
|
256 | - * @throws InvalidEntityException |
|
257 | - */ |
|
258 | - private function loadJqueryValidate() |
|
259 | - { |
|
260 | - $this->addJavascript( |
|
261 | - CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE, |
|
262 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
263 | - array(CoreAssetManager::JS_HANDLE_JQUERY), |
|
264 | - true, |
|
265 | - '1.15.0' |
|
266 | - ); |
|
267 | - |
|
268 | - $this->addJavascript( |
|
269 | - CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA, |
|
270 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
271 | - array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE), |
|
272 | - true, |
|
273 | - '1.15.0' |
|
274 | - ); |
|
275 | - } |
|
276 | - |
|
277 | - |
|
278 | - /** |
|
279 | - * @param JavascriptAsset $script |
|
280 | - * @deprecated $VID:$ |
|
281 | - */ |
|
282 | - public function loadQtipJs(JavascriptAsset $script) |
|
283 | - { |
|
284 | - // replacement: |
|
285 | - // \EventEspresso\core\domain\services\assets\EspressoAdminAssetManager::loadQtipJs |
|
286 | - } |
|
33 | + // WordPress core / Third party JS asset handles |
|
34 | + const JS_HANDLE_JQUERY = 'jquery'; |
|
35 | + |
|
36 | + const JS_HANDLE_JQUERY_VALIDATE = 'jquery-validate'; |
|
37 | + |
|
38 | + const JS_HANDLE_JQUERY_VALIDATE_EXTRA = 'jquery-validate-extra-methods'; |
|
39 | + |
|
40 | + const JS_HANDLE_JS_CORE = 'eejs-core'; |
|
41 | + |
|
42 | + const JS_HANDLE_CORE = 'espresso_core'; |
|
43 | + |
|
44 | + const JS_HANDLE_I18N = 'eei18n'; |
|
45 | + |
|
46 | + const JS_HANDLE_VENDOR = 'eventespresso-vendor'; |
|
47 | + |
|
48 | + // EE CSS assets handles |
|
49 | + const CSS_HANDLE_DEFAULT = 'espresso_default'; |
|
50 | + |
|
51 | + const CSS_HANDLE_CUSTOM = 'espresso_custom_css'; |
|
52 | + |
|
53 | + /** |
|
54 | + * @var EE_Currency_Config $currency_config |
|
55 | + */ |
|
56 | + protected $currency_config; |
|
57 | + |
|
58 | + /** |
|
59 | + * @var EE_Template_Config $template_config |
|
60 | + */ |
|
61 | + protected $template_config; |
|
62 | + |
|
63 | + |
|
64 | + /** |
|
65 | + * CoreAssetRegister constructor. |
|
66 | + * |
|
67 | + * @param AssetCollection $assets |
|
68 | + * @param EE_Currency_Config $currency_config |
|
69 | + * @param EE_Template_Config $template_config |
|
70 | + * @param DomainInterface $domain |
|
71 | + * @param Registry $registry |
|
72 | + */ |
|
73 | + public function __construct( |
|
74 | + AssetCollection $assets, |
|
75 | + EE_Currency_Config $currency_config, |
|
76 | + EE_Template_Config $template_config, |
|
77 | + DomainInterface $domain, |
|
78 | + Registry $registry |
|
79 | + ) { |
|
80 | + $this->currency_config = $currency_config; |
|
81 | + $this->template_config = $template_config; |
|
82 | + parent::__construct($domain, $assets, $registry); |
|
83 | + } |
|
84 | + |
|
85 | + |
|
86 | + /** |
|
87 | + * @since 4.9.62.p |
|
88 | + * @throws DomainException |
|
89 | + * @throws DuplicateCollectionIdentifierException |
|
90 | + * @throws InvalidArgumentException |
|
91 | + * @throws InvalidDataTypeException |
|
92 | + * @throws InvalidEntityException |
|
93 | + * @throws InvalidInterfaceException |
|
94 | + */ |
|
95 | + public function addAssets() |
|
96 | + { |
|
97 | + $this->addJavascriptFiles(); |
|
98 | + $this->addStylesheetFiles(); |
|
99 | + } |
|
100 | + |
|
101 | + |
|
102 | + /** |
|
103 | + * @since 4.9.62.p |
|
104 | + * @throws DomainException |
|
105 | + * @throws DuplicateCollectionIdentifierException |
|
106 | + * @throws InvalidArgumentException |
|
107 | + * @throws InvalidDataTypeException |
|
108 | + * @throws InvalidEntityException |
|
109 | + * @throws InvalidInterfaceException |
|
110 | + */ |
|
111 | + public function addJavascriptFiles() |
|
112 | + { |
|
113 | + $this->loadCoreJs(); |
|
114 | + $this->loadJqueryValidate(); |
|
115 | + } |
|
116 | + |
|
117 | + |
|
118 | + /** |
|
119 | + * @throws DuplicateCollectionIdentifierException |
|
120 | + * @throws InvalidDataTypeException |
|
121 | + * @throws InvalidEntityException |
|
122 | + * @throws DomainException |
|
123 | + * @since 4.9.62.p |
|
124 | + */ |
|
125 | + public function addStylesheetFiles() |
|
126 | + { |
|
127 | + $this->loadCoreCss(); |
|
128 | + } |
|
129 | + |
|
130 | + |
|
131 | + /** |
|
132 | + * core default javascript |
|
133 | + * |
|
134 | + * @since 4.9.62.p |
|
135 | + * @throws DomainException |
|
136 | + * @throws DuplicateCollectionIdentifierException |
|
137 | + * @throws InvalidArgumentException |
|
138 | + * @throws InvalidDataTypeException |
|
139 | + * @throws InvalidEntityException |
|
140 | + * @throws InvalidInterfaceException |
|
141 | + */ |
|
142 | + private function loadCoreJs() |
|
143 | + { |
|
144 | + $this->addJs(CoreAssetManager::JS_HANDLE_VENDOR); |
|
145 | + $this->addJs(CoreAssetManager::JS_HANDLE_JS_CORE)->setHasInlineData(); |
|
146 | + // todo verify that the following data is no longer being used anywhere and remove |
|
147 | + $this->registry->addData('eejs_api_nonce', wp_create_nonce('wp_rest')); |
|
148 | + $this->registry->addData( |
|
149 | + 'paths', |
|
150 | + array( |
|
151 | + 'base_rest_route' => rest_url(), |
|
152 | + 'rest_route' => rest_url('ee/v4.8.36/'), |
|
153 | + 'collection_endpoints' => EED_Core_Rest_Api::getCollectionRoutesIndexedByModelName(), |
|
154 | + 'primary_keys' => EED_Core_Rest_Api::getPrimaryKeyNamesIndexedByModelName(), |
|
155 | + 'site_url' => site_url('/'), |
|
156 | + 'admin_url' => admin_url('/'), |
|
157 | + ) |
|
158 | + ); |
|
159 | + // Event Espresso brand name |
|
160 | + $this->registry->addData('brandName', Domain::brandName()); |
|
161 | + /** site formatting values **/ |
|
162 | + $this->registry->addData( |
|
163 | + 'site_formats', |
|
164 | + array( |
|
165 | + 'date_formats' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats() |
|
166 | + ) |
|
167 | + ); |
|
168 | + /** currency data **/ |
|
169 | + $this->registry->addData( |
|
170 | + 'currency_config', |
|
171 | + $this->getCurrencySettings() |
|
172 | + ); |
|
173 | + /** site timezone */ |
|
174 | + $this->registry->addData( |
|
175 | + 'default_timezone', |
|
176 | + array( |
|
177 | + 'pretty' => EEH_DTT_Helper::get_timezone_string_for_display(), |
|
178 | + 'string' => get_option('timezone_string'), |
|
179 | + 'offset' => EEH_DTT_Helper::get_site_timezone_gmt_offset(), |
|
180 | + ) |
|
181 | + ); |
|
182 | + /** site locale (user locale if user logged in) */ |
|
183 | + $this->registry->addData( |
|
184 | + 'locale', |
|
185 | + array( |
|
186 | + 'user' => get_user_locale(), |
|
187 | + 'site' => get_locale() |
|
188 | + ) |
|
189 | + ); |
|
190 | + |
|
191 | + $this->addJavascript( |
|
192 | + CoreAssetManager::JS_HANDLE_CORE, |
|
193 | + EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
194 | + array(CoreAssetManager::JS_HANDLE_JQUERY) |
|
195 | + ); |
|
196 | + } |
|
197 | + |
|
198 | + |
|
199 | + |
|
200 | + /** |
|
201 | + * Returns configuration data for the js Currency VO. |
|
202 | + * @since 4.9.71.p |
|
203 | + * @return array |
|
204 | + */ |
|
205 | + private function getCurrencySettings() |
|
206 | + { |
|
207 | + return array( |
|
208 | + 'code' => $this->currency_config->code, |
|
209 | + 'singularLabel' => $this->currency_config->name, |
|
210 | + 'pluralLabel' => $this->currency_config->plural, |
|
211 | + 'sign' => $this->currency_config->sign, |
|
212 | + 'signB4' => $this->currency_config->sign_b4, |
|
213 | + 'decimalPlaces' => $this->currency_config->dec_plc, |
|
214 | + 'decimalMark' => $this->currency_config->dec_mrk, |
|
215 | + 'thousandsSeparator' => $this->currency_config->thsnds, |
|
216 | + ); |
|
217 | + } |
|
218 | + |
|
219 | + |
|
220 | + /** |
|
221 | + * @throws DuplicateCollectionIdentifierException |
|
222 | + * @throws InvalidDataTypeException |
|
223 | + * @throws InvalidEntityException |
|
224 | + * @throws DomainException |
|
225 | + * @since 4.9.62.p |
|
226 | + */ |
|
227 | + private function loadCoreCss() |
|
228 | + { |
|
229 | + if ($this->template_config->enable_default_style && ! is_admin()) { |
|
230 | + $this->addStylesheet( |
|
231 | + CoreAssetManager::CSS_HANDLE_DEFAULT, |
|
232 | + is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css') |
|
233 | + ? EVENT_ESPRESSO_UPLOAD_URL . 'css/espresso_default.css' |
|
234 | + : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
235 | + array('dashicons') |
|
236 | + ); |
|
237 | + //Load custom style sheet if available |
|
238 | + if ($this->template_config->custom_style_sheet !== null) { |
|
239 | + $this->addStylesheet( |
|
240 | + CoreAssetManager::CSS_HANDLE_CUSTOM, |
|
241 | + EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
242 | + array(CoreAssetManager::CSS_HANDLE_DEFAULT) |
|
243 | + ); |
|
244 | + } |
|
245 | + } |
|
246 | + } |
|
247 | + |
|
248 | + |
|
249 | + /** |
|
250 | + * jQuery Validate for form validation |
|
251 | + * |
|
252 | + * @since 4.9.62.p |
|
253 | + * @throws DomainException |
|
254 | + * @throws DuplicateCollectionIdentifierException |
|
255 | + * @throws InvalidDataTypeException |
|
256 | + * @throws InvalidEntityException |
|
257 | + */ |
|
258 | + private function loadJqueryValidate() |
|
259 | + { |
|
260 | + $this->addJavascript( |
|
261 | + CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE, |
|
262 | + EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
263 | + array(CoreAssetManager::JS_HANDLE_JQUERY), |
|
264 | + true, |
|
265 | + '1.15.0' |
|
266 | + ); |
|
267 | + |
|
268 | + $this->addJavascript( |
|
269 | + CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA, |
|
270 | + EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
271 | + array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE), |
|
272 | + true, |
|
273 | + '1.15.0' |
|
274 | + ); |
|
275 | + } |
|
276 | + |
|
277 | + |
|
278 | + /** |
|
279 | + * @param JavascriptAsset $script |
|
280 | + * @deprecated $VID:$ |
|
281 | + */ |
|
282 | + public function loadQtipJs(JavascriptAsset $script) |
|
283 | + { |
|
284 | + // replacement: |
|
285 | + // \EventEspresso\core\domain\services\assets\EspressoAdminAssetManager::loadQtipJs |
|
286 | + } |
|
287 | 287 | } |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | |
191 | 191 | $this->addJavascript( |
192 | 192 | CoreAssetManager::JS_HANDLE_CORE, |
193 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
193 | + EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', |
|
194 | 194 | array(CoreAssetManager::JS_HANDLE_JQUERY) |
195 | 195 | ); |
196 | 196 | } |
@@ -229,16 +229,16 @@ discard block |
||
229 | 229 | if ($this->template_config->enable_default_style && ! is_admin()) { |
230 | 230 | $this->addStylesheet( |
231 | 231 | CoreAssetManager::CSS_HANDLE_DEFAULT, |
232 | - is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css') |
|
232 | + is_readable(EVENT_ESPRESSO_UPLOAD_DIR.'css/espresso_default.css') |
|
233 | 233 | ? EVENT_ESPRESSO_UPLOAD_URL . 'css/espresso_default.css' |
234 | - : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
234 | + : EE_GLOBAL_ASSETS_URL.'css/espresso_default.css', |
|
235 | 235 | array('dashicons') |
236 | 236 | ); |
237 | 237 | //Load custom style sheet if available |
238 | 238 | if ($this->template_config->custom_style_sheet !== null) { |
239 | 239 | $this->addStylesheet( |
240 | 240 | CoreAssetManager::CSS_HANDLE_CUSTOM, |
241 | - EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
241 | + EVENT_ESPRESSO_UPLOAD_URL.'css/'.$this->template_config->custom_style_sheet, |
|
242 | 242 | array(CoreAssetManager::CSS_HANDLE_DEFAULT) |
243 | 243 | ); |
244 | 244 | } |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | { |
260 | 260 | $this->addJavascript( |
261 | 261 | CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE, |
262 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
262 | + EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js', |
|
263 | 263 | array(CoreAssetManager::JS_HANDLE_JQUERY), |
264 | 264 | true, |
265 | 265 | '1.15.0' |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | |
268 | 268 | $this->addJavascript( |
269 | 269 | CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA, |
270 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
270 | + EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.additional-methods.min.js', |
|
271 | 271 | array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE), |
272 | 272 | true, |
273 | 273 | '1.15.0' |
@@ -16,28 +16,28 @@ |
||
16 | 16 | class SiteUrls extends JsonDataNode |
17 | 17 | { |
18 | 18 | |
19 | - const NODE_NAME = 'siteUrls'; |
|
20 | - |
|
21 | - |
|
22 | - /** |
|
23 | - * JsonDataNodeHandler constructor. |
|
24 | - * |
|
25 | - * @param JsonDataNodeValidator $validator |
|
26 | - */ |
|
27 | - public function __construct(JsonDataNodeValidator $validator) |
|
28 | - { |
|
29 | - parent::__construct($validator); |
|
30 | - $this->setNodeName(SiteUrls::NODE_NAME); |
|
31 | - } |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * @since $VID:$ |
|
36 | - */ |
|
37 | - public function initialize() |
|
38 | - { |
|
39 | - $this->addData('admin', admin_url('/')); |
|
40 | - $this->addData('home', site_url('/')); |
|
41 | - $this->setInitialized(true); |
|
42 | - } |
|
19 | + const NODE_NAME = 'siteUrls'; |
|
20 | + |
|
21 | + |
|
22 | + /** |
|
23 | + * JsonDataNodeHandler constructor. |
|
24 | + * |
|
25 | + * @param JsonDataNodeValidator $validator |
|
26 | + */ |
|
27 | + public function __construct(JsonDataNodeValidator $validator) |
|
28 | + { |
|
29 | + parent::__construct($validator); |
|
30 | + $this->setNodeName(SiteUrls::NODE_NAME); |
|
31 | + } |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * @since $VID:$ |
|
36 | + */ |
|
37 | + public function initialize() |
|
38 | + { |
|
39 | + $this->addData('admin', admin_url('/')); |
|
40 | + $this->addData('home', site_url('/')); |
|
41 | + $this->setInitialized(true); |
|
42 | + } |
|
43 | 43 | } |
@@ -23,82 +23,82 @@ |
||
23 | 23 | class Config extends JsonDataNode |
24 | 24 | { |
25 | 25 | |
26 | - const NODE_NAME = 'config'; |
|
26 | + const NODE_NAME = 'config'; |
|
27 | 27 | |
28 | - /** |
|
29 | - * @var CurrentUser $current_user |
|
30 | - */ |
|
31 | - private $current_user; |
|
28 | + /** |
|
29 | + * @var CurrentUser $current_user |
|
30 | + */ |
|
31 | + private $current_user; |
|
32 | 32 | |
33 | - /** |
|
34 | - * @var EspressoCoreDomain $core_domain |
|
35 | - */ |
|
36 | - private $core_domain; |
|
33 | + /** |
|
34 | + * @var EspressoCoreDomain $core_domain |
|
35 | + */ |
|
36 | + private $core_domain; |
|
37 | 37 | |
38 | - /** |
|
39 | - * @var GeneralSettings $general_settings |
|
40 | - */ |
|
41 | - private $general_settings; |
|
38 | + /** |
|
39 | + * @var GeneralSettings $general_settings |
|
40 | + */ |
|
41 | + private $general_settings; |
|
42 | 42 | |
43 | - /** |
|
44 | - * @var Locale $locale |
|
45 | - */ |
|
46 | - private $locale; |
|
43 | + /** |
|
44 | + * @var Locale $locale |
|
45 | + */ |
|
46 | + private $locale; |
|
47 | 47 | |
48 | - /** |
|
49 | - * @var SiteCurrency $site_currency |
|
50 | - */ |
|
51 | - private $site_currency; |
|
48 | + /** |
|
49 | + * @var SiteCurrency $site_currency |
|
50 | + */ |
|
51 | + private $site_currency; |
|
52 | 52 | |
53 | - /** |
|
54 | - * @var SiteUrls $site_urls |
|
55 | - */ |
|
56 | - private $site_urls; |
|
53 | + /** |
|
54 | + * @var SiteUrls $site_urls |
|
55 | + */ |
|
56 | + private $site_urls; |
|
57 | 57 | |
58 | 58 | |
59 | - /** |
|
60 | - * JsonDataNode constructor. |
|
61 | - * |
|
62 | - * @param CurrentUser $current_user |
|
63 | - * @param EspressoCoreDomain $core_domain |
|
64 | - * @param GeneralSettings $general_settings |
|
65 | - * @param Locale $locale |
|
66 | - * @param SiteCurrency $site_currency |
|
67 | - * @param SiteUrls $site_urls |
|
68 | - * @param JsonDataNodeValidator $validator |
|
69 | - */ |
|
70 | - public function __construct( |
|
71 | - CurrentUser $current_user, |
|
72 | - EspressoCoreDomain $core_domain, |
|
73 | - GeneralSettings $general_settings, |
|
74 | - Locale $locale, |
|
75 | - SiteCurrency $site_currency, |
|
76 | - SiteUrls $site_urls, |
|
77 | - JsonDataNodeValidator $validator |
|
78 | - ) { |
|
79 | - parent::__construct($validator); |
|
80 | - $this->current_user = $current_user; |
|
81 | - $this->core_domain = $core_domain; |
|
82 | - $this->general_settings = $general_settings; |
|
83 | - $this->locale = $locale; |
|
84 | - $this->site_currency = $site_currency; |
|
85 | - $this->site_urls = $site_urls; |
|
86 | - $this->setNodeName(Config::NODE_NAME); |
|
87 | - } |
|
59 | + /** |
|
60 | + * JsonDataNode constructor. |
|
61 | + * |
|
62 | + * @param CurrentUser $current_user |
|
63 | + * @param EspressoCoreDomain $core_domain |
|
64 | + * @param GeneralSettings $general_settings |
|
65 | + * @param Locale $locale |
|
66 | + * @param SiteCurrency $site_currency |
|
67 | + * @param SiteUrls $site_urls |
|
68 | + * @param JsonDataNodeValidator $validator |
|
69 | + */ |
|
70 | + public function __construct( |
|
71 | + CurrentUser $current_user, |
|
72 | + EspressoCoreDomain $core_domain, |
|
73 | + GeneralSettings $general_settings, |
|
74 | + Locale $locale, |
|
75 | + SiteCurrency $site_currency, |
|
76 | + SiteUrls $site_urls, |
|
77 | + JsonDataNodeValidator $validator |
|
78 | + ) { |
|
79 | + parent::__construct($validator); |
|
80 | + $this->current_user = $current_user; |
|
81 | + $this->core_domain = $core_domain; |
|
82 | + $this->general_settings = $general_settings; |
|
83 | + $this->locale = $locale; |
|
84 | + $this->site_currency = $site_currency; |
|
85 | + $this->site_urls = $site_urls; |
|
86 | + $this->setNodeName(Config::NODE_NAME); |
|
87 | + } |
|
88 | 88 | |
89 | 89 | |
90 | - /** |
|
91 | - * @throws DomainException |
|
92 | - * @since $VID:$ |
|
93 | - */ |
|
94 | - public function initialize() |
|
95 | - { |
|
96 | - $this->addDataNode($this->core_domain); |
|
97 | - $this->addDataNode($this->site_currency); |
|
98 | - $this->addDataNode($this->current_user); |
|
99 | - $this->addDataNode($this->general_settings); |
|
100 | - $this->addDataNode($this->locale); |
|
101 | - $this->addDataNode($this->site_urls); |
|
102 | - $this->setInitialized(true); |
|
103 | - } |
|
90 | + /** |
|
91 | + * @throws DomainException |
|
92 | + * @since $VID:$ |
|
93 | + */ |
|
94 | + public function initialize() |
|
95 | + { |
|
96 | + $this->addDataNode($this->core_domain); |
|
97 | + $this->addDataNode($this->site_currency); |
|
98 | + $this->addDataNode($this->current_user); |
|
99 | + $this->addDataNode($this->general_settings); |
|
100 | + $this->addDataNode($this->locale); |
|
101 | + $this->addDataNode($this->site_urls); |
|
102 | + $this->setInitialized(true); |
|
103 | + } |
|
104 | 104 | } |
@@ -19,34 +19,34 @@ |
||
19 | 19 | class Api extends JsonDataNode |
20 | 20 | { |
21 | 21 | |
22 | - const NODE_NAME = 'api'; |
|
23 | - |
|
24 | - |
|
25 | - /** |
|
26 | - * JsonDataNodeHandler constructor. |
|
27 | - * |
|
28 | - * @param JsonDataNodeValidator $validator |
|
29 | - */ |
|
30 | - public function __construct(JsonDataNodeValidator $validator) |
|
31 | - { |
|
32 | - parent::__construct($validator); |
|
33 | - $this->setNodeName(Api::NODE_NAME); |
|
34 | - } |
|
35 | - |
|
36 | - |
|
37 | - /** |
|
38 | - * @throws DomainException |
|
39 | - * @since $VID:$ |
|
40 | - */ |
|
41 | - public function initialize() |
|
42 | - { |
|
43 | - $this->addData('restApiNonce', wp_create_nonce('wp_rest')); |
|
44 | - $this->addData('restApiBaseUrl', rest_url()); |
|
45 | - $this->addData('restApiRouteUrl', rest_url('ee/v4.8.36/')); |
|
46 | - $this->addData('restApiCollectionEndpoints', EED_Core_Rest_Api::getCollectionRoutesIndexedByModelName()); |
|
47 | - $this->addData('restApiPrimaryKeys', EED_Core_Rest_Api::getPrimaryKeyNamesIndexedByModelName()); |
|
48 | - $graphqlEndpoint = class_exists('WPGraphQL') ? trailingslashit(site_url()) . Router::$route : ''; |
|
49 | - $this->addData('graphqlEndpoint', esc_url($graphqlEndpoint)); |
|
50 | - $this->setInitialized(true); |
|
51 | - } |
|
22 | + const NODE_NAME = 'api'; |
|
23 | + |
|
24 | + |
|
25 | + /** |
|
26 | + * JsonDataNodeHandler constructor. |
|
27 | + * |
|
28 | + * @param JsonDataNodeValidator $validator |
|
29 | + */ |
|
30 | + public function __construct(JsonDataNodeValidator $validator) |
|
31 | + { |
|
32 | + parent::__construct($validator); |
|
33 | + $this->setNodeName(Api::NODE_NAME); |
|
34 | + } |
|
35 | + |
|
36 | + |
|
37 | + /** |
|
38 | + * @throws DomainException |
|
39 | + * @since $VID:$ |
|
40 | + */ |
|
41 | + public function initialize() |
|
42 | + { |
|
43 | + $this->addData('restApiNonce', wp_create_nonce('wp_rest')); |
|
44 | + $this->addData('restApiBaseUrl', rest_url()); |
|
45 | + $this->addData('restApiRouteUrl', rest_url('ee/v4.8.36/')); |
|
46 | + $this->addData('restApiCollectionEndpoints', EED_Core_Rest_Api::getCollectionRoutesIndexedByModelName()); |
|
47 | + $this->addData('restApiPrimaryKeys', EED_Core_Rest_Api::getPrimaryKeyNamesIndexedByModelName()); |
|
48 | + $graphqlEndpoint = class_exists('WPGraphQL') ? trailingslashit(site_url()) . Router::$route : ''; |
|
49 | + $this->addData('graphqlEndpoint', esc_url($graphqlEndpoint)); |
|
50 | + $this->setInitialized(true); |
|
51 | + } |
|
52 | 52 | } |
@@ -45,7 +45,7 @@ |
||
45 | 45 | $this->addData('restApiRouteUrl', rest_url('ee/v4.8.36/')); |
46 | 46 | $this->addData('restApiCollectionEndpoints', EED_Core_Rest_Api::getCollectionRoutesIndexedByModelName()); |
47 | 47 | $this->addData('restApiPrimaryKeys', EED_Core_Rest_Api::getPrimaryKeyNamesIndexedByModelName()); |
48 | - $graphqlEndpoint = class_exists('WPGraphQL') ? trailingslashit(site_url()) . Router::$route : ''; |
|
48 | + $graphqlEndpoint = class_exists('WPGraphQL') ? trailingslashit(site_url()).Router::$route : ''; |
|
49 | 49 | $this->addData('graphqlEndpoint', esc_url($graphqlEndpoint)); |
50 | 50 | $this->setInitialized(true); |
51 | 51 | } |
@@ -16,84 +16,84 @@ |
||
16 | 16 | class PersonalDataRequests extends PublicRoute |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * returns true if the current request matches this route |
|
21 | - * |
|
22 | - * @return bool |
|
23 | - * @since $VID:$ |
|
24 | - */ |
|
25 | - public function matchesCurrentRequest() |
|
26 | - { |
|
27 | - return ($this->request->isAdmin() || $this->request->isAjax()) && $this->maintenance_mode->models_can_query(); |
|
28 | - } |
|
19 | + /** |
|
20 | + * returns true if the current request matches this route |
|
21 | + * |
|
22 | + * @return bool |
|
23 | + * @since $VID:$ |
|
24 | + */ |
|
25 | + public function matchesCurrentRequest() |
|
26 | + { |
|
27 | + return ($this->request->isAdmin() || $this->request->isAjax()) && $this->maintenance_mode->models_can_query(); |
|
28 | + } |
|
29 | 29 | |
30 | 30 | |
31 | - /** |
|
32 | - * @since $VID:$ |
|
33 | - */ |
|
34 | - protected function registerDependencies() |
|
35 | - { |
|
36 | - $this->dependency_map->registerDependencies( |
|
37 | - 'EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy', |
|
38 | - [ |
|
39 | - 'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache, |
|
40 | - 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache |
|
41 | - ] |
|
42 | - ); |
|
43 | - $this->dependency_map->registerDependencies( |
|
44 | - 'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendee', |
|
45 | - ['EEM_Attendee' => EE_Dependency_Map::load_from_cache] |
|
46 | - ); |
|
47 | - $this->dependency_map->registerDependencies( |
|
48 | - 'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendeeBillingData', |
|
49 | - [ |
|
50 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
51 | - 'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache |
|
52 | - ] |
|
53 | - ); |
|
54 | - $this->dependency_map->registerDependencies( |
|
55 | - 'EventEspresso\core\domain\services\admin\privacy\export\ExportCheckins', |
|
56 | - ['EEM_Checkin' => EE_Dependency_Map::load_from_cache] |
|
57 | - ); |
|
58 | - $this->dependency_map->registerDependencies( |
|
59 | - 'EventEspresso\core\domain\services\admin\privacy\export\ExportRegistration', |
|
60 | - ['EEM_Registration' => EE_Dependency_Map::load_from_cache] |
|
61 | - ); |
|
62 | - $this->dependency_map->registerDependencies( |
|
63 | - 'EventEspresso\core\domain\services\admin\privacy\export\ExportTransaction', |
|
64 | - ['EEM_Transaction' => EE_Dependency_Map::load_from_cache] |
|
65 | - ); |
|
66 | - $this->dependency_map->registerDependencies( |
|
67 | - 'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAttendeeData', |
|
68 | - ['EEM_Attendee' => EE_Dependency_Map::load_from_cache] |
|
69 | - ); |
|
70 | - $this->dependency_map->registerDependencies( |
|
71 | - 'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAnswers', |
|
72 | - [ |
|
73 | - 'EEM_Answer' => EE_Dependency_Map::load_from_cache, |
|
74 | - 'EEM_Question' => EE_Dependency_Map::load_from_cache, |
|
75 | - ] |
|
76 | - ); |
|
77 | - $this->dependency_map->registerDependencies( |
|
78 | - 'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler', |
|
79 | - [ |
|
80 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
81 | - 'EE_Config' => EE_Dependency_Map::load_from_cache |
|
82 | - ] |
|
83 | - ); |
|
84 | - } |
|
31 | + /** |
|
32 | + * @since $VID:$ |
|
33 | + */ |
|
34 | + protected function registerDependencies() |
|
35 | + { |
|
36 | + $this->dependency_map->registerDependencies( |
|
37 | + 'EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy', |
|
38 | + [ |
|
39 | + 'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache, |
|
40 | + 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache |
|
41 | + ] |
|
42 | + ); |
|
43 | + $this->dependency_map->registerDependencies( |
|
44 | + 'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendee', |
|
45 | + ['EEM_Attendee' => EE_Dependency_Map::load_from_cache] |
|
46 | + ); |
|
47 | + $this->dependency_map->registerDependencies( |
|
48 | + 'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendeeBillingData', |
|
49 | + [ |
|
50 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
51 | + 'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache |
|
52 | + ] |
|
53 | + ); |
|
54 | + $this->dependency_map->registerDependencies( |
|
55 | + 'EventEspresso\core\domain\services\admin\privacy\export\ExportCheckins', |
|
56 | + ['EEM_Checkin' => EE_Dependency_Map::load_from_cache] |
|
57 | + ); |
|
58 | + $this->dependency_map->registerDependencies( |
|
59 | + 'EventEspresso\core\domain\services\admin\privacy\export\ExportRegistration', |
|
60 | + ['EEM_Registration' => EE_Dependency_Map::load_from_cache] |
|
61 | + ); |
|
62 | + $this->dependency_map->registerDependencies( |
|
63 | + 'EventEspresso\core\domain\services\admin\privacy\export\ExportTransaction', |
|
64 | + ['EEM_Transaction' => EE_Dependency_Map::load_from_cache] |
|
65 | + ); |
|
66 | + $this->dependency_map->registerDependencies( |
|
67 | + 'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAttendeeData', |
|
68 | + ['EEM_Attendee' => EE_Dependency_Map::load_from_cache] |
|
69 | + ); |
|
70 | + $this->dependency_map->registerDependencies( |
|
71 | + 'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAnswers', |
|
72 | + [ |
|
73 | + 'EEM_Answer' => EE_Dependency_Map::load_from_cache, |
|
74 | + 'EEM_Question' => EE_Dependency_Map::load_from_cache, |
|
75 | + ] |
|
76 | + ); |
|
77 | + $this->dependency_map->registerDependencies( |
|
78 | + 'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler', |
|
79 | + [ |
|
80 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
81 | + 'EE_Config' => EE_Dependency_Map::load_from_cache |
|
82 | + ] |
|
83 | + ); |
|
84 | + } |
|
85 | 85 | |
86 | 86 | |
87 | - /** |
|
88 | - * implements logic required to run during request |
|
89 | - * |
|
90 | - * @return bool |
|
91 | - * @since $VID:$ |
|
92 | - */ |
|
93 | - protected function requestHandler() |
|
94 | - { |
|
95 | - $this->loader->getShared('EventEspresso\core\services\privacy\erasure\PersonalDataEraserManager'); |
|
96 | - $this->loader->getShared('EventEspresso\core\services\privacy\export\PersonalDataExporterManager'); |
|
97 | - return true; |
|
98 | - } |
|
87 | + /** |
|
88 | + * implements logic required to run during request |
|
89 | + * |
|
90 | + * @return bool |
|
91 | + * @since $VID:$ |
|
92 | + */ |
|
93 | + protected function requestHandler() |
|
94 | + { |
|
95 | + $this->loader->getShared('EventEspresso\core\services\privacy\erasure\PersonalDataEraserManager'); |
|
96 | + $this->loader->getShared('EventEspresso\core\services\privacy\export\PersonalDataExporterManager'); |
|
97 | + return true; |
|
98 | + } |
|
99 | 99 | } |
@@ -16,46 +16,46 @@ |
||
16 | 16 | { |
17 | 17 | |
18 | 18 | |
19 | - /** |
|
20 | - * returns true if the current request matches this route |
|
21 | - * child classes can override and use Request directly to match route with request |
|
22 | - * or supply a RouteMatchSpecification class and just use the below |
|
23 | - * |
|
24 | - * @return bool |
|
25 | - * @since $VID:$ |
|
26 | - */ |
|
27 | - public function matchesCurrentRequest() |
|
28 | - { |
|
29 | - return ($this->request->isFrontend() || $this->request->isFrontAjax()) && ! $this->maintenance_mode->level(); |
|
30 | - } |
|
31 | - |
|
32 | - |
|
33 | - /** |
|
34 | - * @since $VID:$ |
|
35 | - */ |
|
36 | - protected function registerDependencies() |
|
37 | - { |
|
38 | - $this->dependency_map->registerDependencies( |
|
39 | - 'EE_Front_Controller', |
|
40 | - [ |
|
41 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
42 | - 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
43 | - 'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache, |
|
44 | - ] |
|
45 | - ); |
|
46 | - } |
|
47 | - |
|
48 | - |
|
49 | - /** |
|
50 | - * implements logic required to run during request |
|
51 | - * |
|
52 | - * @return bool |
|
53 | - * @since $VID:$ |
|
54 | - */ |
|
55 | - protected function requestHandler() |
|
56 | - { |
|
57 | - do_action('AHEE__EE_System__load_controllers__load_front_controllers'); |
|
58 | - $this->loader->getShared('EE_Front_Controller'); |
|
59 | - return true; |
|
60 | - } |
|
19 | + /** |
|
20 | + * returns true if the current request matches this route |
|
21 | + * child classes can override and use Request directly to match route with request |
|
22 | + * or supply a RouteMatchSpecification class and just use the below |
|
23 | + * |
|
24 | + * @return bool |
|
25 | + * @since $VID:$ |
|
26 | + */ |
|
27 | + public function matchesCurrentRequest() |
|
28 | + { |
|
29 | + return ($this->request->isFrontend() || $this->request->isFrontAjax()) && ! $this->maintenance_mode->level(); |
|
30 | + } |
|
31 | + |
|
32 | + |
|
33 | + /** |
|
34 | + * @since $VID:$ |
|
35 | + */ |
|
36 | + protected function registerDependencies() |
|
37 | + { |
|
38 | + $this->dependency_map->registerDependencies( |
|
39 | + 'EE_Front_Controller', |
|
40 | + [ |
|
41 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
42 | + 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
43 | + 'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache, |
|
44 | + ] |
|
45 | + ); |
|
46 | + } |
|
47 | + |
|
48 | + |
|
49 | + /** |
|
50 | + * implements logic required to run during request |
|
51 | + * |
|
52 | + * @return bool |
|
53 | + * @since $VID:$ |
|
54 | + */ |
|
55 | + protected function requestHandler() |
|
56 | + { |
|
57 | + do_action('AHEE__EE_System__load_controllers__load_front_controllers'); |
|
58 | + $this->loader->getShared('EE_Front_Controller'); |
|
59 | + return true; |
|
60 | + } |
|
61 | 61 | } |