Completed
Branch CASC/preview-page-2 (893921)
by
unknown
27:19 queued 19:03
created
admin_pages/events/Events_Admin_Page.core.php 3 patches
Unused Use Statements   -3 removed lines patch added patch discarded remove patch
@@ -1,11 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-use EventEspresso\admin_pages\events\form_sections\ConfirmEventDeletionForm;
4 3
 use EventEspresso\core\exceptions\InvalidDataTypeException;
5 4
 use EventEspresso\core\exceptions\InvalidInterfaceException;
6
-use EventEspresso\core\exceptions\UnexpectedEntityException;
7 5
 use EventEspresso\core\services\orm\tree_traversal\NodeGroupDao;
8
-use EventEspresso\core\services\orm\tree_traversal\ModelObjNode;
9 6
 
10 7
 /**
11 8
  * Events_Admin_Page
Please login to merge, or discard this patch.
Indentation   +2632 added lines, -2632 removed lines patch added patch discarded remove patch
@@ -19,2636 +19,2636 @@
 block discarded – undo
19 19
 class Events_Admin_Page extends EE_Admin_Page_CPT
20 20
 {
21 21
 
22
-    /**
23
-     * This will hold the event object for event_details screen.
24
-     *
25
-     * @access protected
26
-     * @var EE_Event $_event
27
-     */
28
-    protected $_event;
29
-
30
-
31
-    /**
32
-     * This will hold the category object for category_details screen.
33
-     *
34
-     * @var stdClass $_category
35
-     */
36
-    protected $_category;
37
-
38
-
39
-    /**
40
-     * This will hold the event model instance
41
-     *
42
-     * @var EEM_Event $_event_model
43
-     */
44
-    protected $_event_model;
45
-
46
-
47
-    /**
48
-     * @var EE_Event
49
-     */
50
-    protected $_cpt_model_obj = false;
51
-
52
-
53
-    /**
54
-     * @var NodeGroupDao
55
-     */
56
-    protected $model_obj_node_group_persister;
57
-
58
-    /**
59
-     * Initialize page props for this admin page group.
60
-     */
61
-    protected function _init_page_props()
62
-    {
63
-        $this->page_slug = EVENTS_PG_SLUG;
64
-        $this->page_label = EVENTS_LABEL;
65
-        $this->_admin_base_url = EVENTS_ADMIN_URL;
66
-        $this->_admin_base_path = EVENTS_ADMIN;
67
-        $this->_cpt_model_names = array(
68
-            'create_new' => 'EEM_Event',
69
-            'edit'       => 'EEM_Event',
70
-        );
71
-        $this->_cpt_edit_routes = array(
72
-            'espresso_events' => 'edit',
73
-        );
74
-        add_action(
75
-            'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object',
76
-            array($this, 'verify_event_edit'),
77
-            10,
78
-            2
79
-        );
80
-    }
81
-
82
-
83
-    /**
84
-     * Sets the ajax hooks used for this admin page group.
85
-     */
86
-    protected function _ajax_hooks()
87
-    {
88
-        add_action('wp_ajax_ee_save_timezone_setting', array($this, 'save_timezonestring_setting'));
89
-    }
90
-
91
-
92
-    /**
93
-     * Sets the page properties for this admin page group.
94
-     */
95
-    protected function _define_page_props()
96
-    {
97
-        $this->_admin_page_title = EVENTS_LABEL;
98
-        $this->_labels = array(
99
-            'buttons'      => array(
100
-                'add'             => esc_html__('Add New Event', 'event_espresso'),
101
-                'edit'            => esc_html__('Edit Event', 'event_espresso'),
102
-                'delete'          => esc_html__('Delete Event', 'event_espresso'),
103
-                'add_category'    => esc_html__('Add New Category', 'event_espresso'),
104
-                'edit_category'   => esc_html__('Edit Category', 'event_espresso'),
105
-                'delete_category' => esc_html__('Delete Category', 'event_espresso'),
106
-            ),
107
-            'editor_title' => array(
108
-                'espresso_events' => esc_html__('Enter event title here', 'event_espresso'),
109
-            ),
110
-            'publishbox'   => array(
111
-                'create_new'        => esc_html__('Save New Event', 'event_espresso'),
112
-                'edit'              => esc_html__('Update Event', 'event_espresso'),
113
-                'add_category'      => esc_html__('Save New Category', 'event_espresso'),
114
-                'edit_category'     => esc_html__('Update Category', 'event_espresso'),
115
-                'template_settings' => esc_html__('Update Settings', 'event_espresso'),
116
-            ),
117
-        );
118
-    }
119
-
120
-
121
-    /**
122
-     * Sets the page routes property for this admin page group.
123
-     */
124
-    protected function _set_page_routes()
125
-    {
126
-        // load formatter helper
127
-        // load field generator helper
128
-        // is there a evt_id in the request?
129
-        $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID'])
130
-            ? $this->_req_data['EVT_ID']
131
-            : 0;
132
-        $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id;
133
-        $this->_page_routes = array(
134
-            'default'                       => array(
135
-                'func'       => '_events_overview_list_table',
136
-                'capability' => 'ee_read_events',
137
-            ),
138
-            'create_new'                    => array(
139
-                'func'       => '_create_new_cpt_item',
140
-                'capability' => 'ee_edit_events',
141
-            ),
142
-            'edit'                          => array(
143
-                'func'       => '_edit_cpt_item',
144
-                'capability' => 'ee_edit_event',
145
-                'obj_id'     => $evt_id,
146
-            ),
147
-            'copy_event'                    => array(
148
-                'func'       => '_copy_events',
149
-                'capability' => 'ee_edit_event',
150
-                'obj_id'     => $evt_id,
151
-                'noheader'   => true,
152
-            ),
153
-            'trash_event'                   => array(
154
-                'func'       => '_trash_or_restore_event',
155
-                'args'       => array('event_status' => 'trash'),
156
-                'capability' => 'ee_delete_event',
157
-                'obj_id'     => $evt_id,
158
-                'noheader'   => true,
159
-            ),
160
-            'trash_events'                  => array(
161
-                'func'       => '_trash_or_restore_events',
162
-                'args'       => array('event_status' => 'trash'),
163
-                'capability' => 'ee_delete_events',
164
-                'noheader'   => true,
165
-            ),
166
-            'restore_event'                 => array(
167
-                'func'       => '_trash_or_restore_event',
168
-                'args'       => array('event_status' => 'draft'),
169
-                'capability' => 'ee_delete_event',
170
-                'obj_id'     => $evt_id,
171
-                'noheader'   => true,
172
-            ),
173
-            'restore_events'                => array(
174
-                'func'       => '_trash_or_restore_events',
175
-                'args'       => array('event_status' => 'draft'),
176
-                'capability' => 'ee_delete_events',
177
-                'noheader'   => true,
178
-            ),
179
-            'delete_event'                  => array(
180
-                'func'       => '_delete_event',
181
-                'capability' => 'ee_delete_event',
182
-                'obj_id'     => $evt_id,
183
-                'noheader'   => true,
184
-            ),
185
-            'delete_events'                 => array(
186
-                'func'       => '_delete_events',
187
-                'capability' => 'ee_delete_events',
188
-                'noheader'   => true,
189
-            ),
190
-            'view_report'                   => array(
191
-                'func'      => '_view_report',
192
-                'capablity' => 'ee_edit_events',
193
-            ),
194
-            'default_event_settings'        => array(
195
-                'func'       => '_default_event_settings',
196
-                'capability' => 'manage_options',
197
-            ),
198
-            'update_default_event_settings' => array(
199
-                'func'       => '_update_default_event_settings',
200
-                'capability' => 'manage_options',
201
-                'noheader'   => true,
202
-            ),
203
-            'template_settings'             => array(
204
-                'func'       => '_template_settings',
205
-                'capability' => 'manage_options',
206
-            ),
207
-            // event category tab related
208
-            'add_category'                  => array(
209
-                'func'       => '_category_details',
210
-                'capability' => 'ee_edit_event_category',
211
-                'args'       => array('add'),
212
-            ),
213
-            'edit_category'                 => array(
214
-                'func'       => '_category_details',
215
-                'capability' => 'ee_edit_event_category',
216
-                'args'       => array('edit'),
217
-            ),
218
-            'delete_categories'             => array(
219
-                'func'       => '_delete_categories',
220
-                'capability' => 'ee_delete_event_category',
221
-                'noheader'   => true,
222
-            ),
223
-            'delete_category'               => array(
224
-                'func'       => '_delete_categories',
225
-                'capability' => 'ee_delete_event_category',
226
-                'noheader'   => true,
227
-            ),
228
-            'insert_category'               => array(
229
-                'func'       => '_insert_or_update_category',
230
-                'args'       => array('new_category' => true),
231
-                'capability' => 'ee_edit_event_category',
232
-                'noheader'   => true,
233
-            ),
234
-            'update_category'               => array(
235
-                'func'       => '_insert_or_update_category',
236
-                'args'       => array('new_category' => false),
237
-                'capability' => 'ee_edit_event_category',
238
-                'noheader'   => true,
239
-            ),
240
-            'category_list'                 => array(
241
-                'func'       => '_category_list_table',
242
-                'capability' => 'ee_manage_event_categories',
243
-            ),
244
-            'preview_deletion' => [
245
-                'func' => 'previewDeletion',
246
-                'capability' => 'ee_delete_events',
247
-            ],
248
-            'confirm_deletion' => [
249
-                'func' => 'confirmDeletion',
250
-                'capability' => 'ee_delete_events',
251
-                'noheader' => true,
252
-            ]
253
-        );
254
-    }
255
-
256
-
257
-    /**
258
-     * Set the _page_config property for this admin page group.
259
-     */
260
-    protected function _set_page_config()
261
-    {
262
-        $this->_page_config = array(
263
-            'default'                => array(
264
-                'nav'           => array(
265
-                    'label' => esc_html__('Overview', 'event_espresso'),
266
-                    'order' => 10,
267
-                ),
268
-                'list_table'    => 'Events_Admin_List_Table',
269
-                'help_tabs'     => array(
270
-                    'events_overview_help_tab'                       => array(
271
-                        'title'    => esc_html__('Events Overview', 'event_espresso'),
272
-                        'filename' => 'events_overview',
273
-                    ),
274
-                    'events_overview_table_column_headings_help_tab' => array(
275
-                        'title'    => esc_html__('Events Overview Table Column Headings', 'event_espresso'),
276
-                        'filename' => 'events_overview_table_column_headings',
277
-                    ),
278
-                    'events_overview_filters_help_tab'               => array(
279
-                        'title'    => esc_html__('Events Overview Filters', 'event_espresso'),
280
-                        'filename' => 'events_overview_filters',
281
-                    ),
282
-                    'events_overview_view_help_tab'                  => array(
283
-                        'title'    => esc_html__('Events Overview Views', 'event_espresso'),
284
-                        'filename' => 'events_overview_views',
285
-                    ),
286
-                    'events_overview_other_help_tab'                 => array(
287
-                        'title'    => esc_html__('Events Overview Other', 'event_espresso'),
288
-                        'filename' => 'events_overview_other',
289
-                    ),
290
-                ),
291
-                'help_tour'     => array(
292
-                    'Event_Overview_Help_Tour',
293
-                    // 'New_Features_Test_Help_Tour' for testing multiple help tour
294
-                ),
295
-                'qtips'         => array(
296
-                    'EE_Event_List_Table_Tips',
297
-                ),
298
-                'require_nonce' => false,
299
-            ),
300
-            'create_new'             => array(
301
-                'nav'           => array(
302
-                    'label'      => esc_html__('Add Event', 'event_espresso'),
303
-                    'order'      => 5,
304
-                    'persistent' => false,
305
-                ),
306
-                'metaboxes'     => array('_register_event_editor_meta_boxes'),
307
-                'help_tabs'     => array(
308
-                    'event_editor_help_tab'                            => array(
309
-                        'title'    => esc_html__('Event Editor', 'event_espresso'),
310
-                        'filename' => 'event_editor',
311
-                    ),
312
-                    'event_editor_title_richtexteditor_help_tab'       => array(
313
-                        'title'    => esc_html__('Event Title & Rich Text Editor', 'event_espresso'),
314
-                        'filename' => 'event_editor_title_richtexteditor',
315
-                    ),
316
-                    'event_editor_venue_details_help_tab'              => array(
317
-                        'title'    => esc_html__('Event Venue Details', 'event_espresso'),
318
-                        'filename' => 'event_editor_venue_details',
319
-                    ),
320
-                    'event_editor_event_datetimes_help_tab'            => array(
321
-                        'title'    => esc_html__('Event Datetimes', 'event_espresso'),
322
-                        'filename' => 'event_editor_event_datetimes',
323
-                    ),
324
-                    'event_editor_event_tickets_help_tab'              => array(
325
-                        'title'    => esc_html__('Event Tickets', 'event_espresso'),
326
-                        'filename' => 'event_editor_event_tickets',
327
-                    ),
328
-                    'event_editor_event_registration_options_help_tab' => array(
329
-                        'title'    => esc_html__('Event Registration Options', 'event_espresso'),
330
-                        'filename' => 'event_editor_event_registration_options',
331
-                    ),
332
-                    'event_editor_tags_categories_help_tab'            => array(
333
-                        'title'    => esc_html__('Event Tags & Categories', 'event_espresso'),
334
-                        'filename' => 'event_editor_tags_categories',
335
-                    ),
336
-                    'event_editor_questions_registrants_help_tab'      => array(
337
-                        'title'    => esc_html__('Questions for Registrants', 'event_espresso'),
338
-                        'filename' => 'event_editor_questions_registrants',
339
-                    ),
340
-                    'event_editor_save_new_event_help_tab'             => array(
341
-                        'title'    => esc_html__('Save New Event', 'event_espresso'),
342
-                        'filename' => 'event_editor_save_new_event',
343
-                    ),
344
-                    'event_editor_other_help_tab'                      => array(
345
-                        'title'    => esc_html__('Event Other', 'event_espresso'),
346
-                        'filename' => 'event_editor_other',
347
-                    ),
348
-                ),
349
-                'help_tour'     => array(
350
-                    'Event_Editor_Help_Tour',
351
-                ),
352
-                'qtips'         => array('EE_Event_Editor_Decaf_Tips'),
353
-                'require_nonce' => false,
354
-            ),
355
-            'edit'                   => array(
356
-                'nav'           => array(
357
-                    'label'      => esc_html__('Edit Event', 'event_espresso'),
358
-                    'order'      => 5,
359
-                    'persistent' => false,
360
-                    'url'        => isset($this->_req_data['post'])
361
-                        ? EE_Admin_Page::add_query_args_and_nonce(
362
-                            array('post' => $this->_req_data['post'], 'action' => 'edit'),
363
-                            $this->_current_page_view_url
364
-                        )
365
-                        : $this->_admin_base_url,
366
-                ),
367
-                'metaboxes'     => array('_register_event_editor_meta_boxes'),
368
-                'help_tabs'     => array(
369
-                    'event_editor_help_tab'                            => array(
370
-                        'title'    => esc_html__('Event Editor', 'event_espresso'),
371
-                        'filename' => 'event_editor',
372
-                    ),
373
-                    'event_editor_title_richtexteditor_help_tab'       => array(
374
-                        'title'    => esc_html__('Event Title & Rich Text Editor', 'event_espresso'),
375
-                        'filename' => 'event_editor_title_richtexteditor',
376
-                    ),
377
-                    'event_editor_venue_details_help_tab'              => array(
378
-                        'title'    => esc_html__('Event Venue Details', 'event_espresso'),
379
-                        'filename' => 'event_editor_venue_details',
380
-                    ),
381
-                    'event_editor_event_datetimes_help_tab'            => array(
382
-                        'title'    => esc_html__('Event Datetimes', 'event_espresso'),
383
-                        'filename' => 'event_editor_event_datetimes',
384
-                    ),
385
-                    'event_editor_event_tickets_help_tab'              => array(
386
-                        'title'    => esc_html__('Event Tickets', 'event_espresso'),
387
-                        'filename' => 'event_editor_event_tickets',
388
-                    ),
389
-                    'event_editor_event_registration_options_help_tab' => array(
390
-                        'title'    => esc_html__('Event Registration Options', 'event_espresso'),
391
-                        'filename' => 'event_editor_event_registration_options',
392
-                    ),
393
-                    'event_editor_tags_categories_help_tab'            => array(
394
-                        'title'    => esc_html__('Event Tags & Categories', 'event_espresso'),
395
-                        'filename' => 'event_editor_tags_categories',
396
-                    ),
397
-                    'event_editor_questions_registrants_help_tab'      => array(
398
-                        'title'    => esc_html__('Questions for Registrants', 'event_espresso'),
399
-                        'filename' => 'event_editor_questions_registrants',
400
-                    ),
401
-                    'event_editor_save_new_event_help_tab'             => array(
402
-                        'title'    => esc_html__('Save New Event', 'event_espresso'),
403
-                        'filename' => 'event_editor_save_new_event',
404
-                    ),
405
-                    'event_editor_other_help_tab'                      => array(
406
-                        'title'    => esc_html__('Event Other', 'event_espresso'),
407
-                        'filename' => 'event_editor_other',
408
-                    ),
409
-                ),
410
-                'qtips'         => array('EE_Event_Editor_Decaf_Tips'),
411
-                'require_nonce' => false,
412
-            ),
413
-            'default_event_settings' => array(
414
-                'nav'           => array(
415
-                    'label' => esc_html__('Default Settings', 'event_espresso'),
416
-                    'order' => 40,
417
-                ),
418
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
419
-                'labels'        => array(
420
-                    'publishbox' => esc_html__('Update Settings', 'event_espresso'),
421
-                ),
422
-                'help_tabs'     => array(
423
-                    'default_settings_help_tab'        => array(
424
-                        'title'    => esc_html__('Default Event Settings', 'event_espresso'),
425
-                        'filename' => 'events_default_settings',
426
-                    ),
427
-                    'default_settings_status_help_tab' => array(
428
-                        'title'    => esc_html__('Default Registration Status', 'event_espresso'),
429
-                        'filename' => 'events_default_settings_status',
430
-                    ),
431
-                    'default_maximum_tickets_help_tab' => array(
432
-                        'title'    => esc_html__('Default Maximum Tickets Per Order', 'event_espresso'),
433
-                        'filename' => 'events_default_settings_max_tickets',
434
-                    ),
435
-                ),
436
-                'help_tour'     => array('Event_Default_Settings_Help_Tour'),
437
-                'require_nonce' => false,
438
-            ),
439
-            // template settings
440
-            'template_settings'      => array(
441
-                'nav'           => array(
442
-                    'label' => esc_html__('Templates', 'event_espresso'),
443
-                    'order' => 30,
444
-                ),
445
-                'metaboxes'     => $this->_default_espresso_metaboxes,
446
-                'help_tabs'     => array(
447
-                    'general_settings_templates_help_tab' => array(
448
-                        'title'    => esc_html__('Templates', 'event_espresso'),
449
-                        'filename' => 'general_settings_templates',
450
-                    ),
451
-                ),
452
-                'help_tour'     => array('Templates_Help_Tour'),
453
-                'require_nonce' => false,
454
-            ),
455
-            // event category stuff
456
-            'add_category'           => array(
457
-                'nav'           => array(
458
-                    'label'      => esc_html__('Add Category', 'event_espresso'),
459
-                    'order'      => 15,
460
-                    'persistent' => false,
461
-                ),
462
-                'help_tabs'     => array(
463
-                    'add_category_help_tab' => array(
464
-                        'title'    => esc_html__('Add New Event Category', 'event_espresso'),
465
-                        'filename' => 'events_add_category',
466
-                    ),
467
-                ),
468
-                'help_tour'     => array('Event_Add_Category_Help_Tour'),
469
-                'metaboxes'     => array('_publish_post_box'),
470
-                'require_nonce' => false,
471
-            ),
472
-            'edit_category'          => array(
473
-                'nav'           => array(
474
-                    'label'      => esc_html__('Edit Category', 'event_espresso'),
475
-                    'order'      => 15,
476
-                    'persistent' => false,
477
-                    'url'        => isset($this->_req_data['EVT_CAT_ID'])
478
-                        ? add_query_arg(
479
-                            array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']),
480
-                            $this->_current_page_view_url
481
-                        )
482
-                        : $this->_admin_base_url,
483
-                ),
484
-                'help_tabs'     => array(
485
-                    'edit_category_help_tab' => array(
486
-                        'title'    => esc_html__('Edit Event Category', 'event_espresso'),
487
-                        'filename' => 'events_edit_category',
488
-                    ),
489
-                ),
490
-                /*'help_tour' => array('Event_Edit_Category_Help_Tour'),*/
491
-                'metaboxes'     => array('_publish_post_box'),
492
-                'require_nonce' => false,
493
-            ),
494
-            'category_list'          => array(
495
-                'nav'           => array(
496
-                    'label' => esc_html__('Categories', 'event_espresso'),
497
-                    'order' => 20,
498
-                ),
499
-                'list_table'    => 'Event_Categories_Admin_List_Table',
500
-                'help_tabs'     => array(
501
-                    'events_categories_help_tab'                       => array(
502
-                        'title'    => esc_html__('Event Categories', 'event_espresso'),
503
-                        'filename' => 'events_categories',
504
-                    ),
505
-                    'events_categories_table_column_headings_help_tab' => array(
506
-                        'title'    => esc_html__('Event Categories Table Column Headings', 'event_espresso'),
507
-                        'filename' => 'events_categories_table_column_headings',
508
-                    ),
509
-                    'events_categories_view_help_tab'                  => array(
510
-                        'title'    => esc_html__('Event Categories Views', 'event_espresso'),
511
-                        'filename' => 'events_categories_views',
512
-                    ),
513
-                    'events_categories_other_help_tab'                 => array(
514
-                        'title'    => esc_html__('Event Categories Other', 'event_espresso'),
515
-                        'filename' => 'events_categories_other',
516
-                    ),
517
-                ),
518
-                'help_tour'     => array(
519
-                    'Event_Categories_Help_Tour',
520
-                ),
521
-                'metaboxes'     => $this->_default_espresso_metaboxes,
522
-                'require_nonce' => false,
523
-            ),
524
-            'preview_deletion'           => array(
525
-                'nav'           => array(
526
-                    'label'      => esc_html__('Preview Deletion', 'event_espresso'),
527
-                    'order'      => 15,
528
-                    'persistent' => false,
529
-                ),
530
-                'require_nonce' => false
531
-            )
532
-        );
533
-    }
534
-
535
-
536
-    /**
537
-     * Used to register any global screen options if necessary for every route in this admin page group.
538
-     */
539
-    protected function _add_screen_options()
540
-    {
541
-    }
542
-
543
-
544
-    /**
545
-     * Implementing the screen options for the 'default' route.
546
-     */
547
-    protected function _add_screen_options_default()
548
-    {
549
-        $this->_per_page_screen_option();
550
-    }
551
-
552
-
553
-    /**
554
-     * Implementing screen options for the category list route.
555
-     */
556
-    protected function _add_screen_options_category_list()
557
-    {
558
-        $page_title = $this->_admin_page_title;
559
-        $this->_admin_page_title = esc_html__('Categories', 'event_espresso');
560
-        $this->_per_page_screen_option();
561
-        $this->_admin_page_title = $page_title;
562
-    }
563
-
564
-
565
-    /**
566
-     * Used to register any global feature pointers for the admin page group.
567
-     */
568
-    protected function _add_feature_pointers()
569
-    {
570
-    }
571
-
572
-
573
-    /**
574
-     * Registers and enqueues any global scripts and styles for the entire admin page group.
575
-     */
576
-    public function load_scripts_styles()
577
-    {
578
-        wp_register_style(
579
-            'events-admin-css',
580
-            EVENTS_ASSETS_URL . 'events-admin-page.css',
581
-            array(),
582
-            EVENT_ESPRESSO_VERSION
583
-        );
584
-        wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION);
585
-        wp_enqueue_style('events-admin-css');
586
-        wp_enqueue_style('ee-cat-admin');
587
-        // todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details
588
-        // registers for all views
589
-        // scripts
590
-        wp_register_script(
591
-            'event_editor_js',
592
-            EVENTS_ASSETS_URL . 'event_editor.js',
593
-            array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'),
594
-            EVENT_ESPRESSO_VERSION,
595
-            true
596
-        );
597
-    }
598
-
599
-
600
-    /**
601
-     * Enqueuing scripts and styles specific to this view
602
-     */
603
-    public function load_scripts_styles_create_new()
604
-    {
605
-        $this->load_scripts_styles_edit();
606
-    }
607
-
608
-
609
-    /**
610
-     * Enqueuing scripts and styles specific to this view
611
-     */
612
-    public function load_scripts_styles_edit()
613
-    {
614
-        // styles
615
-        wp_enqueue_style('espresso-ui-theme');
616
-        wp_register_style(
617
-            'event-editor-css',
618
-            EVENTS_ASSETS_URL . 'event-editor.css',
619
-            array('ee-admin-css'),
620
-            EVENT_ESPRESSO_VERSION
621
-        );
622
-        wp_enqueue_style('event-editor-css');
623
-        // scripts
624
-        wp_register_script(
625
-            'event-datetime-metabox',
626
-            EVENTS_ASSETS_URL . 'event-datetime-metabox.js',
627
-            array('event_editor_js', 'ee-datepicker'),
628
-            EVENT_ESPRESSO_VERSION
629
-        );
630
-        wp_enqueue_script('event-datetime-metabox');
631
-    }
632
-
633
-
634
-    /**
635
-     * Populating the _views property for the category list table view.
636
-     */
637
-    protected function _set_list_table_views_category_list()
638
-    {
639
-        $this->_views = array(
640
-            'all' => array(
641
-                'slug'        => 'all',
642
-                'label'       => esc_html__('All', 'event_espresso'),
643
-                'count'       => 0,
644
-                'bulk_action' => array(
645
-                    'delete_categories' => esc_html__('Delete Permanently', 'event_espresso'),
646
-                ),
647
-            ),
648
-        );
649
-    }
650
-
651
-
652
-    /**
653
-     * For adding anything that fires on the admin_init hook for any route within this admin page group.
654
-     */
655
-    public function admin_init()
656
-    {
657
-        EE_Registry::$i18n_js_strings['image_confirm'] = esc_html__(
658
-            'Do you really want to delete this image? Please remember to update your event to complete the removal.',
659
-            'event_espresso'
660
-        );
661
-    }
662
-
663
-
664
-    /**
665
-     * For adding anything that should be triggered on the admin_notices hook for any route within this admin page
666
-     * group.
667
-     */
668
-    public function admin_notices()
669
-    {
670
-    }
671
-
672
-
673
-    /**
674
-     * For adding anything that should be triggered on the `admin_print_footer_scripts` hook for any route within
675
-     * this admin page group.
676
-     */
677
-    public function admin_footer_scripts()
678
-    {
679
-    }
680
-
681
-
682
-    /**
683
-     * Call this function to verify if an event is public and has tickets for sale.  If it does, then we need to show a
684
-     * warning (via EE_Error::add_error());
685
-     *
686
-     * @param  EE_Event $event Event object
687
-     * @param string    $req_type
688
-     * @return void
689
-     * @throws EE_Error
690
-     * @access public
691
-     */
692
-    public function verify_event_edit($event = null, $req_type = '')
693
-    {
694
-        // don't need to do this when processing
695
-        if (! empty($req_type)) {
696
-            return;
697
-        }
698
-        // no event?
699
-        if (empty($event)) {
700
-            // set event
701
-            $event = $this->_cpt_model_obj;
702
-        }
703
-        // STILL no event?
704
-        if (! $event instanceof EE_Event) {
705
-            return;
706
-        }
707
-        $orig_status = $event->status();
708
-        // first check if event is active.
709
-        if ($orig_status === EEM_Event::cancelled
710
-            || $orig_status === EEM_Event::postponed
711
-            || $event->is_expired()
712
-            || $event->is_inactive()
713
-        ) {
714
-            return;
715
-        }
716
-        // made it here so it IS active... next check that any of the tickets are sold.
717
-        if ($event->is_sold_out(true)) {
718
-            if ($orig_status !== EEM_Event::sold_out && $event->status() !== $orig_status) {
719
-                EE_Error::add_attention(
720
-                    sprintf(
721
-                        esc_html__(
722
-                            '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.',
723
-                            'event_espresso'
724
-                        ),
725
-                        EEH_Template::pretty_status(EEM_Event::sold_out, false, 'sentence')
726
-                    )
727
-                );
728
-            }
729
-            return;
730
-        } elseif ($orig_status === EEM_Event::sold_out) {
731
-            EE_Error::add_attention(
732
-                sprintf(
733
-                    esc_html__(
734
-                        '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.',
735
-                        'event_espresso'
736
-                    ),
737
-                    EEH_Template::pretty_status($event->status(), false, 'sentence')
738
-                )
739
-            );
740
-        }
741
-        // now we need to determine if the event has any tickets on sale.  If not then we dont' show the error
742
-        if (! $event->tickets_on_sale()) {
743
-            return;
744
-        }
745
-        // made it here so show warning
746
-        $this->_edit_event_warning();
747
-    }
748
-
749
-
750
-    /**
751
-     * This is the text used for when an event is being edited that is public and has tickets for sale.
752
-     * When needed, hook this into a EE_Error::add_error() notice.
753
-     *
754
-     * @access protected
755
-     * @return void
756
-     */
757
-    protected function _edit_event_warning()
758
-    {
759
-        // we don't want to add warnings during these requests
760
-        if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'editpost') {
761
-            return;
762
-        }
763
-        EE_Error::add_attention(
764
-            sprintf(
765
-                esc_html__(
766
-                    'Your event is open for registration. Making changes may disrupt any transactions in progress. %sLearn more%s',
767
-                    'event_espresso'
768
-                ),
769
-                '<a class="espresso-help-tab-lnk">',
770
-                '</a>'
771
-            )
772
-        );
773
-    }
774
-
775
-
776
-    /**
777
-     * When a user is creating a new event, notify them if they haven't set their timezone.
778
-     * Otherwise, do the normal logic
779
-     *
780
-     * @return string
781
-     * @throws \EE_Error
782
-     */
783
-    protected function _create_new_cpt_item()
784
-    {
785
-        $has_timezone_string = get_option('timezone_string');
786
-        // only nag them about setting their timezone if it's their first event, and they haven't already done it
787
-        if (! $has_timezone_string && ! EEM_Event::instance()->exists(array())) {
788
-            EE_Error::add_attention(
789
-                sprintf(
790
-                    __(
791
-                        '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',
792
-                        'event_espresso'
793
-                    ),
794
-                    '<br>',
795
-                    '<select id="timezone_string" name="timezone_string" aria-describedby="timezone-description">'
796
-                    . EEH_DTT_Helper::wp_timezone_choice('', EEH_DTT_Helper::get_user_locale())
797
-                    . '</select>',
798
-                    '<button class="button button-secondary timezone-submit">',
799
-                    '</button><span class="spinner"></span>'
800
-                ),
801
-                __FILE__,
802
-                __FUNCTION__,
803
-                __LINE__
804
-            );
805
-        }
806
-        return parent::_create_new_cpt_item();
807
-    }
808
-
809
-
810
-    /**
811
-     * Sets the _views property for the default route in this admin page group.
812
-     */
813
-    protected function _set_list_table_views_default()
814
-    {
815
-        $this->_views = array(
816
-            'all'   => array(
817
-                'slug'        => 'all',
818
-                'label'       => esc_html__('View All Events', 'event_espresso'),
819
-                'count'       => 0,
820
-                'bulk_action' => array(
821
-                    'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
822
-                ),
823
-            ),
824
-            'draft' => array(
825
-                'slug'        => 'draft',
826
-                'label'       => esc_html__('Draft', 'event_espresso'),
827
-                'count'       => 0,
828
-                'bulk_action' => array(
829
-                    'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
830
-                ),
831
-            ),
832
-        );
833
-        if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) {
834
-            $this->_views['trash'] = array(
835
-                'slug'        => 'trash',
836
-                'label'       => esc_html__('Trash', 'event_espresso'),
837
-                'count'       => 0,
838
-                'bulk_action' => array(
839
-                    'restore_events' => esc_html__('Restore From Trash', 'event_espresso'),
840
-                    'delete_events'  => esc_html__('Delete Permanently', 'event_espresso'),
841
-                ),
842
-            );
843
-        }
844
-    }
845
-
846
-
847
-    /**
848
-     * Provides the legend item array for the default list table view.
849
-     *
850
-     * @return array
851
-     */
852
-    protected function _event_legend_items()
853
-    {
854
-        $items = array(
855
-            'view_details'   => array(
856
-                'class' => 'dashicons dashicons-search',
857
-                'desc'  => esc_html__('View Event', 'event_espresso'),
858
-            ),
859
-            'edit_event'     => array(
860
-                'class' => 'ee-icon ee-icon-calendar-edit',
861
-                'desc'  => esc_html__('Edit Event Details', 'event_espresso'),
862
-            ),
863
-            'view_attendees' => array(
864
-                'class' => 'dashicons dashicons-groups',
865
-                'desc'  => esc_html__('View Registrations for Event', 'event_espresso'),
866
-            ),
867
-        );
868
-        $items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items);
869
-        $statuses = array(
870
-            'sold_out_status'  => array(
871
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out,
872
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::sold_out, false, 'sentence'),
873
-            ),
874
-            'active_status'    => array(
875
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active,
876
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::active, false, 'sentence'),
877
-            ),
878
-            'upcoming_status'  => array(
879
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming,
880
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::upcoming, false, 'sentence'),
881
-            ),
882
-            'postponed_status' => array(
883
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed,
884
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::postponed, false, 'sentence'),
885
-            ),
886
-            'cancelled_status' => array(
887
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled,
888
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::cancelled, false, 'sentence'),
889
-            ),
890
-            'expired_status'   => array(
891
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired,
892
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::expired, false, 'sentence'),
893
-            ),
894
-            'inactive_status'  => array(
895
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive,
896
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::inactive, false, 'sentence'),
897
-            ),
898
-        );
899
-        $statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses);
900
-        return array_merge($items, $statuses);
901
-    }
902
-
903
-
904
-    /**
905
-     * @return EEM_Event
906
-     */
907
-    private function _event_model()
908
-    {
909
-        if (! $this->_event_model instanceof EEM_Event) {
910
-            $this->_event_model = EE_Registry::instance()->load_model('Event');
911
-        }
912
-        return $this->_event_model;
913
-    }
914
-
915
-
916
-    /**
917
-     * Adds extra buttons to the WP CPT permalink field row.
918
-     * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter.
919
-     *
920
-     * @param  string $return    the current html
921
-     * @param  int    $id        the post id for the page
922
-     * @param  string $new_title What the title is
923
-     * @param  string $new_slug  what the slug is
924
-     * @return string            The new html string for the permalink area
925
-     */
926
-    public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug)
927
-    {
928
-        // make sure this is only when editing
929
-        if (! empty($id)) {
930
-            $post = get_post($id);
931
-            $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#"  tabindex="-1">'
932
-                       . esc_html__('Shortcode', 'event_espresso')
933
-                       . '</a> ';
934
-            $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id='
935
-                       . $post->ID
936
-                       . ']">';
937
-        }
938
-        return $return;
939
-    }
940
-
941
-
942
-    /**
943
-     * _events_overview_list_table
944
-     * This contains the logic for showing the events_overview list
945
-     *
946
-     * @access protected
947
-     * @return void
948
-     * @throws \EE_Error
949
-     */
950
-    protected function _events_overview_list_table()
951
-    {
952
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
953
-        $this->_template_args['after_list_table'] = ! empty($this->_template_args['after_list_table'])
954
-            ? (array) $this->_template_args['after_list_table']
955
-            : array();
956
-        $this->_template_args['after_list_table']['view_event_list_button'] = EEH_HTML::br()
957
-                . EEH_Template::get_button_or_link(
958
-                    get_post_type_archive_link('espresso_events'),
959
-                    esc_html__("View Event Archive Page", "event_espresso"),
960
-                    'button'
961
-                );
962
-        $this->_template_args['after_list_table']['legend'] = $this->_display_legend($this->_event_legend_items());
963
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
964
-            'create_new',
965
-            'add',
966
-            array(),
967
-            'add-new-h2'
968
-        );
969
-        $this->display_admin_list_table_page_with_no_sidebar();
970
-    }
971
-
972
-
973
-    /**
974
-     * this allows for extra misc actions in the default WP publish box
975
-     *
976
-     * @return void
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
-     */
1000
-    protected function _insert_update_cpt_item($post_id, $post)
1001
-    {
1002
-        if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') {
1003
-            // get out we're not processing an event save.
1004
-            return;
1005
-        }
1006
-        $event_values = array(
1007
-            'EVT_display_desc'                => ! empty($this->_req_data['display_desc']) ? 1 : 0,
1008
-            'EVT_display_ticket_selector'     => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0,
1009
-            'EVT_additional_limit'            => min(
1010
-                apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255),
1011
-                ! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : null
1012
-            ),
1013
-            'EVT_default_registration_status' => ! empty($this->_req_data['EVT_default_registration_status'])
1014
-                ? $this->_req_data['EVT_default_registration_status']
1015
-                : EE_Registry::instance()->CFG->registration->default_STS_ID,
1016
-            'EVT_member_only'                 => ! empty($this->_req_data['member_only']) ? 1 : 0,
1017
-            'EVT_allow_overflow'              => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0,
1018
-            'EVT_timezone_string'             => ! empty($this->_req_data['timezone_string'])
1019
-                ? $this->_req_data['timezone_string'] : null,
1020
-            'EVT_external_URL'                => ! empty($this->_req_data['externalURL'])
1021
-                ? $this->_req_data['externalURL'] : null,
1022
-            'EVT_phone'                       => ! empty($this->_req_data['event_phone'])
1023
-                ? $this->_req_data['event_phone'] : null,
1024
-        );
1025
-        // update event
1026
-        $success = $this->_event_model()->update_by_ID($event_values, $post_id);
1027
-        // 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!
1028
-        $get_one_where = array(
1029
-            $this->_event_model()->primary_key_name() => $post_id,
1030
-            'OR'                                      => array(
1031
-                'status'   => $post->post_status,
1032
-                // if trying to "Publish" a sold out event, it's status will get switched back to "sold_out" in the db,
1033
-                // but the returned object here has a status of "publish", so use the original post status as well
1034
-                'status*1' => $this->_req_data['original_post_status'],
1035
-            ),
1036
-        );
1037
-        $event = $this->_event_model()->get_one(array($get_one_where));
1038
-        // the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons.
1039
-        $event_update_callbacks = apply_filters(
1040
-            'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',
1041
-            array(
1042
-                array($this, '_default_venue_update'),
1043
-                array($this, '_default_tickets_update'),
1044
-            )
1045
-        );
1046
-        $att_success = true;
1047
-        foreach ($event_update_callbacks as $e_callback) {
1048
-            $_success = is_callable($e_callback)
1049
-                ? call_user_func($e_callback, $event, $this->_req_data)
1050
-                : false;
1051
-            // if ANY of these updates fail then we want the appropriate global error message
1052
-            $att_success = ! $att_success ? $att_success : $_success;
1053
-        }
1054
-        // any errors?
1055
-        if ($success && false === $att_success) {
1056
-            EE_Error::add_error(
1057
-                esc_html__(
1058
-                    'Event Details saved successfully but something went wrong with saving attachments.',
1059
-                    'event_espresso'
1060
-                ),
1061
-                __FILE__,
1062
-                __FUNCTION__,
1063
-                __LINE__
1064
-            );
1065
-        } elseif ($success === false) {
1066
-            EE_Error::add_error(
1067
-                esc_html__('Event Details did not save successfully.', 'event_espresso'),
1068
-                __FILE__,
1069
-                __FUNCTION__,
1070
-                __LINE__
1071
-            );
1072
-        }
1073
-    }
1074
-
1075
-
1076
-    /**
1077
-     * @see parent::restore_item()
1078
-     * @param int $post_id
1079
-     * @param int $revision_id
1080
-     */
1081
-    protected function _restore_cpt_item($post_id, $revision_id)
1082
-    {
1083
-        // copy existing event meta to new post
1084
-        $post_evt = $this->_event_model()->get_one_by_ID($post_id);
1085
-        if ($post_evt instanceof EE_Event) {
1086
-            // meta revision restore
1087
-            $post_evt->restore_revision($revision_id);
1088
-            // related objs restore
1089
-            $post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price'));
1090
-        }
1091
-    }
1092
-
1093
-
1094
-    /**
1095
-     * Attach the venue to the Event
1096
-     *
1097
-     * @param  \EE_Event $evtobj Event Object to add the venue to
1098
-     * @param  array     $data   The request data from the form
1099
-     * @return bool           Success or fail.
1100
-     */
1101
-    protected function _default_venue_update(\EE_Event $evtobj, $data)
1102
-    {
1103
-        require_once(EE_MODELS . 'EEM_Venue.model.php');
1104
-        $venue_model = EE_Registry::instance()->load_model('Venue');
1105
-        $rows_affected = null;
1106
-        $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null;
1107
-        // very important.  If we don't have a venue name...
1108
-        // then we'll get out because not necessary to create empty venue
1109
-        if (empty($data['venue_title'])) {
1110
-            return false;
1111
-        }
1112
-        $venue_array = array(
1113
-            'VNU_wp_user'         => $evtobj->get('EVT_wp_user'),
1114
-            'VNU_name'            => ! empty($data['venue_title']) ? $data['venue_title'] : null,
1115
-            'VNU_desc'            => ! empty($data['venue_description']) ? $data['venue_description'] : null,
1116
-            'VNU_identifier'      => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : null,
1117
-            'VNU_short_desc'      => ! empty($data['venue_short_description']) ? $data['venue_short_description']
1118
-                : null,
1119
-            'VNU_address'         => ! empty($data['address']) ? $data['address'] : null,
1120
-            'VNU_address2'        => ! empty($data['address2']) ? $data['address2'] : null,
1121
-            'VNU_city'            => ! empty($data['city']) ? $data['city'] : null,
1122
-            'STA_ID'              => ! empty($data['state']) ? $data['state'] : null,
1123
-            'CNT_ISO'             => ! empty($data['countries']) ? $data['countries'] : null,
1124
-            'VNU_zip'             => ! empty($data['zip']) ? $data['zip'] : null,
1125
-            'VNU_phone'           => ! empty($data['venue_phone']) ? $data['venue_phone'] : null,
1126
-            'VNU_capacity'        => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : null,
1127
-            'VNU_url'             => ! empty($data['venue_url']) ? $data['venue_url'] : null,
1128
-            'VNU_virtual_phone'   => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : null,
1129
-            'VNU_virtual_url'     => ! empty($data['virtual_url']) ? $data['virtual_url'] : null,
1130
-            'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0,
1131
-            'status'              => 'publish',
1132
-        );
1133
-        // if we've got the venue_id then we're just updating the existing venue so let's do that and then get out.
1134
-        if (! empty($venue_id)) {
1135
-            $update_where = array($venue_model->primary_key_name() => $venue_id);
1136
-            $rows_affected = $venue_model->update($venue_array, array($update_where));
1137
-            // 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.
1138
-            $evtobj->_add_relation_to($venue_id, 'Venue');
1139
-            return $rows_affected > 0 ? true : false;
1140
-        } else {
1141
-            // we insert the venue
1142
-            $venue_id = $venue_model->insert($venue_array);
1143
-            $evtobj->_add_relation_to($venue_id, 'Venue');
1144
-            return ! empty($venue_id) ? true : false;
1145
-        }
1146
-        // when we have the ancestor come in it's already been handled by the revision save.
1147
-    }
1148
-
1149
-
1150
-    /**
1151
-     * Handles saving everything related to Tickets (datetimes, tickets, prices)
1152
-     *
1153
-     * @param  EE_Event $evtobj The Event object we're attaching data to
1154
-     * @param  array    $data   The request data from the form
1155
-     * @return array
1156
-     */
1157
-    protected function _default_tickets_update(EE_Event $evtobj, $data)
1158
-    {
1159
-        $success = true;
1160
-        $saved_dtt = null;
1161
-        $saved_tickets = array();
1162
-        $incoming_date_formats = array('Y-m-d', 'h:i a');
1163
-        foreach ($data['edit_event_datetimes'] as $row => $dtt) {
1164
-            // trim all values to ensure any excess whitespace is removed.
1165
-            $dtt = array_map('trim', $dtt);
1166
-            $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end']
1167
-                : $dtt['DTT_EVT_start'];
1168
-            $datetime_values = array(
1169
-                'DTT_ID'        => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : null,
1170
-                'DTT_EVT_start' => $dtt['DTT_EVT_start'],
1171
-                'DTT_EVT_end'   => $dtt['DTT_EVT_end'],
1172
-                'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'],
1173
-                'DTT_order'     => $row,
1174
-            );
1175
-            // 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.
1176
-            if (! empty($dtt['DTT_ID'])) {
1177
-                $DTM = EE_Registry::instance()
1178
-                                  ->load_model('Datetime', array($evtobj->get_timezone()))
1179
-                                  ->get_one_by_ID($dtt['DTT_ID']);
1180
-                $DTM->set_date_format($incoming_date_formats[0]);
1181
-                $DTM->set_time_format($incoming_date_formats[1]);
1182
-                foreach ($datetime_values as $field => $value) {
1183
-                    $DTM->set($field, $value);
1184
-                }
1185
-                // 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.
1186
-                $saved_dtts[ $DTM->ID() ] = $DTM;
1187
-            } else {
1188
-                $DTM = EE_Registry::instance()->load_class(
1189
-                    'Datetime',
1190
-                    array($datetime_values, $evtobj->get_timezone(), $incoming_date_formats),
1191
-                    false,
1192
-                    false
1193
-                );
1194
-                foreach ($datetime_values as $field => $value) {
1195
-                    $DTM->set($field, $value);
1196
-                }
1197
-            }
1198
-            $DTM->save();
1199
-            $DTT = $evtobj->_add_relation_to($DTM, 'Datetime');
1200
-            // load DTT helper
1201
-            // 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.
1202
-            if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) {
1203
-                $DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start'));
1204
-                $DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days');
1205
-                $DTT->save();
1206
-            }
1207
-            // 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.
1208
-            $saved_dtt = $DTT;
1209
-            $success = ! $success ? $success : $DTT;
1210
-            // if ANY of these updates fail then we want the appropriate global error message.
1211
-            // //todo this is actually sucky we need a better error message but this is what it is for now.
1212
-        }
1213
-        // no dtts get deleted so we don't do any of that logic here.
1214
-        // update tickets next
1215
-        $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array();
1216
-        foreach ($data['edit_tickets'] as $row => $tkt) {
1217
-            $incoming_date_formats = array('Y-m-d', 'h:i a');
1218
-            $update_prices = false;
1219
-            $ticket_price = isset($data['edit_prices'][ $row ][1]['PRC_amount'])
1220
-                ? $data['edit_prices'][ $row ][1]['PRC_amount'] : 0;
1221
-            // trim inputs to ensure any excess whitespace is removed.
1222
-            $tkt = array_map('trim', $tkt);
1223
-            if (empty($tkt['TKT_start_date'])) {
1224
-                // let's use now in the set timezone.
1225
-                $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone()));
1226
-                $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0] . ' ' . $incoming_date_formats[1]);
1227
-            }
1228
-            if (empty($tkt['TKT_end_date'])) {
1229
-                // use the start date of the first datetime
1230
-                $dtt = $evtobj->first_datetime();
1231
-                $tkt['TKT_end_date'] = $dtt->start_date_and_time(
1232
-                    $incoming_date_formats[0],
1233
-                    $incoming_date_formats[1]
1234
-                );
1235
-            }
1236
-            $TKT_values = array(
1237
-                'TKT_ID'          => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null,
1238
-                'TTM_ID'          => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0,
1239
-                'TKT_name'        => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '',
1240
-                'TKT_description' => ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '',
1241
-                'TKT_start_date'  => $tkt['TKT_start_date'],
1242
-                'TKT_end_date'    => $tkt['TKT_end_date'],
1243
-                'TKT_qty'         => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'],
1244
-                'TKT_uses'        => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'],
1245
-                'TKT_min'         => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'],
1246
-                'TKT_max'         => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'],
1247
-                'TKT_row'         => $row,
1248
-                'TKT_order'       => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row,
1249
-                'TKT_price'       => $ticket_price,
1250
-            );
1251
-            // 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.
1252
-            if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) {
1253
-                $TKT_values['TKT_ID'] = 0;
1254
-                $TKT_values['TKT_is_default'] = 0;
1255
-                $TKT_values['TKT_price'] = $ticket_price;
1256
-                $update_prices = true;
1257
-            }
1258
-            // if we have a TKT_ID then we need to get that existing TKT_obj and update it
1259
-            // 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.
1260
-            // 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.
1261
-            if (! empty($tkt['TKT_ID'])) {
1262
-                $TKT = EE_Registry::instance()
1263
-                                  ->load_model('Ticket', array($evtobj->get_timezone()))
1264
-                                  ->get_one_by_ID($tkt['TKT_ID']);
1265
-                if ($TKT instanceof EE_Ticket) {
1266
-                    $ticket_sold = $TKT->count_related(
1267
-                        'Registration',
1268
-                        array(
1269
-                            array(
1270
-                                'STS_ID' => array(
1271
-                                    'NOT IN',
1272
-                                    array(EEM_Registration::status_id_incomplete),
1273
-                                ),
1274
-                            ),
1275
-                        )
1276
-                    ) > 0 ? true : false;
1277
-                    // let's just check the total price for the existing ticket and determine if it matches the new total price.  if they are different then we create a new ticket (if tkts sold) if they aren't different then we go ahead and modify existing ticket.
1278
-                    $create_new_TKT = $ticket_sold && $ticket_price != $TKT->get('TKT_price')
1279
-                                      && ! $TKT->get('TKT_deleted');
1280
-                    $TKT->set_date_format($incoming_date_formats[0]);
1281
-                    $TKT->set_time_format($incoming_date_formats[1]);
1282
-                    // set new values
1283
-                    foreach ($TKT_values as $field => $value) {
1284
-                        if ($field == 'TKT_qty') {
1285
-                            $TKT->set_qty($value);
1286
-                        } else {
1287
-                            $TKT->set($field, $value);
1288
-                        }
1289
-                    }
1290
-                    // if $create_new_TKT is false then we can safely update the existing ticket.  Otherwise we have to create a new ticket.
1291
-                    if ($create_new_TKT) {
1292
-                        // archive the old ticket first
1293
-                        $TKT->set('TKT_deleted', 1);
1294
-                        $TKT->save();
1295
-                        // make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine.
1296
-                        $saved_tickets[ $TKT->ID() ] = $TKT;
1297
-                        // 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.
1298
-                        $TKT = clone $TKT;
1299
-                        $TKT->set('TKT_ID', 0);
1300
-                        $TKT->set('TKT_deleted', 0);
1301
-                        $TKT->set('TKT_price', $ticket_price);
1302
-                        $TKT->set('TKT_sold', 0);
1303
-                        // now we need to make sure that $new prices are created as well and attached to new ticket.
1304
-                        $update_prices = true;
1305
-                    }
1306
-                    // make sure price is set if it hasn't been already
1307
-                    $TKT->set('TKT_price', $ticket_price);
1308
-                }
1309
-            } else {
1310
-                // no TKT_id so a new TKT
1311
-                $TKT_values['TKT_price'] = $ticket_price;
1312
-                $TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), false, false);
1313
-                if ($TKT instanceof EE_Ticket) {
1314
-                    // need to reset values to properly account for the date formats
1315
-                    $TKT->set_date_format($incoming_date_formats[0]);
1316
-                    $TKT->set_time_format($incoming_date_formats[1]);
1317
-                    $TKT->set_timezone($evtobj->get_timezone());
1318
-                    // set new values
1319
-                    foreach ($TKT_values as $field => $value) {
1320
-                        if ($field == 'TKT_qty') {
1321
-                            $TKT->set_qty($value);
1322
-                        } else {
1323
-                            $TKT->set($field, $value);
1324
-                        }
1325
-                    }
1326
-                    $update_prices = true;
1327
-                }
1328
-            }
1329
-            // cap ticket qty by datetime reg limits
1330
-            $TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit')));
1331
-            // update ticket.
1332
-            $TKT->save();
1333
-            // 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.
1334
-            if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) {
1335
-                $TKT->set('TKT_end_date', $TKT->get('TKT_start_date'));
1336
-                $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days');
1337
-                $TKT->save();
1338
-            }
1339
-            // initially let's add the ticket to the dtt
1340
-            $saved_dtt->_add_relation_to($TKT, 'Ticket');
1341
-            $saved_tickets[ $TKT->ID() ] = $TKT;
1342
-            // add prices to ticket
1343
-            $this->_add_prices_to_ticket($data['edit_prices'][ $row ], $TKT, $update_prices);
1344
-        }
1345
-        // 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.
1346
-        $old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets;
1347
-        $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets));
1348
-        foreach ($tickets_removed as $id) {
1349
-            $id = absint($id);
1350
-            // get the ticket for this id
1351
-            $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id);
1352
-            // 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)
1353
-            $dtts = $tkt_to_remove->get_many_related('Datetime');
1354
-            foreach ($dtts as $dtt) {
1355
-                $tkt_to_remove->_remove_relation_to($dtt, 'Datetime');
1356
-            }
1357
-            // 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))
1358
-            $tkt_to_remove->delete_related_permanently('Price');
1359
-            // finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships)
1360
-            $tkt_to_remove->delete_permanently();
1361
-        }
1362
-        return array($saved_dtt, $saved_tickets);
1363
-    }
1364
-
1365
-
1366
-    /**
1367
-     * This attaches a list of given prices to a ticket.
1368
-     * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change
1369
-     * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old
1370
-     * price info and prices are automatically "archived" via the ticket.
1371
-     *
1372
-     * @access  private
1373
-     * @param array     $prices     Array of prices from the form.
1374
-     * @param EE_Ticket $ticket     EE_Ticket object that prices are being attached to.
1375
-     * @param bool      $new_prices Whether attach existing incoming prices or create new ones.
1376
-     * @return  void
1377
-     */
1378
-    private function _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = false)
1379
-    {
1380
-        foreach ($prices as $row => $prc) {
1381
-            $PRC_values = array(
1382
-                'PRC_ID'         => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null,
1383
-                'PRT_ID'         => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null,
1384
-                'PRC_amount'     => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0,
1385
-                'PRC_name'       => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '',
1386
-                'PRC_desc'       => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '',
1387
-                'PRC_is_default' => 0, // make sure prices are NOT set as default from this context
1388
-                'PRC_order'      => $row,
1389
-            );
1390
-            if ($new_prices || empty($PRC_values['PRC_ID'])) {
1391
-                $PRC_values['PRC_ID'] = 0;
1392
-                $PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), false, false);
1393
-            } else {
1394
-                $PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']);
1395
-                // update this price with new values
1396
-                foreach ($PRC_values as $field => $newprc) {
1397
-                    $PRC->set($field, $newprc);
1398
-                }
1399
-                $PRC->save();
1400
-            }
1401
-            $ticket->_add_relation_to($PRC, 'Price');
1402
-        }
1403
-    }
1404
-
1405
-
1406
-    /**
1407
-     * Add in our autosave ajax handlers
1408
-     *
1409
-     */
1410
-    protected function _ee_autosave_create_new()
1411
-    {
1412
-    }
1413
-
1414
-
1415
-    /**
1416
-     * More autosave handlers.
1417
-     */
1418
-    protected function _ee_autosave_edit()
1419
-    {
1420
-        return; // TEMPORARILY EXITING CAUSE THIS IS A TODO
1421
-    }
1422
-
1423
-
1424
-    /**
1425
-     *    _generate_publish_box_extra_content
1426
-     */
1427
-    private function _generate_publish_box_extra_content()
1428
-    {
1429
-        // load formatter helper
1430
-        // args for getting related registrations
1431
-        $approved_query_args = array(
1432
-            array(
1433
-                'REG_deleted' => 0,
1434
-                'STS_ID'      => EEM_Registration::status_id_approved,
1435
-            ),
1436
-        );
1437
-        $not_approved_query_args = array(
1438
-            array(
1439
-                'REG_deleted' => 0,
1440
-                'STS_ID'      => EEM_Registration::status_id_not_approved,
1441
-            ),
1442
-        );
1443
-        $pending_payment_query_args = array(
1444
-            array(
1445
-                'REG_deleted' => 0,
1446
-                'STS_ID'      => EEM_Registration::status_id_pending_payment,
1447
-            ),
1448
-        );
1449
-        // publish box
1450
-        $publish_box_extra_args = array(
1451
-            'view_approved_reg_url'        => add_query_arg(
1452
-                array(
1453
-                    'action'      => 'default',
1454
-                    'event_id'    => $this->_cpt_model_obj->ID(),
1455
-                    '_reg_status' => EEM_Registration::status_id_approved,
1456
-                ),
1457
-                REG_ADMIN_URL
1458
-            ),
1459
-            'view_not_approved_reg_url'    => add_query_arg(
1460
-                array(
1461
-                    'action'      => 'default',
1462
-                    'event_id'    => $this->_cpt_model_obj->ID(),
1463
-                    '_reg_status' => EEM_Registration::status_id_not_approved,
1464
-                ),
1465
-                REG_ADMIN_URL
1466
-            ),
1467
-            'view_pending_payment_reg_url' => add_query_arg(
1468
-                array(
1469
-                    'action'      => 'default',
1470
-                    'event_id'    => $this->_cpt_model_obj->ID(),
1471
-                    '_reg_status' => EEM_Registration::status_id_pending_payment,
1472
-                ),
1473
-                REG_ADMIN_URL
1474
-            ),
1475
-            'approved_regs'                => $this->_cpt_model_obj->count_related(
1476
-                'Registration',
1477
-                $approved_query_args
1478
-            ),
1479
-            'not_approved_regs'            => $this->_cpt_model_obj->count_related(
1480
-                'Registration',
1481
-                $not_approved_query_args
1482
-            ),
1483
-            'pending_payment_regs'         => $this->_cpt_model_obj->count_related(
1484
-                'Registration',
1485
-                $pending_payment_query_args
1486
-            ),
1487
-            'misc_pub_section_class'       => apply_filters(
1488
-                'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class',
1489
-                'misc-pub-section'
1490
-            ),
1491
-        );
1492
-        ob_start();
1493
-        do_action(
1494
-            'AHEE__Events_Admin_Page___generate_publish_box_extra_content__event_editor_overview_add',
1495
-            $this->_cpt_model_obj
1496
-        );
1497
-        $publish_box_extra_args['event_editor_overview_add'] = ob_get_clean();
1498
-        // load template
1499
-        EEH_Template::display_template(
1500
-            EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php',
1501
-            $publish_box_extra_args
1502
-        );
1503
-    }
1504
-
1505
-
1506
-    /**
1507
-     * @return EE_Event
1508
-     */
1509
-    public function get_event_object()
1510
-    {
1511
-        return $this->_cpt_model_obj;
1512
-    }
1513
-
1514
-
1515
-
1516
-
1517
-    /** METABOXES * */
1518
-    /**
1519
-     * _register_event_editor_meta_boxes
1520
-     * add all metaboxes related to the event_editor
1521
-     *
1522
-     * @return void
1523
-     */
1524
-    protected function _register_event_editor_meta_boxes()
1525
-    {
1526
-        $this->verify_cpt_object();
1527
-        add_meta_box(
1528
-            'espresso_event_editor_tickets',
1529
-            esc_html__('Event Datetime & Ticket', 'event_espresso'),
1530
-            array($this, 'ticket_metabox'),
1531
-            $this->page_slug,
1532
-            'normal',
1533
-            'high'
1534
-        );
1535
-        add_meta_box(
1536
-            'espresso_event_editor_event_options',
1537
-            esc_html__('Event Registration Options', 'event_espresso'),
1538
-            array($this, 'registration_options_meta_box'),
1539
-            $this->page_slug,
1540
-            'side',
1541
-            'default'
1542
-        );
1543
-        // NOTE: if you're looking for other metaboxes in here,
1544
-        // where a metabox has a related management page in the admin
1545
-        // you will find it setup in the related management page's "_Hooks" file.
1546
-        // i.e. messages metabox is found in "espresso_events_Messages_Hooks.class.php".
1547
-    }
1548
-
1549
-
1550
-    /**
1551
-     * @throws DomainException
1552
-     * @throws EE_Error
1553
-     */
1554
-    public function ticket_metabox()
1555
-    {
1556
-        $existing_datetime_ids = $existing_ticket_ids = array();
1557
-        // defaults for template args
1558
-        $template_args = array(
1559
-            'existing_datetime_ids'    => '',
1560
-            'event_datetime_help_link' => '',
1561
-            'ticket_options_help_link' => '',
1562
-            'time'                     => null,
1563
-            'ticket_rows'              => '',
1564
-            'existing_ticket_ids'      => '',
1565
-            'total_ticket_rows'        => 1,
1566
-            'ticket_js_structure'      => '',
1567
-            'trash_icon'               => 'ee-lock-icon',
1568
-            'disabled'                 => '',
1569
-        );
1570
-        $event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : null;
1571
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1572
-        /**
1573
-         * 1. Start with retrieving Datetimes
1574
-         * 2. Fore each datetime get related tickets
1575
-         * 3. For each ticket get related prices
1576
-         */
1577
-        $times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id);
1578
-        /** @type EE_Datetime $first_datetime */
1579
-        $first_datetime = reset($times);
1580
-        // do we get related tickets?
1581
-        if ($first_datetime instanceof EE_Datetime
1582
-            && $first_datetime->ID() !== 0
1583
-        ) {
1584
-            $existing_datetime_ids[] = $first_datetime->get('DTT_ID');
1585
-            $template_args['time'] = $first_datetime;
1586
-            $related_tickets = $first_datetime->tickets(
1587
-                array(
1588
-                    array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)),
1589
-                    'default_where_conditions' => 'none',
1590
-                )
1591
-            );
1592
-            if (! empty($related_tickets)) {
1593
-                $template_args['total_ticket_rows'] = count($related_tickets);
1594
-                $row = 0;
1595
-                foreach ($related_tickets as $ticket) {
1596
-                    $existing_ticket_ids[] = $ticket->get('TKT_ID');
1597
-                    $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, false, $row);
1598
-                    $row++;
1599
-                }
1600
-            } else {
1601
-                $template_args['total_ticket_rows'] = 1;
1602
-                /** @type EE_Ticket $ticket */
1603
-                $ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object();
1604
-                $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket);
1605
-            }
1606
-        } else {
1607
-            $template_args['time'] = $times[0];
1608
-            /** @type EE_Ticket $ticket */
1609
-            $ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets();
1610
-            $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]);
1611
-            // NOTE: we're just sending the first default row
1612
-            // (decaf can't manage default tickets so this should be sufficient);
1613
-        }
1614
-        $template_args['event_datetime_help_link'] = $this->_get_help_tab_link(
1615
-            'event_editor_event_datetimes_help_tab'
1616
-        );
1617
-        $template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info');
1618
-        $template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids);
1619
-        $template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids);
1620
-        $template_args['ticket_js_structure'] = $this->_get_ticket_row(
1621
-            EE_Registry::instance()->load_model('Ticket')->create_default_object(),
1622
-            true
1623
-        );
1624
-        $template = apply_filters(
1625
-            'FHEE__Events_Admin_Page__ticket_metabox__template',
1626
-            EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php'
1627
-        );
1628
-        EEH_Template::display_template($template, $template_args);
1629
-    }
1630
-
1631
-
1632
-    /**
1633
-     * Setup an individual ticket form for the decaf event editor page
1634
-     *
1635
-     * @access private
1636
-     * @param  EE_Ticket $ticket   the ticket object
1637
-     * @param  boolean   $skeleton whether we're generating a skeleton for js manipulation
1638
-     * @param int        $row
1639
-     * @return string generated html for the ticket row.
1640
-     */
1641
-    private function _get_ticket_row($ticket, $skeleton = false, $row = 0)
1642
-    {
1643
-        $template_args = array(
1644
-            'tkt_status_class'    => ' tkt-status-' . $ticket->ticket_status(),
1645
-            'tkt_archive_class'   => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived'
1646
-                : '',
1647
-            'ticketrow'           => $skeleton ? 'TICKETNUM' : $row,
1648
-            'TKT_ID'              => $ticket->get('TKT_ID'),
1649
-            'TKT_name'            => $ticket->get('TKT_name'),
1650
-            'TKT_start_date'      => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'),
1651
-            'TKT_end_date'        => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'),
1652
-            'TKT_is_default'      => $ticket->get('TKT_is_default'),
1653
-            'TKT_qty'             => $ticket->get_pretty('TKT_qty', 'input'),
1654
-            'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets',
1655
-            'TKT_sold'            => $skeleton ? 0 : $ticket->get('TKT_sold'),
1656
-            'trash_icon'          => ($skeleton || (! empty($ticket) && ! $ticket->get('TKT_deleted')))
1657
-                                     && (! empty($ticket) && $ticket->get('TKT_sold') === 0)
1658
-                ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon',
1659
-            'disabled'            => $skeleton || (! empty($ticket) && ! $ticket->get('TKT_deleted')) ? ''
1660
-                : ' disabled=disabled',
1661
-        );
1662
-        $price = $ticket->ID() !== 0
1663
-            ? $ticket->get_first_related('Price', array('default_where_conditions' => 'none'))
1664
-            : EE_Registry::instance()->load_model('Price')->create_default_object();
1665
-        $price_args = array(
1666
-            'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,
1667
-            'PRC_amount'            => $price->get('PRC_amount'),
1668
-            'PRT_ID'                => $price->get('PRT_ID'),
1669
-            'PRC_ID'                => $price->get('PRC_ID'),
1670
-            'PRC_is_default'        => $price->get('PRC_is_default'),
1671
-        );
1672
-        // make sure we have default start and end dates if skeleton
1673
-        // handle rows that should NOT be empty
1674
-        if (empty($template_args['TKT_start_date'])) {
1675
-            // if empty then the start date will be now.
1676
-            $template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp'));
1677
-        }
1678
-        if (empty($template_args['TKT_end_date'])) {
1679
-            // get the earliest datetime (if present);
1680
-            $earliest_dtt = $this->_cpt_model_obj->ID() > 0
1681
-                ? $this->_cpt_model_obj->get_first_related(
1682
-                    'Datetime',
1683
-                    array('order_by' => array('DTT_EVT_start' => 'ASC'))
1684
-                )
1685
-                : null;
1686
-            if (! empty($earliest_dtt)) {
1687
-                $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a');
1688
-            } else {
1689
-                $template_args['TKT_end_date'] = date(
1690
-                    'Y-m-d h:i a',
1691
-                    mktime(0, 0, 0, date("m"), date("d") + 7, date("Y"))
1692
-                );
1693
-            }
1694
-        }
1695
-        $template_args = array_merge($template_args, $price_args);
1696
-        $template = apply_filters(
1697
-            'FHEE__Events_Admin_Page__get_ticket_row__template',
1698
-            EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php',
1699
-            $ticket
1700
-        );
1701
-        return EEH_Template::display_template($template, $template_args, true);
1702
-    }
1703
-
1704
-
1705
-    /**
1706
-     * @throws DomainException
1707
-     */
1708
-    public function registration_options_meta_box()
1709
-    {
1710
-        $yes_no_values = array(
1711
-            array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')),
1712
-            array('id' => false, 'text' => esc_html__('No', 'event_espresso')),
1713
-        );
1714
-        $default_reg_status_values = EEM_Registration::reg_status_array(
1715
-            array(
1716
-                EEM_Registration::status_id_cancelled,
1717
-                EEM_Registration::status_id_declined,
1718
-                EEM_Registration::status_id_incomplete,
1719
-            ),
1720
-            true
1721
-        );
1722
-        // $template_args['is_active_select'] = EEH_Form_Fields::select_input('is_active', $yes_no_values, $this->_cpt_model_obj->is_active());
1723
-        $template_args['_event'] = $this->_cpt_model_obj;
1724
-        $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false);
1725
-        $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit();
1726
-        $template_args['default_registration_status'] = EEH_Form_Fields::select_input(
1727
-            'default_reg_status',
1728
-            $default_reg_status_values,
1729
-            $this->_cpt_model_obj->default_registration_status()
1730
-        );
1731
-        $template_args['display_description'] = EEH_Form_Fields::select_input(
1732
-            'display_desc',
1733
-            $yes_no_values,
1734
-            $this->_cpt_model_obj->display_description()
1735
-        );
1736
-        $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input(
1737
-            'display_ticket_selector',
1738
-            $yes_no_values,
1739
-            $this->_cpt_model_obj->display_ticket_selector(),
1740
-            '',
1741
-            '',
1742
-            false
1743
-        );
1744
-        $template_args['additional_registration_options'] = apply_filters(
1745
-            'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options',
1746
-            '',
1747
-            $template_args,
1748
-            $yes_no_values,
1749
-            $default_reg_status_values
1750
-        );
1751
-        EEH_Template::display_template(
1752
-            EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php',
1753
-            $template_args
1754
-        );
1755
-    }
1756
-
1757
-
1758
-    /**
1759
-     * _get_events()
1760
-     * This method simply returns all the events (for the given _view and paging)
1761
-     *
1762
-     * @access public
1763
-     * @param int  $per_page     count of items per page (20 default);
1764
-     * @param int  $current_page what is the current page being viewed.
1765
-     * @param bool $count        if TRUE then we just return a count of ALL events matching the given _view.
1766
-     *                           If FALSE then we return an array of event objects
1767
-     *                           that match the given _view and paging parameters.
1768
-     * @return array an array of event objects.
1769
-     */
1770
-    public function get_events($per_page = 10, $current_page = 1, $count = false)
1771
-    {
1772
-        $EEME = $this->_event_model();
1773
-        $offset = ($current_page - 1) * $per_page;
1774
-        $limit = $count ? null : $offset . ',' . $per_page;
1775
-        $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID';
1776
-        $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC";
1777
-        if (isset($this->_req_data['month_range'])) {
1778
-            $pieces = explode(' ', $this->_req_data['month_range'], 3);
1779
-            // simulate the FIRST day of the month, that fixes issues for months like February
1780
-            // where PHP doesn't know what to assume for date.
1781
-            // @see https://events.codebasehq.com/projects/event-espresso/tickets/10437
1782
-            $month_r = ! empty($pieces[0]) ? date('m', \EEH_DTT_Helper::first_of_month_timestamp($pieces[0])) : '';
1783
-            $year_r = ! empty($pieces[1]) ? $pieces[1] : '';
1784
-        }
1785
-        $where = array();
1786
-        $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
1787
-        // determine what post_status our condition will have for the query.
1788
-        switch ($status) {
1789
-            case 'month':
1790
-            case 'today':
1791
-            case null:
1792
-            case 'all':
1793
-                break;
1794
-            case 'draft':
1795
-                $where['status'] = array('IN', array('draft', 'auto-draft'));
1796
-                break;
1797
-            default:
1798
-                $where['status'] = $status;
1799
-        }
1800
-        // categories?
1801
-        $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0
1802
-            ? $this->_req_data['EVT_CAT'] : null;
1803
-        if (! empty($category)) {
1804
-            $where['Term_Taxonomy.taxonomy'] = EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY;
1805
-            $where['Term_Taxonomy.term_id'] = $category;
1806
-        }
1807
-        // date where conditions
1808
-        $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start');
1809
-        if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') {
1810
-            $DateTime = new DateTime(
1811
-                $year_r . '-' . $month_r . '-01 00:00:00',
1812
-                new DateTimeZone(EEM_Datetime::instance()->get_timezone())
1813
-            );
1814
-            $start = $DateTime->format(implode(' ', $start_formats));
1815
-            $end = $DateTime->setDate(
1816
-                $year_r,
1817
-                $month_r,
1818
-                $DateTime
1819
-                    ->format('t')
1820
-            )->setTime(23, 59, 59)
1821
-                            ->format(implode(' ', $start_formats));
1822
-            $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1823
-        } elseif (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') {
1824
-            $DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone()));
1825
-            $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats));
1826
-            $end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats));
1827
-            $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1828
-        } elseif (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') {
1829
-            $now = date('Y-m-01');
1830
-            $DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone()));
1831
-            $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats));
1832
-            $end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t'))
1833
-                            ->setTime(23, 59, 59)
1834
-                            ->format(implode(' ', $start_formats));
1835
-            $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1836
-        }
1837
-        if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
1838
-            $where['EVT_wp_user'] = get_current_user_id();
1839
-        } else {
1840
-            if (! isset($where['status'])) {
1841
-                if (! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) {
1842
-                    $where['OR'] = array(
1843
-                        'status*restrict_private' => array('!=', 'private'),
1844
-                        'AND'                     => array(
1845
-                            'status*inclusive' => array('=', 'private'),
1846
-                            'EVT_wp_user'      => get_current_user_id(),
1847
-                        ),
1848
-                    );
1849
-                }
1850
-            }
1851
-        }
1852
-        if (isset($this->_req_data['EVT_wp_user'])) {
1853
-            if ($this->_req_data['EVT_wp_user'] != get_current_user_id()
1854
-                && EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')
1855
-            ) {
1856
-                $where['EVT_wp_user'] = $this->_req_data['EVT_wp_user'];
1857
-            }
1858
-        }
1859
-        // search query handling
1860
-        if (isset($this->_req_data['s'])) {
1861
-            $search_string = '%' . $this->_req_data['s'] . '%';
1862
-            $where['OR'] = array(
1863
-                'EVT_name'       => array('LIKE', $search_string),
1864
-                'EVT_desc'       => array('LIKE', $search_string),
1865
-                'EVT_short_desc' => array('LIKE', $search_string),
1866
-            );
1867
-        }
1868
-        // filter events by venue.
1869
-        if (isset($this->_req_data['venue']) && ! empty($this->_req_data['venue'])) {
1870
-            $where['Venue.VNU_ID'] = absint($this->_req_data['venue']);
1871
-        }
1872
-        $where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data);
1873
-        $query_params = apply_filters(
1874
-            'FHEE__Events_Admin_Page__get_events__query_params',
1875
-            array(
1876
-                $where,
1877
-                'limit'    => $limit,
1878
-                'order_by' => $orderby,
1879
-                'order'    => $order,
1880
-                'group_by' => 'EVT_ID',
1881
-            ),
1882
-            $this->_req_data
1883
-        );
1884
-        // let's first check if we have special requests coming in.
1885
-        if (isset($this->_req_data['active_status'])) {
1886
-            switch ($this->_req_data['active_status']) {
1887
-                case 'upcoming':
1888
-                    return $EEME->get_upcoming_events($query_params, $count);
1889
-                    break;
1890
-                case 'expired':
1891
-                    return $EEME->get_expired_events($query_params, $count);
1892
-                    break;
1893
-                case 'active':
1894
-                    return $EEME->get_active_events($query_params, $count);
1895
-                    break;
1896
-                case 'inactive':
1897
-                    return $EEME->get_inactive_events($query_params, $count);
1898
-                    break;
1899
-            }
1900
-        }
1901
-
1902
-        $events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params);
1903
-        return $events;
1904
-    }
1905
-
1906
-
1907
-    /**
1908
-     * handling for WordPress CPT actions (trash, restore, delete)
1909
-     *
1910
-     * @param string $post_id
1911
-     */
1912
-    public function trash_cpt_item($post_id)
1913
-    {
1914
-        $this->_req_data['EVT_ID'] = $post_id;
1915
-        $this->_trash_or_restore_event('trash', false);
1916
-    }
1917
-
1918
-
1919
-    /**
1920
-     * @param string $post_id
1921
-     */
1922
-    public function restore_cpt_item($post_id)
1923
-    {
1924
-        $this->_req_data['EVT_ID'] = $post_id;
1925
-        $this->_trash_or_restore_event('draft', false);
1926
-    }
1927
-
1928
-
1929
-    /**
1930
-     * @param string $post_id
1931
-     */
1932
-    public function delete_cpt_item($post_id)
1933
-    {
1934
-        throw new EE_Error(esc_html__('Please contact Event Espresso support with the details of the steps taken to produce this error.', 'event_espresso'));
1935
-        $this->_req_data['EVT_ID'] = $post_id;
1936
-        $this->_delete_event();
1937
-    }
1938
-
1939
-
1940
-    /**
1941
-     * _trash_or_restore_event
1942
-     *
1943
-     * @access protected
1944
-     * @param  string $event_status
1945
-     * @param bool    $redirect_after
1946
-     */
1947
-    protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = true)
1948
-    {
1949
-        // determine the event id and set to array.
1950
-        $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : false;
1951
-        // loop thru events
1952
-        if ($EVT_ID) {
1953
-            // clean status
1954
-            $event_status = sanitize_key($event_status);
1955
-            // grab status
1956
-            if (! empty($event_status)) {
1957
-                $success = $this->_change_event_status($EVT_ID, $event_status);
1958
-            } else {
1959
-                $success = false;
1960
-                $msg = esc_html__(
1961
-                    'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.',
1962
-                    'event_espresso'
1963
-                );
1964
-                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1965
-            }
1966
-        } else {
1967
-            $success = false;
1968
-            $msg = esc_html__(
1969
-                'An error occurred. The event could not be moved to the trash because a valid event ID was not not supplied.',
1970
-                'event_espresso'
1971
-            );
1972
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1973
-        }
1974
-        $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
1975
-        if ($redirect_after) {
1976
-            $this->_redirect_after_action($success, 'Event', $action, array('action' => 'default'));
1977
-        }
1978
-    }
1979
-
1980
-
1981
-    /**
1982
-     * _trash_or_restore_events
1983
-     *
1984
-     * @access protected
1985
-     * @param  string $event_status
1986
-     * @return void
1987
-     */
1988
-    protected function _trash_or_restore_events($event_status = 'trash')
1989
-    {
1990
-        // clean status
1991
-        $event_status = sanitize_key($event_status);
1992
-        // grab status
1993
-        if (! empty($event_status)) {
1994
-            $success = true;
1995
-            // determine the event id and set to array.
1996
-            $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array();
1997
-            // loop thru events
1998
-            foreach ($EVT_IDs as $EVT_ID) {
1999
-                if ($EVT_ID = absint($EVT_ID)) {
2000
-                    $results = $this->_change_event_status($EVT_ID, $event_status);
2001
-                    $success = $results !== false ? $success : false;
2002
-                } else {
2003
-                    $msg = sprintf(
2004
-                        esc_html__(
2005
-                            'An error occurred. Event #%d could not be moved to the trash because a valid event ID was not not supplied.',
2006
-                            'event_espresso'
2007
-                        ),
2008
-                        $EVT_ID
2009
-                    );
2010
-                    EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2011
-                    $success = false;
2012
-                }
2013
-            }
2014
-        } else {
2015
-            $success = false;
2016
-            $msg = esc_html__(
2017
-                'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.',
2018
-                'event_espresso'
2019
-            );
2020
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2021
-        }
2022
-        // in order to force a pluralized result message we need to send back a success status greater than 1
2023
-        $success = $success ? 2 : false;
2024
-        $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
2025
-        $this->_redirect_after_action($success, 'Events', $action, array('action' => 'default'));
2026
-    }
2027
-
2028
-
2029
-    /**
2030
-     * _trash_or_restore_events
2031
-     *
2032
-     * @access  private
2033
-     * @param  int    $EVT_ID
2034
-     * @param  string $event_status
2035
-     * @return bool
2036
-     */
2037
-    private function _change_event_status($EVT_ID = 0, $event_status = '')
2038
-    {
2039
-        // grab event id
2040
-        if (! $EVT_ID) {
2041
-            $msg = esc_html__(
2042
-                'An error occurred. No Event ID or an invalid Event ID was received.',
2043
-                'event_espresso'
2044
-            );
2045
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2046
-            return false;
2047
-        }
2048
-        $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID);
2049
-        // clean status
2050
-        $event_status = sanitize_key($event_status);
2051
-        // grab status
2052
-        if (empty($event_status)) {
2053
-            $msg = esc_html__(
2054
-                'An error occurred. No Event Status or an invalid Event Status was received.',
2055
-                'event_espresso'
2056
-            );
2057
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2058
-            return false;
2059
-        }
2060
-        // was event trashed or restored ?
2061
-        switch ($event_status) {
2062
-            case 'draft':
2063
-                $action = 'restored from the trash';
2064
-                $hook = 'AHEE_event_restored_from_trash';
2065
-                break;
2066
-            case 'trash':
2067
-                $action = 'moved to the trash';
2068
-                $hook = 'AHEE_event_moved_to_trash';
2069
-                break;
2070
-            default:
2071
-                $action = 'updated';
2072
-                $hook = false;
2073
-        }
2074
-        // use class to change status
2075
-        $this->_cpt_model_obj->set_status($event_status);
2076
-        $success = $this->_cpt_model_obj->save();
2077
-        if ($success === false) {
2078
-            $msg = sprintf(esc_html__('An error occurred. The event could not be %s.', 'event_espresso'), $action);
2079
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2080
-            return false;
2081
-        }
2082
-        if ($hook) {
2083
-            do_action($hook);
2084
-        }
2085
-        return true;
2086
-    }
2087
-
2088
-
2089
-    /**
2090
-     * _delete_event
2091
-     *
2092
-     * @access protected
2093
-     * @param bool $redirect_after
2094
-     */
2095
-    protected function _delete_event()
2096
-    {
2097
-        $this->generateDeletionPreview(isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : array());
2098
-    }
2099
-
2100
-    /**
2101
-     * Gets the tree traversal batch persister.
2102
-     * @since $VID:$
2103
-     * @return NodeGroupDao
2104
-     * @throws InvalidArgumentException
2105
-     * @throws InvalidDataTypeException
2106
-     * @throws InvalidInterfaceException
2107
-     */
2108
-    protected function getModelObjNodeGroupPersister()
2109
-    {
2110
-        if (! $this->model_obj_node_group_persister instanceof NodeGroupDao) {
2111
-            $this->model_obj_node_group_persister = $this->getLoader()->load('\EventEspresso\core\services\orm\tree_traversal\NodeGroupDao');
2112
-        }
2113
-        return $this->model_obj_node_group_persister;
2114
-    }
2115
-
2116
-    /**
2117
-     * _delete_events
2118
-     *
2119
-     * @access protected
2120
-     * @return void
2121
-     */
2122
-    protected function _delete_events()
2123
-    {
2124
-        $this->generateDeletionPreview(isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array());
2125
-    }
2126
-
2127
-    protected function generateDeletionPreview($event_ids)
2128
-    {
2129
-        $event_ids = (array) $event_ids;
2130
-        // Set a code we can use to reference this deletion task in the batch jobs and preview page.
2131
-        $deletion_job_code = $this->getModelObjNodeGroupPersister()->generateGroupCode();
2132
-        $return_url = EE_Admin_Page::add_query_args_and_nonce(
2133
-            [
2134
-                'action' => 'preview_deletion',
2135
-                'deletion_job_code' => $deletion_job_code,
2136
-            ],
2137
-            $this->_admin_base_url
2138
-        );
2139
-        $event_ids = array_map(
2140
-            'intval',
2141
-            $event_ids
2142
-        );
2143
-
2144
-        EEH_URL::safeRedirectAndExit(
2145
-            EE_Admin_Page::add_query_args_and_nonce(
2146
-                array(
2147
-                    'page'        => 'espresso_batch',
2148
-                    'batch'       => EED_Batch::batch_job,
2149
-                    'EVT_IDs'      => $event_ids,
2150
-                    'deletion_job_code' => $deletion_job_code,
2151
-                    'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\PreviewEventDeletion'),
2152
-                    'return_url'  => urlencode($return_url),
2153
-                ),
2154
-                admin_url()
2155
-            )
2156
-        );
2157
-    }
2158
-
2159
-    /**
2160
-     * Checks for a POST submission
2161
-     * @since $VID:$
2162
-     */
2163
-    protected function confirmDeletion()
2164
-    {
2165
-        $deletion_redirect_logic = $this->getLoader()->getShared('\EventEspresso\core\domain\services\admin\events\data\ConfirmDeletion');
2166
-        return $deletion_redirect_logic->handle($this);
2167
-    }
2168
-
2169
-    /**
2170
-     * A page for users to preview what exactly will be deleted, and confirm they want to delete it.
2171
-     * @since $VID:$
2172
-     * @throws EE_Error
2173
-     */
2174
-    protected function previewDeletion()
2175
-    {
2176
-        $preview_deletion_logic = $this->getLoader()->getShared('\EventEspresso\core\domain\services\admin\events\data\PreviewDeletion');
2177
-        return $preview_deletion_logic->handle($this);
2178
-    }
2179
-
2180
-    /**
2181
-     * get total number of events
2182
-     *
2183
-     * @access public
2184
-     * @return int
2185
-     */
2186
-    public function total_events()
2187
-    {
2188
-        $count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true);
2189
-        return $count;
2190
-    }
2191
-
2192
-
2193
-    /**
2194
-     * get total number of draft events
2195
-     *
2196
-     * @access public
2197
-     * @return int
2198
-     */
2199
-    public function total_events_draft()
2200
-    {
2201
-        $where = array(
2202
-            'status' => array('IN', array('draft', 'auto-draft')),
2203
-        );
2204
-        $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
2205
-        return $count;
2206
-    }
2207
-
2208
-
2209
-    /**
2210
-     * get total number of trashed events
2211
-     *
2212
-     * @access public
2213
-     * @return int
2214
-     */
2215
-    public function total_trashed_events()
2216
-    {
2217
-        $where = array(
2218
-            'status' => 'trash',
2219
-        );
2220
-        $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
2221
-        return $count;
2222
-    }
2223
-
2224
-
2225
-    /**
2226
-     *    _default_event_settings
2227
-     *    This generates the Default Settings Tab
2228
-     *
2229
-     * @return void
2230
-     * @throws EE_Error
2231
-     */
2232
-    protected function _default_event_settings()
2233
-    {
2234
-        $this->_set_add_edit_form_tags('update_default_event_settings');
2235
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
2236
-        $this->_template_args['admin_page_content'] = $this->_default_event_settings_form()->get_html();
2237
-        $this->display_admin_page_with_sidebar();
2238
-    }
2239
-
2240
-
2241
-    /**
2242
-     * Return the form for event settings.
2243
-     *
2244
-     * @return EE_Form_Section_Proper
2245
-     * @throws EE_Error
2246
-     */
2247
-    protected function _default_event_settings_form()
2248
-    {
2249
-        $registration_config = EE_Registry::instance()->CFG->registration;
2250
-        $registration_stati_for_selection = EEM_Registration::reg_status_array(
2251
-            // exclude
2252
-            array(
2253
-                EEM_Registration::status_id_cancelled,
2254
-                EEM_Registration::status_id_declined,
2255
-                EEM_Registration::status_id_incomplete,
2256
-                EEM_Registration::status_id_wait_list,
2257
-            ),
2258
-            true
2259
-        );
2260
-        return new EE_Form_Section_Proper(
2261
-            array(
2262
-                'name'            => 'update_default_event_settings',
2263
-                'html_id'         => 'update_default_event_settings',
2264
-                'html_class'      => 'form-table',
2265
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
2266
-                'subsections'     => apply_filters(
2267
-                    'FHEE__Events_Admin_Page___default_event_settings_form__form_subsections',
2268
-                    array(
2269
-                        'default_reg_status'  => new EE_Select_Input(
2270
-                            $registration_stati_for_selection,
2271
-                            array(
2272
-                                'default'         => isset($registration_config->default_STS_ID)
2273
-                                                     && array_key_exists(
2274
-                                                         $registration_config->default_STS_ID,
2275
-                                                         $registration_stati_for_selection
2276
-                                                     )
2277
-                                    ? sanitize_text_field($registration_config->default_STS_ID)
2278
-                                    : EEM_Registration::status_id_pending_payment,
2279
-                                'html_label_text' => esc_html__('Default Registration Status', 'event_espresso')
2280
-                                                     . EEH_Template::get_help_tab_link(
2281
-                                                         'default_settings_status_help_tab'
2282
-                                                     ),
2283
-                                'html_help_text'  => esc_html__(
2284
-                                    '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.',
2285
-                                    'event_espresso'
2286
-                                ),
2287
-                            )
2288
-                        ),
2289
-                        'default_max_tickets' => new EE_Integer_Input(
2290
-                            array(
2291
-                                'default'         => isset($registration_config->default_maximum_number_of_tickets)
2292
-                                    ? $registration_config->default_maximum_number_of_tickets
2293
-                                    : EEM_Event::get_default_additional_limit(),
2294
-                                'html_label_text' => esc_html__(
2295
-                                    'Default Maximum Tickets Allowed Per Order:',
2296
-                                    'event_espresso'
2297
-                                )
2298
-                                                     . EEH_Template::get_help_tab_link(
2299
-                                                         'default_maximum_tickets_help_tab"'
2300
-                                                     ),
2301
-                                'html_help_text'  => esc_html__(
2302
-                                    'This setting allows you to indicate what will be the default for the maximum number of tickets per order when creating new events.',
2303
-                                    'event_espresso'
2304
-                                ),
2305
-                            )
2306
-                        ),
2307
-                    )
2308
-                ),
2309
-            )
2310
-        );
2311
-    }
2312
-
2313
-
2314
-    /**
2315
-     * _update_default_event_settings
2316
-     *
2317
-     * @access protected
2318
-     * @return void
2319
-     * @throws EE_Error
2320
-     */
2321
-    protected function _update_default_event_settings()
2322
-    {
2323
-        $registration_config = EE_Registry::instance()->CFG->registration;
2324
-        $form = $this->_default_event_settings_form();
2325
-        if ($form->was_submitted()) {
2326
-            $form->receive_form_submission();
2327
-            if ($form->is_valid()) {
2328
-                $valid_data = $form->valid_data();
2329
-                if (isset($valid_data['default_reg_status'])) {
2330
-                    $registration_config->default_STS_ID = $valid_data['default_reg_status'];
2331
-                }
2332
-                if (isset($valid_data['default_max_tickets'])) {
2333
-                    $registration_config->default_maximum_number_of_tickets = $valid_data['default_max_tickets'];
2334
-                }
2335
-                // update because data was valid!
2336
-                EE_Registry::instance()->CFG->update_espresso_config();
2337
-                EE_Error::overwrite_success();
2338
-                EE_Error::add_success(
2339
-                    __('Default Event Settings were updated', 'event_espresso')
2340
-                );
2341
-            }
2342
-        }
2343
-        $this->_redirect_after_action(0, '', '', array('action' => 'default_event_settings'), true);
2344
-    }
2345
-
2346
-
2347
-    /*************        Templates        *************/
2348
-    protected function _template_settings()
2349
-    {
2350
-        $this->_admin_page_title = esc_html__('Template Settings (Preview)', 'event_espresso');
2351
-        $this->_template_args['preview_img'] = '<img src="'
2352
-                                               . EVENTS_ASSETS_URL
2353
-                                               . '/images/'
2354
-                                               . 'caffeinated_template_features.jpg" alt="'
2355
-                                               . esc_attr__('Template Settings Preview screenshot', 'event_espresso')
2356
-                                               . '" />';
2357
-        $this->_template_args['preview_text'] = '<strong>'
2358
-                                                . esc_html__(
2359
-                                                    '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.',
2360
-                                                    'event_espresso'
2361
-                                                ) . '</strong>';
2362
-        $this->display_admin_caf_preview_page('template_settings_tab');
2363
-    }
2364
-
2365
-
2366
-    /** Event Category Stuff **/
2367
-    /**
2368
-     * set the _category property with the category object for the loaded page.
2369
-     *
2370
-     * @access private
2371
-     * @return void
2372
-     */
2373
-    private function _set_category_object()
2374
-    {
2375
-        if (isset($this->_category->id) && ! empty($this->_category->id)) {
2376
-            return;
2377
-        } //already have the category object so get out.
2378
-        // set default category object
2379
-        $this->_set_empty_category_object();
2380
-        // only set if we've got an id
2381
-        if (! isset($this->_req_data['EVT_CAT_ID'])) {
2382
-            return;
2383
-        }
2384
-        $category_id = absint($this->_req_data['EVT_CAT_ID']);
2385
-        $term = get_term($category_id, EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY);
2386
-        if (! empty($term)) {
2387
-            $this->_category->category_name = $term->name;
2388
-            $this->_category->category_identifier = $term->slug;
2389
-            $this->_category->category_desc = $term->description;
2390
-            $this->_category->id = $term->term_id;
2391
-            $this->_category->parent = $term->parent;
2392
-        }
2393
-    }
2394
-
2395
-
2396
-    /**
2397
-     * Clears out category properties.
2398
-     */
2399
-    private function _set_empty_category_object()
2400
-    {
2401
-        $this->_category = new stdClass();
2402
-        $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = '';
2403
-        $this->_category->id = $this->_category->parent = 0;
2404
-    }
2405
-
2406
-
2407
-    /**
2408
-     * @throws EE_Error
2409
-     */
2410
-    protected function _category_list_table()
2411
-    {
2412
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2413
-        $this->_search_btn_label = esc_html__('Categories', 'event_espresso');
2414
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
2415
-            'add_category',
2416
-            'add_category',
2417
-            array(),
2418
-            'add-new-h2'
2419
-        );
2420
-        $this->display_admin_list_table_page_with_sidebar();
2421
-    }
2422
-
2423
-
2424
-    /**
2425
-     * Output category details view.
2426
-     */
2427
-    protected function _category_details($view)
2428
-    {
2429
-        // load formatter helper
2430
-        // load field generator helper
2431
-        $route = $view == 'edit' ? 'update_category' : 'insert_category';
2432
-        $this->_set_add_edit_form_tags($route);
2433
-        $this->_set_category_object();
2434
-        $id = ! empty($this->_category->id) ? $this->_category->id : '';
2435
-        $delete_action = 'delete_category';
2436
-        // custom redirect
2437
-        $redirect = EE_Admin_Page::add_query_args_and_nonce(
2438
-            array('action' => 'category_list'),
2439
-            $this->_admin_base_url
2440
-        );
2441
-        $this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect);
2442
-        // take care of contents
2443
-        $this->_template_args['admin_page_content'] = $this->_category_details_content();
2444
-        $this->display_admin_page_with_sidebar();
2445
-    }
2446
-
2447
-
2448
-    /**
2449
-     * Output category details content.
2450
-     */
2451
-    protected function _category_details_content()
2452
-    {
2453
-        $editor_args['category_desc'] = array(
2454
-            'type'          => 'wp_editor',
2455
-            'value'         => EEH_Formatter::admin_format_content($this->_category->category_desc),
2456
-            'class'         => 'my_editor_custom',
2457
-            'wpeditor_args' => array('media_buttons' => false),
2458
-        );
2459
-        $_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array');
2460
-        $all_terms = get_terms(
2461
-            array(EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY),
2462
-            array('hide_empty' => 0, 'exclude' => array($this->_category->id))
2463
-        );
2464
-        // setup category select for term parents.
2465
-        $category_select_values[] = array(
2466
-            'text' => esc_html__('No Parent', 'event_espresso'),
2467
-            'id'   => 0,
2468
-        );
2469
-        foreach ($all_terms as $term) {
2470
-            $category_select_values[] = array(
2471
-                'text' => $term->name,
2472
-                'id'   => $term->term_id,
2473
-            );
2474
-        }
2475
-        $category_select = EEH_Form_Fields::select_input(
2476
-            'category_parent',
2477
-            $category_select_values,
2478
-            $this->_category->parent
2479
-        );
2480
-        $template_args = array(
2481
-            'category'                 => $this->_category,
2482
-            'category_select'          => $category_select,
2483
-            'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'),
2484
-            'category_desc_editor'     => $_wp_editor['category_desc']['field'],
2485
-            'disable'                  => '',
2486
-            'disabled_message'         => false,
2487
-        );
2488
-        $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php';
2489
-        return EEH_Template::display_template($template, $template_args, true);
2490
-    }
2491
-
2492
-
2493
-    /**
2494
-     * Handles deleting categories.
2495
-     */
2496
-    protected function _delete_categories()
2497
-    {
2498
-        $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array) $this->_req_data['EVT_CAT_ID']
2499
-            : (array) $this->_req_data['category_id'];
2500
-        foreach ($cat_ids as $cat_id) {
2501
-            $this->_delete_category($cat_id);
2502
-        }
2503
-        // doesn't matter what page we're coming from... we're going to the same place after delete.
2504
-        $query_args = array(
2505
-            'action' => 'category_list',
2506
-        );
2507
-        $this->_redirect_after_action(0, '', '', $query_args);
2508
-    }
2509
-
2510
-
2511
-    /**
2512
-     * Handles deleting specific category.
2513
-     *
2514
-     * @param int $cat_id
2515
-     */
2516
-    protected function _delete_category($cat_id)
2517
-    {
2518
-        $cat_id = absint($cat_id);
2519
-        wp_delete_term($cat_id, EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY);
2520
-    }
2521
-
2522
-
2523
-    /**
2524
-     * Handles triggering the update or insertion of a new category.
2525
-     *
2526
-     * @param bool $new_category true means we're triggering the insert of a new category.
2527
-     */
2528
-    protected function _insert_or_update_category($new_category)
2529
-    {
2530
-        $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(true);
2531
-        $success = 0; // we already have a success message so lets not send another.
2532
-        if ($cat_id) {
2533
-            $query_args = array(
2534
-                'action'     => 'edit_category',
2535
-                'EVT_CAT_ID' => $cat_id,
2536
-            );
2537
-        } else {
2538
-            $query_args = array('action' => 'add_category');
2539
-        }
2540
-        $this->_redirect_after_action($success, '', '', $query_args, true);
2541
-    }
2542
-
2543
-
2544
-    /**
2545
-     * Inserts or updates category
2546
-     *
2547
-     * @param bool $update (true indicates we're updating a category).
2548
-     * @return bool|mixed|string
2549
-     */
2550
-    private function _insert_category($update = false)
2551
-    {
2552
-        $cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : '';
2553
-        $category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : '';
2554
-        $category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : '';
2555
-        $category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0;
2556
-        if (empty($category_name)) {
2557
-            $msg = esc_html__('You must add a name for the category.', 'event_espresso');
2558
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2559
-            return false;
2560
-        }
2561
-        $term_args = array(
2562
-            'name'        => $category_name,
2563
-            'description' => $category_desc,
2564
-            'parent'      => $category_parent,
2565
-        );
2566
-        // was the category_identifier input disabled?
2567
-        if (isset($this->_req_data['category_identifier'])) {
2568
-            $term_args['slug'] = $this->_req_data['category_identifier'];
2569
-        }
2570
-        $insert_ids = $update
2571
-            ? wp_update_term($cat_id, EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY, $term_args)
2572
-            : wp_insert_term($category_name, EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY, $term_args);
2573
-        if (! is_array($insert_ids)) {
2574
-            $msg = esc_html__(
2575
-                'An error occurred and the category has not been saved to the database.',
2576
-                'event_espresso'
2577
-            );
2578
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2579
-        } else {
2580
-            $cat_id = $insert_ids['term_id'];
2581
-            $msg = sprintf(esc_html__('The category %s was successfully saved', 'event_espresso'), $category_name);
2582
-            EE_Error::add_success($msg);
2583
-        }
2584
-        return $cat_id;
2585
-    }
2586
-
2587
-
2588
-    /**
2589
-     * Gets categories or count of categories matching the arguments in the request.
2590
-     *
2591
-     * @param int  $per_page
2592
-     * @param int  $current_page
2593
-     * @param bool $count
2594
-     * @return EE_Base_Class[]|EE_Term_Taxonomy[]|int
2595
-     */
2596
-    public function get_categories($per_page = 10, $current_page = 1, $count = false)
2597
-    {
2598
-        // testing term stuff
2599
-        $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id';
2600
-        $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC';
2601
-        $limit = ($current_page - 1) * $per_page;
2602
-        $where = array('taxonomy' => EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY);
2603
-        if (isset($this->_req_data['s'])) {
2604
-            $sstr = '%' . $this->_req_data['s'] . '%';
2605
-            $where['OR'] = array(
2606
-                'Term.name'   => array('LIKE', $sstr),
2607
-                'description' => array('LIKE', $sstr),
2608
-            );
2609
-        }
2610
-        $query_params = array(
2611
-            $where,
2612
-            'order_by'   => array($orderby => $order),
2613
-            'limit'      => $limit . ',' . $per_page,
2614
-            'force_join' => array('Term'),
2615
-        );
2616
-        $categories = $count
2617
-            ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id')
2618
-            : EEM_Term_Taxonomy::instance()->get_all($query_params);
2619
-        return $categories;
2620
-    }
2621
-
2622
-    /* end category stuff */
2623
-    /**************/
2624
-
2625
-
2626
-    /**
2627
-     * Callback for the `ee_save_timezone_setting` ajax action.
2628
-     *
2629
-     * @throws EE_Error
2630
-     */
2631
-    public function save_timezonestring_setting()
2632
-    {
2633
-        $timezone_string = isset($this->_req_data['timezone_selected'])
2634
-            ? $this->_req_data['timezone_selected']
2635
-            : '';
2636
-        if (empty($timezone_string) || ! EEH_DTT_Helper::validate_timezone($timezone_string, false)) {
2637
-            EE_Error::add_error(
2638
-                esc_html__('An invalid timezone string submitted.', 'event_espresso'),
2639
-                __FILE__,
2640
-                __FUNCTION__,
2641
-                __LINE__
2642
-            );
2643
-            $this->_template_args['error'] = true;
2644
-            $this->_return_json();
2645
-        }
2646
-
2647
-        update_option('timezone_string', $timezone_string);
2648
-        EE_Error::add_success(
2649
-            esc_html__('Your timezone string was updated.', 'event_espresso')
2650
-        );
2651
-        $this->_template_args['success'] = true;
2652
-        $this->_return_json(true, array('action' => 'create_new'));
2653
-    }
22
+	/**
23
+	 * This will hold the event object for event_details screen.
24
+	 *
25
+	 * @access protected
26
+	 * @var EE_Event $_event
27
+	 */
28
+	protected $_event;
29
+
30
+
31
+	/**
32
+	 * This will hold the category object for category_details screen.
33
+	 *
34
+	 * @var stdClass $_category
35
+	 */
36
+	protected $_category;
37
+
38
+
39
+	/**
40
+	 * This will hold the event model instance
41
+	 *
42
+	 * @var EEM_Event $_event_model
43
+	 */
44
+	protected $_event_model;
45
+
46
+
47
+	/**
48
+	 * @var EE_Event
49
+	 */
50
+	protected $_cpt_model_obj = false;
51
+
52
+
53
+	/**
54
+	 * @var NodeGroupDao
55
+	 */
56
+	protected $model_obj_node_group_persister;
57
+
58
+	/**
59
+	 * Initialize page props for this admin page group.
60
+	 */
61
+	protected function _init_page_props()
62
+	{
63
+		$this->page_slug = EVENTS_PG_SLUG;
64
+		$this->page_label = EVENTS_LABEL;
65
+		$this->_admin_base_url = EVENTS_ADMIN_URL;
66
+		$this->_admin_base_path = EVENTS_ADMIN;
67
+		$this->_cpt_model_names = array(
68
+			'create_new' => 'EEM_Event',
69
+			'edit'       => 'EEM_Event',
70
+		);
71
+		$this->_cpt_edit_routes = array(
72
+			'espresso_events' => 'edit',
73
+		);
74
+		add_action(
75
+			'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object',
76
+			array($this, 'verify_event_edit'),
77
+			10,
78
+			2
79
+		);
80
+	}
81
+
82
+
83
+	/**
84
+	 * Sets the ajax hooks used for this admin page group.
85
+	 */
86
+	protected function _ajax_hooks()
87
+	{
88
+		add_action('wp_ajax_ee_save_timezone_setting', array($this, 'save_timezonestring_setting'));
89
+	}
90
+
91
+
92
+	/**
93
+	 * Sets the page properties for this admin page group.
94
+	 */
95
+	protected function _define_page_props()
96
+	{
97
+		$this->_admin_page_title = EVENTS_LABEL;
98
+		$this->_labels = array(
99
+			'buttons'      => array(
100
+				'add'             => esc_html__('Add New Event', 'event_espresso'),
101
+				'edit'            => esc_html__('Edit Event', 'event_espresso'),
102
+				'delete'          => esc_html__('Delete Event', 'event_espresso'),
103
+				'add_category'    => esc_html__('Add New Category', 'event_espresso'),
104
+				'edit_category'   => esc_html__('Edit Category', 'event_espresso'),
105
+				'delete_category' => esc_html__('Delete Category', 'event_espresso'),
106
+			),
107
+			'editor_title' => array(
108
+				'espresso_events' => esc_html__('Enter event title here', 'event_espresso'),
109
+			),
110
+			'publishbox'   => array(
111
+				'create_new'        => esc_html__('Save New Event', 'event_espresso'),
112
+				'edit'              => esc_html__('Update Event', 'event_espresso'),
113
+				'add_category'      => esc_html__('Save New Category', 'event_espresso'),
114
+				'edit_category'     => esc_html__('Update Category', 'event_espresso'),
115
+				'template_settings' => esc_html__('Update Settings', 'event_espresso'),
116
+			),
117
+		);
118
+	}
119
+
120
+
121
+	/**
122
+	 * Sets the page routes property for this admin page group.
123
+	 */
124
+	protected function _set_page_routes()
125
+	{
126
+		// load formatter helper
127
+		// load field generator helper
128
+		// is there a evt_id in the request?
129
+		$evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID'])
130
+			? $this->_req_data['EVT_ID']
131
+			: 0;
132
+		$evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id;
133
+		$this->_page_routes = array(
134
+			'default'                       => array(
135
+				'func'       => '_events_overview_list_table',
136
+				'capability' => 'ee_read_events',
137
+			),
138
+			'create_new'                    => array(
139
+				'func'       => '_create_new_cpt_item',
140
+				'capability' => 'ee_edit_events',
141
+			),
142
+			'edit'                          => array(
143
+				'func'       => '_edit_cpt_item',
144
+				'capability' => 'ee_edit_event',
145
+				'obj_id'     => $evt_id,
146
+			),
147
+			'copy_event'                    => array(
148
+				'func'       => '_copy_events',
149
+				'capability' => 'ee_edit_event',
150
+				'obj_id'     => $evt_id,
151
+				'noheader'   => true,
152
+			),
153
+			'trash_event'                   => array(
154
+				'func'       => '_trash_or_restore_event',
155
+				'args'       => array('event_status' => 'trash'),
156
+				'capability' => 'ee_delete_event',
157
+				'obj_id'     => $evt_id,
158
+				'noheader'   => true,
159
+			),
160
+			'trash_events'                  => array(
161
+				'func'       => '_trash_or_restore_events',
162
+				'args'       => array('event_status' => 'trash'),
163
+				'capability' => 'ee_delete_events',
164
+				'noheader'   => true,
165
+			),
166
+			'restore_event'                 => array(
167
+				'func'       => '_trash_or_restore_event',
168
+				'args'       => array('event_status' => 'draft'),
169
+				'capability' => 'ee_delete_event',
170
+				'obj_id'     => $evt_id,
171
+				'noheader'   => true,
172
+			),
173
+			'restore_events'                => array(
174
+				'func'       => '_trash_or_restore_events',
175
+				'args'       => array('event_status' => 'draft'),
176
+				'capability' => 'ee_delete_events',
177
+				'noheader'   => true,
178
+			),
179
+			'delete_event'                  => array(
180
+				'func'       => '_delete_event',
181
+				'capability' => 'ee_delete_event',
182
+				'obj_id'     => $evt_id,
183
+				'noheader'   => true,
184
+			),
185
+			'delete_events'                 => array(
186
+				'func'       => '_delete_events',
187
+				'capability' => 'ee_delete_events',
188
+				'noheader'   => true,
189
+			),
190
+			'view_report'                   => array(
191
+				'func'      => '_view_report',
192
+				'capablity' => 'ee_edit_events',
193
+			),
194
+			'default_event_settings'        => array(
195
+				'func'       => '_default_event_settings',
196
+				'capability' => 'manage_options',
197
+			),
198
+			'update_default_event_settings' => array(
199
+				'func'       => '_update_default_event_settings',
200
+				'capability' => 'manage_options',
201
+				'noheader'   => true,
202
+			),
203
+			'template_settings'             => array(
204
+				'func'       => '_template_settings',
205
+				'capability' => 'manage_options',
206
+			),
207
+			// event category tab related
208
+			'add_category'                  => array(
209
+				'func'       => '_category_details',
210
+				'capability' => 'ee_edit_event_category',
211
+				'args'       => array('add'),
212
+			),
213
+			'edit_category'                 => array(
214
+				'func'       => '_category_details',
215
+				'capability' => 'ee_edit_event_category',
216
+				'args'       => array('edit'),
217
+			),
218
+			'delete_categories'             => array(
219
+				'func'       => '_delete_categories',
220
+				'capability' => 'ee_delete_event_category',
221
+				'noheader'   => true,
222
+			),
223
+			'delete_category'               => array(
224
+				'func'       => '_delete_categories',
225
+				'capability' => 'ee_delete_event_category',
226
+				'noheader'   => true,
227
+			),
228
+			'insert_category'               => array(
229
+				'func'       => '_insert_or_update_category',
230
+				'args'       => array('new_category' => true),
231
+				'capability' => 'ee_edit_event_category',
232
+				'noheader'   => true,
233
+			),
234
+			'update_category'               => array(
235
+				'func'       => '_insert_or_update_category',
236
+				'args'       => array('new_category' => false),
237
+				'capability' => 'ee_edit_event_category',
238
+				'noheader'   => true,
239
+			),
240
+			'category_list'                 => array(
241
+				'func'       => '_category_list_table',
242
+				'capability' => 'ee_manage_event_categories',
243
+			),
244
+			'preview_deletion' => [
245
+				'func' => 'previewDeletion',
246
+				'capability' => 'ee_delete_events',
247
+			],
248
+			'confirm_deletion' => [
249
+				'func' => 'confirmDeletion',
250
+				'capability' => 'ee_delete_events',
251
+				'noheader' => true,
252
+			]
253
+		);
254
+	}
255
+
256
+
257
+	/**
258
+	 * Set the _page_config property for this admin page group.
259
+	 */
260
+	protected function _set_page_config()
261
+	{
262
+		$this->_page_config = array(
263
+			'default'                => array(
264
+				'nav'           => array(
265
+					'label' => esc_html__('Overview', 'event_espresso'),
266
+					'order' => 10,
267
+				),
268
+				'list_table'    => 'Events_Admin_List_Table',
269
+				'help_tabs'     => array(
270
+					'events_overview_help_tab'                       => array(
271
+						'title'    => esc_html__('Events Overview', 'event_espresso'),
272
+						'filename' => 'events_overview',
273
+					),
274
+					'events_overview_table_column_headings_help_tab' => array(
275
+						'title'    => esc_html__('Events Overview Table Column Headings', 'event_espresso'),
276
+						'filename' => 'events_overview_table_column_headings',
277
+					),
278
+					'events_overview_filters_help_tab'               => array(
279
+						'title'    => esc_html__('Events Overview Filters', 'event_espresso'),
280
+						'filename' => 'events_overview_filters',
281
+					),
282
+					'events_overview_view_help_tab'                  => array(
283
+						'title'    => esc_html__('Events Overview Views', 'event_espresso'),
284
+						'filename' => 'events_overview_views',
285
+					),
286
+					'events_overview_other_help_tab'                 => array(
287
+						'title'    => esc_html__('Events Overview Other', 'event_espresso'),
288
+						'filename' => 'events_overview_other',
289
+					),
290
+				),
291
+				'help_tour'     => array(
292
+					'Event_Overview_Help_Tour',
293
+					// 'New_Features_Test_Help_Tour' for testing multiple help tour
294
+				),
295
+				'qtips'         => array(
296
+					'EE_Event_List_Table_Tips',
297
+				),
298
+				'require_nonce' => false,
299
+			),
300
+			'create_new'             => array(
301
+				'nav'           => array(
302
+					'label'      => esc_html__('Add Event', 'event_espresso'),
303
+					'order'      => 5,
304
+					'persistent' => false,
305
+				),
306
+				'metaboxes'     => array('_register_event_editor_meta_boxes'),
307
+				'help_tabs'     => array(
308
+					'event_editor_help_tab'                            => array(
309
+						'title'    => esc_html__('Event Editor', 'event_espresso'),
310
+						'filename' => 'event_editor',
311
+					),
312
+					'event_editor_title_richtexteditor_help_tab'       => array(
313
+						'title'    => esc_html__('Event Title & Rich Text Editor', 'event_espresso'),
314
+						'filename' => 'event_editor_title_richtexteditor',
315
+					),
316
+					'event_editor_venue_details_help_tab'              => array(
317
+						'title'    => esc_html__('Event Venue Details', 'event_espresso'),
318
+						'filename' => 'event_editor_venue_details',
319
+					),
320
+					'event_editor_event_datetimes_help_tab'            => array(
321
+						'title'    => esc_html__('Event Datetimes', 'event_espresso'),
322
+						'filename' => 'event_editor_event_datetimes',
323
+					),
324
+					'event_editor_event_tickets_help_tab'              => array(
325
+						'title'    => esc_html__('Event Tickets', 'event_espresso'),
326
+						'filename' => 'event_editor_event_tickets',
327
+					),
328
+					'event_editor_event_registration_options_help_tab' => array(
329
+						'title'    => esc_html__('Event Registration Options', 'event_espresso'),
330
+						'filename' => 'event_editor_event_registration_options',
331
+					),
332
+					'event_editor_tags_categories_help_tab'            => array(
333
+						'title'    => esc_html__('Event Tags & Categories', 'event_espresso'),
334
+						'filename' => 'event_editor_tags_categories',
335
+					),
336
+					'event_editor_questions_registrants_help_tab'      => array(
337
+						'title'    => esc_html__('Questions for Registrants', 'event_espresso'),
338
+						'filename' => 'event_editor_questions_registrants',
339
+					),
340
+					'event_editor_save_new_event_help_tab'             => array(
341
+						'title'    => esc_html__('Save New Event', 'event_espresso'),
342
+						'filename' => 'event_editor_save_new_event',
343
+					),
344
+					'event_editor_other_help_tab'                      => array(
345
+						'title'    => esc_html__('Event Other', 'event_espresso'),
346
+						'filename' => 'event_editor_other',
347
+					),
348
+				),
349
+				'help_tour'     => array(
350
+					'Event_Editor_Help_Tour',
351
+				),
352
+				'qtips'         => array('EE_Event_Editor_Decaf_Tips'),
353
+				'require_nonce' => false,
354
+			),
355
+			'edit'                   => array(
356
+				'nav'           => array(
357
+					'label'      => esc_html__('Edit Event', 'event_espresso'),
358
+					'order'      => 5,
359
+					'persistent' => false,
360
+					'url'        => isset($this->_req_data['post'])
361
+						? EE_Admin_Page::add_query_args_and_nonce(
362
+							array('post' => $this->_req_data['post'], 'action' => 'edit'),
363
+							$this->_current_page_view_url
364
+						)
365
+						: $this->_admin_base_url,
366
+				),
367
+				'metaboxes'     => array('_register_event_editor_meta_boxes'),
368
+				'help_tabs'     => array(
369
+					'event_editor_help_tab'                            => array(
370
+						'title'    => esc_html__('Event Editor', 'event_espresso'),
371
+						'filename' => 'event_editor',
372
+					),
373
+					'event_editor_title_richtexteditor_help_tab'       => array(
374
+						'title'    => esc_html__('Event Title & Rich Text Editor', 'event_espresso'),
375
+						'filename' => 'event_editor_title_richtexteditor',
376
+					),
377
+					'event_editor_venue_details_help_tab'              => array(
378
+						'title'    => esc_html__('Event Venue Details', 'event_espresso'),
379
+						'filename' => 'event_editor_venue_details',
380
+					),
381
+					'event_editor_event_datetimes_help_tab'            => array(
382
+						'title'    => esc_html__('Event Datetimes', 'event_espresso'),
383
+						'filename' => 'event_editor_event_datetimes',
384
+					),
385
+					'event_editor_event_tickets_help_tab'              => array(
386
+						'title'    => esc_html__('Event Tickets', 'event_espresso'),
387
+						'filename' => 'event_editor_event_tickets',
388
+					),
389
+					'event_editor_event_registration_options_help_tab' => array(
390
+						'title'    => esc_html__('Event Registration Options', 'event_espresso'),
391
+						'filename' => 'event_editor_event_registration_options',
392
+					),
393
+					'event_editor_tags_categories_help_tab'            => array(
394
+						'title'    => esc_html__('Event Tags & Categories', 'event_espresso'),
395
+						'filename' => 'event_editor_tags_categories',
396
+					),
397
+					'event_editor_questions_registrants_help_tab'      => array(
398
+						'title'    => esc_html__('Questions for Registrants', 'event_espresso'),
399
+						'filename' => 'event_editor_questions_registrants',
400
+					),
401
+					'event_editor_save_new_event_help_tab'             => array(
402
+						'title'    => esc_html__('Save New Event', 'event_espresso'),
403
+						'filename' => 'event_editor_save_new_event',
404
+					),
405
+					'event_editor_other_help_tab'                      => array(
406
+						'title'    => esc_html__('Event Other', 'event_espresso'),
407
+						'filename' => 'event_editor_other',
408
+					),
409
+				),
410
+				'qtips'         => array('EE_Event_Editor_Decaf_Tips'),
411
+				'require_nonce' => false,
412
+			),
413
+			'default_event_settings' => array(
414
+				'nav'           => array(
415
+					'label' => esc_html__('Default Settings', 'event_espresso'),
416
+					'order' => 40,
417
+				),
418
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
419
+				'labels'        => array(
420
+					'publishbox' => esc_html__('Update Settings', 'event_espresso'),
421
+				),
422
+				'help_tabs'     => array(
423
+					'default_settings_help_tab'        => array(
424
+						'title'    => esc_html__('Default Event Settings', 'event_espresso'),
425
+						'filename' => 'events_default_settings',
426
+					),
427
+					'default_settings_status_help_tab' => array(
428
+						'title'    => esc_html__('Default Registration Status', 'event_espresso'),
429
+						'filename' => 'events_default_settings_status',
430
+					),
431
+					'default_maximum_tickets_help_tab' => array(
432
+						'title'    => esc_html__('Default Maximum Tickets Per Order', 'event_espresso'),
433
+						'filename' => 'events_default_settings_max_tickets',
434
+					),
435
+				),
436
+				'help_tour'     => array('Event_Default_Settings_Help_Tour'),
437
+				'require_nonce' => false,
438
+			),
439
+			// template settings
440
+			'template_settings'      => array(
441
+				'nav'           => array(
442
+					'label' => esc_html__('Templates', 'event_espresso'),
443
+					'order' => 30,
444
+				),
445
+				'metaboxes'     => $this->_default_espresso_metaboxes,
446
+				'help_tabs'     => array(
447
+					'general_settings_templates_help_tab' => array(
448
+						'title'    => esc_html__('Templates', 'event_espresso'),
449
+						'filename' => 'general_settings_templates',
450
+					),
451
+				),
452
+				'help_tour'     => array('Templates_Help_Tour'),
453
+				'require_nonce' => false,
454
+			),
455
+			// event category stuff
456
+			'add_category'           => array(
457
+				'nav'           => array(
458
+					'label'      => esc_html__('Add Category', 'event_espresso'),
459
+					'order'      => 15,
460
+					'persistent' => false,
461
+				),
462
+				'help_tabs'     => array(
463
+					'add_category_help_tab' => array(
464
+						'title'    => esc_html__('Add New Event Category', 'event_espresso'),
465
+						'filename' => 'events_add_category',
466
+					),
467
+				),
468
+				'help_tour'     => array('Event_Add_Category_Help_Tour'),
469
+				'metaboxes'     => array('_publish_post_box'),
470
+				'require_nonce' => false,
471
+			),
472
+			'edit_category'          => array(
473
+				'nav'           => array(
474
+					'label'      => esc_html__('Edit Category', 'event_espresso'),
475
+					'order'      => 15,
476
+					'persistent' => false,
477
+					'url'        => isset($this->_req_data['EVT_CAT_ID'])
478
+						? add_query_arg(
479
+							array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']),
480
+							$this->_current_page_view_url
481
+						)
482
+						: $this->_admin_base_url,
483
+				),
484
+				'help_tabs'     => array(
485
+					'edit_category_help_tab' => array(
486
+						'title'    => esc_html__('Edit Event Category', 'event_espresso'),
487
+						'filename' => 'events_edit_category',
488
+					),
489
+				),
490
+				/*'help_tour' => array('Event_Edit_Category_Help_Tour'),*/
491
+				'metaboxes'     => array('_publish_post_box'),
492
+				'require_nonce' => false,
493
+			),
494
+			'category_list'          => array(
495
+				'nav'           => array(
496
+					'label' => esc_html__('Categories', 'event_espresso'),
497
+					'order' => 20,
498
+				),
499
+				'list_table'    => 'Event_Categories_Admin_List_Table',
500
+				'help_tabs'     => array(
501
+					'events_categories_help_tab'                       => array(
502
+						'title'    => esc_html__('Event Categories', 'event_espresso'),
503
+						'filename' => 'events_categories',
504
+					),
505
+					'events_categories_table_column_headings_help_tab' => array(
506
+						'title'    => esc_html__('Event Categories Table Column Headings', 'event_espresso'),
507
+						'filename' => 'events_categories_table_column_headings',
508
+					),
509
+					'events_categories_view_help_tab'                  => array(
510
+						'title'    => esc_html__('Event Categories Views', 'event_espresso'),
511
+						'filename' => 'events_categories_views',
512
+					),
513
+					'events_categories_other_help_tab'                 => array(
514
+						'title'    => esc_html__('Event Categories Other', 'event_espresso'),
515
+						'filename' => 'events_categories_other',
516
+					),
517
+				),
518
+				'help_tour'     => array(
519
+					'Event_Categories_Help_Tour',
520
+				),
521
+				'metaboxes'     => $this->_default_espresso_metaboxes,
522
+				'require_nonce' => false,
523
+			),
524
+			'preview_deletion'           => array(
525
+				'nav'           => array(
526
+					'label'      => esc_html__('Preview Deletion', 'event_espresso'),
527
+					'order'      => 15,
528
+					'persistent' => false,
529
+				),
530
+				'require_nonce' => false
531
+			)
532
+		);
533
+	}
534
+
535
+
536
+	/**
537
+	 * Used to register any global screen options if necessary for every route in this admin page group.
538
+	 */
539
+	protected function _add_screen_options()
540
+	{
541
+	}
542
+
543
+
544
+	/**
545
+	 * Implementing the screen options for the 'default' route.
546
+	 */
547
+	protected function _add_screen_options_default()
548
+	{
549
+		$this->_per_page_screen_option();
550
+	}
551
+
552
+
553
+	/**
554
+	 * Implementing screen options for the category list route.
555
+	 */
556
+	protected function _add_screen_options_category_list()
557
+	{
558
+		$page_title = $this->_admin_page_title;
559
+		$this->_admin_page_title = esc_html__('Categories', 'event_espresso');
560
+		$this->_per_page_screen_option();
561
+		$this->_admin_page_title = $page_title;
562
+	}
563
+
564
+
565
+	/**
566
+	 * Used to register any global feature pointers for the admin page group.
567
+	 */
568
+	protected function _add_feature_pointers()
569
+	{
570
+	}
571
+
572
+
573
+	/**
574
+	 * Registers and enqueues any global scripts and styles for the entire admin page group.
575
+	 */
576
+	public function load_scripts_styles()
577
+	{
578
+		wp_register_style(
579
+			'events-admin-css',
580
+			EVENTS_ASSETS_URL . 'events-admin-page.css',
581
+			array(),
582
+			EVENT_ESPRESSO_VERSION
583
+		);
584
+		wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION);
585
+		wp_enqueue_style('events-admin-css');
586
+		wp_enqueue_style('ee-cat-admin');
587
+		// todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details
588
+		// registers for all views
589
+		// scripts
590
+		wp_register_script(
591
+			'event_editor_js',
592
+			EVENTS_ASSETS_URL . 'event_editor.js',
593
+			array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'),
594
+			EVENT_ESPRESSO_VERSION,
595
+			true
596
+		);
597
+	}
598
+
599
+
600
+	/**
601
+	 * Enqueuing scripts and styles specific to this view
602
+	 */
603
+	public function load_scripts_styles_create_new()
604
+	{
605
+		$this->load_scripts_styles_edit();
606
+	}
607
+
608
+
609
+	/**
610
+	 * Enqueuing scripts and styles specific to this view
611
+	 */
612
+	public function load_scripts_styles_edit()
613
+	{
614
+		// styles
615
+		wp_enqueue_style('espresso-ui-theme');
616
+		wp_register_style(
617
+			'event-editor-css',
618
+			EVENTS_ASSETS_URL . 'event-editor.css',
619
+			array('ee-admin-css'),
620
+			EVENT_ESPRESSO_VERSION
621
+		);
622
+		wp_enqueue_style('event-editor-css');
623
+		// scripts
624
+		wp_register_script(
625
+			'event-datetime-metabox',
626
+			EVENTS_ASSETS_URL . 'event-datetime-metabox.js',
627
+			array('event_editor_js', 'ee-datepicker'),
628
+			EVENT_ESPRESSO_VERSION
629
+		);
630
+		wp_enqueue_script('event-datetime-metabox');
631
+	}
632
+
633
+
634
+	/**
635
+	 * Populating the _views property for the category list table view.
636
+	 */
637
+	protected function _set_list_table_views_category_list()
638
+	{
639
+		$this->_views = array(
640
+			'all' => array(
641
+				'slug'        => 'all',
642
+				'label'       => esc_html__('All', 'event_espresso'),
643
+				'count'       => 0,
644
+				'bulk_action' => array(
645
+					'delete_categories' => esc_html__('Delete Permanently', 'event_espresso'),
646
+				),
647
+			),
648
+		);
649
+	}
650
+
651
+
652
+	/**
653
+	 * For adding anything that fires on the admin_init hook for any route within this admin page group.
654
+	 */
655
+	public function admin_init()
656
+	{
657
+		EE_Registry::$i18n_js_strings['image_confirm'] = esc_html__(
658
+			'Do you really want to delete this image? Please remember to update your event to complete the removal.',
659
+			'event_espresso'
660
+		);
661
+	}
662
+
663
+
664
+	/**
665
+	 * For adding anything that should be triggered on the admin_notices hook for any route within this admin page
666
+	 * group.
667
+	 */
668
+	public function admin_notices()
669
+	{
670
+	}
671
+
672
+
673
+	/**
674
+	 * For adding anything that should be triggered on the `admin_print_footer_scripts` hook for any route within
675
+	 * this admin page group.
676
+	 */
677
+	public function admin_footer_scripts()
678
+	{
679
+	}
680
+
681
+
682
+	/**
683
+	 * Call this function to verify if an event is public and has tickets for sale.  If it does, then we need to show a
684
+	 * warning (via EE_Error::add_error());
685
+	 *
686
+	 * @param  EE_Event $event Event object
687
+	 * @param string    $req_type
688
+	 * @return void
689
+	 * @throws EE_Error
690
+	 * @access public
691
+	 */
692
+	public function verify_event_edit($event = null, $req_type = '')
693
+	{
694
+		// don't need to do this when processing
695
+		if (! empty($req_type)) {
696
+			return;
697
+		}
698
+		// no event?
699
+		if (empty($event)) {
700
+			// set event
701
+			$event = $this->_cpt_model_obj;
702
+		}
703
+		// STILL no event?
704
+		if (! $event instanceof EE_Event) {
705
+			return;
706
+		}
707
+		$orig_status = $event->status();
708
+		// first check if event is active.
709
+		if ($orig_status === EEM_Event::cancelled
710
+			|| $orig_status === EEM_Event::postponed
711
+			|| $event->is_expired()
712
+			|| $event->is_inactive()
713
+		) {
714
+			return;
715
+		}
716
+		// made it here so it IS active... next check that any of the tickets are sold.
717
+		if ($event->is_sold_out(true)) {
718
+			if ($orig_status !== EEM_Event::sold_out && $event->status() !== $orig_status) {
719
+				EE_Error::add_attention(
720
+					sprintf(
721
+						esc_html__(
722
+							'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.',
723
+							'event_espresso'
724
+						),
725
+						EEH_Template::pretty_status(EEM_Event::sold_out, false, 'sentence')
726
+					)
727
+				);
728
+			}
729
+			return;
730
+		} elseif ($orig_status === EEM_Event::sold_out) {
731
+			EE_Error::add_attention(
732
+				sprintf(
733
+					esc_html__(
734
+						'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.',
735
+						'event_espresso'
736
+					),
737
+					EEH_Template::pretty_status($event->status(), false, 'sentence')
738
+				)
739
+			);
740
+		}
741
+		// now we need to determine if the event has any tickets on sale.  If not then we dont' show the error
742
+		if (! $event->tickets_on_sale()) {
743
+			return;
744
+		}
745
+		// made it here so show warning
746
+		$this->_edit_event_warning();
747
+	}
748
+
749
+
750
+	/**
751
+	 * This is the text used for when an event is being edited that is public and has tickets for sale.
752
+	 * When needed, hook this into a EE_Error::add_error() notice.
753
+	 *
754
+	 * @access protected
755
+	 * @return void
756
+	 */
757
+	protected function _edit_event_warning()
758
+	{
759
+		// we don't want to add warnings during these requests
760
+		if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'editpost') {
761
+			return;
762
+		}
763
+		EE_Error::add_attention(
764
+			sprintf(
765
+				esc_html__(
766
+					'Your event is open for registration. Making changes may disrupt any transactions in progress. %sLearn more%s',
767
+					'event_espresso'
768
+				),
769
+				'<a class="espresso-help-tab-lnk">',
770
+				'</a>'
771
+			)
772
+		);
773
+	}
774
+
775
+
776
+	/**
777
+	 * When a user is creating a new event, notify them if they haven't set their timezone.
778
+	 * Otherwise, do the normal logic
779
+	 *
780
+	 * @return string
781
+	 * @throws \EE_Error
782
+	 */
783
+	protected function _create_new_cpt_item()
784
+	{
785
+		$has_timezone_string = get_option('timezone_string');
786
+		// only nag them about setting their timezone if it's their first event, and they haven't already done it
787
+		if (! $has_timezone_string && ! EEM_Event::instance()->exists(array())) {
788
+			EE_Error::add_attention(
789
+				sprintf(
790
+					__(
791
+						'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',
792
+						'event_espresso'
793
+					),
794
+					'<br>',
795
+					'<select id="timezone_string" name="timezone_string" aria-describedby="timezone-description">'
796
+					. EEH_DTT_Helper::wp_timezone_choice('', EEH_DTT_Helper::get_user_locale())
797
+					. '</select>',
798
+					'<button class="button button-secondary timezone-submit">',
799
+					'</button><span class="spinner"></span>'
800
+				),
801
+				__FILE__,
802
+				__FUNCTION__,
803
+				__LINE__
804
+			);
805
+		}
806
+		return parent::_create_new_cpt_item();
807
+	}
808
+
809
+
810
+	/**
811
+	 * Sets the _views property for the default route in this admin page group.
812
+	 */
813
+	protected function _set_list_table_views_default()
814
+	{
815
+		$this->_views = array(
816
+			'all'   => array(
817
+				'slug'        => 'all',
818
+				'label'       => esc_html__('View All Events', 'event_espresso'),
819
+				'count'       => 0,
820
+				'bulk_action' => array(
821
+					'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
822
+				),
823
+			),
824
+			'draft' => array(
825
+				'slug'        => 'draft',
826
+				'label'       => esc_html__('Draft', 'event_espresso'),
827
+				'count'       => 0,
828
+				'bulk_action' => array(
829
+					'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
830
+				),
831
+			),
832
+		);
833
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) {
834
+			$this->_views['trash'] = array(
835
+				'slug'        => 'trash',
836
+				'label'       => esc_html__('Trash', 'event_espresso'),
837
+				'count'       => 0,
838
+				'bulk_action' => array(
839
+					'restore_events' => esc_html__('Restore From Trash', 'event_espresso'),
840
+					'delete_events'  => esc_html__('Delete Permanently', 'event_espresso'),
841
+				),
842
+			);
843
+		}
844
+	}
845
+
846
+
847
+	/**
848
+	 * Provides the legend item array for the default list table view.
849
+	 *
850
+	 * @return array
851
+	 */
852
+	protected function _event_legend_items()
853
+	{
854
+		$items = array(
855
+			'view_details'   => array(
856
+				'class' => 'dashicons dashicons-search',
857
+				'desc'  => esc_html__('View Event', 'event_espresso'),
858
+			),
859
+			'edit_event'     => array(
860
+				'class' => 'ee-icon ee-icon-calendar-edit',
861
+				'desc'  => esc_html__('Edit Event Details', 'event_espresso'),
862
+			),
863
+			'view_attendees' => array(
864
+				'class' => 'dashicons dashicons-groups',
865
+				'desc'  => esc_html__('View Registrations for Event', 'event_espresso'),
866
+			),
867
+		);
868
+		$items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items);
869
+		$statuses = array(
870
+			'sold_out_status'  => array(
871
+				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out,
872
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::sold_out, false, 'sentence'),
873
+			),
874
+			'active_status'    => array(
875
+				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active,
876
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::active, false, 'sentence'),
877
+			),
878
+			'upcoming_status'  => array(
879
+				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming,
880
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::upcoming, false, 'sentence'),
881
+			),
882
+			'postponed_status' => array(
883
+				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed,
884
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::postponed, false, 'sentence'),
885
+			),
886
+			'cancelled_status' => array(
887
+				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled,
888
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::cancelled, false, 'sentence'),
889
+			),
890
+			'expired_status'   => array(
891
+				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired,
892
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::expired, false, 'sentence'),
893
+			),
894
+			'inactive_status'  => array(
895
+				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive,
896
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::inactive, false, 'sentence'),
897
+			),
898
+		);
899
+		$statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses);
900
+		return array_merge($items, $statuses);
901
+	}
902
+
903
+
904
+	/**
905
+	 * @return EEM_Event
906
+	 */
907
+	private function _event_model()
908
+	{
909
+		if (! $this->_event_model instanceof EEM_Event) {
910
+			$this->_event_model = EE_Registry::instance()->load_model('Event');
911
+		}
912
+		return $this->_event_model;
913
+	}
914
+
915
+
916
+	/**
917
+	 * Adds extra buttons to the WP CPT permalink field row.
918
+	 * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter.
919
+	 *
920
+	 * @param  string $return    the current html
921
+	 * @param  int    $id        the post id for the page
922
+	 * @param  string $new_title What the title is
923
+	 * @param  string $new_slug  what the slug is
924
+	 * @return string            The new html string for the permalink area
925
+	 */
926
+	public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug)
927
+	{
928
+		// make sure this is only when editing
929
+		if (! empty($id)) {
930
+			$post = get_post($id);
931
+			$return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#"  tabindex="-1">'
932
+					   . esc_html__('Shortcode', 'event_espresso')
933
+					   . '</a> ';
934
+			$return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id='
935
+					   . $post->ID
936
+					   . ']">';
937
+		}
938
+		return $return;
939
+	}
940
+
941
+
942
+	/**
943
+	 * _events_overview_list_table
944
+	 * This contains the logic for showing the events_overview list
945
+	 *
946
+	 * @access protected
947
+	 * @return void
948
+	 * @throws \EE_Error
949
+	 */
950
+	protected function _events_overview_list_table()
951
+	{
952
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
953
+		$this->_template_args['after_list_table'] = ! empty($this->_template_args['after_list_table'])
954
+			? (array) $this->_template_args['after_list_table']
955
+			: array();
956
+		$this->_template_args['after_list_table']['view_event_list_button'] = EEH_HTML::br()
957
+				. EEH_Template::get_button_or_link(
958
+					get_post_type_archive_link('espresso_events'),
959
+					esc_html__("View Event Archive Page", "event_espresso"),
960
+					'button'
961
+				);
962
+		$this->_template_args['after_list_table']['legend'] = $this->_display_legend($this->_event_legend_items());
963
+		$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
964
+			'create_new',
965
+			'add',
966
+			array(),
967
+			'add-new-h2'
968
+		);
969
+		$this->display_admin_list_table_page_with_no_sidebar();
970
+	}
971
+
972
+
973
+	/**
974
+	 * this allows for extra misc actions in the default WP publish box
975
+	 *
976
+	 * @return void
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
+	 */
1000
+	protected function _insert_update_cpt_item($post_id, $post)
1001
+	{
1002
+		if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') {
1003
+			// get out we're not processing an event save.
1004
+			return;
1005
+		}
1006
+		$event_values = array(
1007
+			'EVT_display_desc'                => ! empty($this->_req_data['display_desc']) ? 1 : 0,
1008
+			'EVT_display_ticket_selector'     => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0,
1009
+			'EVT_additional_limit'            => min(
1010
+				apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255),
1011
+				! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : null
1012
+			),
1013
+			'EVT_default_registration_status' => ! empty($this->_req_data['EVT_default_registration_status'])
1014
+				? $this->_req_data['EVT_default_registration_status']
1015
+				: EE_Registry::instance()->CFG->registration->default_STS_ID,
1016
+			'EVT_member_only'                 => ! empty($this->_req_data['member_only']) ? 1 : 0,
1017
+			'EVT_allow_overflow'              => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0,
1018
+			'EVT_timezone_string'             => ! empty($this->_req_data['timezone_string'])
1019
+				? $this->_req_data['timezone_string'] : null,
1020
+			'EVT_external_URL'                => ! empty($this->_req_data['externalURL'])
1021
+				? $this->_req_data['externalURL'] : null,
1022
+			'EVT_phone'                       => ! empty($this->_req_data['event_phone'])
1023
+				? $this->_req_data['event_phone'] : null,
1024
+		);
1025
+		// update event
1026
+		$success = $this->_event_model()->update_by_ID($event_values, $post_id);
1027
+		// 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!
1028
+		$get_one_where = array(
1029
+			$this->_event_model()->primary_key_name() => $post_id,
1030
+			'OR'                                      => array(
1031
+				'status'   => $post->post_status,
1032
+				// if trying to "Publish" a sold out event, it's status will get switched back to "sold_out" in the db,
1033
+				// but the returned object here has a status of "publish", so use the original post status as well
1034
+				'status*1' => $this->_req_data['original_post_status'],
1035
+			),
1036
+		);
1037
+		$event = $this->_event_model()->get_one(array($get_one_where));
1038
+		// the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons.
1039
+		$event_update_callbacks = apply_filters(
1040
+			'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',
1041
+			array(
1042
+				array($this, '_default_venue_update'),
1043
+				array($this, '_default_tickets_update'),
1044
+			)
1045
+		);
1046
+		$att_success = true;
1047
+		foreach ($event_update_callbacks as $e_callback) {
1048
+			$_success = is_callable($e_callback)
1049
+				? call_user_func($e_callback, $event, $this->_req_data)
1050
+				: false;
1051
+			// if ANY of these updates fail then we want the appropriate global error message
1052
+			$att_success = ! $att_success ? $att_success : $_success;
1053
+		}
1054
+		// any errors?
1055
+		if ($success && false === $att_success) {
1056
+			EE_Error::add_error(
1057
+				esc_html__(
1058
+					'Event Details saved successfully but something went wrong with saving attachments.',
1059
+					'event_espresso'
1060
+				),
1061
+				__FILE__,
1062
+				__FUNCTION__,
1063
+				__LINE__
1064
+			);
1065
+		} elseif ($success === false) {
1066
+			EE_Error::add_error(
1067
+				esc_html__('Event Details did not save successfully.', 'event_espresso'),
1068
+				__FILE__,
1069
+				__FUNCTION__,
1070
+				__LINE__
1071
+			);
1072
+		}
1073
+	}
1074
+
1075
+
1076
+	/**
1077
+	 * @see parent::restore_item()
1078
+	 * @param int $post_id
1079
+	 * @param int $revision_id
1080
+	 */
1081
+	protected function _restore_cpt_item($post_id, $revision_id)
1082
+	{
1083
+		// copy existing event meta to new post
1084
+		$post_evt = $this->_event_model()->get_one_by_ID($post_id);
1085
+		if ($post_evt instanceof EE_Event) {
1086
+			// meta revision restore
1087
+			$post_evt->restore_revision($revision_id);
1088
+			// related objs restore
1089
+			$post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price'));
1090
+		}
1091
+	}
1092
+
1093
+
1094
+	/**
1095
+	 * Attach the venue to the Event
1096
+	 *
1097
+	 * @param  \EE_Event $evtobj Event Object to add the venue to
1098
+	 * @param  array     $data   The request data from the form
1099
+	 * @return bool           Success or fail.
1100
+	 */
1101
+	protected function _default_venue_update(\EE_Event $evtobj, $data)
1102
+	{
1103
+		require_once(EE_MODELS . 'EEM_Venue.model.php');
1104
+		$venue_model = EE_Registry::instance()->load_model('Venue');
1105
+		$rows_affected = null;
1106
+		$venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null;
1107
+		// very important.  If we don't have a venue name...
1108
+		// then we'll get out because not necessary to create empty venue
1109
+		if (empty($data['venue_title'])) {
1110
+			return false;
1111
+		}
1112
+		$venue_array = array(
1113
+			'VNU_wp_user'         => $evtobj->get('EVT_wp_user'),
1114
+			'VNU_name'            => ! empty($data['venue_title']) ? $data['venue_title'] : null,
1115
+			'VNU_desc'            => ! empty($data['venue_description']) ? $data['venue_description'] : null,
1116
+			'VNU_identifier'      => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : null,
1117
+			'VNU_short_desc'      => ! empty($data['venue_short_description']) ? $data['venue_short_description']
1118
+				: null,
1119
+			'VNU_address'         => ! empty($data['address']) ? $data['address'] : null,
1120
+			'VNU_address2'        => ! empty($data['address2']) ? $data['address2'] : null,
1121
+			'VNU_city'            => ! empty($data['city']) ? $data['city'] : null,
1122
+			'STA_ID'              => ! empty($data['state']) ? $data['state'] : null,
1123
+			'CNT_ISO'             => ! empty($data['countries']) ? $data['countries'] : null,
1124
+			'VNU_zip'             => ! empty($data['zip']) ? $data['zip'] : null,
1125
+			'VNU_phone'           => ! empty($data['venue_phone']) ? $data['venue_phone'] : null,
1126
+			'VNU_capacity'        => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : null,
1127
+			'VNU_url'             => ! empty($data['venue_url']) ? $data['venue_url'] : null,
1128
+			'VNU_virtual_phone'   => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : null,
1129
+			'VNU_virtual_url'     => ! empty($data['virtual_url']) ? $data['virtual_url'] : null,
1130
+			'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0,
1131
+			'status'              => 'publish',
1132
+		);
1133
+		// if we've got the venue_id then we're just updating the existing venue so let's do that and then get out.
1134
+		if (! empty($venue_id)) {
1135
+			$update_where = array($venue_model->primary_key_name() => $venue_id);
1136
+			$rows_affected = $venue_model->update($venue_array, array($update_where));
1137
+			// 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.
1138
+			$evtobj->_add_relation_to($venue_id, 'Venue');
1139
+			return $rows_affected > 0 ? true : false;
1140
+		} else {
1141
+			// we insert the venue
1142
+			$venue_id = $venue_model->insert($venue_array);
1143
+			$evtobj->_add_relation_to($venue_id, 'Venue');
1144
+			return ! empty($venue_id) ? true : false;
1145
+		}
1146
+		// when we have the ancestor come in it's already been handled by the revision save.
1147
+	}
1148
+
1149
+
1150
+	/**
1151
+	 * Handles saving everything related to Tickets (datetimes, tickets, prices)
1152
+	 *
1153
+	 * @param  EE_Event $evtobj The Event object we're attaching data to
1154
+	 * @param  array    $data   The request data from the form
1155
+	 * @return array
1156
+	 */
1157
+	protected function _default_tickets_update(EE_Event $evtobj, $data)
1158
+	{
1159
+		$success = true;
1160
+		$saved_dtt = null;
1161
+		$saved_tickets = array();
1162
+		$incoming_date_formats = array('Y-m-d', 'h:i a');
1163
+		foreach ($data['edit_event_datetimes'] as $row => $dtt) {
1164
+			// trim all values to ensure any excess whitespace is removed.
1165
+			$dtt = array_map('trim', $dtt);
1166
+			$dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end']
1167
+				: $dtt['DTT_EVT_start'];
1168
+			$datetime_values = array(
1169
+				'DTT_ID'        => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : null,
1170
+				'DTT_EVT_start' => $dtt['DTT_EVT_start'],
1171
+				'DTT_EVT_end'   => $dtt['DTT_EVT_end'],
1172
+				'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'],
1173
+				'DTT_order'     => $row,
1174
+			);
1175
+			// 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.
1176
+			if (! empty($dtt['DTT_ID'])) {
1177
+				$DTM = EE_Registry::instance()
1178
+								  ->load_model('Datetime', array($evtobj->get_timezone()))
1179
+								  ->get_one_by_ID($dtt['DTT_ID']);
1180
+				$DTM->set_date_format($incoming_date_formats[0]);
1181
+				$DTM->set_time_format($incoming_date_formats[1]);
1182
+				foreach ($datetime_values as $field => $value) {
1183
+					$DTM->set($field, $value);
1184
+				}
1185
+				// 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.
1186
+				$saved_dtts[ $DTM->ID() ] = $DTM;
1187
+			} else {
1188
+				$DTM = EE_Registry::instance()->load_class(
1189
+					'Datetime',
1190
+					array($datetime_values, $evtobj->get_timezone(), $incoming_date_formats),
1191
+					false,
1192
+					false
1193
+				);
1194
+				foreach ($datetime_values as $field => $value) {
1195
+					$DTM->set($field, $value);
1196
+				}
1197
+			}
1198
+			$DTM->save();
1199
+			$DTT = $evtobj->_add_relation_to($DTM, 'Datetime');
1200
+			// load DTT helper
1201
+			// 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.
1202
+			if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) {
1203
+				$DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start'));
1204
+				$DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days');
1205
+				$DTT->save();
1206
+			}
1207
+			// 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.
1208
+			$saved_dtt = $DTT;
1209
+			$success = ! $success ? $success : $DTT;
1210
+			// if ANY of these updates fail then we want the appropriate global error message.
1211
+			// //todo this is actually sucky we need a better error message but this is what it is for now.
1212
+		}
1213
+		// no dtts get deleted so we don't do any of that logic here.
1214
+		// update tickets next
1215
+		$old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array();
1216
+		foreach ($data['edit_tickets'] as $row => $tkt) {
1217
+			$incoming_date_formats = array('Y-m-d', 'h:i a');
1218
+			$update_prices = false;
1219
+			$ticket_price = isset($data['edit_prices'][ $row ][1]['PRC_amount'])
1220
+				? $data['edit_prices'][ $row ][1]['PRC_amount'] : 0;
1221
+			// trim inputs to ensure any excess whitespace is removed.
1222
+			$tkt = array_map('trim', $tkt);
1223
+			if (empty($tkt['TKT_start_date'])) {
1224
+				// let's use now in the set timezone.
1225
+				$now = new DateTime('now', new DateTimeZone($evtobj->get_timezone()));
1226
+				$tkt['TKT_start_date'] = $now->format($incoming_date_formats[0] . ' ' . $incoming_date_formats[1]);
1227
+			}
1228
+			if (empty($tkt['TKT_end_date'])) {
1229
+				// use the start date of the first datetime
1230
+				$dtt = $evtobj->first_datetime();
1231
+				$tkt['TKT_end_date'] = $dtt->start_date_and_time(
1232
+					$incoming_date_formats[0],
1233
+					$incoming_date_formats[1]
1234
+				);
1235
+			}
1236
+			$TKT_values = array(
1237
+				'TKT_ID'          => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null,
1238
+				'TTM_ID'          => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0,
1239
+				'TKT_name'        => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '',
1240
+				'TKT_description' => ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '',
1241
+				'TKT_start_date'  => $tkt['TKT_start_date'],
1242
+				'TKT_end_date'    => $tkt['TKT_end_date'],
1243
+				'TKT_qty'         => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'],
1244
+				'TKT_uses'        => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'],
1245
+				'TKT_min'         => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'],
1246
+				'TKT_max'         => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'],
1247
+				'TKT_row'         => $row,
1248
+				'TKT_order'       => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row,
1249
+				'TKT_price'       => $ticket_price,
1250
+			);
1251
+			// 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.
1252
+			if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) {
1253
+				$TKT_values['TKT_ID'] = 0;
1254
+				$TKT_values['TKT_is_default'] = 0;
1255
+				$TKT_values['TKT_price'] = $ticket_price;
1256
+				$update_prices = true;
1257
+			}
1258
+			// if we have a TKT_ID then we need to get that existing TKT_obj and update it
1259
+			// 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.
1260
+			// 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.
1261
+			if (! empty($tkt['TKT_ID'])) {
1262
+				$TKT = EE_Registry::instance()
1263
+								  ->load_model('Ticket', array($evtobj->get_timezone()))
1264
+								  ->get_one_by_ID($tkt['TKT_ID']);
1265
+				if ($TKT instanceof EE_Ticket) {
1266
+					$ticket_sold = $TKT->count_related(
1267
+						'Registration',
1268
+						array(
1269
+							array(
1270
+								'STS_ID' => array(
1271
+									'NOT IN',
1272
+									array(EEM_Registration::status_id_incomplete),
1273
+								),
1274
+							),
1275
+						)
1276
+					) > 0 ? true : false;
1277
+					// let's just check the total price for the existing ticket and determine if it matches the new total price.  if they are different then we create a new ticket (if tkts sold) if they aren't different then we go ahead and modify existing ticket.
1278
+					$create_new_TKT = $ticket_sold && $ticket_price != $TKT->get('TKT_price')
1279
+									  && ! $TKT->get('TKT_deleted');
1280
+					$TKT->set_date_format($incoming_date_formats[0]);
1281
+					$TKT->set_time_format($incoming_date_formats[1]);
1282
+					// set new values
1283
+					foreach ($TKT_values as $field => $value) {
1284
+						if ($field == 'TKT_qty') {
1285
+							$TKT->set_qty($value);
1286
+						} else {
1287
+							$TKT->set($field, $value);
1288
+						}
1289
+					}
1290
+					// if $create_new_TKT is false then we can safely update the existing ticket.  Otherwise we have to create a new ticket.
1291
+					if ($create_new_TKT) {
1292
+						// archive the old ticket first
1293
+						$TKT->set('TKT_deleted', 1);
1294
+						$TKT->save();
1295
+						// make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine.
1296
+						$saved_tickets[ $TKT->ID() ] = $TKT;
1297
+						// 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.
1298
+						$TKT = clone $TKT;
1299
+						$TKT->set('TKT_ID', 0);
1300
+						$TKT->set('TKT_deleted', 0);
1301
+						$TKT->set('TKT_price', $ticket_price);
1302
+						$TKT->set('TKT_sold', 0);
1303
+						// now we need to make sure that $new prices are created as well and attached to new ticket.
1304
+						$update_prices = true;
1305
+					}
1306
+					// make sure price is set if it hasn't been already
1307
+					$TKT->set('TKT_price', $ticket_price);
1308
+				}
1309
+			} else {
1310
+				// no TKT_id so a new TKT
1311
+				$TKT_values['TKT_price'] = $ticket_price;
1312
+				$TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), false, false);
1313
+				if ($TKT instanceof EE_Ticket) {
1314
+					// need to reset values to properly account for the date formats
1315
+					$TKT->set_date_format($incoming_date_formats[0]);
1316
+					$TKT->set_time_format($incoming_date_formats[1]);
1317
+					$TKT->set_timezone($evtobj->get_timezone());
1318
+					// set new values
1319
+					foreach ($TKT_values as $field => $value) {
1320
+						if ($field == 'TKT_qty') {
1321
+							$TKT->set_qty($value);
1322
+						} else {
1323
+							$TKT->set($field, $value);
1324
+						}
1325
+					}
1326
+					$update_prices = true;
1327
+				}
1328
+			}
1329
+			// cap ticket qty by datetime reg limits
1330
+			$TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit')));
1331
+			// update ticket.
1332
+			$TKT->save();
1333
+			// 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.
1334
+			if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) {
1335
+				$TKT->set('TKT_end_date', $TKT->get('TKT_start_date'));
1336
+				$TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days');
1337
+				$TKT->save();
1338
+			}
1339
+			// initially let's add the ticket to the dtt
1340
+			$saved_dtt->_add_relation_to($TKT, 'Ticket');
1341
+			$saved_tickets[ $TKT->ID() ] = $TKT;
1342
+			// add prices to ticket
1343
+			$this->_add_prices_to_ticket($data['edit_prices'][ $row ], $TKT, $update_prices);
1344
+		}
1345
+		// 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.
1346
+		$old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets;
1347
+		$tickets_removed = array_diff($old_tickets, array_keys($saved_tickets));
1348
+		foreach ($tickets_removed as $id) {
1349
+			$id = absint($id);
1350
+			// get the ticket for this id
1351
+			$tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id);
1352
+			// 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)
1353
+			$dtts = $tkt_to_remove->get_many_related('Datetime');
1354
+			foreach ($dtts as $dtt) {
1355
+				$tkt_to_remove->_remove_relation_to($dtt, 'Datetime');
1356
+			}
1357
+			// 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))
1358
+			$tkt_to_remove->delete_related_permanently('Price');
1359
+			// finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships)
1360
+			$tkt_to_remove->delete_permanently();
1361
+		}
1362
+		return array($saved_dtt, $saved_tickets);
1363
+	}
1364
+
1365
+
1366
+	/**
1367
+	 * This attaches a list of given prices to a ticket.
1368
+	 * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change
1369
+	 * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old
1370
+	 * price info and prices are automatically "archived" via the ticket.
1371
+	 *
1372
+	 * @access  private
1373
+	 * @param array     $prices     Array of prices from the form.
1374
+	 * @param EE_Ticket $ticket     EE_Ticket object that prices are being attached to.
1375
+	 * @param bool      $new_prices Whether attach existing incoming prices or create new ones.
1376
+	 * @return  void
1377
+	 */
1378
+	private function _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = false)
1379
+	{
1380
+		foreach ($prices as $row => $prc) {
1381
+			$PRC_values = array(
1382
+				'PRC_ID'         => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null,
1383
+				'PRT_ID'         => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null,
1384
+				'PRC_amount'     => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0,
1385
+				'PRC_name'       => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '',
1386
+				'PRC_desc'       => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '',
1387
+				'PRC_is_default' => 0, // make sure prices are NOT set as default from this context
1388
+				'PRC_order'      => $row,
1389
+			);
1390
+			if ($new_prices || empty($PRC_values['PRC_ID'])) {
1391
+				$PRC_values['PRC_ID'] = 0;
1392
+				$PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), false, false);
1393
+			} else {
1394
+				$PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']);
1395
+				// update this price with new values
1396
+				foreach ($PRC_values as $field => $newprc) {
1397
+					$PRC->set($field, $newprc);
1398
+				}
1399
+				$PRC->save();
1400
+			}
1401
+			$ticket->_add_relation_to($PRC, 'Price');
1402
+		}
1403
+	}
1404
+
1405
+
1406
+	/**
1407
+	 * Add in our autosave ajax handlers
1408
+	 *
1409
+	 */
1410
+	protected function _ee_autosave_create_new()
1411
+	{
1412
+	}
1413
+
1414
+
1415
+	/**
1416
+	 * More autosave handlers.
1417
+	 */
1418
+	protected function _ee_autosave_edit()
1419
+	{
1420
+		return; // TEMPORARILY EXITING CAUSE THIS IS A TODO
1421
+	}
1422
+
1423
+
1424
+	/**
1425
+	 *    _generate_publish_box_extra_content
1426
+	 */
1427
+	private function _generate_publish_box_extra_content()
1428
+	{
1429
+		// load formatter helper
1430
+		// args for getting related registrations
1431
+		$approved_query_args = array(
1432
+			array(
1433
+				'REG_deleted' => 0,
1434
+				'STS_ID'      => EEM_Registration::status_id_approved,
1435
+			),
1436
+		);
1437
+		$not_approved_query_args = array(
1438
+			array(
1439
+				'REG_deleted' => 0,
1440
+				'STS_ID'      => EEM_Registration::status_id_not_approved,
1441
+			),
1442
+		);
1443
+		$pending_payment_query_args = array(
1444
+			array(
1445
+				'REG_deleted' => 0,
1446
+				'STS_ID'      => EEM_Registration::status_id_pending_payment,
1447
+			),
1448
+		);
1449
+		// publish box
1450
+		$publish_box_extra_args = array(
1451
+			'view_approved_reg_url'        => add_query_arg(
1452
+				array(
1453
+					'action'      => 'default',
1454
+					'event_id'    => $this->_cpt_model_obj->ID(),
1455
+					'_reg_status' => EEM_Registration::status_id_approved,
1456
+				),
1457
+				REG_ADMIN_URL
1458
+			),
1459
+			'view_not_approved_reg_url'    => add_query_arg(
1460
+				array(
1461
+					'action'      => 'default',
1462
+					'event_id'    => $this->_cpt_model_obj->ID(),
1463
+					'_reg_status' => EEM_Registration::status_id_not_approved,
1464
+				),
1465
+				REG_ADMIN_URL
1466
+			),
1467
+			'view_pending_payment_reg_url' => add_query_arg(
1468
+				array(
1469
+					'action'      => 'default',
1470
+					'event_id'    => $this->_cpt_model_obj->ID(),
1471
+					'_reg_status' => EEM_Registration::status_id_pending_payment,
1472
+				),
1473
+				REG_ADMIN_URL
1474
+			),
1475
+			'approved_regs'                => $this->_cpt_model_obj->count_related(
1476
+				'Registration',
1477
+				$approved_query_args
1478
+			),
1479
+			'not_approved_regs'            => $this->_cpt_model_obj->count_related(
1480
+				'Registration',
1481
+				$not_approved_query_args
1482
+			),
1483
+			'pending_payment_regs'         => $this->_cpt_model_obj->count_related(
1484
+				'Registration',
1485
+				$pending_payment_query_args
1486
+			),
1487
+			'misc_pub_section_class'       => apply_filters(
1488
+				'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class',
1489
+				'misc-pub-section'
1490
+			),
1491
+		);
1492
+		ob_start();
1493
+		do_action(
1494
+			'AHEE__Events_Admin_Page___generate_publish_box_extra_content__event_editor_overview_add',
1495
+			$this->_cpt_model_obj
1496
+		);
1497
+		$publish_box_extra_args['event_editor_overview_add'] = ob_get_clean();
1498
+		// load template
1499
+		EEH_Template::display_template(
1500
+			EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php',
1501
+			$publish_box_extra_args
1502
+		);
1503
+	}
1504
+
1505
+
1506
+	/**
1507
+	 * @return EE_Event
1508
+	 */
1509
+	public function get_event_object()
1510
+	{
1511
+		return $this->_cpt_model_obj;
1512
+	}
1513
+
1514
+
1515
+
1516
+
1517
+	/** METABOXES * */
1518
+	/**
1519
+	 * _register_event_editor_meta_boxes
1520
+	 * add all metaboxes related to the event_editor
1521
+	 *
1522
+	 * @return void
1523
+	 */
1524
+	protected function _register_event_editor_meta_boxes()
1525
+	{
1526
+		$this->verify_cpt_object();
1527
+		add_meta_box(
1528
+			'espresso_event_editor_tickets',
1529
+			esc_html__('Event Datetime & Ticket', 'event_espresso'),
1530
+			array($this, 'ticket_metabox'),
1531
+			$this->page_slug,
1532
+			'normal',
1533
+			'high'
1534
+		);
1535
+		add_meta_box(
1536
+			'espresso_event_editor_event_options',
1537
+			esc_html__('Event Registration Options', 'event_espresso'),
1538
+			array($this, 'registration_options_meta_box'),
1539
+			$this->page_slug,
1540
+			'side',
1541
+			'default'
1542
+		);
1543
+		// NOTE: if you're looking for other metaboxes in here,
1544
+		// where a metabox has a related management page in the admin
1545
+		// you will find it setup in the related management page's "_Hooks" file.
1546
+		// i.e. messages metabox is found in "espresso_events_Messages_Hooks.class.php".
1547
+	}
1548
+
1549
+
1550
+	/**
1551
+	 * @throws DomainException
1552
+	 * @throws EE_Error
1553
+	 */
1554
+	public function ticket_metabox()
1555
+	{
1556
+		$existing_datetime_ids = $existing_ticket_ids = array();
1557
+		// defaults for template args
1558
+		$template_args = array(
1559
+			'existing_datetime_ids'    => '',
1560
+			'event_datetime_help_link' => '',
1561
+			'ticket_options_help_link' => '',
1562
+			'time'                     => null,
1563
+			'ticket_rows'              => '',
1564
+			'existing_ticket_ids'      => '',
1565
+			'total_ticket_rows'        => 1,
1566
+			'ticket_js_structure'      => '',
1567
+			'trash_icon'               => 'ee-lock-icon',
1568
+			'disabled'                 => '',
1569
+		);
1570
+		$event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : null;
1571
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1572
+		/**
1573
+		 * 1. Start with retrieving Datetimes
1574
+		 * 2. Fore each datetime get related tickets
1575
+		 * 3. For each ticket get related prices
1576
+		 */
1577
+		$times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id);
1578
+		/** @type EE_Datetime $first_datetime */
1579
+		$first_datetime = reset($times);
1580
+		// do we get related tickets?
1581
+		if ($first_datetime instanceof EE_Datetime
1582
+			&& $first_datetime->ID() !== 0
1583
+		) {
1584
+			$existing_datetime_ids[] = $first_datetime->get('DTT_ID');
1585
+			$template_args['time'] = $first_datetime;
1586
+			$related_tickets = $first_datetime->tickets(
1587
+				array(
1588
+					array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)),
1589
+					'default_where_conditions' => 'none',
1590
+				)
1591
+			);
1592
+			if (! empty($related_tickets)) {
1593
+				$template_args['total_ticket_rows'] = count($related_tickets);
1594
+				$row = 0;
1595
+				foreach ($related_tickets as $ticket) {
1596
+					$existing_ticket_ids[] = $ticket->get('TKT_ID');
1597
+					$template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, false, $row);
1598
+					$row++;
1599
+				}
1600
+			} else {
1601
+				$template_args['total_ticket_rows'] = 1;
1602
+				/** @type EE_Ticket $ticket */
1603
+				$ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object();
1604
+				$template_args['ticket_rows'] .= $this->_get_ticket_row($ticket);
1605
+			}
1606
+		} else {
1607
+			$template_args['time'] = $times[0];
1608
+			/** @type EE_Ticket $ticket */
1609
+			$ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets();
1610
+			$template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]);
1611
+			// NOTE: we're just sending the first default row
1612
+			// (decaf can't manage default tickets so this should be sufficient);
1613
+		}
1614
+		$template_args['event_datetime_help_link'] = $this->_get_help_tab_link(
1615
+			'event_editor_event_datetimes_help_tab'
1616
+		);
1617
+		$template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info');
1618
+		$template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids);
1619
+		$template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids);
1620
+		$template_args['ticket_js_structure'] = $this->_get_ticket_row(
1621
+			EE_Registry::instance()->load_model('Ticket')->create_default_object(),
1622
+			true
1623
+		);
1624
+		$template = apply_filters(
1625
+			'FHEE__Events_Admin_Page__ticket_metabox__template',
1626
+			EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php'
1627
+		);
1628
+		EEH_Template::display_template($template, $template_args);
1629
+	}
1630
+
1631
+
1632
+	/**
1633
+	 * Setup an individual ticket form for the decaf event editor page
1634
+	 *
1635
+	 * @access private
1636
+	 * @param  EE_Ticket $ticket   the ticket object
1637
+	 * @param  boolean   $skeleton whether we're generating a skeleton for js manipulation
1638
+	 * @param int        $row
1639
+	 * @return string generated html for the ticket row.
1640
+	 */
1641
+	private function _get_ticket_row($ticket, $skeleton = false, $row = 0)
1642
+	{
1643
+		$template_args = array(
1644
+			'tkt_status_class'    => ' tkt-status-' . $ticket->ticket_status(),
1645
+			'tkt_archive_class'   => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived'
1646
+				: '',
1647
+			'ticketrow'           => $skeleton ? 'TICKETNUM' : $row,
1648
+			'TKT_ID'              => $ticket->get('TKT_ID'),
1649
+			'TKT_name'            => $ticket->get('TKT_name'),
1650
+			'TKT_start_date'      => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'),
1651
+			'TKT_end_date'        => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'),
1652
+			'TKT_is_default'      => $ticket->get('TKT_is_default'),
1653
+			'TKT_qty'             => $ticket->get_pretty('TKT_qty', 'input'),
1654
+			'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets',
1655
+			'TKT_sold'            => $skeleton ? 0 : $ticket->get('TKT_sold'),
1656
+			'trash_icon'          => ($skeleton || (! empty($ticket) && ! $ticket->get('TKT_deleted')))
1657
+									 && (! empty($ticket) && $ticket->get('TKT_sold') === 0)
1658
+				? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon',
1659
+			'disabled'            => $skeleton || (! empty($ticket) && ! $ticket->get('TKT_deleted')) ? ''
1660
+				: ' disabled=disabled',
1661
+		);
1662
+		$price = $ticket->ID() !== 0
1663
+			? $ticket->get_first_related('Price', array('default_where_conditions' => 'none'))
1664
+			: EE_Registry::instance()->load_model('Price')->create_default_object();
1665
+		$price_args = array(
1666
+			'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,
1667
+			'PRC_amount'            => $price->get('PRC_amount'),
1668
+			'PRT_ID'                => $price->get('PRT_ID'),
1669
+			'PRC_ID'                => $price->get('PRC_ID'),
1670
+			'PRC_is_default'        => $price->get('PRC_is_default'),
1671
+		);
1672
+		// make sure we have default start and end dates if skeleton
1673
+		// handle rows that should NOT be empty
1674
+		if (empty($template_args['TKT_start_date'])) {
1675
+			// if empty then the start date will be now.
1676
+			$template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp'));
1677
+		}
1678
+		if (empty($template_args['TKT_end_date'])) {
1679
+			// get the earliest datetime (if present);
1680
+			$earliest_dtt = $this->_cpt_model_obj->ID() > 0
1681
+				? $this->_cpt_model_obj->get_first_related(
1682
+					'Datetime',
1683
+					array('order_by' => array('DTT_EVT_start' => 'ASC'))
1684
+				)
1685
+				: null;
1686
+			if (! empty($earliest_dtt)) {
1687
+				$template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a');
1688
+			} else {
1689
+				$template_args['TKT_end_date'] = date(
1690
+					'Y-m-d h:i a',
1691
+					mktime(0, 0, 0, date("m"), date("d") + 7, date("Y"))
1692
+				);
1693
+			}
1694
+		}
1695
+		$template_args = array_merge($template_args, $price_args);
1696
+		$template = apply_filters(
1697
+			'FHEE__Events_Admin_Page__get_ticket_row__template',
1698
+			EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php',
1699
+			$ticket
1700
+		);
1701
+		return EEH_Template::display_template($template, $template_args, true);
1702
+	}
1703
+
1704
+
1705
+	/**
1706
+	 * @throws DomainException
1707
+	 */
1708
+	public function registration_options_meta_box()
1709
+	{
1710
+		$yes_no_values = array(
1711
+			array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')),
1712
+			array('id' => false, 'text' => esc_html__('No', 'event_espresso')),
1713
+		);
1714
+		$default_reg_status_values = EEM_Registration::reg_status_array(
1715
+			array(
1716
+				EEM_Registration::status_id_cancelled,
1717
+				EEM_Registration::status_id_declined,
1718
+				EEM_Registration::status_id_incomplete,
1719
+			),
1720
+			true
1721
+		);
1722
+		// $template_args['is_active_select'] = EEH_Form_Fields::select_input('is_active', $yes_no_values, $this->_cpt_model_obj->is_active());
1723
+		$template_args['_event'] = $this->_cpt_model_obj;
1724
+		$template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false);
1725
+		$template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit();
1726
+		$template_args['default_registration_status'] = EEH_Form_Fields::select_input(
1727
+			'default_reg_status',
1728
+			$default_reg_status_values,
1729
+			$this->_cpt_model_obj->default_registration_status()
1730
+		);
1731
+		$template_args['display_description'] = EEH_Form_Fields::select_input(
1732
+			'display_desc',
1733
+			$yes_no_values,
1734
+			$this->_cpt_model_obj->display_description()
1735
+		);
1736
+		$template_args['display_ticket_selector'] = EEH_Form_Fields::select_input(
1737
+			'display_ticket_selector',
1738
+			$yes_no_values,
1739
+			$this->_cpt_model_obj->display_ticket_selector(),
1740
+			'',
1741
+			'',
1742
+			false
1743
+		);
1744
+		$template_args['additional_registration_options'] = apply_filters(
1745
+			'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options',
1746
+			'',
1747
+			$template_args,
1748
+			$yes_no_values,
1749
+			$default_reg_status_values
1750
+		);
1751
+		EEH_Template::display_template(
1752
+			EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php',
1753
+			$template_args
1754
+		);
1755
+	}
1756
+
1757
+
1758
+	/**
1759
+	 * _get_events()
1760
+	 * This method simply returns all the events (for the given _view and paging)
1761
+	 *
1762
+	 * @access public
1763
+	 * @param int  $per_page     count of items per page (20 default);
1764
+	 * @param int  $current_page what is the current page being viewed.
1765
+	 * @param bool $count        if TRUE then we just return a count of ALL events matching the given _view.
1766
+	 *                           If FALSE then we return an array of event objects
1767
+	 *                           that match the given _view and paging parameters.
1768
+	 * @return array an array of event objects.
1769
+	 */
1770
+	public function get_events($per_page = 10, $current_page = 1, $count = false)
1771
+	{
1772
+		$EEME = $this->_event_model();
1773
+		$offset = ($current_page - 1) * $per_page;
1774
+		$limit = $count ? null : $offset . ',' . $per_page;
1775
+		$orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID';
1776
+		$order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC";
1777
+		if (isset($this->_req_data['month_range'])) {
1778
+			$pieces = explode(' ', $this->_req_data['month_range'], 3);
1779
+			// simulate the FIRST day of the month, that fixes issues for months like February
1780
+			// where PHP doesn't know what to assume for date.
1781
+			// @see https://events.codebasehq.com/projects/event-espresso/tickets/10437
1782
+			$month_r = ! empty($pieces[0]) ? date('m', \EEH_DTT_Helper::first_of_month_timestamp($pieces[0])) : '';
1783
+			$year_r = ! empty($pieces[1]) ? $pieces[1] : '';
1784
+		}
1785
+		$where = array();
1786
+		$status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
1787
+		// determine what post_status our condition will have for the query.
1788
+		switch ($status) {
1789
+			case 'month':
1790
+			case 'today':
1791
+			case null:
1792
+			case 'all':
1793
+				break;
1794
+			case 'draft':
1795
+				$where['status'] = array('IN', array('draft', 'auto-draft'));
1796
+				break;
1797
+			default:
1798
+				$where['status'] = $status;
1799
+		}
1800
+		// categories?
1801
+		$category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0
1802
+			? $this->_req_data['EVT_CAT'] : null;
1803
+		if (! empty($category)) {
1804
+			$where['Term_Taxonomy.taxonomy'] = EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY;
1805
+			$where['Term_Taxonomy.term_id'] = $category;
1806
+		}
1807
+		// date where conditions
1808
+		$start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start');
1809
+		if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') {
1810
+			$DateTime = new DateTime(
1811
+				$year_r . '-' . $month_r . '-01 00:00:00',
1812
+				new DateTimeZone(EEM_Datetime::instance()->get_timezone())
1813
+			);
1814
+			$start = $DateTime->format(implode(' ', $start_formats));
1815
+			$end = $DateTime->setDate(
1816
+				$year_r,
1817
+				$month_r,
1818
+				$DateTime
1819
+					->format('t')
1820
+			)->setTime(23, 59, 59)
1821
+							->format(implode(' ', $start_formats));
1822
+			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1823
+		} elseif (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') {
1824
+			$DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone()));
1825
+			$start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats));
1826
+			$end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats));
1827
+			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1828
+		} elseif (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') {
1829
+			$now = date('Y-m-01');
1830
+			$DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone()));
1831
+			$start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats));
1832
+			$end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t'))
1833
+							->setTime(23, 59, 59)
1834
+							->format(implode(' ', $start_formats));
1835
+			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1836
+		}
1837
+		if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
1838
+			$where['EVT_wp_user'] = get_current_user_id();
1839
+		} else {
1840
+			if (! isset($where['status'])) {
1841
+				if (! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) {
1842
+					$where['OR'] = array(
1843
+						'status*restrict_private' => array('!=', 'private'),
1844
+						'AND'                     => array(
1845
+							'status*inclusive' => array('=', 'private'),
1846
+							'EVT_wp_user'      => get_current_user_id(),
1847
+						),
1848
+					);
1849
+				}
1850
+			}
1851
+		}
1852
+		if (isset($this->_req_data['EVT_wp_user'])) {
1853
+			if ($this->_req_data['EVT_wp_user'] != get_current_user_id()
1854
+				&& EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')
1855
+			) {
1856
+				$where['EVT_wp_user'] = $this->_req_data['EVT_wp_user'];
1857
+			}
1858
+		}
1859
+		// search query handling
1860
+		if (isset($this->_req_data['s'])) {
1861
+			$search_string = '%' . $this->_req_data['s'] . '%';
1862
+			$where['OR'] = array(
1863
+				'EVT_name'       => array('LIKE', $search_string),
1864
+				'EVT_desc'       => array('LIKE', $search_string),
1865
+				'EVT_short_desc' => array('LIKE', $search_string),
1866
+			);
1867
+		}
1868
+		// filter events by venue.
1869
+		if (isset($this->_req_data['venue']) && ! empty($this->_req_data['venue'])) {
1870
+			$where['Venue.VNU_ID'] = absint($this->_req_data['venue']);
1871
+		}
1872
+		$where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data);
1873
+		$query_params = apply_filters(
1874
+			'FHEE__Events_Admin_Page__get_events__query_params',
1875
+			array(
1876
+				$where,
1877
+				'limit'    => $limit,
1878
+				'order_by' => $orderby,
1879
+				'order'    => $order,
1880
+				'group_by' => 'EVT_ID',
1881
+			),
1882
+			$this->_req_data
1883
+		);
1884
+		// let's first check if we have special requests coming in.
1885
+		if (isset($this->_req_data['active_status'])) {
1886
+			switch ($this->_req_data['active_status']) {
1887
+				case 'upcoming':
1888
+					return $EEME->get_upcoming_events($query_params, $count);
1889
+					break;
1890
+				case 'expired':
1891
+					return $EEME->get_expired_events($query_params, $count);
1892
+					break;
1893
+				case 'active':
1894
+					return $EEME->get_active_events($query_params, $count);
1895
+					break;
1896
+				case 'inactive':
1897
+					return $EEME->get_inactive_events($query_params, $count);
1898
+					break;
1899
+			}
1900
+		}
1901
+
1902
+		$events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params);
1903
+		return $events;
1904
+	}
1905
+
1906
+
1907
+	/**
1908
+	 * handling for WordPress CPT actions (trash, restore, delete)
1909
+	 *
1910
+	 * @param string $post_id
1911
+	 */
1912
+	public function trash_cpt_item($post_id)
1913
+	{
1914
+		$this->_req_data['EVT_ID'] = $post_id;
1915
+		$this->_trash_or_restore_event('trash', false);
1916
+	}
1917
+
1918
+
1919
+	/**
1920
+	 * @param string $post_id
1921
+	 */
1922
+	public function restore_cpt_item($post_id)
1923
+	{
1924
+		$this->_req_data['EVT_ID'] = $post_id;
1925
+		$this->_trash_or_restore_event('draft', false);
1926
+	}
1927
+
1928
+
1929
+	/**
1930
+	 * @param string $post_id
1931
+	 */
1932
+	public function delete_cpt_item($post_id)
1933
+	{
1934
+		throw new EE_Error(esc_html__('Please contact Event Espresso support with the details of the steps taken to produce this error.', 'event_espresso'));
1935
+		$this->_req_data['EVT_ID'] = $post_id;
1936
+		$this->_delete_event();
1937
+	}
1938
+
1939
+
1940
+	/**
1941
+	 * _trash_or_restore_event
1942
+	 *
1943
+	 * @access protected
1944
+	 * @param  string $event_status
1945
+	 * @param bool    $redirect_after
1946
+	 */
1947
+	protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = true)
1948
+	{
1949
+		// determine the event id and set to array.
1950
+		$EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : false;
1951
+		// loop thru events
1952
+		if ($EVT_ID) {
1953
+			// clean status
1954
+			$event_status = sanitize_key($event_status);
1955
+			// grab status
1956
+			if (! empty($event_status)) {
1957
+				$success = $this->_change_event_status($EVT_ID, $event_status);
1958
+			} else {
1959
+				$success = false;
1960
+				$msg = esc_html__(
1961
+					'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.',
1962
+					'event_espresso'
1963
+				);
1964
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1965
+			}
1966
+		} else {
1967
+			$success = false;
1968
+			$msg = esc_html__(
1969
+				'An error occurred. The event could not be moved to the trash because a valid event ID was not not supplied.',
1970
+				'event_espresso'
1971
+			);
1972
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1973
+		}
1974
+		$action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
1975
+		if ($redirect_after) {
1976
+			$this->_redirect_after_action($success, 'Event', $action, array('action' => 'default'));
1977
+		}
1978
+	}
1979
+
1980
+
1981
+	/**
1982
+	 * _trash_or_restore_events
1983
+	 *
1984
+	 * @access protected
1985
+	 * @param  string $event_status
1986
+	 * @return void
1987
+	 */
1988
+	protected function _trash_or_restore_events($event_status = 'trash')
1989
+	{
1990
+		// clean status
1991
+		$event_status = sanitize_key($event_status);
1992
+		// grab status
1993
+		if (! empty($event_status)) {
1994
+			$success = true;
1995
+			// determine the event id and set to array.
1996
+			$EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array();
1997
+			// loop thru events
1998
+			foreach ($EVT_IDs as $EVT_ID) {
1999
+				if ($EVT_ID = absint($EVT_ID)) {
2000
+					$results = $this->_change_event_status($EVT_ID, $event_status);
2001
+					$success = $results !== false ? $success : false;
2002
+				} else {
2003
+					$msg = sprintf(
2004
+						esc_html__(
2005
+							'An error occurred. Event #%d could not be moved to the trash because a valid event ID was not not supplied.',
2006
+							'event_espresso'
2007
+						),
2008
+						$EVT_ID
2009
+					);
2010
+					EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2011
+					$success = false;
2012
+				}
2013
+			}
2014
+		} else {
2015
+			$success = false;
2016
+			$msg = esc_html__(
2017
+				'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.',
2018
+				'event_espresso'
2019
+			);
2020
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2021
+		}
2022
+		// in order to force a pluralized result message we need to send back a success status greater than 1
2023
+		$success = $success ? 2 : false;
2024
+		$action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
2025
+		$this->_redirect_after_action($success, 'Events', $action, array('action' => 'default'));
2026
+	}
2027
+
2028
+
2029
+	/**
2030
+	 * _trash_or_restore_events
2031
+	 *
2032
+	 * @access  private
2033
+	 * @param  int    $EVT_ID
2034
+	 * @param  string $event_status
2035
+	 * @return bool
2036
+	 */
2037
+	private function _change_event_status($EVT_ID = 0, $event_status = '')
2038
+	{
2039
+		// grab event id
2040
+		if (! $EVT_ID) {
2041
+			$msg = esc_html__(
2042
+				'An error occurred. No Event ID or an invalid Event ID was received.',
2043
+				'event_espresso'
2044
+			);
2045
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2046
+			return false;
2047
+		}
2048
+		$this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID);
2049
+		// clean status
2050
+		$event_status = sanitize_key($event_status);
2051
+		// grab status
2052
+		if (empty($event_status)) {
2053
+			$msg = esc_html__(
2054
+				'An error occurred. No Event Status or an invalid Event Status was received.',
2055
+				'event_espresso'
2056
+			);
2057
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2058
+			return false;
2059
+		}
2060
+		// was event trashed or restored ?
2061
+		switch ($event_status) {
2062
+			case 'draft':
2063
+				$action = 'restored from the trash';
2064
+				$hook = 'AHEE_event_restored_from_trash';
2065
+				break;
2066
+			case 'trash':
2067
+				$action = 'moved to the trash';
2068
+				$hook = 'AHEE_event_moved_to_trash';
2069
+				break;
2070
+			default:
2071
+				$action = 'updated';
2072
+				$hook = false;
2073
+		}
2074
+		// use class to change status
2075
+		$this->_cpt_model_obj->set_status($event_status);
2076
+		$success = $this->_cpt_model_obj->save();
2077
+		if ($success === false) {
2078
+			$msg = sprintf(esc_html__('An error occurred. The event could not be %s.', 'event_espresso'), $action);
2079
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2080
+			return false;
2081
+		}
2082
+		if ($hook) {
2083
+			do_action($hook);
2084
+		}
2085
+		return true;
2086
+	}
2087
+
2088
+
2089
+	/**
2090
+	 * _delete_event
2091
+	 *
2092
+	 * @access protected
2093
+	 * @param bool $redirect_after
2094
+	 */
2095
+	protected function _delete_event()
2096
+	{
2097
+		$this->generateDeletionPreview(isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : array());
2098
+	}
2099
+
2100
+	/**
2101
+	 * Gets the tree traversal batch persister.
2102
+	 * @since $VID:$
2103
+	 * @return NodeGroupDao
2104
+	 * @throws InvalidArgumentException
2105
+	 * @throws InvalidDataTypeException
2106
+	 * @throws InvalidInterfaceException
2107
+	 */
2108
+	protected function getModelObjNodeGroupPersister()
2109
+	{
2110
+		if (! $this->model_obj_node_group_persister instanceof NodeGroupDao) {
2111
+			$this->model_obj_node_group_persister = $this->getLoader()->load('\EventEspresso\core\services\orm\tree_traversal\NodeGroupDao');
2112
+		}
2113
+		return $this->model_obj_node_group_persister;
2114
+	}
2115
+
2116
+	/**
2117
+	 * _delete_events
2118
+	 *
2119
+	 * @access protected
2120
+	 * @return void
2121
+	 */
2122
+	protected function _delete_events()
2123
+	{
2124
+		$this->generateDeletionPreview(isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array());
2125
+	}
2126
+
2127
+	protected function generateDeletionPreview($event_ids)
2128
+	{
2129
+		$event_ids = (array) $event_ids;
2130
+		// Set a code we can use to reference this deletion task in the batch jobs and preview page.
2131
+		$deletion_job_code = $this->getModelObjNodeGroupPersister()->generateGroupCode();
2132
+		$return_url = EE_Admin_Page::add_query_args_and_nonce(
2133
+			[
2134
+				'action' => 'preview_deletion',
2135
+				'deletion_job_code' => $deletion_job_code,
2136
+			],
2137
+			$this->_admin_base_url
2138
+		);
2139
+		$event_ids = array_map(
2140
+			'intval',
2141
+			$event_ids
2142
+		);
2143
+
2144
+		EEH_URL::safeRedirectAndExit(
2145
+			EE_Admin_Page::add_query_args_and_nonce(
2146
+				array(
2147
+					'page'        => 'espresso_batch',
2148
+					'batch'       => EED_Batch::batch_job,
2149
+					'EVT_IDs'      => $event_ids,
2150
+					'deletion_job_code' => $deletion_job_code,
2151
+					'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\PreviewEventDeletion'),
2152
+					'return_url'  => urlencode($return_url),
2153
+				),
2154
+				admin_url()
2155
+			)
2156
+		);
2157
+	}
2158
+
2159
+	/**
2160
+	 * Checks for a POST submission
2161
+	 * @since $VID:$
2162
+	 */
2163
+	protected function confirmDeletion()
2164
+	{
2165
+		$deletion_redirect_logic = $this->getLoader()->getShared('\EventEspresso\core\domain\services\admin\events\data\ConfirmDeletion');
2166
+		return $deletion_redirect_logic->handle($this);
2167
+	}
2168
+
2169
+	/**
2170
+	 * A page for users to preview what exactly will be deleted, and confirm they want to delete it.
2171
+	 * @since $VID:$
2172
+	 * @throws EE_Error
2173
+	 */
2174
+	protected function previewDeletion()
2175
+	{
2176
+		$preview_deletion_logic = $this->getLoader()->getShared('\EventEspresso\core\domain\services\admin\events\data\PreviewDeletion');
2177
+		return $preview_deletion_logic->handle($this);
2178
+	}
2179
+
2180
+	/**
2181
+	 * get total number of events
2182
+	 *
2183
+	 * @access public
2184
+	 * @return int
2185
+	 */
2186
+	public function total_events()
2187
+	{
2188
+		$count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true);
2189
+		return $count;
2190
+	}
2191
+
2192
+
2193
+	/**
2194
+	 * get total number of draft events
2195
+	 *
2196
+	 * @access public
2197
+	 * @return int
2198
+	 */
2199
+	public function total_events_draft()
2200
+	{
2201
+		$where = array(
2202
+			'status' => array('IN', array('draft', 'auto-draft')),
2203
+		);
2204
+		$count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
2205
+		return $count;
2206
+	}
2207
+
2208
+
2209
+	/**
2210
+	 * get total number of trashed events
2211
+	 *
2212
+	 * @access public
2213
+	 * @return int
2214
+	 */
2215
+	public function total_trashed_events()
2216
+	{
2217
+		$where = array(
2218
+			'status' => 'trash',
2219
+		);
2220
+		$count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
2221
+		return $count;
2222
+	}
2223
+
2224
+
2225
+	/**
2226
+	 *    _default_event_settings
2227
+	 *    This generates the Default Settings Tab
2228
+	 *
2229
+	 * @return void
2230
+	 * @throws EE_Error
2231
+	 */
2232
+	protected function _default_event_settings()
2233
+	{
2234
+		$this->_set_add_edit_form_tags('update_default_event_settings');
2235
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
2236
+		$this->_template_args['admin_page_content'] = $this->_default_event_settings_form()->get_html();
2237
+		$this->display_admin_page_with_sidebar();
2238
+	}
2239
+
2240
+
2241
+	/**
2242
+	 * Return the form for event settings.
2243
+	 *
2244
+	 * @return EE_Form_Section_Proper
2245
+	 * @throws EE_Error
2246
+	 */
2247
+	protected function _default_event_settings_form()
2248
+	{
2249
+		$registration_config = EE_Registry::instance()->CFG->registration;
2250
+		$registration_stati_for_selection = EEM_Registration::reg_status_array(
2251
+			// exclude
2252
+			array(
2253
+				EEM_Registration::status_id_cancelled,
2254
+				EEM_Registration::status_id_declined,
2255
+				EEM_Registration::status_id_incomplete,
2256
+				EEM_Registration::status_id_wait_list,
2257
+			),
2258
+			true
2259
+		);
2260
+		return new EE_Form_Section_Proper(
2261
+			array(
2262
+				'name'            => 'update_default_event_settings',
2263
+				'html_id'         => 'update_default_event_settings',
2264
+				'html_class'      => 'form-table',
2265
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
2266
+				'subsections'     => apply_filters(
2267
+					'FHEE__Events_Admin_Page___default_event_settings_form__form_subsections',
2268
+					array(
2269
+						'default_reg_status'  => new EE_Select_Input(
2270
+							$registration_stati_for_selection,
2271
+							array(
2272
+								'default'         => isset($registration_config->default_STS_ID)
2273
+													 && array_key_exists(
2274
+														 $registration_config->default_STS_ID,
2275
+														 $registration_stati_for_selection
2276
+													 )
2277
+									? sanitize_text_field($registration_config->default_STS_ID)
2278
+									: EEM_Registration::status_id_pending_payment,
2279
+								'html_label_text' => esc_html__('Default Registration Status', 'event_espresso')
2280
+													 . EEH_Template::get_help_tab_link(
2281
+														 'default_settings_status_help_tab'
2282
+													 ),
2283
+								'html_help_text'  => esc_html__(
2284
+									'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.',
2285
+									'event_espresso'
2286
+								),
2287
+							)
2288
+						),
2289
+						'default_max_tickets' => new EE_Integer_Input(
2290
+							array(
2291
+								'default'         => isset($registration_config->default_maximum_number_of_tickets)
2292
+									? $registration_config->default_maximum_number_of_tickets
2293
+									: EEM_Event::get_default_additional_limit(),
2294
+								'html_label_text' => esc_html__(
2295
+									'Default Maximum Tickets Allowed Per Order:',
2296
+									'event_espresso'
2297
+								)
2298
+													 . EEH_Template::get_help_tab_link(
2299
+														 'default_maximum_tickets_help_tab"'
2300
+													 ),
2301
+								'html_help_text'  => esc_html__(
2302
+									'This setting allows you to indicate what will be the default for the maximum number of tickets per order when creating new events.',
2303
+									'event_espresso'
2304
+								),
2305
+							)
2306
+						),
2307
+					)
2308
+				),
2309
+			)
2310
+		);
2311
+	}
2312
+
2313
+
2314
+	/**
2315
+	 * _update_default_event_settings
2316
+	 *
2317
+	 * @access protected
2318
+	 * @return void
2319
+	 * @throws EE_Error
2320
+	 */
2321
+	protected function _update_default_event_settings()
2322
+	{
2323
+		$registration_config = EE_Registry::instance()->CFG->registration;
2324
+		$form = $this->_default_event_settings_form();
2325
+		if ($form->was_submitted()) {
2326
+			$form->receive_form_submission();
2327
+			if ($form->is_valid()) {
2328
+				$valid_data = $form->valid_data();
2329
+				if (isset($valid_data['default_reg_status'])) {
2330
+					$registration_config->default_STS_ID = $valid_data['default_reg_status'];
2331
+				}
2332
+				if (isset($valid_data['default_max_tickets'])) {
2333
+					$registration_config->default_maximum_number_of_tickets = $valid_data['default_max_tickets'];
2334
+				}
2335
+				// update because data was valid!
2336
+				EE_Registry::instance()->CFG->update_espresso_config();
2337
+				EE_Error::overwrite_success();
2338
+				EE_Error::add_success(
2339
+					__('Default Event Settings were updated', 'event_espresso')
2340
+				);
2341
+			}
2342
+		}
2343
+		$this->_redirect_after_action(0, '', '', array('action' => 'default_event_settings'), true);
2344
+	}
2345
+
2346
+
2347
+	/*************        Templates        *************/
2348
+	protected function _template_settings()
2349
+	{
2350
+		$this->_admin_page_title = esc_html__('Template Settings (Preview)', 'event_espresso');
2351
+		$this->_template_args['preview_img'] = '<img src="'
2352
+											   . EVENTS_ASSETS_URL
2353
+											   . '/images/'
2354
+											   . 'caffeinated_template_features.jpg" alt="'
2355
+											   . esc_attr__('Template Settings Preview screenshot', 'event_espresso')
2356
+											   . '" />';
2357
+		$this->_template_args['preview_text'] = '<strong>'
2358
+												. esc_html__(
2359
+													'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.',
2360
+													'event_espresso'
2361
+												) . '</strong>';
2362
+		$this->display_admin_caf_preview_page('template_settings_tab');
2363
+	}
2364
+
2365
+
2366
+	/** Event Category Stuff **/
2367
+	/**
2368
+	 * set the _category property with the category object for the loaded page.
2369
+	 *
2370
+	 * @access private
2371
+	 * @return void
2372
+	 */
2373
+	private function _set_category_object()
2374
+	{
2375
+		if (isset($this->_category->id) && ! empty($this->_category->id)) {
2376
+			return;
2377
+		} //already have the category object so get out.
2378
+		// set default category object
2379
+		$this->_set_empty_category_object();
2380
+		// only set if we've got an id
2381
+		if (! isset($this->_req_data['EVT_CAT_ID'])) {
2382
+			return;
2383
+		}
2384
+		$category_id = absint($this->_req_data['EVT_CAT_ID']);
2385
+		$term = get_term($category_id, EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY);
2386
+		if (! empty($term)) {
2387
+			$this->_category->category_name = $term->name;
2388
+			$this->_category->category_identifier = $term->slug;
2389
+			$this->_category->category_desc = $term->description;
2390
+			$this->_category->id = $term->term_id;
2391
+			$this->_category->parent = $term->parent;
2392
+		}
2393
+	}
2394
+
2395
+
2396
+	/**
2397
+	 * Clears out category properties.
2398
+	 */
2399
+	private function _set_empty_category_object()
2400
+	{
2401
+		$this->_category = new stdClass();
2402
+		$this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = '';
2403
+		$this->_category->id = $this->_category->parent = 0;
2404
+	}
2405
+
2406
+
2407
+	/**
2408
+	 * @throws EE_Error
2409
+	 */
2410
+	protected function _category_list_table()
2411
+	{
2412
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2413
+		$this->_search_btn_label = esc_html__('Categories', 'event_espresso');
2414
+		$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
2415
+			'add_category',
2416
+			'add_category',
2417
+			array(),
2418
+			'add-new-h2'
2419
+		);
2420
+		$this->display_admin_list_table_page_with_sidebar();
2421
+	}
2422
+
2423
+
2424
+	/**
2425
+	 * Output category details view.
2426
+	 */
2427
+	protected function _category_details($view)
2428
+	{
2429
+		// load formatter helper
2430
+		// load field generator helper
2431
+		$route = $view == 'edit' ? 'update_category' : 'insert_category';
2432
+		$this->_set_add_edit_form_tags($route);
2433
+		$this->_set_category_object();
2434
+		$id = ! empty($this->_category->id) ? $this->_category->id : '';
2435
+		$delete_action = 'delete_category';
2436
+		// custom redirect
2437
+		$redirect = EE_Admin_Page::add_query_args_and_nonce(
2438
+			array('action' => 'category_list'),
2439
+			$this->_admin_base_url
2440
+		);
2441
+		$this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect);
2442
+		// take care of contents
2443
+		$this->_template_args['admin_page_content'] = $this->_category_details_content();
2444
+		$this->display_admin_page_with_sidebar();
2445
+	}
2446
+
2447
+
2448
+	/**
2449
+	 * Output category details content.
2450
+	 */
2451
+	protected function _category_details_content()
2452
+	{
2453
+		$editor_args['category_desc'] = array(
2454
+			'type'          => 'wp_editor',
2455
+			'value'         => EEH_Formatter::admin_format_content($this->_category->category_desc),
2456
+			'class'         => 'my_editor_custom',
2457
+			'wpeditor_args' => array('media_buttons' => false),
2458
+		);
2459
+		$_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array');
2460
+		$all_terms = get_terms(
2461
+			array(EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY),
2462
+			array('hide_empty' => 0, 'exclude' => array($this->_category->id))
2463
+		);
2464
+		// setup category select for term parents.
2465
+		$category_select_values[] = array(
2466
+			'text' => esc_html__('No Parent', 'event_espresso'),
2467
+			'id'   => 0,
2468
+		);
2469
+		foreach ($all_terms as $term) {
2470
+			$category_select_values[] = array(
2471
+				'text' => $term->name,
2472
+				'id'   => $term->term_id,
2473
+			);
2474
+		}
2475
+		$category_select = EEH_Form_Fields::select_input(
2476
+			'category_parent',
2477
+			$category_select_values,
2478
+			$this->_category->parent
2479
+		);
2480
+		$template_args = array(
2481
+			'category'                 => $this->_category,
2482
+			'category_select'          => $category_select,
2483
+			'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'),
2484
+			'category_desc_editor'     => $_wp_editor['category_desc']['field'],
2485
+			'disable'                  => '',
2486
+			'disabled_message'         => false,
2487
+		);
2488
+		$template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php';
2489
+		return EEH_Template::display_template($template, $template_args, true);
2490
+	}
2491
+
2492
+
2493
+	/**
2494
+	 * Handles deleting categories.
2495
+	 */
2496
+	protected function _delete_categories()
2497
+	{
2498
+		$cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array) $this->_req_data['EVT_CAT_ID']
2499
+			: (array) $this->_req_data['category_id'];
2500
+		foreach ($cat_ids as $cat_id) {
2501
+			$this->_delete_category($cat_id);
2502
+		}
2503
+		// doesn't matter what page we're coming from... we're going to the same place after delete.
2504
+		$query_args = array(
2505
+			'action' => 'category_list',
2506
+		);
2507
+		$this->_redirect_after_action(0, '', '', $query_args);
2508
+	}
2509
+
2510
+
2511
+	/**
2512
+	 * Handles deleting specific category.
2513
+	 *
2514
+	 * @param int $cat_id
2515
+	 */
2516
+	protected function _delete_category($cat_id)
2517
+	{
2518
+		$cat_id = absint($cat_id);
2519
+		wp_delete_term($cat_id, EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY);
2520
+	}
2521
+
2522
+
2523
+	/**
2524
+	 * Handles triggering the update or insertion of a new category.
2525
+	 *
2526
+	 * @param bool $new_category true means we're triggering the insert of a new category.
2527
+	 */
2528
+	protected function _insert_or_update_category($new_category)
2529
+	{
2530
+		$cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(true);
2531
+		$success = 0; // we already have a success message so lets not send another.
2532
+		if ($cat_id) {
2533
+			$query_args = array(
2534
+				'action'     => 'edit_category',
2535
+				'EVT_CAT_ID' => $cat_id,
2536
+			);
2537
+		} else {
2538
+			$query_args = array('action' => 'add_category');
2539
+		}
2540
+		$this->_redirect_after_action($success, '', '', $query_args, true);
2541
+	}
2542
+
2543
+
2544
+	/**
2545
+	 * Inserts or updates category
2546
+	 *
2547
+	 * @param bool $update (true indicates we're updating a category).
2548
+	 * @return bool|mixed|string
2549
+	 */
2550
+	private function _insert_category($update = false)
2551
+	{
2552
+		$cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : '';
2553
+		$category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : '';
2554
+		$category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : '';
2555
+		$category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0;
2556
+		if (empty($category_name)) {
2557
+			$msg = esc_html__('You must add a name for the category.', 'event_espresso');
2558
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2559
+			return false;
2560
+		}
2561
+		$term_args = array(
2562
+			'name'        => $category_name,
2563
+			'description' => $category_desc,
2564
+			'parent'      => $category_parent,
2565
+		);
2566
+		// was the category_identifier input disabled?
2567
+		if (isset($this->_req_data['category_identifier'])) {
2568
+			$term_args['slug'] = $this->_req_data['category_identifier'];
2569
+		}
2570
+		$insert_ids = $update
2571
+			? wp_update_term($cat_id, EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY, $term_args)
2572
+			: wp_insert_term($category_name, EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY, $term_args);
2573
+		if (! is_array($insert_ids)) {
2574
+			$msg = esc_html__(
2575
+				'An error occurred and the category has not been saved to the database.',
2576
+				'event_espresso'
2577
+			);
2578
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2579
+		} else {
2580
+			$cat_id = $insert_ids['term_id'];
2581
+			$msg = sprintf(esc_html__('The category %s was successfully saved', 'event_espresso'), $category_name);
2582
+			EE_Error::add_success($msg);
2583
+		}
2584
+		return $cat_id;
2585
+	}
2586
+
2587
+
2588
+	/**
2589
+	 * Gets categories or count of categories matching the arguments in the request.
2590
+	 *
2591
+	 * @param int  $per_page
2592
+	 * @param int  $current_page
2593
+	 * @param bool $count
2594
+	 * @return EE_Base_Class[]|EE_Term_Taxonomy[]|int
2595
+	 */
2596
+	public function get_categories($per_page = 10, $current_page = 1, $count = false)
2597
+	{
2598
+		// testing term stuff
2599
+		$orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id';
2600
+		$order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC';
2601
+		$limit = ($current_page - 1) * $per_page;
2602
+		$where = array('taxonomy' => EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY);
2603
+		if (isset($this->_req_data['s'])) {
2604
+			$sstr = '%' . $this->_req_data['s'] . '%';
2605
+			$where['OR'] = array(
2606
+				'Term.name'   => array('LIKE', $sstr),
2607
+				'description' => array('LIKE', $sstr),
2608
+			);
2609
+		}
2610
+		$query_params = array(
2611
+			$where,
2612
+			'order_by'   => array($orderby => $order),
2613
+			'limit'      => $limit . ',' . $per_page,
2614
+			'force_join' => array('Term'),
2615
+		);
2616
+		$categories = $count
2617
+			? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id')
2618
+			: EEM_Term_Taxonomy::instance()->get_all($query_params);
2619
+		return $categories;
2620
+	}
2621
+
2622
+	/* end category stuff */
2623
+	/**************/
2624
+
2625
+
2626
+	/**
2627
+	 * Callback for the `ee_save_timezone_setting` ajax action.
2628
+	 *
2629
+	 * @throws EE_Error
2630
+	 */
2631
+	public function save_timezonestring_setting()
2632
+	{
2633
+		$timezone_string = isset($this->_req_data['timezone_selected'])
2634
+			? $this->_req_data['timezone_selected']
2635
+			: '';
2636
+		if (empty($timezone_string) || ! EEH_DTT_Helper::validate_timezone($timezone_string, false)) {
2637
+			EE_Error::add_error(
2638
+				esc_html__('An invalid timezone string submitted.', 'event_espresso'),
2639
+				__FILE__,
2640
+				__FUNCTION__,
2641
+				__LINE__
2642
+			);
2643
+			$this->_template_args['error'] = true;
2644
+			$this->_return_json();
2645
+		}
2646
+
2647
+		update_option('timezone_string', $timezone_string);
2648
+		EE_Error::add_success(
2649
+			esc_html__('Your timezone string was updated.', 'event_espresso')
2650
+		);
2651
+		$this->_template_args['success'] = true;
2652
+		$this->_return_json(true, array('action' => 'create_new'));
2653
+	}
2654 2654
 }
