Completed
Branch EDTR/refactor-master (3ca05b)
by
unknown
21:31 queued 11:45
created
admin_pages/events/Events_Admin_Page.core.php 1 patch
Indentation   +2843 added lines, -2843 removed lines patch added patch discarded remove patch
@@ -15,2847 +15,2847 @@
 block discarded – undo
15 15
 class Events_Admin_Page extends EE_Admin_Page_CPT
16 16
 {
17 17
 
18
-    /**
19
-     * This will hold the event object for event_details screen.
20
-     *
21
-     * @access protected
22
-     * @var EE_Event $_event
23
-     */
24
-    protected $_event;
25
-
26
-
27
-    /**
28
-     * This will hold the category object for category_details screen.
29
-     *
30
-     * @var stdClass $_category
31
-     */
32
-    protected $_category;
33
-
34
-
35
-    /**
36
-     * This will hold the event model instance
37
-     *
38
-     * @var EEM_Event $_event_model
39
-     */
40
-    protected $_event_model;
41
-
42
-
43
-    /**
44
-     * @var EE_Event
45
-     */
46
-    protected $_cpt_model_obj = false;
47
-
48
-
49
-    /**
50
-     * Initialize page props for this admin page group.
51
-     */
52
-    protected function _init_page_props()
53
-    {
54
-        $this->page_slug = EVENTS_PG_SLUG;
55
-        $this->page_label = EVENTS_LABEL;
56
-        $this->_admin_base_url = EVENTS_ADMIN_URL;
57
-        $this->_admin_base_path = EVENTS_ADMIN;
58
-        $this->_cpt_model_names = array(
59
-            'create_new' => 'EEM_Event',
60
-            'edit'       => 'EEM_Event',
61
-        );
62
-        $this->_cpt_edit_routes = array(
63
-            'espresso_events' => 'edit',
64
-        );
65
-        add_action(
66
-            'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object',
67
-            array($this, 'verify_event_edit'),
68
-            10,
69
-            2
70
-        );
71
-    }
72
-
73
-
74
-    /**
75
-     * Sets the ajax hooks used for this admin page group.
76
-     */
77
-    protected function _ajax_hooks()
78
-    {
79
-        add_action('wp_ajax_ee_save_timezone_setting', array($this, 'save_timezonestring_setting'));
80
-    }
81
-
82
-
83
-    /**
84
-     * Sets the page properties for this admin page group.
85
-     */
86
-    protected function _define_page_props()
87
-    {
88
-        $this->_admin_page_title = EVENTS_LABEL;
89
-        $this->_labels = array(
90
-            'buttons'      => array(
91
-                'add'             => esc_html__('Add New Event', 'event_espresso'),
92
-                'edit'            => esc_html__('Edit Event', 'event_espresso'),
93
-                'delete'          => esc_html__('Delete Event', 'event_espresso'),
94
-                'add_category'    => esc_html__('Add New Category', 'event_espresso'),
95
-                'edit_category'   => esc_html__('Edit Category', 'event_espresso'),
96
-                'delete_category' => esc_html__('Delete Category', 'event_espresso'),
97
-            ),
98
-            'editor_title' => array(
99
-                'espresso_events' => esc_html__('Enter event title here', 'event_espresso'),
100
-            ),
101
-            'publishbox'   => array(
102
-                'create_new'        => esc_html__('Save New Event', 'event_espresso'),
103
-                'edit'              => esc_html__('Update Event', 'event_espresso'),
104
-                'add_category'      => esc_html__('Save New Category', 'event_espresso'),
105
-                'edit_category'     => esc_html__('Update Category', 'event_espresso'),
106
-                'template_settings' => esc_html__('Update Settings', 'event_espresso'),
107
-            ),
108
-        );
109
-    }
110
-
111
-
112
-    /**
113
-     * Sets the page routes property for this admin page group.
114
-     */
115
-    protected function _set_page_routes()
116
-    {
117
-        // load formatter helper
118
-        // load field generator helper
119
-        // is there a evt_id in the request?
120
-        $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID'])
121
-            ? $this->_req_data['EVT_ID']
122
-            : 0;
123
-        $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id;
124
-        $this->_page_routes = array(
125
-            'default'                       => array(
126
-                'func'       => '_events_overview_list_table',
127
-                'capability' => 'ee_read_events',
128
-            ),
129
-            'create_new'                    => array(
130
-                'func'       => '_create_new_cpt_item',
131
-                'capability' => 'ee_edit_events',
132
-            ),
133
-            'edit'                          => array(
134
-                'func'       => '_edit_cpt_item',
135
-                'capability' => 'ee_edit_event',
136
-                'obj_id'     => $evt_id,
137
-            ),
138
-            'copy_event'                    => array(
139
-                'func'       => '_copy_events',
140
-                'capability' => 'ee_edit_event',
141
-                'obj_id'     => $evt_id,
142
-                'noheader'   => true,
143
-            ),
144
-            'trash_event'                   => array(
145
-                'func'       => '_trash_or_restore_event',
146
-                'args'       => array('event_status' => 'trash'),
147
-                'capability' => 'ee_delete_event',
148
-                'obj_id'     => $evt_id,
149
-                'noheader'   => true,
150
-            ),
151
-            'trash_events'                  => array(
152
-                'func'       => '_trash_or_restore_events',
153
-                'args'       => array('event_status' => 'trash'),
154
-                'capability' => 'ee_delete_events',
155
-                'noheader'   => true,
156
-            ),
157
-            'restore_event'                 => array(
158
-                'func'       => '_trash_or_restore_event',
159
-                'args'       => array('event_status' => 'draft'),
160
-                'capability' => 'ee_delete_event',
161
-                'obj_id'     => $evt_id,
162
-                'noheader'   => true,
163
-            ),
164
-            'restore_events'                => array(
165
-                'func'       => '_trash_or_restore_events',
166
-                'args'       => array('event_status' => 'draft'),
167
-                'capability' => 'ee_delete_events',
168
-                'noheader'   => true,
169
-            ),
170
-            'delete_event'                  => array(
171
-                'func'       => '_delete_event',
172
-                'capability' => 'ee_delete_event',
173
-                'obj_id'     => $evt_id,
174
-                'noheader'   => true,
175
-            ),
176
-            'delete_events'                 => array(
177
-                'func'       => '_delete_events',
178
-                'capability' => 'ee_delete_events',
179
-                'noheader'   => true,
180
-            ),
181
-            'view_report'                   => array(
182
-                'func'      => '_view_report',
183
-                'capability' => 'ee_edit_events',
184
-            ),
185
-            'default_event_settings'        => array(
186
-                'func'       => '_default_event_settings',
187
-                'capability' => 'manage_options',
188
-            ),
189
-            'update_default_event_settings' => array(
190
-                'func'       => '_update_default_event_settings',
191
-                'capability' => 'manage_options',
192
-                'noheader'   => true,
193
-            ),
194
-            'template_settings'             => array(
195
-                'func'       => '_template_settings',
196
-                'capability' => 'manage_options',
197
-            ),
198
-            // event category tab related
199
-            'add_category'                  => array(
200
-                'func'       => '_category_details',
201
-                'capability' => 'ee_edit_event_category',
202
-                'args'       => array('add'),
203
-            ),
204
-            'edit_category'                 => array(
205
-                'func'       => '_category_details',
206
-                'capability' => 'ee_edit_event_category',
207
-                'args'       => array('edit'),
208
-            ),
209
-            'delete_categories'             => array(
210
-                'func'       => '_delete_categories',
211
-                'capability' => 'ee_delete_event_category',
212
-                'noheader'   => true,
213
-            ),
214
-            'delete_category'               => array(
215
-                'func'       => '_delete_categories',
216
-                'capability' => 'ee_delete_event_category',
217
-                'noheader'   => true,
218
-            ),
219
-            'insert_category'               => array(
220
-                'func'       => '_insert_or_update_category',
221
-                'args'       => array('new_category' => true),
222
-                'capability' => 'ee_edit_event_category',
223
-                'noheader'   => true,
224
-            ),
225
-            'update_category'               => array(
226
-                'func'       => '_insert_or_update_category',
227
-                'args'       => array('new_category' => false),
228
-                'capability' => 'ee_edit_event_category',
229
-                'noheader'   => true,
230
-            ),
231
-            'category_list'                 => array(
232
-                'func'       => '_category_list_table',
233
-                'capability' => 'ee_manage_event_categories',
234
-            ),
235
-        );
236
-    }
237
-
238
-
239
-    /**
240
-     * Set the _page_config property for this admin page group.
241
-     */
242
-    protected function _set_page_config()
243
-    {
244
-        $this->_page_config = array(
245
-            'default'                => array(
246
-                'nav'           => array(
247
-                    'label' => esc_html__('Overview', 'event_espresso'),
248
-                    'order' => 10,
249
-                ),
250
-                'list_table'    => 'Events_Admin_List_Table',
251
-                'help_tabs'     => array(
252
-                    'events_overview_help_tab'                       => array(
253
-                        'title'    => esc_html__('Events Overview', 'event_espresso'),
254
-                        'filename' => 'events_overview',
255
-                    ),
256
-                    'events_overview_table_column_headings_help_tab' => array(
257
-                        'title'    => esc_html__('Events Overview Table Column Headings', 'event_espresso'),
258
-                        'filename' => 'events_overview_table_column_headings',
259
-                    ),
260
-                    'events_overview_filters_help_tab'               => array(
261
-                        'title'    => esc_html__('Events Overview Filters', 'event_espresso'),
262
-                        'filename' => 'events_overview_filters',
263
-                    ),
264
-                    'events_overview_view_help_tab'                  => array(
265
-                        'title'    => esc_html__('Events Overview Views', 'event_espresso'),
266
-                        'filename' => 'events_overview_views',
267
-                    ),
268
-                    'events_overview_other_help_tab'                 => array(
269
-                        'title'    => esc_html__('Events Overview Other', 'event_espresso'),
270
-                        'filename' => 'events_overview_other',
271
-                    ),
272
-                ),
273
-                'help_tour'     => array(
274
-                    'Event_Overview_Help_Tour',
275
-                    // 'New_Features_Test_Help_Tour' for testing multiple help tour
276
-                ),
277
-                'qtips'         => array(
278
-                    'EE_Event_List_Table_Tips',
279
-                ),
280
-                'require_nonce' => false,
281
-            ),
282
-            'create_new'             => array(
283
-                'nav'           => array(
284
-                    'label'      => esc_html__('Add Event', 'event_espresso'),
285
-                    'order'      => 5,
286
-                    'persistent' => false,
287
-                ),
288
-                'metaboxes'     => array('_register_event_editor_meta_boxes'),
289
-                'help_tabs'     => array(
290
-                    'event_editor_help_tab'                            => array(
291
-                        'title'    => esc_html__('Event Editor', 'event_espresso'),
292
-                        'filename' => 'event_editor',
293
-                    ),
294
-                    'event_editor_title_richtexteditor_help_tab'       => array(
295
-                        'title'    => esc_html__('Event Title & Rich Text Editor', 'event_espresso'),
296
-                        'filename' => 'event_editor_title_richtexteditor',
297
-                    ),
298
-                    'event_editor_venue_details_help_tab'              => array(
299
-                        'title'    => esc_html__('Event Venue Details', 'event_espresso'),
300
-                        'filename' => 'event_editor_venue_details',
301
-                    ),
302
-                    'event_editor_event_datetimes_help_tab'            => array(
303
-                        'title'    => esc_html__('Event Datetimes', 'event_espresso'),
304
-                        'filename' => 'event_editor_event_datetimes',
305
-                    ),
306
-                    'event_editor_event_tickets_help_tab'              => array(
307
-                        'title'    => esc_html__('Event Tickets', 'event_espresso'),
308
-                        'filename' => 'event_editor_event_tickets',
309
-                    ),
310
-                    'event_editor_event_registration_options_help_tab' => array(
311
-                        'title'    => esc_html__('Event Registration Options', 'event_espresso'),
312
-                        'filename' => 'event_editor_event_registration_options',
313
-                    ),
314
-                    'event_editor_tags_categories_help_tab'            => array(
315
-                        'title'    => esc_html__('Event Tags & Categories', 'event_espresso'),
316
-                        'filename' => 'event_editor_tags_categories',
317
-                    ),
318
-                    'event_editor_questions_registrants_help_tab'      => array(
319
-                        'title'    => esc_html__('Questions for Registrants', 'event_espresso'),
320
-                        'filename' => 'event_editor_questions_registrants',
321
-                    ),
322
-                    'event_editor_save_new_event_help_tab'             => array(
323
-                        'title'    => esc_html__('Save New Event', 'event_espresso'),
324
-                        'filename' => 'event_editor_save_new_event',
325
-                    ),
326
-                    'event_editor_other_help_tab'                      => array(
327
-                        'title'    => esc_html__('Event Other', 'event_espresso'),
328
-                        'filename' => 'event_editor_other',
329
-                    ),
330
-                ),
331
-                'help_tour'     => array(
332
-                    'Event_Editor_Help_Tour',
333
-                ),
334
-                'qtips'         => array('EE_Event_Editor_Decaf_Tips'),
335
-                'require_nonce' => false,
336
-            ),
337
-            'edit'                   => array(
338
-                'nav'           => array(
339
-                    'label'      => esc_html__('Edit Event', 'event_espresso'),
340
-                    'order'      => 5,
341
-                    'persistent' => false,
342
-                    'url'        => isset($this->_req_data['post'])
343
-                        ? EE_Admin_Page::add_query_args_and_nonce(
344
-                            array('post' => $this->_req_data['post'], 'action' => 'edit'),
345
-                            $this->_current_page_view_url
346
-                        )
347
-                        : $this->_admin_base_url,
348
-                ),
349
-                'metaboxes'     => array('_register_event_editor_meta_boxes'),
350
-                'help_tabs'     => array(
351
-                    'event_editor_help_tab'                            => array(
352
-                        'title'    => esc_html__('Event Editor', 'event_espresso'),
353
-                        'filename' => 'event_editor',
354
-                    ),
355
-                    'event_editor_title_richtexteditor_help_tab'       => array(
356
-                        'title'    => esc_html__('Event Title & Rich Text Editor', 'event_espresso'),
357
-                        'filename' => 'event_editor_title_richtexteditor',
358
-                    ),
359
-                    'event_editor_venue_details_help_tab'              => array(
360
-                        'title'    => esc_html__('Event Venue Details', 'event_espresso'),
361
-                        'filename' => 'event_editor_venue_details',
362
-                    ),
363
-                    'event_editor_event_datetimes_help_tab'            => array(
364
-                        'title'    => esc_html__('Event Datetimes', 'event_espresso'),
365
-                        'filename' => 'event_editor_event_datetimes',
366
-                    ),
367
-                    'event_editor_event_tickets_help_tab'              => array(
368
-                        'title'    => esc_html__('Event Tickets', 'event_espresso'),
369
-                        'filename' => 'event_editor_event_tickets',
370
-                    ),
371
-                    'event_editor_event_registration_options_help_tab' => array(
372
-                        'title'    => esc_html__('Event Registration Options', 'event_espresso'),
373
-                        'filename' => 'event_editor_event_registration_options',
374
-                    ),
375
-                    'event_editor_tags_categories_help_tab'            => array(
376
-                        'title'    => esc_html__('Event Tags & Categories', 'event_espresso'),
377
-                        'filename' => 'event_editor_tags_categories',
378
-                    ),
379
-                    'event_editor_questions_registrants_help_tab'      => array(
380
-                        'title'    => esc_html__('Questions for Registrants', 'event_espresso'),
381
-                        'filename' => 'event_editor_questions_registrants',
382
-                    ),
383
-                    'event_editor_save_new_event_help_tab'             => array(
384
-                        'title'    => esc_html__('Save New Event', 'event_espresso'),
385
-                        'filename' => 'event_editor_save_new_event',
386
-                    ),
387
-                    'event_editor_other_help_tab'                      => array(
388
-                        'title'    => esc_html__('Event Other', 'event_espresso'),
389
-                        'filename' => 'event_editor_other',
390
-                    ),
391
-                ),
392
-                'qtips'         => array('EE_Event_Editor_Decaf_Tips'),
393
-                'require_nonce' => false,
394
-            ),
395
-            'default_event_settings' => array(
396
-                'nav'           => array(
397
-                    'label' => esc_html__('Default Settings', 'event_espresso'),
398
-                    'order' => 40,
399
-                ),
400
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
401
-                'labels'        => array(
402
-                    'publishbox' => esc_html__('Update Settings', 'event_espresso'),
403
-                ),
404
-                'help_tabs'     => array(
405
-                    'default_settings_help_tab'        => array(
406
-                        'title'    => esc_html__('Default Event Settings', 'event_espresso'),
407
-                        'filename' => 'events_default_settings',
408
-                    ),
409
-                    'default_settings_status_help_tab' => array(
410
-                        'title'    => esc_html__('Default Registration Status', 'event_espresso'),
411
-                        'filename' => 'events_default_settings_status',
412
-                    ),
413
-                    'default_maximum_tickets_help_tab' => array(
414
-                        'title'    => esc_html__('Default Maximum Tickets Per Order', 'event_espresso'),
415
-                        'filename' => 'events_default_settings_max_tickets',
416
-                    ),
417
-                ),
418
-                'help_tour'     => array('Event_Default_Settings_Help_Tour'),
419
-                'require_nonce' => false,
420
-            ),
421
-            // template settings
422
-            'template_settings'      => array(
423
-                'nav'           => array(
424
-                    'label' => esc_html__('Templates', 'event_espresso'),
425
-                    'order' => 30,
426
-                ),
427
-                'metaboxes'     => $this->_default_espresso_metaboxes,
428
-                'help_tabs'     => array(
429
-                    'general_settings_templates_help_tab' => array(
430
-                        'title'    => esc_html__('Templates', 'event_espresso'),
431
-                        'filename' => 'general_settings_templates',
432
-                    ),
433
-                ),
434
-                'help_tour'     => array('Templates_Help_Tour'),
435
-                'require_nonce' => false,
436
-            ),
437
-            // event category stuff
438
-            'add_category'           => array(
439
-                'nav'           => array(
440
-                    'label'      => esc_html__('Add Category', 'event_espresso'),
441
-                    'order'      => 15,
442
-                    'persistent' => false,
443
-                ),
444
-                'help_tabs'     => array(
445
-                    'add_category_help_tab' => array(
446
-                        'title'    => esc_html__('Add New Event Category', 'event_espresso'),
447
-                        'filename' => 'events_add_category',
448
-                    ),
449
-                ),
450
-                'help_tour'     => array('Event_Add_Category_Help_Tour'),
451
-                'metaboxes'     => array('_publish_post_box'),
452
-                'require_nonce' => false,
453
-            ),
454
-            'edit_category'          => array(
455
-                'nav'           => array(
456
-                    'label'      => esc_html__('Edit Category', 'event_espresso'),
457
-                    'order'      => 15,
458
-                    'persistent' => false,
459
-                    'url'        => isset($this->_req_data['EVT_CAT_ID'])
460
-                        ? add_query_arg(
461
-                            array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']),
462
-                            $this->_current_page_view_url
463
-                        )
464
-                        : $this->_admin_base_url,
465
-                ),
466
-                'help_tabs'     => array(
467
-                    'edit_category_help_tab' => array(
468
-                        'title'    => esc_html__('Edit Event Category', 'event_espresso'),
469
-                        'filename' => 'events_edit_category',
470
-                    ),
471
-                ),
472
-                /*'help_tour' => array('Event_Edit_Category_Help_Tour'),*/
473
-                'metaboxes'     => array('_publish_post_box'),
474
-                'require_nonce' => false,
475
-            ),
476
-            'category_list'          => array(
477
-                'nav'           => array(
478
-                    'label' => esc_html__('Categories', 'event_espresso'),
479
-                    'order' => 20,
480
-                ),
481
-                'list_table'    => 'Event_Categories_Admin_List_Table',
482
-                'help_tabs'     => array(
483
-                    'events_categories_help_tab'                       => array(
484
-                        'title'    => esc_html__('Event Categories', 'event_espresso'),
485
-                        'filename' => 'events_categories',
486
-                    ),
487
-                    'events_categories_table_column_headings_help_tab' => array(
488
-                        'title'    => esc_html__('Event Categories Table Column Headings', 'event_espresso'),
489
-                        'filename' => 'events_categories_table_column_headings',
490
-                    ),
491
-                    'events_categories_view_help_tab'                  => array(
492
-                        'title'    => esc_html__('Event Categories Views', 'event_espresso'),
493
-                        'filename' => 'events_categories_views',
494
-                    ),
495
-                    'events_categories_other_help_tab'                 => array(
496
-                        'title'    => esc_html__('Event Categories Other', 'event_espresso'),
497
-                        'filename' => 'events_categories_other',
498
-                    ),
499
-                ),
500
-                'help_tour'     => array(
501
-                    'Event_Categories_Help_Tour',
502
-                ),
503
-                'metaboxes'     => $this->_default_espresso_metaboxes,
504
-                'require_nonce' => false,
505
-            ),
506
-        );
507
-    }
508
-
509
-
510
-    /**
511
-     * Used to register any global screen options if necessary for every route in this admin page group.
512
-     */
513
-    protected function _add_screen_options()
514
-    {
515
-    }
516
-
517
-
518
-    /**
519
-     * Implementing the screen options for the 'default' route.
520
-     *
521
-     * @throws InvalidArgumentException
522
-     * @throws InvalidDataTypeException
523
-     * @throws InvalidInterfaceException
524
-     */
525
-    protected function _add_screen_options_default()
526
-    {
527
-        $this->_per_page_screen_option();
528
-    }
529
-
530
-
531
-    /**
532
-     * Implementing screen options for the category list route.
533
-     *
534
-     * @throws InvalidArgumentException
535
-     * @throws InvalidDataTypeException
536
-     * @throws InvalidInterfaceException
537
-     */
538
-    protected function _add_screen_options_category_list()
539
-    {
540
-        $page_title = $this->_admin_page_title;
541
-        $this->_admin_page_title = esc_html__('Categories', 'event_espresso');
542
-        $this->_per_page_screen_option();
543
-        $this->_admin_page_title = $page_title;
544
-    }
545
-
546
-
547
-    /**
548
-     * Used to register any global feature pointers for the admin page group.
549
-     */
550
-    protected function _add_feature_pointers()
551
-    {
552
-    }
553
-
554
-
555
-    /**
556
-     * Registers and enqueues any global scripts and styles for the entire admin page group.
557
-     */
558
-    public function load_scripts_styles()
559
-    {
560
-        wp_register_style(
561
-            'events-admin-css',
562
-            EVENTS_ASSETS_URL . 'events-admin-page.css',
563
-            array(),
564
-            EVENT_ESPRESSO_VERSION
565
-        );
566
-        wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION);
567
-        wp_enqueue_style('events-admin-css');
568
-        wp_enqueue_style('ee-cat-admin');
569
-        // todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details
570
-        // registers for all views
571
-        // scripts
572
-        wp_register_script(
573
-            'event_editor_js',
574
-            EVENTS_ASSETS_URL . 'event_editor.js',
575
-            array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'),
576
-            EVENT_ESPRESSO_VERSION,
577
-            true
578
-        );
579
-    }
580
-
581
-
582
-    /**
583
-     * Enqueuing scripts and styles specific to this view
584
-     */
585
-    public function load_scripts_styles_create_new()
586
-    {
587
-        $this->load_scripts_styles_edit();
588
-    }
589
-
590
-
591
-    /**
592
-     * Enqueuing scripts and styles specific to this view
593
-     */
594
-    public function load_scripts_styles_edit()
595
-    {
596
-        // styles
597
-        wp_enqueue_style('espresso-ui-theme');
598
-        wp_register_style(
599
-            'event-editor-css',
600
-            EVENTS_ASSETS_URL . 'event-editor.css',
601
-            array('ee-admin-css'),
602
-            EVENT_ESPRESSO_VERSION
603
-        );
604
-        wp_enqueue_style('event-editor-css');
605
-        // scripts
606
-        wp_register_script(
607
-            'event-datetime-metabox',
608
-            EVENTS_ASSETS_URL . 'event-datetime-metabox.js',
609
-            array('event_editor_js', 'ee-datepicker'),
610
-            EVENT_ESPRESSO_VERSION
611
-        );
612
-        wp_enqueue_script('event-datetime-metabox');
613
-    }
614
-
615
-
616
-    /**
617
-     * Populating the _views property for the category list table view.
618
-     */
619
-    protected function _set_list_table_views_category_list()
620
-    {
621
-        $this->_views = array(
622
-            'all' => array(
623
-                'slug'        => 'all',
624
-                'label'       => esc_html__('All', 'event_espresso'),
625
-                'count'       => 0,
626
-                'bulk_action' => array(
627
-                    'delete_categories' => esc_html__('Delete Permanently', 'event_espresso'),
628
-                ),
629
-            ),
630
-        );
631
-    }
632
-
633
-
634
-    /**
635
-     * For adding anything that fires on the admin_init hook for any route within this admin page group.
636
-     */
637
-    public function admin_init()
638
-    {
639
-        EE_Registry::$i18n_js_strings['image_confirm'] = esc_html__(
640
-            'Do you really want to delete this image? Please remember to update your event to complete the removal.',
641
-            'event_espresso'
642
-        );
643
-    }
644
-
645
-
646
-    /**
647
-     * For adding anything that should be triggered on the admin_notices hook for any route within this admin page
648
-     * group.
649
-     */
650
-    public function admin_notices()
651
-    {
652
-    }
653
-
654
-
655
-    /**
656
-     * For adding anything that should be triggered on the `admin_print_footer_scripts` hook for any route within
657
-     * this admin page group.
658
-     */
659
-    public function admin_footer_scripts()
660
-    {
661
-    }
662
-
663
-
664
-    /**
665
-     * Call this function to verify if an event is public and has tickets for sale.  If it does, then we need to show a
666
-     * warning (via EE_Error::add_error());
667
-     *
668
-     * @param  EE_Event $event Event object
669
-     * @param string    $req_type
670
-     * @return void
671
-     * @throws EE_Error
672
-     * @access public
673
-     */
674
-    public function verify_event_edit($event = null, $req_type = '')
675
-    {
676
-        // don't need to do this when processing
677
-        if (! empty($req_type)) {
678
-            return;
679
-        }
680
-        // no event?
681
-        if (! $event instanceof EE_Event) {
682
-            $event = $this->_cpt_model_obj;
683
-        }
684
-        // STILL no event?
685
-        if (! $event instanceof EE_Event) {
686
-            return;
687
-        }
688
-        $orig_status = $event->status();
689
-        // first check if event is active.
690
-        if ($orig_status === EEM_Event::cancelled
691
-            || $orig_status === EEM_Event::postponed
692
-            || $event->is_expired()
693
-            || $event->is_inactive()
694
-        ) {
695
-            return;
696
-        }
697
-        // made it here so it IS active... next check that any of the tickets are sold.
698
-        if ($event->is_sold_out(true)) {
699
-            if ($orig_status !== EEM_Event::sold_out && $event->status() !== $orig_status) {
700
-                EE_Error::add_attention(
701
-                    sprintf(
702
-                        esc_html__(
703
-                            'Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event.  However, this change is not permanent until you update the event.  You can change the status back to something else before updating if you wish.',
704
-                            'event_espresso'
705
-                        ),
706
-                        EEH_Template::pretty_status(EEM_Event::sold_out, false, 'sentence')
707
-                    )
708
-                );
709
-            }
710
-            return;
711
-        }
712
-        if ($orig_status === EEM_Event::sold_out) {
713
-            EE_Error::add_attention(
714
-                sprintf(
715
-                    esc_html__(
716
-                        'Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets.  However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.',
717
-                        'event_espresso'
718
-                    ),
719
-                    EEH_Template::pretty_status($event->status(), false, 'sentence')
720
-                )
721
-            );
722
-        }
723
-        // now we need to determine if the event has any tickets on sale.  If not then we dont' show the error
724
-        if (! $event->tickets_on_sale()) {
725
-            return;
726
-        }
727
-        // made it here so show warning
728
-        $this->_edit_event_warning();
729
-    }
730
-
731
-
732
-    /**
733
-     * This is the text used for when an event is being edited that is public and has tickets for sale.
734
-     * When needed, hook this into a EE_Error::add_error() notice.
735
-     *
736
-     * @access protected
737
-     * @return void
738
-     */
739
-    protected function _edit_event_warning()
740
-    {
741
-        // we don't want to add warnings during these requests
742
-        if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'editpost') {
743
-            return;
744
-        }
745
-        EE_Error::add_attention(
746
-            sprintf(
747
-                esc_html__(
748
-                    'Your event is open for registration. Making changes may disrupt any transactions in progress. %sLearn more%s',
749
-                    'event_espresso'
750
-                ),
751
-                '<a class="espresso-help-tab-lnk">',
752
-                '</a>'
753
-            )
754
-        );
755
-    }
756
-
757
-
758
-    /**
759
-     * When a user is creating a new event, notify them if they haven't set their timezone.
760
-     * Otherwise, do the normal logic
761
-     *
762
-     * @return string
763
-     * @throws EE_Error
764
-     * @throws InvalidArgumentException
765
-     * @throws InvalidDataTypeException
766
-     * @throws InvalidInterfaceException
767
-     */
768
-    protected function _create_new_cpt_item()
769
-    {
770
-        $has_timezone_string = get_option('timezone_string');
771
-        // only nag them about setting their timezone if it's their first event, and they haven't already done it
772
-        if (! $has_timezone_string && ! EEM_Event::instance()->exists(array())) {
773
-            EE_Error::add_attention(
774
-                sprintf(
775
-                    __(
776
-                        'Your website\'s timezone is currently set to a UTC offset. We recommend updating your timezone to a city or region near you before you create an event. Change your timezone now:%1$s%2$s%3$sChange Timezone%4$s',
777
-                        'event_espresso'
778
-                    ),
779
-                    '<br>',
780
-                    '<select id="timezone_string" name="timezone_string" aria-describedby="timezone-description">'
781
-                    . EEH_DTT_Helper::wp_timezone_choice('', EEH_DTT_Helper::get_user_locale())
782
-                    . '</select>',
783
-                    '<button class="button button-secondary timezone-submit">',
784
-                    '</button><span class="spinner"></span>'
785
-                ),
786
-                __FILE__,
787
-                __FUNCTION__,
788
-                __LINE__
789
-            );
790
-        }
791
-        parent::_create_new_cpt_item();
792
-    }
793
-
794
-
795
-    /**
796
-     * Sets the _views property for the default route in this admin page group.
797
-     */
798
-    protected function _set_list_table_views_default()
799
-    {
800
-        $this->_views = array(
801
-            'all'   => array(
802
-                'slug'        => 'all',
803
-                'label'       => esc_html__('View All Events', 'event_espresso'),
804
-                'count'       => 0,
805
-                'bulk_action' => array(
806
-                    'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
807
-                ),
808
-            ),
809
-            'draft' => array(
810
-                'slug'        => 'draft',
811
-                'label'       => esc_html__('Draft', 'event_espresso'),
812
-                'count'       => 0,
813
-                'bulk_action' => array(
814
-                    'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
815
-                ),
816
-            ),
817
-        );
818
-        if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) {
819
-            $this->_views['trash'] = array(
820
-                'slug'        => 'trash',
821
-                'label'       => esc_html__('Trash', 'event_espresso'),
822
-                'count'       => 0,
823
-                'bulk_action' => array(
824
-                    'restore_events' => esc_html__('Restore From Trash', 'event_espresso'),
825
-                    'delete_events'  => esc_html__('Delete Permanently', 'event_espresso'),
826
-                ),
827
-            );
828
-        }
829
-    }
830
-
831
-
832
-    /**
833
-     * Provides the legend item array for the default list table view.
834
-     *
835
-     * @return array
836
-     */
837
-    protected function _event_legend_items()
838
-    {
839
-        $items = array(
840
-            'view_details'   => array(
841
-                'class' => 'dashicons dashicons-search',
842
-                'desc'  => esc_html__('View Event', 'event_espresso'),
843
-            ),
844
-            'edit_event'     => array(
845
-                'class' => 'ee-icon ee-icon-calendar-edit',
846
-                'desc'  => esc_html__('Edit Event Details', 'event_espresso'),
847
-            ),
848
-            'view_attendees' => array(
849
-                'class' => 'dashicons dashicons-groups',
850
-                'desc'  => esc_html__('View Registrations for Event', 'event_espresso'),
851
-            ),
852
-        );
853
-        $items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items);
854
-        $statuses = array(
855
-            'sold_out_status'  => array(
856
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out,
857
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::sold_out, false, 'sentence'),
858
-            ),
859
-            'active_status'    => array(
860
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active,
861
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::active, false, 'sentence'),
862
-            ),
863
-            'upcoming_status'  => array(
864
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming,
865
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::upcoming, false, 'sentence'),
866
-            ),
867
-            'postponed_status' => array(
868
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed,
869
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::postponed, false, 'sentence'),
870
-            ),
871
-            'cancelled_status' => array(
872
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled,
873
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::cancelled, false, 'sentence'),
874
-            ),
875
-            'expired_status'   => array(
876
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired,
877
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::expired, false, 'sentence'),
878
-            ),
879
-            'inactive_status'  => array(
880
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive,
881
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::inactive, false, 'sentence'),
882
-            ),
883
-        );
884
-        $statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses);
885
-        return array_merge($items, $statuses);
886
-    }
887
-
888
-
889
-    /**
890
-     * @return EEM_Event
891
-     * @throws EE_Error
892
-     * @throws InvalidArgumentException
893
-     * @throws InvalidDataTypeException
894
-     * @throws InvalidInterfaceException
895
-     * @throws ReflectionException
896
-     */
897
-    private function _event_model()
898
-    {
899
-        if (! $this->_event_model instanceof EEM_Event) {
900
-            $this->_event_model = EE_Registry::instance()->load_model('Event');
901
-        }
902
-        return $this->_event_model;
903
-    }
904
-
905
-
906
-    /**
907
-     * Adds extra buttons to the WP CPT permalink field row.
908
-     * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter.
909
-     *
910
-     * @param  string $return    the current html
911
-     * @param  int    $id        the post id for the page
912
-     * @param  string $new_title What the title is
913
-     * @param  string $new_slug  what the slug is
914
-     * @return string            The new html string for the permalink area
915
-     */
916
-    public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug)
917
-    {
918
-        // make sure this is only when editing
919
-        if (! empty($id)) {
920
-            $post = get_post($id);
921
-            $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#"  tabindex="-1">'
922
-                       . esc_html__('Shortcode', 'event_espresso')
923
-                       . '</a> ';
924
-            $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id='
925
-                       . $post->ID
926
-                       . ']">';
927
-        }
928
-        return $return;
929
-    }
930
-
931
-
932
-    /**
933
-     * _events_overview_list_table
934
-     * This contains the logic for showing the events_overview list
935
-     *
936
-     * @access protected
937
-     * @return void
938
-     * @throws DomainException
939
-     * @throws EE_Error
940
-     * @throws InvalidArgumentException
941
-     * @throws InvalidDataTypeException
942
-     * @throws InvalidInterfaceException
943
-     */
944
-    protected function _events_overview_list_table()
945
-    {
946
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
947
-        $this->_template_args['after_list_table'] = ! empty($this->_template_args['after_list_table'])
948
-            ? (array) $this->_template_args['after_list_table']
949
-            : array();
950
-        $this->_template_args['after_list_table']['view_event_list_button'] = EEH_HTML::br()
951
-                . EEH_Template::get_button_or_link(
952
-                    get_post_type_archive_link('espresso_events'),
953
-                    esc_html__('View Event Archive Page', 'event_espresso'),
954
-                    'button'
955
-                );
956
-        $this->_template_args['after_list_table']['legend'] = $this->_display_legend($this->_event_legend_items());
957
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
958
-            'create_new',
959
-            'add',
960
-            array(),
961
-            'add-new-h2'
962
-        );
963
-        $this->display_admin_list_table_page_with_no_sidebar();
964
-    }
965
-
966
-
967
-    /**
968
-     * this allows for extra misc actions in the default WP publish box
969
-     *
970
-     * @return void
971
-     * @throws DomainException
972
-     * @throws EE_Error
973
-     * @throws InvalidArgumentException
974
-     * @throws InvalidDataTypeException
975
-     * @throws InvalidInterfaceException
976
-     * @throws ReflectionException
977
-     */
978
-    public function extra_misc_actions_publish_box()
979
-    {
980
-        $this->_generate_publish_box_extra_content();
981
-    }
982
-
983
-
984
-    /**
985
-     * This is hooked into the WordPress do_action('save_post') hook and runs after the custom post type has been
986
-     * saved.
987
-     * Typically you would use this to save any additional data.
988
-     * Keep in mind also that "save_post" runs on EVERY post update to the database.
989
-     * ALSO very important.  When a post transitions from scheduled to published,
990
-     * the save_post action is fired but you will NOT have any _POST data containing any extra info you may have from
991
-     * other meta saves. So MAKE sure that you handle this accordingly.
992
-     *
993
-     * @access protected
994
-     * @abstract
995
-     * @param string $post_id The ID of the cpt that was saved (so you can link relationally)
996
-     * @param object $post    The post object of the cpt that was saved.
997
-     * @return void
998
-     * @throws EE_Error
999
-     * @throws InvalidArgumentException
1000
-     * @throws InvalidDataTypeException
1001
-     * @throws InvalidInterfaceException
1002
-     * @throws ReflectionException
1003
-     */
1004
-    protected function _insert_update_cpt_item($post_id, $post)
1005
-    {
1006
-        if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') {
1007
-            // get out we're not processing an event save.
1008
-            return;
1009
-        }
1010
-        $event_values = array(
1011
-            'EVT_display_desc'                => ! empty($this->_req_data['display_desc']) ? 1 : 0,
1012
-            'EVT_display_ticket_selector'     => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0,
1013
-            'EVT_additional_limit'            => min(
1014
-                apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255),
1015
-                ! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : null
1016
-            ),
1017
-            'EVT_default_registration_status' => ! empty($this->_req_data['EVT_default_registration_status'])
1018
-                ? $this->_req_data['EVT_default_registration_status']
1019
-                : EE_Registry::instance()->CFG->registration->default_STS_ID,
1020
-            'EVT_member_only'                 => ! empty($this->_req_data['member_only']) ? 1 : 0,
1021
-            'EVT_allow_overflow'              => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0,
1022
-            'EVT_timezone_string'             => ! empty($this->_req_data['timezone_string'])
1023
-                ? $this->_req_data['timezone_string'] : null,
1024
-            'EVT_external_URL'                => ! empty($this->_req_data['externalURL'])
1025
-                ? $this->_req_data['externalURL'] : null,
1026
-            'EVT_phone'                       => ! empty($this->_req_data['event_phone'])
1027
-                ? $this->_req_data['event_phone'] : null,
1028
-        );
1029
-        // update event
1030
-        $success = $this->_event_model()->update_by_ID($event_values, $post_id);
1031
-        // get event_object for other metaboxes... though it would seem to make sense to just use $this->_event_model()->get_one_by_ID( $post_id ).. i have to setup where conditions to override the filters in the model that filter out autodraft and inherit statuses so we GET the inherit id!
1032
-        $get_one_where = array(
1033
-            $this->_event_model()->primary_key_name() => $post_id,
1034
-            'OR'                                      => array(
1035
-                'status'   => $post->post_status,
1036
-                // if trying to "Publish" a sold out event, it's status will get switched back to "sold_out" in the db,
1037
-                // but the returned object here has a status of "publish", so use the original post status as well
1038
-                'status*1' => $this->_req_data['original_post_status'],
1039
-            ),
1040
-        );
1041
-        $event = $this->_event_model()->get_one(array($get_one_where));
1042
-        // the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons.
1043
-        $event_update_callbacks = apply_filters(
1044
-            'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',
1045
-            array(
1046
-                array($this, '_default_venue_update'),
1047
-                array($this, '_default_tickets_update'),
1048
-            )
1049
-        );
1050
-        $att_success = true;
1051
-        foreach ($event_update_callbacks as $e_callback) {
1052
-            $_success = is_callable($e_callback)
1053
-                ? $e_callback($event, $this->_req_data)
1054
-                : false;
1055
-            // if ANY of these updates fail then we want the appropriate global error message
1056
-            $att_success = ! $att_success ? $att_success : $_success;
1057
-        }
1058
-        // any errors?
1059
-        if ($success && false === $att_success) {
1060
-            EE_Error::add_error(
1061
-                esc_html__(
1062
-                    'Event Details saved successfully but something went wrong with saving attachments.',
1063
-                    'event_espresso'
1064
-                ),
1065
-                __FILE__,
1066
-                __FUNCTION__,
1067
-                __LINE__
1068
-            );
1069
-        } elseif ($success === false) {
1070
-            EE_Error::add_error(
1071
-                esc_html__('Event Details did not save successfully.', 'event_espresso'),
1072
-                __FILE__,
1073
-                __FUNCTION__,
1074
-                __LINE__
1075
-            );
1076
-        }
1077
-    }
1078
-
1079
-
1080
-    /**
1081
-     * @param int $post_id
1082
-     * @param int $revision_id
1083
-     * @throws EE_Error
1084
-     * @throws InvalidArgumentException
1085
-     * @throws InvalidDataTypeException
1086
-     * @throws InvalidInterfaceException
1087
-     * @throws ReflectionException
1088
-     * @see parent::restore_item()
1089
-     */
1090
-    protected function _restore_cpt_item($post_id, $revision_id)
1091
-    {
1092
-        // copy existing event meta to new post
1093
-        $post_evt = $this->_event_model()->get_one_by_ID($post_id);
1094
-        if ($post_evt instanceof EE_Event) {
1095
-            // meta revision restore
1096
-            $post_evt->restore_revision($revision_id);
1097
-            // related objs restore
1098
-            $post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price'));
1099
-        }
1100
-    }
1101
-
1102
-
1103
-    /**
1104
-     * Attach the venue to the Event
1105
-     *
1106
-     * @param EE_Event $evtobj Event Object to add the venue to
1107
-     * @param array    $data   The request data from the form
1108
-     * @return bool           Success or fail.
1109
-     * @throws EE_Error
1110
-     * @throws InvalidArgumentException
1111
-     * @throws InvalidDataTypeException
1112
-     * @throws InvalidInterfaceException
1113
-     * @throws ReflectionException
1114
-     */
1115
-    protected function _default_venue_update(EE_Event $evtobj, $data)
1116
-    {
1117
-        require_once(EE_MODELS . 'EEM_Venue.model.php');
1118
-        $venue_model = EE_Registry::instance()->load_model('Venue');
1119
-        $rows_affected = null;
1120
-        $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null;
1121
-        // very important.  If we don't have a venue name...
1122
-        // then we'll get out because not necessary to create empty venue
1123
-        if (empty($data['venue_title'])) {
1124
-            return false;
1125
-        }
1126
-        $venue_array = array(
1127
-            'VNU_wp_user'         => $evtobj->get('EVT_wp_user'),
1128
-            'VNU_name'            => ! empty($data['venue_title']) ? $data['venue_title'] : null,
1129
-            'VNU_desc'            => ! empty($data['venue_description']) ? $data['venue_description'] : null,
1130
-            'VNU_identifier'      => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : null,
1131
-            'VNU_short_desc'      => ! empty($data['venue_short_description']) ? $data['venue_short_description']
1132
-                : null,
1133
-            'VNU_address'         => ! empty($data['address']) ? $data['address'] : null,
1134
-            'VNU_address2'        => ! empty($data['address2']) ? $data['address2'] : null,
1135
-            'VNU_city'            => ! empty($data['city']) ? $data['city'] : null,
1136
-            'STA_ID'              => ! empty($data['state']) ? $data['state'] : null,
1137
-            'CNT_ISO'             => ! empty($data['countries']) ? $data['countries'] : null,
1138
-            'VNU_zip'             => ! empty($data['zip']) ? $data['zip'] : null,
1139
-            'VNU_phone'           => ! empty($data['venue_phone']) ? $data['venue_phone'] : null,
1140
-            'VNU_capacity'        => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : null,
1141
-            'VNU_url'             => ! empty($data['venue_url']) ? $data['venue_url'] : null,
1142
-            'VNU_virtual_phone'   => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : null,
1143
-            'VNU_virtual_url'     => ! empty($data['virtual_url']) ? $data['virtual_url'] : null,
1144
-            'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0,
1145
-            'status'              => 'publish',
1146
-        );
1147
-        // if we've got the venue_id then we're just updating the existing venue so let's do that and then get out.
1148
-        if (! empty($venue_id)) {
1149
-            $update_where = array($venue_model->primary_key_name() => $venue_id);
1150
-            $rows_affected = $venue_model->update($venue_array, array($update_where));
1151
-            // we've gotta make sure that the venue is always attached to a revision.. add_relation_to should take care of making sure that the relation is already present.
1152
-            $evtobj->_add_relation_to($venue_id, 'Venue');
1153
-            return $rows_affected > 0;
1154
-        }
1155
-        // we insert the venue
1156
-        $venue_id = $venue_model->insert($venue_array);
1157
-        $evtobj->_add_relation_to($venue_id, 'Venue');
1158
-        return ! empty($venue_id) ? true : false;
1159
-        // when we have the ancestor come in it's already been handled by the revision save.
1160
-    }
1161
-
1162
-
1163
-    /**
1164
-     * Handles saving everything related to Tickets (datetimes, tickets, prices)
1165
-     *
1166
-     * @param EE_Event $evtobj The Event object we're attaching data to
1167
-     * @param array    $data   The request data from the form
1168
-     * @return array
1169
-     * @throws EE_Error
1170
-     * @throws InvalidArgumentException
1171
-     * @throws InvalidDataTypeException
1172
-     * @throws InvalidInterfaceException
1173
-     * @throws ReflectionException
1174
-     * @throws Exception
1175
-     */
1176
-    protected function _default_tickets_update(EE_Event $evtobj, $data)
1177
-    {
1178
-        $success = true;
1179
-        $saved_dtt = null;
1180
-        $saved_tickets = array();
1181
-        $incoming_date_formats = array('Y-m-d', 'h:i a');
1182
-        foreach ($data['edit_event_datetimes'] as $row => $dtt) {
1183
-            // trim all values to ensure any excess whitespace is removed.
1184
-            $dtt = array_map('trim', $dtt);
1185
-            $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end']
1186
-                : $dtt['DTT_EVT_start'];
1187
-            $datetime_values = array(
1188
-                'DTT_ID'        => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : null,
1189
-                'DTT_EVT_start' => $dtt['DTT_EVT_start'],
1190
-                'DTT_EVT_end'   => $dtt['DTT_EVT_end'],
1191
-                'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'],
1192
-                'DTT_order'     => $row,
1193
-            );
1194
-            // if we have an id then let's get existing object first and then set the new values.  Otherwise we instantiate a new object for save.
1195
-            if (! empty($dtt['DTT_ID'])) {
1196
-                $DTM = EE_Registry::instance()
1197
-                                  ->load_model('Datetime', array($evtobj->get_timezone()))
1198
-                                  ->get_one_by_ID($dtt['DTT_ID']);
1199
-                $DTM->set_date_format($incoming_date_formats[0]);
1200
-                $DTM->set_time_format($incoming_date_formats[1]);
1201
-                foreach ($datetime_values as $field => $value) {
1202
-                    $DTM->set($field, $value);
1203
-                }
1204
-                // make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it.  We need to do this so we dont' TRASH the parent DTT.
1205
-                $saved_dtts[ $DTM->ID() ] = $DTM;
1206
-            } else {
1207
-                $DTM = EE_Registry::instance()->load_class(
1208
-                    'Datetime',
1209
-                    array($datetime_values, $evtobj->get_timezone(), $incoming_date_formats),
1210
-                    false,
1211
-                    false
1212
-                );
1213
-                foreach ($datetime_values as $field => $value) {
1214
-                    $DTM->set($field, $value);
1215
-                }
1216
-            }
1217
-            $DTM->save();
1218
-            $DTT = $evtobj->_add_relation_to($DTM, 'Datetime');
1219
-            // load DTT helper
1220
-            // before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date.
1221
-            if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) {
1222
-                $DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start'));
1223
-                $DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days');
1224
-                $DTT->save();
1225
-            }
1226
-            // now we got to make sure we add the new DTT_ID to the $saved_dtts array  because it is possible there was a new one created for the autosave.
1227
-            $saved_dtt = $DTT;
1228
-            $success = ! $success ? $success : $DTT;
1229
-            // if ANY of these updates fail then we want the appropriate global error message.
1230
-            // //todo this is actually sucky we need a better error message but this is what it is for now.
1231
-        }
1232
-        // no dtts get deleted so we don't do any of that logic here.
1233
-        // update tickets next
1234
-        $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array();
1235
-        foreach ($data['edit_tickets'] as $row => $tkt) {
1236
-            $incoming_date_formats = array('Y-m-d', 'h:i a');
1237
-            $update_prices = false;
1238
-            $ticket_price = isset($data['edit_prices'][ $row ][1]['PRC_amount'])
1239
-                ? $data['edit_prices'][ $row ][1]['PRC_amount'] : 0;
1240
-            // trim inputs to ensure any excess whitespace is removed.
1241
-            $tkt = array_map('trim', $tkt);
1242
-            if (empty($tkt['TKT_start_date'])) {
1243
-                // let's use now in the set timezone.
1244
-                $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone()));
1245
-                $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0] . ' ' . $incoming_date_formats[1]);
1246
-            }
1247
-            if (empty($tkt['TKT_end_date'])) {
1248
-                // use the start date of the first datetime
1249
-                $dtt = $evtobj->first_datetime();
1250
-                $tkt['TKT_end_date'] = $dtt->start_date_and_time(
1251
-                    $incoming_date_formats[0],
1252
-                    $incoming_date_formats[1]
1253
-                );
1254
-            }
1255
-            $TKT_values = array(
1256
-                'TKT_ID'          => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null,
1257
-                'TTM_ID'          => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0,
1258
-                'TKT_name'        => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '',
1259
-                'TKT_description' => ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '',
1260
-                'TKT_start_date'  => $tkt['TKT_start_date'],
1261
-                'TKT_end_date'    => $tkt['TKT_end_date'],
1262
-                'TKT_qty'         => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'],
1263
-                'TKT_uses'        => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'],
1264
-                'TKT_min'         => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'],
1265
-                'TKT_max'         => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'],
1266
-                'TKT_row'         => $row,
1267
-                'TKT_order'       => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row,
1268
-                'TKT_price'       => $ticket_price,
1269
-            );
1270
-            // if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well.
1271
-            if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) {
1272
-                $TKT_values['TKT_ID'] = 0;
1273
-                $TKT_values['TKT_is_default'] = 0;
1274
-                $TKT_values['TKT_price'] = $ticket_price;
1275
-                $update_prices = true;
1276
-            }
1277
-            // if we have a TKT_ID then we need to get that existing TKT_obj and update it
1278
-            // we actually do our saves a head of doing any add_relations to because its entirely possible that this ticket didn't removed or added to any datetime in the session but DID have it's items modified.
1279
-            // keep in mind that if the TKT has been sold (and we have changed pricing information), then we won't be updating the tkt but instead a new tkt will be created and the old one archived.
1280
-            if (! empty($tkt['TKT_ID'])) {
1281
-                $TKT = EE_Registry::instance()
1282
-                                  ->load_model('Ticket', array($evtobj->get_timezone()))
1283
-                                  ->get_one_by_ID($tkt['TKT_ID']);
1284
-                if ($TKT instanceof EE_Ticket) {
1285
-                    $ticket_sold = $TKT->count_related(
1286
-                        'Registration',
1287
-                        array(
1288
-                            array(
1289
-                                'STS_ID' => array(
1290
-                                    'NOT IN',
1291
-                                    array(EEM_Registration::status_id_incomplete),
1292
-                                ),
1293
-                            ),
1294
-                        )
1295
-                    ) > 0;
1296
-                    // let's just check the total price for the existing ticket and determine if it matches the new
1297
-                    // total price.  if they are different then we create a new ticket (if tickets sold)
1298
-                    // if they aren't different then we go ahead and modify existing ticket.
1299
-                    $create_new_TKT = $ticket_sold && ! $TKT->deleted() && EEH_Money::compare_floats(
1300
-                        $ticket_price,
1301
-                        $TKT->get('TKT_price'),
1302
-                        '!=='
1303
-                    );
1304
-                    $TKT->set_date_format($incoming_date_formats[0]);
1305
-                    $TKT->set_time_format($incoming_date_formats[1]);
1306
-                    // set new values
1307
-                    foreach ($TKT_values as $field => $value) {
1308
-                        if ($field === 'TKT_qty') {
1309
-                            $TKT->set_qty($value);
1310
-                        } else {
1311
-                            $TKT->set($field, $value);
1312
-                        }
1313
-                    }
1314
-                    // if $create_new_TKT is false then we can safely update the existing ticket.  Otherwise we have to create a new ticket.
1315
-                    if ($create_new_TKT) {
1316
-                        // archive the old ticket first
1317
-                        $TKT->set('TKT_deleted', 1);
1318
-                        $TKT->save();
1319
-                        // make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine.
1320
-                        $saved_tickets[ $TKT->ID() ] = $TKT;
1321
-                        // create new ticket that's a copy of the existing except a new id of course (and not archived) AND has the new TKT_price associated with it.
1322
-                        $TKT = clone $TKT;
1323
-                        $TKT->set('TKT_ID', 0);
1324
-                        $TKT->set('TKT_deleted', 0);
1325
-                        $TKT->set('TKT_price', $ticket_price);
1326
-                        $TKT->set('TKT_sold', 0);
1327
-                        // now we need to make sure that $new prices are created as well and attached to new ticket.
1328
-                        $update_prices = true;
1329
-                    }
1330
-                    // make sure price is set if it hasn't been already
1331
-                    $TKT->set('TKT_price', $ticket_price);
1332
-                }
1333
-            } else {
1334
-                // no TKT_id so a new TKT
1335
-                $TKT_values['TKT_price'] = $ticket_price;
1336
-                $TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), false, false);
1337
-                if ($TKT instanceof EE_Ticket) {
1338
-                    // need to reset values to properly account for the date formats
1339
-                    $TKT->set_date_format($incoming_date_formats[0]);
1340
-                    $TKT->set_time_format($incoming_date_formats[1]);
1341
-                    $TKT->set_timezone($evtobj->get_timezone());
1342
-                    // set new values
1343
-                    foreach ($TKT_values as $field => $value) {
1344
-                        if ($field === 'TKT_qty') {
1345
-                            $TKT->set_qty($value);
1346
-                        } else {
1347
-                            $TKT->set($field, $value);
1348
-                        }
1349
-                    }
1350
-                    $update_prices = true;
1351
-                }
1352
-            }
1353
-            // cap ticket qty by datetime reg limits
1354
-            $TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit')));
1355
-            // update ticket.
1356
-            $TKT->save();
1357
-            // before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date.
1358
-            if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) {
1359
-                $TKT->set('TKT_end_date', $TKT->get('TKT_start_date'));
1360
-                $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days');
1361
-                $TKT->save();
1362
-            }
1363
-            // initially let's add the ticket to the dtt
1364
-            $saved_dtt->_add_relation_to($TKT, 'Ticket');
1365
-            $saved_tickets[ $TKT->ID() ] = $TKT;
1366
-            // add prices to ticket
1367
-            $this->_add_prices_to_ticket($data['edit_prices'][ $row ], $TKT, $update_prices);
1368
-        }
1369
-        // however now we need to handle permanently deleting tickets via the ui.  Keep in mind that the ui does not allow deleting/archiving tickets that have ticket sold.  However, it does allow for deleting tickets that have no tickets sold, in which case we want to get rid of permanently because there is no need to save in db.
1370
-        $old_tickets = isset($old_tickets[0]) && $old_tickets[0] === '' ? array() : $old_tickets;
1371
-        $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets));
1372
-        foreach ($tickets_removed as $id) {
1373
-            $id = absint($id);
1374
-            // get the ticket for this id
1375
-            $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id);
1376
-            // need to get all the related datetimes on this ticket and remove from every single one of them (remember this process can ONLY kick off if there are NO tkts_sold)
1377
-            $dtts = $tkt_to_remove->get_many_related('Datetime');
1378
-            foreach ($dtts as $dtt) {
1379
-                $tkt_to_remove->_remove_relation_to($dtt, 'Datetime');
1380
-            }
1381
-            // need to do the same for prices (except these prices can also be deleted because again, tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived))
1382
-            $tkt_to_remove->delete_related_permanently('Price');
1383
-            // finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships)
1384
-            $tkt_to_remove->delete_permanently();
1385
-        }
1386
-        return array($saved_dtt, $saved_tickets);
1387
-    }
1388
-
1389
-
1390
-    /**
1391
-     * This attaches a list of given prices to a ticket.
1392
-     * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change
1393
-     * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old
1394
-     * price info and prices are automatically "archived" via the ticket.
1395
-     *
1396
-     * @access  private
1397
-     * @param array     $prices     Array of prices from the form.
1398
-     * @param EE_Ticket $ticket     EE_Ticket object that prices are being attached to.
1399
-     * @param bool      $new_prices Whether attach existing incoming prices or create new ones.
1400
-     * @return  void
1401
-     * @throws EE_Error
1402
-     * @throws InvalidArgumentException
1403
-     * @throws InvalidDataTypeException
1404
-     * @throws InvalidInterfaceException
1405
-     * @throws ReflectionException
1406
-     */
1407
-    private function _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = false)
1408
-    {
1409
-        foreach ($prices as $row => $prc) {
1410
-            $PRC_values = array(
1411
-                'PRC_ID'         => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null,
1412
-                'PRT_ID'         => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null,
1413
-                'PRC_amount'     => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0,
1414
-                'PRC_name'       => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '',
1415
-                'PRC_desc'       => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '',
1416
-                'PRC_is_default' => 0, // make sure prices are NOT set as default from this context
1417
-                'PRC_order'      => $row,
1418
-            );
1419
-            if ($new_prices || empty($PRC_values['PRC_ID'])) {
1420
-                $PRC_values['PRC_ID'] = 0;
1421
-                $PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), false, false);
1422
-            } else {
1423
-                $PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']);
1424
-                // update this price with new values
1425
-                foreach ($PRC_values as $field => $newprc) {
1426
-                    $PRC->set($field, $newprc);
1427
-                }
1428
-                $PRC->save();
1429
-            }
1430
-            $ticket->_add_relation_to($PRC, 'Price');
1431
-        }
1432
-    }
1433
-
1434
-
1435
-    /**
1436
-     * Add in our autosave ajax handlers
1437
-     *
1438
-     */
1439
-    protected function _ee_autosave_create_new()
1440
-    {
1441
-    }
1442
-
1443
-
1444
-    /**
1445
-     * More autosave handlers.
1446
-     */
1447
-    protected function _ee_autosave_edit()
1448
-    {
1449
-    }
1450
-
1451
-
1452
-    /**
1453
-     *    _generate_publish_box_extra_content
1454
-     *
1455
-     * @throws DomainException
1456
-     * @throws EE_Error
1457
-     * @throws InvalidArgumentException
1458
-     * @throws InvalidDataTypeException
1459
-     * @throws InvalidInterfaceException
1460
-     * @throws ReflectionException
1461
-     */
1462
-    private function _generate_publish_box_extra_content()
1463
-    {
1464
-        // load formatter helper
1465
-        // args for getting related registrations
1466
-        $approved_query_args = array(
1467
-            array(
1468
-                'REG_deleted' => 0,
1469
-                'STS_ID'      => EEM_Registration::status_id_approved,
1470
-            ),
1471
-        );
1472
-        $not_approved_query_args = array(
1473
-            array(
1474
-                'REG_deleted' => 0,
1475
-                'STS_ID'      => EEM_Registration::status_id_not_approved,
1476
-            ),
1477
-        );
1478
-        $pending_payment_query_args = array(
1479
-            array(
1480
-                'REG_deleted' => 0,
1481
-                'STS_ID'      => EEM_Registration::status_id_pending_payment,
1482
-            ),
1483
-        );
1484
-        // publish box
1485
-        $publish_box_extra_args = array(
1486
-            'view_approved_reg_url'        => add_query_arg(
1487
-                array(
1488
-                    'action'      => 'default',
1489
-                    'event_id'    => $this->_cpt_model_obj->ID(),
1490
-                    '_reg_status' => EEM_Registration::status_id_approved,
1491
-                ),
1492
-                REG_ADMIN_URL
1493
-            ),
1494
-            'view_not_approved_reg_url'    => add_query_arg(
1495
-                array(
1496
-                    'action'      => 'default',
1497
-                    'event_id'    => $this->_cpt_model_obj->ID(),
1498
-                    '_reg_status' => EEM_Registration::status_id_not_approved,
1499
-                ),
1500
-                REG_ADMIN_URL
1501
-            ),
1502
-            'view_pending_payment_reg_url' => add_query_arg(
1503
-                array(
1504
-                    'action'      => 'default',
1505
-                    'event_id'    => $this->_cpt_model_obj->ID(),
1506
-                    '_reg_status' => EEM_Registration::status_id_pending_payment,
1507
-                ),
1508
-                REG_ADMIN_URL
1509
-            ),
1510
-            'approved_regs'                => $this->_cpt_model_obj->count_related(
1511
-                'Registration',
1512
-                $approved_query_args
1513
-            ),
1514
-            'not_approved_regs'            => $this->_cpt_model_obj->count_related(
1515
-                'Registration',
1516
-                $not_approved_query_args
1517
-            ),
1518
-            'pending_payment_regs'         => $this->_cpt_model_obj->count_related(
1519
-                'Registration',
1520
-                $pending_payment_query_args
1521
-            ),
1522
-            'misc_pub_section_class'       => apply_filters(
1523
-                'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class',
1524
-                'misc-pub-section'
1525
-            ),
1526
-        );
1527
-        ob_start();
1528
-        do_action(
1529
-            'AHEE__Events_Admin_Page___generate_publish_box_extra_content__event_editor_overview_add',
1530
-            $this->_cpt_model_obj
1531
-        );
1532
-        $publish_box_extra_args['event_editor_overview_add'] = ob_get_clean();
1533
-        // load template
1534
-        EEH_Template::display_template(
1535
-            EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php',
1536
-            $publish_box_extra_args
1537
-        );
1538
-    }
1539
-
1540
-
1541
-    /**
1542
-     * @return EE_Event
1543
-     */
1544
-    public function get_event_object()
1545
-    {
1546
-        return $this->_cpt_model_obj;
1547
-    }
1548
-
1549
-
1550
-
1551
-
1552
-    /** METABOXES * */
1553
-    /**
1554
-     * _register_event_editor_meta_boxes
1555
-     * add all metaboxes related to the event_editor
1556
-     *
1557
-     * @return void
1558
-     * @throws EE_Error
1559
-     * @throws InvalidArgumentException
1560
-     * @throws InvalidDataTypeException
1561
-     * @throws InvalidInterfaceException
1562
-     * @throws ReflectionException
1563
-     */
1564
-    protected function _register_event_editor_meta_boxes()
1565
-    {
1566
-        $this->verify_cpt_object();
1567
-        // add_meta_box(
1568
-        //     'espresso_event_editor_tickets',
1569
-        //     esc_html__('Event Datetime & Ticket', 'event_espresso'),
1570
-        //     array($this, 'ticket_metabox'),
1571
-        //     $this->page_slug,
1572
-        //     'normal',
1573
-        //     'high'
1574
-        // );
1575
-        add_meta_box(
1576
-            'espresso_event_editor_event_options',
1577
-            esc_html__('Event Registration Options', 'event_espresso'),
1578
-            array($this, 'registration_options_meta_box'),
1579
-            $this->page_slug,
1580
-            'side'
1581
-        );
1582
-        // NOTE: if you're looking for other metaboxes in here,
1583
-        // where a metabox has a related management page in the admin
1584
-        // you will find it setup in the related management page's "_Hooks" file.
1585
-        // i.e. messages metabox is found in "espresso_events_Messages_Hooks.class.php".
1586
-    }
1587
-
1588
-
1589
-    /**
1590
-     * @throws DomainException
1591
-     * @throws EE_Error
1592
-     * @throws InvalidArgumentException
1593
-     * @throws InvalidDataTypeException
1594
-     * @throws InvalidInterfaceException
1595
-     * @throws ReflectionException
1596
-     */
1597
-    public function ticket_metabox()
1598
-    {
1599
-        $existing_datetime_ids = $existing_ticket_ids = array();
1600
-        // defaults for template args
1601
-        $template_args = array(
1602
-            'existing_datetime_ids'    => '',
1603
-            'event_datetime_help_link' => '',
1604
-            'ticket_options_help_link' => '',
1605
-            'time'                     => null,
1606
-            'ticket_rows'              => '',
1607
-            'existing_ticket_ids'      => '',
1608
-            'total_ticket_rows'        => 1,
1609
-            'ticket_js_structure'      => '',
1610
-            'trash_icon'               => 'ee-lock-icon',
1611
-            'disabled'                 => '',
1612
-        );
1613
-        $event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : null;
1614
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1615
-        /**
1616
-         * 1. Start with retrieving Datetimes
1617
-         * 2. Fore each datetime get related tickets
1618
-         * 3. For each ticket get related prices
1619
-         */
1620
-        $times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id);
1621
-        /** @type EE_Datetime $first_datetime */
1622
-        $first_datetime = reset($times);
1623
-        // do we get related tickets?
1624
-        if ($first_datetime instanceof EE_Datetime
1625
-            && $first_datetime->ID() !== 0
1626
-        ) {
1627
-            $existing_datetime_ids[] = $first_datetime->get('DTT_ID');
1628
-            $template_args['time'] = $first_datetime;
1629
-            $related_tickets = $first_datetime->tickets(
1630
-                array(
1631
-                    array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)),
1632
-                    'default_where_conditions' => 'none',
1633
-                )
1634
-            );
1635
-            if (! empty($related_tickets)) {
1636
-                $template_args['total_ticket_rows'] = count($related_tickets);
1637
-                $row = 0;
1638
-                foreach ($related_tickets as $ticket) {
1639
-                    $existing_ticket_ids[] = $ticket->get('TKT_ID');
1640
-                    $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, false, $row);
1641
-                    $row++;
1642
-                }
1643
-            } else {
1644
-                $template_args['total_ticket_rows'] = 1;
1645
-                /** @type EE_Ticket $ticket */
1646
-                $ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object();
1647
-                $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket);
1648
-            }
1649
-        } else {
1650
-            $template_args['time'] = $times[0];
1651
-            /** @type EE_Ticket $ticket */
1652
-            $ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets();
1653
-            $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]);
1654
-            // NOTE: we're just sending the first default row
1655
-            // (decaf can't manage default tickets so this should be sufficient);
1656
-        }
1657
-        $template_args['event_datetime_help_link'] = $this->_get_help_tab_link(
1658
-            'event_editor_event_datetimes_help_tab'
1659
-        );
1660
-        $template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info');
1661
-        $template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids);
1662
-        $template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids);
1663
-        $template_args['ticket_js_structure'] = $this->_get_ticket_row(
1664
-            EE_Registry::instance()->load_model('Ticket')->create_default_object(),
1665
-            true
1666
-        );
1667
-        $template = apply_filters(
1668
-            'FHEE__Events_Admin_Page__ticket_metabox__template',
1669
-            EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php'
1670
-        );
1671
-        EEH_Template::display_template($template, $template_args);
1672
-    }
1673
-
1674
-
1675
-    /**
1676
-     * Setup an individual ticket form for the decaf event editor page
1677
-     *
1678
-     * @access private
1679
-     * @param EE_Ticket $ticket   the ticket object
1680
-     * @param boolean   $skeleton whether we're generating a skeleton for js manipulation
1681
-     * @param int       $row
1682
-     * @return string generated html for the ticket row.
1683
-     * @throws DomainException
1684
-     * @throws EE_Error
1685
-     * @throws InvalidArgumentException
1686
-     * @throws InvalidDataTypeException
1687
-     * @throws InvalidInterfaceException
1688
-     * @throws ReflectionException
1689
-     */
1690
-    private function _get_ticket_row($ticket, $skeleton = false, $row = 0)
1691
-    {
1692
-        $template_args = array(
1693
-            'tkt_status_class'    => ' tkt-status-' . $ticket->ticket_status(),
1694
-            'tkt_archive_class'   => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived'
1695
-                : '',
1696
-            'ticketrow'           => $skeleton ? 'TICKETNUM' : $row,
1697
-            'TKT_ID'              => $ticket->get('TKT_ID'),
1698
-            'TKT_name'            => $ticket->get('TKT_name'),
1699
-            'TKT_start_date'      => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'),
1700
-            'TKT_end_date'        => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'),
1701
-            'TKT_is_default'      => $ticket->get('TKT_is_default'),
1702
-            'TKT_qty'             => $ticket->get_pretty('TKT_qty', 'input'),
1703
-            'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets',
1704
-            'TKT_sold'            => $skeleton ? 0 : $ticket->get('TKT_sold'),
1705
-            'trash_icon'          => ($skeleton || (! empty($ticket) && ! $ticket->get('TKT_deleted')))
1706
-                                     && (! empty($ticket) && $ticket->get('TKT_sold') === 0)
1707
-                ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon',
1708
-            'disabled'            => $skeleton || (! empty($ticket) && ! $ticket->get('TKT_deleted')) ? ''
1709
-                : ' disabled=disabled',
1710
-        );
1711
-        $price = $ticket->ID() !== 0
1712
-            ? $ticket->get_first_related('Price', array('default_where_conditions' => 'none'))
1713
-            : EE_Registry::instance()->load_model('Price')->create_default_object();
1714
-        $price_args = array(
1715
-            'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,
1716
-            'PRC_amount'            => $price->get('PRC_amount'),
1717
-            'PRT_ID'                => $price->get('PRT_ID'),
1718
-            'PRC_ID'                => $price->get('PRC_ID'),
1719
-            'PRC_is_default'        => $price->get('PRC_is_default'),
1720
-        );
1721
-        // make sure we have default start and end dates if skeleton
1722
-        // handle rows that should NOT be empty
1723
-        if (empty($template_args['TKT_start_date'])) {
1724
-            // if empty then the start date will be now.
1725
-            $template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp'));
1726
-        }
1727
-        if (empty($template_args['TKT_end_date'])) {
1728
-            // get the earliest datetime (if present);
1729
-            $earliest_dtt = $this->_cpt_model_obj->ID() > 0
1730
-                ? $this->_cpt_model_obj->get_first_related(
1731
-                    'Datetime',
1732
-                    array('order_by' => array('DTT_EVT_start' => 'ASC'))
1733
-                )
1734
-                : null;
1735
-            if (! empty($earliest_dtt)) {
1736
-                $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a');
1737
-            } else {
1738
-                $template_args['TKT_end_date'] = date(
1739
-                    'Y-m-d h:i a',
1740
-                    mktime(0, 0, 0, date('m'), date('d') + 7, date('Y'))
1741
-                );
1742
-            }
1743
-        }
1744
-        $template_args = array_merge($template_args, $price_args);
1745
-        $template = apply_filters(
1746
-            'FHEE__Events_Admin_Page__get_ticket_row__template',
1747
-            EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php',
1748
-            $ticket
1749
-        );
1750
-        return EEH_Template::display_template($template, $template_args, true);
1751
-    }
1752
-
1753
-
1754
-    /**
1755
-     * @throws DomainException
1756
-     * @throws EE_Error
1757
-     */
1758
-    public function registration_options_meta_box()
1759
-    {
1760
-        $yes_no_values = array(
1761
-            array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')),
1762
-            array('id' => false, 'text' => esc_html__('No', 'event_espresso')),
1763
-        );
1764
-        $default_reg_status_values = EEM_Registration::reg_status_array(
1765
-            array(
1766
-                EEM_Registration::status_id_cancelled,
1767
-                EEM_Registration::status_id_declined,
1768
-                EEM_Registration::status_id_incomplete,
1769
-            ),
1770
-            true
1771
-        );
1772
-        // $template_args['is_active_select'] = EEH_Form_Fields::select_input('is_active', $yes_no_values, $this->_cpt_model_obj->is_active());
1773
-        $template_args['_event'] = $this->_cpt_model_obj;
1774
-        $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false);
1775
-        $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit();
1776
-        $template_args['default_registration_status'] = EEH_Form_Fields::select_input(
1777
-            'default_reg_status',
1778
-            $default_reg_status_values,
1779
-            $this->_cpt_model_obj->default_registration_status()
1780
-        );
1781
-        $template_args['display_description'] = EEH_Form_Fields::select_input(
1782
-            'display_desc',
1783
-            $yes_no_values,
1784
-            $this->_cpt_model_obj->display_description()
1785
-        );
1786
-        $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input(
1787
-            'display_ticket_selector',
1788
-            $yes_no_values,
1789
-            $this->_cpt_model_obj->display_ticket_selector(),
1790
-            '',
1791
-            '',
1792
-            false
1793
-        );
1794
-        $template_args['additional_registration_options'] = apply_filters(
1795
-            'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options',
1796
-            '',
1797
-            $template_args,
1798
-            $yes_no_values,
1799
-            $default_reg_status_values
1800
-        );
1801
-        EEH_Template::display_template(
1802
-            EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php',
1803
-            $template_args
1804
-        );
1805
-    }
1806
-
1807
-
1808
-    /**
1809
-     * _get_events()
1810
-     * This method simply returns all the events (for the given _view and paging)
1811
-     *
1812
-     * @access public
1813
-     * @param int  $per_page     count of items per page (20 default);
1814
-     * @param int  $current_page what is the current page being viewed.
1815
-     * @param bool $count        if TRUE then we just return a count of ALL events matching the given _view.
1816
-     *                           If FALSE then we return an array of event objects
1817
-     *                           that match the given _view and paging parameters.
1818
-     * @return array an array of event objects.
1819
-     * @throws EE_Error
1820
-     * @throws InvalidArgumentException
1821
-     * @throws InvalidDataTypeException
1822
-     * @throws InvalidInterfaceException
1823
-     * @throws ReflectionException
1824
-     * @throws Exception
1825
-     * @throws Exception
1826
-     * @throws Exception
1827
-     */
1828
-    public function get_events($per_page = 10, $current_page = 1, $count = false)
1829
-    {
1830
-        $EEME = $this->_event_model();
1831
-        $offset = ($current_page - 1) * $per_page;
1832
-        $limit = $count ? null : $offset . ',' . $per_page;
1833
-        $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID';
1834
-        $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC';
1835
-        if (isset($this->_req_data['month_range'])) {
1836
-            $pieces = explode(' ', $this->_req_data['month_range'], 3);
1837
-            // simulate the FIRST day of the month, that fixes issues for months like February
1838
-            // where PHP doesn't know what to assume for date.
1839
-            // @see https://events.codebasehq.com/projects/event-espresso/tickets/10437
1840
-            $month_r = ! empty($pieces[0]) ? date('m', EEH_DTT_Helper::first_of_month_timestamp($pieces[0])) : '';
1841
-            $year_r = ! empty($pieces[1]) ? $pieces[1] : '';
1842
-        }
1843
-        $where = array();
1844
-        $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
1845
-        // determine what post_status our condition will have for the query.
1846
-        switch ($status) {
1847
-            case 'month':
1848
-            case 'today':
1849
-            case null:
1850
-            case 'all':
1851
-                break;
1852
-            case 'draft':
1853
-                $where['status'] = array('IN', array('draft', 'auto-draft'));
1854
-                break;
1855
-            default:
1856
-                $where['status'] = $status;
1857
-        }
1858
-        // categories?
1859
-        $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0
1860
-            ? $this->_req_data['EVT_CAT'] : null;
1861
-        if (! empty($category)) {
1862
-            $where['Term_Taxonomy.taxonomy'] = EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY;
1863
-            $where['Term_Taxonomy.term_id'] = $category;
1864
-        }
1865
-        // date where conditions
1866
-        $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start');
1867
-        if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] !== '') {
1868
-            $DateTime = new DateTime(
1869
-                $year_r . '-' . $month_r . '-01 00:00:00',
1870
-                new DateTimeZone(EEM_Datetime::instance()->get_timezone())
1871
-            );
1872
-            $start = $DateTime->format(implode(' ', $start_formats));
1873
-            $end = $DateTime->setDate(
1874
-                $year_r,
1875
-                $month_r,
1876
-                $DateTime
1877
-                    ->format('t')
1878
-            )->setTime(23, 59, 59)
1879
-                            ->format(implode(' ', $start_formats));
1880
-            $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1881
-        } elseif (isset($this->_req_data['status']) && $this->_req_data['status'] === 'today') {
1882
-            $DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone()));
1883
-            $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats));
1884
-            $end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats));
1885
-            $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1886
-        } elseif (isset($this->_req_data['status']) && $this->_req_data['status'] === 'month') {
1887
-            $now = date('Y-m-01');
1888
-            $DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone()));
1889
-            $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats));
1890
-            $end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t'))
1891
-                            ->setTime(23, 59, 59)
1892
-                            ->format(implode(' ', $start_formats));
1893
-            $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1894
-        }
1895
-        if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
1896
-            $where['EVT_wp_user'] = get_current_user_id();
1897
-        } elseif (! isset($where['status'])
1898
-            && ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')
1899
-        ) {
1900
-            $where['OR'] = array(
1901
-                'status*restrict_private' => array('!=', 'private'),
1902
-                'AND'                     => array(
1903
-                    'status*inclusive' => array('=', 'private'),
1904
-                    'EVT_wp_user'      => get_current_user_id(),
1905
-                ),
1906
-            );
1907
-        }
1908
-
1909
-        if (isset($this->_req_data['EVT_wp_user'])
1910
-            && (int) $this->_req_data['EVT_wp_user'] !== (int) get_current_user_id()
1911
-            && EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')
1912
-        ) {
1913
-            $where['EVT_wp_user'] = $this->_req_data['EVT_wp_user'];
1914
-        }
1915
-        // search query handling
1916
-        if (isset($this->_req_data['s'])) {
1917
-            $search_string = '%' . $this->_req_data['s'] . '%';
1918
-            $where['OR'] = array(
1919
-                'EVT_name'       => array('LIKE', $search_string),
1920
-                'EVT_desc'       => array('LIKE', $search_string),
1921
-                'EVT_short_desc' => array('LIKE', $search_string),
1922
-            );
1923
-        }
1924
-        // filter events by venue.
1925
-        if (isset($this->_req_data['venue']) && ! empty($this->_req_data['venue'])) {
1926
-            $where['Venue.VNU_ID'] = absint($this->_req_data['venue']);
1927
-        }
1928
-        $where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data);
1929
-        $query_params = apply_filters(
1930
-            'FHEE__Events_Admin_Page__get_events__query_params',
1931
-            array(
1932
-                $where,
1933
-                'limit'    => $limit,
1934
-                'order_by' => $orderby,
1935
-                'order'    => $order,
1936
-                'group_by' => 'EVT_ID',
1937
-            ),
1938
-            $this->_req_data
1939
-        );
1940
-        // let's first check if we have special requests coming in.
1941
-        if (isset($this->_req_data['active_status'])) {
1942
-            switch ($this->_req_data['active_status']) {
1943
-                case 'upcoming':
1944
-                    return $EEME->get_upcoming_events($query_params, $count);
1945
-                    break;
1946
-                case 'expired':
1947
-                    return $EEME->get_expired_events($query_params, $count);
1948
-                    break;
1949
-                case 'active':
1950
-                    return $EEME->get_active_events($query_params, $count);
1951
-                    break;
1952
-                case 'inactive':
1953
-                    return $EEME->get_inactive_events($query_params, $count);
1954
-                    break;
1955
-            }
1956
-        }
1957
-
1958
-        $events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params);
1959
-        return $events;
1960
-    }
1961
-
1962
-
1963
-    /**
1964
-     * handling for WordPress CPT actions (trash, restore, delete)
1965
-     *
1966
-     * @param string $post_id
1967
-     * @throws EE_Error
1968
-     * @throws InvalidArgumentException
1969
-     * @throws InvalidDataTypeException
1970
-     * @throws InvalidInterfaceException
1971
-     * @throws ReflectionException
1972
-     */
1973
-    public function trash_cpt_item($post_id)
1974
-    {
1975
-        $this->_req_data['EVT_ID'] = $post_id;
1976
-        $this->_trash_or_restore_event('trash', false);
1977
-    }
1978
-
1979
-
1980
-    /**
1981
-     * @param string $post_id
1982
-     * @throws EE_Error
1983
-     * @throws InvalidArgumentException
1984
-     * @throws InvalidDataTypeException
1985
-     * @throws InvalidInterfaceException
1986
-     * @throws ReflectionException
1987
-     */
1988
-    public function restore_cpt_item($post_id)
1989
-    {
1990
-        $this->_req_data['EVT_ID'] = $post_id;
1991
-        $this->_trash_or_restore_event('draft', false);
1992
-    }
1993
-
1994
-
1995
-    /**
1996
-     * @param string $post_id
1997
-     * @throws EE_Error
1998
-     * @throws InvalidArgumentException
1999
-     * @throws InvalidDataTypeException
2000
-     * @throws InvalidInterfaceException
2001
-     * @throws ReflectionException
2002
-     */
2003
-    public function delete_cpt_item($post_id)
2004
-    {
2005
-        $this->_req_data['EVT_ID'] = $post_id;
2006
-        $this->_delete_event(false);
2007
-    }
2008
-
2009
-
2010
-    /**
2011
-     * _trash_or_restore_event
2012
-     *
2013
-     * @access protected
2014
-     * @param string $event_status
2015
-     * @param bool   $redirect_after
2016
-     * @throws EE_Error
2017
-     * @throws InvalidArgumentException
2018
-     * @throws InvalidDataTypeException
2019
-     * @throws InvalidInterfaceException
2020
-     * @throws ReflectionException
2021
-     */
2022
-    protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = true)
2023
-    {
2024
-        // determine the event id and set to array.
2025
-        $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : false;
2026
-        // loop thru events
2027
-        if ($EVT_ID) {
2028
-            // clean status
2029
-            $event_status = sanitize_key($event_status);
2030
-            // grab status
2031
-            if (! empty($event_status)) {
2032
-                $success = $this->_change_event_status($EVT_ID, $event_status);
2033
-            } else {
2034
-                $success = false;
2035
-                $msg = esc_html__(
2036
-                    'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.',
2037
-                    'event_espresso'
2038
-                );
2039
-                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2040
-            }
2041
-        } else {
2042
-            $success = false;
2043
-            $msg = esc_html__(
2044
-                'An error occurred. The event could not be moved to the trash because a valid event ID was not not supplied.',
2045
-                'event_espresso'
2046
-            );
2047
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2048
-        }
2049
-        $action = $event_status === 'trash' ? 'moved to the trash' : 'restored from the trash';
2050
-        if ($redirect_after) {
2051
-            $this->_redirect_after_action($success, 'Event', $action, array('action' => 'default'));
2052
-        }
2053
-    }
2054
-
2055
-
2056
-    /**
2057
-     * _trash_or_restore_events
2058
-     *
2059
-     * @access protected
2060
-     * @param string $event_status
2061
-     * @return void
2062
-     * @throws EE_Error
2063
-     * @throws InvalidArgumentException
2064
-     * @throws InvalidDataTypeException
2065
-     * @throws InvalidInterfaceException
2066
-     * @throws ReflectionException
2067
-     */
2068
-    protected function _trash_or_restore_events($event_status = 'trash')
2069
-    {
2070
-        // clean status
2071
-        $event_status = sanitize_key($event_status);
2072
-        // grab status
2073
-        if (! empty($event_status)) {
2074
-            $success = true;
2075
-            // determine the event id and set to array.
2076
-            $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array();
2077
-            // loop thru events
2078
-            foreach ($EVT_IDs as $EVT_ID) {
2079
-                if ($EVT_ID = absint($EVT_ID)) {
2080
-                    $results = $this->_change_event_status($EVT_ID, $event_status);
2081
-                    $success = $results !== false ? $success : false;
2082
-                } else {
2083
-                    $msg = sprintf(
2084
-                        esc_html__(
2085
-                            'An error occurred. Event #%d could not be moved to the trash because a valid event ID was not not supplied.',
2086
-                            'event_espresso'
2087
-                        ),
2088
-                        $EVT_ID
2089
-                    );
2090
-                    EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2091
-                    $success = false;
2092
-                }
2093
-            }
2094
-        } else {
2095
-            $success = false;
2096
-            $msg = esc_html__(
2097
-                'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.',
2098
-                'event_espresso'
2099
-            );
2100
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2101
-        }
2102
-        // in order to force a pluralized result message we need to send back a success status greater than 1
2103
-        $success = $success ? 2 : false;
2104
-        $action = $event_status === 'trash' ? 'moved to the trash' : 'restored from the trash';
2105
-        $this->_redirect_after_action($success, 'Events', $action, array('action' => 'default'));
2106
-    }
2107
-
2108
-
2109
-    /**
2110
-     * _trash_or_restore_events
2111
-     *
2112
-     * @access  private
2113
-     * @param int    $EVT_ID
2114
-     * @param string $event_status
2115
-     * @return bool
2116
-     * @throws EE_Error
2117
-     * @throws InvalidArgumentException
2118
-     * @throws InvalidDataTypeException
2119
-     * @throws InvalidInterfaceException
2120
-     * @throws ReflectionException
2121
-     */
2122
-    private function _change_event_status($EVT_ID = 0, $event_status = '')
2123
-    {
2124
-        // grab event id
2125
-        if (! $EVT_ID) {
2126
-            $msg = esc_html__(
2127
-                'An error occurred. No Event ID or an invalid Event ID was received.',
2128
-                'event_espresso'
2129
-            );
2130
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2131
-            return false;
2132
-        }
2133
-        $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID);
2134
-        // clean status
2135
-        $event_status = sanitize_key($event_status);
2136
-        // grab status
2137
-        if (empty($event_status)) {
2138
-            $msg = esc_html__(
2139
-                'An error occurred. No Event Status or an invalid Event Status was received.',
2140
-                'event_espresso'
2141
-            );
2142
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2143
-            return false;
2144
-        }
2145
-        // was event trashed or restored ?
2146
-        switch ($event_status) {
2147
-            case 'draft':
2148
-                $action = 'restored from the trash';
2149
-                $hook = 'AHEE_event_restored_from_trash';
2150
-                break;
2151
-            case 'trash':
2152
-                $action = 'moved to the trash';
2153
-                $hook = 'AHEE_event_moved_to_trash';
2154
-                break;
2155
-            default:
2156
-                $action = 'updated';
2157
-                $hook = false;
2158
-        }
2159
-        // use class to change status
2160
-        $this->_cpt_model_obj->set_status($event_status);
2161
-        $success = $this->_cpt_model_obj->save();
2162
-        if ($success === false) {
2163
-            $msg = sprintf(esc_html__('An error occurred. The event could not be %s.', 'event_espresso'), $action);
2164
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2165
-            return false;
2166
-        }
2167
-        if ($hook) {
2168
-            do_action($hook);
2169
-        }
2170
-        return true;
2171
-    }
2172
-
2173
-
2174
-    /**
2175
-     * _delete_event
2176
-     *
2177
-     * @access protected
2178
-     * @param bool $redirect_after
2179
-     * @throws EE_Error
2180
-     * @throws InvalidArgumentException
2181
-     * @throws InvalidDataTypeException
2182
-     * @throws InvalidInterfaceException
2183
-     * @throws ReflectionException
2184
-     */
2185
-    protected function _delete_event($redirect_after = true)
2186
-    {
2187
-        // determine the event id and set to array.
2188
-        $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : null;
2189
-        $EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID;
2190
-        // loop thru events
2191
-        if ($EVT_ID) {
2192
-            $success = $this->_permanently_delete_event($EVT_ID);
2193
-            // get list of events with no prices
2194
-            $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array());
2195
-            // remove this event from the list of events with no prices
2196
-            if (isset($espresso_no_ticket_prices[ $EVT_ID ])) {
2197
-                unset($espresso_no_ticket_prices[ $EVT_ID ]);
2198
-            }
2199
-            update_option('ee_no_ticket_prices', $espresso_no_ticket_prices);
2200
-        } else {
2201
-            $success = false;
2202
-            $msg = esc_html__(
2203
-                'An error occurred. An event could not be deleted because a valid event ID was not not supplied.',
2204
-                'event_espresso'
2205
-            );
2206
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2207
-        }
2208
-        if ($redirect_after) {
2209
-            $this->_redirect_after_action(
2210
-                $success,
2211
-                'Event',
2212
-                'deleted',
2213
-                array('action' => 'default', 'status' => 'trash')
2214
-            );
2215
-        }
2216
-    }
2217
-
2218
-
2219
-    /**
2220
-     * _delete_events
2221
-     *
2222
-     * @access protected
2223
-     * @return void
2224
-     * @throws EE_Error
2225
-     * @throws InvalidArgumentException
2226
-     * @throws InvalidDataTypeException
2227
-     * @throws InvalidInterfaceException
2228
-     * @throws ReflectionException
2229
-     */
2230
-    protected function _delete_events()
2231
-    {
2232
-        $success = true;
2233
-        // get list of events with no prices
2234
-        $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array());
2235
-        // determine the event id and set to array.
2236
-        $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array();
2237
-        // loop thru events
2238
-        foreach ($EVT_IDs as $EVT_ID) {
2239
-            $EVT_ID = absint($EVT_ID);
2240
-            if ($EVT_ID) {
2241
-                $results = $this->_permanently_delete_event($EVT_ID);
2242
-                $success = $results !== false ? $success : false;
2243
-                // remove this event from the list of events with no prices
2244
-                unset($espresso_no_ticket_prices[ $EVT_ID ]);
2245
-            } else {
2246
-                $success = false;
2247
-                $msg = esc_html__(
2248
-                    'An error occurred. An event could not be deleted because a valid event ID was not not supplied.',
2249
-                    'event_espresso'
2250
-                );
2251
-                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2252
-            }
2253
-        }
2254
-        update_option('ee_no_ticket_prices', $espresso_no_ticket_prices);
2255
-        // in order to force a pluralized result message we need to send back a success status greater than 1
2256
-        $success = $success ? 2 : false;
2257
-        $this->_redirect_after_action($success, 'Events', 'deleted', array('action' => 'default'));
2258
-    }
2259
-
2260
-
2261
-    /**
2262
-     * _permanently_delete_event
2263
-     *
2264
-     * @access  private
2265
-     * @param int $EVT_ID
2266
-     * @return bool
2267
-     * @throws EE_Error
2268
-     * @throws InvalidArgumentException
2269
-     * @throws InvalidDataTypeException
2270
-     * @throws InvalidInterfaceException
2271
-     * @throws ReflectionException
2272
-     */
2273
-    private function _permanently_delete_event($EVT_ID = 0)
2274
-    {
2275
-        // grab event id
2276
-        if (! $EVT_ID) {
2277
-            $msg = esc_html__(
2278
-                'An error occurred. No Event ID or an invalid Event ID was received.',
2279
-                'event_espresso'
2280
-            );
2281
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2282
-            return false;
2283
-        }
2284
-        if (! $this->_cpt_model_obj instanceof EE_Event
2285
-            || $this->_cpt_model_obj->ID() !== $EVT_ID
2286
-        ) {
2287
-            $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID);
2288
-        }
2289
-        if (! $this->_cpt_model_obj instanceof EE_Event) {
2290
-            return false;
2291
-        }
2292
-        // need to delete related tickets and prices first.
2293
-        $datetimes = $this->_cpt_model_obj->get_many_related('Datetime');
2294
-        foreach ($datetimes as $datetime) {
2295
-            $this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime');
2296
-            $tickets = $datetime->get_many_related('Ticket');
2297
-            foreach ($tickets as $ticket) {
2298
-                $ticket->_remove_relation_to($datetime, 'Datetime');
2299
-                $ticket->delete_related_permanently('Price');
2300
-                $ticket->delete_permanently();
2301
-            }
2302
-            $datetime->delete();
2303
-        }
2304
-        // what about related venues or terms?
2305
-        $venues = $this->_cpt_model_obj->get_many_related('Venue');
2306
-        foreach ($venues as $venue) {
2307
-            $this->_cpt_model_obj->_remove_relation_to($venue, 'Venue');
2308
-        }
2309
-        // any attached question groups?
2310
-        $question_groups = $this->_cpt_model_obj->get_many_related('Question_Group');
2311
-        if (! empty($question_groups)) {
2312
-            foreach ($question_groups as $question_group) {
2313
-                $this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group');
2314
-            }
2315
-        }
2316
-        // Message Template Groups
2317
-        $this->_cpt_model_obj->_remove_relations('Message_Template_Group');
2318
-        /** @type EE_Term_Taxonomy[] $term_taxonomies */
2319
-        $term_taxonomies = $this->_cpt_model_obj->term_taxonomies();
2320
-        foreach ($term_taxonomies as $term_taxonomy) {
2321
-            $this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy);
2322
-        }
2323
-        $success = $this->_cpt_model_obj->delete_permanently();
2324
-        // did it all go as planned ?
2325
-        if ($success) {
2326
-            $msg = sprintf(esc_html__('Event ID # %d has been deleted.', 'event_espresso'), $EVT_ID);
2327
-            EE_Error::add_success($msg);
2328
-        } else {
2329
-            $msg = sprintf(
2330
-                esc_html__('An error occurred. Event ID # %d could not be deleted.', 'event_espresso'),
2331
-                $EVT_ID
2332
-            );
2333
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2334
-            return false;
2335
-        }
2336
-        do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID);
2337
-        return true;
2338
-    }
2339
-
2340
-
2341
-    /**
2342
-     * get total number of events
2343
-     *
2344
-     * @access public
2345
-     * @return int
2346
-     * @throws EE_Error
2347
-     * @throws InvalidArgumentException
2348
-     * @throws InvalidDataTypeException
2349
-     * @throws InvalidInterfaceException
2350
-     */
2351
-    public function total_events()
2352
-    {
2353
-        $count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true);
2354
-        return $count;
2355
-    }
2356
-
2357
-
2358
-    /**
2359
-     * get total number of draft events
2360
-     *
2361
-     * @access public
2362
-     * @return int
2363
-     * @throws EE_Error
2364
-     * @throws InvalidArgumentException
2365
-     * @throws InvalidDataTypeException
2366
-     * @throws InvalidInterfaceException
2367
-     */
2368
-    public function total_events_draft()
2369
-    {
2370
-        $where = array(
2371
-            'status' => array('IN', array('draft', 'auto-draft')),
2372
-        );
2373
-        $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
2374
-        return $count;
2375
-    }
2376
-
2377
-
2378
-    /**
2379
-     * get total number of trashed events
2380
-     *
2381
-     * @access public
2382
-     * @return int
2383
-     * @throws EE_Error
2384
-     * @throws InvalidArgumentException
2385
-     * @throws InvalidDataTypeException
2386
-     * @throws InvalidInterfaceException
2387
-     */
2388
-    public function total_trashed_events()
2389
-    {
2390
-        $where = array(
2391
-            'status' => 'trash',
2392
-        );
2393
-        $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
2394
-        return $count;
2395
-    }
2396
-
2397
-
2398
-    /**
2399
-     *    _default_event_settings
2400
-     *    This generates the Default Settings Tab
2401
-     *
2402
-     * @return void
2403
-     * @throws DomainException
2404
-     * @throws EE_Error
2405
-     * @throws InvalidArgumentException
2406
-     * @throws InvalidDataTypeException
2407
-     * @throws InvalidInterfaceException
2408
-     */
2409
-    protected function _default_event_settings()
2410
-    {
2411
-        $this->_set_add_edit_form_tags('update_default_event_settings');
2412
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
2413
-        $this->_template_args['admin_page_content'] = $this->_default_event_settings_form()->get_html();
2414
-        $this->display_admin_page_with_sidebar();
2415
-    }
2416
-
2417
-
2418
-    /**
2419
-     * Return the form for event settings.
2420
-     *
2421
-     * @return EE_Form_Section_Proper
2422
-     * @throws EE_Error
2423
-     */
2424
-    protected function _default_event_settings_form()
2425
-    {
2426
-        $registration_config = EE_Registry::instance()->CFG->registration;
2427
-        $registration_stati_for_selection = EEM_Registration::reg_status_array(
2428
-            // exclude
2429
-            array(
2430
-                EEM_Registration::status_id_cancelled,
2431
-                EEM_Registration::status_id_declined,
2432
-                EEM_Registration::status_id_incomplete,
2433
-                EEM_Registration::status_id_wait_list,
2434
-            ),
2435
-            true
2436
-        );
2437
-        return new EE_Form_Section_Proper(
2438
-            array(
2439
-                'name'            => 'update_default_event_settings',
2440
-                'html_id'         => 'update_default_event_settings',
2441
-                'html_class'      => 'form-table',
2442
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
2443
-                'subsections'     => apply_filters(
2444
-                    'FHEE__Events_Admin_Page___default_event_settings_form__form_subsections',
2445
-                    array(
2446
-                        'default_reg_status'  => new EE_Select_Input(
2447
-                            $registration_stati_for_selection,
2448
-                            array(
2449
-                                'default'         => isset($registration_config->default_STS_ID)
2450
-                                                     && array_key_exists(
2451
-                                                         $registration_config->default_STS_ID,
2452
-                                                         $registration_stati_for_selection
2453
-                                                     )
2454
-                                    ? sanitize_text_field($registration_config->default_STS_ID)
2455
-                                    : EEM_Registration::status_id_pending_payment,
2456
-                                'html_label_text' => esc_html__('Default Registration Status', 'event_espresso')
2457
-                                                     . EEH_Template::get_help_tab_link(
2458
-                                                         'default_settings_status_help_tab'
2459
-                                                     ),
2460
-                                'html_help_text'  => esc_html__(
2461
-                                    'This setting allows you to preselect what the default registration status setting is when creating an event.  Note that changing this setting does NOT retroactively apply it to existing events.',
2462
-                                    'event_espresso'
2463
-                                ),
2464
-                            )
2465
-                        ),
2466
-                        'default_max_tickets' => new EE_Integer_Input(
2467
-                            array(
2468
-                                'default'         => isset($registration_config->default_maximum_number_of_tickets)
2469
-                                    ? $registration_config->default_maximum_number_of_tickets
2470
-                                    : EEM_Event::get_default_additional_limit(),
2471
-                                'html_label_text' => esc_html__(
2472
-                                    'Default Maximum Tickets Allowed Per Order:',
2473
-                                    'event_espresso'
2474
-                                )
2475
-                                                     . EEH_Template::get_help_tab_link(
2476
-                                                         'default_maximum_tickets_help_tab"'
2477
-                                                     ),
2478
-                                'html_help_text'  => esc_html__(
2479
-                                    'This setting allows you to indicate what will be the default for the maximum number of tickets per order when creating new events.',
2480
-                                    'event_espresso'
2481
-                                ),
2482
-                            )
2483
-                        ),
2484
-                    )
2485
-                ),
2486
-            )
2487
-        );
2488
-    }
2489
-
2490
-
2491
-    /**
2492
-     * @return void
2493
-     * @throws EE_Error
2494
-     * @throws InvalidArgumentException
2495
-     * @throws InvalidDataTypeException
2496
-     * @throws InvalidInterfaceException
2497
-     */
2498
-    protected function _update_default_event_settings()
2499
-    {
2500
-        $form = $this->_default_event_settings_form();
2501
-        if ($form->was_submitted()) {
2502
-            $form->receive_form_submission();
2503
-            if ($form->is_valid()) {
2504
-                $registration_config = EE_Registry::instance()->CFG->registration;
2505
-                $valid_data = $form->valid_data();
2506
-                if (isset($valid_data['default_reg_status'])) {
2507
-                    $registration_config->default_STS_ID = $valid_data['default_reg_status'];
2508
-                }
2509
-                if (isset($valid_data['default_max_tickets'])) {
2510
-                    $registration_config->default_maximum_number_of_tickets = $valid_data['default_max_tickets'];
2511
-                }
2512
-                do_action(
2513
-                    'AHEE__Events_Admin_Page___update_default_event_settings',
2514
-                    $valid_data,
2515
-                    EE_Registry::instance()->CFG,
2516
-                    $this
2517
-                );
2518
-                // update because data was valid!
2519
-                EE_Registry::instance()->CFG->update_espresso_config();
2520
-                EE_Error::overwrite_success();
2521
-                EE_Error::add_success(
2522
-                    __('Default Event Settings were updated', 'event_espresso')
2523
-                );
2524
-            }
2525
-        }
2526
-        $this->_redirect_after_action(0, '', '', array('action' => 'default_event_settings'), true);
2527
-    }
2528
-
2529
-
2530
-    /*************        Templates        *************/
2531
-    protected function _template_settings()
2532
-    {
2533
-        $this->_admin_page_title = esc_html__('Template Settings (Preview)', 'event_espresso');
2534
-        $this->_template_args['preview_img'] = '<img src="'
2535
-                                               . EVENTS_ASSETS_URL
2536
-                                               . '/images/'
2537
-                                               . 'caffeinated_template_features.jpg" alt="'
2538
-                                               . esc_attr__('Template Settings Preview screenshot', 'event_espresso')
2539
-                                               . '" />';
2540
-        $this->_template_args['preview_text'] = '<strong>'
2541
-                                                . esc_html__(
2542
-                                                    'Template Settings is a feature that is only available in the premium version of Event Espresso 4 which is available with a support license purchase on EventEspresso.com. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.',
2543
-                                                    'event_espresso'
2544
-                                                ) . '</strong>';
2545
-        $this->display_admin_caf_preview_page('template_settings_tab');
2546
-    }
2547
-
2548
-
2549
-    /** Event Category Stuff **/
2550
-    /**
2551
-     * set the _category property with the category object for the loaded page.
2552
-     *
2553
-     * @access private
2554
-     * @return void
2555
-     */
2556
-    private function _set_category_object()
2557
-    {
2558
-        if (isset($this->_category->id) && ! empty($this->_category->id)) {
2559
-            return;
2560
-        } //already have the category object so get out.
2561
-        // set default category object
2562
-        $this->_set_empty_category_object();
2563
-        // only set if we've got an id
2564
-        if (! isset($this->_req_data['EVT_CAT_ID'])) {
2565
-            return;
2566
-        }
2567
-        $category_id = absint($this->_req_data['EVT_CAT_ID']);
2568
-        $term = get_term($category_id, EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY);
2569
-        if (! empty($term)) {
2570
-            $this->_category->category_name = $term->name;
2571
-            $this->_category->category_identifier = $term->slug;
2572
-            $this->_category->category_desc = $term->description;
2573
-            $this->_category->id = $term->term_id;
2574
-            $this->_category->parent = $term->parent;
2575
-        }
2576
-    }
2577
-
2578
-
2579
-    /**
2580
-     * Clears out category properties.
2581
-     */
2582
-    private function _set_empty_category_object()
2583
-    {
2584
-        $this->_category = new stdClass();
2585
-        $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = '';
2586
-        $this->_category->id = $this->_category->parent = 0;
2587
-    }
2588
-
2589
-
2590
-    /**
2591
-     * @throws DomainException
2592
-     * @throws EE_Error
2593
-     * @throws InvalidArgumentException
2594
-     * @throws InvalidDataTypeException
2595
-     * @throws InvalidInterfaceException
2596
-     */
2597
-    protected function _category_list_table()
2598
-    {
2599
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2600
-        $this->_search_btn_label = esc_html__('Categories', 'event_espresso');
2601
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
2602
-            'add_category',
2603
-            'add_category',
2604
-            array(),
2605
-            'add-new-h2'
2606
-        );
2607
-        $this->display_admin_list_table_page_with_sidebar();
2608
-    }
2609
-
2610
-
2611
-    /**
2612
-     * Output category details view.
2613
-     *
2614
-     * @param string $view
2615
-     * @throws DomainException
2616
-     * @throws EE_Error
2617
-     * @throws InvalidArgumentException
2618
-     * @throws InvalidDataTypeException
2619
-     * @throws InvalidInterfaceException
2620
-     */
2621
-    protected function _category_details($view)
2622
-    {
2623
-        // load formatter helper
2624
-        // load field generator helper
2625
-        $route = $view === 'edit' ? 'update_category' : 'insert_category';
2626
-        $this->_set_add_edit_form_tags($route);
2627
-        $this->_set_category_object();
2628
-        $id = ! empty($this->_category->id) ? $this->_category->id : '';
2629
-        $delete_action = 'delete_category';
2630
-        // custom redirect
2631
-        $redirect = EE_Admin_Page::add_query_args_and_nonce(
2632
-            array('action' => 'category_list'),
2633
-            $this->_admin_base_url
2634
-        );
2635
-        $this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect);
2636
-        // take care of contents
2637
-        $this->_template_args['admin_page_content'] = $this->_category_details_content();
2638
-        $this->display_admin_page_with_sidebar();
2639
-    }
2640
-
2641
-
2642
-    /**
2643
-     * Output category details content.
2644
-     *
2645
-     * @throws DomainException
2646
-     */
2647
-    protected function _category_details_content()
2648
-    {
2649
-        $editor_args['category_desc'] = array(
2650
-            'type'          => 'wp_editor',
2651
-            'value'         => EEH_Formatter::admin_format_content($this->_category->category_desc),
2652
-            'class'         => 'my_editor_custom',
2653
-            'wpeditor_args' => array('media_buttons' => false),
2654
-        );
2655
-        $_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array');
2656
-        $all_terms = get_terms(
2657
-            array(EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY),
2658
-            array('hide_empty' => 0, 'exclude' => array($this->_category->id))
2659
-        );
2660
-        // setup category select for term parents.
2661
-        $category_select_values[] = array(
2662
-            'text' => esc_html__('No Parent', 'event_espresso'),
2663
-            'id'   => 0,
2664
-        );
2665
-        foreach ($all_terms as $term) {
2666
-            $category_select_values[] = array(
2667
-                'text' => $term->name,
2668
-                'id'   => $term->term_id,
2669
-            );
2670
-        }
2671
-        $category_select = EEH_Form_Fields::select_input(
2672
-            'category_parent',
2673
-            $category_select_values,
2674
-            $this->_category->parent
2675
-        );
2676
-        $template_args = array(
2677
-            'category'                 => $this->_category,
2678
-            'category_select'          => $category_select,
2679
-            'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'),
2680
-            'category_desc_editor'     => $_wp_editor['category_desc']['field'],
2681
-            'disable'                  => '',
2682
-            'disabled_message'         => false,
2683
-        );
2684
-        $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php';
2685
-        return EEH_Template::display_template($template, $template_args, true);
2686
-    }
2687
-
2688
-
2689
-    /**
2690
-     * Handles deleting categories.
2691
-     */
2692
-    protected function _delete_categories()
2693
-    {
2694
-        $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array) $this->_req_data['EVT_CAT_ID']
2695
-            : (array) $this->_req_data['category_id'];
2696
-        foreach ($cat_ids as $cat_id) {
2697
-            $this->_delete_category($cat_id);
2698
-        }
2699
-        // doesn't matter what page we're coming from... we're going to the same place after delete.
2700
-        $query_args = array(
2701
-            'action' => 'category_list',
2702
-        );
2703
-        $this->_redirect_after_action(0, '', '', $query_args);
2704
-    }
2705
-
2706
-
2707
-    /**
2708
-     * Handles deleting specific category.
2709
-     *
2710
-     * @param int $cat_id
2711
-     */
2712
-    protected function _delete_category($cat_id)
2713
-    {
2714
-        $cat_id = absint($cat_id);
2715
-        wp_delete_term($cat_id, EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY);
2716
-    }
2717
-
2718
-
2719
-    /**
2720
-     * Handles triggering the update or insertion of a new category.
2721
-     *
2722
-     * @param bool $new_category true means we're triggering the insert of a new category.
2723
-     * @throws EE_Error
2724
-     * @throws InvalidArgumentException
2725
-     * @throws InvalidDataTypeException
2726
-     * @throws InvalidInterfaceException
2727
-     */
2728
-    protected function _insert_or_update_category($new_category)
2729
-    {
2730
-        $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(true);
2731
-        $success = 0; // we already have a success message so lets not send another.
2732
-        if ($cat_id) {
2733
-            $query_args = array(
2734
-                'action'     => 'edit_category',
2735
-                'EVT_CAT_ID' => $cat_id,
2736
-            );
2737
-        } else {
2738
-            $query_args = array('action' => 'add_category');
2739
-        }
2740
-        $this->_redirect_after_action($success, '', '', $query_args, true);
2741
-    }
2742
-
2743
-
2744
-    /**
2745
-     * Inserts or updates category
2746
-     *
2747
-     * @param bool $update (true indicates we're updating a category).
2748
-     * @return bool|mixed|string
2749
-     */
2750
-    private function _insert_category($update = false)
2751
-    {
2752
-        $cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : '';
2753
-        $category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : '';
2754
-        $category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : '';
2755
-        $category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0;
2756
-        if (empty($category_name)) {
2757
-            $msg = esc_html__('You must add a name for the category.', 'event_espresso');
2758
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2759
-            return false;
2760
-        }
2761
-        $term_args = array(
2762
-            'name'        => $category_name,
2763
-            'description' => $category_desc,
2764
-            'parent'      => $category_parent,
2765
-        );
2766
-        // was the category_identifier input disabled?
2767
-        if (isset($this->_req_data['category_identifier'])) {
2768
-            $term_args['slug'] = $this->_req_data['category_identifier'];
2769
-        }
2770
-        $insert_ids = $update
2771
-            ? wp_update_term($cat_id, EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY, $term_args)
2772
-            : wp_insert_term($category_name, EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY, $term_args);
2773
-        if (! is_array($insert_ids)) {
2774
-            $msg = esc_html__(
2775
-                'An error occurred and the category has not been saved to the database.',
2776
-                'event_espresso'
2777
-            );
2778
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2779
-        } else {
2780
-            $cat_id = $insert_ids['term_id'];
2781
-            $msg = sprintf(esc_html__('The category %s was successfully saved', 'event_espresso'), $category_name);
2782
-            EE_Error::add_success($msg);
2783
-        }
2784
-        return $cat_id;
2785
-    }
2786
-
2787
-
2788
-    /**
2789
-     * Gets categories or count of categories matching the arguments in the request.
2790
-     *
2791
-     * @param int  $per_page
2792
-     * @param int  $current_page
2793
-     * @param bool $count
2794
-     * @return EE_Base_Class[]|EE_Term_Taxonomy[]|int
2795
-     * @throws EE_Error
2796
-     * @throws InvalidArgumentException
2797
-     * @throws InvalidDataTypeException
2798
-     * @throws InvalidInterfaceException
2799
-     */
2800
-    public function get_categories($per_page = 10, $current_page = 1, $count = false)
2801
-    {
2802
-        // testing term stuff
2803
-        $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id';
2804
-        $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC';
2805
-        $limit = ($current_page - 1) * $per_page;
2806
-        $where = array('taxonomy' => EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY);
2807
-        if (isset($this->_req_data['s'])) {
2808
-            $sstr = '%' . $this->_req_data['s'] . '%';
2809
-            $where['OR'] = array(
2810
-                'Term.name'   => array('LIKE', $sstr),
2811
-                'description' => array('LIKE', $sstr),
2812
-            );
2813
-        }
2814
-        $query_params = array(
2815
-            $where,
2816
-            'order_by'   => array($orderby => $order),
2817
-            'limit'      => $limit . ',' . $per_page,
2818
-            'force_join' => array('Term'),
2819
-        );
2820
-        $categories = $count
2821
-            ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id')
2822
-            : EEM_Term_Taxonomy::instance()->get_all($query_params);
2823
-        return $categories;
2824
-    }
2825
-
2826
-    /* end category stuff */
2827
-    /**************/
2828
-
2829
-
2830
-    /**
2831
-     * Callback for the `ee_save_timezone_setting` ajax action.
2832
-     *
2833
-     * @throws EE_Error
2834
-     * @throws InvalidArgumentException
2835
-     * @throws InvalidDataTypeException
2836
-     * @throws InvalidInterfaceException
2837
-     */
2838
-    public function save_timezonestring_setting()
2839
-    {
2840
-        $timezone_string = isset($this->_req_data['timezone_selected'])
2841
-            ? $this->_req_data['timezone_selected']
2842
-            : '';
2843
-        if (empty($timezone_string) || ! EEH_DTT_Helper::validate_timezone($timezone_string, false)) {
2844
-            EE_Error::add_error(
2845
-                esc_html__('An invalid timezone string submitted.', 'event_espresso'),
2846
-                __FILE__,
2847
-                __FUNCTION__,
2848
-                __LINE__
2849
-            );
2850
-            $this->_template_args['error'] = true;
2851
-            $this->_return_json();
2852
-        }
2853
-
2854
-        update_option('timezone_string', $timezone_string);
2855
-        EE_Error::add_success(
2856
-            esc_html__('Your timezone string was updated.', 'event_espresso')
2857
-        );
2858
-        $this->_template_args['success'] = true;
2859
-        $this->_return_json(true, array('action' => 'create_new'));
2860
-    }
18
+	/**
19
+	 * This will hold the event object for event_details screen.
20
+	 *
21
+	 * @access protected
22
+	 * @var EE_Event $_event
23
+	 */
24
+	protected $_event;
25
+
26
+
27
+	/**
28
+	 * This will hold the category object for category_details screen.
29
+	 *
30
+	 * @var stdClass $_category
31
+	 */
32
+	protected $_category;
33
+
34
+
35
+	/**
36
+	 * This will hold the event model instance
37
+	 *
38
+	 * @var EEM_Event $_event_model
39
+	 */
40
+	protected $_event_model;
41
+
42
+
43
+	/**
44
+	 * @var EE_Event
45
+	 */
46
+	protected $_cpt_model_obj = false;
47
+
48
+
49
+	/**
50
+	 * Initialize page props for this admin page group.
51
+	 */
52
+	protected function _init_page_props()
53
+	{
54
+		$this->page_slug = EVENTS_PG_SLUG;
55
+		$this->page_label = EVENTS_LABEL;
56
+		$this->_admin_base_url = EVENTS_ADMIN_URL;
57
+		$this->_admin_base_path = EVENTS_ADMIN;
58
+		$this->_cpt_model_names = array(
59
+			'create_new' => 'EEM_Event',
60
+			'edit'       => 'EEM_Event',
61
+		);
62
+		$this->_cpt_edit_routes = array(
63
+			'espresso_events' => 'edit',
64
+		);
65
+		add_action(
66
+			'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object',
67
+			array($this, 'verify_event_edit'),
68
+			10,
69
+			2
70
+		);
71
+	}
72
+
73
+
74
+	/**
75
+	 * Sets the ajax hooks used for this admin page group.
76
+	 */
77
+	protected function _ajax_hooks()
78
+	{
79
+		add_action('wp_ajax_ee_save_timezone_setting', array($this, 'save_timezonestring_setting'));
80
+	}
81
+
82
+
83
+	/**
84
+	 * Sets the page properties for this admin page group.
85
+	 */
86
+	protected function _define_page_props()
87
+	{
88
+		$this->_admin_page_title = EVENTS_LABEL;
89
+		$this->_labels = array(
90
+			'buttons'      => array(
91
+				'add'             => esc_html__('Add New Event', 'event_espresso'),
92
+				'edit'            => esc_html__('Edit Event', 'event_espresso'),
93
+				'delete'          => esc_html__('Delete Event', 'event_espresso'),
94
+				'add_category'    => esc_html__('Add New Category', 'event_espresso'),
95
+				'edit_category'   => esc_html__('Edit Category', 'event_espresso'),
96
+				'delete_category' => esc_html__('Delete Category', 'event_espresso'),
97
+			),
98
+			'editor_title' => array(
99
+				'espresso_events' => esc_html__('Enter event title here', 'event_espresso'),
100
+			),
101
+			'publishbox'   => array(
102
+				'create_new'        => esc_html__('Save New Event', 'event_espresso'),
103
+				'edit'              => esc_html__('Update Event', 'event_espresso'),
104
+				'add_category'      => esc_html__('Save New Category', 'event_espresso'),
105
+				'edit_category'     => esc_html__('Update Category', 'event_espresso'),
106
+				'template_settings' => esc_html__('Update Settings', 'event_espresso'),
107
+			),
108
+		);
109
+	}
110
+
111
+
112
+	/**
113
+	 * Sets the page routes property for this admin page group.
114
+	 */
115
+	protected function _set_page_routes()
116
+	{
117
+		// load formatter helper
118
+		// load field generator helper
119
+		// is there a evt_id in the request?
120
+		$evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID'])
121
+			? $this->_req_data['EVT_ID']
122
+			: 0;
123
+		$evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id;
124
+		$this->_page_routes = array(
125
+			'default'                       => array(
126
+				'func'       => '_events_overview_list_table',
127
+				'capability' => 'ee_read_events',
128
+			),
129
+			'create_new'                    => array(
130
+				'func'       => '_create_new_cpt_item',
131
+				'capability' => 'ee_edit_events',
132
+			),
133
+			'edit'                          => array(
134
+				'func'       => '_edit_cpt_item',
135
+				'capability' => 'ee_edit_event',
136
+				'obj_id'     => $evt_id,
137
+			),
138
+			'copy_event'                    => array(
139
+				'func'       => '_copy_events',
140
+				'capability' => 'ee_edit_event',
141
+				'obj_id'     => $evt_id,
142
+				'noheader'   => true,
143
+			),
144
+			'trash_event'                   => array(
145
+				'func'       => '_trash_or_restore_event',
146
+				'args'       => array('event_status' => 'trash'),
147
+				'capability' => 'ee_delete_event',
148
+				'obj_id'     => $evt_id,
149
+				'noheader'   => true,
150
+			),
151
+			'trash_events'                  => array(
152
+				'func'       => '_trash_or_restore_events',
153
+				'args'       => array('event_status' => 'trash'),
154
+				'capability' => 'ee_delete_events',
155
+				'noheader'   => true,
156
+			),
157
+			'restore_event'                 => array(
158
+				'func'       => '_trash_or_restore_event',
159
+				'args'       => array('event_status' => 'draft'),
160
+				'capability' => 'ee_delete_event',
161
+				'obj_id'     => $evt_id,
162
+				'noheader'   => true,
163
+			),
164
+			'restore_events'                => array(
165
+				'func'       => '_trash_or_restore_events',
166
+				'args'       => array('event_status' => 'draft'),
167
+				'capability' => 'ee_delete_events',
168
+				'noheader'   => true,
169
+			),
170
+			'delete_event'                  => array(
171
+				'func'       => '_delete_event',
172
+				'capability' => 'ee_delete_event',
173
+				'obj_id'     => $evt_id,
174
+				'noheader'   => true,
175
+			),
176
+			'delete_events'                 => array(
177
+				'func'       => '_delete_events',
178
+				'capability' => 'ee_delete_events',
179
+				'noheader'   => true,
180
+			),
181
+			'view_report'                   => array(
182
+				'func'      => '_view_report',
183
+				'capability' => 'ee_edit_events',
184
+			),
185
+			'default_event_settings'        => array(
186
+				'func'       => '_default_event_settings',
187
+				'capability' => 'manage_options',
188
+			),
189
+			'update_default_event_settings' => array(
190
+				'func'       => '_update_default_event_settings',
191
+				'capability' => 'manage_options',
192
+				'noheader'   => true,
193
+			),
194
+			'template_settings'             => array(
195
+				'func'       => '_template_settings',
196
+				'capability' => 'manage_options',
197
+			),
198
+			// event category tab related
199
+			'add_category'                  => array(
200
+				'func'       => '_category_details',
201
+				'capability' => 'ee_edit_event_category',
202
+				'args'       => array('add'),
203
+			),
204
+			'edit_category'                 => array(
205
+				'func'       => '_category_details',
206
+				'capability' => 'ee_edit_event_category',
207
+				'args'       => array('edit'),
208
+			),
209
+			'delete_categories'             => array(
210
+				'func'       => '_delete_categories',
211
+				'capability' => 'ee_delete_event_category',
212
+				'noheader'   => true,
213
+			),
214
+			'delete_category'               => array(
215
+				'func'       => '_delete_categories',
216
+				'capability' => 'ee_delete_event_category',
217
+				'noheader'   => true,
218
+			),
219
+			'insert_category'               => array(
220
+				'func'       => '_insert_or_update_category',
221
+				'args'       => array('new_category' => true),
222
+				'capability' => 'ee_edit_event_category',
223
+				'noheader'   => true,
224
+			),
225
+			'update_category'               => array(
226
+				'func'       => '_insert_or_update_category',
227
+				'args'       => array('new_category' => false),
228
+				'capability' => 'ee_edit_event_category',
229
+				'noheader'   => true,
230
+			),
231
+			'category_list'                 => array(
232
+				'func'       => '_category_list_table',
233
+				'capability' => 'ee_manage_event_categories',
234
+			),
235
+		);
236
+	}
237
+
238
+
239
+	/**
240
+	 * Set the _page_config property for this admin page group.
241
+	 */
242
+	protected function _set_page_config()
243
+	{
244
+		$this->_page_config = array(
245
+			'default'                => array(
246
+				'nav'           => array(
247
+					'label' => esc_html__('Overview', 'event_espresso'),
248
+					'order' => 10,
249
+				),
250
+				'list_table'    => 'Events_Admin_List_Table',
251
+				'help_tabs'     => array(
252
+					'events_overview_help_tab'                       => array(
253
+						'title'    => esc_html__('Events Overview', 'event_espresso'),
254
+						'filename' => 'events_overview',
255
+					),
256
+					'events_overview_table_column_headings_help_tab' => array(
257
+						'title'    => esc_html__('Events Overview Table Column Headings', 'event_espresso'),
258
+						'filename' => 'events_overview_table_column_headings',
259
+					),
260
+					'events_overview_filters_help_tab'               => array(
261
+						'title'    => esc_html__('Events Overview Filters', 'event_espresso'),
262
+						'filename' => 'events_overview_filters',
263
+					),
264
+					'events_overview_view_help_tab'                  => array(
265
+						'title'    => esc_html__('Events Overview Views', 'event_espresso'),
266
+						'filename' => 'events_overview_views',
267
+					),
268
+					'events_overview_other_help_tab'                 => array(
269
+						'title'    => esc_html__('Events Overview Other', 'event_espresso'),
270
+						'filename' => 'events_overview_other',
271
+					),
272
+				),
273
+				'help_tour'     => array(
274
+					'Event_Overview_Help_Tour',
275
+					// 'New_Features_Test_Help_Tour' for testing multiple help tour
276
+				),
277
+				'qtips'         => array(
278
+					'EE_Event_List_Table_Tips',
279
+				),
280
+				'require_nonce' => false,
281
+			),
282
+			'create_new'             => array(
283
+				'nav'           => array(
284
+					'label'      => esc_html__('Add Event', 'event_espresso'),
285
+					'order'      => 5,
286
+					'persistent' => false,
287
+				),
288
+				'metaboxes'     => array('_register_event_editor_meta_boxes'),
289
+				'help_tabs'     => array(
290
+					'event_editor_help_tab'                            => array(
291
+						'title'    => esc_html__('Event Editor', 'event_espresso'),
292
+						'filename' => 'event_editor',
293
+					),
294
+					'event_editor_title_richtexteditor_help_tab'       => array(
295
+						'title'    => esc_html__('Event Title & Rich Text Editor', 'event_espresso'),
296
+						'filename' => 'event_editor_title_richtexteditor',
297
+					),
298
+					'event_editor_venue_details_help_tab'              => array(
299
+						'title'    => esc_html__('Event Venue Details', 'event_espresso'),
300
+						'filename' => 'event_editor_venue_details',
301
+					),
302
+					'event_editor_event_datetimes_help_tab'            => array(
303
+						'title'    => esc_html__('Event Datetimes', 'event_espresso'),
304
+						'filename' => 'event_editor_event_datetimes',
305
+					),
306
+					'event_editor_event_tickets_help_tab'              => array(
307
+						'title'    => esc_html__('Event Tickets', 'event_espresso'),
308
+						'filename' => 'event_editor_event_tickets',
309
+					),
310
+					'event_editor_event_registration_options_help_tab' => array(
311
+						'title'    => esc_html__('Event Registration Options', 'event_espresso'),
312
+						'filename' => 'event_editor_event_registration_options',
313
+					),
314
+					'event_editor_tags_categories_help_tab'            => array(
315
+						'title'    => esc_html__('Event Tags & Categories', 'event_espresso'),
316
+						'filename' => 'event_editor_tags_categories',
317
+					),
318
+					'event_editor_questions_registrants_help_tab'      => array(
319
+						'title'    => esc_html__('Questions for Registrants', 'event_espresso'),
320
+						'filename' => 'event_editor_questions_registrants',
321
+					),
322
+					'event_editor_save_new_event_help_tab'             => array(
323
+						'title'    => esc_html__('Save New Event', 'event_espresso'),
324
+						'filename' => 'event_editor_save_new_event',
325
+					),
326
+					'event_editor_other_help_tab'                      => array(
327
+						'title'    => esc_html__('Event Other', 'event_espresso'),
328
+						'filename' => 'event_editor_other',
329
+					),
330
+				),
331
+				'help_tour'     => array(
332
+					'Event_Editor_Help_Tour',
333
+				),
334
+				'qtips'         => array('EE_Event_Editor_Decaf_Tips'),
335
+				'require_nonce' => false,
336
+			),
337
+			'edit'                   => array(
338
+				'nav'           => array(
339
+					'label'      => esc_html__('Edit Event', 'event_espresso'),
340
+					'order'      => 5,
341
+					'persistent' => false,
342
+					'url'        => isset($this->_req_data['post'])
343
+						? EE_Admin_Page::add_query_args_and_nonce(
344
+							array('post' => $this->_req_data['post'], 'action' => 'edit'),
345
+							$this->_current_page_view_url
346
+						)
347
+						: $this->_admin_base_url,
348
+				),
349
+				'metaboxes'     => array('_register_event_editor_meta_boxes'),
350
+				'help_tabs'     => array(
351
+					'event_editor_help_tab'                            => array(
352
+						'title'    => esc_html__('Event Editor', 'event_espresso'),
353
+						'filename' => 'event_editor',
354
+					),
355
+					'event_editor_title_richtexteditor_help_tab'       => array(
356
+						'title'    => esc_html__('Event Title & Rich Text Editor', 'event_espresso'),
357
+						'filename' => 'event_editor_title_richtexteditor',
358
+					),
359
+					'event_editor_venue_details_help_tab'              => array(
360
+						'title'    => esc_html__('Event Venue Details', 'event_espresso'),
361
+						'filename' => 'event_editor_venue_details',
362
+					),
363
+					'event_editor_event_datetimes_help_tab'            => array(
364
+						'title'    => esc_html__('Event Datetimes', 'event_espresso'),
365
+						'filename' => 'event_editor_event_datetimes',
366
+					),
367
+					'event_editor_event_tickets_help_tab'              => array(
368
+						'title'    => esc_html__('Event Tickets', 'event_espresso'),
369
+						'filename' => 'event_editor_event_tickets',
370
+					),
371
+					'event_editor_event_registration_options_help_tab' => array(
372
+						'title'    => esc_html__('Event Registration Options', 'event_espresso'),
373
+						'filename' => 'event_editor_event_registration_options',
374
+					),
375
+					'event_editor_tags_categories_help_tab'            => array(
376
+						'title'    => esc_html__('Event Tags & Categories', 'event_espresso'),
377
+						'filename' => 'event_editor_tags_categories',
378
+					),
379
+					'event_editor_questions_registrants_help_tab'      => array(
380
+						'title'    => esc_html__('Questions for Registrants', 'event_espresso'),
381
+						'filename' => 'event_editor_questions_registrants',
382
+					),
383
+					'event_editor_save_new_event_help_tab'             => array(
384
+						'title'    => esc_html__('Save New Event', 'event_espresso'),
385
+						'filename' => 'event_editor_save_new_event',
386
+					),
387
+					'event_editor_other_help_tab'                      => array(
388
+						'title'    => esc_html__('Event Other', 'event_espresso'),
389
+						'filename' => 'event_editor_other',
390
+					),
391
+				),
392
+				'qtips'         => array('EE_Event_Editor_Decaf_Tips'),
393
+				'require_nonce' => false,
394
+			),
395
+			'default_event_settings' => array(
396
+				'nav'           => array(
397
+					'label' => esc_html__('Default Settings', 'event_espresso'),
398
+					'order' => 40,
399
+				),
400
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
401
+				'labels'        => array(
402
+					'publishbox' => esc_html__('Update Settings', 'event_espresso'),
403
+				),
404
+				'help_tabs'     => array(
405
+					'default_settings_help_tab'        => array(
406
+						'title'    => esc_html__('Default Event Settings', 'event_espresso'),
407
+						'filename' => 'events_default_settings',
408
+					),
409
+					'default_settings_status_help_tab' => array(
410
+						'title'    => esc_html__('Default Registration Status', 'event_espresso'),
411
+						'filename' => 'events_default_settings_status',
412
+					),
413
+					'default_maximum_tickets_help_tab' => array(
414
+						'title'    => esc_html__('Default Maximum Tickets Per Order', 'event_espresso'),
415
+						'filename' => 'events_default_settings_max_tickets',
416
+					),
417
+				),
418
+				'help_tour'     => array('Event_Default_Settings_Help_Tour'),
419
+				'require_nonce' => false,
420
+			),
421
+			// template settings
422
+			'template_settings'      => array(
423
+				'nav'           => array(
424
+					'label' => esc_html__('Templates', 'event_espresso'),
425
+					'order' => 30,
426
+				),
427
+				'metaboxes'     => $this->_default_espresso_metaboxes,
428
+				'help_tabs'     => array(
429
+					'general_settings_templates_help_tab' => array(
430
+						'title'    => esc_html__('Templates', 'event_espresso'),
431
+						'filename' => 'general_settings_templates',
432
+					),
433
+				),
434
+				'help_tour'     => array('Templates_Help_Tour'),
435
+				'require_nonce' => false,
436
+			),
437
+			// event category stuff
438
+			'add_category'           => array(
439
+				'nav'           => array(
440
+					'label'      => esc_html__('Add Category', 'event_espresso'),
441
+					'order'      => 15,
442
+					'persistent' => false,
443
+				),
444
+				'help_tabs'     => array(
445
+					'add_category_help_tab' => array(
446
+						'title'    => esc_html__('Add New Event Category', 'event_espresso'),
447
+						'filename' => 'events_add_category',
448
+					),
449
+				),
450
+				'help_tour'     => array('Event_Add_Category_Help_Tour'),
451
+				'metaboxes'     => array('_publish_post_box'),
452
+				'require_nonce' => false,
453
+			),
454
+			'edit_category'          => array(
455
+				'nav'           => array(
456
+					'label'      => esc_html__('Edit Category', 'event_espresso'),
457
+					'order'      => 15,
458
+					'persistent' => false,
459
+					'url'        => isset($this->_req_data['EVT_CAT_ID'])
460
+						? add_query_arg(
461
+							array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']),
462
+							$this->_current_page_view_url
463
+						)
464
+						: $this->_admin_base_url,
465
+				),
466
+				'help_tabs'     => array(
467
+					'edit_category_help_tab' => array(
468
+						'title'    => esc_html__('Edit Event Category', 'event_espresso'),
469
+						'filename' => 'events_edit_category',
470
+					),
471
+				),
472
+				/*'help_tour' => array('Event_Edit_Category_Help_Tour'),*/
473
+				'metaboxes'     => array('_publish_post_box'),
474
+				'require_nonce' => false,
475
+			),
476
+			'category_list'          => array(
477
+				'nav'           => array(
478
+					'label' => esc_html__('Categories', 'event_espresso'),
479
+					'order' => 20,
480
+				),
481
+				'list_table'    => 'Event_Categories_Admin_List_Table',
482
+				'help_tabs'     => array(
483
+					'events_categories_help_tab'                       => array(
484
+						'title'    => esc_html__('Event Categories', 'event_espresso'),
485
+						'filename' => 'events_categories',
486
+					),
487
+					'events_categories_table_column_headings_help_tab' => array(
488
+						'title'    => esc_html__('Event Categories Table Column Headings', 'event_espresso'),
489
+						'filename' => 'events_categories_table_column_headings',
490
+					),
491
+					'events_categories_view_help_tab'                  => array(
492
+						'title'    => esc_html__('Event Categories Views', 'event_espresso'),
493
+						'filename' => 'events_categories_views',
494
+					),
495
+					'events_categories_other_help_tab'                 => array(
496
+						'title'    => esc_html__('Event Categories Other', 'event_espresso'),
497
+						'filename' => 'events_categories_other',
498
+					),
499
+				),
500
+				'help_tour'     => array(
501
+					'Event_Categories_Help_Tour',
502
+				),
503
+				'metaboxes'     => $this->_default_espresso_metaboxes,
504
+				'require_nonce' => false,
505
+			),
506
+		);
507
+	}
508
+
509
+
510
+	/**
511
+	 * Used to register any global screen options if necessary for every route in this admin page group.
512
+	 */
513
+	protected function _add_screen_options()
514
+	{
515
+	}
516
+
517
+
518
+	/**
519
+	 * Implementing the screen options for the 'default' route.
520
+	 *
521
+	 * @throws InvalidArgumentException
522
+	 * @throws InvalidDataTypeException
523
+	 * @throws InvalidInterfaceException
524
+	 */
525
+	protected function _add_screen_options_default()
526
+	{
527
+		$this->_per_page_screen_option();
528
+	}
529
+
530
+
531
+	/**
532
+	 * Implementing screen options for the category list route.
533
+	 *
534
+	 * @throws InvalidArgumentException
535
+	 * @throws InvalidDataTypeException
536
+	 * @throws InvalidInterfaceException
537
+	 */
538
+	protected function _add_screen_options_category_list()
539
+	{
540
+		$page_title = $this->_admin_page_title;
541
+		$this->_admin_page_title = esc_html__('Categories', 'event_espresso');
542
+		$this->_per_page_screen_option();
543
+		$this->_admin_page_title = $page_title;
544
+	}
545
+
546
+
547
+	/**
548
+	 * Used to register any global feature pointers for the admin page group.
549
+	 */
550
+	protected function _add_feature_pointers()
551
+	{
552
+	}
553
+
554
+
555
+	/**
556
+	 * Registers and enqueues any global scripts and styles for the entire admin page group.
557
+	 */
558
+	public function load_scripts_styles()
559
+	{
560
+		wp_register_style(
561
+			'events-admin-css',
562
+			EVENTS_ASSETS_URL . 'events-admin-page.css',
563
+			array(),
564
+			EVENT_ESPRESSO_VERSION
565
+		);
566
+		wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION);
567
+		wp_enqueue_style('events-admin-css');
568
+		wp_enqueue_style('ee-cat-admin');
569
+		// todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details
570
+		// registers for all views
571
+		// scripts
572
+		wp_register_script(
573
+			'event_editor_js',
574
+			EVENTS_ASSETS_URL . 'event_editor.js',
575
+			array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'),
576
+			EVENT_ESPRESSO_VERSION,
577
+			true
578
+		);
579
+	}
580
+
581
+
582
+	/**
583
+	 * Enqueuing scripts and styles specific to this view
584
+	 */
585
+	public function load_scripts_styles_create_new()
586
+	{
587
+		$this->load_scripts_styles_edit();
588
+	}
589
+
590
+
591
+	/**
592
+	 * Enqueuing scripts and styles specific to this view
593
+	 */
594
+	public function load_scripts_styles_edit()
595
+	{
596
+		// styles
597
+		wp_enqueue_style('espresso-ui-theme');
598
+		wp_register_style(
599
+			'event-editor-css',
600
+			EVENTS_ASSETS_URL . 'event-editor.css',
601
+			array('ee-admin-css'),
602
+			EVENT_ESPRESSO_VERSION
603
+		);
604
+		wp_enqueue_style('event-editor-css');
605
+		// scripts
606
+		wp_register_script(
607
+			'event-datetime-metabox',
608
+			EVENTS_ASSETS_URL . 'event-datetime-metabox.js',
609
+			array('event_editor_js', 'ee-datepicker'),
610
+			EVENT_ESPRESSO_VERSION
611
+		);
612
+		wp_enqueue_script('event-datetime-metabox');
613
+	}
614
+
615
+
616
+	/**
617
+	 * Populating the _views property for the category list table view.
618
+	 */
619
+	protected function _set_list_table_views_category_list()
620
+	{
621
+		$this->_views = array(
622
+			'all' => array(
623
+				'slug'        => 'all',
624
+				'label'       => esc_html__('All', 'event_espresso'),
625
+				'count'       => 0,
626
+				'bulk_action' => array(
627
+					'delete_categories' => esc_html__('Delete Permanently', 'event_espresso'),
628
+				),
629
+			),
630
+		);
631
+	}
632
+
633
+
634
+	/**
635
+	 * For adding anything that fires on the admin_init hook for any route within this admin page group.
636
+	 */
637
+	public function admin_init()
638
+	{
639
+		EE_Registry::$i18n_js_strings['image_confirm'] = esc_html__(
640
+			'Do you really want to delete this image? Please remember to update your event to complete the removal.',
641
+			'event_espresso'
642
+		);
643
+	}
644
+
645
+
646
+	/**
647
+	 * For adding anything that should be triggered on the admin_notices hook for any route within this admin page
648
+	 * group.
649
+	 */
650
+	public function admin_notices()
651
+	{
652
+	}
653
+
654
+
655
+	/**
656
+	 * For adding anything that should be triggered on the `admin_print_footer_scripts` hook for any route within
657
+	 * this admin page group.
658
+	 */
659
+	public function admin_footer_scripts()
660
+	{
661
+	}
662
+
663
+
664
+	/**
665
+	 * Call this function to verify if an event is public and has tickets for sale.  If it does, then we need to show a
666
+	 * warning (via EE_Error::add_error());
667
+	 *
668
+	 * @param  EE_Event $event Event object
669
+	 * @param string    $req_type
670
+	 * @return void
671
+	 * @throws EE_Error
672
+	 * @access public
673
+	 */
674
+	public function verify_event_edit($event = null, $req_type = '')
675
+	{
676
+		// don't need to do this when processing
677
+		if (! empty($req_type)) {
678
+			return;
679
+		}
680
+		// no event?
681
+		if (! $event instanceof EE_Event) {
682
+			$event = $this->_cpt_model_obj;
683
+		}
684
+		// STILL no event?
685
+		if (! $event instanceof EE_Event) {
686
+			return;
687
+		}
688
+		$orig_status = $event->status();
689
+		// first check if event is active.
690
+		if ($orig_status === EEM_Event::cancelled
691
+			|| $orig_status === EEM_Event::postponed
692
+			|| $event->is_expired()
693
+			|| $event->is_inactive()
694
+		) {
695
+			return;
696
+		}
697
+		// made it here so it IS active... next check that any of the tickets are sold.
698
+		if ($event->is_sold_out(true)) {
699
+			if ($orig_status !== EEM_Event::sold_out && $event->status() !== $orig_status) {
700
+				EE_Error::add_attention(
701
+					sprintf(
702
+						esc_html__(
703
+							'Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event.  However, this change is not permanent until you update the event.  You can change the status back to something else before updating if you wish.',
704
+							'event_espresso'
705
+						),
706
+						EEH_Template::pretty_status(EEM_Event::sold_out, false, 'sentence')
707
+					)
708
+				);
709
+			}
710
+			return;
711
+		}
712
+		if ($orig_status === EEM_Event::sold_out) {
713
+			EE_Error::add_attention(
714
+				sprintf(
715
+					esc_html__(
716
+						'Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets.  However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.',
717
+						'event_espresso'
718
+					),
719
+					EEH_Template::pretty_status($event->status(), false, 'sentence')
720
+				)
721
+			);
722
+		}
723
+		// now we need to determine if the event has any tickets on sale.  If not then we dont' show the error
724
+		if (! $event->tickets_on_sale()) {
725
+			return;
726
+		}
727
+		// made it here so show warning
728
+		$this->_edit_event_warning();
729
+	}
730
+
731
+
732
+	/**
733
+	 * This is the text used for when an event is being edited that is public and has tickets for sale.
734
+	 * When needed, hook this into a EE_Error::add_error() notice.
735
+	 *
736
+	 * @access protected
737
+	 * @return void
738
+	 */
739
+	protected function _edit_event_warning()
740
+	{
741
+		// we don't want to add warnings during these requests
742
+		if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'editpost') {
743
+			return;
744
+		}
745
+		EE_Error::add_attention(
746
+			sprintf(
747
+				esc_html__(
748
+					'Your event is open for registration. Making changes may disrupt any transactions in progress. %sLearn more%s',
749
+					'event_espresso'
750
+				),
751
+				'<a class="espresso-help-tab-lnk">',
752
+				'</a>'
753
+			)
754
+		);
755
+	}
756
+
757
+
758
+	/**
759
+	 * When a user is creating a new event, notify them if they haven't set their timezone.
760
+	 * Otherwise, do the normal logic
761
+	 *
762
+	 * @return string
763
+	 * @throws EE_Error
764
+	 * @throws InvalidArgumentException
765
+	 * @throws InvalidDataTypeException
766
+	 * @throws InvalidInterfaceException
767
+	 */
768
+	protected function _create_new_cpt_item()
769
+	{
770
+		$has_timezone_string = get_option('timezone_string');
771
+		// only nag them about setting their timezone if it's their first event, and they haven't already done it
772
+		if (! $has_timezone_string && ! EEM_Event::instance()->exists(array())) {
773
+			EE_Error::add_attention(
774
+				sprintf(
775
+					__(
776
+						'Your website\'s timezone is currently set to a UTC offset. We recommend updating your timezone to a city or region near you before you create an event. Change your timezone now:%1$s%2$s%3$sChange Timezone%4$s',
777
+						'event_espresso'
778
+					),
779
+					'<br>',
780
+					'<select id="timezone_string" name="timezone_string" aria-describedby="timezone-description">'
781
+					. EEH_DTT_Helper::wp_timezone_choice('', EEH_DTT_Helper::get_user_locale())
782
+					. '</select>',
783
+					'<button class="button button-secondary timezone-submit">',
784
+					'</button><span class="spinner"></span>'
785
+				),
786
+				__FILE__,
787
+				__FUNCTION__,
788
+				__LINE__
789
+			);
790
+		}
791
+		parent::_create_new_cpt_item();
792
+	}
793
+
794
+
795
+	/**
796
+	 * Sets the _views property for the default route in this admin page group.
797
+	 */
798
+	protected function _set_list_table_views_default()
799
+	{
800
+		$this->_views = array(
801
+			'all'   => array(
802
+				'slug'        => 'all',
803
+				'label'       => esc_html__('View All Events', 'event_espresso'),
804
+				'count'       => 0,
805
+				'bulk_action' => array(
806
+					'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
807
+				),
808
+			),
809
+			'draft' => array(
810
+				'slug'        => 'draft',
811
+				'label'       => esc_html__('Draft', 'event_espresso'),
812
+				'count'       => 0,
813
+				'bulk_action' => array(
814
+					'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
815
+				),
816
+			),
817
+		);
818
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) {
819
+			$this->_views['trash'] = array(
820
+				'slug'        => 'trash',
821
+				'label'       => esc_html__('Trash', 'event_espresso'),
822
+				'count'       => 0,
823
+				'bulk_action' => array(
824
+					'restore_events' => esc_html__('Restore From Trash', 'event_espresso'),
825
+					'delete_events'  => esc_html__('Delete Permanently', 'event_espresso'),
826
+				),
827
+			);
828
+		}
829
+	}
830
+
831
+
832
+	/**
833
+	 * Provides the legend item array for the default list table view.
834
+	 *
835
+	 * @return array
836
+	 */
837
+	protected function _event_legend_items()
838
+	{
839
+		$items = array(
840
+			'view_details'   => array(
841
+				'class' => 'dashicons dashicons-search',
842
+				'desc'  => esc_html__('View Event', 'event_espresso'),
843
+			),
844
+			'edit_event'     => array(
845
+				'class' => 'ee-icon ee-icon-calendar-edit',
846
+				'desc'  => esc_html__('Edit Event Details', 'event_espresso'),
847
+			),
848
+			'view_attendees' => array(
849
+				'class' => 'dashicons dashicons-groups',
850
+				'desc'  => esc_html__('View Registrations for Event', 'event_espresso'),
851
+			),
852
+		);
853
+		$items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items);
854
+		$statuses = array(
855
+			'sold_out_status'  => array(
856
+				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out,
857
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::sold_out, false, 'sentence'),
858
+			),
859
+			'active_status'    => array(
860
+				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active,
861
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::active, false, 'sentence'),
862
+			),
863
+			'upcoming_status'  => array(
864
+				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming,
865
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::upcoming, false, 'sentence'),
866
+			),
867
+			'postponed_status' => array(
868
+				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed,
869
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::postponed, false, 'sentence'),
870
+			),
871
+			'cancelled_status' => array(
872
+				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled,
873
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::cancelled, false, 'sentence'),
874
+			),
875
+			'expired_status'   => array(
876
+				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired,
877
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::expired, false, 'sentence'),
878
+			),
879
+			'inactive_status'  => array(
880
+				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive,
881
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::inactive, false, 'sentence'),
882
+			),
883
+		);
884
+		$statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses);
885
+		return array_merge($items, $statuses);
886
+	}
887
+
888
+
889
+	/**
890
+	 * @return EEM_Event
891
+	 * @throws EE_Error
892
+	 * @throws InvalidArgumentException
893
+	 * @throws InvalidDataTypeException
894
+	 * @throws InvalidInterfaceException
895
+	 * @throws ReflectionException
896
+	 */
897
+	private function _event_model()
898
+	{
899
+		if (! $this->_event_model instanceof EEM_Event) {
900
+			$this->_event_model = EE_Registry::instance()->load_model('Event');
901
+		}
902
+		return $this->_event_model;
903
+	}
904
+
905
+
906
+	/**
907
+	 * Adds extra buttons to the WP CPT permalink field row.
908
+	 * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter.
909
+	 *
910
+	 * @param  string $return    the current html
911
+	 * @param  int    $id        the post id for the page
912
+	 * @param  string $new_title What the title is
913
+	 * @param  string $new_slug  what the slug is
914
+	 * @return string            The new html string for the permalink area
915
+	 */
916
+	public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug)
917
+	{
918
+		// make sure this is only when editing
919
+		if (! empty($id)) {
920
+			$post = get_post($id);
921
+			$return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#"  tabindex="-1">'
922
+					   . esc_html__('Shortcode', 'event_espresso')
923
+					   . '</a> ';
924
+			$return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id='
925
+					   . $post->ID
926
+					   . ']">';
927
+		}
928
+		return $return;
929
+	}
930
+
931
+
932
+	/**
933
+	 * _events_overview_list_table
934
+	 * This contains the logic for showing the events_overview list
935
+	 *
936
+	 * @access protected
937
+	 * @return void
938
+	 * @throws DomainException
939
+	 * @throws EE_Error
940
+	 * @throws InvalidArgumentException
941
+	 * @throws InvalidDataTypeException
942
+	 * @throws InvalidInterfaceException
943
+	 */
944
+	protected function _events_overview_list_table()
945
+	{
946
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
947
+		$this->_template_args['after_list_table'] = ! empty($this->_template_args['after_list_table'])
948
+			? (array) $this->_template_args['after_list_table']
949
+			: array();
950
+		$this->_template_args['after_list_table']['view_event_list_button'] = EEH_HTML::br()
951
+				. EEH_Template::get_button_or_link(
952
+					get_post_type_archive_link('espresso_events'),
953
+					esc_html__('View Event Archive Page', 'event_espresso'),
954
+					'button'
955
+				);
956
+		$this->_template_args['after_list_table']['legend'] = $this->_display_legend($this->_event_legend_items());
957
+		$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
958
+			'create_new',
959
+			'add',
960
+			array(),
961
+			'add-new-h2'
962
+		);
963
+		$this->display_admin_list_table_page_with_no_sidebar();
964
+	}
965
+
966
+
967
+	/**
968
+	 * this allows for extra misc actions in the default WP publish box
969
+	 *
970
+	 * @return void
971
+	 * @throws DomainException
972
+	 * @throws EE_Error
973
+	 * @throws InvalidArgumentException
974
+	 * @throws InvalidDataTypeException
975
+	 * @throws InvalidInterfaceException
976
+	 * @throws ReflectionException
977
+	 */
978
+	public function extra_misc_actions_publish_box()
979
+	{
980
+		$this->_generate_publish_box_extra_content();
981
+	}
982
+
983
+
984
+	/**
985
+	 * This is hooked into the WordPress do_action('save_post') hook and runs after the custom post type has been
986
+	 * saved.
987
+	 * Typically you would use this to save any additional data.
988
+	 * Keep in mind also that "save_post" runs on EVERY post update to the database.
989
+	 * ALSO very important.  When a post transitions from scheduled to published,
990
+	 * the save_post action is fired but you will NOT have any _POST data containing any extra info you may have from
991
+	 * other meta saves. So MAKE sure that you handle this accordingly.
992
+	 *
993
+	 * @access protected
994
+	 * @abstract
995
+	 * @param string $post_id The ID of the cpt that was saved (so you can link relationally)
996
+	 * @param object $post    The post object of the cpt that was saved.
997
+	 * @return void
998
+	 * @throws EE_Error
999
+	 * @throws InvalidArgumentException
1000
+	 * @throws InvalidDataTypeException
1001
+	 * @throws InvalidInterfaceException
1002
+	 * @throws ReflectionException
1003
+	 */
1004
+	protected function _insert_update_cpt_item($post_id, $post)
1005
+	{
1006
+		if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') {
1007
+			// get out we're not processing an event save.
1008
+			return;
1009
+		}
1010
+		$event_values = array(
1011
+			'EVT_display_desc'                => ! empty($this->_req_data['display_desc']) ? 1 : 0,
1012
+			'EVT_display_ticket_selector'     => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0,
1013
+			'EVT_additional_limit'            => min(
1014
+				apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255),
1015
+				! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : null
1016
+			),
1017
+			'EVT_default_registration_status' => ! empty($this->_req_data['EVT_default_registration_status'])
1018
+				? $this->_req_data['EVT_default_registration_status']
1019
+				: EE_Registry::instance()->CFG->registration->default_STS_ID,
1020
+			'EVT_member_only'                 => ! empty($this->_req_data['member_only']) ? 1 : 0,
1021
+			'EVT_allow_overflow'              => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0,
1022
+			'EVT_timezone_string'             => ! empty($this->_req_data['timezone_string'])
1023
+				? $this->_req_data['timezone_string'] : null,
1024
+			'EVT_external_URL'                => ! empty($this->_req_data['externalURL'])
1025
+				? $this->_req_data['externalURL'] : null,
1026
+			'EVT_phone'                       => ! empty($this->_req_data['event_phone'])
1027
+				? $this->_req_data['event_phone'] : null,
1028
+		);
1029
+		// update event
1030
+		$success = $this->_event_model()->update_by_ID($event_values, $post_id);
1031
+		// get event_object for other metaboxes... though it would seem to make sense to just use $this->_event_model()->get_one_by_ID( $post_id ).. i have to setup where conditions to override the filters in the model that filter out autodraft and inherit statuses so we GET the inherit id!
1032
+		$get_one_where = array(
1033
+			$this->_event_model()->primary_key_name() => $post_id,
1034
+			'OR'                                      => array(
1035
+				'status'   => $post->post_status,
1036
+				// if trying to "Publish" a sold out event, it's status will get switched back to "sold_out" in the db,
1037
+				// but the returned object here has a status of "publish", so use the original post status as well
1038
+				'status*1' => $this->_req_data['original_post_status'],
1039
+			),
1040
+		);
1041
+		$event = $this->_event_model()->get_one(array($get_one_where));
1042
+		// the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons.
1043
+		$event_update_callbacks = apply_filters(
1044
+			'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',
1045
+			array(
1046
+				array($this, '_default_venue_update'),
1047
+				array($this, '_default_tickets_update'),
1048
+			)
1049
+		);
1050
+		$att_success = true;
1051
+		foreach ($event_update_callbacks as $e_callback) {
1052
+			$_success = is_callable($e_callback)
1053
+				? $e_callback($event, $this->_req_data)
1054
+				: false;
1055
+			// if ANY of these updates fail then we want the appropriate global error message
1056
+			$att_success = ! $att_success ? $att_success : $_success;
1057
+		}
1058
+		// any errors?
1059
+		if ($success && false === $att_success) {
1060
+			EE_Error::add_error(
1061
+				esc_html__(
1062
+					'Event Details saved successfully but something went wrong with saving attachments.',
1063
+					'event_espresso'
1064
+				),
1065
+				__FILE__,
1066
+				__FUNCTION__,
1067
+				__LINE__
1068
+			);
1069
+		} elseif ($success === false) {
1070
+			EE_Error::add_error(
1071
+				esc_html__('Event Details did not save successfully.', 'event_espresso'),
1072
+				__FILE__,
1073
+				__FUNCTION__,
1074
+				__LINE__
1075
+			);
1076
+		}
1077
+	}
1078
+
1079
+
1080
+	/**
1081
+	 * @param int $post_id
1082
+	 * @param int $revision_id
1083
+	 * @throws EE_Error
1084
+	 * @throws InvalidArgumentException
1085
+	 * @throws InvalidDataTypeException
1086
+	 * @throws InvalidInterfaceException
1087
+	 * @throws ReflectionException
1088
+	 * @see parent::restore_item()
1089
+	 */
1090
+	protected function _restore_cpt_item($post_id, $revision_id)
1091
+	{
1092
+		// copy existing event meta to new post
1093
+		$post_evt = $this->_event_model()->get_one_by_ID($post_id);
1094
+		if ($post_evt instanceof EE_Event) {
1095
+			// meta revision restore
1096
+			$post_evt->restore_revision($revision_id);
1097
+			// related objs restore
1098
+			$post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price'));
1099
+		}
1100
+	}
1101
+
1102
+
1103
+	/**
1104
+	 * Attach the venue to the Event
1105
+	 *
1106
+	 * @param EE_Event $evtobj Event Object to add the venue to
1107
+	 * @param array    $data   The request data from the form
1108
+	 * @return bool           Success or fail.
1109
+	 * @throws EE_Error
1110
+	 * @throws InvalidArgumentException
1111
+	 * @throws InvalidDataTypeException
1112
+	 * @throws InvalidInterfaceException
1113
+	 * @throws ReflectionException
1114
+	 */
1115
+	protected function _default_venue_update(EE_Event $evtobj, $data)
1116
+	{
1117
+		require_once(EE_MODELS . 'EEM_Venue.model.php');
1118
+		$venue_model = EE_Registry::instance()->load_model('Venue');
1119
+		$rows_affected = null;
1120
+		$venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null;
1121
+		// very important.  If we don't have a venue name...
1122
+		// then we'll get out because not necessary to create empty venue
1123
+		if (empty($data['venue_title'])) {
1124
+			return false;
1125
+		}
1126
+		$venue_array = array(
1127
+			'VNU_wp_user'         => $evtobj->get('EVT_wp_user'),
1128
+			'VNU_name'            => ! empty($data['venue_title']) ? $data['venue_title'] : null,
1129
+			'VNU_desc'            => ! empty($data['venue_description']) ? $data['venue_description'] : null,
1130
+			'VNU_identifier'      => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : null,
1131
+			'VNU_short_desc'      => ! empty($data['venue_short_description']) ? $data['venue_short_description']
1132
+				: null,
1133
+			'VNU_address'         => ! empty($data['address']) ? $data['address'] : null,
1134
+			'VNU_address2'        => ! empty($data['address2']) ? $data['address2'] : null,
1135
+			'VNU_city'            => ! empty($data['city']) ? $data['city'] : null,
1136
+			'STA_ID'              => ! empty($data['state']) ? $data['state'] : null,
1137
+			'CNT_ISO'             => ! empty($data['countries']) ? $data['countries'] : null,
1138
+			'VNU_zip'             => ! empty($data['zip']) ? $data['zip'] : null,
1139
+			'VNU_phone'           => ! empty($data['venue_phone']) ? $data['venue_phone'] : null,
1140
+			'VNU_capacity'        => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : null,
1141
+			'VNU_url'             => ! empty($data['venue_url']) ? $data['venue_url'] : null,
1142
+			'VNU_virtual_phone'   => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : null,
1143
+			'VNU_virtual_url'     => ! empty($data['virtual_url']) ? $data['virtual_url'] : null,
1144
+			'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0,
1145
+			'status'              => 'publish',
1146
+		);
1147
+		// if we've got the venue_id then we're just updating the existing venue so let's do that and then get out.
1148
+		if (! empty($venue_id)) {
1149
+			$update_where = array($venue_model->primary_key_name() => $venue_id);
1150
+			$rows_affected = $venue_model->update($venue_array, array($update_where));
1151
+			// we've gotta make sure that the venue is always attached to a revision.. add_relation_to should take care of making sure that the relation is already present.
1152
+			$evtobj->_add_relation_to($venue_id, 'Venue');
1153
+			return $rows_affected > 0;
1154
+		}
1155
+		// we insert the venue
1156
+		$venue_id = $venue_model->insert($venue_array);
1157
+		$evtobj->_add_relation_to($venue_id, 'Venue');
1158
+		return ! empty($venue_id) ? true : false;
1159
+		// when we have the ancestor come in it's already been handled by the revision save.
1160
+	}
1161
+
1162
+
1163
+	/**
1164
+	 * Handles saving everything related to Tickets (datetimes, tickets, prices)
1165
+	 *
1166
+	 * @param EE_Event $evtobj The Event object we're attaching data to
1167
+	 * @param array    $data   The request data from the form
1168
+	 * @return array
1169
+	 * @throws EE_Error
1170
+	 * @throws InvalidArgumentException
1171
+	 * @throws InvalidDataTypeException
1172
+	 * @throws InvalidInterfaceException
1173
+	 * @throws ReflectionException
1174
+	 * @throws Exception
1175
+	 */
1176
+	protected function _default_tickets_update(EE_Event $evtobj, $data)
1177
+	{
1178
+		$success = true;
1179
+		$saved_dtt = null;
1180
+		$saved_tickets = array();
1181
+		$incoming_date_formats = array('Y-m-d', 'h:i a');
1182
+		foreach ($data['edit_event_datetimes'] as $row => $dtt) {
1183
+			// trim all values to ensure any excess whitespace is removed.
1184
+			$dtt = array_map('trim', $dtt);
1185
+			$dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end']
1186
+				: $dtt['DTT_EVT_start'];
1187
+			$datetime_values = array(
1188
+				'DTT_ID'        => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : null,
1189
+				'DTT_EVT_start' => $dtt['DTT_EVT_start'],
1190
+				'DTT_EVT_end'   => $dtt['DTT_EVT_end'],
1191
+				'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'],
1192
+				'DTT_order'     => $row,
1193
+			);
1194
+			// if we have an id then let's get existing object first and then set the new values.  Otherwise we instantiate a new object for save.
1195
+			if (! empty($dtt['DTT_ID'])) {
1196
+				$DTM = EE_Registry::instance()
1197
+								  ->load_model('Datetime', array($evtobj->get_timezone()))
1198
+								  ->get_one_by_ID($dtt['DTT_ID']);
1199
+				$DTM->set_date_format($incoming_date_formats[0]);
1200
+				$DTM->set_time_format($incoming_date_formats[1]);
1201
+				foreach ($datetime_values as $field => $value) {
1202
+					$DTM->set($field, $value);
1203
+				}
1204
+				// make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it.  We need to do this so we dont' TRASH the parent DTT.
1205
+				$saved_dtts[ $DTM->ID() ] = $DTM;
1206
+			} else {
1207
+				$DTM = EE_Registry::instance()->load_class(
1208
+					'Datetime',
1209
+					array($datetime_values, $evtobj->get_timezone(), $incoming_date_formats),
1210
+					false,
1211
+					false
1212
+				);
1213
+				foreach ($datetime_values as $field => $value) {
1214
+					$DTM->set($field, $value);
1215
+				}
1216
+			}
1217
+			$DTM->save();
1218
+			$DTT = $evtobj->_add_relation_to($DTM, 'Datetime');
1219
+			// load DTT helper
1220
+			// before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date.
1221
+			if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) {
1222
+				$DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start'));
1223
+				$DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days');
1224
+				$DTT->save();
1225
+			}
1226
+			// now we got to make sure we add the new DTT_ID to the $saved_dtts array  because it is possible there was a new one created for the autosave.
1227
+			$saved_dtt = $DTT;
1228
+			$success = ! $success ? $success : $DTT;
1229
+			// if ANY of these updates fail then we want the appropriate global error message.
1230
+			// //todo this is actually sucky we need a better error message but this is what it is for now.
1231
+		}
1232
+		// no dtts get deleted so we don't do any of that logic here.
1233
+		// update tickets next
1234
+		$old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array();
1235
+		foreach ($data['edit_tickets'] as $row => $tkt) {
1236
+			$incoming_date_formats = array('Y-m-d', 'h:i a');
1237
+			$update_prices = false;
1238
+			$ticket_price = isset($data['edit_prices'][ $row ][1]['PRC_amount'])
1239
+				? $data['edit_prices'][ $row ][1]['PRC_amount'] : 0;
1240
+			// trim inputs to ensure any excess whitespace is removed.
1241
+			$tkt = array_map('trim', $tkt);
1242
+			if (empty($tkt['TKT_start_date'])) {
1243
+				// let's use now in the set timezone.
1244
+				$now = new DateTime('now', new DateTimeZone($evtobj->get_timezone()));
1245
+				$tkt['TKT_start_date'] = $now->format($incoming_date_formats[0] . ' ' . $incoming_date_formats[1]);
1246
+			}
1247
+			if (empty($tkt['TKT_end_date'])) {
1248
+				// use the start date of the first datetime
1249
+				$dtt = $evtobj->first_datetime();
1250
+				$tkt['TKT_end_date'] = $dtt->start_date_and_time(
1251
+					$incoming_date_formats[0],
1252
+					$incoming_date_formats[1]
1253
+				);
1254
+			}
1255
+			$TKT_values = array(
1256
+				'TKT_ID'          => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null,
1257
+				'TTM_ID'          => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0,
1258
+				'TKT_name'        => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '',
1259
+				'TKT_description' => ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '',
1260
+				'TKT_start_date'  => $tkt['TKT_start_date'],
1261
+				'TKT_end_date'    => $tkt['TKT_end_date'],
1262
+				'TKT_qty'         => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'],
1263
+				'TKT_uses'        => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'],
1264
+				'TKT_min'         => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'],
1265
+				'TKT_max'         => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'],
1266
+				'TKT_row'         => $row,
1267
+				'TKT_order'       => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row,
1268
+				'TKT_price'       => $ticket_price,
1269
+			);
1270
+			// if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well.
1271
+			if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) {
1272
+				$TKT_values['TKT_ID'] = 0;
1273
+				$TKT_values['TKT_is_default'] = 0;
1274
+				$TKT_values['TKT_price'] = $ticket_price;
1275
+				$update_prices = true;
1276
+			}
1277
+			// if we have a TKT_ID then we need to get that existing TKT_obj and update it
1278
+			// we actually do our saves a head of doing any add_relations to because its entirely possible that this ticket didn't removed or added to any datetime in the session but DID have it's items modified.
1279
+			// keep in mind that if the TKT has been sold (and we have changed pricing information), then we won't be updating the tkt but instead a new tkt will be created and the old one archived.
1280
+			if (! empty($tkt['TKT_ID'])) {
1281
+				$TKT = EE_Registry::instance()
1282
+								  ->load_model('Ticket', array($evtobj->get_timezone()))
1283
+								  ->get_one_by_ID($tkt['TKT_ID']);
1284
+				if ($TKT instanceof EE_Ticket) {
1285
+					$ticket_sold = $TKT->count_related(
1286
+						'Registration',
1287
+						array(
1288
+							array(
1289
+								'STS_ID' => array(
1290
+									'NOT IN',
1291
+									array(EEM_Registration::status_id_incomplete),
1292
+								),
1293
+							),
1294
+						)
1295
+					) > 0;
1296
+					// let's just check the total price for the existing ticket and determine if it matches the new
1297
+					// total price.  if they are different then we create a new ticket (if tickets sold)
1298
+					// if they aren't different then we go ahead and modify existing ticket.
1299
+					$create_new_TKT = $ticket_sold && ! $TKT->deleted() && EEH_Money::compare_floats(
1300
+						$ticket_price,
1301
+						$TKT->get('TKT_price'),
1302
+						'!=='
1303
+					);
1304
+					$TKT->set_date_format($incoming_date_formats[0]);
1305
+					$TKT->set_time_format($incoming_date_formats[1]);
1306
+					// set new values
1307
+					foreach ($TKT_values as $field => $value) {
1308
+						if ($field === 'TKT_qty') {
1309
+							$TKT->set_qty($value);
1310
+						} else {
1311
+							$TKT->set($field, $value);
1312
+						}
1313
+					}
1314
+					// if $create_new_TKT is false then we can safely update the existing ticket.  Otherwise we have to create a new ticket.
1315
+					if ($create_new_TKT) {
1316
+						// archive the old ticket first
1317
+						$TKT->set('TKT_deleted', 1);
1318
+						$TKT->save();
1319
+						// make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine.
1320
+						$saved_tickets[ $TKT->ID() ] = $TKT;
1321
+						// create new ticket that's a copy of the existing except a new id of course (and not archived) AND has the new TKT_price associated with it.
1322
+						$TKT = clone $TKT;
1323
+						$TKT->set('TKT_ID', 0);
1324
+						$TKT->set('TKT_deleted', 0);
1325
+						$TKT->set('TKT_price', $ticket_price);
1326
+						$TKT->set('TKT_sold', 0);
1327
+						// now we need to make sure that $new prices are created as well and attached to new ticket.
1328
+						$update_prices = true;
1329
+					}
1330
+					// make sure price is set if it hasn't been already
1331
+					$TKT->set('TKT_price', $ticket_price);
1332
+				}
1333
+			} else {
1334
+				// no TKT_id so a new TKT
1335
+				$TKT_values['TKT_price'] = $ticket_price;
1336
+				$TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), false, false);
1337
+				if ($TKT instanceof EE_Ticket) {
1338
+					// need to reset values to properly account for the date formats
1339
+					$TKT->set_date_format($incoming_date_formats[0]);
1340
+					$TKT->set_time_format($incoming_date_formats[1]);
1341
+					$TKT->set_timezone($evtobj->get_timezone());
1342
+					// set new values
1343
+					foreach ($TKT_values as $field => $value) {
1344
+						if ($field === 'TKT_qty') {
1345
+							$TKT->set_qty($value);
1346
+						} else {
1347
+							$TKT->set($field, $value);
1348
+						}
1349
+					}
1350
+					$update_prices = true;
1351
+				}
1352
+			}
1353
+			// cap ticket qty by datetime reg limits
1354
+			$TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit')));
1355
+			// update ticket.
1356
+			$TKT->save();
1357
+			// before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date.
1358
+			if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) {
1359
+				$TKT->set('TKT_end_date', $TKT->get('TKT_start_date'));
1360
+				$TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days');
1361
+				$TKT->save();
1362
+			}
1363
+			// initially let's add the ticket to the dtt
1364
+			$saved_dtt->_add_relation_to($TKT, 'Ticket');
1365
+			$saved_tickets[ $TKT->ID() ] = $TKT;
1366
+			// add prices to ticket
1367
+			$this->_add_prices_to_ticket($data['edit_prices'][ $row ], $TKT, $update_prices);
1368
+		}
1369
+		// however now we need to handle permanently deleting tickets via the ui.  Keep in mind that the ui does not allow deleting/archiving tickets that have ticket sold.  However, it does allow for deleting tickets that have no tickets sold, in which case we want to get rid of permanently because there is no need to save in db.
1370
+		$old_tickets = isset($old_tickets[0]) && $old_tickets[0] === '' ? array() : $old_tickets;
1371
+		$tickets_removed = array_diff($old_tickets, array_keys($saved_tickets));
1372
+		foreach ($tickets_removed as $id) {
1373
+			$id = absint($id);
1374
+			// get the ticket for this id
1375
+			$tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id);
1376
+			// need to get all the related datetimes on this ticket and remove from every single one of them (remember this process can ONLY kick off if there are NO tkts_sold)
1377
+			$dtts = $tkt_to_remove->get_many_related('Datetime');
1378
+			foreach ($dtts as $dtt) {
1379
+				$tkt_to_remove->_remove_relation_to($dtt, 'Datetime');
1380
+			}
1381
+			// need to do the same for prices (except these prices can also be deleted because again, tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived))
1382
+			$tkt_to_remove->delete_related_permanently('Price');
1383
+			// finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships)
1384
+			$tkt_to_remove->delete_permanently();
1385
+		}
1386
+		return array($saved_dtt, $saved_tickets);
1387
+	}
1388
+
1389
+
1390
+	/**
1391
+	 * This attaches a list of given prices to a ticket.
1392
+	 * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change
1393
+	 * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old
1394
+	 * price info and prices are automatically "archived" via the ticket.
1395
+	 *
1396
+	 * @access  private
1397
+	 * @param array     $prices     Array of prices from the form.
1398
+	 * @param EE_Ticket $ticket     EE_Ticket object that prices are being attached to.
1399
+	 * @param bool      $new_prices Whether attach existing incoming prices or create new ones.
1400
+	 * @return  void
1401
+	 * @throws EE_Error
1402
+	 * @throws InvalidArgumentException
1403
+	 * @throws InvalidDataTypeException
1404
+	 * @throws InvalidInterfaceException
1405
+	 * @throws ReflectionException
1406
+	 */
1407
+	private function _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = false)
1408
+	{
1409
+		foreach ($prices as $row => $prc) {
1410
+			$PRC_values = array(
1411
+				'PRC_ID'         => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null,
1412
+				'PRT_ID'         => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null,
1413
+				'PRC_amount'     => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0,
1414
+				'PRC_name'       => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '',
1415
+				'PRC_desc'       => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '',
1416
+				'PRC_is_default' => 0, // make sure prices are NOT set as default from this context
1417
+				'PRC_order'      => $row,
1418
+			);
1419
+			if ($new_prices || empty($PRC_values['PRC_ID'])) {
1420
+				$PRC_values['PRC_ID'] = 0;
1421
+				$PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), false, false);
1422
+			} else {
1423
+				$PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']);
1424
+				// update this price with new values
1425
+				foreach ($PRC_values as $field => $newprc) {
1426
+					$PRC->set($field, $newprc);
1427
+				}
1428
+				$PRC->save();
1429
+			}
1430
+			$ticket->_add_relation_to($PRC, 'Price');
1431
+		}
1432
+	}
1433
+
1434
+
1435
+	/**
1436
+	 * Add in our autosave ajax handlers
1437
+	 *
1438
+	 */
1439
+	protected function _ee_autosave_create_new()
1440
+	{
1441
+	}
1442
+
1443
+
1444
+	/**
1445
+	 * More autosave handlers.
1446
+	 */
1447
+	protected function _ee_autosave_edit()
1448
+	{
1449
+	}
1450
+
1451
+
1452
+	/**
1453
+	 *    _generate_publish_box_extra_content
1454
+	 *
1455
+	 * @throws DomainException
1456
+	 * @throws EE_Error
1457
+	 * @throws InvalidArgumentException
1458
+	 * @throws InvalidDataTypeException
1459
+	 * @throws InvalidInterfaceException
1460
+	 * @throws ReflectionException
1461
+	 */
1462
+	private function _generate_publish_box_extra_content()
1463
+	{
1464
+		// load formatter helper
1465
+		// args for getting related registrations
1466
+		$approved_query_args = array(
1467
+			array(
1468
+				'REG_deleted' => 0,
1469
+				'STS_ID'      => EEM_Registration::status_id_approved,
1470
+			),
1471
+		);
1472
+		$not_approved_query_args = array(
1473
+			array(
1474
+				'REG_deleted' => 0,
1475
+				'STS_ID'      => EEM_Registration::status_id_not_approved,
1476
+			),
1477
+		);
1478
+		$pending_payment_query_args = array(
1479
+			array(
1480
+				'REG_deleted' => 0,
1481
+				'STS_ID'      => EEM_Registration::status_id_pending_payment,
1482
+			),
1483
+		);
1484
+		// publish box
1485
+		$publish_box_extra_args = array(
1486
+			'view_approved_reg_url'        => add_query_arg(
1487
+				array(
1488
+					'action'      => 'default',
1489
+					'event_id'    => $this->_cpt_model_obj->ID(),
1490
+					'_reg_status' => EEM_Registration::status_id_approved,
1491
+				),
1492
+				REG_ADMIN_URL
1493
+			),
1494
+			'view_not_approved_reg_url'    => add_query_arg(
1495
+				array(
1496
+					'action'      => 'default',
1497
+					'event_id'    => $this->_cpt_model_obj->ID(),
1498
+					'_reg_status' => EEM_Registration::status_id_not_approved,
1499
+				),
1500
+				REG_ADMIN_URL
1501
+			),
1502
+			'view_pending_payment_reg_url' => add_query_arg(
1503
+				array(
1504
+					'action'      => 'default',
1505
+					'event_id'    => $this->_cpt_model_obj->ID(),
1506
+					'_reg_status' => EEM_Registration::status_id_pending_payment,
1507
+				),
1508
+				REG_ADMIN_URL
1509
+			),
1510
+			'approved_regs'                => $this->_cpt_model_obj->count_related(
1511
+				'Registration',
1512
+				$approved_query_args
1513
+			),
1514
+			'not_approved_regs'            => $this->_cpt_model_obj->count_related(
1515
+				'Registration',
1516
+				$not_approved_query_args
1517
+			),
1518
+			'pending_payment_regs'         => $this->_cpt_model_obj->count_related(
1519
+				'Registration',
1520
+				$pending_payment_query_args
1521
+			),
1522
+			'misc_pub_section_class'       => apply_filters(
1523
+				'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class',
1524
+				'misc-pub-section'
1525
+			),
1526
+		);
1527
+		ob_start();
1528
+		do_action(
1529
+			'AHEE__Events_Admin_Page___generate_publish_box_extra_content__event_editor_overview_add',
1530
+			$this->_cpt_model_obj
1531
+		);
1532
+		$publish_box_extra_args['event_editor_overview_add'] = ob_get_clean();
1533
+		// load template
1534
+		EEH_Template::display_template(
1535
+			EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php',
1536
+			$publish_box_extra_args
1537
+		);
1538
+	}
1539
+
1540
+
1541
+	/**
1542
+	 * @return EE_Event
1543
+	 */
1544
+	public function get_event_object()
1545
+	{
1546
+		return $this->_cpt_model_obj;
1547
+	}
1548
+
1549
+
1550
+
1551
+
1552
+	/** METABOXES * */
1553
+	/**
1554
+	 * _register_event_editor_meta_boxes
1555
+	 * add all metaboxes related to the event_editor
1556
+	 *
1557
+	 * @return void
1558
+	 * @throws EE_Error
1559
+	 * @throws InvalidArgumentException
1560
+	 * @throws InvalidDataTypeException
1561
+	 * @throws InvalidInterfaceException
1562
+	 * @throws ReflectionException
1563
+	 */
1564
+	protected function _register_event_editor_meta_boxes()
1565
+	{
1566
+		$this->verify_cpt_object();
1567
+		// add_meta_box(
1568
+		//     'espresso_event_editor_tickets',
1569
+		//     esc_html__('Event Datetime & Ticket', 'event_espresso'),
1570
+		//     array($this, 'ticket_metabox'),
1571
+		//     $this->page_slug,
1572
+		//     'normal',
1573
+		//     'high'
1574
+		// );
1575
+		add_meta_box(
1576
+			'espresso_event_editor_event_options',
1577
+			esc_html__('Event Registration Options', 'event_espresso'),
1578
+			array($this, 'registration_options_meta_box'),
1579
+			$this->page_slug,
1580
+			'side'
1581
+		);
1582
+		// NOTE: if you're looking for other metaboxes in here,
1583
+		// where a metabox has a related management page in the admin
1584
+		// you will find it setup in the related management page's "_Hooks" file.
1585
+		// i.e. messages metabox is found in "espresso_events_Messages_Hooks.class.php".
1586
+	}
1587
+
1588
+
1589
+	/**
1590
+	 * @throws DomainException
1591
+	 * @throws EE_Error
1592
+	 * @throws InvalidArgumentException
1593
+	 * @throws InvalidDataTypeException
1594
+	 * @throws InvalidInterfaceException
1595
+	 * @throws ReflectionException
1596
+	 */
1597
+	public function ticket_metabox()
1598
+	{
1599
+		$existing_datetime_ids = $existing_ticket_ids = array();
1600
+		// defaults for template args
1601
+		$template_args = array(
1602
+			'existing_datetime_ids'    => '',
1603
+			'event_datetime_help_link' => '',
1604
+			'ticket_options_help_link' => '',
1605
+			'time'                     => null,
1606
+			'ticket_rows'              => '',
1607
+			'existing_ticket_ids'      => '',
1608
+			'total_ticket_rows'        => 1,
1609
+			'ticket_js_structure'      => '',
1610
+			'trash_icon'               => 'ee-lock-icon',
1611
+			'disabled'                 => '',
1612
+		);
1613
+		$event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : null;
1614
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1615
+		/**
1616
+		 * 1. Start with retrieving Datetimes
1617
+		 * 2. Fore each datetime get related tickets
1618
+		 * 3. For each ticket get related prices
1619
+		 */
1620
+		$times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id);
1621
+		/** @type EE_Datetime $first_datetime */
1622
+		$first_datetime = reset($times);
1623
+		// do we get related tickets?
1624
+		if ($first_datetime instanceof EE_Datetime
1625
+			&& $first_datetime->ID() !== 0
1626
+		) {
1627
+			$existing_datetime_ids[] = $first_datetime->get('DTT_ID');
1628
+			$template_args['time'] = $first_datetime;
1629
+			$related_tickets = $first_datetime->tickets(
1630
+				array(
1631
+					array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)),
1632
+					'default_where_conditions' => 'none',
1633
+				)
1634
+			);
1635
+			if (! empty($related_tickets)) {
1636
+				$template_args['total_ticket_rows'] = count($related_tickets);
1637
+				$row = 0;
1638
+				foreach ($related_tickets as $ticket) {
1639
+					$existing_ticket_ids[] = $ticket->get('TKT_ID');
1640
+					$template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, false, $row);
1641
+					$row++;
1642
+				}
1643
+			} else {
1644
+				$template_args['total_ticket_rows'] = 1;
1645
+				/** @type EE_Ticket $ticket */
1646
+				$ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object();
1647
+				$template_args['ticket_rows'] .= $this->_get_ticket_row($ticket);
1648
+			}
1649
+		} else {
1650
+			$template_args['time'] = $times[0];
1651
+			/** @type EE_Ticket $ticket */
1652
+			$ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets();
1653
+			$template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]);
1654
+			// NOTE: we're just sending the first default row
1655
+			// (decaf can't manage default tickets so this should be sufficient);
1656
+		}
1657
+		$template_args['event_datetime_help_link'] = $this->_get_help_tab_link(
1658
+			'event_editor_event_datetimes_help_tab'
1659
+		);
1660
+		$template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info');
1661
+		$template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids);
1662
+		$template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids);
1663
+		$template_args['ticket_js_structure'] = $this->_get_ticket_row(
1664
+			EE_Registry::instance()->load_model('Ticket')->create_default_object(),
1665
+			true
1666
+		);
1667
+		$template = apply_filters(
1668
+			'FHEE__Events_Admin_Page__ticket_metabox__template',
1669
+			EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php'
1670
+		);
1671
+		EEH_Template::display_template($template, $template_args);
1672
+	}
1673
+
1674
+
1675
+	/**
1676
+	 * Setup an individual ticket form for the decaf event editor page
1677
+	 *
1678
+	 * @access private
1679
+	 * @param EE_Ticket $ticket   the ticket object
1680
+	 * @param boolean   $skeleton whether we're generating a skeleton for js manipulation
1681
+	 * @param int       $row
1682
+	 * @return string generated html for the ticket row.
1683
+	 * @throws DomainException
1684
+	 * @throws EE_Error
1685
+	 * @throws InvalidArgumentException
1686
+	 * @throws InvalidDataTypeException
1687
+	 * @throws InvalidInterfaceException
1688
+	 * @throws ReflectionException
1689
+	 */
1690
+	private function _get_ticket_row($ticket, $skeleton = false, $row = 0)
1691
+	{
1692
+		$template_args = array(
1693
+			'tkt_status_class'    => ' tkt-status-' . $ticket->ticket_status(),
1694
+			'tkt_archive_class'   => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived'
1695
+				: '',
1696
+			'ticketrow'           => $skeleton ? 'TICKETNUM' : $row,
1697
+			'TKT_ID'              => $ticket->get('TKT_ID'),
1698
+			'TKT_name'            => $ticket->get('TKT_name'),
1699
+			'TKT_start_date'      => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'),
1700
+			'TKT_end_date'        => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'),
1701
+			'TKT_is_default'      => $ticket->get('TKT_is_default'),
1702
+			'TKT_qty'             => $ticket->get_pretty('TKT_qty', 'input'),
1703
+			'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets',
1704
+			'TKT_sold'            => $skeleton ? 0 : $ticket->get('TKT_sold'),
1705
+			'trash_icon'          => ($skeleton || (! empty($ticket) && ! $ticket->get('TKT_deleted')))
1706
+									 && (! empty($ticket) && $ticket->get('TKT_sold') === 0)
1707
+				? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon',
1708
+			'disabled'            => $skeleton || (! empty($ticket) && ! $ticket->get('TKT_deleted')) ? ''
1709
+				: ' disabled=disabled',
1710
+		);
1711
+		$price = $ticket->ID() !== 0
1712
+			? $ticket->get_first_related('Price', array('default_where_conditions' => 'none'))
1713
+			: EE_Registry::instance()->load_model('Price')->create_default_object();
1714
+		$price_args = array(
1715
+			'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,
1716
+			'PRC_amount'            => $price->get('PRC_amount'),
1717
+			'PRT_ID'                => $price->get('PRT_ID'),
1718
+			'PRC_ID'                => $price->get('PRC_ID'),
1719
+			'PRC_is_default'        => $price->get('PRC_is_default'),
1720
+		);
1721
+		// make sure we have default start and end dates if skeleton
1722
+		// handle rows that should NOT be empty
1723
+		if (empty($template_args['TKT_start_date'])) {
1724
+			// if empty then the start date will be now.
1725
+			$template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp'));
1726
+		}
1727
+		if (empty($template_args['TKT_end_date'])) {
1728
+			// get the earliest datetime (if present);
1729
+			$earliest_dtt = $this->_cpt_model_obj->ID() > 0
1730
+				? $this->_cpt_model_obj->get_first_related(
1731
+					'Datetime',
1732
+					array('order_by' => array('DTT_EVT_start' => 'ASC'))
1733
+				)
1734
+				: null;
1735
+			if (! empty($earliest_dtt)) {
1736
+				$template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a');
1737
+			} else {
1738
+				$template_args['TKT_end_date'] = date(
1739
+					'Y-m-d h:i a',
1740
+					mktime(0, 0, 0, date('m'), date('d') + 7, date('Y'))
1741
+				);
1742
+			}
1743
+		}
1744
+		$template_args = array_merge($template_args, $price_args);
1745
+		$template = apply_filters(
1746
+			'FHEE__Events_Admin_Page__get_ticket_row__template',
1747
+			EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php',
1748
+			$ticket
1749
+		);
1750
+		return EEH_Template::display_template($template, $template_args, true);
1751
+	}
1752
+
1753
+
1754
+	/**
1755
+	 * @throws DomainException
1756
+	 * @throws EE_Error
1757
+	 */
1758
+	public function registration_options_meta_box()
1759
+	{
1760
+		$yes_no_values = array(
1761
+			array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')),
1762
+			array('id' => false, 'text' => esc_html__('No', 'event_espresso')),
1763
+		);
1764
+		$default_reg_status_values = EEM_Registration::reg_status_array(
1765
+			array(
1766
+				EEM_Registration::status_id_cancelled,
1767
+				EEM_Registration::status_id_declined,
1768
+				EEM_Registration::status_id_incomplete,
1769
+			),
1770
+			true
1771
+		);
1772
+		// $template_args['is_active_select'] = EEH_Form_Fields::select_input('is_active', $yes_no_values, $this->_cpt_model_obj->is_active());
1773
+		$template_args['_event'] = $this->_cpt_model_obj;
1774
+		$template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false);
1775
+		$template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit();
1776
+		$template_args['default_registration_status'] = EEH_Form_Fields::select_input(
1777
+			'default_reg_status',
1778
+			$default_reg_status_values,
1779
+			$this->_cpt_model_obj->default_registration_status()
1780
+		);
1781
+		$template_args['display_description'] = EEH_Form_Fields::select_input(
1782
+			'display_desc',
1783
+			$yes_no_values,
1784
+			$this->_cpt_model_obj->display_description()
1785
+		);
1786
+		$template_args['display_ticket_selector'] = EEH_Form_Fields::select_input(
1787
+			'display_ticket_selector',
1788
+			$yes_no_values,
1789
+			$this->_cpt_model_obj->display_ticket_selector(),
1790
+			'',
1791
+			'',
1792
+			false
1793
+		);
1794
+		$template_args['additional_registration_options'] = apply_filters(
1795
+			'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options',
1796
+			'',
1797
+			$template_args,
1798
+			$yes_no_values,
1799
+			$default_reg_status_values
1800
+		);
1801
+		EEH_Template::display_template(
1802
+			EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php',
1803
+			$template_args
1804
+		);
1805
+	}
1806
+
1807
+
1808
+	/**
1809
+	 * _get_events()
1810
+	 * This method simply returns all the events (for the given _view and paging)
1811
+	 *
1812
+	 * @access public
1813
+	 * @param int  $per_page     count of items per page (20 default);
1814
+	 * @param int  $current_page what is the current page being viewed.
1815
+	 * @param bool $count        if TRUE then we just return a count of ALL events matching the given _view.
1816
+	 *                           If FALSE then we return an array of event objects
1817
+	 *                           that match the given _view and paging parameters.
1818
+	 * @return array an array of event objects.
1819
+	 * @throws EE_Error
1820
+	 * @throws InvalidArgumentException
1821
+	 * @throws InvalidDataTypeException
1822
+	 * @throws InvalidInterfaceException
1823
+	 * @throws ReflectionException
1824
+	 * @throws Exception
1825
+	 * @throws Exception
1826
+	 * @throws Exception
1827
+	 */
1828
+	public function get_events($per_page = 10, $current_page = 1, $count = false)
1829
+	{
1830
+		$EEME = $this->_event_model();
1831
+		$offset = ($current_page - 1) * $per_page;
1832
+		$limit = $count ? null : $offset . ',' . $per_page;
1833
+		$orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID';
1834
+		$order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC';
1835
+		if (isset($this->_req_data['month_range'])) {
1836
+			$pieces = explode(' ', $this->_req_data['month_range'], 3);
1837
+			// simulate the FIRST day of the month, that fixes issues for months like February
1838
+			// where PHP doesn't know what to assume for date.
1839
+			// @see https://events.codebasehq.com/projects/event-espresso/tickets/10437
1840
+			$month_r = ! empty($pieces[0]) ? date('m', EEH_DTT_Helper::first_of_month_timestamp($pieces[0])) : '';
1841
+			$year_r = ! empty($pieces[1]) ? $pieces[1] : '';
1842
+		}
1843
+		$where = array();
1844
+		$status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
1845
+		// determine what post_status our condition will have for the query.
1846
+		switch ($status) {
1847
+			case 'month':
1848
+			case 'today':
1849
+			case null:
1850
+			case 'all':
1851
+				break;
1852
+			case 'draft':
1853
+				$where['status'] = array('IN', array('draft', 'auto-draft'));
1854
+				break;
1855
+			default:
1856
+				$where['status'] = $status;
1857
+		}
1858
+		// categories?
1859
+		$category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0
1860
+			? $this->_req_data['EVT_CAT'] : null;
1861
+		if (! empty($category)) {
1862
+			$where['Term_Taxonomy.taxonomy'] = EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY;
1863
+			$where['Term_Taxonomy.term_id'] = $category;
1864
+		}
1865
+		// date where conditions
1866
+		$start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start');
1867
+		if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] !== '') {
1868
+			$DateTime = new DateTime(
1869
+				$year_r . '-' . $month_r . '-01 00:00:00',
1870
+				new DateTimeZone(EEM_Datetime::instance()->get_timezone())
1871
+			);
1872
+			$start = $DateTime->format(implode(' ', $start_formats));
1873
+			$end = $DateTime->setDate(
1874
+				$year_r,
1875
+				$month_r,
1876
+				$DateTime
1877
+					->format('t')
1878
+			)->setTime(23, 59, 59)
1879
+							->format(implode(' ', $start_formats));
1880
+			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1881
+		} elseif (isset($this->_req_data['status']) && $this->_req_data['status'] === 'today') {
1882
+			$DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone()));
1883
+			$start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats));
1884
+			$end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats));
1885
+			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1886
+		} elseif (isset($this->_req_data['status']) && $this->_req_data['status'] === 'month') {
1887
+			$now = date('Y-m-01');
1888
+			$DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone()));
1889
+			$start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats));
1890
+			$end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t'))
1891
+							->setTime(23, 59, 59)
1892
+							->format(implode(' ', $start_formats));
1893
+			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1894
+		}
1895
+		if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
1896
+			$where['EVT_wp_user'] = get_current_user_id();
1897
+		} elseif (! isset($where['status'])
1898
+			&& ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')
1899
+		) {
1900
+			$where['OR'] = array(
1901
+				'status*restrict_private' => array('!=', 'private'),
1902
+				'AND'                     => array(
1903
+					'status*inclusive' => array('=', 'private'),
1904
+					'EVT_wp_user'      => get_current_user_id(),
1905
+				),
1906
+			);
1907
+		}
1908
+
1909
+		if (isset($this->_req_data['EVT_wp_user'])
1910
+			&& (int) $this->_req_data['EVT_wp_user'] !== (int) get_current_user_id()
1911
+			&& EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')
1912
+		) {
1913
+			$where['EVT_wp_user'] = $this->_req_data['EVT_wp_user'];
1914
+		}
1915
+		// search query handling
1916
+		if (isset($this->_req_data['s'])) {
1917
+			$search_string = '%' . $this->_req_data['s'] . '%';
1918
+			$where['OR'] = array(
1919
+				'EVT_name'       => array('LIKE', $search_string),
1920
+				'EVT_desc'       => array('LIKE', $search_string),
1921
+				'EVT_short_desc' => array('LIKE', $search_string),
1922
+			);
1923
+		}
1924
+		// filter events by venue.
1925
+		if (isset($this->_req_data['venue']) && ! empty($this->_req_data['venue'])) {
1926
+			$where['Venue.VNU_ID'] = absint($this->_req_data['venue']);
1927
+		}
1928
+		$where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data);
1929
+		$query_params = apply_filters(
1930
+			'FHEE__Events_Admin_Page__get_events__query_params',
1931
+			array(
1932
+				$where,
1933
+				'limit'    => $limit,
1934
+				'order_by' => $orderby,
1935
+				'order'    => $order,
1936
+				'group_by' => 'EVT_ID',
1937
+			),
1938
+			$this->_req_data
1939
+		);
1940
+		// let's first check if we have special requests coming in.
1941
+		if (isset($this->_req_data['active_status'])) {
1942
+			switch ($this->_req_data['active_status']) {
1943
+				case 'upcoming':
1944
+					return $EEME->get_upcoming_events($query_params, $count);
1945
+					break;
1946
+				case 'expired':
1947
+					return $EEME->get_expired_events($query_params, $count);
1948
+					break;
1949
+				case 'active':
1950
+					return $EEME->get_active_events($query_params, $count);
1951
+					break;
1952
+				case 'inactive':
1953
+					return $EEME->get_inactive_events($query_params, $count);
1954
+					break;
1955
+			}
1956
+		}
1957
+
1958
+		$events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params);
1959
+		return $events;
1960
+	}
1961
+
1962
+
1963
+	/**
1964
+	 * handling for WordPress CPT actions (trash, restore, delete)
1965
+	 *
1966
+	 * @param string $post_id
1967
+	 * @throws EE_Error
1968
+	 * @throws InvalidArgumentException
1969
+	 * @throws InvalidDataTypeException
1970
+	 * @throws InvalidInterfaceException
1971
+	 * @throws ReflectionException
1972
+	 */
1973
+	public function trash_cpt_item($post_id)
1974
+	{
1975
+		$this->_req_data['EVT_ID'] = $post_id;
1976
+		$this->_trash_or_restore_event('trash', false);
1977
+	}
1978
+
1979
+
1980
+	/**
1981
+	 * @param string $post_id
1982
+	 * @throws EE_Error
1983
+	 * @throws InvalidArgumentException
1984
+	 * @throws InvalidDataTypeException
1985
+	 * @throws InvalidInterfaceException
1986
+	 * @throws ReflectionException
1987
+	 */
1988
+	public function restore_cpt_item($post_id)
1989
+	{
1990
+		$this->_req_data['EVT_ID'] = $post_id;
1991
+		$this->_trash_or_restore_event('draft', false);
1992
+	}
1993
+
1994
+
1995
+	/**
1996
+	 * @param string $post_id
1997
+	 * @throws EE_Error
1998
+	 * @throws InvalidArgumentException
1999
+	 * @throws InvalidDataTypeException
2000
+	 * @throws InvalidInterfaceException
2001
+	 * @throws ReflectionException
2002
+	 */
2003
+	public function delete_cpt_item($post_id)
2004
+	{
2005
+		$this->_req_data['EVT_ID'] = $post_id;
2006
+		$this->_delete_event(false);
2007
+	}
2008
+
2009
+
2010
+	/**
2011
+	 * _trash_or_restore_event
2012
+	 *
2013
+	 * @access protected
2014
+	 * @param string $event_status
2015
+	 * @param bool   $redirect_after
2016
+	 * @throws EE_Error
2017
+	 * @throws InvalidArgumentException
2018
+	 * @throws InvalidDataTypeException
2019
+	 * @throws InvalidInterfaceException
2020
+	 * @throws ReflectionException
2021
+	 */
2022
+	protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = true)
2023
+	{
2024
+		// determine the event id and set to array.
2025
+		$EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : false;
2026
+		// loop thru events
2027
+		if ($EVT_ID) {
2028
+			// clean status
2029
+			$event_status = sanitize_key($event_status);
2030
+			// grab status
2031
+			if (! empty($event_status)) {
2032
+				$success = $this->_change_event_status($EVT_ID, $event_status);
2033
+			} else {
2034
+				$success = false;
2035
+				$msg = esc_html__(
2036
+					'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.',
2037
+					'event_espresso'
2038
+				);
2039
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2040
+			}
2041
+		} else {
2042
+			$success = false;
2043
+			$msg = esc_html__(
2044
+				'An error occurred. The event could not be moved to the trash because a valid event ID was not not supplied.',
2045
+				'event_espresso'
2046
+			);
2047
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2048
+		}
2049
+		$action = $event_status === 'trash' ? 'moved to the trash' : 'restored from the trash';
2050
+		if ($redirect_after) {
2051
+			$this->_redirect_after_action($success, 'Event', $action, array('action' => 'default'));
2052
+		}
2053
+	}
2054
+
2055
+
2056
+	/**
2057
+	 * _trash_or_restore_events
2058
+	 *
2059
+	 * @access protected
2060
+	 * @param string $event_status
2061
+	 * @return void
2062
+	 * @throws EE_Error
2063
+	 * @throws InvalidArgumentException
2064
+	 * @throws InvalidDataTypeException
2065
+	 * @throws InvalidInterfaceException
2066
+	 * @throws ReflectionException
2067
+	 */
2068
+	protected function _trash_or_restore_events($event_status = 'trash')
2069
+	{
2070
+		// clean status
2071
+		$event_status = sanitize_key($event_status);
2072
+		// grab status
2073
+		if (! empty($event_status)) {
2074
+			$success = true;
2075
+			// determine the event id and set to array.
2076
+			$EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array();
2077
+			// loop thru events
2078
+			foreach ($EVT_IDs as $EVT_ID) {
2079
+				if ($EVT_ID = absint($EVT_ID)) {
2080
+					$results = $this->_change_event_status($EVT_ID, $event_status);
2081
+					$success = $results !== false ? $success : false;
2082
+				} else {
2083
+					$msg = sprintf(
2084
+						esc_html__(
2085
+							'An error occurred. Event #%d could not be moved to the trash because a valid event ID was not not supplied.',
2086
+							'event_espresso'
2087
+						),
2088
+						$EVT_ID
2089
+					);
2090
+					EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2091
+					$success = false;
2092
+				}
2093
+			}
2094
+		} else {
2095
+			$success = false;
2096
+			$msg = esc_html__(
2097
+				'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.',
2098
+				'event_espresso'
2099
+			);
2100
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2101
+		}
2102
+		// in order to force a pluralized result message we need to send back a success status greater than 1
2103
+		$success = $success ? 2 : false;
2104
+		$action = $event_status === 'trash' ? 'moved to the trash' : 'restored from the trash';
2105
+		$this->_redirect_after_action($success, 'Events', $action, array('action' => 'default'));
2106
+	}
2107
+
2108
+
2109
+	/**
2110
+	 * _trash_or_restore_events
2111
+	 *
2112
+	 * @access  private
2113
+	 * @param int    $EVT_ID
2114
+	 * @param string $event_status
2115
+	 * @return bool
2116
+	 * @throws EE_Error
2117
+	 * @throws InvalidArgumentException
2118
+	 * @throws InvalidDataTypeException
2119
+	 * @throws InvalidInterfaceException
2120
+	 * @throws ReflectionException
2121
+	 */
2122
+	private function _change_event_status($EVT_ID = 0, $event_status = '')
2123
+	{
2124
+		// grab event id
2125
+		if (! $EVT_ID) {
2126
+			$msg = esc_html__(
2127
+				'An error occurred. No Event ID or an invalid Event ID was received.',
2128
+				'event_espresso'
2129
+			);
2130
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2131
+			return false;
2132
+		}
2133
+		$this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID);
2134
+		// clean status
2135
+		$event_status = sanitize_key($event_status);
2136
+		// grab status
2137
+		if (empty($event_status)) {
2138
+			$msg = esc_html__(
2139
+				'An error occurred. No Event Status or an invalid Event Status was received.',
2140
+				'event_espresso'
2141
+			);
2142
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2143
+			return false;
2144
+		}
2145
+		// was event trashed or restored ?
2146
+		switch ($event_status) {
2147
+			case 'draft':
2148
+				$action = 'restored from the trash';
2149
+				$hook = 'AHEE_event_restored_from_trash';
2150
+				break;
2151
+			case 'trash':
2152
+				$action = 'moved to the trash';
2153
+				$hook = 'AHEE_event_moved_to_trash';
2154
+				break;
2155
+			default:
2156
+				$action = 'updated';
2157
+				$hook = false;
2158
+		}
2159
+		// use class to change status
2160
+		$this->_cpt_model_obj->set_status($event_status);
2161
+		$success = $this->_cpt_model_obj->save();
2162
+		if ($success === false) {
2163
+			$msg = sprintf(esc_html__('An error occurred. The event could not be %s.', 'event_espresso'), $action);
2164
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2165
+			return false;
2166
+		}
2167
+		if ($hook) {
2168
+			do_action($hook);
2169
+		}
2170
+		return true;
2171
+	}
2172
+
2173
+
2174
+	/**
2175
+	 * _delete_event
2176
+	 *
2177
+	 * @access protected
2178
+	 * @param bool $redirect_after
2179
+	 * @throws EE_Error
2180
+	 * @throws InvalidArgumentException
2181
+	 * @throws InvalidDataTypeException
2182
+	 * @throws InvalidInterfaceException
2183
+	 * @throws ReflectionException
2184
+	 */
2185
+	protected function _delete_event($redirect_after = true)
2186
+	{
2187
+		// determine the event id and set to array.
2188
+		$EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : null;
2189
+		$EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID;
2190
+		// loop thru events
2191
+		if ($EVT_ID) {
2192
+			$success = $this->_permanently_delete_event($EVT_ID);
2193
+			// get list of events with no prices
2194
+			$espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array());
2195
+			// remove this event from the list of events with no prices
2196
+			if (isset($espresso_no_ticket_prices[ $EVT_ID ])) {
2197
+				unset($espresso_no_ticket_prices[ $EVT_ID ]);
2198
+			}
2199
+			update_option('ee_no_ticket_prices', $espresso_no_ticket_prices);
2200
+		} else {
2201
+			$success = false;
2202
+			$msg = esc_html__(
2203
+				'An error occurred. An event could not be deleted because a valid event ID was not not supplied.',
2204
+				'event_espresso'
2205
+			);
2206
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2207
+		}
2208
+		if ($redirect_after) {
2209
+			$this->_redirect_after_action(
2210
+				$success,
2211
+				'Event',
2212
+				'deleted',
2213
+				array('action' => 'default', 'status' => 'trash')
2214
+			);
2215
+		}
2216
+	}
2217
+
2218
+
2219
+	/**
2220
+	 * _delete_events
2221
+	 *
2222
+	 * @access protected
2223
+	 * @return void
2224
+	 * @throws EE_Error
2225
+	 * @throws InvalidArgumentException
2226
+	 * @throws InvalidDataTypeException
2227
+	 * @throws InvalidInterfaceException
2228
+	 * @throws ReflectionException
2229
+	 */
2230
+	protected function _delete_events()
2231
+	{
2232
+		$success = true;
2233
+		// get list of events with no prices
2234
+		$espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array());
2235
+		// determine the event id and set to array.
2236
+		$EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array();
2237
+		// loop thru events
2238
+		foreach ($EVT_IDs as $EVT_ID) {
2239
+			$EVT_ID = absint($EVT_ID);
2240
+			if ($EVT_ID) {
2241
+				$results = $this->_permanently_delete_event($EVT_ID);
2242
+				$success = $results !== false ? $success : false;
2243
+				// remove this event from the list of events with no prices
2244
+				unset($espresso_no_ticket_prices[ $EVT_ID ]);
2245
+			} else {
2246
+				$success = false;
2247
+				$msg = esc_html__(
2248
+					'An error occurred. An event could not be deleted because a valid event ID was not not supplied.',
2249
+					'event_espresso'
2250
+				);
2251
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2252
+			}
2253
+		}
2254
+		update_option('ee_no_ticket_prices', $espresso_no_ticket_prices);
2255
+		// in order to force a pluralized result message we need to send back a success status greater than 1
2256
+		$success = $success ? 2 : false;
2257
+		$this->_redirect_after_action($success, 'Events', 'deleted', array('action' => 'default'));
2258
+	}
2259
+
2260
+
2261
+	/**
2262
+	 * _permanently_delete_event
2263
+	 *
2264
+	 * @access  private
2265
+	 * @param int $EVT_ID
2266
+	 * @return bool
2267
+	 * @throws EE_Error
2268
+	 * @throws InvalidArgumentException
2269
+	 * @throws InvalidDataTypeException
2270
+	 * @throws InvalidInterfaceException
2271
+	 * @throws ReflectionException
2272
+	 */
2273
+	private function _permanently_delete_event($EVT_ID = 0)
2274
+	{
2275
+		// grab event id
2276
+		if (! $EVT_ID) {
2277
+			$msg = esc_html__(
2278
+				'An error occurred. No Event ID or an invalid Event ID was received.',
2279
+				'event_espresso'
2280
+			);
2281
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2282
+			return false;
2283
+		}
2284
+		if (! $this->_cpt_model_obj instanceof EE_Event
2285
+			|| $this->_cpt_model_obj->ID() !== $EVT_ID
2286
+		) {
2287
+			$this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID);
2288
+		}
2289
+		if (! $this->_cpt_model_obj instanceof EE_Event) {
2290
+			return false;
2291
+		}
2292
+		// need to delete related tickets and prices first.
2293
+		$datetimes = $this->_cpt_model_obj->get_many_related('Datetime');
2294
+		foreach ($datetimes as $datetime) {
2295
+			$this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime');
2296
+			$tickets = $datetime->get_many_related('Ticket');
2297
+			foreach ($tickets as $ticket) {
2298
+				$ticket->_remove_relation_to($datetime, 'Datetime');
2299
+				$ticket->delete_related_permanently('Price');
2300
+				$ticket->delete_permanently();
2301
+			}
2302
+			$datetime->delete();
2303
+		}
2304
+		// what about related venues or terms?
2305
+		$venues = $this->_cpt_model_obj->get_many_related('Venue');
2306
+		foreach ($venues as $venue) {
2307
+			$this->_cpt_model_obj->_remove_relation_to($venue, 'Venue');
2308
+		}
2309
+		// any attached question groups?
2310
+		$question_groups = $this->_cpt_model_obj->get_many_related('Question_Group');
2311
+		if (! empty($question_groups)) {
2312
+			foreach ($question_groups as $question_group) {
2313
+				$this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group');
2314
+			}
2315
+		}
2316
+		// Message Template Groups
2317
+		$this->_cpt_model_obj->_remove_relations('Message_Template_Group');
2318
+		/** @type EE_Term_Taxonomy[] $term_taxonomies */
2319
+		$term_taxonomies = $this->_cpt_model_obj->term_taxonomies();
2320
+		foreach ($term_taxonomies as $term_taxonomy) {
2321
+			$this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy);
2322
+		}
2323
+		$success = $this->_cpt_model_obj->delete_permanently();
2324
+		// did it all go as planned ?
2325
+		if ($success) {
2326
+			$msg = sprintf(esc_html__('Event ID # %d has been deleted.', 'event_espresso'), $EVT_ID);
2327
+			EE_Error::add_success($msg);
2328
+		} else {
2329
+			$msg = sprintf(
2330
+				esc_html__('An error occurred. Event ID # %d could not be deleted.', 'event_espresso'),
2331
+				$EVT_ID
2332
+			);
2333
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2334
+			return false;
2335
+		}
2336
+		do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID);
2337
+		return true;
2338
+	}
2339
+
2340
+
2341
+	/**
2342
+	 * get total number of events
2343
+	 *
2344
+	 * @access public
2345
+	 * @return int
2346
+	 * @throws EE_Error
2347
+	 * @throws InvalidArgumentException
2348
+	 * @throws InvalidDataTypeException
2349
+	 * @throws InvalidInterfaceException
2350
+	 */
2351
+	public function total_events()
2352
+	{
2353
+		$count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true);
2354
+		return $count;
2355
+	}
2356
+
2357
+
2358
+	/**
2359
+	 * get total number of draft events
2360
+	 *
2361
+	 * @access public
2362
+	 * @return int
2363
+	 * @throws EE_Error
2364
+	 * @throws InvalidArgumentException
2365
+	 * @throws InvalidDataTypeException
2366
+	 * @throws InvalidInterfaceException
2367
+	 */
2368
+	public function total_events_draft()
2369
+	{
2370
+		$where = array(
2371
+			'status' => array('IN', array('draft', 'auto-draft')),
2372
+		);
2373
+		$count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
2374
+		return $count;
2375
+	}
2376
+
2377
+
2378
+	/**
2379
+	 * get total number of trashed events
2380
+	 *
2381
+	 * @access public
2382
+	 * @return int
2383
+	 * @throws EE_Error
2384
+	 * @throws InvalidArgumentException
2385
+	 * @throws InvalidDataTypeException
2386
+	 * @throws InvalidInterfaceException
2387
+	 */
2388
+	public function total_trashed_events()
2389
+	{
2390
+		$where = array(
2391
+			'status' => 'trash',
2392
+		);
2393
+		$count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
2394
+		return $count;
2395
+	}
2396
+
2397
+
2398
+	/**
2399
+	 *    _default_event_settings
2400
+	 *    This generates the Default Settings Tab
2401
+	 *
2402
+	 * @return void
2403
+	 * @throws DomainException
2404
+	 * @throws EE_Error
2405
+	 * @throws InvalidArgumentException
2406
+	 * @throws InvalidDataTypeException
2407
+	 * @throws InvalidInterfaceException
2408
+	 */
2409
+	protected function _default_event_settings()
2410
+	{
2411
+		$this->_set_add_edit_form_tags('update_default_event_settings');
2412
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
2413
+		$this->_template_args['admin_page_content'] = $this->_default_event_settings_form()->get_html();
2414
+		$this->display_admin_page_with_sidebar();
2415
+	}
2416
+
2417
+
2418
+	/**
2419
+	 * Return the form for event settings.
2420
+	 *
2421
+	 * @return EE_Form_Section_Proper
2422
+	 * @throws EE_Error
2423
+	 */
2424
+	protected function _default_event_settings_form()
2425
+	{
2426
+		$registration_config = EE_Registry::instance()->CFG->registration;
2427
+		$registration_stati_for_selection = EEM_Registration::reg_status_array(
2428
+			// exclude
2429
+			array(
2430
+				EEM_Registration::status_id_cancelled,
2431
+				EEM_Registration::status_id_declined,
2432
+				EEM_Registration::status_id_incomplete,
2433
+				EEM_Registration::status_id_wait_list,
2434
+			),
2435
+			true
2436
+		);
2437
+		return new EE_Form_Section_Proper(
2438
+			array(
2439
+				'name'            => 'update_default_event_settings',
2440
+				'html_id'         => 'update_default_event_settings',
2441
+				'html_class'      => 'form-table',
2442
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
2443
+				'subsections'     => apply_filters(
2444
+					'FHEE__Events_Admin_Page___default_event_settings_form__form_subsections',
2445
+					array(
2446
+						'default_reg_status'  => new EE_Select_Input(
2447
+							$registration_stati_for_selection,
2448
+							array(
2449
+								'default'         => isset($registration_config->default_STS_ID)
2450
+													 && array_key_exists(
2451
+														 $registration_config->default_STS_ID,
2452
+														 $registration_stati_for_selection
2453
+													 )
2454
+									? sanitize_text_field($registration_config->default_STS_ID)
2455
+									: EEM_Registration::status_id_pending_payment,
2456
+								'html_label_text' => esc_html__('Default Registration Status', 'event_espresso')
2457
+													 . EEH_Template::get_help_tab_link(
2458
+														 'default_settings_status_help_tab'
2459
+													 ),
2460
+								'html_help_text'  => esc_html__(
2461
+									'This setting allows you to preselect what the default registration status setting is when creating an event.  Note that changing this setting does NOT retroactively apply it to existing events.',
2462
+									'event_espresso'
2463
+								),
2464
+							)
2465
+						),
2466
+						'default_max_tickets' => new EE_Integer_Input(
2467
+							array(
2468
+								'default'         => isset($registration_config->default_maximum_number_of_tickets)
2469
+									? $registration_config->default_maximum_number_of_tickets
2470
+									: EEM_Event::get_default_additional_limit(),
2471
+								'html_label_text' => esc_html__(
2472
+									'Default Maximum Tickets Allowed Per Order:',
2473
+									'event_espresso'
2474
+								)
2475
+													 . EEH_Template::get_help_tab_link(
2476
+														 'default_maximum_tickets_help_tab"'
2477
+													 ),
2478
+								'html_help_text'  => esc_html__(
2479
+									'This setting allows you to indicate what will be the default for the maximum number of tickets per order when creating new events.',
2480
+									'event_espresso'
2481
+								),
2482
+							)
2483
+						),
2484
+					)
2485
+				),
2486
+			)
2487
+		);
2488
+	}
2489
+
2490
+
2491
+	/**
2492
+	 * @return void
2493
+	 * @throws EE_Error
2494
+	 * @throws InvalidArgumentException
2495
+	 * @throws InvalidDataTypeException
2496
+	 * @throws InvalidInterfaceException
2497
+	 */
2498
+	protected function _update_default_event_settings()
2499
+	{
2500
+		$form = $this->_default_event_settings_form();
2501
+		if ($form->was_submitted()) {
2502
+			$form->receive_form_submission();
2503
+			if ($form->is_valid()) {
2504
+				$registration_config = EE_Registry::instance()->CFG->registration;
2505
+				$valid_data = $form->valid_data();
2506
+				if (isset($valid_data['default_reg_status'])) {
2507
+					$registration_config->default_STS_ID = $valid_data['default_reg_status'];
2508
+				}
2509
+				if (isset($valid_data['default_max_tickets'])) {
2510
+					$registration_config->default_maximum_number_of_tickets = $valid_data['default_max_tickets'];
2511
+				}
2512
+				do_action(
2513
+					'AHEE__Events_Admin_Page___update_default_event_settings',
2514
+					$valid_data,
2515
+					EE_Registry::instance()->CFG,
2516
+					$this
2517
+				);
2518
+				// update because data was valid!
2519
+				EE_Registry::instance()->CFG->update_espresso_config();
2520
+				EE_Error::overwrite_success();
2521
+				EE_Error::add_success(
2522
+					__('Default Event Settings were updated', 'event_espresso')
2523
+				);
2524
+			}
2525
+		}
2526
+		$this->_redirect_after_action(0, '', '', array('action' => 'default_event_settings'), true);
2527
+	}
2528
+
2529
+
2530
+	/*************        Templates        *************/
2531
+	protected function _template_settings()
2532
+	{
2533
+		$this->_admin_page_title = esc_html__('Template Settings (Preview)', 'event_espresso');
2534
+		$this->_template_args['preview_img'] = '<img src="'
2535
+											   . EVENTS_ASSETS_URL
2536
+											   . '/images/'
2537
+											   . 'caffeinated_template_features.jpg" alt="'
2538
+											   . esc_attr__('Template Settings Preview screenshot', 'event_espresso')
2539
+											   . '" />';
2540
+		$this->_template_args['preview_text'] = '<strong>'
2541
+												. esc_html__(
2542
+													'Template Settings is a feature that is only available in the premium version of Event Espresso 4 which is available with a support license purchase on EventEspresso.com. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.',
2543
+													'event_espresso'
2544
+												) . '</strong>';
2545
+		$this->display_admin_caf_preview_page('template_settings_tab');
2546
+	}
2547
+
2548
+
2549
+	/** Event Category Stuff **/
2550
+	/**
2551
+	 * set the _category property with the category object for the loaded page.
2552
+	 *
2553
+	 * @access private
2554
+	 * @return void
2555
+	 */
2556
+	private function _set_category_object()
2557
+	{
2558
+		if (isset($this->_category->id) && ! empty($this->_category->id)) {
2559
+			return;
2560
+		} //already have the category object so get out.
2561
+		// set default category object
2562
+		$this->_set_empty_category_object();
2563
+		// only set if we've got an id
2564
+		if (! isset($this->_req_data['EVT_CAT_ID'])) {
2565
+			return;
2566
+		}
2567
+		$category_id = absint($this->_req_data['EVT_CAT_ID']);
2568
+		$term = get_term($category_id, EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY);
2569
+		if (! empty($term)) {
2570
+			$this->_category->category_name = $term->name;
2571
+			$this->_category->category_identifier = $term->slug;
2572
+			$this->_category->category_desc = $term->description;
2573
+			$this->_category->id = $term->term_id;
2574
+			$this->_category->parent = $term->parent;
2575
+		}
2576
+	}
2577
+
2578
+
2579
+	/**
2580
+	 * Clears out category properties.
2581
+	 */
2582
+	private function _set_empty_category_object()
2583
+	{
2584
+		$this->_category = new stdClass();
2585
+		$this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = '';
2586
+		$this->_category->id = $this->_category->parent = 0;
2587
+	}
2588
+
2589
+
2590
+	/**
2591
+	 * @throws DomainException
2592
+	 * @throws EE_Error
2593
+	 * @throws InvalidArgumentException
2594
+	 * @throws InvalidDataTypeException
2595
+	 * @throws InvalidInterfaceException
2596
+	 */
2597
+	protected function _category_list_table()
2598
+	{
2599
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2600
+		$this->_search_btn_label = esc_html__('Categories', 'event_espresso');
2601
+		$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
2602
+			'add_category',
2603
+			'add_category',
2604
+			array(),
2605
+			'add-new-h2'
2606
+		);
2607
+		$this->display_admin_list_table_page_with_sidebar();
2608
+	}
2609
+
2610
+
2611
+	/**
2612
+	 * Output category details view.
2613
+	 *
2614
+	 * @param string $view
2615
+	 * @throws DomainException
2616
+	 * @throws EE_Error
2617
+	 * @throws InvalidArgumentException
2618
+	 * @throws InvalidDataTypeException
2619
+	 * @throws InvalidInterfaceException
2620
+	 */
2621
+	protected function _category_details($view)
2622
+	{
2623
+		// load formatter helper
2624
+		// load field generator helper
2625
+		$route = $view === 'edit' ? 'update_category' : 'insert_category';
2626
+		$this->_set_add_edit_form_tags($route);
2627
+		$this->_set_category_object();
2628
+		$id = ! empty($this->_category->id) ? $this->_category->id : '';
2629
+		$delete_action = 'delete_category';
2630
+		// custom redirect
2631
+		$redirect = EE_Admin_Page::add_query_args_and_nonce(
2632
+			array('action' => 'category_list'),
2633
+			$this->_admin_base_url
2634
+		);
2635
+		$this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect);
2636
+		// take care of contents
2637
+		$this->_template_args['admin_page_content'] = $this->_category_details_content();
2638
+		$this->display_admin_page_with_sidebar();
2639
+	}
2640
+
2641
+
2642
+	/**
2643
+	 * Output category details content.
2644
+	 *
2645
+	 * @throws DomainException
2646
+	 */
2647
+	protected function _category_details_content()
2648
+	{
2649
+		$editor_args['category_desc'] = array(
2650
+			'type'          => 'wp_editor',
2651
+			'value'         => EEH_Formatter::admin_format_content($this->_category->category_desc),
2652
+			'class'         => 'my_editor_custom',
2653
+			'wpeditor_args' => array('media_buttons' => false),
2654
+		);
2655
+		$_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array');
2656
+		$all_terms = get_terms(
2657
+			array(EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY),
2658
+			array('hide_empty' => 0, 'exclude' => array($this->_category->id))
2659
+		);
2660
+		// setup category select for term parents.
2661
+		$category_select_values[] = array(
2662
+			'text' => esc_html__('No Parent', 'event_espresso'),
2663
+			'id'   => 0,
2664
+		);
2665
+		foreach ($all_terms as $term) {
2666
+			$category_select_values[] = array(
2667
+				'text' => $term->name,
2668
+				'id'   => $term->term_id,
2669
+			);
2670
+		}
2671
+		$category_select = EEH_Form_Fields::select_input(
2672
+			'category_parent',
2673
+			$category_select_values,
2674
+			$this->_category->parent
2675
+		);
2676
+		$template_args = array(
2677
+			'category'                 => $this->_category,
2678
+			'category_select'          => $category_select,
2679
+			'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'),
2680
+			'category_desc_editor'     => $_wp_editor['category_desc']['field'],
2681
+			'disable'                  => '',
2682
+			'disabled_message'         => false,
2683
+		);
2684
+		$template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php';
2685
+		return EEH_Template::display_template($template, $template_args, true);
2686
+	}
2687
+
2688
+
2689
+	/**
2690
+	 * Handles deleting categories.
2691
+	 */
2692
+	protected function _delete_categories()
2693
+	{
2694
+		$cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array) $this->_req_data['EVT_CAT_ID']
2695
+			: (array) $this->_req_data['category_id'];
2696
+		foreach ($cat_ids as $cat_id) {
2697
+			$this->_delete_category($cat_id);
2698
+		}
2699
+		// doesn't matter what page we're coming from... we're going to the same place after delete.
2700
+		$query_args = array(
2701
+			'action' => 'category_list',
2702
+		);
2703
+		$this->_redirect_after_action(0, '', '', $query_args);
2704
+	}
2705
+
2706
+
2707
+	/**
2708
+	 * Handles deleting specific category.
2709
+	 *
2710
+	 * @param int $cat_id
2711
+	 */
2712
+	protected function _delete_category($cat_id)
2713
+	{
2714
+		$cat_id = absint($cat_id);
2715
+		wp_delete_term($cat_id, EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY);
2716
+	}
2717
+
2718
+
2719
+	/**
2720
+	 * Handles triggering the update or insertion of a new category.
2721
+	 *
2722
+	 * @param bool $new_category true means we're triggering the insert of a new category.
2723
+	 * @throws EE_Error
2724
+	 * @throws InvalidArgumentException
2725
+	 * @throws InvalidDataTypeException
2726
+	 * @throws InvalidInterfaceException
2727
+	 */
2728
+	protected function _insert_or_update_category($new_category)
2729
+	{
2730
+		$cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(true);
2731
+		$success = 0; // we already have a success message so lets not send another.
2732
+		if ($cat_id) {
2733
+			$query_args = array(
2734
+				'action'     => 'edit_category',
2735
+				'EVT_CAT_ID' => $cat_id,
2736
+			);
2737
+		} else {
2738
+			$query_args = array('action' => 'add_category');
2739
+		}
2740
+		$this->_redirect_after_action($success, '', '', $query_args, true);
2741
+	}
2742
+
2743
+
2744
+	/**
2745
+	 * Inserts or updates category
2746
+	 *
2747
+	 * @param bool $update (true indicates we're updating a category).
2748
+	 * @return bool|mixed|string
2749
+	 */
2750
+	private function _insert_category($update = false)
2751
+	{
2752
+		$cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : '';
2753
+		$category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : '';
2754
+		$category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : '';
2755
+		$category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0;
2756
+		if (empty($category_name)) {
2757
+			$msg = esc_html__('You must add a name for the category.', 'event_espresso');
2758
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2759
+			return false;
2760
+		}
2761
+		$term_args = array(
2762
+			'name'        => $category_name,
2763
+			'description' => $category_desc,
2764
+			'parent'      => $category_parent,
2765
+		);
2766
+		// was the category_identifier input disabled?
2767
+		if (isset($this->_req_data['category_identifier'])) {
2768
+			$term_args['slug'] = $this->_req_data['category_identifier'];
2769
+		}
2770
+		$insert_ids = $update
2771
+			? wp_update_term($cat_id, EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY, $term_args)
2772
+			: wp_insert_term($category_name, EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY, $term_args);
2773
+		if (! is_array($insert_ids)) {
2774
+			$msg = esc_html__(
2775
+				'An error occurred and the category has not been saved to the database.',
2776
+				'event_espresso'
2777
+			);
2778
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2779
+		} else {
2780
+			$cat_id = $insert_ids['term_id'];
2781
+			$msg = sprintf(esc_html__('The category %s was successfully saved', 'event_espresso'), $category_name);
2782
+			EE_Error::add_success($msg);
2783
+		}
2784
+		return $cat_id;
2785
+	}
2786
+
2787
+
2788
+	/**
2789
+	 * Gets categories or count of categories matching the arguments in the request.
2790
+	 *
2791
+	 * @param int  $per_page
2792
+	 * @param int  $current_page
2793
+	 * @param bool $count
2794
+	 * @return EE_Base_Class[]|EE_Term_Taxonomy[]|int
2795
+	 * @throws EE_Error
2796
+	 * @throws InvalidArgumentException
2797
+	 * @throws InvalidDataTypeException
2798
+	 * @throws InvalidInterfaceException
2799
+	 */
2800
+	public function get_categories($per_page = 10, $current_page = 1, $count = false)
2801
+	{
2802
+		// testing term stuff
2803
+		$orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id';
2804
+		$order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC';
2805
+		$limit = ($current_page - 1) * $per_page;
2806
+		$where = array('taxonomy' => EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY);
2807
+		if (isset($this->_req_data['s'])) {
2808
+			$sstr = '%' . $this->_req_data['s'] . '%';
2809
+			$where['OR'] = array(
2810
+				'Term.name'   => array('LIKE', $sstr),
2811
+				'description' => array('LIKE', $sstr),
2812
+			);
2813
+		}
2814
+		$query_params = array(
2815
+			$where,
2816
+			'order_by'   => array($orderby => $order),
2817
+			'limit'      => $limit . ',' . $per_page,
2818
+			'force_join' => array('Term'),
2819
+		);
2820
+		$categories = $count
2821
+			? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id')
2822
+			: EEM_Term_Taxonomy::instance()->get_all($query_params);
2823
+		return $categories;
2824
+	}
2825
+
2826
+	/* end category stuff */
2827
+	/**************/
2828
+
2829
+
2830
+	/**
2831
+	 * Callback for the `ee_save_timezone_setting` ajax action.
2832
+	 *
2833
+	 * @throws EE_Error
2834
+	 * @throws InvalidArgumentException
2835
+	 * @throws InvalidDataTypeException
2836
+	 * @throws InvalidInterfaceException
2837
+	 */
2838
+	public function save_timezonestring_setting()
2839
+	{
2840
+		$timezone_string = isset($this->_req_data['timezone_selected'])
2841
+			? $this->_req_data['timezone_selected']
2842
+			: '';
2843
+		if (empty($timezone_string) || ! EEH_DTT_Helper::validate_timezone($timezone_string, false)) {
2844
+			EE_Error::add_error(
2845
+				esc_html__('An invalid timezone string submitted.', 'event_espresso'),
2846
+				__FILE__,
2847
+				__FUNCTION__,
2848
+				__LINE__
2849
+			);
2850
+			$this->_template_args['error'] = true;
2851
+			$this->_return_json();
2852
+		}
2853
+
2854
+		update_option('timezone_string', $timezone_string);
2855
+		EE_Error::add_success(
2856
+			esc_html__('Your timezone string was updated.', 'event_espresso')
2857
+		);
2858
+		$this->_template_args['success'] = true;
2859
+		$this->_return_json(true, array('action' => 'create_new'));
2860
+	}
2861 2861
 }
Please login to merge, or discard this patch.
caffeinated/admin/extend/events/Extend_Events_Admin_Page.core.php 2 patches
Indentation   +1383 added lines, -1383 removed lines patch added patch discarded remove patch
@@ -17,1387 +17,1387 @@
 block discarded – undo
17 17
 class Extend_Events_Admin_Page extends Events_Admin_Page
18 18
 {
19 19
 
20
-    /**
21
-     * @var AdvancedEditorAdminFormSection
22
-     */
23
-    protected $advanced_editor_admin_form;
24
-    /**
25
-     * @var AdvancedEditorEntityData
26
-     */
27
-    protected $advanced_editor_data;
28
-
29
-
30
-    /**
31
-     * Extend_Events_Admin_Page constructor.
32
-     *
33
-     * @param bool $routing
34
-     * @throws EE_Error
35
-     * @throws InvalidArgumentException
36
-     * @throws InvalidDataTypeException
37
-     * @throws InvalidInterfaceException
38
-     * @throws ReflectionException
39
-     */
40
-    public function __construct($routing = true)
41
-    {
42
-        if (! defined('EVENTS_CAF_TEMPLATE_PATH')) {
43
-            define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/');
44
-            define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/');
45
-            define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/');
46
-        }
47
-        parent::__construct($routing);
48
-        if (isset($this->_req_data['action'])
49
-            && (
50
-                $this->_req_data['action'] === 'default_event_settings'
51
-                || $this->_req_data['action'] === 'update_default_event_settings'
52
-            )
53
-        ) {
54
-            $this->advanced_editor_admin_form = $this->loader->getShared(
55
-                'EventEspresso\core\domain\services\admin\events\default_settings\AdvancedEditorAdminFormSection'
56
-            );
57
-        }
58
-        if (isset($this->_req_data['action'])
59
-            && ( $this->_req_data['action'] === 'edit' || $this->_req_data['action'] === 'create_new')
60
-        ) {
61
-            $this->advanced_editor_data = $this->loader->getShared(
62
-                'EventEspresso\core\domain\services\admin\events\editor\AdvancedEditorEntityData'
63
-            );
64
-        }
65
-    }
66
-
67
-
68
-    /**
69
-     * Sets routes.
70
-     *
71
-     * @throws EE_Error
72
-     * @throws InvalidArgumentException
73
-     * @throws InvalidDataTypeException
74
-     * @throws InvalidInterfaceException
75
-     * @since $VID:$
76
-     */
77
-    protected function _extend_page_config()
78
-    {
79
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events';
80
-        // is there a evt_id in the request?
81
-        $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID'])
82
-            ? $this->_req_data['EVT_ID']
83
-            : 0;
84
-        $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id;
85
-        // tkt_id?
86
-        $tkt_id = ! empty($this->_req_data['TKT_ID']) && ! is_array($this->_req_data['TKT_ID'])
87
-            ? $this->_req_data['TKT_ID']
88
-            : 0;
89
-        $new_page_routes = array(
90
-            'duplicate_event'          => array(
91
-                'func'       => '_duplicate_event',
92
-                'capability' => 'ee_edit_event',
93
-                'obj_id'     => $evt_id,
94
-                'noheader'   => true,
95
-            ),
96
-            'ticket_list_table'        => array(
97
-                'func'       => '_tickets_overview_list_table',
98
-                'capability' => 'ee_read_default_tickets',
99
-            ),
100
-            'trash_ticket'             => array(
101
-                'func'       => '_trash_or_restore_ticket',
102
-                'capability' => 'ee_delete_default_ticket',
103
-                'obj_id'     => $tkt_id,
104
-                'noheader'   => true,
105
-                'args'       => array('trash' => true),
106
-            ),
107
-            'trash_tickets'            => array(
108
-                'func'       => '_trash_or_restore_ticket',
109
-                'capability' => 'ee_delete_default_tickets',
110
-                'noheader'   => true,
111
-                'args'       => array('trash' => true),
112
-            ),
113
-            'restore_ticket'           => array(
114
-                'func'       => '_trash_or_restore_ticket',
115
-                'capability' => 'ee_delete_default_ticket',
116
-                'obj_id'     => $tkt_id,
117
-                'noheader'   => true,
118
-            ),
119
-            'restore_tickets'          => array(
120
-                'func'       => '_trash_or_restore_ticket',
121
-                'capability' => 'ee_delete_default_tickets',
122
-                'noheader'   => true,
123
-            ),
124
-            'delete_ticket'            => array(
125
-                'func'       => '_delete_ticket',
126
-                'capability' => 'ee_delete_default_ticket',
127
-                'obj_id'     => $tkt_id,
128
-                'noheader'   => true,
129
-            ),
130
-            'delete_tickets'           => array(
131
-                'func'       => '_delete_ticket',
132
-                'capability' => 'ee_delete_default_tickets',
133
-                'noheader'   => true,
134
-            ),
135
-            'import_page'              => array(
136
-                'func'       => '_import_page',
137
-                'capability' => 'import',
138
-            ),
139
-            'import'                   => array(
140
-                'func'       => '_import_events',
141
-                'capability' => 'import',
142
-                'noheader'   => true,
143
-            ),
144
-            'import_events'            => array(
145
-                'func'       => '_import_events',
146
-                'capability' => 'import',
147
-                'noheader'   => true,
148
-            ),
149
-            'export_events'            => array(
150
-                'func'       => '_events_export',
151
-                'capability' => 'export',
152
-                'noheader'   => true,
153
-            ),
154
-            'export_categories'        => array(
155
-                'func'       => '_categories_export',
156
-                'capability' => 'export',
157
-                'noheader'   => true,
158
-            ),
159
-            'sample_export_file'       => array(
160
-                'func'       => '_sample_export_file',
161
-                'capability' => 'export',
162
-                'noheader'   => true,
163
-            ),
164
-            'update_template_settings' => array(
165
-                'func'       => '_update_template_settings',
166
-                'capability' => 'manage_options',
167
-                'noheader'   => true,
168
-            ),
169
-        );
170
-        $this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
171
-        // partial route/config override
172
-        $this->_page_config['import_events']['metaboxes'] = $this->_default_espresso_metaboxes;
173
-        $this->_page_config['create_new']['metaboxes'][] = '_premium_event_editor_meta_boxes';
174
-        $this->_page_config['create_new']['qtips'][] = 'EE_Event_Editor_Tips';
175
-        $this->_page_config['edit']['qtips'][] = 'EE_Event_Editor_Tips';
176
-        $this->_page_config['edit']['metaboxes'][] = '_premium_event_editor_meta_boxes';
177
-        $this->_page_config['default']['list_table'] = 'Extend_Events_Admin_List_Table';
178
-        // add tickets tab but only if there are more than one default ticket!
179
-        $tkt_count = EEM_Ticket::instance()->count_deleted_and_undeleted(
180
-            array(array('TKT_is_default' => 1)),
181
-            'TKT_ID',
182
-            true
183
-        );
184
-        if ($tkt_count > 1) {
185
-            $new_page_config = array(
186
-                'ticket_list_table' => array(
187
-                    'nav'           => array(
188
-                        'label' => esc_html__('Default Tickets', 'event_espresso'),
189
-                        'order' => 60,
190
-                    ),
191
-                    'list_table'    => 'Tickets_List_Table',
192
-                    'require_nonce' => false,
193
-                ),
194
-            );
195
-        }
196
-        // template settings
197
-        $new_page_config['template_settings'] = array(
198
-            'nav'           => array(
199
-                'label' => esc_html__('Templates', 'event_espresso'),
200
-                'order' => 30,
201
-            ),
202
-            'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
203
-            'help_tabs'     => array(
204
-                'general_settings_templates_help_tab' => array(
205
-                    'title'    => esc_html__('Templates', 'event_espresso'),
206
-                    'filename' => 'general_settings_templates',
207
-                ),
208
-            ),
209
-            'help_tour'     => array('Templates_Help_Tour'),
210
-            'require_nonce' => false,
211
-        );
212
-        $this->_page_config = array_merge($this->_page_config, $new_page_config);
213
-        // add filters and actions
214
-        // modifying _views
215
-        add_filter(
216
-            'FHEE_event_datetime_metabox_add_additional_date_time_template',
217
-            array($this, 'add_additional_datetime_button'),
218
-            10,
219
-            2
220
-        );
221
-        add_filter(
222
-            'FHEE_event_datetime_metabox_clone_button_template',
223
-            array($this, 'add_datetime_clone_button'),
224
-            10,
225
-            2
226
-        );
227
-        add_filter(
228
-            'FHEE_event_datetime_metabox_timezones_template',
229
-            array($this, 'datetime_timezones_template'),
230
-            10,
231
-            2
232
-        );
233
-        // filters for event list table
234
-        add_filter('FHEE__Extend_Events_Admin_List_Table__filters', array($this, 'list_table_filters'), 10, 2);
235
-        add_filter(
236
-            'FHEE__Events_Admin_List_Table__column_actions__action_links',
237
-            array($this, 'extra_list_table_actions'),
238
-            10,
239
-            2
240
-        );
241
-        // legend item
242
-        add_filter('FHEE__Events_Admin_Page___event_legend_items__items', array($this, 'additional_legend_items'));
243
-        add_action('admin_init', array($this, 'admin_init'));
244
-    }
245
-
246
-
247
-    /**
248
-     * admin_init
249
-     */
250
-    public function admin_init()
251
-    {
252
-        EE_Registry::$i18n_js_strings = array_merge(
253
-            EE_Registry::$i18n_js_strings,
254
-            array(
255
-                'image_confirm'          => esc_html__(
256
-                    'Do you really want to delete this image? Please remember to update your event to complete the removal.',
257
-                    'event_espresso'
258
-                ),
259
-                'event_starts_on'        => esc_html__('Event Starts on', 'event_espresso'),
260
-                'event_ends_on'          => esc_html__('Event Ends on', 'event_espresso'),
261
-                'event_datetime_actions' => esc_html__('Actions', 'event_espresso'),
262
-                'event_clone_dt_msg'     => esc_html__('Clone this Event Date and Time', 'event_espresso'),
263
-                'remove_event_dt_msg'    => esc_html__('Remove this Event Time', 'event_espresso'),
264
-            )
265
-        );
266
-    }
267
-
268
-
269
-    /**
270
-     * Add per page screen options to the default ticket list table view.
271
-     *
272
-     * @throws InvalidArgumentException
273
-     * @throws InvalidDataTypeException
274
-     * @throws InvalidInterfaceException
275
-     */
276
-    protected function _add_screen_options_ticket_list_table()
277
-    {
278
-        $this->_per_page_screen_option();
279
-    }
280
-
281
-
282
-    /**
283
-     * @param string $return
284
-     * @param int    $id
285
-     * @param string $new_title
286
-     * @param string $new_slug
287
-     * @return string
288
-     */
289
-    public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug)
290
-    {
291
-        $return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug);
292
-        // make sure this is only when editing
293
-        if (! empty($id)) {
294
-            $href = EE_Admin_Page::add_query_args_and_nonce(
295
-                array('action' => 'duplicate_event', 'EVT_ID' => $id),
296
-                $this->_admin_base_url
297
-            );
298
-            $title = esc_attr__('Duplicate Event', 'event_espresso');
299
-            $return .= '<a href="'
300
-                       . $href
301
-                       . '" title="'
302
-                       . $title
303
-                       . '" id="ee-duplicate-event-button" class="button button-small"  value="duplicate_event">'
304
-                       . $title
305
-                       . '</a>';
306
-        }
307
-        return $return;
308
-    }
309
-
310
-
311
-    /**
312
-     * Set the list table views for the default ticket list table view.
313
-     */
314
-    public function _set_list_table_views_ticket_list_table()
315
-    {
316
-        $this->_views = array(
317
-            'all'     => array(
318
-                'slug'        => 'all',
319
-                'label'       => esc_html__('All', 'event_espresso'),
320
-                'count'       => 0,
321
-                'bulk_action' => array(
322
-                    'trash_tickets' => esc_html__('Move to Trash', 'event_espresso'),
323
-                ),
324
-            ),
325
-            'trashed' => array(
326
-                'slug'        => 'trashed',
327
-                'label'       => esc_html__('Trash', 'event_espresso'),
328
-                'count'       => 0,
329
-                'bulk_action' => array(
330
-                    'restore_tickets' => esc_html__('Restore from Trash', 'event_espresso'),
331
-                    'delete_tickets'  => esc_html__('Delete Permanently', 'event_espresso'),
332
-                ),
333
-            ),
334
-        );
335
-    }
336
-
337
-
338
-    /**
339
-     * Enqueue scripts and styles for the event editor.
340
-     */
341
-    public function load_scripts_styles_edit()
342
-    {
343
-        wp_register_script(
344
-            'ee-event-editor-heartbeat',
345
-            EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js',
346
-            array('ee_admin_js', 'heartbeat'),
347
-            EVENT_ESPRESSO_VERSION,
348
-            true
349
-        );
350
-        wp_enqueue_script('ee-accounting');
351
-        // styles
352
-        wp_enqueue_style('espresso-ui-theme');
353
-        wp_enqueue_script('event_editor_js');
354
-        wp_enqueue_script('ee-event-editor-heartbeat');
355
-    }
356
-
357
-
358
-    /**
359
-     * Returns template for the additional datetime.
360
-     *
361
-     * @param $template
362
-     * @param $template_args
363
-     * @return mixed
364
-     * @throws DomainException
365
-     */
366
-    public function add_additional_datetime_button($template, $template_args)
367
-    {
368
-        return EEH_Template::display_template(
369
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php',
370
-            $template_args,
371
-            true
372
-        );
373
-    }
374
-
375
-
376
-    /**
377
-     * Returns the template for cloning a datetime.
378
-     *
379
-     * @param $template
380
-     * @param $template_args
381
-     * @return mixed
382
-     * @throws DomainException
383
-     */
384
-    public function add_datetime_clone_button($template, $template_args)
385
-    {
386
-        return EEH_Template::display_template(
387
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php',
388
-            $template_args,
389
-            true
390
-        );
391
-    }
392
-
393
-
394
-    /**
395
-     * Returns the template for datetime timezones.
396
-     *
397
-     * @param $template
398
-     * @param $template_args
399
-     * @return mixed
400
-     * @throws DomainException
401
-     */
402
-    public function datetime_timezones_template($template, $template_args)
403
-    {
404
-        return EEH_Template::display_template(
405
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php',
406
-            $template_args,
407
-            true
408
-        );
409
-    }
410
-
411
-
412
-    /**
413
-     * Sets the views for the default list table view.
414
-     */
415
-    protected function _set_list_table_views_default()
416
-    {
417
-        parent::_set_list_table_views_default();
418
-        $new_views = array(
419
-            'today' => array(
420
-                'slug'        => 'today',
421
-                'label'       => esc_html__('Today', 'event_espresso'),
422
-                'count'       => $this->total_events_today(),
423
-                'bulk_action' => array(
424
-                    'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
425
-                ),
426
-            ),
427
-            'month' => array(
428
-                'slug'        => 'month',
429
-                'label'       => esc_html__('This Month', 'event_espresso'),
430
-                'count'       => $this->total_events_this_month(),
431
-                'bulk_action' => array(
432
-                    'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
433
-                ),
434
-            ),
435
-        );
436
-        $this->_views = array_merge($this->_views, $new_views);
437
-    }
438
-
439
-
440
-    /**
441
-     * Returns the extra action links for the default list table view.
442
-     *
443
-     * @param array    $action_links
444
-     * @param EE_Event $event
445
-     * @return array
446
-     * @throws EE_Error
447
-     * @throws InvalidArgumentException
448
-     * @throws InvalidDataTypeException
449
-     * @throws InvalidInterfaceException
450
-     * @throws ReflectionException
451
-     */
452
-    public function extra_list_table_actions(array $action_links, EE_Event $event)
453
-    {
454
-        if (EE_Registry::instance()->CAP->current_user_can(
455
-            'ee_read_registrations',
456
-            'espresso_registrations_reports',
457
-            $event->ID()
458
-        )
459
-        ) {
460
-            $reports_query_args = array(
461
-                'action' => 'reports',
462
-                'EVT_ID' => $event->ID(),
463
-            );
464
-            $reports_link = EE_Admin_Page::add_query_args_and_nonce($reports_query_args, REG_ADMIN_URL);
465
-            $action_links[] = '<a href="'
466
-                              . $reports_link
467
-                              . '" title="'
468
-                              . esc_attr__('View Report', 'event_espresso')
469
-                              . '"><div class="dashicons dashicons-chart-bar"></div></a>'
470
-                              . "\n\t";
471
-        }
472
-        if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
473
-            EE_Registry::instance()->load_helper('MSG_Template');
474
-            $action_links[] = EEH_MSG_Template::get_message_action_link(
475
-                'see_notifications_for',
476
-                null,
477
-                array('EVT_ID' => $event->ID())
478
-            );
479
-        }
480
-        return $action_links;
481
-    }
482
-
483
-
484
-    /**
485
-     * @param $items
486
-     * @return mixed
487
-     */
488
-    public function additional_legend_items($items)
489
-    {
490
-        if (EE_Registry::instance()->CAP->current_user_can(
491
-            'ee_read_registrations',
492
-            'espresso_registrations_reports'
493
-        )
494
-        ) {
495
-            $items['reports'] = array(
496
-                'class' => 'dashicons dashicons-chart-bar',
497
-                'desc'  => esc_html__('Event Reports', 'event_espresso'),
498
-            );
499
-        }
500
-        if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
501
-            $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
502
-            // $related_for_icon can sometimes be a string so 'css_class' would be an illegal offset
503
-            // (can only use numeric offsets when treating strings as arrays)
504
-            if (is_array($related_for_icon) && isset($related_for_icon['css_class'], $related_for_icon['label'])) {
505
-                $items['view_related_messages'] = array(
506
-                    'class' => $related_for_icon['css_class'],
507
-                    'desc'  => $related_for_icon['label'],
508
-                );
509
-            }
510
-        }
511
-        return $items;
512
-    }
513
-
514
-
515
-    /**
516
-     * This is the callback method for the duplicate event route
517
-     * Method looks for 'EVT_ID' in the request and retrieves that event and its details and duplicates them
518
-     * into a new event.  We add a hook so that any plugins that add extra event details can hook into this
519
-     * action.  Note that the dupe will have **DUPLICATE** as its title and slug.
520
-     * After duplication the redirect is to the new event edit page.
521
-     *
522
-     * @return void
523
-     * @throws EE_Error If EE_Event is not available with given ID
524
-     * @throws InvalidArgumentException
525
-     * @throws InvalidDataTypeException
526
-     * @throws InvalidInterfaceException
527
-     * @throws ReflectionException
528
-     * @access protected
529
-     */
530
-    protected function _duplicate_event()
531
-    {
532
-        // first make sure the ID for the event is in the request.
533
-        //  If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?)
534
-        if (! isset($this->_req_data['EVT_ID'])) {
535
-            EE_Error::add_error(
536
-                esc_html__(
537
-                    'In order to duplicate an event an Event ID is required.  None was given.',
538
-                    'event_espresso'
539
-                ),
540
-                __FILE__,
541
-                __FUNCTION__,
542
-                __LINE__
543
-            );
544
-            $this->_redirect_after_action(false, '', '', array(), true);
545
-            return;
546
-        }
547
-        // k we've got EVT_ID so let's use that to get the event we'll duplicate
548
-        $orig_event = EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']);
549
-        if (! $orig_event instanceof EE_Event) {
550
-            throw new EE_Error(
551
-                sprintf(
552
-                    esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'),
553
-                    $this->_req_data['EVT_ID']
554
-                )
555
-            );
556
-        }
557
-        // k now let's clone the $orig_event before getting relations
558
-        $new_event = clone $orig_event;
559
-        // original datetimes
560
-        $orig_datetimes = $orig_event->get_many_related('Datetime');
561
-        // other original relations
562
-        $orig_ven = $orig_event->get_many_related('Venue');
563
-        // reset the ID and modify other details to make it clear this is a dupe
564
-        $new_event->set('EVT_ID', 0);
565
-        $new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso');
566
-        $new_event->set('EVT_name', $new_name);
567
-        $new_event->set(
568
-            'EVT_slug',
569
-            wp_unique_post_slug(
570
-                sanitize_title($orig_event->name()),
571
-                0,
572
-                'publish',
573
-                'espresso_events',
574
-                0
575
-            )
576
-        );
577
-        $new_event->set('status', 'draft');
578
-        // duplicate discussion settings
579
-        $new_event->set('comment_status', $orig_event->get('comment_status'));
580
-        $new_event->set('ping_status', $orig_event->get('ping_status'));
581
-        // save the new event
582
-        $new_event->save();
583
-        // venues
584
-        foreach ($orig_ven as $ven) {
585
-            $new_event->_add_relation_to($ven, 'Venue');
586
-        }
587
-        $new_event->save();
588
-        // now we need to get the question group relations and handle that
589
-        // first primary question groups
590
-        $orig_primary_qgs = $orig_event->get_many_related(
591
-            'Question_Group',
592
-            [['Event_Question_Group.EQG_primary' => true]]
593
-        );
594
-        if (! empty($orig_primary_qgs)) {
595
-            foreach ($orig_primary_qgs as $id => $obj) {
596
-                if ($obj instanceof EE_Question_Group) {
597
-                    $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_primary' => true]);
598
-                }
599
-            }
600
-        }
601
-        // next additional attendee question groups
602
-        $orig_additional_qgs = $orig_event->get_many_related(
603
-            'Question_Group',
604
-            [['Event_Question_Group.EQG_additional' => true]]
605
-        );
606
-        if (! empty($orig_additional_qgs)) {
607
-            foreach ($orig_additional_qgs as $id => $obj) {
608
-                if ($obj instanceof EE_Question_Group) {
609
-                    $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_additional' => true]);
610
-                }
611
-            }
612
-        }
613
-
614
-        $new_event->save();
615
-
616
-        // k now that we have the new event saved we can loop through the datetimes and start adding relations.
617
-        $cloned_tickets = array();
618
-        foreach ($orig_datetimes as $orig_dtt) {
619
-            if (! $orig_dtt instanceof EE_Datetime) {
620
-                continue;
621
-            }
622
-            $new_dtt = clone $orig_dtt;
623
-            $orig_tkts = $orig_dtt->tickets();
624
-            // save new dtt then add to event
625
-            $new_dtt->set('DTT_ID', 0);
626
-            $new_dtt->set('DTT_sold', 0);
627
-            $new_dtt->set_reserved(0);
628
-            $new_dtt->save();
629
-            $new_event->_add_relation_to($new_dtt, 'Datetime');
630
-            $new_event->save();
631
-            // now let's get the ticket relations setup.
632
-            foreach ((array) $orig_tkts as $orig_tkt) {
633
-                // it's possible a datetime will have no tickets so let's verify we HAVE a ticket first.
634
-                if (! $orig_tkt instanceof EE_Ticket) {
635
-                    continue;
636
-                }
637
-                // is this ticket archived?  If it is then let's skip
638
-                if ($orig_tkt->get('TKT_deleted')) {
639
-                    continue;
640
-                }
641
-                // does this original ticket already exist in the clone_tickets cache?
642
-                //  If so we'll just use the new ticket from it.
643
-                if (isset($cloned_tickets[ $orig_tkt->ID() ])) {
644
-                    $new_tkt = $cloned_tickets[ $orig_tkt->ID() ];
645
-                } else {
646
-                    $new_tkt = clone $orig_tkt;
647
-                    // get relations on the $orig_tkt that we need to setup.
648
-                    $orig_prices = $orig_tkt->prices();
649
-                    $new_tkt->set('TKT_ID', 0);
650
-                    $new_tkt->set('TKT_sold', 0);
651
-                    $new_tkt->set('TKT_reserved', 0);
652
-                    $new_tkt->save(); // make sure new ticket has ID.
653
-                    // price relations on new ticket need to be setup.
654
-                    foreach ($orig_prices as $orig_price) {
655
-                        $new_price = clone $orig_price;
656
-                        $new_price->set('PRC_ID', 0);
657
-                        $new_price->save();
658
-                        $new_tkt->_add_relation_to($new_price, 'Price');
659
-                        $new_tkt->save();
660
-                    }
661
-
662
-                    do_action(
663
-                        'AHEE__Extend_Events_Admin_Page___duplicate_event__duplicate_ticket__after',
664
-                        $orig_tkt,
665
-                        $new_tkt,
666
-                        $orig_prices,
667
-                        $orig_event,
668
-                        $orig_dtt,
669
-                        $new_dtt
670
-                    );
671
-                }
672
-                // k now we can add the new ticket as a relation to the new datetime
673
-                // and make sure its added to our cached $cloned_tickets array
674
-                // for use with later datetimes that have the same ticket.
675
-                $new_dtt->_add_relation_to($new_tkt, 'Ticket');
676
-                $new_dtt->save();
677
-                $cloned_tickets[ $orig_tkt->ID() ] = $new_tkt;
678
-            }
679
-        }
680
-        // clone taxonomy information
681
-        $taxonomies_to_clone_with = apply_filters(
682
-            'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone',
683
-            array('espresso_event_categories', 'espresso_event_type', 'post_tag')
684
-        );
685
-        // get terms for original event (notice)
686
-        $orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with);
687
-        // loop through terms and add them to new event.
688
-        foreach ($orig_terms as $term) {
689
-            wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true);
690
-        }
691
-
692
-        // duplicate other core WP_Post items for this event.
693
-        // post thumbnail (feature image).
694
-        $feature_image_id = get_post_thumbnail_id($orig_event->ID());
695
-        if ($feature_image_id) {
696
-            update_post_meta($new_event->ID(), '_thumbnail_id', $feature_image_id);
697
-        }
698
-
699
-        // duplicate page_template setting
700
-        $page_template = get_post_meta($orig_event->ID(), '_wp_page_template', true);
701
-        if ($page_template) {
702
-            update_post_meta($new_event->ID(), '_wp_page_template', $page_template);
703
-        }
704
-
705
-        do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event);
706
-        // now let's redirect to the edit page for this duplicated event if we have a new event id.
707
-        if ($new_event->ID()) {
708
-            $redirect_args = array(
709
-                'post'   => $new_event->ID(),
710
-                'action' => 'edit',
711
-            );
712
-            EE_Error::add_success(
713
-                esc_html__(
714
-                    'Event successfully duplicated.  Please review the details below and make any necessary edits',
715
-                    'event_espresso'
716
-                )
717
-            );
718
-        } else {
719
-            $redirect_args = array(
720
-                'action' => 'default',
721
-            );
722
-            EE_Error::add_error(
723
-                esc_html__('Not able to duplicate event.  Something went wrong.', 'event_espresso'),
724
-                __FILE__,
725
-                __FUNCTION__,
726
-                __LINE__
727
-            );
728
-        }
729
-        $this->_redirect_after_action(false, '', '', $redirect_args, true);
730
-    }
731
-
732
-
733
-    /**
734
-     * Generates output for the import page.
735
-     *
736
-     * @throws DomainException
737
-     * @throws EE_Error
738
-     * @throws InvalidArgumentException
739
-     * @throws InvalidDataTypeException
740
-     * @throws InvalidInterfaceException
741
-     */
742
-    protected function _import_page()
743
-    {
744
-        $title = esc_html__('Import', 'event_espresso');
745
-        $intro = esc_html__(
746
-            'If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ',
747
-            'event_espresso'
748
-        );
749
-        $form_url = EVENTS_ADMIN_URL;
750
-        $action = 'import_events';
751
-        $type = 'csv';
752
-        $this->_template_args['form'] = EE_Import::instance()->upload_form(
753
-            $title,
754
-            $intro,
755
-            $form_url,
756
-            $action,
757
-            $type
758
-        );
759
-        $this->_template_args['sample_file_link'] = EE_Admin_Page::add_query_args_and_nonce(
760
-            array('action' => 'sample_export_file'),
761
-            $this->_admin_base_url
762
-        );
763
-        $content = EEH_Template::display_template(
764
-            EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php',
765
-            $this->_template_args,
766
-            true
767
-        );
768
-        $this->_template_args['admin_page_content'] = $content;
769
-        $this->display_admin_page_with_sidebar();
770
-    }
771
-
772
-
773
-    /**
774
-     * _import_events
775
-     * This handles displaying the screen and running imports for importing events.
776
-     *
777
-     * @return void
778
-     * @throws EE_Error
779
-     * @throws InvalidArgumentException
780
-     * @throws InvalidDataTypeException
781
-     * @throws InvalidInterfaceException
782
-     */
783
-    protected function _import_events()
784
-    {
785
-        require_once(EE_CLASSES . 'EE_Import.class.php');
786
-        $success = EE_Import::instance()->import();
787
-        $this->_redirect_after_action($success, 'Import File', 'ran', array('action' => 'import_page'), true);
788
-    }
789
-
790
-
791
-    /**
792
-     * _events_export
793
-     * Will export all (or just the given event) to a Excel compatible file.
794
-     *
795
-     * @access protected
796
-     * @return void
797
-     */
798
-    protected function _events_export()
799
-    {
800
-        if (isset($this->_req_data['EVT_ID'])) {
801
-            $event_ids = $this->_req_data['EVT_ID'];
802
-        } elseif (isset($this->_req_data['EVT_IDs'])) {
803
-            $event_ids = $this->_req_data['EVT_IDs'];
804
-        } else {
805
-            $event_ids = null;
806
-        }
807
-        // todo: I don't like doing this but it'll do until we modify EE_Export Class.
808
-        $new_request_args = array(
809
-            'export' => 'report',
810
-            'action' => 'all_event_data',
811
-            'EVT_ID' => $event_ids,
812
-        );
813
-        $this->_req_data = array_merge($this->_req_data, $new_request_args);
814
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
815
-            require_once(EE_CLASSES . 'EE_Export.class.php');
816
-            $EE_Export = EE_Export::instance($this->_req_data);
817
-            $EE_Export->export();
818
-        }
819
-    }
820
-
821
-
822
-    /**
823
-     * handle category exports()
824
-     *
825
-     * @return void
826
-     */
827
-    protected function _categories_export()
828
-    {
829
-        // todo: I don't like doing this but it'll do until we modify EE_Export Class.
830
-        $new_request_args = array(
831
-            'export'       => 'report',
832
-            'action'       => 'categories',
833
-            'category_ids' => $this->_req_data['EVT_CAT_ID'],
834
-        );
835
-        $this->_req_data = array_merge($this->_req_data, $new_request_args);
836
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
837
-            require_once(EE_CLASSES . 'EE_Export.class.php');
838
-            $EE_Export = EE_Export::instance($this->_req_data);
839
-            $EE_Export->export();
840
-        }
841
-    }
842
-
843
-
844
-    /**
845
-     * Creates a sample CSV file for importing
846
-     */
847
-    protected function _sample_export_file()
848
-    {
849
-        // require_once(EE_CLASSES . 'EE_Export.class.php');
850
-        EE_Export::instance()->export_sample();
851
-    }
852
-
853
-
854
-    /*************        Template Settings        *************/
855
-    /**
856
-     * Generates template settings page output
857
-     *
858
-     * @throws DomainException
859
-     * @throws EE_Error
860
-     * @throws InvalidArgumentException
861
-     * @throws InvalidDataTypeException
862
-     * @throws InvalidInterfaceException
863
-     */
864
-    protected function _template_settings()
865
-    {
866
-        $this->_template_args['values'] = $this->_yes_no_values;
867
-        /**
868
-         * Note leaving this filter in for backward compatibility this was moved in 4.6.x
869
-         * from General_Settings_Admin_Page to here.
870
-         */
871
-        $this->_template_args = apply_filters(
872
-            'FHEE__General_Settings_Admin_Page__template_settings__template_args',
873
-            $this->_template_args
874
-        );
875
-        $this->_set_add_edit_form_tags('update_template_settings');
876
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
877
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
878
-            EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php',
879
-            $this->_template_args,
880
-            true
881
-        );
882
-        $this->display_admin_page_with_sidebar();
883
-    }
884
-
885
-
886
-    /**
887
-     * Handler for updating template settings.
888
-     *
889
-     * @throws EE_Error
890
-     * @throws InvalidArgumentException
891
-     * @throws InvalidDataTypeException
892
-     * @throws InvalidInterfaceException
893
-     */
894
-    protected function _update_template_settings()
895
-    {
896
-        /**
897
-         * Note leaving this filter in for backward compatibility this was moved in 4.6.x
898
-         * from General_Settings_Admin_Page to here.
899
-         */
900
-        EE_Registry::instance()->CFG->template_settings = apply_filters(
901
-            'FHEE__General_Settings_Admin_Page__update_template_settings__data',
902
-            EE_Registry::instance()->CFG->template_settings,
903
-            $this->_req_data
904
-        );
905
-        // update custom post type slugs and detect if we need to flush rewrite rules
906
-        $old_slug = EE_Registry::instance()->CFG->core->event_cpt_slug;
907
-        EE_Registry::instance()->CFG->core->event_cpt_slug = empty($this->_req_data['event_cpt_slug'])
908
-            ? EE_Registry::instance()->CFG->core->event_cpt_slug
909
-            : EEH_URL::slugify($this->_req_data['event_cpt_slug'], 'events');
910
-        $what = 'Template Settings';
911
-        $success = $this->_update_espresso_configuration(
912
-            $what,
913
-            EE_Registry::instance()->CFG->template_settings,
914
-            __FILE__,
915
-            __FUNCTION__,
916
-            __LINE__
917
-        );
918
-        if (EE_Registry::instance()->CFG->core->event_cpt_slug !== $old_slug) {
919
-            /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */
920
-            $rewrite_rules = LoaderFactory::getLoader()->getShared(
921
-                'EventEspresso\core\domain\services\custom_post_types\RewriteRules'
922
-            );
923
-            $rewrite_rules->flush();
924
-        }
925
-        $this->_redirect_after_action($success, $what, 'updated', array('action' => 'template_settings'));
926
-    }
927
-
928
-
929
-    /**
930
-     * _premium_event_editor_meta_boxes
931
-     * add all metaboxes related to the event_editor
932
-     *
933
-     * @access protected
934
-     * @return void
935
-     * @throws EE_Error
936
-     * @throws InvalidArgumentException
937
-     * @throws InvalidDataTypeException
938
-     * @throws InvalidInterfaceException
939
-     * @throws ReflectionException
940
-     */
941
-    protected function _premium_event_editor_meta_boxes()
942
-    {
943
-        $this->verify_cpt_object();
944
-        add_meta_box(
945
-            'espresso_event_editor_event_options',
946
-            esc_html__('Event Registration Options', 'event_espresso'),
947
-            array($this, 'registration_options_meta_box'),
948
-            $this->page_slug,
949
-            'side',
950
-            'core'
951
-        );
952
-    }
953
-
954
-
955
-    /**
956
-     * override caf metabox
957
-     *
958
-     * @return void
959
-     * @throws DomainException
960
-     * @throws EE_Error
961
-     */
962
-    public function registration_options_meta_box()
963
-    {
964
-        $yes_no_values = array(
965
-            array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')),
966
-            array('id' => false, 'text' => esc_html__('No', 'event_espresso')),
967
-        );
968
-        $default_reg_status_values = EEM_Registration::reg_status_array(
969
-            array(
970
-                EEM_Registration::status_id_cancelled,
971
-                EEM_Registration::status_id_declined,
972
-                EEM_Registration::status_id_incomplete,
973
-                EEM_Registration::status_id_wait_list,
974
-            ),
975
-            true
976
-        );
977
-        $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false);
978
-        $template_args['_event'] = $this->_cpt_model_obj;
979
-        $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit();
980
-        $template_args['default_registration_status'] = EEH_Form_Fields::select_input(
981
-            'default_reg_status',
982
-            $default_reg_status_values,
983
-            $this->_cpt_model_obj->default_registration_status()
984
-        );
985
-        $template_args['display_description'] = EEH_Form_Fields::select_input(
986
-            'display_desc',
987
-            $yes_no_values,
988
-            $this->_cpt_model_obj->display_description()
989
-        );
990
-        $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input(
991
-            'display_ticket_selector',
992
-            $yes_no_values,
993
-            $this->_cpt_model_obj->display_ticket_selector(),
994
-            '',
995
-            '',
996
-            false
997
-        );
998
-        $template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input(
999
-            'EVT_default_registration_status',
1000
-            $default_reg_status_values,
1001
-            $this->_cpt_model_obj->default_registration_status()
1002
-        );
1003
-        $template_args['additional_registration_options'] = apply_filters(
1004
-            'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options',
1005
-            '',
1006
-            $template_args,
1007
-            $yes_no_values,
1008
-            $default_reg_status_values
1009
-        );
1010
-        EEH_Template::display_template(
1011
-            EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php',
1012
-            $template_args
1013
-        );
1014
-    }
1015
-
1016
-
1017
-
1018
-    /**
1019
-     * wp_list_table_mods for caf
1020
-     * ============================
1021
-     */
1022
-    /**
1023
-     * hook into list table filters and provide filters for caffeinated list table
1024
-     *
1025
-     * @param array $old_filters    any existing filters present
1026
-     * @param array $list_table_obj the list table object
1027
-     * @return array                  new filters
1028
-     * @throws EE_Error
1029
-     * @throws InvalidArgumentException
1030
-     * @throws InvalidDataTypeException
1031
-     * @throws InvalidInterfaceException
1032
-     * @throws ReflectionException
1033
-     */
1034
-    public function list_table_filters($old_filters, $list_table_obj)
1035
-    {
1036
-        $filters = array();
1037
-        // first month/year filters
1038
-        $filters[] = $this->espresso_event_months_dropdown();
1039
-        $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
1040
-        // active status dropdown
1041
-        if ($status !== 'draft') {
1042
-            $filters[] = $this->active_status_dropdown(
1043
-                isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : ''
1044
-            );
1045
-            $filters[] = $this->venuesDropdown(
1046
-                isset($this->_req_data['venue']) ? $this->_req_data['venue'] : ''
1047
-            );
1048
-        }
1049
-        // category filter
1050
-        $filters[] = $this->category_dropdown();
1051
-        return array_merge($old_filters, $filters);
1052
-    }
1053
-
1054
-
1055
-    /**
1056
-     * espresso_event_months_dropdown
1057
-     *
1058
-     * @access public
1059
-     * @return string                dropdown listing month/year selections for events.
1060
-     */
1061
-    public function espresso_event_months_dropdown()
1062
-    {
1063
-        // what we need to do is get all PRIMARY datetimes for all events to filter on.
1064
-        // Note we need to include any other filters that are set!
1065
-        $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
1066
-        // categories?
1067
-        $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0
1068
-            ? $this->_req_data['EVT_CAT']
1069
-            : null;
1070
-        // active status?
1071
-        $active_status = isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : null;
1072
-        $cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : '';
1073
-        return EEH_Form_Fields::generate_event_months_dropdown($cur_date, $status, $category, $active_status);
1074
-    }
1075
-
1076
-
1077
-    /**
1078
-     * returns a list of "active" statuses on the event
1079
-     *
1080
-     * @param  string $current_value whatever the current active status is
1081
-     * @return string
1082
-     */
1083
-    public function active_status_dropdown($current_value = '')
1084
-    {
1085
-        $select_name = 'active_status';
1086
-        $values = array(
1087
-            'none'     => esc_html__('Show Active/Inactive', 'event_espresso'),
1088
-            'active'   => esc_html__('Active', 'event_espresso'),
1089
-            'upcoming' => esc_html__('Upcoming', 'event_espresso'),
1090
-            'expired'  => esc_html__('Expired', 'event_espresso'),
1091
-            'inactive' => esc_html__('Inactive', 'event_espresso'),
1092
-        );
1093
-
1094
-        return EEH_Form_Fields::select_input($select_name, $values, $current_value, '', 'wide');
1095
-    }
1096
-
1097
-
1098
-    /**
1099
-     * returns a list of "venues"
1100
-     *
1101
-     * @param string $current_value whatever the current active status is
1102
-     * @return string
1103
-     * @throws EE_Error
1104
-     * @throws InvalidArgumentException
1105
-     * @throws InvalidDataTypeException
1106
-     * @throws InvalidInterfaceException
1107
-     * @throws ReflectionException
1108
-     */
1109
-    protected function venuesDropdown($current_value = '')
1110
-    {
1111
-        $select_name = 'venue';
1112
-        $values = array(
1113
-            '' => esc_html__('All Venues', 'event_espresso'),
1114
-        );
1115
-        // populate the list of venues.
1116
-        $venue_model = EE_Registry::instance()->load_model('Venue');
1117
-        $venues = $venue_model->get_all(array('order_by' => array('VNU_name' => 'ASC')));
1118
-
1119
-        foreach ($venues as $venue) {
1120
-            $values[ $venue->ID() ] = $venue->name();
1121
-        }
1122
-
1123
-        return EEH_Form_Fields::select_input($select_name, $values, $current_value, '', 'wide');
1124
-    }
1125
-
1126
-
1127
-    /**
1128
-     * output a dropdown of the categories for the category filter on the event admin list table
1129
-     *
1130
-     * @access  public
1131
-     * @return string html
1132
-     */
1133
-    public function category_dropdown()
1134
-    {
1135
-        $cur_cat = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1;
1136
-        return EEH_Form_Fields::generate_event_category_dropdown($cur_cat);
1137
-    }
1138
-
1139
-
1140
-    /**
1141
-     * get total number of events today
1142
-     *
1143
-     * @access public
1144
-     * @return int
1145
-     * @throws EE_Error
1146
-     * @throws InvalidArgumentException
1147
-     * @throws InvalidDataTypeException
1148
-     * @throws InvalidInterfaceException
1149
-     */
1150
-    public function total_events_today()
1151
-    {
1152
-        $start = EEM_Datetime::instance()->convert_datetime_for_query(
1153
-            'DTT_EVT_start',
1154
-            date('Y-m-d') . ' 00:00:00',
1155
-            'Y-m-d H:i:s',
1156
-            'UTC'
1157
-        );
1158
-        $end = EEM_Datetime::instance()->convert_datetime_for_query(
1159
-            'DTT_EVT_start',
1160
-            date('Y-m-d') . ' 23:59:59',
1161
-            'Y-m-d H:i:s',
1162
-            'UTC'
1163
-        );
1164
-        $where = array(
1165
-            'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)),
1166
-        );
1167
-        $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
1168
-        return $count;
1169
-    }
1170
-
1171
-
1172
-    /**
1173
-     * get total number of events this month
1174
-     *
1175
-     * @access public
1176
-     * @return int
1177
-     * @throws EE_Error
1178
-     * @throws InvalidArgumentException
1179
-     * @throws InvalidDataTypeException
1180
-     * @throws InvalidInterfaceException
1181
-     */
1182
-    public function total_events_this_month()
1183
-    {
1184
-        // Dates
1185
-        $this_year_r = date('Y');
1186
-        $this_month_r = date('m');
1187
-        $days_this_month = date('t');
1188
-        $start = EEM_Datetime::instance()->convert_datetime_for_query(
1189
-            'DTT_EVT_start',
1190
-            $this_year_r . '-' . $this_month_r . '-01 00:00:00',
1191
-            'Y-m-d H:i:s',
1192
-            'UTC'
1193
-        );
1194
-        $end = EEM_Datetime::instance()->convert_datetime_for_query(
1195
-            'DTT_EVT_start',
1196
-            $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59',
1197
-            'Y-m-d H:i:s',
1198
-            'UTC'
1199
-        );
1200
-        $where = array(
1201
-            'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)),
1202
-        );
1203
-        $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
1204
-        return $count;
1205
-    }
1206
-
1207
-
1208
-    /** DEFAULT TICKETS STUFF **/
1209
-
1210
-    /**
1211
-     * Output default tickets list table view.
1212
-     *
1213
-     * @throws DomainException
1214
-     * @throws EE_Error
1215
-     * @throws InvalidArgumentException
1216
-     * @throws InvalidDataTypeException
1217
-     * @throws InvalidInterfaceException
1218
-     */
1219
-    public function _tickets_overview_list_table()
1220
-    {
1221
-        $this->_search_btn_label = esc_html__('Tickets', 'event_espresso');
1222
-        $this->display_admin_list_table_page_with_no_sidebar();
1223
-    }
1224
-
1225
-
1226
-    /**
1227
-     * @param int  $per_page
1228
-     * @param bool $count
1229
-     * @param bool $trashed
1230
-     * @return EE_Soft_Delete_Base_Class[]|int
1231
-     * @throws EE_Error
1232
-     * @throws InvalidArgumentException
1233
-     * @throws InvalidDataTypeException
1234
-     * @throws InvalidInterfaceException
1235
-     */
1236
-    public function get_default_tickets($per_page = 10, $count = false, $trashed = false)
1237
-    {
1238
-        $orderby = empty($this->_req_data['orderby']) ? 'TKT_name' : $this->_req_data['orderby'];
1239
-        $order = empty($this->_req_data['order']) ? 'ASC' : $this->_req_data['order'];
1240
-        switch ($orderby) {
1241
-            case 'TKT_name':
1242
-                $orderby = array('TKT_name' => $order);
1243
-                break;
1244
-            case 'TKT_price':
1245
-                $orderby = array('TKT_price' => $order);
1246
-                break;
1247
-            case 'TKT_uses':
1248
-                $orderby = array('TKT_uses' => $order);
1249
-                break;
1250
-            case 'TKT_min':
1251
-                $orderby = array('TKT_min' => $order);
1252
-                break;
1253
-            case 'TKT_max':
1254
-                $orderby = array('TKT_max' => $order);
1255
-                break;
1256
-            case 'TKT_qty':
1257
-                $orderby = array('TKT_qty' => $order);
1258
-                break;
1259
-        }
1260
-        $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
1261
-            ? $this->_req_data['paged']
1262
-            : 1;
1263
-        $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
1264
-            ? $this->_req_data['perpage']
1265
-            : $per_page;
1266
-        $_where = array(
1267
-            'TKT_is_default' => 1,
1268
-            'TKT_deleted'    => $trashed,
1269
-        );
1270
-        $offset = ($current_page - 1) * $per_page;
1271
-        $limit = array($offset, $per_page);
1272
-        if (isset($this->_req_data['s'])) {
1273
-            $sstr = '%' . $this->_req_data['s'] . '%';
1274
-            $_where['OR'] = array(
1275
-                'TKT_name'        => array('LIKE', $sstr),
1276
-                'TKT_description' => array('LIKE', $sstr),
1277
-            );
1278
-        }
1279
-        $query_params = array(
1280
-            $_where,
1281
-            'order_by' => $orderby,
1282
-            'limit'    => $limit,
1283
-            'group_by' => 'TKT_ID',
1284
-        );
1285
-        if ($count) {
1286
-            return EEM_Ticket::instance()->count_deleted_and_undeleted(array($_where));
1287
-        } else {
1288
-            return EEM_Ticket::instance()->get_all_deleted_and_undeleted($query_params);
1289
-        }
1290
-    }
1291
-
1292
-
1293
-    /**
1294
-     * @param bool $trash
1295
-     * @throws EE_Error
1296
-     * @throws InvalidArgumentException
1297
-     * @throws InvalidDataTypeException
1298
-     * @throws InvalidInterfaceException
1299
-     */
1300
-    protected function _trash_or_restore_ticket($trash = false)
1301
-    {
1302
-        $success = 1;
1303
-        $TKT = EEM_Ticket::instance();
1304
-        // checkboxes?
1305
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1306
-            // if array has more than one element then success message should be plural
1307
-            $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1308
-            // cycle thru the boxes
1309
-            foreach ($this->_req_data['checkbox'] as $TKT_ID) {
1310
-                if ($trash) {
1311
-                    if (! $TKT->delete_by_ID($TKT_ID)) {
1312
-                        $success = 0;
1313
-                    }
1314
-                } elseif (! $TKT->restore_by_ID($TKT_ID)) {
1315
-                    $success = 0;
1316
-                }
1317
-            }
1318
-        } else {
1319
-            // grab single id and trash
1320
-            $TKT_ID = absint($this->_req_data['TKT_ID']);
1321
-            if ($trash) {
1322
-                if (! $TKT->delete_by_ID($TKT_ID)) {
1323
-                    $success = 0;
1324
-                }
1325
-            } elseif (! $TKT->restore_by_ID($TKT_ID)) {
1326
-                $success = 0;
1327
-            }
1328
-        }
1329
-        $action_desc = $trash ? 'moved to the trash' : 'restored';
1330
-        $query_args = array(
1331
-            'action' => 'ticket_list_table',
1332
-            'status' => $trash ? '' : 'trashed',
1333
-        );
1334
-        $this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args);
1335
-    }
1336
-
1337
-
1338
-    /**
1339
-     * Handles trashing default ticket.
1340
-     *
1341
-     * @throws EE_Error
1342
-     * @throws InvalidArgumentException
1343
-     * @throws InvalidDataTypeException
1344
-     * @throws InvalidInterfaceException
1345
-     * @throws ReflectionException
1346
-     */
1347
-    protected function _delete_ticket()
1348
-    {
1349
-        $success = 1;
1350
-        // checkboxes?
1351
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1352
-            // if array has more than one element then success message should be plural
1353
-            $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1354
-            // cycle thru the boxes
1355
-            foreach ($this->_req_data['checkbox'] as $TKT_ID) {
1356
-                // delete
1357
-                if (! $this->_delete_the_ticket($TKT_ID)) {
1358
-                    $success = 0;
1359
-                }
1360
-            }
1361
-        } else {
1362
-            // grab single id and trash
1363
-            $TKT_ID = absint($this->_req_data['TKT_ID']);
1364
-            if (! $this->_delete_the_ticket($TKT_ID)) {
1365
-                $success = 0;
1366
-            }
1367
-        }
1368
-        $action_desc = 'deleted';
1369
-        $query_args = array(
1370
-            'action' => 'ticket_list_table',
1371
-            'status' => 'trashed',
1372
-        );
1373
-        // fail safe.  If the default ticket count === 1 then we need to redirect to event overview.
1374
-        if (EEM_Ticket::instance()->count_deleted_and_undeleted(
1375
-            array(array('TKT_is_default' => 1)),
1376
-            'TKT_ID',
1377
-            true
1378
-        )
1379
-        ) {
1380
-            $query_args = array();
1381
-        }
1382
-        $this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args);
1383
-    }
1384
-
1385
-
1386
-    /**
1387
-     * @param int $TKT_ID
1388
-     * @return bool|int
1389
-     * @throws EE_Error
1390
-     * @throws InvalidArgumentException
1391
-     * @throws InvalidDataTypeException
1392
-     * @throws InvalidInterfaceException
1393
-     * @throws ReflectionException
1394
-     */
1395
-    protected function _delete_the_ticket($TKT_ID)
1396
-    {
1397
-        $tkt = EEM_Ticket::instance()->get_one_by_ID($TKT_ID);
1398
-        $tkt->_remove_relations('Datetime');
1399
-        // delete all related prices first
1400
-        $tkt->delete_related_permanently('Price');
1401
-        return $tkt->delete_permanently();
1402
-    }
20
+	/**
21
+	 * @var AdvancedEditorAdminFormSection
22
+	 */
23
+	protected $advanced_editor_admin_form;
24
+	/**
25
+	 * @var AdvancedEditorEntityData
26
+	 */
27
+	protected $advanced_editor_data;
28
+
29
+
30
+	/**
31
+	 * Extend_Events_Admin_Page constructor.
32
+	 *
33
+	 * @param bool $routing
34
+	 * @throws EE_Error
35
+	 * @throws InvalidArgumentException
36
+	 * @throws InvalidDataTypeException
37
+	 * @throws InvalidInterfaceException
38
+	 * @throws ReflectionException
39
+	 */
40
+	public function __construct($routing = true)
41
+	{
42
+		if (! defined('EVENTS_CAF_TEMPLATE_PATH')) {
43
+			define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/');
44
+			define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/');
45
+			define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/');
46
+		}
47
+		parent::__construct($routing);
48
+		if (isset($this->_req_data['action'])
49
+			&& (
50
+				$this->_req_data['action'] === 'default_event_settings'
51
+				|| $this->_req_data['action'] === 'update_default_event_settings'
52
+			)
53
+		) {
54
+			$this->advanced_editor_admin_form = $this->loader->getShared(
55
+				'EventEspresso\core\domain\services\admin\events\default_settings\AdvancedEditorAdminFormSection'
56
+			);
57
+		}
58
+		if (isset($this->_req_data['action'])
59
+			&& ( $this->_req_data['action'] === 'edit' || $this->_req_data['action'] === 'create_new')
60
+		) {
61
+			$this->advanced_editor_data = $this->loader->getShared(
62
+				'EventEspresso\core\domain\services\admin\events\editor\AdvancedEditorEntityData'
63
+			);
64
+		}
65
+	}
66
+
67
+
68
+	/**
69
+	 * Sets routes.
70
+	 *
71
+	 * @throws EE_Error
72
+	 * @throws InvalidArgumentException
73
+	 * @throws InvalidDataTypeException
74
+	 * @throws InvalidInterfaceException
75
+	 * @since $VID:$
76
+	 */
77
+	protected function _extend_page_config()
78
+	{
79
+		$this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events';
80
+		// is there a evt_id in the request?
81
+		$evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID'])
82
+			? $this->_req_data['EVT_ID']
83
+			: 0;
84
+		$evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id;
85
+		// tkt_id?
86
+		$tkt_id = ! empty($this->_req_data['TKT_ID']) && ! is_array($this->_req_data['TKT_ID'])
87
+			? $this->_req_data['TKT_ID']
88
+			: 0;
89
+		$new_page_routes = array(
90
+			'duplicate_event'          => array(
91
+				'func'       => '_duplicate_event',
92
+				'capability' => 'ee_edit_event',
93
+				'obj_id'     => $evt_id,
94
+				'noheader'   => true,
95
+			),
96
+			'ticket_list_table'        => array(
97
+				'func'       => '_tickets_overview_list_table',
98
+				'capability' => 'ee_read_default_tickets',
99
+			),
100
+			'trash_ticket'             => array(
101
+				'func'       => '_trash_or_restore_ticket',
102
+				'capability' => 'ee_delete_default_ticket',
103
+				'obj_id'     => $tkt_id,
104
+				'noheader'   => true,
105
+				'args'       => array('trash' => true),
106
+			),
107
+			'trash_tickets'            => array(
108
+				'func'       => '_trash_or_restore_ticket',
109
+				'capability' => 'ee_delete_default_tickets',
110
+				'noheader'   => true,
111
+				'args'       => array('trash' => true),
112
+			),
113
+			'restore_ticket'           => array(
114
+				'func'       => '_trash_or_restore_ticket',
115
+				'capability' => 'ee_delete_default_ticket',
116
+				'obj_id'     => $tkt_id,
117
+				'noheader'   => true,
118
+			),
119
+			'restore_tickets'          => array(
120
+				'func'       => '_trash_or_restore_ticket',
121
+				'capability' => 'ee_delete_default_tickets',
122
+				'noheader'   => true,
123
+			),
124
+			'delete_ticket'            => array(
125
+				'func'       => '_delete_ticket',
126
+				'capability' => 'ee_delete_default_ticket',
127
+				'obj_id'     => $tkt_id,
128
+				'noheader'   => true,
129
+			),
130
+			'delete_tickets'           => array(
131
+				'func'       => '_delete_ticket',
132
+				'capability' => 'ee_delete_default_tickets',
133
+				'noheader'   => true,
134
+			),
135
+			'import_page'              => array(
136
+				'func'       => '_import_page',
137
+				'capability' => 'import',
138
+			),
139
+			'import'                   => array(
140
+				'func'       => '_import_events',
141
+				'capability' => 'import',
142
+				'noheader'   => true,
143
+			),
144
+			'import_events'            => array(
145
+				'func'       => '_import_events',
146
+				'capability' => 'import',
147
+				'noheader'   => true,
148
+			),
149
+			'export_events'            => array(
150
+				'func'       => '_events_export',
151
+				'capability' => 'export',
152
+				'noheader'   => true,
153
+			),
154
+			'export_categories'        => array(
155
+				'func'       => '_categories_export',
156
+				'capability' => 'export',
157
+				'noheader'   => true,
158
+			),
159
+			'sample_export_file'       => array(
160
+				'func'       => '_sample_export_file',
161
+				'capability' => 'export',
162
+				'noheader'   => true,
163
+			),
164
+			'update_template_settings' => array(
165
+				'func'       => '_update_template_settings',
166
+				'capability' => 'manage_options',
167
+				'noheader'   => true,
168
+			),
169
+		);
170
+		$this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
171
+		// partial route/config override
172
+		$this->_page_config['import_events']['metaboxes'] = $this->_default_espresso_metaboxes;
173
+		$this->_page_config['create_new']['metaboxes'][] = '_premium_event_editor_meta_boxes';
174
+		$this->_page_config['create_new']['qtips'][] = 'EE_Event_Editor_Tips';
175
+		$this->_page_config['edit']['qtips'][] = 'EE_Event_Editor_Tips';
176
+		$this->_page_config['edit']['metaboxes'][] = '_premium_event_editor_meta_boxes';
177
+		$this->_page_config['default']['list_table'] = 'Extend_Events_Admin_List_Table';
178
+		// add tickets tab but only if there are more than one default ticket!
179
+		$tkt_count = EEM_Ticket::instance()->count_deleted_and_undeleted(
180
+			array(array('TKT_is_default' => 1)),
181
+			'TKT_ID',
182
+			true
183
+		);
184
+		if ($tkt_count > 1) {
185
+			$new_page_config = array(
186
+				'ticket_list_table' => array(
187
+					'nav'           => array(
188
+						'label' => esc_html__('Default Tickets', 'event_espresso'),
189
+						'order' => 60,
190
+					),
191
+					'list_table'    => 'Tickets_List_Table',
192
+					'require_nonce' => false,
193
+				),
194
+			);
195
+		}
196
+		// template settings
197
+		$new_page_config['template_settings'] = array(
198
+			'nav'           => array(
199
+				'label' => esc_html__('Templates', 'event_espresso'),
200
+				'order' => 30,
201
+			),
202
+			'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
203
+			'help_tabs'     => array(
204
+				'general_settings_templates_help_tab' => array(
205
+					'title'    => esc_html__('Templates', 'event_espresso'),
206
+					'filename' => 'general_settings_templates',
207
+				),
208
+			),
209
+			'help_tour'     => array('Templates_Help_Tour'),
210
+			'require_nonce' => false,
211
+		);
212
+		$this->_page_config = array_merge($this->_page_config, $new_page_config);
213
+		// add filters and actions
214
+		// modifying _views
215
+		add_filter(
216
+			'FHEE_event_datetime_metabox_add_additional_date_time_template',
217
+			array($this, 'add_additional_datetime_button'),
218
+			10,
219
+			2
220
+		);
221
+		add_filter(
222
+			'FHEE_event_datetime_metabox_clone_button_template',
223
+			array($this, 'add_datetime_clone_button'),
224
+			10,
225
+			2
226
+		);
227
+		add_filter(
228
+			'FHEE_event_datetime_metabox_timezones_template',
229
+			array($this, 'datetime_timezones_template'),
230
+			10,
231
+			2
232
+		);
233
+		// filters for event list table
234
+		add_filter('FHEE__Extend_Events_Admin_List_Table__filters', array($this, 'list_table_filters'), 10, 2);
235
+		add_filter(
236
+			'FHEE__Events_Admin_List_Table__column_actions__action_links',
237
+			array($this, 'extra_list_table_actions'),
238
+			10,
239
+			2
240
+		);
241
+		// legend item
242
+		add_filter('FHEE__Events_Admin_Page___event_legend_items__items', array($this, 'additional_legend_items'));
243
+		add_action('admin_init', array($this, 'admin_init'));
244
+	}
245
+
246
+
247
+	/**
248
+	 * admin_init
249
+	 */
250
+	public function admin_init()
251
+	{
252
+		EE_Registry::$i18n_js_strings = array_merge(
253
+			EE_Registry::$i18n_js_strings,
254
+			array(
255
+				'image_confirm'          => esc_html__(
256
+					'Do you really want to delete this image? Please remember to update your event to complete the removal.',
257
+					'event_espresso'
258
+				),
259
+				'event_starts_on'        => esc_html__('Event Starts on', 'event_espresso'),
260
+				'event_ends_on'          => esc_html__('Event Ends on', 'event_espresso'),
261
+				'event_datetime_actions' => esc_html__('Actions', 'event_espresso'),
262
+				'event_clone_dt_msg'     => esc_html__('Clone this Event Date and Time', 'event_espresso'),
263
+				'remove_event_dt_msg'    => esc_html__('Remove this Event Time', 'event_espresso'),
264
+			)
265
+		);
266
+	}
267
+
268
+
269
+	/**
270
+	 * Add per page screen options to the default ticket list table view.
271
+	 *
272
+	 * @throws InvalidArgumentException
273
+	 * @throws InvalidDataTypeException
274
+	 * @throws InvalidInterfaceException
275
+	 */
276
+	protected function _add_screen_options_ticket_list_table()
277
+	{
278
+		$this->_per_page_screen_option();
279
+	}
280
+
281
+
282
+	/**
283
+	 * @param string $return
284
+	 * @param int    $id
285
+	 * @param string $new_title
286
+	 * @param string $new_slug
287
+	 * @return string
288
+	 */
289
+	public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug)
290
+	{
291
+		$return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug);
292
+		// make sure this is only when editing
293
+		if (! empty($id)) {
294
+			$href = EE_Admin_Page::add_query_args_and_nonce(
295
+				array('action' => 'duplicate_event', 'EVT_ID' => $id),
296
+				$this->_admin_base_url
297
+			);
298
+			$title = esc_attr__('Duplicate Event', 'event_espresso');
299
+			$return .= '<a href="'
300
+					   . $href
301
+					   . '" title="'
302
+					   . $title
303
+					   . '" id="ee-duplicate-event-button" class="button button-small"  value="duplicate_event">'
304
+					   . $title
305
+					   . '</a>';
306
+		}
307
+		return $return;
308
+	}
309
+
310
+
311
+	/**
312
+	 * Set the list table views for the default ticket list table view.
313
+	 */
314
+	public function _set_list_table_views_ticket_list_table()
315
+	{
316
+		$this->_views = array(
317
+			'all'     => array(
318
+				'slug'        => 'all',
319
+				'label'       => esc_html__('All', 'event_espresso'),
320
+				'count'       => 0,
321
+				'bulk_action' => array(
322
+					'trash_tickets' => esc_html__('Move to Trash', 'event_espresso'),
323
+				),
324
+			),
325
+			'trashed' => array(
326
+				'slug'        => 'trashed',
327
+				'label'       => esc_html__('Trash', 'event_espresso'),
328
+				'count'       => 0,
329
+				'bulk_action' => array(
330
+					'restore_tickets' => esc_html__('Restore from Trash', 'event_espresso'),
331
+					'delete_tickets'  => esc_html__('Delete Permanently', 'event_espresso'),
332
+				),
333
+			),
334
+		);
335
+	}
336
+
337
+
338
+	/**
339
+	 * Enqueue scripts and styles for the event editor.
340
+	 */
341
+	public function load_scripts_styles_edit()
342
+	{
343
+		wp_register_script(
344
+			'ee-event-editor-heartbeat',
345
+			EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js',
346
+			array('ee_admin_js', 'heartbeat'),
347
+			EVENT_ESPRESSO_VERSION,
348
+			true
349
+		);
350
+		wp_enqueue_script('ee-accounting');
351
+		// styles
352
+		wp_enqueue_style('espresso-ui-theme');
353
+		wp_enqueue_script('event_editor_js');
354
+		wp_enqueue_script('ee-event-editor-heartbeat');
355
+	}
356
+
357
+
358
+	/**
359
+	 * Returns template for the additional datetime.
360
+	 *
361
+	 * @param $template
362
+	 * @param $template_args
363
+	 * @return mixed
364
+	 * @throws DomainException
365
+	 */
366
+	public function add_additional_datetime_button($template, $template_args)
367
+	{
368
+		return EEH_Template::display_template(
369
+			EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php',
370
+			$template_args,
371
+			true
372
+		);
373
+	}
374
+
375
+
376
+	/**
377
+	 * Returns the template for cloning a datetime.
378
+	 *
379
+	 * @param $template
380
+	 * @param $template_args
381
+	 * @return mixed
382
+	 * @throws DomainException
383
+	 */
384
+	public function add_datetime_clone_button($template, $template_args)
385
+	{
386
+		return EEH_Template::display_template(
387
+			EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php',
388
+			$template_args,
389
+			true
390
+		);
391
+	}
392
+
393
+
394
+	/**
395
+	 * Returns the template for datetime timezones.
396
+	 *
397
+	 * @param $template
398
+	 * @param $template_args
399
+	 * @return mixed
400
+	 * @throws DomainException
401
+	 */
402
+	public function datetime_timezones_template($template, $template_args)
403
+	{
404
+		return EEH_Template::display_template(
405
+			EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php',
406
+			$template_args,
407
+			true
408
+		);
409
+	}
410
+
411
+
412
+	/**
413
+	 * Sets the views for the default list table view.
414
+	 */
415
+	protected function _set_list_table_views_default()
416
+	{
417
+		parent::_set_list_table_views_default();
418
+		$new_views = array(
419
+			'today' => array(
420
+				'slug'        => 'today',
421
+				'label'       => esc_html__('Today', 'event_espresso'),
422
+				'count'       => $this->total_events_today(),
423
+				'bulk_action' => array(
424
+					'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
425
+				),
426
+			),
427
+			'month' => array(
428
+				'slug'        => 'month',
429
+				'label'       => esc_html__('This Month', 'event_espresso'),
430
+				'count'       => $this->total_events_this_month(),
431
+				'bulk_action' => array(
432
+					'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
433
+				),
434
+			),
435
+		);
436
+		$this->_views = array_merge($this->_views, $new_views);
437
+	}
438
+
439
+
440
+	/**
441
+	 * Returns the extra action links for the default list table view.
442
+	 *
443
+	 * @param array    $action_links
444
+	 * @param EE_Event $event
445
+	 * @return array
446
+	 * @throws EE_Error
447
+	 * @throws InvalidArgumentException
448
+	 * @throws InvalidDataTypeException
449
+	 * @throws InvalidInterfaceException
450
+	 * @throws ReflectionException
451
+	 */
452
+	public function extra_list_table_actions(array $action_links, EE_Event $event)
453
+	{
454
+		if (EE_Registry::instance()->CAP->current_user_can(
455
+			'ee_read_registrations',
456
+			'espresso_registrations_reports',
457
+			$event->ID()
458
+		)
459
+		) {
460
+			$reports_query_args = array(
461
+				'action' => 'reports',
462
+				'EVT_ID' => $event->ID(),
463
+			);
464
+			$reports_link = EE_Admin_Page::add_query_args_and_nonce($reports_query_args, REG_ADMIN_URL);
465
+			$action_links[] = '<a href="'
466
+							  . $reports_link
467
+							  . '" title="'
468
+							  . esc_attr__('View Report', 'event_espresso')
469
+							  . '"><div class="dashicons dashicons-chart-bar"></div></a>'
470
+							  . "\n\t";
471
+		}
472
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
473
+			EE_Registry::instance()->load_helper('MSG_Template');
474
+			$action_links[] = EEH_MSG_Template::get_message_action_link(
475
+				'see_notifications_for',
476
+				null,
477
+				array('EVT_ID' => $event->ID())
478
+			);
479
+		}
480
+		return $action_links;
481
+	}
482
+
483
+
484
+	/**
485
+	 * @param $items
486
+	 * @return mixed
487
+	 */
488
+	public function additional_legend_items($items)
489
+	{
490
+		if (EE_Registry::instance()->CAP->current_user_can(
491
+			'ee_read_registrations',
492
+			'espresso_registrations_reports'
493
+		)
494
+		) {
495
+			$items['reports'] = array(
496
+				'class' => 'dashicons dashicons-chart-bar',
497
+				'desc'  => esc_html__('Event Reports', 'event_espresso'),
498
+			);
499
+		}
500
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
501
+			$related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
502
+			// $related_for_icon can sometimes be a string so 'css_class' would be an illegal offset
503
+			// (can only use numeric offsets when treating strings as arrays)
504
+			if (is_array($related_for_icon) && isset($related_for_icon['css_class'], $related_for_icon['label'])) {
505
+				$items['view_related_messages'] = array(
506
+					'class' => $related_for_icon['css_class'],
507
+					'desc'  => $related_for_icon['label'],
508
+				);
509
+			}
510
+		}
511
+		return $items;
512
+	}
513
+
514
+
515
+	/**
516
+	 * This is the callback method for the duplicate event route
517
+	 * Method looks for 'EVT_ID' in the request and retrieves that event and its details and duplicates them
518
+	 * into a new event.  We add a hook so that any plugins that add extra event details can hook into this
519
+	 * action.  Note that the dupe will have **DUPLICATE** as its title and slug.
520
+	 * After duplication the redirect is to the new event edit page.
521
+	 *
522
+	 * @return void
523
+	 * @throws EE_Error If EE_Event is not available with given ID
524
+	 * @throws InvalidArgumentException
525
+	 * @throws InvalidDataTypeException
526
+	 * @throws InvalidInterfaceException
527
+	 * @throws ReflectionException
528
+	 * @access protected
529
+	 */
530
+	protected function _duplicate_event()
531
+	{
532
+		// first make sure the ID for the event is in the request.
533
+		//  If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?)
534
+		if (! isset($this->_req_data['EVT_ID'])) {
535
+			EE_Error::add_error(
536
+				esc_html__(
537
+					'In order to duplicate an event an Event ID is required.  None was given.',
538
+					'event_espresso'
539
+				),
540
+				__FILE__,
541
+				__FUNCTION__,
542
+				__LINE__
543
+			);
544
+			$this->_redirect_after_action(false, '', '', array(), true);
545
+			return;
546
+		}
547
+		// k we've got EVT_ID so let's use that to get the event we'll duplicate
548
+		$orig_event = EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']);
549
+		if (! $orig_event instanceof EE_Event) {
550
+			throw new EE_Error(
551
+				sprintf(
552
+					esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'),
553
+					$this->_req_data['EVT_ID']
554
+				)
555
+			);
556
+		}
557
+		// k now let's clone the $orig_event before getting relations
558
+		$new_event = clone $orig_event;
559
+		// original datetimes
560
+		$orig_datetimes = $orig_event->get_many_related('Datetime');
561
+		// other original relations
562
+		$orig_ven = $orig_event->get_many_related('Venue');
563
+		// reset the ID and modify other details to make it clear this is a dupe
564
+		$new_event->set('EVT_ID', 0);
565
+		$new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso');
566
+		$new_event->set('EVT_name', $new_name);
567
+		$new_event->set(
568
+			'EVT_slug',
569
+			wp_unique_post_slug(
570
+				sanitize_title($orig_event->name()),
571
+				0,
572
+				'publish',
573
+				'espresso_events',
574
+				0
575
+			)
576
+		);
577
+		$new_event->set('status', 'draft');
578
+		// duplicate discussion settings
579
+		$new_event->set('comment_status', $orig_event->get('comment_status'));
580
+		$new_event->set('ping_status', $orig_event->get('ping_status'));
581
+		// save the new event
582
+		$new_event->save();
583
+		// venues
584
+		foreach ($orig_ven as $ven) {
585
+			$new_event->_add_relation_to($ven, 'Venue');
586
+		}
587
+		$new_event->save();
588
+		// now we need to get the question group relations and handle that
589
+		// first primary question groups
590
+		$orig_primary_qgs = $orig_event->get_many_related(
591
+			'Question_Group',
592
+			[['Event_Question_Group.EQG_primary' => true]]
593
+		);
594
+		if (! empty($orig_primary_qgs)) {
595
+			foreach ($orig_primary_qgs as $id => $obj) {
596
+				if ($obj instanceof EE_Question_Group) {
597
+					$new_event->_add_relation_to($obj, 'Question_Group', ['EQG_primary' => true]);
598
+				}
599
+			}
600
+		}
601
+		// next additional attendee question groups
602
+		$orig_additional_qgs = $orig_event->get_many_related(
603
+			'Question_Group',
604
+			[['Event_Question_Group.EQG_additional' => true]]
605
+		);
606
+		if (! empty($orig_additional_qgs)) {
607
+			foreach ($orig_additional_qgs as $id => $obj) {
608
+				if ($obj instanceof EE_Question_Group) {
609
+					$new_event->_add_relation_to($obj, 'Question_Group', ['EQG_additional' => true]);
610
+				}
611
+			}
612
+		}
613
+
614
+		$new_event->save();
615
+
616
+		// k now that we have the new event saved we can loop through the datetimes and start adding relations.
617
+		$cloned_tickets = array();
618
+		foreach ($orig_datetimes as $orig_dtt) {
619
+			if (! $orig_dtt instanceof EE_Datetime) {
620
+				continue;
621
+			}
622
+			$new_dtt = clone $orig_dtt;
623
+			$orig_tkts = $orig_dtt->tickets();
624
+			// save new dtt then add to event
625
+			$new_dtt->set('DTT_ID', 0);
626
+			$new_dtt->set('DTT_sold', 0);
627
+			$new_dtt->set_reserved(0);
628
+			$new_dtt->save();
629
+			$new_event->_add_relation_to($new_dtt, 'Datetime');
630
+			$new_event->save();
631
+			// now let's get the ticket relations setup.
632
+			foreach ((array) $orig_tkts as $orig_tkt) {
633
+				// it's possible a datetime will have no tickets so let's verify we HAVE a ticket first.
634
+				if (! $orig_tkt instanceof EE_Ticket) {
635
+					continue;
636
+				}
637
+				// is this ticket archived?  If it is then let's skip
638
+				if ($orig_tkt->get('TKT_deleted')) {
639
+					continue;
640
+				}
641
+				// does this original ticket already exist in the clone_tickets cache?
642
+				//  If so we'll just use the new ticket from it.
643
+				if (isset($cloned_tickets[ $orig_tkt->ID() ])) {
644
+					$new_tkt = $cloned_tickets[ $orig_tkt->ID() ];
645
+				} else {
646
+					$new_tkt = clone $orig_tkt;
647
+					// get relations on the $orig_tkt that we need to setup.
648
+					$orig_prices = $orig_tkt->prices();
649
+					$new_tkt->set('TKT_ID', 0);
650
+					$new_tkt->set('TKT_sold', 0);
651
+					$new_tkt->set('TKT_reserved', 0);
652
+					$new_tkt->save(); // make sure new ticket has ID.
653
+					// price relations on new ticket need to be setup.
654
+					foreach ($orig_prices as $orig_price) {
655
+						$new_price = clone $orig_price;
656
+						$new_price->set('PRC_ID', 0);
657
+						$new_price->save();
658
+						$new_tkt->_add_relation_to($new_price, 'Price');
659
+						$new_tkt->save();
660
+					}
661
+
662
+					do_action(
663
+						'AHEE__Extend_Events_Admin_Page___duplicate_event__duplicate_ticket__after',
664
+						$orig_tkt,
665
+						$new_tkt,
666
+						$orig_prices,
667
+						$orig_event,
668
+						$orig_dtt,
669
+						$new_dtt
670
+					);
671
+				}
672
+				// k now we can add the new ticket as a relation to the new datetime
673
+				// and make sure its added to our cached $cloned_tickets array
674
+				// for use with later datetimes that have the same ticket.
675
+				$new_dtt->_add_relation_to($new_tkt, 'Ticket');
676
+				$new_dtt->save();
677
+				$cloned_tickets[ $orig_tkt->ID() ] = $new_tkt;
678
+			}
679
+		}
680
+		// clone taxonomy information
681
+		$taxonomies_to_clone_with = apply_filters(
682
+			'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone',
683
+			array('espresso_event_categories', 'espresso_event_type', 'post_tag')
684
+		);
685
+		// get terms for original event (notice)
686
+		$orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with);
687
+		// loop through terms and add them to new event.
688
+		foreach ($orig_terms as $term) {
689
+			wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true);
690
+		}
691
+
692
+		// duplicate other core WP_Post items for this event.
693
+		// post thumbnail (feature image).
694
+		$feature_image_id = get_post_thumbnail_id($orig_event->ID());
695
+		if ($feature_image_id) {
696
+			update_post_meta($new_event->ID(), '_thumbnail_id', $feature_image_id);
697
+		}
698
+
699
+		// duplicate page_template setting
700
+		$page_template = get_post_meta($orig_event->ID(), '_wp_page_template', true);
701
+		if ($page_template) {
702
+			update_post_meta($new_event->ID(), '_wp_page_template', $page_template);
703
+		}
704
+
705
+		do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event);
706
+		// now let's redirect to the edit page for this duplicated event if we have a new event id.
707
+		if ($new_event->ID()) {
708
+			$redirect_args = array(
709
+				'post'   => $new_event->ID(),
710
+				'action' => 'edit',
711
+			);
712
+			EE_Error::add_success(
713
+				esc_html__(
714
+					'Event successfully duplicated.  Please review the details below and make any necessary edits',
715
+					'event_espresso'
716
+				)
717
+			);
718
+		} else {
719
+			$redirect_args = array(
720
+				'action' => 'default',
721
+			);
722
+			EE_Error::add_error(
723
+				esc_html__('Not able to duplicate event.  Something went wrong.', 'event_espresso'),
724
+				__FILE__,
725
+				__FUNCTION__,
726
+				__LINE__
727
+			);
728
+		}
729
+		$this->_redirect_after_action(false, '', '', $redirect_args, true);
730
+	}
731
+
732
+
733
+	/**
734
+	 * Generates output for the import page.
735
+	 *
736
+	 * @throws DomainException
737
+	 * @throws EE_Error
738
+	 * @throws InvalidArgumentException
739
+	 * @throws InvalidDataTypeException
740
+	 * @throws InvalidInterfaceException
741
+	 */
742
+	protected function _import_page()
743
+	{
744
+		$title = esc_html__('Import', 'event_espresso');
745
+		$intro = esc_html__(
746
+			'If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ',
747
+			'event_espresso'
748
+		);
749
+		$form_url = EVENTS_ADMIN_URL;
750
+		$action = 'import_events';
751
+		$type = 'csv';
752
+		$this->_template_args['form'] = EE_Import::instance()->upload_form(
753
+			$title,
754
+			$intro,
755
+			$form_url,
756
+			$action,
757
+			$type
758
+		);
759
+		$this->_template_args['sample_file_link'] = EE_Admin_Page::add_query_args_and_nonce(
760
+			array('action' => 'sample_export_file'),
761
+			$this->_admin_base_url
762
+		);
763
+		$content = EEH_Template::display_template(
764
+			EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php',
765
+			$this->_template_args,
766
+			true
767
+		);
768
+		$this->_template_args['admin_page_content'] = $content;
769
+		$this->display_admin_page_with_sidebar();
770
+	}
771
+
772
+
773
+	/**
774
+	 * _import_events
775
+	 * This handles displaying the screen and running imports for importing events.
776
+	 *
777
+	 * @return void
778
+	 * @throws EE_Error
779
+	 * @throws InvalidArgumentException
780
+	 * @throws InvalidDataTypeException
781
+	 * @throws InvalidInterfaceException
782
+	 */
783
+	protected function _import_events()
784
+	{
785
+		require_once(EE_CLASSES . 'EE_Import.class.php');
786
+		$success = EE_Import::instance()->import();
787
+		$this->_redirect_after_action($success, 'Import File', 'ran', array('action' => 'import_page'), true);
788
+	}
789
+
790
+
791
+	/**
792
+	 * _events_export
793
+	 * Will export all (or just the given event) to a Excel compatible file.
794
+	 *
795
+	 * @access protected
796
+	 * @return void
797
+	 */
798
+	protected function _events_export()
799
+	{
800
+		if (isset($this->_req_data['EVT_ID'])) {
801
+			$event_ids = $this->_req_data['EVT_ID'];
802
+		} elseif (isset($this->_req_data['EVT_IDs'])) {
803
+			$event_ids = $this->_req_data['EVT_IDs'];
804
+		} else {
805
+			$event_ids = null;
806
+		}
807
+		// todo: I don't like doing this but it'll do until we modify EE_Export Class.
808
+		$new_request_args = array(
809
+			'export' => 'report',
810
+			'action' => 'all_event_data',
811
+			'EVT_ID' => $event_ids,
812
+		);
813
+		$this->_req_data = array_merge($this->_req_data, $new_request_args);
814
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
815
+			require_once(EE_CLASSES . 'EE_Export.class.php');
816
+			$EE_Export = EE_Export::instance($this->_req_data);
817
+			$EE_Export->export();
818
+		}
819
+	}
820
+
821
+
822
+	/**
823
+	 * handle category exports()
824
+	 *
825
+	 * @return void
826
+	 */
827
+	protected function _categories_export()
828
+	{
829
+		// todo: I don't like doing this but it'll do until we modify EE_Export Class.
830
+		$new_request_args = array(
831
+			'export'       => 'report',
832
+			'action'       => 'categories',
833
+			'category_ids' => $this->_req_data['EVT_CAT_ID'],
834
+		);
835
+		$this->_req_data = array_merge($this->_req_data, $new_request_args);
836
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
837
+			require_once(EE_CLASSES . 'EE_Export.class.php');
838
+			$EE_Export = EE_Export::instance($this->_req_data);
839
+			$EE_Export->export();
840
+		}
841
+	}
842
+
843
+
844
+	/**
845
+	 * Creates a sample CSV file for importing
846
+	 */
847
+	protected function _sample_export_file()
848
+	{
849
+		// require_once(EE_CLASSES . 'EE_Export.class.php');
850
+		EE_Export::instance()->export_sample();
851
+	}
852
+
853
+
854
+	/*************        Template Settings        *************/
855
+	/**
856
+	 * Generates template settings page output
857
+	 *
858
+	 * @throws DomainException
859
+	 * @throws EE_Error
860
+	 * @throws InvalidArgumentException
861
+	 * @throws InvalidDataTypeException
862
+	 * @throws InvalidInterfaceException
863
+	 */
864
+	protected function _template_settings()
865
+	{
866
+		$this->_template_args['values'] = $this->_yes_no_values;
867
+		/**
868
+		 * Note leaving this filter in for backward compatibility this was moved in 4.6.x
869
+		 * from General_Settings_Admin_Page to here.
870
+		 */
871
+		$this->_template_args = apply_filters(
872
+			'FHEE__General_Settings_Admin_Page__template_settings__template_args',
873
+			$this->_template_args
874
+		);
875
+		$this->_set_add_edit_form_tags('update_template_settings');
876
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
877
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
878
+			EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php',
879
+			$this->_template_args,
880
+			true
881
+		);
882
+		$this->display_admin_page_with_sidebar();
883
+	}
884
+
885
+
886
+	/**
887
+	 * Handler for updating template settings.
888
+	 *
889
+	 * @throws EE_Error
890
+	 * @throws InvalidArgumentException
891
+	 * @throws InvalidDataTypeException
892
+	 * @throws InvalidInterfaceException
893
+	 */
894
+	protected function _update_template_settings()
895
+	{
896
+		/**
897
+		 * Note leaving this filter in for backward compatibility this was moved in 4.6.x
898
+		 * from General_Settings_Admin_Page to here.
899
+		 */
900
+		EE_Registry::instance()->CFG->template_settings = apply_filters(
901
+			'FHEE__General_Settings_Admin_Page__update_template_settings__data',
902
+			EE_Registry::instance()->CFG->template_settings,
903
+			$this->_req_data
904
+		);
905
+		// update custom post type slugs and detect if we need to flush rewrite rules
906
+		$old_slug = EE_Registry::instance()->CFG->core->event_cpt_slug;
907
+		EE_Registry::instance()->CFG->core->event_cpt_slug = empty($this->_req_data['event_cpt_slug'])
908
+			? EE_Registry::instance()->CFG->core->event_cpt_slug
909
+			: EEH_URL::slugify($this->_req_data['event_cpt_slug'], 'events');
910
+		$what = 'Template Settings';
911
+		$success = $this->_update_espresso_configuration(
912
+			$what,
913
+			EE_Registry::instance()->CFG->template_settings,
914
+			__FILE__,
915
+			__FUNCTION__,
916
+			__LINE__
917
+		);
918
+		if (EE_Registry::instance()->CFG->core->event_cpt_slug !== $old_slug) {
919
+			/** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */
920
+			$rewrite_rules = LoaderFactory::getLoader()->getShared(
921
+				'EventEspresso\core\domain\services\custom_post_types\RewriteRules'
922
+			);
923
+			$rewrite_rules->flush();
924
+		}
925
+		$this->_redirect_after_action($success, $what, 'updated', array('action' => 'template_settings'));
926
+	}
927
+
928
+
929
+	/**
930
+	 * _premium_event_editor_meta_boxes
931
+	 * add all metaboxes related to the event_editor
932
+	 *
933
+	 * @access protected
934
+	 * @return void
935
+	 * @throws EE_Error
936
+	 * @throws InvalidArgumentException
937
+	 * @throws InvalidDataTypeException
938
+	 * @throws InvalidInterfaceException
939
+	 * @throws ReflectionException
940
+	 */
941
+	protected function _premium_event_editor_meta_boxes()
942
+	{
943
+		$this->verify_cpt_object();
944
+		add_meta_box(
945
+			'espresso_event_editor_event_options',
946
+			esc_html__('Event Registration Options', 'event_espresso'),
947
+			array($this, 'registration_options_meta_box'),
948
+			$this->page_slug,
949
+			'side',
950
+			'core'
951
+		);
952
+	}
953
+
954
+
955
+	/**
956
+	 * override caf metabox
957
+	 *
958
+	 * @return void
959
+	 * @throws DomainException
960
+	 * @throws EE_Error
961
+	 */
962
+	public function registration_options_meta_box()
963
+	{
964
+		$yes_no_values = array(
965
+			array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')),
966
+			array('id' => false, 'text' => esc_html__('No', 'event_espresso')),
967
+		);
968
+		$default_reg_status_values = EEM_Registration::reg_status_array(
969
+			array(
970
+				EEM_Registration::status_id_cancelled,
971
+				EEM_Registration::status_id_declined,
972
+				EEM_Registration::status_id_incomplete,
973
+				EEM_Registration::status_id_wait_list,
974
+			),
975
+			true
976
+		);
977
+		$template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false);
978
+		$template_args['_event'] = $this->_cpt_model_obj;
979
+		$template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit();
980
+		$template_args['default_registration_status'] = EEH_Form_Fields::select_input(
981
+			'default_reg_status',
982
+			$default_reg_status_values,
983
+			$this->_cpt_model_obj->default_registration_status()
984
+		);
985
+		$template_args['display_description'] = EEH_Form_Fields::select_input(
986
+			'display_desc',
987
+			$yes_no_values,
988
+			$this->_cpt_model_obj->display_description()
989
+		);
990
+		$template_args['display_ticket_selector'] = EEH_Form_Fields::select_input(
991
+			'display_ticket_selector',
992
+			$yes_no_values,
993
+			$this->_cpt_model_obj->display_ticket_selector(),
994
+			'',
995
+			'',
996
+			false
997
+		);
998
+		$template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input(
999
+			'EVT_default_registration_status',
1000
+			$default_reg_status_values,
1001
+			$this->_cpt_model_obj->default_registration_status()
1002
+		);
1003
+		$template_args['additional_registration_options'] = apply_filters(
1004
+			'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options',
1005
+			'',
1006
+			$template_args,
1007
+			$yes_no_values,
1008
+			$default_reg_status_values
1009
+		);
1010
+		EEH_Template::display_template(
1011
+			EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php',
1012
+			$template_args
1013
+		);
1014
+	}
1015
+
1016
+
1017
+
1018
+	/**
1019
+	 * wp_list_table_mods for caf
1020
+	 * ============================
1021
+	 */
1022
+	/**
1023
+	 * hook into list table filters and provide filters for caffeinated list table
1024
+	 *
1025
+	 * @param array $old_filters    any existing filters present
1026
+	 * @param array $list_table_obj the list table object
1027
+	 * @return array                  new filters
1028
+	 * @throws EE_Error
1029
+	 * @throws InvalidArgumentException
1030
+	 * @throws InvalidDataTypeException
1031
+	 * @throws InvalidInterfaceException
1032
+	 * @throws ReflectionException
1033
+	 */
1034
+	public function list_table_filters($old_filters, $list_table_obj)
1035
+	{
1036
+		$filters = array();
1037
+		// first month/year filters
1038
+		$filters[] = $this->espresso_event_months_dropdown();
1039
+		$status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
1040
+		// active status dropdown
1041
+		if ($status !== 'draft') {
1042
+			$filters[] = $this->active_status_dropdown(
1043
+				isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : ''
1044
+			);
1045
+			$filters[] = $this->venuesDropdown(
1046
+				isset($this->_req_data['venue']) ? $this->_req_data['venue'] : ''
1047
+			);
1048
+		}
1049
+		// category filter
1050
+		$filters[] = $this->category_dropdown();
1051
+		return array_merge($old_filters, $filters);
1052
+	}
1053
+
1054
+
1055
+	/**
1056
+	 * espresso_event_months_dropdown
1057
+	 *
1058
+	 * @access public
1059
+	 * @return string                dropdown listing month/year selections for events.
1060
+	 */
1061
+	public function espresso_event_months_dropdown()
1062
+	{
1063
+		// what we need to do is get all PRIMARY datetimes for all events to filter on.
1064
+		// Note we need to include any other filters that are set!
1065
+		$status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
1066
+		// categories?
1067
+		$category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0
1068
+			? $this->_req_data['EVT_CAT']
1069
+			: null;
1070
+		// active status?
1071
+		$active_status = isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : null;
1072
+		$cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : '';
1073
+		return EEH_Form_Fields::generate_event_months_dropdown($cur_date, $status, $category, $active_status);
1074
+	}
1075
+
1076
+
1077
+	/**
1078
+	 * returns a list of "active" statuses on the event
1079
+	 *
1080
+	 * @param  string $current_value whatever the current active status is
1081
+	 * @return string
1082
+	 */
1083
+	public function active_status_dropdown($current_value = '')
1084
+	{
1085
+		$select_name = 'active_status';
1086
+		$values = array(
1087
+			'none'     => esc_html__('Show Active/Inactive', 'event_espresso'),
1088
+			'active'   => esc_html__('Active', 'event_espresso'),
1089
+			'upcoming' => esc_html__('Upcoming', 'event_espresso'),
1090
+			'expired'  => esc_html__('Expired', 'event_espresso'),
1091
+			'inactive' => esc_html__('Inactive', 'event_espresso'),
1092
+		);
1093
+
1094
+		return EEH_Form_Fields::select_input($select_name, $values, $current_value, '', 'wide');
1095
+	}
1096
+
1097
+
1098
+	/**
1099
+	 * returns a list of "venues"
1100
+	 *
1101
+	 * @param string $current_value whatever the current active status is
1102
+	 * @return string
1103
+	 * @throws EE_Error
1104
+	 * @throws InvalidArgumentException
1105
+	 * @throws InvalidDataTypeException
1106
+	 * @throws InvalidInterfaceException
1107
+	 * @throws ReflectionException
1108
+	 */
1109
+	protected function venuesDropdown($current_value = '')
1110
+	{
1111
+		$select_name = 'venue';
1112
+		$values = array(
1113
+			'' => esc_html__('All Venues', 'event_espresso'),
1114
+		);
1115
+		// populate the list of venues.
1116
+		$venue_model = EE_Registry::instance()->load_model('Venue');
1117
+		$venues = $venue_model->get_all(array('order_by' => array('VNU_name' => 'ASC')));
1118
+
1119
+		foreach ($venues as $venue) {
1120
+			$values[ $venue->ID() ] = $venue->name();
1121
+		}
1122
+
1123
+		return EEH_Form_Fields::select_input($select_name, $values, $current_value, '', 'wide');
1124
+	}
1125
+
1126
+
1127
+	/**
1128
+	 * output a dropdown of the categories for the category filter on the event admin list table
1129
+	 *
1130
+	 * @access  public
1131
+	 * @return string html
1132
+	 */
1133
+	public function category_dropdown()
1134
+	{
1135
+		$cur_cat = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1;
1136
+		return EEH_Form_Fields::generate_event_category_dropdown($cur_cat);
1137
+	}
1138
+
1139
+
1140
+	/**
1141
+	 * get total number of events today
1142
+	 *
1143
+	 * @access public
1144
+	 * @return int
1145
+	 * @throws EE_Error
1146
+	 * @throws InvalidArgumentException
1147
+	 * @throws InvalidDataTypeException
1148
+	 * @throws InvalidInterfaceException
1149
+	 */
1150
+	public function total_events_today()
1151
+	{
1152
+		$start = EEM_Datetime::instance()->convert_datetime_for_query(
1153
+			'DTT_EVT_start',
1154
+			date('Y-m-d') . ' 00:00:00',
1155
+			'Y-m-d H:i:s',
1156
+			'UTC'
1157
+		);
1158
+		$end = EEM_Datetime::instance()->convert_datetime_for_query(
1159
+			'DTT_EVT_start',
1160
+			date('Y-m-d') . ' 23:59:59',
1161
+			'Y-m-d H:i:s',
1162
+			'UTC'
1163
+		);
1164
+		$where = array(
1165
+			'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)),
1166
+		);
1167
+		$count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
1168
+		return $count;
1169
+	}
1170
+
1171
+
1172
+	/**
1173
+	 * get total number of events this month
1174
+	 *
1175
+	 * @access public
1176
+	 * @return int
1177
+	 * @throws EE_Error
1178
+	 * @throws InvalidArgumentException
1179
+	 * @throws InvalidDataTypeException
1180
+	 * @throws InvalidInterfaceException
1181
+	 */
1182
+	public function total_events_this_month()
1183
+	{
1184
+		// Dates
1185
+		$this_year_r = date('Y');
1186
+		$this_month_r = date('m');
1187
+		$days_this_month = date('t');
1188
+		$start = EEM_Datetime::instance()->convert_datetime_for_query(
1189
+			'DTT_EVT_start',
1190
+			$this_year_r . '-' . $this_month_r . '-01 00:00:00',
1191
+			'Y-m-d H:i:s',
1192
+			'UTC'
1193
+		);
1194
+		$end = EEM_Datetime::instance()->convert_datetime_for_query(
1195
+			'DTT_EVT_start',
1196
+			$this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59',
1197
+			'Y-m-d H:i:s',
1198
+			'UTC'
1199
+		);
1200
+		$where = array(
1201
+			'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)),
1202
+		);
1203
+		$count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
1204
+		return $count;
1205
+	}
1206
+
1207
+
1208
+	/** DEFAULT TICKETS STUFF **/
1209
+
1210
+	/**
1211
+	 * Output default tickets list table view.
1212
+	 *
1213
+	 * @throws DomainException
1214
+	 * @throws EE_Error
1215
+	 * @throws InvalidArgumentException
1216
+	 * @throws InvalidDataTypeException
1217
+	 * @throws InvalidInterfaceException
1218
+	 */
1219
+	public function _tickets_overview_list_table()
1220
+	{
1221
+		$this->_search_btn_label = esc_html__('Tickets', 'event_espresso');
1222
+		$this->display_admin_list_table_page_with_no_sidebar();
1223
+	}
1224
+
1225
+
1226
+	/**
1227
+	 * @param int  $per_page
1228
+	 * @param bool $count
1229
+	 * @param bool $trashed
1230
+	 * @return EE_Soft_Delete_Base_Class[]|int
1231
+	 * @throws EE_Error
1232
+	 * @throws InvalidArgumentException
1233
+	 * @throws InvalidDataTypeException
1234
+	 * @throws InvalidInterfaceException
1235
+	 */
1236
+	public function get_default_tickets($per_page = 10, $count = false, $trashed = false)
1237
+	{
1238
+		$orderby = empty($this->_req_data['orderby']) ? 'TKT_name' : $this->_req_data['orderby'];
1239
+		$order = empty($this->_req_data['order']) ? 'ASC' : $this->_req_data['order'];
1240
+		switch ($orderby) {
1241
+			case 'TKT_name':
1242
+				$orderby = array('TKT_name' => $order);
1243
+				break;
1244
+			case 'TKT_price':
1245
+				$orderby = array('TKT_price' => $order);
1246
+				break;
1247
+			case 'TKT_uses':
1248
+				$orderby = array('TKT_uses' => $order);
1249
+				break;
1250
+			case 'TKT_min':
1251
+				$orderby = array('TKT_min' => $order);
1252
+				break;
1253
+			case 'TKT_max':
1254
+				$orderby = array('TKT_max' => $order);
1255
+				break;
1256
+			case 'TKT_qty':
1257
+				$orderby = array('TKT_qty' => $order);
1258
+				break;
1259
+		}
1260
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
1261
+			? $this->_req_data['paged']
1262
+			: 1;
1263
+		$per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
1264
+			? $this->_req_data['perpage']
1265
+			: $per_page;
1266
+		$_where = array(
1267
+			'TKT_is_default' => 1,
1268
+			'TKT_deleted'    => $trashed,
1269
+		);
1270
+		$offset = ($current_page - 1) * $per_page;
1271
+		$limit = array($offset, $per_page);
1272
+		if (isset($this->_req_data['s'])) {
1273
+			$sstr = '%' . $this->_req_data['s'] . '%';
1274
+			$_where['OR'] = array(
1275
+				'TKT_name'        => array('LIKE', $sstr),
1276
+				'TKT_description' => array('LIKE', $sstr),
1277
+			);
1278
+		}
1279
+		$query_params = array(
1280
+			$_where,
1281
+			'order_by' => $orderby,
1282
+			'limit'    => $limit,
1283
+			'group_by' => 'TKT_ID',
1284
+		);
1285
+		if ($count) {
1286
+			return EEM_Ticket::instance()->count_deleted_and_undeleted(array($_where));
1287
+		} else {
1288
+			return EEM_Ticket::instance()->get_all_deleted_and_undeleted($query_params);
1289
+		}
1290
+	}
1291
+
1292
+
1293
+	/**
1294
+	 * @param bool $trash
1295
+	 * @throws EE_Error
1296
+	 * @throws InvalidArgumentException
1297
+	 * @throws InvalidDataTypeException
1298
+	 * @throws InvalidInterfaceException
1299
+	 */
1300
+	protected function _trash_or_restore_ticket($trash = false)
1301
+	{
1302
+		$success = 1;
1303
+		$TKT = EEM_Ticket::instance();
1304
+		// checkboxes?
1305
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1306
+			// if array has more than one element then success message should be plural
1307
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1308
+			// cycle thru the boxes
1309
+			foreach ($this->_req_data['checkbox'] as $TKT_ID) {
1310
+				if ($trash) {
1311
+					if (! $TKT->delete_by_ID($TKT_ID)) {
1312
+						$success = 0;
1313
+					}
1314
+				} elseif (! $TKT->restore_by_ID($TKT_ID)) {
1315
+					$success = 0;
1316
+				}
1317
+			}
1318
+		} else {
1319
+			// grab single id and trash
1320
+			$TKT_ID = absint($this->_req_data['TKT_ID']);
1321
+			if ($trash) {
1322
+				if (! $TKT->delete_by_ID($TKT_ID)) {
1323
+					$success = 0;
1324
+				}
1325
+			} elseif (! $TKT->restore_by_ID($TKT_ID)) {
1326
+				$success = 0;
1327
+			}
1328
+		}
1329
+		$action_desc = $trash ? 'moved to the trash' : 'restored';
1330
+		$query_args = array(
1331
+			'action' => 'ticket_list_table',
1332
+			'status' => $trash ? '' : 'trashed',
1333
+		);
1334
+		$this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args);
1335
+	}
1336
+
1337
+
1338
+	/**
1339
+	 * Handles trashing default ticket.
1340
+	 *
1341
+	 * @throws EE_Error
1342
+	 * @throws InvalidArgumentException
1343
+	 * @throws InvalidDataTypeException
1344
+	 * @throws InvalidInterfaceException
1345
+	 * @throws ReflectionException
1346
+	 */
1347
+	protected function _delete_ticket()
1348
+	{
1349
+		$success = 1;
1350
+		// checkboxes?
1351
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1352
+			// if array has more than one element then success message should be plural
1353
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1354
+			// cycle thru the boxes
1355
+			foreach ($this->_req_data['checkbox'] as $TKT_ID) {
1356
+				// delete
1357
+				if (! $this->_delete_the_ticket($TKT_ID)) {
1358
+					$success = 0;
1359
+				}
1360
+			}
1361
+		} else {
1362
+			// grab single id and trash
1363
+			$TKT_ID = absint($this->_req_data['TKT_ID']);
1364
+			if (! $this->_delete_the_ticket($TKT_ID)) {
1365
+				$success = 0;
1366
+			}
1367
+		}
1368
+		$action_desc = 'deleted';
1369
+		$query_args = array(
1370
+			'action' => 'ticket_list_table',
1371
+			'status' => 'trashed',
1372
+		);
1373
+		// fail safe.  If the default ticket count === 1 then we need to redirect to event overview.
1374
+		if (EEM_Ticket::instance()->count_deleted_and_undeleted(
1375
+			array(array('TKT_is_default' => 1)),
1376
+			'TKT_ID',
1377
+			true
1378
+		)
1379
+		) {
1380
+			$query_args = array();
1381
+		}
1382
+		$this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args);
1383
+	}
1384
+
1385
+
1386
+	/**
1387
+	 * @param int $TKT_ID
1388
+	 * @return bool|int
1389
+	 * @throws EE_Error
1390
+	 * @throws InvalidArgumentException
1391
+	 * @throws InvalidDataTypeException
1392
+	 * @throws InvalidInterfaceException
1393
+	 * @throws ReflectionException
1394
+	 */
1395
+	protected function _delete_the_ticket($TKT_ID)
1396
+	{
1397
+		$tkt = EEM_Ticket::instance()->get_one_by_ID($TKT_ID);
1398
+		$tkt->_remove_relations('Datetime');
1399
+		// delete all related prices first
1400
+		$tkt->delete_related_permanently('Price');
1401
+		return $tkt->delete_permanently();
1402
+	}
1403 1403
 }
Please login to merge, or discard this patch.
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -39,10 +39,10 @@  discard block
 block discarded – undo
39 39
      */
40 40
     public function __construct($routing = true)
41 41
     {
42
-        if (! defined('EVENTS_CAF_TEMPLATE_PATH')) {
43
-            define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/');
44
-            define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/');
45
-            define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/');
42
+        if ( ! defined('EVENTS_CAF_TEMPLATE_PATH')) {
43
+            define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'events/templates/');
44
+            define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND.'events/assets/');
45
+            define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'events/assets/');
46 46
         }
47 47
         parent::__construct($routing);
48 48
         if (isset($this->_req_data['action'])
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
             );
57 57
         }
58 58
         if (isset($this->_req_data['action'])
59
-            && ( $this->_req_data['action'] === 'edit' || $this->_req_data['action'] === 'create_new')
59
+            && ($this->_req_data['action'] === 'edit' || $this->_req_data['action'] === 'create_new')
60 60
         ) {
61 61
             $this->advanced_editor_data = $this->loader->getShared(
62 62
                 'EventEspresso\core\domain\services\admin\events\editor\AdvancedEditorEntityData'
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
      */
77 77
     protected function _extend_page_config()
78 78
     {
79
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events';
79
+        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'events';
80 80
         // is there a evt_id in the request?
81 81
         $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID'])
82 82
             ? $this->_req_data['EVT_ID']
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
     {
291 291
         $return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug);
292 292
         // make sure this is only when editing
293
-        if (! empty($id)) {
293
+        if ( ! empty($id)) {
294 294
             $href = EE_Admin_Page::add_query_args_and_nonce(
295 295
                 array('action' => 'duplicate_event', 'EVT_ID' => $id),
296 296
                 $this->_admin_base_url
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
     {
343 343
         wp_register_script(
344 344
             'ee-event-editor-heartbeat',
345
-            EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js',
345
+            EVENTS_CAF_ASSETS_URL.'event-editor-heartbeat.js',
346 346
             array('ee_admin_js', 'heartbeat'),
347 347
             EVENT_ESPRESSO_VERSION,
348 348
             true
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
     public function add_additional_datetime_button($template, $template_args)
367 367
     {
368 368
         return EEH_Template::display_template(
369
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php',
369
+            EVENTS_CAF_TEMPLATE_PATH.'event_datetime_add_additional_time.template.php',
370 370
             $template_args,
371 371
             true
372 372
         );
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
     public function add_datetime_clone_button($template, $template_args)
385 385
     {
386 386
         return EEH_Template::display_template(
387
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php',
387
+            EVENTS_CAF_TEMPLATE_PATH.'event_datetime_metabox_clone_button.template.php',
388 388
             $template_args,
389 389
             true
390 390
         );
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
     public function datetime_timezones_template($template, $template_args)
403 403
     {
404 404
         return EEH_Template::display_template(
405
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php',
405
+            EVENTS_CAF_TEMPLATE_PATH.'event_datetime_timezones.template.php',
406 406
             $template_args,
407 407
             true
408 408
         );
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
     {
532 532
         // first make sure the ID for the event is in the request.
533 533
         //  If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?)
534
-        if (! isset($this->_req_data['EVT_ID'])) {
534
+        if ( ! isset($this->_req_data['EVT_ID'])) {
535 535
             EE_Error::add_error(
536 536
                 esc_html__(
537 537
                     'In order to duplicate an event an Event ID is required.  None was given.',
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
         }
547 547
         // k we've got EVT_ID so let's use that to get the event we'll duplicate
548 548
         $orig_event = EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']);
549
-        if (! $orig_event instanceof EE_Event) {
549
+        if ( ! $orig_event instanceof EE_Event) {
550 550
             throw new EE_Error(
551 551
                 sprintf(
552 552
                     esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'),
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
         $orig_ven = $orig_event->get_many_related('Venue');
563 563
         // reset the ID and modify other details to make it clear this is a dupe
564 564
         $new_event->set('EVT_ID', 0);
565
-        $new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso');
565
+        $new_name = $new_event->name().' '.esc_html__('**DUPLICATE**', 'event_espresso');
566 566
         $new_event->set('EVT_name', $new_name);
567 567
         $new_event->set(
568 568
             'EVT_slug',
@@ -591,7 +591,7 @@  discard block
 block discarded – undo
591 591
             'Question_Group',
592 592
             [['Event_Question_Group.EQG_primary' => true]]
593 593
         );
594
-        if (! empty($orig_primary_qgs)) {
594
+        if ( ! empty($orig_primary_qgs)) {
595 595
             foreach ($orig_primary_qgs as $id => $obj) {
596 596
                 if ($obj instanceof EE_Question_Group) {
597 597
                     $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_primary' => true]);
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
             'Question_Group',
604 604
             [['Event_Question_Group.EQG_additional' => true]]
605 605
         );
606
-        if (! empty($orig_additional_qgs)) {
606
+        if ( ! empty($orig_additional_qgs)) {
607 607
             foreach ($orig_additional_qgs as $id => $obj) {
608 608
                 if ($obj instanceof EE_Question_Group) {
609 609
                     $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_additional' => true]);
@@ -616,7 +616,7 @@  discard block
 block discarded – undo
616 616
         // k now that we have the new event saved we can loop through the datetimes and start adding relations.
617 617
         $cloned_tickets = array();
618 618
         foreach ($orig_datetimes as $orig_dtt) {
619
-            if (! $orig_dtt instanceof EE_Datetime) {
619
+            if ( ! $orig_dtt instanceof EE_Datetime) {
620 620
                 continue;
621 621
             }
622 622
             $new_dtt = clone $orig_dtt;
@@ -631,7 +631,7 @@  discard block
 block discarded – undo
631 631
             // now let's get the ticket relations setup.
632 632
             foreach ((array) $orig_tkts as $orig_tkt) {
633 633
                 // it's possible a datetime will have no tickets so let's verify we HAVE a ticket first.
634
-                if (! $orig_tkt instanceof EE_Ticket) {
634
+                if ( ! $orig_tkt instanceof EE_Ticket) {
635 635
                     continue;
636 636
                 }
637 637
                 // is this ticket archived?  If it is then let's skip
@@ -640,8 +640,8 @@  discard block
 block discarded – undo
640 640
                 }
641 641
                 // does this original ticket already exist in the clone_tickets cache?
642 642
                 //  If so we'll just use the new ticket from it.
643
-                if (isset($cloned_tickets[ $orig_tkt->ID() ])) {
644
-                    $new_tkt = $cloned_tickets[ $orig_tkt->ID() ];
643
+                if (isset($cloned_tickets[$orig_tkt->ID()])) {
644
+                    $new_tkt = $cloned_tickets[$orig_tkt->ID()];
645 645
                 } else {
646 646
                     $new_tkt = clone $orig_tkt;
647 647
                     // get relations on the $orig_tkt that we need to setup.
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
                 // for use with later datetimes that have the same ticket.
675 675
                 $new_dtt->_add_relation_to($new_tkt, 'Ticket');
676 676
                 $new_dtt->save();
677
-                $cloned_tickets[ $orig_tkt->ID() ] = $new_tkt;
677
+                $cloned_tickets[$orig_tkt->ID()] = $new_tkt;
678 678
             }
679 679
         }
680 680
         // clone taxonomy information
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
             $this->_admin_base_url
762 762
         );
763 763
         $content = EEH_Template::display_template(
764
-            EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php',
764
+            EVENTS_CAF_TEMPLATE_PATH.'import_page.template.php',
765 765
             $this->_template_args,
766 766
             true
767 767
         );
@@ -782,7 +782,7 @@  discard block
 block discarded – undo
782 782
      */
783 783
     protected function _import_events()
784 784
     {
785
-        require_once(EE_CLASSES . 'EE_Import.class.php');
785
+        require_once(EE_CLASSES.'EE_Import.class.php');
786 786
         $success = EE_Import::instance()->import();
787 787
         $this->_redirect_after_action($success, 'Import File', 'ran', array('action' => 'import_page'), true);
788 788
     }
@@ -811,8 +811,8 @@  discard block
 block discarded – undo
811 811
             'EVT_ID' => $event_ids,
812 812
         );
813 813
         $this->_req_data = array_merge($this->_req_data, $new_request_args);
814
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
815
-            require_once(EE_CLASSES . 'EE_Export.class.php');
814
+        if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
815
+            require_once(EE_CLASSES.'EE_Export.class.php');
816 816
             $EE_Export = EE_Export::instance($this->_req_data);
817 817
             $EE_Export->export();
818 818
         }
@@ -833,8 +833,8 @@  discard block
 block discarded – undo
833 833
             'category_ids' => $this->_req_data['EVT_CAT_ID'],
834 834
         );
835 835
         $this->_req_data = array_merge($this->_req_data, $new_request_args);
836
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
837
-            require_once(EE_CLASSES . 'EE_Export.class.php');
836
+        if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
837
+            require_once(EE_CLASSES.'EE_Export.class.php');
838 838
             $EE_Export = EE_Export::instance($this->_req_data);
839 839
             $EE_Export->export();
840 840
         }
@@ -875,7 +875,7 @@  discard block
 block discarded – undo
875 875
         $this->_set_add_edit_form_tags('update_template_settings');
876 876
         $this->_set_publish_post_box_vars(null, false, false, null, false);
877 877
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
878
-            EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php',
878
+            EVENTS_CAF_TEMPLATE_PATH.'template_settings.template.php',
879 879
             $this->_template_args,
880 880
             true
881 881
         );
@@ -1008,7 +1008,7 @@  discard block
 block discarded – undo
1008 1008
             $default_reg_status_values
1009 1009
         );
1010 1010
         EEH_Template::display_template(
1011
-            EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php',
1011
+            EVENTS_CAF_TEMPLATE_PATH.'event_registration_options.template.php',
1012 1012
             $template_args
1013 1013
         );
1014 1014
     }
@@ -1117,7 +1117,7 @@  discard block
 block discarded – undo
1117 1117
         $venues = $venue_model->get_all(array('order_by' => array('VNU_name' => 'ASC')));
1118 1118
 
1119 1119
         foreach ($venues as $venue) {
1120
-            $values[ $venue->ID() ] = $venue->name();
1120
+            $values[$venue->ID()] = $venue->name();
1121 1121
         }
1122 1122
 
1123 1123
         return EEH_Form_Fields::select_input($select_name, $values, $current_value, '', 'wide');
@@ -1151,13 +1151,13 @@  discard block
 block discarded – undo
1151 1151
     {
1152 1152
         $start = EEM_Datetime::instance()->convert_datetime_for_query(
1153 1153
             'DTT_EVT_start',
1154
-            date('Y-m-d') . ' 00:00:00',
1154
+            date('Y-m-d').' 00:00:00',
1155 1155
             'Y-m-d H:i:s',
1156 1156
             'UTC'
1157 1157
         );
1158 1158
         $end = EEM_Datetime::instance()->convert_datetime_for_query(
1159 1159
             'DTT_EVT_start',
1160
-            date('Y-m-d') . ' 23:59:59',
1160
+            date('Y-m-d').' 23:59:59',
1161 1161
             'Y-m-d H:i:s',
1162 1162
             'UTC'
1163 1163
         );
@@ -1187,13 +1187,13 @@  discard block
 block discarded – undo
1187 1187
         $days_this_month = date('t');
1188 1188
         $start = EEM_Datetime::instance()->convert_datetime_for_query(
1189 1189
             'DTT_EVT_start',
1190
-            $this_year_r . '-' . $this_month_r . '-01 00:00:00',
1190
+            $this_year_r.'-'.$this_month_r.'-01 00:00:00',
1191 1191
             'Y-m-d H:i:s',
1192 1192
             'UTC'
1193 1193
         );
1194 1194
         $end = EEM_Datetime::instance()->convert_datetime_for_query(
1195 1195
             'DTT_EVT_start',
1196
-            $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59',
1196
+            $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' 23:59:59',
1197 1197
             'Y-m-d H:i:s',
1198 1198
             'UTC'
1199 1199
         );
@@ -1270,7 +1270,7 @@  discard block
 block discarded – undo
1270 1270
         $offset = ($current_page - 1) * $per_page;
1271 1271
         $limit = array($offset, $per_page);
1272 1272
         if (isset($this->_req_data['s'])) {
1273
-            $sstr = '%' . $this->_req_data['s'] . '%';
1273
+            $sstr = '%'.$this->_req_data['s'].'%';
1274 1274
             $_where['OR'] = array(
1275 1275
                 'TKT_name'        => array('LIKE', $sstr),
1276 1276
                 'TKT_description' => array('LIKE', $sstr),
@@ -1302,16 +1302,16 @@  discard block
 block discarded – undo
1302 1302
         $success = 1;
1303 1303
         $TKT = EEM_Ticket::instance();
1304 1304
         // checkboxes?
1305
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1305
+        if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1306 1306
             // if array has more than one element then success message should be plural
1307 1307
             $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1308 1308
             // cycle thru the boxes
1309 1309
             foreach ($this->_req_data['checkbox'] as $TKT_ID) {
1310 1310
                 if ($trash) {
1311
-                    if (! $TKT->delete_by_ID($TKT_ID)) {
1311
+                    if ( ! $TKT->delete_by_ID($TKT_ID)) {
1312 1312
                         $success = 0;
1313 1313
                     }
1314
-                } elseif (! $TKT->restore_by_ID($TKT_ID)) {
1314
+                } elseif ( ! $TKT->restore_by_ID($TKT_ID)) {
1315 1315
                     $success = 0;
1316 1316
                 }
1317 1317
             }
@@ -1319,10 +1319,10 @@  discard block
 block discarded – undo
1319 1319
             // grab single id and trash
1320 1320
             $TKT_ID = absint($this->_req_data['TKT_ID']);
1321 1321
             if ($trash) {
1322
-                if (! $TKT->delete_by_ID($TKT_ID)) {
1322
+                if ( ! $TKT->delete_by_ID($TKT_ID)) {
1323 1323
                     $success = 0;
1324 1324
                 }
1325
-            } elseif (! $TKT->restore_by_ID($TKT_ID)) {
1325
+            } elseif ( ! $TKT->restore_by_ID($TKT_ID)) {
1326 1326
                 $success = 0;
1327 1327
             }
1328 1328
         }
@@ -1348,20 +1348,20 @@  discard block
 block discarded – undo
1348 1348
     {
1349 1349
         $success = 1;
1350 1350
         // checkboxes?
1351
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1351
+        if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1352 1352
             // if array has more than one element then success message should be plural
1353 1353
             $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1354 1354
             // cycle thru the boxes
1355 1355
             foreach ($this->_req_data['checkbox'] as $TKT_ID) {
1356 1356
                 // delete
1357
-                if (! $this->_delete_the_ticket($TKT_ID)) {
1357
+                if ( ! $this->_delete_the_ticket($TKT_ID)) {
1358 1358
                     $success = 0;
1359 1359
                 }
1360 1360
             }
1361 1361
         } else {
1362 1362
             // grab single id and trash
1363 1363
             $TKT_ID = absint($this->_req_data['TKT_ID']);
1364
-            if (! $this->_delete_the_ticket($TKT_ID)) {
1364
+            if ( ! $this->_delete_the_ticket($TKT_ID)) {
1365 1365
                 $success = 0;
1366 1366
             }
1367 1367
         }
Please login to merge, or discard this patch.
core/domain/services/admin/events/editor/AdvancedEditorEntityData.php 2 patches
Indentation   +223 added lines, -223 removed lines patch added patch discarded remove patch
@@ -35,243 +35,243 @@
 block discarded – undo
35 35
 class AdvancedEditorEntityData
36 36
 {
37 37
 
38
-    /**
39
-     * @var RestApiSpoofer
40
-     */
41
-    protected $spoofer;
38
+	/**
39
+	 * @var RestApiSpoofer
40
+	 */
41
+	protected $spoofer;
42 42
 
43
-    /**
44
-     * @var EE_Admin_Config
45
-     */
46
-    protected $admin_config;
43
+	/**
44
+	 * @var EE_Admin_Config
45
+	 */
46
+	protected $admin_config;
47 47
 
48
-    /**
49
-     * @var EEM_Datetime $datetime_model
50
-     */
51
-    protected $datetime_model;
48
+	/**
49
+	 * @var EEM_Datetime $datetime_model
50
+	 */
51
+	protected $datetime_model;
52 52
 
53
-    /**
54
-     * @var EEM_Event $event_model
55
-     */
56
-    protected $event_model;
53
+	/**
54
+	 * @var EEM_Event $event_model
55
+	 */
56
+	protected $event_model;
57 57
 
58
-    /**
59
-     * @var EEM_Price $price_model
60
-     */
61
-    protected $price_model;
58
+	/**
59
+	 * @var EEM_Price $price_model
60
+	 */
61
+	protected $price_model;
62 62
 
63
-    /**
64
-     * @var EEM_Price_Type $price_type_model
65
-     */
66
-    protected $price_type_model;
63
+	/**
64
+	 * @var EEM_Price_Type $price_type_model
65
+	 */
66
+	protected $price_type_model;
67 67
 
68
-    /**
69
-     * @var EEM_Ticket $ticket_model
70
-     */
71
-    protected $ticket_model;
72
-    /**
73
-     * @var EEM_Venue $venue_model
74
-     */
75
-    protected $venue_model;
68
+	/**
69
+	 * @var EEM_Ticket $ticket_model
70
+	 */
71
+	protected $ticket_model;
72
+	/**
73
+	 * @var EEM_Venue $venue_model
74
+	 */
75
+	protected $venue_model;
76 76
 
77 77
 
78
-    /**
79
-     * AdvancedEditorAdminForm constructor.
80
-     *
81
-     * @param RestApiSpoofer $spoofer
82
-     * @param EE_Admin_Config $admin_config
83
-     * @param EEM_Datetime $datetime_model
84
-     * @param EEM_Event $event_model
85
-     * @param EEM_Price $price_model
86
-     * @param EEM_Price_Type $price_type_model
87
-     * @param EEM_Ticket $ticket_model
88
-     * @param EEM_Venue $venue_model
89
-     */
90
-    public function __construct(
91
-        RestApiSpoofer $spoofer,
92
-        EE_Admin_Config $admin_config,
93
-        EEM_Datetime $datetime_model,
94
-        EEM_Event $event_model,
95
-        EEM_Price $price_model,
96
-        EEM_Price_Type $price_type_model,
97
-        EEM_Ticket $ticket_model,
98
-        EEM_Venue $venue_model
99
-    ) {
100
-        $this->admin_config = $admin_config;
101
-        $this->spoofer = $spoofer;
102
-        $this->datetime_model = $datetime_model;
103
-        $this->event_model = $event_model;
104
-        $this->price_model = $price_model;
105
-        $this->price_type_model = $price_type_model;
106
-        $this->ticket_model = $ticket_model;
107
-        $this->venue_model = $venue_model;
108
-        add_action('admin_enqueue_scripts', [$this, 'loadScriptsStyles']);
109
-    }
78
+	/**
79
+	 * AdvancedEditorAdminForm constructor.
80
+	 *
81
+	 * @param RestApiSpoofer $spoofer
82
+	 * @param EE_Admin_Config $admin_config
83
+	 * @param EEM_Datetime $datetime_model
84
+	 * @param EEM_Event $event_model
85
+	 * @param EEM_Price $price_model
86
+	 * @param EEM_Price_Type $price_type_model
87
+	 * @param EEM_Ticket $ticket_model
88
+	 * @param EEM_Venue $venue_model
89
+	 */
90
+	public function __construct(
91
+		RestApiSpoofer $spoofer,
92
+		EE_Admin_Config $admin_config,
93
+		EEM_Datetime $datetime_model,
94
+		EEM_Event $event_model,
95
+		EEM_Price $price_model,
96
+		EEM_Price_Type $price_type_model,
97
+		EEM_Ticket $ticket_model,
98
+		EEM_Venue $venue_model
99
+	) {
100
+		$this->admin_config = $admin_config;
101
+		$this->spoofer = $spoofer;
102
+		$this->datetime_model = $datetime_model;
103
+		$this->event_model = $event_model;
104
+		$this->price_model = $price_model;
105
+		$this->price_type_model = $price_type_model;
106
+		$this->ticket_model = $ticket_model;
107
+		$this->venue_model = $venue_model;
108
+		add_action('admin_enqueue_scripts', [$this, 'loadScriptsStyles']);
109
+	}
110 110
 
111 111
 
112
-    /**
113
-     * @throws EE_Error
114
-     * @throws InvalidArgumentException
115
-     * @throws InvalidDataTypeException
116
-     * @throws InvalidInterfaceException
117
-     * @throws ModelConfigurationException
118
-     * @throws ReflectionException
119
-     * @throws RestException
120
-     * @throws RestPasswordIncorrectException
121
-     * @throws RestPasswordRequiredException
122
-     * @throws UnexpectedEntityException
123
-     * @throws DomainException
124
-     * @since $VID:$
125
-     */
126
-    public function loadScriptsStyles()
127
-    {
128
-        if ($this->admin_config->useAdvancedEditor()) {
129
-            global $post;
130
-            $eventId = isset($_REQUEST['post']) ? absint($_REQUEST['post']) : 0;
131
-            $eventId = $eventId === 0 && $post instanceof WP_Post ? $post->ID : $eventId;
132
-            if ($eventId) {
133
-                $data = $this->getAllEventData($eventId);
134
-                $data = wp_json_encode($data);
135
-                add_action(
136
-                    'admin_footer',
137
-                    static function () use ($data) {
138
-                        wp_add_inline_script(
139
-                            EspressoEditorAssetManager::JS_HANDLE_EDITOR,
140
-                            "var eeEditorEventData={$data};",
141
-                            'before'
142
-                        );
143
-                    }
144
-                );
145
-            }
146
-        }
147
-    }
112
+	/**
113
+	 * @throws EE_Error
114
+	 * @throws InvalidArgumentException
115
+	 * @throws InvalidDataTypeException
116
+	 * @throws InvalidInterfaceException
117
+	 * @throws ModelConfigurationException
118
+	 * @throws ReflectionException
119
+	 * @throws RestException
120
+	 * @throws RestPasswordIncorrectException
121
+	 * @throws RestPasswordRequiredException
122
+	 * @throws UnexpectedEntityException
123
+	 * @throws DomainException
124
+	 * @since $VID:$
125
+	 */
126
+	public function loadScriptsStyles()
127
+	{
128
+		if ($this->admin_config->useAdvancedEditor()) {
129
+			global $post;
130
+			$eventId = isset($_REQUEST['post']) ? absint($_REQUEST['post']) : 0;
131
+			$eventId = $eventId === 0 && $post instanceof WP_Post ? $post->ID : $eventId;
132
+			if ($eventId) {
133
+				$data = $this->getAllEventData($eventId);
134
+				$data = wp_json_encode($data);
135
+				add_action(
136
+					'admin_footer',
137
+					static function () use ($data) {
138
+						wp_add_inline_script(
139
+							EspressoEditorAssetManager::JS_HANDLE_EDITOR,
140
+							"var eeEditorEventData={$data};",
141
+							'before'
142
+						);
143
+					}
144
+				);
145
+			}
146
+		}
147
+	}
148 148
 
149 149
 
150
-    /**
151
-     * @param int $eventId
152
-     * @return array
153
-     * @throws EE_Error
154
-     * @throws InvalidDataTypeException
155
-     * @throws InvalidInterfaceException
156
-     * @throws ModelConfigurationException
157
-     * @throws RestPasswordIncorrectException
158
-     * @throws RestPasswordRequiredException
159
-     * @throws UnexpectedEntityException
160
-     * @throws RestException
161
-     * @throws InvalidArgumentException
162
-     * @throws ReflectionException
163
-     * @throws DomainException
164
-     * @since $VID:$
165
-     */
166
-    protected function getAllEventData($eventId)
167
-    {
168
-        // these should ultimately be extracted out into their own classes (one per model)
169
-        $event = $this->spoofer->getOneApiResult(
170
-            $this->event_model,
171
-            [['EVT_ID' => $eventId]]
172
-        );
173
-        if (! (is_array($event) && isset($event['EVT_ID']) && $event['EVT_ID'] === $eventId)) {
174
-            return [];
175
-        }
176
-        $event = [$eventId => $event];
177
-        $relations = [
178
-            'event' => [ $eventId => [] ],
179
-            'datetime' => [],
180
-            'ticket' => [],
181
-            'price' => [],
182
-        ];
183
-        $eventDates = $this->spoofer->getApiResults(
184
-            $this->datetime_model,
185
-            [[
186
-                'EVT_ID' => $eventId,
187
-                'DTT_deleted' => ['IN', [true, false]]
188
-            ]]
189
-        );
190
-        $relations['event'][ $eventId ]['datetime'] = [];
150
+	/**
151
+	 * @param int $eventId
152
+	 * @return array
153
+	 * @throws EE_Error
154
+	 * @throws InvalidDataTypeException
155
+	 * @throws InvalidInterfaceException
156
+	 * @throws ModelConfigurationException
157
+	 * @throws RestPasswordIncorrectException
158
+	 * @throws RestPasswordRequiredException
159
+	 * @throws UnexpectedEntityException
160
+	 * @throws RestException
161
+	 * @throws InvalidArgumentException
162
+	 * @throws ReflectionException
163
+	 * @throws DomainException
164
+	 * @since $VID:$
165
+	 */
166
+	protected function getAllEventData($eventId)
167
+	{
168
+		// these should ultimately be extracted out into their own classes (one per model)
169
+		$event = $this->spoofer->getOneApiResult(
170
+			$this->event_model,
171
+			[['EVT_ID' => $eventId]]
172
+		);
173
+		if (! (is_array($event) && isset($event['EVT_ID']) && $event['EVT_ID'] === $eventId)) {
174
+			return [];
175
+		}
176
+		$event = [$eventId => $event];
177
+		$relations = [
178
+			'event' => [ $eventId => [] ],
179
+			'datetime' => [],
180
+			'ticket' => [],
181
+			'price' => [],
182
+		];
183
+		$eventDates = $this->spoofer->getApiResults(
184
+			$this->datetime_model,
185
+			[[
186
+				'EVT_ID' => $eventId,
187
+				'DTT_deleted' => ['IN', [true, false]]
188
+			]]
189
+		);
190
+		$relations['event'][ $eventId ]['datetime'] = [];
191 191
 
192
-        $datetimes = [];
193
-        $eventDateTickets = [];
194
-        if (is_array($eventDates)) {
195
-            foreach ($eventDates as $eventDate) {
196
-                if (isset($eventDate['DTT_ID']) && $eventDate['DTT_ID']) {
197
-                    $DTT_ID = $eventDate['DTT_ID'];
198
-                    $datetimes[ $DTT_ID ] = $eventDate;
199
-                    $relations['event'][ $eventId ]['datetime'][] = $DTT_ID;
200
-                    $eventDateTickets[ $DTT_ID ] = $this->spoofer->getApiResults(
201
-                        $this->ticket_model,
202
-                        [[
203
-                            'Datetime.DTT_ID' => $DTT_ID,
204
-                            'TKT_deleted' => ['IN', [true, false]]
205
-                        ]]
206
-                    );
207
-                }
208
-            }
209
-        }
192
+		$datetimes = [];
193
+		$eventDateTickets = [];
194
+		if (is_array($eventDates)) {
195
+			foreach ($eventDates as $eventDate) {
196
+				if (isset($eventDate['DTT_ID']) && $eventDate['DTT_ID']) {
197
+					$DTT_ID = $eventDate['DTT_ID'];
198
+					$datetimes[ $DTT_ID ] = $eventDate;
199
+					$relations['event'][ $eventId ]['datetime'][] = $DTT_ID;
200
+					$eventDateTickets[ $DTT_ID ] = $this->spoofer->getApiResults(
201
+						$this->ticket_model,
202
+						[[
203
+							'Datetime.DTT_ID' => $DTT_ID,
204
+							'TKT_deleted' => ['IN', [true, false]]
205
+						]]
206
+					);
207
+				}
208
+			}
209
+		}
210 210
 
211
-        $prices = [];
212
-        $tickets = [];
213
-        if (is_array($eventDateTickets)) {
214
-            foreach ($eventDateTickets as $DTT_ID => $dateTickets) {
215
-                if (is_array($dateTickets)) {
216
-                    $relations['datetime'][ $DTT_ID ]['ticket'] = [];
217
-                    foreach ($dateTickets as $ticket) {
218
-                        if (isset($ticket['TKT_ID']) && $ticket['TKT_ID']) {
219
-                            $TKT_ID = $ticket['TKT_ID'];
220
-                            $tickets[ $TKT_ID ] = $ticket;
221
-                            $relations['datetime'][ $DTT_ID ]['ticket'][] = $TKT_ID;
222
-                            $ticketPrices[ $TKT_ID ] = $this->spoofer->getApiResults(
223
-                                $this->price_model,
224
-                                [['Ticket.TKT_ID' => $TKT_ID]]
225
-                            );
226
-                            if (is_array($ticketPrices[ $TKT_ID ])) {
227
-                                $relations['ticket'][ $TKT_ID ]['price'] = [];
228
-                                foreach ($ticketPrices[ $TKT_ID ] as $ticketPrice) {
229
-                                    $PRC_ID = $ticketPrice['PRC_ID'];
230
-                                    $prices[ $PRC_ID ] = $ticketPrice;
231
-                                    $relations['ticket'][ $TKT_ID ]['price'][] = $PRC_ID;
232
-                                }
233
-                            }
234
-                        }
235
-                    }
236
-                }
237
-            }
238
-        }
239
-        $price_type_results = $this->spoofer->getApiResults(
240
-            $this->price_type_model,
241
-            [['PRT_deleted' => false]]
242
-        );
243
-        $price_types = [];
244
-        foreach ($price_type_results as $price_type) {
245
-            $price_types[ $price_type['PRT_ID'] ] = $price_type;
246
-        }
247
-        $venue = $this->spoofer->getOneApiResult(
248
-            $this->venue_model,
249
-            [['Event.EVT_ID' => $eventId]]
250
-        );
251
-        if (is_array($venue) && isset($venue['VNU_ID'])) {
252
-            $relations['event'][ $eventId ]['venue'] = [ $venue['VNU_ID'] ];
253
-            $venue = [$venue['VNU_ID'] => $venue];
254
-        }
211
+		$prices = [];
212
+		$tickets = [];
213
+		if (is_array($eventDateTickets)) {
214
+			foreach ($eventDateTickets as $DTT_ID => $dateTickets) {
215
+				if (is_array($dateTickets)) {
216
+					$relations['datetime'][ $DTT_ID ]['ticket'] = [];
217
+					foreach ($dateTickets as $ticket) {
218
+						if (isset($ticket['TKT_ID']) && $ticket['TKT_ID']) {
219
+							$TKT_ID = $ticket['TKT_ID'];
220
+							$tickets[ $TKT_ID ] = $ticket;
221
+							$relations['datetime'][ $DTT_ID ]['ticket'][] = $TKT_ID;
222
+							$ticketPrices[ $TKT_ID ] = $this->spoofer->getApiResults(
223
+								$this->price_model,
224
+								[['Ticket.TKT_ID' => $TKT_ID]]
225
+							);
226
+							if (is_array($ticketPrices[ $TKT_ID ])) {
227
+								$relations['ticket'][ $TKT_ID ]['price'] = [];
228
+								foreach ($ticketPrices[ $TKT_ID ] as $ticketPrice) {
229
+									$PRC_ID = $ticketPrice['PRC_ID'];
230
+									$prices[ $PRC_ID ] = $ticketPrice;
231
+									$relations['ticket'][ $TKT_ID ]['price'][] = $PRC_ID;
232
+								}
233
+							}
234
+						}
235
+					}
236
+				}
237
+			}
238
+		}
239
+		$price_type_results = $this->spoofer->getApiResults(
240
+			$this->price_type_model,
241
+			[['PRT_deleted' => false]]
242
+		);
243
+		$price_types = [];
244
+		foreach ($price_type_results as $price_type) {
245
+			$price_types[ $price_type['PRT_ID'] ] = $price_type;
246
+		}
247
+		$venue = $this->spoofer->getOneApiResult(
248
+			$this->venue_model,
249
+			[['Event.EVT_ID' => $eventId]]
250
+		);
251
+		if (is_array($venue) && isset($venue['VNU_ID'])) {
252
+			$relations['event'][ $eventId ]['venue'] = [ $venue['VNU_ID'] ];
253
+			$venue = [$venue['VNU_ID'] => $venue];
254
+		}
255 255
 
256
-        $schemas = [
257
-            'event'      => $this->spoofer->getModelSchema('events'),
258
-            'datetime'   => $this->spoofer->getModelSchema('datetimes'),
259
-            'ticket'     => $this->spoofer->getModelSchema('tickets'),
260
-            'price'      => $this->spoofer->getModelSchema('prices'),
261
-            'price_type' => $this->spoofer->getModelSchema('price_types'),
262
-            'venue'      => $this->spoofer->getModelSchema('venues'),
263
-        ];
256
+		$schemas = [
257
+			'event'      => $this->spoofer->getModelSchema('events'),
258
+			'datetime'   => $this->spoofer->getModelSchema('datetimes'),
259
+			'ticket'     => $this->spoofer->getModelSchema('tickets'),
260
+			'price'      => $this->spoofer->getModelSchema('prices'),
261
+			'price_type' => $this->spoofer->getModelSchema('price_types'),
262
+			'venue'      => $this->spoofer->getModelSchema('venues'),
263
+		];
264 264
 
265
-        return [
266
-            'eventId'    => $eventId,
267
-            'event'      => $event,
268
-            'datetime'   => $datetimes,
269
-            'ticket'     => $tickets,
270
-            'price'      => $prices,
271
-            'price_type' => $price_types,
272
-            'venue'      => $venue,
273
-            'schemas'    => $schemas,
274
-            'relations'  => $relations,
275
-        ];
276
-    }
265
+		return [
266
+			'eventId'    => $eventId,
267
+			'event'      => $event,
268
+			'datetime'   => $datetimes,
269
+			'ticket'     => $tickets,
270
+			'price'      => $prices,
271
+			'price_type' => $price_types,
272
+			'venue'      => $venue,
273
+			'schemas'    => $schemas,
274
+			'relations'  => $relations,
275
+		];
276
+	}
277 277
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
                 $data = wp_json_encode($data);
135 135
                 add_action(
136 136
                     'admin_footer',
137
-                    static function () use ($data) {
137
+                    static function() use ($data) {
138 138
                         wp_add_inline_script(
139 139
                             EspressoEditorAssetManager::JS_HANDLE_EDITOR,
140 140
                             "var eeEditorEventData={$data};",
@@ -170,12 +170,12 @@  discard block
 block discarded – undo
170 170
             $this->event_model,
171 171
             [['EVT_ID' => $eventId]]
172 172
         );
173
-        if (! (is_array($event) && isset($event['EVT_ID']) && $event['EVT_ID'] === $eventId)) {
173
+        if ( ! (is_array($event) && isset($event['EVT_ID']) && $event['EVT_ID'] === $eventId)) {
174 174
             return [];
175 175
         }
176 176
         $event = [$eventId => $event];
177 177
         $relations = [
178
-            'event' => [ $eventId => [] ],
178
+            'event' => [$eventId => []],
179 179
             'datetime' => [],
180 180
             'ticket' => [],
181 181
             'price' => [],
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
                 'DTT_deleted' => ['IN', [true, false]]
188 188
             ]]
189 189
         );
190
-        $relations['event'][ $eventId ]['datetime'] = [];
190
+        $relations['event'][$eventId]['datetime'] = [];
191 191
 
192 192
         $datetimes = [];
193 193
         $eventDateTickets = [];
@@ -195,9 +195,9 @@  discard block
 block discarded – undo
195 195
             foreach ($eventDates as $eventDate) {
196 196
                 if (isset($eventDate['DTT_ID']) && $eventDate['DTT_ID']) {
197 197
                     $DTT_ID = $eventDate['DTT_ID'];
198
-                    $datetimes[ $DTT_ID ] = $eventDate;
199
-                    $relations['event'][ $eventId ]['datetime'][] = $DTT_ID;
200
-                    $eventDateTickets[ $DTT_ID ] = $this->spoofer->getApiResults(
198
+                    $datetimes[$DTT_ID] = $eventDate;
199
+                    $relations['event'][$eventId]['datetime'][] = $DTT_ID;
200
+                    $eventDateTickets[$DTT_ID] = $this->spoofer->getApiResults(
201 201
                         $this->ticket_model,
202 202
                         [[
203 203
                             'Datetime.DTT_ID' => $DTT_ID,
@@ -213,22 +213,22 @@  discard block
 block discarded – undo
213 213
         if (is_array($eventDateTickets)) {
214 214
             foreach ($eventDateTickets as $DTT_ID => $dateTickets) {
215 215
                 if (is_array($dateTickets)) {
216
-                    $relations['datetime'][ $DTT_ID ]['ticket'] = [];
216
+                    $relations['datetime'][$DTT_ID]['ticket'] = [];
217 217
                     foreach ($dateTickets as $ticket) {
218 218
                         if (isset($ticket['TKT_ID']) && $ticket['TKT_ID']) {
219 219
                             $TKT_ID = $ticket['TKT_ID'];
220
-                            $tickets[ $TKT_ID ] = $ticket;
221
-                            $relations['datetime'][ $DTT_ID ]['ticket'][] = $TKT_ID;
222
-                            $ticketPrices[ $TKT_ID ] = $this->spoofer->getApiResults(
220
+                            $tickets[$TKT_ID] = $ticket;
221
+                            $relations['datetime'][$DTT_ID]['ticket'][] = $TKT_ID;
222
+                            $ticketPrices[$TKT_ID] = $this->spoofer->getApiResults(
223 223
                                 $this->price_model,
224 224
                                 [['Ticket.TKT_ID' => $TKT_ID]]
225 225
                             );
226
-                            if (is_array($ticketPrices[ $TKT_ID ])) {
227
-                                $relations['ticket'][ $TKT_ID ]['price'] = [];
228
-                                foreach ($ticketPrices[ $TKT_ID ] as $ticketPrice) {
226
+                            if (is_array($ticketPrices[$TKT_ID])) {
227
+                                $relations['ticket'][$TKT_ID]['price'] = [];
228
+                                foreach ($ticketPrices[$TKT_ID] as $ticketPrice) {
229 229
                                     $PRC_ID = $ticketPrice['PRC_ID'];
230
-                                    $prices[ $PRC_ID ] = $ticketPrice;
231
-                                    $relations['ticket'][ $TKT_ID ]['price'][] = $PRC_ID;
230
+                                    $prices[$PRC_ID] = $ticketPrice;
231
+                                    $relations['ticket'][$TKT_ID]['price'][] = $PRC_ID;
232 232
                                 }
233 233
                             }
234 234
                         }
@@ -242,14 +242,14 @@  discard block
 block discarded – undo
242 242
         );
243 243
         $price_types = [];
244 244
         foreach ($price_type_results as $price_type) {
245
-            $price_types[ $price_type['PRT_ID'] ] = $price_type;
245
+            $price_types[$price_type['PRT_ID']] = $price_type;
246 246
         }
247 247
         $venue = $this->spoofer->getOneApiResult(
248 248
             $this->venue_model,
249 249
             [['Event.EVT_ID' => $eventId]]
250 250
         );
251 251
         if (is_array($venue) && isset($venue['VNU_ID'])) {
252
-            $relations['event'][ $eventId ]['venue'] = [ $venue['VNU_ID'] ];
252
+            $relations['event'][$eventId]['venue'] = [$venue['VNU_ID']];
253 253
             $venue = [$venue['VNU_ID'] => $venue];
254 254
         }
255 255
 
Please login to merge, or discard this patch.
core/domain/services/converters/RestApiSpoofer.php 2 patches
Indentation   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -49,134 +49,134 @@
 block discarded – undo
49 49
 class RestApiSpoofer
50 50
 {
51 51
 
52
-    /**
53
-     * @var WP_REST_Server $wp_rest_server
54
-     */
55
-    protected $wp_rest_server;
52
+	/**
53
+	 * @var WP_REST_Server $wp_rest_server
54
+	 */
55
+	protected $wp_rest_server;
56 56
 
57
-    /**
58
-     * @var Read
59
-     */
60
-    protected $rest_controller;
57
+	/**
58
+	 * @var Read
59
+	 */
60
+	protected $rest_controller;
61 61
 
62
-    /**
63
-     * @var EED_Core_Rest_Api $rest_module
64
-     */
65
-    protected $rest_module;
62
+	/**
63
+	 * @var EED_Core_Rest_Api $rest_module
64
+	 */
65
+	protected $rest_module;
66 66
 
67 67
 
68
-    /**
69
-     * RestApiSpoofer constructor.
70
-     *
71
-     * @param WP_REST_Server        $wp_rest_server
72
-     * @param EED_Core_Rest_Api $rest_module
73
-     * @param Read                  $rest_api
74
-     * @param string                $api_version
75
-     */
76
-    public function __construct(
77
-        WP_REST_Server $wp_rest_server,
78
-        EED_Core_Rest_Api $rest_module,
79
-        Read $rest_api,
80
-        $api_version = '4.8.36'
81
-    ) {
82
-        $this->wp_rest_server = $wp_rest_server;
83
-        $this->rest_module = $rest_module;
84
-        $this->rest_controller = $rest_api;
85
-        $this->rest_controller->setRequestedVersion($api_version);
86
-        $this->setUpRestServer();
87
-    }
68
+	/**
69
+	 * RestApiSpoofer constructor.
70
+	 *
71
+	 * @param WP_REST_Server        $wp_rest_server
72
+	 * @param EED_Core_Rest_Api $rest_module
73
+	 * @param Read                  $rest_api
74
+	 * @param string                $api_version
75
+	 */
76
+	public function __construct(
77
+		WP_REST_Server $wp_rest_server,
78
+		EED_Core_Rest_Api $rest_module,
79
+		Read $rest_api,
80
+		$api_version = '4.8.36'
81
+	) {
82
+		$this->wp_rest_server = $wp_rest_server;
83
+		$this->rest_module = $rest_module;
84
+		$this->rest_controller = $rest_api;
85
+		$this->rest_controller->setRequestedVersion($api_version);
86
+		$this->setUpRestServer();
87
+	}
88 88
 
89 89
 
90
-    private function setUpRestServer()
91
-    {
92
-        /* @var WP_REST_Server $wp_rest_server */
93
-        global $wp_rest_server;
94
-        $wp_rest_server = $this->wp_rest_server;
95
-        EED_Core_Rest_Api::set_hooks_both();
96
-        do_action('rest_api_init', $this->wp_rest_server);
97
-    }
90
+	private function setUpRestServer()
91
+	{
92
+		/* @var WP_REST_Server $wp_rest_server */
93
+		global $wp_rest_server;
94
+		$wp_rest_server = $this->wp_rest_server;
95
+		EED_Core_Rest_Api::set_hooks_both();
96
+		do_action('rest_api_init', $this->wp_rest_server);
97
+	}
98 98
 
99
-    /**
100
-     * @param EEM_Base $model
101
-     * @param array    $query_params
102
-     * @param string   $include
103
-     * @return array
104
-     * @throws EE_Error
105
-     * @throws InvalidArgumentException
106
-     * @throws InvalidDataTypeException
107
-     * @throws InvalidInterfaceException
108
-     * @throws ModelConfigurationException
109
-     * @throws ReflectionException
110
-     * @throws RestException
111
-     * @throws RestPasswordIncorrectException
112
-     * @throws RestPasswordRequiredException
113
-     * @throws UnexpectedEntityException
114
-     * @throws DomainException
115
-     * @since $VID:$
116
-     */
117
-    public function getOneApiResult(EEM_Base $model, array $query_params, $include = '')
118
-    {
119
-        if (! array_key_exists('limit', $query_params)) {
120
-            $query_params['limit'] = 1;
121
-        }
122
-        $result = $this->getApiResults($model, $query_params, $include);
123
-        return is_array($result) && isset($result[0]) ? $result[0] : [];
124
-    }
99
+	/**
100
+	 * @param EEM_Base $model
101
+	 * @param array    $query_params
102
+	 * @param string   $include
103
+	 * @return array
104
+	 * @throws EE_Error
105
+	 * @throws InvalidArgumentException
106
+	 * @throws InvalidDataTypeException
107
+	 * @throws InvalidInterfaceException
108
+	 * @throws ModelConfigurationException
109
+	 * @throws ReflectionException
110
+	 * @throws RestException
111
+	 * @throws RestPasswordIncorrectException
112
+	 * @throws RestPasswordRequiredException
113
+	 * @throws UnexpectedEntityException
114
+	 * @throws DomainException
115
+	 * @since $VID:$
116
+	 */
117
+	public function getOneApiResult(EEM_Base $model, array $query_params, $include = '')
118
+	{
119
+		if (! array_key_exists('limit', $query_params)) {
120
+			$query_params['limit'] = 1;
121
+		}
122
+		$result = $this->getApiResults($model, $query_params, $include);
123
+		return is_array($result) && isset($result[0]) ? $result[0] : [];
124
+	}
125 125
 
126
-    /**
127
-     * @param EEM_Base $model
128
-     * @param array    $query_params
129
-     * @param string   $include
130
-     * @return array
131
-     * @throws EE_Error
132
-     * @throws InvalidArgumentException
133
-     * @throws InvalidDataTypeException
134
-     * @throws InvalidInterfaceException
135
-     * @throws ModelConfigurationException
136
-     * @throws ReflectionException
137
-     * @throws RestException
138
-     * @throws RestPasswordIncorrectException
139
-     * @throws RestPasswordRequiredException
140
-     * @throws UnexpectedEntityException
141
-     * @throws DomainException
142
-     * @since $VID:$
143
-     */
144
-    public function getApiResults(EEM_Base $model, array $query_params, $include = '')
145
-    {
146
-        if (! array_key_exists('caps', $query_params)) {
147
-            $query_params['caps'] = EEM_Base::caps_read_admin;
148
-        }
149
-        /** @type array $results */
150
-        $results = $model->get_all_wpdb_results($query_params);
151
-        $rest_request = new WP_REST_Request();
152
-        $rest_request->set_param('include', $include);
153
-        $rest_request->set_param('caps', 'edit');
154
-        $nice_results = array();
155
-        foreach ($results as $result) {
156
-            $nice_results[] = $this->rest_controller->createEntityFromWpdbResult(
157
-                $model,
158
-                $result,
159
-                $rest_request
160
-            );
161
-        }
162
-        return $nice_results;
163
-    }
126
+	/**
127
+	 * @param EEM_Base $model
128
+	 * @param array    $query_params
129
+	 * @param string   $include
130
+	 * @return array
131
+	 * @throws EE_Error
132
+	 * @throws InvalidArgumentException
133
+	 * @throws InvalidDataTypeException
134
+	 * @throws InvalidInterfaceException
135
+	 * @throws ModelConfigurationException
136
+	 * @throws ReflectionException
137
+	 * @throws RestException
138
+	 * @throws RestPasswordIncorrectException
139
+	 * @throws RestPasswordRequiredException
140
+	 * @throws UnexpectedEntityException
141
+	 * @throws DomainException
142
+	 * @since $VID:$
143
+	 */
144
+	public function getApiResults(EEM_Base $model, array $query_params, $include = '')
145
+	{
146
+		if (! array_key_exists('caps', $query_params)) {
147
+			$query_params['caps'] = EEM_Base::caps_read_admin;
148
+		}
149
+		/** @type array $results */
150
+		$results = $model->get_all_wpdb_results($query_params);
151
+		$rest_request = new WP_REST_Request();
152
+		$rest_request->set_param('include', $include);
153
+		$rest_request->set_param('caps', 'edit');
154
+		$nice_results = array();
155
+		foreach ($results as $result) {
156
+			$nice_results[] = $this->rest_controller->createEntityFromWpdbResult(
157
+				$model,
158
+				$result,
159
+				$rest_request
160
+			);
161
+		}
162
+		return $nice_results;
163
+	}
164 164
 
165 165
 
166
-    /**
167
-     * @param string $endpoint
168
-     * @return array
169
-     * @throws EE_Error
170
-     * @since $VID:$
171
-     */
172
-    public function getModelSchema($endpoint)
173
-    {
174
-        $response = $this->wp_rest_server->dispatch(
175
-            new WP_REST_Request(
176
-                'OPTIONS',
177
-                "/ee/v4.8.36/{$endpoint}"
178
-            )
179
-        );
180
-        return $response->get_data();
181
-    }
166
+	/**
167
+	 * @param string $endpoint
168
+	 * @return array
169
+	 * @throws EE_Error
170
+	 * @since $VID:$
171
+	 */
172
+	public function getModelSchema($endpoint)
173
+	{
174
+		$response = $this->wp_rest_server->dispatch(
175
+			new WP_REST_Request(
176
+				'OPTIONS',
177
+				"/ee/v4.8.36/{$endpoint}"
178
+			)
179
+		);
180
+		return $response->get_data();
181
+	}
182 182
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
      */
117 117
     public function getOneApiResult(EEM_Base $model, array $query_params, $include = '')
118 118
     {
119
-        if (! array_key_exists('limit', $query_params)) {
119
+        if ( ! array_key_exists('limit', $query_params)) {
120 120
             $query_params['limit'] = 1;
121 121
         }
122 122
         $result = $this->getApiResults($model, $query_params, $include);
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
      */
144 144
     public function getApiResults(EEM_Base $model, array $query_params, $include = '')
145 145
     {
146
-        if (! array_key_exists('caps', $query_params)) {
146
+        if ( ! array_key_exists('caps', $query_params)) {
147 147
             $query_params['caps'] = EEM_Base::caps_read_admin;
148 148
         }
149 149
         /** @type array $results */
Please login to merge, or discard this patch.
core/entities/models/JsonModelSchema.php 1 patch
Indentation   +235 added lines, -235 removed lines patch added patch discarded remove patch
@@ -25,256 +25,256 @@
 block discarded – undo
25 25
 class JsonModelSchema
26 26
 {
27 27
 
28
-    /**
29
-     * @var EEM_Base
30
-     */
31
-    protected $model;
28
+	/**
29
+	 * @var EEM_Base
30
+	 */
31
+	protected $model;
32 32
 
33
-    /**
34
-     * @var CalculatedModelFields
35
-     */
36
-    protected $fields_calculator;
33
+	/**
34
+	 * @var CalculatedModelFields
35
+	 */
36
+	protected $fields_calculator;
37 37
 
38 38
 
39
-    /**
40
-     * JsonModelSchema constructor.
41
-     *
42
-     * @param EEM_Base              $model
43
-     * @param CalculatedModelFields $fields_calculator
44
-     */
45
-    public function __construct(EEM_Base $model, CalculatedModelFields $fields_calculator)
46
-    {
47
-        $this->model = $model;
48
-        $this->fields_calculator = $fields_calculator;
49
-    }
39
+	/**
40
+	 * JsonModelSchema constructor.
41
+	 *
42
+	 * @param EEM_Base              $model
43
+	 * @param CalculatedModelFields $fields_calculator
44
+	 */
45
+	public function __construct(EEM_Base $model, CalculatedModelFields $fields_calculator)
46
+	{
47
+		$this->model = $model;
48
+		$this->fields_calculator = $fields_calculator;
49
+	}
50 50
 
51 51
 
52
-    /**
53
-     * Return the schema for a given model from a given model.
54
-     *
55
-     * @return array
56
-     */
57
-    public function getModelSchema()
58
-    {
59
-        return $this->getModelSchemaForRelations(
60
-            $this->model->relation_settings(),
61
-            $this->getModelSchemaForFields(
62
-                $this->model->field_settings(),
63
-                $this->getInitialSchemaStructure()
64
-            )
65
-        );
66
-    }
52
+	/**
53
+	 * Return the schema for a given model from a given model.
54
+	 *
55
+	 * @return array
56
+	 */
57
+	public function getModelSchema()
58
+	{
59
+		return $this->getModelSchemaForRelations(
60
+			$this->model->relation_settings(),
61
+			$this->getModelSchemaForFields(
62
+				$this->model->field_settings(),
63
+				$this->getInitialSchemaStructure()
64
+			)
65
+		);
66
+	}
67 67
 
68 68
 
69
-    /**
70
-     * Get the schema for a given set of model fields.
71
-     *
72
-     * @param EE_Model_Field_Base[] $model_fields
73
-     * @param array                  $schema
74
-     * @return array
75
-     */
76
-    public function getModelSchemaForFields(array $model_fields, array $schema)
77
-    {
78
-        foreach ($model_fields as $field => $model_field) {
79
-            if (! $model_field instanceof EE_Model_Field_Base) {
80
-                continue;
81
-            }
82
-            $schema['properties'][ $field ] = $model_field->getSchema();
69
+	/**
70
+	 * Get the schema for a given set of model fields.
71
+	 *
72
+	 * @param EE_Model_Field_Base[] $model_fields
73
+	 * @param array                  $schema
74
+	 * @return array
75
+	 */
76
+	public function getModelSchemaForFields(array $model_fields, array $schema)
77
+	{
78
+		foreach ($model_fields as $field => $model_field) {
79
+			if (! $model_field instanceof EE_Model_Field_Base) {
80
+				continue;
81
+			}
82
+			$schema['properties'][ $field ] = $model_field->getSchema();
83 83
 
84
-            // if this is a primary key field add the primary key item
85
-            if ($model_field instanceof EE_Primary_Key_Field_Base) {
86
-                $schema['properties'][ $field ]['primary_key'] = true;
87
-                if ($model_field instanceof EE_Primary_Key_Int_Field) {
88
-                    $schema['properties'][ $field ]['readonly'] = true;
89
-                }
90
-            }
84
+			// if this is a primary key field add the primary key item
85
+			if ($model_field instanceof EE_Primary_Key_Field_Base) {
86
+				$schema['properties'][ $field ]['primary_key'] = true;
87
+				if ($model_field instanceof EE_Primary_Key_Int_Field) {
88
+					$schema['properties'][ $field ]['readonly'] = true;
89
+				}
90
+			}
91 91
 
92
-            // if this is a foreign key field add the foreign key item
93
-            if ($model_field instanceof EE_Foreign_Key_Field_Base) {
94
-                $schema['properties'][ $field ]['foreign_key'] = array(
95
-                    'description' => esc_html__(
96
-                        'This is a foreign key the points to the given models.',
97
-                        'event_espresso'
98
-                    ),
99
-                    'type'        => 'array',
100
-                    'enum'        => $model_field->get_model_class_names_pointed_to(),
101
-                );
102
-            }
103
-        }
104
-        return $schema;
105
-    }
92
+			// if this is a foreign key field add the foreign key item
93
+			if ($model_field instanceof EE_Foreign_Key_Field_Base) {
94
+				$schema['properties'][ $field ]['foreign_key'] = array(
95
+					'description' => esc_html__(
96
+						'This is a foreign key the points to the given models.',
97
+						'event_espresso'
98
+					),
99
+					'type'        => 'array',
100
+					'enum'        => $model_field->get_model_class_names_pointed_to(),
101
+				);
102
+			}
103
+		}
104
+		return $schema;
105
+	}
106 106
 
107 107
 
108
-    /**
109
-     * Get the schema for a given set of model relations
110
-     *
111
-     * @param EE_Model_Relation_Base[] $relations_on_model
112
-     * @param array                    $schema
113
-     * @return array
114
-     */
115
-    public function getModelSchemaForRelations(array $relations_on_model, array $schema)
116
-    {
117
-        foreach ($relations_on_model as $model_name => $relation) {
118
-            if (! $relation instanceof EE_Model_Relation_Base) {
119
-                continue;
120
-            }
121
-            $model_name_for_schema = $relation instanceof EE_Belongs_To_Relation
122
-                ? strtolower($model_name)
123
-                : EEH_Inflector::pluralize_and_lower($model_name);
124
-            $schema['properties'][ $model_name_for_schema ] = $relation->getSchema();
125
-            $schema['properties'][ $model_name_for_schema ]['relation_model'] = $model_name;
108
+	/**
109
+	 * Get the schema for a given set of model relations
110
+	 *
111
+	 * @param EE_Model_Relation_Base[] $relations_on_model
112
+	 * @param array                    $schema
113
+	 * @return array
114
+	 */
115
+	public function getModelSchemaForRelations(array $relations_on_model, array $schema)
116
+	{
117
+		foreach ($relations_on_model as $model_name => $relation) {
118
+			if (! $relation instanceof EE_Model_Relation_Base) {
119
+				continue;
120
+			}
121
+			$model_name_for_schema = $relation instanceof EE_Belongs_To_Relation
122
+				? strtolower($model_name)
123
+				: EEH_Inflector::pluralize_and_lower($model_name);
124
+			$schema['properties'][ $model_name_for_schema ] = $relation->getSchema();
125
+			$schema['properties'][ $model_name_for_schema ]['relation_model'] = $model_name;
126 126
 
127
-            // links schema
128
-            $links_key = 'https://api.eventespresso.com/' . strtolower($model_name);
129
-            $schema['properties']['_links']['properties'][ $links_key ] = array(
130
-                'description' => esc_html__(
131
-                    'Array of objects describing the link(s) for this relation resource.',
132
-                    'event_espresso'
133
-                ),
134
-                'type' => 'array',
135
-                'readonly' => true,
136
-                'items' => array(
137
-                    'type' => 'object',
138
-                    'properties' => array(
139
-                        'href' => array(
140
-                            'type' => 'string',
141
-                            'description' => sprintf(
142
-                                // translators: placeholder is the model name for the relation.
143
-                                esc_html__(
144
-                                    'The link to the resource for the %s relation(s) to this entity',
145
-                                    'event_espresso'
146
-                                ),
147
-                                $model_name
148
-                            ),
149
-                        ),
150
-                        'single' => array(
151
-                            'type' => 'boolean',
152
-                            'description' => sprintf(
153
-                                // translators: placeholder is the model name for the relation.
154
-                                esc_html__(
155
-                                    'Whether or not there is only a single %s relation to this entity',
156
-                                    'event_espresso'
157
-                                ),
158
-                                $model_name
159
-                            ),
160
-                        ),
161
-                    ),
162
-                    'additionalProperties' => false
163
-                ),
164
-            );
165
-        }
166
-        return $schema;
167
-    }
127
+			// links schema
128
+			$links_key = 'https://api.eventespresso.com/' . strtolower($model_name);
129
+			$schema['properties']['_links']['properties'][ $links_key ] = array(
130
+				'description' => esc_html__(
131
+					'Array of objects describing the link(s) for this relation resource.',
132
+					'event_espresso'
133
+				),
134
+				'type' => 'array',
135
+				'readonly' => true,
136
+				'items' => array(
137
+					'type' => 'object',
138
+					'properties' => array(
139
+						'href' => array(
140
+							'type' => 'string',
141
+							'description' => sprintf(
142
+								// translators: placeholder is the model name for the relation.
143
+								esc_html__(
144
+									'The link to the resource for the %s relation(s) to this entity',
145
+									'event_espresso'
146
+								),
147
+								$model_name
148
+							),
149
+						),
150
+						'single' => array(
151
+							'type' => 'boolean',
152
+							'description' => sprintf(
153
+								// translators: placeholder is the model name for the relation.
154
+								esc_html__(
155
+									'Whether or not there is only a single %s relation to this entity',
156
+									'event_espresso'
157
+								),
158
+								$model_name
159
+							),
160
+						),
161
+					),
162
+					'additionalProperties' => false
163
+				),
164
+			);
165
+		}
166
+		return $schema;
167
+	}
168 168
 
169 169
 
170
-    /**
171
-     * Outputs the schema header for a model.
172
-     *
173
-     * @return array
174
-     */
175
-    public function getInitialSchemaStructure()
176
-    {
177
-        return array(
178
-            '$schema'    => 'http://json-schema.org/draft-04/schema#',
179
-            'title'      => $this->model->get_this_model_name(),
180
-            'type'       => 'object',
181
-            'properties' => array(
182
-                'link' => array(
183
-                    'description' => esc_html__(
184
-                        'Link to event on WordPress site hosting events.',
185
-                        'event_espresso'
186
-                    ),
187
-                    'type' => 'string',
188
-                    'readonly' => true,
189
-                ),
190
-                '_links' => array(
191
-                    'description' => esc_html__(
192
-                        'Various links for resources related to the entity.',
193
-                        'event_espresso'
194
-                    ),
195
-                    'type' => 'object',
196
-                    'readonly' => true,
197
-                    'properties' => array(
198
-                        'self' => array(
199
-                            'description' => esc_html__(
200
-                                'Link to this entities resource.',
201
-                                'event_espresso'
202
-                            ),
203
-                            'type' => 'array',
204
-                            'items' => array(
205
-                                'type' => 'object',
206
-                                'properties' => array(
207
-                                    'href' => array(
208
-                                        'type' => 'string',
209
-                                    ),
210
-                                ),
211
-                                'additionalProperties' => false
212
-                            ),
213
-                            'readonly' => true
214
-                        ),
215
-                        'collection' => array(
216
-                            'description' => esc_html__(
217
-                                'Link to this entities collection resource.',
218
-                                'event_espresso'
219
-                            ),
220
-                            'type' => 'array',
221
-                            'items' => array(
222
-                                'type' => 'object',
223
-                                'properties' => array(
224
-                                    'href' => array(
225
-                                        'type' => 'string'
226
-                                    ),
227
-                                ),
228
-                                'additionalProperties' => false
229
-                            ),
230
-                            'readonly' => true
231
-                        ),
232
-                    ),
233
-                    'additionalProperties' => false,
234
-                ),
235
-                '_calculated_fields' => array_merge(
236
-                    $this->fields_calculator->getJsonSchemaForModel($this->model),
237
-                    array(
238
-                        '_protected' => $this->getProtectedFieldsSchema()
239
-                    )
240
-                ),
241
-                '_protected' => $this->getProtectedFieldsSchema()
242
-            ),
243
-            'additionalProperties' => false,
244
-        );
245
-    }
170
+	/**
171
+	 * Outputs the schema header for a model.
172
+	 *
173
+	 * @return array
174
+	 */
175
+	public function getInitialSchemaStructure()
176
+	{
177
+		return array(
178
+			'$schema'    => 'http://json-schema.org/draft-04/schema#',
179
+			'title'      => $this->model->get_this_model_name(),
180
+			'type'       => 'object',
181
+			'properties' => array(
182
+				'link' => array(
183
+					'description' => esc_html__(
184
+						'Link to event on WordPress site hosting events.',
185
+						'event_espresso'
186
+					),
187
+					'type' => 'string',
188
+					'readonly' => true,
189
+				),
190
+				'_links' => array(
191
+					'description' => esc_html__(
192
+						'Various links for resources related to the entity.',
193
+						'event_espresso'
194
+					),
195
+					'type' => 'object',
196
+					'readonly' => true,
197
+					'properties' => array(
198
+						'self' => array(
199
+							'description' => esc_html__(
200
+								'Link to this entities resource.',
201
+								'event_espresso'
202
+							),
203
+							'type' => 'array',
204
+							'items' => array(
205
+								'type' => 'object',
206
+								'properties' => array(
207
+									'href' => array(
208
+										'type' => 'string',
209
+									),
210
+								),
211
+								'additionalProperties' => false
212
+							),
213
+							'readonly' => true
214
+						),
215
+						'collection' => array(
216
+							'description' => esc_html__(
217
+								'Link to this entities collection resource.',
218
+								'event_espresso'
219
+							),
220
+							'type' => 'array',
221
+							'items' => array(
222
+								'type' => 'object',
223
+								'properties' => array(
224
+									'href' => array(
225
+										'type' => 'string'
226
+									),
227
+								),
228
+								'additionalProperties' => false
229
+							),
230
+							'readonly' => true
231
+						),
232
+					),
233
+					'additionalProperties' => false,
234
+				),
235
+				'_calculated_fields' => array_merge(
236
+					$this->fields_calculator->getJsonSchemaForModel($this->model),
237
+					array(
238
+						'_protected' => $this->getProtectedFieldsSchema()
239
+					)
240
+				),
241
+				'_protected' => $this->getProtectedFieldsSchema()
242
+			),
243
+			'additionalProperties' => false,
244
+		);
245
+	}
246 246
 
247
-    /**
248
-     * Returns an array of JSON schema to describe the _protected property on responses
249
-     * @since 4.9.74.p
250
-     * @return array
251
-     */
252
-    protected function getProtectedFieldsSchema()
253
-    {
254
-        return array(
255
-            'description' => esc_html__('Array of property names whose values were replaced with their default (because they are related to a password-protected entity.)', 'event_espresso'),
256
-            'type' => 'array',
257
-            'items' => array(
258
-                'description' => esc_html__('Each name corresponds to a property that is protected by password for this entity and has its default value returned in the response.', 'event_espresso'),
259
-                'type' => 'string',
260
-                'readonly' => true,
261
-            ),
262
-            'readonly' => true
263
-        );
264
-    }
247
+	/**
248
+	 * Returns an array of JSON schema to describe the _protected property on responses
249
+	 * @since 4.9.74.p
250
+	 * @return array
251
+	 */
252
+	protected function getProtectedFieldsSchema()
253
+	{
254
+		return array(
255
+			'description' => esc_html__('Array of property names whose values were replaced with their default (because they are related to a password-protected entity.)', 'event_espresso'),
256
+			'type' => 'array',
257
+			'items' => array(
258
+				'description' => esc_html__('Each name corresponds to a property that is protected by password for this entity and has its default value returned in the response.', 'event_espresso'),
259
+				'type' => 'string',
260
+				'readonly' => true,
261
+			),
262
+			'readonly' => true
263
+		);
264
+	}
265 265
 
266 266
 
267
-    /**
268
-     * Allows one to just use the object as a string to get the json.
269
-     * eg.
270
-     * $json_schema = new JsonModelSchema(EEM_Event::instance(), new CalculatedModelFields);
271
-     * echo $json_schema; //outputs the schema as a json formatted string.
272
-     *
273
-     * @return string
274
-     */
275
-    public function __toString()
276
-    {
277
-        $schema = wp_json_encode($this->getModelSchema());
278
-        return is_string($schema) ? $schema : '';
279
-    }
267
+	/**
268
+	 * Allows one to just use the object as a string to get the json.
269
+	 * eg.
270
+	 * $json_schema = new JsonModelSchema(EEM_Event::instance(), new CalculatedModelFields);
271
+	 * echo $json_schema; //outputs the schema as a json formatted string.
272
+	 *
273
+	 * @return string
274
+	 */
275
+	public function __toString()
276
+	{
277
+		$schema = wp_json_encode($this->getModelSchema());
278
+		return is_string($schema) ? $schema : '';
279
+	}
280 280
 }
Please login to merge, or discard this patch.
core/EE_Dependency_Map.core.php 2 patches
Indentation   +1149 added lines, -1149 removed lines patch added patch discarded remove patch
@@ -20,1153 +20,1153 @@
 block discarded – undo
20 20
 class EE_Dependency_Map
21 21
 {
22 22
 
23
-    /**
24
-     * This means that the requested class dependency is not present in the dependency map
25
-     */
26
-    const not_registered = 0;
27
-
28
-    /**
29
-     * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
30
-     */
31
-    const load_new_object = 1;
32
-
33
-    /**
34
-     * This instructs class loaders to return a previously instantiated and cached object for the requested class.
35
-     * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
36
-     */
37
-    const load_from_cache = 2;
38
-
39
-    /**
40
-     * When registering a dependency,
41
-     * this indicates to keep any existing dependencies that already exist,
42
-     * and simply discard any new dependencies declared in the incoming data
43
-     */
44
-    const KEEP_EXISTING_DEPENDENCIES = 0;
45
-
46
-    /**
47
-     * When registering a dependency,
48
-     * this indicates to overwrite any existing dependencies that already exist using the incoming data
49
-     */
50
-    const OVERWRITE_DEPENDENCIES = 1;
51
-
52
-
53
-    /**
54
-     * @type EE_Dependency_Map $_instance
55
-     */
56
-    protected static $_instance;
57
-
58
-    /**
59
-     * @var ClassInterfaceCache $class_cache
60
-     */
61
-    private $class_cache;
62
-
63
-    /**
64
-     * @type RequestInterface $request
65
-     */
66
-    protected $request;
67
-
68
-    /**
69
-     * @type LegacyRequestInterface $legacy_request
70
-     */
71
-    protected $legacy_request;
72
-
73
-    /**
74
-     * @type ResponseInterface $response
75
-     */
76
-    protected $response;
77
-
78
-    /**
79
-     * @type LoaderInterface $loader
80
-     */
81
-    protected $loader;
82
-
83
-    /**
84
-     * @type array $_dependency_map
85
-     */
86
-    protected $_dependency_map = array();
87
-
88
-    /**
89
-     * @type array $_class_loaders
90
-     */
91
-    protected $_class_loaders = array();
92
-
93
-
94
-    /**
95
-     * EE_Dependency_Map constructor.
96
-     *
97
-     * @param ClassInterfaceCache $class_cache
98
-     */
99
-    protected function __construct(ClassInterfaceCache $class_cache)
100
-    {
101
-        $this->class_cache = $class_cache;
102
-        do_action('EE_Dependency_Map____construct', $this);
103
-    }
104
-
105
-
106
-    /**
107
-     * @return void
108
-     */
109
-    public function initialize()
110
-    {
111
-        $this->_register_core_dependencies();
112
-        $this->_register_core_class_loaders();
113
-        $this->_register_core_aliases();
114
-    }
115
-
116
-
117
-    /**
118
-     * @singleton method used to instantiate class object
119
-     * @param ClassInterfaceCache|null $class_cache
120
-     * @return EE_Dependency_Map
121
-     */
122
-    public static function instance(ClassInterfaceCache $class_cache = null)
123
-    {
124
-        // check if class object is instantiated, and instantiated properly
125
-        if (! self::$_instance instanceof EE_Dependency_Map
126
-            && $class_cache instanceof ClassInterfaceCache
127
-        ) {
128
-            self::$_instance = new EE_Dependency_Map($class_cache);
129
-        }
130
-        return self::$_instance;
131
-    }
132
-
133
-
134
-    /**
135
-     * @param RequestInterface $request
136
-     */
137
-    public function setRequest(RequestInterface $request)
138
-    {
139
-        $this->request = $request;
140
-    }
141
-
142
-
143
-    /**
144
-     * @param LegacyRequestInterface $legacy_request
145
-     */
146
-    public function setLegacyRequest(LegacyRequestInterface $legacy_request)
147
-    {
148
-        $this->legacy_request = $legacy_request;
149
-    }
150
-
151
-
152
-    /**
153
-     * @param ResponseInterface $response
154
-     */
155
-    public function setResponse(ResponseInterface $response)
156
-    {
157
-        $this->response = $response;
158
-    }
159
-
160
-
161
-    /**
162
-     * @param LoaderInterface $loader
163
-     */
164
-    public function setLoader(LoaderInterface $loader)
165
-    {
166
-        $this->loader = $loader;
167
-    }
168
-
169
-
170
-    /**
171
-     * @param string $class
172
-     * @param array  $dependencies
173
-     * @param int    $overwrite
174
-     * @return bool
175
-     */
176
-    public static function register_dependencies(
177
-        $class,
178
-        array $dependencies,
179
-        $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
180
-    ) {
181
-        return self::$_instance->registerDependencies($class, $dependencies, $overwrite);
182
-    }
183
-
184
-
185
-    /**
186
-     * Assigns an array of class names and corresponding load sources (new or cached)
187
-     * to the class specified by the first parameter.
188
-     * IMPORTANT !!!
189
-     * The order of elements in the incoming $dependencies array MUST match
190
-     * the order of the constructor parameters for the class in question.
191
-     * This is especially important when overriding any existing dependencies that are registered.
192
-     * the third parameter controls whether any duplicate dependencies are overwritten or not.
193
-     *
194
-     * @param string $class
195
-     * @param array  $dependencies
196
-     * @param int    $overwrite
197
-     * @return bool
198
-     */
199
-    public function registerDependencies(
200
-        $class,
201
-        array $dependencies,
202
-        $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
203
-    ) {
204
-        $class = trim($class, '\\');
205
-        $registered = false;
206
-        if (empty(self::$_instance->_dependency_map[ $class ])) {
207
-            self::$_instance->_dependency_map[ $class ] = array();
208
-        }
209
-        // we need to make sure that any aliases used when registering a dependency
210
-        // get resolved to the correct class name
211
-        foreach ($dependencies as $dependency => $load_source) {
212
-            $alias = self::$_instance->getFqnForAlias($dependency);
213
-            if ($overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
214
-                || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
215
-            ) {
216
-                unset($dependencies[ $dependency ]);
217
-                $dependencies[ $alias ] = $load_source;
218
-                $registered = true;
219
-            }
220
-        }
221
-        // now add our two lists of dependencies together.
222
-        // using Union (+=) favours the arrays in precedence from left to right,
223
-        // so $dependencies is NOT overwritten because it is listed first
224
-        // ie: with A = B + C, entries in B take precedence over duplicate entries in C
225
-        // Union is way faster than array_merge() but should be used with caution...
226
-        // especially with numerically indexed arrays
227
-        $dependencies += self::$_instance->_dependency_map[ $class ];
228
-        // now we need to ensure that the resulting dependencies
229
-        // array only has the entries that are required for the class
230
-        // so first count how many dependencies were originally registered for the class
231
-        $dependency_count = count(self::$_instance->_dependency_map[ $class ]);
232
-        // if that count is non-zero (meaning dependencies were already registered)
233
-        self::$_instance->_dependency_map[ $class ] = $dependency_count
234
-            // then truncate the  final array to match that count
235
-            ? array_slice($dependencies, 0, $dependency_count)
236
-            // otherwise just take the incoming array because nothing previously existed
237
-            : $dependencies;
238
-        return $registered;
239
-    }
240
-
241
-
242
-    /**
243
-     * @param string $class_name
244
-     * @param string $loader
245
-     * @return bool
246
-     * @throws DomainException
247
-     */
248
-    public static function register_class_loader($class_name, $loader = 'load_core')
249
-    {
250
-        if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
251
-            throw new DomainException(
252
-                esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
253
-            );
254
-        }
255
-        // check that loader is callable or method starts with "load_" and exists in EE_Registry
256
-        if (! is_callable($loader)
257
-            && (
258
-                strpos($loader, 'load_') !== 0
259
-                || ! method_exists('EE_Registry', $loader)
260
-            )
261
-        ) {
262
-            throw new DomainException(
263
-                sprintf(
264
-                    esc_html__(
265
-                        '"%1$s" is not a valid loader method on EE_Registry.',
266
-                        'event_espresso'
267
-                    ),
268
-                    $loader
269
-                )
270
-            );
271
-        }
272
-        $class_name = self::$_instance->getFqnForAlias($class_name);
273
-        if (! isset(self::$_instance->_class_loaders[ $class_name ])) {
274
-            self::$_instance->_class_loaders[ $class_name ] = $loader;
275
-            return true;
276
-        }
277
-        return false;
278
-    }
279
-
280
-
281
-    /**
282
-     * @return array
283
-     */
284
-    public function dependency_map()
285
-    {
286
-        return $this->_dependency_map;
287
-    }
288
-
289
-
290
-    /**
291
-     * returns TRUE if dependency map contains a listing for the provided class name
292
-     *
293
-     * @param string $class_name
294
-     * @return boolean
295
-     */
296
-    public function has($class_name = '')
297
-    {
298
-        // all legacy models have the same dependencies
299
-        if (strpos($class_name, 'EEM_') === 0) {
300
-            $class_name = 'LEGACY_MODELS';
301
-        }
302
-        return isset($this->_dependency_map[ $class_name ]) ? true : false;
303
-    }
304
-
305
-
306
-    /**
307
-     * returns TRUE if dependency map contains a listing for the provided class name AND dependency
308
-     *
309
-     * @param string $class_name
310
-     * @param string $dependency
311
-     * @return bool
312
-     */
313
-    public function has_dependency_for_class($class_name = '', $dependency = '')
314
-    {
315
-        // all legacy models have the same dependencies
316
-        if (strpos($class_name, 'EEM_') === 0) {
317
-            $class_name = 'LEGACY_MODELS';
318
-        }
319
-        $dependency = $this->getFqnForAlias($dependency, $class_name);
320
-        return isset($this->_dependency_map[ $class_name ][ $dependency ])
321
-            ? true
322
-            : false;
323
-    }
324
-
325
-
326
-    /**
327
-     * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
328
-     *
329
-     * @param string $class_name
330
-     * @param string $dependency
331
-     * @return int
332
-     */
333
-    public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
334
-    {
335
-        // all legacy models have the same dependencies
336
-        if (strpos($class_name, 'EEM_') === 0) {
337
-            $class_name = 'LEGACY_MODELS';
338
-        }
339
-        $dependency = $this->getFqnForAlias($dependency);
340
-        return $this->has_dependency_for_class($class_name, $dependency)
341
-            ? $this->_dependency_map[ $class_name ][ $dependency ]
342
-            : EE_Dependency_Map::not_registered;
343
-    }
344
-
345
-
346
-    /**
347
-     * @param string $class_name
348
-     * @return string | Closure
349
-     */
350
-    public function class_loader($class_name)
351
-    {
352
-        // all legacy models use load_model()
353
-        if (strpos($class_name, 'EEM_') === 0) {
354
-            return 'load_model';
355
-        }
356
-        // EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc
357
-        // perform strpos() first to avoid loading regex every time we load a class
358
-        if (strpos($class_name, 'EE_CPT_') === 0
359
-            && preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name)
360
-        ) {
361
-            return 'load_core';
362
-        }
363
-        $class_name = $this->getFqnForAlias($class_name);
364
-        return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : '';
365
-    }
366
-
367
-
368
-    /**
369
-     * @return array
370
-     */
371
-    public function class_loaders()
372
-    {
373
-        return $this->_class_loaders;
374
-    }
375
-
376
-
377
-    /**
378
-     * adds an alias for a classname
379
-     *
380
-     * @param string $fqcn      the class name that should be used (concrete class to replace interface)
381
-     * @param string $alias     the class name that would be type hinted for (abstract parent or interface)
382
-     * @param string $for_class the class that has the dependency (is type hinting for the interface)
383
-     */
384
-    public function add_alias($fqcn, $alias, $for_class = '')
385
-    {
386
-        $this->class_cache->addAlias($fqcn, $alias, $for_class);
387
-    }
388
-
389
-
390
-    /**
391
-     * Returns TRUE if the provided fully qualified name IS an alias
392
-     * WHY?
393
-     * Because if a class is type hinting for a concretion,
394
-     * then why would we need to find another class to supply it?
395
-     * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
396
-     * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
397
-     * Don't go looking for some substitute.
398
-     * Whereas if a class is type hinting for an interface...
399
-     * then we need to find an actual class to use.
400
-     * So the interface IS the alias for some other FQN,
401
-     * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
402
-     * represents some other class.
403
-     *
404
-     * @param string $fqn
405
-     * @param string $for_class
406
-     * @return bool
407
-     */
408
-    public function isAlias($fqn = '', $for_class = '')
409
-    {
410
-        return $this->class_cache->isAlias($fqn, $for_class);
411
-    }
412
-
413
-
414
-    /**
415
-     * Returns a FQN for provided alias if one exists, otherwise returns the original $alias
416
-     * functions recursively, so that multiple aliases can be used to drill down to a FQN
417
-     *  for example:
418
-     *      if the following two entries were added to the _aliases array:
419
-     *          array(
420
-     *              'interface_alias'           => 'some\namespace\interface'
421
-     *              'some\namespace\interface'  => 'some\namespace\classname'
422
-     *          )
423
-     *      then one could use EE_Registry::instance()->create( 'interface_alias' )
424
-     *      to load an instance of 'some\namespace\classname'
425
-     *
426
-     * @param string $alias
427
-     * @param string $for_class
428
-     * @return string
429
-     */
430
-    public function getFqnForAlias($alias = '', $for_class = '')
431
-    {
432
-        return (string) $this->class_cache->getFqnForAlias($alias, $for_class);
433
-    }
434
-
435
-
436
-    /**
437
-     * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
438
-     * if one exists, or whether a new object should be generated every time the requested class is loaded.
439
-     * This is done by using the following class constants:
440
-     *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
441
-     *        EE_Dependency_Map::load_new_object - generates a new object every time
442
-     */
443
-    protected function _register_core_dependencies()
444
-    {
445
-        $this->_dependency_map = array(
446
-            'EE_Request_Handler'                                                                                          => array(
447
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
448
-            ),
449
-            'EE_System'                                                                                                   => array(
450
-                'EE_Registry'                                 => EE_Dependency_Map::load_from_cache,
451
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
452
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
453
-                'EE_Maintenance_Mode'                         => EE_Dependency_Map::load_from_cache,
454
-            ),
455
-            'EE_Session'                                                                                                  => array(
456
-                'EventEspresso\core\services\cache\TransientCacheStorage'  => EE_Dependency_Map::load_from_cache,
457
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
458
-                'EventEspresso\core\services\request\Request'              => EE_Dependency_Map::load_from_cache,
459
-                'EventEspresso\core\services\session\SessionStartHandler'  => EE_Dependency_Map::load_from_cache,
460
-                'EE_Encryption'                                            => EE_Dependency_Map::load_from_cache,
461
-            ),
462
-            'EE_Cart'                                                                                                     => array(
463
-                'EE_Session' => EE_Dependency_Map::load_from_cache,
464
-            ),
465
-            'EE_Front_Controller'                                                                                         => array(
466
-                'EE_Registry'              => EE_Dependency_Map::load_from_cache,
467
-                'EE_Request_Handler'       => EE_Dependency_Map::load_from_cache,
468
-                'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache,
469
-            ),
470
-            'EE_Messenger_Collection_Loader'                                                                              => array(
471
-                'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
472
-            ),
473
-            'EE_Message_Type_Collection_Loader'                                                                           => array(
474
-                'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
475
-            ),
476
-            'EE_Message_Resource_Manager'                                                                                 => array(
477
-                'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
478
-                'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
479
-                'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
480
-            ),
481
-            'EE_Message_Factory'                                                                                          => array(
482
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
483
-            ),
484
-            'EE_messages'                                                                                                 => array(
485
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
486
-            ),
487
-            'EE_Messages_Generator'                                                                                       => array(
488
-                'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
489
-                'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
490
-                'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
491
-                'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
492
-            ),
493
-            'EE_Messages_Processor'                                                                                       => array(
494
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
495
-            ),
496
-            'EE_Messages_Queue'                                                                                           => array(
497
-                'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
498
-            ),
499
-            'EE_Messages_Template_Defaults'                                                                               => array(
500
-                'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
501
-                'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
502
-            ),
503
-            'EE_Message_To_Generate_From_Request'                                                                         => array(
504
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
505
-                'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
506
-            ),
507
-            'EventEspresso\core\services\commands\CommandBus'                                                             => array(
508
-                'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
509
-            ),
510
-            'EventEspresso\services\commands\CommandHandler'                                                              => array(
511
-                'EE_Registry'         => EE_Dependency_Map::load_from_cache,
512
-                'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
513
-            ),
514
-            'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => array(
515
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
516
-            ),
517
-            'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => array(
518
-                'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
519
-                'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
520
-            ),
521
-            'EventEspresso\core\services\commands\CommandFactory'                                                         => array(
522
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
523
-            ),
524
-            'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => array(
525
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
526
-            ),
527
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => array(
528
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
529
-            ),
530
-            'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => array(
531
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
532
-            ),
533
-            'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => array(
534
-                'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
535
-            ),
536
-            'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => array(
537
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
538
-            ),
539
-            'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => array(
540
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
541
-            ),
542
-            'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => array(
543
-                'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
544
-            ),
545
-            'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array(
546
-                'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
547
-            ),
548
-            'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => array(
549
-                'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
550
-            ),
551
-            'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => array(
552
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
553
-            ),
554
-            'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => array(
555
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
556
-            ),
557
-            'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler'                                  => array(
558
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
559
-            ),
560
-            'EventEspresso\core\services\database\TableManager'                                                           => array(
561
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
562
-            ),
563
-            'EE_Data_Migration_Class_Base'                                                                                => array(
564
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
565
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
566
-            ),
567
-            'EE_DMS_Core_4_1_0'                                                                                           => array(
568
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
569
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
570
-            ),
571
-            'EE_DMS_Core_4_2_0'                                                                                           => array(
572
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
573
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
574
-            ),
575
-            'EE_DMS_Core_4_3_0'                                                                                           => array(
576
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
577
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
578
-            ),
579
-            'EE_DMS_Core_4_4_0'                                                                                           => array(
580
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
581
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
582
-            ),
583
-            'EE_DMS_Core_4_5_0'                                                                                           => array(
584
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
585
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
586
-            ),
587
-            'EE_DMS_Core_4_6_0'                                                                                           => array(
588
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
589
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
590
-            ),
591
-            'EE_DMS_Core_4_7_0'                                                                                           => array(
592
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
593
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
594
-            ),
595
-            'EE_DMS_Core_4_8_0'                                                                                           => array(
596
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
597
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
598
-            ),
599
-            'EE_DMS_Core_4_9_0' => array(
600
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
601
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
602
-            ),
603
-            'EE_DMS_Core_4_10_0' => array(
604
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
605
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
606
-                'EE_DMS_Core_4_9_0'                                  => EE_Dependency_Map::load_from_cache,
607
-            ),
608
-            'EventEspresso\core\services\assets\I18nRegistry'                                                             => array(
609
-                array(),
610
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
611
-            ),
612
-            'EventEspresso\core\services\assets\Registry'                                                                 => array(
613
-                'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
614
-                'EventEspresso\core\services\assets\I18nRegistry'    => EE_Dependency_Map::load_from_cache,
615
-            ),
616
-            'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled'                                             => array(
617
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
618
-            ),
619
-            'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout'                                              => array(
620
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
621
-            ),
622
-            'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees'                                        => array(
623
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
624
-            ),
625
-            'EventEspresso\core\domain\entities\shortcodes\EspressoEvents'                                                => array(
626
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
627
-            ),
628
-            'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou'                                              => array(
629
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
630
-            ),
631
-            'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector'                                        => array(
632
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
633
-            ),
634
-            'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage'                                               => array(
635
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
636
-            ),
637
-            'EventEspresso\core\services\cache\BasicCacheManager'                                                         => array(
638
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
639
-            ),
640
-            'EventEspresso\core\services\cache\PostRelatedCacheManager'                                                   => array(
641
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
642
-            ),
643
-            'EventEspresso\core\domain\services\validation\email\EmailValidationService'                                  => array(
644
-                'EE_Registration_Config'                     => EE_Dependency_Map::load_from_cache,
645
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
646
-            ),
647
-            'EventEspresso\core\domain\values\EmailAddress'                                                               => array(
648
-                null,
649
-                'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache,
650
-            ),
651
-            'EventEspresso\core\services\orm\ModelFieldFactory'                                                           => array(
652
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
653
-            ),
654
-            'LEGACY_MODELS'                                                                                               => array(
655
-                null,
656
-                'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache,
657
-            ),
658
-            'EE_Module_Request_Router'                                                                                    => array(
659
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
660
-            ),
661
-            'EE_Registration_Processor'                                                                                   => array(
662
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
663
-            ),
664
-            'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'                                      => array(
665
-                null,
666
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
667
-                'EventEspresso\core\services\request\Request'                         => EE_Dependency_Map::load_from_cache,
668
-            ),
669
-            'EventEspresso\core\services\licensing\LicenseService'                                                        => array(
670
-                'EventEspresso\core\domain\services\pue\Stats'  => EE_Dependency_Map::load_from_cache,
671
-                'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache,
672
-            ),
673
-            'EE_Admin_Transactions_List_Table'                                                                            => array(
674
-                null,
675
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
676
-            ),
677
-            'EventEspresso\core\domain\services\pue\Stats'                                                                => array(
678
-                'EventEspresso\core\domain\services\pue\Config'        => EE_Dependency_Map::load_from_cache,
679
-                'EE_Maintenance_Mode'                                  => EE_Dependency_Map::load_from_cache,
680
-                'EventEspresso\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache,
681
-            ),
682
-            'EventEspresso\core\domain\services\pue\Config'                                                               => array(
683
-                'EE_Network_Config' => EE_Dependency_Map::load_from_cache,
684
-                'EE_Config'         => EE_Dependency_Map::load_from_cache,
685
-            ),
686
-            'EventEspresso\core\domain\services\pue\StatsGatherer'                                                        => array(
687
-                'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
688
-                'EEM_Event'          => EE_Dependency_Map::load_from_cache,
689
-                'EEM_Datetime'       => EE_Dependency_Map::load_from_cache,
690
-                'EEM_Ticket'         => EE_Dependency_Map::load_from_cache,
691
-                'EEM_Registration'   => EE_Dependency_Map::load_from_cache,
692
-                'EEM_Transaction'    => EE_Dependency_Map::load_from_cache,
693
-                'EE_Config'          => EE_Dependency_Map::load_from_cache,
694
-            ),
695
-            'EventEspresso\core\domain\services\admin\ExitModal'                                                          => array(
696
-                'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache,
697
-            ),
698
-            'EventEspresso\core\domain\services\admin\PluginUpsells'                                                      => array(
699
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
700
-            ),
701
-            'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha'                                    => array(
702
-                'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
703
-                'EE_Session'             => EE_Dependency_Map::load_from_cache,
704
-            ),
705
-            'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings'                                => array(
706
-                'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
707
-            ),
708
-            'EventEspresso\modules\ticket_selector\ProcessTicketSelector'                                                 => array(
709
-                'EE_Core_Config'                                                          => EE_Dependency_Map::load_from_cache,
710
-                'EventEspresso\core\services\request\Request'                             => EE_Dependency_Map::load_from_cache,
711
-                'EE_Session'                                                              => EE_Dependency_Map::load_from_cache,
712
-                'EEM_Ticket'                                                              => EE_Dependency_Map::load_from_cache,
713
-                'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache,
714
-            ),
715
-            'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker'                                     => array(
716
-                'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
717
-            ),
718
-            'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'                              => array(
719
-                'EE_Core_Config'                             => EE_Dependency_Map::load_from_cache,
720
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
721
-            ),
722
-            'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes'                                => array(
723
-                'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
724
-            ),
725
-            'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies'                               => array(
726
-                'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
727
-            ),
728
-            'EE_CPT_Strategy'                                                                                             => array(
729
-                'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
730
-                'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
731
-            ),
732
-            'EventEspresso\core\services\loaders\ObjectIdentifier'                                                        => array(
733
-                'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
734
-            ),
735
-            'EventEspresso\core\domain\services\assets\CoreAssetManager'                                                  => array(
736
-                'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
737
-                'EE_Currency_Config'                                 => EE_Dependency_Map::load_from_cache,
738
-                'EE_Template_Config'                                 => EE_Dependency_Map::load_from_cache,
739
-                'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
740
-                'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
741
-            ),
742
-            'EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy' => array(
743
-                'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
744
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache
745
-            ),
746
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendee' => array(
747
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
748
-            ),
749
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendeeBillingData' => array(
750
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
751
-                'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache
752
-            ),
753
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportCheckins' => array(
754
-                'EEM_Checkin' => EE_Dependency_Map::load_from_cache,
755
-            ),
756
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportRegistration' => array(
757
-                'EEM_Registration' => EE_Dependency_Map::load_from_cache,
758
-            ),
759
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportTransaction' => array(
760
-                'EEM_Transaction' => EE_Dependency_Map::load_from_cache,
761
-            ),
762
-            'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAttendeeData' => array(
763
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
764
-            ),
765
-            'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAnswers' => array(
766
-                'EEM_Answer' => EE_Dependency_Map::load_from_cache,
767
-                'EEM_Question' => EE_Dependency_Map::load_from_cache,
768
-            ),
769
-            'EventEspresso\core\CPTs\CptQueryModifier' => array(
770
-                null,
771
-                null,
772
-                null,
773
-                'EE_Request_Handler'                          => EE_Dependency_Map::load_from_cache,
774
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
775
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
776
-            ),
777
-            'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler' => array(
778
-                'EE_Registry' => EE_Dependency_Map::load_from_cache,
779
-                'EE_Config' => EE_Dependency_Map::load_from_cache
780
-            ),
781
-            'EventEspresso\core\services\editor\BlockRegistrationManager'                                                 => array(
782
-                'EventEspresso\core\services\assets\BlockAssetManagerCollection' => EE_Dependency_Map::load_from_cache,
783
-                'EventEspresso\core\domain\entities\editor\BlockCollection'      => EE_Dependency_Map::load_from_cache,
784
-                'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => EE_Dependency_Map::load_from_cache,
785
-                'EventEspresso\core\services\request\Request'                    => EE_Dependency_Map::load_from_cache,
786
-            ),
787
-            'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => array(
788
-                'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
789
-                'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
790
-                'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
791
-            ),
792
-            'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => array(
793
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
794
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
795
-            ),
796
-            'EventEspresso\core\domain\entities\editor\blocks\EventAttendees' => array(
797
-                'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => self::load_from_cache,
798
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
799
-                'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => self::load_from_cache,
800
-            ),
801
-            'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => array(
802
-                'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache,
803
-                'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
804
-                'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache,
805
-            ),
806
-            'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => array(
807
-                'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => EE_Dependency_Map::load_from_cache,
808
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
809
-            ),
810
-            'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => array(
811
-                'EventEspresso\core\services\route_match\RouteMatchSpecificationCollection' => EE_Dependency_Map::load_from_cache,
812
-                'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => EE_Dependency_Map::load_from_cache,
813
-            ),
814
-            'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => array(
815
-                'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => EE_Dependency_Map::load_from_cache
816
-            ),
817
-            'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => array(
818
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
819
-            ),
820
-            'EventEspresso\core\libraries\rest_api\controllers\model\Read' => array(
821
-                'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => EE_Dependency_Map::load_from_cache
822
-            ),
823
-            'EventEspresso\core\libraries\rest_api\calculations\Datetime' => array(
824
-                'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
825
-                'EEM_Registration' => EE_Dependency_Map::load_from_cache
826
-            ),
827
-            'EventEspresso\core\libraries\rest_api\calculations\Event' => array(
828
-                'EEM_Event' => EE_Dependency_Map::load_from_cache,
829
-                'EEM_Registration' => EE_Dependency_Map::load_from_cache
830
-            ),
831
-            'EventEspresso\core\libraries\rest_api\calculations\Registration' => array(
832
-                'EEM_Registration' => EE_Dependency_Map::load_from_cache
833
-            ),
834
-            'EventEspresso\core\services\session\SessionStartHandler' => array(
835
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
836
-            ),
837
-            'EE_URL_Validation_Strategy' => array(
838
-                null,
839
-                null,
840
-                'EventEspresso\core\services\validators\URLValidator' => EE_Dependency_Map::load_from_cache
841
-            ),
842
-            'EventEspresso\admin_pages\general_settings\OrganizationSettings' => array(
843
-                'EE_Registry'                                             => EE_Dependency_Map::load_from_cache,
844
-                'EE_Organization_Config'                                  => EE_Dependency_Map::load_from_cache,
845
-                'EE_Core_Config'                                          => EE_Dependency_Map::load_from_cache,
846
-                'EE_Network_Core_Config'                                  => EE_Dependency_Map::load_from_cache,
847
-                'EventEspresso\core\services\address\CountrySubRegionDao' => EE_Dependency_Map::load_from_cache,
848
-            ),
849
-            'EventEspresso\core\services\address\CountrySubRegionDao' => array(
850
-                'EEM_State'                                            => EE_Dependency_Map::load_from_cache,
851
-                'EventEspresso\core\services\validators\JsonValidator' => EE_Dependency_Map::load_from_cache
852
-            ),
853
-            'EventEspresso\core\domain\services\admin\ajax\WordpressHeartbeat' => array(
854
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
855
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
856
-            ),
857
-            'EventEspresso\core\domain\services\admin\ajax\EventEditorHeartbeat' => array(
858
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
859
-                'EE_Environment_Config'            => EE_Dependency_Map::load_from_cache,
860
-            ),
861
-            'EventEspresso\core\services\request\files\FilesDataHandler' => array(
862
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
863
-            ),
864
-            'EventEspressoBatchRequest\BatchRequestProcessor' => [
865
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
866
-            ],
867
-            'EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder' => [
868
-                null,
869
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
870
-                'EEM_Registration'  => EE_Dependency_Map::load_from_cache,
871
-            ],
872
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\AttendeeFilterHeader' => [
873
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
874
-                'EEM_Attendee'  => EE_Dependency_Map::load_from_cache,
875
-            ],
876
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\DateFilterHeader' => [
877
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
878
-                'EEM_Datetime'  => EE_Dependency_Map::load_from_cache,
879
-            ],
880
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\EventFilterHeader' => [
881
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
882
-                'EEM_Event'  => EE_Dependency_Map::load_from_cache,
883
-            ],
884
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\TicketFilterHeader' => [
885
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
886
-                'EEM_Ticket'  => EE_Dependency_Map::load_from_cache,
887
-            ],
888
-            'EventEspresso\core\domain\services\converters\RestApiSpoofer' => [
889
-                'WP_REST_Server' => EE_Dependency_Map::load_from_cache,
890
-                'EED_Core_Rest_Api' => EE_Dependency_Map::load_from_cache,
891
-                'EventEspresso\core\libraries\rest_api\controllers\model\Read' => EE_Dependency_Map::load_from_cache,
892
-                null
893
-            ],
894
-            'EventEspresso\core\domain\services\admin\events\default_settings\AdvancedEditorAdminFormSection'  => [
895
-                'EE_Admin_Config' => EE_Dependency_Map::load_from_cache
896
-            ],
897
-            'EventEspresso\core\domain\services\admin\events\editor\AdvancedEditorEntityData'  => [
898
-                'EventEspresso\core\domain\services\converters\RestApiSpoofer' => EE_Dependency_Map::load_from_cache,
899
-                'EE_Admin_Config' => EE_Dependency_Map::load_from_cache,
900
-                'EEM_Datetime'    => EE_Dependency_Map::load_from_cache,
901
-                'EEM_Event'       => EE_Dependency_Map::load_from_cache,
902
-                'EEM_Price'       => EE_Dependency_Map::load_from_cache,
903
-                'EEM_Price_Type'  => EE_Dependency_Map::load_from_cache,
904
-                'EEM_Ticket'      => EE_Dependency_Map::load_from_cache,
905
-                'EEM_Venue'       => EE_Dependency_Map::load_from_cache,
906
-            ],
907
-        );
908
-    }
909
-
910
-
911
-    /**
912
-     * Registers how core classes are loaded.
913
-     * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
914
-     *        'EE_Request_Handler' => 'load_core'
915
-     *        'EE_Messages_Queue'  => 'load_lib'
916
-     *        'EEH_Debug_Tools'    => 'load_helper'
917
-     * or, if greater control is required, by providing a custom closure. For example:
918
-     *        'Some_Class' => function () {
919
-     *            return new Some_Class();
920
-     *        },
921
-     * This is required for instantiating dependencies
922
-     * where an interface has been type hinted in a class constructor. For example:
923
-     *        'Required_Interface' => function () {
924
-     *            return new A_Class_That_Implements_Required_Interface();
925
-     *        },
926
-     */
927
-    protected function _register_core_class_loaders()
928
-    {
929
-        $this->_class_loaders = array(
930
-            // load_core
931
-            'EE_Dependency_Map'                            => function () {
932
-                return $this;
933
-            },
934
-            'EE_Capabilities'                              => 'load_core',
935
-            'EE_Encryption'                                => 'load_core',
936
-            'EE_Front_Controller'                          => 'load_core',
937
-            'EE_Module_Request_Router'                     => 'load_core',
938
-            'EE_Registry'                                  => 'load_core',
939
-            'EE_Request'                                   => function () {
940
-                return $this->legacy_request;
941
-            },
942
-            'EventEspresso\core\services\request\Request'  => function () {
943
-                return $this->request;
944
-            },
945
-            'EventEspresso\core\services\request\Response' => function () {
946
-                return $this->response;
947
-            },
948
-            'EE_Base'                                      => 'load_core',
949
-            'EE_Request_Handler'                           => 'load_core',
950
-            'EE_Session'                                   => 'load_core',
951
-            'EE_Cron_Tasks'                                => 'load_core',
952
-            'EE_System'                                    => 'load_core',
953
-            'EE_Maintenance_Mode'                          => 'load_core',
954
-            'EE_Register_CPTs'                             => 'load_core',
955
-            'EE_Admin'                                     => 'load_core',
956
-            'EE_CPT_Strategy'                              => 'load_core',
957
-            // load_class
958
-            'EE_Registration_Processor'                    => 'load_class',
959
-            // load_lib
960
-            'EE_Message_Resource_Manager'                  => 'load_lib',
961
-            'EE_Message_Type_Collection'                   => 'load_lib',
962
-            'EE_Message_Type_Collection_Loader'            => 'load_lib',
963
-            'EE_Messenger_Collection'                      => 'load_lib',
964
-            'EE_Messenger_Collection_Loader'               => 'load_lib',
965
-            'EE_Messages_Processor'                        => 'load_lib',
966
-            'EE_Message_Repository'                        => 'load_lib',
967
-            'EE_Messages_Queue'                            => 'load_lib',
968
-            'EE_Messages_Data_Handler_Collection'          => 'load_lib',
969
-            'EE_Message_Template_Group_Collection'         => 'load_lib',
970
-            'EE_Payment_Method_Manager'                    => 'load_lib',
971
-            'EE_DMS_Core_4_1_0'                            => 'load_dms',
972
-            'EE_DMS_Core_4_2_0'                            => 'load_dms',
973
-            'EE_DMS_Core_4_3_0'                            => 'load_dms',
974
-            'EE_DMS_Core_4_5_0'                            => 'load_dms',
975
-            'EE_DMS_Core_4_6_0'                            => 'load_dms',
976
-            'EE_DMS_Core_4_7_0'                            => 'load_dms',
977
-            'EE_DMS_Core_4_8_0'                            => 'load_dms',
978
-            'EE_DMS_Core_4_9_0'                            => 'load_dms',
979
-            'EE_DMS_Core_4_10_0'                            => 'load_dms',
980
-            'EE_Messages_Generator'                        => function () {
981
-                return EE_Registry::instance()->load_lib(
982
-                    'Messages_Generator',
983
-                    array(),
984
-                    false,
985
-                    false
986
-                );
987
-            },
988
-            'EE_Messages_Template_Defaults'                => function ($arguments = array()) {
989
-                return EE_Registry::instance()->load_lib(
990
-                    'Messages_Template_Defaults',
991
-                    $arguments,
992
-                    false,
993
-                    false
994
-                );
995
-            },
996
-            // load_helper
997
-            'EEH_Parse_Shortcodes'                         => function () {
998
-                if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
999
-                    return new EEH_Parse_Shortcodes();
1000
-                }
1001
-                return null;
1002
-            },
1003
-            'EE_Template_Config'                           => function () {
1004
-                return EE_Config::instance()->template_settings;
1005
-            },
1006
-            'EE_Currency_Config'                           => function () {
1007
-                return EE_Config::instance()->currency;
1008
-            },
1009
-            'EE_Registration_Config'                       => function () {
1010
-                return EE_Config::instance()->registration;
1011
-            },
1012
-            'EE_Core_Config'                               => function () {
1013
-                return EE_Config::instance()->core;
1014
-            },
1015
-            'EventEspresso\core\services\loaders\Loader'   => function () {
1016
-                return LoaderFactory::getLoader();
1017
-            },
1018
-            'EE_Network_Config'                            => function () {
1019
-                return EE_Network_Config::instance();
1020
-            },
1021
-            'EE_Config'                                    => function () {
1022
-                return EE_Config::instance();
1023
-            },
1024
-            'EventEspresso\core\domain\Domain'             => function () {
1025
-                return DomainFactory::getEventEspressoCoreDomain();
1026
-            },
1027
-            'EE_Admin_Config'                              => function () {
1028
-                return EE_Config::instance()->admin;
1029
-            },
1030
-            'EE_Organization_Config'                       => function () {
1031
-                return EE_Config::instance()->organization;
1032
-            },
1033
-            'EE_Network_Core_Config'                       => function () {
1034
-                return EE_Network_Config::instance()->core;
1035
-            },
1036
-            'EE_Environment_Config'                        => function () {
1037
-                return EE_Config::instance()->environment;
1038
-            },
1039
-            'EED_Core_Rest_Api'                            => static function () {
1040
-                return EED_Core_Rest_Api::instance();
1041
-            },
1042
-            'WP_REST_Server'                            => static function () {
1043
-                return rest_get_server();
1044
-            },
1045
-        );
1046
-    }
1047
-
1048
-
1049
-    /**
1050
-     * can be used for supplying alternate names for classes,
1051
-     * or for connecting interface names to instantiable classes
1052
-     */
1053
-    protected function _register_core_aliases()
1054
-    {
1055
-        $aliases = array(
1056
-            'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
1057
-            'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
1058
-            'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
1059
-            'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
1060
-            'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
1061
-            'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
1062
-            'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
1063
-            'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
1064
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
1065
-            'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
1066
-            'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
1067
-            'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
1068
-            'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
1069
-            'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
1070
-            'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
1071
-            'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
1072
-            'CreateTransactionCommandHandler'                                              => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
1073
-            'CreateAttendeeCommandHandler'                                                 => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
1074
-            'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
1075
-            'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
1076
-            'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
1077
-            'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
1078
-            'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
1079
-            'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
1080
-            'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
1081
-            'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
1082
-            'CommandFactoryInterface'                                                      => 'EventEspresso\core\services\commands\CommandFactoryInterface',
1083
-            'EventEspresso\core\services\commands\CommandFactoryInterface'                 => 'EventEspresso\core\services\commands\CommandFactory',
1084
-            'EmailValidatorInterface'                                                      => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
1085
-            'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface'  => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
1086
-            'NoticeConverterInterface'                                                     => 'EventEspresso\core\services\notices\NoticeConverterInterface',
1087
-            'EventEspresso\core\services\notices\NoticeConverterInterface'                 => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
1088
-            'NoticesContainerInterface'                                                    => 'EventEspresso\core\services\notices\NoticesContainerInterface',
1089
-            'EventEspresso\core\services\notices\NoticesContainerInterface'                => 'EventEspresso\core\services\notices\NoticesContainer',
1090
-            'EventEspresso\core\services\request\RequestInterface'                         => 'EventEspresso\core\services\request\Request',
1091
-            'EventEspresso\core\services\request\ResponseInterface'                        => 'EventEspresso\core\services\request\Response',
1092
-            'EventEspresso\core\domain\DomainInterface'                                    => 'EventEspresso\core\domain\Domain',
1093
-            'Registration_Processor'                                                       => 'EE_Registration_Processor',
1094
-        );
1095
-        foreach ($aliases as $alias => $fqn) {
1096
-            if (is_array($fqn)) {
1097
-                foreach ($fqn as $class => $for_class) {
1098
-                    $this->class_cache->addAlias($class, $alias, $for_class);
1099
-                }
1100
-                continue;
1101
-            }
1102
-            $this->class_cache->addAlias($fqn, $alias);
1103
-        }
1104
-        if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
1105
-            $this->class_cache->addAlias(
1106
-                'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices',
1107
-                'EventEspresso\core\services\notices\NoticeConverterInterface'
1108
-            );
1109
-        }
1110
-    }
1111
-
1112
-
1113
-    /**
1114
-     * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
1115
-     * request Primarily used by unit tests.
1116
-     */
1117
-    public function reset()
1118
-    {
1119
-        $this->_register_core_class_loaders();
1120
-        $this->_register_core_dependencies();
1121
-    }
1122
-
1123
-
1124
-    /**
1125
-     * PLZ NOTE: a better name for this method would be is_alias()
1126
-     * because it returns TRUE if the provided fully qualified name IS an alias
1127
-     * WHY?
1128
-     * Because if a class is type hinting for a concretion,
1129
-     * then why would we need to find another class to supply it?
1130
-     * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
1131
-     * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
1132
-     * Don't go looking for some substitute.
1133
-     * Whereas if a class is type hinting for an interface...
1134
-     * then we need to find an actual class to use.
1135
-     * So the interface IS the alias for some other FQN,
1136
-     * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
1137
-     * represents some other class.
1138
-     *
1139
-     * @deprecated 4.9.62.p
1140
-     * @param string $fqn
1141
-     * @param string $for_class
1142
-     * @return bool
1143
-     */
1144
-    public function has_alias($fqn = '', $for_class = '')
1145
-    {
1146
-        return $this->isAlias($fqn, $for_class);
1147
-    }
1148
-
1149
-
1150
-    /**
1151
-     * PLZ NOTE: a better name for this method would be get_fqn_for_alias()
1152
-     * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias
1153
-     * functions recursively, so that multiple aliases can be used to drill down to a FQN
1154
-     *  for example:
1155
-     *      if the following two entries were added to the _aliases array:
1156
-     *          array(
1157
-     *              'interface_alias'           => 'some\namespace\interface'
1158
-     *              'some\namespace\interface'  => 'some\namespace\classname'
1159
-     *          )
1160
-     *      then one could use EE_Registry::instance()->create( 'interface_alias' )
1161
-     *      to load an instance of 'some\namespace\classname'
1162
-     *
1163
-     * @deprecated 4.9.62.p
1164
-     * @param string $alias
1165
-     * @param string $for_class
1166
-     * @return string
1167
-     */
1168
-    public function get_alias($alias = '', $for_class = '')
1169
-    {
1170
-        return $this->getFqnForAlias($alias, $for_class);
1171
-    }
23
+	/**
24
+	 * This means that the requested class dependency is not present in the dependency map
25
+	 */
26
+	const not_registered = 0;
27
+
28
+	/**
29
+	 * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
30
+	 */
31
+	const load_new_object = 1;
32
+
33
+	/**
34
+	 * This instructs class loaders to return a previously instantiated and cached object for the requested class.
35
+	 * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
36
+	 */
37
+	const load_from_cache = 2;
38
+
39
+	/**
40
+	 * When registering a dependency,
41
+	 * this indicates to keep any existing dependencies that already exist,
42
+	 * and simply discard any new dependencies declared in the incoming data
43
+	 */
44
+	const KEEP_EXISTING_DEPENDENCIES = 0;
45
+
46
+	/**
47
+	 * When registering a dependency,
48
+	 * this indicates to overwrite any existing dependencies that already exist using the incoming data
49
+	 */
50
+	const OVERWRITE_DEPENDENCIES = 1;
51
+
52
+
53
+	/**
54
+	 * @type EE_Dependency_Map $_instance
55
+	 */
56
+	protected static $_instance;
57
+
58
+	/**
59
+	 * @var ClassInterfaceCache $class_cache
60
+	 */
61
+	private $class_cache;
62
+
63
+	/**
64
+	 * @type RequestInterface $request
65
+	 */
66
+	protected $request;
67
+
68
+	/**
69
+	 * @type LegacyRequestInterface $legacy_request
70
+	 */
71
+	protected $legacy_request;
72
+
73
+	/**
74
+	 * @type ResponseInterface $response
75
+	 */
76
+	protected $response;
77
+
78
+	/**
79
+	 * @type LoaderInterface $loader
80
+	 */
81
+	protected $loader;
82
+
83
+	/**
84
+	 * @type array $_dependency_map
85
+	 */
86
+	protected $_dependency_map = array();
87
+
88
+	/**
89
+	 * @type array $_class_loaders
90
+	 */
91
+	protected $_class_loaders = array();
92
+
93
+
94
+	/**
95
+	 * EE_Dependency_Map constructor.
96
+	 *
97
+	 * @param ClassInterfaceCache $class_cache
98
+	 */
99
+	protected function __construct(ClassInterfaceCache $class_cache)
100
+	{
101
+		$this->class_cache = $class_cache;
102
+		do_action('EE_Dependency_Map____construct', $this);
103
+	}
104
+
105
+
106
+	/**
107
+	 * @return void
108
+	 */
109
+	public function initialize()
110
+	{
111
+		$this->_register_core_dependencies();
112
+		$this->_register_core_class_loaders();
113
+		$this->_register_core_aliases();
114
+	}
115
+
116
+
117
+	/**
118
+	 * @singleton method used to instantiate class object
119
+	 * @param ClassInterfaceCache|null $class_cache
120
+	 * @return EE_Dependency_Map
121
+	 */
122
+	public static function instance(ClassInterfaceCache $class_cache = null)
123
+	{
124
+		// check if class object is instantiated, and instantiated properly
125
+		if (! self::$_instance instanceof EE_Dependency_Map
126
+			&& $class_cache instanceof ClassInterfaceCache
127
+		) {
128
+			self::$_instance = new EE_Dependency_Map($class_cache);
129
+		}
130
+		return self::$_instance;
131
+	}
132
+
133
+
134
+	/**
135
+	 * @param RequestInterface $request
136
+	 */
137
+	public function setRequest(RequestInterface $request)
138
+	{
139
+		$this->request = $request;
140
+	}
141
+
142
+
143
+	/**
144
+	 * @param LegacyRequestInterface $legacy_request
145
+	 */
146
+	public function setLegacyRequest(LegacyRequestInterface $legacy_request)
147
+	{
148
+		$this->legacy_request = $legacy_request;
149
+	}
150
+
151
+
152
+	/**
153
+	 * @param ResponseInterface $response
154
+	 */
155
+	public function setResponse(ResponseInterface $response)
156
+	{
157
+		$this->response = $response;
158
+	}
159
+
160
+
161
+	/**
162
+	 * @param LoaderInterface $loader
163
+	 */
164
+	public function setLoader(LoaderInterface $loader)
165
+	{
166
+		$this->loader = $loader;
167
+	}
168
+
169
+
170
+	/**
171
+	 * @param string $class
172
+	 * @param array  $dependencies
173
+	 * @param int    $overwrite
174
+	 * @return bool
175
+	 */
176
+	public static function register_dependencies(
177
+		$class,
178
+		array $dependencies,
179
+		$overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
180
+	) {
181
+		return self::$_instance->registerDependencies($class, $dependencies, $overwrite);
182
+	}
183
+
184
+
185
+	/**
186
+	 * Assigns an array of class names and corresponding load sources (new or cached)
187
+	 * to the class specified by the first parameter.
188
+	 * IMPORTANT !!!
189
+	 * The order of elements in the incoming $dependencies array MUST match
190
+	 * the order of the constructor parameters for the class in question.
191
+	 * This is especially important when overriding any existing dependencies that are registered.
192
+	 * the third parameter controls whether any duplicate dependencies are overwritten or not.
193
+	 *
194
+	 * @param string $class
195
+	 * @param array  $dependencies
196
+	 * @param int    $overwrite
197
+	 * @return bool
198
+	 */
199
+	public function registerDependencies(
200
+		$class,
201
+		array $dependencies,
202
+		$overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
203
+	) {
204
+		$class = trim($class, '\\');
205
+		$registered = false;
206
+		if (empty(self::$_instance->_dependency_map[ $class ])) {
207
+			self::$_instance->_dependency_map[ $class ] = array();
208
+		}
209
+		// we need to make sure that any aliases used when registering a dependency
210
+		// get resolved to the correct class name
211
+		foreach ($dependencies as $dependency => $load_source) {
212
+			$alias = self::$_instance->getFqnForAlias($dependency);
213
+			if ($overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
214
+				|| ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
215
+			) {
216
+				unset($dependencies[ $dependency ]);
217
+				$dependencies[ $alias ] = $load_source;
218
+				$registered = true;
219
+			}
220
+		}
221
+		// now add our two lists of dependencies together.
222
+		// using Union (+=) favours the arrays in precedence from left to right,
223
+		// so $dependencies is NOT overwritten because it is listed first
224
+		// ie: with A = B + C, entries in B take precedence over duplicate entries in C
225
+		// Union is way faster than array_merge() but should be used with caution...
226
+		// especially with numerically indexed arrays
227
+		$dependencies += self::$_instance->_dependency_map[ $class ];
228
+		// now we need to ensure that the resulting dependencies
229
+		// array only has the entries that are required for the class
230
+		// so first count how many dependencies were originally registered for the class
231
+		$dependency_count = count(self::$_instance->_dependency_map[ $class ]);
232
+		// if that count is non-zero (meaning dependencies were already registered)
233
+		self::$_instance->_dependency_map[ $class ] = $dependency_count
234
+			// then truncate the  final array to match that count
235
+			? array_slice($dependencies, 0, $dependency_count)
236
+			// otherwise just take the incoming array because nothing previously existed
237
+			: $dependencies;
238
+		return $registered;
239
+	}
240
+
241
+
242
+	/**
243
+	 * @param string $class_name
244
+	 * @param string $loader
245
+	 * @return bool
246
+	 * @throws DomainException
247
+	 */
248
+	public static function register_class_loader($class_name, $loader = 'load_core')
249
+	{
250
+		if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
251
+			throw new DomainException(
252
+				esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
253
+			);
254
+		}
255
+		// check that loader is callable or method starts with "load_" and exists in EE_Registry
256
+		if (! is_callable($loader)
257
+			&& (
258
+				strpos($loader, 'load_') !== 0
259
+				|| ! method_exists('EE_Registry', $loader)
260
+			)
261
+		) {
262
+			throw new DomainException(
263
+				sprintf(
264
+					esc_html__(
265
+						'"%1$s" is not a valid loader method on EE_Registry.',
266
+						'event_espresso'
267
+					),
268
+					$loader
269
+				)
270
+			);
271
+		}
272
+		$class_name = self::$_instance->getFqnForAlias($class_name);
273
+		if (! isset(self::$_instance->_class_loaders[ $class_name ])) {
274
+			self::$_instance->_class_loaders[ $class_name ] = $loader;
275
+			return true;
276
+		}
277
+		return false;
278
+	}
279
+
280
+
281
+	/**
282
+	 * @return array
283
+	 */
284
+	public function dependency_map()
285
+	{
286
+		return $this->_dependency_map;
287
+	}
288
+
289
+
290
+	/**
291
+	 * returns TRUE if dependency map contains a listing for the provided class name
292
+	 *
293
+	 * @param string $class_name
294
+	 * @return boolean
295
+	 */
296
+	public function has($class_name = '')
297
+	{
298
+		// all legacy models have the same dependencies
299
+		if (strpos($class_name, 'EEM_') === 0) {
300
+			$class_name = 'LEGACY_MODELS';
301
+		}
302
+		return isset($this->_dependency_map[ $class_name ]) ? true : false;
303
+	}
304
+
305
+
306
+	/**
307
+	 * returns TRUE if dependency map contains a listing for the provided class name AND dependency
308
+	 *
309
+	 * @param string $class_name
310
+	 * @param string $dependency
311
+	 * @return bool
312
+	 */
313
+	public function has_dependency_for_class($class_name = '', $dependency = '')
314
+	{
315
+		// all legacy models have the same dependencies
316
+		if (strpos($class_name, 'EEM_') === 0) {
317
+			$class_name = 'LEGACY_MODELS';
318
+		}
319
+		$dependency = $this->getFqnForAlias($dependency, $class_name);
320
+		return isset($this->_dependency_map[ $class_name ][ $dependency ])
321
+			? true
322
+			: false;
323
+	}
324
+
325
+
326
+	/**
327
+	 * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
328
+	 *
329
+	 * @param string $class_name
330
+	 * @param string $dependency
331
+	 * @return int
332
+	 */
333
+	public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
334
+	{
335
+		// all legacy models have the same dependencies
336
+		if (strpos($class_name, 'EEM_') === 0) {
337
+			$class_name = 'LEGACY_MODELS';
338
+		}
339
+		$dependency = $this->getFqnForAlias($dependency);
340
+		return $this->has_dependency_for_class($class_name, $dependency)
341
+			? $this->_dependency_map[ $class_name ][ $dependency ]
342
+			: EE_Dependency_Map::not_registered;
343
+	}
344
+
345
+
346
+	/**
347
+	 * @param string $class_name
348
+	 * @return string | Closure
349
+	 */
350
+	public function class_loader($class_name)
351
+	{
352
+		// all legacy models use load_model()
353
+		if (strpos($class_name, 'EEM_') === 0) {
354
+			return 'load_model';
355
+		}
356
+		// EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc
357
+		// perform strpos() first to avoid loading regex every time we load a class
358
+		if (strpos($class_name, 'EE_CPT_') === 0
359
+			&& preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name)
360
+		) {
361
+			return 'load_core';
362
+		}
363
+		$class_name = $this->getFqnForAlias($class_name);
364
+		return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : '';
365
+	}
366
+
367
+
368
+	/**
369
+	 * @return array
370
+	 */
371
+	public function class_loaders()
372
+	{
373
+		return $this->_class_loaders;
374
+	}
375
+
376
+
377
+	/**
378
+	 * adds an alias for a classname
379
+	 *
380
+	 * @param string $fqcn      the class name that should be used (concrete class to replace interface)
381
+	 * @param string $alias     the class name that would be type hinted for (abstract parent or interface)
382
+	 * @param string $for_class the class that has the dependency (is type hinting for the interface)
383
+	 */
384
+	public function add_alias($fqcn, $alias, $for_class = '')
385
+	{
386
+		$this->class_cache->addAlias($fqcn, $alias, $for_class);
387
+	}
388
+
389
+
390
+	/**
391
+	 * Returns TRUE if the provided fully qualified name IS an alias
392
+	 * WHY?
393
+	 * Because if a class is type hinting for a concretion,
394
+	 * then why would we need to find another class to supply it?
395
+	 * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
396
+	 * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
397
+	 * Don't go looking for some substitute.
398
+	 * Whereas if a class is type hinting for an interface...
399
+	 * then we need to find an actual class to use.
400
+	 * So the interface IS the alias for some other FQN,
401
+	 * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
402
+	 * represents some other class.
403
+	 *
404
+	 * @param string $fqn
405
+	 * @param string $for_class
406
+	 * @return bool
407
+	 */
408
+	public function isAlias($fqn = '', $for_class = '')
409
+	{
410
+		return $this->class_cache->isAlias($fqn, $for_class);
411
+	}
412
+
413
+
414
+	/**
415
+	 * Returns a FQN for provided alias if one exists, otherwise returns the original $alias
416
+	 * functions recursively, so that multiple aliases can be used to drill down to a FQN
417
+	 *  for example:
418
+	 *      if the following two entries were added to the _aliases array:
419
+	 *          array(
420
+	 *              'interface_alias'           => 'some\namespace\interface'
421
+	 *              'some\namespace\interface'  => 'some\namespace\classname'
422
+	 *          )
423
+	 *      then one could use EE_Registry::instance()->create( 'interface_alias' )
424
+	 *      to load an instance of 'some\namespace\classname'
425
+	 *
426
+	 * @param string $alias
427
+	 * @param string $for_class
428
+	 * @return string
429
+	 */
430
+	public function getFqnForAlias($alias = '', $for_class = '')
431
+	{
432
+		return (string) $this->class_cache->getFqnForAlias($alias, $for_class);
433
+	}
434
+
435
+
436
+	/**
437
+	 * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
438
+	 * if one exists, or whether a new object should be generated every time the requested class is loaded.
439
+	 * This is done by using the following class constants:
440
+	 *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
441
+	 *        EE_Dependency_Map::load_new_object - generates a new object every time
442
+	 */
443
+	protected function _register_core_dependencies()
444
+	{
445
+		$this->_dependency_map = array(
446
+			'EE_Request_Handler'                                                                                          => array(
447
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
448
+			),
449
+			'EE_System'                                                                                                   => array(
450
+				'EE_Registry'                                 => EE_Dependency_Map::load_from_cache,
451
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
452
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
453
+				'EE_Maintenance_Mode'                         => EE_Dependency_Map::load_from_cache,
454
+			),
455
+			'EE_Session'                                                                                                  => array(
456
+				'EventEspresso\core\services\cache\TransientCacheStorage'  => EE_Dependency_Map::load_from_cache,
457
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
458
+				'EventEspresso\core\services\request\Request'              => EE_Dependency_Map::load_from_cache,
459
+				'EventEspresso\core\services\session\SessionStartHandler'  => EE_Dependency_Map::load_from_cache,
460
+				'EE_Encryption'                                            => EE_Dependency_Map::load_from_cache,
461
+			),
462
+			'EE_Cart'                                                                                                     => array(
463
+				'EE_Session' => EE_Dependency_Map::load_from_cache,
464
+			),
465
+			'EE_Front_Controller'                                                                                         => array(
466
+				'EE_Registry'              => EE_Dependency_Map::load_from_cache,
467
+				'EE_Request_Handler'       => EE_Dependency_Map::load_from_cache,
468
+				'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache,
469
+			),
470
+			'EE_Messenger_Collection_Loader'                                                                              => array(
471
+				'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
472
+			),
473
+			'EE_Message_Type_Collection_Loader'                                                                           => array(
474
+				'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
475
+			),
476
+			'EE_Message_Resource_Manager'                                                                                 => array(
477
+				'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
478
+				'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
479
+				'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
480
+			),
481
+			'EE_Message_Factory'                                                                                          => array(
482
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
483
+			),
484
+			'EE_messages'                                                                                                 => array(
485
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
486
+			),
487
+			'EE_Messages_Generator'                                                                                       => array(
488
+				'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
489
+				'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
490
+				'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
491
+				'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
492
+			),
493
+			'EE_Messages_Processor'                                                                                       => array(
494
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
495
+			),
496
+			'EE_Messages_Queue'                                                                                           => array(
497
+				'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
498
+			),
499
+			'EE_Messages_Template_Defaults'                                                                               => array(
500
+				'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
501
+				'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
502
+			),
503
+			'EE_Message_To_Generate_From_Request'                                                                         => array(
504
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
505
+				'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
506
+			),
507
+			'EventEspresso\core\services\commands\CommandBus'                                                             => array(
508
+				'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
509
+			),
510
+			'EventEspresso\services\commands\CommandHandler'                                                              => array(
511
+				'EE_Registry'         => EE_Dependency_Map::load_from_cache,
512
+				'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
513
+			),
514
+			'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => array(
515
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
516
+			),
517
+			'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => array(
518
+				'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
519
+				'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
520
+			),
521
+			'EventEspresso\core\services\commands\CommandFactory'                                                         => array(
522
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
523
+			),
524
+			'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => array(
525
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
526
+			),
527
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => array(
528
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
529
+			),
530
+			'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => array(
531
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
532
+			),
533
+			'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => array(
534
+				'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
535
+			),
536
+			'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => array(
537
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
538
+			),
539
+			'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => array(
540
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
541
+			),
542
+			'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => array(
543
+				'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
544
+			),
545
+			'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array(
546
+				'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
547
+			),
548
+			'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => array(
549
+				'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
550
+			),
551
+			'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => array(
552
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
553
+			),
554
+			'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => array(
555
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
556
+			),
557
+			'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler'                                  => array(
558
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
559
+			),
560
+			'EventEspresso\core\services\database\TableManager'                                                           => array(
561
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
562
+			),
563
+			'EE_Data_Migration_Class_Base'                                                                                => array(
564
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
565
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
566
+			),
567
+			'EE_DMS_Core_4_1_0'                                                                                           => array(
568
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
569
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
570
+			),
571
+			'EE_DMS_Core_4_2_0'                                                                                           => array(
572
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
573
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
574
+			),
575
+			'EE_DMS_Core_4_3_0'                                                                                           => array(
576
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
577
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
578
+			),
579
+			'EE_DMS_Core_4_4_0'                                                                                           => array(
580
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
581
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
582
+			),
583
+			'EE_DMS_Core_4_5_0'                                                                                           => array(
584
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
585
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
586
+			),
587
+			'EE_DMS_Core_4_6_0'                                                                                           => array(
588
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
589
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
590
+			),
591
+			'EE_DMS_Core_4_7_0'                                                                                           => array(
592
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
593
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
594
+			),
595
+			'EE_DMS_Core_4_8_0'                                                                                           => array(
596
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
597
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
598
+			),
599
+			'EE_DMS_Core_4_9_0' => array(
600
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
601
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
602
+			),
603
+			'EE_DMS_Core_4_10_0' => array(
604
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
605
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
606
+				'EE_DMS_Core_4_9_0'                                  => EE_Dependency_Map::load_from_cache,
607
+			),
608
+			'EventEspresso\core\services\assets\I18nRegistry'                                                             => array(
609
+				array(),
610
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
611
+			),
612
+			'EventEspresso\core\services\assets\Registry'                                                                 => array(
613
+				'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
614
+				'EventEspresso\core\services\assets\I18nRegistry'    => EE_Dependency_Map::load_from_cache,
615
+			),
616
+			'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled'                                             => array(
617
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
618
+			),
619
+			'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout'                                              => array(
620
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
621
+			),
622
+			'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees'                                        => array(
623
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
624
+			),
625
+			'EventEspresso\core\domain\entities\shortcodes\EspressoEvents'                                                => array(
626
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
627
+			),
628
+			'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou'                                              => array(
629
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
630
+			),
631
+			'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector'                                        => array(
632
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
633
+			),
634
+			'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage'                                               => array(
635
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
636
+			),
637
+			'EventEspresso\core\services\cache\BasicCacheManager'                                                         => array(
638
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
639
+			),
640
+			'EventEspresso\core\services\cache\PostRelatedCacheManager'                                                   => array(
641
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
642
+			),
643
+			'EventEspresso\core\domain\services\validation\email\EmailValidationService'                                  => array(
644
+				'EE_Registration_Config'                     => EE_Dependency_Map::load_from_cache,
645
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
646
+			),
647
+			'EventEspresso\core\domain\values\EmailAddress'                                                               => array(
648
+				null,
649
+				'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache,
650
+			),
651
+			'EventEspresso\core\services\orm\ModelFieldFactory'                                                           => array(
652
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
653
+			),
654
+			'LEGACY_MODELS'                                                                                               => array(
655
+				null,
656
+				'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache,
657
+			),
658
+			'EE_Module_Request_Router'                                                                                    => array(
659
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
660
+			),
661
+			'EE_Registration_Processor'                                                                                   => array(
662
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
663
+			),
664
+			'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'                                      => array(
665
+				null,
666
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
667
+				'EventEspresso\core\services\request\Request'                         => EE_Dependency_Map::load_from_cache,
668
+			),
669
+			'EventEspresso\core\services\licensing\LicenseService'                                                        => array(
670
+				'EventEspresso\core\domain\services\pue\Stats'  => EE_Dependency_Map::load_from_cache,
671
+				'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache,
672
+			),
673
+			'EE_Admin_Transactions_List_Table'                                                                            => array(
674
+				null,
675
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
676
+			),
677
+			'EventEspresso\core\domain\services\pue\Stats'                                                                => array(
678
+				'EventEspresso\core\domain\services\pue\Config'        => EE_Dependency_Map::load_from_cache,
679
+				'EE_Maintenance_Mode'                                  => EE_Dependency_Map::load_from_cache,
680
+				'EventEspresso\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache,
681
+			),
682
+			'EventEspresso\core\domain\services\pue\Config'                                                               => array(
683
+				'EE_Network_Config' => EE_Dependency_Map::load_from_cache,
684
+				'EE_Config'         => EE_Dependency_Map::load_from_cache,
685
+			),
686
+			'EventEspresso\core\domain\services\pue\StatsGatherer'                                                        => array(
687
+				'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
688
+				'EEM_Event'          => EE_Dependency_Map::load_from_cache,
689
+				'EEM_Datetime'       => EE_Dependency_Map::load_from_cache,
690
+				'EEM_Ticket'         => EE_Dependency_Map::load_from_cache,
691
+				'EEM_Registration'   => EE_Dependency_Map::load_from_cache,
692
+				'EEM_Transaction'    => EE_Dependency_Map::load_from_cache,
693
+				'EE_Config'          => EE_Dependency_Map::load_from_cache,
694
+			),
695
+			'EventEspresso\core\domain\services\admin\ExitModal'                                                          => array(
696
+				'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache,
697
+			),
698
+			'EventEspresso\core\domain\services\admin\PluginUpsells'                                                      => array(
699
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
700
+			),
701
+			'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha'                                    => array(
702
+				'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
703
+				'EE_Session'             => EE_Dependency_Map::load_from_cache,
704
+			),
705
+			'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings'                                => array(
706
+				'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
707
+			),
708
+			'EventEspresso\modules\ticket_selector\ProcessTicketSelector'                                                 => array(
709
+				'EE_Core_Config'                                                          => EE_Dependency_Map::load_from_cache,
710
+				'EventEspresso\core\services\request\Request'                             => EE_Dependency_Map::load_from_cache,
711
+				'EE_Session'                                                              => EE_Dependency_Map::load_from_cache,
712
+				'EEM_Ticket'                                                              => EE_Dependency_Map::load_from_cache,
713
+				'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache,
714
+			),
715
+			'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker'                                     => array(
716
+				'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
717
+			),
718
+			'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'                              => array(
719
+				'EE_Core_Config'                             => EE_Dependency_Map::load_from_cache,
720
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
721
+			),
722
+			'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes'                                => array(
723
+				'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
724
+			),
725
+			'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies'                               => array(
726
+				'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
727
+			),
728
+			'EE_CPT_Strategy'                                                                                             => array(
729
+				'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
730
+				'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
731
+			),
732
+			'EventEspresso\core\services\loaders\ObjectIdentifier'                                                        => array(
733
+				'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
734
+			),
735
+			'EventEspresso\core\domain\services\assets\CoreAssetManager'                                                  => array(
736
+				'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
737
+				'EE_Currency_Config'                                 => EE_Dependency_Map::load_from_cache,
738
+				'EE_Template_Config'                                 => EE_Dependency_Map::load_from_cache,
739
+				'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
740
+				'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
741
+			),
742
+			'EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy' => array(
743
+				'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
744
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache
745
+			),
746
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendee' => array(
747
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
748
+			),
749
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendeeBillingData' => array(
750
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
751
+				'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache
752
+			),
753
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportCheckins' => array(
754
+				'EEM_Checkin' => EE_Dependency_Map::load_from_cache,
755
+			),
756
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportRegistration' => array(
757
+				'EEM_Registration' => EE_Dependency_Map::load_from_cache,
758
+			),
759
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportTransaction' => array(
760
+				'EEM_Transaction' => EE_Dependency_Map::load_from_cache,
761
+			),
762
+			'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAttendeeData' => array(
763
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
764
+			),
765
+			'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAnswers' => array(
766
+				'EEM_Answer' => EE_Dependency_Map::load_from_cache,
767
+				'EEM_Question' => EE_Dependency_Map::load_from_cache,
768
+			),
769
+			'EventEspresso\core\CPTs\CptQueryModifier' => array(
770
+				null,
771
+				null,
772
+				null,
773
+				'EE_Request_Handler'                          => EE_Dependency_Map::load_from_cache,
774
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
775
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
776
+			),
777
+			'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler' => array(
778
+				'EE_Registry' => EE_Dependency_Map::load_from_cache,
779
+				'EE_Config' => EE_Dependency_Map::load_from_cache
780
+			),
781
+			'EventEspresso\core\services\editor\BlockRegistrationManager'                                                 => array(
782
+				'EventEspresso\core\services\assets\BlockAssetManagerCollection' => EE_Dependency_Map::load_from_cache,
783
+				'EventEspresso\core\domain\entities\editor\BlockCollection'      => EE_Dependency_Map::load_from_cache,
784
+				'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => EE_Dependency_Map::load_from_cache,
785
+				'EventEspresso\core\services\request\Request'                    => EE_Dependency_Map::load_from_cache,
786
+			),
787
+			'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => array(
788
+				'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
789
+				'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
790
+				'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
791
+			),
792
+			'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => array(
793
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
794
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
795
+			),
796
+			'EventEspresso\core\domain\entities\editor\blocks\EventAttendees' => array(
797
+				'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => self::load_from_cache,
798
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
799
+				'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => self::load_from_cache,
800
+			),
801
+			'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => array(
802
+				'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache,
803
+				'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
804
+				'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache,
805
+			),
806
+			'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => array(
807
+				'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => EE_Dependency_Map::load_from_cache,
808
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
809
+			),
810
+			'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => array(
811
+				'EventEspresso\core\services\route_match\RouteMatchSpecificationCollection' => EE_Dependency_Map::load_from_cache,
812
+				'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => EE_Dependency_Map::load_from_cache,
813
+			),
814
+			'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => array(
815
+				'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => EE_Dependency_Map::load_from_cache
816
+			),
817
+			'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => array(
818
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
819
+			),
820
+			'EventEspresso\core\libraries\rest_api\controllers\model\Read' => array(
821
+				'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => EE_Dependency_Map::load_from_cache
822
+			),
823
+			'EventEspresso\core\libraries\rest_api\calculations\Datetime' => array(
824
+				'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
825
+				'EEM_Registration' => EE_Dependency_Map::load_from_cache
826
+			),
827
+			'EventEspresso\core\libraries\rest_api\calculations\Event' => array(
828
+				'EEM_Event' => EE_Dependency_Map::load_from_cache,
829
+				'EEM_Registration' => EE_Dependency_Map::load_from_cache
830
+			),
831
+			'EventEspresso\core\libraries\rest_api\calculations\Registration' => array(
832
+				'EEM_Registration' => EE_Dependency_Map::load_from_cache
833
+			),
834
+			'EventEspresso\core\services\session\SessionStartHandler' => array(
835
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
836
+			),
837
+			'EE_URL_Validation_Strategy' => array(
838
+				null,
839
+				null,
840
+				'EventEspresso\core\services\validators\URLValidator' => EE_Dependency_Map::load_from_cache
841
+			),
842
+			'EventEspresso\admin_pages\general_settings\OrganizationSettings' => array(
843
+				'EE_Registry'                                             => EE_Dependency_Map::load_from_cache,
844
+				'EE_Organization_Config'                                  => EE_Dependency_Map::load_from_cache,
845
+				'EE_Core_Config'                                          => EE_Dependency_Map::load_from_cache,
846
+				'EE_Network_Core_Config'                                  => EE_Dependency_Map::load_from_cache,
847
+				'EventEspresso\core\services\address\CountrySubRegionDao' => EE_Dependency_Map::load_from_cache,
848
+			),
849
+			'EventEspresso\core\services\address\CountrySubRegionDao' => array(
850
+				'EEM_State'                                            => EE_Dependency_Map::load_from_cache,
851
+				'EventEspresso\core\services\validators\JsonValidator' => EE_Dependency_Map::load_from_cache
852
+			),
853
+			'EventEspresso\core\domain\services\admin\ajax\WordpressHeartbeat' => array(
854
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
855
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
856
+			),
857
+			'EventEspresso\core\domain\services\admin\ajax\EventEditorHeartbeat' => array(
858
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
859
+				'EE_Environment_Config'            => EE_Dependency_Map::load_from_cache,
860
+			),
861
+			'EventEspresso\core\services\request\files\FilesDataHandler' => array(
862
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
863
+			),
864
+			'EventEspressoBatchRequest\BatchRequestProcessor' => [
865
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
866
+			],
867
+			'EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder' => [
868
+				null,
869
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
870
+				'EEM_Registration'  => EE_Dependency_Map::load_from_cache,
871
+			],
872
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\AttendeeFilterHeader' => [
873
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
874
+				'EEM_Attendee'  => EE_Dependency_Map::load_from_cache,
875
+			],
876
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\DateFilterHeader' => [
877
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
878
+				'EEM_Datetime'  => EE_Dependency_Map::load_from_cache,
879
+			],
880
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\EventFilterHeader' => [
881
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
882
+				'EEM_Event'  => EE_Dependency_Map::load_from_cache,
883
+			],
884
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\TicketFilterHeader' => [
885
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
886
+				'EEM_Ticket'  => EE_Dependency_Map::load_from_cache,
887
+			],
888
+			'EventEspresso\core\domain\services\converters\RestApiSpoofer' => [
889
+				'WP_REST_Server' => EE_Dependency_Map::load_from_cache,
890
+				'EED_Core_Rest_Api' => EE_Dependency_Map::load_from_cache,
891
+				'EventEspresso\core\libraries\rest_api\controllers\model\Read' => EE_Dependency_Map::load_from_cache,
892
+				null
893
+			],
894
+			'EventEspresso\core\domain\services\admin\events\default_settings\AdvancedEditorAdminFormSection'  => [
895
+				'EE_Admin_Config' => EE_Dependency_Map::load_from_cache
896
+			],
897
+			'EventEspresso\core\domain\services\admin\events\editor\AdvancedEditorEntityData'  => [
898
+				'EventEspresso\core\domain\services\converters\RestApiSpoofer' => EE_Dependency_Map::load_from_cache,
899
+				'EE_Admin_Config' => EE_Dependency_Map::load_from_cache,
900
+				'EEM_Datetime'    => EE_Dependency_Map::load_from_cache,
901
+				'EEM_Event'       => EE_Dependency_Map::load_from_cache,
902
+				'EEM_Price'       => EE_Dependency_Map::load_from_cache,
903
+				'EEM_Price_Type'  => EE_Dependency_Map::load_from_cache,
904
+				'EEM_Ticket'      => EE_Dependency_Map::load_from_cache,
905
+				'EEM_Venue'       => EE_Dependency_Map::load_from_cache,
906
+			],
907
+		);
908
+	}
909
+
910
+
911
+	/**
912
+	 * Registers how core classes are loaded.
913
+	 * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
914
+	 *        'EE_Request_Handler' => 'load_core'
915
+	 *        'EE_Messages_Queue'  => 'load_lib'
916
+	 *        'EEH_Debug_Tools'    => 'load_helper'
917
+	 * or, if greater control is required, by providing a custom closure. For example:
918
+	 *        'Some_Class' => function () {
919
+	 *            return new Some_Class();
920
+	 *        },
921
+	 * This is required for instantiating dependencies
922
+	 * where an interface has been type hinted in a class constructor. For example:
923
+	 *        'Required_Interface' => function () {
924
+	 *            return new A_Class_That_Implements_Required_Interface();
925
+	 *        },
926
+	 */
927
+	protected function _register_core_class_loaders()
928
+	{
929
+		$this->_class_loaders = array(
930
+			// load_core
931
+			'EE_Dependency_Map'                            => function () {
932
+				return $this;
933
+			},
934
+			'EE_Capabilities'                              => 'load_core',
935
+			'EE_Encryption'                                => 'load_core',
936
+			'EE_Front_Controller'                          => 'load_core',
937
+			'EE_Module_Request_Router'                     => 'load_core',
938
+			'EE_Registry'                                  => 'load_core',
939
+			'EE_Request'                                   => function () {
940
+				return $this->legacy_request;
941
+			},
942
+			'EventEspresso\core\services\request\Request'  => function () {
943
+				return $this->request;
944
+			},
945
+			'EventEspresso\core\services\request\Response' => function () {
946
+				return $this->response;
947
+			},
948
+			'EE_Base'                                      => 'load_core',
949
+			'EE_Request_Handler'                           => 'load_core',
950
+			'EE_Session'                                   => 'load_core',
951
+			'EE_Cron_Tasks'                                => 'load_core',
952
+			'EE_System'                                    => 'load_core',
953
+			'EE_Maintenance_Mode'                          => 'load_core',
954
+			'EE_Register_CPTs'                             => 'load_core',
955
+			'EE_Admin'                                     => 'load_core',
956
+			'EE_CPT_Strategy'                              => 'load_core',
957
+			// load_class
958
+			'EE_Registration_Processor'                    => 'load_class',
959
+			// load_lib
960
+			'EE_Message_Resource_Manager'                  => 'load_lib',
961
+			'EE_Message_Type_Collection'                   => 'load_lib',
962
+			'EE_Message_Type_Collection_Loader'            => 'load_lib',
963
+			'EE_Messenger_Collection'                      => 'load_lib',
964
+			'EE_Messenger_Collection_Loader'               => 'load_lib',
965
+			'EE_Messages_Processor'                        => 'load_lib',
966
+			'EE_Message_Repository'                        => 'load_lib',
967
+			'EE_Messages_Queue'                            => 'load_lib',
968
+			'EE_Messages_Data_Handler_Collection'          => 'load_lib',
969
+			'EE_Message_Template_Group_Collection'         => 'load_lib',
970
+			'EE_Payment_Method_Manager'                    => 'load_lib',
971
+			'EE_DMS_Core_4_1_0'                            => 'load_dms',
972
+			'EE_DMS_Core_4_2_0'                            => 'load_dms',
973
+			'EE_DMS_Core_4_3_0'                            => 'load_dms',
974
+			'EE_DMS_Core_4_5_0'                            => 'load_dms',
975
+			'EE_DMS_Core_4_6_0'                            => 'load_dms',
976
+			'EE_DMS_Core_4_7_0'                            => 'load_dms',
977
+			'EE_DMS_Core_4_8_0'                            => 'load_dms',
978
+			'EE_DMS_Core_4_9_0'                            => 'load_dms',
979
+			'EE_DMS_Core_4_10_0'                            => 'load_dms',
980
+			'EE_Messages_Generator'                        => function () {
981
+				return EE_Registry::instance()->load_lib(
982
+					'Messages_Generator',
983
+					array(),
984
+					false,
985
+					false
986
+				);
987
+			},
988
+			'EE_Messages_Template_Defaults'                => function ($arguments = array()) {
989
+				return EE_Registry::instance()->load_lib(
990
+					'Messages_Template_Defaults',
991
+					$arguments,
992
+					false,
993
+					false
994
+				);
995
+			},
996
+			// load_helper
997
+			'EEH_Parse_Shortcodes'                         => function () {
998
+				if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
999
+					return new EEH_Parse_Shortcodes();
1000
+				}
1001
+				return null;
1002
+			},
1003
+			'EE_Template_Config'                           => function () {
1004
+				return EE_Config::instance()->template_settings;
1005
+			},
1006
+			'EE_Currency_Config'                           => function () {
1007
+				return EE_Config::instance()->currency;
1008
+			},
1009
+			'EE_Registration_Config'                       => function () {
1010
+				return EE_Config::instance()->registration;
1011
+			},
1012
+			'EE_Core_Config'                               => function () {
1013
+				return EE_Config::instance()->core;
1014
+			},
1015
+			'EventEspresso\core\services\loaders\Loader'   => function () {
1016
+				return LoaderFactory::getLoader();
1017
+			},
1018
+			'EE_Network_Config'                            => function () {
1019
+				return EE_Network_Config::instance();
1020
+			},
1021
+			'EE_Config'                                    => function () {
1022
+				return EE_Config::instance();
1023
+			},
1024
+			'EventEspresso\core\domain\Domain'             => function () {
1025
+				return DomainFactory::getEventEspressoCoreDomain();
1026
+			},
1027
+			'EE_Admin_Config'                              => function () {
1028
+				return EE_Config::instance()->admin;
1029
+			},
1030
+			'EE_Organization_Config'                       => function () {
1031
+				return EE_Config::instance()->organization;
1032
+			},
1033
+			'EE_Network_Core_Config'                       => function () {
1034
+				return EE_Network_Config::instance()->core;
1035
+			},
1036
+			'EE_Environment_Config'                        => function () {
1037
+				return EE_Config::instance()->environment;
1038
+			},
1039
+			'EED_Core_Rest_Api'                            => static function () {
1040
+				return EED_Core_Rest_Api::instance();
1041
+			},
1042
+			'WP_REST_Server'                            => static function () {
1043
+				return rest_get_server();
1044
+			},
1045
+		);
1046
+	}
1047
+
1048
+
1049
+	/**
1050
+	 * can be used for supplying alternate names for classes,
1051
+	 * or for connecting interface names to instantiable classes
1052
+	 */
1053
+	protected function _register_core_aliases()
1054
+	{
1055
+		$aliases = array(
1056
+			'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
1057
+			'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
1058
+			'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
1059
+			'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
1060
+			'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
1061
+			'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
1062
+			'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
1063
+			'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
1064
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
1065
+			'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
1066
+			'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
1067
+			'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
1068
+			'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
1069
+			'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
1070
+			'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
1071
+			'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
1072
+			'CreateTransactionCommandHandler'                                              => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
1073
+			'CreateAttendeeCommandHandler'                                                 => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
1074
+			'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
1075
+			'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
1076
+			'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
1077
+			'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
1078
+			'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
1079
+			'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
1080
+			'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
1081
+			'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
1082
+			'CommandFactoryInterface'                                                      => 'EventEspresso\core\services\commands\CommandFactoryInterface',
1083
+			'EventEspresso\core\services\commands\CommandFactoryInterface'                 => 'EventEspresso\core\services\commands\CommandFactory',
1084
+			'EmailValidatorInterface'                                                      => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
1085
+			'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface'  => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
1086
+			'NoticeConverterInterface'                                                     => 'EventEspresso\core\services\notices\NoticeConverterInterface',
1087
+			'EventEspresso\core\services\notices\NoticeConverterInterface'                 => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
1088
+			'NoticesContainerInterface'                                                    => 'EventEspresso\core\services\notices\NoticesContainerInterface',
1089
+			'EventEspresso\core\services\notices\NoticesContainerInterface'                => 'EventEspresso\core\services\notices\NoticesContainer',
1090
+			'EventEspresso\core\services\request\RequestInterface'                         => 'EventEspresso\core\services\request\Request',
1091
+			'EventEspresso\core\services\request\ResponseInterface'                        => 'EventEspresso\core\services\request\Response',
1092
+			'EventEspresso\core\domain\DomainInterface'                                    => 'EventEspresso\core\domain\Domain',
1093
+			'Registration_Processor'                                                       => 'EE_Registration_Processor',
1094
+		);
1095
+		foreach ($aliases as $alias => $fqn) {
1096
+			if (is_array($fqn)) {
1097
+				foreach ($fqn as $class => $for_class) {
1098
+					$this->class_cache->addAlias($class, $alias, $for_class);
1099
+				}
1100
+				continue;
1101
+			}
1102
+			$this->class_cache->addAlias($fqn, $alias);
1103
+		}
1104
+		if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
1105
+			$this->class_cache->addAlias(
1106
+				'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices',
1107
+				'EventEspresso\core\services\notices\NoticeConverterInterface'
1108
+			);
1109
+		}
1110
+	}
1111
+
1112
+
1113
+	/**
1114
+	 * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
1115
+	 * request Primarily used by unit tests.
1116
+	 */
1117
+	public function reset()
1118
+	{
1119
+		$this->_register_core_class_loaders();
1120
+		$this->_register_core_dependencies();
1121
+	}
1122
+
1123
+
1124
+	/**
1125
+	 * PLZ NOTE: a better name for this method would be is_alias()
1126
+	 * because it returns TRUE if the provided fully qualified name IS an alias
1127
+	 * WHY?
1128
+	 * Because if a class is type hinting for a concretion,
1129
+	 * then why would we need to find another class to supply it?
1130
+	 * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
1131
+	 * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
1132
+	 * Don't go looking for some substitute.
1133
+	 * Whereas if a class is type hinting for an interface...
1134
+	 * then we need to find an actual class to use.
1135
+	 * So the interface IS the alias for some other FQN,
1136
+	 * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
1137
+	 * represents some other class.
1138
+	 *
1139
+	 * @deprecated 4.9.62.p
1140
+	 * @param string $fqn
1141
+	 * @param string $for_class
1142
+	 * @return bool
1143
+	 */
1144
+	public function has_alias($fqn = '', $for_class = '')
1145
+	{
1146
+		return $this->isAlias($fqn, $for_class);
1147
+	}
1148
+
1149
+
1150
+	/**
1151
+	 * PLZ NOTE: a better name for this method would be get_fqn_for_alias()
1152
+	 * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias
1153
+	 * functions recursively, so that multiple aliases can be used to drill down to a FQN
1154
+	 *  for example:
1155
+	 *      if the following two entries were added to the _aliases array:
1156
+	 *          array(
1157
+	 *              'interface_alias'           => 'some\namespace\interface'
1158
+	 *              'some\namespace\interface'  => 'some\namespace\classname'
1159
+	 *          )
1160
+	 *      then one could use EE_Registry::instance()->create( 'interface_alias' )
1161
+	 *      to load an instance of 'some\namespace\classname'
1162
+	 *
1163
+	 * @deprecated 4.9.62.p
1164
+	 * @param string $alias
1165
+	 * @param string $for_class
1166
+	 * @return string
1167
+	 */
1168
+	public function get_alias($alias = '', $for_class = '')
1169
+	{
1170
+		return $this->getFqnForAlias($alias, $for_class);
1171
+	}
1172 1172
 }
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
     public static function instance(ClassInterfaceCache $class_cache = null)
123 123
     {
124 124
         // check if class object is instantiated, and instantiated properly
125
-        if (! self::$_instance instanceof EE_Dependency_Map
125
+        if ( ! self::$_instance instanceof EE_Dependency_Map
126 126
             && $class_cache instanceof ClassInterfaceCache
127 127
         ) {
128 128
             self::$_instance = new EE_Dependency_Map($class_cache);
@@ -203,18 +203,18 @@  discard block
 block discarded – undo
203 203
     ) {
204 204
         $class = trim($class, '\\');
205 205
         $registered = false;
206
-        if (empty(self::$_instance->_dependency_map[ $class ])) {
207
-            self::$_instance->_dependency_map[ $class ] = array();
206
+        if (empty(self::$_instance->_dependency_map[$class])) {
207
+            self::$_instance->_dependency_map[$class] = array();
208 208
         }
209 209
         // we need to make sure that any aliases used when registering a dependency
210 210
         // get resolved to the correct class name
211 211
         foreach ($dependencies as $dependency => $load_source) {
212 212
             $alias = self::$_instance->getFqnForAlias($dependency);
213 213
             if ($overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
214
-                || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
214
+                || ! isset(self::$_instance->_dependency_map[$class][$alias])
215 215
             ) {
216
-                unset($dependencies[ $dependency ]);
217
-                $dependencies[ $alias ] = $load_source;
216
+                unset($dependencies[$dependency]);
217
+                $dependencies[$alias] = $load_source;
218 218
                 $registered = true;
219 219
             }
220 220
         }
@@ -224,13 +224,13 @@  discard block
 block discarded – undo
224 224
         // ie: with A = B + C, entries in B take precedence over duplicate entries in C
225 225
         // Union is way faster than array_merge() but should be used with caution...
226 226
         // especially with numerically indexed arrays
227
-        $dependencies += self::$_instance->_dependency_map[ $class ];
227
+        $dependencies += self::$_instance->_dependency_map[$class];
228 228
         // now we need to ensure that the resulting dependencies
229 229
         // array only has the entries that are required for the class
230 230
         // so first count how many dependencies were originally registered for the class
231
-        $dependency_count = count(self::$_instance->_dependency_map[ $class ]);
231
+        $dependency_count = count(self::$_instance->_dependency_map[$class]);
232 232
         // if that count is non-zero (meaning dependencies were already registered)
233
-        self::$_instance->_dependency_map[ $class ] = $dependency_count
233
+        self::$_instance->_dependency_map[$class] = $dependency_count
234 234
             // then truncate the  final array to match that count
235 235
             ? array_slice($dependencies, 0, $dependency_count)
236 236
             // otherwise just take the incoming array because nothing previously existed
@@ -247,13 +247,13 @@  discard block
 block discarded – undo
247 247
      */
248 248
     public static function register_class_loader($class_name, $loader = 'load_core')
249 249
     {
250
-        if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
250
+        if ( ! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
251 251
             throw new DomainException(
252 252
                 esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
253 253
             );
254 254
         }
255 255
         // check that loader is callable or method starts with "load_" and exists in EE_Registry
256
-        if (! is_callable($loader)
256
+        if ( ! is_callable($loader)
257 257
             && (
258 258
                 strpos($loader, 'load_') !== 0
259 259
                 || ! method_exists('EE_Registry', $loader)
@@ -270,8 +270,8 @@  discard block
 block discarded – undo
270 270
             );
271 271
         }
272 272
         $class_name = self::$_instance->getFqnForAlias($class_name);
273
-        if (! isset(self::$_instance->_class_loaders[ $class_name ])) {
274
-            self::$_instance->_class_loaders[ $class_name ] = $loader;
273
+        if ( ! isset(self::$_instance->_class_loaders[$class_name])) {
274
+            self::$_instance->_class_loaders[$class_name] = $loader;
275 275
             return true;
276 276
         }
277 277
         return false;
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
         if (strpos($class_name, 'EEM_') === 0) {
300 300
             $class_name = 'LEGACY_MODELS';
301 301
         }
302
-        return isset($this->_dependency_map[ $class_name ]) ? true : false;
302
+        return isset($this->_dependency_map[$class_name]) ? true : false;
303 303
     }
304 304
 
305 305
 
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
             $class_name = 'LEGACY_MODELS';
318 318
         }
319 319
         $dependency = $this->getFqnForAlias($dependency, $class_name);
320
-        return isset($this->_dependency_map[ $class_name ][ $dependency ])
320
+        return isset($this->_dependency_map[$class_name][$dependency])
321 321
             ? true
322 322
             : false;
323 323
     }
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
         }
339 339
         $dependency = $this->getFqnForAlias($dependency);
340 340
         return $this->has_dependency_for_class($class_name, $dependency)
341
-            ? $this->_dependency_map[ $class_name ][ $dependency ]
341
+            ? $this->_dependency_map[$class_name][$dependency]
342 342
             : EE_Dependency_Map::not_registered;
343 343
     }
344 344
 
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
             return 'load_core';
362 362
         }
363 363
         $class_name = $this->getFqnForAlias($class_name);
364
-        return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : '';
364
+        return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : '';
365 365
     }
366 366
 
367 367
 
@@ -928,7 +928,7 @@  discard block
 block discarded – undo
928 928
     {
929 929
         $this->_class_loaders = array(
930 930
             // load_core
931
-            'EE_Dependency_Map'                            => function () {
931
+            'EE_Dependency_Map'                            => function() {
932 932
                 return $this;
933 933
             },
934 934
             'EE_Capabilities'                              => 'load_core',
@@ -936,13 +936,13 @@  discard block
 block discarded – undo
936 936
             'EE_Front_Controller'                          => 'load_core',
937 937
             'EE_Module_Request_Router'                     => 'load_core',
938 938
             'EE_Registry'                                  => 'load_core',
939
-            'EE_Request'                                   => function () {
939
+            'EE_Request'                                   => function() {
940 940
                 return $this->legacy_request;
941 941
             },
942
-            'EventEspresso\core\services\request\Request'  => function () {
942
+            'EventEspresso\core\services\request\Request'  => function() {
943 943
                 return $this->request;
944 944
             },
945
-            'EventEspresso\core\services\request\Response' => function () {
945
+            'EventEspresso\core\services\request\Response' => function() {
946 946
                 return $this->response;
947 947
             },
948 948
             'EE_Base'                                      => 'load_core',
@@ -977,7 +977,7 @@  discard block
 block discarded – undo
977 977
             'EE_DMS_Core_4_8_0'                            => 'load_dms',
978 978
             'EE_DMS_Core_4_9_0'                            => 'load_dms',
979 979
             'EE_DMS_Core_4_10_0'                            => 'load_dms',
980
-            'EE_Messages_Generator'                        => function () {
980
+            'EE_Messages_Generator'                        => function() {
981 981
                 return EE_Registry::instance()->load_lib(
982 982
                     'Messages_Generator',
983 983
                     array(),
@@ -985,7 +985,7 @@  discard block
 block discarded – undo
985 985
                     false
986 986
                 );
987 987
             },
988
-            'EE_Messages_Template_Defaults'                => function ($arguments = array()) {
988
+            'EE_Messages_Template_Defaults'                => function($arguments = array()) {
989 989
                 return EE_Registry::instance()->load_lib(
990 990
                     'Messages_Template_Defaults',
991 991
                     $arguments,
@@ -994,52 +994,52 @@  discard block
 block discarded – undo
994 994
                 );
995 995
             },
996 996
             // load_helper
997
-            'EEH_Parse_Shortcodes'                         => function () {
997
+            'EEH_Parse_Shortcodes'                         => function() {
998 998
                 if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
999 999
                     return new EEH_Parse_Shortcodes();
1000 1000
                 }
1001 1001
                 return null;
1002 1002
             },
1003
-            'EE_Template_Config'                           => function () {
1003
+            'EE_Template_Config'                           => function() {
1004 1004
                 return EE_Config::instance()->template_settings;
1005 1005
             },
1006
-            'EE_Currency_Config'                           => function () {
1006
+            'EE_Currency_Config'                           => function() {
1007 1007
                 return EE_Config::instance()->currency;
1008 1008
             },
1009
-            'EE_Registration_Config'                       => function () {
1009
+            'EE_Registration_Config'                       => function() {
1010 1010
                 return EE_Config::instance()->registration;
1011 1011
             },
1012
-            'EE_Core_Config'                               => function () {
1012
+            'EE_Core_Config'                               => function() {
1013 1013
                 return EE_Config::instance()->core;
1014 1014
             },
1015
-            'EventEspresso\core\services\loaders\Loader'   => function () {
1015
+            'EventEspresso\core\services\loaders\Loader'   => function() {
1016 1016
                 return LoaderFactory::getLoader();
1017 1017
             },
1018
-            'EE_Network_Config'                            => function () {
1018
+            'EE_Network_Config'                            => function() {
1019 1019
                 return EE_Network_Config::instance();
1020 1020
             },
1021
-            'EE_Config'                                    => function () {
1021
+            'EE_Config'                                    => function() {
1022 1022
                 return EE_Config::instance();
1023 1023
             },
1024
-            'EventEspresso\core\domain\Domain'             => function () {
1024
+            'EventEspresso\core\domain\Domain'             => function() {
1025 1025
                 return DomainFactory::getEventEspressoCoreDomain();
1026 1026
             },
1027
-            'EE_Admin_Config'                              => function () {
1027
+            'EE_Admin_Config'                              => function() {
1028 1028
                 return EE_Config::instance()->admin;
1029 1029
             },
1030
-            'EE_Organization_Config'                       => function () {
1030
+            'EE_Organization_Config'                       => function() {
1031 1031
                 return EE_Config::instance()->organization;
1032 1032
             },
1033
-            'EE_Network_Core_Config'                       => function () {
1033
+            'EE_Network_Core_Config'                       => function() {
1034 1034
                 return EE_Network_Config::instance()->core;
1035 1035
             },
1036
-            'EE_Environment_Config'                        => function () {
1036
+            'EE_Environment_Config'                        => function() {
1037 1037
                 return EE_Config::instance()->environment;
1038 1038
             },
1039
-            'EED_Core_Rest_Api'                            => static function () {
1039
+            'EED_Core_Rest_Api'                            => static function() {
1040 1040
                 return EED_Core_Rest_Api::instance();
1041 1041
             },
1042
-            'WP_REST_Server'                            => static function () {
1042
+            'WP_REST_Server'                            => static function() {
1043 1043
                 return rest_get_server();
1044 1044
             },
1045 1045
         );
@@ -1101,7 +1101,7 @@  discard block
 block discarded – undo
1101 1101
             }
1102 1102
             $this->class_cache->addAlias($fqn, $alias);
1103 1103
         }
1104
-        if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
1104
+        if ( ! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
1105 1105
             $this->class_cache->addAlias(
1106 1106
                 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices',
1107 1107
                 'EventEspresso\core\services\notices\NoticeConverterInterface'
Please login to merge, or discard this patch.