Please login to merge, or discard this patch.
Spacing   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -577,11 +577,11 @@  discard block
 block discarded – undo
577 577
     {
578 578
         wp_register_style(
579 579
             'events-admin-css',
580
-            EVENTS_ASSETS_URL . 'events-admin-page.css',
580
+            EVENTS_ASSETS_URL.'events-admin-page.css',
581 581
             array(),
582 582
             EVENT_ESPRESSO_VERSION
583 583
         );
584
-        wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION);
584
+        wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL.'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION);
585 585
         wp_enqueue_style('events-admin-css');
586 586
         wp_enqueue_style('ee-cat-admin');
587 587
         // todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
         // scripts
590 590
         wp_register_script(
591 591
             'event_editor_js',
592
-            EVENTS_ASSETS_URL . 'event_editor.js',
592
+            EVENTS_ASSETS_URL.'event_editor.js',
593 593
             array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'),
594 594
             EVENT_ESPRESSO_VERSION,
595 595
             true
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
         wp_enqueue_style('espresso-ui-theme');
616 616
         wp_register_style(
617 617
             'event-editor-css',
618
-            EVENTS_ASSETS_URL . 'event-editor.css',
618
+            EVENTS_ASSETS_URL.'event-editor.css',
619 619
             array('ee-admin-css'),
620 620
             EVENT_ESPRESSO_VERSION
621 621
         );
@@ -623,7 +623,7 @@  discard block
 block discarded – undo
623 623
         // scripts
624 624
         wp_register_script(
625 625
             'event-datetime-metabox',
626
-            EVENTS_ASSETS_URL . 'event-datetime-metabox.js',
626
+            EVENTS_ASSETS_URL.'event-datetime-metabox.js',
627 627
             array('event_editor_js', 'ee-datepicker'),
628 628
             EVENT_ESPRESSO_VERSION
629 629
         );
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
     public function verify_event_edit($event = null, $req_type = '')
693 693
     {
694 694
         // don't need to do this when processing
695
-        if (! empty($req_type)) {
695
+        if ( ! empty($req_type)) {
696 696
             return;
697 697
         }
698 698
         // no event?
@@ -701,7 +701,7 @@  discard block
 block discarded – undo
701 701
             $event = $this->_cpt_model_obj;
702 702
         }
703 703
         // STILL no event?
704
-        if (! $event instanceof EE_Event) {
704
+        if ( ! $event instanceof EE_Event) {
705 705
             return;
706 706
         }
707 707
         $orig_status = $event->status();
@@ -739,7 +739,7 @@  discard block
 block discarded – undo
739 739
             );
740 740
         }
741 741
         // now we need to determine if the event has any tickets on sale.  If not then we dont' show the error
742
-        if (! $event->tickets_on_sale()) {
742
+        if ( ! $event->tickets_on_sale()) {
743 743
             return;
744 744
         }
745 745
         // made it here so show warning
@@ -784,7 +784,7 @@  discard block
 block discarded – undo
784 784
     {
785 785
         $has_timezone_string = get_option('timezone_string');
786 786
         // only nag them about setting their timezone if it's their first event, and they haven't already done it
787
-        if (! $has_timezone_string && ! EEM_Event::instance()->exists(array())) {
787
+        if ( ! $has_timezone_string && ! EEM_Event::instance()->exists(array())) {
788 788
             EE_Error::add_attention(
789 789
                 sprintf(
790 790
                     __(
@@ -868,31 +868,31 @@  discard block
 block discarded – undo
868 868
         $items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items);
869 869
         $statuses = array(
870 870
             'sold_out_status'  => array(
871
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out,
871
+                'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::sold_out,
872 872
                 'desc'  => EEH_Template::pretty_status(EE_Datetime::sold_out, false, 'sentence'),
873 873
             ),
874 874
             'active_status'    => array(
875
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active,
875
+                'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::active,
876 876
                 'desc'  => EEH_Template::pretty_status(EE_Datetime::active, false, 'sentence'),
877 877
             ),
878 878
             'upcoming_status'  => array(
879
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming,
879
+                'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::upcoming,
880 880
                 'desc'  => EEH_Template::pretty_status(EE_Datetime::upcoming, false, 'sentence'),
881 881
             ),
882 882
             'postponed_status' => array(
883
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed,
883
+                'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::postponed,
884 884
                 'desc'  => EEH_Template::pretty_status(EE_Datetime::postponed, false, 'sentence'),
885 885
             ),
886 886
             'cancelled_status' => array(
887
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled,
887
+                'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::cancelled,
888 888
                 'desc'  => EEH_Template::pretty_status(EE_Datetime::cancelled, false, 'sentence'),
889 889
             ),
890 890
             'expired_status'   => array(
891
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired,
891
+                'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::expired,
892 892
                 'desc'  => EEH_Template::pretty_status(EE_Datetime::expired, false, 'sentence'),
893 893
             ),
894 894
             'inactive_status'  => array(
895
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive,
895
+                'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::inactive,
896 896
                 'desc'  => EEH_Template::pretty_status(EE_Datetime::inactive, false, 'sentence'),
897 897
             ),
898 898
         );
@@ -906,7 +906,7 @@  discard block
 block discarded – undo
906 906
      */
907 907
     private function _event_model()
908 908
     {
909
-        if (! $this->_event_model instanceof EEM_Event) {
909
+        if ( ! $this->_event_model instanceof EEM_Event) {
910 910
             $this->_event_model = EE_Registry::instance()->load_model('Event');
911 911
         }
912 912
         return $this->_event_model;
@@ -926,7 +926,7 @@  discard block
 block discarded – undo
926 926
     public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug)
927 927
     {
928 928
         // make sure this is only when editing
929
-        if (! empty($id)) {
929
+        if ( ! empty($id)) {
930 930
             $post = get_post($id);
931 931
             $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#"  tabindex="-1">'
932 932
                        . esc_html__('Shortcode', 'event_espresso')
@@ -960,7 +960,7 @@  discard block
 block discarded – undo
960 960
                     'button'
961 961
                 );
962 962
         $this->_template_args['after_list_table']['legend'] = $this->_display_legend($this->_event_legend_items());
963
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
963
+        $this->_admin_page_title .= ' '.$this->get_action_link_or_button(
964 964
             'create_new',
965 965
             'add',
966 966
             array(),
@@ -1100,7 +1100,7 @@  discard block
 block discarded – undo
1100 1100
      */
1101 1101
     protected function _default_venue_update(\EE_Event $evtobj, $data)
1102 1102
     {
1103
-        require_once(EE_MODELS . 'EEM_Venue.model.php');
1103
+        require_once(EE_MODELS.'EEM_Venue.model.php');
1104 1104
         $venue_model = EE_Registry::instance()->load_model('Venue');
1105 1105
         $rows_affected = null;
1106 1106
         $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null;
@@ -1131,7 +1131,7 @@  discard block
 block discarded – undo
1131 1131
             'status'              => 'publish',
1132 1132
         );
1133 1133
         // if we've got the venue_id then we're just updating the existing venue so let's do that and then get out.
1134
-        if (! empty($venue_id)) {
1134
+        if ( ! empty($venue_id)) {
1135 1135
             $update_where = array($venue_model->primary_key_name() => $venue_id);
1136 1136
             $rows_affected = $venue_model->update($venue_array, array($update_where));
1137 1137
             // 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.
@@ -1173,7 +1173,7 @@  discard block
 block discarded – undo
1173 1173
                 'DTT_order'     => $row,
1174 1174
             );
1175 1175
             // 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.
1176
-            if (! empty($dtt['DTT_ID'])) {
1176
+            if ( ! empty($dtt['DTT_ID'])) {
1177 1177
                 $DTM = EE_Registry::instance()
1178 1178
                                   ->load_model('Datetime', array($evtobj->get_timezone()))
1179 1179
                                   ->get_one_by_ID($dtt['DTT_ID']);
@@ -1183,7 +1183,7 @@  discard block
 block discarded – undo
1183 1183
                     $DTM->set($field, $value);
1184 1184
                 }
1185 1185
                 // 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.
1186
-                $saved_dtts[ $DTM->ID() ] = $DTM;
1186
+                $saved_dtts[$DTM->ID()] = $DTM;
1187 1187
             } else {
1188 1188
                 $DTM = EE_Registry::instance()->load_class(
1189 1189
                     'Datetime',
@@ -1216,14 +1216,14 @@  discard block
 block discarded – undo
1216 1216
         foreach ($data['edit_tickets'] as $row => $tkt) {
1217 1217
             $incoming_date_formats = array('Y-m-d', 'h:i a');
1218 1218
             $update_prices = false;
1219
-            $ticket_price = isset($data['edit_prices'][ $row ][1]['PRC_amount'])
1220
-                ? $data['edit_prices'][ $row ][1]['PRC_amount'] : 0;
1219
+            $ticket_price = isset($data['edit_prices'][$row][1]['PRC_amount'])
1220
+                ? $data['edit_prices'][$row][1]['PRC_amount'] : 0;
1221 1221
             // trim inputs to ensure any excess whitespace is removed.
1222 1222
             $tkt = array_map('trim', $tkt);
1223 1223
             if (empty($tkt['TKT_start_date'])) {
1224 1224
                 // let's use now in the set timezone.
1225 1225
                 $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone()));
1226
-                $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0] . ' ' . $incoming_date_formats[1]);
1226
+                $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0].' '.$incoming_date_formats[1]);
1227 1227
             }
1228 1228
             if (empty($tkt['TKT_end_date'])) {
1229 1229
                 // use the start date of the first datetime
@@ -1258,7 +1258,7 @@  discard block
 block discarded – undo
1258 1258
             // if we have a TKT_ID then we need to get that existing TKT_obj and update it
1259 1259
             // 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.
1260 1260
             // 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.
1261
-            if (! empty($tkt['TKT_ID'])) {
1261
+            if ( ! empty($tkt['TKT_ID'])) {
1262 1262
                 $TKT = EE_Registry::instance()
1263 1263
                                   ->load_model('Ticket', array($evtobj->get_timezone()))
1264 1264
                                   ->get_one_by_ID($tkt['TKT_ID']);
@@ -1293,7 +1293,7 @@  discard block
 block discarded – undo
1293 1293
                         $TKT->set('TKT_deleted', 1);
1294 1294
                         $TKT->save();
1295 1295
                         // make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine.
1296
-                        $saved_tickets[ $TKT->ID() ] = $TKT;
1296
+                        $saved_tickets[$TKT->ID()] = $TKT;
1297 1297
                         // 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.
1298 1298
                         $TKT = clone $TKT;
1299 1299
                         $TKT->set('TKT_ID', 0);
@@ -1338,9 +1338,9 @@  discard block
 block discarded – undo
1338 1338
             }
1339 1339
             // initially let's add the ticket to the dtt
1340 1340
             $saved_dtt->_add_relation_to($TKT, 'Ticket');
1341
-            $saved_tickets[ $TKT->ID() ] = $TKT;
1341
+            $saved_tickets[$TKT->ID()] = $TKT;
1342 1342
             // add prices to ticket
1343
-            $this->_add_prices_to_ticket($data['edit_prices'][ $row ], $TKT, $update_prices);
1343
+            $this->_add_prices_to_ticket($data['edit_prices'][$row], $TKT, $update_prices);
1344 1344
         }
1345 1345
         // 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.
1346 1346
         $old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets;
@@ -1497,7 +1497,7 @@  discard block
 block discarded – undo
1497 1497
         $publish_box_extra_args['event_editor_overview_add'] = ob_get_clean();
1498 1498
         // load template
1499 1499
         EEH_Template::display_template(
1500
-            EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php',
1500
+            EVENTS_TEMPLATE_PATH.'event_publish_box_extras.template.php',
1501 1501
             $publish_box_extra_args
1502 1502
         );
1503 1503
     }
@@ -1589,7 +1589,7 @@  discard block
 block discarded – undo
1589 1589
                     'default_where_conditions' => 'none',
1590 1590
                 )
1591 1591
             );
1592
-            if (! empty($related_tickets)) {
1592
+            if ( ! empty($related_tickets)) {
1593 1593
                 $template_args['total_ticket_rows'] = count($related_tickets);
1594 1594
                 $row = 0;
1595 1595
                 foreach ($related_tickets as $ticket) {
@@ -1623,7 +1623,7 @@  discard block
 block discarded – undo
1623 1623
         );
1624 1624
         $template = apply_filters(
1625 1625
             'FHEE__Events_Admin_Page__ticket_metabox__template',
1626
-            EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php'
1626
+            EVENTS_TEMPLATE_PATH.'event_tickets_metabox_main.template.php'
1627 1627
         );
1628 1628
         EEH_Template::display_template($template, $template_args);
1629 1629
     }
@@ -1641,7 +1641,7 @@  discard block
 block discarded – undo
1641 1641
     private function _get_ticket_row($ticket, $skeleton = false, $row = 0)
1642 1642
     {
1643 1643
         $template_args = array(
1644
-            'tkt_status_class'    => ' tkt-status-' . $ticket->ticket_status(),
1644
+            'tkt_status_class'    => ' tkt-status-'.$ticket->ticket_status(),
1645 1645
             'tkt_archive_class'   => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived'
1646 1646
                 : '',
1647 1647
             'ticketrow'           => $skeleton ? 'TICKETNUM' : $row,
@@ -1653,10 +1653,10 @@  discard block
 block discarded – undo
1653 1653
             'TKT_qty'             => $ticket->get_pretty('TKT_qty', 'input'),
1654 1654
             'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets',
1655 1655
             'TKT_sold'            => $skeleton ? 0 : $ticket->get('TKT_sold'),
1656
-            'trash_icon'          => ($skeleton || (! empty($ticket) && ! $ticket->get('TKT_deleted')))
1657
-                                     && (! empty($ticket) && $ticket->get('TKT_sold') === 0)
1656
+            'trash_icon'          => ($skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')))
1657
+                                     && ( ! empty($ticket) && $ticket->get('TKT_sold') === 0)
1658 1658
                 ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon',
1659
-            'disabled'            => $skeleton || (! empty($ticket) && ! $ticket->get('TKT_deleted')) ? ''
1659
+            'disabled'            => $skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')) ? ''
1660 1660
                 : ' disabled=disabled',
1661 1661
         );
1662 1662
         $price = $ticket->ID() !== 0
@@ -1683,7 +1683,7 @@  discard block
 block discarded – undo
1683 1683
                     array('order_by' => array('DTT_EVT_start' => 'ASC'))
1684 1684
                 )
1685 1685
                 : null;
1686
-            if (! empty($earliest_dtt)) {
1686
+            if ( ! empty($earliest_dtt)) {
1687 1687
                 $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a');
1688 1688
             } else {
1689 1689
                 $template_args['TKT_end_date'] = date(
@@ -1695,7 +1695,7 @@  discard block
 block discarded – undo
1695 1695
         $template_args = array_merge($template_args, $price_args);
1696 1696
         $template = apply_filters(
1697 1697
             'FHEE__Events_Admin_Page__get_ticket_row__template',
1698
-            EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php',
1698
+            EVENTS_TEMPLATE_PATH.'event_tickets_metabox_ticket_row.template.php',
1699 1699
             $ticket
1700 1700
         );
1701 1701
         return EEH_Template::display_template($template, $template_args, true);
@@ -1749,7 +1749,7 @@  discard block
 block discarded – undo
1749 1749
             $default_reg_status_values
1750 1750
         );
1751 1751
         EEH_Template::display_template(
1752
-            EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php',
1752
+            EVENTS_TEMPLATE_PATH.'event_registration_options.template.php',
1753 1753
             $template_args
1754 1754
         );
1755 1755
     }
@@ -1771,7 +1771,7 @@  discard block
 block discarded – undo
1771 1771
     {
1772 1772
         $EEME = $this->_event_model();
1773 1773
         $offset = ($current_page - 1) * $per_page;
1774
-        $limit = $count ? null : $offset . ',' . $per_page;
1774
+        $limit = $count ? null : $offset.','.$per_page;
1775 1775
         $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID';
1776 1776
         $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC";
1777 1777
         if (isset($this->_req_data['month_range'])) {
@@ -1800,7 +1800,7 @@  discard block
 block discarded – undo
1800 1800
         // categories?
1801 1801
         $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0
1802 1802
             ? $this->_req_data['EVT_CAT'] : null;
1803
-        if (! empty($category)) {
1803
+        if ( ! empty($category)) {
1804 1804
             $where['Term_Taxonomy.taxonomy'] = EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY;
1805 1805
             $where['Term_Taxonomy.term_id'] = $category;
1806 1806
         }
@@ -1808,7 +1808,7 @@  discard block
 block discarded – undo
1808 1808
         $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start');
1809 1809
         if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') {
1810 1810
             $DateTime = new DateTime(
1811
-                $year_r . '-' . $month_r . '-01 00:00:00',
1811
+                $year_r.'-'.$month_r.'-01 00:00:00',
1812 1812
                 new DateTimeZone(EEM_Datetime::instance()->get_timezone())
1813 1813
             );
1814 1814
             $start = $DateTime->format(implode(' ', $start_formats));
@@ -1834,11 +1834,11 @@  discard block
 block discarded – undo
1834 1834
                             ->format(implode(' ', $start_formats));
1835 1835
             $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1836 1836
         }
1837
-        if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
1837
+        if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
1838 1838
             $where['EVT_wp_user'] = get_current_user_id();
1839 1839
         } else {
1840
-            if (! isset($where['status'])) {
1841
-                if (! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) {
1840
+            if ( ! isset($where['status'])) {
1841
+                if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) {
1842 1842
                     $where['OR'] = array(
1843 1843
                         'status*restrict_private' => array('!=', 'private'),
1844 1844
                         'AND'                     => array(
@@ -1858,7 +1858,7 @@  discard block
 block discarded – undo
1858 1858
         }
1859 1859
         // search query handling
1860 1860
         if (isset($this->_req_data['s'])) {
1861
-            $search_string = '%' . $this->_req_data['s'] . '%';
1861
+            $search_string = '%'.$this->_req_data['s'].'%';
1862 1862
             $where['OR'] = array(
1863 1863
                 'EVT_name'       => array('LIKE', $search_string),
1864 1864
                 'EVT_desc'       => array('LIKE', $search_string),
@@ -1953,7 +1953,7 @@  discard block
 block discarded – undo
1953 1953
             // clean status
1954 1954
             $event_status = sanitize_key($event_status);
1955 1955
             // grab status
1956
-            if (! empty($event_status)) {
1956
+            if ( ! empty($event_status)) {
1957 1957
                 $success = $this->_change_event_status($EVT_ID, $event_status);
1958 1958
             } else {
1959 1959
                 $success = false;
@@ -1990,7 +1990,7 @@  discard block
 block discarded – undo
1990 1990
         // clean status
1991 1991
         $event_status = sanitize_key($event_status);
1992 1992
         // grab status
1993
-        if (! empty($event_status)) {
1993
+        if ( ! empty($event_status)) {
1994 1994
             $success = true;
1995 1995
             // determine the event id and set to array.
1996 1996
             $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array();
@@ -2037,7 +2037,7 @@  discard block
 block discarded – undo
2037 2037
     private function _change_event_status($EVT_ID = 0, $event_status = '')
2038 2038
     {
2039 2039
         // grab event id
2040
-        if (! $EVT_ID) {
2040
+        if ( ! $EVT_ID) {
2041 2041
             $msg = esc_html__(
2042 2042
                 'An error occurred. No Event ID or an invalid Event ID was received.',
2043 2043
                 'event_espresso'
@@ -2107,7 +2107,7 @@  discard block
 block discarded – undo
2107 2107
      */
2108 2108
     protected function getModelObjNodeGroupPersister()
2109 2109
     {
2110
-        if (! $this->model_obj_node_group_persister instanceof NodeGroupDao) {
2110
+        if ( ! $this->model_obj_node_group_persister instanceof NodeGroupDao) {
2111 2111
             $this->model_obj_node_group_persister = $this->getLoader()->load('\EventEspresso\core\services\orm\tree_traversal\NodeGroupDao');
2112 2112
         }
2113 2113
         return $this->model_obj_node_group_persister;
@@ -2358,7 +2358,7 @@  discard block
 block discarded – undo
2358 2358
                                                 . esc_html__(
2359 2359
                                                     '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.',
2360 2360
                                                     'event_espresso'
2361
-                                                ) . '</strong>';
2361
+                                                ).'</strong>';
2362 2362
         $this->display_admin_caf_preview_page('template_settings_tab');
2363 2363
     }
2364 2364
 
@@ -2378,12 +2378,12 @@  discard block
 block discarded – undo
2378 2378
         // set default category object
2379 2379
         $this->_set_empty_category_object();
2380 2380
         // only set if we've got an id
2381
-        if (! isset($this->_req_data['EVT_CAT_ID'])) {
2381
+        if ( ! isset($this->_req_data['EVT_CAT_ID'])) {
2382 2382
             return;
2383 2383
         }
2384 2384
         $category_id = absint($this->_req_data['EVT_CAT_ID']);
2385 2385
         $term = get_term($category_id, EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY);
2386
-        if (! empty($term)) {
2386
+        if ( ! empty($term)) {
2387 2387
             $this->_category->category_name = $term->name;
2388 2388
             $this->_category->category_identifier = $term->slug;
2389 2389
             $this->_category->category_desc = $term->description;
@@ -2411,7 +2411,7 @@  discard block
 block discarded – undo
2411 2411
     {
2412 2412
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2413 2413
         $this->_search_btn_label = esc_html__('Categories', 'event_espresso');
2414
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
2414
+        $this->_admin_page_title .= ' '.$this->get_action_link_or_button(
2415 2415
             'add_category',
2416 2416
             'add_category',
2417 2417
             array(),
@@ -2485,7 +2485,7 @@  discard block
 block discarded – undo
2485 2485
             'disable'                  => '',
2486 2486
             'disabled_message'         => false,
2487 2487
         );
2488
-        $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php';
2488
+        $template = EVENTS_TEMPLATE_PATH.'event_category_details.template.php';
2489 2489
         return EEH_Template::display_template($template, $template_args, true);
2490 2490
     }
2491 2491
 
@@ -2570,7 +2570,7 @@  discard block
 block discarded – undo
2570 2570
         $insert_ids = $update
2571 2571
             ? wp_update_term($cat_id, EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY, $term_args)
2572 2572
             : wp_insert_term($category_name, EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY, $term_args);
2573
-        if (! is_array($insert_ids)) {
2573
+        if ( ! is_array($insert_ids)) {
2574 2574
             $msg = esc_html__(
2575 2575
                 'An error occurred and the category has not been saved to the database.',
2576 2576
                 'event_espresso'
@@ -2601,7 +2601,7 @@  discard block
 block discarded – undo
2601 2601
         $limit = ($current_page - 1) * $per_page;
2602 2602
         $where = array('taxonomy' => EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY);
2603 2603
         if (isset($this->_req_data['s'])) {
2604
-            $sstr = '%' . $this->_req_data['s'] . '%';
2604
+            $sstr = '%'.$this->_req_data['s'].'%';
2605 2605
             $where['OR'] = array(
2606 2606
                 'Term.name'   => array('LIKE', $sstr),
2607 2607
                 'description' => array('LIKE', $sstr),
@@ -2610,7 +2610,7 @@  discard block
 block discarded – undo
2610 2610
         $query_params = array(
2611 2611
             $where,
2612 2612
             'order_by'   => array($orderby => $order),
2613
-            'limit'      => $limit . ',' . $per_page,
2613
+            'limit'      => $limit.','.$per_page,
2614 2614
             'force_join' => array('Term'),
2615 2615
         );
2616 2616
         $categories = $count
Please login to merge, or discard this patch.
core/libraries/batch/JobHandlers/ExecuteBatchDeletion.php 3 patches
Unused Use Statements   -8 removed lines patch added patch discarded remove patch
@@ -4,21 +4,13 @@
 block discarded – undo
4 4
 
5 5
 use EE_Change_Log;
6 6
 use EE_Registry;
7
-use EEM_Event;
8
-use EEM_Price;
9
-use EEM_Ticket;
10
-use EventEspresso\core\exceptions\InvalidClassException;
11
-use EventEspresso\core\exceptions\InvalidDataTypeException;
12
-use EventEspresso\core\exceptions\InvalidInterfaceException;
13 7
 use EventEspresso\core\exceptions\UnexpectedEntityException;
14
-use EventEspresso\core\services\loaders\LoaderFactory;
15 8
 use EventEspresso\core\services\orm\tree_traversal\NodeGroupDao;
16 9
 use EventEspresso\core\services\orm\tree_traversal\ModelObjNode;
17 10
 use EventEspressoBatchRequest\Helpers\BatchRequestException;
18 11
 use EventEspressoBatchRequest\Helpers\JobParameters;
19 12
 use EventEspressoBatchRequest\Helpers\JobStepResponse;
20 13
 use EventEspressoBatchRequest\JobHandlerBaseClasses\JobHandler;
21
-use InvalidArgumentException;
22 14
 
23 15
 /**
24 16
  * Class EventDeletion
Please login to merge, or discard this patch.
Indentation   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -32,158 +32,158 @@
 block discarded – undo
32 32
  */
33 33
 class ExecuteBatchDeletion extends JobHandler
34 34
 {
35
-    /**
36
-     * @var NodeGroupDao
37
-     */
38
-    protected $model_obj_node_group_persister;
39
-    public function __construct(NodeGroupDao $model_obj_node_group_persister)
40
-    {
41
-        $this->model_obj_node_group_persister = $model_obj_node_group_persister;
42
-    }
35
+	/**
36
+	 * @var NodeGroupDao
37
+	 */
38
+	protected $model_obj_node_group_persister;
39
+	public function __construct(NodeGroupDao $model_obj_node_group_persister)
40
+	{
41
+		$this->model_obj_node_group_persister = $model_obj_node_group_persister;
42
+	}
43 43
 
44 44
 
45
-    // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
46
-    /**
47
-     *
48
-     * @param JobParameters $job_parameters
49
-     * @throws BatchRequestException
50
-     * @return JobStepResponse
51
-     */
52
-    public function create_job(JobParameters $job_parameters)
53
-    {
54
-        $deletion_job_code = $job_parameters->request_datum('deletion_job_code', null);
55
-        $roots = $this->model_obj_node_group_persister->getModelObjNodesInGroup($deletion_job_code);
56
-        if ($roots === null) {
57
-            throw new UnexpectedEntityException($roots, 'array', esc_html__('The job seems to be stale. Please press the back button in your browser twice.', 'event_espresso'));
58
-        }
59
-        $models_and_ids_to_delete = [];
60
-        foreach ($roots as $root) {
61
-            if (! $root instanceof ModelObjNode) {
62
-                throw new UnexpectedEntityException($root, 'ModelObjNode');
63
-            }
64
-            $models_and_ids_to_delete = array_replace_recursive($models_and_ids_to_delete, $root->getIds());
65
-        }
66
-        $job_parameters->set_extra_data(
67
-            [
68
-                'models_and_ids_to_delete' => $models_and_ids_to_delete
69
-            ]
70
-        );
71
-        // Find the job's actual size.
72
-        $job_size = 0;
73
-        foreach ($models_and_ids_to_delete as $model_name => $ids) {
74
-            $job_size += count($ids);
75
-        }
76
-        $job_parameters->set_job_size($job_size);
77
-        return new JobStepResponse(
78
-            $job_parameters,
79
-            esc_html__('Beginning to delete items...', 'event_espresso')
80
-        );
81
-    }
45
+	// phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
46
+	/**
47
+	 *
48
+	 * @param JobParameters $job_parameters
49
+	 * @throws BatchRequestException
50
+	 * @return JobStepResponse
51
+	 */
52
+	public function create_job(JobParameters $job_parameters)
53
+	{
54
+		$deletion_job_code = $job_parameters->request_datum('deletion_job_code', null);
55
+		$roots = $this->model_obj_node_group_persister->getModelObjNodesInGroup($deletion_job_code);
56
+		if ($roots === null) {
57
+			throw new UnexpectedEntityException($roots, 'array', esc_html__('The job seems to be stale. Please press the back button in your browser twice.', 'event_espresso'));
58
+		}
59
+		$models_and_ids_to_delete = [];
60
+		foreach ($roots as $root) {
61
+			if (! $root instanceof ModelObjNode) {
62
+				throw new UnexpectedEntityException($root, 'ModelObjNode');
63
+			}
64
+			$models_and_ids_to_delete = array_replace_recursive($models_and_ids_to_delete, $root->getIds());
65
+		}
66
+		$job_parameters->set_extra_data(
67
+			[
68
+				'models_and_ids_to_delete' => $models_and_ids_to_delete
69
+			]
70
+		);
71
+		// Find the job's actual size.
72
+		$job_size = 0;
73
+		foreach ($models_and_ids_to_delete as $model_name => $ids) {
74
+			$job_size += count($ids);
75
+		}
76
+		$job_parameters->set_job_size($job_size);
77
+		return new JobStepResponse(
78
+			$job_parameters,
79
+			esc_html__('Beginning to delete items...', 'event_espresso')
80
+		);
81
+	}
82 82
 
83
-    /**
84
-     * Performs another step of the job
85
-     * @param JobParameters $job_parameters
86
-     * @param int $batch_size
87
-     * @return JobStepResponse
88
-     * @throws BatchRequestException
89
-     */
90
-    public function continue_job(JobParameters $job_parameters, $batch_size = 50)
91
-    {
92
-        // We already have the items IDs. So deleting is really fast. Let's speed it up.
93
-        $batch_size *= 10;
94
-        $units_processed = 0;
95
-        $models_and_ids_to_delete = $job_parameters->extra_datum('models_and_ids_to_delete', []);
96
-        // Build a new list of everything leftover after this request's of deletions.
97
-        $models_and_ids_remaining = [];
98
-        foreach ($models_and_ids_to_delete as $model_name => $ids_to_delete) {
99
-            if ($units_processed < $batch_size) {
100
-                $model = EE_Registry::instance()->load_model($model_name);
101
-                $ids_to_delete_this_query = array_slice($ids_to_delete, 0, $batch_size - $units_processed, true);
102
-                if ($model->has_primary_key_field()) {
103
-                    $where_conditions = [
104
-                        $model->primary_key_name() => [
105
-                            'IN',
106
-                            $ids_to_delete_this_query
107
-                        ]
108
-                    ];
109
-                } else {
110
-                    $where_conditions = [
111
-                        'OR' => []
112
-                    ];
113
-                    foreach ($ids_to_delete_this_query as $index_primary_key_string) {
114
-                        $keys_n_values = $model->parse_index_primary_key_string($index_primary_key_string);
115
-                        $where_conditions['OR'][ 'AND*' . $index_primary_key_string ] = $keys_n_values;
116
-                    }
117
-                }
118
-                // Deleting time!
119
-                // The model's deletion method reports every ROW deleted, and in the case of CPT models that will be
120
-                // two rows deleted for event CPT item. So don't rely on it for the count of items deleted.
121
-                $model->delete_permanently(
122
-                    [
123
-                        $where_conditions
124
-                    ],
125
-                    false
126
-                );
127
-                $units_processed += count($ids_to_delete_this_query);
128
-                $remaining_ids = array_diff_key($ids_to_delete, $ids_to_delete_this_query);
129
-                // If there's any more from this model, we'll do them next time.
130
-                if (count($remaining_ids) > 0) {
131
-                    $models_and_ids_remaining[ $model_name ] = $remaining_ids;
132
-                }
133
-            } else {
134
-                $models_and_ids_remaining[ $model_name ] = $models_and_ids_to_delete[ $model_name ];
135
-            }
136
-        }
137
-        $job_parameters->mark_processed($units_processed);
138
-        // All done deleting for this request. Is there anything to do next time?
139
-        if (empty($models_and_ids_remaining)) {
140
-            $job_parameters->set_status(JobParameters::status_complete);
141
-            return new JobStepResponse(
142
-                $job_parameters,
143
-                esc_html__('Deletion complete.', 'event_espresso')
144
-            );
145
-        }
146
-        $job_parameters->add_extra_data('models_and_ids_to_delete', $models_and_ids_remaining);
147
-        return new JobStepResponse(
148
-            $job_parameters,
149
-            sprintf(
150
-                esc_html__('Deleted %d items.', 'event_espresso'),
151
-                $units_processed
152
-            )
153
-        );
154
-    }
83
+	/**
84
+	 * Performs another step of the job
85
+	 * @param JobParameters $job_parameters
86
+	 * @param int $batch_size
87
+	 * @return JobStepResponse
88
+	 * @throws BatchRequestException
89
+	 */
90
+	public function continue_job(JobParameters $job_parameters, $batch_size = 50)
91
+	{
92
+		// We already have the items IDs. So deleting is really fast. Let's speed it up.
93
+		$batch_size *= 10;
94
+		$units_processed = 0;
95
+		$models_and_ids_to_delete = $job_parameters->extra_datum('models_and_ids_to_delete', []);
96
+		// Build a new list of everything leftover after this request's of deletions.
97
+		$models_and_ids_remaining = [];
98
+		foreach ($models_and_ids_to_delete as $model_name => $ids_to_delete) {
99
+			if ($units_processed < $batch_size) {
100
+				$model = EE_Registry::instance()->load_model($model_name);
101
+				$ids_to_delete_this_query = array_slice($ids_to_delete, 0, $batch_size - $units_processed, true);
102
+				if ($model->has_primary_key_field()) {
103
+					$where_conditions = [
104
+						$model->primary_key_name() => [
105
+							'IN',
106
+							$ids_to_delete_this_query
107
+						]
108
+					];
109
+				} else {
110
+					$where_conditions = [
111
+						'OR' => []
112
+					];
113
+					foreach ($ids_to_delete_this_query as $index_primary_key_string) {
114
+						$keys_n_values = $model->parse_index_primary_key_string($index_primary_key_string);
115
+						$where_conditions['OR'][ 'AND*' . $index_primary_key_string ] = $keys_n_values;
116
+					}
117
+				}
118
+				// Deleting time!
119
+				// The model's deletion method reports every ROW deleted, and in the case of CPT models that will be
120
+				// two rows deleted for event CPT item. So don't rely on it for the count of items deleted.
121
+				$model->delete_permanently(
122
+					[
123
+						$where_conditions
124
+					],
125
+					false
126
+				);
127
+				$units_processed += count($ids_to_delete_this_query);
128
+				$remaining_ids = array_diff_key($ids_to_delete, $ids_to_delete_this_query);
129
+				// If there's any more from this model, we'll do them next time.
130
+				if (count($remaining_ids) > 0) {
131
+					$models_and_ids_remaining[ $model_name ] = $remaining_ids;
132
+				}
133
+			} else {
134
+				$models_and_ids_remaining[ $model_name ] = $models_and_ids_to_delete[ $model_name ];
135
+			}
136
+		}
137
+		$job_parameters->mark_processed($units_processed);
138
+		// All done deleting for this request. Is there anything to do next time?
139
+		if (empty($models_and_ids_remaining)) {
140
+			$job_parameters->set_status(JobParameters::status_complete);
141
+			return new JobStepResponse(
142
+				$job_parameters,
143
+				esc_html__('Deletion complete.', 'event_espresso')
144
+			);
145
+		}
146
+		$job_parameters->add_extra_data('models_and_ids_to_delete', $models_and_ids_remaining);
147
+		return new JobStepResponse(
148
+			$job_parameters,
149
+			sprintf(
150
+				esc_html__('Deleted %d items.', 'event_espresso'),
151
+				$units_processed
152
+			)
153
+		);
154
+	}
155 155
 
156
-    /**
157
-     * Performs any clean-up logic when we know the job is completed
158
-     * @param JobParameters $job_parameters
159
-     * @return JobStepResponse
160
-     */
161
-    public function cleanup_job(JobParameters $job_parameters)
162
-    {
163
-        $this->model_obj_node_group_persister->deleteModelObjNodesInGroup(
164
-            $job_parameters->request_datum('deletion_job_code')
165
-        );
166
-        // For backwards compatibility with how we used to delete events, make sure we still trigger the old action.
167
-        $models_and_ids_to_delete = $job_parameters->extra_datum('models_and_ids_to_delete', []);
168
-        foreach ($models_and_ids_to_delete['Event'] as $event_id) {
169
-            // Create a log entry so we know who and when this event was permanently deleted.
170
-            (EE_Change_Log::new_instance(
171
-                [
172
-                    'OBJ_ID' => $event_id,
173
-                    'OBJ_type' => 'Event',
174
-                    'LOG_message' => sprintf(
175
-                        esc_html__('Event %1$d permanently deleted using ExecuteBatchDeletion.', 'event_espresso'),
176
-                        $event_id
177
-                    )
178
-                ]
179
-            ))->save();
180
-            do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $event_id);
181
-        }
182
-        return new JobStepResponse(
183
-            $job_parameters,
184
-            esc_html__('All done', 'event_espresso')
185
-        );
186
-    }
156
+	/**
157
+	 * Performs any clean-up logic when we know the job is completed
158
+	 * @param JobParameters $job_parameters
159
+	 * @return JobStepResponse
160
+	 */
161
+	public function cleanup_job(JobParameters $job_parameters)
162
+	{
163
+		$this->model_obj_node_group_persister->deleteModelObjNodesInGroup(
164
+			$job_parameters->request_datum('deletion_job_code')
165
+		);
166
+		// For backwards compatibility with how we used to delete events, make sure we still trigger the old action.
167
+		$models_and_ids_to_delete = $job_parameters->extra_datum('models_and_ids_to_delete', []);
168
+		foreach ($models_and_ids_to_delete['Event'] as $event_id) {
169
+			// Create a log entry so we know who and when this event was permanently deleted.
170
+			(EE_Change_Log::new_instance(
171
+				[
172
+					'OBJ_ID' => $event_id,
173
+					'OBJ_type' => 'Event',
174
+					'LOG_message' => sprintf(
175
+						esc_html__('Event %1$d permanently deleted using ExecuteBatchDeletion.', 'event_espresso'),
176
+						$event_id
177
+					)
178
+				]
179
+			))->save();
180
+			do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $event_id);
181
+		}
182
+		return new JobStepResponse(
183
+			$job_parameters,
184
+			esc_html__('All done', 'event_espresso')
185
+		);
186
+	}
187 187
 }
188 188
 // End of file EventDeletion.php
189 189
 // Location: EventEspressoBatchRequest\JobHandlers/EventDeletion.php
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
         }
59 59
         $models_and_ids_to_delete = [];
60 60
         foreach ($roots as $root) {
61
-            if (! $root instanceof ModelObjNode) {
61
+            if ( ! $root instanceof ModelObjNode) {
62 62
                 throw new UnexpectedEntityException($root, 'ModelObjNode');
63 63
             }
64 64
             $models_and_ids_to_delete = array_replace_recursive($models_and_ids_to_delete, $root->getIds());
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
                     ];
113 113
                     foreach ($ids_to_delete_this_query as $index_primary_key_string) {
114 114
                         $keys_n_values = $model->parse_index_primary_key_string($index_primary_key_string);
115
-                        $where_conditions['OR'][ 'AND*' . $index_primary_key_string ] = $keys_n_values;
115
+                        $where_conditions['OR']['AND*'.$index_primary_key_string] = $keys_n_values;
116 116
                     }
117 117
                 }
118 118
                 // Deleting time!
@@ -128,10 +128,10 @@  discard block
 block discarded – undo
128 128
                 $remaining_ids = array_diff_key($ids_to_delete, $ids_to_delete_this_query);
129 129
                 // If there's any more from this model, we'll do them next time.
130 130
                 if (count($remaining_ids) > 0) {
131
-                    $models_and_ids_remaining[ $model_name ] = $remaining_ids;
131
+                    $models_and_ids_remaining[$model_name] = $remaining_ids;
132 132
                 }
133 133
             } else {
134
-                $models_and_ids_remaining[ $model_name ] = $models_and_ids_to_delete[ $model_name ];
134
+                $models_and_ids_remaining[$model_name] = $models_and_ids_to_delete[$model_name];
135 135
             }
136 136
         }
137 137
         $job_parameters->mark_processed($units_processed);
Please login to merge, or discard this patch.
core/libraries/batch/JobHandlers/PreviewEventDeletion.php 3 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,6 @@
 block discarded – undo
6 6
 use EEM_Price;
7 7
 use EEM_Ticket;
8 8
 use EventEspresso\core\exceptions\InvalidClassException;
9
-use EventEspresso\core\services\loaders\LoaderFactory;
10 9
 use EventEspresso\core\services\orm\tree_traversal\ModelObjNode;
11 10
 use EventEspresso\core\services\orm\tree_traversal\NodeGroupDao;
12 11
 use EventEspressoBatchRequest\Helpers\BatchRequestException;
Please login to merge, or discard this patch.
Indentation   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -28,145 +28,145 @@
 block discarded – undo
28 28
 class PreviewEventDeletion extends JobHandler
29 29
 {
30 30
 
31
-    /**
32
-     * @var NodeGroupDao
33
-     */
34
-    protected $model_obj_node_group_persister;
35
-    public function __construct(NodeGroupDao $model_obj_node_group_persister)
36
-    {
37
-        $this->model_obj_node_group_persister = $model_obj_node_group_persister;
38
-    }
31
+	/**
32
+	 * @var NodeGroupDao
33
+	 */
34
+	protected $model_obj_node_group_persister;
35
+	public function __construct(NodeGroupDao $model_obj_node_group_persister)
36
+	{
37
+		$this->model_obj_node_group_persister = $model_obj_node_group_persister;
38
+	}
39 39
 
40
-    // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
41
-    /**
42
-     *
43
-     * @param JobParameters $job_parameters
44
-     * @throws BatchRequestException
45
-     * @return JobStepResponse
46
-     */
47
-    public function create_job(JobParameters $job_parameters)
48
-    {
49
-        // Set the "root" model objects we will want to delete (record their ID and model)
50
-        $event_ids = $job_parameters->request_datum('EVT_IDs', array());
51
-        // Find all the root nodes to delete (this isn't just events, because there's other data, like related tickets,
52
-        // prices, message templates, etc, whose model definition doesn't make them dependent on events. But,
53
-        // we have no UI to access them independent of events, so they may as well get deleted too.)
54
-        $model_objects_to_delete = [];
55
-        foreach ($event_ids as $event_id) {
56
-            $event = EEM_Event::instance()->get_one_by_ID($event_id);
57
-            // Also, we want to delete their related, non-global, tickets, prices and message templates
58
-            $related_non_global_tickets = EEM_Ticket::instance()->get_all_deleted_and_undeleted(
59
-                [
60
-                    [
61
-                        'TKT_is_default' => false,
62
-                        'Datetime.EVT_ID' => $event_id
63
-                    ]
64
-                ]
65
-            );
66
-            $related_non_global_prices = EEM_Price::instance()->get_all_deleted_and_undeleted(
67
-                [
68
-                    [
69
-                        'PRC_is_default' => false,
70
-                        'Ticket.Datetime.EVT_ID' => $event_id
71
-                    ]
72
-                ]
73
-            );
74
-            $model_objects_to_delete = array_merge(
75
-                $model_objects_to_delete,
76
-                [$event],
77
-                $related_non_global_tickets,
78
-                $related_non_global_prices
79
-            );
80
-        }
81
-        $roots = [];
82
-        foreach ($model_objects_to_delete as $model_object) {
83
-            $roots[] = new ModelObjNode($model_object->ID(), $model_object->get_model());
84
-        }
85
-        $job_parameters->add_extra_data('roots', $roots);
86
-        // Set an estimate of how long this will take (we're discovering as we go, so it seems impossible to give
87
-        // an accurate count.)
88
-        $estimated_work_per_model_obj = 100;
89
-        $job_parameters->set_job_size(count($roots) * $estimated_work_per_model_obj);
90
-        return new JobStepResponse(
91
-            $job_parameters,
92
-            esc_html__('Generating preview of data to be deleted...', 'event_espresso')
93
-        );
94
-    }
40
+	// phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
41
+	/**
42
+	 *
43
+	 * @param JobParameters $job_parameters
44
+	 * @throws BatchRequestException
45
+	 * @return JobStepResponse
46
+	 */
47
+	public function create_job(JobParameters $job_parameters)
48
+	{
49
+		// Set the "root" model objects we will want to delete (record their ID and model)
50
+		$event_ids = $job_parameters->request_datum('EVT_IDs', array());
51
+		// Find all the root nodes to delete (this isn't just events, because there's other data, like related tickets,
52
+		// prices, message templates, etc, whose model definition doesn't make them dependent on events. But,
53
+		// we have no UI to access them independent of events, so they may as well get deleted too.)
54
+		$model_objects_to_delete = [];
55
+		foreach ($event_ids as $event_id) {
56
+			$event = EEM_Event::instance()->get_one_by_ID($event_id);
57
+			// Also, we want to delete their related, non-global, tickets, prices and message templates
58
+			$related_non_global_tickets = EEM_Ticket::instance()->get_all_deleted_and_undeleted(
59
+				[
60
+					[
61
+						'TKT_is_default' => false,
62
+						'Datetime.EVT_ID' => $event_id
63
+					]
64
+				]
65
+			);
66
+			$related_non_global_prices = EEM_Price::instance()->get_all_deleted_and_undeleted(
67
+				[
68
+					[
69
+						'PRC_is_default' => false,
70
+						'Ticket.Datetime.EVT_ID' => $event_id
71
+					]
72
+				]
73
+			);
74
+			$model_objects_to_delete = array_merge(
75
+				$model_objects_to_delete,
76
+				[$event],
77
+				$related_non_global_tickets,
78
+				$related_non_global_prices
79
+			);
80
+		}
81
+		$roots = [];
82
+		foreach ($model_objects_to_delete as $model_object) {
83
+			$roots[] = new ModelObjNode($model_object->ID(), $model_object->get_model());
84
+		}
85
+		$job_parameters->add_extra_data('roots', $roots);
86
+		// Set an estimate of how long this will take (we're discovering as we go, so it seems impossible to give
87
+		// an accurate count.)
88
+		$estimated_work_per_model_obj = 100;
89
+		$job_parameters->set_job_size(count($roots) * $estimated_work_per_model_obj);
90
+		return new JobStepResponse(
91
+			$job_parameters,
92
+			esc_html__('Generating preview of data to be deleted...', 'event_espresso')
93
+		);
94
+	}
95 95
 
96
-    /**
97
-     * Performs another step of the job
98
-     * @param JobParameters $job_parameters
99
-     * @param int $batch_size
100
-     * @return JobStepResponse
101
-     * @throws BatchRequestException
102
-     */
103
-    public function continue_job(JobParameters $job_parameters, $batch_size = 50)
104
-    {
105
-        // Serializing and unserializing is what really makes this drag on (eg on localhost, the ajax requests took
106
-        // about 4 seconds when the batch size was 250, but 3 seconds when the batch size was 50. So like
107
-        // 50% of the request is just serializing and unserializing.) So, make the batches much bigger.
108
-        $batch_size *= 3;
109
-        $units_processed = 0;
110
-        foreach ($job_parameters->extra_datum('roots', array()) as $root_node) {
111
-            if ($units_processed >= $batch_size) {
112
-                break;
113
-            }
114
-            if (! $root_node instanceof ModelObjNode) {
115
-                throw new InvalidClassException('ModelObjNode');
116
-            }
117
-            if ($root_node->isComplete()) {
118
-                continue;
119
-            }
120
-            $units_processed += $root_node->visit($batch_size - $units_processed);
121
-        }
122
-        $job_parameters->mark_processed($units_processed);
123
-        // If the most-recently processed root node is complete, we must be all done because we're doing them
124
-        // sequentially.
125
-        if (isset($root_node) && $root_node instanceof ModelObjNode && $root_node->isComplete()) {
126
-            $job_parameters->set_status(JobParameters::status_complete);
127
-            // Show a full progress bar.
128
-            $job_parameters->set_units_processed($job_parameters->job_size());
129
-            $deletion_job_code = $job_parameters->request_datum('deletion_job_code');
130
-            $this->model_obj_node_group_persister->persistModelObjNodesGroup(
131
-                $job_parameters->extra_datum('roots'),
132
-                $deletion_job_code
133
-            );
134
-            return new JobStepResponse(
135
-                $job_parameters,
136
-                esc_html__('Finished identifying items for deletion.', 'event_espresso'),
137
-                [
138
-                    'deletion_job_code' => $deletion_job_code
139
-                ]
140
-            );
141
-        } else {
142
-            // Because the job size was a guess, it may have likely been provden wrong. We don't want to show more work
143
-            // done than we originally said there would be. So adjust the estimate.
144
-            if (($job_parameters->units_processed() / $job_parameters->job_size()) > .8) {
145
-                $job_parameters->set_job_size($job_parameters->job_size() * 2);
146
-            }
147
-            return new JobStepResponse(
148
-                $job_parameters,
149
-                sprintf(
150
-                    esc_html__('Identified %d items for deletion.', 'event_espresso'),
151
-                    $units_processed
152
-                )
153
-            );
154
-        }
155
-    }
96
+	/**
97
+	 * Performs another step of the job
98
+	 * @param JobParameters $job_parameters
99
+	 * @param int $batch_size
100
+	 * @return JobStepResponse
101
+	 * @throws BatchRequestException
102
+	 */
103
+	public function continue_job(JobParameters $job_parameters, $batch_size = 50)
104
+	{
105
+		// Serializing and unserializing is what really makes this drag on (eg on localhost, the ajax requests took
106
+		// about 4 seconds when the batch size was 250, but 3 seconds when the batch size was 50. So like
107
+		// 50% of the request is just serializing and unserializing.) So, make the batches much bigger.
108
+		$batch_size *= 3;
109
+		$units_processed = 0;
110
+		foreach ($job_parameters->extra_datum('roots', array()) as $root_node) {
111
+			if ($units_processed >= $batch_size) {
112
+				break;
113
+			}
114
+			if (! $root_node instanceof ModelObjNode) {
115
+				throw new InvalidClassException('ModelObjNode');
116
+			}
117
+			if ($root_node->isComplete()) {
118
+				continue;
119
+			}
120
+			$units_processed += $root_node->visit($batch_size - $units_processed);
121
+		}
122
+		$job_parameters->mark_processed($units_processed);
123
+		// If the most-recently processed root node is complete, we must be all done because we're doing them
124
+		// sequentially.
125
+		if (isset($root_node) && $root_node instanceof ModelObjNode && $root_node->isComplete()) {
126
+			$job_parameters->set_status(JobParameters::status_complete);
127
+			// Show a full progress bar.
128
+			$job_parameters->set_units_processed($job_parameters->job_size());
129
+			$deletion_job_code = $job_parameters->request_datum('deletion_job_code');
130
+			$this->model_obj_node_group_persister->persistModelObjNodesGroup(
131
+				$job_parameters->extra_datum('roots'),
132
+				$deletion_job_code
133
+			);
134
+			return new JobStepResponse(
135
+				$job_parameters,
136
+				esc_html__('Finished identifying items for deletion.', 'event_espresso'),
137
+				[
138
+					'deletion_job_code' => $deletion_job_code
139
+				]
140
+			);
141
+		} else {
142
+			// Because the job size was a guess, it may have likely been provden wrong. We don't want to show more work
143
+			// done than we originally said there would be. So adjust the estimate.
144
+			if (($job_parameters->units_processed() / $job_parameters->job_size()) > .8) {
145
+				$job_parameters->set_job_size($job_parameters->job_size() * 2);
146
+			}
147
+			return new JobStepResponse(
148
+				$job_parameters,
149
+				sprintf(
150
+					esc_html__('Identified %d items for deletion.', 'event_espresso'),
151
+					$units_processed
152
+				)
153
+			);
154
+		}
155
+	}
156 156
 
157
-    /**
158
-     * Performs any clean-up logic when we know the job is completed
159
-     * @param JobParameters $job_parameters
160
-     * @return JobStepResponse
161
-     */
162
-    public function cleanup_job(JobParameters $job_parameters)
163
-    {
164
-        // Nothing much to do. We can't delete the option with the built tree because we may need it in a moment for the deletion
165
-        return new JobStepResponse(
166
-            $job_parameters,
167
-            esc_html__('All done', 'event_espresso')
168
-        );
169
-    }
157
+	/**
158
+	 * Performs any clean-up logic when we know the job is completed
159
+	 * @param JobParameters $job_parameters
160
+	 * @return JobStepResponse
161
+	 */
162
+	public function cleanup_job(JobParameters $job_parameters)
163
+	{
164
+		// Nothing much to do. We can't delete the option with the built tree because we may need it in a moment for the deletion
165
+		return new JobStepResponse(
166
+			$job_parameters,
167
+			esc_html__('All done', 'event_espresso')
168
+		);
169
+	}
170 170
 }
171 171
 // End of file EventDeletion.php
172 172
 // Location: EventEspressoBatchRequest\JobHandlers/EventDeletion.php
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -111,7 +111,7 @@
 block discarded – undo
111 111
             if ($units_processed >= $batch_size) {
112 112
                 break;
113 113
             }
114
-            if (! $root_node instanceof ModelObjNode) {
114
+            if ( ! $root_node instanceof ModelObjNode) {
115 115
                 throw new InvalidClassException('ModelObjNode');
116 116
             }
117 117
             if ($root_node->isComplete()) {
Please login to merge, or discard this patch.
admin_pages/events/templates/event_preview_deletion.template.php 1 patch
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -1,68 +1,68 @@  discard block
 block discarded – undo
1 1
 <h2><?php esc_html_e('Please Confirm You Want to Permanently Delete the Following Data', 'event_espresso'); ?></h2>
2 2
 <h3>
3 3
     <?php
4
-    printf(
5
-        esc_html(
6
-            // translators: 1: number of events
7
-            _n('%1$d Event', '%1$d Events', count($events), 'event_espresso')
8
-        ),
9
-        count($events)
10
-    );
11
-    ?>
4
+	printf(
5
+		esc_html(
6
+			// translators: 1: number of events
7
+			_n('%1$d Event', '%1$d Events', count($events), 'event_espresso')
8
+		),
9
+		count($events)
10
+	);
11
+	?>
12 12
 </h3>
13 13
 <ul>
14 14
     <?php
15
-    foreach ($events as $event) {
16
-        ?>
15
+	foreach ($events as $event) {
16
+		?>
17 17
         <li>
18 18
             <?php echo $event->name(); ?>
19 19
         </li>
20 20
         <?php
21
-    }
22
-    ?>
21
+	}
22
+	?>
23 23
 </ul>
24 24
 <h3>
25 25
     <?php
26
-    printf(
27
-        esc_html(
28
-            // translators: 1: number of datetimes
29
-            _n('%1$d Datetime', '%1$d Datetimes', count($datetimes), 'event_espresso')
30
-        ),
31
-        count($datetimes)
32
-    );
33
-    ?>
26
+	printf(
27
+		esc_html(
28
+			// translators: 1: number of datetimes
29
+			_n('%1$d Datetime', '%1$d Datetimes', count($datetimes), 'event_espresso')
30
+		),
31
+		count($datetimes)
32
+	);
33
+	?>
34 34
 </h3>
35 35
 <ul>
36 36
     <?php
37
-    foreach ($datetimes as $datetime) {
38
-        ?>
37
+	foreach ($datetimes as $datetime) {
38
+		?>
39 39
         <li>
40 40
             <?php echo $datetime->get_dtt_display_name(true); ?>
41 41
         </li>
42 42
         <?php
43
-    }
44
-    ?>
43
+	}
44
+	?>
45 45
 </ul>
46 46
 <h3>
47 47
     <?php
48
-    printf(
49
-        esc_html(
50
-            _n('%1$d Registration', '%1$d Registrations', $reg_count, 'event_espresso')
51
-        ),
52
-        $reg_count
53
-    );
54
-    ?>
48
+	printf(
49
+		esc_html(
50
+			_n('%1$d Registration', '%1$d Registrations', $reg_count, 'event_espresso')
51
+		),
52
+		$reg_count
53
+	);
54
+	?>
55 55
 </h3>
56 56
 <?php
57 57
 if ($reg_count > count($registrations)) {
58
-    ?>
58
+	?>
59 59
     <p class="notice">
60 60
         <?php
61
-        printf(
62
-            esc_html__('Only showing first %1$d.', 'event_espresso'),
63
-            count($registrations)
64
-        );
65
-        ?>
61
+		printf(
62
+			esc_html__('Only showing first %1$d.', 'event_espresso'),
63
+			count($registrations)
64
+		);
65
+		?>
66 66
     </p>
67 67
     <?php
68 68
 }
@@ -70,22 +70,22 @@  discard block
 block discarded – undo
70 70
 <p><?php esc_html_e('Note: contacts will not be deleted, only their registrations for the enumerated events. You can delete the contacts afterwards if you like.', 'event_espresso'); ?></p>
71 71
 <ul>
72 72
     <?php
73
-    foreach ($registrations as $registration) {
74
-        ?>
73
+	foreach ($registrations as $registration) {
74
+		?>
75 75
         <li>
76 76
             <?php
77
-            printf(
78
-                esc_html(
79
-                    _x('%1$s (%2$d of %3$d)', 'Registration name (number of count)', 'event_espresso')
80
-                ),
81
-                $registration->attendeeName(true),
82
-                $registration->count(),
83
-                $registration->group_size()
84
-            ); ?>
77
+			printf(
78
+				esc_html(
79
+					_x('%1$s (%2$d of %3$d)', 'Registration name (number of count)', 'event_espresso')
80
+				),
81
+				$registration->attendeeName(true),
82
+				$registration->count(),
83
+				$registration->group_size()
84
+			); ?>
85 85
         </li>
86 86
         <?php
87
-    }
88
-    ?>
87
+	}
88
+	?>
89 89
 </ul>
90 90
 <form action="<?php echo $form_url; ?>" method="POST">
91 91
     <?php echo $form->get_html_and_js(); ?>
Please login to merge, or discard this patch.
core/services/orm/tree_traversal/NodeGroupDao.php 2 patches
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -22,112 +22,112 @@
 block discarded – undo
22 22
  */
23 23
 class NodeGroupDao
24 24
 {
25
-    /**
26
-     * @since $VID:$
27
-     * @return mixed|void
28
-     */
29
-    public function generateGroupCode()
30
-    {
31
-        return wp_generate_password(6, false);
32
-    }
25
+	/**
26
+	 * @since $VID:$
27
+	 * @return mixed|void
28
+	 */
29
+	public function generateGroupCode()
30
+	{
31
+		return wp_generate_password(6, false);
32
+	}
33 33
 
34
-    /**
35
-     * Gets the string we put in front of the WP Option name used to store the jobs.
36
-     * @since $VID:$
37
-     * @return string
38
-     */
39
-    private function getOptionPrefix()
40
-    {
41
-        return 'ee_deletion_';
42
-    }
34
+	/**
35
+	 * Gets the string we put in front of the WP Option name used to store the jobs.
36
+	 * @since $VID:$
37
+	 * @return string
38
+	 */
39
+	private function getOptionPrefix()
40
+	{
41
+		return 'ee_deletion_';
42
+	}
43 43
 
44
-    /**
45
-     * @since $VID:$
46
-     * @param $code
47
-     * @return ModelObjNode[]
48
-     * @throws UnexpectedEntityException
49
-     */
50
-    public function getModelObjNodesInGroup($code)
51
-    {
52
-        if (! $code) {
53
-            throw new Exception(esc_html__('We aren’t sure which job you are performing. Please press back in your browser and try again.', 'event_espresso'));
54
-        }
55
-        $deletion_data = get_option($this->getOptionPrefix() . $code, []);
56
-        foreach ($deletion_data as $root) {
57
-            if (! $root instanceof ModelObjNode) {
58
-                throw new UnexpectedEntityException($root, 'ModelObjNode');
59
-            }
60
-        }
61
-        return $deletion_data;
62
-    }
44
+	/**
45
+	 * @since $VID:$
46
+	 * @param $code
47
+	 * @return ModelObjNode[]
48
+	 * @throws UnexpectedEntityException
49
+	 */
50
+	public function getModelObjNodesInGroup($code)
51
+	{
52
+		if (! $code) {
53
+			throw new Exception(esc_html__('We aren’t sure which job you are performing. Please press back in your browser and try again.', 'event_espresso'));
54
+		}
55
+		$deletion_data = get_option($this->getOptionPrefix() . $code, []);
56
+		foreach ($deletion_data as $root) {
57
+			if (! $root instanceof ModelObjNode) {
58
+				throw new UnexpectedEntityException($root, 'ModelObjNode');
59
+			}
60
+		}
61
+		return $deletion_data;
62
+	}
63 63
 
64
-    /**
65
-     * Gets an array indicating what database rows are contained in the job.
66
-     * Each top-level key is a model name, and its value is an array of IDs.
67
-     * @since $VID:$
68
-     * @param ModelObjNode[] $model_obj_nodes
69
-     * @return array
70
-     * @throws EE_Error
71
-     * @throws InvalidDataTypeException
72
-     * @throws InvalidInterfaceException
73
-     * @throws InvalidArgumentException
74
-     * @throws ReflectionException
75
-     */
76
-    public function getModelsAndIdsContainedIn($model_obj_nodes)
77
-    {
78
-        $models_and_ids_to_delete = [];
79
-        foreach ($model_obj_nodes as $root) {
80
-            $models_and_ids_to_delete = array_replace_recursive($models_and_ids_to_delete, $root->getIds());
81
-        }
82
-        return $models_and_ids_to_delete;
83
-    }
64
+	/**
65
+	 * Gets an array indicating what database rows are contained in the job.
66
+	 * Each top-level key is a model name, and its value is an array of IDs.
67
+	 * @since $VID:$
68
+	 * @param ModelObjNode[] $model_obj_nodes
69
+	 * @return array
70
+	 * @throws EE_Error
71
+	 * @throws InvalidDataTypeException
72
+	 * @throws InvalidInterfaceException
73
+	 * @throws InvalidArgumentException
74
+	 * @throws ReflectionException
75
+	 */
76
+	public function getModelsAndIdsContainedIn($model_obj_nodes)
77
+	{
78
+		$models_and_ids_to_delete = [];
79
+		foreach ($model_obj_nodes as $root) {
80
+			$models_and_ids_to_delete = array_replace_recursive($models_and_ids_to_delete, $root->getIds());
81
+		}
82
+		return $models_and_ids_to_delete;
83
+	}
84 84
 
85
-    /**
86
-     * Gets an array indicating what database rows are contained in the job.
87
-     * Each top-level key is a model name, and its value is an array of IDs.
88
-     * @since $VID:$
89
-     * @param string $code
90
-     * @return array
91
-     * @throws EE_Error
92
-     * @throws InvalidArgumentException
93
-     * @throws InvalidDataTypeException
94
-     * @throws InvalidInterfaceException
95
-     * @throws ReflectionException
96
-     * @throws UnexpectedEntityException
97
-     */
98
-    public function getModelsAndIdsFromGroup($code)
99
-    {
100
-        $model_obj_nodes = $this->getModelObjNodesInGroup($code);
101
-        return $this->getModelsAndIdsContainedIn($model_obj_nodes);
102
-    }
85
+	/**
86
+	 * Gets an array indicating what database rows are contained in the job.
87
+	 * Each top-level key is a model name, and its value is an array of IDs.
88
+	 * @since $VID:$
89
+	 * @param string $code
90
+	 * @return array
91
+	 * @throws EE_Error
92
+	 * @throws InvalidArgumentException
93
+	 * @throws InvalidDataTypeException
94
+	 * @throws InvalidInterfaceException
95
+	 * @throws ReflectionException
96
+	 * @throws UnexpectedEntityException
97
+	 */
98
+	public function getModelsAndIdsFromGroup($code)
99
+	{
100
+		$model_obj_nodes = $this->getModelObjNodesInGroup($code);
101
+		return $this->getModelsAndIdsContainedIn($model_obj_nodes);
102
+	}
103 103
 
104
-    /**
105
-     * Persists the ModelObjNodes for future requests, using the code for reference.
106
-     * @since $VID:$
107
-     * @param ModelObjNode[] $model_obj_nodes
108
-     * @param string $code
109
-     * @return bool
110
-     */
111
-    public function persistModelObjNodesGroup($model_obj_nodes, $code)
112
-    {
113
-        return add_option(
114
-            $this->getOptionPrefix() . $code,
115
-            $model_obj_nodes,
116
-            null,
117
-            'no'
118
-        );
119
-    }
104
+	/**
105
+	 * Persists the ModelObjNodes for future requests, using the code for reference.
106
+	 * @since $VID:$
107
+	 * @param ModelObjNode[] $model_obj_nodes
108
+	 * @param string $code
109
+	 * @return bool
110
+	 */
111
+	public function persistModelObjNodesGroup($model_obj_nodes, $code)
112
+	{
113
+		return add_option(
114
+			$this->getOptionPrefix() . $code,
115
+			$model_obj_nodes,
116
+			null,
117
+			'no'
118
+		);
119
+	}
120 120
 
121
-    /**
122
-     * Forgets about the group of ModelObjNodes. Doesn't delete the rows in the database they reference though.
123
-     * @since $VID:$
124
-     * @param $code
125
-     * @return bool
126
-     */
127
-    public function deleteModelObjNodesInGroup($code)
128
-    {
129
-        return delete_option($this->getOptionPrefix() . $code);
130
-    }
121
+	/**
122
+	 * Forgets about the group of ModelObjNodes. Doesn't delete the rows in the database they reference though.
123
+	 * @since $VID:$
124
+	 * @param $code
125
+	 * @return bool
126
+	 */
127
+	public function deleteModelObjNodesInGroup($code)
128
+	{
129
+		return delete_option($this->getOptionPrefix() . $code);
130
+	}
131 131
 }
132 132
 // End of file NodeGroupDao.php
133 133
 // Location: EventEspresso\core\services\orm\tree_traversal/NodeGroupDao.php
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -49,12 +49,12 @@  discard block
 block discarded – undo
49 49
      */
50 50
     public function getModelObjNodesInGroup($code)
51 51
     {
52
-        if (! $code) {
52
+        if ( ! $code) {
53 53
             throw new Exception(esc_html__('We aren’t sure which job you are performing. Please press back in your browser and try again.', 'event_espresso'));
54 54
         }
55
-        $deletion_data = get_option($this->getOptionPrefix() . $code, []);
55
+        $deletion_data = get_option($this->getOptionPrefix().$code, []);
56 56
         foreach ($deletion_data as $root) {
57
-            if (! $root instanceof ModelObjNode) {
57
+            if ( ! $root instanceof ModelObjNode) {
58 58
                 throw new UnexpectedEntityException($root, 'ModelObjNode');
59 59
             }
60 60
         }
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
     public function persistModelObjNodesGroup($model_obj_nodes, $code)
112 112
     {
113 113
         return add_option(
114
-            $this->getOptionPrefix() . $code,
114
+            $this->getOptionPrefix().$code,
115 115
             $model_obj_nodes,
116 116
             null,
117 117
             'no'
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
      */
127 127
     public function deleteModelObjNodesInGroup($code)
128 128
     {
129
-        return delete_option($this->getOptionPrefix() . $code);
129
+        return delete_option($this->getOptionPrefix().$code);
130 130
     }
131 131
 }
132 132
 // End of file NodeGroupDao.php
Please login to merge, or discard this patch.
core/domain/services/admin/events/data/PreviewDeletion.php 2 patches
Indentation   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -24,118 +24,118 @@
 block discarded – undo
24 24
  */
25 25
 class PreviewDeletion
26 26
 {
27
-    /**
28
-     * @var NodeGroupDao
29
-     */
30
-    protected $dao;
27
+	/**
28
+	 * @var NodeGroupDao
29
+	 */
30
+	protected $dao;
31 31
 
32
-    /**
33
-     * @var EEM_Event
34
-     */
35
-    protected $event_model;
32
+	/**
33
+	 * @var EEM_Event
34
+	 */
35
+	protected $event_model;
36 36
 
37
-    /**
38
-     * @var EEM_Datetime
39
-     */
40
-    protected $datetime_model;
37
+	/**
38
+	 * @var EEM_Datetime
39
+	 */
40
+	protected $datetime_model;
41 41
 
42
-    /**
43
-     * @var EEM_Registration
44
-     */
45
-    protected $registration_model;
42
+	/**
43
+	 * @var EEM_Registration
44
+	 */
45
+	protected $registration_model;
46 46
 
47
-    /**
48
-     * PreviewDeletion constructor.
49
-     * @param NodeGroupDao $dao
50
-     * @param EEM_Event $event_model
51
-     * @param EEM_Datetime $datetime_model
52
-     * @param EEM_Registration $registration_model
53
-     */
54
-    public function __construct(
55
-        NodeGroupDao $dao,
56
-        EEM_Event $event_model,
57
-        EEM_Datetime $datetime_model,
58
-        EEM_Registration $registration_model
59
-    )
60
-    {
61
-        $this->dao = $dao;
62
-        $this->event_model = $event_model;
63
-        $this->datetime_model = $datetime_model;
64
-        $this->registration_model = $registration_model;
65
-    }
47
+	/**
48
+	 * PreviewDeletion constructor.
49
+	 * @param NodeGroupDao $dao
50
+	 * @param EEM_Event $event_model
51
+	 * @param EEM_Datetime $datetime_model
52
+	 * @param EEM_Registration $registration_model
53
+	 */
54
+	public function __construct(
55
+		NodeGroupDao $dao,
56
+		EEM_Event $event_model,
57
+		EEM_Datetime $datetime_model,
58
+		EEM_Registration $registration_model
59
+	)
60
+	{
61
+		$this->dao = $dao;
62
+		$this->event_model = $event_model;
63
+		$this->datetime_model = $datetime_model;
64
+		$this->registration_model = $registration_model;
65
+	}
66 66
 
67
-    public function handle(Events_Admin_Page $admin_page)
68
-    {
69
-        $request_data = $admin_page->get_request_data();
70
-        $deletion_job_code = isset($request_data['deletion_job_code']) ? sanitize_key($request_data['deletion_job_code']) : '';
71
-        $models_and_ids_to_delete = $this->dao->getModelsAndIdsFromGroup($deletion_job_code);
72
-        $event_ids = isset($models_and_ids_to_delete['Event']) ? $models_and_ids_to_delete['Event'] : array();
73
-        if (empty($event_ids) || !is_array($event_ids)) {
74
-            throw new EE_Error(
75
-                esc_html__('No Events were found to delete.', 'event_espresso')
76
-            );
77
-        }
78
-        $datetime_ids = isset($models_and_ids_to_delete['Datetime']) ? $models_and_ids_to_delete['Datetime'] : array();
79
-        if (!is_array($datetime_ids)) {
80
-            throw new UnexpectedEntityException($datetime_ids, 'array');
81
-        }
82
-        $registration_ids = isset($models_and_ids_to_delete['Registration']) ? $models_and_ids_to_delete['Registration'] : array();
83
-        if (!is_array($registration_ids)) {
84
-            throw new UnexpectedEntityException($registration_ids, 'array');
85
-        }
86
-        $num_registrations_to_show = 10;
87
-        $reg_count = count($registration_ids);
88
-        if ($reg_count > $num_registrations_to_show) {
89
-            $registration_ids = array_slice($registration_ids, 0, $num_registrations_to_show);
90
-        }
91
-        $form = new ConfirmEventDeletionForm($event_ids);
92
-        $events = $this->event_model->get_all_deleted_and_undeleted(
93
-            [
94
-                [
95
-                    'EVT_ID' => ['IN', $event_ids]
96
-                ]
97
-            ]
98
-        );
99
-        $datetimes = $this->datetime_model->get_all_deleted_and_undeleted(
100
-            [
101
-                [
102
-                    'DTT_ID' => ['IN', $datetime_ids]
103
-                ]
104
-            ]
105
-        );
106
-        $registrations = $this->registration_model->get_all_deleted_and_undeleted(
107
-            [
108
-                [
109
-                    'REG_ID' => ['IN', $registration_ids]
110
-                ]
111
-            ]
112
-        );
113
-        $confirm_deletion_args = [
114
-            'action' => 'confirm_deletion',
115
-            'deletion_job_code' => $deletion_job_code
116
-        ];
117
-        $admin_page->set_template_args(
118
-            [
119
-                'admin_page_content' => EEH_Template::display_template(
120
-                    EVENTS_TEMPLATE_PATH . 'event_preview_deletion.template.php',
121
-                    [
122
-                        'form_url' => EE_Admin_Page::add_query_args_and_nonce(
123
-                            $confirm_deletion_args,
124
-                            $admin_page->admin_base_url()
125
-                        ),
126
-                        'form' => $form,
127
-                        'events' => $events,
128
-                        'datetimes' => $datetimes,
129
-                        'registrations' => $registrations,
130
-                        'reg_count' => $reg_count,
131
-                        'num_registrations_to_show' => $num_registrations_to_show
132
-                    ],
133
-                    true
134
-                )
135
-            ]
136
-        );
137
-        $admin_page->display_admin_page_with_no_sidebar();
138
-    }
67
+	public function handle(Events_Admin_Page $admin_page)
68
+	{
69
+		$request_data = $admin_page->get_request_data();
70
+		$deletion_job_code = isset($request_data['deletion_job_code']) ? sanitize_key($request_data['deletion_job_code']) : '';
71
+		$models_and_ids_to_delete = $this->dao->getModelsAndIdsFromGroup($deletion_job_code);
72
+		$event_ids = isset($models_and_ids_to_delete['Event']) ? $models_and_ids_to_delete['Event'] : array();
73
+		if (empty($event_ids) || !is_array($event_ids)) {
74
+			throw new EE_Error(
75
+				esc_html__('No Events were found to delete.', 'event_espresso')
76
+			);
77
+		}
78
+		$datetime_ids = isset($models_and_ids_to_delete['Datetime']) ? $models_and_ids_to_delete['Datetime'] : array();
79
+		if (!is_array($datetime_ids)) {
80
+			throw new UnexpectedEntityException($datetime_ids, 'array');
81
+		}
82
+		$registration_ids = isset($models_and_ids_to_delete['Registration']) ? $models_and_ids_to_delete['Registration'] : array();
83
+		if (!is_array($registration_ids)) {
84
+			throw new UnexpectedEntityException($registration_ids, 'array');
85
+		}
86
+		$num_registrations_to_show = 10;
87
+		$reg_count = count($registration_ids);
88
+		if ($reg_count > $num_registrations_to_show) {
89
+			$registration_ids = array_slice($registration_ids, 0, $num_registrations_to_show);
90
+		}
91
+		$form = new ConfirmEventDeletionForm($event_ids);
92
+		$events = $this->event_model->get_all_deleted_and_undeleted(
93
+			[
94
+				[
95
+					'EVT_ID' => ['IN', $event_ids]
96
+				]
97
+			]
98
+		);
99
+		$datetimes = $this->datetime_model->get_all_deleted_and_undeleted(
100
+			[
101
+				[
102
+					'DTT_ID' => ['IN', $datetime_ids]
103
+				]
104
+			]
105
+		);
106
+		$registrations = $this->registration_model->get_all_deleted_and_undeleted(
107
+			[
108
+				[
109
+					'REG_ID' => ['IN', $registration_ids]
110
+				]
111
+			]
112
+		);
113
+		$confirm_deletion_args = [
114
+			'action' => 'confirm_deletion',
115
+			'deletion_job_code' => $deletion_job_code
116
+		];
117
+		$admin_page->set_template_args(
118
+			[
119
+				'admin_page_content' => EEH_Template::display_template(
120
+					EVENTS_TEMPLATE_PATH . 'event_preview_deletion.template.php',
121
+					[
122
+						'form_url' => EE_Admin_Page::add_query_args_and_nonce(
123
+							$confirm_deletion_args,
124
+							$admin_page->admin_base_url()
125
+						),
126
+						'form' => $form,
127
+						'events' => $events,
128
+						'datetimes' => $datetimes,
129
+						'registrations' => $registrations,
130
+						'reg_count' => $reg_count,
131
+						'num_registrations_to_show' => $num_registrations_to_show
132
+					],
133
+					true
134
+				)
135
+			]
136
+		);
137
+		$admin_page->display_admin_page_with_no_sidebar();
138
+	}
139 139
 }
140 140
 // End of file PreviewDeletion.php
141 141
 // Location: EventEspresso\core\domain\services\admin\events\data/PreviewDeletion.php
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -70,17 +70,17 @@  discard block
 block discarded – undo
70 70
         $deletion_job_code = isset($request_data['deletion_job_code']) ? sanitize_key($request_data['deletion_job_code']) : '';
71 71
         $models_and_ids_to_delete = $this->dao->getModelsAndIdsFromGroup($deletion_job_code);
72 72
         $event_ids = isset($models_and_ids_to_delete['Event']) ? $models_and_ids_to_delete['Event'] : array();
73
-        if (empty($event_ids) || !is_array($event_ids)) {
73
+        if (empty($event_ids) || ! is_array($event_ids)) {
74 74
             throw new EE_Error(
75 75
                 esc_html__('No Events were found to delete.', 'event_espresso')
76 76
             );
77 77
         }
78 78
         $datetime_ids = isset($models_and_ids_to_delete['Datetime']) ? $models_and_ids_to_delete['Datetime'] : array();
79
-        if (!is_array($datetime_ids)) {
79
+        if ( ! is_array($datetime_ids)) {
80 80
             throw new UnexpectedEntityException($datetime_ids, 'array');
81 81
         }
82 82
         $registration_ids = isset($models_and_ids_to_delete['Registration']) ? $models_and_ids_to_delete['Registration'] : array();
83
-        if (!is_array($registration_ids)) {
83
+        if ( ! is_array($registration_ids)) {
84 84
             throw new UnexpectedEntityException($registration_ids, 'array');
85 85
         }
86 86
         $num_registrations_to_show = 10;
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
         $admin_page->set_template_args(
118 118
             [
119 119
                 'admin_page_content' => EEH_Template::display_template(
120
-                    EVENTS_TEMPLATE_PATH . 'event_preview_deletion.template.php',
120
+                    EVENTS_TEMPLATE_PATH.'event_preview_deletion.template.php',
121 121
                     [
122 122
                         'form_url' => EE_Admin_Page::add_query_args_and_nonce(
123 123
                             $confirm_deletion_args,
Please login to merge, or discard this patch.
core/domain/services/admin/events/data/ConfirmDeletion.php 1 patch
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -21,85 +21,85 @@
 block discarded – undo
21 21
  */
22 22
 class ConfirmDeletion
23 23
 {
24
-    /**
25
-     * @var NodeGroupDao
26
-     */
27
-    private $dao;
24
+	/**
25
+	 * @var NodeGroupDao
26
+	 */
27
+	private $dao;
28 28
 
29
-    /**
30
-     * ConfirmDeletion constructor.
31
-     * @param NodeGroupDao $dao
32
-     */
33
-    public function __construct(
34
-        NodeGroupDao $dao
35
-    )
36
-    {
29
+	/**
30
+	 * ConfirmDeletion constructor.
31
+	 * @param NodeGroupDao $dao
32
+	 */
33
+	public function __construct(
34
+		NodeGroupDao $dao
35
+	)
36
+	{
37 37
 
38
-        $this->dao = $dao;
39
-    }
38
+		$this->dao = $dao;
39
+	}
40 40
 
41
-    /**
42
-     * @since $VID:$
43
-     * @param \Events_Admin_Page $admin_page
44
-     * @throws EE_Error
45
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
46
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
47
-     * @throws \EventEspresso\core\exceptions\UnexpectedEntityException
48
-     * @throws \InvalidArgumentException
49
-     * @throws \ReflectionException
50
-     */
51
-    public function handle(\Events_Admin_Page $admin_page)
52
-    {
53
-        $request_data = $admin_page->get_request_data();
54
-        $deletion_job_code = isset($request_data['deletion_job_code']) ? sanitize_key($request_data['deletion_job_code']) : '';
55
-        $models_and_ids_to_delete = $this->dao->getModelsAndIdsFromGroup($deletion_job_code);
56
-        $form = new ConfirmEventDeletionForm($models_and_ids_to_delete['Event']);
57
-        // Initialize the form from the request, and check if its valid.
58
-        $form->receive_form_submission($request_data);
59
-        if ($form->is_valid()) {
60
-            // Redirect the user to the deletion batch job.
61
-            EEH_URL::safeRedirectAndExit(
62
-                EE_Admin_Page::add_query_args_and_nonce(
63
-                    array(
64
-                        'page' => 'espresso_batch',
65
-                        'batch' => EED_Batch::batch_job,
66
-                        'deletion_job_code' => $deletion_job_code,
67
-                        'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\ExecuteBatchDeletion'),
68
-                        'return_url' => urlencode(
69
-                            add_query_arg(
70
-                                [
71
-                                    'status' => 'trash'
72
-                                ],
73
-                                EVENTS_ADMIN_URL
74
-                            )
75
-                        )
76
-                    ),
77
-                    admin_url()
78
-                )
79
-            );
80
-        }
81
-        // Dont' use $form->submission_error_message() because it adds the form input's label in front
82
-        // of each validation error which ends up looking quite confusing.
83
-        $validation_errors = $form->get_validation_errors_accumulated();
84
-        foreach ($validation_errors as $validation_error) {
85
-            EE_Error::add_error(
86
-                $validation_error->getMessage(),
87
-                __FILE__,
88
-                __FUNCTION__,
89
-                __LINE__
90
-            );
91
-        }
41
+	/**
42
+	 * @since $VID:$
43
+	 * @param \Events_Admin_Page $admin_page
44
+	 * @throws EE_Error
45
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
46
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
47
+	 * @throws \EventEspresso\core\exceptions\UnexpectedEntityException
48
+	 * @throws \InvalidArgumentException
49
+	 * @throws \ReflectionException
50
+	 */
51
+	public function handle(\Events_Admin_Page $admin_page)
52
+	{
53
+		$request_data = $admin_page->get_request_data();
54
+		$deletion_job_code = isset($request_data['deletion_job_code']) ? sanitize_key($request_data['deletion_job_code']) : '';
55
+		$models_and_ids_to_delete = $this->dao->getModelsAndIdsFromGroup($deletion_job_code);
56
+		$form = new ConfirmEventDeletionForm($models_and_ids_to_delete['Event']);
57
+		// Initialize the form from the request, and check if its valid.
58
+		$form->receive_form_submission($request_data);
59
+		if ($form->is_valid()) {
60
+			// Redirect the user to the deletion batch job.
61
+			EEH_URL::safeRedirectAndExit(
62
+				EE_Admin_Page::add_query_args_and_nonce(
63
+					array(
64
+						'page' => 'espresso_batch',
65
+						'batch' => EED_Batch::batch_job,
66
+						'deletion_job_code' => $deletion_job_code,
67
+						'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\ExecuteBatchDeletion'),
68
+						'return_url' => urlencode(
69
+							add_query_arg(
70
+								[
71
+									'status' => 'trash'
72
+								],
73
+								EVENTS_ADMIN_URL
74
+							)
75
+						)
76
+					),
77
+					admin_url()
78
+				)
79
+			);
80
+		}
81
+		// Dont' use $form->submission_error_message() because it adds the form input's label in front
82
+		// of each validation error which ends up looking quite confusing.
83
+		$validation_errors = $form->get_validation_errors_accumulated();
84
+		foreach ($validation_errors as $validation_error) {
85
+			EE_Error::add_error(
86
+				$validation_error->getMessage(),
87
+				__FILE__,
88
+				__FUNCTION__,
89
+				__LINE__
90
+			);
91
+		}
92 92
 
93
-        EEH_URL::safeRedirectAndExit(
94
-            EE_Admin_Page::add_query_args_and_nonce(
95
-                [
96
-                    'action' => 'preview_deletion',
97
-                    'deletion_job_code' => $deletion_job_code
98
-                ],
99
-                $admin_page->admin_base_url()
100
-            )
101
-        );
102
-    }
93
+		EEH_URL::safeRedirectAndExit(
94
+			EE_Admin_Page::add_query_args_and_nonce(
95
+				[
96
+					'action' => 'preview_deletion',
97
+					'deletion_job_code' => $deletion_job_code
98
+				],
99
+				$admin_page->admin_base_url()
100
+			)
101
+		);
102
+	}
103 103
 }
104 104
 // End of file ConfirmDeletion.php
105 105
 // Location: EventEspresso\core\domain\services\admin\events\data/ConfirmDeletion.php
Please login to merge, or discard this patch.
core/EE_Dependency_Map.core.php 1 patch
Indentation   +1140 added lines, -1140 removed lines patch added patch discarded remove patch
@@ -20,1144 +20,1144 @@
 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
-            'EventEspressoBatchRequest\JobHandlers\ExecuteBatchDeletion' => [
889
-                'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache
890
-            ],
891
-            'EventEspressoBatchRequest\JobHandlers\PreviewEventDeletion' => [
892
-                'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache
893
-            ],
894
-            'EventEspresso\core\domain\services\admin\events\data\PreviewDeletion' => [
895
-                'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache,
896
-                'EEM_Event' => EE_Dependency_Map::load_from_cache,
897
-                'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
898
-                'EEM_Registration' => EE_Dependency_Map::load_from_cache,
899
-                'Events_Admin_Page' => EE_Dependency_Map::load_from_cache
900
-            ],
901
-            'EventEspresso\core\domain\services\admin\events\data\ConfirmDeletion' => [
902
-                'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache,
903
-            ]
904
-        );
905
-    }
906
-
907
-
908
-    /**
909
-     * Registers how core classes are loaded.
910
-     * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
911
-     *        'EE_Request_Handler' => 'load_core'
912
-     *        'EE_Messages_Queue'  => 'load_lib'
913
-     *        'EEH_Debug_Tools'    => 'load_helper'
914
-     * or, if greater control is required, by providing a custom closure. For example:
915
-     *        'Some_Class' => function () {
916
-     *            return new Some_Class();
917
-     *        },
918
-     * This is required for instantiating dependencies
919
-     * where an interface has been type hinted in a class constructor. For example:
920
-     *        'Required_Interface' => function () {
921
-     *            return new A_Class_That_Implements_Required_Interface();
922
-     *        },
923
-     */
924
-    protected function _register_core_class_loaders()
925
-    {
926
-        $this->_class_loaders = array(
927
-            // load_core
928
-            'EE_Dependency_Map'                            => function () {
929
-                return $this;
930
-            },
931
-            'EE_Capabilities'                              => 'load_core',
932
-            'EE_Encryption'                                => 'load_core',
933
-            'EE_Front_Controller'                          => 'load_core',
934
-            'EE_Module_Request_Router'                     => 'load_core',
935
-            'EE_Registry'                                  => 'load_core',
936
-            'EE_Request'                                   => function () {
937
-                return $this->legacy_request;
938
-            },
939
-            'EventEspresso\core\services\request\Request'  => function () {
940
-                return $this->request;
941
-            },
942
-            'EventEspresso\core\services\request\Response' => function () {
943
-                return $this->response;
944
-            },
945
-            'EE_Base'                                      => 'load_core',
946
-            'EE_Request_Handler'                           => 'load_core',
947
-            'EE_Session'                                   => 'load_core',
948
-            'EE_Cron_Tasks'                                => 'load_core',
949
-            'EE_System'                                    => 'load_core',
950
-            'EE_Maintenance_Mode'                          => 'load_core',
951
-            'EE_Register_CPTs'                             => 'load_core',
952
-            'EE_Admin'                                     => 'load_core',
953
-            'EE_CPT_Strategy'                              => 'load_core',
954
-            // load_class
955
-            'EE_Registration_Processor'                    => 'load_class',
956
-            // load_lib
957
-            'EE_Message_Resource_Manager'                  => 'load_lib',
958
-            'EE_Message_Type_Collection'                   => 'load_lib',
959
-            'EE_Message_Type_Collection_Loader'            => 'load_lib',
960
-            'EE_Messenger_Collection'                      => 'load_lib',
961
-            'EE_Messenger_Collection_Loader'               => 'load_lib',
962
-            'EE_Messages_Processor'                        => 'load_lib',
963
-            'EE_Message_Repository'                        => 'load_lib',
964
-            'EE_Messages_Queue'                            => 'load_lib',
965
-            'EE_Messages_Data_Handler_Collection'          => 'load_lib',
966
-            'EE_Message_Template_Group_Collection'         => 'load_lib',
967
-            'EE_Payment_Method_Manager'                    => 'load_lib',
968
-            'EE_DMS_Core_4_1_0'                            => 'load_dms',
969
-            'EE_DMS_Core_4_2_0'                            => 'load_dms',
970
-            'EE_DMS_Core_4_3_0'                            => 'load_dms',
971
-            'EE_DMS_Core_4_5_0'                            => 'load_dms',
972
-            'EE_DMS_Core_4_6_0'                            => 'load_dms',
973
-            'EE_DMS_Core_4_7_0'                            => 'load_dms',
974
-            'EE_DMS_Core_4_8_0'                            => 'load_dms',
975
-            'EE_DMS_Core_4_9_0'                            => 'load_dms',
976
-            'EE_DMS_Core_4_10_0'                            => 'load_dms',
977
-            'EE_Messages_Generator'                        => function () {
978
-                return EE_Registry::instance()->load_lib(
979
-                    'Messages_Generator',
980
-                    array(),
981
-                    false,
982
-                    false
983
-                );
984
-            },
985
-            'EE_Messages_Template_Defaults'                => function ($arguments = array()) {
986
-                return EE_Registry::instance()->load_lib(
987
-                    'Messages_Template_Defaults',
988
-                    $arguments,
989
-                    false,
990
-                    false
991
-                );
992
-            },
993
-            // load_helper
994
-            'EEH_Parse_Shortcodes'                         => function () {
995
-                if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
996
-                    return new EEH_Parse_Shortcodes();
997
-                }
998
-                return null;
999
-            },
1000
-            'EE_Template_Config'                           => function () {
1001
-                return EE_Config::instance()->template_settings;
1002
-            },
1003
-            'EE_Currency_Config'                           => function () {
1004
-                return EE_Config::instance()->currency;
1005
-            },
1006
-            'EE_Registration_Config'                       => function () {
1007
-                return EE_Config::instance()->registration;
1008
-            },
1009
-            'EE_Core_Config'                               => function () {
1010
-                return EE_Config::instance()->core;
1011
-            },
1012
-            'EventEspresso\core\services\loaders\Loader'   => function () {
1013
-                return LoaderFactory::getLoader();
1014
-            },
1015
-            'EE_Network_Config'                            => function () {
1016
-                return EE_Network_Config::instance();
1017
-            },
1018
-            'EE_Config'                                    => function () {
1019
-                return EE_Config::instance();
1020
-            },
1021
-            'EventEspresso\core\domain\Domain'             => function () {
1022
-                return DomainFactory::getEventEspressoCoreDomain();
1023
-            },
1024
-            'EE_Admin_Config'                              => function () {
1025
-                return EE_Config::instance()->admin;
1026
-            },
1027
-            'EE_Organization_Config'                       => function () {
1028
-                return EE_Config::instance()->organization;
1029
-            },
1030
-            'EE_Network_Core_Config'                       => function () {
1031
-                return EE_Network_Config::instance()->core;
1032
-            },
1033
-            'EE_Environment_Config'                        => function () {
1034
-                return EE_Config::instance()->environment;
1035
-            },
1036
-        );
1037
-    }
1038
-
1039
-
1040
-    /**
1041
-     * can be used for supplying alternate names for classes,
1042
-     * or for connecting interface names to instantiable classes
1043
-     */
1044
-    protected function _register_core_aliases()
1045
-    {
1046
-        $aliases = array(
1047
-            'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
1048
-            'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
1049
-            'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
1050
-            'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
1051
-            'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
1052
-            'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
1053
-            'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
1054
-            'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
1055
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
1056
-            'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
1057
-            'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
1058
-            'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
1059
-            'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
1060
-            'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
1061
-            'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
1062
-            'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
1063
-            'CreateTransactionCommandHandler'                                              => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
1064
-            'CreateAttendeeCommandHandler'                                                 => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
1065
-            'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
1066
-            'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
1067
-            'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
1068
-            'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
1069
-            'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
1070
-            'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
1071
-            'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
1072
-            'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
1073
-            'CommandFactoryInterface'                                                      => 'EventEspresso\core\services\commands\CommandFactoryInterface',
1074
-            'EventEspresso\core\services\commands\CommandFactoryInterface'                 => 'EventEspresso\core\services\commands\CommandFactory',
1075
-            'EmailValidatorInterface'                                                      => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
1076
-            'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface'  => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
1077
-            'NoticeConverterInterface'                                                     => 'EventEspresso\core\services\notices\NoticeConverterInterface',
1078
-            'EventEspresso\core\services\notices\NoticeConverterInterface'                 => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
1079
-            'NoticesContainerInterface'                                                    => 'EventEspresso\core\services\notices\NoticesContainerInterface',
1080
-            'EventEspresso\core\services\notices\NoticesContainerInterface'                => 'EventEspresso\core\services\notices\NoticesContainer',
1081
-            'EventEspresso\core\services\request\RequestInterface'                         => 'EventEspresso\core\services\request\Request',
1082
-            'EventEspresso\core\services\request\ResponseInterface'                        => 'EventEspresso\core\services\request\Response',
1083
-            'EventEspresso\core\domain\DomainInterface'                                    => 'EventEspresso\core\domain\Domain',
1084
-            'Registration_Processor'                                                       => 'EE_Registration_Processor',
1085
-        );
1086
-        foreach ($aliases as $alias => $fqn) {
1087
-            if (is_array($fqn)) {
1088
-                foreach ($fqn as $class => $for_class) {
1089
-                    $this->class_cache->addAlias($class, $alias, $for_class);
1090
-                }
1091
-                continue;
1092
-            }
1093
-            $this->class_cache->addAlias($fqn, $alias);
1094
-        }
1095
-        if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
1096
-            $this->class_cache->addAlias(
1097
-                'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices',
1098
-                'EventEspresso\core\services\notices\NoticeConverterInterface'
1099
-            );
1100
-        }
1101
-    }
1102
-
1103
-
1104
-    /**
1105
-     * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
1106
-     * request Primarily used by unit tests.
1107
-     */
1108
-    public function reset()
1109
-    {
1110
-        $this->_register_core_class_loaders();
1111
-        $this->_register_core_dependencies();
1112
-    }
1113
-
1114
-
1115
-    /**
1116
-     * PLZ NOTE: a better name for this method would be is_alias()
1117
-     * because it returns TRUE if the provided fully qualified name IS an alias
1118
-     * WHY?
1119
-     * Because if a class is type hinting for a concretion,
1120
-     * then why would we need to find another class to supply it?
1121
-     * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
1122
-     * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
1123
-     * Don't go looking for some substitute.
1124
-     * Whereas if a class is type hinting for an interface...
1125
-     * then we need to find an actual class to use.
1126
-     * So the interface IS the alias for some other FQN,
1127
-     * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
1128
-     * represents some other class.
1129
-     *
1130
-     * @deprecated 4.9.62.p
1131
-     * @param string $fqn
1132
-     * @param string $for_class
1133
-     * @return bool
1134
-     */
1135
-    public function has_alias($fqn = '', $for_class = '')
1136
-    {
1137
-        return $this->isAlias($fqn, $for_class);
1138
-    }
1139
-
1140
-
1141
-    /**
1142
-     * PLZ NOTE: a better name for this method would be get_fqn_for_alias()
1143
-     * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias
1144
-     * functions recursively, so that multiple aliases can be used to drill down to a FQN
1145
-     *  for example:
1146
-     *      if the following two entries were added to the _aliases array:
1147
-     *          array(
1148
-     *              'interface_alias'           => 'some\namespace\interface'
1149
-     *              'some\namespace\interface'  => 'some\namespace\classname'
1150
-     *          )
1151
-     *      then one could use EE_Registry::instance()->create( 'interface_alias' )
1152
-     *      to load an instance of 'some\namespace\classname'
1153
-     *
1154
-     * @deprecated 4.9.62.p
1155
-     * @param string $alias
1156
-     * @param string $for_class
1157
-     * @return string
1158
-     */
1159
-    public function get_alias($alias = '', $for_class = '')
1160
-    {
1161
-        return $this->getFqnForAlias($alias, $for_class);
1162
-    }
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
+			'EventEspressoBatchRequest\JobHandlers\ExecuteBatchDeletion' => [
889
+				'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache
890
+			],
891
+			'EventEspressoBatchRequest\JobHandlers\PreviewEventDeletion' => [
892
+				'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache
893
+			],
894
+			'EventEspresso\core\domain\services\admin\events\data\PreviewDeletion' => [
895
+				'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache,
896
+				'EEM_Event' => EE_Dependency_Map::load_from_cache,
897
+				'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
898
+				'EEM_Registration' => EE_Dependency_Map::load_from_cache,
899
+				'Events_Admin_Page' => EE_Dependency_Map::load_from_cache
900
+			],
901
+			'EventEspresso\core\domain\services\admin\events\data\ConfirmDeletion' => [
902
+				'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache,
903
+			]
904
+		);
905
+	}
906
+
907
+
908
+	/**
909
+	 * Registers how core classes are loaded.
910
+	 * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
911
+	 *        'EE_Request_Handler' => 'load_core'
912
+	 *        'EE_Messages_Queue'  => 'load_lib'
913
+	 *        'EEH_Debug_Tools'    => 'load_helper'
914
+	 * or, if greater control is required, by providing a custom closure. For example:
915
+	 *        'Some_Class' => function () {
916
+	 *            return new Some_Class();
917
+	 *        },
918
+	 * This is required for instantiating dependencies
919
+	 * where an interface has been type hinted in a class constructor. For example:
920
+	 *        'Required_Interface' => function () {
921
+	 *            return new A_Class_That_Implements_Required_Interface();
922
+	 *        },
923
+	 */
924
+	protected function _register_core_class_loaders()
925
+	{
926
+		$this->_class_loaders = array(
927
+			// load_core
928
+			'EE_Dependency_Map'                            => function () {
929
+				return $this;
930
+			},
931
+			'EE_Capabilities'                              => 'load_core',
932
+			'EE_Encryption'                                => 'load_core',
933
+			'EE_Front_Controller'                          => 'load_core',
934
+			'EE_Module_Request_Router'                     => 'load_core',
935
+			'EE_Registry'                                  => 'load_core',
936
+			'EE_Request'                                   => function () {
937
+				return $this->legacy_request;
938
+			},
939
+			'EventEspresso\core\services\request\Request'  => function () {
940
+				return $this->request;
941
+			},
942
+			'EventEspresso\core\services\request\Response' => function () {
943
+				return $this->response;
944
+			},
945
+			'EE_Base'                                      => 'load_core',
946
+			'EE_Request_Handler'                           => 'load_core',
947
+			'EE_Session'                                   => 'load_core',
948
+			'EE_Cron_Tasks'                                => 'load_core',
949
+			'EE_System'                                    => 'load_core',
950
+			'EE_Maintenance_Mode'                          => 'load_core',
951
+			'EE_Register_CPTs'                             => 'load_core',
952
+			'EE_Admin'                                     => 'load_core',
953
+			'EE_CPT_Strategy'                              => 'load_core',
954
+			// load_class
955
+			'EE_Registration_Processor'                    => 'load_class',
956
+			// load_lib
957
+			'EE_Message_Resource_Manager'                  => 'load_lib',
958
+			'EE_Message_Type_Collection'                   => 'load_lib',
959
+			'EE_Message_Type_Collection_Loader'            => 'load_lib',
960
+			'EE_Messenger_Collection'                      => 'load_lib',
961
+			'EE_Messenger_Collection_Loader'               => 'load_lib',
962
+			'EE_Messages_Processor'                        => 'load_lib',
963
+			'EE_Message_Repository'                        => 'load_lib',
964
+			'EE_Messages_Queue'                            => 'load_lib',
965
+			'EE_Messages_Data_Handler_Collection'          => 'load_lib',
966
+			'EE_Message_Template_Group_Collection'         => 'load_lib',
967
+			'EE_Payment_Method_Manager'                    => 'load_lib',
968
+			'EE_DMS_Core_4_1_0'                            => 'load_dms',
969
+			'EE_DMS_Core_4_2_0'                            => 'load_dms',
970
+			'EE_DMS_Core_4_3_0'                            => 'load_dms',
971
+			'EE_DMS_Core_4_5_0'                            => 'load_dms',
972
+			'EE_DMS_Core_4_6_0'                            => 'load_dms',
973
+			'EE_DMS_Core_4_7_0'                            => 'load_dms',
974
+			'EE_DMS_Core_4_8_0'                            => 'load_dms',
975
+			'EE_DMS_Core_4_9_0'                            => 'load_dms',
976
+			'EE_DMS_Core_4_10_0'                            => 'load_dms',
977
+			'EE_Messages_Generator'                        => function () {
978
+				return EE_Registry::instance()->load_lib(
979
+					'Messages_Generator',
980
+					array(),
981
+					false,
982
+					false
983
+				);
984
+			},
985
+			'EE_Messages_Template_Defaults'                => function ($arguments = array()) {
986
+				return EE_Registry::instance()->load_lib(
987
+					'Messages_Template_Defaults',
988
+					$arguments,
989
+					false,
990
+					false
991
+				);
992
+			},
993
+			// load_helper
994
+			'EEH_Parse_Shortcodes'                         => function () {
995
+				if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
996
+					return new EEH_Parse_Shortcodes();
997
+				}
998
+				return null;
999
+			},
1000
+			'EE_Template_Config'                           => function () {
1001
+				return EE_Config::instance()->template_settings;
1002
+			},
1003
+			'EE_Currency_Config'                           => function () {
1004
+				return EE_Config::instance()->currency;
1005
+			},
1006
+			'EE_Registration_Config'                       => function () {
1007
+				return EE_Config::instance()->registration;
1008
+			},
1009
+			'EE_Core_Config'                               => function () {
1010
+				return EE_Config::instance()->core;
1011
+			},
1012
+			'EventEspresso\core\services\loaders\Loader'   => function () {
1013
+				return LoaderFactory::getLoader();
1014
+			},
1015
+			'EE_Network_Config'                            => function () {
1016
+				return EE_Network_Config::instance();
1017
+			},
1018
+			'EE_Config'                                    => function () {
1019
+				return EE_Config::instance();
1020
+			},
1021
+			'EventEspresso\core\domain\Domain'             => function () {
1022
+				return DomainFactory::getEventEspressoCoreDomain();
1023
+			},
1024
+			'EE_Admin_Config'                              => function () {
1025
+				return EE_Config::instance()->admin;
1026
+			},
1027
+			'EE_Organization_Config'                       => function () {
1028
+				return EE_Config::instance()->organization;
1029
+			},
1030
+			'EE_Network_Core_Config'                       => function () {
1031
+				return EE_Network_Config::instance()->core;
1032
+			},
1033
+			'EE_Environment_Config'                        => function () {
1034
+				return EE_Config::instance()->environment;
1035
+			},
1036
+		);
1037
+	}
1038
+
1039
+
1040
+	/**
1041
+	 * can be used for supplying alternate names for classes,
1042
+	 * or for connecting interface names to instantiable classes
1043
+	 */
1044
+	protected function _register_core_aliases()
1045
+	{
1046
+		$aliases = array(
1047
+			'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
1048
+			'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
1049
+			'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
1050
+			'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
1051
+			'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
1052
+			'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
1053
+			'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
1054
+			'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
1055
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
1056
+			'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
1057
+			'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
1058
+			'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
1059
+			'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
1060
+			'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
1061
+			'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
1062
+			'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
1063
+			'CreateTransactionCommandHandler'                                              => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
1064
+			'CreateAttendeeCommandHandler'                                                 => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
1065
+			'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
1066
+			'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
1067
+			'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
1068
+			'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
1069
+			'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
1070
+			'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
1071
+			'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
1072
+			'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
1073
+			'CommandFactoryInterface'                                                      => 'EventEspresso\core\services\commands\CommandFactoryInterface',
1074
+			'EventEspresso\core\services\commands\CommandFactoryInterface'                 => 'EventEspresso\core\services\commands\CommandFactory',
1075
+			'EmailValidatorInterface'                                                      => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
1076
+			'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface'  => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
1077
+			'NoticeConverterInterface'                                                     => 'EventEspresso\core\services\notices\NoticeConverterInterface',
1078
+			'EventEspresso\core\services\notices\NoticeConverterInterface'                 => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
1079
+			'NoticesContainerInterface'                                                    => 'EventEspresso\core\services\notices\NoticesContainerInterface',
1080
+			'EventEspresso\core\services\notices\NoticesContainerInterface'                => 'EventEspresso\core\services\notices\NoticesContainer',
1081
+			'EventEspresso\core\services\request\RequestInterface'                         => 'EventEspresso\core\services\request\Request',
1082
+			'EventEspresso\core\services\request\ResponseInterface'                        => 'EventEspresso\core\services\request\Response',
1083
+			'EventEspresso\core\domain\DomainInterface'                                    => 'EventEspresso\core\domain\Domain',
1084
+			'Registration_Processor'                                                       => 'EE_Registration_Processor',
1085
+		);
1086
+		foreach ($aliases as $alias => $fqn) {
1087
+			if (is_array($fqn)) {
1088
+				foreach ($fqn as $class => $for_class) {
1089
+					$this->class_cache->addAlias($class, $alias, $for_class);
1090
+				}
1091
+				continue;
1092
+			}
1093
+			$this->class_cache->addAlias($fqn, $alias);
1094
+		}
1095
+		if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
1096
+			$this->class_cache->addAlias(
1097
+				'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices',
1098
+				'EventEspresso\core\services\notices\NoticeConverterInterface'
1099
+			);
1100
+		}
1101
+	}
1102
+
1103
+
1104
+	/**
1105
+	 * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
1106
+	 * request Primarily used by unit tests.
1107
+	 */
1108
+	public function reset()
1109
+	{
1110
+		$this->_register_core_class_loaders();
1111
+		$this->_register_core_dependencies();
1112
+	}
1113
+
1114
+
1115
+	/**
1116
+	 * PLZ NOTE: a better name for this method would be is_alias()
1117
+	 * because it returns TRUE if the provided fully qualified name IS an alias
1118
+	 * WHY?
1119
+	 * Because if a class is type hinting for a concretion,
1120
+	 * then why would we need to find another class to supply it?
1121
+	 * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
1122
+	 * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
1123
+	 * Don't go looking for some substitute.
1124
+	 * Whereas if a class is type hinting for an interface...
1125
+	 * then we need to find an actual class to use.
1126
+	 * So the interface IS the alias for some other FQN,
1127
+	 * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
1128
+	 * represents some other class.
1129
+	 *
1130
+	 * @deprecated 4.9.62.p
1131
+	 * @param string $fqn
1132
+	 * @param string $for_class
1133
+	 * @return bool
1134
+	 */
1135
+	public function has_alias($fqn = '', $for_class = '')
1136
+	{
1137
+		return $this->isAlias($fqn, $for_class);
1138
+	}
1139
+
1140
+
1141
+	/**
1142
+	 * PLZ NOTE: a better name for this method would be get_fqn_for_alias()
1143
+	 * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias
1144
+	 * functions recursively, so that multiple aliases can be used to drill down to a FQN
1145
+	 *  for example:
1146
+	 *      if the following two entries were added to the _aliases array:
1147
+	 *          array(
1148
+	 *              'interface_alias'           => 'some\namespace\interface'
1149
+	 *              'some\namespace\interface'  => 'some\namespace\classname'
1150
+	 *          )
1151
+	 *      then one could use EE_Registry::instance()->create( 'interface_alias' )
1152
+	 *      to load an instance of 'some\namespace\classname'
1153
+	 *
1154
+	 * @deprecated 4.9.62.p
1155
+	 * @param string $alias
1156
+	 * @param string $for_class
1157
+	 * @return string
1158
+	 */
1159
+	public function get_alias($alias = '', $for_class = '')
1160
+	{
1161
+		return $this->getFqnForAlias($alias, $for_class);
1162
+	}
1163 1163
 }
Please login to merge, or discard this patch.