Completed
Branch ADMIN-REFRESH (41ec76)
by
unknown
03:25 queued 28s
created
admin_pages/events/Events_Admin_Page.core.php 1 patch
Indentation   +2892 added lines, -2892 removed lines patch added patch discarded remove patch
@@ -16,2899 +16,2899 @@
 block discarded – undo
16 16
 class Events_Admin_Page extends EE_Admin_Page_CPT
17 17
 {
18 18
 
19
-    /**
20
-     * This will hold the event object for event_details screen.
19
+	/**
20
+	 * This will hold the event object for event_details screen.
21
+	 *
22
+	 * @var EE_Event $_event
23
+	 */
24
+	protected $_event;
25
+
26
+
27
+	/**
28
+	 * This will hold the category object for category_details screen.
29
+	 *
30
+	 * @var stdClass $_category
31
+	 */
32
+	protected $_category;
33
+
34
+
35
+	/**
36
+	 * This will hold the event model instance
37
+	 *
38
+	 * @var EEM_Event $_event_model
39
+	 */
40
+	protected $_event_model;
41
+
42
+
43
+	/**
44
+	 * @var EE_Event
45
+	 */
46
+	protected $_cpt_model_obj = false;
47
+
48
+
49
+	/**
50
+	 * @var NodeGroupDao
51
+	 */
52
+	protected $model_obj_node_group_persister;
53
+
54
+
55
+	/**
56
+	 * Initialize page props for this admin page group.
57
+	 */
58
+	protected function _init_page_props()
59
+	{
60
+		$this->page_slug        = EVENTS_PG_SLUG;
61
+		$this->page_label       = EVENTS_LABEL;
62
+		$this->_admin_base_url  = EVENTS_ADMIN_URL;
63
+		$this->_admin_base_path = EVENTS_ADMIN;
64
+		$this->_cpt_model_names = [
65
+			'create_new' => 'EEM_Event',
66
+			'edit'       => 'EEM_Event',
67
+		];
68
+		$this->_cpt_edit_routes = [
69
+			'espresso_events' => 'edit',
70
+		];
71
+		add_action(
72
+			'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object',
73
+			[$this, 'verify_event_edit'],
74
+			10,
75
+			2
76
+		);
77
+	}
78
+
79
+
80
+	/**
81
+	 * Sets the ajax hooks used for this admin page group.
82
+	 */
83
+	protected function _ajax_hooks()
84
+	{
85
+		add_action('wp_ajax_ee_save_timezone_setting', [$this, 'saveTimezoneString']);
86
+	}
87
+
88
+
89
+	/**
90
+	 * Sets the page properties for this admin page group.
91
+	 */
92
+	protected function _define_page_props()
93
+	{
94
+		$this->_admin_page_title = EVENTS_LABEL;
95
+		$this->_labels           = [
96
+			'buttons'      => [
97
+				'add'             => esc_html__('Add New Event', 'event_espresso'),
98
+				'edit'            => esc_html__('Edit Event', 'event_espresso'),
99
+				'delete'          => esc_html__('Delete Event', 'event_espresso'),
100
+				'add_category'    => esc_html__('Add New Category', 'event_espresso'),
101
+				'edit_category'   => esc_html__('Edit Category', 'event_espresso'),
102
+				'delete_category' => esc_html__('Delete Category', 'event_espresso'),
103
+			],
104
+			'editor_title' => [
105
+				'espresso_events' => esc_html__('Enter event title here', 'event_espresso'),
106
+			],
107
+			'publishbox'   => [
108
+				'create_new'        => esc_html__('Save New Event', 'event_espresso'),
109
+				'edit'              => esc_html__('Update Event', 'event_espresso'),
110
+				'add_category'      => esc_html__('Save New Category', 'event_espresso'),
111
+				'edit_category'     => esc_html__('Update Category', 'event_espresso'),
112
+				'template_settings' => esc_html__('Update Settings', 'event_espresso'),
113
+			],
114
+		];
115
+	}
116
+
117
+
118
+	/**
119
+	 * Sets the page routes property for this admin page group.
120
+	 */
121
+	protected function _set_page_routes()
122
+	{
123
+		// load formatter helper
124
+		// load field generator helper
125
+		// is there a evt_id in the request?
126
+		$EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int');
127
+		$EVT_ID = $this->request->getRequestParam('post', $EVT_ID, 'int');
128
+
129
+		$this->_page_routes = [
130
+			'default'                       => [
131
+				'func'       => '_events_overview_list_table',
132
+				'capability' => 'ee_read_events',
133
+			],
134
+			'create_new'                    => [
135
+				'func'       => '_create_new_cpt_item',
136
+				'capability' => 'ee_edit_events',
137
+			],
138
+			'edit'                          => [
139
+				'func'       => '_edit_cpt_item',
140
+				'capability' => 'ee_edit_event',
141
+				'obj_id'     => $EVT_ID,
142
+			],
143
+			'copy_event'                    => [
144
+				'func'       => '_copy_events',
145
+				'capability' => 'ee_edit_event',
146
+				'obj_id'     => $EVT_ID,
147
+				'noheader'   => true,
148
+			],
149
+			'trash_event'                   => [
150
+				'func'       => '_trash_or_restore_event',
151
+				'args'       => ['event_status' => 'trash'],
152
+				'capability' => 'ee_delete_event',
153
+				'obj_id'     => $EVT_ID,
154
+				'noheader'   => true,
155
+			],
156
+			'trash_events'                  => [
157
+				'func'       => '_trash_or_restore_events',
158
+				'args'       => ['event_status' => 'trash'],
159
+				'capability' => 'ee_delete_events',
160
+				'noheader'   => true,
161
+			],
162
+			'restore_event'                 => [
163
+				'func'       => '_trash_or_restore_event',
164
+				'args'       => ['event_status' => 'draft'],
165
+				'capability' => 'ee_delete_event',
166
+				'obj_id'     => $EVT_ID,
167
+				'noheader'   => true,
168
+			],
169
+			'restore_events'                => [
170
+				'func'       => '_trash_or_restore_events',
171
+				'args'       => ['event_status' => 'draft'],
172
+				'capability' => 'ee_delete_events',
173
+				'noheader'   => true,
174
+			],
175
+			'delete_event'                  => [
176
+				'func'       => '_delete_event',
177
+				'capability' => 'ee_delete_event',
178
+				'obj_id'     => $EVT_ID,
179
+				'noheader'   => true,
180
+			],
181
+			'delete_events'                 => [
182
+				'func'       => '_delete_events',
183
+				'capability' => 'ee_delete_events',
184
+				'noheader'   => true,
185
+			],
186
+			'view_report'                   => [
187
+				'func'       => '_view_report',
188
+				'capability' => 'ee_edit_events',
189
+			],
190
+			'default_event_settings'        => [
191
+				'func'       => '_default_event_settings',
192
+				'capability' => 'manage_options',
193
+			],
194
+			'update_default_event_settings' => [
195
+				'func'       => '_update_default_event_settings',
196
+				'capability' => 'manage_options',
197
+				'noheader'   => true,
198
+			],
199
+			'template_settings'             => [
200
+				'func'       => '_template_settings',
201
+				'capability' => 'manage_options',
202
+			],
203
+			// event category tab related
204
+			'add_category'                  => [
205
+				'func'       => '_category_details',
206
+				'capability' => 'ee_edit_event_category',
207
+				'args'       => ['add'],
208
+			],
209
+			'edit_category'                 => [
210
+				'func'       => '_category_details',
211
+				'capability' => 'ee_edit_event_category',
212
+				'args'       => ['edit'],
213
+			],
214
+			'delete_categories'             => [
215
+				'func'       => '_delete_categories',
216
+				'capability' => 'ee_delete_event_category',
217
+				'noheader'   => true,
218
+			],
219
+			'delete_category'               => [
220
+				'func'       => '_delete_categories',
221
+				'capability' => 'ee_delete_event_category',
222
+				'noheader'   => true,
223
+			],
224
+			'insert_category'               => [
225
+				'func'       => '_insert_or_update_category',
226
+				'args'       => ['new_category' => true],
227
+				'capability' => 'ee_edit_event_category',
228
+				'noheader'   => true,
229
+			],
230
+			'update_category'               => [
231
+				'func'       => '_insert_or_update_category',
232
+				'args'       => ['new_category' => false],
233
+				'capability' => 'ee_edit_event_category',
234
+				'noheader'   => true,
235
+			],
236
+			'category_list'                 => [
237
+				'func'       => '_category_list_table',
238
+				'capability' => 'ee_manage_event_categories',
239
+			],
240
+			'preview_deletion'              => [
241
+				'func'       => 'previewDeletion',
242
+				'capability' => 'ee_delete_events',
243
+			],
244
+			'confirm_deletion'              => [
245
+				'func'       => 'confirmDeletion',
246
+				'capability' => 'ee_delete_events',
247
+				'noheader'   => true,
248
+			],
249
+		];
250
+	}
251
+
252
+
253
+	/**
254
+	 * Set the _page_config property for this admin page group.
255
+	 */
256
+	protected function _set_page_config()
257
+	{
258
+		$post_id            = $this->request->getRequestParam('post', 0, 'int');
259
+		$EVT_CAT_ID         = $this->request->getRequestParam('EVT_CAT_ID', 0, 'int');
260
+		$this->_page_config = [
261
+			'default'                => [
262
+				'nav'           => [
263
+					'label' => esc_html__('Overview', 'event_espresso'),
264
+					'order' => 10,
265
+				],
266
+				'list_table'    => 'Events_Admin_List_Table',
267
+				'help_tabs'     => [
268
+					'events_overview_help_tab'                       => [
269
+						'title'    => esc_html__('Events Overview', 'event_espresso'),
270
+						'filename' => 'events_overview',
271
+					],
272
+					'events_overview_table_column_headings_help_tab' => [
273
+						'title'    => esc_html__('Events Overview Table Column Headings', 'event_espresso'),
274
+						'filename' => 'events_overview_table_column_headings',
275
+					],
276
+					'events_overview_filters_help_tab'               => [
277
+						'title'    => esc_html__('Events Overview Filters', 'event_espresso'),
278
+						'filename' => 'events_overview_filters',
279
+					],
280
+					'events_overview_view_help_tab'                  => [
281
+						'title'    => esc_html__('Events Overview Views', 'event_espresso'),
282
+						'filename' => 'events_overview_views',
283
+					],
284
+					'events_overview_other_help_tab'                 => [
285
+						'title'    => esc_html__('Events Overview Other', 'event_espresso'),
286
+						'filename' => 'events_overview_other',
287
+					],
288
+				],
289
+				'require_nonce' => false,
290
+			],
291
+			'create_new'             => [
292
+				'nav'           => [
293
+					'label'      => esc_html__('Add New Event', 'event_espresso'),
294
+					'order'      => 5,
295
+					'persistent' => false,
296
+				],
297
+				'metaboxes'     => ['_register_event_editor_meta_boxes'],
298
+				'help_tabs'     => [
299
+					'event_editor_help_tab'                            => [
300
+						'title'    => esc_html__('Event Editor', 'event_espresso'),
301
+						'filename' => 'event_editor',
302
+					],
303
+					'event_editor_title_richtexteditor_help_tab'       => [
304
+						'title'    => esc_html__('Event Title & Rich Text Editor', 'event_espresso'),
305
+						'filename' => 'event_editor_title_richtexteditor',
306
+					],
307
+					'event_editor_venue_details_help_tab'              => [
308
+						'title'    => esc_html__('Event Venue Details', 'event_espresso'),
309
+						'filename' => 'event_editor_venue_details',
310
+					],
311
+					'event_editor_event_datetimes_help_tab'            => [
312
+						'title'    => esc_html__('Event Datetimes', 'event_espresso'),
313
+						'filename' => 'event_editor_event_datetimes',
314
+					],
315
+					'event_editor_event_tickets_help_tab'              => [
316
+						'title'    => esc_html__('Event Tickets', 'event_espresso'),
317
+						'filename' => 'event_editor_event_tickets',
318
+					],
319
+					'event_editor_event_registration_options_help_tab' => [
320
+						'title'    => esc_html__('Event Registration Options', 'event_espresso'),
321
+						'filename' => 'event_editor_event_registration_options',
322
+					],
323
+					'event_editor_tags_categories_help_tab'            => [
324
+						'title'    => esc_html__('Event Tags & Categories', 'event_espresso'),
325
+						'filename' => 'event_editor_tags_categories',
326
+					],
327
+					'event_editor_questions_registrants_help_tab'      => [
328
+						'title'    => esc_html__('Questions for Registrants', 'event_espresso'),
329
+						'filename' => 'event_editor_questions_registrants',
330
+					],
331
+					'event_editor_save_new_event_help_tab'             => [
332
+						'title'    => esc_html__('Save New Event', 'event_espresso'),
333
+						'filename' => 'event_editor_save_new_event',
334
+					],
335
+					'event_editor_other_help_tab'                      => [
336
+						'title'    => esc_html__('Event Other', 'event_espresso'),
337
+						'filename' => 'event_editor_other',
338
+					],
339
+				],
340
+				'qtips'         => ['EE_Event_Editor_Decaf_Tips'],
341
+				'require_nonce' => false,
342
+			],
343
+			'edit'                   => [
344
+				'nav'           => [
345
+					'label'      => esc_html__('Edit Event', 'event_espresso'),
346
+					'order'      => 5,
347
+					'persistent' => false,
348
+					'url'        => $post_id
349
+						? EE_Admin_Page::add_query_args_and_nonce(
350
+							['post' => $post_id, 'action' => 'edit'],
351
+							$this->_current_page_view_url
352
+						)
353
+						: $this->_admin_base_url,
354
+				],
355
+				'metaboxes'     => ['_register_event_editor_meta_boxes'],
356
+				'help_tabs'     => [
357
+					'event_editor_help_tab'                            => [
358
+						'title'    => esc_html__('Event Editor', 'event_espresso'),
359
+						'filename' => 'event_editor',
360
+					],
361
+					'event_editor_title_richtexteditor_help_tab'       => [
362
+						'title'    => esc_html__('Event Title & Rich Text Editor', 'event_espresso'),
363
+						'filename' => 'event_editor_title_richtexteditor',
364
+					],
365
+					'event_editor_venue_details_help_tab'              => [
366
+						'title'    => esc_html__('Event Venue Details', 'event_espresso'),
367
+						'filename' => 'event_editor_venue_details',
368
+					],
369
+					'event_editor_event_datetimes_help_tab'            => [
370
+						'title'    => esc_html__('Event Datetimes', 'event_espresso'),
371
+						'filename' => 'event_editor_event_datetimes',
372
+					],
373
+					'event_editor_event_tickets_help_tab'              => [
374
+						'title'    => esc_html__('Event Tickets', 'event_espresso'),
375
+						'filename' => 'event_editor_event_tickets',
376
+					],
377
+					'event_editor_event_registration_options_help_tab' => [
378
+						'title'    => esc_html__('Event Registration Options', 'event_espresso'),
379
+						'filename' => 'event_editor_event_registration_options',
380
+					],
381
+					'event_editor_tags_categories_help_tab'            => [
382
+						'title'    => esc_html__('Event Tags & Categories', 'event_espresso'),
383
+						'filename' => 'event_editor_tags_categories',
384
+					],
385
+					'event_editor_questions_registrants_help_tab'      => [
386
+						'title'    => esc_html__('Questions for Registrants', 'event_espresso'),
387
+						'filename' => 'event_editor_questions_registrants',
388
+					],
389
+					'event_editor_save_new_event_help_tab'             => [
390
+						'title'    => esc_html__('Save New Event', 'event_espresso'),
391
+						'filename' => 'event_editor_save_new_event',
392
+					],
393
+					'event_editor_other_help_tab'                      => [
394
+						'title'    => esc_html__('Event Other', 'event_espresso'),
395
+						'filename' => 'event_editor_other',
396
+					],
397
+				],
398
+				'require_nonce' => false,
399
+			],
400
+			'default_event_settings' => [
401
+				'nav'           => [
402
+					'label' => esc_html__('Default Settings', 'event_espresso'),
403
+					'order' => 40,
404
+				],
405
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
406
+				'labels'        => [
407
+					'publishbox' => esc_html__('Update Settings', 'event_espresso'),
408
+				],
409
+				'help_tabs'     => [
410
+					'default_settings_help_tab'        => [
411
+						'title'    => esc_html__('Default Event Settings', 'event_espresso'),
412
+						'filename' => 'events_default_settings',
413
+					],
414
+					'default_settings_status_help_tab' => [
415
+						'title'    => esc_html__('Default Registration Status', 'event_espresso'),
416
+						'filename' => 'events_default_settings_status',
417
+					],
418
+					'default_maximum_tickets_help_tab' => [
419
+						'title'    => esc_html__('Default Maximum Tickets Per Order', 'event_espresso'),
420
+						'filename' => 'events_default_settings_max_tickets',
421
+					],
422
+				],
423
+				'require_nonce' => false,
424
+			],
425
+			// template settings
426
+			'template_settings'      => [
427
+				'nav'           => [
428
+					'label' => esc_html__('Templates', 'event_espresso'),
429
+					'order' => 30,
430
+				],
431
+				'metaboxes'     => $this->_default_espresso_metaboxes,
432
+				'help_tabs'     => [
433
+					'general_settings_templates_help_tab' => [
434
+						'title'    => esc_html__('Templates', 'event_espresso'),
435
+						'filename' => 'general_settings_templates',
436
+					],
437
+				],
438
+				'require_nonce' => false,
439
+			],
440
+			// event category stuff
441
+			'add_category'           => [
442
+				'nav'           => [
443
+					'label'      => esc_html__('Add Category', 'event_espresso'),
444
+					'order'      => 15,
445
+					'persistent' => false,
446
+				],
447
+				'help_tabs'     => [
448
+					'add_category_help_tab' => [
449
+						'title'    => esc_html__('Add New Event Category', 'event_espresso'),
450
+						'filename' => 'events_add_category',
451
+					],
452
+				],
453
+				'metaboxes'     => ['_publish_post_box'],
454
+				'require_nonce' => false,
455
+			],
456
+			'edit_category'          => [
457
+				'nav'           => [
458
+					'label'      => esc_html__('Edit Category', 'event_espresso'),
459
+					'order'      => 15,
460
+					'persistent' => false,
461
+					'url'        => $EVT_CAT_ID
462
+						? add_query_arg(
463
+							['EVT_CAT_ID' => $EVT_CAT_ID],
464
+							$this->_current_page_view_url
465
+						)
466
+						: $this->_admin_base_url,
467
+				],
468
+				'help_tabs'     => [
469
+					'edit_category_help_tab' => [
470
+						'title'    => esc_html__('Edit Event Category', 'event_espresso'),
471
+						'filename' => 'events_edit_category',
472
+					],
473
+				],
474
+				'metaboxes'     => ['_publish_post_box'],
475
+				'require_nonce' => false,
476
+			],
477
+			'category_list'          => [
478
+				'nav'           => [
479
+					'label' => esc_html__('Categories', 'event_espresso'),
480
+					'order' => 20,
481
+				],
482
+				'list_table'    => 'Event_Categories_Admin_List_Table',
483
+				'help_tabs'     => [
484
+					'events_categories_help_tab'                       => [
485
+						'title'    => esc_html__('Event Categories', 'event_espresso'),
486
+						'filename' => 'events_categories',
487
+					],
488
+					'events_categories_table_column_headings_help_tab' => [
489
+						'title'    => esc_html__('Event Categories Table Column Headings', 'event_espresso'),
490
+						'filename' => 'events_categories_table_column_headings',
491
+					],
492
+					'events_categories_view_help_tab'                  => [
493
+						'title'    => esc_html__('Event Categories Views', 'event_espresso'),
494
+						'filename' => 'events_categories_views',
495
+					],
496
+					'events_categories_other_help_tab'                 => [
497
+						'title'    => esc_html__('Event Categories Other', 'event_espresso'),
498
+						'filename' => 'events_categories_other',
499
+					],
500
+				],
501
+				'metaboxes'     => $this->_default_espresso_metaboxes,
502
+				'require_nonce' => false,
503
+			],
504
+			'preview_deletion'       => [
505
+				'nav'           => [
506
+					'label'      => esc_html__('Preview Deletion', 'event_espresso'),
507
+					'order'      => 15,
508
+					'persistent' => false,
509
+					'url'        => '',
510
+				],
511
+				'require_nonce' => false,
512
+			],
513
+		];
514
+	}
515
+
516
+
517
+	/**
518
+	 * Used to register any global screen options if necessary for every route in this admin page group.
519
+	 */
520
+	protected function _add_screen_options()
521
+	{
522
+	}
523
+
524
+
525
+	/**
526
+	 * Implementing the screen options for the 'default' route.
527
+	 *
528
+	 * @throws InvalidArgumentException
529
+	 * @throws InvalidDataTypeException
530
+	 * @throws InvalidInterfaceException
531
+	 */
532
+	protected function _add_screen_options_default()
533
+	{
534
+		$this->_per_page_screen_option();
535
+	}
536
+
537
+
538
+	/**
539
+	 * Implementing screen options for the category list route.
540
+	 *
541
+	 * @throws InvalidArgumentException
542
+	 * @throws InvalidDataTypeException
543
+	 * @throws InvalidInterfaceException
544
+	 */
545
+	protected function _add_screen_options_category_list()
546
+	{
547
+		$page_title              = $this->_admin_page_title;
548
+		$this->_admin_page_title = esc_html__('Categories', 'event_espresso');
549
+		$this->_per_page_screen_option();
550
+		$this->_admin_page_title = $page_title;
551
+	}
552
+
553
+
554
+	/**
555
+	 * Used to register any global feature pointers for the admin page group.
556
+	 */
557
+	protected function _add_feature_pointers()
558
+	{
559
+	}
560
+
561
+
562
+	/**
563
+	 * Registers and enqueues any global scripts and styles for the entire admin page group.
564
+	 */
565
+	public function load_scripts_styles()
566
+	{
567
+		wp_register_style(
568
+			'events-admin-css',
569
+			EVENTS_ASSETS_URL . 'events-admin-page.css',
570
+			[],
571
+			EVENT_ESPRESSO_VERSION
572
+		);
573
+		wp_register_style(
574
+			'ee-cat-admin',
575
+			EVENTS_ASSETS_URL . 'ee-cat-admin.css',
576
+			[],
577
+			EVENT_ESPRESSO_VERSION
578
+		);
579
+		wp_enqueue_style('events-admin-css');
580
+		wp_enqueue_style('ee-cat-admin');
581
+		// scripts
582
+		wp_register_script(
583
+			'event_editor_js',
584
+			EVENTS_ASSETS_URL . 'event_editor.js',
585
+			['ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'],
586
+			EVENT_ESPRESSO_VERSION,
587
+			true
588
+		);
589
+	}
590
+
591
+
592
+	/**
593
+	 * Enqueuing scripts and styles specific to this view
594
+	 */
595
+	public function load_scripts_styles_create_new()
596
+	{
597
+		$this->load_scripts_styles_edit();
598
+	}
599
+
600
+
601
+	/**
602
+	 * Enqueuing scripts and styles specific to this view
603
+	 */
604
+	public function load_scripts_styles_edit()
605
+	{
606
+		// styles
607
+		wp_enqueue_style('espresso-ui-theme');
608
+		wp_register_style(
609
+			'event-editor-css',
610
+			EVENTS_ASSETS_URL . 'event-editor.css',
611
+			['ee-admin-css'],
612
+			EVENT_ESPRESSO_VERSION
613
+		);
614
+		wp_enqueue_style('event-editor-css');
615
+		// scripts
616
+		if (! $this->admin_config->useAdvancedEditor()) {
617
+			wp_register_script(
618
+				'event-datetime-metabox',
619
+				EVENTS_ASSETS_URL . 'event-datetime-metabox.js',
620
+				['event_editor_js', 'ee-datepicker'],
621
+				EVENT_ESPRESSO_VERSION
622
+			);
623
+			wp_enqueue_script('event-datetime-metabox');
624
+		}
625
+	}
626
+
627
+
628
+	/**
629
+	 * Populating the _views property for the category list table view.
630
+	 */
631
+	protected function _set_list_table_views_category_list()
632
+	{
633
+		$this->_views = [
634
+			'all' => [
635
+				'slug'        => 'all',
636
+				'label'       => esc_html__('All', 'event_espresso'),
637
+				'count'       => 0,
638
+				'bulk_action' => [
639
+					'delete_categories' => esc_html__('Delete Permanently', 'event_espresso'),
640
+				],
641
+			],
642
+		];
643
+	}
644
+
645
+
646
+	/**
647
+	 * For adding anything that fires on the admin_init hook for any route within this admin page group.
648
+	 */
649
+	public function admin_init()
650
+	{
651
+		EE_Registry::$i18n_js_strings['image_confirm'] = esc_html__(
652
+			'Do you really want to delete this image? Please remember to update your event to complete the removal.',
653
+			'event_espresso'
654
+		);
655
+	}
656
+
657
+
658
+	/**
659
+	 * For adding anything that should be triggered on the admin_notices hook for any route within this admin page
660
+	 * group.
661
+	 */
662
+	public function admin_notices()
663
+	{
664
+	}
665
+
666
+
667
+	/**
668
+	 * For adding anything that should be triggered on the `admin_print_footer_scripts` hook for any route within
669
+	 * this admin page group.
670
+	 */
671
+	public function admin_footer_scripts()
672
+	{
673
+	}
674
+
675
+
676
+	/**
677
+	 * Call this function to verify if an event is public and has tickets for sale.  If it does, then we need to show a
678
+	 * warning (via EE_Error::add_error());
679
+	 *
680
+	 * @param EE_Event $event Event object
681
+	 * @param string   $req_type
682
+	 * @return void
683
+	 * @throws EE_Error
684
+	 * @throws ReflectionException
685
+	 */
686
+	public function verify_event_edit($event = null, $req_type = '')
687
+	{
688
+		// don't need to do this when processing
689
+		if (! empty($req_type)) {
690
+			return;
691
+		}
692
+		// no event?
693
+		if (! $event instanceof EE_Event) {
694
+			$event = $this->_cpt_model_obj;
695
+		}
696
+		// STILL no event?
697
+		if (! $event instanceof EE_Event) {
698
+			return;
699
+		}
700
+		$orig_status = $event->status();
701
+		// first check if event is active.
702
+		if (
703
+			$orig_status === EEM_Event::cancelled
704
+			|| $orig_status === EEM_Event::postponed
705
+			|| $event->is_expired()
706
+			|| $event->is_inactive()
707
+		) {
708
+			return;
709
+		}
710
+		// made it here so it IS active... next check that any of the tickets are sold.
711
+		if ($event->is_sold_out(true)) {
712
+			if ($orig_status !== EEM_Event::sold_out && $event->status() !== $orig_status) {
713
+				EE_Error::add_attention(
714
+					sprintf(
715
+						esc_html__(
716
+							'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.',
717
+							'event_espresso'
718
+						),
719
+						EEH_Template::pretty_status(EEM_Event::sold_out, false, 'sentence')
720
+					)
721
+				);
722
+			}
723
+			return;
724
+		}
725
+		if ($orig_status === EEM_Event::sold_out) {
726
+			EE_Error::add_attention(
727
+				sprintf(
728
+					esc_html__(
729
+						'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.',
730
+						'event_espresso'
731
+					),
732
+					EEH_Template::pretty_status($event->status(), false, 'sentence')
733
+				)
734
+			);
735
+		}
736
+		// now we need to determine if the event has any tickets on sale.  If not then we dont' show the error
737
+		if (! $event->tickets_on_sale()) {
738
+			return;
739
+		}
740
+		// made it here so show warning
741
+		$this->_edit_event_warning();
742
+	}
743
+
744
+
745
+	/**
746
+	 * This is the text used for when an event is being edited that is public and has tickets for sale.
747
+	 * When needed, hook this into a EE_Error::add_error() notice.
748
+	 *
749
+	 * @access protected
750
+	 * @return void
751
+	 */
752
+	protected function _edit_event_warning()
753
+	{
754
+		// we don't want to add warnings during these requests
755
+		if ($this->request->getRequestParam('action') === 'editpost') {
756
+			return;
757
+		}
758
+		EE_Error::add_attention(
759
+			sprintf(
760
+				esc_html__(
761
+					'Your event is open for registration. Making changes may disrupt any transactions in progress. %sLearn more%s',
762
+					'event_espresso'
763
+				),
764
+				'<a class="espresso-help-tab-lnk">',
765
+				'</a>'
766
+			)
767
+		);
768
+	}
769
+
770
+
771
+	/**
772
+	 * When a user is creating a new event, notify them if they haven't set their timezone.
773
+	 * Otherwise, do the normal logic
774
+	 *
775
+	 * @return void
776
+	 * @throws EE_Error
777
+	 * @throws InvalidArgumentException
778
+	 * @throws InvalidDataTypeException
779
+	 * @throws InvalidInterfaceException
780
+	 */
781
+	protected function _create_new_cpt_item()
782
+	{
783
+		$has_timezone_string = get_option('timezone_string');
784
+		// only nag them about setting their timezone if it's their first event, and they haven't already done it
785
+		if (! $has_timezone_string && ! EEM_Event::instance()->exists([])) {
786
+			EE_Error::add_attention(
787
+				sprintf(
788
+					esc_html__(
789
+						'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',
790
+						'event_espresso'
791
+					),
792
+					'<br>',
793
+					'<select id="timezone_string" name="timezone_string" aria-describedby="timezone-description">'
794
+					. EEH_DTT_Helper::wp_timezone_choice('', EEH_DTT_Helper::get_user_locale())
795
+					. '</select>',
796
+					'<button class="button button--secondary timezone-submit">',
797
+					'</button><span class="spinner"></span>'
798
+				),
799
+				__FILE__,
800
+				__FUNCTION__,
801
+				__LINE__
802
+			);
803
+		}
804
+		parent::_create_new_cpt_item();
805
+	}
806
+
807
+
808
+	/**
809
+	 * Sets the _views property for the default route in this admin page group.
810
+	 */
811
+	protected function _set_list_table_views_default()
812
+	{
813
+		$this->_views = [
814
+			'all'   => [
815
+				'slug'        => 'all',
816
+				'label'       => esc_html__('View All Events', 'event_espresso'),
817
+				'count'       => 0,
818
+				'bulk_action' => [
819
+					'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
820
+				],
821
+			],
822
+			'draft' => [
823
+				'slug'        => 'draft',
824
+				'label'       => esc_html__('Draft', 'event_espresso'),
825
+				'count'       => 0,
826
+				'bulk_action' => [
827
+					'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
828
+				],
829
+			],
830
+		];
831
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) {
832
+			$this->_views['trash'] = [
833
+				'slug'        => 'trash',
834
+				'label'       => esc_html__('Trash', 'event_espresso'),
835
+				'count'       => 0,
836
+				'bulk_action' => [
837
+					'restore_events' => esc_html__('Restore From Trash', 'event_espresso'),
838
+					'delete_events'  => esc_html__('Delete Permanently', 'event_espresso'),
839
+				],
840
+			];
841
+		}
842
+	}
843
+
844
+
845
+	/**
846
+	 * Provides the legend item array for the default list table view.
847
+	 *
848
+	 * @return array
849
+	 * @throws EE_Error
850
+	 * @throws EE_Error
851
+	 */
852
+	protected function _event_legend_items()
853
+	{
854
+		$items    = [
855
+			'view_details'   => [
856
+				'class' => 'dashicons dashicons-visibility',
857
+				'desc'  => esc_html__('View Event', 'event_espresso'),
858
+			],
859
+			'edit_event'     => [
860
+				'class' => 'dashicons dashicons-calendar-alt',
861
+				'desc'  => esc_html__('Edit Event Details', 'event_espresso'),
862
+			],
863
+			'view_attendees' => [
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 = [
870
+			'sold_out_status'  => [
871
+				'class' => 'ee-status-legend ee-status-bg--' . EE_Datetime::sold_out,
872
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::sold_out, false, 'sentence'),
873
+			],
874
+			'active_status'    => [
875
+				'class' => 'ee-status-legend ee-status-bg--' . EE_Datetime::active,
876
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::active, false, 'sentence'),
877
+			],
878
+			'upcoming_status'  => [
879
+				'class' => 'ee-status-legend ee-status-bg--' . EE_Datetime::upcoming,
880
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::upcoming, false, 'sentence'),
881
+			],
882
+			'postponed_status' => [
883
+				'class' => 'ee-status-legend ee-status-bg--' . EE_Datetime::postponed,
884
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::postponed, false, 'sentence'),
885
+			],
886
+			'cancelled_status' => [
887
+				'class' => 'ee-status-legend ee-status-bg--' . EE_Datetime::cancelled,
888
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::cancelled, false, 'sentence'),
889
+			],
890
+			'expired_status'   => [
891
+				'class' => 'ee-status-legend ee-status-bg--' . EE_Datetime::expired,
892
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::expired, false, 'sentence'),
893
+			],
894
+			'inactive_status'  => [
895
+				'class' => 'ee-status-legend ee-status-bg--' . 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
+	 * @throws EE_Error
907
+	 * @throws InvalidArgumentException
908
+	 * @throws InvalidDataTypeException
909
+	 * @throws InvalidInterfaceException
910
+	 * @throws ReflectionException
911
+	 */
912
+	private function _event_model()
913
+	{
914
+		if (! $this->_event_model instanceof EEM_Event) {
915
+			$this->_event_model = EE_Registry::instance()->load_model('Event');
916
+		}
917
+		return $this->_event_model;
918
+	}
919
+
920
+
921
+	/**
922
+	 * Adds extra buttons to the WP CPT permalink field row.
923
+	 * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter.
924
+	 *
925
+	 * @param string $return    the current html
926
+	 * @param int    $id        the post id for the page
927
+	 * @param string $new_title What the title is
928
+	 * @param string $new_slug  what the slug is
929
+	 * @return string            The new html string for the permalink area
930
+	 */
931
+	public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug)
932
+	{
933
+		// make sure this is only when editing
934
+		if (! empty($id)) {
935
+			$post = get_post($id);
936
+			$return .= '<a class="button button--small button--secondary" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#"  tabindex="-1">'
937
+					   . esc_html__('Shortcode', 'event_espresso')
938
+					   . '</a> ';
939
+			$return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id='
940
+					   . $post->ID
941
+					   . ']">';
942
+		}
943
+		return $return;
944
+	}
945
+
946
+
947
+	/**
948
+	 * _events_overview_list_table
949
+	 * This contains the logic for showing the events_overview list
950
+	 *
951
+	 * @access protected
952
+	 * @return void
953
+	 * @throws DomainException
954
+	 * @throws EE_Error
955
+	 * @throws InvalidArgumentException
956
+	 * @throws InvalidDataTypeException
957
+	 * @throws InvalidInterfaceException
958
+	 */
959
+	protected function _events_overview_list_table()
960
+	{
961
+		$after_list_table                           = [];
962
+		$links_html = EEH_HTML::div('', '', 'ee-admin-section ee-layout-stack');
963
+		$links_html .= EEH_HTML::h3(esc_html__('Links', 'event_espresso'));
964
+		$links_html .= EEH_HTML::div(
965
+			EEH_Template::get_button_or_link(
966
+				get_post_type_archive_link('espresso_events'),
967
+				esc_html__('View Event Archive Page', 'event_espresso'),
968
+				'button button--small button--secondary'
969
+			),
970
+			'',
971
+			'ee-admin-button-row ee-admin-button-row--align-start'
972
+		);
973
+		$links_html .= EEH_HTML::divx();
974
+
975
+		$after_list_table['view_event_list_button'] = $links_html;
976
+
977
+		$after_list_table['legend'] = $this->_display_legend($this->_event_legend_items());
978
+		$this->_admin_page_title                    .= ' ' . $this->get_action_link_or_button(
979
+			'create_new',
980
+			'add',
981
+			[],
982
+			'add-new-h2'
983
+		);
984
+
985
+		$this->_template_args['after_list_table']   = array_merge(
986
+			(array) $this->_template_args['after_list_table'],
987
+			$after_list_table
988
+		);
989
+		$this->display_admin_list_table_page_with_no_sidebar();
990
+	}
991
+
992
+
993
+	/**
994
+	 * this allows for extra misc actions in the default WP publish box
995
+	 *
996
+	 * @return void
997
+	 * @throws DomainException
998
+	 * @throws EE_Error
999
+	 * @throws InvalidArgumentException
1000
+	 * @throws InvalidDataTypeException
1001
+	 * @throws InvalidInterfaceException
1002
+	 * @throws ReflectionException
1003
+	 */
1004
+	public function extra_misc_actions_publish_box()
1005
+	{
1006
+		$this->_generate_publish_box_extra_content();
1007
+	}
1008
+
1009
+
1010
+	/**
1011
+	 * This is hooked into the WordPress do_action('save_post') hook and runs after the custom post type has been
1012
+	 * saved.
1013
+	 * Typically you would use this to save any additional data.
1014
+	 * Keep in mind also that "save_post" runs on EVERY post update to the database.
1015
+	 * ALSO very important.  When a post transitions from scheduled to published,
1016
+	 * the save_post action is fired but you will NOT have any _POST data containing any extra info you may have from
1017
+	 * other meta saves. So MAKE sure that you handle this accordingly.
1018
+	 *
1019
+	 * @access protected
1020
+	 * @abstract
1021
+	 * @param string $post_id The ID of the cpt that was saved (so you can link relationally)
1022
+	 * @param object $post    The post object of the cpt that was saved.
1023
+	 * @return void
1024
+	 * @throws EE_Error
1025
+	 * @throws InvalidArgumentException
1026
+	 * @throws InvalidDataTypeException
1027
+	 * @throws InvalidInterfaceException
1028
+	 * @throws ReflectionException
1029
+	 */
1030
+	protected function _insert_update_cpt_item($post_id, $post)
1031
+	{
1032
+		if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') {
1033
+			// get out we're not processing an event save.
1034
+			return;
1035
+		}
1036
+		$event_values = [
1037
+			'EVT_member_only'     => $this->request->getRequestParam('member_only', false, 'bool'),
1038
+			'EVT_allow_overflow'  => $this->request->getRequestParam('EVT_allow_overflow', false, 'bool'),
1039
+			'EVT_timezone_string' => $this->request->getRequestParam('timezone_string'),
1040
+		];
1041
+		// check if the new EDTR reg options meta box is being used, and if so, don't run updates for legacy version
1042
+		if (! $this->admin_config->useAdvancedEditor() || ! $this->feature->allowed('use_reg_options_meta_box')) {
1043
+			$event_values['EVT_display_ticket_selector']     = $this->request->getRequestParam(
1044
+				'display_ticket_selector',
1045
+				false,
1046
+				'bool'
1047
+			);
1048
+			$event_values['EVT_additional_limit']            = min(
1049
+				apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255),
1050
+				$this->request->getRequestParam('additional_limit', null, 'int')
1051
+			);
1052
+			$event_values['EVT_default_registration_status'] = $this->request->getRequestParam(
1053
+				'EVT_default_registration_status',
1054
+				EE_Registry::instance()->CFG->registration->default_STS_ID
1055
+			);
1056
+
1057
+			$event_values['EVT_external_URL'] = $this->request->getRequestParam('externalURL');
1058
+			$event_values['EVT_phone']        = $this->request->getRequestParam('event_phone');
1059
+			$event_values['EVT_display_desc'] = $this->request->getRequestParam('display_desc', false, 'bool');
1060
+		}
1061
+		// update event
1062
+		$success = $this->_event_model()->update_by_ID($event_values, $post_id);
1063
+		// get event_object for other metaboxes...
1064
+		// though it would seem to make sense to just use $this->_event_model()->get_one_by_ID( $post_id )..
1065
+		// i have to setup where conditions to override the filters in the model
1066
+		// that filter out autodraft and inherit statuses so we GET the inherit id!
1067
+		$event = $this->_event_model()->get_one(
1068
+			[
1069
+				[
1070
+					$this->_event_model()->primary_key_name() => $post_id,
1071
+					'OR'                                      => [
1072
+						'status'   => $post->post_status,
1073
+						// if trying to "Publish" a sold out event, it's status will get switched back to "sold_out" in the db,
1074
+						// but the returned object here has a status of "publish", so use the original post status as well
1075
+						'status*1' => $this->request->getRequestParam('original_post_status'),
1076
+					],
1077
+				],
1078
+			]
1079
+		);
1080
+
1081
+		// the following are default callbacks for event attachment updates
1082
+		// that can be overridden by caffeinated functionality and/or addons.
1083
+		$event_update_callbacks = [];
1084
+		if (! $this->admin_config->useAdvancedEditor()) {
1085
+			$event_update_callbacks['_default_venue_update']   = [$this, '_default_venue_update'];
1086
+			$event_update_callbacks['_default_tickets_update'] = [$this, '_default_tickets_update'];
1087
+		}
1088
+		$event_update_callbacks = apply_filters(
1089
+			'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',
1090
+			$event_update_callbacks
1091
+		);
1092
+
1093
+		$att_success = true;
1094
+		foreach ($event_update_callbacks as $e_callback) {
1095
+			$_success = is_callable($e_callback)
1096
+				? $e_callback($event, $this->request->requestParams())
1097
+				: false;
1098
+			// if ANY of these updates fail then we want the appropriate global error message
1099
+			$att_success = $_success !== false ? $att_success : false;
1100
+		}
1101
+		// any errors?
1102
+		if ($success && $att_success === false) {
1103
+			EE_Error::add_error(
1104
+				esc_html__(
1105
+					'Event Details saved successfully but something went wrong with saving attachments.',
1106
+					'event_espresso'
1107
+				),
1108
+				__FILE__,
1109
+				__FUNCTION__,
1110
+				__LINE__
1111
+			);
1112
+		} elseif ($success === false) {
1113
+			EE_Error::add_error(
1114
+				esc_html__('Event Details did not save successfully.', 'event_espresso'),
1115
+				__FILE__,
1116
+				__FUNCTION__,
1117
+				__LINE__
1118
+			);
1119
+		}
1120
+	}
1121
+
1122
+
1123
+	/**
1124
+	 * @param int $post_id
1125
+	 * @param int $revision_id
1126
+	 * @throws EE_Error
1127
+	 * @throws EE_Error
1128
+	 * @throws ReflectionException
1129
+	 * @see parent::restore_item()
1130
+	 */
1131
+	protected function _restore_cpt_item($post_id, $revision_id)
1132
+	{
1133
+		// copy existing event meta to new post
1134
+		$post_evt = $this->_event_model()->get_one_by_ID($post_id);
1135
+		if ($post_evt instanceof EE_Event) {
1136
+			// meta revision restore
1137
+			$post_evt->restore_revision($revision_id);
1138
+			// related objs restore
1139
+			$post_evt->restore_revision($revision_id, ['Venue', 'Datetime', 'Price']);
1140
+		}
1141
+	}
1142
+
1143
+
1144
+	/**
1145
+	 * Attach the venue to the Event
1146
+	 *
1147
+	 * @param EE_Event $event Event Object to add the venue to
1148
+	 * @param array    $data  The request data from the form
1149
+	 * @return bool           Success or fail.
1150
+	 * @throws EE_Error
1151
+	 * @throws ReflectionException
1152
+	 */
1153
+	protected function _default_venue_update(EE_Event $event, $data)
1154
+	{
1155
+		require_once(EE_MODELS . 'EEM_Venue.model.php');
1156
+		$venue_model = EE_Registry::instance()->load_model('Venue');
1157
+		$venue_id    = ! empty($data['venue_id']) ? $data['venue_id'] : null;
1158
+		// very important.  If we don't have a venue name...
1159
+		// then we'll get out because not necessary to create empty venue
1160
+		if (empty($data['venue_title'])) {
1161
+			return false;
1162
+		}
1163
+		$venue_array = [
1164
+			'VNU_wp_user'         => $event->get('EVT_wp_user'),
1165
+			'VNU_name'            => ! empty($data['venue_title']) ? $data['venue_title'] : null,
1166
+			'VNU_desc'            => ! empty($data['venue_description']) ? $data['venue_description'] : null,
1167
+			'VNU_identifier'      => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : null,
1168
+			'VNU_short_desc'      => ! empty($data['venue_short_description'])
1169
+				? $data['venue_short_description']
1170
+				: null,
1171
+			'VNU_address'         => ! empty($data['address']) ? $data['address'] : null,
1172
+			'VNU_address2'        => ! empty($data['address2']) ? $data['address2'] : null,
1173
+			'VNU_city'            => ! empty($data['city']) ? $data['city'] : null,
1174
+			'STA_ID'              => ! empty($data['state']) ? $data['state'] : null,
1175
+			'CNT_ISO'             => ! empty($data['countries']) ? $data['countries'] : null,
1176
+			'VNU_zip'             => ! empty($data['zip']) ? $data['zip'] : null,
1177
+			'VNU_phone'           => ! empty($data['venue_phone']) ? $data['venue_phone'] : null,
1178
+			'VNU_capacity'        => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : null,
1179
+			'VNU_url'             => ! empty($data['venue_url']) ? $data['venue_url'] : null,
1180
+			'VNU_virtual_phone'   => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : null,
1181
+			'VNU_virtual_url'     => ! empty($data['virtual_url']) ? $data['virtual_url'] : null,
1182
+			'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0,
1183
+			'status'              => 'publish',
1184
+		];
1185
+		// if we've got the venue_id then we're just updating the existing venue so let's do that and then get out.
1186
+		if (! empty($venue_id)) {
1187
+			$update_where  = [$venue_model->primary_key_name() => $venue_id];
1188
+			$rows_affected = $venue_model->update($venue_array, [$update_where]);
1189
+			// we've gotta make sure that the venue is always attached to a revision..
1190
+			// add_relation_to should take care of making sure that the relation is already present.
1191
+			$event->_add_relation_to($venue_id, 'Venue');
1192
+			return $rows_affected > 0;
1193
+		}
1194
+		// we insert the venue
1195
+		$venue_id = $venue_model->insert($venue_array);
1196
+		$event->_add_relation_to($venue_id, 'Venue');
1197
+		return ! empty($venue_id);
1198
+		// when we have the ancestor come in it's already been handled by the revision save.
1199
+	}
1200
+
1201
+
1202
+	/**
1203
+	 * Handles saving everything related to Tickets (datetimes, tickets, prices)
1204
+	 *
1205
+	 * @param EE_Event $event The Event object we're attaching data to
1206
+	 * @param array    $data  The request data from the form
1207
+	 * @return array
1208
+	 * @throws EE_Error
1209
+	 * @throws ReflectionException
1210
+	 * @throws Exception
1211
+	 */
1212
+	protected function _default_tickets_update(EE_Event $event, $data)
1213
+	{
1214
+		if ($this->admin_config->useAdvancedEditor()) {
1215
+			return [];
1216
+		}
1217
+		$datetime       = null;
1218
+		$saved_tickets  = [];
1219
+		$event_timezone = $event->get_timezone();
1220
+		$date_formats   = ['Y-m-d', 'h:i a'];
1221
+		foreach ($data['edit_event_datetimes'] as $row => $datetime_data) {
1222
+			// trim all values to ensure any excess whitespace is removed.
1223
+			$datetime_data                = array_map('trim', $datetime_data);
1224
+			$datetime_data['DTT_EVT_end'] =
1225
+				isset($datetime_data['DTT_EVT_end']) && ! empty($datetime_data['DTT_EVT_end'])
1226
+					? $datetime_data['DTT_EVT_end']
1227
+					: $datetime_data['DTT_EVT_start'];
1228
+			$datetime_values              = [
1229
+				'DTT_ID'        => ! empty($datetime_data['DTT_ID']) ? $datetime_data['DTT_ID'] : null,
1230
+				'DTT_EVT_start' => $datetime_data['DTT_EVT_start'],
1231
+				'DTT_EVT_end'   => $datetime_data['DTT_EVT_end'],
1232
+				'DTT_reg_limit' => empty($datetime_data['DTT_reg_limit']) ? EE_INF : $datetime_data['DTT_reg_limit'],
1233
+				'DTT_order'     => $row,
1234
+			];
1235
+			// if we have an id then let's get existing object first and then set the new values.
1236
+			//  Otherwise we instantiate a new object for save.
1237
+			if (! empty($datetime_data['DTT_ID'])) {
1238
+				$datetime = EEM_Datetime::instance($event_timezone)->get_one_by_ID($datetime_data['DTT_ID']);
1239
+				if (! $datetime instanceof EE_Datetime) {
1240
+					throw new RuntimeException(
1241
+						sprintf(
1242
+							esc_html__(
1243
+								'Something went wrong! A valid Datetime could not be retrieved from the database using the supplied ID: %1$d',
1244
+								'event_espresso'
1245
+							),
1246
+							$datetime_data['DTT_ID']
1247
+						)
1248
+					);
1249
+				}
1250
+				$datetime->set_date_format($date_formats[0]);
1251
+				$datetime->set_time_format($date_formats[1]);
1252
+				foreach ($datetime_values as $field => $value) {
1253
+					$datetime->set($field, $value);
1254
+				}
1255
+			} else {
1256
+				$datetime = EE_Datetime::new_instance($datetime_values, $event_timezone, $date_formats);
1257
+			}
1258
+			if (! $datetime instanceof EE_Datetime) {
1259
+				throw new RuntimeException(
1260
+					sprintf(
1261
+						esc_html__(
1262
+							'Something went wrong! A valid Datetime could not be generated or retrieved using the supplied data: %1$s',
1263
+							'event_espresso'
1264
+						),
1265
+						print_r($datetime_values, true)
1266
+					)
1267
+				);
1268
+			}
1269
+			// before going any further make sure our dates are setup correctly
1270
+			// so that the end date is always equal or greater than the start date.
1271
+			if ($datetime->get_raw('DTT_EVT_start') > $datetime->get_raw('DTT_EVT_end')) {
1272
+				$datetime->set('DTT_EVT_end', $datetime->get('DTT_EVT_start'));
1273
+				$datetime = EEH_DTT_Helper::date_time_add($datetime, 'DTT_EVT_end', 'days');
1274
+			}
1275
+			$datetime->save();
1276
+			$event->_add_relation_to($datetime, 'Datetime');
1277
+		}
1278
+		// no datetimes get deleted so we don't do any of that logic here.
1279
+		// update tickets next
1280
+		$old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : [];
1281
+
1282
+		// set up some default start and end dates in case those are not present in the incoming data
1283
+		$default_start_date = new DateTime('now', new DateTimeZone($event->get_timezone()));
1284
+		$default_start_date = $default_start_date->format($date_formats[0] . ' ' . $date_formats[1]);
1285
+		// use the start date of the first datetime for the end date
1286
+		$first_datetime   = $event->first_datetime();
1287
+		$default_end_date = $first_datetime->start_date_and_time($date_formats[0], $date_formats[1]);
1288
+
1289
+		// now process the incoming data
1290
+		foreach ($data['edit_tickets'] as $row => $ticket_data) {
1291
+			$update_prices = false;
1292
+			$ticket_price  = isset($data['edit_prices'][ $row ][1]['PRC_amount'])
1293
+				? $data['edit_prices'][ $row ][1]['PRC_amount']
1294
+				: 0;
1295
+			// trim inputs to ensure any excess whitespace is removed.
1296
+			$ticket_data   = array_map('trim', $ticket_data);
1297
+			$ticket_values = [
1298
+				'TKT_ID'          => ! empty($ticket_data['TKT_ID']) ? $ticket_data['TKT_ID'] : null,
1299
+				'TTM_ID'          => ! empty($ticket_data['TTM_ID']) ? $ticket_data['TTM_ID'] : 0,
1300
+				'TKT_name'        => ! empty($ticket_data['TKT_name']) ? $ticket_data['TKT_name'] : '',
1301
+				'TKT_description' => ! empty($ticket_data['TKT_description']) ? $ticket_data['TKT_description'] : '',
1302
+				'TKT_start_date'  => ! empty($ticket_data['TKT_start_date'])
1303
+					? $ticket_data['TKT_start_date']
1304
+					: $default_start_date,
1305
+				'TKT_end_date'    => ! empty($ticket_data['TKT_end_date'])
1306
+					? $ticket_data['TKT_end_date']
1307
+					: $default_end_date,
1308
+				'TKT_qty'         => ! empty($ticket_data['TKT_qty'])
1309
+									 || (isset($ticket_data['TKT_qty']) && (int) $ticket_data['TKT_qty'] === 0)
1310
+					? $ticket_data['TKT_qty']
1311
+					: EE_INF,
1312
+				'TKT_uses'        => ! empty($ticket_data['TKT_uses'])
1313
+									 || (isset($ticket_data['TKT_uses']) && (int) $ticket_data['TKT_uses'] === 0)
1314
+					? $ticket_data['TKT_uses']
1315
+					: EE_INF,
1316
+				'TKT_min'         => ! empty($ticket_data['TKT_min']) ? $ticket_data['TKT_min'] : 0,
1317
+				'TKT_max'         => ! empty($ticket_data['TKT_max']) ? $ticket_data['TKT_max'] : EE_INF,
1318
+				'TKT_order'       => isset($ticket_data['TKT_order']) ? $ticket_data['TKT_order'] : $row,
1319
+				'TKT_price'       => $ticket_price,
1320
+				'TKT_row'         => $row,
1321
+			];
1322
+			// if this is a default ticket, then we need to set the TKT_ID to 0 and update accordingly,
1323
+			// which means in turn that the prices will become new prices as well.
1324
+			if (isset($ticket_data['TKT_is_default']) && $ticket_data['TKT_is_default']) {
1325
+				$ticket_values['TKT_ID']         = 0;
1326
+				$ticket_values['TKT_is_default'] = 0;
1327
+				$update_prices                   = true;
1328
+			}
1329
+			// if we have a TKT_ID then we need to get that existing TKT_obj and update it
1330
+			// we actually do our saves ahead of adding any relations because its entirely possible that this
1331
+			// ticket didn't get removed or added to any datetime in the session but DID have it's items modified.
1332
+			// keep in mind that if the ticket has been sold (and we have changed pricing information),
1333
+			// then we won't be updating the tkt but instead a new tkt will be created and the old one archived.
1334
+			if (! empty($ticket_data['TKT_ID'])) {
1335
+				$existing_ticket = EEM_Ticket::instance($event_timezone)->get_one_by_ID($ticket_data['TKT_ID']);
1336
+				if (! $existing_ticket instanceof EE_Ticket) {
1337
+					throw new RuntimeException(
1338
+						sprintf(
1339
+							esc_html__(
1340
+								'Something went wrong! A valid Ticket could not be retrieved from the database using the supplied ID: %1$d',
1341
+								'event_espresso'
1342
+							),
1343
+							$ticket_data['TKT_ID']
1344
+						)
1345
+					);
1346
+				}
1347
+				$ticket_sold = $existing_ticket->count_related(
1348
+					'Registration',
1349
+					[
1350
+							[
1351
+								'STS_ID' => [
1352
+									'NOT IN',
1353
+									[EEM_Registration::status_id_incomplete],
1354
+								],
1355
+							],
1356
+						]
1357
+				) > 0;
1358
+				// let's just check the total price for the existing ticket and determine if it matches the new total price.
1359
+				// if they are different then we create a new ticket (if $ticket_sold)
1360
+				// if they aren't different then we go ahead and modify existing ticket.
1361
+				$create_new_ticket = $ticket_sold
1362
+									 && $ticket_price !== $existing_ticket->price()
1363
+									 && ! $existing_ticket->deleted();
1364
+				$existing_ticket->set_date_format($date_formats[0]);
1365
+				$existing_ticket->set_time_format($date_formats[1]);
1366
+				// set new values
1367
+				foreach ($ticket_values as $field => $value) {
1368
+					if ($field == 'TKT_qty') {
1369
+						$existing_ticket->set_qty($value);
1370
+					} elseif ($field == 'TKT_price') {
1371
+						$existing_ticket->set('TKT_price', $ticket_price);
1372
+					} else {
1373
+						$existing_ticket->set($field, $value);
1374
+					}
1375
+				}
1376
+				$ticket = $existing_ticket;
1377
+				// if $create_new_ticket is false then we can safely update the existing ticket.
1378
+				//  Otherwise we have to create a new ticket.
1379
+				if ($create_new_ticket) {
1380
+					// archive the old ticket first
1381
+					$existing_ticket->set('TKT_deleted', 1);
1382
+					$existing_ticket->save();
1383
+					// make sure this ticket is still recorded in our $saved_tickets
1384
+					// so we don't run it through the regular trash routine.
1385
+					$saved_tickets[ $existing_ticket->ID() ] = $existing_ticket;
1386
+					// create new ticket that's a copy of the existing except,
1387
+					// (a new id of course and not archived) AND has the new TKT_price associated with it.
1388
+					$new_ticket = clone $existing_ticket;
1389
+					$new_ticket->set('TKT_ID', 0);
1390
+					$new_ticket->set('TKT_deleted', 0);
1391
+					$new_ticket->set('TKT_sold', 0);
1392
+					// now we need to make sure that $new prices are created as well and attached to new ticket.
1393
+					$update_prices = true;
1394
+					$ticket        = $new_ticket;
1395
+				}
1396
+			} else {
1397
+				// no TKT_id so a new ticket
1398
+				$ticket_values['TKT_price'] = $ticket_price;
1399
+				$ticket                     = EE_Ticket::new_instance($ticket_values, $event_timezone, $date_formats);
1400
+				$update_prices              = true;
1401
+			}
1402
+			if (! $ticket instanceof EE_Ticket) {
1403
+				throw new RuntimeException(
1404
+					sprintf(
1405
+						esc_html__(
1406
+							'Something went wrong! A valid Ticket could not be generated or retrieved using the supplied data: %1$s',
1407
+							'event_espresso'
1408
+						),
1409
+						print_r($ticket_values, true)
1410
+					)
1411
+				);
1412
+			}
1413
+			// cap ticket qty by datetime reg limits
1414
+			$ticket->set_qty(min($ticket->qty(), $ticket->qty('reg_limit')));
1415
+			// update ticket.
1416
+			$ticket->save();
1417
+			// before going any further make sure our dates are setup correctly
1418
+			// so that the end date is always equal or greater than the start date.
1419
+			if ($ticket->get_raw('TKT_start_date') > $ticket->get_raw('TKT_end_date')) {
1420
+				$ticket->set('TKT_end_date', $ticket->get('TKT_start_date'));
1421
+				$ticket = EEH_DTT_Helper::date_time_add($ticket, 'TKT_end_date', 'days');
1422
+				$ticket->save();
1423
+			}
1424
+			// initially let's add the ticket to the datetime
1425
+			$datetime->_add_relation_to($ticket, 'Ticket');
1426
+			$saved_tickets[ $ticket->ID() ] = $ticket;
1427
+			// add prices to ticket
1428
+			$this->_add_prices_to_ticket($data['edit_prices'][ $row ], $ticket, $update_prices);
1429
+		}
1430
+		// however now we need to handle permanently deleting tickets via the ui.
1431
+		//  Keep in mind that the ui does not allow deleting/archiving tickets that have ticket sold.
1432
+		//  However, it does allow for deleting tickets that have no tickets sold,
1433
+		// in which case we want to get rid of permanently because there is no need to save in db.
1434
+		$old_tickets     = isset($old_tickets[0]) && $old_tickets[0] === '' ? [] : $old_tickets;
1435
+		$tickets_removed = array_diff($old_tickets, array_keys($saved_tickets));
1436
+		foreach ($tickets_removed as $id) {
1437
+			$id = absint($id);
1438
+			// get the ticket for this id
1439
+			$ticket_to_remove = EEM_Ticket::instance()->get_one_by_ID($id);
1440
+			if (! $ticket_to_remove instanceof EE_Ticket) {
1441
+				continue;
1442
+			}
1443
+			// need to get all the related datetimes on this ticket and remove from every single one of them
1444
+			// (remember this process can ONLY kick off if there are NO tickets sold)
1445
+			$related_datetimes = $ticket_to_remove->get_many_related('Datetime');
1446
+			foreach ($related_datetimes as $related_datetime) {
1447
+				$ticket_to_remove->_remove_relation_to($related_datetime, 'Datetime');
1448
+			}
1449
+			// need to do the same for prices (except these prices can also be deleted because again,
1450
+			// tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived))
1451
+			$ticket_to_remove->delete_related_permanently('Price');
1452
+			// finally let's delete this ticket
1453
+			// (which should not be blocked at this point b/c we've removed all our relationships)
1454
+			$ticket_to_remove->delete_permanently();
1455
+		}
1456
+		return [$datetime, $saved_tickets];
1457
+	}
1458
+
1459
+
1460
+	/**
1461
+	 * This attaches a list of given prices to a ticket.
1462
+	 * Note we dont' have to worry about ever removing relationships (or archiving prices)
1463
+	 * because if there is a change in price information on a ticket, a new ticket is created anyways
1464
+	 * so the archived ticket will retain the old price info and prices are automatically "archived" via the ticket.
1465
+	 *
1466
+	 * @access  private
1467
+	 * @param array     $prices_data Array of prices from the form.
1468
+	 * @param EE_Ticket $ticket      EE_Ticket object that prices are being attached to.
1469
+	 * @param bool      $new_prices  Whether attach existing incoming prices or create new ones.
1470
+	 * @return  void
1471
+	 * @throws EE_Error
1472
+	 * @throws ReflectionException
1473
+	 */
1474
+	private function _add_prices_to_ticket($prices_data, EE_Ticket $ticket, $new_prices = false)
1475
+	{
1476
+		$timezone = $ticket->get_timezone();
1477
+		foreach ($prices_data as $row => $price_data) {
1478
+			$price_values = [
1479
+				'PRC_ID'         => ! empty($price_data['PRC_ID']) ? $price_data['PRC_ID'] : null,
1480
+				'PRT_ID'         => ! empty($price_data['PRT_ID']) ? $price_data['PRT_ID'] : null,
1481
+				'PRC_amount'     => ! empty($price_data['PRC_amount']) ? $price_data['PRC_amount'] : 0,
1482
+				'PRC_name'       => ! empty($price_data['PRC_name']) ? $price_data['PRC_name'] : '',
1483
+				'PRC_desc'       => ! empty($price_data['PRC_desc']) ? $price_data['PRC_desc'] : '',
1484
+				'PRC_is_default' => 0, // make sure prices are NOT set as default from this context
1485
+				'PRC_order'      => $row,
1486
+			];
1487
+			if ($new_prices || empty($price_values['PRC_ID'])) {
1488
+				$price_values['PRC_ID'] = 0;
1489
+				$price                  = EE_Price::new_instance($price_values, $timezone);
1490
+			} else {
1491
+				$price = EEM_Price::instance($timezone)->get_one_by_ID($price_data['PRC_ID']);
1492
+				// update this price with new values
1493
+				foreach ($price_values as $field => $new_price) {
1494
+					$price->set($field, $new_price);
1495
+				}
1496
+			}
1497
+			if (! $price instanceof EE_Price) {
1498
+				throw new RuntimeException(
1499
+					sprintf(
1500
+						esc_html__(
1501
+							'Something went wrong! A valid Price could not be generated or retrieved using the supplied data: %1$s',
1502
+							'event_espresso'
1503
+						),
1504
+						print_r($price_values, true)
1505
+					)
1506
+				);
1507
+			}
1508
+			$price->save();
1509
+			$ticket->_add_relation_to($price, 'Price');
1510
+		}
1511
+	}
1512
+
1513
+
1514
+	/**
1515
+	 * Add in our autosave ajax handlers
1516
+	 *
1517
+	 */
1518
+	protected function _ee_autosave_create_new()
1519
+	{
1520
+	}
1521
+
1522
+
1523
+	/**
1524
+	 * More autosave handlers.
1525
+	 */
1526
+	protected function _ee_autosave_edit()
1527
+	{
1528
+	}
1529
+
1530
+
1531
+	/**
1532
+	 * @throws EE_Error
1533
+	 * @throws ReflectionException
1534
+	 */
1535
+	private function _generate_publish_box_extra_content()
1536
+	{
1537
+		// load formatter helper
1538
+		// args for getting related registrations
1539
+		$approved_query_args        = [
1540
+			[
1541
+				'REG_deleted' => 0,
1542
+				'STS_ID'      => EEM_Registration::status_id_approved,
1543
+			],
1544
+		];
1545
+		$not_approved_query_args    = [
1546
+			[
1547
+				'REG_deleted' => 0,
1548
+				'STS_ID'      => EEM_Registration::status_id_not_approved,
1549
+			],
1550
+		];
1551
+		$pending_payment_query_args = [
1552
+			[
1553
+				'REG_deleted' => 0,
1554
+				'STS_ID'      => EEM_Registration::status_id_pending_payment,
1555
+			],
1556
+		];
1557
+		// publish box
1558
+		$publish_box_extra_args = [
1559
+			'view_approved_reg_url'        => add_query_arg(
1560
+				[
1561
+					'action'      => 'default',
1562
+					'event_id'    => $this->_cpt_model_obj->ID(),
1563
+					'_reg_status' => EEM_Registration::status_id_approved,
1564
+				],
1565
+				REG_ADMIN_URL
1566
+			),
1567
+			'view_not_approved_reg_url'    => add_query_arg(
1568
+				[
1569
+					'action'      => 'default',
1570
+					'event_id'    => $this->_cpt_model_obj->ID(),
1571
+					'_reg_status' => EEM_Registration::status_id_not_approved,
1572
+				],
1573
+				REG_ADMIN_URL
1574
+			),
1575
+			'view_pending_payment_reg_url' => add_query_arg(
1576
+				[
1577
+					'action'      => 'default',
1578
+					'event_id'    => $this->_cpt_model_obj->ID(),
1579
+					'_reg_status' => EEM_Registration::status_id_pending_payment,
1580
+				],
1581
+				REG_ADMIN_URL
1582
+			),
1583
+			'approved_regs'                => $this->_cpt_model_obj->count_related(
1584
+				'Registration',
1585
+				$approved_query_args
1586
+			),
1587
+			'not_approved_regs'            => $this->_cpt_model_obj->count_related(
1588
+				'Registration',
1589
+				$not_approved_query_args
1590
+			),
1591
+			'pending_payment_regs'         => $this->_cpt_model_obj->count_related(
1592
+				'Registration',
1593
+				$pending_payment_query_args
1594
+			),
1595
+			'misc_pub_section_class'       => apply_filters(
1596
+				'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class',
1597
+				'misc-pub-section'
1598
+			),
1599
+		];
1600
+		ob_start();
1601
+		do_action(
1602
+			'AHEE__Events_Admin_Page___generate_publish_box_extra_content__event_editor_overview_add',
1603
+			$this->_cpt_model_obj
1604
+		);
1605
+		$publish_box_extra_args['event_editor_overview_add'] = ob_get_clean();
1606
+		// load template
1607
+		EEH_Template::display_template(
1608
+			EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php',
1609
+			$publish_box_extra_args
1610
+		);
1611
+	}
1612
+
1613
+
1614
+	/**
1615
+	 * @return EE_Event
1616
+	 */
1617
+	public function get_event_object()
1618
+	{
1619
+		return $this->_cpt_model_obj;
1620
+	}
1621
+
1622
+
1623
+
1624
+
1625
+	/** METABOXES * */
1626
+	/**
1627
+	 * _register_event_editor_meta_boxes
1628
+	 * add all metaboxes related to the event_editor
1629
+	 *
1630
+	 * @return void
1631
+	 * @throws EE_Error
1632
+	 * @throws ReflectionException
1633
+	 */
1634
+	protected function _register_event_editor_meta_boxes()
1635
+	{
1636
+		$this->verify_cpt_object();
1637
+		$use_advanced_editor = $this->admin_config->useAdvancedEditor();
1638
+		// check if the new EDTR reg options meta box is being used, and if so, don't load the legacy version
1639
+		if (! $use_advanced_editor || ! $this->feature->allowed('use_reg_options_meta_box')) {
1640
+			$this->addMetaBox(
1641
+				'espresso_event_editor_event_options',
1642
+				esc_html__('Event Registration Options', 'event_espresso'),
1643
+				[$this, 'registration_options_meta_box'],
1644
+				$this->page_slug,
1645
+				'side'
1646
+			);
1647
+		}
1648
+		if (! $use_advanced_editor) {
1649
+			$this->addMetaBox(
1650
+				'espresso_event_editor_tickets',
1651
+				esc_html__('Event Datetime & Ticket', 'event_espresso'),
1652
+				[$this, 'ticket_metabox'],
1653
+				$this->page_slug,
1654
+				'normal',
1655
+				'high'
1656
+			);
1657
+		} elseif ($this->feature->allowed('use_reg_options_meta_box')) {
1658
+			add_action(
1659
+				'add_meta_boxes_espresso_events',
1660
+				function () {
1661
+					global $current_screen;
1662
+					remove_meta_box('authordiv', $current_screen, 'normal');
1663
+				},
1664
+				99
1665
+			);
1666
+		}
1667
+		// NOTE: if you're looking for other metaboxes in here,
1668
+		// where a metabox has a related management page in the admin
1669
+		// you will find it setup in the related management page's "_Hooks" file.
1670
+		// i.e. messages metabox is found in "espresso_events_Messages_Hooks.class.php".
1671
+	}
1672
+
1673
+
1674
+	/**
1675
+	 * @throws DomainException
1676
+	 * @throws EE_Error
1677
+	 * @throws ReflectionException
1678
+	 */
1679
+	public function ticket_metabox()
1680
+	{
1681
+		$existing_datetime_ids = $existing_ticket_ids = [];
1682
+		// defaults for template args
1683
+		$template_args = [
1684
+			'existing_datetime_ids'    => '',
1685
+			'event_datetime_help_link' => '',
1686
+			'ticket_options_help_link' => '',
1687
+			'time'                     => null,
1688
+			'ticket_rows'              => '',
1689
+			'existing_ticket_ids'      => '',
1690
+			'total_ticket_rows'        => 1,
1691
+			'ticket_js_structure'      => '',
1692
+			'trash_icon'               => 'dashicons dashicons-lock',
1693
+			'disabled'                 => '',
1694
+		];
1695
+		$event_id      = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : null;
1696
+		/**
1697
+		 * 1. Start with retrieving Datetimes
1698
+		 * 2. Fore each datetime get related tickets
1699
+		 * 3. For each ticket get related prices
1700
+		 */
1701
+		/** @var EEM_Datetime $datetime_model */
1702
+		$datetime_model = EE_Registry::instance()->load_model('Datetime');
1703
+		/** @var EEM_Ticket $datetime_model */
1704
+		$ticket_model = EE_Registry::instance()->load_model('Ticket');
1705
+		$times        = $datetime_model->get_all_event_dates($event_id);
1706
+		/** @type EE_Datetime $first_datetime */
1707
+		$first_datetime = reset($times);
1708
+		// do we get related tickets?
1709
+		if (
1710
+			$first_datetime instanceof EE_Datetime
1711
+			&& $first_datetime->ID() !== 0
1712
+		) {
1713
+			$existing_datetime_ids[] = $first_datetime->get('DTT_ID');
1714
+			$template_args['time']   = $first_datetime;
1715
+			$related_tickets         = $first_datetime->tickets(
1716
+				[
1717
+					['OR' => ['TKT_deleted' => 1, 'TKT_deleted*' => 0]],
1718
+					'default_where_conditions' => 'none',
1719
+				]
1720
+			);
1721
+			if (! empty($related_tickets)) {
1722
+				$template_args['total_ticket_rows'] = count($related_tickets);
1723
+				$row                                = 0;
1724
+				foreach ($related_tickets as $ticket) {
1725
+					$existing_ticket_ids[]        = $ticket->get('TKT_ID');
1726
+					$template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, false, $row);
1727
+					$row++;
1728
+				}
1729
+			} else {
1730
+				$template_args['total_ticket_rows'] = 1;
1731
+				/** @type EE_Ticket $ticket */
1732
+				$ticket                       = $ticket_model->create_default_object();
1733
+				$template_args['ticket_rows'] .= $this->_get_ticket_row($ticket);
1734
+			}
1735
+		} else {
1736
+			$template_args['time'] = $times[0];
1737
+			/** @type EE_Ticket[] $tickets */
1738
+			$tickets                      = $ticket_model->get_all_default_tickets();
1739
+			$template_args['ticket_rows'] .= $this->_get_ticket_row($tickets[1]);
1740
+			// NOTE: we're just sending the first default row
1741
+			// (decaf can't manage default tickets so this should be sufficient);
1742
+		}
1743
+		$template_args['event_datetime_help_link'] = $this->_get_help_tab_link(
1744
+			'event_editor_event_datetimes_help_tab'
1745
+		);
1746
+		$template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info');
1747
+		$template_args['existing_datetime_ids']    = implode(',', $existing_datetime_ids);
1748
+		$template_args['existing_ticket_ids']      = implode(',', $existing_ticket_ids);
1749
+		$template_args['ticket_js_structure']      = $this->_get_ticket_row(
1750
+			$ticket_model->create_default_object(),
1751
+			true
1752
+		);
1753
+		$template                                  = apply_filters(
1754
+			'FHEE__Events_Admin_Page__ticket_metabox__template',
1755
+			EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php'
1756
+		);
1757
+		EEH_Template::display_template($template, $template_args);
1758
+	}
1759
+
1760
+
1761
+	/**
1762
+	 * Setup an individual ticket form for the decaf event editor page
1763
+	 *
1764
+	 * @access private
1765
+	 * @param EE_Ticket $ticket   the ticket object
1766
+	 * @param boolean   $skeleton whether we're generating a skeleton for js manipulation
1767
+	 * @param int       $row
1768
+	 * @return string generated html for the ticket row.
1769
+	 * @throws EE_Error
1770
+	 * @throws ReflectionException
1771
+	 */
1772
+	private function _get_ticket_row($ticket, $skeleton = false, $row = 0)
1773
+	{
1774
+		$template_args = [
1775
+			'tkt_status_class'    => ' tkt-status-' . $ticket->ticket_status(),
1776
+			'tkt_archive_class'   => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived'
1777
+				: '',
1778
+			'ticketrow'           => $skeleton ? 'TICKETNUM' : $row,
1779
+			'TKT_ID'              => $ticket->get('TKT_ID'),
1780
+			'TKT_name'            => $ticket->get('TKT_name'),
1781
+			'TKT_start_date'      => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'),
1782
+			'TKT_end_date'        => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'),
1783
+			'TKT_is_default'      => $ticket->get('TKT_is_default'),
1784
+			'TKT_qty'             => $ticket->get_pretty('TKT_qty', 'input'),
1785
+			'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets',
1786
+			'TKT_sold'            => $skeleton ? 0 : $ticket->get('TKT_sold'),
1787
+			'trash_icon'          => ($skeleton || (! empty($ticket) && ! $ticket->get('TKT_deleted')))
1788
+									 && (! empty($ticket) && $ticket->get('TKT_sold') === 0)
1789
+				? 'trash-icon dashicons dashicons-post-trash clickable' : 'dashicons dashicons-lock',
1790
+			'disabled'            => $skeleton || (! empty($ticket) && ! $ticket->get('TKT_deleted')) ? ''
1791
+				: ' disabled=disabled',
1792
+		];
1793
+		$price         = $ticket->ID() !== 0
1794
+			? $ticket->get_first_related('Price', ['default_where_conditions' => 'none'])
1795
+			: null;
1796
+		$price         = $price instanceof EE_Price
1797
+			? $price
1798
+			: EEM_Price::instance()->create_default_object();
1799
+		$price_args    = [
1800
+			'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,
1801
+			'PRC_amount'            => $price->get('PRC_amount'),
1802
+			'PRT_ID'                => $price->get('PRT_ID'),
1803
+			'PRC_ID'                => $price->get('PRC_ID'),
1804
+			'PRC_is_default'        => $price->get('PRC_is_default'),
1805
+		];
1806
+		// make sure we have default start and end dates if skeleton
1807
+		// handle rows that should NOT be empty
1808
+		if (empty($template_args['TKT_start_date'])) {
1809
+			// if empty then the start date will be now.
1810
+			$template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp'));
1811
+		}
1812
+		if (empty($template_args['TKT_end_date'])) {
1813
+			// get the earliest datetime (if present);
1814
+			$earliest_datetime             = $this->_cpt_model_obj->ID() > 0
1815
+				? $this->_cpt_model_obj->get_first_related(
1816
+					'Datetime',
1817
+					['order_by' => ['DTT_EVT_start' => 'ASC']]
1818
+				)
1819
+				: null;
1820
+			$template_args['TKT_end_date'] = $earliest_datetime instanceof EE_Datetime
1821
+				? $earliest_datetime->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a')
1822
+				: date('Y-m-d h:i a', mktime(0, 0, 0, date('m'), date('d') + 7, date('Y')));
1823
+		}
1824
+		$template_args = array_merge($template_args, $price_args);
1825
+		$template      = apply_filters(
1826
+			'FHEE__Events_Admin_Page__get_ticket_row__template',
1827
+			EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php',
1828
+			$ticket
1829
+		);
1830
+		return EEH_Template::display_template($template, $template_args, true);
1831
+	}
1832
+
1833
+
1834
+	/**
1835
+	 * @throws EE_Error
1836
+	 * @throws ReflectionException
1837
+	 */
1838
+	public function registration_options_meta_box()
1839
+	{
1840
+		$yes_no_values             = [
1841
+			['id' => true, 'text' => esc_html__('Yes', 'event_espresso')],
1842
+			['id' => false, 'text' => esc_html__('No', 'event_espresso')],
1843
+		];
1844
+		$default_reg_status_values = EEM_Registration::reg_status_array(
1845
+			[
1846
+				EEM_Registration::status_id_cancelled,
1847
+				EEM_Registration::status_id_declined,
1848
+				EEM_Registration::status_id_incomplete,
1849
+			],
1850
+			true
1851
+		);
1852
+		// $template_args['is_active_select'] = EEH_Form_Fields::select_input('is_active', $yes_no_values, $this->_cpt_model_obj->is_active());
1853
+		$template_args['_event']                          = $this->_cpt_model_obj;
1854
+		$template_args['event']                           = $this->_cpt_model_obj;
1855
+		$template_args['active_status']                   = $this->_cpt_model_obj->pretty_active_status(false);
1856
+		$template_args['additional_limit']                = $this->_cpt_model_obj->additional_limit();
1857
+		$template_args['default_registration_status']     = EEH_Form_Fields::select_input(
1858
+			'default_reg_status',
1859
+			$default_reg_status_values,
1860
+			$this->_cpt_model_obj->default_registration_status()
1861
+		);
1862
+		$template_args['display_description']             = EEH_Form_Fields::select_input(
1863
+			'display_desc',
1864
+			$yes_no_values,
1865
+			$this->_cpt_model_obj->display_description()
1866
+		);
1867
+		$template_args['display_ticket_selector']         = EEH_Form_Fields::select_input(
1868
+			'display_ticket_selector',
1869
+			$yes_no_values,
1870
+			$this->_cpt_model_obj->display_ticket_selector(),
1871
+			'',
1872
+			'',
1873
+			false
1874
+		);
1875
+		$template_args['additional_registration_options'] = apply_filters(
1876
+			'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options',
1877
+			'',
1878
+			$template_args,
1879
+			$yes_no_values,
1880
+			$default_reg_status_values
1881
+		);
1882
+		EEH_Template::display_template(
1883
+			EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php',
1884
+			$template_args
1885
+		);
1886
+	}
1887
+
1888
+
1889
+	/**
1890
+	 * _get_events()
1891
+	 * This method simply returns all the events (for the given _view and paging)
1892
+	 *
1893
+	 * @access public
1894
+	 * @param int  $per_page     count of items per page (20 default);
1895
+	 * @param int  $current_page what is the current page being viewed.
1896
+	 * @param bool $count        if TRUE then we just return a count of ALL events matching the given _view.
1897
+	 *                           If FALSE then we return an array of event objects
1898
+	 *                           that match the given _view and paging parameters.
1899
+	 * @return array|int         an array of event objects or a count of them.
1900
+	 * @throws Exception
1901
+	 */
1902
+	public function get_events($per_page = 10, $current_page = 1, $count = false)
1903
+	{
1904
+		$EEM_Event   = $this->_event_model();
1905
+		$offset      = ($current_page - 1) * $per_page;
1906
+		$limit       = $count ? null : $offset . ',' . $per_page;
1907
+		$orderby     = $this->request->getRequestParam('orderby', 'EVT_ID');
1908
+		$order       = $this->request->getRequestParam('order', 'DESC');
1909
+		$month_range = $this->request->getRequestParam('month_range');
1910
+		if ($month_range) {
1911
+			$pieces = explode(' ', $month_range, 3);
1912
+			// simulate the FIRST day of the month, that fixes issues for months like February
1913
+			// where PHP doesn't know what to assume for date.
1914
+			// @see https://events.codebasehq.com/projects/event-espresso/tickets/10437
1915
+			$month_r = ! empty($pieces[0]) ? date('m', EEH_DTT_Helper::first_of_month_timestamp($pieces[0])) : '';
1916
+			$year_r  = ! empty($pieces[1]) ? $pieces[1] : '';
1917
+		}
1918
+		$where  = [];
1919
+		$status = $this->request->getRequestParam('status');
1920
+		// determine what post_status our condition will have for the query.
1921
+		switch ($status) {
1922
+			case 'month':
1923
+			case 'today':
1924
+			case null:
1925
+			case 'all':
1926
+				break;
1927
+			case 'draft':
1928
+				$where['status'] = ['IN', ['draft', 'auto-draft']];
1929
+				break;
1930
+			default:
1931
+				$where['status'] = $status;
1932
+		}
1933
+		// categories? The default for all categories is -1
1934
+		$category = $this->request->getRequestParam('EVT_CAT', -1, 'int');
1935
+		if ($category !== -1) {
1936
+			$where['Term_Taxonomy.taxonomy'] = EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY;
1937
+			$where['Term_Taxonomy.term_id']  = $category;
1938
+		}
1939
+		// date where conditions
1940
+		$start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start');
1941
+		if ($month_range) {
1942
+			$DateTime = new DateTime(
1943
+				$year_r . '-' . $month_r . '-01 00:00:00',
1944
+				new DateTimeZone('UTC')
1945
+			);
1946
+			$start    = $DateTime->getTimestamp();
1947
+			// set the datetime to be the end of the month
1948
+			$DateTime->setDate(
1949
+				$year_r,
1950
+				$month_r,
1951
+				$DateTime->format('t')
1952
+			)->setTime(23, 59, 59);
1953
+			$end                             = $DateTime->getTimestamp();
1954
+			$where['Datetime.DTT_EVT_start'] = ['BETWEEN', [$start, $end]];
1955
+		} elseif ($status === 'today') {
1956
+			$DateTime                        =
1957
+				new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone()));
1958
+			$start                           = $DateTime->setTime(0, 0)->format(implode(' ', $start_formats));
1959
+			$end                             = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats));
1960
+			$where['Datetime.DTT_EVT_start'] = ['BETWEEN', [$start, $end]];
1961
+		} elseif ($status === 'month') {
1962
+			$now                             = date('Y-m-01');
1963
+			$DateTime                        =
1964
+				new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone()));
1965
+			$start                           = $DateTime->setTime(0, 0)->format(implode(' ', $start_formats));
1966
+			$end                             = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t'))
1967
+														->setTime(23, 59, 59)
1968
+														->format(implode(' ', $start_formats));
1969
+			$where['Datetime.DTT_EVT_start'] = ['BETWEEN', [$start, $end]];
1970
+		}
1971
+		if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
1972
+			$where['EVT_wp_user'] = get_current_user_id();
1973
+		} else {
1974
+			if (! isset($where['status'])) {
1975
+				if (! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) {
1976
+					$where['OR'] = [
1977
+						'status*restrict_private' => ['!=', 'private'],
1978
+						'AND'                     => [
1979
+							'status*inclusive' => ['=', 'private'],
1980
+							'EVT_wp_user'      => get_current_user_id(),
1981
+						],
1982
+					];
1983
+				}
1984
+			}
1985
+		}
1986
+		$wp_user = $this->request->getRequestParam('EVT_wp_user', 0, 'int');
1987
+		if (
1988
+			$wp_user
1989
+			&& $wp_user !== get_current_user_id()
1990
+			&& EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')
1991
+		) {
1992
+			$where['EVT_wp_user'] = $wp_user;
1993
+		}
1994
+		// search query handling
1995
+		$search_term = $this->request->getRequestParam('s');
1996
+		if ($search_term) {
1997
+			$search_term = '%' . $search_term . '%';
1998
+			$where['OR'] = [
1999
+				'EVT_name'       => ['LIKE', $search_term],
2000
+				'EVT_desc'       => ['LIKE', $search_term],
2001
+				'EVT_short_desc' => ['LIKE', $search_term],
2002
+			];
2003
+		}
2004
+		// filter events by venue.
2005
+		$venue = $this->request->getRequestParam('venue', 0, 'int');
2006
+		if ($venue) {
2007
+			$where['Venue.VNU_ID'] = $venue;
2008
+		}
2009
+		$request_params = $this->request->requestParams();
2010
+		$where          = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $request_params);
2011
+		$query_params   = apply_filters(
2012
+			'FHEE__Events_Admin_Page__get_events__query_params',
2013
+			[
2014
+				$where,
2015
+				'limit'    => $limit,
2016
+				'order_by' => $orderby,
2017
+				'order'    => $order,
2018
+				'group_by' => 'EVT_ID',
2019
+			],
2020
+			$request_params
2021
+		);
2022
+
2023
+		// let's first check if we have special requests coming in.
2024
+		$active_status = $this->request->getRequestParam('active_status');
2025
+		if ($active_status) {
2026
+			switch ($active_status) {
2027
+				case 'upcoming':
2028
+					return $EEM_Event->get_upcoming_events($query_params, $count);
2029
+				case 'expired':
2030
+					return $EEM_Event->get_expired_events($query_params, $count);
2031
+				case 'active':
2032
+					return $EEM_Event->get_active_events($query_params, $count);
2033
+				case 'inactive':
2034
+					return $EEM_Event->get_inactive_events($query_params, $count);
2035
+			}
2036
+		}
2037
+
2038
+		return $count ? $EEM_Event->count([$where], 'EVT_ID', true) : $EEM_Event->get_all($query_params);
2039
+	}
2040
+
2041
+
2042
+	/**
2043
+	 * handling for WordPress CPT actions (trash, restore, delete)
2044
+	 *
2045
+	 * @param string $post_id
2046
+	 * @throws EE_Error
2047
+	 * @throws ReflectionException
2048
+	 */
2049
+	public function trash_cpt_item($post_id)
2050
+	{
2051
+		$this->request->setRequestParam('EVT_ID', $post_id);
2052
+		$this->_trash_or_restore_event('trash', false);
2053
+	}
2054
+
2055
+
2056
+	/**
2057
+	 * @param string $post_id
2058
+	 * @throws EE_Error
2059
+	 * @throws ReflectionException
2060
+	 */
2061
+	public function restore_cpt_item($post_id)
2062
+	{
2063
+		$this->request->setRequestParam('EVT_ID', $post_id);
2064
+		$this->_trash_or_restore_event('draft', false);
2065
+	}
2066
+
2067
+
2068
+	/**
2069
+	 * @param string $post_id
2070
+	 * @throws EE_Error
2071
+	 * @throws EE_Error
2072
+	 */
2073
+	public function delete_cpt_item($post_id)
2074
+	{
2075
+		throw new EE_Error(
2076
+			esc_html__(
2077
+				'Please contact Event Espresso support with the details of the steps taken to produce this error.',
2078
+				'event_espresso'
2079
+			)
2080
+		);
2081
+		// $this->request->setRequestParam('EVT_ID', $post_id);
2082
+		// $this->_delete_event();
2083
+	}
2084
+
2085
+
2086
+	/**
2087
+	 * _trash_or_restore_event
2088
+	 *
2089
+	 * @access protected
2090
+	 * @param string $event_status
2091
+	 * @param bool   $redirect_after
2092
+	 * @throws EE_Error
2093
+	 * @throws EE_Error
2094
+	 * @throws ReflectionException
2095
+	 */
2096
+	protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = true)
2097
+	{
2098
+		// determine the event id and set to array.
2099
+		$EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int');
2100
+		// loop thru events
2101
+		if ($EVT_ID) {
2102
+			// clean status
2103
+			$event_status = sanitize_key($event_status);
2104
+			// grab status
2105
+			if (! empty($event_status)) {
2106
+				$success = $this->_change_event_status($EVT_ID, $event_status);
2107
+			} else {
2108
+				$success = false;
2109
+				$msg     = esc_html__(
2110
+					'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.',
2111
+					'event_espresso'
2112
+				);
2113
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2114
+			}
2115
+		} else {
2116
+			$success = false;
2117
+			$msg     = esc_html__(
2118
+				'An error occurred. The event could not be moved to the trash because a valid event ID was not not supplied.',
2119
+				'event_espresso'
2120
+			);
2121
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2122
+		}
2123
+		$action = $event_status === 'trash' ? 'moved to the trash' : 'restored from the trash';
2124
+		if ($redirect_after) {
2125
+			$this->_redirect_after_action($success, 'Event', $action, ['action' => 'default']);
2126
+		}
2127
+	}
2128
+
2129
+
2130
+	/**
2131
+	 * _trash_or_restore_events
2132
+	 *
2133
+	 * @access protected
2134
+	 * @param string $event_status
2135
+	 * @return void
2136
+	 * @throws EE_Error
2137
+	 * @throws EE_Error
2138
+	 * @throws ReflectionException
2139
+	 */
2140
+	protected function _trash_or_restore_events($event_status = 'trash')
2141
+	{
2142
+		// clean status
2143
+		$event_status = sanitize_key($event_status);
2144
+		// grab status
2145
+		if (! empty($event_status)) {
2146
+			$success = true;
2147
+			// determine the event id and set to array.
2148
+			$EVT_IDs = $this->request->getRequestParam('EVT_IDs', [], 'int', true);
2149
+			// loop thru events
2150
+			foreach ($EVT_IDs as $EVT_ID) {
2151
+				if ($EVT_ID = absint($EVT_ID)) {
2152
+					$results = $this->_change_event_status($EVT_ID, $event_status);
2153
+					$success = $results !== false ? $success : false;
2154
+				} else {
2155
+					$msg = sprintf(
2156
+						esc_html__(
2157
+							'An error occurred. Event #%d could not be moved to the trash because a valid event ID was not not supplied.',
2158
+							'event_espresso'
2159
+						),
2160
+						$EVT_ID
2161
+					);
2162
+					EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2163
+					$success = false;
2164
+				}
2165
+			}
2166
+		} else {
2167
+			$success = false;
2168
+			$msg     = esc_html__(
2169
+				'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.',
2170
+				'event_espresso'
2171
+			);
2172
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2173
+		}
2174
+		// in order to force a pluralized result message we need to send back a success status greater than 1
2175
+		$success = $success ? 2 : false;
2176
+		$action  = $event_status === 'trash' ? 'moved to the trash' : 'restored from the trash';
2177
+		$this->_redirect_after_action($success, 'Events', $action, ['action' => 'default']);
2178
+	}
2179
+
2180
+
2181
+	/**
2182
+	 * @param int    $EVT_ID
2183
+	 * @param string $event_status
2184
+	 * @return bool
2185
+	 * @throws EE_Error
2186
+	 * @throws ReflectionException
2187
+	 */
2188
+	private function _change_event_status($EVT_ID = 0, $event_status = '')
2189
+	{
2190
+		// grab event id
2191
+		if (! $EVT_ID) {
2192
+			$msg = esc_html__(
2193
+				'An error occurred. No Event ID or an invalid Event ID was received.',
2194
+				'event_espresso'
2195
+			);
2196
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2197
+			return false;
2198
+		}
2199
+		$this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID);
2200
+		// clean status
2201
+		$event_status = sanitize_key($event_status);
2202
+		// grab status
2203
+		if (empty($event_status)) {
2204
+			$msg = esc_html__(
2205
+				'An error occurred. No Event Status or an invalid Event Status was received.',
2206
+				'event_espresso'
2207
+			);
2208
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2209
+			return false;
2210
+		}
2211
+		// was event trashed or restored ?
2212
+		switch ($event_status) {
2213
+			case 'draft':
2214
+				$action = 'restored from the trash';
2215
+				$hook   = 'AHEE_event_restored_from_trash';
2216
+				break;
2217
+			case 'trash':
2218
+				$action = 'moved to the trash';
2219
+				$hook   = 'AHEE_event_moved_to_trash';
2220
+				break;
2221
+			default:
2222
+				$action = 'updated';
2223
+				$hook   = false;
2224
+		}
2225
+		// use class to change status
2226
+		$this->_cpt_model_obj->set_status($event_status);
2227
+		$success = $this->_cpt_model_obj->save();
2228
+		if (! $success) {
2229
+			$msg = sprintf(esc_html__('An error occurred. The event could not be %s.', 'event_espresso'), $action);
2230
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2231
+			return false;
2232
+		}
2233
+		if ($hook) {
2234
+			do_action($hook);
2235
+		}
2236
+		return true;
2237
+	}
2238
+
2239
+
2240
+	/**
2241
+	 * @param array $event_ids
2242
+	 * @return array
2243
+	 * @since   4.10.23.p
2244
+	 */
2245
+	private function cleanEventIds(array $event_ids)
2246
+	{
2247
+		return array_map('absint', $event_ids);
2248
+	}
2249
+
2250
+
2251
+	/**
2252
+	 * @return array
2253
+	 * @since   4.10.23.p
2254
+	 */
2255
+	private function getEventIdsFromRequest()
2256
+	{
2257
+		if ($this->request->requestParamIsSet('EVT_IDs')) {
2258
+			return $this->request->getRequestParam('EVT_IDs', [], 'int', true);
2259
+		} else {
2260
+			return $this->request->getRequestParam('EVT_ID', [], 'int', true);
2261
+		}
2262
+	}
2263
+
2264
+
2265
+	/**
2266
+	 * @param bool $preview_delete
2267
+	 * @throws EE_Error
2268
+	 */
2269
+	protected function _delete_event($preview_delete = true)
2270
+	{
2271
+		$this->_delete_events($preview_delete);
2272
+	}
2273
+
2274
+
2275
+	/**
2276
+	 * Gets the tree traversal batch persister.
2277
+	 *
2278
+	 * @return NodeGroupDao
2279
+	 * @throws InvalidArgumentException
2280
+	 * @throws InvalidDataTypeException
2281
+	 * @throws InvalidInterfaceException
2282
+	 * @since 4.10.12.p
2283
+	 */
2284
+	protected function getModelObjNodeGroupPersister()
2285
+	{
2286
+		if (! $this->model_obj_node_group_persister instanceof NodeGroupDao) {
2287
+			$this->model_obj_node_group_persister =
2288
+				$this->getLoader()->load('\EventEspresso\core\services\orm\tree_traversal\NodeGroupDao');
2289
+		}
2290
+		return $this->model_obj_node_group_persister;
2291
+	}
2292
+
2293
+
2294
+	/**
2295
+	 * @param bool $preview_delete
2296
+	 * @return void
2297
+	 * @throws EE_Error
2298
+	 */
2299
+	protected function _delete_events($preview_delete = true)
2300
+	{
2301
+		$event_ids = $this->getEventIdsFromRequest();
2302
+		if ($preview_delete) {
2303
+			$this->generateDeletionPreview($event_ids);
2304
+		} else {
2305
+			EEM_Event::instance()->delete_permanently([['EVT_ID' => ['IN', $event_ids]]]);
2306
+		}
2307
+	}
2308
+
2309
+
2310
+	/**
2311
+	 * @param array $event_ids
2312
+	 */
2313
+	protected function generateDeletionPreview(array $event_ids)
2314
+	{
2315
+		$event_ids = $this->cleanEventIds($event_ids);
2316
+		// Set a code we can use to reference this deletion task in the batch jobs and preview page.
2317
+		$deletion_job_code = $this->getModelObjNodeGroupPersister()->generateGroupCode();
2318
+		$return_url        = EE_Admin_Page::add_query_args_and_nonce(
2319
+			[
2320
+				'action'            => 'preview_deletion',
2321
+				'deletion_job_code' => $deletion_job_code,
2322
+			],
2323
+			$this->_admin_base_url
2324
+		);
2325
+		EEH_URL::safeRedirectAndExit(
2326
+			EE_Admin_Page::add_query_args_and_nonce(
2327
+				[
2328
+					'page'              => 'espresso_batch',
2329
+					'batch'             => EED_Batch::batch_job,
2330
+					'EVT_IDs'           => $event_ids,
2331
+					'deletion_job_code' => $deletion_job_code,
2332
+					'job_handler'       => urlencode('EventEspressoBatchRequest\JobHandlers\PreviewEventDeletion'),
2333
+					'return_url'        => urlencode($return_url),
2334
+				],
2335
+				admin_url()
2336
+			)
2337
+		);
2338
+	}
2339
+
2340
+
2341
+	/**
2342
+	 * Checks for a POST submission
2343
+	 *
2344
+	 * @since 4.10.12.p
2345
+	 */
2346
+	protected function confirmDeletion()
2347
+	{
2348
+		$deletion_redirect_logic =
2349
+			$this->getLoader()->getShared('\EventEspresso\core\domain\services\admin\events\data\ConfirmDeletion');
2350
+		$deletion_redirect_logic->handle($this->get_request_data(), $this->admin_base_url());
2351
+	}
2352
+
2353
+
2354
+	/**
2355
+	 * A page for users to preview what exactly will be deleted, and confirm they want to delete it.
2356
+	 *
2357
+	 * @throws EE_Error
2358
+	 * @since 4.10.12.p
2359
+	 */
2360
+	protected function previewDeletion()
2361
+	{
2362
+		$preview_deletion_logic =
2363
+			$this->getLoader()->getShared('\EventEspresso\core\domain\services\admin\events\data\PreviewDeletion');
2364
+		$this->set_template_args($preview_deletion_logic->handle($this->get_request_data(), $this->admin_base_url()));
2365
+		$this->display_admin_page_with_no_sidebar();
2366
+	}
2367
+
2368
+
2369
+	/**
2370
+	 * get total number of events
2371
+	 *
2372
+	 * @access public
2373
+	 * @return int
2374
+	 * @throws EE_Error
2375
+	 * @throws EE_Error
2376
+	 */
2377
+	public function total_events()
2378
+	{
2379
+		return EEM_Event::instance()->count(
2380
+			['caps' => 'read_admin'],
2381
+			'EVT_ID',
2382
+			true
2383
+		);
2384
+	}
2385
+
2386
+
2387
+	/**
2388
+	 * get total number of draft events
2389
+	 *
2390
+	 * @access public
2391
+	 * @return int
2392
+	 * @throws EE_Error
2393
+	 * @throws EE_Error
2394
+	 */
2395
+	public function total_events_draft()
2396
+	{
2397
+		return EEM_Event::instance()->count(
2398
+			[
2399
+				['status' => ['IN', ['draft', 'auto-draft']]],
2400
+				'caps' => 'read_admin',
2401
+			],
2402
+			'EVT_ID',
2403
+			true
2404
+		);
2405
+	}
2406
+
2407
+
2408
+	/**
2409
+	 * get total number of trashed events
2410
+	 *
2411
+	 * @access public
2412
+	 * @return int
2413
+	 * @throws EE_Error
2414
+	 * @throws EE_Error
2415
+	 */
2416
+	public function total_trashed_events()
2417
+	{
2418
+		return EEM_Event::instance()->count(
2419
+			[
2420
+				['status' => 'trash'],
2421
+				'caps' => 'read_admin',
2422
+			],
2423
+			'EVT_ID',
2424
+			true
2425
+		);
2426
+	}
2427
+
2428
+
2429
+	/**
2430
+	 *    _default_event_settings
2431
+	 *    This generates the Default Settings Tab
2432
+	 *
2433
+	 * @return void
2434
+	 * @throws DomainException
2435
+	 * @throws EE_Error
2436
+	 * @throws InvalidArgumentException
2437
+	 * @throws InvalidDataTypeException
2438
+	 * @throws InvalidInterfaceException
2439
+	 */
2440
+	protected function _default_event_settings()
2441
+	{
2442
+		$this->_set_add_edit_form_tags('update_default_event_settings');
2443
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
2444
+		$this->_template_args['admin_page_content'] = EEH_HTML::div(
2445
+			$this->_default_event_settings_form()->get_html(),
2446
+			'',
2447
+			'padding'
2448
+		);
2449
+		$this->display_admin_page_with_sidebar();
2450
+	}
2451
+
2452
+
2453
+	/**
2454
+	 * Return the form for event settings.
2455
+	 *
2456
+	 * @return EE_Form_Section_Proper
2457
+	 * @throws EE_Error
2458
+	 */
2459
+	protected function _default_event_settings_form()
2460
+	{
2461
+		$registration_config              = EE_Registry::instance()->CFG->registration;
2462
+		$registration_stati_for_selection = EEM_Registration::reg_status_array(
2463
+		// exclude
2464
+			[
2465
+				EEM_Registration::status_id_cancelled,
2466
+				EEM_Registration::status_id_declined,
2467
+				EEM_Registration::status_id_incomplete,
2468
+				EEM_Registration::status_id_wait_list,
2469
+			],
2470
+			true
2471
+		);
2472
+		return new EE_Form_Section_Proper(
2473
+			[
2474
+				'name'            => 'update_default_event_settings',
2475
+				'html_id'         => 'update_default_event_settings',
2476
+				'html_class'      => 'form-table',
2477
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
2478
+				'subsections'     => apply_filters(
2479
+					'FHEE__Events_Admin_Page___default_event_settings_form__form_subsections',
2480
+					[
2481
+						'defaults_section_header' => new EE_Form_Section_HTML(
2482
+							EEH_HTML::h2(
2483
+								esc_html__('Default Settings', 'event_espresso'),
2484
+								'',
2485
+								'ee-admin-settings-hdr'
2486
+							)
2487
+						),
2488
+						'default_reg_status'  => new EE_Select_Input(
2489
+							$registration_stati_for_selection,
2490
+							[
2491
+								'default'         => isset($registration_config->default_STS_ID)
2492
+													 && array_key_exists(
2493
+														 $registration_config->default_STS_ID,
2494
+														 $registration_stati_for_selection
2495
+													 )
2496
+									? sanitize_text_field($registration_config->default_STS_ID)
2497
+									: EEM_Registration::status_id_pending_payment,
2498
+								'html_label_text' => esc_html__('Default Registration Status', 'event_espresso')
2499
+													 . EEH_Template::get_help_tab_link(
2500
+														 'default_settings_status_help_tab'
2501
+													 ),
2502
+								'html_help_text'  => esc_html__(
2503
+									'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.',
2504
+									'event_espresso'
2505
+								),
2506
+							]
2507
+						),
2508
+						'default_max_tickets' => new EE_Integer_Input(
2509
+							[
2510
+								'default'         => isset($registration_config->default_maximum_number_of_tickets)
2511
+									? $registration_config->default_maximum_number_of_tickets
2512
+									: EEM_Event::get_default_additional_limit(),
2513
+								'html_label_text' => esc_html__(
2514
+									'Default Maximum Tickets Allowed Per Order:',
2515
+									'event_espresso'
2516
+								)
2517
+													 . EEH_Template::get_help_tab_link(
2518
+														 'default_maximum_tickets_help_tab"'
2519
+													 ),
2520
+								'html_help_text'  => esc_html__(
2521
+									'This setting allows you to indicate what will be the default for the maximum number of tickets per order when creating new events.',
2522
+									'event_espresso'
2523
+								),
2524
+							]
2525
+						),
2526
+					]
2527
+				),
2528
+			]
2529
+		);
2530
+	}
2531
+
2532
+
2533
+	/**
2534
+	 * @return void
2535
+	 * @throws EE_Error
2536
+	 * @throws InvalidArgumentException
2537
+	 * @throws InvalidDataTypeException
2538
+	 * @throws InvalidInterfaceException
2539
+	 */
2540
+	protected function _update_default_event_settings()
2541
+	{
2542
+		$form = $this->_default_event_settings_form();
2543
+		if ($form->was_submitted()) {
2544
+			$form->receive_form_submission();
2545
+			if ($form->is_valid()) {
2546
+				$registration_config = EE_Registry::instance()->CFG->registration;
2547
+				$valid_data          = $form->valid_data();
2548
+				if (isset($valid_data['default_reg_status'])) {
2549
+					$registration_config->default_STS_ID = $valid_data['default_reg_status'];
2550
+				}
2551
+				if (isset($valid_data['default_max_tickets'])) {
2552
+					$registration_config->default_maximum_number_of_tickets = $valid_data['default_max_tickets'];
2553
+				}
2554
+				do_action(
2555
+					'AHEE__Events_Admin_Page___update_default_event_settings',
2556
+					$valid_data,
2557
+					EE_Registry::instance()->CFG,
2558
+					$this
2559
+				);
2560
+				// update because data was valid!
2561
+				EE_Registry::instance()->CFG->update_espresso_config();
2562
+				EE_Error::overwrite_success();
2563
+				EE_Error::add_success(
2564
+					esc_html__('Default Event Settings were updated', 'event_espresso')
2565
+				);
2566
+			}
2567
+		}
2568
+		$this->_redirect_after_action(0, '', '', ['action' => 'default_event_settings'], true);
2569
+	}
2570
+
2571
+
2572
+	/*************        Templates        *************
21 2573
      *
22
-     * @var EE_Event $_event
23
-     */
24
-    protected $_event;
25
-
26
-
27
-    /**
28
-     * This will hold the category object for category_details screen.
29
-     *
30
-     * @var stdClass $_category
31
-     */
32
-    protected $_category;
33
-
34
-
35
-    /**
36
-     * This will hold the event model instance
37
-     *
38
-     * @var EEM_Event $_event_model
39
-     */
40
-    protected $_event_model;
41
-
42
-
43
-    /**
44
-     * @var EE_Event
45
-     */
46
-    protected $_cpt_model_obj = false;
47
-
48
-
49
-    /**
50
-     * @var NodeGroupDao
51
-     */
52
-    protected $model_obj_node_group_persister;
53
-
54
-
55
-    /**
56
-     * Initialize page props for this admin page group.
57
-     */
58
-    protected function _init_page_props()
59
-    {
60
-        $this->page_slug        = EVENTS_PG_SLUG;
61
-        $this->page_label       = EVENTS_LABEL;
62
-        $this->_admin_base_url  = EVENTS_ADMIN_URL;
63
-        $this->_admin_base_path = EVENTS_ADMIN;
64
-        $this->_cpt_model_names = [
65
-            'create_new' => 'EEM_Event',
66
-            'edit'       => 'EEM_Event',
67
-        ];
68
-        $this->_cpt_edit_routes = [
69
-            'espresso_events' => 'edit',
70
-        ];
71
-        add_action(
72
-            'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object',
73
-            [$this, 'verify_event_edit'],
74
-            10,
75
-            2
76
-        );
77
-    }
78
-
79
-
80
-    /**
81
-     * Sets the ajax hooks used for this admin page group.
82
-     */
83
-    protected function _ajax_hooks()
84
-    {
85
-        add_action('wp_ajax_ee_save_timezone_setting', [$this, 'saveTimezoneString']);
86
-    }
87
-
88
-
89
-    /**
90
-     * Sets the page properties for this admin page group.
91
-     */
92
-    protected function _define_page_props()
93
-    {
94
-        $this->_admin_page_title = EVENTS_LABEL;
95
-        $this->_labels           = [
96
-            'buttons'      => [
97
-                'add'             => esc_html__('Add New Event', 'event_espresso'),
98
-                'edit'            => esc_html__('Edit Event', 'event_espresso'),
99
-                'delete'          => esc_html__('Delete Event', 'event_espresso'),
100
-                'add_category'    => esc_html__('Add New Category', 'event_espresso'),
101
-                'edit_category'   => esc_html__('Edit Category', 'event_espresso'),
102
-                'delete_category' => esc_html__('Delete Category', 'event_espresso'),
103
-            ],
104
-            'editor_title' => [
105
-                'espresso_events' => esc_html__('Enter event title here', 'event_espresso'),
106
-            ],
107
-            'publishbox'   => [
108
-                'create_new'        => esc_html__('Save New Event', 'event_espresso'),
109
-                'edit'              => esc_html__('Update Event', 'event_espresso'),
110
-                'add_category'      => esc_html__('Save New Category', 'event_espresso'),
111
-                'edit_category'     => esc_html__('Update Category', 'event_espresso'),
112
-                'template_settings' => esc_html__('Update Settings', 'event_espresso'),
113
-            ],
114
-        ];
115
-    }
116
-
117
-
118
-    /**
119
-     * Sets the page routes property for this admin page group.
120
-     */
121
-    protected function _set_page_routes()
122
-    {
123
-        // load formatter helper
124
-        // load field generator helper
125
-        // is there a evt_id in the request?
126
-        $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int');
127
-        $EVT_ID = $this->request->getRequestParam('post', $EVT_ID, 'int');
128
-
129
-        $this->_page_routes = [
130
-            'default'                       => [
131
-                'func'       => '_events_overview_list_table',
132
-                'capability' => 'ee_read_events',
133
-            ],
134
-            'create_new'                    => [
135
-                'func'       => '_create_new_cpt_item',
136
-                'capability' => 'ee_edit_events',
137
-            ],
138
-            'edit'                          => [
139
-                'func'       => '_edit_cpt_item',
140
-                'capability' => 'ee_edit_event',
141
-                'obj_id'     => $EVT_ID,
142
-            ],
143
-            'copy_event'                    => [
144
-                'func'       => '_copy_events',
145
-                'capability' => 'ee_edit_event',
146
-                'obj_id'     => $EVT_ID,
147
-                'noheader'   => true,
148
-            ],
149
-            'trash_event'                   => [
150
-                'func'       => '_trash_or_restore_event',
151
-                'args'       => ['event_status' => 'trash'],
152
-                'capability' => 'ee_delete_event',
153
-                'obj_id'     => $EVT_ID,
154
-                'noheader'   => true,
155
-            ],
156
-            'trash_events'                  => [
157
-                'func'       => '_trash_or_restore_events',
158
-                'args'       => ['event_status' => 'trash'],
159
-                'capability' => 'ee_delete_events',
160
-                'noheader'   => true,
161
-            ],
162
-            'restore_event'                 => [
163
-                'func'       => '_trash_or_restore_event',
164
-                'args'       => ['event_status' => 'draft'],
165
-                'capability' => 'ee_delete_event',
166
-                'obj_id'     => $EVT_ID,
167
-                'noheader'   => true,
168
-            ],
169
-            'restore_events'                => [
170
-                'func'       => '_trash_or_restore_events',
171
-                'args'       => ['event_status' => 'draft'],
172
-                'capability' => 'ee_delete_events',
173
-                'noheader'   => true,
174
-            ],
175
-            'delete_event'                  => [
176
-                'func'       => '_delete_event',
177
-                'capability' => 'ee_delete_event',
178
-                'obj_id'     => $EVT_ID,
179
-                'noheader'   => true,
180
-            ],
181
-            'delete_events'                 => [
182
-                'func'       => '_delete_events',
183
-                'capability' => 'ee_delete_events',
184
-                'noheader'   => true,
185
-            ],
186
-            'view_report'                   => [
187
-                'func'       => '_view_report',
188
-                'capability' => 'ee_edit_events',
189
-            ],
190
-            'default_event_settings'        => [
191
-                'func'       => '_default_event_settings',
192
-                'capability' => 'manage_options',
193
-            ],
194
-            'update_default_event_settings' => [
195
-                'func'       => '_update_default_event_settings',
196
-                'capability' => 'manage_options',
197
-                'noheader'   => true,
198
-            ],
199
-            'template_settings'             => [
200
-                'func'       => '_template_settings',
201
-                'capability' => 'manage_options',
202
-            ],
203
-            // event category tab related
204
-            'add_category'                  => [
205
-                'func'       => '_category_details',
206
-                'capability' => 'ee_edit_event_category',
207
-                'args'       => ['add'],
208
-            ],
209
-            'edit_category'                 => [
210
-                'func'       => '_category_details',
211
-                'capability' => 'ee_edit_event_category',
212
-                'args'       => ['edit'],
213
-            ],
214
-            'delete_categories'             => [
215
-                'func'       => '_delete_categories',
216
-                'capability' => 'ee_delete_event_category',
217
-                'noheader'   => true,
218
-            ],
219
-            'delete_category'               => [
220
-                'func'       => '_delete_categories',
221
-                'capability' => 'ee_delete_event_category',
222
-                'noheader'   => true,
223
-            ],
224
-            'insert_category'               => [
225
-                'func'       => '_insert_or_update_category',
226
-                'args'       => ['new_category' => true],
227
-                'capability' => 'ee_edit_event_category',
228
-                'noheader'   => true,
229
-            ],
230
-            'update_category'               => [
231
-                'func'       => '_insert_or_update_category',
232
-                'args'       => ['new_category' => false],
233
-                'capability' => 'ee_edit_event_category',
234
-                'noheader'   => true,
235
-            ],
236
-            'category_list'                 => [
237
-                'func'       => '_category_list_table',
238
-                'capability' => 'ee_manage_event_categories',
239
-            ],
240
-            'preview_deletion'              => [
241
-                'func'       => 'previewDeletion',
242
-                'capability' => 'ee_delete_events',
243
-            ],
244
-            'confirm_deletion'              => [
245
-                'func'       => 'confirmDeletion',
246
-                'capability' => 'ee_delete_events',
247
-                'noheader'   => true,
248
-            ],
249
-        ];
250
-    }
251
-
252
-
253
-    /**
254
-     * Set the _page_config property for this admin page group.
255
-     */
256
-    protected function _set_page_config()
257
-    {
258
-        $post_id            = $this->request->getRequestParam('post', 0, 'int');
259
-        $EVT_CAT_ID         = $this->request->getRequestParam('EVT_CAT_ID', 0, 'int');
260
-        $this->_page_config = [
261
-            'default'                => [
262
-                'nav'           => [
263
-                    'label' => esc_html__('Overview', 'event_espresso'),
264
-                    'order' => 10,
265
-                ],
266
-                'list_table'    => 'Events_Admin_List_Table',
267
-                'help_tabs'     => [
268
-                    'events_overview_help_tab'                       => [
269
-                        'title'    => esc_html__('Events Overview', 'event_espresso'),
270
-                        'filename' => 'events_overview',
271
-                    ],
272
-                    'events_overview_table_column_headings_help_tab' => [
273
-                        'title'    => esc_html__('Events Overview Table Column Headings', 'event_espresso'),
274
-                        'filename' => 'events_overview_table_column_headings',
275
-                    ],
276
-                    'events_overview_filters_help_tab'               => [
277
-                        'title'    => esc_html__('Events Overview Filters', 'event_espresso'),
278
-                        'filename' => 'events_overview_filters',
279
-                    ],
280
-                    'events_overview_view_help_tab'                  => [
281
-                        'title'    => esc_html__('Events Overview Views', 'event_espresso'),
282
-                        'filename' => 'events_overview_views',
283
-                    ],
284
-                    'events_overview_other_help_tab'                 => [
285
-                        'title'    => esc_html__('Events Overview Other', 'event_espresso'),
286
-                        'filename' => 'events_overview_other',
287
-                    ],
288
-                ],
289
-                'require_nonce' => false,
290
-            ],
291
-            'create_new'             => [
292
-                'nav'           => [
293
-                    'label'      => esc_html__('Add New Event', 'event_espresso'),
294
-                    'order'      => 5,
295
-                    'persistent' => false,
296
-                ],
297
-                'metaboxes'     => ['_register_event_editor_meta_boxes'],
298
-                'help_tabs'     => [
299
-                    'event_editor_help_tab'                            => [
300
-                        'title'    => esc_html__('Event Editor', 'event_espresso'),
301
-                        'filename' => 'event_editor',
302
-                    ],
303
-                    'event_editor_title_richtexteditor_help_tab'       => [
304
-                        'title'    => esc_html__('Event Title & Rich Text Editor', 'event_espresso'),
305
-                        'filename' => 'event_editor_title_richtexteditor',
306
-                    ],
307
-                    'event_editor_venue_details_help_tab'              => [
308
-                        'title'    => esc_html__('Event Venue Details', 'event_espresso'),
309
-                        'filename' => 'event_editor_venue_details',
310
-                    ],
311
-                    'event_editor_event_datetimes_help_tab'            => [
312
-                        'title'    => esc_html__('Event Datetimes', 'event_espresso'),
313
-                        'filename' => 'event_editor_event_datetimes',
314
-                    ],
315
-                    'event_editor_event_tickets_help_tab'              => [
316
-                        'title'    => esc_html__('Event Tickets', 'event_espresso'),
317
-                        'filename' => 'event_editor_event_tickets',
318
-                    ],
319
-                    'event_editor_event_registration_options_help_tab' => [
320
-                        'title'    => esc_html__('Event Registration Options', 'event_espresso'),
321
-                        'filename' => 'event_editor_event_registration_options',
322
-                    ],
323
-                    'event_editor_tags_categories_help_tab'            => [
324
-                        'title'    => esc_html__('Event Tags & Categories', 'event_espresso'),
325
-                        'filename' => 'event_editor_tags_categories',
326
-                    ],
327
-                    'event_editor_questions_registrants_help_tab'      => [
328
-                        'title'    => esc_html__('Questions for Registrants', 'event_espresso'),
329
-                        'filename' => 'event_editor_questions_registrants',
330
-                    ],
331
-                    'event_editor_save_new_event_help_tab'             => [
332
-                        'title'    => esc_html__('Save New Event', 'event_espresso'),
333
-                        'filename' => 'event_editor_save_new_event',
334
-                    ],
335
-                    'event_editor_other_help_tab'                      => [
336
-                        'title'    => esc_html__('Event Other', 'event_espresso'),
337
-                        'filename' => 'event_editor_other',
338
-                    ],
339
-                ],
340
-                'qtips'         => ['EE_Event_Editor_Decaf_Tips'],
341
-                'require_nonce' => false,
342
-            ],
343
-            'edit'                   => [
344
-                'nav'           => [
345
-                    'label'      => esc_html__('Edit Event', 'event_espresso'),
346
-                    'order'      => 5,
347
-                    'persistent' => false,
348
-                    'url'        => $post_id
349
-                        ? EE_Admin_Page::add_query_args_and_nonce(
350
-                            ['post' => $post_id, 'action' => 'edit'],
351
-                            $this->_current_page_view_url
352
-                        )
353
-                        : $this->_admin_base_url,
354
-                ],
355
-                'metaboxes'     => ['_register_event_editor_meta_boxes'],
356
-                'help_tabs'     => [
357
-                    'event_editor_help_tab'                            => [
358
-                        'title'    => esc_html__('Event Editor', 'event_espresso'),
359
-                        'filename' => 'event_editor',
360
-                    ],
361
-                    'event_editor_title_richtexteditor_help_tab'       => [
362
-                        'title'    => esc_html__('Event Title & Rich Text Editor', 'event_espresso'),
363
-                        'filename' => 'event_editor_title_richtexteditor',
364
-                    ],
365
-                    'event_editor_venue_details_help_tab'              => [
366
-                        'title'    => esc_html__('Event Venue Details', 'event_espresso'),
367
-                        'filename' => 'event_editor_venue_details',
368
-                    ],
369
-                    'event_editor_event_datetimes_help_tab'            => [
370
-                        'title'    => esc_html__('Event Datetimes', 'event_espresso'),
371
-                        'filename' => 'event_editor_event_datetimes',
372
-                    ],
373
-                    'event_editor_event_tickets_help_tab'              => [
374
-                        'title'    => esc_html__('Event Tickets', 'event_espresso'),
375
-                        'filename' => 'event_editor_event_tickets',
376
-                    ],
377
-                    'event_editor_event_registration_options_help_tab' => [
378
-                        'title'    => esc_html__('Event Registration Options', 'event_espresso'),
379
-                        'filename' => 'event_editor_event_registration_options',
380
-                    ],
381
-                    'event_editor_tags_categories_help_tab'            => [
382
-                        'title'    => esc_html__('Event Tags & Categories', 'event_espresso'),
383
-                        'filename' => 'event_editor_tags_categories',
384
-                    ],
385
-                    'event_editor_questions_registrants_help_tab'      => [
386
-                        'title'    => esc_html__('Questions for Registrants', 'event_espresso'),
387
-                        'filename' => 'event_editor_questions_registrants',
388
-                    ],
389
-                    'event_editor_save_new_event_help_tab'             => [
390
-                        'title'    => esc_html__('Save New Event', 'event_espresso'),
391
-                        'filename' => 'event_editor_save_new_event',
392
-                    ],
393
-                    'event_editor_other_help_tab'                      => [
394
-                        'title'    => esc_html__('Event Other', 'event_espresso'),
395
-                        'filename' => 'event_editor_other',
396
-                    ],
397
-                ],
398
-                'require_nonce' => false,
399
-            ],
400
-            'default_event_settings' => [
401
-                'nav'           => [
402
-                    'label' => esc_html__('Default Settings', 'event_espresso'),
403
-                    'order' => 40,
404
-                ],
405
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
406
-                'labels'        => [
407
-                    'publishbox' => esc_html__('Update Settings', 'event_espresso'),
408
-                ],
409
-                'help_tabs'     => [
410
-                    'default_settings_help_tab'        => [
411
-                        'title'    => esc_html__('Default Event Settings', 'event_espresso'),
412
-                        'filename' => 'events_default_settings',
413
-                    ],
414
-                    'default_settings_status_help_tab' => [
415
-                        'title'    => esc_html__('Default Registration Status', 'event_espresso'),
416
-                        'filename' => 'events_default_settings_status',
417
-                    ],
418
-                    'default_maximum_tickets_help_tab' => [
419
-                        'title'    => esc_html__('Default Maximum Tickets Per Order', 'event_espresso'),
420
-                        'filename' => 'events_default_settings_max_tickets',
421
-                    ],
422
-                ],
423
-                'require_nonce' => false,
424
-            ],
425
-            // template settings
426
-            'template_settings'      => [
427
-                'nav'           => [
428
-                    'label' => esc_html__('Templates', 'event_espresso'),
429
-                    'order' => 30,
430
-                ],
431
-                'metaboxes'     => $this->_default_espresso_metaboxes,
432
-                'help_tabs'     => [
433
-                    'general_settings_templates_help_tab' => [
434
-                        'title'    => esc_html__('Templates', 'event_espresso'),
435
-                        'filename' => 'general_settings_templates',
436
-                    ],
437
-                ],
438
-                'require_nonce' => false,
439
-            ],
440
-            // event category stuff
441
-            'add_category'           => [
442
-                'nav'           => [
443
-                    'label'      => esc_html__('Add Category', 'event_espresso'),
444
-                    'order'      => 15,
445
-                    'persistent' => false,
446
-                ],
447
-                'help_tabs'     => [
448
-                    'add_category_help_tab' => [
449
-                        'title'    => esc_html__('Add New Event Category', 'event_espresso'),
450
-                        'filename' => 'events_add_category',
451
-                    ],
452
-                ],
453
-                'metaboxes'     => ['_publish_post_box'],
454
-                'require_nonce' => false,
455
-            ],
456
-            'edit_category'          => [
457
-                'nav'           => [
458
-                    'label'      => esc_html__('Edit Category', 'event_espresso'),
459
-                    'order'      => 15,
460
-                    'persistent' => false,
461
-                    'url'        => $EVT_CAT_ID
462
-                        ? add_query_arg(
463
-                            ['EVT_CAT_ID' => $EVT_CAT_ID],
464
-                            $this->_current_page_view_url
465
-                        )
466
-                        : $this->_admin_base_url,
467
-                ],
468
-                'help_tabs'     => [
469
-                    'edit_category_help_tab' => [
470
-                        'title'    => esc_html__('Edit Event Category', 'event_espresso'),
471
-                        'filename' => 'events_edit_category',
472
-                    ],
473
-                ],
474
-                'metaboxes'     => ['_publish_post_box'],
475
-                'require_nonce' => false,
476
-            ],
477
-            'category_list'          => [
478
-                'nav'           => [
479
-                    'label' => esc_html__('Categories', 'event_espresso'),
480
-                    'order' => 20,
481
-                ],
482
-                'list_table'    => 'Event_Categories_Admin_List_Table',
483
-                'help_tabs'     => [
484
-                    'events_categories_help_tab'                       => [
485
-                        'title'    => esc_html__('Event Categories', 'event_espresso'),
486
-                        'filename' => 'events_categories',
487
-                    ],
488
-                    'events_categories_table_column_headings_help_tab' => [
489
-                        'title'    => esc_html__('Event Categories Table Column Headings', 'event_espresso'),
490
-                        'filename' => 'events_categories_table_column_headings',
491
-                    ],
492
-                    'events_categories_view_help_tab'                  => [
493
-                        'title'    => esc_html__('Event Categories Views', 'event_espresso'),
494
-                        'filename' => 'events_categories_views',
495
-                    ],
496
-                    'events_categories_other_help_tab'                 => [
497
-                        'title'    => esc_html__('Event Categories Other', 'event_espresso'),
498
-                        'filename' => 'events_categories_other',
499
-                    ],
500
-                ],
501
-                'metaboxes'     => $this->_default_espresso_metaboxes,
502
-                'require_nonce' => false,
503
-            ],
504
-            'preview_deletion'       => [
505
-                'nav'           => [
506
-                    'label'      => esc_html__('Preview Deletion', 'event_espresso'),
507
-                    'order'      => 15,
508
-                    'persistent' => false,
509
-                    'url'        => '',
510
-                ],
511
-                'require_nonce' => false,
512
-            ],
513
-        ];
514
-    }
515
-
516
-
517
-    /**
518
-     * Used to register any global screen options if necessary for every route in this admin page group.
519
-     */
520
-    protected function _add_screen_options()
521
-    {
522
-    }
523
-
524
-
525
-    /**
526
-     * Implementing the screen options for the 'default' route.
527
-     *
528
-     * @throws InvalidArgumentException
529
-     * @throws InvalidDataTypeException
530
-     * @throws InvalidInterfaceException
531
-     */
532
-    protected function _add_screen_options_default()
533
-    {
534
-        $this->_per_page_screen_option();
535
-    }
536
-
537
-
538
-    /**
539
-     * Implementing screen options for the category list route.
540
-     *
541
-     * @throws InvalidArgumentException
542
-     * @throws InvalidDataTypeException
543
-     * @throws InvalidInterfaceException
544
-     */
545
-    protected function _add_screen_options_category_list()
546
-    {
547
-        $page_title              = $this->_admin_page_title;
548
-        $this->_admin_page_title = esc_html__('Categories', 'event_espresso');
549
-        $this->_per_page_screen_option();
550
-        $this->_admin_page_title = $page_title;
551
-    }
552
-
553
-
554
-    /**
555
-     * Used to register any global feature pointers for the admin page group.
556
-     */
557
-    protected function _add_feature_pointers()
558
-    {
559
-    }
560
-
561
-
562
-    /**
563
-     * Registers and enqueues any global scripts and styles for the entire admin page group.
564
-     */
565
-    public function load_scripts_styles()
566
-    {
567
-        wp_register_style(
568
-            'events-admin-css',
569
-            EVENTS_ASSETS_URL . 'events-admin-page.css',
570
-            [],
571
-            EVENT_ESPRESSO_VERSION
572
-        );
573
-        wp_register_style(
574
-            'ee-cat-admin',
575
-            EVENTS_ASSETS_URL . 'ee-cat-admin.css',
576
-            [],
577
-            EVENT_ESPRESSO_VERSION
578
-        );
579
-        wp_enqueue_style('events-admin-css');
580
-        wp_enqueue_style('ee-cat-admin');
581
-        // scripts
582
-        wp_register_script(
583
-            'event_editor_js',
584
-            EVENTS_ASSETS_URL . 'event_editor.js',
585
-            ['ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'],
586
-            EVENT_ESPRESSO_VERSION,
587
-            true
588
-        );
589
-    }
590
-
591
-
592
-    /**
593
-     * Enqueuing scripts and styles specific to this view
594
-     */
595
-    public function load_scripts_styles_create_new()
596
-    {
597
-        $this->load_scripts_styles_edit();
598
-    }
599
-
600
-
601
-    /**
602
-     * Enqueuing scripts and styles specific to this view
603
-     */
604
-    public function load_scripts_styles_edit()
605
-    {
606
-        // styles
607
-        wp_enqueue_style('espresso-ui-theme');
608
-        wp_register_style(
609
-            'event-editor-css',
610
-            EVENTS_ASSETS_URL . 'event-editor.css',
611
-            ['ee-admin-css'],
612
-            EVENT_ESPRESSO_VERSION
613
-        );
614
-        wp_enqueue_style('event-editor-css');
615
-        // scripts
616
-        if (! $this->admin_config->useAdvancedEditor()) {
617
-            wp_register_script(
618
-                'event-datetime-metabox',
619
-                EVENTS_ASSETS_URL . 'event-datetime-metabox.js',
620
-                ['event_editor_js', 'ee-datepicker'],
621
-                EVENT_ESPRESSO_VERSION
622
-            );
623
-            wp_enqueue_script('event-datetime-metabox');
624
-        }
625
-    }
626
-
627
-
628
-    /**
629
-     * Populating the _views property for the category list table view.
630
-     */
631
-    protected function _set_list_table_views_category_list()
632
-    {
633
-        $this->_views = [
634
-            'all' => [
635
-                'slug'        => 'all',
636
-                'label'       => esc_html__('All', 'event_espresso'),
637
-                'count'       => 0,
638
-                'bulk_action' => [
639
-                    'delete_categories' => esc_html__('Delete Permanently', 'event_espresso'),
640
-                ],
641
-            ],
642
-        ];
643
-    }
644
-
645
-
646
-    /**
647
-     * For adding anything that fires on the admin_init hook for any route within this admin page group.
648
-     */
649
-    public function admin_init()
650
-    {
651
-        EE_Registry::$i18n_js_strings['image_confirm'] = esc_html__(
652
-            'Do you really want to delete this image? Please remember to update your event to complete the removal.',
653
-            'event_espresso'
654
-        );
655
-    }
656
-
657
-
658
-    /**
659
-     * For adding anything that should be triggered on the admin_notices hook for any route within this admin page
660
-     * group.
661
-     */
662
-    public function admin_notices()
663
-    {
664
-    }
665
-
666
-
667
-    /**
668
-     * For adding anything that should be triggered on the `admin_print_footer_scripts` hook for any route within
669
-     * this admin page group.
670
-     */
671
-    public function admin_footer_scripts()
672
-    {
673
-    }
674
-
675
-
676
-    /**
677
-     * Call this function to verify if an event is public and has tickets for sale.  If it does, then we need to show a
678
-     * warning (via EE_Error::add_error());
679
-     *
680
-     * @param EE_Event $event Event object
681
-     * @param string   $req_type
682
-     * @return void
683
-     * @throws EE_Error
684
-     * @throws ReflectionException
685
-     */
686
-    public function verify_event_edit($event = null, $req_type = '')
687
-    {
688
-        // don't need to do this when processing
689
-        if (! empty($req_type)) {
690
-            return;
691
-        }
692
-        // no event?
693
-        if (! $event instanceof EE_Event) {
694
-            $event = $this->_cpt_model_obj;
695
-        }
696
-        // STILL no event?
697
-        if (! $event instanceof EE_Event) {
698
-            return;
699
-        }
700
-        $orig_status = $event->status();
701
-        // first check if event is active.
702
-        if (
703
-            $orig_status === EEM_Event::cancelled
704
-            || $orig_status === EEM_Event::postponed
705
-            || $event->is_expired()
706
-            || $event->is_inactive()
707
-        ) {
708
-            return;
709
-        }
710
-        // made it here so it IS active... next check that any of the tickets are sold.
711
-        if ($event->is_sold_out(true)) {
712
-            if ($orig_status !== EEM_Event::sold_out && $event->status() !== $orig_status) {
713
-                EE_Error::add_attention(
714
-                    sprintf(
715
-                        esc_html__(
716
-                            '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.',
717
-                            'event_espresso'
718
-                        ),
719
-                        EEH_Template::pretty_status(EEM_Event::sold_out, false, 'sentence')
720
-                    )
721
-                );
722
-            }
723
-            return;
724
-        }
725
-        if ($orig_status === EEM_Event::sold_out) {
726
-            EE_Error::add_attention(
727
-                sprintf(
728
-                    esc_html__(
729
-                        '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.',
730
-                        'event_espresso'
731
-                    ),
732
-                    EEH_Template::pretty_status($event->status(), false, 'sentence')
733
-                )
734
-            );
735
-        }
736
-        // now we need to determine if the event has any tickets on sale.  If not then we dont' show the error
737
-        if (! $event->tickets_on_sale()) {
738
-            return;
739
-        }
740
-        // made it here so show warning
741
-        $this->_edit_event_warning();
742
-    }
743
-
744
-
745
-    /**
746
-     * This is the text used for when an event is being edited that is public and has tickets for sale.
747
-     * When needed, hook this into a EE_Error::add_error() notice.
748
-     *
749
-     * @access protected
750
-     * @return void
751
-     */
752
-    protected function _edit_event_warning()
753
-    {
754
-        // we don't want to add warnings during these requests
755
-        if ($this->request->getRequestParam('action') === 'editpost') {
756
-            return;
757
-        }
758
-        EE_Error::add_attention(
759
-            sprintf(
760
-                esc_html__(
761
-                    'Your event is open for registration. Making changes may disrupt any transactions in progress. %sLearn more%s',
762
-                    'event_espresso'
763
-                ),
764
-                '<a class="espresso-help-tab-lnk">',
765
-                '</a>'
766
-            )
767
-        );
768
-    }
769
-
770
-
771
-    /**
772
-     * When a user is creating a new event, notify them if they haven't set their timezone.
773
-     * Otherwise, do the normal logic
774
-     *
775
-     * @return void
776
-     * @throws EE_Error
777
-     * @throws InvalidArgumentException
778
-     * @throws InvalidDataTypeException
779
-     * @throws InvalidInterfaceException
780
-     */
781
-    protected function _create_new_cpt_item()
782
-    {
783
-        $has_timezone_string = get_option('timezone_string');
784
-        // only nag them about setting their timezone if it's their first event, and they haven't already done it
785
-        if (! $has_timezone_string && ! EEM_Event::instance()->exists([])) {
786
-            EE_Error::add_attention(
787
-                sprintf(
788
-                    esc_html__(
789
-                        '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',
790
-                        'event_espresso'
791
-                    ),
792
-                    '<br>',
793
-                    '<select id="timezone_string" name="timezone_string" aria-describedby="timezone-description">'
794
-                    . EEH_DTT_Helper::wp_timezone_choice('', EEH_DTT_Helper::get_user_locale())
795
-                    . '</select>',
796
-                    '<button class="button button--secondary timezone-submit">',
797
-                    '</button><span class="spinner"></span>'
798
-                ),
799
-                __FILE__,
800
-                __FUNCTION__,
801
-                __LINE__
802
-            );
803
-        }
804
-        parent::_create_new_cpt_item();
805
-    }
806
-
807
-
808
-    /**
809
-     * Sets the _views property for the default route in this admin page group.
810
-     */
811
-    protected function _set_list_table_views_default()
812
-    {
813
-        $this->_views = [
814
-            'all'   => [
815
-                'slug'        => 'all',
816
-                'label'       => esc_html__('View All Events', 'event_espresso'),
817
-                'count'       => 0,
818
-                'bulk_action' => [
819
-                    'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
820
-                ],
821
-            ],
822
-            'draft' => [
823
-                'slug'        => 'draft',
824
-                'label'       => esc_html__('Draft', 'event_espresso'),
825
-                'count'       => 0,
826
-                'bulk_action' => [
827
-                    'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
828
-                ],
829
-            ],
830
-        ];
831
-        if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) {
832
-            $this->_views['trash'] = [
833
-                'slug'        => 'trash',
834
-                'label'       => esc_html__('Trash', 'event_espresso'),
835
-                'count'       => 0,
836
-                'bulk_action' => [
837
-                    'restore_events' => esc_html__('Restore From Trash', 'event_espresso'),
838
-                    'delete_events'  => esc_html__('Delete Permanently', 'event_espresso'),
839
-                ],
840
-            ];
841
-        }
842
-    }
843
-
844
-
845
-    /**
846
-     * Provides the legend item array for the default list table view.
847
-     *
848
-     * @return array
849
-     * @throws EE_Error
850
-     * @throws EE_Error
851
-     */
852
-    protected function _event_legend_items()
853
-    {
854
-        $items    = [
855
-            'view_details'   => [
856
-                'class' => 'dashicons dashicons-visibility',
857
-                'desc'  => esc_html__('View Event', 'event_espresso'),
858
-            ],
859
-            'edit_event'     => [
860
-                'class' => 'dashicons dashicons-calendar-alt',
861
-                'desc'  => esc_html__('Edit Event Details', 'event_espresso'),
862
-            ],
863
-            'view_attendees' => [
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 = [
870
-            'sold_out_status'  => [
871
-                'class' => 'ee-status-legend ee-status-bg--' . EE_Datetime::sold_out,
872
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::sold_out, false, 'sentence'),
873
-            ],
874
-            'active_status'    => [
875
-                'class' => 'ee-status-legend ee-status-bg--' . EE_Datetime::active,
876
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::active, false, 'sentence'),
877
-            ],
878
-            'upcoming_status'  => [
879
-                'class' => 'ee-status-legend ee-status-bg--' . EE_Datetime::upcoming,
880
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::upcoming, false, 'sentence'),
881
-            ],
882
-            'postponed_status' => [
883
-                'class' => 'ee-status-legend ee-status-bg--' . EE_Datetime::postponed,
884
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::postponed, false, 'sentence'),
885
-            ],
886
-            'cancelled_status' => [
887
-                'class' => 'ee-status-legend ee-status-bg--' . EE_Datetime::cancelled,
888
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::cancelled, false, 'sentence'),
889
-            ],
890
-            'expired_status'   => [
891
-                'class' => 'ee-status-legend ee-status-bg--' . EE_Datetime::expired,
892
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::expired, false, 'sentence'),
893
-            ],
894
-            'inactive_status'  => [
895
-                'class' => 'ee-status-legend ee-status-bg--' . 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
-     * @throws EE_Error
907
-     * @throws InvalidArgumentException
908
-     * @throws InvalidDataTypeException
909
-     * @throws InvalidInterfaceException
910
-     * @throws ReflectionException
911
-     */
912
-    private function _event_model()
913
-    {
914
-        if (! $this->_event_model instanceof EEM_Event) {
915
-            $this->_event_model = EE_Registry::instance()->load_model('Event');
916
-        }
917
-        return $this->_event_model;
918
-    }
919
-
920
-
921
-    /**
922
-     * Adds extra buttons to the WP CPT permalink field row.
923
-     * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter.
924
-     *
925
-     * @param string $return    the current html
926
-     * @param int    $id        the post id for the page
927
-     * @param string $new_title What the title is
928
-     * @param string $new_slug  what the slug is
929
-     * @return string            The new html string for the permalink area
930
-     */
931
-    public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug)
932
-    {
933
-        // make sure this is only when editing
934
-        if (! empty($id)) {
935
-            $post = get_post($id);
936
-            $return .= '<a class="button button--small button--secondary" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#"  tabindex="-1">'
937
-                       . esc_html__('Shortcode', 'event_espresso')
938
-                       . '</a> ';
939
-            $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id='
940
-                       . $post->ID
941
-                       . ']">';
942
-        }
943
-        return $return;
944
-    }
945
-
946
-
947
-    /**
948
-     * _events_overview_list_table
949
-     * This contains the logic for showing the events_overview list
950
-     *
951
-     * @access protected
952
-     * @return void
953
-     * @throws DomainException
954
-     * @throws EE_Error
955
-     * @throws InvalidArgumentException
956
-     * @throws InvalidDataTypeException
957
-     * @throws InvalidInterfaceException
958
-     */
959
-    protected function _events_overview_list_table()
960
-    {
961
-        $after_list_table                           = [];
962
-        $links_html = EEH_HTML::div('', '', 'ee-admin-section ee-layout-stack');
963
-        $links_html .= EEH_HTML::h3(esc_html__('Links', 'event_espresso'));
964
-        $links_html .= EEH_HTML::div(
965
-            EEH_Template::get_button_or_link(
966
-                get_post_type_archive_link('espresso_events'),
967
-                esc_html__('View Event Archive Page', 'event_espresso'),
968
-                'button button--small button--secondary'
969
-            ),
970
-            '',
971
-            'ee-admin-button-row ee-admin-button-row--align-start'
972
-        );
973
-        $links_html .= EEH_HTML::divx();
974
-
975
-        $after_list_table['view_event_list_button'] = $links_html;
976
-
977
-        $after_list_table['legend'] = $this->_display_legend($this->_event_legend_items());
978
-        $this->_admin_page_title                    .= ' ' . $this->get_action_link_or_button(
979
-            'create_new',
980
-            'add',
981
-            [],
982
-            'add-new-h2'
983
-        );
984
-
985
-        $this->_template_args['after_list_table']   = array_merge(
986
-            (array) $this->_template_args['after_list_table'],
987
-            $after_list_table
988
-        );
989
-        $this->display_admin_list_table_page_with_no_sidebar();
990
-    }
991
-
992
-
993
-    /**
994
-     * this allows for extra misc actions in the default WP publish box
995
-     *
996
-     * @return void
997
-     * @throws DomainException
998
-     * @throws EE_Error
999
-     * @throws InvalidArgumentException
1000
-     * @throws InvalidDataTypeException
1001
-     * @throws InvalidInterfaceException
1002
-     * @throws ReflectionException
1003
-     */
1004
-    public function extra_misc_actions_publish_box()
1005
-    {
1006
-        $this->_generate_publish_box_extra_content();
1007
-    }
1008
-
1009
-
1010
-    /**
1011
-     * This is hooked into the WordPress do_action('save_post') hook and runs after the custom post type has been
1012
-     * saved.
1013
-     * Typically you would use this to save any additional data.
1014
-     * Keep in mind also that "save_post" runs on EVERY post update to the database.
1015
-     * ALSO very important.  When a post transitions from scheduled to published,
1016
-     * the save_post action is fired but you will NOT have any _POST data containing any extra info you may have from
1017
-     * other meta saves. So MAKE sure that you handle this accordingly.
1018
-     *
1019
-     * @access protected
1020
-     * @abstract
1021
-     * @param string $post_id The ID of the cpt that was saved (so you can link relationally)
1022
-     * @param object $post    The post object of the cpt that was saved.
1023
-     * @return void
1024
-     * @throws EE_Error
1025
-     * @throws InvalidArgumentException
1026
-     * @throws InvalidDataTypeException
1027
-     * @throws InvalidInterfaceException
1028
-     * @throws ReflectionException
1029
-     */
1030
-    protected function _insert_update_cpt_item($post_id, $post)
1031
-    {
1032
-        if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') {
1033
-            // get out we're not processing an event save.
1034
-            return;
1035
-        }
1036
-        $event_values = [
1037
-            'EVT_member_only'     => $this->request->getRequestParam('member_only', false, 'bool'),
1038
-            'EVT_allow_overflow'  => $this->request->getRequestParam('EVT_allow_overflow', false, 'bool'),
1039
-            'EVT_timezone_string' => $this->request->getRequestParam('timezone_string'),
1040
-        ];
1041
-        // check if the new EDTR reg options meta box is being used, and if so, don't run updates for legacy version
1042
-        if (! $this->admin_config->useAdvancedEditor() || ! $this->feature->allowed('use_reg_options_meta_box')) {
1043
-            $event_values['EVT_display_ticket_selector']     = $this->request->getRequestParam(
1044
-                'display_ticket_selector',
1045
-                false,
1046
-                'bool'
1047
-            );
1048
-            $event_values['EVT_additional_limit']            = min(
1049
-                apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255),
1050
-                $this->request->getRequestParam('additional_limit', null, 'int')
1051
-            );
1052
-            $event_values['EVT_default_registration_status'] = $this->request->getRequestParam(
1053
-                'EVT_default_registration_status',
1054
-                EE_Registry::instance()->CFG->registration->default_STS_ID
1055
-            );
1056
-
1057
-            $event_values['EVT_external_URL'] = $this->request->getRequestParam('externalURL');
1058
-            $event_values['EVT_phone']        = $this->request->getRequestParam('event_phone');
1059
-            $event_values['EVT_display_desc'] = $this->request->getRequestParam('display_desc', false, 'bool');
1060
-        }
1061
-        // update event
1062
-        $success = $this->_event_model()->update_by_ID($event_values, $post_id);
1063
-        // get event_object for other metaboxes...
1064
-        // though it would seem to make sense to just use $this->_event_model()->get_one_by_ID( $post_id )..
1065
-        // i have to setup where conditions to override the filters in the model
1066
-        // that filter out autodraft and inherit statuses so we GET the inherit id!
1067
-        $event = $this->_event_model()->get_one(
1068
-            [
1069
-                [
1070
-                    $this->_event_model()->primary_key_name() => $post_id,
1071
-                    'OR'                                      => [
1072
-                        'status'   => $post->post_status,
1073
-                        // if trying to "Publish" a sold out event, it's status will get switched back to "sold_out" in the db,
1074
-                        // but the returned object here has a status of "publish", so use the original post status as well
1075
-                        'status*1' => $this->request->getRequestParam('original_post_status'),
1076
-                    ],
1077
-                ],
1078
-            ]
1079
-        );
1080
-
1081
-        // the following are default callbacks for event attachment updates
1082
-        // that can be overridden by caffeinated functionality and/or addons.
1083
-        $event_update_callbacks = [];
1084
-        if (! $this->admin_config->useAdvancedEditor()) {
1085
-            $event_update_callbacks['_default_venue_update']   = [$this, '_default_venue_update'];
1086
-            $event_update_callbacks['_default_tickets_update'] = [$this, '_default_tickets_update'];
1087
-        }
1088
-        $event_update_callbacks = apply_filters(
1089
-            'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',
1090
-            $event_update_callbacks
1091
-        );
1092
-
1093
-        $att_success = true;
1094
-        foreach ($event_update_callbacks as $e_callback) {
1095
-            $_success = is_callable($e_callback)
1096
-                ? $e_callback($event, $this->request->requestParams())
1097
-                : false;
1098
-            // if ANY of these updates fail then we want the appropriate global error message
1099
-            $att_success = $_success !== false ? $att_success : false;
1100
-        }
1101
-        // any errors?
1102
-        if ($success && $att_success === false) {
1103
-            EE_Error::add_error(
1104
-                esc_html__(
1105
-                    'Event Details saved successfully but something went wrong with saving attachments.',
1106
-                    'event_espresso'
1107
-                ),
1108
-                __FILE__,
1109
-                __FUNCTION__,
1110
-                __LINE__
1111
-            );
1112
-        } elseif ($success === false) {
1113
-            EE_Error::add_error(
1114
-                esc_html__('Event Details did not save successfully.', 'event_espresso'),
1115
-                __FILE__,
1116
-                __FUNCTION__,
1117
-                __LINE__
1118
-            );
1119
-        }
1120
-    }
1121
-
1122
-
1123
-    /**
1124
-     * @param int $post_id
1125
-     * @param int $revision_id
1126
-     * @throws EE_Error
1127
-     * @throws EE_Error
1128
-     * @throws ReflectionException
1129
-     * @see parent::restore_item()
1130
-     */
1131
-    protected function _restore_cpt_item($post_id, $revision_id)
1132
-    {
1133
-        // copy existing event meta to new post
1134
-        $post_evt = $this->_event_model()->get_one_by_ID($post_id);
1135
-        if ($post_evt instanceof EE_Event) {
1136
-            // meta revision restore
1137
-            $post_evt->restore_revision($revision_id);
1138
-            // related objs restore
1139
-            $post_evt->restore_revision($revision_id, ['Venue', 'Datetime', 'Price']);
1140
-        }
1141
-    }
1142
-
1143
-
1144
-    /**
1145
-     * Attach the venue to the Event
1146
-     *
1147
-     * @param EE_Event $event Event Object to add the venue to
1148
-     * @param array    $data  The request data from the form
1149
-     * @return bool           Success or fail.
1150
-     * @throws EE_Error
1151
-     * @throws ReflectionException
1152
-     */
1153
-    protected function _default_venue_update(EE_Event $event, $data)
1154
-    {
1155
-        require_once(EE_MODELS . 'EEM_Venue.model.php');
1156
-        $venue_model = EE_Registry::instance()->load_model('Venue');
1157
-        $venue_id    = ! empty($data['venue_id']) ? $data['venue_id'] : null;
1158
-        // very important.  If we don't have a venue name...
1159
-        // then we'll get out because not necessary to create empty venue
1160
-        if (empty($data['venue_title'])) {
1161
-            return false;
1162
-        }
1163
-        $venue_array = [
1164
-            'VNU_wp_user'         => $event->get('EVT_wp_user'),
1165
-            'VNU_name'            => ! empty($data['venue_title']) ? $data['venue_title'] : null,
1166
-            'VNU_desc'            => ! empty($data['venue_description']) ? $data['venue_description'] : null,
1167
-            'VNU_identifier'      => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : null,
1168
-            'VNU_short_desc'      => ! empty($data['venue_short_description'])
1169
-                ? $data['venue_short_description']
1170
-                : null,
1171
-            'VNU_address'         => ! empty($data['address']) ? $data['address'] : null,
1172
-            'VNU_address2'        => ! empty($data['address2']) ? $data['address2'] : null,
1173
-            'VNU_city'            => ! empty($data['city']) ? $data['city'] : null,
1174
-            'STA_ID'              => ! empty($data['state']) ? $data['state'] : null,
1175
-            'CNT_ISO'             => ! empty($data['countries']) ? $data['countries'] : null,
1176
-            'VNU_zip'             => ! empty($data['zip']) ? $data['zip'] : null,
1177
-            'VNU_phone'           => ! empty($data['venue_phone']) ? $data['venue_phone'] : null,
1178
-            'VNU_capacity'        => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : null,
1179
-            'VNU_url'             => ! empty($data['venue_url']) ? $data['venue_url'] : null,
1180
-            'VNU_virtual_phone'   => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : null,
1181
-            'VNU_virtual_url'     => ! empty($data['virtual_url']) ? $data['virtual_url'] : null,
1182
-            'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0,
1183
-            'status'              => 'publish',
1184
-        ];
1185
-        // if we've got the venue_id then we're just updating the existing venue so let's do that and then get out.
1186
-        if (! empty($venue_id)) {
1187
-            $update_where  = [$venue_model->primary_key_name() => $venue_id];
1188
-            $rows_affected = $venue_model->update($venue_array, [$update_where]);
1189
-            // we've gotta make sure that the venue is always attached to a revision..
1190
-            // add_relation_to should take care of making sure that the relation is already present.
1191
-            $event->_add_relation_to($venue_id, 'Venue');
1192
-            return $rows_affected > 0;
1193
-        }
1194
-        // we insert the venue
1195
-        $venue_id = $venue_model->insert($venue_array);
1196
-        $event->_add_relation_to($venue_id, 'Venue');
1197
-        return ! empty($venue_id);
1198
-        // when we have the ancestor come in it's already been handled by the revision save.
1199
-    }
1200
-
1201
-
1202
-    /**
1203
-     * Handles saving everything related to Tickets (datetimes, tickets, prices)
1204
-     *
1205
-     * @param EE_Event $event The Event object we're attaching data to
1206
-     * @param array    $data  The request data from the form
1207
-     * @return array
1208
-     * @throws EE_Error
1209
-     * @throws ReflectionException
1210
-     * @throws Exception
1211
-     */
1212
-    protected function _default_tickets_update(EE_Event $event, $data)
1213
-    {
1214
-        if ($this->admin_config->useAdvancedEditor()) {
1215
-            return [];
1216
-        }
1217
-        $datetime       = null;
1218
-        $saved_tickets  = [];
1219
-        $event_timezone = $event->get_timezone();
1220
-        $date_formats   = ['Y-m-d', 'h:i a'];
1221
-        foreach ($data['edit_event_datetimes'] as $row => $datetime_data) {
1222
-            // trim all values to ensure any excess whitespace is removed.
1223
-            $datetime_data                = array_map('trim', $datetime_data);
1224
-            $datetime_data['DTT_EVT_end'] =
1225
-                isset($datetime_data['DTT_EVT_end']) && ! empty($datetime_data['DTT_EVT_end'])
1226
-                    ? $datetime_data['DTT_EVT_end']
1227
-                    : $datetime_data['DTT_EVT_start'];
1228
-            $datetime_values              = [
1229
-                'DTT_ID'        => ! empty($datetime_data['DTT_ID']) ? $datetime_data['DTT_ID'] : null,
1230
-                'DTT_EVT_start' => $datetime_data['DTT_EVT_start'],
1231
-                'DTT_EVT_end'   => $datetime_data['DTT_EVT_end'],
1232
-                'DTT_reg_limit' => empty($datetime_data['DTT_reg_limit']) ? EE_INF : $datetime_data['DTT_reg_limit'],
1233
-                'DTT_order'     => $row,
1234
-            ];
1235
-            // if we have an id then let's get existing object first and then set the new values.
1236
-            //  Otherwise we instantiate a new object for save.
1237
-            if (! empty($datetime_data['DTT_ID'])) {
1238
-                $datetime = EEM_Datetime::instance($event_timezone)->get_one_by_ID($datetime_data['DTT_ID']);
1239
-                if (! $datetime instanceof EE_Datetime) {
1240
-                    throw new RuntimeException(
1241
-                        sprintf(
1242
-                            esc_html__(
1243
-                                'Something went wrong! A valid Datetime could not be retrieved from the database using the supplied ID: %1$d',
1244
-                                'event_espresso'
1245
-                            ),
1246
-                            $datetime_data['DTT_ID']
1247
-                        )
1248
-                    );
1249
-                }
1250
-                $datetime->set_date_format($date_formats[0]);
1251
-                $datetime->set_time_format($date_formats[1]);
1252
-                foreach ($datetime_values as $field => $value) {
1253
-                    $datetime->set($field, $value);
1254
-                }
1255
-            } else {
1256
-                $datetime = EE_Datetime::new_instance($datetime_values, $event_timezone, $date_formats);
1257
-            }
1258
-            if (! $datetime instanceof EE_Datetime) {
1259
-                throw new RuntimeException(
1260
-                    sprintf(
1261
-                        esc_html__(
1262
-                            'Something went wrong! A valid Datetime could not be generated or retrieved using the supplied data: %1$s',
1263
-                            'event_espresso'
1264
-                        ),
1265
-                        print_r($datetime_values, true)
1266
-                    )
1267
-                );
1268
-            }
1269
-            // before going any further make sure our dates are setup correctly
1270
-            // so that the end date is always equal or greater than the start date.
1271
-            if ($datetime->get_raw('DTT_EVT_start') > $datetime->get_raw('DTT_EVT_end')) {
1272
-                $datetime->set('DTT_EVT_end', $datetime->get('DTT_EVT_start'));
1273
-                $datetime = EEH_DTT_Helper::date_time_add($datetime, 'DTT_EVT_end', 'days');
1274
-            }
1275
-            $datetime->save();
1276
-            $event->_add_relation_to($datetime, 'Datetime');
1277
-        }
1278
-        // no datetimes get deleted so we don't do any of that logic here.
1279
-        // update tickets next
1280
-        $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : [];
1281
-
1282
-        // set up some default start and end dates in case those are not present in the incoming data
1283
-        $default_start_date = new DateTime('now', new DateTimeZone($event->get_timezone()));
1284
-        $default_start_date = $default_start_date->format($date_formats[0] . ' ' . $date_formats[1]);
1285
-        // use the start date of the first datetime for the end date
1286
-        $first_datetime   = $event->first_datetime();
1287
-        $default_end_date = $first_datetime->start_date_and_time($date_formats[0], $date_formats[1]);
1288
-
1289
-        // now process the incoming data
1290
-        foreach ($data['edit_tickets'] as $row => $ticket_data) {
1291
-            $update_prices = false;
1292
-            $ticket_price  = isset($data['edit_prices'][ $row ][1]['PRC_amount'])
1293
-                ? $data['edit_prices'][ $row ][1]['PRC_amount']
1294
-                : 0;
1295
-            // trim inputs to ensure any excess whitespace is removed.
1296
-            $ticket_data   = array_map('trim', $ticket_data);
1297
-            $ticket_values = [
1298
-                'TKT_ID'          => ! empty($ticket_data['TKT_ID']) ? $ticket_data['TKT_ID'] : null,
1299
-                'TTM_ID'          => ! empty($ticket_data['TTM_ID']) ? $ticket_data['TTM_ID'] : 0,
1300
-                'TKT_name'        => ! empty($ticket_data['TKT_name']) ? $ticket_data['TKT_name'] : '',
1301
-                'TKT_description' => ! empty($ticket_data['TKT_description']) ? $ticket_data['TKT_description'] : '',
1302
-                'TKT_start_date'  => ! empty($ticket_data['TKT_start_date'])
1303
-                    ? $ticket_data['TKT_start_date']
1304
-                    : $default_start_date,
1305
-                'TKT_end_date'    => ! empty($ticket_data['TKT_end_date'])
1306
-                    ? $ticket_data['TKT_end_date']
1307
-                    : $default_end_date,
1308
-                'TKT_qty'         => ! empty($ticket_data['TKT_qty'])
1309
-                                     || (isset($ticket_data['TKT_qty']) && (int) $ticket_data['TKT_qty'] === 0)
1310
-                    ? $ticket_data['TKT_qty']
1311
-                    : EE_INF,
1312
-                'TKT_uses'        => ! empty($ticket_data['TKT_uses'])
1313
-                                     || (isset($ticket_data['TKT_uses']) && (int) $ticket_data['TKT_uses'] === 0)
1314
-                    ? $ticket_data['TKT_uses']
1315
-                    : EE_INF,
1316
-                'TKT_min'         => ! empty($ticket_data['TKT_min']) ? $ticket_data['TKT_min'] : 0,
1317
-                'TKT_max'         => ! empty($ticket_data['TKT_max']) ? $ticket_data['TKT_max'] : EE_INF,
1318
-                'TKT_order'       => isset($ticket_data['TKT_order']) ? $ticket_data['TKT_order'] : $row,
1319
-                'TKT_price'       => $ticket_price,
1320
-                'TKT_row'         => $row,
1321
-            ];
1322
-            // if this is a default ticket, then we need to set the TKT_ID to 0 and update accordingly,
1323
-            // which means in turn that the prices will become new prices as well.
1324
-            if (isset($ticket_data['TKT_is_default']) && $ticket_data['TKT_is_default']) {
1325
-                $ticket_values['TKT_ID']         = 0;
1326
-                $ticket_values['TKT_is_default'] = 0;
1327
-                $update_prices                   = true;
1328
-            }
1329
-            // if we have a TKT_ID then we need to get that existing TKT_obj and update it
1330
-            // we actually do our saves ahead of adding any relations because its entirely possible that this
1331
-            // ticket didn't get removed or added to any datetime in the session but DID have it's items modified.
1332
-            // keep in mind that if the ticket has been sold (and we have changed pricing information),
1333
-            // then we won't be updating the tkt but instead a new tkt will be created and the old one archived.
1334
-            if (! empty($ticket_data['TKT_ID'])) {
1335
-                $existing_ticket = EEM_Ticket::instance($event_timezone)->get_one_by_ID($ticket_data['TKT_ID']);
1336
-                if (! $existing_ticket instanceof EE_Ticket) {
1337
-                    throw new RuntimeException(
1338
-                        sprintf(
1339
-                            esc_html__(
1340
-                                'Something went wrong! A valid Ticket could not be retrieved from the database using the supplied ID: %1$d',
1341
-                                'event_espresso'
1342
-                            ),
1343
-                            $ticket_data['TKT_ID']
1344
-                        )
1345
-                    );
1346
-                }
1347
-                $ticket_sold = $existing_ticket->count_related(
1348
-                    'Registration',
1349
-                    [
1350
-                            [
1351
-                                'STS_ID' => [
1352
-                                    'NOT IN',
1353
-                                    [EEM_Registration::status_id_incomplete],
1354
-                                ],
1355
-                            ],
1356
-                        ]
1357
-                ) > 0;
1358
-                // let's just check the total price for the existing ticket and determine if it matches the new total price.
1359
-                // if they are different then we create a new ticket (if $ticket_sold)
1360
-                // if they aren't different then we go ahead and modify existing ticket.
1361
-                $create_new_ticket = $ticket_sold
1362
-                                     && $ticket_price !== $existing_ticket->price()
1363
-                                     && ! $existing_ticket->deleted();
1364
-                $existing_ticket->set_date_format($date_formats[0]);
1365
-                $existing_ticket->set_time_format($date_formats[1]);
1366
-                // set new values
1367
-                foreach ($ticket_values as $field => $value) {
1368
-                    if ($field == 'TKT_qty') {
1369
-                        $existing_ticket->set_qty($value);
1370
-                    } elseif ($field == 'TKT_price') {
1371
-                        $existing_ticket->set('TKT_price', $ticket_price);
1372
-                    } else {
1373
-                        $existing_ticket->set($field, $value);
1374
-                    }
1375
-                }
1376
-                $ticket = $existing_ticket;
1377
-                // if $create_new_ticket is false then we can safely update the existing ticket.
1378
-                //  Otherwise we have to create a new ticket.
1379
-                if ($create_new_ticket) {
1380
-                    // archive the old ticket first
1381
-                    $existing_ticket->set('TKT_deleted', 1);
1382
-                    $existing_ticket->save();
1383
-                    // make sure this ticket is still recorded in our $saved_tickets
1384
-                    // so we don't run it through the regular trash routine.
1385
-                    $saved_tickets[ $existing_ticket->ID() ] = $existing_ticket;
1386
-                    // create new ticket that's a copy of the existing except,
1387
-                    // (a new id of course and not archived) AND has the new TKT_price associated with it.
1388
-                    $new_ticket = clone $existing_ticket;
1389
-                    $new_ticket->set('TKT_ID', 0);
1390
-                    $new_ticket->set('TKT_deleted', 0);
1391
-                    $new_ticket->set('TKT_sold', 0);
1392
-                    // now we need to make sure that $new prices are created as well and attached to new ticket.
1393
-                    $update_prices = true;
1394
-                    $ticket        = $new_ticket;
1395
-                }
1396
-            } else {
1397
-                // no TKT_id so a new ticket
1398
-                $ticket_values['TKT_price'] = $ticket_price;
1399
-                $ticket                     = EE_Ticket::new_instance($ticket_values, $event_timezone, $date_formats);
1400
-                $update_prices              = true;
1401
-            }
1402
-            if (! $ticket instanceof EE_Ticket) {
1403
-                throw new RuntimeException(
1404
-                    sprintf(
1405
-                        esc_html__(
1406
-                            'Something went wrong! A valid Ticket could not be generated or retrieved using the supplied data: %1$s',
1407
-                            'event_espresso'
1408
-                        ),
1409
-                        print_r($ticket_values, true)
1410
-                    )
1411
-                );
1412
-            }
1413
-            // cap ticket qty by datetime reg limits
1414
-            $ticket->set_qty(min($ticket->qty(), $ticket->qty('reg_limit')));
1415
-            // update ticket.
1416
-            $ticket->save();
1417
-            // before going any further make sure our dates are setup correctly
1418
-            // so that the end date is always equal or greater than the start date.
1419
-            if ($ticket->get_raw('TKT_start_date') > $ticket->get_raw('TKT_end_date')) {
1420
-                $ticket->set('TKT_end_date', $ticket->get('TKT_start_date'));
1421
-                $ticket = EEH_DTT_Helper::date_time_add($ticket, 'TKT_end_date', 'days');
1422
-                $ticket->save();
1423
-            }
1424
-            // initially let's add the ticket to the datetime
1425
-            $datetime->_add_relation_to($ticket, 'Ticket');
1426
-            $saved_tickets[ $ticket->ID() ] = $ticket;
1427
-            // add prices to ticket
1428
-            $this->_add_prices_to_ticket($data['edit_prices'][ $row ], $ticket, $update_prices);
1429
-        }
1430
-        // however now we need to handle permanently deleting tickets via the ui.
1431
-        //  Keep in mind that the ui does not allow deleting/archiving tickets that have ticket sold.
1432
-        //  However, it does allow for deleting tickets that have no tickets sold,
1433
-        // in which case we want to get rid of permanently because there is no need to save in db.
1434
-        $old_tickets     = isset($old_tickets[0]) && $old_tickets[0] === '' ? [] : $old_tickets;
1435
-        $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets));
1436
-        foreach ($tickets_removed as $id) {
1437
-            $id = absint($id);
1438
-            // get the ticket for this id
1439
-            $ticket_to_remove = EEM_Ticket::instance()->get_one_by_ID($id);
1440
-            if (! $ticket_to_remove instanceof EE_Ticket) {
1441
-                continue;
1442
-            }
1443
-            // need to get all the related datetimes on this ticket and remove from every single one of them
1444
-            // (remember this process can ONLY kick off if there are NO tickets sold)
1445
-            $related_datetimes = $ticket_to_remove->get_many_related('Datetime');
1446
-            foreach ($related_datetimes as $related_datetime) {
1447
-                $ticket_to_remove->_remove_relation_to($related_datetime, 'Datetime');
1448
-            }
1449
-            // need to do the same for prices (except these prices can also be deleted because again,
1450
-            // tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived))
1451
-            $ticket_to_remove->delete_related_permanently('Price');
1452
-            // finally let's delete this ticket
1453
-            // (which should not be blocked at this point b/c we've removed all our relationships)
1454
-            $ticket_to_remove->delete_permanently();
1455
-        }
1456
-        return [$datetime, $saved_tickets];
1457
-    }
1458
-
1459
-
1460
-    /**
1461
-     * This attaches a list of given prices to a ticket.
1462
-     * Note we dont' have to worry about ever removing relationships (or archiving prices)
1463
-     * because if there is a change in price information on a ticket, a new ticket is created anyways
1464
-     * so the archived ticket will retain the old price info and prices are automatically "archived" via the ticket.
1465
-     *
1466
-     * @access  private
1467
-     * @param array     $prices_data Array of prices from the form.
1468
-     * @param EE_Ticket $ticket      EE_Ticket object that prices are being attached to.
1469
-     * @param bool      $new_prices  Whether attach existing incoming prices or create new ones.
1470
-     * @return  void
1471
-     * @throws EE_Error
1472
-     * @throws ReflectionException
1473
-     */
1474
-    private function _add_prices_to_ticket($prices_data, EE_Ticket $ticket, $new_prices = false)
1475
-    {
1476
-        $timezone = $ticket->get_timezone();
1477
-        foreach ($prices_data as $row => $price_data) {
1478
-            $price_values = [
1479
-                'PRC_ID'         => ! empty($price_data['PRC_ID']) ? $price_data['PRC_ID'] : null,
1480
-                'PRT_ID'         => ! empty($price_data['PRT_ID']) ? $price_data['PRT_ID'] : null,
1481
-                'PRC_amount'     => ! empty($price_data['PRC_amount']) ? $price_data['PRC_amount'] : 0,
1482
-                'PRC_name'       => ! empty($price_data['PRC_name']) ? $price_data['PRC_name'] : '',
1483
-                'PRC_desc'       => ! empty($price_data['PRC_desc']) ? $price_data['PRC_desc'] : '',
1484
-                'PRC_is_default' => 0, // make sure prices are NOT set as default from this context
1485
-                'PRC_order'      => $row,
1486
-            ];
1487
-            if ($new_prices || empty($price_values['PRC_ID'])) {
1488
-                $price_values['PRC_ID'] = 0;
1489
-                $price                  = EE_Price::new_instance($price_values, $timezone);
1490
-            } else {
1491
-                $price = EEM_Price::instance($timezone)->get_one_by_ID($price_data['PRC_ID']);
1492
-                // update this price with new values
1493
-                foreach ($price_values as $field => $new_price) {
1494
-                    $price->set($field, $new_price);
1495
-                }
1496
-            }
1497
-            if (! $price instanceof EE_Price) {
1498
-                throw new RuntimeException(
1499
-                    sprintf(
1500
-                        esc_html__(
1501
-                            'Something went wrong! A valid Price could not be generated or retrieved using the supplied data: %1$s',
1502
-                            'event_espresso'
1503
-                        ),
1504
-                        print_r($price_values, true)
1505
-                    )
1506
-                );
1507
-            }
1508
-            $price->save();
1509
-            $ticket->_add_relation_to($price, 'Price');
1510
-        }
1511
-    }
1512
-
1513
-
1514
-    /**
1515
-     * Add in our autosave ajax handlers
1516
-     *
1517
-     */
1518
-    protected function _ee_autosave_create_new()
1519
-    {
1520
-    }
1521
-
1522
-
1523
-    /**
1524
-     * More autosave handlers.
1525
-     */
1526
-    protected function _ee_autosave_edit()
1527
-    {
1528
-    }
1529
-
1530
-
1531
-    /**
1532
-     * @throws EE_Error
1533
-     * @throws ReflectionException
1534
-     */
1535
-    private function _generate_publish_box_extra_content()
1536
-    {
1537
-        // load formatter helper
1538
-        // args for getting related registrations
1539
-        $approved_query_args        = [
1540
-            [
1541
-                'REG_deleted' => 0,
1542
-                'STS_ID'      => EEM_Registration::status_id_approved,
1543
-            ],
1544
-        ];
1545
-        $not_approved_query_args    = [
1546
-            [
1547
-                'REG_deleted' => 0,
1548
-                'STS_ID'      => EEM_Registration::status_id_not_approved,
1549
-            ],
1550
-        ];
1551
-        $pending_payment_query_args = [
1552
-            [
1553
-                'REG_deleted' => 0,
1554
-                'STS_ID'      => EEM_Registration::status_id_pending_payment,
1555
-            ],
1556
-        ];
1557
-        // publish box
1558
-        $publish_box_extra_args = [
1559
-            'view_approved_reg_url'        => add_query_arg(
1560
-                [
1561
-                    'action'      => 'default',
1562
-                    'event_id'    => $this->_cpt_model_obj->ID(),
1563
-                    '_reg_status' => EEM_Registration::status_id_approved,
1564
-                ],
1565
-                REG_ADMIN_URL
1566
-            ),
1567
-            'view_not_approved_reg_url'    => add_query_arg(
1568
-                [
1569
-                    'action'      => 'default',
1570
-                    'event_id'    => $this->_cpt_model_obj->ID(),
1571
-                    '_reg_status' => EEM_Registration::status_id_not_approved,
1572
-                ],
1573
-                REG_ADMIN_URL
1574
-            ),
1575
-            'view_pending_payment_reg_url' => add_query_arg(
1576
-                [
1577
-                    'action'      => 'default',
1578
-                    'event_id'    => $this->_cpt_model_obj->ID(),
1579
-                    '_reg_status' => EEM_Registration::status_id_pending_payment,
1580
-                ],
1581
-                REG_ADMIN_URL
1582
-            ),
1583
-            'approved_regs'                => $this->_cpt_model_obj->count_related(
1584
-                'Registration',
1585
-                $approved_query_args
1586
-            ),
1587
-            'not_approved_regs'            => $this->_cpt_model_obj->count_related(
1588
-                'Registration',
1589
-                $not_approved_query_args
1590
-            ),
1591
-            'pending_payment_regs'         => $this->_cpt_model_obj->count_related(
1592
-                'Registration',
1593
-                $pending_payment_query_args
1594
-            ),
1595
-            'misc_pub_section_class'       => apply_filters(
1596
-                'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class',
1597
-                'misc-pub-section'
1598
-            ),
1599
-        ];
1600
-        ob_start();
1601
-        do_action(
1602
-            'AHEE__Events_Admin_Page___generate_publish_box_extra_content__event_editor_overview_add',
1603
-            $this->_cpt_model_obj
1604
-        );
1605
-        $publish_box_extra_args['event_editor_overview_add'] = ob_get_clean();
1606
-        // load template
1607
-        EEH_Template::display_template(
1608
-            EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php',
1609
-            $publish_box_extra_args
1610
-        );
1611
-    }
1612
-
1613
-
1614
-    /**
1615
-     * @return EE_Event
1616
-     */
1617
-    public function get_event_object()
1618
-    {
1619
-        return $this->_cpt_model_obj;
1620
-    }
1621
-
1622
-
1623
-
1624
-
1625
-    /** METABOXES * */
1626
-    /**
1627
-     * _register_event_editor_meta_boxes
1628
-     * add all metaboxes related to the event_editor
1629
-     *
1630
-     * @return void
1631
-     * @throws EE_Error
1632
-     * @throws ReflectionException
1633
-     */
1634
-    protected function _register_event_editor_meta_boxes()
1635
-    {
1636
-        $this->verify_cpt_object();
1637
-        $use_advanced_editor = $this->admin_config->useAdvancedEditor();
1638
-        // check if the new EDTR reg options meta box is being used, and if so, don't load the legacy version
1639
-        if (! $use_advanced_editor || ! $this->feature->allowed('use_reg_options_meta_box')) {
1640
-            $this->addMetaBox(
1641
-                'espresso_event_editor_event_options',
1642
-                esc_html__('Event Registration Options', 'event_espresso'),
1643
-                [$this, 'registration_options_meta_box'],
1644
-                $this->page_slug,
1645
-                'side'
1646
-            );
1647
-        }
1648
-        if (! $use_advanced_editor) {
1649
-            $this->addMetaBox(
1650
-                'espresso_event_editor_tickets',
1651
-                esc_html__('Event Datetime & Ticket', 'event_espresso'),
1652
-                [$this, 'ticket_metabox'],
1653
-                $this->page_slug,
1654
-                'normal',
1655
-                'high'
1656
-            );
1657
-        } elseif ($this->feature->allowed('use_reg_options_meta_box')) {
1658
-            add_action(
1659
-                'add_meta_boxes_espresso_events',
1660
-                function () {
1661
-                    global $current_screen;
1662
-                    remove_meta_box('authordiv', $current_screen, 'normal');
1663
-                },
1664
-                99
1665
-            );
1666
-        }
1667
-        // NOTE: if you're looking for other metaboxes in here,
1668
-        // where a metabox has a related management page in the admin
1669
-        // you will find it setup in the related management page's "_Hooks" file.
1670
-        // i.e. messages metabox is found in "espresso_events_Messages_Hooks.class.php".
1671
-    }
1672
-
1673
-
1674
-    /**
1675
-     * @throws DomainException
1676
-     * @throws EE_Error
1677
-     * @throws ReflectionException
1678
-     */
1679
-    public function ticket_metabox()
1680
-    {
1681
-        $existing_datetime_ids = $existing_ticket_ids = [];
1682
-        // defaults for template args
1683
-        $template_args = [
1684
-            'existing_datetime_ids'    => '',
1685
-            'event_datetime_help_link' => '',
1686
-            'ticket_options_help_link' => '',
1687
-            'time'                     => null,
1688
-            'ticket_rows'              => '',
1689
-            'existing_ticket_ids'      => '',
1690
-            'total_ticket_rows'        => 1,
1691
-            'ticket_js_structure'      => '',
1692
-            'trash_icon'               => 'dashicons dashicons-lock',
1693
-            'disabled'                 => '',
1694
-        ];
1695
-        $event_id      = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : null;
1696
-        /**
1697
-         * 1. Start with retrieving Datetimes
1698
-         * 2. Fore each datetime get related tickets
1699
-         * 3. For each ticket get related prices
1700
-         */
1701
-        /** @var EEM_Datetime $datetime_model */
1702
-        $datetime_model = EE_Registry::instance()->load_model('Datetime');
1703
-        /** @var EEM_Ticket $datetime_model */
1704
-        $ticket_model = EE_Registry::instance()->load_model('Ticket');
1705
-        $times        = $datetime_model->get_all_event_dates($event_id);
1706
-        /** @type EE_Datetime $first_datetime */
1707
-        $first_datetime = reset($times);
1708
-        // do we get related tickets?
1709
-        if (
1710
-            $first_datetime instanceof EE_Datetime
1711
-            && $first_datetime->ID() !== 0
1712
-        ) {
1713
-            $existing_datetime_ids[] = $first_datetime->get('DTT_ID');
1714
-            $template_args['time']   = $first_datetime;
1715
-            $related_tickets         = $first_datetime->tickets(
1716
-                [
1717
-                    ['OR' => ['TKT_deleted' => 1, 'TKT_deleted*' => 0]],
1718
-                    'default_where_conditions' => 'none',
1719
-                ]
1720
-            );
1721
-            if (! empty($related_tickets)) {
1722
-                $template_args['total_ticket_rows'] = count($related_tickets);
1723
-                $row                                = 0;
1724
-                foreach ($related_tickets as $ticket) {
1725
-                    $existing_ticket_ids[]        = $ticket->get('TKT_ID');
1726
-                    $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, false, $row);
1727
-                    $row++;
1728
-                }
1729
-            } else {
1730
-                $template_args['total_ticket_rows'] = 1;
1731
-                /** @type EE_Ticket $ticket */
1732
-                $ticket                       = $ticket_model->create_default_object();
1733
-                $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket);
1734
-            }
1735
-        } else {
1736
-            $template_args['time'] = $times[0];
1737
-            /** @type EE_Ticket[] $tickets */
1738
-            $tickets                      = $ticket_model->get_all_default_tickets();
1739
-            $template_args['ticket_rows'] .= $this->_get_ticket_row($tickets[1]);
1740
-            // NOTE: we're just sending the first default row
1741
-            // (decaf can't manage default tickets so this should be sufficient);
1742
-        }
1743
-        $template_args['event_datetime_help_link'] = $this->_get_help_tab_link(
1744
-            'event_editor_event_datetimes_help_tab'
1745
-        );
1746
-        $template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info');
1747
-        $template_args['existing_datetime_ids']    = implode(',', $existing_datetime_ids);
1748
-        $template_args['existing_ticket_ids']      = implode(',', $existing_ticket_ids);
1749
-        $template_args['ticket_js_structure']      = $this->_get_ticket_row(
1750
-            $ticket_model->create_default_object(),
1751
-            true
1752
-        );
1753
-        $template                                  = apply_filters(
1754
-            'FHEE__Events_Admin_Page__ticket_metabox__template',
1755
-            EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php'
1756
-        );
1757
-        EEH_Template::display_template($template, $template_args);
1758
-    }
1759
-
1760
-
1761
-    /**
1762
-     * Setup an individual ticket form for the decaf event editor page
1763
-     *
1764
-     * @access private
1765
-     * @param EE_Ticket $ticket   the ticket object
1766
-     * @param boolean   $skeleton whether we're generating a skeleton for js manipulation
1767
-     * @param int       $row
1768
-     * @return string generated html for the ticket row.
1769
-     * @throws EE_Error
1770
-     * @throws ReflectionException
1771
-     */
1772
-    private function _get_ticket_row($ticket, $skeleton = false, $row = 0)
1773
-    {
1774
-        $template_args = [
1775
-            'tkt_status_class'    => ' tkt-status-' . $ticket->ticket_status(),
1776
-            'tkt_archive_class'   => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived'
1777
-                : '',
1778
-            'ticketrow'           => $skeleton ? 'TICKETNUM' : $row,
1779
-            'TKT_ID'              => $ticket->get('TKT_ID'),
1780
-            'TKT_name'            => $ticket->get('TKT_name'),
1781
-            'TKT_start_date'      => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'),
1782
-            'TKT_end_date'        => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'),
1783
-            'TKT_is_default'      => $ticket->get('TKT_is_default'),
1784
-            'TKT_qty'             => $ticket->get_pretty('TKT_qty', 'input'),
1785
-            'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets',
1786
-            'TKT_sold'            => $skeleton ? 0 : $ticket->get('TKT_sold'),
1787
-            'trash_icon'          => ($skeleton || (! empty($ticket) && ! $ticket->get('TKT_deleted')))
1788
-                                     && (! empty($ticket) && $ticket->get('TKT_sold') === 0)
1789
-                ? 'trash-icon dashicons dashicons-post-trash clickable' : 'dashicons dashicons-lock',
1790
-            'disabled'            => $skeleton || (! empty($ticket) && ! $ticket->get('TKT_deleted')) ? ''
1791
-                : ' disabled=disabled',
1792
-        ];
1793
-        $price         = $ticket->ID() !== 0
1794
-            ? $ticket->get_first_related('Price', ['default_where_conditions' => 'none'])
1795
-            : null;
1796
-        $price         = $price instanceof EE_Price
1797
-            ? $price
1798
-            : EEM_Price::instance()->create_default_object();
1799
-        $price_args    = [
1800
-            'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,
1801
-            'PRC_amount'            => $price->get('PRC_amount'),
1802
-            'PRT_ID'                => $price->get('PRT_ID'),
1803
-            'PRC_ID'                => $price->get('PRC_ID'),
1804
-            'PRC_is_default'        => $price->get('PRC_is_default'),
1805
-        ];
1806
-        // make sure we have default start and end dates if skeleton
1807
-        // handle rows that should NOT be empty
1808
-        if (empty($template_args['TKT_start_date'])) {
1809
-            // if empty then the start date will be now.
1810
-            $template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp'));
1811
-        }
1812
-        if (empty($template_args['TKT_end_date'])) {
1813
-            // get the earliest datetime (if present);
1814
-            $earliest_datetime             = $this->_cpt_model_obj->ID() > 0
1815
-                ? $this->_cpt_model_obj->get_first_related(
1816
-                    'Datetime',
1817
-                    ['order_by' => ['DTT_EVT_start' => 'ASC']]
1818
-                )
1819
-                : null;
1820
-            $template_args['TKT_end_date'] = $earliest_datetime instanceof EE_Datetime
1821
-                ? $earliest_datetime->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a')
1822
-                : date('Y-m-d h:i a', mktime(0, 0, 0, date('m'), date('d') + 7, date('Y')));
1823
-        }
1824
-        $template_args = array_merge($template_args, $price_args);
1825
-        $template      = apply_filters(
1826
-            'FHEE__Events_Admin_Page__get_ticket_row__template',
1827
-            EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php',
1828
-            $ticket
1829
-        );
1830
-        return EEH_Template::display_template($template, $template_args, true);
1831
-    }
1832
-
1833
-
1834
-    /**
1835
-     * @throws EE_Error
1836
-     * @throws ReflectionException
1837
-     */
1838
-    public function registration_options_meta_box()
1839
-    {
1840
-        $yes_no_values             = [
1841
-            ['id' => true, 'text' => esc_html__('Yes', 'event_espresso')],
1842
-            ['id' => false, 'text' => esc_html__('No', 'event_espresso')],
1843
-        ];
1844
-        $default_reg_status_values = EEM_Registration::reg_status_array(
1845
-            [
1846
-                EEM_Registration::status_id_cancelled,
1847
-                EEM_Registration::status_id_declined,
1848
-                EEM_Registration::status_id_incomplete,
1849
-            ],
1850
-            true
1851
-        );
1852
-        // $template_args['is_active_select'] = EEH_Form_Fields::select_input('is_active', $yes_no_values, $this->_cpt_model_obj->is_active());
1853
-        $template_args['_event']                          = $this->_cpt_model_obj;
1854
-        $template_args['event']                           = $this->_cpt_model_obj;
1855
-        $template_args['active_status']                   = $this->_cpt_model_obj->pretty_active_status(false);
1856
-        $template_args['additional_limit']                = $this->_cpt_model_obj->additional_limit();
1857
-        $template_args['default_registration_status']     = EEH_Form_Fields::select_input(
1858
-            'default_reg_status',
1859
-            $default_reg_status_values,
1860
-            $this->_cpt_model_obj->default_registration_status()
1861
-        );
1862
-        $template_args['display_description']             = EEH_Form_Fields::select_input(
1863
-            'display_desc',
1864
-            $yes_no_values,
1865
-            $this->_cpt_model_obj->display_description()
1866
-        );
1867
-        $template_args['display_ticket_selector']         = EEH_Form_Fields::select_input(
1868
-            'display_ticket_selector',
1869
-            $yes_no_values,
1870
-            $this->_cpt_model_obj->display_ticket_selector(),
1871
-            '',
1872
-            '',
1873
-            false
1874
-        );
1875
-        $template_args['additional_registration_options'] = apply_filters(
1876
-            'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options',
1877
-            '',
1878
-            $template_args,
1879
-            $yes_no_values,
1880
-            $default_reg_status_values
1881
-        );
1882
-        EEH_Template::display_template(
1883
-            EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php',
1884
-            $template_args
1885
-        );
1886
-    }
1887
-
1888
-
1889
-    /**
1890
-     * _get_events()
1891
-     * This method simply returns all the events (for the given _view and paging)
1892
-     *
1893
-     * @access public
1894
-     * @param int  $per_page     count of items per page (20 default);
1895
-     * @param int  $current_page what is the current page being viewed.
1896
-     * @param bool $count        if TRUE then we just return a count of ALL events matching the given _view.
1897
-     *                           If FALSE then we return an array of event objects
1898
-     *                           that match the given _view and paging parameters.
1899
-     * @return array|int         an array of event objects or a count of them.
1900
-     * @throws Exception
1901
-     */
1902
-    public function get_events($per_page = 10, $current_page = 1, $count = false)
1903
-    {
1904
-        $EEM_Event   = $this->_event_model();
1905
-        $offset      = ($current_page - 1) * $per_page;
1906
-        $limit       = $count ? null : $offset . ',' . $per_page;
1907
-        $orderby     = $this->request->getRequestParam('orderby', 'EVT_ID');
1908
-        $order       = $this->request->getRequestParam('order', 'DESC');
1909
-        $month_range = $this->request->getRequestParam('month_range');
1910
-        if ($month_range) {
1911
-            $pieces = explode(' ', $month_range, 3);
1912
-            // simulate the FIRST day of the month, that fixes issues for months like February
1913
-            // where PHP doesn't know what to assume for date.
1914
-            // @see https://events.codebasehq.com/projects/event-espresso/tickets/10437
1915
-            $month_r = ! empty($pieces[0]) ? date('m', EEH_DTT_Helper::first_of_month_timestamp($pieces[0])) : '';
1916
-            $year_r  = ! empty($pieces[1]) ? $pieces[1] : '';
1917
-        }
1918
-        $where  = [];
1919
-        $status = $this->request->getRequestParam('status');
1920
-        // determine what post_status our condition will have for the query.
1921
-        switch ($status) {
1922
-            case 'month':
1923
-            case 'today':
1924
-            case null:
1925
-            case 'all':
1926
-                break;
1927
-            case 'draft':
1928
-                $where['status'] = ['IN', ['draft', 'auto-draft']];
1929
-                break;
1930
-            default:
1931
-                $where['status'] = $status;
1932
-        }
1933
-        // categories? The default for all categories is -1
1934
-        $category = $this->request->getRequestParam('EVT_CAT', -1, 'int');
1935
-        if ($category !== -1) {
1936
-            $where['Term_Taxonomy.taxonomy'] = EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY;
1937
-            $where['Term_Taxonomy.term_id']  = $category;
1938
-        }
1939
-        // date where conditions
1940
-        $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start');
1941
-        if ($month_range) {
1942
-            $DateTime = new DateTime(
1943
-                $year_r . '-' . $month_r . '-01 00:00:00',
1944
-                new DateTimeZone('UTC')
1945
-            );
1946
-            $start    = $DateTime->getTimestamp();
1947
-            // set the datetime to be the end of the month
1948
-            $DateTime->setDate(
1949
-                $year_r,
1950
-                $month_r,
1951
-                $DateTime->format('t')
1952
-            )->setTime(23, 59, 59);
1953
-            $end                             = $DateTime->getTimestamp();
1954
-            $where['Datetime.DTT_EVT_start'] = ['BETWEEN', [$start, $end]];
1955
-        } elseif ($status === 'today') {
1956
-            $DateTime                        =
1957
-                new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone()));
1958
-            $start                           = $DateTime->setTime(0, 0)->format(implode(' ', $start_formats));
1959
-            $end                             = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats));
1960
-            $where['Datetime.DTT_EVT_start'] = ['BETWEEN', [$start, $end]];
1961
-        } elseif ($status === 'month') {
1962
-            $now                             = date('Y-m-01');
1963
-            $DateTime                        =
1964
-                new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone()));
1965
-            $start                           = $DateTime->setTime(0, 0)->format(implode(' ', $start_formats));
1966
-            $end                             = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t'))
1967
-                                                        ->setTime(23, 59, 59)
1968
-                                                        ->format(implode(' ', $start_formats));
1969
-            $where['Datetime.DTT_EVT_start'] = ['BETWEEN', [$start, $end]];
1970
-        }
1971
-        if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
1972
-            $where['EVT_wp_user'] = get_current_user_id();
1973
-        } else {
1974
-            if (! isset($where['status'])) {
1975
-                if (! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) {
1976
-                    $where['OR'] = [
1977
-                        'status*restrict_private' => ['!=', 'private'],
1978
-                        'AND'                     => [
1979
-                            'status*inclusive' => ['=', 'private'],
1980
-                            'EVT_wp_user'      => get_current_user_id(),
1981
-                        ],
1982
-                    ];
1983
-                }
1984
-            }
1985
-        }
1986
-        $wp_user = $this->request->getRequestParam('EVT_wp_user', 0, 'int');
1987
-        if (
1988
-            $wp_user
1989
-            && $wp_user !== get_current_user_id()
1990
-            && EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')
1991
-        ) {
1992
-            $where['EVT_wp_user'] = $wp_user;
1993
-        }
1994
-        // search query handling
1995
-        $search_term = $this->request->getRequestParam('s');
1996
-        if ($search_term) {
1997
-            $search_term = '%' . $search_term . '%';
1998
-            $where['OR'] = [
1999
-                'EVT_name'       => ['LIKE', $search_term],
2000
-                'EVT_desc'       => ['LIKE', $search_term],
2001
-                'EVT_short_desc' => ['LIKE', $search_term],
2002
-            ];
2003
-        }
2004
-        // filter events by venue.
2005
-        $venue = $this->request->getRequestParam('venue', 0, 'int');
2006
-        if ($venue) {
2007
-            $where['Venue.VNU_ID'] = $venue;
2008
-        }
2009
-        $request_params = $this->request->requestParams();
2010
-        $where          = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $request_params);
2011
-        $query_params   = apply_filters(
2012
-            'FHEE__Events_Admin_Page__get_events__query_params',
2013
-            [
2014
-                $where,
2015
-                'limit'    => $limit,
2016
-                'order_by' => $orderby,
2017
-                'order'    => $order,
2018
-                'group_by' => 'EVT_ID',
2019
-            ],
2020
-            $request_params
2021
-        );
2022
-
2023
-        // let's first check if we have special requests coming in.
2024
-        $active_status = $this->request->getRequestParam('active_status');
2025
-        if ($active_status) {
2026
-            switch ($active_status) {
2027
-                case 'upcoming':
2028
-                    return $EEM_Event->get_upcoming_events($query_params, $count);
2029
-                case 'expired':
2030
-                    return $EEM_Event->get_expired_events($query_params, $count);
2031
-                case 'active':
2032
-                    return $EEM_Event->get_active_events($query_params, $count);
2033
-                case 'inactive':
2034
-                    return $EEM_Event->get_inactive_events($query_params, $count);
2035
-            }
2036
-        }
2037
-
2038
-        return $count ? $EEM_Event->count([$where], 'EVT_ID', true) : $EEM_Event->get_all($query_params);
2039
-    }
2040
-
2041
-
2042
-    /**
2043
-     * handling for WordPress CPT actions (trash, restore, delete)
2044
-     *
2045
-     * @param string $post_id
2046
-     * @throws EE_Error
2047
-     * @throws ReflectionException
2048
-     */
2049
-    public function trash_cpt_item($post_id)
2050
-    {
2051
-        $this->request->setRequestParam('EVT_ID', $post_id);
2052
-        $this->_trash_or_restore_event('trash', false);
2053
-    }
2054
-
2055
-
2056
-    /**
2057
-     * @param string $post_id
2058
-     * @throws EE_Error
2059
-     * @throws ReflectionException
2060
-     */
2061
-    public function restore_cpt_item($post_id)
2062
-    {
2063
-        $this->request->setRequestParam('EVT_ID', $post_id);
2064
-        $this->_trash_or_restore_event('draft', false);
2065
-    }
2066
-
2067
-
2068
-    /**
2069
-     * @param string $post_id
2070
-     * @throws EE_Error
2071
-     * @throws EE_Error
2072
-     */
2073
-    public function delete_cpt_item($post_id)
2074
-    {
2075
-        throw new EE_Error(
2076
-            esc_html__(
2077
-                'Please contact Event Espresso support with the details of the steps taken to produce this error.',
2078
-                'event_espresso'
2079
-            )
2080
-        );
2081
-        // $this->request->setRequestParam('EVT_ID', $post_id);
2082
-        // $this->_delete_event();
2083
-    }
2084
-
2085
-
2086
-    /**
2087
-     * _trash_or_restore_event
2088
-     *
2089
-     * @access protected
2090
-     * @param string $event_status
2091
-     * @param bool   $redirect_after
2092
-     * @throws EE_Error
2093
-     * @throws EE_Error
2094
-     * @throws ReflectionException
2095
-     */
2096
-    protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = true)
2097
-    {
2098
-        // determine the event id and set to array.
2099
-        $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int');
2100
-        // loop thru events
2101
-        if ($EVT_ID) {
2102
-            // clean status
2103
-            $event_status = sanitize_key($event_status);
2104
-            // grab status
2105
-            if (! empty($event_status)) {
2106
-                $success = $this->_change_event_status($EVT_ID, $event_status);
2107
-            } else {
2108
-                $success = false;
2109
-                $msg     = esc_html__(
2110
-                    'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.',
2111
-                    'event_espresso'
2112
-                );
2113
-                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2114
-            }
2115
-        } else {
2116
-            $success = false;
2117
-            $msg     = esc_html__(
2118
-                'An error occurred. The event could not be moved to the trash because a valid event ID was not not supplied.',
2119
-                'event_espresso'
2120
-            );
2121
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2122
-        }
2123
-        $action = $event_status === 'trash' ? 'moved to the trash' : 'restored from the trash';
2124
-        if ($redirect_after) {
2125
-            $this->_redirect_after_action($success, 'Event', $action, ['action' => 'default']);
2126
-        }
2127
-    }
2128
-
2129
-
2130
-    /**
2131
-     * _trash_or_restore_events
2132
-     *
2133
-     * @access protected
2134
-     * @param string $event_status
2135
-     * @return void
2136
-     * @throws EE_Error
2137
-     * @throws EE_Error
2138
-     * @throws ReflectionException
2139
-     */
2140
-    protected function _trash_or_restore_events($event_status = 'trash')
2141
-    {
2142
-        // clean status
2143
-        $event_status = sanitize_key($event_status);
2144
-        // grab status
2145
-        if (! empty($event_status)) {
2146
-            $success = true;
2147
-            // determine the event id and set to array.
2148
-            $EVT_IDs = $this->request->getRequestParam('EVT_IDs', [], 'int', true);
2149
-            // loop thru events
2150
-            foreach ($EVT_IDs as $EVT_ID) {
2151
-                if ($EVT_ID = absint($EVT_ID)) {
2152
-                    $results = $this->_change_event_status($EVT_ID, $event_status);
2153
-                    $success = $results !== false ? $success : false;
2154
-                } else {
2155
-                    $msg = sprintf(
2156
-                        esc_html__(
2157
-                            'An error occurred. Event #%d could not be moved to the trash because a valid event ID was not not supplied.',
2158
-                            'event_espresso'
2159
-                        ),
2160
-                        $EVT_ID
2161
-                    );
2162
-                    EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2163
-                    $success = false;
2164
-                }
2165
-            }
2166
-        } else {
2167
-            $success = false;
2168
-            $msg     = esc_html__(
2169
-                'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.',
2170
-                'event_espresso'
2171
-            );
2172
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2173
-        }
2174
-        // in order to force a pluralized result message we need to send back a success status greater than 1
2175
-        $success = $success ? 2 : false;
2176
-        $action  = $event_status === 'trash' ? 'moved to the trash' : 'restored from the trash';
2177
-        $this->_redirect_after_action($success, 'Events', $action, ['action' => 'default']);
2178
-    }
2179
-
2180
-
2181
-    /**
2182
-     * @param int    $EVT_ID
2183
-     * @param string $event_status
2184
-     * @return bool
2185
-     * @throws EE_Error
2186
-     * @throws ReflectionException
2187
-     */
2188
-    private function _change_event_status($EVT_ID = 0, $event_status = '')
2189
-    {
2190
-        // grab event id
2191
-        if (! $EVT_ID) {
2192
-            $msg = esc_html__(
2193
-                'An error occurred. No Event ID or an invalid Event ID was received.',
2194
-                'event_espresso'
2195
-            );
2196
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2197
-            return false;
2198
-        }
2199
-        $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID);
2200
-        // clean status
2201
-        $event_status = sanitize_key($event_status);
2202
-        // grab status
2203
-        if (empty($event_status)) {
2204
-            $msg = esc_html__(
2205
-                'An error occurred. No Event Status or an invalid Event Status was received.',
2206
-                'event_espresso'
2207
-            );
2208
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2209
-            return false;
2210
-        }
2211
-        // was event trashed or restored ?
2212
-        switch ($event_status) {
2213
-            case 'draft':
2214
-                $action = 'restored from the trash';
2215
-                $hook   = 'AHEE_event_restored_from_trash';
2216
-                break;
2217
-            case 'trash':
2218
-                $action = 'moved to the trash';
2219
-                $hook   = 'AHEE_event_moved_to_trash';
2220
-                break;
2221
-            default:
2222
-                $action = 'updated';
2223
-                $hook   = false;
2224
-        }
2225
-        // use class to change status
2226
-        $this->_cpt_model_obj->set_status($event_status);
2227
-        $success = $this->_cpt_model_obj->save();
2228
-        if (! $success) {
2229
-            $msg = sprintf(esc_html__('An error occurred. The event could not be %s.', 'event_espresso'), $action);
2230
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2231
-            return false;
2232
-        }
2233
-        if ($hook) {
2234
-            do_action($hook);
2235
-        }
2236
-        return true;
2237
-    }
2238
-
2239
-
2240
-    /**
2241
-     * @param array $event_ids
2242
-     * @return array
2243
-     * @since   4.10.23.p
2244
-     */
2245
-    private function cleanEventIds(array $event_ids)
2246
-    {
2247
-        return array_map('absint', $event_ids);
2248
-    }
2249
-
2250
-
2251
-    /**
2252
-     * @return array
2253
-     * @since   4.10.23.p
2254
-     */
2255
-    private function getEventIdsFromRequest()
2256
-    {
2257
-        if ($this->request->requestParamIsSet('EVT_IDs')) {
2258
-            return $this->request->getRequestParam('EVT_IDs', [], 'int', true);
2259
-        } else {
2260
-            return $this->request->getRequestParam('EVT_ID', [], 'int', true);
2261
-        }
2262
-    }
2263
-
2264
-
2265
-    /**
2266
-     * @param bool $preview_delete
2267
-     * @throws EE_Error
2268
-     */
2269
-    protected function _delete_event($preview_delete = true)
2270
-    {
2271
-        $this->_delete_events($preview_delete);
2272
-    }
2273
-
2274
-
2275
-    /**
2276
-     * Gets the tree traversal batch persister.
2277
-     *
2278
-     * @return NodeGroupDao
2279
-     * @throws InvalidArgumentException
2280
-     * @throws InvalidDataTypeException
2281
-     * @throws InvalidInterfaceException
2282
-     * @since 4.10.12.p
2283
-     */
2284
-    protected function getModelObjNodeGroupPersister()
2285
-    {
2286
-        if (! $this->model_obj_node_group_persister instanceof NodeGroupDao) {
2287
-            $this->model_obj_node_group_persister =
2288
-                $this->getLoader()->load('\EventEspresso\core\services\orm\tree_traversal\NodeGroupDao');
2289
-        }
2290
-        return $this->model_obj_node_group_persister;
2291
-    }
2292
-
2293
-
2294
-    /**
2295
-     * @param bool $preview_delete
2296
-     * @return void
2297
-     * @throws EE_Error
2298
-     */
2299
-    protected function _delete_events($preview_delete = true)
2300
-    {
2301
-        $event_ids = $this->getEventIdsFromRequest();
2302
-        if ($preview_delete) {
2303
-            $this->generateDeletionPreview($event_ids);
2304
-        } else {
2305
-            EEM_Event::instance()->delete_permanently([['EVT_ID' => ['IN', $event_ids]]]);
2306
-        }
2307
-    }
2308
-
2309
-
2310
-    /**
2311
-     * @param array $event_ids
2312
-     */
2313
-    protected function generateDeletionPreview(array $event_ids)
2314
-    {
2315
-        $event_ids = $this->cleanEventIds($event_ids);
2316
-        // Set a code we can use to reference this deletion task in the batch jobs and preview page.
2317
-        $deletion_job_code = $this->getModelObjNodeGroupPersister()->generateGroupCode();
2318
-        $return_url        = EE_Admin_Page::add_query_args_and_nonce(
2319
-            [
2320
-                'action'            => 'preview_deletion',
2321
-                'deletion_job_code' => $deletion_job_code,
2322
-            ],
2323
-            $this->_admin_base_url
2324
-        );
2325
-        EEH_URL::safeRedirectAndExit(
2326
-            EE_Admin_Page::add_query_args_and_nonce(
2327
-                [
2328
-                    'page'              => 'espresso_batch',
2329
-                    'batch'             => EED_Batch::batch_job,
2330
-                    'EVT_IDs'           => $event_ids,
2331
-                    'deletion_job_code' => $deletion_job_code,
2332
-                    'job_handler'       => urlencode('EventEspressoBatchRequest\JobHandlers\PreviewEventDeletion'),
2333
-                    'return_url'        => urlencode($return_url),
2334
-                ],
2335
-                admin_url()
2336
-            )
2337
-        );
2338
-    }
2339
-
2340
-
2341
-    /**
2342
-     * Checks for a POST submission
2343
-     *
2344
-     * @since 4.10.12.p
2345
-     */
2346
-    protected function confirmDeletion()
2347
-    {
2348
-        $deletion_redirect_logic =
2349
-            $this->getLoader()->getShared('\EventEspresso\core\domain\services\admin\events\data\ConfirmDeletion');
2350
-        $deletion_redirect_logic->handle($this->get_request_data(), $this->admin_base_url());
2351
-    }
2352
-
2353
-
2354
-    /**
2355
-     * A page for users to preview what exactly will be deleted, and confirm they want to delete it.
2356
-     *
2357
-     * @throws EE_Error
2358
-     * @since 4.10.12.p
2359
-     */
2360
-    protected function previewDeletion()
2361
-    {
2362
-        $preview_deletion_logic =
2363
-            $this->getLoader()->getShared('\EventEspresso\core\domain\services\admin\events\data\PreviewDeletion');
2364
-        $this->set_template_args($preview_deletion_logic->handle($this->get_request_data(), $this->admin_base_url()));
2365
-        $this->display_admin_page_with_no_sidebar();
2366
-    }
2367
-
2368
-
2369
-    /**
2370
-     * get total number of events
2371
-     *
2372
-     * @access public
2373
-     * @return int
2374
-     * @throws EE_Error
2375
-     * @throws EE_Error
2376
-     */
2377
-    public function total_events()
2378
-    {
2379
-        return EEM_Event::instance()->count(
2380
-            ['caps' => 'read_admin'],
2381
-            'EVT_ID',
2382
-            true
2383
-        );
2384
-    }
2385
-
2386
-
2387
-    /**
2388
-     * get total number of draft events
2389
-     *
2390
-     * @access public
2391
-     * @return int
2392
-     * @throws EE_Error
2393
-     * @throws EE_Error
2394
-     */
2395
-    public function total_events_draft()
2396
-    {
2397
-        return EEM_Event::instance()->count(
2398
-            [
2399
-                ['status' => ['IN', ['draft', 'auto-draft']]],
2400
-                'caps' => 'read_admin',
2401
-            ],
2402
-            'EVT_ID',
2403
-            true
2404
-        );
2405
-    }
2406
-
2407
-
2408
-    /**
2409
-     * get total number of trashed events
2410
-     *
2411
-     * @access public
2412
-     * @return int
2413
-     * @throws EE_Error
2414
-     * @throws EE_Error
2415
-     */
2416
-    public function total_trashed_events()
2417
-    {
2418
-        return EEM_Event::instance()->count(
2419
-            [
2420
-                ['status' => 'trash'],
2421
-                'caps' => 'read_admin',
2422
-            ],
2423
-            'EVT_ID',
2424
-            true
2425
-        );
2426
-    }
2427
-
2428
-
2429
-    /**
2430
-     *    _default_event_settings
2431
-     *    This generates the Default Settings Tab
2432
-     *
2433
-     * @return void
2434
-     * @throws DomainException
2435
-     * @throws EE_Error
2436
-     * @throws InvalidArgumentException
2437
-     * @throws InvalidDataTypeException
2438
-     * @throws InvalidInterfaceException
2439
-     */
2440
-    protected function _default_event_settings()
2441
-    {
2442
-        $this->_set_add_edit_form_tags('update_default_event_settings');
2443
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
2444
-        $this->_template_args['admin_page_content'] = EEH_HTML::div(
2445
-            $this->_default_event_settings_form()->get_html(),
2446
-            '',
2447
-            'padding'
2448
-        );
2449
-        $this->display_admin_page_with_sidebar();
2450
-    }
2451
-
2452
-
2453
-    /**
2454
-     * Return the form for event settings.
2455
-     *
2456
-     * @return EE_Form_Section_Proper
2457
-     * @throws EE_Error
2458
-     */
2459
-    protected function _default_event_settings_form()
2460
-    {
2461
-        $registration_config              = EE_Registry::instance()->CFG->registration;
2462
-        $registration_stati_for_selection = EEM_Registration::reg_status_array(
2463
-        // exclude
2464
-            [
2465
-                EEM_Registration::status_id_cancelled,
2466
-                EEM_Registration::status_id_declined,
2467
-                EEM_Registration::status_id_incomplete,
2468
-                EEM_Registration::status_id_wait_list,
2469
-            ],
2470
-            true
2471
-        );
2472
-        return new EE_Form_Section_Proper(
2473
-            [
2474
-                'name'            => 'update_default_event_settings',
2475
-                'html_id'         => 'update_default_event_settings',
2476
-                'html_class'      => 'form-table',
2477
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
2478
-                'subsections'     => apply_filters(
2479
-                    'FHEE__Events_Admin_Page___default_event_settings_form__form_subsections',
2480
-                    [
2481
-                        'defaults_section_header' => new EE_Form_Section_HTML(
2482
-                            EEH_HTML::h2(
2483
-                                esc_html__('Default Settings', 'event_espresso'),
2484
-                                '',
2485
-                                'ee-admin-settings-hdr'
2486
-                            )
2487
-                        ),
2488
-                        'default_reg_status'  => new EE_Select_Input(
2489
-                            $registration_stati_for_selection,
2490
-                            [
2491
-                                'default'         => isset($registration_config->default_STS_ID)
2492
-                                                     && array_key_exists(
2493
-                                                         $registration_config->default_STS_ID,
2494
-                                                         $registration_stati_for_selection
2495
-                                                     )
2496
-                                    ? sanitize_text_field($registration_config->default_STS_ID)
2497
-                                    : EEM_Registration::status_id_pending_payment,
2498
-                                'html_label_text' => esc_html__('Default Registration Status', 'event_espresso')
2499
-                                                     . EEH_Template::get_help_tab_link(
2500
-                                                         'default_settings_status_help_tab'
2501
-                                                     ),
2502
-                                'html_help_text'  => esc_html__(
2503
-                                    '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.',
2504
-                                    'event_espresso'
2505
-                                ),
2506
-                            ]
2507
-                        ),
2508
-                        'default_max_tickets' => new EE_Integer_Input(
2509
-                            [
2510
-                                'default'         => isset($registration_config->default_maximum_number_of_tickets)
2511
-                                    ? $registration_config->default_maximum_number_of_tickets
2512
-                                    : EEM_Event::get_default_additional_limit(),
2513
-                                'html_label_text' => esc_html__(
2514
-                                    'Default Maximum Tickets Allowed Per Order:',
2515
-                                    'event_espresso'
2516
-                                )
2517
-                                                     . EEH_Template::get_help_tab_link(
2518
-                                                         'default_maximum_tickets_help_tab"'
2519
-                                                     ),
2520
-                                'html_help_text'  => esc_html__(
2521
-                                    'This setting allows you to indicate what will be the default for the maximum number of tickets per order when creating new events.',
2522
-                                    'event_espresso'
2523
-                                ),
2524
-                            ]
2525
-                        ),
2526
-                    ]
2527
-                ),
2528
-            ]
2529
-        );
2530
-    }
2531
-
2532
-
2533
-    /**
2534
-     * @return void
2535
-     * @throws EE_Error
2536
-     * @throws InvalidArgumentException
2537
-     * @throws InvalidDataTypeException
2538
-     * @throws InvalidInterfaceException
2539
-     */
2540
-    protected function _update_default_event_settings()
2541
-    {
2542
-        $form = $this->_default_event_settings_form();
2543
-        if ($form->was_submitted()) {
2544
-            $form->receive_form_submission();
2545
-            if ($form->is_valid()) {
2546
-                $registration_config = EE_Registry::instance()->CFG->registration;
2547
-                $valid_data          = $form->valid_data();
2548
-                if (isset($valid_data['default_reg_status'])) {
2549
-                    $registration_config->default_STS_ID = $valid_data['default_reg_status'];
2550
-                }
2551
-                if (isset($valid_data['default_max_tickets'])) {
2552
-                    $registration_config->default_maximum_number_of_tickets = $valid_data['default_max_tickets'];
2553
-                }
2554
-                do_action(
2555
-                    'AHEE__Events_Admin_Page___update_default_event_settings',
2556
-                    $valid_data,
2557
-                    EE_Registry::instance()->CFG,
2558
-                    $this
2559
-                );
2560
-                // update because data was valid!
2561
-                EE_Registry::instance()->CFG->update_espresso_config();
2562
-                EE_Error::overwrite_success();
2563
-                EE_Error::add_success(
2564
-                    esc_html__('Default Event Settings were updated', 'event_espresso')
2565
-                );
2566
-            }
2567
-        }
2568
-        $this->_redirect_after_action(0, '', '', ['action' => 'default_event_settings'], true);
2569
-    }
2570
-
2571
-
2572
-    /*************        Templates        *************
2573
-     *
2574
-     * @throws EE_Error
2575
-     */
2576
-    protected function _template_settings()
2577
-    {
2578
-        $this->_admin_page_title              = esc_html__('Template Settings (Preview)', 'event_espresso');
2579
-        $this->_template_args['preview_img']  = '<img src="'
2580
-                                                . EVENTS_ASSETS_URL
2581
-                                                . '/images/'
2582
-                                                . 'caffeinated_template_features.jpg" alt="'
2583
-                                                . esc_attr__('Template Settings Preview screenshot', 'event_espresso')
2584
-                                                . '" />';
2585
-        $this->_template_args['preview_text'] = '<strong>'
2586
-                                                . esc_html__(
2587
-                                                    '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.',
2588
-                                                    'event_espresso'
2589
-                                                ) . '</strong>';
2590
-        $this->display_admin_caf_preview_page('template_settings_tab');
2591
-    }
2592
-
2593
-
2594
-    /** Event Category Stuff **/
2595
-    /**
2596
-     * set the _category property with the category object for the loaded page.
2597
-     *
2598
-     * @access private
2599
-     * @return void
2600
-     */
2601
-    private function _set_category_object()
2602
-    {
2603
-        if (isset($this->_category->id) && ! empty($this->_category->id)) {
2604
-            return;
2605
-        } //already have the category object so get out.
2606
-        // set default category object
2607
-        $this->_set_empty_category_object();
2608
-        // only set if we've got an id
2609
-        $category_ID = $this->request->getRequestParam('EVT_CAT_ID', 0, 'int');
2610
-        if (! $category_ID) {
2611
-            return;
2612
-        }
2613
-        $term = get_term($category_ID, EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY);
2614
-        if (! empty($term)) {
2615
-            $this->_category->category_name       = $term->name;
2616
-            $this->_category->category_identifier = $term->slug;
2617
-            $this->_category->category_desc       = $term->description;
2618
-            $this->_category->id                  = $term->term_id;
2619
-            $this->_category->parent              = $term->parent;
2620
-        }
2621
-    }
2622
-
2623
-
2624
-    /**
2625
-     * Clears out category properties.
2626
-     */
2627
-    private function _set_empty_category_object()
2628
-    {
2629
-        $this->_category                = new stdClass();
2630
-        $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = '';
2631
-        $this->_category->id            = $this->_category->parent = 0;
2632
-    }
2633
-
2634
-
2635
-    /**
2636
-     * @throws DomainException
2637
-     * @throws EE_Error
2638
-     * @throws InvalidArgumentException
2639
-     * @throws InvalidDataTypeException
2640
-     * @throws InvalidInterfaceException
2641
-     */
2642
-    protected function _category_list_table()
2643
-    {
2644
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2645
-        $this->_search_btn_label = esc_html__('Categories', 'event_espresso');
2646
-        $this->_admin_page_title .= ' ';
2647
-        $this->_admin_page_title .= $this->get_action_link_or_button(
2648
-            'add_category',
2649
-            'add_category',
2650
-            [],
2651
-            'add-new-h2'
2652
-        );
2653
-        $this->display_admin_list_table_page_with_sidebar();
2654
-    }
2655
-
2656
-
2657
-    /**
2658
-     * Output category details view.
2659
-     *
2660
-     * @throws EE_Error
2661
-     * @throws EE_Error
2662
-     */
2663
-    protected function _category_details($view)
2664
-    {
2665
-        // load formatter helper
2666
-        // load field generator helper
2667
-        $route = $view === 'edit' ? 'update_category' : 'insert_category';
2668
-        $this->_set_add_edit_form_tags($route);
2669
-        $this->_set_category_object();
2670
-        $id            = ! empty($this->_category->id) ? $this->_category->id : '';
2671
-        $delete_action = 'delete_category';
2672
-        // custom redirect
2673
-        $redirect = EE_Admin_Page::add_query_args_and_nonce(
2674
-            ['action' => 'category_list'],
2675
-            $this->_admin_base_url
2676
-        );
2677
-        $this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect);
2678
-        // take care of contents
2679
-        $this->_template_args['admin_page_content'] = $this->_category_details_content();
2680
-        $this->display_admin_page_with_sidebar();
2681
-    }
2682
-
2683
-
2684
-    /**
2685
-     * Output category details content.
2686
-     *
2687
-     * @throws DomainException
2688
-     */
2689
-    protected function _category_details_content()
2690
-    {
2691
-        $editor_args['category_desc'] = [
2692
-            'type'          => 'wp_editor',
2693
-            'value'         => EEH_Formatter::admin_format_content($this->_category->category_desc),
2694
-            'class'         => 'my_editor_custom',
2695
-            'wpeditor_args' => ['media_buttons' => false],
2696
-        ];
2697
-        $_wp_editor                   = $this->_generate_admin_form_fields($editor_args, 'array');
2698
-        $all_terms                    = get_terms(
2699
-            [EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY],
2700
-            ['hide_empty' => 0, 'exclude' => [$this->_category->id]]
2701
-        );
2702
-        // setup category select for term parents.
2703
-        $category_select_values[] = [
2704
-            'text' => esc_html__('No Parent', 'event_espresso'),
2705
-            'id'   => 0,
2706
-        ];
2707
-        foreach ($all_terms as $term) {
2708
-            $category_select_values[] = [
2709
-                'text' => $term->name,
2710
-                'id'   => $term->term_id,
2711
-            ];
2712
-        }
2713
-        $category_select = EEH_Form_Fields::select_input(
2714
-            'category_parent',
2715
-            $category_select_values,
2716
-            $this->_category->parent
2717
-        );
2718
-        $template_args   = [
2719
-            'category'                 => $this->_category,
2720
-            'category_select'          => $category_select,
2721
-            'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'),
2722
-            'category_desc_editor'     => $_wp_editor['category_desc']['field'],
2723
-            'disable'                  => '',
2724
-            'disabled_message'         => false,
2725
-        ];
2726
-        $template        = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php';
2727
-        return EEH_Template::display_template($template, $template_args, true);
2728
-    }
2729
-
2730
-
2731
-    /**
2732
-     * Handles deleting categories.
2733
-     *
2734
-     * @throws EE_Error
2735
-     */
2736
-    protected function _delete_categories()
2737
-    {
2738
-        $category_IDs = $this->request->getRequestParam('EVT_CAT_ID', 0, 'int', true);
2739
-        foreach ($category_IDs as $category_ID) {
2740
-            $this->_delete_category($category_ID);
2741
-        }
2742
-        // doesn't matter what page we're coming from... we're going to the same place after delete.
2743
-        $query_args = [
2744
-            'action' => 'category_list',
2745
-        ];
2746
-        $this->_redirect_after_action(0, '', '', $query_args);
2747
-    }
2748
-
2749
-
2750
-    /**
2751
-     * Handles deleting specific category.
2752
-     *
2753
-     * @param int $cat_id
2754
-     */
2755
-    protected function _delete_category($cat_id)
2756
-    {
2757
-        $cat_id = absint($cat_id);
2758
-        wp_delete_term($cat_id, EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY);
2759
-    }
2760
-
2761
-
2762
-    /**
2763
-     * Handles triggering the update or insertion of a new category.
2764
-     *
2765
-     * @param bool $new_category true means we're triggering the insert of a new category.
2766
-     * @throws EE_Error
2767
-     * @throws EE_Error
2768
-     */
2769
-    protected function _insert_or_update_category($new_category)
2770
-    {
2771
-        $cat_id  = $new_category ? $this->_insert_category() : $this->_insert_category(true);
2772
-        $success = 0; // we already have a success message so lets not send another.
2773
-        if ($cat_id) {
2774
-            $query_args = [
2775
-                'action'     => 'edit_category',
2776
-                'EVT_CAT_ID' => $cat_id,
2777
-            ];
2778
-        } else {
2779
-            $query_args = ['action' => 'add_category'];
2780
-        }
2781
-        $this->_redirect_after_action($success, '', '', $query_args, true);
2782
-    }
2783
-
2784
-
2785
-    /**
2786
-     * Inserts or updates category
2787
-     *
2788
-     * @param bool $update (true indicates we're updating a category).
2789
-     * @return bool|mixed|string
2790
-     */
2791
-    private function _insert_category($update = false)
2792
-    {
2793
-        $category_ID         = $update ? $this->request->getRequestParam('EVT_CAT_ID', 0, 'int') : 0;
2794
-        $category_name       = $this->request->getRequestParam('category_name', '');
2795
-        $category_desc       = $this->request->getRequestParam('category_desc', '');
2796
-        $category_parent     = $this->request->getRequestParam('category_parent', 0, 'int');
2797
-        $category_identifier = $this->request->getRequestParam('category_identifier', '');
2798
-
2799
-        if (empty($category_name)) {
2800
-            $msg = esc_html__('You must add a name for the category.', 'event_espresso');
2801
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2802
-            return false;
2803
-        }
2804
-        $term_args = [
2805
-            'name'        => $category_name,
2806
-            'description' => $category_desc,
2807
-            'parent'      => $category_parent,
2808
-        ];
2809
-        // was the category_identifier input disabled?
2810
-        if ($category_identifier) {
2811
-            $term_args['slug'] = $category_identifier;
2812
-        }
2813
-        $insert_ids = $update
2814
-            ? wp_update_term($category_ID, EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY, $term_args)
2815
-            : wp_insert_term($category_name, EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY, $term_args);
2816
-        if (! is_array($insert_ids)) {
2817
-            $msg = esc_html__(
2818
-                'An error occurred and the category has not been saved to the database.',
2819
-                'event_espresso'
2820
-            );
2821
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2822
-        } else {
2823
-            $category_ID = $insert_ids['term_id'];
2824
-            $msg         = sprintf(
2825
-                esc_html__('The category %s was successfully saved', 'event_espresso'),
2826
-                $category_name
2827
-            );
2828
-            EE_Error::add_success($msg);
2829
-        }
2830
-        return $category_ID;
2831
-    }
2832
-
2833
-
2834
-    /**
2835
-     * Gets categories or count of categories matching the arguments in the request.
2836
-     *
2837
-     * @param int  $per_page
2838
-     * @param int  $current_page
2839
-     * @param bool $count
2840
-     * @return EE_Term_Taxonomy[]|int
2841
-     * @throws EE_Error
2842
-     */
2843
-    public function get_categories($per_page = 10, $current_page = 1, $count = false)
2844
-    {
2845
-        // testing term stuff
2846
-        $orderby     = $this->request->getRequestParam('orderby', 'Term.term_id');
2847
-        $order       = $this->request->getRequestParam('order', 'DESC');
2848
-        $limit       = ($current_page - 1) * $per_page;
2849
-        $where       = ['taxonomy' => EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY];
2850
-        $search_term = $this->request->getRequestParam('s');
2851
-        if ($search_term) {
2852
-            $search_term = '%' . $search_term . '%';
2853
-            $where['OR'] = [
2854
-                'Term.name'   => ['LIKE', $search_term],
2855
-                'description' => ['LIKE', $search_term],
2856
-            ];
2857
-        }
2858
-        $query_params = [
2859
-            $where,
2860
-            'order_by'   => [$orderby => $order],
2861
-            'limit'      => $limit . ',' . $per_page,
2862
-            'force_join' => ['Term'],
2863
-        ];
2864
-        return $count
2865
-            ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id')
2866
-            : EEM_Term_Taxonomy::instance()->get_all($query_params);
2867
-    }
2868
-
2869
-    /* end category stuff */
2870
-
2871
-
2872
-    /**************/
2873
-
2874
-
2875
-    /**
2876
-     * Callback for the `ee_save_timezone_setting` ajax action.
2877
-     *
2878
-     * @throws EE_Error
2879
-     * @throws InvalidArgumentException
2880
-     * @throws InvalidDataTypeException
2881
-     * @throws InvalidInterfaceException
2882
-     */
2883
-    public function saveTimezoneString()
2884
-    {
2885
-        $timezone_string = $this->request->getRequestParam('timezone_selected');
2886
-        if (empty($timezone_string) || ! EEH_DTT_Helper::validate_timezone($timezone_string, false)) {
2887
-            EE_Error::add_error(
2888
-                esc_html__('An invalid timezone string submitted.', 'event_espresso'),
2889
-                __FILE__,
2890
-                __FUNCTION__,
2891
-                __LINE__
2892
-            );
2893
-            $this->_template_args['error'] = true;
2894
-            $this->_return_json();
2895
-        }
2896
-
2897
-        update_option('timezone_string', $timezone_string);
2898
-        EE_Error::add_success(
2899
-            esc_html__('Your timezone string was updated.', 'event_espresso')
2900
-        );
2901
-        $this->_template_args['success'] = true;
2902
-        $this->_return_json(true, ['action' => 'create_new']);
2903
-    }
2904
-
2905
-
2906
-    /**
2907 2574
      * @throws EE_Error
2908
-     * @deprecated 4.10.25.p
2909 2575
      */
2910
-    public function save_timezonestring_setting()
2911
-    {
2912
-        $this->saveTimezoneString();
2913
-    }
2576
+	protected function _template_settings()
2577
+	{
2578
+		$this->_admin_page_title              = esc_html__('Template Settings (Preview)', 'event_espresso');
2579
+		$this->_template_args['preview_img']  = '<img src="'
2580
+												. EVENTS_ASSETS_URL
2581
+												. '/images/'
2582
+												. 'caffeinated_template_features.jpg" alt="'
2583
+												. esc_attr__('Template Settings Preview screenshot', 'event_espresso')
2584
+												. '" />';
2585
+		$this->_template_args['preview_text'] = '<strong>'
2586
+												. esc_html__(
2587
+													'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.',
2588
+													'event_espresso'
2589
+												) . '</strong>';
2590
+		$this->display_admin_caf_preview_page('template_settings_tab');
2591
+	}
2592
+
2593
+
2594
+	/** Event Category Stuff **/
2595
+	/**
2596
+	 * set the _category property with the category object for the loaded page.
2597
+	 *
2598
+	 * @access private
2599
+	 * @return void
2600
+	 */
2601
+	private function _set_category_object()
2602
+	{
2603
+		if (isset($this->_category->id) && ! empty($this->_category->id)) {
2604
+			return;
2605
+		} //already have the category object so get out.
2606
+		// set default category object
2607
+		$this->_set_empty_category_object();
2608
+		// only set if we've got an id
2609
+		$category_ID = $this->request->getRequestParam('EVT_CAT_ID', 0, 'int');
2610
+		if (! $category_ID) {
2611
+			return;
2612
+		}
2613
+		$term = get_term($category_ID, EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY);
2614
+		if (! empty($term)) {
2615
+			$this->_category->category_name       = $term->name;
2616
+			$this->_category->category_identifier = $term->slug;
2617
+			$this->_category->category_desc       = $term->description;
2618
+			$this->_category->id                  = $term->term_id;
2619
+			$this->_category->parent              = $term->parent;
2620
+		}
2621
+	}
2622
+
2623
+
2624
+	/**
2625
+	 * Clears out category properties.
2626
+	 */
2627
+	private function _set_empty_category_object()
2628
+	{
2629
+		$this->_category                = new stdClass();
2630
+		$this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = '';
2631
+		$this->_category->id            = $this->_category->parent = 0;
2632
+	}
2633
+
2634
+
2635
+	/**
2636
+	 * @throws DomainException
2637
+	 * @throws EE_Error
2638
+	 * @throws InvalidArgumentException
2639
+	 * @throws InvalidDataTypeException
2640
+	 * @throws InvalidInterfaceException
2641
+	 */
2642
+	protected function _category_list_table()
2643
+	{
2644
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2645
+		$this->_search_btn_label = esc_html__('Categories', 'event_espresso');
2646
+		$this->_admin_page_title .= ' ';
2647
+		$this->_admin_page_title .= $this->get_action_link_or_button(
2648
+			'add_category',
2649
+			'add_category',
2650
+			[],
2651
+			'add-new-h2'
2652
+		);
2653
+		$this->display_admin_list_table_page_with_sidebar();
2654
+	}
2655
+
2656
+
2657
+	/**
2658
+	 * Output category details view.
2659
+	 *
2660
+	 * @throws EE_Error
2661
+	 * @throws EE_Error
2662
+	 */
2663
+	protected function _category_details($view)
2664
+	{
2665
+		// load formatter helper
2666
+		// load field generator helper
2667
+		$route = $view === 'edit' ? 'update_category' : 'insert_category';
2668
+		$this->_set_add_edit_form_tags($route);
2669
+		$this->_set_category_object();
2670
+		$id            = ! empty($this->_category->id) ? $this->_category->id : '';
2671
+		$delete_action = 'delete_category';
2672
+		// custom redirect
2673
+		$redirect = EE_Admin_Page::add_query_args_and_nonce(
2674
+			['action' => 'category_list'],
2675
+			$this->_admin_base_url
2676
+		);
2677
+		$this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect);
2678
+		// take care of contents
2679
+		$this->_template_args['admin_page_content'] = $this->_category_details_content();
2680
+		$this->display_admin_page_with_sidebar();
2681
+	}
2682
+
2683
+
2684
+	/**
2685
+	 * Output category details content.
2686
+	 *
2687
+	 * @throws DomainException
2688
+	 */
2689
+	protected function _category_details_content()
2690
+	{
2691
+		$editor_args['category_desc'] = [
2692
+			'type'          => 'wp_editor',
2693
+			'value'         => EEH_Formatter::admin_format_content($this->_category->category_desc),
2694
+			'class'         => 'my_editor_custom',
2695
+			'wpeditor_args' => ['media_buttons' => false],
2696
+		];
2697
+		$_wp_editor                   = $this->_generate_admin_form_fields($editor_args, 'array');
2698
+		$all_terms                    = get_terms(
2699
+			[EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY],
2700
+			['hide_empty' => 0, 'exclude' => [$this->_category->id]]
2701
+		);
2702
+		// setup category select for term parents.
2703
+		$category_select_values[] = [
2704
+			'text' => esc_html__('No Parent', 'event_espresso'),
2705
+			'id'   => 0,
2706
+		];
2707
+		foreach ($all_terms as $term) {
2708
+			$category_select_values[] = [
2709
+				'text' => $term->name,
2710
+				'id'   => $term->term_id,
2711
+			];
2712
+		}
2713
+		$category_select = EEH_Form_Fields::select_input(
2714
+			'category_parent',
2715
+			$category_select_values,
2716
+			$this->_category->parent
2717
+		);
2718
+		$template_args   = [
2719
+			'category'                 => $this->_category,
2720
+			'category_select'          => $category_select,
2721
+			'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'),
2722
+			'category_desc_editor'     => $_wp_editor['category_desc']['field'],
2723
+			'disable'                  => '',
2724
+			'disabled_message'         => false,
2725
+		];
2726
+		$template        = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php';
2727
+		return EEH_Template::display_template($template, $template_args, true);
2728
+	}
2729
+
2730
+
2731
+	/**
2732
+	 * Handles deleting categories.
2733
+	 *
2734
+	 * @throws EE_Error
2735
+	 */
2736
+	protected function _delete_categories()
2737
+	{
2738
+		$category_IDs = $this->request->getRequestParam('EVT_CAT_ID', 0, 'int', true);
2739
+		foreach ($category_IDs as $category_ID) {
2740
+			$this->_delete_category($category_ID);
2741
+		}
2742
+		// doesn't matter what page we're coming from... we're going to the same place after delete.
2743
+		$query_args = [
2744
+			'action' => 'category_list',
2745
+		];
2746
+		$this->_redirect_after_action(0, '', '', $query_args);
2747
+	}
2748
+
2749
+
2750
+	/**
2751
+	 * Handles deleting specific category.
2752
+	 *
2753
+	 * @param int $cat_id
2754
+	 */
2755
+	protected function _delete_category($cat_id)
2756
+	{
2757
+		$cat_id = absint($cat_id);
2758
+		wp_delete_term($cat_id, EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY);
2759
+	}
2760
+
2761
+
2762
+	/**
2763
+	 * Handles triggering the update or insertion of a new category.
2764
+	 *
2765
+	 * @param bool $new_category true means we're triggering the insert of a new category.
2766
+	 * @throws EE_Error
2767
+	 * @throws EE_Error
2768
+	 */
2769
+	protected function _insert_or_update_category($new_category)
2770
+	{
2771
+		$cat_id  = $new_category ? $this->_insert_category() : $this->_insert_category(true);
2772
+		$success = 0; // we already have a success message so lets not send another.
2773
+		if ($cat_id) {
2774
+			$query_args = [
2775
+				'action'     => 'edit_category',
2776
+				'EVT_CAT_ID' => $cat_id,
2777
+			];
2778
+		} else {
2779
+			$query_args = ['action' => 'add_category'];
2780
+		}
2781
+		$this->_redirect_after_action($success, '', '', $query_args, true);
2782
+	}
2783
+
2784
+
2785
+	/**
2786
+	 * Inserts or updates category
2787
+	 *
2788
+	 * @param bool $update (true indicates we're updating a category).
2789
+	 * @return bool|mixed|string
2790
+	 */
2791
+	private function _insert_category($update = false)
2792
+	{
2793
+		$category_ID         = $update ? $this->request->getRequestParam('EVT_CAT_ID', 0, 'int') : 0;
2794
+		$category_name       = $this->request->getRequestParam('category_name', '');
2795
+		$category_desc       = $this->request->getRequestParam('category_desc', '');
2796
+		$category_parent     = $this->request->getRequestParam('category_parent', 0, 'int');
2797
+		$category_identifier = $this->request->getRequestParam('category_identifier', '');
2798
+
2799
+		if (empty($category_name)) {
2800
+			$msg = esc_html__('You must add a name for the category.', 'event_espresso');
2801
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2802
+			return false;
2803
+		}
2804
+		$term_args = [
2805
+			'name'        => $category_name,
2806
+			'description' => $category_desc,
2807
+			'parent'      => $category_parent,
2808
+		];
2809
+		// was the category_identifier input disabled?
2810
+		if ($category_identifier) {
2811
+			$term_args['slug'] = $category_identifier;
2812
+		}
2813
+		$insert_ids = $update
2814
+			? wp_update_term($category_ID, EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY, $term_args)
2815
+			: wp_insert_term($category_name, EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY, $term_args);
2816
+		if (! is_array($insert_ids)) {
2817
+			$msg = esc_html__(
2818
+				'An error occurred and the category has not been saved to the database.',
2819
+				'event_espresso'
2820
+			);
2821
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2822
+		} else {
2823
+			$category_ID = $insert_ids['term_id'];
2824
+			$msg         = sprintf(
2825
+				esc_html__('The category %s was successfully saved', 'event_espresso'),
2826
+				$category_name
2827
+			);
2828
+			EE_Error::add_success($msg);
2829
+		}
2830
+		return $category_ID;
2831
+	}
2832
+
2833
+
2834
+	/**
2835
+	 * Gets categories or count of categories matching the arguments in the request.
2836
+	 *
2837
+	 * @param int  $per_page
2838
+	 * @param int  $current_page
2839
+	 * @param bool $count
2840
+	 * @return EE_Term_Taxonomy[]|int
2841
+	 * @throws EE_Error
2842
+	 */
2843
+	public function get_categories($per_page = 10, $current_page = 1, $count = false)
2844
+	{
2845
+		// testing term stuff
2846
+		$orderby     = $this->request->getRequestParam('orderby', 'Term.term_id');
2847
+		$order       = $this->request->getRequestParam('order', 'DESC');
2848
+		$limit       = ($current_page - 1) * $per_page;
2849
+		$where       = ['taxonomy' => EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY];
2850
+		$search_term = $this->request->getRequestParam('s');
2851
+		if ($search_term) {
2852
+			$search_term = '%' . $search_term . '%';
2853
+			$where['OR'] = [
2854
+				'Term.name'   => ['LIKE', $search_term],
2855
+				'description' => ['LIKE', $search_term],
2856
+			];
2857
+		}
2858
+		$query_params = [
2859
+			$where,
2860
+			'order_by'   => [$orderby => $order],
2861
+			'limit'      => $limit . ',' . $per_page,
2862
+			'force_join' => ['Term'],
2863
+		];
2864
+		return $count
2865
+			? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id')
2866
+			: EEM_Term_Taxonomy::instance()->get_all($query_params);
2867
+	}
2868
+
2869
+	/* end category stuff */
2870
+
2871
+
2872
+	/**************/
2873
+
2874
+
2875
+	/**
2876
+	 * Callback for the `ee_save_timezone_setting` ajax action.
2877
+	 *
2878
+	 * @throws EE_Error
2879
+	 * @throws InvalidArgumentException
2880
+	 * @throws InvalidDataTypeException
2881
+	 * @throws InvalidInterfaceException
2882
+	 */
2883
+	public function saveTimezoneString()
2884
+	{
2885
+		$timezone_string = $this->request->getRequestParam('timezone_selected');
2886
+		if (empty($timezone_string) || ! EEH_DTT_Helper::validate_timezone($timezone_string, false)) {
2887
+			EE_Error::add_error(
2888
+				esc_html__('An invalid timezone string submitted.', 'event_espresso'),
2889
+				__FILE__,
2890
+				__FUNCTION__,
2891
+				__LINE__
2892
+			);
2893
+			$this->_template_args['error'] = true;
2894
+			$this->_return_json();
2895
+		}
2896
+
2897
+		update_option('timezone_string', $timezone_string);
2898
+		EE_Error::add_success(
2899
+			esc_html__('Your timezone string was updated.', 'event_espresso')
2900
+		);
2901
+		$this->_template_args['success'] = true;
2902
+		$this->_return_json(true, ['action' => 'create_new']);
2903
+	}
2904
+
2905
+
2906
+	/**
2907
+	 * @throws EE_Error
2908
+	 * @deprecated 4.10.25.p
2909
+	 */
2910
+	public function save_timezonestring_setting()
2911
+	{
2912
+		$this->saveTimezoneString();
2913
+	}
2914 2914
 }
Please login to merge, or discard this patch.
ui/browser/checkins/entities/CheckinStatusDashicon.php 2 patches
Indentation   +133 added lines, -133 removed lines patch added patch discarded remove patch
@@ -17,137 +17,137 @@
 block discarded – undo
17 17
  */
18 18
 class CheckinStatusDashicon
19 19
 {
20
-    /**
21
-     * @var int $checkin_status
22
-     */
23
-    private $checkin_status;
24
-
25
-
26
-    /**
27
-     * CheckinStatusDashicon constructor.
28
-     *
29
-     * @param int $checkin_status
30
-     */
31
-    public function __construct(int $checkin_status = EE_Checkin::status_checked_never)
32
-    {
33
-        $this->checkin_status = $checkin_status;
34
-    }
35
-
36
-
37
-    /**
38
-     * @return int
39
-     */
40
-    public function checkinStatus(): int
41
-    {
42
-        return $this->checkin_status;
43
-    }
44
-
45
-
46
-    /**
47
-     * @param EE_Checkin $checkin
48
-     * @return CheckinStatusDashicon
49
-     * @throws EE_Error
50
-     * @throws ReflectionException
51
-     */
52
-    public static function fromCheckin(EE_Checkin $checkin): CheckinStatusDashicon
53
-    {
54
-        return new CheckinStatusDashicon(
55
-            $checkin->status()
56
-                ? EE_Checkin::status_checked_in
57
-                : EE_Checkin::status_checked_out
58
-        );
59
-    }
60
-
61
-
62
-    /**
63
-     * @param EE_Registration $registration
64
-     * @param EE_Datetime     $datetime
65
-     * @return CheckinStatusDashicon
66
-     * @throws EE_Error
67
-     * @throws ReflectionException
68
-     */
69
-    public static function fromRegistrationAndDatetime(EE_Registration $registration, EE_Datetime $datetime): CheckinStatusDashicon
70
-    {
71
-        return new CheckinStatusDashicon(
72
-            $registration->check_in_status_for_datetime(
73
-                $datetime->ID()
74
-            )
75
-        );
76
-    }
77
-
78
-
79
-    /**
80
-     * @param EE_Registration $registration
81
-     * @param int             $DTT_ID
82
-     * @return CheckinStatusDashicon
83
-     * @throws EE_Error
84
-     * @throws ReflectionException
85
-     */
86
-    public static function fromRegistrationAndDatetimeId(EE_Registration $registration, int $DTT_ID = 0): CheckinStatusDashicon
87
-    {
88
-        return new CheckinStatusDashicon(
89
-            $registration->check_in_status_for_datetime(
90
-                absint($DTT_ID)
91
-            )
92
-        );
93
-    }
94
-
95
-    /**
96
-     * Will return the correct set of dashicon css classes for the set checkin status
97
-     *
98
-     * @return string
99
-     */
100
-    public function cssClasses(): string
101
-    {
102
-        switch($this->checkin_status) {
103
-            case EE_Checkin::status_checked_in:
104
-                return "dashicons dashicons-yes-alt checkin-icons checkedin-status-{$this->checkin_status}";
105
-            case EE_Checkin::status_checked_out:
106
-                return "dashicons dashicons-marker checkin-icons checkedin-status-{$this->checkin_status}";
107
-            case EE_Checkin::status_checked_never:
108
-                return "dashicons dashicons-no checkin-icons checkedin-status-{$this->checkin_status}";
109
-            default:
110
-                return 'dashicons dashicons-warning ee-status--warning';
111
-        }
112
-    }
113
-
114
-    /**
115
-     * returns a description for the Checkin Status Dashicon that can be used in List Table Legends
116
-     *
117
-     * @return string
118
-     */
119
-    public function legendLabel(): string
120
-    {
121
-        switch ($this->checkin_status) {
122
-            case EE_Checkin::status_checked_in:
123
-                return esc_html__('This Registrant has been Checked In', 'event_espresso');
124
-            case EE_Checkin::status_checked_out:
125
-                return esc_html__('This Registrant has been Checked Out', 'event_espresso');
126
-            case EE_Checkin::status_checked_never:
127
-                return esc_html__('No Check-in Record has been Created for this Registrant', 'event_espresso');
128
-            default:
129
-                return esc_html__('Can not perform Registrant Check-in.', 'event_espresso');
130
-        }
131
-    }
132
-
133
-    /**
134
-     * returns a description for the Checkin Status Dashicon that can be used as a button aria label
135
-     *
136
-     * @return string
137
-     */
138
-    public function ariaLabel(): string
139
-    {
140
-        switch ($this->checkin_status) {
141
-            case EE_Checkin::status_checked_in:
142
-                return esc_html__('click to change status to Checked Out', 'event_espresso');
143
-            case EE_Checkin::status_checked_out:
144
-            case EE_Checkin::status_checked_never:
145
-                return esc_html__('click to change status to Checked In', 'event_espresso');
146
-            default:
147
-                return esc_html__(
148
-                    'Can not perform Registrant Check-in because there are either no event dates currently active for this ticket option (event has not yet started) or there are multiple dates to choose from. Please use the filters above to select a single, currently active event date in order to perform check-ins.',
149
-                    'event_espresso'
150
-                );
151
-        }
152
-    }
20
+	/**
21
+	 * @var int $checkin_status
22
+	 */
23
+	private $checkin_status;
24
+
25
+
26
+	/**
27
+	 * CheckinStatusDashicon constructor.
28
+	 *
29
+	 * @param int $checkin_status
30
+	 */
31
+	public function __construct(int $checkin_status = EE_Checkin::status_checked_never)
32
+	{
33
+		$this->checkin_status = $checkin_status;
34
+	}
35
+
36
+
37
+	/**
38
+	 * @return int
39
+	 */
40
+	public function checkinStatus(): int
41
+	{
42
+		return $this->checkin_status;
43
+	}
44
+
45
+
46
+	/**
47
+	 * @param EE_Checkin $checkin
48
+	 * @return CheckinStatusDashicon
49
+	 * @throws EE_Error
50
+	 * @throws ReflectionException
51
+	 */
52
+	public static function fromCheckin(EE_Checkin $checkin): CheckinStatusDashicon
53
+	{
54
+		return new CheckinStatusDashicon(
55
+			$checkin->status()
56
+				? EE_Checkin::status_checked_in
57
+				: EE_Checkin::status_checked_out
58
+		);
59
+	}
60
+
61
+
62
+	/**
63
+	 * @param EE_Registration $registration
64
+	 * @param EE_Datetime     $datetime
65
+	 * @return CheckinStatusDashicon
66
+	 * @throws EE_Error
67
+	 * @throws ReflectionException
68
+	 */
69
+	public static function fromRegistrationAndDatetime(EE_Registration $registration, EE_Datetime $datetime): CheckinStatusDashicon
70
+	{
71
+		return new CheckinStatusDashicon(
72
+			$registration->check_in_status_for_datetime(
73
+				$datetime->ID()
74
+			)
75
+		);
76
+	}
77
+
78
+
79
+	/**
80
+	 * @param EE_Registration $registration
81
+	 * @param int             $DTT_ID
82
+	 * @return CheckinStatusDashicon
83
+	 * @throws EE_Error
84
+	 * @throws ReflectionException
85
+	 */
86
+	public static function fromRegistrationAndDatetimeId(EE_Registration $registration, int $DTT_ID = 0): CheckinStatusDashicon
87
+	{
88
+		return new CheckinStatusDashicon(
89
+			$registration->check_in_status_for_datetime(
90
+				absint($DTT_ID)
91
+			)
92
+		);
93
+	}
94
+
95
+	/**
96
+	 * Will return the correct set of dashicon css classes for the set checkin status
97
+	 *
98
+	 * @return string
99
+	 */
100
+	public function cssClasses(): string
101
+	{
102
+		switch($this->checkin_status) {
103
+			case EE_Checkin::status_checked_in:
104
+				return "dashicons dashicons-yes-alt checkin-icons checkedin-status-{$this->checkin_status}";
105
+			case EE_Checkin::status_checked_out:
106
+				return "dashicons dashicons-marker checkin-icons checkedin-status-{$this->checkin_status}";
107
+			case EE_Checkin::status_checked_never:
108
+				return "dashicons dashicons-no checkin-icons checkedin-status-{$this->checkin_status}";
109
+			default:
110
+				return 'dashicons dashicons-warning ee-status--warning';
111
+		}
112
+	}
113
+
114
+	/**
115
+	 * returns a description for the Checkin Status Dashicon that can be used in List Table Legends
116
+	 *
117
+	 * @return string
118
+	 */
119
+	public function legendLabel(): string
120
+	{
121
+		switch ($this->checkin_status) {
122
+			case EE_Checkin::status_checked_in:
123
+				return esc_html__('This Registrant has been Checked In', 'event_espresso');
124
+			case EE_Checkin::status_checked_out:
125
+				return esc_html__('This Registrant has been Checked Out', 'event_espresso');
126
+			case EE_Checkin::status_checked_never:
127
+				return esc_html__('No Check-in Record has been Created for this Registrant', 'event_espresso');
128
+			default:
129
+				return esc_html__('Can not perform Registrant Check-in.', 'event_espresso');
130
+		}
131
+	}
132
+
133
+	/**
134
+	 * returns a description for the Checkin Status Dashicon that can be used as a button aria label
135
+	 *
136
+	 * @return string
137
+	 */
138
+	public function ariaLabel(): string
139
+	{
140
+		switch ($this->checkin_status) {
141
+			case EE_Checkin::status_checked_in:
142
+				return esc_html__('click to change status to Checked Out', 'event_espresso');
143
+			case EE_Checkin::status_checked_out:
144
+			case EE_Checkin::status_checked_never:
145
+				return esc_html__('click to change status to Checked In', 'event_espresso');
146
+			default:
147
+				return esc_html__(
148
+					'Can not perform Registrant Check-in because there are either no event dates currently active for this ticket option (event has not yet started) or there are multiple dates to choose from. Please use the filters above to select a single, currently active event date in order to perform check-ins.',
149
+					'event_espresso'
150
+				);
151
+		}
152
+	}
153 153
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@
 block discarded – undo
99 99
      */
100 100
     public function cssClasses(): string
101 101
     {
102
-        switch($this->checkin_status) {
102
+        switch ($this->checkin_status) {
103 103
             case EE_Checkin::status_checked_in:
104 104
                 return "dashicons dashicons-yes-alt checkin-icons checkedin-status-{$this->checkin_status}";
105 105
             case EE_Checkin::status_checked_out:
Please login to merge, or discard this patch.
core/admin/EE_Admin_List_Table.core.php 2 patches
Indentation   +918 added lines, -918 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 use EventEspresso\core\services\request\RequestInterface;
5 5
 
6 6
 if (! class_exists('WP_List_Table')) {
7
-    require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
7
+	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
8 8
 }
9 9
 
10 10
 
@@ -22,921 +22,921 @@  discard block
 block discarded – undo
22 22
  */
23 23
 abstract class EE_Admin_List_Table extends WP_List_Table
24 24
 {
25
-    const ACTION_COPY    = 'duplicate';
26
-
27
-    const ACTION_DELETE  = 'delete';
28
-
29
-    const ACTION_EDIT    = 'edit';
30
-
31
-    const ACTION_RESTORE = 'restore';
32
-
33
-    const ACTION_TRASH   = 'trash';
34
-
35
-    protected static $actions = [
36
-        self::ACTION_COPY,
37
-        self::ACTION_DELETE,
38
-        self::ACTION_EDIT,
39
-        self::ACTION_RESTORE,
40
-        self::ACTION_TRASH,
41
-    ];
42
-
43
-    /**
44
-     * holds the data that will be processed for the table
45
-     *
46
-     * @var array $_data
47
-     */
48
-    protected $_data;
49
-
50
-
51
-    /**
52
-     * This holds the value of all the data available for the given view (for all pages).
53
-     *
54
-     * @var int $_all_data_count
55
-     */
56
-    protected $_all_data_count;
57
-
58
-
59
-    /**
60
-     * Will contain the count of trashed items for the view label.
61
-     *
62
-     * @var int $_trashed_count
63
-     */
64
-    protected $_trashed_count;
65
-
66
-
67
-    /**
68
-     * This is what will be referenced as the slug for the current screen
69
-     *
70
-     * @var string $_screen
71
-     */
72
-    protected $_screen;
73
-
74
-
75
-    /**
76
-     * this is the EE_Admin_Page object
77
-     *
78
-     * @var EE_Admin_Page $_admin_page
79
-     */
80
-    protected $_admin_page;
81
-
82
-
83
-    /**
84
-     * The current view
85
-     *
86
-     * @var string $_view
87
-     */
88
-    protected $_view;
89
-
90
-
91
-    /**
92
-     * array of possible views for this table
93
-     *
94
-     * @var array $_views
95
-     */
96
-    protected $_views;
97
-
98
-
99
-    /**
100
-     * An array of key => value pairs containing information about the current table
101
-     * array(
102
-     *        'plural' => 'plural label',
103
-     *        'singular' => 'singular label',
104
-     *        'ajax' => false, //whether to use ajax or not
105
-     *        'screen' => null, //string used to reference what screen this is
106
-     *        (WP_List_table converts to screen object)
107
-     * )
108
-     *
109
-     * @var array $_wp_list_args
110
-     */
111
-    protected $_wp_list_args;
112
-
113
-    /**
114
-     * an array of column names
115
-     * array(
116
-     *    'internal-name' => 'Title'
117
-     * )
118
-     *
119
-     * @var array $_columns
120
-     */
121
-    protected $_columns;
122
-
123
-    /**
124
-     * An array of sortable columns
125
-     * array(
126
-     *    'internal-name' => 'orderby' //or
127
-     *    'internal-name' => array( 'orderby', true )
128
-     * )
129
-     *
130
-     * @var array $_sortable_columns
131
-     */
132
-    protected $_sortable_columns;
133
-
134
-    /**
135
-     * callback method used to perform AJAX row reordering
136
-     *
137
-     * @var string $_ajax_sorting_callback
138
-     */
139
-    protected $_ajax_sorting_callback;
140
-
141
-    /**
142
-     * An array of hidden columns (if needed)
143
-     * array('internal-name', 'internal-name')
144
-     *
145
-     * @var array $_hidden_columns
146
-     */
147
-    protected $_hidden_columns;
148
-
149
-    /**
150
-     * holds the per_page value
151
-     *
152
-     * @var int $_per_page
153
-     */
154
-    protected $_per_page;
155
-
156
-    /**
157
-     * holds what page number is currently being viewed
158
-     *
159
-     * @var int $_current_page
160
-     */
161
-    protected $_current_page;
162
-
163
-    /**
164
-     * the reference string for the nonce_action
165
-     *
166
-     * @var string $_nonce_action_ref
167
-     */
168
-    protected $_nonce_action_ref;
169
-
170
-    /**
171
-     * property to hold incoming request data (as set by the admin_page_core)
172
-     *
173
-     * @var array $_req_data
174
-     */
175
-    protected $_req_data;
176
-
177
-
178
-    /**
179
-     * yes / no array for admin form fields
180
-     *
181
-     * @var array $_yes_no
182
-     */
183
-    protected $_yes_no = [];
184
-
185
-    /**
186
-     * Array describing buttons that should appear at the bottom of the page
187
-     * Keys are strings that represent the button's function (specifically a key in _labels['buttons']),
188
-     * and the values are another array with the following keys
189
-     * array(
190
-     *    'route' => 'page_route',
191
-     *    'extra_request' => array('evt_id' => 1 ); //extra request vars that need to be included in the button.
192
-     * )
193
-     *
194
-     * @var array $_bottom_buttons
195
-     */
196
-    protected $_bottom_buttons = [];
197
-
198
-
199
-    /**
200
-     * Used to indicate what should be the primary column for the list table.
201
-     * If not present then falls back to what WP calculates
202
-     * as the primary column.
203
-     *
204
-     * @type string $_primary_column
205
-     */
206
-    protected $_primary_column = '';
207
-
208
-
209
-    /**
210
-     * Used to indicate whether the table has a checkbox column or not.
211
-     *
212
-     * @type bool $_has_checkbox_column
213
-     */
214
-    protected $_has_checkbox_column = false;
215
-
216
-
217
-    /**
218
-     * @param EE_Admin_Page $admin_page we use this for obtaining everything we need in the list table
219
-     */
220
-    public function __construct(EE_Admin_Page $admin_page)
221
-    {
222
-        $this->_admin_page   = $admin_page;
223
-        $this->_req_data     = $this->_admin_page->get_request_data();
224
-        $this->_view         = $this->_admin_page->get_view();
225
-        $this->_views        = empty($this->_views) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views;
226
-        $this->_current_page = $this->get_pagenum();
227
-        $this->_screen       = $this->_admin_page->get_current_page() . '_' . $this->_admin_page->get_current_view();
228
-        $this->_yes_no       = [
229
-            esc_html__('No', 'event_espresso'),
230
-            esc_html__('Yes', 'event_espresso')
231
-        ];
232
-
233
-        $this->_per_page = $this->get_items_per_page($this->_screen . '_per_page');
234
-
235
-        $this->_setup_data();
236
-        $this->_add_view_counts();
237
-
238
-        $this->_nonce_action_ref = $this->_view;
239
-
240
-        $this->_set_properties();
241
-
242
-        // set primary column
243
-        add_filter('list_table_primary_column', [$this, 'set_primary_column']);
244
-
245
-        // set parent defaults
246
-        parent::__construct($this->_wp_list_args);
247
-
248
-        $this->prepare_items();
249
-    }
250
-
251
-
252
-    /**
253
-     * _setup_data
254
-     * this method is used to setup the $_data, $_all_data_count, and _per_page properties
255
-     *
256
-     * @return void
257
-     * @uses $this->_admin_page
258
-     */
259
-    abstract protected function _setup_data();
260
-
261
-
262
-    /**
263
-     * set the properties that this class needs to be able to execute wp_list_table properly
264
-     * properties set:
265
-     * _wp_list_args = what the arguments required for the parent _wp_list_table.
266
-     * _columns = set the columns in an array.
267
-     * _sortable_columns = columns that are sortable (array).
268
-     * _hidden_columns = columns that are hidden (array)
269
-     * _default_orderby = the default orderby for sorting.
270
-     *
271
-     * @abstract
272
-     * @access protected
273
-     * @return void
274
-     */
275
-    abstract protected function _set_properties();
276
-
277
-
278
-    /**
279
-     * _get_table_filters
280
-     * We use this to assemble and return any filters that are associated with this table that help further refine what
281
-     * gets shown in the table.
282
-     *
283
-     * @abstract
284
-     * @access protected
285
-     * @return string
286
-     */
287
-    abstract protected function _get_table_filters();
288
-
289
-
290
-    /**
291
-     * this is a method that child class will do to add counts to the views array so when views are displayed the
292
-     * counts of the views is accurate.
293
-     *
294
-     * @abstract
295
-     * @access protected
296
-     * @return void
297
-     */
298
-    abstract protected function _add_view_counts();
299
-
300
-
301
-    /**
302
-     * _get_hidden_fields
303
-     * returns a html string of hidden fields so if any table filters are used the current view will be respected.
304
-     *
305
-     * @return string
306
-     */
307
-    protected function _get_hidden_fields()
308
-    {
309
-        $action = isset($this->_req_data['route']) ? $this->_req_data['route'] : '';
310
-        $action = empty($action) && isset($this->_req_data['action']) ? $this->_req_data['action'] : $action;
311
-        // if action is STILL empty, then we set it to default
312
-        $action = empty($action) ? 'default' : $action;
313
-        $field  = '<input type="hidden" name="page" value="' . esc_attr($this->_req_data['page']) . '" />' . "\n";
314
-        $field  .= '<input type="hidden" name="route" value="' . esc_attr($action) . '" />' . "\n";
315
-        $field  .= '<input type="hidden" name="perpage" value="' . esc_attr($this->_per_page) . '" />' . "\n";
316
-
317
-        $bulk_actions = $this->_get_bulk_actions();
318
-        foreach ($bulk_actions as $bulk_action => $label) {
319
-            $field .= '<input type="hidden" name="' . $bulk_action . '_nonce"'
320
-                      . ' value="' . wp_create_nonce($bulk_action . '_nonce') . '" />' . "\n";
321
-        }
322
-
323
-        return $field;
324
-    }
325
-
326
-
327
-    /**
328
-     * _set_column_info
329
-     * we're using this to set the column headers property.
330
-     *
331
-     * @access protected
332
-     * @return void
333
-     */
334
-    protected function _set_column_info()
335
-    {
336
-        $columns   = $this->get_columns();
337
-        $hidden    = $this->get_hidden_columns();
338
-        $_sortable = $this->get_sortable_columns();
339
-
340
-        /**
341
-         * Dynamic hook allowing for adding sortable columns in this list table.
342
-         * Note that $this->screen->id is in the format
343
-         * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
344
-         * table it is: event-espresso_page_espresso_messages.
345
-         * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
346
-         * hook prefix ("event-espresso") will be different.
347
-         *
348
-         * @var array
349
-         */
350
-        $_sortable = apply_filters("FHEE_manage_{$this->screen->id}_sortable_columns", $_sortable, $this->_screen);
351
-
352
-        $sortable = [];
353
-        foreach ($_sortable as $id => $data) {
354
-            if (empty($data)) {
355
-                continue;
356
-            }
357
-            // fix for offset errors with WP_List_Table default get_columninfo()
358
-            if (is_array($data)) {
359
-                $_data[0] = key($data);
360
-                $_data[1] = isset($data[1]) ? $data[1] : false;
361
-            } else {
362
-                $_data[0] = $data;
363
-            }
364
-
365
-            $data = (array) $data;
366
-
367
-            if (! isset($data[1])) {
368
-                $_data[1] = false;
369
-            }
370
-
371
-            $sortable[ $id ] = $_data;
372
-        }
373
-        $primary               = $this->get_primary_column_name();
374
-        $this->_column_headers = [$columns, $hidden, $sortable, $primary];
375
-    }
376
-
377
-
378
-    /**
379
-     * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
380
-     *
381
-     * @return string
382
-     */
383
-    protected function get_primary_column_name()
384
-    {
385
-        foreach (class_parents($this) as $parent) {
386
-            if ($parent === 'WP_List_Table' && method_exists($parent, 'get_primary_column_name')) {
387
-                return parent::get_primary_column_name();
388
-            }
389
-        }
390
-        return $this->_primary_column;
391
-    }
392
-
393
-
394
-    /**
395
-     * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
396
-     *
397
-     * @param EE_Base_Class $item
398
-     * @param string        $column_name
399
-     * @param string        $primary
400
-     * @return string
401
-     */
402
-    protected function handle_row_actions($item, $column_name, $primary)
403
-    {
404
-        foreach (class_parents($this) as $parent) {
405
-            if ($parent === 'WP_List_Table' && method_exists($parent, 'handle_row_actions')) {
406
-                return parent::handle_row_actions($item, $column_name, $primary);
407
-            }
408
-        }
409
-        return '';
410
-    }
411
-
412
-
413
-    /**
414
-     * _get_bulk_actions
415
-     * This is a wrapper called by WP_List_Table::get_bulk_actions()
416
-     *
417
-     * @access protected
418
-     * @return array bulk_actions
419
-     */
420
-    protected function _get_bulk_actions(): array
421
-    {
422
-        $actions = [];
423
-        // the _views property should have the bulk_actions, so let's go through and extract them into a properly
424
-        // formatted array for the wp_list_table();
425
-        foreach ($this->_views as $view => $args) {
426
-            if ($this->_view === $view && isset($args['bulk_action']) && is_array($args['bulk_action'])) {
427
-                // each bulk action will correspond with a admin page route, so we can check whatever the capability is
428
-                // for that page route and skip adding the bulk action if no access for the current logged in user.
429
-                foreach ($args['bulk_action'] as $route => $label) {
430
-                    if ($this->_admin_page->check_user_access($route, true)) {
431
-                        $actions[ $route ] = $label;
432
-                    }
433
-                }
434
-            }
435
-        }
436
-        return $actions;
437
-    }
438
-
439
-
440
-    /**
441
-     * Generate the table navigation above or below the table.
442
-     * Overrides the parent table nav in WP_List_Table so we can hide the bulk action div if there are no bulk actions.
443
-     *
444
-     * @throws EE_Error
445
-     * @since 4.9.44.rc.001
446
-     */
447
-    public function display_tablenav($which)
448
-    {
449
-        if ('top' === $which) {
450
-            wp_nonce_field('bulk-' . $this->_args['plural']);
451
-        }
452
-        ?>
25
+	const ACTION_COPY    = 'duplicate';
26
+
27
+	const ACTION_DELETE  = 'delete';
28
+
29
+	const ACTION_EDIT    = 'edit';
30
+
31
+	const ACTION_RESTORE = 'restore';
32
+
33
+	const ACTION_TRASH   = 'trash';
34
+
35
+	protected static $actions = [
36
+		self::ACTION_COPY,
37
+		self::ACTION_DELETE,
38
+		self::ACTION_EDIT,
39
+		self::ACTION_RESTORE,
40
+		self::ACTION_TRASH,
41
+	];
42
+
43
+	/**
44
+	 * holds the data that will be processed for the table
45
+	 *
46
+	 * @var array $_data
47
+	 */
48
+	protected $_data;
49
+
50
+
51
+	/**
52
+	 * This holds the value of all the data available for the given view (for all pages).
53
+	 *
54
+	 * @var int $_all_data_count
55
+	 */
56
+	protected $_all_data_count;
57
+
58
+
59
+	/**
60
+	 * Will contain the count of trashed items for the view label.
61
+	 *
62
+	 * @var int $_trashed_count
63
+	 */
64
+	protected $_trashed_count;
65
+
66
+
67
+	/**
68
+	 * This is what will be referenced as the slug for the current screen
69
+	 *
70
+	 * @var string $_screen
71
+	 */
72
+	protected $_screen;
73
+
74
+
75
+	/**
76
+	 * this is the EE_Admin_Page object
77
+	 *
78
+	 * @var EE_Admin_Page $_admin_page
79
+	 */
80
+	protected $_admin_page;
81
+
82
+
83
+	/**
84
+	 * The current view
85
+	 *
86
+	 * @var string $_view
87
+	 */
88
+	protected $_view;
89
+
90
+
91
+	/**
92
+	 * array of possible views for this table
93
+	 *
94
+	 * @var array $_views
95
+	 */
96
+	protected $_views;
97
+
98
+
99
+	/**
100
+	 * An array of key => value pairs containing information about the current table
101
+	 * array(
102
+	 *        'plural' => 'plural label',
103
+	 *        'singular' => 'singular label',
104
+	 *        'ajax' => false, //whether to use ajax or not
105
+	 *        'screen' => null, //string used to reference what screen this is
106
+	 *        (WP_List_table converts to screen object)
107
+	 * )
108
+	 *
109
+	 * @var array $_wp_list_args
110
+	 */
111
+	protected $_wp_list_args;
112
+
113
+	/**
114
+	 * an array of column names
115
+	 * array(
116
+	 *    'internal-name' => 'Title'
117
+	 * )
118
+	 *
119
+	 * @var array $_columns
120
+	 */
121
+	protected $_columns;
122
+
123
+	/**
124
+	 * An array of sortable columns
125
+	 * array(
126
+	 *    'internal-name' => 'orderby' //or
127
+	 *    'internal-name' => array( 'orderby', true )
128
+	 * )
129
+	 *
130
+	 * @var array $_sortable_columns
131
+	 */
132
+	protected $_sortable_columns;
133
+
134
+	/**
135
+	 * callback method used to perform AJAX row reordering
136
+	 *
137
+	 * @var string $_ajax_sorting_callback
138
+	 */
139
+	protected $_ajax_sorting_callback;
140
+
141
+	/**
142
+	 * An array of hidden columns (if needed)
143
+	 * array('internal-name', 'internal-name')
144
+	 *
145
+	 * @var array $_hidden_columns
146
+	 */
147
+	protected $_hidden_columns;
148
+
149
+	/**
150
+	 * holds the per_page value
151
+	 *
152
+	 * @var int $_per_page
153
+	 */
154
+	protected $_per_page;
155
+
156
+	/**
157
+	 * holds what page number is currently being viewed
158
+	 *
159
+	 * @var int $_current_page
160
+	 */
161
+	protected $_current_page;
162
+
163
+	/**
164
+	 * the reference string for the nonce_action
165
+	 *
166
+	 * @var string $_nonce_action_ref
167
+	 */
168
+	protected $_nonce_action_ref;
169
+
170
+	/**
171
+	 * property to hold incoming request data (as set by the admin_page_core)
172
+	 *
173
+	 * @var array $_req_data
174
+	 */
175
+	protected $_req_data;
176
+
177
+
178
+	/**
179
+	 * yes / no array for admin form fields
180
+	 *
181
+	 * @var array $_yes_no
182
+	 */
183
+	protected $_yes_no = [];
184
+
185
+	/**
186
+	 * Array describing buttons that should appear at the bottom of the page
187
+	 * Keys are strings that represent the button's function (specifically a key in _labels['buttons']),
188
+	 * and the values are another array with the following keys
189
+	 * array(
190
+	 *    'route' => 'page_route',
191
+	 *    'extra_request' => array('evt_id' => 1 ); //extra request vars that need to be included in the button.
192
+	 * )
193
+	 *
194
+	 * @var array $_bottom_buttons
195
+	 */
196
+	protected $_bottom_buttons = [];
197
+
198
+
199
+	/**
200
+	 * Used to indicate what should be the primary column for the list table.
201
+	 * If not present then falls back to what WP calculates
202
+	 * as the primary column.
203
+	 *
204
+	 * @type string $_primary_column
205
+	 */
206
+	protected $_primary_column = '';
207
+
208
+
209
+	/**
210
+	 * Used to indicate whether the table has a checkbox column or not.
211
+	 *
212
+	 * @type bool $_has_checkbox_column
213
+	 */
214
+	protected $_has_checkbox_column = false;
215
+
216
+
217
+	/**
218
+	 * @param EE_Admin_Page $admin_page we use this for obtaining everything we need in the list table
219
+	 */
220
+	public function __construct(EE_Admin_Page $admin_page)
221
+	{
222
+		$this->_admin_page   = $admin_page;
223
+		$this->_req_data     = $this->_admin_page->get_request_data();
224
+		$this->_view         = $this->_admin_page->get_view();
225
+		$this->_views        = empty($this->_views) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views;
226
+		$this->_current_page = $this->get_pagenum();
227
+		$this->_screen       = $this->_admin_page->get_current_page() . '_' . $this->_admin_page->get_current_view();
228
+		$this->_yes_no       = [
229
+			esc_html__('No', 'event_espresso'),
230
+			esc_html__('Yes', 'event_espresso')
231
+		];
232
+
233
+		$this->_per_page = $this->get_items_per_page($this->_screen . '_per_page');
234
+
235
+		$this->_setup_data();
236
+		$this->_add_view_counts();
237
+
238
+		$this->_nonce_action_ref = $this->_view;
239
+
240
+		$this->_set_properties();
241
+
242
+		// set primary column
243
+		add_filter('list_table_primary_column', [$this, 'set_primary_column']);
244
+
245
+		// set parent defaults
246
+		parent::__construct($this->_wp_list_args);
247
+
248
+		$this->prepare_items();
249
+	}
250
+
251
+
252
+	/**
253
+	 * _setup_data
254
+	 * this method is used to setup the $_data, $_all_data_count, and _per_page properties
255
+	 *
256
+	 * @return void
257
+	 * @uses $this->_admin_page
258
+	 */
259
+	abstract protected function _setup_data();
260
+
261
+
262
+	/**
263
+	 * set the properties that this class needs to be able to execute wp_list_table properly
264
+	 * properties set:
265
+	 * _wp_list_args = what the arguments required for the parent _wp_list_table.
266
+	 * _columns = set the columns in an array.
267
+	 * _sortable_columns = columns that are sortable (array).
268
+	 * _hidden_columns = columns that are hidden (array)
269
+	 * _default_orderby = the default orderby for sorting.
270
+	 *
271
+	 * @abstract
272
+	 * @access protected
273
+	 * @return void
274
+	 */
275
+	abstract protected function _set_properties();
276
+
277
+
278
+	/**
279
+	 * _get_table_filters
280
+	 * We use this to assemble and return any filters that are associated with this table that help further refine what
281
+	 * gets shown in the table.
282
+	 *
283
+	 * @abstract
284
+	 * @access protected
285
+	 * @return string
286
+	 */
287
+	abstract protected function _get_table_filters();
288
+
289
+
290
+	/**
291
+	 * this is a method that child class will do to add counts to the views array so when views are displayed the
292
+	 * counts of the views is accurate.
293
+	 *
294
+	 * @abstract
295
+	 * @access protected
296
+	 * @return void
297
+	 */
298
+	abstract protected function _add_view_counts();
299
+
300
+
301
+	/**
302
+	 * _get_hidden_fields
303
+	 * returns a html string of hidden fields so if any table filters are used the current view will be respected.
304
+	 *
305
+	 * @return string
306
+	 */
307
+	protected function _get_hidden_fields()
308
+	{
309
+		$action = isset($this->_req_data['route']) ? $this->_req_data['route'] : '';
310
+		$action = empty($action) && isset($this->_req_data['action']) ? $this->_req_data['action'] : $action;
311
+		// if action is STILL empty, then we set it to default
312
+		$action = empty($action) ? 'default' : $action;
313
+		$field  = '<input type="hidden" name="page" value="' . esc_attr($this->_req_data['page']) . '" />' . "\n";
314
+		$field  .= '<input type="hidden" name="route" value="' . esc_attr($action) . '" />' . "\n";
315
+		$field  .= '<input type="hidden" name="perpage" value="' . esc_attr($this->_per_page) . '" />' . "\n";
316
+
317
+		$bulk_actions = $this->_get_bulk_actions();
318
+		foreach ($bulk_actions as $bulk_action => $label) {
319
+			$field .= '<input type="hidden" name="' . $bulk_action . '_nonce"'
320
+					  . ' value="' . wp_create_nonce($bulk_action . '_nonce') . '" />' . "\n";
321
+		}
322
+
323
+		return $field;
324
+	}
325
+
326
+
327
+	/**
328
+	 * _set_column_info
329
+	 * we're using this to set the column headers property.
330
+	 *
331
+	 * @access protected
332
+	 * @return void
333
+	 */
334
+	protected function _set_column_info()
335
+	{
336
+		$columns   = $this->get_columns();
337
+		$hidden    = $this->get_hidden_columns();
338
+		$_sortable = $this->get_sortable_columns();
339
+
340
+		/**
341
+		 * Dynamic hook allowing for adding sortable columns in this list table.
342
+		 * Note that $this->screen->id is in the format
343
+		 * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
344
+		 * table it is: event-espresso_page_espresso_messages.
345
+		 * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
346
+		 * hook prefix ("event-espresso") will be different.
347
+		 *
348
+		 * @var array
349
+		 */
350
+		$_sortable = apply_filters("FHEE_manage_{$this->screen->id}_sortable_columns", $_sortable, $this->_screen);
351
+
352
+		$sortable = [];
353
+		foreach ($_sortable as $id => $data) {
354
+			if (empty($data)) {
355
+				continue;
356
+			}
357
+			// fix for offset errors with WP_List_Table default get_columninfo()
358
+			if (is_array($data)) {
359
+				$_data[0] = key($data);
360
+				$_data[1] = isset($data[1]) ? $data[1] : false;
361
+			} else {
362
+				$_data[0] = $data;
363
+			}
364
+
365
+			$data = (array) $data;
366
+
367
+			if (! isset($data[1])) {
368
+				$_data[1] = false;
369
+			}
370
+
371
+			$sortable[ $id ] = $_data;
372
+		}
373
+		$primary               = $this->get_primary_column_name();
374
+		$this->_column_headers = [$columns, $hidden, $sortable, $primary];
375
+	}
376
+
377
+
378
+	/**
379
+	 * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
380
+	 *
381
+	 * @return string
382
+	 */
383
+	protected function get_primary_column_name()
384
+	{
385
+		foreach (class_parents($this) as $parent) {
386
+			if ($parent === 'WP_List_Table' && method_exists($parent, 'get_primary_column_name')) {
387
+				return parent::get_primary_column_name();
388
+			}
389
+		}
390
+		return $this->_primary_column;
391
+	}
392
+
393
+
394
+	/**
395
+	 * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
396
+	 *
397
+	 * @param EE_Base_Class $item
398
+	 * @param string        $column_name
399
+	 * @param string        $primary
400
+	 * @return string
401
+	 */
402
+	protected function handle_row_actions($item, $column_name, $primary)
403
+	{
404
+		foreach (class_parents($this) as $parent) {
405
+			if ($parent === 'WP_List_Table' && method_exists($parent, 'handle_row_actions')) {
406
+				return parent::handle_row_actions($item, $column_name, $primary);
407
+			}
408
+		}
409
+		return '';
410
+	}
411
+
412
+
413
+	/**
414
+	 * _get_bulk_actions
415
+	 * This is a wrapper called by WP_List_Table::get_bulk_actions()
416
+	 *
417
+	 * @access protected
418
+	 * @return array bulk_actions
419
+	 */
420
+	protected function _get_bulk_actions(): array
421
+	{
422
+		$actions = [];
423
+		// the _views property should have the bulk_actions, so let's go through and extract them into a properly
424
+		// formatted array for the wp_list_table();
425
+		foreach ($this->_views as $view => $args) {
426
+			if ($this->_view === $view && isset($args['bulk_action']) && is_array($args['bulk_action'])) {
427
+				// each bulk action will correspond with a admin page route, so we can check whatever the capability is
428
+				// for that page route and skip adding the bulk action if no access for the current logged in user.
429
+				foreach ($args['bulk_action'] as $route => $label) {
430
+					if ($this->_admin_page->check_user_access($route, true)) {
431
+						$actions[ $route ] = $label;
432
+					}
433
+				}
434
+			}
435
+		}
436
+		return $actions;
437
+	}
438
+
439
+
440
+	/**
441
+	 * Generate the table navigation above or below the table.
442
+	 * Overrides the parent table nav in WP_List_Table so we can hide the bulk action div if there are no bulk actions.
443
+	 *
444
+	 * @throws EE_Error
445
+	 * @since 4.9.44.rc.001
446
+	 */
447
+	public function display_tablenav($which)
448
+	{
449
+		if ('top' === $which) {
450
+			wp_nonce_field('bulk-' . $this->_args['plural']);
451
+		}
452
+		?>
453 453
         <div class="tablenav <?php echo esc_attr($which); ?>">
454 454
             <?php if ($this->_get_bulk_actions()) { ?>
455 455
                 <div class="alignleft actions bulkactions">
456 456
                     <?php $this->bulk_actions(); ?>
457 457
                 </div>
458 458
             <?php }
459
-            $this->extra_tablenav($which);
460
-            $this->pagination($which);
461
-            ?>
459
+			$this->extra_tablenav($which);
460
+			$this->pagination($which);
461
+			?>
462 462
 
463 463
             <br class="clear" />
464 464
         </div>
465 465
         <?php
466
-    }
467
-
468
-
469
-    /**
470
-     * _filters
471
-     * This receives the filters array from children _get_table_filters() and assembles the string including the filter
472
-     * button.
473
-     *
474
-     * @access private
475
-     * @return void  echos html showing filters
476
-     */
477
-    private function _filters()
478
-    {
479
-        $classname = get_class($this);
480
-        $filters   = apply_filters(
481
-            "FHEE__{$classname}__filters",
482
-            (array) $this->_get_table_filters(),
483
-            $this,
484
-            $this->_screen
485
-        );
486
-
487
-        if (empty($filters)) {
488
-            return;
489
-        }
490
-        foreach ($filters as $filter) {
491
-            echo $filter; // already escaped
492
-        }
493
-        // add filter button at end
494
-        echo '<input type="submit" class="button button--secondary" value="'
495
-             . esc_html__('Filter', 'event_espresso')
496
-             . '" id="post-query-submit" />';
497
-        // add reset filters button at end
498
-        echo '<a class="button button--secondary"  href="'
499
-             . esc_url_raw($this->_admin_page->get_current_page_view_url())
500
-             . '">'
501
-             . esc_html__('Reset Filters', 'event_espresso')
502
-             . '</a>';
503
-    }
504
-
505
-
506
-    /**
507
-     * Callback for 'list_table_primary_column' WordPress filter
508
-     * If child EE_Admin_List_Table classes set the _primary_column property then that will be set as the primary
509
-     * column when class is instantiated.
510
-     *
511
-     * @param string $column_name
512
-     * @return string
513
-     * @see WP_List_Table::get_primary_column_name
514
-     */
515
-    public function set_primary_column($column_name)
516
-    {
517
-        return ! empty($this->_primary_column) ? $this->_primary_column : $column_name;
518
-    }
519
-
520
-
521
-    /**
522
-     *
523
-     */
524
-    public function prepare_items()
525
-    {
526
-        $this->_set_column_info();
527
-        // $this->_column_headers = $this->get_column_info();
528
-        $total_items = $this->_all_data_count;
529
-        $this->process_bulk_action();
530
-
531
-        $this->items = $this->_data;
532
-        $this->set_pagination_args(
533
-            [
534
-                'total_items' => $total_items,
535
-                'per_page'    => $this->_per_page,
536
-                'total_pages' => ceil($total_items / $this->_per_page),
537
-            ]
538
-        );
539
-    }
540
-
541
-
542
-    /**
543
-     * @param object|array $item
544
-     * @return string html content for the column
545
-     */
546
-    protected function column_cb($item)
547
-    {
548
-        return '';
549
-    }
550
-
551
-
552
-    /**
553
-     * This column is the default for when there is no defined column method for a registered column.
554
-     * This can be overridden by child classes, but allows for hooking in for custom columns.
555
-     *
556
-     * @param EE_Base_Class $item
557
-     * @param string        $column_name The column being called.
558
-     * @return string html content for the column
559
-     */
560
-    public function column_default($item, $column_name)
561
-    {
562
-        /**
563
-         * Dynamic hook allowing for adding additional column content in this list table.
564
-         * Note that $this->screen->id is in the format
565
-         * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
566
-         * table it is: event-espresso_page_espresso_messages.
567
-         * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
568
-         * hook prefix ("event-espresso") will be different.
569
-         */
570
-        ob_start();
571
-        do_action(
572
-            'AHEE__EE_Admin_List_Table__column_' . $column_name . '__' . $this->screen->id,
573
-            $item,
574
-            $this->_screen
575
-        );
576
-        return ob_get_clean();
577
-    }
578
-
579
-
580
-    /**
581
-     * Get a list of columns. The format is:
582
-     * 'internal-name' => 'Title'
583
-     *
584
-     * @return array
585
-     * @since  3.1.0
586
-     * @access public
587
-     * @abstract
588
-     */
589
-    public function get_columns()
590
-    {
591
-        /**
592
-         * Dynamic hook allowing for adding additional columns in this list table.
593
-         * Note that $this->screen->id is in the format
594
-         * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
595
-         * table it is: event-espresso_page_espresso_messages.
596
-         * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
597
-         * hook prefix ("event-espresso") will be different.
598
-         *
599
-         * @var array
600
-         */
601
-        return apply_filters('FHEE_manage_' . $this->screen->id . '_columns', $this->_columns, $this->_screen);
602
-    }
603
-
604
-
605
-    /**
606
-     * Get an associative array ( id => link ) with the list
607
-     * of views available on this table.
608
-     *
609
-     * @return array
610
-     * @since  3.1.0
611
-     * @access protected
612
-     */
613
-    public function get_views()
614
-    {
615
-        return $this->_views;
616
-    }
617
-
618
-
619
-    /**
620
-     * Generate the views html.
621
-     */
622
-    public function display_views()
623
-    {
624
-        $views           = $this->get_views();
625
-        $assembled_views = [];
626
-
627
-        if (empty($views)) {
628
-            return;
629
-        }
630
-        echo "<ul class='subsubsub'>\n";
631
-        foreach ($views as $view) {
632
-            $count = isset($view['count']) && ! empty($view['count']) ? absint($view['count']) : 0;
633
-            if (isset($view['slug'], $view['class'], $view['url'], $view['label'])) {
634
-                $filter = "<li";
635
-                $filter .= $view['class'] ? " class='" . esc_attr($view['class']) . "'" : '';
636
-                $filter .= ">";
637
-                $filter .= '<a href="' . esc_url_raw($view['url']) . '">' . esc_html($view['label']) . '</a>';
638
-                $filter .= '<span class="count">(' . $count . ')</span>';
639
-                $filter .= '</li>';
640
-                $assembled_views[ $view['slug'] ] = $filter;
641
-            }
642
-        }
643
-
644
-        echo ! empty($assembled_views)
645
-            ? implode("<li style='margin:0 .5rem;'>|</li>", $assembled_views)
646
-            : '';
647
-        echo "</ul>";
648
-    }
649
-
650
-
651
-    /**
652
-     * Generates content for a single row of the table
653
-     *
654
-     * @param EE_Base_Class $item The current item
655
-     * @since  4.1
656
-     * @access public
657
-     */
658
-    public function single_row($item)
659
-    {
660
-        $row_class = $this->_get_row_class($item);
661
-        echo '<tr class="' . esc_attr($row_class) . '">';
662
-        $this->single_row_columns($item); // already escaped
663
-        echo '</tr>';
664
-    }
665
-
666
-
667
-    /**
668
-     * This simply sets up the row class for the table rows.
669
-     * Allows for easier overriding of child methods for setting up sorting.
670
-     *
671
-     * @param EE_Base_Class $item the current item
672
-     * @return string
673
-     */
674
-    protected function _get_row_class($item)
675
-    {
676
-        static $row_class = '';
677
-        $row_class = ($row_class === '' ? 'alternate' : '');
678
-
679
-        $new_row_class = $row_class;
680
-
681
-        if (! empty($this->_ajax_sorting_callback)) {
682
-            $new_row_class .= ' rowsortable';
683
-        }
684
-
685
-        return $new_row_class;
686
-    }
687
-
688
-
689
-    /**
690
-     * @return array
691
-     */
692
-    public function get_sortable_columns()
693
-    {
694
-        return (array) $this->_sortable_columns;
695
-    }
696
-
697
-
698
-    /**
699
-     * @return string
700
-     */
701
-    public function get_ajax_sorting_callback()
702
-    {
703
-        return $this->_ajax_sorting_callback;
704
-    }
705
-
706
-
707
-    /**
708
-     * @return array
709
-     */
710
-    public function get_hidden_columns()
711
-    {
712
-        $user_id     = get_current_user_id();
713
-        $has_default = get_user_option('default' . $this->screen->id . 'columnshidden', $user_id);
714
-        if (empty($has_default) && ! empty($this->_hidden_columns)) {
715
-            update_user_option($user_id, 'default' . $this->screen->id . 'columnshidden', true);
716
-            update_user_option($user_id, 'manage' . $this->screen->id . 'columnshidden', $this->_hidden_columns, true);
717
-        }
718
-        $ref = 'manage' . $this->screen->id . 'columnshidden';
719
-        return (array) get_user_option($ref, $user_id);
720
-    }
721
-
722
-
723
-    /**
724
-     * Generates the columns for a single row of the table.
725
-     * Overridden from wp_list_table so as to allow us to filter the column content for a given
726
-     * column.
727
-     *
728
-     * @param EE_Base_Class $item The current item
729
-     * @since 3.1.0
730
-     */
731
-    public function single_row_columns($item)
732
-    {
733
-        [$columns, $hidden, $sortable, $primary] = $this->get_column_info();
734
-
735
-        foreach ($columns as $column_name => $column_display_name) {
736
-
737
-            /**
738
-             * With WordPress version 4.3.RC+ WordPress started using the hidden css class to control whether columns
739
-             * are hidden or not instead of using "display:none;".  This bit of code provides backward compat.
740
-             */
741
-            $hidden_class = in_array($column_name, $hidden) ? ' hidden' : '';
742
-
743
-            $classes = $column_name . ' column-' . $column_name . $hidden_class;
744
-            if ($primary === $column_name) {
745
-                $classes .= ' has-row-actions column-primary';
746
-            }
747
-
748
-            $data = ' data-colname="' . wp_strip_all_tags($column_display_name) . '"';
749
-
750
-            $class = 'class="' . esc_attr($classes) . '"';
751
-
752
-            $attributes = "{$class}{$data}";
753
-
754
-            if ($column_name === 'cb') {
755
-                echo '<th scope="row" class="check-column">';
756
-                echo apply_filters(
757
-                    'FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content',
758
-                    $this->column_cb($item), // already escaped
759
-                    $item,
760
-                    $this
761
-                );
762
-                echo '</th>';
763
-            } elseif (method_exists($this, 'column_' . $column_name)) {
764
-                echo "<td $attributes>"; // already escaped
765
-                echo apply_filters(
766
-                    'FHEE__EE_Admin_List_Table__single_row_columns__column_' . $column_name . '__column_content',
767
-                    call_user_func([$this, 'column_' . $column_name], $item),
768
-                    $item,
769
-                    $this
770
-                );
771
-                echo $this->handle_row_actions($item, $column_name, $primary);
772
-                echo "</td>";
773
-            } else {
774
-                echo "<td $attributes>"; // already escaped
775
-                echo apply_filters(
776
-                    'FHEE__EE_Admin_List_Table__single_row_columns__column_default__column_content',
777
-                    $this->column_default($item, $column_name),
778
-                    $item,
779
-                    $column_name,
780
-                    $this
781
-                );
782
-                echo $this->handle_row_actions($item, $column_name, $primary);
783
-                echo "</td>";
784
-            }
785
-        }
786
-    }
787
-
788
-
789
-    /**
790
-     * Extra controls to be displayed between bulk actions and pagination
791
-     *
792
-     * @access public
793
-     * @param string $which
794
-     * @throws EE_Error
795
-     */
796
-    public function extra_tablenav($which)
797
-    {
798
-        if ($which === 'top') {
799
-            $this->_filters();
800
-            echo $this->_get_hidden_fields(); // already escaped
801
-        } else {
802
-            echo '<div class="list-table-bottom-buttons alignleft actions">';
803
-            foreach ($this->_bottom_buttons as $type => $action) {
804
-                $route         = isset($action['route']) ? $action['route'] : '';
805
-                $extra_request = isset($action['extra_request']) ? $action['extra_request'] : '';
806
-                // already escaped
807
-                echo $this->_admin_page->get_action_link_or_button(
808
-                    $route,
809
-                    $type,
810
-                    $extra_request,
811
-                    'button button--secondary'
812
-                );
813
-            }
814
-            do_action('AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', $this, $this->_screen);
815
-            echo '</div>';
816
-        }
817
-    }
818
-
819
-
820
-    /**
821
-     * Get an associative array ( option_name => option_title ) with the list
822
-     * of bulk actions available on this table.
823
-     *
824
-     * @return array
825
-     * @since  3.1.0
826
-     * @access protected
827
-     */
828
-    public function get_bulk_actions()
829
-    {
830
-        return (array) $this->_get_bulk_actions();
831
-    }
832
-
833
-
834
-    /**
835
-     * Processing bulk actions.
836
-     */
837
-    public function process_bulk_action()
838
-    {
839
-        // this is not used it is handled by the child EE_Admin_Page class (routes).  However, including here for
840
-        // reference in case there is a case where it gets used.
841
-    }
842
-
843
-
844
-    /**
845
-     * returns the EE admin page this list table is associated with
846
-     *
847
-     * @return EE_Admin_Page
848
-     */
849
-    public function get_admin_page()
850
-    {
851
-        return $this->_admin_page;
852
-    }
853
-
854
-
855
-    /**
856
-     * A "helper" function for all children to provide an html string of
857
-     * actions to output in their content.  It is preferable for child classes
858
-     * to use this method for generating their actions content so that it's
859
-     * filterable by plugins
860
-     *
861
-     * @param string        $action_container           what are the html container
862
-     *                                                  elements for this actions string?
863
-     * @param string        $action_class               What class is for the container
864
-     *                                                  element.
865
-     * @param string        $action_items               The contents for the action items
866
-     *                                                  container.  This is filtered before
867
-     *                                                  returned.
868
-     * @param string        $action_id                  What id (optional) is used for the
869
-     *                                                  container element.
870
-     * @param EE_Base_Class $item                       The object for the column displaying
871
-     *                                                  the actions.
872
-     * @return string The assembled action elements container.
873
-     */
874
-    protected function _action_string(
875
-        $action_items,
876
-        $item,
877
-        $action_container = 'ul',
878
-        $action_class = '',
879
-        $action_id = ''
880
-    ) {
881
-        $action_class = ! empty($action_class) ? ' class="' . esc_attr($action_class) . '"' : '';
882
-        $action_id    = ! empty($action_id) ? ' id="' . esc_attr($action_id) . '"' : '';
883
-        $open_tag     = ! empty($action_container) ? '<' . $action_container . $action_class . $action_id . '>' : '';
884
-        $close_tag    = ! empty($action_container) ? '</' . $action_container . '>' : '';
885
-        try {
886
-            $content = apply_filters(
887
-                'FHEE__EE_Admin_List_Table___action_string__action_items',
888
-                $action_items,
889
-                $item,
890
-                $this
891
-            );
892
-        } catch (Exception $e) {
893
-            if (WP_DEBUG) {
894
-                EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
895
-            }
896
-            $content = $action_items;
897
-        }
898
-        return "{$open_tag}{$content}{$close_tag}";
899
-    }
900
-
901
-
902
-    /**
903
-     * @return string
904
-     */
905
-    protected function getReturnUrl()
906
-    {
907
-        $host = $this->_admin_page->get_request()->getServerParam('HTTP_HOST');
908
-        $uri  = $this->_admin_page->get_request()->getServerParam('REQUEST_URI');
909
-        return urlencode(esc_url_raw("//{$host}{$uri}"));
910
-    }
911
-
912
-
913
-    /**
914
-     * @param string $id
915
-     * @param string $content
916
-     * @param string $align     start (default), center, end
917
-     * @return string
918
-     * @since   $VID:$
919
-     */
920
-    protected function columnContent($id, $content, $align = 'start')
921
-    {
922
-        if (! isset($this->_columns[ $id ])) {
923
-            throw new DomainException('missing column id');
924
-        }
925
-        $heading = $id !== 'cb' ? $this->_columns[ $id ] : '';
926
-        $align = in_array($align, ['start', 'center', 'end']) ? $align : 'start';
927
-        $align = "ee-responsive-table-cell--{$align}";
928
-
929
-        $html = "<div class='ee-responsive-table-cell ee-responsive-table-cell--column-{$id} {$align} ee-layout-row'>";
930
-        $html .= "<div class='ee-responsive-table-cell__heading'>{$heading}</div>";
931
-        $html .= "<div class='ee-responsive-table-cell__content ee-layout-row'>{$content}</div>";
932
-        $html .= "</div>";
933
-        return $html;
934
-    }
935
-
936
-
937
-    protected function actionsModalMenu($actions): string
938
-    {
939
-        return '
466
+	}
467
+
468
+
469
+	/**
470
+	 * _filters
471
+	 * This receives the filters array from children _get_table_filters() and assembles the string including the filter
472
+	 * button.
473
+	 *
474
+	 * @access private
475
+	 * @return void  echos html showing filters
476
+	 */
477
+	private function _filters()
478
+	{
479
+		$classname = get_class($this);
480
+		$filters   = apply_filters(
481
+			"FHEE__{$classname}__filters",
482
+			(array) $this->_get_table_filters(),
483
+			$this,
484
+			$this->_screen
485
+		);
486
+
487
+		if (empty($filters)) {
488
+			return;
489
+		}
490
+		foreach ($filters as $filter) {
491
+			echo $filter; // already escaped
492
+		}
493
+		// add filter button at end
494
+		echo '<input type="submit" class="button button--secondary" value="'
495
+			 . esc_html__('Filter', 'event_espresso')
496
+			 . '" id="post-query-submit" />';
497
+		// add reset filters button at end
498
+		echo '<a class="button button--secondary"  href="'
499
+			 . esc_url_raw($this->_admin_page->get_current_page_view_url())
500
+			 . '">'
501
+			 . esc_html__('Reset Filters', 'event_espresso')
502
+			 . '</a>';
503
+	}
504
+
505
+
506
+	/**
507
+	 * Callback for 'list_table_primary_column' WordPress filter
508
+	 * If child EE_Admin_List_Table classes set the _primary_column property then that will be set as the primary
509
+	 * column when class is instantiated.
510
+	 *
511
+	 * @param string $column_name
512
+	 * @return string
513
+	 * @see WP_List_Table::get_primary_column_name
514
+	 */
515
+	public function set_primary_column($column_name)
516
+	{
517
+		return ! empty($this->_primary_column) ? $this->_primary_column : $column_name;
518
+	}
519
+
520
+
521
+	/**
522
+	 *
523
+	 */
524
+	public function prepare_items()
525
+	{
526
+		$this->_set_column_info();
527
+		// $this->_column_headers = $this->get_column_info();
528
+		$total_items = $this->_all_data_count;
529
+		$this->process_bulk_action();
530
+
531
+		$this->items = $this->_data;
532
+		$this->set_pagination_args(
533
+			[
534
+				'total_items' => $total_items,
535
+				'per_page'    => $this->_per_page,
536
+				'total_pages' => ceil($total_items / $this->_per_page),
537
+			]
538
+		);
539
+	}
540
+
541
+
542
+	/**
543
+	 * @param object|array $item
544
+	 * @return string html content for the column
545
+	 */
546
+	protected function column_cb($item)
547
+	{
548
+		return '';
549
+	}
550
+
551
+
552
+	/**
553
+	 * This column is the default for when there is no defined column method for a registered column.
554
+	 * This can be overridden by child classes, but allows for hooking in for custom columns.
555
+	 *
556
+	 * @param EE_Base_Class $item
557
+	 * @param string        $column_name The column being called.
558
+	 * @return string html content for the column
559
+	 */
560
+	public function column_default($item, $column_name)
561
+	{
562
+		/**
563
+		 * Dynamic hook allowing for adding additional column content in this list table.
564
+		 * Note that $this->screen->id is in the format
565
+		 * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
566
+		 * table it is: event-espresso_page_espresso_messages.
567
+		 * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
568
+		 * hook prefix ("event-espresso") will be different.
569
+		 */
570
+		ob_start();
571
+		do_action(
572
+			'AHEE__EE_Admin_List_Table__column_' . $column_name . '__' . $this->screen->id,
573
+			$item,
574
+			$this->_screen
575
+		);
576
+		return ob_get_clean();
577
+	}
578
+
579
+
580
+	/**
581
+	 * Get a list of columns. The format is:
582
+	 * 'internal-name' => 'Title'
583
+	 *
584
+	 * @return array
585
+	 * @since  3.1.0
586
+	 * @access public
587
+	 * @abstract
588
+	 */
589
+	public function get_columns()
590
+	{
591
+		/**
592
+		 * Dynamic hook allowing for adding additional columns in this list table.
593
+		 * Note that $this->screen->id is in the format
594
+		 * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
595
+		 * table it is: event-espresso_page_espresso_messages.
596
+		 * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
597
+		 * hook prefix ("event-espresso") will be different.
598
+		 *
599
+		 * @var array
600
+		 */
601
+		return apply_filters('FHEE_manage_' . $this->screen->id . '_columns', $this->_columns, $this->_screen);
602
+	}
603
+
604
+
605
+	/**
606
+	 * Get an associative array ( id => link ) with the list
607
+	 * of views available on this table.
608
+	 *
609
+	 * @return array
610
+	 * @since  3.1.0
611
+	 * @access protected
612
+	 */
613
+	public function get_views()
614
+	{
615
+		return $this->_views;
616
+	}
617
+
618
+
619
+	/**
620
+	 * Generate the views html.
621
+	 */
622
+	public function display_views()
623
+	{
624
+		$views           = $this->get_views();
625
+		$assembled_views = [];
626
+
627
+		if (empty($views)) {
628
+			return;
629
+		}
630
+		echo "<ul class='subsubsub'>\n";
631
+		foreach ($views as $view) {
632
+			$count = isset($view['count']) && ! empty($view['count']) ? absint($view['count']) : 0;
633
+			if (isset($view['slug'], $view['class'], $view['url'], $view['label'])) {
634
+				$filter = "<li";
635
+				$filter .= $view['class'] ? " class='" . esc_attr($view['class']) . "'" : '';
636
+				$filter .= ">";
637
+				$filter .= '<a href="' . esc_url_raw($view['url']) . '">' . esc_html($view['label']) . '</a>';
638
+				$filter .= '<span class="count">(' . $count . ')</span>';
639
+				$filter .= '</li>';
640
+				$assembled_views[ $view['slug'] ] = $filter;
641
+			}
642
+		}
643
+
644
+		echo ! empty($assembled_views)
645
+			? implode("<li style='margin:0 .5rem;'>|</li>", $assembled_views)
646
+			: '';
647
+		echo "</ul>";
648
+	}
649
+
650
+
651
+	/**
652
+	 * Generates content for a single row of the table
653
+	 *
654
+	 * @param EE_Base_Class $item The current item
655
+	 * @since  4.1
656
+	 * @access public
657
+	 */
658
+	public function single_row($item)
659
+	{
660
+		$row_class = $this->_get_row_class($item);
661
+		echo '<tr class="' . esc_attr($row_class) . '">';
662
+		$this->single_row_columns($item); // already escaped
663
+		echo '</tr>';
664
+	}
665
+
666
+
667
+	/**
668
+	 * This simply sets up the row class for the table rows.
669
+	 * Allows for easier overriding of child methods for setting up sorting.
670
+	 *
671
+	 * @param EE_Base_Class $item the current item
672
+	 * @return string
673
+	 */
674
+	protected function _get_row_class($item)
675
+	{
676
+		static $row_class = '';
677
+		$row_class = ($row_class === '' ? 'alternate' : '');
678
+
679
+		$new_row_class = $row_class;
680
+
681
+		if (! empty($this->_ajax_sorting_callback)) {
682
+			$new_row_class .= ' rowsortable';
683
+		}
684
+
685
+		return $new_row_class;
686
+	}
687
+
688
+
689
+	/**
690
+	 * @return array
691
+	 */
692
+	public function get_sortable_columns()
693
+	{
694
+		return (array) $this->_sortable_columns;
695
+	}
696
+
697
+
698
+	/**
699
+	 * @return string
700
+	 */
701
+	public function get_ajax_sorting_callback()
702
+	{
703
+		return $this->_ajax_sorting_callback;
704
+	}
705
+
706
+
707
+	/**
708
+	 * @return array
709
+	 */
710
+	public function get_hidden_columns()
711
+	{
712
+		$user_id     = get_current_user_id();
713
+		$has_default = get_user_option('default' . $this->screen->id . 'columnshidden', $user_id);
714
+		if (empty($has_default) && ! empty($this->_hidden_columns)) {
715
+			update_user_option($user_id, 'default' . $this->screen->id . 'columnshidden', true);
716
+			update_user_option($user_id, 'manage' . $this->screen->id . 'columnshidden', $this->_hidden_columns, true);
717
+		}
718
+		$ref = 'manage' . $this->screen->id . 'columnshidden';
719
+		return (array) get_user_option($ref, $user_id);
720
+	}
721
+
722
+
723
+	/**
724
+	 * Generates the columns for a single row of the table.
725
+	 * Overridden from wp_list_table so as to allow us to filter the column content for a given
726
+	 * column.
727
+	 *
728
+	 * @param EE_Base_Class $item The current item
729
+	 * @since 3.1.0
730
+	 */
731
+	public function single_row_columns($item)
732
+	{
733
+		[$columns, $hidden, $sortable, $primary] = $this->get_column_info();
734
+
735
+		foreach ($columns as $column_name => $column_display_name) {
736
+
737
+			/**
738
+			 * With WordPress version 4.3.RC+ WordPress started using the hidden css class to control whether columns
739
+			 * are hidden or not instead of using "display:none;".  This bit of code provides backward compat.
740
+			 */
741
+			$hidden_class = in_array($column_name, $hidden) ? ' hidden' : '';
742
+
743
+			$classes = $column_name . ' column-' . $column_name . $hidden_class;
744
+			if ($primary === $column_name) {
745
+				$classes .= ' has-row-actions column-primary';
746
+			}
747
+
748
+			$data = ' data-colname="' . wp_strip_all_tags($column_display_name) . '"';
749
+
750
+			$class = 'class="' . esc_attr($classes) . '"';
751
+
752
+			$attributes = "{$class}{$data}";
753
+
754
+			if ($column_name === 'cb') {
755
+				echo '<th scope="row" class="check-column">';
756
+				echo apply_filters(
757
+					'FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content',
758
+					$this->column_cb($item), // already escaped
759
+					$item,
760
+					$this
761
+				);
762
+				echo '</th>';
763
+			} elseif (method_exists($this, 'column_' . $column_name)) {
764
+				echo "<td $attributes>"; // already escaped
765
+				echo apply_filters(
766
+					'FHEE__EE_Admin_List_Table__single_row_columns__column_' . $column_name . '__column_content',
767
+					call_user_func([$this, 'column_' . $column_name], $item),
768
+					$item,
769
+					$this
770
+				);
771
+				echo $this->handle_row_actions($item, $column_name, $primary);
772
+				echo "</td>";
773
+			} else {
774
+				echo "<td $attributes>"; // already escaped
775
+				echo apply_filters(
776
+					'FHEE__EE_Admin_List_Table__single_row_columns__column_default__column_content',
777
+					$this->column_default($item, $column_name),
778
+					$item,
779
+					$column_name,
780
+					$this
781
+				);
782
+				echo $this->handle_row_actions($item, $column_name, $primary);
783
+				echo "</td>";
784
+			}
785
+		}
786
+	}
787
+
788
+
789
+	/**
790
+	 * Extra controls to be displayed between bulk actions and pagination
791
+	 *
792
+	 * @access public
793
+	 * @param string $which
794
+	 * @throws EE_Error
795
+	 */
796
+	public function extra_tablenav($which)
797
+	{
798
+		if ($which === 'top') {
799
+			$this->_filters();
800
+			echo $this->_get_hidden_fields(); // already escaped
801
+		} else {
802
+			echo '<div class="list-table-bottom-buttons alignleft actions">';
803
+			foreach ($this->_bottom_buttons as $type => $action) {
804
+				$route         = isset($action['route']) ? $action['route'] : '';
805
+				$extra_request = isset($action['extra_request']) ? $action['extra_request'] : '';
806
+				// already escaped
807
+				echo $this->_admin_page->get_action_link_or_button(
808
+					$route,
809
+					$type,
810
+					$extra_request,
811
+					'button button--secondary'
812
+				);
813
+			}
814
+			do_action('AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', $this, $this->_screen);
815
+			echo '</div>';
816
+		}
817
+	}
818
+
819
+
820
+	/**
821
+	 * Get an associative array ( option_name => option_title ) with the list
822
+	 * of bulk actions available on this table.
823
+	 *
824
+	 * @return array
825
+	 * @since  3.1.0
826
+	 * @access protected
827
+	 */
828
+	public function get_bulk_actions()
829
+	{
830
+		return (array) $this->_get_bulk_actions();
831
+	}
832
+
833
+
834
+	/**
835
+	 * Processing bulk actions.
836
+	 */
837
+	public function process_bulk_action()
838
+	{
839
+		// this is not used it is handled by the child EE_Admin_Page class (routes).  However, including here for
840
+		// reference in case there is a case where it gets used.
841
+	}
842
+
843
+
844
+	/**
845
+	 * returns the EE admin page this list table is associated with
846
+	 *
847
+	 * @return EE_Admin_Page
848
+	 */
849
+	public function get_admin_page()
850
+	{
851
+		return $this->_admin_page;
852
+	}
853
+
854
+
855
+	/**
856
+	 * A "helper" function for all children to provide an html string of
857
+	 * actions to output in their content.  It is preferable for child classes
858
+	 * to use this method for generating their actions content so that it's
859
+	 * filterable by plugins
860
+	 *
861
+	 * @param string        $action_container           what are the html container
862
+	 *                                                  elements for this actions string?
863
+	 * @param string        $action_class               What class is for the container
864
+	 *                                                  element.
865
+	 * @param string        $action_items               The contents for the action items
866
+	 *                                                  container.  This is filtered before
867
+	 *                                                  returned.
868
+	 * @param string        $action_id                  What id (optional) is used for the
869
+	 *                                                  container element.
870
+	 * @param EE_Base_Class $item                       The object for the column displaying
871
+	 *                                                  the actions.
872
+	 * @return string The assembled action elements container.
873
+	 */
874
+	protected function _action_string(
875
+		$action_items,
876
+		$item,
877
+		$action_container = 'ul',
878
+		$action_class = '',
879
+		$action_id = ''
880
+	) {
881
+		$action_class = ! empty($action_class) ? ' class="' . esc_attr($action_class) . '"' : '';
882
+		$action_id    = ! empty($action_id) ? ' id="' . esc_attr($action_id) . '"' : '';
883
+		$open_tag     = ! empty($action_container) ? '<' . $action_container . $action_class . $action_id . '>' : '';
884
+		$close_tag    = ! empty($action_container) ? '</' . $action_container . '>' : '';
885
+		try {
886
+			$content = apply_filters(
887
+				'FHEE__EE_Admin_List_Table___action_string__action_items',
888
+				$action_items,
889
+				$item,
890
+				$this
891
+			);
892
+		} catch (Exception $e) {
893
+			if (WP_DEBUG) {
894
+				EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
895
+			}
896
+			$content = $action_items;
897
+		}
898
+		return "{$open_tag}{$content}{$close_tag}";
899
+	}
900
+
901
+
902
+	/**
903
+	 * @return string
904
+	 */
905
+	protected function getReturnUrl()
906
+	{
907
+		$host = $this->_admin_page->get_request()->getServerParam('HTTP_HOST');
908
+		$uri  = $this->_admin_page->get_request()->getServerParam('REQUEST_URI');
909
+		return urlencode(esc_url_raw("//{$host}{$uri}"));
910
+	}
911
+
912
+
913
+	/**
914
+	 * @param string $id
915
+	 * @param string $content
916
+	 * @param string $align     start (default), center, end
917
+	 * @return string
918
+	 * @since   $VID:$
919
+	 */
920
+	protected function columnContent($id, $content, $align = 'start')
921
+	{
922
+		if (! isset($this->_columns[ $id ])) {
923
+			throw new DomainException('missing column id');
924
+		}
925
+		$heading = $id !== 'cb' ? $this->_columns[ $id ] : '';
926
+		$align = in_array($align, ['start', 'center', 'end']) ? $align : 'start';
927
+		$align = "ee-responsive-table-cell--{$align}";
928
+
929
+		$html = "<div class='ee-responsive-table-cell ee-responsive-table-cell--column-{$id} {$align} ee-layout-row'>";
930
+		$html .= "<div class='ee-responsive-table-cell__heading'>{$heading}</div>";
931
+		$html .= "<div class='ee-responsive-table-cell__content ee-layout-row'>{$content}</div>";
932
+		$html .= "</div>";
933
+		return $html;
934
+	}
935
+
936
+
937
+	protected function actionsModalMenu($actions): string
938
+	{
939
+		return '
940 940
         <div class="ee-modal-menu">
941 941
             <button class="ee-modal-menu__button button button--small button--icon-only ee-aria-tooltip"
942 942
                     aria-label="' . esc_attr__('list table actions menu', 'event_espresso') . '"
@@ -948,24 +948,24 @@  discard block
 block discarded – undo
948 948
                 ' . $actions . '
949 949
             </div>
950 950
         </div>';
951
-    }
951
+	}
952 952
 
953 953
 
954
-    protected function actionsColumnHeader(): string
955
-    {
956
-        return '
954
+	protected function actionsColumnHeader(): string
955
+	{
956
+		return '
957 957
             <span class="ee-actions-column-header-wrap">
958 958
                 <span class="dashicons dashicons-screenoptions"></span>
959 959
                 <span class="ee-actions-column-header">' . esc_html__('Actions', 'event_espresso') . '</span>
960 960
             </span>';
961
-    }
961
+	}
962 962
 
963 963
 
964
-    protected function getActionLink(string $url, string $display_text, string $label, $class = ''): string
965
-    {
966
-        $class = ! empty($class) ? "{$class} ee-list-table-action" : 'ee-list-table-action';
967
-        $class = ! empty($label) ? "{$class} ee-aria-tooltip" : $class;
968
-        $label = ! empty($label) ? " aria-label='{$label}'" : '';
969
-        return "<a href='{$url}' class='{$class}'{$label}>{$display_text}</a>";
970
-    }
964
+	protected function getActionLink(string $url, string $display_text, string $label, $class = ''): string
965
+	{
966
+		$class = ! empty($class) ? "{$class} ee-list-table-action" : 'ee-list-table-action';
967
+		$class = ! empty($label) ? "{$class} ee-aria-tooltip" : $class;
968
+		$label = ! empty($label) ? " aria-label='{$label}'" : '';
969
+		return "<a href='{$url}' class='{$class}'{$label}>{$display_text}</a>";
970
+	}
971 971
 }
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@  discard block
 block discarded – undo
3 3
 use EventEspresso\core\services\loaders\LoaderFactory;
4 4
 use EventEspresso\core\services\request\RequestInterface;
5 5
 
6
-if (! class_exists('WP_List_Table')) {
7
-    require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
6
+if ( ! class_exists('WP_List_Table')) {
7
+    require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php';
8 8
 }
9 9
 
10 10
 
@@ -224,13 +224,13 @@  discard block
 block discarded – undo
224 224
         $this->_view         = $this->_admin_page->get_view();
225 225
         $this->_views        = empty($this->_views) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views;
226 226
         $this->_current_page = $this->get_pagenum();
227
-        $this->_screen       = $this->_admin_page->get_current_page() . '_' . $this->_admin_page->get_current_view();
227
+        $this->_screen       = $this->_admin_page->get_current_page().'_'.$this->_admin_page->get_current_view();
228 228
         $this->_yes_no       = [
229 229
             esc_html__('No', 'event_espresso'),
230 230
             esc_html__('Yes', 'event_espresso')
231 231
         ];
232 232
 
233
-        $this->_per_page = $this->get_items_per_page($this->_screen . '_per_page');
233
+        $this->_per_page = $this->get_items_per_page($this->_screen.'_per_page');
234 234
 
235 235
         $this->_setup_data();
236 236
         $this->_add_view_counts();
@@ -310,14 +310,14 @@  discard block
 block discarded – undo
310 310
         $action = empty($action) && isset($this->_req_data['action']) ? $this->_req_data['action'] : $action;
311 311
         // if action is STILL empty, then we set it to default
312 312
         $action = empty($action) ? 'default' : $action;
313
-        $field  = '<input type="hidden" name="page" value="' . esc_attr($this->_req_data['page']) . '" />' . "\n";
314
-        $field  .= '<input type="hidden" name="route" value="' . esc_attr($action) . '" />' . "\n";
315
-        $field  .= '<input type="hidden" name="perpage" value="' . esc_attr($this->_per_page) . '" />' . "\n";
313
+        $field  = '<input type="hidden" name="page" value="'.esc_attr($this->_req_data['page']).'" />'."\n";
314
+        $field  .= '<input type="hidden" name="route" value="'.esc_attr($action).'" />'."\n";
315
+        $field  .= '<input type="hidden" name="perpage" value="'.esc_attr($this->_per_page).'" />'."\n";
316 316
 
317 317
         $bulk_actions = $this->_get_bulk_actions();
318 318
         foreach ($bulk_actions as $bulk_action => $label) {
319
-            $field .= '<input type="hidden" name="' . $bulk_action . '_nonce"'
320
-                      . ' value="' . wp_create_nonce($bulk_action . '_nonce') . '" />' . "\n";
319
+            $field .= '<input type="hidden" name="'.$bulk_action.'_nonce"'
320
+                      . ' value="'.wp_create_nonce($bulk_action.'_nonce').'" />'."\n";
321 321
         }
322 322
 
323 323
         return $field;
@@ -364,11 +364,11 @@  discard block
 block discarded – undo
364 364
 
365 365
             $data = (array) $data;
366 366
 
367
-            if (! isset($data[1])) {
367
+            if ( ! isset($data[1])) {
368 368
                 $_data[1] = false;
369 369
             }
370 370
 
371
-            $sortable[ $id ] = $_data;
371
+            $sortable[$id] = $_data;
372 372
         }
373 373
         $primary               = $this->get_primary_column_name();
374 374
         $this->_column_headers = [$columns, $hidden, $sortable, $primary];
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
                 // for that page route and skip adding the bulk action if no access for the current logged in user.
429 429
                 foreach ($args['bulk_action'] as $route => $label) {
430 430
                     if ($this->_admin_page->check_user_access($route, true)) {
431
-                        $actions[ $route ] = $label;
431
+                        $actions[$route] = $label;
432 432
                     }
433 433
                 }
434 434
             }
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
     public function display_tablenav($which)
448 448
     {
449 449
         if ('top' === $which) {
450
-            wp_nonce_field('bulk-' . $this->_args['plural']);
450
+            wp_nonce_field('bulk-'.$this->_args['plural']);
451 451
         }
452 452
         ?>
453 453
         <div class="tablenav <?php echo esc_attr($which); ?>">
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
          */
570 570
         ob_start();
571 571
         do_action(
572
-            'AHEE__EE_Admin_List_Table__column_' . $column_name . '__' . $this->screen->id,
572
+            'AHEE__EE_Admin_List_Table__column_'.$column_name.'__'.$this->screen->id,
573 573
             $item,
574 574
             $this->_screen
575 575
         );
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
          *
599 599
          * @var array
600 600
          */
601
-        return apply_filters('FHEE_manage_' . $this->screen->id . '_columns', $this->_columns, $this->_screen);
601
+        return apply_filters('FHEE_manage_'.$this->screen->id.'_columns', $this->_columns, $this->_screen);
602 602
     }
603 603
 
604 604
 
@@ -632,12 +632,12 @@  discard block
 block discarded – undo
632 632
             $count = isset($view['count']) && ! empty($view['count']) ? absint($view['count']) : 0;
633 633
             if (isset($view['slug'], $view['class'], $view['url'], $view['label'])) {
634 634
                 $filter = "<li";
635
-                $filter .= $view['class'] ? " class='" . esc_attr($view['class']) . "'" : '';
635
+                $filter .= $view['class'] ? " class='".esc_attr($view['class'])."'" : '';
636 636
                 $filter .= ">";
637
-                $filter .= '<a href="' . esc_url_raw($view['url']) . '">' . esc_html($view['label']) . '</a>';
638
-                $filter .= '<span class="count">(' . $count . ')</span>';
637
+                $filter .= '<a href="'.esc_url_raw($view['url']).'">'.esc_html($view['label']).'</a>';
638
+                $filter .= '<span class="count">('.$count.')</span>';
639 639
                 $filter .= '</li>';
640
-                $assembled_views[ $view['slug'] ] = $filter;
640
+                $assembled_views[$view['slug']] = $filter;
641 641
             }
642 642
         }
643 643
 
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
     public function single_row($item)
659 659
     {
660 660
         $row_class = $this->_get_row_class($item);
661
-        echo '<tr class="' . esc_attr($row_class) . '">';
661
+        echo '<tr class="'.esc_attr($row_class).'">';
662 662
         $this->single_row_columns($item); // already escaped
663 663
         echo '</tr>';
664 664
     }
@@ -678,7 +678,7 @@  discard block
 block discarded – undo
678 678
 
679 679
         $new_row_class = $row_class;
680 680
 
681
-        if (! empty($this->_ajax_sorting_callback)) {
681
+        if ( ! empty($this->_ajax_sorting_callback)) {
682 682
             $new_row_class .= ' rowsortable';
683 683
         }
684 684
 
@@ -710,12 +710,12 @@  discard block
 block discarded – undo
710 710
     public function get_hidden_columns()
711 711
     {
712 712
         $user_id     = get_current_user_id();
713
-        $has_default = get_user_option('default' . $this->screen->id . 'columnshidden', $user_id);
713
+        $has_default = get_user_option('default'.$this->screen->id.'columnshidden', $user_id);
714 714
         if (empty($has_default) && ! empty($this->_hidden_columns)) {
715
-            update_user_option($user_id, 'default' . $this->screen->id . 'columnshidden', true);
716
-            update_user_option($user_id, 'manage' . $this->screen->id . 'columnshidden', $this->_hidden_columns, true);
715
+            update_user_option($user_id, 'default'.$this->screen->id.'columnshidden', true);
716
+            update_user_option($user_id, 'manage'.$this->screen->id.'columnshidden', $this->_hidden_columns, true);
717 717
         }
718
-        $ref = 'manage' . $this->screen->id . 'columnshidden';
718
+        $ref = 'manage'.$this->screen->id.'columnshidden';
719 719
         return (array) get_user_option($ref, $user_id);
720 720
     }
721 721
 
@@ -740,14 +740,14 @@  discard block
 block discarded – undo
740 740
              */
741 741
             $hidden_class = in_array($column_name, $hidden) ? ' hidden' : '';
742 742
 
743
-            $classes = $column_name . ' column-' . $column_name . $hidden_class;
743
+            $classes = $column_name.' column-'.$column_name.$hidden_class;
744 744
             if ($primary === $column_name) {
745 745
                 $classes .= ' has-row-actions column-primary';
746 746
             }
747 747
 
748
-            $data = ' data-colname="' . wp_strip_all_tags($column_display_name) . '"';
748
+            $data = ' data-colname="'.wp_strip_all_tags($column_display_name).'"';
749 749
 
750
-            $class = 'class="' . esc_attr($classes) . '"';
750
+            $class = 'class="'.esc_attr($classes).'"';
751 751
 
752 752
             $attributes = "{$class}{$data}";
753 753
 
@@ -760,11 +760,11 @@  discard block
 block discarded – undo
760 760
                     $this
761 761
                 );
762 762
                 echo '</th>';
763
-            } elseif (method_exists($this, 'column_' . $column_name)) {
763
+            } elseif (method_exists($this, 'column_'.$column_name)) {
764 764
                 echo "<td $attributes>"; // already escaped
765 765
                 echo apply_filters(
766
-                    'FHEE__EE_Admin_List_Table__single_row_columns__column_' . $column_name . '__column_content',
767
-                    call_user_func([$this, 'column_' . $column_name], $item),
766
+                    'FHEE__EE_Admin_List_Table__single_row_columns__column_'.$column_name.'__column_content',
767
+                    call_user_func([$this, 'column_'.$column_name], $item),
768 768
                     $item,
769 769
                     $this
770 770
                 );
@@ -878,10 +878,10 @@  discard block
 block discarded – undo
878 878
         $action_class = '',
879 879
         $action_id = ''
880 880
     ) {
881
-        $action_class = ! empty($action_class) ? ' class="' . esc_attr($action_class) . '"' : '';
882
-        $action_id    = ! empty($action_id) ? ' id="' . esc_attr($action_id) . '"' : '';
883
-        $open_tag     = ! empty($action_container) ? '<' . $action_container . $action_class . $action_id . '>' : '';
884
-        $close_tag    = ! empty($action_container) ? '</' . $action_container . '>' : '';
881
+        $action_class = ! empty($action_class) ? ' class="'.esc_attr($action_class).'"' : '';
882
+        $action_id    = ! empty($action_id) ? ' id="'.esc_attr($action_id).'"' : '';
883
+        $open_tag     = ! empty($action_container) ? '<'.$action_container.$action_class.$action_id.'>' : '';
884
+        $close_tag    = ! empty($action_container) ? '</'.$action_container.'>' : '';
885 885
         try {
886 886
             $content = apply_filters(
887 887
                 'FHEE__EE_Admin_List_Table___action_string__action_items',
@@ -919,10 +919,10 @@  discard block
 block discarded – undo
919 919
      */
920 920
     protected function columnContent($id, $content, $align = 'start')
921 921
     {
922
-        if (! isset($this->_columns[ $id ])) {
922
+        if ( ! isset($this->_columns[$id])) {
923 923
             throw new DomainException('missing column id');
924 924
         }
925
-        $heading = $id !== 'cb' ? $this->_columns[ $id ] : '';
925
+        $heading = $id !== 'cb' ? $this->_columns[$id] : '';
926 926
         $align = in_array($align, ['start', 'center', 'end']) ? $align : 'start';
927 927
         $align = "ee-responsive-table-cell--{$align}";
928 928
 
@@ -939,13 +939,13 @@  discard block
 block discarded – undo
939 939
         return '
940 940
         <div class="ee-modal-menu">
941 941
             <button class="ee-modal-menu__button button button--small button--icon-only ee-aria-tooltip"
942
-                    aria-label="' . esc_attr__('list table actions menu', 'event_espresso') . '"
942
+                    aria-label="' . esc_attr__('list table actions menu', 'event_espresso').'"
943 943
             >
944 944
                 <span class="dashicons dashicons-menu"></span>
945 945
             </button>
946 946
             <div class="ee-modal-menu__content ee-admin-container">
947 947
                 <span class="ee-modal-menu__close dashicons dashicons-no"></span>
948
-                ' . $actions . '
948
+                ' . $actions.'
949 949
             </div>
950 950
         </div>';
951 951
     }
@@ -956,7 +956,7 @@  discard block
 block discarded – undo
956 956
         return '
957 957
             <span class="ee-actions-column-header-wrap">
958 958
                 <span class="dashicons dashicons-screenoptions"></span>
959
-                <span class="ee-actions-column-header">' . esc_html__('Actions', 'event_espresso') . '</span>
959
+                <span class="ee-actions-column-header">' . esc_html__('Actions', 'event_espresso').'</span>
960 960
             </span>';
961 961
     }
962 962
 
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page.core.php 2 patches
Indentation   +4139 added lines, -4139 removed lines patch added patch discarded remove patch
@@ -20,4221 +20,4221 @@
 block discarded – undo
20 20
  */
21 21
 abstract class EE_Admin_Page extends EE_Base implements InterminableInterface
22 22
 {
23
-    /**
24
-     * @var EE_Admin_Config
25
-     */
26
-    protected $admin_config;
23
+	/**
24
+	 * @var EE_Admin_Config
25
+	 */
26
+	protected $admin_config;
27 27
 
28
-    /**
29
-     * @var LoaderInterface
30
-     */
31
-    protected $loader;
28
+	/**
29
+	 * @var LoaderInterface
30
+	 */
31
+	protected $loader;
32 32
 
33
-    /**
34
-     * @var RequestInterface
35
-     */
36
-    protected $request;
33
+	/**
34
+	 * @var RequestInterface
35
+	 */
36
+	protected $request;
37 37
 
38
-    // set in _init_page_props()
39
-    public $page_slug;
38
+	// set in _init_page_props()
39
+	public $page_slug;
40 40
 
41
-    public $page_label;
41
+	public $page_label;
42 42
 
43
-    public $page_folder;
43
+	public $page_folder;
44 44
 
45
-    // set in define_page_props()
46
-    protected $_admin_base_url;
45
+	// set in define_page_props()
46
+	protected $_admin_base_url;
47 47
 
48
-    protected $_admin_base_path;
48
+	protected $_admin_base_path;
49 49
 
50
-    protected $_admin_page_title;
50
+	protected $_admin_page_title;
51 51
 
52
-    protected $_labels;
52
+	protected $_labels;
53 53
 
54 54
 
55
-    // set early within EE_Admin_Init
56
-    protected $_wp_page_slug;
55
+	// set early within EE_Admin_Init
56
+	protected $_wp_page_slug;
57 57
 
58
-    // nav tabs
59
-    protected $_nav_tabs;
58
+	// nav tabs
59
+	protected $_nav_tabs;
60 60
 
61
-    protected $_default_nav_tab_name;
61
+	protected $_default_nav_tab_name;
62 62
 
63 63
 
64
-    // template variables (used by templates)
65
-    protected $_template_path;
64
+	// template variables (used by templates)
65
+	protected $_template_path;
66 66
 
67
-    protected $_column_template_path;
67
+	protected $_column_template_path;
68 68
 
69
-    /**
70
-     * @var array $_template_args
71
-     */
72
-    protected $_template_args = [];
69
+	/**
70
+	 * @var array $_template_args
71
+	 */
72
+	protected $_template_args = [];
73 73
 
74
-    /**
75
-     * this will hold the list table object for a given view.
76
-     *
77
-     * @var EE_Admin_List_Table $_list_table_object
78
-     */
79
-    protected $_list_table_object;
74
+	/**
75
+	 * this will hold the list table object for a given view.
76
+	 *
77
+	 * @var EE_Admin_List_Table $_list_table_object
78
+	 */
79
+	protected $_list_table_object;
80 80
 
81
-    // boolean
82
-    protected $_is_UI_request; // this starts at null so we can have no header routes progress through two states.
81
+	// boolean
82
+	protected $_is_UI_request; // this starts at null so we can have no header routes progress through two states.
83 83
 
84
-    protected $_routing;
84
+	protected $_routing;
85 85
 
86
-    // list table args
87
-    protected $_view;
86
+	// list table args
87
+	protected $_view;
88 88
 
89
-    protected $_views;
89
+	protected $_views;
90 90
 
91 91
 
92
-    // action => method pairs used for routing incoming requests
93
-    protected $_page_routes;
92
+	// action => method pairs used for routing incoming requests
93
+	protected $_page_routes;
94 94
 
95
-    /**
96
-     * @var array $_page_config
97
-     */
98
-    protected $_page_config;
95
+	/**
96
+	 * @var array $_page_config
97
+	 */
98
+	protected $_page_config;
99 99
 
100
-    /**
101
-     * the current page route and route config
102
-     *
103
-     * @var string $_route
104
-     */
105
-    protected $_route;
100
+	/**
101
+	 * the current page route and route config
102
+	 *
103
+	 * @var string $_route
104
+	 */
105
+	protected $_route;
106 106
 
107
-    /**
108
-     * @var string $_cpt_route
109
-     */
110
-    protected $_cpt_route;
107
+	/**
108
+	 * @var string $_cpt_route
109
+	 */
110
+	protected $_cpt_route;
111 111
 
112
-    /**
113
-     * @var array $_route_config
114
-     */
115
-    protected $_route_config;
112
+	/**
113
+	 * @var array $_route_config
114
+	 */
115
+	protected $_route_config;
116 116
 
117
-    /**
118
-     * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
119
-     * actions.
120
-     *
121
-     * @since 4.6.x
122
-     * @var array.
123
-     */
124
-    protected $_default_route_query_args;
117
+	/**
118
+	 * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
119
+	 * actions.
120
+	 *
121
+	 * @since 4.6.x
122
+	 * @var array.
123
+	 */
124
+	protected $_default_route_query_args;
125 125
 
126
-    // set via request page and action args.
127
-    protected $_current_page;
128
-
129
-    protected $_current_view;
126
+	// set via request page and action args.
127
+	protected $_current_page;
128
+
129
+	protected $_current_view;
130 130
 
131
-    protected $_current_page_view_url;
131
+	protected $_current_page_view_url;
132 132
 
133
-    /**
134
-     * unprocessed value for the 'action' request param (default '')
135
-     *
136
-     * @var string
137
-     */
138
-    protected $raw_req_action = '';
139
-
140
-    /**
141
-     * unprocessed value for the 'page' request param (default '')
142
-     *
143
-     * @var string
144
-     */
145
-    protected $raw_req_page = '';
146
-
147
-    /**
148
-     * sanitized request action (and nonce)
149
-     *
150
-     * @var string
151
-     */
152
-    protected $_req_action = '';
153
-
154
-    /**
155
-     * sanitized request action nonce
156
-     *
157
-     * @var string
158
-     */
159
-    protected $_req_nonce = '';
160
-
161
-    /**
162
-     * @var string
163
-     */
164
-    protected $_search_btn_label = '';
165
-
166
-    /**
167
-     * @var string
168
-     */
169
-    protected $_search_box_callback = '';
170
-
171
-    /**
172
-     * @var WP_Screen
173
-     */
174
-    protected $_current_screen;
175
-
176
-    // for holding EE_Admin_Hooks object when needed (set via set_hook_object())
177
-    protected $_hook_obj;
178
-
179
-    // for holding incoming request data
180
-    protected $_req_data = [];
181
-
182
-    // yes / no array for admin form fields
183
-    protected $_yes_no_values = [];
184
-
185
-    // some default things shared by all child classes
186
-    protected $_default_espresso_metaboxes;
187
-
188
-    /**
189
-     * @var EE_Registry
190
-     */
191
-    protected $EE;
192
-
193
-
194
-    /**
195
-     * This is just a property that flags whether the given route is a caffeinated route or not.
196
-     *
197
-     * @var boolean
198
-     */
199
-    protected $_is_caf = false;
200
-
201
-    /**
202
-     * whether or not initializePage() has run
203
-     *
204
-     * @var boolean
205
-     */
206
-    protected $initialized = false;
207
-
208
-    /**
209
-     * @var FeatureFlags
210
-     */
211
-    protected $feature;
212
-
213
-
214
-    /**
215
-     * @Constructor
216
-     * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
217
-     * @throws InvalidArgumentException
218
-     * @throws InvalidDataTypeException
219
-     * @throws InvalidInterfaceException
220
-     * @throws ReflectionException
221
-     */
222
-    public function __construct($routing = true)
223
-    {
224
-        $this->loader = LoaderFactory::getLoader();
225
-        $this->admin_config = $this->loader->getShared('EE_Admin_Config');
226
-        $this->feature = $this->loader->getShared(FeatureFlags::class);
227
-        $this->request = $this->loader->getShared(RequestInterface::class);
228
-        // routing enabled?
229
-        $this->_routing = $routing;
230
-
231
-        if (strpos($this->_get_dir(), 'caffeinated') !== false) {
232
-            $this->_is_caf = true;
233
-        }
234
-        $this->_yes_no_values = [
235
-            ['id' => true, 'text' => esc_html__('Yes', 'event_espresso')],
236
-            ['id' => false, 'text' => esc_html__('No', 'event_espresso')],
237
-        ];
238
-        // set the _req_data property.
239
-        $this->_req_data = $this->request->requestParams();
240
-    }
241
-
242
-
243
-    /**
244
-     * @return EE_Admin_Config
245
-     */
246
-    public function adminConfig(): EE_Admin_Config
247
-    {
248
-        return $this->admin_config;
249
-    }
250
-
251
-
252
-    /**
253
-     * @return FeatureFlags
254
-     */
255
-    public function feature(): FeatureFlags
256
-    {
257
-        return $this->feature;
258
-    }
259
-
260
-
261
-    /**
262
-     * This logic used to be in the constructor, but that caused a chicken <--> egg scenario
263
-     * for child classes that needed to set properties prior to these methods getting called,
264
-     * but also needed the parent class to have its construction completed as well.
265
-     * Bottom line is that constructors should ONLY be used for setting initial properties
266
-     * and any complex initialization logic should only run after instantiation is complete.
267
-     *
268
-     * This method gets called immediately after construction from within
269
-     *      EE_Admin_Page_Init::_initialize_admin_page()
270
-     *
271
-     * @throws EE_Error
272
-     * @throws InvalidArgumentException
273
-     * @throws InvalidDataTypeException
274
-     * @throws InvalidInterfaceException
275
-     * @throws ReflectionException
276
-     * @since $VID:$
277
-     */
278
-    public function initializePage()
279
-    {
280
-        if ($this->initialized) {
281
-            return;
282
-        }
283
-        // set initial page props (child method)
284
-        $this->_init_page_props();
285
-        // set global defaults
286
-        $this->_set_defaults();
287
-        // set early because incoming requests could be ajax related and we need to register those hooks.
288
-        $this->_global_ajax_hooks();
289
-        $this->_ajax_hooks();
290
-        // other_page_hooks have to be early too.
291
-        $this->_do_other_page_hooks();
292
-        // set up page dependencies
293
-        $this->_before_page_setup();
294
-        $this->_page_setup();
295
-        $this->initialized = true;
296
-    }
297
-
298
-
299
-    /**
300
-     * _init_page_props
301
-     * Child classes use to set at least the following properties:
302
-     * $page_slug.
303
-     * $page_label.
304
-     *
305
-     * @abstract
306
-     * @return void
307
-     */
308
-    abstract protected function _init_page_props();
309
-
310
-
311
-    /**
312
-     * _ajax_hooks
313
-     * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
314
-     * Note: within the ajax callback methods.
315
-     *
316
-     * @abstract
317
-     * @return void
318
-     */
319
-    abstract protected function _ajax_hooks();
320
-
321
-
322
-    /**
323
-     * _define_page_props
324
-     * child classes define page properties in here.  Must include at least:
325
-     * $_admin_base_url = base_url for all admin pages
326
-     * $_admin_page_title = default admin_page_title for admin pages
327
-     * $_labels = array of default labels for various automatically generated elements:
328
-     *    array(
329
-     *        'buttons' => array(
330
-     *            'add' => esc_html__('label for add new button'),
331
-     *            'edit' => esc_html__('label for edit button'),
332
-     *            'delete' => esc_html__('label for delete button')
333
-     *            )
334
-     *        )
335
-     *
336
-     * @abstract
337
-     * @return void
338
-     */
339
-    abstract protected function _define_page_props();
340
-
341
-
342
-    /**
343
-     * _set_page_routes
344
-     * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
345
-     * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
346
-     * have a 'default' route. Here's the format
347
-     * $this->_page_routes = array(
348
-     *        'default' => array(
349
-     *            'func' => '_default_method_handling_route',
350
-     *            'args' => array('array','of','args'),
351
-     *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
352
-     *            ajax request, backend processing)
353
-     *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
354
-     *            headers route after.  The string you enter here should match the defined route reference for a
355
-     *            headers sent route.
356
-     *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
357
-     *            this route.
358
-     *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
359
-     *            checks).
360
-     *        ),
361
-     *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
362
-     *        handling method.
363
-     *        )
364
-     * )
365
-     *
366
-     * @abstract
367
-     * @return void
368
-     */
369
-    abstract protected function _set_page_routes();
370
-
371
-
372
-    /**
373
-     * _set_page_config
374
-     * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
375
-     * array corresponds to the page_route for the loaded page. Format:
376
-     * $this->_page_config = array(
377
-     *        'default' => array(
378
-     *            'labels' => array(
379
-     *                'buttons' => array(
380
-     *                    'add' => esc_html__('label for adding item'),
381
-     *                    'edit' => esc_html__('label for editing item'),
382
-     *                    'delete' => esc_html__('label for deleting item')
383
-     *                ),
384
-     *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
385
-     *            ), //optional an array of custom labels for various automatically generated elements to use on the
386
-     *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
387
-     *            _define_page_props() method
388
-     *            'nav' => array(
389
-     *                'label' => esc_html__('Label for Tab', 'event_espresso').
390
-     *                'url' => 'http://someurl', //automatically generated UNLESS you define
391
-     *                'css_class' => 'css-class', //automatically generated UNLESS you define
392
-     *                'order' => 10, //required to indicate tab position.
393
-     *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
394
-     *                displayed then add this parameter.
395
-     *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
396
-     *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
397
-     *            metaboxes set for eventespresso admin pages.
398
-     *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
399
-     *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
400
-     *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
401
-     *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
402
-     *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
403
-     *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
404
-     *            array indicates the max number of columns (4) and the default number of columns on page load (2).
405
-     *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
406
-     *            want to display.
407
-     *            'help_tabs' => array( //this is used for adding help tabs to a page
408
-     *                'tab_id' => array(
409
-     *                    'title' => 'tab_title',
410
-     *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
411
-     *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
412
-     *                    should match a file in the admin folder's "help_tabs" dir (ie..
413
-     *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
414
-     *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
415
-     *                    attempt to use the callback which should match the name of a method in the class
416
-     *                    ),
417
-     *                'tab2_id' => array(
418
-     *                    'title' => 'tab2 title',
419
-     *                    'filename' => 'file_name_2'
420
-     *                    'callback' => 'callback_method_for_content',
421
-     *                 ),
422
-     *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
423
-     *            help tab area on an admin page. @return void
424
-     *
425
-     * @abstract
426
-     */
427
-    abstract protected function _set_page_config();
428
-
429
-
430
-    /**
431
-     * _add_screen_options
432
-     * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
433
-     * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
434
-     * to a particular view.
435
-     *
436
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
437
-     *         see also WP_Screen object documents...
438
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
439
-     * @abstract
440
-     * @return void
441
-     */
442
-    abstract protected function _add_screen_options();
443
-
444
-
445
-    /**
446
-     * _add_feature_pointers
447
-     * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
448
-     * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
449
-     * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
450
-     * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
451
-     * extended) also see:
452
-     *
453
-     * @link   http://eamann.com/tech/wordpress-portland/
454
-     * @abstract
455
-     * @return void
456
-     */
457
-    abstract protected function _add_feature_pointers();
458
-
459
-
460
-    /**
461
-     * load_scripts_styles
462
-     * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
463
-     * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
464
-     * scripts/styles per view by putting them in a dynamic function in this format
465
-     * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
466
-     *
467
-     * @abstract
468
-     * @return void
469
-     */
470
-    abstract public function load_scripts_styles();
471
-
472
-
473
-    /**
474
-     * admin_init
475
-     * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
476
-     * all pages/views loaded by child class.
477
-     *
478
-     * @abstract
479
-     * @return void
480
-     */
481
-    abstract public function admin_init();
482
-
483
-
484
-    /**
485
-     * admin_notices
486
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
487
-     * all pages/views loaded by child class.
488
-     *
489
-     * @abstract
490
-     * @return void
491
-     */
492
-    abstract public function admin_notices();
493
-
494
-
495
-    /**
496
-     * admin_footer_scripts
497
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
498
-     * will apply to all pages/views loaded by child class.
499
-     *
500
-     * @return void
501
-     */
502
-    abstract public function admin_footer_scripts();
503
-
504
-
505
-    /**
506
-     * admin_footer
507
-     * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
508
-     * apply to all pages/views loaded by child class.
509
-     *
510
-     * @return void
511
-     */
512
-    public function admin_footer()
513
-    {
514
-    }
515
-
516
-
517
-    /**
518
-     * _global_ajax_hooks
519
-     * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
520
-     * Note: within the ajax callback methods.
521
-     *
522
-     * @abstract
523
-     * @return void
524
-     */
525
-    protected function _global_ajax_hooks()
526
-    {
527
-        // for lazy loading of metabox content
528
-        add_action('wp_ajax_espresso-ajax-content', [$this, 'ajax_metabox_content'], 10);
529
-
530
-        add_action(
531
-            'wp_ajax_espresso_hide_status_change_notice',
532
-            [$this, 'hideStatusChangeNotice']
533
-        );
534
-        add_action(
535
-            'wp_ajax_nopriv_espresso_hide_status_change_notice',
536
-            [$this, 'hideStatusChangeNotice']
537
-        );
538
-    }
539
-
540
-
541
-    public function ajax_metabox_content()
542
-    {
543
-        $content_id  = $this->request->getRequestParam('contentid', '');
544
-        $content_url = $this->request->getRequestParam('contenturl', '', 'url');
545
-        EE_Admin_Page::cached_rss_display($content_id, $content_url);
546
-        wp_die();
547
-    }
548
-
549
-
550
-    public function hideStatusChangeNotice()
551
-    {
552
-        $response = [];
553
-        try {
554
-            /** @var EventEspresso\core\admin\StatusChangeNotice $status_change_notice */
555
-            $status_change_notice = $this->loader->getShared('EventEspresso\core\admin\StatusChangeNotice');
556
-            $response['success'] = $status_change_notice->dismiss() > -1;
557
-        } catch (Exception $exception) {
558
-            $response['errors'] = $exception->getMessage();
559
-        }
560
-        echo wp_json_encode($response);
561
-        exit();
562
-    }
563
-
564
-
565
-    /**
566
-     * allows extending classes do something specific before the parent constructor runs _page_setup().
567
-     *
568
-     * @return void
569
-     */
570
-    protected function _before_page_setup()
571
-    {
572
-        // default is to do nothing
573
-    }
574
-
575
-
576
-    /**
577
-     * Makes sure any things that need to be loaded early get handled.
578
-     * We also escape early here if the page requested doesn't match the object.
579
-     *
580
-     * @final
581
-     * @return void
582
-     * @throws EE_Error
583
-     * @throws InvalidArgumentException
584
-     * @throws ReflectionException
585
-     * @throws InvalidDataTypeException
586
-     * @throws InvalidInterfaceException
587
-     */
588
-    final protected function _page_setup()
589
-    {
590
-        // requires?
591
-        // admin_init stuff - global - we're setting this REALLY early
592
-        // so if EE_Admin pages have to hook into other WP pages they can.
593
-        // But keep in mind, not everything is available from the EE_Admin Page object at this point.
594
-        add_action('admin_init', [$this, 'admin_init_global'], 5);
595
-        // next verify if we need to load anything...
596
-        $this->_current_page = $this->request->getRequestParam('page', '', 'key');
597
-        $this->page_folder   = strtolower(
598
-            str_replace(['_Admin_Page', 'Extend_'], '', get_class($this))
599
-        );
600
-        global $ee_menu_slugs;
601
-        $ee_menu_slugs = (array) $ee_menu_slugs;
602
-        if (
603
-            ! $this->request->isAjax()
604
-            && (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))
605
-        ) {
606
-            return;
607
-        }
608
-        // because WP List tables have two duplicate select inputs for choosing bulk actions,
609
-        // we need to copy the action from the second to the first
610
-        $action     = $this->request->getRequestParam('action', '-1', 'key');
611
-        $action2    = $this->request->getRequestParam('action2', '-1', 'key');
612
-        $action     = $action !== '-1' ? $action : $action2;
613
-        $req_action = $action !== '-1' ? $action : 'default';
614
-
615
-        // if a specific 'route' has been set, and the action is 'default' OR we are doing_ajax
616
-        // then let's use the route as the action.
617
-        // This covers cases where we're coming in from a list table that isn't on the default route.
618
-        $route = $this->request->getRequestParam('route');
619
-        $this->_req_action = $route && ($req_action === 'default' || $this->request->isAjax())
620
-            ? $route
621
-            : $req_action;
622
-
623
-        $this->_current_view = $this->_req_action;
624
-        $this->_req_nonce    = $this->_req_action . '_nonce';
625
-        $this->_define_page_props();
626
-        $this->_current_page_view_url = add_query_arg(
627
-            ['page' => $this->_current_page, 'action' => $this->_current_view],
628
-            $this->_admin_base_url
629
-        );
630
-        // default things
631
-        $this->_default_espresso_metaboxes = [
632
-            '_espresso_news_post_box',
633
-            '_espresso_links_post_box',
634
-            '_espresso_ratings_request',
635
-            '_espresso_sponsors_post_box',
636
-        ];
637
-        // set page configs
638
-        $this->_set_page_routes();
639
-        $this->_set_page_config();
640
-        // let's include any referrer data in our default_query_args for this route for "stickiness".
641
-        if ($this->request->requestParamIsSet('wp_referer')) {
642
-            $wp_referer = $this->request->getRequestParam('wp_referer');
643
-            if ($wp_referer) {
644
-                $this->_default_route_query_args['wp_referer'] = $wp_referer;
645
-            }
646
-        }
647
-        // for caffeinated and other extended functionality.
648
-        //  If there is a _extend_page_config method
649
-        // then let's run that to modify the all the various page configuration arrays
650
-        if (method_exists($this, '_extend_page_config')) {
651
-            $this->_extend_page_config();
652
-        }
653
-        // for CPT and other extended functionality.
654
-        // If there is an _extend_page_config_for_cpt
655
-        // then let's run that to modify all the various page configuration arrays.
656
-        if (method_exists($this, '_extend_page_config_for_cpt')) {
657
-            $this->_extend_page_config_for_cpt();
658
-        }
659
-        // filter routes and page_config so addons can add their stuff. Filtering done per class
660
-        $this->_page_routes = apply_filters(
661
-            'FHEE__' . get_class($this) . '__page_setup__page_routes',
662
-            $this->_page_routes,
663
-            $this
664
-        );
665
-        $this->_page_config = apply_filters(
666
-            'FHEE__' . get_class($this) . '__page_setup__page_config',
667
-            $this->_page_config,
668
-            $this
669
-        );
670
-        // if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
671
-        // then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
672
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
673
-            add_action(
674
-                'AHEE__EE_Admin_Page__route_admin_request',
675
-                [$this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view],
676
-                10,
677
-                2
678
-            );
679
-        }
680
-        // next route only if routing enabled
681
-        if ($this->_routing && ! $this->request->isAjax()) {
682
-            $this->_verify_routes();
683
-            // next let's just check user_access and kill if no access
684
-            $this->check_user_access();
685
-            if ($this->_is_UI_request) {
686
-                // admin_init stuff - global, all views for this page class, specific view
687
-                add_action('admin_init', [$this, 'admin_init'], 10);
688
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
689
-                    add_action('admin_init', [$this, 'admin_init_' . $this->_current_view], 15);
690
-                }
691
-            } else {
692
-                // hijack regular WP loading and route admin request immediately
693
-                @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
694
-                $this->route_admin_request();
695
-            }
696
-        }
697
-    }
698
-
699
-
700
-    /**
701
-     * Provides a way for related child admin pages to load stuff on the loaded admin page.
702
-     *
703
-     * @return void
704
-     * @throws EE_Error
705
-     */
706
-    private function _do_other_page_hooks()
707
-    {
708
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, []);
709
-        foreach ($registered_pages as $page) {
710
-            // now let's setup the file name and class that should be present
711
-            $classname = str_replace('.class.php', '', $page);
712
-            // autoloaders should take care of loading file
713
-            if (! class_exists($classname)) {
714
-                $error_msg[] = sprintf(
715
-                    esc_html__(
716
-                        'Something went wrong with loading the %s admin hooks page.',
717
-                        'event_espresso'
718
-                    ),
719
-                    $page
720
-                );
721
-                $error_msg[] = $error_msg[0]
722
-                               . "\r\n"
723
-                               . sprintf(
724
-                                   esc_html__(
725
-                                       'There is no class in place for the %1$s admin hooks page.%2$sMake sure you have %3$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
726
-                                       'event_espresso'
727
-                                   ),
728
-                                   $page,
729
-                                   '<br />',
730
-                                   '<strong>' . $classname . '</strong>'
731
-                               );
732
-                throw new EE_Error(implode('||', $error_msg));
733
-            }
734
-            // notice we are passing the instance of this class to the hook object.
735
-            $this->loader->getShared($classname, [$this]);
736
-        }
737
-    }
738
-
739
-
740
-    /**
741
-     * @throws ReflectionException
742
-     * @throws EE_Error
743
-     */
744
-    public function load_page_dependencies()
745
-    {
746
-        try {
747
-            $this->_load_page_dependencies();
748
-        } catch (EE_Error $e) {
749
-            $e->get_error();
750
-        }
751
-    }
752
-
753
-
754
-    /**
755
-     * load_page_dependencies
756
-     * loads things specific to this page class when its loaded.  Really helps with efficiency.
757
-     *
758
-     * @return void
759
-     * @throws DomainException
760
-     * @throws EE_Error
761
-     * @throws InvalidArgumentException
762
-     * @throws InvalidDataTypeException
763
-     * @throws InvalidInterfaceException
764
-     */
765
-    protected function _load_page_dependencies()
766
-    {
767
-        // let's set the current_screen and screen options to override what WP set
768
-        $this->_current_screen = get_current_screen();
769
-        // load admin_notices - global, page class, and view specific
770
-        add_action('admin_notices', [$this, 'admin_notices_global'], 5);
771
-        add_action('admin_notices', [$this, 'admin_notices'], 10);
772
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
773
-            add_action('admin_notices', [$this, 'admin_notices_' . $this->_current_view], 15);
774
-        }
775
-        // load network admin_notices - global, page class, and view specific
776
-        add_action('network_admin_notices', [$this, 'network_admin_notices_global'], 5);
777
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
778
-            add_action('network_admin_notices', [$this, 'network_admin_notices_' . $this->_current_view]);
779
-        }
780
-        // this will save any per_page screen options if they are present
781
-        $this->_set_per_page_screen_options();
782
-        // setup list table properties
783
-        $this->_set_list_table();
784
-        // child classes can "register" a metabox to be automatically handled via the _page_config array property.
785
-        // However in some cases the metaboxes will need to be added within a route handling callback.
786
-        $this->_add_registered_meta_boxes();
787
-        $this->_add_screen_columns();
788
-        // add screen options - global, page child class, and view specific
789
-        $this->_add_global_screen_options();
790
-        $this->_add_screen_options();
791
-        $add_screen_options = "_add_screen_options_{$this->_current_view}";
792
-        if (method_exists($this, $add_screen_options)) {
793
-            $this->{$add_screen_options}();
794
-        }
795
-        // add help tab(s) - set via page_config and qtips.
796
-        $this->_add_help_tabs();
797
-        $this->_add_qtips();
798
-        // add feature_pointers - global, page child class, and view specific
799
-        $this->_add_feature_pointers();
800
-        $this->_add_global_feature_pointers();
801
-        $add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
802
-        if (method_exists($this, $add_feature_pointer)) {
803
-            $this->{$add_feature_pointer}();
804
-        }
805
-        // enqueue scripts/styles - global, page class, and view specific
806
-        add_action('admin_enqueue_scripts', [$this, 'load_global_scripts_styles'], 5);
807
-        add_action('admin_enqueue_scripts', [$this, 'load_scripts_styles'], 10);
808
-        if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
809
-            add_action('admin_enqueue_scripts', [$this, "load_scripts_styles_{$this->_current_view}"], 15);
810
-        }
811
-        add_action('admin_enqueue_scripts', [$this, 'admin_footer_scripts_eei18n_js_strings'], 100);
812
-        // admin_print_footer_scripts - global, page child class, and view specific.
813
-        // NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
814
-        // In most cases that's doing_it_wrong().  But adding hidden container elements etc.
815
-        // is a good use case. Notice the late priority we're giving these
816
-        add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts_global'], 99);
817
-        add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts'], 100);
818
-        if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
819
-            add_action('admin_print_footer_scripts', [$this, "admin_footer_scripts_{$this->_current_view}"], 101);
820
-        }
821
-        // admin footer scripts
822
-        add_action('admin_footer', [$this, 'admin_footer_global'], 99);
823
-        add_action('admin_footer', [$this, 'admin_footer'], 100);
824
-        if (method_exists($this, "admin_footer_{$this->_current_view}")) {
825
-            add_action('admin_footer', [$this, "admin_footer_{$this->_current_view}"], 101);
826
-        }
827
-        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
828
-        // targeted hook
829
-        do_action(
830
-            "FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
831
-        );
832
-    }
833
-
834
-
835
-    /**
836
-     * _set_defaults
837
-     * This sets some global defaults for class properties.
838
-     */
839
-    private function _set_defaults()
840
-    {
841
-        $this->_current_screen       = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
842
-        $this->_event                = $this->_template_path = $this->_column_template_path = null;
843
-        $this->_nav_tabs             = $this->_views = $this->_page_routes = [];
844
-        $this->_page_config          = $this->_default_route_query_args = [];
845
-        $this->_default_nav_tab_name = 'overview';
846
-        // init template args
847
-        $this->_template_args = [
848
-            'admin_page_header'  => '',
849
-            'admin_page_content' => '',
850
-            'post_body_content'  => '',
851
-            'before_list_table'  => '',
852
-            'after_list_table'   => '',
853
-        ];
854
-    }
855
-
856
-
857
-    /**
858
-     * route_admin_request
859
-     *
860
-     * @return void
861
-     * @throws InvalidArgumentException
862
-     * @throws InvalidInterfaceException
863
-     * @throws InvalidDataTypeException
864
-     * @throws EE_Error
865
-     * @throws ReflectionException
866
-     * @see    _route_admin_request()
867
-     */
868
-    public function route_admin_request()
869
-    {
870
-        try {
871
-            $this->_route_admin_request();
872
-        } catch (EE_Error $e) {
873
-            $e->get_error();
874
-        }
875
-    }
876
-
877
-
878
-    public function set_wp_page_slug($wp_page_slug)
879
-    {
880
-        $this->_wp_page_slug = $wp_page_slug;
881
-        // if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
882
-        if (is_network_admin()) {
883
-            $this->_wp_page_slug .= '-network';
884
-        }
885
-    }
886
-
887
-
888
-    /**
889
-     * _verify_routes
890
-     * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
891
-     * we know if we need to drop out.
892
-     *
893
-     * @return bool
894
-     * @throws EE_Error
895
-     */
896
-    protected function _verify_routes()
897
-    {
898
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
899
-        if (! $this->_current_page && ! $this->request->isAjax()) {
900
-            return false;
901
-        }
902
-        $this->_route = false;
903
-        // check that the page_routes array is not empty
904
-        if (empty($this->_page_routes)) {
905
-            // user error msg
906
-            $error_msg = sprintf(
907
-                esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
908
-                $this->_admin_page_title
909
-            );
910
-            // developer error msg
911
-            $error_msg .= '||' . $error_msg
912
-                          . esc_html__(
913
-                              ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
914
-                              'event_espresso'
915
-                          );
916
-            throw new EE_Error($error_msg);
917
-        }
918
-        // and that the requested page route exists
919
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
920
-            $this->_route        = $this->_page_routes[ $this->_req_action ];
921
-            $this->_route_config = $this->_page_config[ $this->_req_action ] ?? [];
922
-        } else {
923
-            // user error msg
924
-            $error_msg = sprintf(
925
-                esc_html__(
926
-                    'The requested page route does not exist for the %s admin page.',
927
-                    'event_espresso'
928
-                ),
929
-                $this->_admin_page_title
930
-            );
931
-            // developer error msg
932
-            $error_msg .= '||' . $error_msg
933
-                          . sprintf(
934
-                              esc_html__(
935
-                                  ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
936
-                                  'event_espresso'
937
-                              ),
938
-                              $this->_req_action
939
-                          );
940
-            throw new EE_Error($error_msg);
941
-        }
942
-        // and that a default route exists
943
-        if (! array_key_exists('default', $this->_page_routes)) {
944
-            // user error msg
945
-            $error_msg = sprintf(
946
-                esc_html__(
947
-                    'A default page route has not been set for the % admin page.',
948
-                    'event_espresso'
949
-                ),
950
-                $this->_admin_page_title
951
-            );
952
-            // developer error msg
953
-            $error_msg .= '||' . $error_msg
954
-                          . esc_html__(
955
-                              ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
956
-                              'event_espresso'
957
-                          );
958
-            throw new EE_Error($error_msg);
959
-        }
960
-
961
-        // first lets' catch if the UI request has EVER been set.
962
-        if ($this->_is_UI_request === null) {
963
-            // lets set if this is a UI request or not.
964
-            $this->_is_UI_request = ! $this->request->getRequestParam('noheader', false, 'bool');
965
-            // wait a minute... we might have a noheader in the route array
966
-            $this->_is_UI_request = ! (
967
-                is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader']
968
-            )
969
-                ? $this->_is_UI_request
970
-                : false;
971
-        }
972
-        $this->_set_current_labels();
973
-        return true;
974
-    }
975
-
976
-
977
-    /**
978
-     * this method simply verifies a given route and makes sure its an actual route available for the loaded page
979
-     *
980
-     * @param string $route the route name we're verifying
981
-     * @return bool we'll throw an exception if this isn't a valid route.
982
-     * @throws EE_Error
983
-     */
984
-    protected function _verify_route($route)
985
-    {
986
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
987
-            return true;
988
-        }
989
-        // user error msg
990
-        $error_msg = sprintf(
991
-            esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
992
-            $this->_admin_page_title
993
-        );
994
-        // developer error msg
995
-        $error_msg .= '||' . $error_msg
996
-                      . sprintf(
997
-                          esc_html__(
998
-                              ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
999
-                              'event_espresso'
1000
-                          ),
1001
-                          $route
1002
-                      );
1003
-        throw new EE_Error($error_msg);
1004
-    }
1005
-
1006
-
1007
-    /**
1008
-     * perform nonce verification
1009
-     * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
1010
-     * using this method (and save retyping!)
1011
-     *
1012
-     * @param string $nonce     The nonce sent
1013
-     * @param string $nonce_ref The nonce reference string (name0)
1014
-     * @return void
1015
-     * @throws EE_Error
1016
-     * @throws InvalidArgumentException
1017
-     * @throws InvalidDataTypeException
1018
-     * @throws InvalidInterfaceException
1019
-     */
1020
-    protected function _verify_nonce($nonce, $nonce_ref)
1021
-    {
1022
-        // verify nonce against expected value
1023
-        if (! wp_verify_nonce($nonce, $nonce_ref)) {
1024
-            // these are not the droids you are looking for !!!
1025
-            $msg = sprintf(
1026
-                esc_html__('%sNonce Fail.%s', 'event_espresso'),
1027
-                '<a href="https://www.youtube.com/watch?v=56_S0WeTkzs">',
1028
-                '</a>'
1029
-            );
1030
-            if (WP_DEBUG) {
1031
-                $msg .= "\n  ";
1032
-                $msg .= sprintf(
1033
-                    esc_html__(
1034
-                        'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
1035
-                        'event_espresso'
1036
-                    ),
1037
-                    __CLASS__
1038
-                );
1039
-            }
1040
-            if (! $this->request->isAjax()) {
1041
-                wp_die($msg);
1042
-            }
1043
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1044
-            $this->_return_json();
1045
-        }
1046
-    }
1047
-
1048
-
1049
-    /**
1050
-     * _route_admin_request()
1051
-     * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if there are
1052
-     * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
1053
-     * in the page routes and then will try to load the corresponding method.
1054
-     *
1055
-     * @return void
1056
-     * @throws EE_Error
1057
-     * @throws InvalidArgumentException
1058
-     * @throws InvalidDataTypeException
1059
-     * @throws InvalidInterfaceException
1060
-     * @throws ReflectionException
1061
-     */
1062
-    protected function _route_admin_request()
1063
-    {
1064
-        if (! $this->_is_UI_request) {
1065
-            $this->_verify_routes();
1066
-        }
1067
-        $nonce_check = ! isset($this->_route_config['require_nonce']) || $this->_route_config['require_nonce'];
1068
-        if ($this->_req_action !== 'default' && $nonce_check) {
1069
-            // set nonce from post data
1070
-            $nonce = $this->request->getRequestParam($this->_req_nonce, '');
1071
-            $this->_verify_nonce($nonce, $this->_req_nonce);
1072
-        }
1073
-        // set the nav_tabs array but ONLY if this is  UI_request
1074
-        if ($this->_is_UI_request) {
1075
-            $this->_set_nav_tabs();
1076
-        }
1077
-        // grab callback function
1078
-        $func = is_array($this->_route) && isset($this->_route['func']) ? $this->_route['func'] : $this->_route;
1079
-        // check if callback has args
1080
-        $args      = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : [];
1081
-        $error_msg = '';
1082
-        // action right before calling route
1083
-        // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
1084
-        if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
1085
-            do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
1086
-        }
1087
-        // strip _wp_http_referer from the server REQUEST_URI
1088
-        // else it grows in length on every submission due to recursion,
1089
-        // ultimately causing a "Request-URI Too Large" error
1090
-        $request_uri = remove_query_arg(
1091
-                '_wp_http_referer',
1092
-                wp_unslash($this->request->getServerParam('REQUEST_URI'))
1093
-        );
1094
-        // set new value in both our Request object and the super global
1095
-        $this->request->setServerParam('REQUEST_URI', $request_uri, true);
1096
-        if (! empty($func)) {
1097
-            if (is_array($func)) {
1098
-                [$class, $method] = $func;
1099
-            } elseif (strpos($func, '::') !== false) {
1100
-                [$class, $method] = explode('::', $func);
1101
-            } else {
1102
-                $class  = $this;
1103
-                $method = $func;
1104
-            }
1105
-            if (! (is_object($class) && $class === $this)) {
1106
-                // send along this admin page object for access by addons.
1107
-                $args['admin_page_object'] = $this;
1108
-            }
1109
-            if (
1110
-                // is it a method on a class that doesn't work?
1111
-                (
1112
-                    (
1113
-                        method_exists($class, $method)
1114
-                        && call_user_func_array([$class, $method], $args) === false
1115
-                    )
1116
-                    && (
1117
-                        // is it a standalone function that doesn't work?
1118
-                        function_exists($method)
1119
-                        && call_user_func_array(
1120
-                            $func,
1121
-                            array_merge(['admin_page_object' => $this], $args)
1122
-                        ) === false
1123
-                    )
1124
-                )
1125
-                || (
1126
-                    // is it neither a class method NOR a standalone function?
1127
-                    ! method_exists($class, $method)
1128
-                    && ! function_exists($method)
1129
-                )
1130
-            ) {
1131
-                // user error msg
1132
-                $error_msg = esc_html__(
1133
-                    'An error occurred. The  requested page route could not be found.',
1134
-                    'event_espresso'
1135
-                );
1136
-                // developer error msg
1137
-                $error_msg .= '||';
1138
-                $error_msg .= sprintf(
1139
-                    esc_html__(
1140
-                        'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1141
-                        'event_espresso'
1142
-                    ),
1143
-                    $method
1144
-                );
1145
-            }
1146
-            if (! empty($error_msg)) {
1147
-                throw new EE_Error($error_msg);
1148
-            }
1149
-        }
1150
-        // if we've routed and this route has a no headers route AND a sent_headers_route,
1151
-        // then we need to reset the routing properties to the new route.
1152
-        // now if UI request is FALSE and noheader is true AND we have a headers_sent_route in the route array then let's set UI_request to true because the no header route has a second func after headers have been sent.
1153
-        if (
1154
-            $this->_is_UI_request === false
1155
-            && is_array($this->_route)
1156
-            && ! empty($this->_route['headers_sent_route'])
1157
-        ) {
1158
-            $this->_reset_routing_properties($this->_route['headers_sent_route']);
1159
-        }
1160
-    }
1161
-
1162
-
1163
-    /**
1164
-     * This method just allows the resetting of page properties in the case where a no headers
1165
-     * route redirects to a headers route in its route config.
1166
-     *
1167
-     * @param string $new_route New (non header) route to redirect to.
1168
-     * @return   void
1169
-     * @throws ReflectionException
1170
-     * @throws InvalidArgumentException
1171
-     * @throws InvalidInterfaceException
1172
-     * @throws InvalidDataTypeException
1173
-     * @throws EE_Error
1174
-     * @since   4.3.0
1175
-     */
1176
-    protected function _reset_routing_properties($new_route)
1177
-    {
1178
-        $this->_is_UI_request = true;
1179
-        // now we set the current route to whatever the headers_sent_route is set at
1180
-        $this->request->setRequestParam('action', $new_route);
1181
-        // rerun page setup
1182
-        $this->_page_setup();
1183
-    }
1184
-
1185
-
1186
-    /**
1187
-     * _add_query_arg
1188
-     * adds nonce to array of arguments then calls WP add_query_arg function
1189
-     *(internally just uses EEH_URL's function with the same name)
1190
-     *
1191
-     * @param array  $args
1192
-     * @param string $url
1193
-     * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1194
-     *                                        generated url in an associative array indexed by the key 'wp_referer';
1195
-     *                                        Example usage: If the current page is:
1196
-     *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1197
-     *                                        &action=default&event_id=20&month_range=March%202015
1198
-     *                                        &_wpnonce=5467821
1199
-     *                                        and you call:
1200
-     *                                        EE_Admin_Page::add_query_args_and_nonce(
1201
-     *                                        array(
1202
-     *                                        'action' => 'resend_something',
1203
-     *                                        'page=>espresso_registrations'
1204
-     *                                        ),
1205
-     *                                        $some_url,
1206
-     *                                        true
1207
-     *                                        );
1208
-     *                                        It will produce a url in this structure:
1209
-     *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1210
-     *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1211
-     *                                        month_range]=March%202015
1212
-     * @param bool   $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1213
-     * @return string
1214
-     */
1215
-    public static function add_query_args_and_nonce(
1216
-        $args = [],
1217
-        $url = '',
1218
-        $sticky = false,
1219
-        $exclude_nonce = false
1220
-    ) {
1221
-        // if there is a _wp_http_referer include the values from the request but only if sticky = true
1222
-        if ($sticky) {
1223
-            /** @var RequestInterface $request */
1224
-            $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
1225
-            $request->unSetRequestParams(['_wp_http_referer', 'wp_referer'], true);
1226
-            $request->unSetServerParam('_wp_http_referer', true);
1227
-            foreach ($request->requestParams() as $key => $value) {
1228
-                // do not add nonces
1229
-                if (strpos($key, 'nonce') !== false) {
1230
-                    continue;
1231
-                }
1232
-                $args[ 'wp_referer[' . $key . ']' ] = is_string($value) ? htmlspecialchars($value) : $value;
1233
-            }
1234
-        }
1235
-        return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1236
-    }
1237
-
1238
-
1239
-    /**
1240
-     * This returns a generated link that will load the related help tab.
1241
-     *
1242
-     * @param string $help_tab_id the id for the connected help tab
1243
-     * @param string $icon_style  (optional) include css class for the style you want to use for the help icon.
1244
-     * @param string $help_text   (optional) send help text you want to use for the link if default not to be used
1245
-     * @return string              generated link
1246
-     * @uses EEH_Template::get_help_tab_link()
1247
-     */
1248
-    protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1249
-    {
1250
-        return EEH_Template::get_help_tab_link(
1251
-            $help_tab_id,
1252
-            $this->page_slug,
1253
-            $this->_req_action,
1254
-            $icon_style,
1255
-            $help_text
1256
-        );
1257
-    }
1258
-
1259
-
1260
-    /**
1261
-     * _add_help_tabs
1262
-     * Note child classes define their help tabs within the page_config array.
1263
-     *
1264
-     * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1265
-     * @return void
1266
-     * @throws DomainException
1267
-     * @throws EE_Error
1268
-     * @throws ReflectionException
1269
-     */
1270
-    protected function _add_help_tabs()
1271
-    {
1272
-        if (isset($this->_page_config[ $this->_req_action ])) {
1273
-            $config = $this->_page_config[ $this->_req_action ];
1274
-            // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1275
-            if (is_array($config) && isset($config['help_sidebar'])) {
1276
-                // check that the callback given is valid
1277
-                if (! method_exists($this, $config['help_sidebar'])) {
1278
-                    throw new EE_Error(
1279
-                        sprintf(
1280
-                            esc_html__(
1281
-                                'The _page_config array has a callback set for the "help_sidebar" option.  However the callback given (%s) is not a valid callback.  Doublecheck the spelling and make sure this method exists for the class %s',
1282
-                                'event_espresso'
1283
-                            ),
1284
-                            $config['help_sidebar'],
1285
-                            get_class($this)
1286
-                        )
1287
-                    );
1288
-                }
1289
-                $content = apply_filters(
1290
-                    'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1291
-                    $this->{$config['help_sidebar']}()
1292
-                );
1293
-                $this->_current_screen->set_help_sidebar($content);
1294
-            }
1295
-            if (! isset($config['help_tabs'])) {
1296
-                return;
1297
-            } //no help tabs for this route
1298
-            foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1299
-                // we're here so there ARE help tabs!
1300
-                // make sure we've got what we need
1301
-                if (! isset($cfg['title'])) {
1302
-                    throw new EE_Error(
1303
-                        esc_html__(
1304
-                            'The _page_config array is not set up properly for help tabs.  It is missing a title',
1305
-                            'event_espresso'
1306
-                        )
1307
-                    );
1308
-                }
1309
-                if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1310
-                    throw new EE_Error(
1311
-                        esc_html__(
1312
-                            'The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab',
1313
-                            'event_espresso'
1314
-                        )
1315
-                    );
1316
-                }
1317
-                // first priority goes to content.
1318
-                if (! empty($cfg['content'])) {
1319
-                    $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1320
-                    // second priority goes to filename
1321
-                } elseif (! empty($cfg['filename'])) {
1322
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1323
-                    // it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too)
1324
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1325
-                                                             . basename($this->_get_dir())
1326
-                                                             . '/help_tabs/'
1327
-                                                             . $cfg['filename']
1328
-                                                             . '.help_tab.php' : $file_path;
1329
-                    // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1330
-                    if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1331
-                        EE_Error::add_error(
1332
-                            sprintf(
1333
-                                esc_html__(
1334
-                                    'The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content.  Please check that the string you set for the help tab on this route (%s) is the correct spelling.  The file should be in %s',
1335
-                                    'event_espresso'
1336
-                                ),
1337
-                                $tab_id,
1338
-                                key($config),
1339
-                                $file_path
1340
-                            ),
1341
-                            __FILE__,
1342
-                            __FUNCTION__,
1343
-                            __LINE__
1344
-                        );
1345
-                        return;
1346
-                    }
1347
-                    $template_args['admin_page_obj'] = $this;
1348
-                    $content                         = EEH_Template::display_template(
1349
-                        $file_path,
1350
-                        $template_args,
1351
-                        true
1352
-                    );
1353
-                } else {
1354
-                    $content = '';
1355
-                }
1356
-                // check if callback is valid
1357
-                if (
1358
-                    empty($content)
1359
-                    && (
1360
-                        ! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1361
-                    )
1362
-                ) {
1363
-                    EE_Error::add_error(
1364
-                        sprintf(
1365
-                            esc_html__(
1366
-                                'The callback given for a %s help tab on this page does not content OR a corresponding method for generating the content.  Check the spelling or make sure the method is present.',
1367
-                                'event_espresso'
1368
-                            ),
1369
-                            $cfg['title']
1370
-                        ),
1371
-                        __FILE__,
1372
-                        __FUNCTION__,
1373
-                        __LINE__
1374
-                    );
1375
-                    return;
1376
-                }
1377
-                // setup config array for help tab method
1378
-                $id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1379
-                $_ht = [
1380
-                    'id'       => $id,
1381
-                    'title'    => $cfg['title'],
1382
-                    'callback' => isset($cfg['callback']) && empty($content) ? [$this, $cfg['callback']] : null,
1383
-                    'content'  => $content,
1384
-                ];
1385
-                $this->_current_screen->add_help_tab($_ht);
1386
-            }
1387
-        }
1388
-    }
1389
-
1390
-
1391
-    /**
1392
-     * This simply sets up any qtips that have been defined in the page config
1393
-     *
1394
-     * @return void
1395
-     * @throws ReflectionException
1396
-     * @throws EE_Error
1397
-     */
1398
-    protected function _add_qtips()
1399
-    {
1400
-        if (isset($this->_route_config['qtips'])) {
1401
-            $qtips = (array) $this->_route_config['qtips'];
1402
-            // load qtip loader
1403
-            $path = [
1404
-                $this->_get_dir() . '/qtips/',
1405
-                EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1406
-            ];
1407
-            EEH_Qtip_Loader::instance()->register($qtips, $path);
1408
-        }
1409
-    }
1410
-
1411
-
1412
-    /**
1413
-     * _set_nav_tabs
1414
-     * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1415
-     * wish to add additional tabs or modify accordingly.
1416
-     *
1417
-     * @return void
1418
-     * @throws InvalidArgumentException
1419
-     * @throws InvalidInterfaceException
1420
-     * @throws InvalidDataTypeException
1421
-     */
1422
-    protected function _set_nav_tabs()
1423
-    {
1424
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1425
-        $i = 0;
1426
-        foreach ($this->_page_config as $slug => $config) {
1427
-            if (! is_array($config) || empty($config['nav'])) {
1428
-                continue;
1429
-            }
1430
-            // no nav tab for this config
1431
-            // check for persistent flag
1432
-            if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1433
-                // nav tab is only to appear when route requested.
1434
-                continue;
1435
-            }
1436
-            if (! $this->check_user_access($slug, true)) {
1437
-                // no nav tab because current user does not have access.
1438
-                continue;
1439
-            }
1440
-            $css_class                = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1441
-            $this->_nav_tabs[ $slug ] = [
1442
-                'url'       => isset($config['nav']['url'])
1443
-                    ? $config['nav']['url']
1444
-                    : EE_Admin_Page::add_query_args_and_nonce(
1445
-                        ['action' => $slug],
1446
-                        $this->_admin_base_url
1447
-                    ),
1448
-                'link_text' => isset($config['nav']['label'])
1449
-                    ? $config['nav']['label']
1450
-                    : ucwords(
1451
-                        str_replace('_', ' ', $slug)
1452
-                    ),
1453
-                'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1454
-                'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1455
-            ];
1456
-            $i++;
1457
-        }
1458
-        // if $this->_nav_tabs is empty then lets set the default
1459
-        if (empty($this->_nav_tabs)) {
1460
-            $this->_nav_tabs[ $this->_default_nav_tab_name ] = [
1461
-                'url'       => $this->_admin_base_url,
1462
-                'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1463
-                'css_class' => 'nav-tab-active',
1464
-                'order'     => 10,
1465
-            ];
1466
-        }
1467
-        // now let's sort the tabs according to order
1468
-        usort($this->_nav_tabs, [$this, '_sort_nav_tabs']);
1469
-    }
1470
-
1471
-
1472
-    /**
1473
-     * _set_current_labels
1474
-     * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1475
-     * property array
1476
-     *
1477
-     * @return void
1478
-     */
1479
-    private function _set_current_labels()
1480
-    {
1481
-        if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1482
-            foreach ($this->_route_config['labels'] as $label => $text) {
1483
-                if (is_array($text)) {
1484
-                    foreach ($text as $sublabel => $subtext) {
1485
-                        $this->_labels[ $label ][ $sublabel ] = $subtext;
1486
-                    }
1487
-                } else {
1488
-                    $this->_labels[ $label ] = $text;
1489
-                }
1490
-            }
1491
-        }
1492
-    }
1493
-
1494
-
1495
-    /**
1496
-     *        verifies user access for this admin page
1497
-     *
1498
-     * @param string $route_to_check if present then the capability for the route matching this string is checked.
1499
-     * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1500
-     *                               return false if verify fail.
1501
-     * @return bool
1502
-     * @throws InvalidArgumentException
1503
-     * @throws InvalidDataTypeException
1504
-     * @throws InvalidInterfaceException
1505
-     */
1506
-    public function check_user_access($route_to_check = '', $verify_only = false)
1507
-    {
1508
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1509
-        $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1510
-        $capability     = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1511
-                          && is_array(
1512
-                              $this->_page_routes[ $route_to_check ]
1513
-                          )
1514
-                          && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1515
-            ? $this->_page_routes[ $route_to_check ]['capability'] : null;
1516
-        if (empty($capability) && empty($route_to_check)) {
1517
-            $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1518
-                : $this->_route['capability'];
1519
-        } else {
1520
-            $capability = empty($capability) ? 'manage_options' : $capability;
1521
-        }
1522
-        $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1523
-        if (
1524
-            ! $this->request->isAjax()
1525
-            && (
1526
-                ! function_exists('is_admin')
1527
-                || ! EE_Registry::instance()->CAP->current_user_can(
1528
-                    $capability,
1529
-                    $this->page_slug
1530
-                    . '_'
1531
-                    . $route_to_check,
1532
-                    $id
1533
-                )
1534
-            )
1535
-        ) {
1536
-            if ($verify_only) {
1537
-                return false;
1538
-            }
1539
-            if (is_user_logged_in()) {
1540
-                wp_die(esc_html__('You do not have access to this route.', 'event_espresso'));
1541
-            } else {
1542
-                return false;
1543
-            }
1544
-        }
1545
-        return true;
1546
-    }
1547
-
1548
-
1549
-    protected function addMetaBox(
1550
-        $box_id,
1551
-        $title,
1552
-        $callback,
1553
-        $screen,
1554
-        $context = 'normal',
1555
-        $priority = 'default',
1556
-        $callback_args = null
1557
-    ) {
1558
-        add_meta_box($box_id, $title, $callback, $screen, $context, $priority, $callback_args);
1559
-        add_filter(
1560
-            "postbox_classes_{$this->_wp_page_slug}_{$box_id}",
1561
-            function ($classes) {
1562
-                array_push($classes, 'ee-admin-container');
1563
-                return $classes;
1564
-            }
1565
-        );
1566
-    }
1567
-
1568
-
1569
-    /**
1570
-     * admin_init_global
1571
-     * This runs all the code that we want executed within the WP admin_init hook.
1572
-     * This method executes for ALL EE Admin pages.
1573
-     *
1574
-     * @return void
1575
-     */
1576
-    public function admin_init_global()
1577
-    {
1578
-    }
1579
-
1580
-
1581
-    /**
1582
-     * wp_loaded_global
1583
-     * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1584
-     * EE_Admin page and will execute on every EE Admin Page load
1585
-     *
1586
-     * @return void
1587
-     */
1588
-    public function wp_loaded()
1589
-    {
1590
-    }
1591
-
1592
-
1593
-    /**
1594
-     * admin_notices
1595
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1596
-     * ALL EE_Admin pages.
1597
-     *
1598
-     * @return void
1599
-     */
1600
-    public function admin_notices_global()
1601
-    {
1602
-        $this->_display_no_javascript_warning();
1603
-        $this->_display_espresso_notices();
1604
-    }
1605
-
1606
-
1607
-    public function network_admin_notices_global()
1608
-    {
1609
-        $this->_display_no_javascript_warning();
1610
-        $this->_display_espresso_notices();
1611
-    }
1612
-
1613
-
1614
-    /**
1615
-     * admin_footer_scripts_global
1616
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1617
-     * will apply on ALL EE_Admin pages.
1618
-     *
1619
-     * @return void
1620
-     */
1621
-    public function admin_footer_scripts_global()
1622
-    {
1623
-        $this->_add_admin_page_ajax_loading_img();
1624
-        $this->_add_admin_page_overlay();
1625
-        // if metaboxes are present we need to add the nonce field
1626
-        if (
1627
-            isset($this->_route_config['metaboxes'])
1628
-            || isset($this->_route_config['list_table'])
1629
-            || (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1630
-        ) {
1631
-            wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1632
-            wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1633
-        }
1634
-    }
1635
-
1636
-
1637
-    /**
1638
-     * admin_footer_global
1639
-     * Anything triggered by the wp 'admin_footer' wp hook should be put in here.
1640
-     * This particular method will apply on ALL EE_Admin Pages.
1641
-     *
1642
-     * @return void
1643
-     */
1644
-    public function admin_footer_global()
1645
-    {
1646
-        // dialog container for dialog helper
1647
-        echo '
133
+	/**
134
+	 * unprocessed value for the 'action' request param (default '')
135
+	 *
136
+	 * @var string
137
+	 */
138
+	protected $raw_req_action = '';
139
+
140
+	/**
141
+	 * unprocessed value for the 'page' request param (default '')
142
+	 *
143
+	 * @var string
144
+	 */
145
+	protected $raw_req_page = '';
146
+
147
+	/**
148
+	 * sanitized request action (and nonce)
149
+	 *
150
+	 * @var string
151
+	 */
152
+	protected $_req_action = '';
153
+
154
+	/**
155
+	 * sanitized request action nonce
156
+	 *
157
+	 * @var string
158
+	 */
159
+	protected $_req_nonce = '';
160
+
161
+	/**
162
+	 * @var string
163
+	 */
164
+	protected $_search_btn_label = '';
165
+
166
+	/**
167
+	 * @var string
168
+	 */
169
+	protected $_search_box_callback = '';
170
+
171
+	/**
172
+	 * @var WP_Screen
173
+	 */
174
+	protected $_current_screen;
175
+
176
+	// for holding EE_Admin_Hooks object when needed (set via set_hook_object())
177
+	protected $_hook_obj;
178
+
179
+	// for holding incoming request data
180
+	protected $_req_data = [];
181
+
182
+	// yes / no array for admin form fields
183
+	protected $_yes_no_values = [];
184
+
185
+	// some default things shared by all child classes
186
+	protected $_default_espresso_metaboxes;
187
+
188
+	/**
189
+	 * @var EE_Registry
190
+	 */
191
+	protected $EE;
192
+
193
+
194
+	/**
195
+	 * This is just a property that flags whether the given route is a caffeinated route or not.
196
+	 *
197
+	 * @var boolean
198
+	 */
199
+	protected $_is_caf = false;
200
+
201
+	/**
202
+	 * whether or not initializePage() has run
203
+	 *
204
+	 * @var boolean
205
+	 */
206
+	protected $initialized = false;
207
+
208
+	/**
209
+	 * @var FeatureFlags
210
+	 */
211
+	protected $feature;
212
+
213
+
214
+	/**
215
+	 * @Constructor
216
+	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
217
+	 * @throws InvalidArgumentException
218
+	 * @throws InvalidDataTypeException
219
+	 * @throws InvalidInterfaceException
220
+	 * @throws ReflectionException
221
+	 */
222
+	public function __construct($routing = true)
223
+	{
224
+		$this->loader = LoaderFactory::getLoader();
225
+		$this->admin_config = $this->loader->getShared('EE_Admin_Config');
226
+		$this->feature = $this->loader->getShared(FeatureFlags::class);
227
+		$this->request = $this->loader->getShared(RequestInterface::class);
228
+		// routing enabled?
229
+		$this->_routing = $routing;
230
+
231
+		if (strpos($this->_get_dir(), 'caffeinated') !== false) {
232
+			$this->_is_caf = true;
233
+		}
234
+		$this->_yes_no_values = [
235
+			['id' => true, 'text' => esc_html__('Yes', 'event_espresso')],
236
+			['id' => false, 'text' => esc_html__('No', 'event_espresso')],
237
+		];
238
+		// set the _req_data property.
239
+		$this->_req_data = $this->request->requestParams();
240
+	}
241
+
242
+
243
+	/**
244
+	 * @return EE_Admin_Config
245
+	 */
246
+	public function adminConfig(): EE_Admin_Config
247
+	{
248
+		return $this->admin_config;
249
+	}
250
+
251
+
252
+	/**
253
+	 * @return FeatureFlags
254
+	 */
255
+	public function feature(): FeatureFlags
256
+	{
257
+		return $this->feature;
258
+	}
259
+
260
+
261
+	/**
262
+	 * This logic used to be in the constructor, but that caused a chicken <--> egg scenario
263
+	 * for child classes that needed to set properties prior to these methods getting called,
264
+	 * but also needed the parent class to have its construction completed as well.
265
+	 * Bottom line is that constructors should ONLY be used for setting initial properties
266
+	 * and any complex initialization logic should only run after instantiation is complete.
267
+	 *
268
+	 * This method gets called immediately after construction from within
269
+	 *      EE_Admin_Page_Init::_initialize_admin_page()
270
+	 *
271
+	 * @throws EE_Error
272
+	 * @throws InvalidArgumentException
273
+	 * @throws InvalidDataTypeException
274
+	 * @throws InvalidInterfaceException
275
+	 * @throws ReflectionException
276
+	 * @since $VID:$
277
+	 */
278
+	public function initializePage()
279
+	{
280
+		if ($this->initialized) {
281
+			return;
282
+		}
283
+		// set initial page props (child method)
284
+		$this->_init_page_props();
285
+		// set global defaults
286
+		$this->_set_defaults();
287
+		// set early because incoming requests could be ajax related and we need to register those hooks.
288
+		$this->_global_ajax_hooks();
289
+		$this->_ajax_hooks();
290
+		// other_page_hooks have to be early too.
291
+		$this->_do_other_page_hooks();
292
+		// set up page dependencies
293
+		$this->_before_page_setup();
294
+		$this->_page_setup();
295
+		$this->initialized = true;
296
+	}
297
+
298
+
299
+	/**
300
+	 * _init_page_props
301
+	 * Child classes use to set at least the following properties:
302
+	 * $page_slug.
303
+	 * $page_label.
304
+	 *
305
+	 * @abstract
306
+	 * @return void
307
+	 */
308
+	abstract protected function _init_page_props();
309
+
310
+
311
+	/**
312
+	 * _ajax_hooks
313
+	 * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
314
+	 * Note: within the ajax callback methods.
315
+	 *
316
+	 * @abstract
317
+	 * @return void
318
+	 */
319
+	abstract protected function _ajax_hooks();
320
+
321
+
322
+	/**
323
+	 * _define_page_props
324
+	 * child classes define page properties in here.  Must include at least:
325
+	 * $_admin_base_url = base_url for all admin pages
326
+	 * $_admin_page_title = default admin_page_title for admin pages
327
+	 * $_labels = array of default labels for various automatically generated elements:
328
+	 *    array(
329
+	 *        'buttons' => array(
330
+	 *            'add' => esc_html__('label for add new button'),
331
+	 *            'edit' => esc_html__('label for edit button'),
332
+	 *            'delete' => esc_html__('label for delete button')
333
+	 *            )
334
+	 *        )
335
+	 *
336
+	 * @abstract
337
+	 * @return void
338
+	 */
339
+	abstract protected function _define_page_props();
340
+
341
+
342
+	/**
343
+	 * _set_page_routes
344
+	 * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
345
+	 * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
346
+	 * have a 'default' route. Here's the format
347
+	 * $this->_page_routes = array(
348
+	 *        'default' => array(
349
+	 *            'func' => '_default_method_handling_route',
350
+	 *            'args' => array('array','of','args'),
351
+	 *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
352
+	 *            ajax request, backend processing)
353
+	 *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
354
+	 *            headers route after.  The string you enter here should match the defined route reference for a
355
+	 *            headers sent route.
356
+	 *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
357
+	 *            this route.
358
+	 *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
359
+	 *            checks).
360
+	 *        ),
361
+	 *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
362
+	 *        handling method.
363
+	 *        )
364
+	 * )
365
+	 *
366
+	 * @abstract
367
+	 * @return void
368
+	 */
369
+	abstract protected function _set_page_routes();
370
+
371
+
372
+	/**
373
+	 * _set_page_config
374
+	 * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
375
+	 * array corresponds to the page_route for the loaded page. Format:
376
+	 * $this->_page_config = array(
377
+	 *        'default' => array(
378
+	 *            'labels' => array(
379
+	 *                'buttons' => array(
380
+	 *                    'add' => esc_html__('label for adding item'),
381
+	 *                    'edit' => esc_html__('label for editing item'),
382
+	 *                    'delete' => esc_html__('label for deleting item')
383
+	 *                ),
384
+	 *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
385
+	 *            ), //optional an array of custom labels for various automatically generated elements to use on the
386
+	 *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
387
+	 *            _define_page_props() method
388
+	 *            'nav' => array(
389
+	 *                'label' => esc_html__('Label for Tab', 'event_espresso').
390
+	 *                'url' => 'http://someurl', //automatically generated UNLESS you define
391
+	 *                'css_class' => 'css-class', //automatically generated UNLESS you define
392
+	 *                'order' => 10, //required to indicate tab position.
393
+	 *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
394
+	 *                displayed then add this parameter.
395
+	 *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
396
+	 *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
397
+	 *            metaboxes set for eventespresso admin pages.
398
+	 *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
399
+	 *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
400
+	 *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
401
+	 *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
402
+	 *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
403
+	 *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
404
+	 *            array indicates the max number of columns (4) and the default number of columns on page load (2).
405
+	 *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
406
+	 *            want to display.
407
+	 *            'help_tabs' => array( //this is used for adding help tabs to a page
408
+	 *                'tab_id' => array(
409
+	 *                    'title' => 'tab_title',
410
+	 *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
411
+	 *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
412
+	 *                    should match a file in the admin folder's "help_tabs" dir (ie..
413
+	 *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
414
+	 *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
415
+	 *                    attempt to use the callback which should match the name of a method in the class
416
+	 *                    ),
417
+	 *                'tab2_id' => array(
418
+	 *                    'title' => 'tab2 title',
419
+	 *                    'filename' => 'file_name_2'
420
+	 *                    'callback' => 'callback_method_for_content',
421
+	 *                 ),
422
+	 *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
423
+	 *            help tab area on an admin page. @return void
424
+	 *
425
+	 * @abstract
426
+	 */
427
+	abstract protected function _set_page_config();
428
+
429
+
430
+	/**
431
+	 * _add_screen_options
432
+	 * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
433
+	 * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
434
+	 * to a particular view.
435
+	 *
436
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
437
+	 *         see also WP_Screen object documents...
438
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
439
+	 * @abstract
440
+	 * @return void
441
+	 */
442
+	abstract protected function _add_screen_options();
443
+
444
+
445
+	/**
446
+	 * _add_feature_pointers
447
+	 * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
448
+	 * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
449
+	 * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
450
+	 * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
451
+	 * extended) also see:
452
+	 *
453
+	 * @link   http://eamann.com/tech/wordpress-portland/
454
+	 * @abstract
455
+	 * @return void
456
+	 */
457
+	abstract protected function _add_feature_pointers();
458
+
459
+
460
+	/**
461
+	 * load_scripts_styles
462
+	 * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
463
+	 * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
464
+	 * scripts/styles per view by putting them in a dynamic function in this format
465
+	 * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
466
+	 *
467
+	 * @abstract
468
+	 * @return void
469
+	 */
470
+	abstract public function load_scripts_styles();
471
+
472
+
473
+	/**
474
+	 * admin_init
475
+	 * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
476
+	 * all pages/views loaded by child class.
477
+	 *
478
+	 * @abstract
479
+	 * @return void
480
+	 */
481
+	abstract public function admin_init();
482
+
483
+
484
+	/**
485
+	 * admin_notices
486
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
487
+	 * all pages/views loaded by child class.
488
+	 *
489
+	 * @abstract
490
+	 * @return void
491
+	 */
492
+	abstract public function admin_notices();
493
+
494
+
495
+	/**
496
+	 * admin_footer_scripts
497
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
498
+	 * will apply to all pages/views loaded by child class.
499
+	 *
500
+	 * @return void
501
+	 */
502
+	abstract public function admin_footer_scripts();
503
+
504
+
505
+	/**
506
+	 * admin_footer
507
+	 * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
508
+	 * apply to all pages/views loaded by child class.
509
+	 *
510
+	 * @return void
511
+	 */
512
+	public function admin_footer()
513
+	{
514
+	}
515
+
516
+
517
+	/**
518
+	 * _global_ajax_hooks
519
+	 * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
520
+	 * Note: within the ajax callback methods.
521
+	 *
522
+	 * @abstract
523
+	 * @return void
524
+	 */
525
+	protected function _global_ajax_hooks()
526
+	{
527
+		// for lazy loading of metabox content
528
+		add_action('wp_ajax_espresso-ajax-content', [$this, 'ajax_metabox_content'], 10);
529
+
530
+		add_action(
531
+			'wp_ajax_espresso_hide_status_change_notice',
532
+			[$this, 'hideStatusChangeNotice']
533
+		);
534
+		add_action(
535
+			'wp_ajax_nopriv_espresso_hide_status_change_notice',
536
+			[$this, 'hideStatusChangeNotice']
537
+		);
538
+	}
539
+
540
+
541
+	public function ajax_metabox_content()
542
+	{
543
+		$content_id  = $this->request->getRequestParam('contentid', '');
544
+		$content_url = $this->request->getRequestParam('contenturl', '', 'url');
545
+		EE_Admin_Page::cached_rss_display($content_id, $content_url);
546
+		wp_die();
547
+	}
548
+
549
+
550
+	public function hideStatusChangeNotice()
551
+	{
552
+		$response = [];
553
+		try {
554
+			/** @var EventEspresso\core\admin\StatusChangeNotice $status_change_notice */
555
+			$status_change_notice = $this->loader->getShared('EventEspresso\core\admin\StatusChangeNotice');
556
+			$response['success'] = $status_change_notice->dismiss() > -1;
557
+		} catch (Exception $exception) {
558
+			$response['errors'] = $exception->getMessage();
559
+		}
560
+		echo wp_json_encode($response);
561
+		exit();
562
+	}
563
+
564
+
565
+	/**
566
+	 * allows extending classes do something specific before the parent constructor runs _page_setup().
567
+	 *
568
+	 * @return void
569
+	 */
570
+	protected function _before_page_setup()
571
+	{
572
+		// default is to do nothing
573
+	}
574
+
575
+
576
+	/**
577
+	 * Makes sure any things that need to be loaded early get handled.
578
+	 * We also escape early here if the page requested doesn't match the object.
579
+	 *
580
+	 * @final
581
+	 * @return void
582
+	 * @throws EE_Error
583
+	 * @throws InvalidArgumentException
584
+	 * @throws ReflectionException
585
+	 * @throws InvalidDataTypeException
586
+	 * @throws InvalidInterfaceException
587
+	 */
588
+	final protected function _page_setup()
589
+	{
590
+		// requires?
591
+		// admin_init stuff - global - we're setting this REALLY early
592
+		// so if EE_Admin pages have to hook into other WP pages they can.
593
+		// But keep in mind, not everything is available from the EE_Admin Page object at this point.
594
+		add_action('admin_init', [$this, 'admin_init_global'], 5);
595
+		// next verify if we need to load anything...
596
+		$this->_current_page = $this->request->getRequestParam('page', '', 'key');
597
+		$this->page_folder   = strtolower(
598
+			str_replace(['_Admin_Page', 'Extend_'], '', get_class($this))
599
+		);
600
+		global $ee_menu_slugs;
601
+		$ee_menu_slugs = (array) $ee_menu_slugs;
602
+		if (
603
+			! $this->request->isAjax()
604
+			&& (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))
605
+		) {
606
+			return;
607
+		}
608
+		// because WP List tables have two duplicate select inputs for choosing bulk actions,
609
+		// we need to copy the action from the second to the first
610
+		$action     = $this->request->getRequestParam('action', '-1', 'key');
611
+		$action2    = $this->request->getRequestParam('action2', '-1', 'key');
612
+		$action     = $action !== '-1' ? $action : $action2;
613
+		$req_action = $action !== '-1' ? $action : 'default';
614
+
615
+		// if a specific 'route' has been set, and the action is 'default' OR we are doing_ajax
616
+		// then let's use the route as the action.
617
+		// This covers cases where we're coming in from a list table that isn't on the default route.
618
+		$route = $this->request->getRequestParam('route');
619
+		$this->_req_action = $route && ($req_action === 'default' || $this->request->isAjax())
620
+			? $route
621
+			: $req_action;
622
+
623
+		$this->_current_view = $this->_req_action;
624
+		$this->_req_nonce    = $this->_req_action . '_nonce';
625
+		$this->_define_page_props();
626
+		$this->_current_page_view_url = add_query_arg(
627
+			['page' => $this->_current_page, 'action' => $this->_current_view],
628
+			$this->_admin_base_url
629
+		);
630
+		// default things
631
+		$this->_default_espresso_metaboxes = [
632
+			'_espresso_news_post_box',
633
+			'_espresso_links_post_box',
634
+			'_espresso_ratings_request',
635
+			'_espresso_sponsors_post_box',
636
+		];
637
+		// set page configs
638
+		$this->_set_page_routes();
639
+		$this->_set_page_config();
640
+		// let's include any referrer data in our default_query_args for this route for "stickiness".
641
+		if ($this->request->requestParamIsSet('wp_referer')) {
642
+			$wp_referer = $this->request->getRequestParam('wp_referer');
643
+			if ($wp_referer) {
644
+				$this->_default_route_query_args['wp_referer'] = $wp_referer;
645
+			}
646
+		}
647
+		// for caffeinated and other extended functionality.
648
+		//  If there is a _extend_page_config method
649
+		// then let's run that to modify the all the various page configuration arrays
650
+		if (method_exists($this, '_extend_page_config')) {
651
+			$this->_extend_page_config();
652
+		}
653
+		// for CPT and other extended functionality.
654
+		// If there is an _extend_page_config_for_cpt
655
+		// then let's run that to modify all the various page configuration arrays.
656
+		if (method_exists($this, '_extend_page_config_for_cpt')) {
657
+			$this->_extend_page_config_for_cpt();
658
+		}
659
+		// filter routes and page_config so addons can add their stuff. Filtering done per class
660
+		$this->_page_routes = apply_filters(
661
+			'FHEE__' . get_class($this) . '__page_setup__page_routes',
662
+			$this->_page_routes,
663
+			$this
664
+		);
665
+		$this->_page_config = apply_filters(
666
+			'FHEE__' . get_class($this) . '__page_setup__page_config',
667
+			$this->_page_config,
668
+			$this
669
+		);
670
+		// if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
671
+		// then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
672
+		if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
673
+			add_action(
674
+				'AHEE__EE_Admin_Page__route_admin_request',
675
+				[$this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view],
676
+				10,
677
+				2
678
+			);
679
+		}
680
+		// next route only if routing enabled
681
+		if ($this->_routing && ! $this->request->isAjax()) {
682
+			$this->_verify_routes();
683
+			// next let's just check user_access and kill if no access
684
+			$this->check_user_access();
685
+			if ($this->_is_UI_request) {
686
+				// admin_init stuff - global, all views for this page class, specific view
687
+				add_action('admin_init', [$this, 'admin_init'], 10);
688
+				if (method_exists($this, 'admin_init_' . $this->_current_view)) {
689
+					add_action('admin_init', [$this, 'admin_init_' . $this->_current_view], 15);
690
+				}
691
+			} else {
692
+				// hijack regular WP loading and route admin request immediately
693
+				@ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
694
+				$this->route_admin_request();
695
+			}
696
+		}
697
+	}
698
+
699
+
700
+	/**
701
+	 * Provides a way for related child admin pages to load stuff on the loaded admin page.
702
+	 *
703
+	 * @return void
704
+	 * @throws EE_Error
705
+	 */
706
+	private function _do_other_page_hooks()
707
+	{
708
+		$registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, []);
709
+		foreach ($registered_pages as $page) {
710
+			// now let's setup the file name and class that should be present
711
+			$classname = str_replace('.class.php', '', $page);
712
+			// autoloaders should take care of loading file
713
+			if (! class_exists($classname)) {
714
+				$error_msg[] = sprintf(
715
+					esc_html__(
716
+						'Something went wrong with loading the %s admin hooks page.',
717
+						'event_espresso'
718
+					),
719
+					$page
720
+				);
721
+				$error_msg[] = $error_msg[0]
722
+							   . "\r\n"
723
+							   . sprintf(
724
+								   esc_html__(
725
+									   'There is no class in place for the %1$s admin hooks page.%2$sMake sure you have %3$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
726
+									   'event_espresso'
727
+								   ),
728
+								   $page,
729
+								   '<br />',
730
+								   '<strong>' . $classname . '</strong>'
731
+							   );
732
+				throw new EE_Error(implode('||', $error_msg));
733
+			}
734
+			// notice we are passing the instance of this class to the hook object.
735
+			$this->loader->getShared($classname, [$this]);
736
+		}
737
+	}
738
+
739
+
740
+	/**
741
+	 * @throws ReflectionException
742
+	 * @throws EE_Error
743
+	 */
744
+	public function load_page_dependencies()
745
+	{
746
+		try {
747
+			$this->_load_page_dependencies();
748
+		} catch (EE_Error $e) {
749
+			$e->get_error();
750
+		}
751
+	}
752
+
753
+
754
+	/**
755
+	 * load_page_dependencies
756
+	 * loads things specific to this page class when its loaded.  Really helps with efficiency.
757
+	 *
758
+	 * @return void
759
+	 * @throws DomainException
760
+	 * @throws EE_Error
761
+	 * @throws InvalidArgumentException
762
+	 * @throws InvalidDataTypeException
763
+	 * @throws InvalidInterfaceException
764
+	 */
765
+	protected function _load_page_dependencies()
766
+	{
767
+		// let's set the current_screen and screen options to override what WP set
768
+		$this->_current_screen = get_current_screen();
769
+		// load admin_notices - global, page class, and view specific
770
+		add_action('admin_notices', [$this, 'admin_notices_global'], 5);
771
+		add_action('admin_notices', [$this, 'admin_notices'], 10);
772
+		if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
773
+			add_action('admin_notices', [$this, 'admin_notices_' . $this->_current_view], 15);
774
+		}
775
+		// load network admin_notices - global, page class, and view specific
776
+		add_action('network_admin_notices', [$this, 'network_admin_notices_global'], 5);
777
+		if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
778
+			add_action('network_admin_notices', [$this, 'network_admin_notices_' . $this->_current_view]);
779
+		}
780
+		// this will save any per_page screen options if they are present
781
+		$this->_set_per_page_screen_options();
782
+		// setup list table properties
783
+		$this->_set_list_table();
784
+		// child classes can "register" a metabox to be automatically handled via the _page_config array property.
785
+		// However in some cases the metaboxes will need to be added within a route handling callback.
786
+		$this->_add_registered_meta_boxes();
787
+		$this->_add_screen_columns();
788
+		// add screen options - global, page child class, and view specific
789
+		$this->_add_global_screen_options();
790
+		$this->_add_screen_options();
791
+		$add_screen_options = "_add_screen_options_{$this->_current_view}";
792
+		if (method_exists($this, $add_screen_options)) {
793
+			$this->{$add_screen_options}();
794
+		}
795
+		// add help tab(s) - set via page_config and qtips.
796
+		$this->_add_help_tabs();
797
+		$this->_add_qtips();
798
+		// add feature_pointers - global, page child class, and view specific
799
+		$this->_add_feature_pointers();
800
+		$this->_add_global_feature_pointers();
801
+		$add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
802
+		if (method_exists($this, $add_feature_pointer)) {
803
+			$this->{$add_feature_pointer}();
804
+		}
805
+		// enqueue scripts/styles - global, page class, and view specific
806
+		add_action('admin_enqueue_scripts', [$this, 'load_global_scripts_styles'], 5);
807
+		add_action('admin_enqueue_scripts', [$this, 'load_scripts_styles'], 10);
808
+		if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
809
+			add_action('admin_enqueue_scripts', [$this, "load_scripts_styles_{$this->_current_view}"], 15);
810
+		}
811
+		add_action('admin_enqueue_scripts', [$this, 'admin_footer_scripts_eei18n_js_strings'], 100);
812
+		// admin_print_footer_scripts - global, page child class, and view specific.
813
+		// NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
814
+		// In most cases that's doing_it_wrong().  But adding hidden container elements etc.
815
+		// is a good use case. Notice the late priority we're giving these
816
+		add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts_global'], 99);
817
+		add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts'], 100);
818
+		if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
819
+			add_action('admin_print_footer_scripts', [$this, "admin_footer_scripts_{$this->_current_view}"], 101);
820
+		}
821
+		// admin footer scripts
822
+		add_action('admin_footer', [$this, 'admin_footer_global'], 99);
823
+		add_action('admin_footer', [$this, 'admin_footer'], 100);
824
+		if (method_exists($this, "admin_footer_{$this->_current_view}")) {
825
+			add_action('admin_footer', [$this, "admin_footer_{$this->_current_view}"], 101);
826
+		}
827
+		do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
828
+		// targeted hook
829
+		do_action(
830
+			"FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
831
+		);
832
+	}
833
+
834
+
835
+	/**
836
+	 * _set_defaults
837
+	 * This sets some global defaults for class properties.
838
+	 */
839
+	private function _set_defaults()
840
+	{
841
+		$this->_current_screen       = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
842
+		$this->_event                = $this->_template_path = $this->_column_template_path = null;
843
+		$this->_nav_tabs             = $this->_views = $this->_page_routes = [];
844
+		$this->_page_config          = $this->_default_route_query_args = [];
845
+		$this->_default_nav_tab_name = 'overview';
846
+		// init template args
847
+		$this->_template_args = [
848
+			'admin_page_header'  => '',
849
+			'admin_page_content' => '',
850
+			'post_body_content'  => '',
851
+			'before_list_table'  => '',
852
+			'after_list_table'   => '',
853
+		];
854
+	}
855
+
856
+
857
+	/**
858
+	 * route_admin_request
859
+	 *
860
+	 * @return void
861
+	 * @throws InvalidArgumentException
862
+	 * @throws InvalidInterfaceException
863
+	 * @throws InvalidDataTypeException
864
+	 * @throws EE_Error
865
+	 * @throws ReflectionException
866
+	 * @see    _route_admin_request()
867
+	 */
868
+	public function route_admin_request()
869
+	{
870
+		try {
871
+			$this->_route_admin_request();
872
+		} catch (EE_Error $e) {
873
+			$e->get_error();
874
+		}
875
+	}
876
+
877
+
878
+	public function set_wp_page_slug($wp_page_slug)
879
+	{
880
+		$this->_wp_page_slug = $wp_page_slug;
881
+		// if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
882
+		if (is_network_admin()) {
883
+			$this->_wp_page_slug .= '-network';
884
+		}
885
+	}
886
+
887
+
888
+	/**
889
+	 * _verify_routes
890
+	 * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
891
+	 * we know if we need to drop out.
892
+	 *
893
+	 * @return bool
894
+	 * @throws EE_Error
895
+	 */
896
+	protected function _verify_routes()
897
+	{
898
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
899
+		if (! $this->_current_page && ! $this->request->isAjax()) {
900
+			return false;
901
+		}
902
+		$this->_route = false;
903
+		// check that the page_routes array is not empty
904
+		if (empty($this->_page_routes)) {
905
+			// user error msg
906
+			$error_msg = sprintf(
907
+				esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
908
+				$this->_admin_page_title
909
+			);
910
+			// developer error msg
911
+			$error_msg .= '||' . $error_msg
912
+						  . esc_html__(
913
+							  ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
914
+							  'event_espresso'
915
+						  );
916
+			throw new EE_Error($error_msg);
917
+		}
918
+		// and that the requested page route exists
919
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
920
+			$this->_route        = $this->_page_routes[ $this->_req_action ];
921
+			$this->_route_config = $this->_page_config[ $this->_req_action ] ?? [];
922
+		} else {
923
+			// user error msg
924
+			$error_msg = sprintf(
925
+				esc_html__(
926
+					'The requested page route does not exist for the %s admin page.',
927
+					'event_espresso'
928
+				),
929
+				$this->_admin_page_title
930
+			);
931
+			// developer error msg
932
+			$error_msg .= '||' . $error_msg
933
+						  . sprintf(
934
+							  esc_html__(
935
+								  ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
936
+								  'event_espresso'
937
+							  ),
938
+							  $this->_req_action
939
+						  );
940
+			throw new EE_Error($error_msg);
941
+		}
942
+		// and that a default route exists
943
+		if (! array_key_exists('default', $this->_page_routes)) {
944
+			// user error msg
945
+			$error_msg = sprintf(
946
+				esc_html__(
947
+					'A default page route has not been set for the % admin page.',
948
+					'event_espresso'
949
+				),
950
+				$this->_admin_page_title
951
+			);
952
+			// developer error msg
953
+			$error_msg .= '||' . $error_msg
954
+						  . esc_html__(
955
+							  ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
956
+							  'event_espresso'
957
+						  );
958
+			throw new EE_Error($error_msg);
959
+		}
960
+
961
+		// first lets' catch if the UI request has EVER been set.
962
+		if ($this->_is_UI_request === null) {
963
+			// lets set if this is a UI request or not.
964
+			$this->_is_UI_request = ! $this->request->getRequestParam('noheader', false, 'bool');
965
+			// wait a minute... we might have a noheader in the route array
966
+			$this->_is_UI_request = ! (
967
+				is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader']
968
+			)
969
+				? $this->_is_UI_request
970
+				: false;
971
+		}
972
+		$this->_set_current_labels();
973
+		return true;
974
+	}
975
+
976
+
977
+	/**
978
+	 * this method simply verifies a given route and makes sure its an actual route available for the loaded page
979
+	 *
980
+	 * @param string $route the route name we're verifying
981
+	 * @return bool we'll throw an exception if this isn't a valid route.
982
+	 * @throws EE_Error
983
+	 */
984
+	protected function _verify_route($route)
985
+	{
986
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
987
+			return true;
988
+		}
989
+		// user error msg
990
+		$error_msg = sprintf(
991
+			esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
992
+			$this->_admin_page_title
993
+		);
994
+		// developer error msg
995
+		$error_msg .= '||' . $error_msg
996
+					  . sprintf(
997
+						  esc_html__(
998
+							  ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
999
+							  'event_espresso'
1000
+						  ),
1001
+						  $route
1002
+					  );
1003
+		throw new EE_Error($error_msg);
1004
+	}
1005
+
1006
+
1007
+	/**
1008
+	 * perform nonce verification
1009
+	 * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
1010
+	 * using this method (and save retyping!)
1011
+	 *
1012
+	 * @param string $nonce     The nonce sent
1013
+	 * @param string $nonce_ref The nonce reference string (name0)
1014
+	 * @return void
1015
+	 * @throws EE_Error
1016
+	 * @throws InvalidArgumentException
1017
+	 * @throws InvalidDataTypeException
1018
+	 * @throws InvalidInterfaceException
1019
+	 */
1020
+	protected function _verify_nonce($nonce, $nonce_ref)
1021
+	{
1022
+		// verify nonce against expected value
1023
+		if (! wp_verify_nonce($nonce, $nonce_ref)) {
1024
+			// these are not the droids you are looking for !!!
1025
+			$msg = sprintf(
1026
+				esc_html__('%sNonce Fail.%s', 'event_espresso'),
1027
+				'<a href="https://www.youtube.com/watch?v=56_S0WeTkzs">',
1028
+				'</a>'
1029
+			);
1030
+			if (WP_DEBUG) {
1031
+				$msg .= "\n  ";
1032
+				$msg .= sprintf(
1033
+					esc_html__(
1034
+						'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
1035
+						'event_espresso'
1036
+					),
1037
+					__CLASS__
1038
+				);
1039
+			}
1040
+			if (! $this->request->isAjax()) {
1041
+				wp_die($msg);
1042
+			}
1043
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1044
+			$this->_return_json();
1045
+		}
1046
+	}
1047
+
1048
+
1049
+	/**
1050
+	 * _route_admin_request()
1051
+	 * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if there are
1052
+	 * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
1053
+	 * in the page routes and then will try to load the corresponding method.
1054
+	 *
1055
+	 * @return void
1056
+	 * @throws EE_Error
1057
+	 * @throws InvalidArgumentException
1058
+	 * @throws InvalidDataTypeException
1059
+	 * @throws InvalidInterfaceException
1060
+	 * @throws ReflectionException
1061
+	 */
1062
+	protected function _route_admin_request()
1063
+	{
1064
+		if (! $this->_is_UI_request) {
1065
+			$this->_verify_routes();
1066
+		}
1067
+		$nonce_check = ! isset($this->_route_config['require_nonce']) || $this->_route_config['require_nonce'];
1068
+		if ($this->_req_action !== 'default' && $nonce_check) {
1069
+			// set nonce from post data
1070
+			$nonce = $this->request->getRequestParam($this->_req_nonce, '');
1071
+			$this->_verify_nonce($nonce, $this->_req_nonce);
1072
+		}
1073
+		// set the nav_tabs array but ONLY if this is  UI_request
1074
+		if ($this->_is_UI_request) {
1075
+			$this->_set_nav_tabs();
1076
+		}
1077
+		// grab callback function
1078
+		$func = is_array($this->_route) && isset($this->_route['func']) ? $this->_route['func'] : $this->_route;
1079
+		// check if callback has args
1080
+		$args      = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : [];
1081
+		$error_msg = '';
1082
+		// action right before calling route
1083
+		// (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
1084
+		if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
1085
+			do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
1086
+		}
1087
+		// strip _wp_http_referer from the server REQUEST_URI
1088
+		// else it grows in length on every submission due to recursion,
1089
+		// ultimately causing a "Request-URI Too Large" error
1090
+		$request_uri = remove_query_arg(
1091
+				'_wp_http_referer',
1092
+				wp_unslash($this->request->getServerParam('REQUEST_URI'))
1093
+		);
1094
+		// set new value in both our Request object and the super global
1095
+		$this->request->setServerParam('REQUEST_URI', $request_uri, true);
1096
+		if (! empty($func)) {
1097
+			if (is_array($func)) {
1098
+				[$class, $method] = $func;
1099
+			} elseif (strpos($func, '::') !== false) {
1100
+				[$class, $method] = explode('::', $func);
1101
+			} else {
1102
+				$class  = $this;
1103
+				$method = $func;
1104
+			}
1105
+			if (! (is_object($class) && $class === $this)) {
1106
+				// send along this admin page object for access by addons.
1107
+				$args['admin_page_object'] = $this;
1108
+			}
1109
+			if (
1110
+				// is it a method on a class that doesn't work?
1111
+				(
1112
+					(
1113
+						method_exists($class, $method)
1114
+						&& call_user_func_array([$class, $method], $args) === false
1115
+					)
1116
+					&& (
1117
+						// is it a standalone function that doesn't work?
1118
+						function_exists($method)
1119
+						&& call_user_func_array(
1120
+							$func,
1121
+							array_merge(['admin_page_object' => $this], $args)
1122
+						) === false
1123
+					)
1124
+				)
1125
+				|| (
1126
+					// is it neither a class method NOR a standalone function?
1127
+					! method_exists($class, $method)
1128
+					&& ! function_exists($method)
1129
+				)
1130
+			) {
1131
+				// user error msg
1132
+				$error_msg = esc_html__(
1133
+					'An error occurred. The  requested page route could not be found.',
1134
+					'event_espresso'
1135
+				);
1136
+				// developer error msg
1137
+				$error_msg .= '||';
1138
+				$error_msg .= sprintf(
1139
+					esc_html__(
1140
+						'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1141
+						'event_espresso'
1142
+					),
1143
+					$method
1144
+				);
1145
+			}
1146
+			if (! empty($error_msg)) {
1147
+				throw new EE_Error($error_msg);
1148
+			}
1149
+		}
1150
+		// if we've routed and this route has a no headers route AND a sent_headers_route,
1151
+		// then we need to reset the routing properties to the new route.
1152
+		// now if UI request is FALSE and noheader is true AND we have a headers_sent_route in the route array then let's set UI_request to true because the no header route has a second func after headers have been sent.
1153
+		if (
1154
+			$this->_is_UI_request === false
1155
+			&& is_array($this->_route)
1156
+			&& ! empty($this->_route['headers_sent_route'])
1157
+		) {
1158
+			$this->_reset_routing_properties($this->_route['headers_sent_route']);
1159
+		}
1160
+	}
1161
+
1162
+
1163
+	/**
1164
+	 * This method just allows the resetting of page properties in the case where a no headers
1165
+	 * route redirects to a headers route in its route config.
1166
+	 *
1167
+	 * @param string $new_route New (non header) route to redirect to.
1168
+	 * @return   void
1169
+	 * @throws ReflectionException
1170
+	 * @throws InvalidArgumentException
1171
+	 * @throws InvalidInterfaceException
1172
+	 * @throws InvalidDataTypeException
1173
+	 * @throws EE_Error
1174
+	 * @since   4.3.0
1175
+	 */
1176
+	protected function _reset_routing_properties($new_route)
1177
+	{
1178
+		$this->_is_UI_request = true;
1179
+		// now we set the current route to whatever the headers_sent_route is set at
1180
+		$this->request->setRequestParam('action', $new_route);
1181
+		// rerun page setup
1182
+		$this->_page_setup();
1183
+	}
1184
+
1185
+
1186
+	/**
1187
+	 * _add_query_arg
1188
+	 * adds nonce to array of arguments then calls WP add_query_arg function
1189
+	 *(internally just uses EEH_URL's function with the same name)
1190
+	 *
1191
+	 * @param array  $args
1192
+	 * @param string $url
1193
+	 * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1194
+	 *                                        generated url in an associative array indexed by the key 'wp_referer';
1195
+	 *                                        Example usage: If the current page is:
1196
+	 *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1197
+	 *                                        &action=default&event_id=20&month_range=March%202015
1198
+	 *                                        &_wpnonce=5467821
1199
+	 *                                        and you call:
1200
+	 *                                        EE_Admin_Page::add_query_args_and_nonce(
1201
+	 *                                        array(
1202
+	 *                                        'action' => 'resend_something',
1203
+	 *                                        'page=>espresso_registrations'
1204
+	 *                                        ),
1205
+	 *                                        $some_url,
1206
+	 *                                        true
1207
+	 *                                        );
1208
+	 *                                        It will produce a url in this structure:
1209
+	 *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1210
+	 *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1211
+	 *                                        month_range]=March%202015
1212
+	 * @param bool   $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1213
+	 * @return string
1214
+	 */
1215
+	public static function add_query_args_and_nonce(
1216
+		$args = [],
1217
+		$url = '',
1218
+		$sticky = false,
1219
+		$exclude_nonce = false
1220
+	) {
1221
+		// if there is a _wp_http_referer include the values from the request but only if sticky = true
1222
+		if ($sticky) {
1223
+			/** @var RequestInterface $request */
1224
+			$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
1225
+			$request->unSetRequestParams(['_wp_http_referer', 'wp_referer'], true);
1226
+			$request->unSetServerParam('_wp_http_referer', true);
1227
+			foreach ($request->requestParams() as $key => $value) {
1228
+				// do not add nonces
1229
+				if (strpos($key, 'nonce') !== false) {
1230
+					continue;
1231
+				}
1232
+				$args[ 'wp_referer[' . $key . ']' ] = is_string($value) ? htmlspecialchars($value) : $value;
1233
+			}
1234
+		}
1235
+		return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1236
+	}
1237
+
1238
+
1239
+	/**
1240
+	 * This returns a generated link that will load the related help tab.
1241
+	 *
1242
+	 * @param string $help_tab_id the id for the connected help tab
1243
+	 * @param string $icon_style  (optional) include css class for the style you want to use for the help icon.
1244
+	 * @param string $help_text   (optional) send help text you want to use for the link if default not to be used
1245
+	 * @return string              generated link
1246
+	 * @uses EEH_Template::get_help_tab_link()
1247
+	 */
1248
+	protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1249
+	{
1250
+		return EEH_Template::get_help_tab_link(
1251
+			$help_tab_id,
1252
+			$this->page_slug,
1253
+			$this->_req_action,
1254
+			$icon_style,
1255
+			$help_text
1256
+		);
1257
+	}
1258
+
1259
+
1260
+	/**
1261
+	 * _add_help_tabs
1262
+	 * Note child classes define their help tabs within the page_config array.
1263
+	 *
1264
+	 * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1265
+	 * @return void
1266
+	 * @throws DomainException
1267
+	 * @throws EE_Error
1268
+	 * @throws ReflectionException
1269
+	 */
1270
+	protected function _add_help_tabs()
1271
+	{
1272
+		if (isset($this->_page_config[ $this->_req_action ])) {
1273
+			$config = $this->_page_config[ $this->_req_action ];
1274
+			// let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1275
+			if (is_array($config) && isset($config['help_sidebar'])) {
1276
+				// check that the callback given is valid
1277
+				if (! method_exists($this, $config['help_sidebar'])) {
1278
+					throw new EE_Error(
1279
+						sprintf(
1280
+							esc_html__(
1281
+								'The _page_config array has a callback set for the "help_sidebar" option.  However the callback given (%s) is not a valid callback.  Doublecheck the spelling and make sure this method exists for the class %s',
1282
+								'event_espresso'
1283
+							),
1284
+							$config['help_sidebar'],
1285
+							get_class($this)
1286
+						)
1287
+					);
1288
+				}
1289
+				$content = apply_filters(
1290
+					'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1291
+					$this->{$config['help_sidebar']}()
1292
+				);
1293
+				$this->_current_screen->set_help_sidebar($content);
1294
+			}
1295
+			if (! isset($config['help_tabs'])) {
1296
+				return;
1297
+			} //no help tabs for this route
1298
+			foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1299
+				// we're here so there ARE help tabs!
1300
+				// make sure we've got what we need
1301
+				if (! isset($cfg['title'])) {
1302
+					throw new EE_Error(
1303
+						esc_html__(
1304
+							'The _page_config array is not set up properly for help tabs.  It is missing a title',
1305
+							'event_espresso'
1306
+						)
1307
+					);
1308
+				}
1309
+				if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1310
+					throw new EE_Error(
1311
+						esc_html__(
1312
+							'The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab',
1313
+							'event_espresso'
1314
+						)
1315
+					);
1316
+				}
1317
+				// first priority goes to content.
1318
+				if (! empty($cfg['content'])) {
1319
+					$content = ! empty($cfg['content']) ? $cfg['content'] : null;
1320
+					// second priority goes to filename
1321
+				} elseif (! empty($cfg['filename'])) {
1322
+					$file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1323
+					// it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too)
1324
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1325
+															 . basename($this->_get_dir())
1326
+															 . '/help_tabs/'
1327
+															 . $cfg['filename']
1328
+															 . '.help_tab.php' : $file_path;
1329
+					// if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1330
+					if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1331
+						EE_Error::add_error(
1332
+							sprintf(
1333
+								esc_html__(
1334
+									'The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content.  Please check that the string you set for the help tab on this route (%s) is the correct spelling.  The file should be in %s',
1335
+									'event_espresso'
1336
+								),
1337
+								$tab_id,
1338
+								key($config),
1339
+								$file_path
1340
+							),
1341
+							__FILE__,
1342
+							__FUNCTION__,
1343
+							__LINE__
1344
+						);
1345
+						return;
1346
+					}
1347
+					$template_args['admin_page_obj'] = $this;
1348
+					$content                         = EEH_Template::display_template(
1349
+						$file_path,
1350
+						$template_args,
1351
+						true
1352
+					);
1353
+				} else {
1354
+					$content = '';
1355
+				}
1356
+				// check if callback is valid
1357
+				if (
1358
+					empty($content)
1359
+					&& (
1360
+						! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1361
+					)
1362
+				) {
1363
+					EE_Error::add_error(
1364
+						sprintf(
1365
+							esc_html__(
1366
+								'The callback given for a %s help tab on this page does not content OR a corresponding method for generating the content.  Check the spelling or make sure the method is present.',
1367
+								'event_espresso'
1368
+							),
1369
+							$cfg['title']
1370
+						),
1371
+						__FILE__,
1372
+						__FUNCTION__,
1373
+						__LINE__
1374
+					);
1375
+					return;
1376
+				}
1377
+				// setup config array for help tab method
1378
+				$id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1379
+				$_ht = [
1380
+					'id'       => $id,
1381
+					'title'    => $cfg['title'],
1382
+					'callback' => isset($cfg['callback']) && empty($content) ? [$this, $cfg['callback']] : null,
1383
+					'content'  => $content,
1384
+				];
1385
+				$this->_current_screen->add_help_tab($_ht);
1386
+			}
1387
+		}
1388
+	}
1389
+
1390
+
1391
+	/**
1392
+	 * This simply sets up any qtips that have been defined in the page config
1393
+	 *
1394
+	 * @return void
1395
+	 * @throws ReflectionException
1396
+	 * @throws EE_Error
1397
+	 */
1398
+	protected function _add_qtips()
1399
+	{
1400
+		if (isset($this->_route_config['qtips'])) {
1401
+			$qtips = (array) $this->_route_config['qtips'];
1402
+			// load qtip loader
1403
+			$path = [
1404
+				$this->_get_dir() . '/qtips/',
1405
+				EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1406
+			];
1407
+			EEH_Qtip_Loader::instance()->register($qtips, $path);
1408
+		}
1409
+	}
1410
+
1411
+
1412
+	/**
1413
+	 * _set_nav_tabs
1414
+	 * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1415
+	 * wish to add additional tabs or modify accordingly.
1416
+	 *
1417
+	 * @return void
1418
+	 * @throws InvalidArgumentException
1419
+	 * @throws InvalidInterfaceException
1420
+	 * @throws InvalidDataTypeException
1421
+	 */
1422
+	protected function _set_nav_tabs()
1423
+	{
1424
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1425
+		$i = 0;
1426
+		foreach ($this->_page_config as $slug => $config) {
1427
+			if (! is_array($config) || empty($config['nav'])) {
1428
+				continue;
1429
+			}
1430
+			// no nav tab for this config
1431
+			// check for persistent flag
1432
+			if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1433
+				// nav tab is only to appear when route requested.
1434
+				continue;
1435
+			}
1436
+			if (! $this->check_user_access($slug, true)) {
1437
+				// no nav tab because current user does not have access.
1438
+				continue;
1439
+			}
1440
+			$css_class                = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1441
+			$this->_nav_tabs[ $slug ] = [
1442
+				'url'       => isset($config['nav']['url'])
1443
+					? $config['nav']['url']
1444
+					: EE_Admin_Page::add_query_args_and_nonce(
1445
+						['action' => $slug],
1446
+						$this->_admin_base_url
1447
+					),
1448
+				'link_text' => isset($config['nav']['label'])
1449
+					? $config['nav']['label']
1450
+					: ucwords(
1451
+						str_replace('_', ' ', $slug)
1452
+					),
1453
+				'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1454
+				'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1455
+			];
1456
+			$i++;
1457
+		}
1458
+		// if $this->_nav_tabs is empty then lets set the default
1459
+		if (empty($this->_nav_tabs)) {
1460
+			$this->_nav_tabs[ $this->_default_nav_tab_name ] = [
1461
+				'url'       => $this->_admin_base_url,
1462
+				'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1463
+				'css_class' => 'nav-tab-active',
1464
+				'order'     => 10,
1465
+			];
1466
+		}
1467
+		// now let's sort the tabs according to order
1468
+		usort($this->_nav_tabs, [$this, '_sort_nav_tabs']);
1469
+	}
1470
+
1471
+
1472
+	/**
1473
+	 * _set_current_labels
1474
+	 * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1475
+	 * property array
1476
+	 *
1477
+	 * @return void
1478
+	 */
1479
+	private function _set_current_labels()
1480
+	{
1481
+		if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1482
+			foreach ($this->_route_config['labels'] as $label => $text) {
1483
+				if (is_array($text)) {
1484
+					foreach ($text as $sublabel => $subtext) {
1485
+						$this->_labels[ $label ][ $sublabel ] = $subtext;
1486
+					}
1487
+				} else {
1488
+					$this->_labels[ $label ] = $text;
1489
+				}
1490
+			}
1491
+		}
1492
+	}
1493
+
1494
+
1495
+	/**
1496
+	 *        verifies user access for this admin page
1497
+	 *
1498
+	 * @param string $route_to_check if present then the capability for the route matching this string is checked.
1499
+	 * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1500
+	 *                               return false if verify fail.
1501
+	 * @return bool
1502
+	 * @throws InvalidArgumentException
1503
+	 * @throws InvalidDataTypeException
1504
+	 * @throws InvalidInterfaceException
1505
+	 */
1506
+	public function check_user_access($route_to_check = '', $verify_only = false)
1507
+	{
1508
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1509
+		$route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1510
+		$capability     = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1511
+						  && is_array(
1512
+							  $this->_page_routes[ $route_to_check ]
1513
+						  )
1514
+						  && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1515
+			? $this->_page_routes[ $route_to_check ]['capability'] : null;
1516
+		if (empty($capability) && empty($route_to_check)) {
1517
+			$capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1518
+				: $this->_route['capability'];
1519
+		} else {
1520
+			$capability = empty($capability) ? 'manage_options' : $capability;
1521
+		}
1522
+		$id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1523
+		if (
1524
+			! $this->request->isAjax()
1525
+			&& (
1526
+				! function_exists('is_admin')
1527
+				|| ! EE_Registry::instance()->CAP->current_user_can(
1528
+					$capability,
1529
+					$this->page_slug
1530
+					. '_'
1531
+					. $route_to_check,
1532
+					$id
1533
+				)
1534
+			)
1535
+		) {
1536
+			if ($verify_only) {
1537
+				return false;
1538
+			}
1539
+			if (is_user_logged_in()) {
1540
+				wp_die(esc_html__('You do not have access to this route.', 'event_espresso'));
1541
+			} else {
1542
+				return false;
1543
+			}
1544
+		}
1545
+		return true;
1546
+	}
1547
+
1548
+
1549
+	protected function addMetaBox(
1550
+		$box_id,
1551
+		$title,
1552
+		$callback,
1553
+		$screen,
1554
+		$context = 'normal',
1555
+		$priority = 'default',
1556
+		$callback_args = null
1557
+	) {
1558
+		add_meta_box($box_id, $title, $callback, $screen, $context, $priority, $callback_args);
1559
+		add_filter(
1560
+			"postbox_classes_{$this->_wp_page_slug}_{$box_id}",
1561
+			function ($classes) {
1562
+				array_push($classes, 'ee-admin-container');
1563
+				return $classes;
1564
+			}
1565
+		);
1566
+	}
1567
+
1568
+
1569
+	/**
1570
+	 * admin_init_global
1571
+	 * This runs all the code that we want executed within the WP admin_init hook.
1572
+	 * This method executes for ALL EE Admin pages.
1573
+	 *
1574
+	 * @return void
1575
+	 */
1576
+	public function admin_init_global()
1577
+	{
1578
+	}
1579
+
1580
+
1581
+	/**
1582
+	 * wp_loaded_global
1583
+	 * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1584
+	 * EE_Admin page and will execute on every EE Admin Page load
1585
+	 *
1586
+	 * @return void
1587
+	 */
1588
+	public function wp_loaded()
1589
+	{
1590
+	}
1591
+
1592
+
1593
+	/**
1594
+	 * admin_notices
1595
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1596
+	 * ALL EE_Admin pages.
1597
+	 *
1598
+	 * @return void
1599
+	 */
1600
+	public function admin_notices_global()
1601
+	{
1602
+		$this->_display_no_javascript_warning();
1603
+		$this->_display_espresso_notices();
1604
+	}
1605
+
1606
+
1607
+	public function network_admin_notices_global()
1608
+	{
1609
+		$this->_display_no_javascript_warning();
1610
+		$this->_display_espresso_notices();
1611
+	}
1612
+
1613
+
1614
+	/**
1615
+	 * admin_footer_scripts_global
1616
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1617
+	 * will apply on ALL EE_Admin pages.
1618
+	 *
1619
+	 * @return void
1620
+	 */
1621
+	public function admin_footer_scripts_global()
1622
+	{
1623
+		$this->_add_admin_page_ajax_loading_img();
1624
+		$this->_add_admin_page_overlay();
1625
+		// if metaboxes are present we need to add the nonce field
1626
+		if (
1627
+			isset($this->_route_config['metaboxes'])
1628
+			|| isset($this->_route_config['list_table'])
1629
+			|| (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1630
+		) {
1631
+			wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1632
+			wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1633
+		}
1634
+	}
1635
+
1636
+
1637
+	/**
1638
+	 * admin_footer_global
1639
+	 * Anything triggered by the wp 'admin_footer' wp hook should be put in here.
1640
+	 * This particular method will apply on ALL EE_Admin Pages.
1641
+	 *
1642
+	 * @return void
1643
+	 */
1644
+	public function admin_footer_global()
1645
+	{
1646
+		// dialog container for dialog helper
1647
+		echo '
1648 1648
         <div class="ee-admin-dialog-container auto-hide hidden">
1649 1649
             <div class="ee-notices"></div>
1650 1650
             <div class="ee-admin-dialog-container-inner-content"></div>
1651 1651
         </div>
1652 1652
         ';
1653 1653
 
1654
-        // current set timezone for timezone js
1655
-        echo '<span id="current_timezone" class="hidden">' . esc_html(EEH_DTT_Helper::get_timezone()) . '</span>';
1656
-    }
1657
-
1658
-
1659
-    /**
1660
-     * This function sees if there is a method for help popup content existing for the given route.  If there is then
1661
-     * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1662
-     * help popups then in your templates or your content you set "triggers" for the content using the
1663
-     * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1664
-     * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1665
-     * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1666
-     * for the
1667
-     * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1668
-     * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1669
-     *    'help_trigger_id' => array(
1670
-     *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1671
-     *        'content' => esc_html__('localized content for popup', 'event_espresso')
1672
-     *    )
1673
-     * );
1674
-     * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1675
-     *
1676
-     * @param array $help_array
1677
-     * @param bool  $display
1678
-     * @return string content
1679
-     * @throws DomainException
1680
-     * @throws EE_Error
1681
-     */
1682
-    protected function _set_help_popup_content($help_array = [], $display = false)
1683
-    {
1684
-        $content    = '';
1685
-        $help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1686
-        // loop through the array and setup content
1687
-        foreach ($help_array as $trigger => $help) {
1688
-            // make sure the array is setup properly
1689
-            if (! isset($help['title'], $help['content'])) {
1690
-                throw new EE_Error(
1691
-                    esc_html__(
1692
-                        'Does not look like the popup content array has been setup correctly.  Might want to double check that.  Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class',
1693
-                        'event_espresso'
1694
-                    )
1695
-                );
1696
-            }
1697
-            // we're good so let's setup the template vars and then assign parsed template content to our content.
1698
-            $template_args = [
1699
-                'help_popup_id'      => $trigger,
1700
-                'help_popup_title'   => $help['title'],
1701
-                'help_popup_content' => $help['content'],
1702
-            ];
1703
-            $content       .= EEH_Template::display_template(
1704
-                EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1705
-                $template_args,
1706
-                true
1707
-            );
1708
-        }
1709
-        if ($display) {
1710
-            echo $content; // already escaped
1711
-            return '';
1712
-        }
1713
-        return $content;
1714
-    }
1715
-
1716
-
1717
-    /**
1718
-     * All this does is retrieve the help content array if set by the EE_Admin_Page child
1719
-     *
1720
-     * @return array properly formatted array for help popup content
1721
-     * @throws EE_Error
1722
-     */
1723
-    private function _get_help_content()
1724
-    {
1725
-        // what is the method we're looking for?
1726
-        $method_name = '_help_popup_content_' . $this->_req_action;
1727
-        // if method doesn't exist let's get out.
1728
-        if (! method_exists($this, $method_name)) {
1729
-            return [];
1730
-        }
1731
-        // k we're good to go let's retrieve the help array
1732
-        $help_array = $this->{$method_name}();
1733
-        // make sure we've got an array!
1734
-        if (! is_array($help_array)) {
1735
-            throw new EE_Error(
1736
-                esc_html__(
1737
-                    'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1738
-                    'event_espresso'
1739
-                )
1740
-            );
1741
-        }
1742
-        return $help_array;
1743
-    }
1744
-
1745
-
1746
-    /**
1747
-     * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1748
-     * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1749
-     * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1750
-     *
1751
-     * @param string  $trigger_id reference for retrieving the trigger content for the popup
1752
-     * @param boolean $display    if false then we return the trigger string
1753
-     * @param array   $dimensions an array of dimensions for the box (array(h,w))
1754
-     * @return string
1755
-     * @throws DomainException
1756
-     * @throws EE_Error
1757
-     */
1758
-    protected function _set_help_trigger($trigger_id, $display = true, $dimensions = ['400', '640'])
1759
-    {
1760
-        if ($this->request->isAjax()) {
1761
-            return '';
1762
-        }
1763
-        // let's check and see if there is any content set for this popup.  If there isn't then we'll include a default title and content so that developers know something needs to be corrected
1764
-        $help_array   = $this->_get_help_content();
1765
-        $help_content = '';
1766
-        if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1767
-            $help_array[ $trigger_id ] = [
1768
-                'title'   => esc_html__('Missing Content', 'event_espresso'),
1769
-                'content' => esc_html__(
1770
-                    'A trigger has been set that doesn\'t have any corresponding content. Make sure you have set the help content. (see the "_set_help_popup_content" method in the EE_Admin_Page for instructions.)',
1771
-                    'event_espresso'
1772
-                ),
1773
-            ];
1774
-            $help_content = $this->_set_help_popup_content($help_array);
1775
-        }
1776
-        // let's setup the trigger
1777
-        $content = '<a class="ee-dialog" href="?height='
1778
-                   . esc_attr($dimensions[0])
1779
-                   . '&width='
1780
-                   . esc_attr($dimensions[1])
1781
-                   . '&inlineId='
1782
-                   . esc_attr($trigger_id)
1783
-                   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1784
-        $content .= $help_content;
1785
-        if ($display) {
1786
-            echo $content; // already escaped
1787
-            return '';
1788
-        }
1789
-        return $content;
1790
-    }
1791
-
1792
-
1793
-    /**
1794
-     * _add_global_screen_options
1795
-     * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1796
-     * This particular method will add_screen_options on ALL EE_Admin Pages
1797
-     *
1798
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1799
-     *         see also WP_Screen object documents...
1800
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1801
-     * @abstract
1802
-     * @return void
1803
-     */
1804
-    private function _add_global_screen_options()
1805
-    {
1806
-    }
1807
-
1808
-
1809
-    /**
1810
-     * _add_global_feature_pointers
1811
-     * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1812
-     * This particular method will implement feature pointers for ALL EE_Admin pages.
1813
-     * Note: this is just a placeholder for now.  Implementation will come down the road
1814
-     *
1815
-     * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1816
-     *         extended) also see:
1817
-     * @link   http://eamann.com/tech/wordpress-portland/
1818
-     * @abstract
1819
-     * @return void
1820
-     */
1821
-    private function _add_global_feature_pointers()
1822
-    {
1823
-    }
1824
-
1825
-
1826
-    /**
1827
-     * load_global_scripts_styles
1828
-     * The scripts and styles enqueued in here will be loaded on every EE Admin page
1829
-     *
1830
-     * @return void
1831
-     */
1832
-    public function load_global_scripts_styles()
1833
-    {
1834
-        // add debugging styles
1835
-        if (WP_DEBUG) {
1836
-            add_action('admin_head', [$this, 'add_xdebug_style']);
1837
-        }
1838
-        // taking care of metaboxes
1839
-        if (
1840
-            empty($this->_cpt_route)
1841
-            && (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
1842
-        ) {
1843
-            wp_enqueue_script('dashboard');
1844
-        }
1845
-
1846
-        wp_enqueue_script(JqueryAssetManager::JS_HANDLE_JQUERY_UI_TOUCH_PUNCH);
1847
-        wp_enqueue_script(EspressoLegacyAdminAssetManager::JS_HANDLE_EE_ADMIN);
1848
-        // LOCALIZED DATA
1849
-        // localize script for ajax lazy loading
1850
-        wp_localize_script(
1851
-            EspressoLegacyAdminAssetManager::JS_HANDLE_EE_ADMIN,
1852
-            'eeLazyLoadingContainers',
1853
-            apply_filters(
1854
-                'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
1855
-                ['espresso_news_post_box_content']
1856
-            )
1857
-        );
1858
-        add_filter(
1859
-            'admin_body_class',
1860
-            function ($classes) {
1861
-                if (strpos($classes, 'espresso-admin') === false) {
1862
-                    $classes .= ' espresso-admin';
1863
-                }
1864
-                return $classes;
1865
-            }
1866
-        );
1867
-    }
1868
-
1869
-
1870
-    /**
1871
-     *        admin_footer_scripts_eei18n_js_strings
1872
-     *
1873
-     * @return        void
1874
-     */
1875
-    public function admin_footer_scripts_eei18n_js_strings()
1876
-    {
1877
-        EE_Registry::$i18n_js_strings['ajax_url']       = WP_AJAX_URL;
1878
-        EE_Registry::$i18n_js_strings['confirm_delete'] = wp_strip_all_tags(
1879
-            __(
1880
-                'Are you absolutely sure you want to delete this item?\nThis action will delete ALL DATA associated with this item!!!\nThis can NOT be undone!!!',
1881
-                'event_espresso'
1882
-            )
1883
-        );
1884
-        EE_Registry::$i18n_js_strings['January']        = wp_strip_all_tags(__('January', 'event_espresso'));
1885
-        EE_Registry::$i18n_js_strings['February']       = wp_strip_all_tags(__('February', 'event_espresso'));
1886
-        EE_Registry::$i18n_js_strings['March']          = wp_strip_all_tags(__('March', 'event_espresso'));
1887
-        EE_Registry::$i18n_js_strings['April']          = wp_strip_all_tags(__('April', 'event_espresso'));
1888
-        EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
1889
-        EE_Registry::$i18n_js_strings['June']           = wp_strip_all_tags(__('June', 'event_espresso'));
1890
-        EE_Registry::$i18n_js_strings['July']           = wp_strip_all_tags(__('July', 'event_espresso'));
1891
-        EE_Registry::$i18n_js_strings['August']         = wp_strip_all_tags(__('August', 'event_espresso'));
1892
-        EE_Registry::$i18n_js_strings['September']      = wp_strip_all_tags(__('September', 'event_espresso'));
1893
-        EE_Registry::$i18n_js_strings['October']        = wp_strip_all_tags(__('October', 'event_espresso'));
1894
-        EE_Registry::$i18n_js_strings['November']       = wp_strip_all_tags(__('November', 'event_espresso'));
1895
-        EE_Registry::$i18n_js_strings['December']       = wp_strip_all_tags(__('December', 'event_espresso'));
1896
-        EE_Registry::$i18n_js_strings['Jan']            = wp_strip_all_tags(__('Jan', 'event_espresso'));
1897
-        EE_Registry::$i18n_js_strings['Feb']            = wp_strip_all_tags(__('Feb', 'event_espresso'));
1898
-        EE_Registry::$i18n_js_strings['Mar']            = wp_strip_all_tags(__('Mar', 'event_espresso'));
1899
-        EE_Registry::$i18n_js_strings['Apr']            = wp_strip_all_tags(__('Apr', 'event_espresso'));
1900
-        EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
1901
-        EE_Registry::$i18n_js_strings['Jun']            = wp_strip_all_tags(__('Jun', 'event_espresso'));
1902
-        EE_Registry::$i18n_js_strings['Jul']            = wp_strip_all_tags(__('Jul', 'event_espresso'));
1903
-        EE_Registry::$i18n_js_strings['Aug']            = wp_strip_all_tags(__('Aug', 'event_espresso'));
1904
-        EE_Registry::$i18n_js_strings['Sep']            = wp_strip_all_tags(__('Sep', 'event_espresso'));
1905
-        EE_Registry::$i18n_js_strings['Oct']            = wp_strip_all_tags(__('Oct', 'event_espresso'));
1906
-        EE_Registry::$i18n_js_strings['Nov']            = wp_strip_all_tags(__('Nov', 'event_espresso'));
1907
-        EE_Registry::$i18n_js_strings['Dec']            = wp_strip_all_tags(__('Dec', 'event_espresso'));
1908
-        EE_Registry::$i18n_js_strings['Sunday']         = wp_strip_all_tags(__('Sunday', 'event_espresso'));
1909
-        EE_Registry::$i18n_js_strings['Monday']         = wp_strip_all_tags(__('Monday', 'event_espresso'));
1910
-        EE_Registry::$i18n_js_strings['Tuesday']        = wp_strip_all_tags(__('Tuesday', 'event_espresso'));
1911
-        EE_Registry::$i18n_js_strings['Wednesday']      = wp_strip_all_tags(__('Wednesday', 'event_espresso'));
1912
-        EE_Registry::$i18n_js_strings['Thursday']       = wp_strip_all_tags(__('Thursday', 'event_espresso'));
1913
-        EE_Registry::$i18n_js_strings['Friday']         = wp_strip_all_tags(__('Friday', 'event_espresso'));
1914
-        EE_Registry::$i18n_js_strings['Saturday']       = wp_strip_all_tags(__('Saturday', 'event_espresso'));
1915
-        EE_Registry::$i18n_js_strings['Sun']            = wp_strip_all_tags(__('Sun', 'event_espresso'));
1916
-        EE_Registry::$i18n_js_strings['Mon']            = wp_strip_all_tags(__('Mon', 'event_espresso'));
1917
-        EE_Registry::$i18n_js_strings['Tue']            = wp_strip_all_tags(__('Tue', 'event_espresso'));
1918
-        EE_Registry::$i18n_js_strings['Wed']            = wp_strip_all_tags(__('Wed', 'event_espresso'));
1919
-        EE_Registry::$i18n_js_strings['Thu']            = wp_strip_all_tags(__('Thu', 'event_espresso'));
1920
-        EE_Registry::$i18n_js_strings['Fri']            = wp_strip_all_tags(__('Fri', 'event_espresso'));
1921
-        EE_Registry::$i18n_js_strings['Sat']            = wp_strip_all_tags(__('Sat', 'event_espresso'));
1922
-    }
1923
-
1924
-
1925
-    /**
1926
-     *        load enhanced xdebug styles for ppl with failing eyesight
1927
-     *
1928
-     * @return        void
1929
-     */
1930
-    public function add_xdebug_style()
1931
-    {
1932
-        echo '<style>.xdebug-error { font-size:1.5em; }</style>';
1933
-    }
1934
-
1935
-
1936
-    /************************/
1937
-    /** LIST TABLE METHODS **/
1938
-    /************************/
1939
-    /**
1940
-     * this sets up the list table if the current view requires it.
1941
-     *
1942
-     * @return void
1943
-     * @throws EE_Error
1944
-     * @throws InvalidArgumentException
1945
-     * @throws InvalidDataTypeException
1946
-     * @throws InvalidInterfaceException
1947
-     */
1948
-    protected function _set_list_table()
1949
-    {
1950
-        // first is this a list_table view?
1951
-        if (! isset($this->_route_config['list_table'])) {
1952
-            return;
1953
-        } //not a list_table view so get out.
1954
-        // list table functions are per view specific (because some admin pages might have more than one list table!)
1955
-        $list_table_view = '_set_list_table_views_' . $this->_req_action;
1956
-        if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
1957
-            // user error msg
1958
-            $error_msg = esc_html__(
1959
-                'An error occurred. The requested list table views could not be found.',
1960
-                'event_espresso'
1961
-            );
1962
-            // developer error msg
1963
-            $error_msg .= '||'
1964
-                          . sprintf(
1965
-                              esc_html__(
1966
-                                  'List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.',
1967
-                                  'event_espresso'
1968
-                              ),
1969
-                              $this->_req_action,
1970
-                              $list_table_view
1971
-                          );
1972
-            throw new EE_Error($error_msg);
1973
-        }
1974
-        // let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
1975
-        $this->_views = apply_filters(
1976
-            'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
1977
-            $this->_views
1978
-        );
1979
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
1980
-        $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
1981
-        $this->_set_list_table_view();
1982
-        $this->_set_list_table_object();
1983
-    }
1984
-
1985
-
1986
-    /**
1987
-     * set current view for List Table
1988
-     *
1989
-     * @return void
1990
-     */
1991
-    protected function _set_list_table_view()
1992
-    {
1993
-        $this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
1994
-        $status = $this->request->getRequestParam('status', null, 'key');
1995
-        $this->_view = $status && array_key_exists($status, $this->_views)
1996
-            ? $status
1997
-            : $this->_view;
1998
-    }
1999
-
2000
-
2001
-    /**
2002
-     * _set_list_table_object
2003
-     * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
2004
-     *
2005
-     * @throws InvalidInterfaceException
2006
-     * @throws InvalidArgumentException
2007
-     * @throws InvalidDataTypeException
2008
-     * @throws EE_Error
2009
-     * @throws InvalidInterfaceException
2010
-     */
2011
-    protected function _set_list_table_object()
2012
-    {
2013
-        if (isset($this->_route_config['list_table'])) {
2014
-            if (! class_exists($this->_route_config['list_table'])) {
2015
-                throw new EE_Error(
2016
-                    sprintf(
2017
-                        esc_html__(
2018
-                            'The %s class defined for the list table does not exist.  Please check the spelling of the class ref in the $_page_config property on %s.',
2019
-                            'event_espresso'
2020
-                        ),
2021
-                        $this->_route_config['list_table'],
2022
-                        get_class($this)
2023
-                    )
2024
-                );
2025
-            }
2026
-            $this->_list_table_object = $this->loader->getShared(
2027
-                $this->_route_config['list_table'],
2028
-                [$this]
2029
-            );
2030
-        }
2031
-    }
2032
-
2033
-
2034
-    /**
2035
-     * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2036
-     *
2037
-     * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2038
-     *                                                    urls.  The array should be indexed by the view it is being
2039
-     *                                                    added to.
2040
-     * @return array
2041
-     */
2042
-    public function get_list_table_view_RLs($extra_query_args = [])
2043
-    {
2044
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2045
-        if (empty($this->_views)) {
2046
-            $this->_views = [];
2047
-        }
2048
-        // cycle thru views
2049
-        foreach ($this->_views as $key => $view) {
2050
-            $query_args = [];
2051
-            // check for current view
2052
-            $this->_views[ $key ]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2053
-            $query_args['action']                        = $this->_req_action;
2054
-            $query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2055
-            $query_args['status']                        = $view['slug'];
2056
-            // merge any other arguments sent in.
2057
-            if (isset($extra_query_args[ $view['slug'] ])) {
2058
-                foreach ($extra_query_args[ $view['slug'] ] as $extra_query_arg) {
2059
-                    $query_args[] = $extra_query_arg;
2060
-                }
2061
-            }
2062
-            $this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2063
-        }
2064
-        return $this->_views;
2065
-    }
2066
-
2067
-
2068
-    /**
2069
-     * _entries_per_page_dropdown
2070
-     * generates a dropdown box for selecting the number of visible rows in an admin page list table
2071
-     *
2072
-     * @param int $max_entries total number of rows in the table
2073
-     * @return string
2074
-     * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2075
-     *         WP does it.
2076
-     */
2077
-    protected function _entries_per_page_dropdown($max_entries = 0)
2078
-    {
2079
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2080
-        $values   = [10, 25, 50, 100];
2081
-        $per_page = $this->request->getRequestParam('per_page', 10, 'int');
2082
-        if ($max_entries) {
2083
-            $values[] = $max_entries;
2084
-            sort($values);
2085
-        }
2086
-        $entries_per_page_dropdown = '
1654
+		// current set timezone for timezone js
1655
+		echo '<span id="current_timezone" class="hidden">' . esc_html(EEH_DTT_Helper::get_timezone()) . '</span>';
1656
+	}
1657
+
1658
+
1659
+	/**
1660
+	 * This function sees if there is a method for help popup content existing for the given route.  If there is then
1661
+	 * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1662
+	 * help popups then in your templates or your content you set "triggers" for the content using the
1663
+	 * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1664
+	 * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1665
+	 * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1666
+	 * for the
1667
+	 * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1668
+	 * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1669
+	 *    'help_trigger_id' => array(
1670
+	 *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1671
+	 *        'content' => esc_html__('localized content for popup', 'event_espresso')
1672
+	 *    )
1673
+	 * );
1674
+	 * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1675
+	 *
1676
+	 * @param array $help_array
1677
+	 * @param bool  $display
1678
+	 * @return string content
1679
+	 * @throws DomainException
1680
+	 * @throws EE_Error
1681
+	 */
1682
+	protected function _set_help_popup_content($help_array = [], $display = false)
1683
+	{
1684
+		$content    = '';
1685
+		$help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1686
+		// loop through the array and setup content
1687
+		foreach ($help_array as $trigger => $help) {
1688
+			// make sure the array is setup properly
1689
+			if (! isset($help['title'], $help['content'])) {
1690
+				throw new EE_Error(
1691
+					esc_html__(
1692
+						'Does not look like the popup content array has been setup correctly.  Might want to double check that.  Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class',
1693
+						'event_espresso'
1694
+					)
1695
+				);
1696
+			}
1697
+			// we're good so let's setup the template vars and then assign parsed template content to our content.
1698
+			$template_args = [
1699
+				'help_popup_id'      => $trigger,
1700
+				'help_popup_title'   => $help['title'],
1701
+				'help_popup_content' => $help['content'],
1702
+			];
1703
+			$content       .= EEH_Template::display_template(
1704
+				EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1705
+				$template_args,
1706
+				true
1707
+			);
1708
+		}
1709
+		if ($display) {
1710
+			echo $content; // already escaped
1711
+			return '';
1712
+		}
1713
+		return $content;
1714
+	}
1715
+
1716
+
1717
+	/**
1718
+	 * All this does is retrieve the help content array if set by the EE_Admin_Page child
1719
+	 *
1720
+	 * @return array properly formatted array for help popup content
1721
+	 * @throws EE_Error
1722
+	 */
1723
+	private function _get_help_content()
1724
+	{
1725
+		// what is the method we're looking for?
1726
+		$method_name = '_help_popup_content_' . $this->_req_action;
1727
+		// if method doesn't exist let's get out.
1728
+		if (! method_exists($this, $method_name)) {
1729
+			return [];
1730
+		}
1731
+		// k we're good to go let's retrieve the help array
1732
+		$help_array = $this->{$method_name}();
1733
+		// make sure we've got an array!
1734
+		if (! is_array($help_array)) {
1735
+			throw new EE_Error(
1736
+				esc_html__(
1737
+					'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1738
+					'event_espresso'
1739
+				)
1740
+			);
1741
+		}
1742
+		return $help_array;
1743
+	}
1744
+
1745
+
1746
+	/**
1747
+	 * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1748
+	 * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1749
+	 * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1750
+	 *
1751
+	 * @param string  $trigger_id reference for retrieving the trigger content for the popup
1752
+	 * @param boolean $display    if false then we return the trigger string
1753
+	 * @param array   $dimensions an array of dimensions for the box (array(h,w))
1754
+	 * @return string
1755
+	 * @throws DomainException
1756
+	 * @throws EE_Error
1757
+	 */
1758
+	protected function _set_help_trigger($trigger_id, $display = true, $dimensions = ['400', '640'])
1759
+	{
1760
+		if ($this->request->isAjax()) {
1761
+			return '';
1762
+		}
1763
+		// let's check and see if there is any content set for this popup.  If there isn't then we'll include a default title and content so that developers know something needs to be corrected
1764
+		$help_array   = $this->_get_help_content();
1765
+		$help_content = '';
1766
+		if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1767
+			$help_array[ $trigger_id ] = [
1768
+				'title'   => esc_html__('Missing Content', 'event_espresso'),
1769
+				'content' => esc_html__(
1770
+					'A trigger has been set that doesn\'t have any corresponding content. Make sure you have set the help content. (see the "_set_help_popup_content" method in the EE_Admin_Page for instructions.)',
1771
+					'event_espresso'
1772
+				),
1773
+			];
1774
+			$help_content = $this->_set_help_popup_content($help_array);
1775
+		}
1776
+		// let's setup the trigger
1777
+		$content = '<a class="ee-dialog" href="?height='
1778
+				   . esc_attr($dimensions[0])
1779
+				   . '&width='
1780
+				   . esc_attr($dimensions[1])
1781
+				   . '&inlineId='
1782
+				   . esc_attr($trigger_id)
1783
+				   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1784
+		$content .= $help_content;
1785
+		if ($display) {
1786
+			echo $content; // already escaped
1787
+			return '';
1788
+		}
1789
+		return $content;
1790
+	}
1791
+
1792
+
1793
+	/**
1794
+	 * _add_global_screen_options
1795
+	 * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1796
+	 * This particular method will add_screen_options on ALL EE_Admin Pages
1797
+	 *
1798
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1799
+	 *         see also WP_Screen object documents...
1800
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1801
+	 * @abstract
1802
+	 * @return void
1803
+	 */
1804
+	private function _add_global_screen_options()
1805
+	{
1806
+	}
1807
+
1808
+
1809
+	/**
1810
+	 * _add_global_feature_pointers
1811
+	 * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1812
+	 * This particular method will implement feature pointers for ALL EE_Admin pages.
1813
+	 * Note: this is just a placeholder for now.  Implementation will come down the road
1814
+	 *
1815
+	 * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1816
+	 *         extended) also see:
1817
+	 * @link   http://eamann.com/tech/wordpress-portland/
1818
+	 * @abstract
1819
+	 * @return void
1820
+	 */
1821
+	private function _add_global_feature_pointers()
1822
+	{
1823
+	}
1824
+
1825
+
1826
+	/**
1827
+	 * load_global_scripts_styles
1828
+	 * The scripts and styles enqueued in here will be loaded on every EE Admin page
1829
+	 *
1830
+	 * @return void
1831
+	 */
1832
+	public function load_global_scripts_styles()
1833
+	{
1834
+		// add debugging styles
1835
+		if (WP_DEBUG) {
1836
+			add_action('admin_head', [$this, 'add_xdebug_style']);
1837
+		}
1838
+		// taking care of metaboxes
1839
+		if (
1840
+			empty($this->_cpt_route)
1841
+			&& (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
1842
+		) {
1843
+			wp_enqueue_script('dashboard');
1844
+		}
1845
+
1846
+		wp_enqueue_script(JqueryAssetManager::JS_HANDLE_JQUERY_UI_TOUCH_PUNCH);
1847
+		wp_enqueue_script(EspressoLegacyAdminAssetManager::JS_HANDLE_EE_ADMIN);
1848
+		// LOCALIZED DATA
1849
+		// localize script for ajax lazy loading
1850
+		wp_localize_script(
1851
+			EspressoLegacyAdminAssetManager::JS_HANDLE_EE_ADMIN,
1852
+			'eeLazyLoadingContainers',
1853
+			apply_filters(
1854
+				'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
1855
+				['espresso_news_post_box_content']
1856
+			)
1857
+		);
1858
+		add_filter(
1859
+			'admin_body_class',
1860
+			function ($classes) {
1861
+				if (strpos($classes, 'espresso-admin') === false) {
1862
+					$classes .= ' espresso-admin';
1863
+				}
1864
+				return $classes;
1865
+			}
1866
+		);
1867
+	}
1868
+
1869
+
1870
+	/**
1871
+	 *        admin_footer_scripts_eei18n_js_strings
1872
+	 *
1873
+	 * @return        void
1874
+	 */
1875
+	public function admin_footer_scripts_eei18n_js_strings()
1876
+	{
1877
+		EE_Registry::$i18n_js_strings['ajax_url']       = WP_AJAX_URL;
1878
+		EE_Registry::$i18n_js_strings['confirm_delete'] = wp_strip_all_tags(
1879
+			__(
1880
+				'Are you absolutely sure you want to delete this item?\nThis action will delete ALL DATA associated with this item!!!\nThis can NOT be undone!!!',
1881
+				'event_espresso'
1882
+			)
1883
+		);
1884
+		EE_Registry::$i18n_js_strings['January']        = wp_strip_all_tags(__('January', 'event_espresso'));
1885
+		EE_Registry::$i18n_js_strings['February']       = wp_strip_all_tags(__('February', 'event_espresso'));
1886
+		EE_Registry::$i18n_js_strings['March']          = wp_strip_all_tags(__('March', 'event_espresso'));
1887
+		EE_Registry::$i18n_js_strings['April']          = wp_strip_all_tags(__('April', 'event_espresso'));
1888
+		EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
1889
+		EE_Registry::$i18n_js_strings['June']           = wp_strip_all_tags(__('June', 'event_espresso'));
1890
+		EE_Registry::$i18n_js_strings['July']           = wp_strip_all_tags(__('July', 'event_espresso'));
1891
+		EE_Registry::$i18n_js_strings['August']         = wp_strip_all_tags(__('August', 'event_espresso'));
1892
+		EE_Registry::$i18n_js_strings['September']      = wp_strip_all_tags(__('September', 'event_espresso'));
1893
+		EE_Registry::$i18n_js_strings['October']        = wp_strip_all_tags(__('October', 'event_espresso'));
1894
+		EE_Registry::$i18n_js_strings['November']       = wp_strip_all_tags(__('November', 'event_espresso'));
1895
+		EE_Registry::$i18n_js_strings['December']       = wp_strip_all_tags(__('December', 'event_espresso'));
1896
+		EE_Registry::$i18n_js_strings['Jan']            = wp_strip_all_tags(__('Jan', 'event_espresso'));
1897
+		EE_Registry::$i18n_js_strings['Feb']            = wp_strip_all_tags(__('Feb', 'event_espresso'));
1898
+		EE_Registry::$i18n_js_strings['Mar']            = wp_strip_all_tags(__('Mar', 'event_espresso'));
1899
+		EE_Registry::$i18n_js_strings['Apr']            = wp_strip_all_tags(__('Apr', 'event_espresso'));
1900
+		EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
1901
+		EE_Registry::$i18n_js_strings['Jun']            = wp_strip_all_tags(__('Jun', 'event_espresso'));
1902
+		EE_Registry::$i18n_js_strings['Jul']            = wp_strip_all_tags(__('Jul', 'event_espresso'));
1903
+		EE_Registry::$i18n_js_strings['Aug']            = wp_strip_all_tags(__('Aug', 'event_espresso'));
1904
+		EE_Registry::$i18n_js_strings['Sep']            = wp_strip_all_tags(__('Sep', 'event_espresso'));
1905
+		EE_Registry::$i18n_js_strings['Oct']            = wp_strip_all_tags(__('Oct', 'event_espresso'));
1906
+		EE_Registry::$i18n_js_strings['Nov']            = wp_strip_all_tags(__('Nov', 'event_espresso'));
1907
+		EE_Registry::$i18n_js_strings['Dec']            = wp_strip_all_tags(__('Dec', 'event_espresso'));
1908
+		EE_Registry::$i18n_js_strings['Sunday']         = wp_strip_all_tags(__('Sunday', 'event_espresso'));
1909
+		EE_Registry::$i18n_js_strings['Monday']         = wp_strip_all_tags(__('Monday', 'event_espresso'));
1910
+		EE_Registry::$i18n_js_strings['Tuesday']        = wp_strip_all_tags(__('Tuesday', 'event_espresso'));
1911
+		EE_Registry::$i18n_js_strings['Wednesday']      = wp_strip_all_tags(__('Wednesday', 'event_espresso'));
1912
+		EE_Registry::$i18n_js_strings['Thursday']       = wp_strip_all_tags(__('Thursday', 'event_espresso'));
1913
+		EE_Registry::$i18n_js_strings['Friday']         = wp_strip_all_tags(__('Friday', 'event_espresso'));
1914
+		EE_Registry::$i18n_js_strings['Saturday']       = wp_strip_all_tags(__('Saturday', 'event_espresso'));
1915
+		EE_Registry::$i18n_js_strings['Sun']            = wp_strip_all_tags(__('Sun', 'event_espresso'));
1916
+		EE_Registry::$i18n_js_strings['Mon']            = wp_strip_all_tags(__('Mon', 'event_espresso'));
1917
+		EE_Registry::$i18n_js_strings['Tue']            = wp_strip_all_tags(__('Tue', 'event_espresso'));
1918
+		EE_Registry::$i18n_js_strings['Wed']            = wp_strip_all_tags(__('Wed', 'event_espresso'));
1919
+		EE_Registry::$i18n_js_strings['Thu']            = wp_strip_all_tags(__('Thu', 'event_espresso'));
1920
+		EE_Registry::$i18n_js_strings['Fri']            = wp_strip_all_tags(__('Fri', 'event_espresso'));
1921
+		EE_Registry::$i18n_js_strings['Sat']            = wp_strip_all_tags(__('Sat', 'event_espresso'));
1922
+	}
1923
+
1924
+
1925
+	/**
1926
+	 *        load enhanced xdebug styles for ppl with failing eyesight
1927
+	 *
1928
+	 * @return        void
1929
+	 */
1930
+	public function add_xdebug_style()
1931
+	{
1932
+		echo '<style>.xdebug-error { font-size:1.5em; }</style>';
1933
+	}
1934
+
1935
+
1936
+	/************************/
1937
+	/** LIST TABLE METHODS **/
1938
+	/************************/
1939
+	/**
1940
+	 * this sets up the list table if the current view requires it.
1941
+	 *
1942
+	 * @return void
1943
+	 * @throws EE_Error
1944
+	 * @throws InvalidArgumentException
1945
+	 * @throws InvalidDataTypeException
1946
+	 * @throws InvalidInterfaceException
1947
+	 */
1948
+	protected function _set_list_table()
1949
+	{
1950
+		// first is this a list_table view?
1951
+		if (! isset($this->_route_config['list_table'])) {
1952
+			return;
1953
+		} //not a list_table view so get out.
1954
+		// list table functions are per view specific (because some admin pages might have more than one list table!)
1955
+		$list_table_view = '_set_list_table_views_' . $this->_req_action;
1956
+		if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
1957
+			// user error msg
1958
+			$error_msg = esc_html__(
1959
+				'An error occurred. The requested list table views could not be found.',
1960
+				'event_espresso'
1961
+			);
1962
+			// developer error msg
1963
+			$error_msg .= '||'
1964
+						  . sprintf(
1965
+							  esc_html__(
1966
+								  'List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.',
1967
+								  'event_espresso'
1968
+							  ),
1969
+							  $this->_req_action,
1970
+							  $list_table_view
1971
+						  );
1972
+			throw new EE_Error($error_msg);
1973
+		}
1974
+		// let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
1975
+		$this->_views = apply_filters(
1976
+			'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
1977
+			$this->_views
1978
+		);
1979
+		$this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
1980
+		$this->_views = apply_filters('FHEE_list_table_views', $this->_views);
1981
+		$this->_set_list_table_view();
1982
+		$this->_set_list_table_object();
1983
+	}
1984
+
1985
+
1986
+	/**
1987
+	 * set current view for List Table
1988
+	 *
1989
+	 * @return void
1990
+	 */
1991
+	protected function _set_list_table_view()
1992
+	{
1993
+		$this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
1994
+		$status = $this->request->getRequestParam('status', null, 'key');
1995
+		$this->_view = $status && array_key_exists($status, $this->_views)
1996
+			? $status
1997
+			: $this->_view;
1998
+	}
1999
+
2000
+
2001
+	/**
2002
+	 * _set_list_table_object
2003
+	 * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
2004
+	 *
2005
+	 * @throws InvalidInterfaceException
2006
+	 * @throws InvalidArgumentException
2007
+	 * @throws InvalidDataTypeException
2008
+	 * @throws EE_Error
2009
+	 * @throws InvalidInterfaceException
2010
+	 */
2011
+	protected function _set_list_table_object()
2012
+	{
2013
+		if (isset($this->_route_config['list_table'])) {
2014
+			if (! class_exists($this->_route_config['list_table'])) {
2015
+				throw new EE_Error(
2016
+					sprintf(
2017
+						esc_html__(
2018
+							'The %s class defined for the list table does not exist.  Please check the spelling of the class ref in the $_page_config property on %s.',
2019
+							'event_espresso'
2020
+						),
2021
+						$this->_route_config['list_table'],
2022
+						get_class($this)
2023
+					)
2024
+				);
2025
+			}
2026
+			$this->_list_table_object = $this->loader->getShared(
2027
+				$this->_route_config['list_table'],
2028
+				[$this]
2029
+			);
2030
+		}
2031
+	}
2032
+
2033
+
2034
+	/**
2035
+	 * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2036
+	 *
2037
+	 * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2038
+	 *                                                    urls.  The array should be indexed by the view it is being
2039
+	 *                                                    added to.
2040
+	 * @return array
2041
+	 */
2042
+	public function get_list_table_view_RLs($extra_query_args = [])
2043
+	{
2044
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2045
+		if (empty($this->_views)) {
2046
+			$this->_views = [];
2047
+		}
2048
+		// cycle thru views
2049
+		foreach ($this->_views as $key => $view) {
2050
+			$query_args = [];
2051
+			// check for current view
2052
+			$this->_views[ $key ]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2053
+			$query_args['action']                        = $this->_req_action;
2054
+			$query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2055
+			$query_args['status']                        = $view['slug'];
2056
+			// merge any other arguments sent in.
2057
+			if (isset($extra_query_args[ $view['slug'] ])) {
2058
+				foreach ($extra_query_args[ $view['slug'] ] as $extra_query_arg) {
2059
+					$query_args[] = $extra_query_arg;
2060
+				}
2061
+			}
2062
+			$this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2063
+		}
2064
+		return $this->_views;
2065
+	}
2066
+
2067
+
2068
+	/**
2069
+	 * _entries_per_page_dropdown
2070
+	 * generates a dropdown box for selecting the number of visible rows in an admin page list table
2071
+	 *
2072
+	 * @param int $max_entries total number of rows in the table
2073
+	 * @return string
2074
+	 * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2075
+	 *         WP does it.
2076
+	 */
2077
+	protected function _entries_per_page_dropdown($max_entries = 0)
2078
+	{
2079
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2080
+		$values   = [10, 25, 50, 100];
2081
+		$per_page = $this->request->getRequestParam('per_page', 10, 'int');
2082
+		if ($max_entries) {
2083
+			$values[] = $max_entries;
2084
+			sort($values);
2085
+		}
2086
+		$entries_per_page_dropdown = '
2087 2087
 			<div id="entries-per-page-dv" class="alignleft actions">
2088 2088
 				<label class="hide-if-no-js">
2089 2089
 					Show
2090 2090
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
2091
-        foreach ($values as $value) {
2092
-            if ($value < $max_entries) {
2093
-                $selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2094
-                $entries_per_page_dropdown .= '
2091
+		foreach ($values as $value) {
2092
+			if ($value < $max_entries) {
2093
+				$selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2094
+				$entries_per_page_dropdown .= '
2095 2095
 						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
2096
-            }
2097
-        }
2098
-        $selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2099
-        $entries_per_page_dropdown .= '
2096
+			}
2097
+		}
2098
+		$selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2099
+		$entries_per_page_dropdown .= '
2100 2100
 						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
2101
-        $entries_per_page_dropdown .= '
2101
+		$entries_per_page_dropdown .= '
2102 2102
 					</select>
2103 2103
 					entries
2104 2104
 				</label>
2105 2105
 				<input id="entries-per-page-btn" class="button button--secondary" type="submit" value="Go" >
2106 2106
 			</div>
2107 2107
 		';
2108
-        return $entries_per_page_dropdown;
2109
-    }
2110
-
2111
-
2112
-    /**
2113
-     *        _set_search_attributes
2114
-     *
2115
-     * @return        void
2116
-     */
2117
-    public function _set_search_attributes()
2118
-    {
2119
-        $this->_template_args['search']['btn_label'] = sprintf(
2120
-            esc_html__('Search %s', 'event_espresso'),
2121
-            empty($this->_search_btn_label) ? $this->page_label
2122
-                : $this->_search_btn_label
2123
-        );
2124
-        $this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2125
-    }
2126
-
2127
-
2128
-
2129
-    /*** END LIST TABLE METHODS **/
2130
-
2131
-
2132
-    /**
2133
-     * _add_registered_metaboxes
2134
-     *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2135
-     *
2136
-     * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2137
-     * @return void
2138
-     * @throws EE_Error
2139
-     */
2140
-    private function _add_registered_meta_boxes()
2141
-    {
2142
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2143
-        // we only add meta boxes if the page_route calls for it
2144
-        if (
2145
-            is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2146
-            && is_array(
2147
-                $this->_route_config['metaboxes']
2148
-            )
2149
-        ) {
2150
-            // this simply loops through the callbacks provided
2151
-            // and checks if there is a corresponding callback registered by the child
2152
-            // if there is then we go ahead and process the metabox loader.
2153
-            foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2154
-                // first check for Closures
2155
-                if ($metabox_callback instanceof Closure) {
2156
-                    $result = $metabox_callback();
2157
-                } elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2158
-                    $result = call_user_func([$metabox_callback[0], $metabox_callback[1]]);
2159
-                } else {
2160
-                    $result = $this->{$metabox_callback}();
2161
-                }
2162
-                if ($result === false) {
2163
-                    // user error msg
2164
-                    $error_msg = esc_html__(
2165
-                        'An error occurred. The  requested metabox could not be found.',
2166
-                        'event_espresso'
2167
-                    );
2168
-                    // developer error msg
2169
-                    $error_msg .= '||'
2170
-                                  . sprintf(
2171
-                                      esc_html__(
2172
-                                          'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.',
2173
-                                          'event_espresso'
2174
-                                      ),
2175
-                                      $metabox_callback
2176
-                                  );
2177
-                    throw new EE_Error($error_msg);
2178
-                }
2179
-            }
2180
-        }
2181
-    }
2182
-
2183
-
2184
-    /**
2185
-     * _add_screen_columns
2186
-     * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2187
-     * the dynamic column template and we'll setup the column options for the page.
2188
-     *
2189
-     * @return void
2190
-     */
2191
-    private function _add_screen_columns()
2192
-    {
2193
-        if (
2194
-            is_array($this->_route_config)
2195
-            && isset($this->_route_config['columns'])
2196
-            && is_array($this->_route_config['columns'])
2197
-            && count($this->_route_config['columns']) === 2
2198
-        ) {
2199
-            add_screen_option(
2200
-                'layout_columns',
2201
-                [
2202
-                    'max'     => (int) $this->_route_config['columns'][0],
2203
-                    'default' => (int) $this->_route_config['columns'][1],
2204
-                ]
2205
-            );
2206
-            $this->_template_args['num_columns']                 = $this->_route_config['columns'][0];
2207
-            $screen_id                                           = $this->_current_screen->id;
2208
-            $screen_columns                                      = (int) get_user_option("screen_layout_{$screen_id}");
2209
-            $total_columns                                       = ! empty($screen_columns)
2210
-                ? $screen_columns
2211
-                : $this->_route_config['columns'][1];
2212
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2213
-            $this->_template_args['current_page']                = $this->_wp_page_slug;
2214
-            $this->_template_args['screen']                      = $this->_current_screen;
2215
-            $this->_column_template_path                         = EE_ADMIN_TEMPLATE
2216
-                                                                   . 'admin_details_metabox_column_wrapper.template.php';
2217
-            // finally if we don't have has_metaboxes set in the route config
2218
-            // let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2219
-            $this->_route_config['has_metaboxes'] = true;
2220
-        }
2221
-    }
2222
-
2223
-
2224
-
2225
-    /** GLOBALLY AVAILABLE METABOXES **/
2226
-
2227
-
2228
-    /**
2229
-     * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2230
-     * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2231
-     * these get loaded on.
2232
-     */
2233
-    private function _espresso_news_post_box()
2234
-    {
2235
-        $news_box_title = apply_filters(
2236
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2237
-            esc_html__('New @ Event Espresso', 'event_espresso')
2238
-        );
2239
-        $this->addMetaBox(
2240
-            'espresso_news_post_box',
2241
-            $news_box_title,
2242
-            [
2243
-                $this,
2244
-                'espresso_news_post_box',
2245
-            ],
2246
-            $this->_wp_page_slug,
2247
-            'side',
2248
-            'low'
2249
-        );
2250
-    }
2251
-
2252
-
2253
-    /**
2254
-     * Code for setting up espresso ratings request metabox.
2255
-     */
2256
-    protected function _espresso_ratings_request()
2257
-    {
2258
-        if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2259
-            return;
2260
-        }
2261
-        $ratings_box_title = apply_filters(
2262
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2263
-            esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2264
-        );
2265
-        $this->addMetaBox(
2266
-            'espresso_ratings_request',
2267
-            $ratings_box_title,
2268
-            [
2269
-                $this,
2270
-                'espresso_ratings_request',
2271
-            ],
2272
-            $this->_wp_page_slug,
2273
-            'side'
2274
-        );
2275
-    }
2276
-
2277
-
2278
-    /**
2279
-     * Code for setting up espresso ratings request metabox content.
2280
-     *
2281
-     * @throws DomainException
2282
-     */
2283
-    public function espresso_ratings_request()
2284
-    {
2285
-        EEH_Template::display_template(EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php');
2286
-    }
2287
-
2288
-
2289
-    public static function cached_rss_display($rss_id, $url)
2290
-    {
2291
-        $loading   = '<p class="widget-loading hide-if-no-js">'
2292
-                     . esc_html__('Loading&#8230;', 'event_espresso')
2293
-                     . '</p><p class="hide-if-js">'
2294
-                     . esc_html__('This widget requires JavaScript.', 'event_espresso')
2295
-                     . '</p>';
2296
-        $pre       = '<div class="espresso-rss-display">' . "\n\t";
2297
-        $pre       .= '<span id="' . esc_attr($rss_id) . '_url" class="hidden">' . esc_url_raw($url) . '</span>';
2298
-        $post      = '</div>' . "\n";
2299
-        $cache_key = 'ee_rss_' . md5($rss_id);
2300
-        $output    = get_transient($cache_key);
2301
-        if ($output !== false) {
2302
-            echo $pre . $output . $post; // already escaped
2303
-            return true;
2304
-        }
2305
-        if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2306
-            echo $pre . $loading . $post; // already escaped
2307
-            return false;
2308
-        }
2309
-        ob_start();
2310
-        wp_widget_rss_output($url, ['show_date' => 0, 'items' => 5]);
2311
-        set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2312
-        return true;
2313
-    }
2314
-
2315
-
2316
-    public function espresso_news_post_box()
2317
-    {
2318
-        ?>
2108
+		return $entries_per_page_dropdown;
2109
+	}
2110
+
2111
+
2112
+	/**
2113
+	 *        _set_search_attributes
2114
+	 *
2115
+	 * @return        void
2116
+	 */
2117
+	public function _set_search_attributes()
2118
+	{
2119
+		$this->_template_args['search']['btn_label'] = sprintf(
2120
+			esc_html__('Search %s', 'event_espresso'),
2121
+			empty($this->_search_btn_label) ? $this->page_label
2122
+				: $this->_search_btn_label
2123
+		);
2124
+		$this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2125
+	}
2126
+
2127
+
2128
+
2129
+	/*** END LIST TABLE METHODS **/
2130
+
2131
+
2132
+	/**
2133
+	 * _add_registered_metaboxes
2134
+	 *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2135
+	 *
2136
+	 * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2137
+	 * @return void
2138
+	 * @throws EE_Error
2139
+	 */
2140
+	private function _add_registered_meta_boxes()
2141
+	{
2142
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2143
+		// we only add meta boxes if the page_route calls for it
2144
+		if (
2145
+			is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2146
+			&& is_array(
2147
+				$this->_route_config['metaboxes']
2148
+			)
2149
+		) {
2150
+			// this simply loops through the callbacks provided
2151
+			// and checks if there is a corresponding callback registered by the child
2152
+			// if there is then we go ahead and process the metabox loader.
2153
+			foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2154
+				// first check for Closures
2155
+				if ($metabox_callback instanceof Closure) {
2156
+					$result = $metabox_callback();
2157
+				} elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2158
+					$result = call_user_func([$metabox_callback[0], $metabox_callback[1]]);
2159
+				} else {
2160
+					$result = $this->{$metabox_callback}();
2161
+				}
2162
+				if ($result === false) {
2163
+					// user error msg
2164
+					$error_msg = esc_html__(
2165
+						'An error occurred. The  requested metabox could not be found.',
2166
+						'event_espresso'
2167
+					);
2168
+					// developer error msg
2169
+					$error_msg .= '||'
2170
+								  . sprintf(
2171
+									  esc_html__(
2172
+										  'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.',
2173
+										  'event_espresso'
2174
+									  ),
2175
+									  $metabox_callback
2176
+								  );
2177
+					throw new EE_Error($error_msg);
2178
+				}
2179
+			}
2180
+		}
2181
+	}
2182
+
2183
+
2184
+	/**
2185
+	 * _add_screen_columns
2186
+	 * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2187
+	 * the dynamic column template and we'll setup the column options for the page.
2188
+	 *
2189
+	 * @return void
2190
+	 */
2191
+	private function _add_screen_columns()
2192
+	{
2193
+		if (
2194
+			is_array($this->_route_config)
2195
+			&& isset($this->_route_config['columns'])
2196
+			&& is_array($this->_route_config['columns'])
2197
+			&& count($this->_route_config['columns']) === 2
2198
+		) {
2199
+			add_screen_option(
2200
+				'layout_columns',
2201
+				[
2202
+					'max'     => (int) $this->_route_config['columns'][0],
2203
+					'default' => (int) $this->_route_config['columns'][1],
2204
+				]
2205
+			);
2206
+			$this->_template_args['num_columns']                 = $this->_route_config['columns'][0];
2207
+			$screen_id                                           = $this->_current_screen->id;
2208
+			$screen_columns                                      = (int) get_user_option("screen_layout_{$screen_id}");
2209
+			$total_columns                                       = ! empty($screen_columns)
2210
+				? $screen_columns
2211
+				: $this->_route_config['columns'][1];
2212
+			$this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2213
+			$this->_template_args['current_page']                = $this->_wp_page_slug;
2214
+			$this->_template_args['screen']                      = $this->_current_screen;
2215
+			$this->_column_template_path                         = EE_ADMIN_TEMPLATE
2216
+																   . 'admin_details_metabox_column_wrapper.template.php';
2217
+			// finally if we don't have has_metaboxes set in the route config
2218
+			// let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2219
+			$this->_route_config['has_metaboxes'] = true;
2220
+		}
2221
+	}
2222
+
2223
+
2224
+
2225
+	/** GLOBALLY AVAILABLE METABOXES **/
2226
+
2227
+
2228
+	/**
2229
+	 * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2230
+	 * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2231
+	 * these get loaded on.
2232
+	 */
2233
+	private function _espresso_news_post_box()
2234
+	{
2235
+		$news_box_title = apply_filters(
2236
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2237
+			esc_html__('New @ Event Espresso', 'event_espresso')
2238
+		);
2239
+		$this->addMetaBox(
2240
+			'espresso_news_post_box',
2241
+			$news_box_title,
2242
+			[
2243
+				$this,
2244
+				'espresso_news_post_box',
2245
+			],
2246
+			$this->_wp_page_slug,
2247
+			'side',
2248
+			'low'
2249
+		);
2250
+	}
2251
+
2252
+
2253
+	/**
2254
+	 * Code for setting up espresso ratings request metabox.
2255
+	 */
2256
+	protected function _espresso_ratings_request()
2257
+	{
2258
+		if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2259
+			return;
2260
+		}
2261
+		$ratings_box_title = apply_filters(
2262
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2263
+			esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2264
+		);
2265
+		$this->addMetaBox(
2266
+			'espresso_ratings_request',
2267
+			$ratings_box_title,
2268
+			[
2269
+				$this,
2270
+				'espresso_ratings_request',
2271
+			],
2272
+			$this->_wp_page_slug,
2273
+			'side'
2274
+		);
2275
+	}
2276
+
2277
+
2278
+	/**
2279
+	 * Code for setting up espresso ratings request metabox content.
2280
+	 *
2281
+	 * @throws DomainException
2282
+	 */
2283
+	public function espresso_ratings_request()
2284
+	{
2285
+		EEH_Template::display_template(EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php');
2286
+	}
2287
+
2288
+
2289
+	public static function cached_rss_display($rss_id, $url)
2290
+	{
2291
+		$loading   = '<p class="widget-loading hide-if-no-js">'
2292
+					 . esc_html__('Loading&#8230;', 'event_espresso')
2293
+					 . '</p><p class="hide-if-js">'
2294
+					 . esc_html__('This widget requires JavaScript.', 'event_espresso')
2295
+					 . '</p>';
2296
+		$pre       = '<div class="espresso-rss-display">' . "\n\t";
2297
+		$pre       .= '<span id="' . esc_attr($rss_id) . '_url" class="hidden">' . esc_url_raw($url) . '</span>';
2298
+		$post      = '</div>' . "\n";
2299
+		$cache_key = 'ee_rss_' . md5($rss_id);
2300
+		$output    = get_transient($cache_key);
2301
+		if ($output !== false) {
2302
+			echo $pre . $output . $post; // already escaped
2303
+			return true;
2304
+		}
2305
+		if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2306
+			echo $pre . $loading . $post; // already escaped
2307
+			return false;
2308
+		}
2309
+		ob_start();
2310
+		wp_widget_rss_output($url, ['show_date' => 0, 'items' => 5]);
2311
+		set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2312
+		return true;
2313
+	}
2314
+
2315
+
2316
+	public function espresso_news_post_box()
2317
+	{
2318
+		?>
2319 2319
         <div class="padding">
2320 2320
             <div id="espresso_news_post_box_content" class="infolinks">
2321 2321
                 <?php
2322
-                // Get RSS Feed(s)
2323
-                EE_Admin_Page::cached_rss_display(
2324
-                    'espresso_news_post_box_content',
2325
-                    esc_url_raw(
2326
-                        apply_filters(
2327
-                            'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2328
-                            'https://eventespresso.com/feed/'
2329
-                        )
2330
-                    )
2331
-                );
2332
-                ?>
2322
+				// Get RSS Feed(s)
2323
+				EE_Admin_Page::cached_rss_display(
2324
+					'espresso_news_post_box_content',
2325
+					esc_url_raw(
2326
+						apply_filters(
2327
+							'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2328
+							'https://eventespresso.com/feed/'
2329
+						)
2330
+					)
2331
+				);
2332
+				?>
2333 2333
             </div>
2334 2334
             <?php do_action('AHEE__EE_Admin_Page__espresso_news_post_box__after_content'); ?>
2335 2335
         </div>
2336 2336
         <?php
2337
-    }
2338
-
2339
-
2340
-    private function _espresso_links_post_box()
2341
-    {
2342
-        // Hiding until we actually have content to put in here...
2343
-        // $this->addMetaBox('espresso_links_post_box', esc_html__('Helpful Plugin Links', 'event_espresso'), array( $this, 'espresso_links_post_box'), $this->_wp_page_slug, 'side');
2344
-    }
2345
-
2346
-
2347
-    public function espresso_links_post_box()
2348
-    {
2349
-        // Hiding until we actually have content to put in here...
2350
-        // EEH_Template::display_template(
2351
-        //     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2352
-        // );
2353
-    }
2354
-
2355
-
2356
-    protected function _espresso_sponsors_post_box()
2357
-    {
2358
-        if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2359
-            $this->addMetaBox(
2360
-                'espresso_sponsors_post_box',
2361
-                esc_html__('Event Espresso Highlights', 'event_espresso'),
2362
-                [$this, 'espresso_sponsors_post_box'],
2363
-                $this->_wp_page_slug,
2364
-                'side'
2365
-            );
2366
-        }
2367
-    }
2368
-
2369
-
2370
-    public function espresso_sponsors_post_box()
2371
-    {
2372
-        EEH_Template::display_template(
2373
-            EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2374
-        );
2375
-    }
2376
-
2377
-
2378
-    private function _publish_post_box()
2379
-    {
2380
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2381
-        // if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2382
-        // then we'll use that for the metabox label.
2383
-        // Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2384
-        if (! empty($this->_labels['publishbox'])) {
2385
-            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2386
-                : $this->_labels['publishbox'];
2387
-        } else {
2388
-            $box_label = esc_html__('Publish', 'event_espresso');
2389
-        }
2390
-        $box_label = apply_filters(
2391
-            'FHEE__EE_Admin_Page___publish_post_box__box_label',
2392
-            $box_label,
2393
-            $this->_req_action,
2394
-            $this
2395
-        );
2396
-        $this->addMetaBox(
2397
-            $meta_box_ref,
2398
-            $box_label,
2399
-            [$this, 'editor_overview'],
2400
-            $this->_current_screen->id,
2401
-            'side',
2402
-            'high'
2403
-        );
2404
-    }
2405
-
2406
-
2407
-    public function editor_overview()
2408
-    {
2409
-        // if we have extra content set let's add it in if not make sure its empty
2410
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2411
-            ? $this->_template_args['publish_box_extra_content']
2412
-            : '';
2413
-        echo EEH_Template::display_template(
2414
-            EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2415
-            $this->_template_args,
2416
-            true
2417
-        );
2418
-    }
2419
-
2420
-
2421
-    /** end of globally available metaboxes section **/
2422
-
2423
-
2424
-    /**
2425
-     * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2426
-     * protected method.
2427
-     *
2428
-     * @param string $name
2429
-     * @param int    $id
2430
-     * @param bool   $delete
2431
-     * @param string $save_close_redirect_URL
2432
-     * @param bool   $both_btns
2433
-     * @throws EE_Error
2434
-     * @throws InvalidArgumentException
2435
-     * @throws InvalidDataTypeException
2436
-     * @throws InvalidInterfaceException
2437
-     * @see   $this->_set_publish_post_box_vars for param details
2438
-     * @since 4.6.0
2439
-     */
2440
-    public function set_publish_post_box_vars(
2441
-        $name = '',
2442
-        $id = 0,
2443
-        $delete = false,
2444
-        $save_close_redirect_URL = '',
2445
-        $both_btns = true
2446
-    ) {
2447
-        $this->_set_publish_post_box_vars(
2448
-            $name,
2449
-            $id,
2450
-            $delete,
2451
-            $save_close_redirect_URL,
2452
-            $both_btns
2453
-        );
2454
-    }
2455
-
2456
-
2457
-    /**
2458
-     * Sets the _template_args arguments used by the _publish_post_box shortcut
2459
-     * Note: currently there is no validation for this.  However if you want the delete button, the
2460
-     * save, and save and close buttons to work properly, then you will want to include a
2461
-     * values for the name and id arguments.
2462
-     *
2463
-     * @param string  $name                       key used for the action ID (i.e. event_id)
2464
-     * @param int     $id                         id attached to the item published
2465
-     * @param string  $delete                     page route callback for the delete action
2466
-     * @param string  $save_close_redirect_URL    custom URL to redirect to after Save & Close has been completed
2467
-     * @param boolean $both_btns                  whether to display BOTH the "Save & Close" and "Save" buttons or just
2468
-     *                                            the Save button
2469
-     * @throws EE_Error
2470
-     * @throws InvalidArgumentException
2471
-     * @throws InvalidDataTypeException
2472
-     * @throws InvalidInterfaceException
2473
-     * @todo  Add in validation for name/id arguments.
2474
-     */
2475
-    protected function _set_publish_post_box_vars(
2476
-        $name = '',
2477
-        $id = 0,
2478
-        $delete = '',
2479
-        $save_close_redirect_URL = '',
2480
-        $both_btns = true
2481
-    ) {
2482
-        // if Save & Close, use a custom redirect URL or default to the main page?
2483
-        $save_close_redirect_URL = ! empty($save_close_redirect_URL)
2484
-            ? $save_close_redirect_URL
2485
-            : $this->_admin_base_url;
2486
-        // create the Save & Close and Save buttons
2487
-        $this->_set_save_buttons($both_btns, [], [], $save_close_redirect_URL);
2488
-        // if we have extra content set let's add it in if not make sure its empty
2489
-        $this->_template_args['publish_box_extra_content'] = $this->_template_args['publish_box_extra_content'] ?? '';
2490
-        $delete_link = '';
2491
-        if ($delete && ! empty($id)) {
2492
-            // make sure we have a default if just true is sent.
2493
-            $delete           = ! empty($delete) ? $delete : 'delete';
2494
-            $delete_link      = $this->get_action_link_or_button(
2495
-                $delete,
2496
-                $delete,
2497
-                [$name => $id],
2498
-                'submitdelete deletion button button--small  button--outline button--caution'
2499
-            );
2500
-        }
2501
-        $this->_template_args['publish_delete_link'] = $delete_link;
2502
-        if (! empty($name) && ! empty($id)) {
2503
-            $hidden_field_arr[ $name ] = [
2504
-                'type'  => 'hidden',
2505
-                'value' => $id,
2506
-            ];
2507
-            $hf                        = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2508
-        } else {
2509
-            $hf = '';
2510
-        }
2511
-        // add hidden field
2512
-        $this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2513
-            ? $hf[ $name ]['field']
2514
-            : $hf;
2515
-    }
2516
-
2517
-
2518
-    /**
2519
-     * displays an error message to ppl who have javascript disabled
2520
-     *
2521
-     * @return void
2522
-     */
2523
-    private function _display_no_javascript_warning()
2524
-    {
2525
-        ?>
2337
+	}
2338
+
2339
+
2340
+	private function _espresso_links_post_box()
2341
+	{
2342
+		// Hiding until we actually have content to put in here...
2343
+		// $this->addMetaBox('espresso_links_post_box', esc_html__('Helpful Plugin Links', 'event_espresso'), array( $this, 'espresso_links_post_box'), $this->_wp_page_slug, 'side');
2344
+	}
2345
+
2346
+
2347
+	public function espresso_links_post_box()
2348
+	{
2349
+		// Hiding until we actually have content to put in here...
2350
+		// EEH_Template::display_template(
2351
+		//     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2352
+		// );
2353
+	}
2354
+
2355
+
2356
+	protected function _espresso_sponsors_post_box()
2357
+	{
2358
+		if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2359
+			$this->addMetaBox(
2360
+				'espresso_sponsors_post_box',
2361
+				esc_html__('Event Espresso Highlights', 'event_espresso'),
2362
+				[$this, 'espresso_sponsors_post_box'],
2363
+				$this->_wp_page_slug,
2364
+				'side'
2365
+			);
2366
+		}
2367
+	}
2368
+
2369
+
2370
+	public function espresso_sponsors_post_box()
2371
+	{
2372
+		EEH_Template::display_template(
2373
+			EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2374
+		);
2375
+	}
2376
+
2377
+
2378
+	private function _publish_post_box()
2379
+	{
2380
+		$meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2381
+		// if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2382
+		// then we'll use that for the metabox label.
2383
+		// Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2384
+		if (! empty($this->_labels['publishbox'])) {
2385
+			$box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2386
+				: $this->_labels['publishbox'];
2387
+		} else {
2388
+			$box_label = esc_html__('Publish', 'event_espresso');
2389
+		}
2390
+		$box_label = apply_filters(
2391
+			'FHEE__EE_Admin_Page___publish_post_box__box_label',
2392
+			$box_label,
2393
+			$this->_req_action,
2394
+			$this
2395
+		);
2396
+		$this->addMetaBox(
2397
+			$meta_box_ref,
2398
+			$box_label,
2399
+			[$this, 'editor_overview'],
2400
+			$this->_current_screen->id,
2401
+			'side',
2402
+			'high'
2403
+		);
2404
+	}
2405
+
2406
+
2407
+	public function editor_overview()
2408
+	{
2409
+		// if we have extra content set let's add it in if not make sure its empty
2410
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2411
+			? $this->_template_args['publish_box_extra_content']
2412
+			: '';
2413
+		echo EEH_Template::display_template(
2414
+			EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2415
+			$this->_template_args,
2416
+			true
2417
+		);
2418
+	}
2419
+
2420
+
2421
+	/** end of globally available metaboxes section **/
2422
+
2423
+
2424
+	/**
2425
+	 * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2426
+	 * protected method.
2427
+	 *
2428
+	 * @param string $name
2429
+	 * @param int    $id
2430
+	 * @param bool   $delete
2431
+	 * @param string $save_close_redirect_URL
2432
+	 * @param bool   $both_btns
2433
+	 * @throws EE_Error
2434
+	 * @throws InvalidArgumentException
2435
+	 * @throws InvalidDataTypeException
2436
+	 * @throws InvalidInterfaceException
2437
+	 * @see   $this->_set_publish_post_box_vars for param details
2438
+	 * @since 4.6.0
2439
+	 */
2440
+	public function set_publish_post_box_vars(
2441
+		$name = '',
2442
+		$id = 0,
2443
+		$delete = false,
2444
+		$save_close_redirect_URL = '',
2445
+		$both_btns = true
2446
+	) {
2447
+		$this->_set_publish_post_box_vars(
2448
+			$name,
2449
+			$id,
2450
+			$delete,
2451
+			$save_close_redirect_URL,
2452
+			$both_btns
2453
+		);
2454
+	}
2455
+
2456
+
2457
+	/**
2458
+	 * Sets the _template_args arguments used by the _publish_post_box shortcut
2459
+	 * Note: currently there is no validation for this.  However if you want the delete button, the
2460
+	 * save, and save and close buttons to work properly, then you will want to include a
2461
+	 * values for the name and id arguments.
2462
+	 *
2463
+	 * @param string  $name                       key used for the action ID (i.e. event_id)
2464
+	 * @param int     $id                         id attached to the item published
2465
+	 * @param string  $delete                     page route callback for the delete action
2466
+	 * @param string  $save_close_redirect_URL    custom URL to redirect to after Save & Close has been completed
2467
+	 * @param boolean $both_btns                  whether to display BOTH the "Save & Close" and "Save" buttons or just
2468
+	 *                                            the Save button
2469
+	 * @throws EE_Error
2470
+	 * @throws InvalidArgumentException
2471
+	 * @throws InvalidDataTypeException
2472
+	 * @throws InvalidInterfaceException
2473
+	 * @todo  Add in validation for name/id arguments.
2474
+	 */
2475
+	protected function _set_publish_post_box_vars(
2476
+		$name = '',
2477
+		$id = 0,
2478
+		$delete = '',
2479
+		$save_close_redirect_URL = '',
2480
+		$both_btns = true
2481
+	) {
2482
+		// if Save & Close, use a custom redirect URL or default to the main page?
2483
+		$save_close_redirect_URL = ! empty($save_close_redirect_URL)
2484
+			? $save_close_redirect_URL
2485
+			: $this->_admin_base_url;
2486
+		// create the Save & Close and Save buttons
2487
+		$this->_set_save_buttons($both_btns, [], [], $save_close_redirect_URL);
2488
+		// if we have extra content set let's add it in if not make sure its empty
2489
+		$this->_template_args['publish_box_extra_content'] = $this->_template_args['publish_box_extra_content'] ?? '';
2490
+		$delete_link = '';
2491
+		if ($delete && ! empty($id)) {
2492
+			// make sure we have a default if just true is sent.
2493
+			$delete           = ! empty($delete) ? $delete : 'delete';
2494
+			$delete_link      = $this->get_action_link_or_button(
2495
+				$delete,
2496
+				$delete,
2497
+				[$name => $id],
2498
+				'submitdelete deletion button button--small  button--outline button--caution'
2499
+			);
2500
+		}
2501
+		$this->_template_args['publish_delete_link'] = $delete_link;
2502
+		if (! empty($name) && ! empty($id)) {
2503
+			$hidden_field_arr[ $name ] = [
2504
+				'type'  => 'hidden',
2505
+				'value' => $id,
2506
+			];
2507
+			$hf                        = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2508
+		} else {
2509
+			$hf = '';
2510
+		}
2511
+		// add hidden field
2512
+		$this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2513
+			? $hf[ $name ]['field']
2514
+			: $hf;
2515
+	}
2516
+
2517
+
2518
+	/**
2519
+	 * displays an error message to ppl who have javascript disabled
2520
+	 *
2521
+	 * @return void
2522
+	 */
2523
+	private function _display_no_javascript_warning()
2524
+	{
2525
+		?>
2526 2526
         <noscript>
2527 2527
             <div id="no-js-message" class="error">
2528 2528
                 <p style="font-size:1.3em;">
2529 2529
                     <span style="color:red;"><?php esc_html_e('Warning!', 'event_espresso'); ?></span>
2530 2530
                     <?php esc_html_e(
2531
-                        'Javascript is currently turned off for your browser. Javascript must be enabled in order for all of the features on this page to function properly. Please turn your javascript back on.',
2532
-                        'event_espresso'
2533
-                    ); ?>
2531
+						'Javascript is currently turned off for your browser. Javascript must be enabled in order for all of the features on this page to function properly. Please turn your javascript back on.',
2532
+						'event_espresso'
2533
+					); ?>
2534 2534
                 </p>
2535 2535
             </div>
2536 2536
         </noscript>
2537 2537
         <?php
2538
-    }
2539
-
2540
-
2541
-    /**
2542
-     * displays espresso success and/or error notices
2543
-     *
2544
-     * @return void
2545
-     */
2546
-    protected function _display_espresso_notices()
2547
-    {
2548
-        $notices = $this->_get_transient(true);
2549
-        echo stripslashes($notices);
2550
-    }
2551
-
2552
-
2553
-    /**
2554
-     * spinny things pacify the masses
2555
-     *
2556
-     * @return void
2557
-     */
2558
-    protected function _add_admin_page_ajax_loading_img()
2559
-    {
2560
-        ?>
2538
+	}
2539
+
2540
+
2541
+	/**
2542
+	 * displays espresso success and/or error notices
2543
+	 *
2544
+	 * @return void
2545
+	 */
2546
+	protected function _display_espresso_notices()
2547
+	{
2548
+		$notices = $this->_get_transient(true);
2549
+		echo stripslashes($notices);
2550
+	}
2551
+
2552
+
2553
+	/**
2554
+	 * spinny things pacify the masses
2555
+	 *
2556
+	 * @return void
2557
+	 */
2558
+	protected function _add_admin_page_ajax_loading_img()
2559
+	{
2560
+		?>
2561 2561
         <div id="espresso-ajax-loading" class="ajax-loading-grey">
2562 2562
             <span class="ee-spinner ee-spin"></span><span class="hidden"><?php
2563
-                esc_html_e('loading...', 'event_espresso'); ?></span>
2563
+				esc_html_e('loading...', 'event_espresso'); ?></span>
2564 2564
         </div>
2565 2565
         <?php
2566
-    }
2566
+	}
2567 2567
 
2568 2568
 
2569
-    /**
2570
-     * add admin page overlay for modal boxes
2571
-     *
2572
-     * @return void
2573
-     */
2574
-    protected function _add_admin_page_overlay()
2575
-    {
2576
-        ?>
2569
+	/**
2570
+	 * add admin page overlay for modal boxes
2571
+	 *
2572
+	 * @return void
2573
+	 */
2574
+	protected function _add_admin_page_overlay()
2575
+	{
2576
+		?>
2577 2577
         <div id="espresso-admin-page-overlay-dv" class=""></div>
2578 2578
         <?php
2579
-    }
2580
-
2581
-
2582
-    /**
2583
-     * facade for $this->addMetaBox()
2584
-     *
2585
-     * @param string  $action        where the metabox gets displayed
2586
-     * @param string  $title         Title of Metabox (output in metabox header)
2587
-     * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2588
-     *                               instead of the one created in here.
2589
-     * @param array   $callback_args an array of args supplied for the metabox
2590
-     * @param string  $column        what metabox column
2591
-     * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2592
-     * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2593
-     *                               created but just set our own callback for wp's add_meta_box.
2594
-     * @throws DomainException
2595
-     */
2596
-    public function _add_admin_page_meta_box(
2597
-        $action,
2598
-        $title,
2599
-        $callback,
2600
-        $callback_args,
2601
-        $column = 'normal',
2602
-        $priority = 'high',
2603
-        $create_func = true
2604
-    ) {
2605
-        do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2606
-        // if we have empty callback args and we want to automatically create the metabox callback then we need to make sure the callback args are generated.
2607
-        if (empty($callback_args) && $create_func) {
2608
-            $callback_args = [
2609
-                'template_path' => $this->_template_path,
2610
-                'template_args' => $this->_template_args,
2611
-            ];
2612
-        }
2613
-        // if $create_func is true (default) then we automatically create the function for displaying the actual meta box.  If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish)
2614
-        $call_back_func = $create_func
2615
-            ? static function ($post, $metabox) {
2616
-                do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2617
-                echo EEH_Template::display_template(
2618
-                    $metabox['args']['template_path'],
2619
-                    $metabox['args']['template_args'],
2620
-                    true
2621
-                );
2622
-            }
2623
-            : $callback;
2624
-        $this->addMetaBox(
2625
-            str_replace('_', '-', $action) . '-mbox',
2626
-            $title,
2627
-            $call_back_func,
2628
-            $this->_wp_page_slug,
2629
-            $column,
2630
-            $priority,
2631
-            $callback_args
2632
-        );
2633
-    }
2634
-
2635
-
2636
-    /**
2637
-     * generates HTML wrapper for and admin details page that contains metaboxes in columns
2638
-     *
2639
-     * @throws DomainException
2640
-     * @throws EE_Error
2641
-     * @throws InvalidArgumentException
2642
-     * @throws InvalidDataTypeException
2643
-     * @throws InvalidInterfaceException
2644
-     */
2645
-    public function display_admin_page_with_metabox_columns()
2646
-    {
2647
-        $this->_template_args['post_body_content']  = $this->_template_args['admin_page_content'];
2648
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2649
-            $this->_column_template_path,
2650
-            $this->_template_args,
2651
-            true
2652
-        );
2653
-        // the final wrapper
2654
-        $this->admin_page_wrapper();
2655
-    }
2656
-
2657
-
2658
-    /**
2659
-     * generates  HTML wrapper for an admin details page
2660
-     *
2661
-     * @return void
2662
-     * @throws DomainException
2663
-     * @throws EE_Error
2664
-     * @throws InvalidArgumentException
2665
-     * @throws InvalidDataTypeException
2666
-     * @throws InvalidInterfaceException
2667
-     */
2668
-    public function display_admin_page_with_sidebar()
2669
-    {
2670
-        $this->_display_admin_page(true);
2671
-    }
2672
-
2673
-
2674
-    /**
2675
-     * generates  HTML wrapper for an admin details page (except no sidebar)
2676
-     *
2677
-     * @return void
2678
-     * @throws DomainException
2679
-     * @throws EE_Error
2680
-     * @throws InvalidArgumentException
2681
-     * @throws InvalidDataTypeException
2682
-     * @throws InvalidInterfaceException
2683
-     */
2684
-    public function display_admin_page_with_no_sidebar()
2685
-    {
2686
-        $this->_display_admin_page();
2687
-    }
2688
-
2689
-
2690
-    /**
2691
-     * generates HTML wrapper for an EE about admin page (no sidebar)
2692
-     *
2693
-     * @return void
2694
-     * @throws DomainException
2695
-     * @throws EE_Error
2696
-     * @throws InvalidArgumentException
2697
-     * @throws InvalidDataTypeException
2698
-     * @throws InvalidInterfaceException
2699
-     */
2700
-    public function display_about_admin_page()
2701
-    {
2702
-        $this->_display_admin_page(false, true);
2703
-    }
2704
-
2705
-
2706
-    /**
2707
-     * display_admin_page
2708
-     * contains the code for actually displaying an admin page
2709
-     *
2710
-     * @param boolean $sidebar true with sidebar, false without
2711
-     * @param boolean $about   use the about admin wrapper instead of the default.
2712
-     * @return void
2713
-     * @throws DomainException
2714
-     * @throws EE_Error
2715
-     * @throws InvalidArgumentException
2716
-     * @throws InvalidDataTypeException
2717
-     * @throws InvalidInterfaceException
2718
-     */
2719
-    private function _display_admin_page($sidebar = false, $about = false)
2720
-    {
2721
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2722
-        // custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2723
-        do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2724
-        // set current wp page slug - looks like: event-espresso_page_event_categories
2725
-        // keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2726
-
2727
-        $post_body_content = $this->_template_args['before_admin_page_content'] ?? '';
2728
-
2729
-        $this->_template_args['add_page_frame'] = $this->_req_action !== 'system_status'
2730
-                                                 && $this->_req_action !== 'data_reset'
2731
-                                                 && $this->_wp_page_slug !== 'event-espresso_page_espresso_packages'
2732
-                                                 && strpos($post_body_content, 'wp-list-table') === false;
2733
-
2734
-        $this->_template_args['current_page']              = $this->_wp_page_slug;
2735
-        $this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2736
-            ? 'poststuff'
2737
-            : 'espresso-default-admin';
2738
-        $this->_template_args['admin_page_wrapper_div_class'] = str_replace(
2739
-            'event-espresso_page_espresso_',
2740
-            '',
2741
-            $this->_wp_page_slug
2742
-        ) . ' ' . $this->_req_action . '-route';
2743
-
2744
-        $template_path = $sidebar
2745
-            ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2746
-            : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2747
-        if ($this->request->isAjax()) {
2748
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2749
-        }
2750
-        $template_path = ! empty($this->_column_template_path) ? $this->_column_template_path : $template_path;
2751
-
2752
-        $this->_template_args['post_body_content']         = $this->_template_args['admin_page_content'] ?? '';
2753
-        $this->_template_args['before_admin_page_content'] = $post_body_content;
2754
-        $this->_template_args['after_admin_page_content']  = $this->_template_args['after_admin_page_content'] ?? '';
2755
-        $this->_template_args['admin_page_content']        = EEH_Template::display_template(
2756
-            $template_path,
2757
-            $this->_template_args,
2758
-            true
2759
-        );
2760
-        // the final template wrapper
2761
-        $this->admin_page_wrapper($about);
2762
-    }
2763
-
2764
-
2765
-    /**
2766
-     * This is used to display caf preview pages.
2767
-     *
2768
-     * @param string $utm_campaign_source what is the key used for google analytics link
2769
-     * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2770
-     *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2771
-     * @return void
2772
-     * @throws DomainException
2773
-     * @throws EE_Error
2774
-     * @throws InvalidArgumentException
2775
-     * @throws InvalidDataTypeException
2776
-     * @throws InvalidInterfaceException
2777
-     * @since 4.3.2
2778
-     */
2779
-    public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2780
-    {
2781
-        // let's generate a default preview action button if there isn't one already present.
2782
-        $this->_labels['buttons']['buy_now']           = esc_html__(
2783
-            'Upgrade to Event Espresso 4 Right Now',
2784
-            'event_espresso'
2785
-        );
2786
-        $buy_now_url                                   = add_query_arg(
2787
-            [
2788
-                'ee_ver'       => 'ee4',
2789
-                'utm_source'   => 'ee4_plugin_admin',
2790
-                'utm_medium'   => 'link',
2791
-                'utm_campaign' => $utm_campaign_source,
2792
-                'utm_content'  => 'buy_now_button',
2793
-            ],
2794
-            'https://eventespresso.com/pricing/'
2795
-        );
2796
-        $this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2797
-            ? $this->get_action_link_or_button(
2798
-                '',
2799
-                'buy_now',
2800
-                [],
2801
-                'button button--primary button--big',
2802
-                esc_url_raw($buy_now_url),
2803
-                true
2804
-            )
2805
-            : $this->_template_args['preview_action_button'];
2806
-        $this->_template_args['admin_page_content']    = EEH_Template::display_template(
2807
-            EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2808
-            $this->_template_args,
2809
-            true
2810
-        );
2811
-        $this->_display_admin_page($display_sidebar);
2812
-    }
2813
-
2814
-
2815
-    /**
2816
-     * display_admin_list_table_page_with_sidebar
2817
-     * generates HTML wrapper for an admin_page with list_table
2818
-     *
2819
-     * @return void
2820
-     * @throws DomainException
2821
-     * @throws EE_Error
2822
-     * @throws InvalidArgumentException
2823
-     * @throws InvalidDataTypeException
2824
-     * @throws InvalidInterfaceException
2825
-     */
2826
-    public function display_admin_list_table_page_with_sidebar()
2827
-    {
2828
-        $this->_display_admin_list_table_page(true);
2829
-    }
2830
-
2831
-
2832
-    /**
2833
-     * display_admin_list_table_page_with_no_sidebar
2834
-     * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2835
-     *
2836
-     * @return void
2837
-     * @throws DomainException
2838
-     * @throws EE_Error
2839
-     * @throws InvalidArgumentException
2840
-     * @throws InvalidDataTypeException
2841
-     * @throws InvalidInterfaceException
2842
-     */
2843
-    public function display_admin_list_table_page_with_no_sidebar()
2844
-    {
2845
-        $this->_display_admin_list_table_page();
2846
-    }
2847
-
2848
-
2849
-    /**
2850
-     * generates html wrapper for an admin_list_table page
2851
-     *
2852
-     * @param boolean $sidebar whether to display with sidebar or not.
2853
-     * @return void
2854
-     * @throws DomainException
2855
-     * @throws EE_Error
2856
-     * @throws InvalidArgumentException
2857
-     * @throws InvalidDataTypeException
2858
-     * @throws InvalidInterfaceException
2859
-     */
2860
-    private function _display_admin_list_table_page($sidebar = false)
2861
-    {
2862
-        // setup search attributes
2863
-        $this->_set_search_attributes();
2864
-        $this->_template_args['current_page']     = $this->_wp_page_slug;
2865
-        $template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2866
-        $this->_template_args['table_url']        = $this->request->isAjax()
2867
-            ? add_query_arg(['noheader' => 'true', 'route' => $this->_req_action], $this->_admin_base_url)
2868
-            : add_query_arg(['route' => $this->_req_action], $this->_admin_base_url);
2869
-        $this->_template_args['list_table']       = $this->_list_table_object;
2870
-        $this->_template_args['current_route']    = $this->_req_action;
2871
-        $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2872
-        $ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
2873
-        if (! empty($ajax_sorting_callback)) {
2874
-            $sortable_list_table_form_fields = wp_nonce_field(
2875
-                $ajax_sorting_callback . '_nonce',
2876
-                $ajax_sorting_callback . '_nonce',
2877
-                false,
2878
-                false
2879
-            );
2880
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
2881
-                                                . $this->page_slug
2882
-                                                . '" />';
2883
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
2884
-                                                . $ajax_sorting_callback
2885
-                                                . '" />';
2886
-        } else {
2887
-            $sortable_list_table_form_fields = '';
2888
-        }
2889
-        $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2890
-
2891
-        $hidden_form_fields = $this->_template_args['list_table_hidden_fields'] ?? '';
2892
-
2893
-        $nonce_ref          = $this->_req_action . '_nonce';
2894
-        $hidden_form_fields .= '
2579
+	}
2580
+
2581
+
2582
+	/**
2583
+	 * facade for $this->addMetaBox()
2584
+	 *
2585
+	 * @param string  $action        where the metabox gets displayed
2586
+	 * @param string  $title         Title of Metabox (output in metabox header)
2587
+	 * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2588
+	 *                               instead of the one created in here.
2589
+	 * @param array   $callback_args an array of args supplied for the metabox
2590
+	 * @param string  $column        what metabox column
2591
+	 * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2592
+	 * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2593
+	 *                               created but just set our own callback for wp's add_meta_box.
2594
+	 * @throws DomainException
2595
+	 */
2596
+	public function _add_admin_page_meta_box(
2597
+		$action,
2598
+		$title,
2599
+		$callback,
2600
+		$callback_args,
2601
+		$column = 'normal',
2602
+		$priority = 'high',
2603
+		$create_func = true
2604
+	) {
2605
+		do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2606
+		// if we have empty callback args and we want to automatically create the metabox callback then we need to make sure the callback args are generated.
2607
+		if (empty($callback_args) && $create_func) {
2608
+			$callback_args = [
2609
+				'template_path' => $this->_template_path,
2610
+				'template_args' => $this->_template_args,
2611
+			];
2612
+		}
2613
+		// if $create_func is true (default) then we automatically create the function for displaying the actual meta box.  If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish)
2614
+		$call_back_func = $create_func
2615
+			? static function ($post, $metabox) {
2616
+				do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2617
+				echo EEH_Template::display_template(
2618
+					$metabox['args']['template_path'],
2619
+					$metabox['args']['template_args'],
2620
+					true
2621
+				);
2622
+			}
2623
+			: $callback;
2624
+		$this->addMetaBox(
2625
+			str_replace('_', '-', $action) . '-mbox',
2626
+			$title,
2627
+			$call_back_func,
2628
+			$this->_wp_page_slug,
2629
+			$column,
2630
+			$priority,
2631
+			$callback_args
2632
+		);
2633
+	}
2634
+
2635
+
2636
+	/**
2637
+	 * generates HTML wrapper for and admin details page that contains metaboxes in columns
2638
+	 *
2639
+	 * @throws DomainException
2640
+	 * @throws EE_Error
2641
+	 * @throws InvalidArgumentException
2642
+	 * @throws InvalidDataTypeException
2643
+	 * @throws InvalidInterfaceException
2644
+	 */
2645
+	public function display_admin_page_with_metabox_columns()
2646
+	{
2647
+		$this->_template_args['post_body_content']  = $this->_template_args['admin_page_content'];
2648
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2649
+			$this->_column_template_path,
2650
+			$this->_template_args,
2651
+			true
2652
+		);
2653
+		// the final wrapper
2654
+		$this->admin_page_wrapper();
2655
+	}
2656
+
2657
+
2658
+	/**
2659
+	 * generates  HTML wrapper for an admin details page
2660
+	 *
2661
+	 * @return void
2662
+	 * @throws DomainException
2663
+	 * @throws EE_Error
2664
+	 * @throws InvalidArgumentException
2665
+	 * @throws InvalidDataTypeException
2666
+	 * @throws InvalidInterfaceException
2667
+	 */
2668
+	public function display_admin_page_with_sidebar()
2669
+	{
2670
+		$this->_display_admin_page(true);
2671
+	}
2672
+
2673
+
2674
+	/**
2675
+	 * generates  HTML wrapper for an admin details page (except no sidebar)
2676
+	 *
2677
+	 * @return void
2678
+	 * @throws DomainException
2679
+	 * @throws EE_Error
2680
+	 * @throws InvalidArgumentException
2681
+	 * @throws InvalidDataTypeException
2682
+	 * @throws InvalidInterfaceException
2683
+	 */
2684
+	public function display_admin_page_with_no_sidebar()
2685
+	{
2686
+		$this->_display_admin_page();
2687
+	}
2688
+
2689
+
2690
+	/**
2691
+	 * generates HTML wrapper for an EE about admin page (no sidebar)
2692
+	 *
2693
+	 * @return void
2694
+	 * @throws DomainException
2695
+	 * @throws EE_Error
2696
+	 * @throws InvalidArgumentException
2697
+	 * @throws InvalidDataTypeException
2698
+	 * @throws InvalidInterfaceException
2699
+	 */
2700
+	public function display_about_admin_page()
2701
+	{
2702
+		$this->_display_admin_page(false, true);
2703
+	}
2704
+
2705
+
2706
+	/**
2707
+	 * display_admin_page
2708
+	 * contains the code for actually displaying an admin page
2709
+	 *
2710
+	 * @param boolean $sidebar true with sidebar, false without
2711
+	 * @param boolean $about   use the about admin wrapper instead of the default.
2712
+	 * @return void
2713
+	 * @throws DomainException
2714
+	 * @throws EE_Error
2715
+	 * @throws InvalidArgumentException
2716
+	 * @throws InvalidDataTypeException
2717
+	 * @throws InvalidInterfaceException
2718
+	 */
2719
+	private function _display_admin_page($sidebar = false, $about = false)
2720
+	{
2721
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2722
+		// custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2723
+		do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2724
+		// set current wp page slug - looks like: event-espresso_page_event_categories
2725
+		// keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2726
+
2727
+		$post_body_content = $this->_template_args['before_admin_page_content'] ?? '';
2728
+
2729
+		$this->_template_args['add_page_frame'] = $this->_req_action !== 'system_status'
2730
+												 && $this->_req_action !== 'data_reset'
2731
+												 && $this->_wp_page_slug !== 'event-espresso_page_espresso_packages'
2732
+												 && strpos($post_body_content, 'wp-list-table') === false;
2733
+
2734
+		$this->_template_args['current_page']              = $this->_wp_page_slug;
2735
+		$this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2736
+			? 'poststuff'
2737
+			: 'espresso-default-admin';
2738
+		$this->_template_args['admin_page_wrapper_div_class'] = str_replace(
2739
+			'event-espresso_page_espresso_',
2740
+			'',
2741
+			$this->_wp_page_slug
2742
+		) . ' ' . $this->_req_action . '-route';
2743
+
2744
+		$template_path = $sidebar
2745
+			? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2746
+			: EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2747
+		if ($this->request->isAjax()) {
2748
+			$template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2749
+		}
2750
+		$template_path = ! empty($this->_column_template_path) ? $this->_column_template_path : $template_path;
2751
+
2752
+		$this->_template_args['post_body_content']         = $this->_template_args['admin_page_content'] ?? '';
2753
+		$this->_template_args['before_admin_page_content'] = $post_body_content;
2754
+		$this->_template_args['after_admin_page_content']  = $this->_template_args['after_admin_page_content'] ?? '';
2755
+		$this->_template_args['admin_page_content']        = EEH_Template::display_template(
2756
+			$template_path,
2757
+			$this->_template_args,
2758
+			true
2759
+		);
2760
+		// the final template wrapper
2761
+		$this->admin_page_wrapper($about);
2762
+	}
2763
+
2764
+
2765
+	/**
2766
+	 * This is used to display caf preview pages.
2767
+	 *
2768
+	 * @param string $utm_campaign_source what is the key used for google analytics link
2769
+	 * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2770
+	 *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2771
+	 * @return void
2772
+	 * @throws DomainException
2773
+	 * @throws EE_Error
2774
+	 * @throws InvalidArgumentException
2775
+	 * @throws InvalidDataTypeException
2776
+	 * @throws InvalidInterfaceException
2777
+	 * @since 4.3.2
2778
+	 */
2779
+	public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2780
+	{
2781
+		// let's generate a default preview action button if there isn't one already present.
2782
+		$this->_labels['buttons']['buy_now']           = esc_html__(
2783
+			'Upgrade to Event Espresso 4 Right Now',
2784
+			'event_espresso'
2785
+		);
2786
+		$buy_now_url                                   = add_query_arg(
2787
+			[
2788
+				'ee_ver'       => 'ee4',
2789
+				'utm_source'   => 'ee4_plugin_admin',
2790
+				'utm_medium'   => 'link',
2791
+				'utm_campaign' => $utm_campaign_source,
2792
+				'utm_content'  => 'buy_now_button',
2793
+			],
2794
+			'https://eventespresso.com/pricing/'
2795
+		);
2796
+		$this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2797
+			? $this->get_action_link_or_button(
2798
+				'',
2799
+				'buy_now',
2800
+				[],
2801
+				'button button--primary button--big',
2802
+				esc_url_raw($buy_now_url),
2803
+				true
2804
+			)
2805
+			: $this->_template_args['preview_action_button'];
2806
+		$this->_template_args['admin_page_content']    = EEH_Template::display_template(
2807
+			EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2808
+			$this->_template_args,
2809
+			true
2810
+		);
2811
+		$this->_display_admin_page($display_sidebar);
2812
+	}
2813
+
2814
+
2815
+	/**
2816
+	 * display_admin_list_table_page_with_sidebar
2817
+	 * generates HTML wrapper for an admin_page with list_table
2818
+	 *
2819
+	 * @return void
2820
+	 * @throws DomainException
2821
+	 * @throws EE_Error
2822
+	 * @throws InvalidArgumentException
2823
+	 * @throws InvalidDataTypeException
2824
+	 * @throws InvalidInterfaceException
2825
+	 */
2826
+	public function display_admin_list_table_page_with_sidebar()
2827
+	{
2828
+		$this->_display_admin_list_table_page(true);
2829
+	}
2830
+
2831
+
2832
+	/**
2833
+	 * display_admin_list_table_page_with_no_sidebar
2834
+	 * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2835
+	 *
2836
+	 * @return void
2837
+	 * @throws DomainException
2838
+	 * @throws EE_Error
2839
+	 * @throws InvalidArgumentException
2840
+	 * @throws InvalidDataTypeException
2841
+	 * @throws InvalidInterfaceException
2842
+	 */
2843
+	public function display_admin_list_table_page_with_no_sidebar()
2844
+	{
2845
+		$this->_display_admin_list_table_page();
2846
+	}
2847
+
2848
+
2849
+	/**
2850
+	 * generates html wrapper for an admin_list_table page
2851
+	 *
2852
+	 * @param boolean $sidebar whether to display with sidebar or not.
2853
+	 * @return void
2854
+	 * @throws DomainException
2855
+	 * @throws EE_Error
2856
+	 * @throws InvalidArgumentException
2857
+	 * @throws InvalidDataTypeException
2858
+	 * @throws InvalidInterfaceException
2859
+	 */
2860
+	private function _display_admin_list_table_page($sidebar = false)
2861
+	{
2862
+		// setup search attributes
2863
+		$this->_set_search_attributes();
2864
+		$this->_template_args['current_page']     = $this->_wp_page_slug;
2865
+		$template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2866
+		$this->_template_args['table_url']        = $this->request->isAjax()
2867
+			? add_query_arg(['noheader' => 'true', 'route' => $this->_req_action], $this->_admin_base_url)
2868
+			: add_query_arg(['route' => $this->_req_action], $this->_admin_base_url);
2869
+		$this->_template_args['list_table']       = $this->_list_table_object;
2870
+		$this->_template_args['current_route']    = $this->_req_action;
2871
+		$this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2872
+		$ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
2873
+		if (! empty($ajax_sorting_callback)) {
2874
+			$sortable_list_table_form_fields = wp_nonce_field(
2875
+				$ajax_sorting_callback . '_nonce',
2876
+				$ajax_sorting_callback . '_nonce',
2877
+				false,
2878
+				false
2879
+			);
2880
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
2881
+												. $this->page_slug
2882
+												. '" />';
2883
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
2884
+												. $ajax_sorting_callback
2885
+												. '" />';
2886
+		} else {
2887
+			$sortable_list_table_form_fields = '';
2888
+		}
2889
+		$this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2890
+
2891
+		$hidden_form_fields = $this->_template_args['list_table_hidden_fields'] ?? '';
2892
+
2893
+		$nonce_ref          = $this->_req_action . '_nonce';
2894
+		$hidden_form_fields .= '
2895 2895
             <input type="hidden" name="' . $nonce_ref . '" value="' . wp_create_nonce($nonce_ref) . '">';
2896 2896
 
2897
-        $this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
2898
-        // display message about search results?
2899
-        $search = $this->request->getRequestParam('s');
2900
-        $this->_template_args['before_list_table'] .= ! empty($search)
2901
-            ? '<p class="ee-search-results">' . sprintf(
2902
-                esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
2903
-                trim($search, '%')
2904
-            ) . '</p>'
2905
-            : '';
2906
-        // filter before_list_table template arg
2907
-        $this->_template_args['before_list_table'] = apply_filters(
2908
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
2909
-            $this->_template_args['before_list_table'],
2910
-            $this->page_slug,
2911
-            $this->request->requestParams(),
2912
-            $this->_req_action
2913
-        );
2914
-        // convert to array and filter again
2915
-        // arrays are easier to inject new items in a specific location,
2916
-        // but would not be backwards compatible, so we have to add a new filter
2917
-        $this->_template_args['before_list_table'] = implode(
2918
-            " \n",
2919
-            (array) apply_filters(
2920
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
2921
-                (array) $this->_template_args['before_list_table'],
2922
-                $this->page_slug,
2923
-                $this->request->requestParams(),
2924
-                $this->_req_action
2925
-            )
2926
-        );
2927
-        // filter after_list_table template arg
2928
-        $this->_template_args['after_list_table'] = apply_filters(
2929
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
2930
-            $this->_template_args['after_list_table'],
2931
-            $this->page_slug,
2932
-            $this->request->requestParams(),
2933
-            $this->_req_action
2934
-        );
2935
-        // convert to array and filter again
2936
-        // arrays are easier to inject new items in a specific location,
2937
-        // but would not be backwards compatible, so we have to add a new filter
2938
-        $this->_template_args['after_list_table']   = implode(
2939
-            " \n",
2940
-            (array) apply_filters(
2941
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
2942
-                (array) $this->_template_args['after_list_table'],
2943
-                $this->page_slug,
2944
-                $this->request->requestParams(),
2945
-                $this->_req_action
2946
-            )
2947
-        );
2948
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2949
-            $template_path,
2950
-            $this->_template_args,
2951
-            true
2952
-        );
2953
-        // the final template wrapper
2954
-        if ($sidebar) {
2955
-            $this->display_admin_page_with_sidebar();
2956
-        } else {
2957
-            $this->display_admin_page_with_no_sidebar();
2958
-        }
2959
-    }
2960
-
2961
-
2962
-    /**
2963
-     * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
2964
-     * html string for the legend.
2965
-     * $items are expected in an array in the following format:
2966
-     * $legend_items = array(
2967
-     *        'item_id' => array(
2968
-     *            'icon' => 'http://url_to_icon_being_described.png',
2969
-     *            'desc' => esc_html__('localized description of item');
2970
-     *        )
2971
-     * );
2972
-     *
2973
-     * @param array $items see above for format of array
2974
-     * @return string html string of legend
2975
-     * @throws DomainException
2976
-     */
2977
-    protected function _display_legend($items)
2978
-    {
2979
-        $this->_template_args['items'] = apply_filters(
2980
-            'FHEE__EE_Admin_Page___display_legend__items',
2981
-            (array) $items,
2982
-            $this
2983
-        );
2984
-        /** @var EventEspresso\core\admin\StatusChangeNotice $status_change_notice */
2985
-        $status_change_notice = $this->loader->getShared('EventEspresso\core\admin\StatusChangeNotice');
2986
-        if (! $status_change_notice->isDismissed()) {
2987
-            $this->_template_args['status_change_notice'] = EEH_Template::display_template(
2988
-                EE_ADMIN_TEMPLATE . 'status_change_notice.template.php',
2989
-                [ 'context' => '__admin-legend', 'page_slug' => $this->page_slug ],
2990
-                true
2991
-            );
2992
-        }
2993
-        return EEH_Template::display_template(
2994
-            EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
2995
-            $this->_template_args,
2996
-            true
2997
-        );
2998
-    }
2999
-
3000
-
3001
-    /**
3002
-     * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
3003
-     * The returned json object is created from an array in the following format:
3004
-     * array(
3005
-     *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
3006
-     *  'success' => FALSE, //(default FALSE) - contains any special success message.
3007
-     *  'notices' => '', // - contains any EE_Error formatted notices
3008
-     *  'content' => 'string can be html', //this is a string of formatted content (can be html)
3009
-     *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
3010
-     *  We're also going to include the template args with every package (so js can pick out any specific template args
3011
-     *  that might be included in here)
3012
-     * )
3013
-     * The json object is populated by whatever is set in the $_template_args property.
3014
-     *
3015
-     * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
3016
-     *                                 instead of displayed.
3017
-     * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
3018
-     * @return void
3019
-     * @throws EE_Error
3020
-     * @throws InvalidArgumentException
3021
-     * @throws InvalidDataTypeException
3022
-     * @throws InvalidInterfaceException
3023
-     */
3024
-    protected function _return_json($sticky_notices = false, $notices_arguments = [])
3025
-    {
3026
-        // make sure any EE_Error notices have been handled.
3027
-        $this->_process_notices($notices_arguments, true, $sticky_notices);
3028
-        $data = isset($this->_template_args['data']) ? $this->_template_args['data'] : [];
3029
-        unset($this->_template_args['data']);
3030
-        $json = [
3031
-            'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
3032
-            'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
3033
-            'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
3034
-            'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
3035
-            'notices'   => EE_Error::get_notices(),
3036
-            'content'   => isset($this->_template_args['admin_page_content'])
3037
-                ? $this->_template_args['admin_page_content'] : '',
3038
-            'data'      => array_merge($data, ['template_args' => $this->_template_args]),
3039
-            'isEEajax'  => true
3040
-            // special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
3041
-        ];
3042
-        // make sure there are no php errors or headers_sent.  Then we can set correct json header.
3043
-        if (null === error_get_last() || ! headers_sent()) {
3044
-            header('Content-Type: application/json; charset=UTF-8');
3045
-        }
3046
-        echo wp_json_encode($json);
3047
-        exit();
3048
-    }
3049
-
3050
-
3051
-    /**
3052
-     * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
3053
-     *
3054
-     * @return void
3055
-     * @throws EE_Error
3056
-     * @throws InvalidArgumentException
3057
-     * @throws InvalidDataTypeException
3058
-     * @throws InvalidInterfaceException
3059
-     */
3060
-    public function return_json()
3061
-    {
3062
-        if ($this->request->isAjax()) {
3063
-            $this->_return_json();
3064
-        } else {
3065
-            throw new EE_Error(
3066
-                sprintf(
3067
-                    esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3068
-                    __FUNCTION__
3069
-                )
3070
-            );
3071
-        }
3072
-    }
3073
-
3074
-
3075
-    /**
3076
-     * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3077
-     * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3078
-     *
3079
-     * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3080
-     */
3081
-    public function set_hook_object(EE_Admin_Hooks $hook_obj)
3082
-    {
3083
-        $this->_hook_obj = $hook_obj;
3084
-    }
3085
-
3086
-
3087
-    /**
3088
-     *        generates  HTML wrapper with Tabbed nav for an admin page
3089
-     *
3090
-     * @param boolean $about whether to use the special about page wrapper or default.
3091
-     * @return void
3092
-     * @throws DomainException
3093
-     * @throws EE_Error
3094
-     * @throws InvalidArgumentException
3095
-     * @throws InvalidDataTypeException
3096
-     * @throws InvalidInterfaceException
3097
-     */
3098
-    public function admin_page_wrapper($about = false)
3099
-    {
3100
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3101
-        $this->_nav_tabs                                   = $this->_get_main_nav_tabs();
3102
-        $this->_template_args['nav_tabs']                  = $this->_nav_tabs;
3103
-        $this->_template_args['admin_page_title']          = $this->_admin_page_title;
3104
-
3105
-        $this->_template_args['before_admin_page_content'] = apply_filters(
3106
-            "FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3107
-            $this->_template_args['before_admin_page_content'] ?? ''
3108
-        );
3109
-
3110
-        $this->_template_args['after_admin_page_content']  = apply_filters(
3111
-            "FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3112
-            $this->_template_args['after_admin_page_content'] ?? ''
3113
-        );
3114
-        $this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3115
-
3116
-        if ($this->request->isAjax()) {
3117
-            $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3118
-                // $template_path,
3119
-                EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php',
3120
-                $this->_template_args,
3121
-                true
3122
-            );
3123
-            $this->_return_json();
3124
-        }
3125
-        // load settings page wrapper template
3126
-        $template_path = $about
3127
-            ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3128
-            : EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php';
3129
-
3130
-        EEH_Template::display_template($template_path, $this->_template_args);
3131
-    }
3132
-
3133
-
3134
-    /**
3135
-     * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3136
-     *
3137
-     * @return string html
3138
-     * @throws EE_Error
3139
-     */
3140
-    protected function _get_main_nav_tabs()
3141
-    {
3142
-        // let's generate the html using the EEH_Tabbed_Content helper.
3143
-        // We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3144
-        // (rather than setting in the page_routes array)
3145
-        return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3146
-    }
3147
-
3148
-
3149
-    /**
3150
-     *        sort nav tabs
3151
-     *
3152
-     * @param $a
3153
-     * @param $b
3154
-     * @return int
3155
-     */
3156
-    private function _sort_nav_tabs($a, $b)
3157
-    {
3158
-        if ($a['order'] === $b['order']) {
3159
-            return 0;
3160
-        }
3161
-        return ($a['order'] < $b['order']) ? -1 : 1;
3162
-    }
3163
-
3164
-
3165
-    /**
3166
-     * generates HTML for the forms used on admin pages
3167
-     *
3168
-     * @param array  $input_vars - array of input field details
3169
-     * @param string $generator  indicates which generator to use: options are 'string' or 'array'
3170
-     * @param bool   $id
3171
-     * @return array|string
3172
-     * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3173
-     * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3174
-     */
3175
-    protected function _generate_admin_form_fields($input_vars = [], $generator = 'string', $id = false)
3176
-    {
3177
-        return $generator === 'string'
3178
-            ? EEH_Form_Fields::get_form_fields($input_vars, $id)
3179
-            : EEH_Form_Fields::get_form_fields_array($input_vars);
3180
-    }
3181
-
3182
-
3183
-    /**
3184
-     * generates the "Save" and "Save & Close" buttons for edit forms
3185
-     *
3186
-     * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3187
-     *                                   Close" button.
3188
-     * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3189
-     *                                   'Save', [1] => 'save & close')
3190
-     * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3191
-     *                                   via the "name" value in the button).  We can also use this to just dump
3192
-     *                                   default actions by submitting some other value.
3193
-     * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3194
-     *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3195
-     *                                   close (normal form handling).
3196
-     */
3197
-    protected function _set_save_buttons($both = true, $text = [], $actions = [], $referrer = null)
3198
-    {
3199
-        // make sure $text and $actions are in an array
3200
-        $text          = (array) $text;
3201
-        $actions       = (array) $actions;
3202
-        $referrer_url  = ! empty($referrer) ? $referrer : $this->request->getServerParam('REQUEST_URI');
3203
-        $button_text   = ! empty($text)
3204
-            ? $text
3205
-            : [
3206
-                esc_html__('Save', 'event_espresso'),
3207
-                esc_html__('Save and Close', 'event_espresso'),
3208
-            ];
3209
-        $default_names = ['save', 'save_and_close'];
3210
-        $buttons = '';
3211
-        foreach ($button_text as $key => $button) {
3212
-            $ref     = $default_names[ $key ];
3213
-            $name    = ! empty($actions) ? $actions[ $key ] : $ref;
3214
-            $buttons .= '<input type="submit" class="button button--primary ' . $ref . '" '
3215
-                        . 'value="' . $button . '" name="' . $name . '" '
3216
-                        . 'id="' . $this->_current_view . '_' . $ref . '" />';
3217
-            if (! $both) {
3218
-                break;
3219
-            }
3220
-        }
3221
-        // add in a hidden index for the current page (so save and close redirects properly)
3222
-        $buttons .= '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3223
-                   . $referrer_url
3224
-                   . '" />';
3225
-        $this->_template_args['save_buttons'] = $buttons;
3226
-    }
3227
-
3228
-
3229
-    /**
3230
-     * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3231
-     *
3232
-     * @param string $route
3233
-     * @param array  $additional_hidden_fields
3234
-     * @see   $this->_set_add_edit_form_tags() for details on params
3235
-     * @since 4.6.0
3236
-     */
3237
-    public function set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3238
-    {
3239
-        $this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3240
-    }
3241
-
3242
-
3243
-    /**
3244
-     * set form open and close tags on add/edit pages.
3245
-     *
3246
-     * @param string $route                    the route you want the form to direct to
3247
-     * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3248
-     * @return void
3249
-     */
3250
-    protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3251
-    {
3252
-        if (empty($route)) {
3253
-            $user_msg = esc_html__(
3254
-                'An error occurred. No action was set for this page\'s form.',
3255
-                'event_espresso'
3256
-            );
3257
-            $dev_msg  = $user_msg . "\n"
3258
-                        . sprintf(
3259
-                            esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3260
-                            __FUNCTION__,
3261
-                            __CLASS__
3262
-                        );
3263
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3264
-        }
3265
-        // open form
3266
-        $action = $this->_admin_base_url;
3267
-        $this->_template_args['before_admin_page_content'] = "
2897
+		$this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
2898
+		// display message about search results?
2899
+		$search = $this->request->getRequestParam('s');
2900
+		$this->_template_args['before_list_table'] .= ! empty($search)
2901
+			? '<p class="ee-search-results">' . sprintf(
2902
+				esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
2903
+				trim($search, '%')
2904
+			) . '</p>'
2905
+			: '';
2906
+		// filter before_list_table template arg
2907
+		$this->_template_args['before_list_table'] = apply_filters(
2908
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
2909
+			$this->_template_args['before_list_table'],
2910
+			$this->page_slug,
2911
+			$this->request->requestParams(),
2912
+			$this->_req_action
2913
+		);
2914
+		// convert to array and filter again
2915
+		// arrays are easier to inject new items in a specific location,
2916
+		// but would not be backwards compatible, so we have to add a new filter
2917
+		$this->_template_args['before_list_table'] = implode(
2918
+			" \n",
2919
+			(array) apply_filters(
2920
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
2921
+				(array) $this->_template_args['before_list_table'],
2922
+				$this->page_slug,
2923
+				$this->request->requestParams(),
2924
+				$this->_req_action
2925
+			)
2926
+		);
2927
+		// filter after_list_table template arg
2928
+		$this->_template_args['after_list_table'] = apply_filters(
2929
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
2930
+			$this->_template_args['after_list_table'],
2931
+			$this->page_slug,
2932
+			$this->request->requestParams(),
2933
+			$this->_req_action
2934
+		);
2935
+		// convert to array and filter again
2936
+		// arrays are easier to inject new items in a specific location,
2937
+		// but would not be backwards compatible, so we have to add a new filter
2938
+		$this->_template_args['after_list_table']   = implode(
2939
+			" \n",
2940
+			(array) apply_filters(
2941
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
2942
+				(array) $this->_template_args['after_list_table'],
2943
+				$this->page_slug,
2944
+				$this->request->requestParams(),
2945
+				$this->_req_action
2946
+			)
2947
+		);
2948
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2949
+			$template_path,
2950
+			$this->_template_args,
2951
+			true
2952
+		);
2953
+		// the final template wrapper
2954
+		if ($sidebar) {
2955
+			$this->display_admin_page_with_sidebar();
2956
+		} else {
2957
+			$this->display_admin_page_with_no_sidebar();
2958
+		}
2959
+	}
2960
+
2961
+
2962
+	/**
2963
+	 * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
2964
+	 * html string for the legend.
2965
+	 * $items are expected in an array in the following format:
2966
+	 * $legend_items = array(
2967
+	 *        'item_id' => array(
2968
+	 *            'icon' => 'http://url_to_icon_being_described.png',
2969
+	 *            'desc' => esc_html__('localized description of item');
2970
+	 *        )
2971
+	 * );
2972
+	 *
2973
+	 * @param array $items see above for format of array
2974
+	 * @return string html string of legend
2975
+	 * @throws DomainException
2976
+	 */
2977
+	protected function _display_legend($items)
2978
+	{
2979
+		$this->_template_args['items'] = apply_filters(
2980
+			'FHEE__EE_Admin_Page___display_legend__items',
2981
+			(array) $items,
2982
+			$this
2983
+		);
2984
+		/** @var EventEspresso\core\admin\StatusChangeNotice $status_change_notice */
2985
+		$status_change_notice = $this->loader->getShared('EventEspresso\core\admin\StatusChangeNotice');
2986
+		if (! $status_change_notice->isDismissed()) {
2987
+			$this->_template_args['status_change_notice'] = EEH_Template::display_template(
2988
+				EE_ADMIN_TEMPLATE . 'status_change_notice.template.php',
2989
+				[ 'context' => '__admin-legend', 'page_slug' => $this->page_slug ],
2990
+				true
2991
+			);
2992
+		}
2993
+		return EEH_Template::display_template(
2994
+			EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
2995
+			$this->_template_args,
2996
+			true
2997
+		);
2998
+	}
2999
+
3000
+
3001
+	/**
3002
+	 * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
3003
+	 * The returned json object is created from an array in the following format:
3004
+	 * array(
3005
+	 *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
3006
+	 *  'success' => FALSE, //(default FALSE) - contains any special success message.
3007
+	 *  'notices' => '', // - contains any EE_Error formatted notices
3008
+	 *  'content' => 'string can be html', //this is a string of formatted content (can be html)
3009
+	 *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
3010
+	 *  We're also going to include the template args with every package (so js can pick out any specific template args
3011
+	 *  that might be included in here)
3012
+	 * )
3013
+	 * The json object is populated by whatever is set in the $_template_args property.
3014
+	 *
3015
+	 * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
3016
+	 *                                 instead of displayed.
3017
+	 * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
3018
+	 * @return void
3019
+	 * @throws EE_Error
3020
+	 * @throws InvalidArgumentException
3021
+	 * @throws InvalidDataTypeException
3022
+	 * @throws InvalidInterfaceException
3023
+	 */
3024
+	protected function _return_json($sticky_notices = false, $notices_arguments = [])
3025
+	{
3026
+		// make sure any EE_Error notices have been handled.
3027
+		$this->_process_notices($notices_arguments, true, $sticky_notices);
3028
+		$data = isset($this->_template_args['data']) ? $this->_template_args['data'] : [];
3029
+		unset($this->_template_args['data']);
3030
+		$json = [
3031
+			'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
3032
+			'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
3033
+			'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
3034
+			'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
3035
+			'notices'   => EE_Error::get_notices(),
3036
+			'content'   => isset($this->_template_args['admin_page_content'])
3037
+				? $this->_template_args['admin_page_content'] : '',
3038
+			'data'      => array_merge($data, ['template_args' => $this->_template_args]),
3039
+			'isEEajax'  => true
3040
+			// special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
3041
+		];
3042
+		// make sure there are no php errors or headers_sent.  Then we can set correct json header.
3043
+		if (null === error_get_last() || ! headers_sent()) {
3044
+			header('Content-Type: application/json; charset=UTF-8');
3045
+		}
3046
+		echo wp_json_encode($json);
3047
+		exit();
3048
+	}
3049
+
3050
+
3051
+	/**
3052
+	 * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
3053
+	 *
3054
+	 * @return void
3055
+	 * @throws EE_Error
3056
+	 * @throws InvalidArgumentException
3057
+	 * @throws InvalidDataTypeException
3058
+	 * @throws InvalidInterfaceException
3059
+	 */
3060
+	public function return_json()
3061
+	{
3062
+		if ($this->request->isAjax()) {
3063
+			$this->_return_json();
3064
+		} else {
3065
+			throw new EE_Error(
3066
+				sprintf(
3067
+					esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3068
+					__FUNCTION__
3069
+				)
3070
+			);
3071
+		}
3072
+	}
3073
+
3074
+
3075
+	/**
3076
+	 * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3077
+	 * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3078
+	 *
3079
+	 * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3080
+	 */
3081
+	public function set_hook_object(EE_Admin_Hooks $hook_obj)
3082
+	{
3083
+		$this->_hook_obj = $hook_obj;
3084
+	}
3085
+
3086
+
3087
+	/**
3088
+	 *        generates  HTML wrapper with Tabbed nav for an admin page
3089
+	 *
3090
+	 * @param boolean $about whether to use the special about page wrapper or default.
3091
+	 * @return void
3092
+	 * @throws DomainException
3093
+	 * @throws EE_Error
3094
+	 * @throws InvalidArgumentException
3095
+	 * @throws InvalidDataTypeException
3096
+	 * @throws InvalidInterfaceException
3097
+	 */
3098
+	public function admin_page_wrapper($about = false)
3099
+	{
3100
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3101
+		$this->_nav_tabs                                   = $this->_get_main_nav_tabs();
3102
+		$this->_template_args['nav_tabs']                  = $this->_nav_tabs;
3103
+		$this->_template_args['admin_page_title']          = $this->_admin_page_title;
3104
+
3105
+		$this->_template_args['before_admin_page_content'] = apply_filters(
3106
+			"FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3107
+			$this->_template_args['before_admin_page_content'] ?? ''
3108
+		);
3109
+
3110
+		$this->_template_args['after_admin_page_content']  = apply_filters(
3111
+			"FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3112
+			$this->_template_args['after_admin_page_content'] ?? ''
3113
+		);
3114
+		$this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3115
+
3116
+		if ($this->request->isAjax()) {
3117
+			$this->_template_args['admin_page_content'] = EEH_Template::display_template(
3118
+				// $template_path,
3119
+				EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php',
3120
+				$this->_template_args,
3121
+				true
3122
+			);
3123
+			$this->_return_json();
3124
+		}
3125
+		// load settings page wrapper template
3126
+		$template_path = $about
3127
+			? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3128
+			: EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php';
3129
+
3130
+		EEH_Template::display_template($template_path, $this->_template_args);
3131
+	}
3132
+
3133
+
3134
+	/**
3135
+	 * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3136
+	 *
3137
+	 * @return string html
3138
+	 * @throws EE_Error
3139
+	 */
3140
+	protected function _get_main_nav_tabs()
3141
+	{
3142
+		// let's generate the html using the EEH_Tabbed_Content helper.
3143
+		// We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3144
+		// (rather than setting in the page_routes array)
3145
+		return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3146
+	}
3147
+
3148
+
3149
+	/**
3150
+	 *        sort nav tabs
3151
+	 *
3152
+	 * @param $a
3153
+	 * @param $b
3154
+	 * @return int
3155
+	 */
3156
+	private function _sort_nav_tabs($a, $b)
3157
+	{
3158
+		if ($a['order'] === $b['order']) {
3159
+			return 0;
3160
+		}
3161
+		return ($a['order'] < $b['order']) ? -1 : 1;
3162
+	}
3163
+
3164
+
3165
+	/**
3166
+	 * generates HTML for the forms used on admin pages
3167
+	 *
3168
+	 * @param array  $input_vars - array of input field details
3169
+	 * @param string $generator  indicates which generator to use: options are 'string' or 'array'
3170
+	 * @param bool   $id
3171
+	 * @return array|string
3172
+	 * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3173
+	 * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3174
+	 */
3175
+	protected function _generate_admin_form_fields($input_vars = [], $generator = 'string', $id = false)
3176
+	{
3177
+		return $generator === 'string'
3178
+			? EEH_Form_Fields::get_form_fields($input_vars, $id)
3179
+			: EEH_Form_Fields::get_form_fields_array($input_vars);
3180
+	}
3181
+
3182
+
3183
+	/**
3184
+	 * generates the "Save" and "Save & Close" buttons for edit forms
3185
+	 *
3186
+	 * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3187
+	 *                                   Close" button.
3188
+	 * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3189
+	 *                                   'Save', [1] => 'save & close')
3190
+	 * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3191
+	 *                                   via the "name" value in the button).  We can also use this to just dump
3192
+	 *                                   default actions by submitting some other value.
3193
+	 * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3194
+	 *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3195
+	 *                                   close (normal form handling).
3196
+	 */
3197
+	protected function _set_save_buttons($both = true, $text = [], $actions = [], $referrer = null)
3198
+	{
3199
+		// make sure $text and $actions are in an array
3200
+		$text          = (array) $text;
3201
+		$actions       = (array) $actions;
3202
+		$referrer_url  = ! empty($referrer) ? $referrer : $this->request->getServerParam('REQUEST_URI');
3203
+		$button_text   = ! empty($text)
3204
+			? $text
3205
+			: [
3206
+				esc_html__('Save', 'event_espresso'),
3207
+				esc_html__('Save and Close', 'event_espresso'),
3208
+			];
3209
+		$default_names = ['save', 'save_and_close'];
3210
+		$buttons = '';
3211
+		foreach ($button_text as $key => $button) {
3212
+			$ref     = $default_names[ $key ];
3213
+			$name    = ! empty($actions) ? $actions[ $key ] : $ref;
3214
+			$buttons .= '<input type="submit" class="button button--primary ' . $ref . '" '
3215
+						. 'value="' . $button . '" name="' . $name . '" '
3216
+						. 'id="' . $this->_current_view . '_' . $ref . '" />';
3217
+			if (! $both) {
3218
+				break;
3219
+			}
3220
+		}
3221
+		// add in a hidden index for the current page (so save and close redirects properly)
3222
+		$buttons .= '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3223
+				   . $referrer_url
3224
+				   . '" />';
3225
+		$this->_template_args['save_buttons'] = $buttons;
3226
+	}
3227
+
3228
+
3229
+	/**
3230
+	 * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3231
+	 *
3232
+	 * @param string $route
3233
+	 * @param array  $additional_hidden_fields
3234
+	 * @see   $this->_set_add_edit_form_tags() for details on params
3235
+	 * @since 4.6.0
3236
+	 */
3237
+	public function set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3238
+	{
3239
+		$this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3240
+	}
3241
+
3242
+
3243
+	/**
3244
+	 * set form open and close tags on add/edit pages.
3245
+	 *
3246
+	 * @param string $route                    the route you want the form to direct to
3247
+	 * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3248
+	 * @return void
3249
+	 */
3250
+	protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3251
+	{
3252
+		if (empty($route)) {
3253
+			$user_msg = esc_html__(
3254
+				'An error occurred. No action was set for this page\'s form.',
3255
+				'event_espresso'
3256
+			);
3257
+			$dev_msg  = $user_msg . "\n"
3258
+						. sprintf(
3259
+							esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3260
+							__FUNCTION__,
3261
+							__CLASS__
3262
+						);
3263
+			EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3264
+		}
3265
+		// open form
3266
+		$action = $this->_admin_base_url;
3267
+		$this->_template_args['before_admin_page_content'] = "
3268 3268
             <form name='form' method='post' action='{$action}' id='{$route}_event_form' class='ee-admin-page-form' >
3269 3269
             ";
3270
-        // add nonce
3271
-        $nonce                                             =
3272
-            wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3273
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3274
-        // add REQUIRED form action
3275
-        $hidden_fields = [
3276
-            'action' => ['type' => 'hidden', 'value' => $route],
3277
-        ];
3278
-        // merge arrays
3279
-        $hidden_fields = is_array($additional_hidden_fields)
3280
-            ? array_merge($hidden_fields, $additional_hidden_fields)
3281
-            : $hidden_fields;
3282
-        // generate form fields
3283
-        $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3284
-        // add fields to form
3285
-        foreach ((array) $form_fields as $form_field) {
3286
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3287
-        }
3288
-        // close form
3289
-        $this->_template_args['after_admin_page_content'] = '</form>';
3290
-    }
3291
-
3292
-
3293
-    /**
3294
-     * Public Wrapper for _redirect_after_action() method since its
3295
-     * discovered it would be useful for external code to have access.
3296
-     *
3297
-     * @param bool   $success
3298
-     * @param string $what
3299
-     * @param string $action_desc
3300
-     * @param array  $query_args
3301
-     * @param bool   $override_overwrite
3302
-     * @throws EE_Error
3303
-     * @see   EE_Admin_Page::_redirect_after_action() for params.
3304
-     * @since 4.5.0
3305
-     */
3306
-    public function redirect_after_action(
3307
-        $success = false,
3308
-        $what = 'item',
3309
-        $action_desc = 'processed',
3310
-        $query_args = [],
3311
-        $override_overwrite = false
3312
-    ) {
3313
-        $this->_redirect_after_action(
3314
-            $success,
3315
-            $what,
3316
-            $action_desc,
3317
-            $query_args,
3318
-            $override_overwrite
3319
-        );
3320
-    }
3321
-
3322
-
3323
-    /**
3324
-     * Helper method for merging existing request data with the returned redirect url.
3325
-     *
3326
-     * This is typically used for redirects after an action so that if the original view was a filtered view those
3327
-     * filters are still applied.
3328
-     *
3329
-     * @param array $new_route_data
3330
-     * @return array
3331
-     */
3332
-    protected function mergeExistingRequestParamsWithRedirectArgs(array $new_route_data)
3333
-    {
3334
-        foreach ($this->request->requestParams() as $ref => $value) {
3335
-            // unset nonces
3336
-            if (strpos($ref, 'nonce') !== false) {
3337
-                $this->request->unSetRequestParam($ref);
3338
-                continue;
3339
-            }
3340
-            // urlencode values.
3341
-            $value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
3342
-            $this->request->setRequestParam($ref, $value);
3343
-        }
3344
-        return array_merge($this->request->requestParams(), $new_route_data);
3345
-    }
3346
-
3347
-
3348
-    /**
3349
-     * @param int|float|string $success      - whether success was for two or more records, or just one, or none
3350
-     * @param string           $what         - what the action was performed on
3351
-     * @param string           $action_desc  - what was done ie: updated, deleted, etc
3352
-     * @param array $query_args              - an array of query_args to be added to the URL to redirect to
3353
-     * @param BOOL $override_overwrite       - by default all EE_Error::success messages are overwritten,
3354
-     *                                         this allows you to override this so that they show.
3355
-     * @return void
3356
-     * @throws EE_Error
3357
-     * @throws InvalidArgumentException
3358
-     * @throws InvalidDataTypeException
3359
-     * @throws InvalidInterfaceException
3360
-     */
3361
-    protected function _redirect_after_action(
3362
-        $success = 0,
3363
-        string $what = 'item',
3364
-        string $action_desc = 'processed',
3365
-        array $query_args = [],
3366
-        bool $override_overwrite = false
3367
-    ) {
3368
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3369
-        $notices      = EE_Error::get_notices(false);
3370
-        // overwrite default success messages //BUT ONLY if overwrite not overridden
3371
-        if (! $override_overwrite || ! empty($notices['errors'])) {
3372
-            EE_Error::overwrite_success();
3373
-        }
3374
-        if (! $override_overwrite && ! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3375
-            // how many records affected ? more than one record ? or just one ?
3376
-            EE_Error::add_success(
3377
-                sprintf(
3378
-                    esc_html(
3379
-                        _n(
3380
-                            'The "%s" has been successfully %s.',
3381
-                            'The "%s" have been successfully %s.',
3382
-                            $success,
3383
-                            'event_espresso'
3384
-                        )
3385
-                    ),
3386
-                    $what,
3387
-                    $action_desc
3388
-                ),
3389
-                __FILE__,
3390
-                __FUNCTION__,
3391
-                __LINE__
3392
-            );
3393
-        }
3394
-        // check that $query_args isn't something crazy
3395
-        if (! is_array($query_args)) {
3396
-            $query_args = [];
3397
-        }
3398
-        // class name for actions/filters.
3399
-        $classname = get_class($this);
3400
-        /**
3401
-         * Allow injecting actions before the query_args are modified for possible different
3402
-         * redirections on save and close actions
3403
-         *
3404
-         * @param array $query_args       The original query_args array coming into the
3405
-         *                                method.
3406
-         * @since 4.2.0
3407
-         */
3408
-        do_action(
3409
-            "AHEE__{$classname}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3410
-            $query_args
3411
-        );
3412
-        // set redirect url.
3413
-        // Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3414
-        // otherwise we go with whatever is set as the _admin_base_url
3415
-        $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3416
-        // calculate where we're going (if we have a "save and close" button pushed)
3417
-        if (
3418
-            $this->request->requestParamIsSet('save_and_close')
3419
-            && $this->request->requestParamIsSet('save_and_close_referrer')
3420
-        ) {
3421
-            // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3422
-            $parsed_url = parse_url($this->request->getRequestParam('save_and_close_referrer', '', 'url'));
3423
-            // regenerate query args array from referrer URL
3424
-            parse_str($parsed_url['query'], $query_args);
3425
-            // correct page and action will be in the query args now
3426
-            $redirect_url = admin_url('admin.php');
3427
-        }
3428
-        // merge any default query_args set in _default_route_query_args property
3429
-        if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3430
-            $args_to_merge = [];
3431
-            foreach ($this->_default_route_query_args as $query_param => $query_value) {
3432
-                // is there a wp_referer array in our _default_route_query_args property?
3433
-                if ($query_param === 'wp_referer') {
3434
-                    $query_value = (array) $query_value;
3435
-                    foreach ($query_value as $reference => $value) {
3436
-                        if (strpos($reference, 'nonce') !== false) {
3437
-                            continue;
3438
-                        }
3439
-                        // finally we will override any arguments in the referer with
3440
-                        // what might be set on the _default_route_query_args array.
3441
-                        if (isset($this->_default_route_query_args[ $reference ])) {
3442
-                            $args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3443
-                        } else {
3444
-                            $args_to_merge[ $reference ] = urlencode($value);
3445
-                        }
3446
-                    }
3447
-                    continue;
3448
-                }
3449
-                $args_to_merge[ $query_param ] = $query_value;
3450
-            }
3451
-            // now let's merge these arguments but override with what was specifically sent in to the
3452
-            // redirect.
3453
-            $query_args = array_merge($args_to_merge, $query_args);
3454
-        }
3455
-        $this->_process_notices($query_args);
3456
-        // generate redirect url
3457
-        // if redirecting to anything other than the main page, add a nonce
3458
-        if (isset($query_args['action'])) {
3459
-            // manually generate wp_nonce and merge that with the query vars
3460
-            // becuz the wp_nonce_url function wrecks havoc on some vars
3461
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3462
-        }
3463
-        // we're adding some hooks and filters in here for processing any things just before redirects
3464
-        // (example: an admin page has done an insert or update and we want to run something after that).
3465
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3466
-        $redirect_url = apply_filters(
3467
-            'FHEE_redirect_' . $classname . $this->_req_action,
3468
-            EE_Admin_Page::add_query_args_and_nonce($query_args, $redirect_url),
3469
-            $query_args
3470
-        );
3471
-        // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3472
-        if ($this->request->isAjax()) {
3473
-            $default_data                    = [
3474
-                'close'        => true,
3475
-                'redirect_url' => $redirect_url,
3476
-                'where'        => 'main',
3477
-                'what'         => 'append',
3478
-            ];
3479
-            $this->_template_args['success'] = $success;
3480
-            $this->_template_args['data']    = ! empty($this->_template_args['data']) ? array_merge(
3481
-                $default_data,
3482
-                $this->_template_args['data']
3483
-            ) : $default_data;
3484
-            $this->_return_json();
3485
-        }
3486
-        wp_safe_redirect($redirect_url);
3487
-        exit();
3488
-    }
3489
-
3490
-
3491
-    /**
3492
-     * process any notices before redirecting (or returning ajax request)
3493
-     * This method sets the $this->_template_args['notices'] attribute;
3494
-     *
3495
-     * @param array $query_args         any query args that need to be used for notice transient ('action')
3496
-     * @param bool  $skip_route_verify  This is typically used when we are processing notices REALLY early and
3497
-     *                                  page_routes haven't been defined yet.
3498
-     * @param bool  $sticky_notices     This is used to flag that regardless of whether this is doing_ajax or not, we
3499
-     *                                  still save a transient for the notice.
3500
-     * @return void
3501
-     * @throws EE_Error
3502
-     * @throws InvalidArgumentException
3503
-     * @throws InvalidDataTypeException
3504
-     * @throws InvalidInterfaceException
3505
-     */
3506
-    protected function _process_notices($query_args = [], $skip_route_verify = false, $sticky_notices = true)
3507
-    {
3508
-        // first let's set individual error properties if doing_ajax and the properties aren't already set.
3509
-        if ($this->request->isAjax()) {
3510
-            $notices = EE_Error::get_notices(false);
3511
-            if (empty($this->_template_args['success'])) {
3512
-                $this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3513
-            }
3514
-            if (empty($this->_template_args['errors'])) {
3515
-                $this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3516
-            }
3517
-            if (empty($this->_template_args['attention'])) {
3518
-                $this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3519
-            }
3520
-        }
3521
-        $this->_template_args['notices'] = EE_Error::get_notices();
3522
-        // IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3523
-        if (! $this->request->isAjax() || $sticky_notices) {
3524
-            $route = isset($query_args['action']) ? $query_args['action'] : 'default';
3525
-            $this->_add_transient(
3526
-                $route,
3527
-                $this->_template_args['notices'],
3528
-                true,
3529
-                $skip_route_verify
3530
-            );
3531
-        }
3532
-    }
3533
-
3534
-
3535
-    /**
3536
-     * get_action_link_or_button
3537
-     * returns the button html for adding, editing, or deleting an item (depending on given type)
3538
-     *
3539
-     * @param string $action        use this to indicate which action the url is generated with.
3540
-     * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3541
-     *                              property.
3542
-     * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3543
-     * @param string $class         Use this to give the class for the button. Defaults to 'button--primary'
3544
-     * @param string $base_url      If this is not provided
3545
-     *                              the _admin_base_url will be used as the default for the button base_url.
3546
-     *                              Otherwise this value will be used.
3547
-     * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3548
-     * @return string
3549
-     * @throws InvalidArgumentException
3550
-     * @throws InvalidInterfaceException
3551
-     * @throws InvalidDataTypeException
3552
-     * @throws EE_Error
3553
-     */
3554
-    public function get_action_link_or_button(
3555
-        $action,
3556
-        $type = 'add',
3557
-        $extra_request = [],
3558
-        $class = 'button--primary',
3559
-        $base_url = '',
3560
-        $exclude_nonce = false
3561
-    ) {
3562
-        // first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3563
-        if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3564
-            throw new EE_Error(
3565
-                sprintf(
3566
-                    esc_html__(
3567
-                        'There is no page route for given action for the button.  This action was given: %s',
3568
-                        'event_espresso'
3569
-                    ),
3570
-                    $action
3571
-                )
3572
-            );
3573
-        }
3574
-        if (! isset($this->_labels['buttons'][ $type ])) {
3575
-            throw new EE_Error(
3576
-                sprintf(
3577
-                    esc_html__(
3578
-                        'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3579
-                        'event_espresso'
3580
-                    ),
3581
-                    $type
3582
-                )
3583
-            );
3584
-        }
3585
-        // finally check user access for this button.
3586
-        $has_access = $this->check_user_access($action, true);
3587
-        if (! $has_access) {
3588
-            return '';
3589
-        }
3590
-        $_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
3591
-        $query_args = [
3592
-            'action' => $action,
3593
-        ];
3594
-        // merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3595
-        if (! empty($extra_request)) {
3596
-            $query_args = array_merge($extra_request, $query_args);
3597
-        }
3598
-        $url = EE_Admin_Page::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3599
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3600
-    }
3601
-
3602
-
3603
-    /**
3604
-     * _per_page_screen_option
3605
-     * Utility function for adding in a per_page_option in the screen_options_dropdown.
3606
-     *
3607
-     * @return void
3608
-     * @throws InvalidArgumentException
3609
-     * @throws InvalidInterfaceException
3610
-     * @throws InvalidDataTypeException
3611
-     */
3612
-    protected function _per_page_screen_option()
3613
-    {
3614
-        $option = 'per_page';
3615
-        $args   = [
3616
-            'label'   => apply_filters(
3617
-                'FHEE__EE_Admin_Page___per_page_screen_options___label',
3618
-                $this->_admin_page_title,
3619
-                $this
3620
-            ),
3621
-            'default' => (int) apply_filters(
3622
-                'FHEE__EE_Admin_Page___per_page_screen_options__default',
3623
-                20
3624
-            ),
3625
-            'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3626
-        ];
3627
-        // ONLY add the screen option if the user has access to it.
3628
-        if ($this->check_user_access($this->_current_view, true)) {
3629
-            add_screen_option($option, $args);
3630
-        }
3631
-    }
3632
-
3633
-
3634
-    /**
3635
-     * set_per_page_screen_option
3636
-     * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3637
-     * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3638
-     * admin_menu.
3639
-     *
3640
-     * @return void
3641
-     */
3642
-    private function _set_per_page_screen_options()
3643
-    {
3644
-        if ($this->request->requestParamIsSet('wp_screen_options')) {
3645
-            check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3646
-            if (! $user = wp_get_current_user()) {
3647
-                return;
3648
-            }
3649
-            $option = $this->request->getRequestParam('wp_screen_options[option]', '', 'key');
3650
-            if (! $option) {
3651
-                return;
3652
-            }
3653
-            $value  = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3654
-            $map_option = $option;
3655
-            $option     = str_replace('-', '_', $option);
3656
-            switch ($map_option) {
3657
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3658
-                    $max_value = apply_filters(
3659
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3660
-                        999,
3661
-                        $this->_current_page,
3662
-                        $this->_current_view
3663
-                    );
3664
-                    if ($value < 1) {
3665
-                        return;
3666
-                    }
3667
-                    $value = min($value, $max_value);
3668
-                    break;
3669
-                default:
3670
-                    $value = apply_filters(
3671
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3672
-                        false,
3673
-                        $option,
3674
-                        $value
3675
-                    );
3676
-                    if (false === $value) {
3677
-                        return;
3678
-                    }
3679
-                    break;
3680
-            }
3681
-            update_user_meta($user->ID, $option, $value);
3682
-            wp_safe_redirect(remove_query_arg(['pagenum', 'apage', 'paged'], wp_get_referer()));
3683
-            exit;
3684
-        }
3685
-    }
3686
-
3687
-
3688
-    /**
3689
-     * This just allows for setting the $_template_args property if it needs to be set outside the object
3690
-     *
3691
-     * @param array $data array that will be assigned to template args.
3692
-     */
3693
-    public function set_template_args($data)
3694
-    {
3695
-        $this->_template_args = array_merge($this->_template_args, (array) $data);
3696
-    }
3697
-
3698
-
3699
-    /**
3700
-     * This makes available the WP transient system for temporarily moving data between routes
3701
-     *
3702
-     * @param string $route             the route that should receive the transient
3703
-     * @param array  $data              the data that gets sent
3704
-     * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3705
-     *                                  normal route transient.
3706
-     * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3707
-     *                                  when we are adding a transient before page_routes have been defined.
3708
-     * @return void
3709
-     * @throws EE_Error
3710
-     */
3711
-    protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3712
-    {
3713
-        $user_id = get_current_user_id();
3714
-        if (! $skip_route_verify) {
3715
-            $this->_verify_route($route);
3716
-        }
3717
-        // now let's set the string for what kind of transient we're setting
3718
-        $transient = $notices
3719
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3720
-            : 'rte_tx_' . $route . '_' . $user_id;
3721
-        $data      = $notices ? ['notices' => $data] : $data;
3722
-        // is there already a transient for this route?  If there is then let's ADD to that transient
3723
-        $existing = is_multisite() && is_network_admin()
3724
-            ? get_site_transient($transient)
3725
-            : get_transient($transient);
3726
-        if ($existing) {
3727
-            $data = array_merge((array) $data, (array) $existing);
3728
-        }
3729
-        if (is_multisite() && is_network_admin()) {
3730
-            set_site_transient($transient, $data, 8);
3731
-        } else {
3732
-            set_transient($transient, $data, 8);
3733
-        }
3734
-    }
3735
-
3736
-
3737
-    /**
3738
-     * this retrieves the temporary transient that has been set for moving data between routes.
3739
-     *
3740
-     * @param bool   $notices true we get notices transient. False we just return normal route transient
3741
-     * @param string $route
3742
-     * @return mixed data
3743
-     */
3744
-    protected function _get_transient($notices = false, $route = '')
3745
-    {
3746
-        $user_id   = get_current_user_id();
3747
-        $route     = ! $route ? $this->_req_action : $route;
3748
-        $transient = $notices
3749
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3750
-            : 'rte_tx_' . $route . '_' . $user_id;
3751
-        $data      = is_multisite() && is_network_admin()
3752
-            ? get_site_transient($transient)
3753
-            : get_transient($transient);
3754
-        // delete transient after retrieval (just in case it hasn't expired);
3755
-        if (is_multisite() && is_network_admin()) {
3756
-            delete_site_transient($transient);
3757
-        } else {
3758
-            delete_transient($transient);
3759
-        }
3760
-        return $notices && isset($data['notices']) ? $data['notices'] : $data;
3761
-    }
3762
-
3763
-
3764
-    /**
3765
-     * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3766
-     * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3767
-     * default route callback on the EE_Admin page you want it run.)
3768
-     *
3769
-     * @return void
3770
-     */
3771
-    protected function _transient_garbage_collection()
3772
-    {
3773
-        global $wpdb;
3774
-        // retrieve all existing transients
3775
-        $query =
3776
-            "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3777
-        if ($results = $wpdb->get_results($query)) {
3778
-            foreach ($results as $result) {
3779
-                $transient = str_replace('_transient_', '', $result->option_name);
3780
-                get_transient($transient);
3781
-                if (is_multisite() && is_network_admin()) {
3782
-                    get_site_transient($transient);
3783
-                }
3784
-            }
3785
-        }
3786
-    }
3787
-
3788
-
3789
-    /**
3790
-     * get_view
3791
-     *
3792
-     * @return string content of _view property
3793
-     */
3794
-    public function get_view()
3795
-    {
3796
-        return $this->_view;
3797
-    }
3798
-
3799
-
3800
-    /**
3801
-     * getter for the protected $_views property
3802
-     *
3803
-     * @return array
3804
-     */
3805
-    public function get_views()
3806
-    {
3807
-        return $this->_views;
3808
-    }
3809
-
3810
-
3811
-    /**
3812
-     * get_current_page
3813
-     *
3814
-     * @return string _current_page property value
3815
-     */
3816
-    public function get_current_page()
3817
-    {
3818
-        return $this->_current_page;
3819
-    }
3820
-
3821
-
3822
-    /**
3823
-     * get_current_view
3824
-     *
3825
-     * @return string _current_view property value
3826
-     */
3827
-    public function get_current_view()
3828
-    {
3829
-        return $this->_current_view;
3830
-    }
3831
-
3832
-
3833
-    /**
3834
-     * get_current_screen
3835
-     *
3836
-     * @return object The current WP_Screen object
3837
-     */
3838
-    public function get_current_screen()
3839
-    {
3840
-        return $this->_current_screen;
3841
-    }
3842
-
3843
-
3844
-    /**
3845
-     * get_current_page_view_url
3846
-     *
3847
-     * @return string This returns the url for the current_page_view.
3848
-     */
3849
-    public function get_current_page_view_url()
3850
-    {
3851
-        return $this->_current_page_view_url;
3852
-    }
3853
-
3854
-
3855
-    /**
3856
-     * just returns the Request
3857
-     *
3858
-     * @return RequestInterface
3859
-     */
3860
-    public function get_request()
3861
-    {
3862
-        return $this->request;
3863
-    }
3864
-
3865
-
3866
-    /**
3867
-     * just returns the _req_data property
3868
-     *
3869
-     * @return array
3870
-     */
3871
-    public function get_request_data()
3872
-    {
3873
-        return $this->request->requestParams();
3874
-    }
3875
-
3876
-
3877
-    /**
3878
-     * returns the _req_data protected property
3879
-     *
3880
-     * @return string
3881
-     */
3882
-    public function get_req_action()
3883
-    {
3884
-        return $this->_req_action;
3885
-    }
3886
-
3887
-
3888
-    /**
3889
-     * @return bool  value of $_is_caf property
3890
-     */
3891
-    public function is_caf()
3892
-    {
3893
-        return $this->_is_caf;
3894
-    }
3895
-
3896
-
3897
-    /**
3898
-     * @return mixed
3899
-     */
3900
-    public function default_espresso_metaboxes()
3901
-    {
3902
-        return $this->_default_espresso_metaboxes;
3903
-    }
3904
-
3905
-
3906
-    /**
3907
-     * @return mixed
3908
-     */
3909
-    public function admin_base_url()
3910
-    {
3911
-        return $this->_admin_base_url;
3912
-    }
3913
-
3914
-
3915
-    /**
3916
-     * @return mixed
3917
-     */
3918
-    public function wp_page_slug()
3919
-    {
3920
-        return $this->_wp_page_slug;
3921
-    }
3922
-
3923
-
3924
-    /**
3925
-     * updates  espresso configuration settings
3926
-     *
3927
-     * @param string                   $tab
3928
-     * @param EE_Config_Base|EE_Config $config
3929
-     * @param string                   $file file where error occurred
3930
-     * @param string                   $func function  where error occurred
3931
-     * @param string                   $line line no where error occurred
3932
-     * @return boolean
3933
-     */
3934
-    protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
3935
-    {
3936
-        // remove any options that are NOT going to be saved with the config settings.
3937
-        if (isset($config->core->ee_ueip_optin)) {
3938
-            // TODO: remove the following two lines and make sure values are migrated from 3.1
3939
-            update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
3940
-            update_option('ee_ueip_has_notified', true);
3941
-        }
3942
-        // and save it (note we're also doing the network save here)
3943
-        $net_saved    = ! is_main_site() || EE_Network_Config::instance()->update_config(false, false);
3944
-        $config_saved = EE_Config::instance()->update_espresso_config(false, false);
3945
-        if ($config_saved && $net_saved) {
3946
-            EE_Error::add_success(sprintf(esc_html__('"%s" have been successfully updated.', 'event_espresso'), $tab));
3947
-            return true;
3948
-        }
3949
-        EE_Error::add_error(sprintf(esc_html__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
3950
-        return false;
3951
-    }
3952
-
3953
-
3954
-    /**
3955
-     * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
3956
-     *
3957
-     * @return array
3958
-     */
3959
-    public function get_yes_no_values()
3960
-    {
3961
-        return $this->_yes_no_values;
3962
-    }
3963
-
3964
-
3965
-    /**
3966
-     * @return string
3967
-     * @throws ReflectionException
3968
-     * @since $VID:$
3969
-     */
3970
-    protected function _get_dir()
3971
-    {
3972
-        $reflector = new ReflectionClass(get_class($this));
3973
-        return dirname($reflector->getFileName());
3974
-    }
3975
-
3976
-
3977
-    /**
3978
-     * A helper for getting a "next link".
3979
-     *
3980
-     * @param string $url   The url to link to
3981
-     * @param string $class The class to use.
3982
-     * @return string
3983
-     */
3984
-    protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
3985
-    {
3986
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3987
-    }
3988
-
3989
-
3990
-    /**
3991
-     * A helper for getting a "previous link".
3992
-     *
3993
-     * @param string $url   The url to link to
3994
-     * @param string $class The class to use.
3995
-     * @return string
3996
-     */
3997
-    protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
3998
-    {
3999
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4000
-    }
4001
-
4002
-
4003
-
4004
-
4005
-
4006
-
4007
-
4008
-    // below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
4009
-
4010
-
4011
-    /**
4012
-     * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
4013
-     * knows that the _REG_ID isn't in the req_data array but CAN obtain it, the caller should ADD the _REG_ID to the
4014
-     * _req_data array.
4015
-     *
4016
-     * @return bool success/fail
4017
-     * @throws EE_Error
4018
-     * @throws InvalidArgumentException
4019
-     * @throws ReflectionException
4020
-     * @throws InvalidDataTypeException
4021
-     * @throws InvalidInterfaceException
4022
-     */
4023
-    protected function _process_resend_registration()
4024
-    {
4025
-        $this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
4026
-        do_action(
4027
-            'AHEE__EE_Admin_Page___process_resend_registration',
4028
-            $this->_template_args['success'],
4029
-            $this->request->requestParams()
4030
-        );
4031
-        return $this->_template_args['success'];
4032
-    }
4033
-
4034
-
4035
-    /**
4036
-     * This automatically processes any payment message notifications when manual payment has been applied.
4037
-     *
4038
-     * @param EE_Payment $payment
4039
-     * @return bool success/fail
4040
-     */
4041
-    protected function _process_payment_notification(EE_Payment $payment)
4042
-    {
4043
-        add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
4044
-        do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
4045
-        $this->_template_args['success'] = apply_filters(
4046
-            'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
4047
-            false,
4048
-            $payment
4049
-        );
4050
-        return $this->_template_args['success'];
4051
-    }
4052
-
4053
-
4054
-    /**
4055
-     * @param EEM_Base      $entity_model
4056
-     * @param string        $entity_PK_name name of the primary key field used as a request param, ie: id, ID, etc
4057
-     * @param string        $action         one of the EE_Admin_List_Table::ACTION_* constants: delete, restore, trash
4058
-     * @param string        $delete_column  name of the field that denotes whether entity is trashed
4059
-     * @param callable|null $callback       called after entity is trashed, restored, or deleted
4060
-     * @return int|float
4061
-     * @throws EE_Error
4062
-     */
4063
-    protected function trashRestoreDeleteEntities(
4064
-            EEM_Base $entity_model,
4065
-            string $entity_PK_name,
4066
-            string $action = EE_Admin_List_Table::ACTION_DELETE,
4067
-            string $delete_column = '',
4068
-            callable $callback = null
4069
-    ) {
4070
-        $entity_PK      = $entity_model->get_primary_key_field();
4071
-        $entity_PK_name = $entity_PK_name ?: $entity_PK->get_name();
4072
-        $entity_PK_type = $this->resolveEntityFieldDataType($entity_PK);
4073
-        // grab ID if deleting a single entity
4074
-        if ($this->request->requestParamIsSet($entity_PK_name)) {
4075
-            $ID = $this->request->getRequestParam($entity_PK_name, 0, $entity_PK_type);
4076
-            return $this->trashRestoreDeleteEntity($entity_model, $ID, $action, $delete_column, $callback) ? 1 : 0;
4077
-        }
4078
-        // or grab checkbox array if bulk deleting
4079
-        $checkboxes = $this->request->getRequestParam('checkbox', [], $entity_PK_type, true);
4080
-        if (empty($checkboxes)) {
4081
-            return 0;
4082
-        }
4083
-        $success = 0;
4084
-        $IDs     = array_keys($checkboxes);
4085
-        // cycle thru bulk action checkboxes
4086
-        foreach ($IDs as $ID) {
4087
-            // increment $success
4088
-            if ($this->trashRestoreDeleteEntity($entity_model, $ID, $action, $delete_column, $callback)) {
4089
-                $success++;
4090
-            }
4091
-        }
4092
-        $count = (int) count($checkboxes);
4093
-        // if multiple entities were deleted successfully, then $deleted will be full count of deletions,
4094
-        // otherwise it will be a fraction of ( actual deletions / total entities to be deleted )
4095
-        return $success === $count ? $count : $success / $count;
4096
-    }
4097
-
4098
-
4099
-    /**
4100
-     * @param EE_Primary_Key_Field_Base $entity_PK
4101
-     * @return string
4102
-     * @throws EE_Error
4103
-     * @since   $VID:$
4104
-     */
4105
-    private function resolveEntityFieldDataType(EE_Primary_Key_Field_Base $entity_PK): string
4106
-    {
4107
-        $entity_PK_type = $entity_PK->getSchemaType();
4108
-        switch ($entity_PK_type) {
4109
-            case 'boolean':
4110
-                return 'bool';
4111
-            case 'integer':
4112
-                return 'int';
4113
-            case 'number':
4114
-                return 'float';
4115
-            case 'string':
4116
-                return 'string';
4117
-        }
4118
-        throw new RuntimeException(
4119
-                sprintf(
4120
-                        esc_html__(
4121
-                                '"%1$s" is an invalid schema type for the %2$s primary key.',
4122
-                                'event_espresso'
4123
-                        ),
4124
-                        $entity_PK_type,
4125
-                        $entity_PK->get_name()
4126
-                )
4127
-        );
4128
-    }
4129
-
4130
-
4131
-    /**
4132
-     * @param EEM_Base      $entity_model
4133
-     * @param int|string    $entity_ID
4134
-     * @param string        $action        one of the EE_Admin_List_Table::ACTION_* constants: delete, restore, trash
4135
-     * @param string        $delete_column name of the field that denotes whether entity is trashed
4136
-     * @param callable|null $callback      called after entity is trashed, restored, or deleted
4137
-     * @return bool
4138
-     */
4139
-    protected function trashRestoreDeleteEntity(
4140
-            EEM_Base $entity_model,
4141
-            $entity_ID,
4142
-            string $action,
4143
-            string $delete_column,
4144
-            ?callable $callback = null
4145
-    ): bool {
4146
-        $entity_ID = absint($entity_ID);
4147
-        if (! $entity_ID) {
4148
-            $this->trashRestoreDeleteError($action, $entity_model);
4149
-        }
4150
-        $result = 0;
4151
-        try {
4152
-            switch ($action) {
4153
-                case EE_Admin_List_Table::ACTION_DELETE:
4154
-                    $result = (bool) $entity_model->delete_permanently_by_ID($entity_ID);
4155
-                    break;
4156
-                case EE_Admin_List_Table::ACTION_RESTORE:
4157
-                    $this->validateDeleteColumn($entity_model, $delete_column);
4158
-                    $result = $entity_model->update_by_ID([$delete_column => 0], $entity_ID);
4159
-                    break;
4160
-                case EE_Admin_List_Table::ACTION_TRASH:
4161
-                    $this->validateDeleteColumn($entity_model, $delete_column);
4162
-                    $result = $entity_model->update_by_ID([$delete_column => 1], $entity_ID);
4163
-                    break;
4164
-            }
4165
-        } catch (Exception $exception) {
4166
-            $this->trashRestoreDeleteError($action, $entity_model, $exception);
4167
-        }
4168
-        if (is_callable($callback)) {
4169
-            call_user_func_array($callback, [$entity_model, $entity_ID, $action, $result, $delete_column]);
4170
-        }
4171
-        return $result;
4172
-    }
4173
-
4174
-
4175
-    /**
4176
-     * @param EEM_Base $entity_model
4177
-     * @param string   $delete_column
4178
-     * @since $VID:$
4179
-     */
4180
-    private function validateDeleteColumn(EEM_Base $entity_model, string $delete_column)
4181
-    {
4182
-        if (empty($delete_column)) {
4183
-            throw new DomainException(
4184
-                    sprintf(
4185
-                            esc_html__(
4186
-                                    'You need to specify the name of the "delete column" on the %2$s model, in order to trash or restore an entity.',
4187
-                                    'event_espresso'
4188
-                            ),
4189
-                            $entity_model->get_this_model_name()
4190
-                    )
4191
-            );
4192
-        }
4193
-        if (! $entity_model->has_field($delete_column)) {
4194
-            throw new DomainException(
4195
-                    sprintf(
4196
-                            esc_html__(
4197
-                                    'The %1$s field does not exist on the %2$s model.',
4198
-                                    'event_espresso'
4199
-                            ),
4200
-                            $delete_column,
4201
-                            $entity_model->get_this_model_name()
4202
-                    )
4203
-            );
4204
-        }
4205
-    }
4206
-
4207
-
4208
-    /**
4209
-     * @param EEM_Base       $entity_model
4210
-     * @param Exception|null $exception
4211
-     * @param string         $action
4212
-     * @since $VID:$
4213
-     */
4214
-    private function trashRestoreDeleteError(string $action, EEM_Base $entity_model, ?Exception $exception = null)
4215
-    {
4216
-        if ($exception instanceof Exception) {
4217
-            throw new RuntimeException(
4218
-                    sprintf(
4219
-                            esc_html__(
4220
-                                    'Could not %1$s the %2$s because the following error occurred: %3$s',
4221
-                                    'event_espresso'
4222
-                            ),
4223
-                            $action,
4224
-                            $entity_model->get_this_model_name(),
4225
-                            $exception->getMessage()
4226
-                    )
4227
-            );
4228
-        }
4229
-        throw new RuntimeException(
4230
-                sprintf(
4231
-                        esc_html__(
4232
-                                'Could not %1$s the %2$s because an invalid ID was received.',
4233
-                                'event_espresso'
4234
-                        ),
4235
-                        $action,
4236
-                        $entity_model->get_this_model_name()
4237
-                )
4238
-        );
4239
-    }
3270
+		// add nonce
3271
+		$nonce                                             =
3272
+			wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3273
+		$this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3274
+		// add REQUIRED form action
3275
+		$hidden_fields = [
3276
+			'action' => ['type' => 'hidden', 'value' => $route],
3277
+		];
3278
+		// merge arrays
3279
+		$hidden_fields = is_array($additional_hidden_fields)
3280
+			? array_merge($hidden_fields, $additional_hidden_fields)
3281
+			: $hidden_fields;
3282
+		// generate form fields
3283
+		$form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3284
+		// add fields to form
3285
+		foreach ((array) $form_fields as $form_field) {
3286
+			$this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3287
+		}
3288
+		// close form
3289
+		$this->_template_args['after_admin_page_content'] = '</form>';
3290
+	}
3291
+
3292
+
3293
+	/**
3294
+	 * Public Wrapper for _redirect_after_action() method since its
3295
+	 * discovered it would be useful for external code to have access.
3296
+	 *
3297
+	 * @param bool   $success
3298
+	 * @param string $what
3299
+	 * @param string $action_desc
3300
+	 * @param array  $query_args
3301
+	 * @param bool   $override_overwrite
3302
+	 * @throws EE_Error
3303
+	 * @see   EE_Admin_Page::_redirect_after_action() for params.
3304
+	 * @since 4.5.0
3305
+	 */
3306
+	public function redirect_after_action(
3307
+		$success = false,
3308
+		$what = 'item',
3309
+		$action_desc = 'processed',
3310
+		$query_args = [],
3311
+		$override_overwrite = false
3312
+	) {
3313
+		$this->_redirect_after_action(
3314
+			$success,
3315
+			$what,
3316
+			$action_desc,
3317
+			$query_args,
3318
+			$override_overwrite
3319
+		);
3320
+	}
3321
+
3322
+
3323
+	/**
3324
+	 * Helper method for merging existing request data with the returned redirect url.
3325
+	 *
3326
+	 * This is typically used for redirects after an action so that if the original view was a filtered view those
3327
+	 * filters are still applied.
3328
+	 *
3329
+	 * @param array $new_route_data
3330
+	 * @return array
3331
+	 */
3332
+	protected function mergeExistingRequestParamsWithRedirectArgs(array $new_route_data)
3333
+	{
3334
+		foreach ($this->request->requestParams() as $ref => $value) {
3335
+			// unset nonces
3336
+			if (strpos($ref, 'nonce') !== false) {
3337
+				$this->request->unSetRequestParam($ref);
3338
+				continue;
3339
+			}
3340
+			// urlencode values.
3341
+			$value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
3342
+			$this->request->setRequestParam($ref, $value);
3343
+		}
3344
+		return array_merge($this->request->requestParams(), $new_route_data);
3345
+	}
3346
+
3347
+
3348
+	/**
3349
+	 * @param int|float|string $success      - whether success was for two or more records, or just one, or none
3350
+	 * @param string           $what         - what the action was performed on
3351
+	 * @param string           $action_desc  - what was done ie: updated, deleted, etc
3352
+	 * @param array $query_args              - an array of query_args to be added to the URL to redirect to
3353
+	 * @param BOOL $override_overwrite       - by default all EE_Error::success messages are overwritten,
3354
+	 *                                         this allows you to override this so that they show.
3355
+	 * @return void
3356
+	 * @throws EE_Error
3357
+	 * @throws InvalidArgumentException
3358
+	 * @throws InvalidDataTypeException
3359
+	 * @throws InvalidInterfaceException
3360
+	 */
3361
+	protected function _redirect_after_action(
3362
+		$success = 0,
3363
+		string $what = 'item',
3364
+		string $action_desc = 'processed',
3365
+		array $query_args = [],
3366
+		bool $override_overwrite = false
3367
+	) {
3368
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3369
+		$notices      = EE_Error::get_notices(false);
3370
+		// overwrite default success messages //BUT ONLY if overwrite not overridden
3371
+		if (! $override_overwrite || ! empty($notices['errors'])) {
3372
+			EE_Error::overwrite_success();
3373
+		}
3374
+		if (! $override_overwrite && ! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3375
+			// how many records affected ? more than one record ? or just one ?
3376
+			EE_Error::add_success(
3377
+				sprintf(
3378
+					esc_html(
3379
+						_n(
3380
+							'The "%s" has been successfully %s.',
3381
+							'The "%s" have been successfully %s.',
3382
+							$success,
3383
+							'event_espresso'
3384
+						)
3385
+					),
3386
+					$what,
3387
+					$action_desc
3388
+				),
3389
+				__FILE__,
3390
+				__FUNCTION__,
3391
+				__LINE__
3392
+			);
3393
+		}
3394
+		// check that $query_args isn't something crazy
3395
+		if (! is_array($query_args)) {
3396
+			$query_args = [];
3397
+		}
3398
+		// class name for actions/filters.
3399
+		$classname = get_class($this);
3400
+		/**
3401
+		 * Allow injecting actions before the query_args are modified for possible different
3402
+		 * redirections on save and close actions
3403
+		 *
3404
+		 * @param array $query_args       The original query_args array coming into the
3405
+		 *                                method.
3406
+		 * @since 4.2.0
3407
+		 */
3408
+		do_action(
3409
+			"AHEE__{$classname}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3410
+			$query_args
3411
+		);
3412
+		// set redirect url.
3413
+		// Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3414
+		// otherwise we go with whatever is set as the _admin_base_url
3415
+		$redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3416
+		// calculate where we're going (if we have a "save and close" button pushed)
3417
+		if (
3418
+			$this->request->requestParamIsSet('save_and_close')
3419
+			&& $this->request->requestParamIsSet('save_and_close_referrer')
3420
+		) {
3421
+			// even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3422
+			$parsed_url = parse_url($this->request->getRequestParam('save_and_close_referrer', '', 'url'));
3423
+			// regenerate query args array from referrer URL
3424
+			parse_str($parsed_url['query'], $query_args);
3425
+			// correct page and action will be in the query args now
3426
+			$redirect_url = admin_url('admin.php');
3427
+		}
3428
+		// merge any default query_args set in _default_route_query_args property
3429
+		if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3430
+			$args_to_merge = [];
3431
+			foreach ($this->_default_route_query_args as $query_param => $query_value) {
3432
+				// is there a wp_referer array in our _default_route_query_args property?
3433
+				if ($query_param === 'wp_referer') {
3434
+					$query_value = (array) $query_value;
3435
+					foreach ($query_value as $reference => $value) {
3436
+						if (strpos($reference, 'nonce') !== false) {
3437
+							continue;
3438
+						}
3439
+						// finally we will override any arguments in the referer with
3440
+						// what might be set on the _default_route_query_args array.
3441
+						if (isset($this->_default_route_query_args[ $reference ])) {
3442
+							$args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3443
+						} else {
3444
+							$args_to_merge[ $reference ] = urlencode($value);
3445
+						}
3446
+					}
3447
+					continue;
3448
+				}
3449
+				$args_to_merge[ $query_param ] = $query_value;
3450
+			}
3451
+			// now let's merge these arguments but override with what was specifically sent in to the
3452
+			// redirect.
3453
+			$query_args = array_merge($args_to_merge, $query_args);
3454
+		}
3455
+		$this->_process_notices($query_args);
3456
+		// generate redirect url
3457
+		// if redirecting to anything other than the main page, add a nonce
3458
+		if (isset($query_args['action'])) {
3459
+			// manually generate wp_nonce and merge that with the query vars
3460
+			// becuz the wp_nonce_url function wrecks havoc on some vars
3461
+			$query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3462
+		}
3463
+		// we're adding some hooks and filters in here for processing any things just before redirects
3464
+		// (example: an admin page has done an insert or update and we want to run something after that).
3465
+		do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3466
+		$redirect_url = apply_filters(
3467
+			'FHEE_redirect_' . $classname . $this->_req_action,
3468
+			EE_Admin_Page::add_query_args_and_nonce($query_args, $redirect_url),
3469
+			$query_args
3470
+		);
3471
+		// check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3472
+		if ($this->request->isAjax()) {
3473
+			$default_data                    = [
3474
+				'close'        => true,
3475
+				'redirect_url' => $redirect_url,
3476
+				'where'        => 'main',
3477
+				'what'         => 'append',
3478
+			];
3479
+			$this->_template_args['success'] = $success;
3480
+			$this->_template_args['data']    = ! empty($this->_template_args['data']) ? array_merge(
3481
+				$default_data,
3482
+				$this->_template_args['data']
3483
+			) : $default_data;
3484
+			$this->_return_json();
3485
+		}
3486
+		wp_safe_redirect($redirect_url);
3487
+		exit();
3488
+	}
3489
+
3490
+
3491
+	/**
3492
+	 * process any notices before redirecting (or returning ajax request)
3493
+	 * This method sets the $this->_template_args['notices'] attribute;
3494
+	 *
3495
+	 * @param array $query_args         any query args that need to be used for notice transient ('action')
3496
+	 * @param bool  $skip_route_verify  This is typically used when we are processing notices REALLY early and
3497
+	 *                                  page_routes haven't been defined yet.
3498
+	 * @param bool  $sticky_notices     This is used to flag that regardless of whether this is doing_ajax or not, we
3499
+	 *                                  still save a transient for the notice.
3500
+	 * @return void
3501
+	 * @throws EE_Error
3502
+	 * @throws InvalidArgumentException
3503
+	 * @throws InvalidDataTypeException
3504
+	 * @throws InvalidInterfaceException
3505
+	 */
3506
+	protected function _process_notices($query_args = [], $skip_route_verify = false, $sticky_notices = true)
3507
+	{
3508
+		// first let's set individual error properties if doing_ajax and the properties aren't already set.
3509
+		if ($this->request->isAjax()) {
3510
+			$notices = EE_Error::get_notices(false);
3511
+			if (empty($this->_template_args['success'])) {
3512
+				$this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3513
+			}
3514
+			if (empty($this->_template_args['errors'])) {
3515
+				$this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3516
+			}
3517
+			if (empty($this->_template_args['attention'])) {
3518
+				$this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3519
+			}
3520
+		}
3521
+		$this->_template_args['notices'] = EE_Error::get_notices();
3522
+		// IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3523
+		if (! $this->request->isAjax() || $sticky_notices) {
3524
+			$route = isset($query_args['action']) ? $query_args['action'] : 'default';
3525
+			$this->_add_transient(
3526
+				$route,
3527
+				$this->_template_args['notices'],
3528
+				true,
3529
+				$skip_route_verify
3530
+			);
3531
+		}
3532
+	}
3533
+
3534
+
3535
+	/**
3536
+	 * get_action_link_or_button
3537
+	 * returns the button html for adding, editing, or deleting an item (depending on given type)
3538
+	 *
3539
+	 * @param string $action        use this to indicate which action the url is generated with.
3540
+	 * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3541
+	 *                              property.
3542
+	 * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3543
+	 * @param string $class         Use this to give the class for the button. Defaults to 'button--primary'
3544
+	 * @param string $base_url      If this is not provided
3545
+	 *                              the _admin_base_url will be used as the default for the button base_url.
3546
+	 *                              Otherwise this value will be used.
3547
+	 * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3548
+	 * @return string
3549
+	 * @throws InvalidArgumentException
3550
+	 * @throws InvalidInterfaceException
3551
+	 * @throws InvalidDataTypeException
3552
+	 * @throws EE_Error
3553
+	 */
3554
+	public function get_action_link_or_button(
3555
+		$action,
3556
+		$type = 'add',
3557
+		$extra_request = [],
3558
+		$class = 'button--primary',
3559
+		$base_url = '',
3560
+		$exclude_nonce = false
3561
+	) {
3562
+		// first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3563
+		if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3564
+			throw new EE_Error(
3565
+				sprintf(
3566
+					esc_html__(
3567
+						'There is no page route for given action for the button.  This action was given: %s',
3568
+						'event_espresso'
3569
+					),
3570
+					$action
3571
+				)
3572
+			);
3573
+		}
3574
+		if (! isset($this->_labels['buttons'][ $type ])) {
3575
+			throw new EE_Error(
3576
+				sprintf(
3577
+					esc_html__(
3578
+						'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3579
+						'event_espresso'
3580
+					),
3581
+					$type
3582
+				)
3583
+			);
3584
+		}
3585
+		// finally check user access for this button.
3586
+		$has_access = $this->check_user_access($action, true);
3587
+		if (! $has_access) {
3588
+			return '';
3589
+		}
3590
+		$_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
3591
+		$query_args = [
3592
+			'action' => $action,
3593
+		];
3594
+		// merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3595
+		if (! empty($extra_request)) {
3596
+			$query_args = array_merge($extra_request, $query_args);
3597
+		}
3598
+		$url = EE_Admin_Page::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3599
+		return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3600
+	}
3601
+
3602
+
3603
+	/**
3604
+	 * _per_page_screen_option
3605
+	 * Utility function for adding in a per_page_option in the screen_options_dropdown.
3606
+	 *
3607
+	 * @return void
3608
+	 * @throws InvalidArgumentException
3609
+	 * @throws InvalidInterfaceException
3610
+	 * @throws InvalidDataTypeException
3611
+	 */
3612
+	protected function _per_page_screen_option()
3613
+	{
3614
+		$option = 'per_page';
3615
+		$args   = [
3616
+			'label'   => apply_filters(
3617
+				'FHEE__EE_Admin_Page___per_page_screen_options___label',
3618
+				$this->_admin_page_title,
3619
+				$this
3620
+			),
3621
+			'default' => (int) apply_filters(
3622
+				'FHEE__EE_Admin_Page___per_page_screen_options__default',
3623
+				20
3624
+			),
3625
+			'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3626
+		];
3627
+		// ONLY add the screen option if the user has access to it.
3628
+		if ($this->check_user_access($this->_current_view, true)) {
3629
+			add_screen_option($option, $args);
3630
+		}
3631
+	}
3632
+
3633
+
3634
+	/**
3635
+	 * set_per_page_screen_option
3636
+	 * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3637
+	 * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3638
+	 * admin_menu.
3639
+	 *
3640
+	 * @return void
3641
+	 */
3642
+	private function _set_per_page_screen_options()
3643
+	{
3644
+		if ($this->request->requestParamIsSet('wp_screen_options')) {
3645
+			check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3646
+			if (! $user = wp_get_current_user()) {
3647
+				return;
3648
+			}
3649
+			$option = $this->request->getRequestParam('wp_screen_options[option]', '', 'key');
3650
+			if (! $option) {
3651
+				return;
3652
+			}
3653
+			$value  = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3654
+			$map_option = $option;
3655
+			$option     = str_replace('-', '_', $option);
3656
+			switch ($map_option) {
3657
+				case $this->_current_page . '_' . $this->_current_view . '_per_page':
3658
+					$max_value = apply_filters(
3659
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3660
+						999,
3661
+						$this->_current_page,
3662
+						$this->_current_view
3663
+					);
3664
+					if ($value < 1) {
3665
+						return;
3666
+					}
3667
+					$value = min($value, $max_value);
3668
+					break;
3669
+				default:
3670
+					$value = apply_filters(
3671
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3672
+						false,
3673
+						$option,
3674
+						$value
3675
+					);
3676
+					if (false === $value) {
3677
+						return;
3678
+					}
3679
+					break;
3680
+			}
3681
+			update_user_meta($user->ID, $option, $value);
3682
+			wp_safe_redirect(remove_query_arg(['pagenum', 'apage', 'paged'], wp_get_referer()));
3683
+			exit;
3684
+		}
3685
+	}
3686
+
3687
+
3688
+	/**
3689
+	 * This just allows for setting the $_template_args property if it needs to be set outside the object
3690
+	 *
3691
+	 * @param array $data array that will be assigned to template args.
3692
+	 */
3693
+	public function set_template_args($data)
3694
+	{
3695
+		$this->_template_args = array_merge($this->_template_args, (array) $data);
3696
+	}
3697
+
3698
+
3699
+	/**
3700
+	 * This makes available the WP transient system for temporarily moving data between routes
3701
+	 *
3702
+	 * @param string $route             the route that should receive the transient
3703
+	 * @param array  $data              the data that gets sent
3704
+	 * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3705
+	 *                                  normal route transient.
3706
+	 * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3707
+	 *                                  when we are adding a transient before page_routes have been defined.
3708
+	 * @return void
3709
+	 * @throws EE_Error
3710
+	 */
3711
+	protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3712
+	{
3713
+		$user_id = get_current_user_id();
3714
+		if (! $skip_route_verify) {
3715
+			$this->_verify_route($route);
3716
+		}
3717
+		// now let's set the string for what kind of transient we're setting
3718
+		$transient = $notices
3719
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3720
+			: 'rte_tx_' . $route . '_' . $user_id;
3721
+		$data      = $notices ? ['notices' => $data] : $data;
3722
+		// is there already a transient for this route?  If there is then let's ADD to that transient
3723
+		$existing = is_multisite() && is_network_admin()
3724
+			? get_site_transient($transient)
3725
+			: get_transient($transient);
3726
+		if ($existing) {
3727
+			$data = array_merge((array) $data, (array) $existing);
3728
+		}
3729
+		if (is_multisite() && is_network_admin()) {
3730
+			set_site_transient($transient, $data, 8);
3731
+		} else {
3732
+			set_transient($transient, $data, 8);
3733
+		}
3734
+	}
3735
+
3736
+
3737
+	/**
3738
+	 * this retrieves the temporary transient that has been set for moving data between routes.
3739
+	 *
3740
+	 * @param bool   $notices true we get notices transient. False we just return normal route transient
3741
+	 * @param string $route
3742
+	 * @return mixed data
3743
+	 */
3744
+	protected function _get_transient($notices = false, $route = '')
3745
+	{
3746
+		$user_id   = get_current_user_id();
3747
+		$route     = ! $route ? $this->_req_action : $route;
3748
+		$transient = $notices
3749
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3750
+			: 'rte_tx_' . $route . '_' . $user_id;
3751
+		$data      = is_multisite() && is_network_admin()
3752
+			? get_site_transient($transient)
3753
+			: get_transient($transient);
3754
+		// delete transient after retrieval (just in case it hasn't expired);
3755
+		if (is_multisite() && is_network_admin()) {
3756
+			delete_site_transient($transient);
3757
+		} else {
3758
+			delete_transient($transient);
3759
+		}
3760
+		return $notices && isset($data['notices']) ? $data['notices'] : $data;
3761
+	}
3762
+
3763
+
3764
+	/**
3765
+	 * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3766
+	 * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3767
+	 * default route callback on the EE_Admin page you want it run.)
3768
+	 *
3769
+	 * @return void
3770
+	 */
3771
+	protected function _transient_garbage_collection()
3772
+	{
3773
+		global $wpdb;
3774
+		// retrieve all existing transients
3775
+		$query =
3776
+			"SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3777
+		if ($results = $wpdb->get_results($query)) {
3778
+			foreach ($results as $result) {
3779
+				$transient = str_replace('_transient_', '', $result->option_name);
3780
+				get_transient($transient);
3781
+				if (is_multisite() && is_network_admin()) {
3782
+					get_site_transient($transient);
3783
+				}
3784
+			}
3785
+		}
3786
+	}
3787
+
3788
+
3789
+	/**
3790
+	 * get_view
3791
+	 *
3792
+	 * @return string content of _view property
3793
+	 */
3794
+	public function get_view()
3795
+	{
3796
+		return $this->_view;
3797
+	}
3798
+
3799
+
3800
+	/**
3801
+	 * getter for the protected $_views property
3802
+	 *
3803
+	 * @return array
3804
+	 */
3805
+	public function get_views()
3806
+	{
3807
+		return $this->_views;
3808
+	}
3809
+
3810
+
3811
+	/**
3812
+	 * get_current_page
3813
+	 *
3814
+	 * @return string _current_page property value
3815
+	 */
3816
+	public function get_current_page()
3817
+	{
3818
+		return $this->_current_page;
3819
+	}
3820
+
3821
+
3822
+	/**
3823
+	 * get_current_view
3824
+	 *
3825
+	 * @return string _current_view property value
3826
+	 */
3827
+	public function get_current_view()
3828
+	{
3829
+		return $this->_current_view;
3830
+	}
3831
+
3832
+
3833
+	/**
3834
+	 * get_current_screen
3835
+	 *
3836
+	 * @return object The current WP_Screen object
3837
+	 */
3838
+	public function get_current_screen()
3839
+	{
3840
+		return $this->_current_screen;
3841
+	}
3842
+
3843
+
3844
+	/**
3845
+	 * get_current_page_view_url
3846
+	 *
3847
+	 * @return string This returns the url for the current_page_view.
3848
+	 */
3849
+	public function get_current_page_view_url()
3850
+	{
3851
+		return $this->_current_page_view_url;
3852
+	}
3853
+
3854
+
3855
+	/**
3856
+	 * just returns the Request
3857
+	 *
3858
+	 * @return RequestInterface
3859
+	 */
3860
+	public function get_request()
3861
+	{
3862
+		return $this->request;
3863
+	}
3864
+
3865
+
3866
+	/**
3867
+	 * just returns the _req_data property
3868
+	 *
3869
+	 * @return array
3870
+	 */
3871
+	public function get_request_data()
3872
+	{
3873
+		return $this->request->requestParams();
3874
+	}
3875
+
3876
+
3877
+	/**
3878
+	 * returns the _req_data protected property
3879
+	 *
3880
+	 * @return string
3881
+	 */
3882
+	public function get_req_action()
3883
+	{
3884
+		return $this->_req_action;
3885
+	}
3886
+
3887
+
3888
+	/**
3889
+	 * @return bool  value of $_is_caf property
3890
+	 */
3891
+	public function is_caf()
3892
+	{
3893
+		return $this->_is_caf;
3894
+	}
3895
+
3896
+
3897
+	/**
3898
+	 * @return mixed
3899
+	 */
3900
+	public function default_espresso_metaboxes()
3901
+	{
3902
+		return $this->_default_espresso_metaboxes;
3903
+	}
3904
+
3905
+
3906
+	/**
3907
+	 * @return mixed
3908
+	 */
3909
+	public function admin_base_url()
3910
+	{
3911
+		return $this->_admin_base_url;
3912
+	}
3913
+
3914
+
3915
+	/**
3916
+	 * @return mixed
3917
+	 */
3918
+	public function wp_page_slug()
3919
+	{
3920
+		return $this->_wp_page_slug;
3921
+	}
3922
+
3923
+
3924
+	/**
3925
+	 * updates  espresso configuration settings
3926
+	 *
3927
+	 * @param string                   $tab
3928
+	 * @param EE_Config_Base|EE_Config $config
3929
+	 * @param string                   $file file where error occurred
3930
+	 * @param string                   $func function  where error occurred
3931
+	 * @param string                   $line line no where error occurred
3932
+	 * @return boolean
3933
+	 */
3934
+	protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
3935
+	{
3936
+		// remove any options that are NOT going to be saved with the config settings.
3937
+		if (isset($config->core->ee_ueip_optin)) {
3938
+			// TODO: remove the following two lines and make sure values are migrated from 3.1
3939
+			update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
3940
+			update_option('ee_ueip_has_notified', true);
3941
+		}
3942
+		// and save it (note we're also doing the network save here)
3943
+		$net_saved    = ! is_main_site() || EE_Network_Config::instance()->update_config(false, false);
3944
+		$config_saved = EE_Config::instance()->update_espresso_config(false, false);
3945
+		if ($config_saved && $net_saved) {
3946
+			EE_Error::add_success(sprintf(esc_html__('"%s" have been successfully updated.', 'event_espresso'), $tab));
3947
+			return true;
3948
+		}
3949
+		EE_Error::add_error(sprintf(esc_html__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
3950
+		return false;
3951
+	}
3952
+
3953
+
3954
+	/**
3955
+	 * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
3956
+	 *
3957
+	 * @return array
3958
+	 */
3959
+	public function get_yes_no_values()
3960
+	{
3961
+		return $this->_yes_no_values;
3962
+	}
3963
+
3964
+
3965
+	/**
3966
+	 * @return string
3967
+	 * @throws ReflectionException
3968
+	 * @since $VID:$
3969
+	 */
3970
+	protected function _get_dir()
3971
+	{
3972
+		$reflector = new ReflectionClass(get_class($this));
3973
+		return dirname($reflector->getFileName());
3974
+	}
3975
+
3976
+
3977
+	/**
3978
+	 * A helper for getting a "next link".
3979
+	 *
3980
+	 * @param string $url   The url to link to
3981
+	 * @param string $class The class to use.
3982
+	 * @return string
3983
+	 */
3984
+	protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
3985
+	{
3986
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
3987
+	}
3988
+
3989
+
3990
+	/**
3991
+	 * A helper for getting a "previous link".
3992
+	 *
3993
+	 * @param string $url   The url to link to
3994
+	 * @param string $class The class to use.
3995
+	 * @return string
3996
+	 */
3997
+	protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
3998
+	{
3999
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
4000
+	}
4001
+
4002
+
4003
+
4004
+
4005
+
4006
+
4007
+
4008
+	// below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
4009
+
4010
+
4011
+	/**
4012
+	 * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
4013
+	 * knows that the _REG_ID isn't in the req_data array but CAN obtain it, the caller should ADD the _REG_ID to the
4014
+	 * _req_data array.
4015
+	 *
4016
+	 * @return bool success/fail
4017
+	 * @throws EE_Error
4018
+	 * @throws InvalidArgumentException
4019
+	 * @throws ReflectionException
4020
+	 * @throws InvalidDataTypeException
4021
+	 * @throws InvalidInterfaceException
4022
+	 */
4023
+	protected function _process_resend_registration()
4024
+	{
4025
+		$this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
4026
+		do_action(
4027
+			'AHEE__EE_Admin_Page___process_resend_registration',
4028
+			$this->_template_args['success'],
4029
+			$this->request->requestParams()
4030
+		);
4031
+		return $this->_template_args['success'];
4032
+	}
4033
+
4034
+
4035
+	/**
4036
+	 * This automatically processes any payment message notifications when manual payment has been applied.
4037
+	 *
4038
+	 * @param EE_Payment $payment
4039
+	 * @return bool success/fail
4040
+	 */
4041
+	protected function _process_payment_notification(EE_Payment $payment)
4042
+	{
4043
+		add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
4044
+		do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
4045
+		$this->_template_args['success'] = apply_filters(
4046
+			'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
4047
+			false,
4048
+			$payment
4049
+		);
4050
+		return $this->_template_args['success'];
4051
+	}
4052
+
4053
+
4054
+	/**
4055
+	 * @param EEM_Base      $entity_model
4056
+	 * @param string        $entity_PK_name name of the primary key field used as a request param, ie: id, ID, etc
4057
+	 * @param string        $action         one of the EE_Admin_List_Table::ACTION_* constants: delete, restore, trash
4058
+	 * @param string        $delete_column  name of the field that denotes whether entity is trashed
4059
+	 * @param callable|null $callback       called after entity is trashed, restored, or deleted
4060
+	 * @return int|float
4061
+	 * @throws EE_Error
4062
+	 */
4063
+	protected function trashRestoreDeleteEntities(
4064
+			EEM_Base $entity_model,
4065
+			string $entity_PK_name,
4066
+			string $action = EE_Admin_List_Table::ACTION_DELETE,
4067
+			string $delete_column = '',
4068
+			callable $callback = null
4069
+	) {
4070
+		$entity_PK      = $entity_model->get_primary_key_field();
4071
+		$entity_PK_name = $entity_PK_name ?: $entity_PK->get_name();
4072
+		$entity_PK_type = $this->resolveEntityFieldDataType($entity_PK);
4073
+		// grab ID if deleting a single entity
4074
+		if ($this->request->requestParamIsSet($entity_PK_name)) {
4075
+			$ID = $this->request->getRequestParam($entity_PK_name, 0, $entity_PK_type);
4076
+			return $this->trashRestoreDeleteEntity($entity_model, $ID, $action, $delete_column, $callback) ? 1 : 0;
4077
+		}
4078
+		// or grab checkbox array if bulk deleting
4079
+		$checkboxes = $this->request->getRequestParam('checkbox', [], $entity_PK_type, true);
4080
+		if (empty($checkboxes)) {
4081
+			return 0;
4082
+		}
4083
+		$success = 0;
4084
+		$IDs     = array_keys($checkboxes);
4085
+		// cycle thru bulk action checkboxes
4086
+		foreach ($IDs as $ID) {
4087
+			// increment $success
4088
+			if ($this->trashRestoreDeleteEntity($entity_model, $ID, $action, $delete_column, $callback)) {
4089
+				$success++;
4090
+			}
4091
+		}
4092
+		$count = (int) count($checkboxes);
4093
+		// if multiple entities were deleted successfully, then $deleted will be full count of deletions,
4094
+		// otherwise it will be a fraction of ( actual deletions / total entities to be deleted )
4095
+		return $success === $count ? $count : $success / $count;
4096
+	}
4097
+
4098
+
4099
+	/**
4100
+	 * @param EE_Primary_Key_Field_Base $entity_PK
4101
+	 * @return string
4102
+	 * @throws EE_Error
4103
+	 * @since   $VID:$
4104
+	 */
4105
+	private function resolveEntityFieldDataType(EE_Primary_Key_Field_Base $entity_PK): string
4106
+	{
4107
+		$entity_PK_type = $entity_PK->getSchemaType();
4108
+		switch ($entity_PK_type) {
4109
+			case 'boolean':
4110
+				return 'bool';
4111
+			case 'integer':
4112
+				return 'int';
4113
+			case 'number':
4114
+				return 'float';
4115
+			case 'string':
4116
+				return 'string';
4117
+		}
4118
+		throw new RuntimeException(
4119
+				sprintf(
4120
+						esc_html__(
4121
+								'"%1$s" is an invalid schema type for the %2$s primary key.',
4122
+								'event_espresso'
4123
+						),
4124
+						$entity_PK_type,
4125
+						$entity_PK->get_name()
4126
+				)
4127
+		);
4128
+	}
4129
+
4130
+
4131
+	/**
4132
+	 * @param EEM_Base      $entity_model
4133
+	 * @param int|string    $entity_ID
4134
+	 * @param string        $action        one of the EE_Admin_List_Table::ACTION_* constants: delete, restore, trash
4135
+	 * @param string        $delete_column name of the field that denotes whether entity is trashed
4136
+	 * @param callable|null $callback      called after entity is trashed, restored, or deleted
4137
+	 * @return bool
4138
+	 */
4139
+	protected function trashRestoreDeleteEntity(
4140
+			EEM_Base $entity_model,
4141
+			$entity_ID,
4142
+			string $action,
4143
+			string $delete_column,
4144
+			?callable $callback = null
4145
+	): bool {
4146
+		$entity_ID = absint($entity_ID);
4147
+		if (! $entity_ID) {
4148
+			$this->trashRestoreDeleteError($action, $entity_model);
4149
+		}
4150
+		$result = 0;
4151
+		try {
4152
+			switch ($action) {
4153
+				case EE_Admin_List_Table::ACTION_DELETE:
4154
+					$result = (bool) $entity_model->delete_permanently_by_ID($entity_ID);
4155
+					break;
4156
+				case EE_Admin_List_Table::ACTION_RESTORE:
4157
+					$this->validateDeleteColumn($entity_model, $delete_column);
4158
+					$result = $entity_model->update_by_ID([$delete_column => 0], $entity_ID);
4159
+					break;
4160
+				case EE_Admin_List_Table::ACTION_TRASH:
4161
+					$this->validateDeleteColumn($entity_model, $delete_column);
4162
+					$result = $entity_model->update_by_ID([$delete_column => 1], $entity_ID);
4163
+					break;
4164
+			}
4165
+		} catch (Exception $exception) {
4166
+			$this->trashRestoreDeleteError($action, $entity_model, $exception);
4167
+		}
4168
+		if (is_callable($callback)) {
4169
+			call_user_func_array($callback, [$entity_model, $entity_ID, $action, $result, $delete_column]);
4170
+		}
4171
+		return $result;
4172
+	}
4173
+
4174
+
4175
+	/**
4176
+	 * @param EEM_Base $entity_model
4177
+	 * @param string   $delete_column
4178
+	 * @since $VID:$
4179
+	 */
4180
+	private function validateDeleteColumn(EEM_Base $entity_model, string $delete_column)
4181
+	{
4182
+		if (empty($delete_column)) {
4183
+			throw new DomainException(
4184
+					sprintf(
4185
+							esc_html__(
4186
+									'You need to specify the name of the "delete column" on the %2$s model, in order to trash or restore an entity.',
4187
+									'event_espresso'
4188
+							),
4189
+							$entity_model->get_this_model_name()
4190
+					)
4191
+			);
4192
+		}
4193
+		if (! $entity_model->has_field($delete_column)) {
4194
+			throw new DomainException(
4195
+					sprintf(
4196
+							esc_html__(
4197
+									'The %1$s field does not exist on the %2$s model.',
4198
+									'event_espresso'
4199
+							),
4200
+							$delete_column,
4201
+							$entity_model->get_this_model_name()
4202
+					)
4203
+			);
4204
+		}
4205
+	}
4206
+
4207
+
4208
+	/**
4209
+	 * @param EEM_Base       $entity_model
4210
+	 * @param Exception|null $exception
4211
+	 * @param string         $action
4212
+	 * @since $VID:$
4213
+	 */
4214
+	private function trashRestoreDeleteError(string $action, EEM_Base $entity_model, ?Exception $exception = null)
4215
+	{
4216
+		if ($exception instanceof Exception) {
4217
+			throw new RuntimeException(
4218
+					sprintf(
4219
+							esc_html__(
4220
+									'Could not %1$s the %2$s because the following error occurred: %3$s',
4221
+									'event_espresso'
4222
+							),
4223
+							$action,
4224
+							$entity_model->get_this_model_name(),
4225
+							$exception->getMessage()
4226
+					)
4227
+			);
4228
+		}
4229
+		throw new RuntimeException(
4230
+				sprintf(
4231
+						esc_html__(
4232
+								'Could not %1$s the %2$s because an invalid ID was received.',
4233
+								'event_espresso'
4234
+						),
4235
+						$action,
4236
+						$entity_model->get_this_model_name()
4237
+				)
4238
+		);
4239
+	}
4240 4240
 }
Please login to merge, or discard this patch.
Spacing   +176 added lines, -176 removed lines patch added patch discarded remove patch
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
         $ee_menu_slugs = (array) $ee_menu_slugs;
602 602
         if (
603 603
             ! $this->request->isAjax()
604
-            && (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))
604
+            && ( ! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page]))
605 605
         ) {
606 606
             return;
607 607
         }
@@ -621,7 +621,7 @@  discard block
 block discarded – undo
621 621
             : $req_action;
622 622
 
623 623
         $this->_current_view = $this->_req_action;
624
-        $this->_req_nonce    = $this->_req_action . '_nonce';
624
+        $this->_req_nonce    = $this->_req_action.'_nonce';
625 625
         $this->_define_page_props();
626 626
         $this->_current_page_view_url = add_query_arg(
627 627
             ['page' => $this->_current_page, 'action' => $this->_current_view],
@@ -658,21 +658,21 @@  discard block
 block discarded – undo
658 658
         }
659 659
         // filter routes and page_config so addons can add their stuff. Filtering done per class
660 660
         $this->_page_routes = apply_filters(
661
-            'FHEE__' . get_class($this) . '__page_setup__page_routes',
661
+            'FHEE__'.get_class($this).'__page_setup__page_routes',
662 662
             $this->_page_routes,
663 663
             $this
664 664
         );
665 665
         $this->_page_config = apply_filters(
666
-            'FHEE__' . get_class($this) . '__page_setup__page_config',
666
+            'FHEE__'.get_class($this).'__page_setup__page_config',
667 667
             $this->_page_config,
668 668
             $this
669 669
         );
670 670
         // if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
671 671
         // then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
672
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
672
+        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view)) {
673 673
             add_action(
674 674
                 'AHEE__EE_Admin_Page__route_admin_request',
675
-                [$this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view],
675
+                [$this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view],
676 676
                 10,
677 677
                 2
678 678
             );
@@ -685,8 +685,8 @@  discard block
 block discarded – undo
685 685
             if ($this->_is_UI_request) {
686 686
                 // admin_init stuff - global, all views for this page class, specific view
687 687
                 add_action('admin_init', [$this, 'admin_init'], 10);
688
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
689
-                    add_action('admin_init', [$this, 'admin_init_' . $this->_current_view], 15);
688
+                if (method_exists($this, 'admin_init_'.$this->_current_view)) {
689
+                    add_action('admin_init', [$this, 'admin_init_'.$this->_current_view], 15);
690 690
                 }
691 691
             } else {
692 692
                 // hijack regular WP loading and route admin request immediately
@@ -705,12 +705,12 @@  discard block
 block discarded – undo
705 705
      */
706 706
     private function _do_other_page_hooks()
707 707
     {
708
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, []);
708
+        $registered_pages = apply_filters('FHEE_do_other_page_hooks_'.$this->page_slug, []);
709 709
         foreach ($registered_pages as $page) {
710 710
             // now let's setup the file name and class that should be present
711 711
             $classname = str_replace('.class.php', '', $page);
712 712
             // autoloaders should take care of loading file
713
-            if (! class_exists($classname)) {
713
+            if ( ! class_exists($classname)) {
714 714
                 $error_msg[] = sprintf(
715 715
                     esc_html__(
716 716
                         'Something went wrong with loading the %s admin hooks page.',
@@ -727,7 +727,7 @@  discard block
 block discarded – undo
727 727
                                    ),
728 728
                                    $page,
729 729
                                    '<br />',
730
-                                   '<strong>' . $classname . '</strong>'
730
+                                   '<strong>'.$classname.'</strong>'
731 731
                                );
732 732
                 throw new EE_Error(implode('||', $error_msg));
733 733
             }
@@ -769,13 +769,13 @@  discard block
 block discarded – undo
769 769
         // load admin_notices - global, page class, and view specific
770 770
         add_action('admin_notices', [$this, 'admin_notices_global'], 5);
771 771
         add_action('admin_notices', [$this, 'admin_notices'], 10);
772
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
773
-            add_action('admin_notices', [$this, 'admin_notices_' . $this->_current_view], 15);
772
+        if (method_exists($this, 'admin_notices_'.$this->_current_view)) {
773
+            add_action('admin_notices', [$this, 'admin_notices_'.$this->_current_view], 15);
774 774
         }
775 775
         // load network admin_notices - global, page class, and view specific
776 776
         add_action('network_admin_notices', [$this, 'network_admin_notices_global'], 5);
777
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
778
-            add_action('network_admin_notices', [$this, 'network_admin_notices_' . $this->_current_view]);
777
+        if (method_exists($this, 'network_admin_notices_'.$this->_current_view)) {
778
+            add_action('network_admin_notices', [$this, 'network_admin_notices_'.$this->_current_view]);
779 779
         }
780 780
         // this will save any per_page screen options if they are present
781 781
         $this->_set_per_page_screen_options();
@@ -896,7 +896,7 @@  discard block
 block discarded – undo
896 896
     protected function _verify_routes()
897 897
     {
898 898
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
899
-        if (! $this->_current_page && ! $this->request->isAjax()) {
899
+        if ( ! $this->_current_page && ! $this->request->isAjax()) {
900 900
             return false;
901 901
         }
902 902
         $this->_route = false;
@@ -908,7 +908,7 @@  discard block
 block discarded – undo
908 908
                 $this->_admin_page_title
909 909
             );
910 910
             // developer error msg
911
-            $error_msg .= '||' . $error_msg
911
+            $error_msg .= '||'.$error_msg
912 912
                           . esc_html__(
913 913
                               ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
914 914
                               'event_espresso'
@@ -917,8 +917,8 @@  discard block
 block discarded – undo
917 917
         }
918 918
         // and that the requested page route exists
919 919
         if (array_key_exists($this->_req_action, $this->_page_routes)) {
920
-            $this->_route        = $this->_page_routes[ $this->_req_action ];
921
-            $this->_route_config = $this->_page_config[ $this->_req_action ] ?? [];
920
+            $this->_route        = $this->_page_routes[$this->_req_action];
921
+            $this->_route_config = $this->_page_config[$this->_req_action] ?? [];
922 922
         } else {
923 923
             // user error msg
924 924
             $error_msg = sprintf(
@@ -929,7 +929,7 @@  discard block
 block discarded – undo
929 929
                 $this->_admin_page_title
930 930
             );
931 931
             // developer error msg
932
-            $error_msg .= '||' . $error_msg
932
+            $error_msg .= '||'.$error_msg
933 933
                           . sprintf(
934 934
                               esc_html__(
935 935
                                   ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
@@ -940,7 +940,7 @@  discard block
 block discarded – undo
940 940
             throw new EE_Error($error_msg);
941 941
         }
942 942
         // and that a default route exists
943
-        if (! array_key_exists('default', $this->_page_routes)) {
943
+        if ( ! array_key_exists('default', $this->_page_routes)) {
944 944
             // user error msg
945 945
             $error_msg = sprintf(
946 946
                 esc_html__(
@@ -950,7 +950,7 @@  discard block
 block discarded – undo
950 950
                 $this->_admin_page_title
951 951
             );
952 952
             // developer error msg
953
-            $error_msg .= '||' . $error_msg
953
+            $error_msg .= '||'.$error_msg
954 954
                           . esc_html__(
955 955
                               ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
956 956
                               'event_espresso'
@@ -992,7 +992,7 @@  discard block
 block discarded – undo
992 992
             $this->_admin_page_title
993 993
         );
994 994
         // developer error msg
995
-        $error_msg .= '||' . $error_msg
995
+        $error_msg .= '||'.$error_msg
996 996
                       . sprintf(
997 997
                           esc_html__(
998 998
                               ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
@@ -1020,7 +1020,7 @@  discard block
 block discarded – undo
1020 1020
     protected function _verify_nonce($nonce, $nonce_ref)
1021 1021
     {
1022 1022
         // verify nonce against expected value
1023
-        if (! wp_verify_nonce($nonce, $nonce_ref)) {
1023
+        if ( ! wp_verify_nonce($nonce, $nonce_ref)) {
1024 1024
             // these are not the droids you are looking for !!!
1025 1025
             $msg = sprintf(
1026 1026
                 esc_html__('%sNonce Fail.%s', 'event_espresso'),
@@ -1037,7 +1037,7 @@  discard block
 block discarded – undo
1037 1037
                     __CLASS__
1038 1038
                 );
1039 1039
             }
1040
-            if (! $this->request->isAjax()) {
1040
+            if ( ! $this->request->isAjax()) {
1041 1041
                 wp_die($msg);
1042 1042
             }
1043 1043
             EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
@@ -1061,7 +1061,7 @@  discard block
 block discarded – undo
1061 1061
      */
1062 1062
     protected function _route_admin_request()
1063 1063
     {
1064
-        if (! $this->_is_UI_request) {
1064
+        if ( ! $this->_is_UI_request) {
1065 1065
             $this->_verify_routes();
1066 1066
         }
1067 1067
         $nonce_check = ! isset($this->_route_config['require_nonce']) || $this->_route_config['require_nonce'];
@@ -1081,7 +1081,7 @@  discard block
 block discarded – undo
1081 1081
         $error_msg = '';
1082 1082
         // action right before calling route
1083 1083
         // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
1084
-        if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
1084
+        if ( ! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
1085 1085
             do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
1086 1086
         }
1087 1087
         // strip _wp_http_referer from the server REQUEST_URI
@@ -1093,7 +1093,7 @@  discard block
 block discarded – undo
1093 1093
         );
1094 1094
         // set new value in both our Request object and the super global
1095 1095
         $this->request->setServerParam('REQUEST_URI', $request_uri, true);
1096
-        if (! empty($func)) {
1096
+        if ( ! empty($func)) {
1097 1097
             if (is_array($func)) {
1098 1098
                 [$class, $method] = $func;
1099 1099
             } elseif (strpos($func, '::') !== false) {
@@ -1102,7 +1102,7 @@  discard block
 block discarded – undo
1102 1102
                 $class  = $this;
1103 1103
                 $method = $func;
1104 1104
             }
1105
-            if (! (is_object($class) && $class === $this)) {
1105
+            if ( ! (is_object($class) && $class === $this)) {
1106 1106
                 // send along this admin page object for access by addons.
1107 1107
                 $args['admin_page_object'] = $this;
1108 1108
             }
@@ -1143,7 +1143,7 @@  discard block
 block discarded – undo
1143 1143
                     $method
1144 1144
                 );
1145 1145
             }
1146
-            if (! empty($error_msg)) {
1146
+            if ( ! empty($error_msg)) {
1147 1147
                 throw new EE_Error($error_msg);
1148 1148
             }
1149 1149
         }
@@ -1229,7 +1229,7 @@  discard block
 block discarded – undo
1229 1229
                 if (strpos($key, 'nonce') !== false) {
1230 1230
                     continue;
1231 1231
                 }
1232
-                $args[ 'wp_referer[' . $key . ']' ] = is_string($value) ? htmlspecialchars($value) : $value;
1232
+                $args['wp_referer['.$key.']'] = is_string($value) ? htmlspecialchars($value) : $value;
1233 1233
             }
1234 1234
         }
1235 1235
         return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
@@ -1269,12 +1269,12 @@  discard block
 block discarded – undo
1269 1269
      */
1270 1270
     protected function _add_help_tabs()
1271 1271
     {
1272
-        if (isset($this->_page_config[ $this->_req_action ])) {
1273
-            $config = $this->_page_config[ $this->_req_action ];
1272
+        if (isset($this->_page_config[$this->_req_action])) {
1273
+            $config = $this->_page_config[$this->_req_action];
1274 1274
             // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1275 1275
             if (is_array($config) && isset($config['help_sidebar'])) {
1276 1276
                 // check that the callback given is valid
1277
-                if (! method_exists($this, $config['help_sidebar'])) {
1277
+                if ( ! method_exists($this, $config['help_sidebar'])) {
1278 1278
                     throw new EE_Error(
1279 1279
                         sprintf(
1280 1280
                             esc_html__(
@@ -1287,18 +1287,18 @@  discard block
 block discarded – undo
1287 1287
                     );
1288 1288
                 }
1289 1289
                 $content = apply_filters(
1290
-                    'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1290
+                    'FHEE__'.get_class($this).'__add_help_tabs__help_sidebar',
1291 1291
                     $this->{$config['help_sidebar']}()
1292 1292
                 );
1293 1293
                 $this->_current_screen->set_help_sidebar($content);
1294 1294
             }
1295
-            if (! isset($config['help_tabs'])) {
1295
+            if ( ! isset($config['help_tabs'])) {
1296 1296
                 return;
1297 1297
             } //no help tabs for this route
1298 1298
             foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1299 1299
                 // we're here so there ARE help tabs!
1300 1300
                 // make sure we've got what we need
1301
-                if (! isset($cfg['title'])) {
1301
+                if ( ! isset($cfg['title'])) {
1302 1302
                     throw new EE_Error(
1303 1303
                         esc_html__(
1304 1304
                             'The _page_config array is not set up properly for help tabs.  It is missing a title',
@@ -1306,7 +1306,7 @@  discard block
 block discarded – undo
1306 1306
                         )
1307 1307
                     );
1308 1308
                 }
1309
-                if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1309
+                if ( ! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1310 1310
                     throw new EE_Error(
1311 1311
                         esc_html__(
1312 1312
                             'The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab',
@@ -1315,11 +1315,11 @@  discard block
 block discarded – undo
1315 1315
                     );
1316 1316
                 }
1317 1317
                 // first priority goes to content.
1318
-                if (! empty($cfg['content'])) {
1318
+                if ( ! empty($cfg['content'])) {
1319 1319
                     $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1320 1320
                     // second priority goes to filename
1321
-                } elseif (! empty($cfg['filename'])) {
1322
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1321
+                } elseif ( ! empty($cfg['filename'])) {
1322
+                    $file_path = $this->_get_dir().'/help_tabs/'.$cfg['filename'].'.help_tab.php';
1323 1323
                     // it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too)
1324 1324
                     $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1325 1325
                                                              . basename($this->_get_dir())
@@ -1327,7 +1327,7 @@  discard block
 block discarded – undo
1327 1327
                                                              . $cfg['filename']
1328 1328
                                                              . '.help_tab.php' : $file_path;
1329 1329
                     // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1330
-                    if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1330
+                    if ( ! isset($cfg['callback']) && ! is_readable($file_path)) {
1331 1331
                         EE_Error::add_error(
1332 1332
                             sprintf(
1333 1333
                                 esc_html__(
@@ -1375,7 +1375,7 @@  discard block
 block discarded – undo
1375 1375
                     return;
1376 1376
                 }
1377 1377
                 // setup config array for help tab method
1378
-                $id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1378
+                $id  = $this->page_slug.'-'.$this->_req_action.'-'.$tab_id;
1379 1379
                 $_ht = [
1380 1380
                     'id'       => $id,
1381 1381
                     'title'    => $cfg['title'],
@@ -1401,8 +1401,8 @@  discard block
 block discarded – undo
1401 1401
             $qtips = (array) $this->_route_config['qtips'];
1402 1402
             // load qtip loader
1403 1403
             $path = [
1404
-                $this->_get_dir() . '/qtips/',
1405
-                EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1404
+                $this->_get_dir().'/qtips/',
1405
+                EE_ADMIN_PAGES.basename($this->_get_dir()).'/qtips/',
1406 1406
             ];
1407 1407
             EEH_Qtip_Loader::instance()->register($qtips, $path);
1408 1408
         }
@@ -1424,7 +1424,7 @@  discard block
 block discarded – undo
1424 1424
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1425 1425
         $i = 0;
1426 1426
         foreach ($this->_page_config as $slug => $config) {
1427
-            if (! is_array($config) || empty($config['nav'])) {
1427
+            if ( ! is_array($config) || empty($config['nav'])) {
1428 1428
                 continue;
1429 1429
             }
1430 1430
             // no nav tab for this config
@@ -1433,12 +1433,12 @@  discard block
 block discarded – undo
1433 1433
                 // nav tab is only to appear when route requested.
1434 1434
                 continue;
1435 1435
             }
1436
-            if (! $this->check_user_access($slug, true)) {
1436
+            if ( ! $this->check_user_access($slug, true)) {
1437 1437
                 // no nav tab because current user does not have access.
1438 1438
                 continue;
1439 1439
             }
1440
-            $css_class                = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1441
-            $this->_nav_tabs[ $slug ] = [
1440
+            $css_class                = isset($config['css_class']) ? $config['css_class'].' ' : '';
1441
+            $this->_nav_tabs[$slug] = [
1442 1442
                 'url'       => isset($config['nav']['url'])
1443 1443
                     ? $config['nav']['url']
1444 1444
                     : EE_Admin_Page::add_query_args_and_nonce(
@@ -1450,14 +1450,14 @@  discard block
 block discarded – undo
1450 1450
                     : ucwords(
1451 1451
                         str_replace('_', ' ', $slug)
1452 1452
                     ),
1453
-                'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1453
+                'css_class' => $this->_req_action === $slug ? $css_class.'nav-tab-active' : $css_class,
1454 1454
                 'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1455 1455
             ];
1456 1456
             $i++;
1457 1457
         }
1458 1458
         // if $this->_nav_tabs is empty then lets set the default
1459 1459
         if (empty($this->_nav_tabs)) {
1460
-            $this->_nav_tabs[ $this->_default_nav_tab_name ] = [
1460
+            $this->_nav_tabs[$this->_default_nav_tab_name] = [
1461 1461
                 'url'       => $this->_admin_base_url,
1462 1462
                 'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1463 1463
                 'css_class' => 'nav-tab-active',
@@ -1482,10 +1482,10 @@  discard block
 block discarded – undo
1482 1482
             foreach ($this->_route_config['labels'] as $label => $text) {
1483 1483
                 if (is_array($text)) {
1484 1484
                     foreach ($text as $sublabel => $subtext) {
1485
-                        $this->_labels[ $label ][ $sublabel ] = $subtext;
1485
+                        $this->_labels[$label][$sublabel] = $subtext;
1486 1486
                     }
1487 1487
                 } else {
1488
-                    $this->_labels[ $label ] = $text;
1488
+                    $this->_labels[$label] = $text;
1489 1489
                 }
1490 1490
             }
1491 1491
         }
@@ -1507,12 +1507,12 @@  discard block
 block discarded – undo
1507 1507
     {
1508 1508
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1509 1509
         $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1510
-        $capability     = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1510
+        $capability     = ! empty($route_to_check) && isset($this->_page_routes[$route_to_check])
1511 1511
                           && is_array(
1512
-                              $this->_page_routes[ $route_to_check ]
1512
+                              $this->_page_routes[$route_to_check]
1513 1513
                           )
1514
-                          && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1515
-            ? $this->_page_routes[ $route_to_check ]['capability'] : null;
1514
+                          && ! empty($this->_page_routes[$route_to_check]['capability'])
1515
+            ? $this->_page_routes[$route_to_check]['capability'] : null;
1516 1516
         if (empty($capability) && empty($route_to_check)) {
1517 1517
             $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1518 1518
                 : $this->_route['capability'];
@@ -1558,7 +1558,7 @@  discard block
 block discarded – undo
1558 1558
         add_meta_box($box_id, $title, $callback, $screen, $context, $priority, $callback_args);
1559 1559
         add_filter(
1560 1560
             "postbox_classes_{$this->_wp_page_slug}_{$box_id}",
1561
-            function ($classes) {
1561
+            function($classes) {
1562 1562
                 array_push($classes, 'ee-admin-container');
1563 1563
                 return $classes;
1564 1564
             }
@@ -1652,7 +1652,7 @@  discard block
 block discarded – undo
1652 1652
         ';
1653 1653
 
1654 1654
         // current set timezone for timezone js
1655
-        echo '<span id="current_timezone" class="hidden">' . esc_html(EEH_DTT_Helper::get_timezone()) . '</span>';
1655
+        echo '<span id="current_timezone" class="hidden">'.esc_html(EEH_DTT_Helper::get_timezone()).'</span>';
1656 1656
     }
1657 1657
 
1658 1658
 
@@ -1686,7 +1686,7 @@  discard block
 block discarded – undo
1686 1686
         // loop through the array and setup content
1687 1687
         foreach ($help_array as $trigger => $help) {
1688 1688
             // make sure the array is setup properly
1689
-            if (! isset($help['title'], $help['content'])) {
1689
+            if ( ! isset($help['title'], $help['content'])) {
1690 1690
                 throw new EE_Error(
1691 1691
                     esc_html__(
1692 1692
                         'Does not look like the popup content array has been setup correctly.  Might want to double check that.  Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class',
@@ -1700,8 +1700,8 @@  discard block
 block discarded – undo
1700 1700
                 'help_popup_title'   => $help['title'],
1701 1701
                 'help_popup_content' => $help['content'],
1702 1702
             ];
1703
-            $content       .= EEH_Template::display_template(
1704
-                EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1703
+            $content .= EEH_Template::display_template(
1704
+                EE_ADMIN_TEMPLATE.'admin_help_popup.template.php',
1705 1705
                 $template_args,
1706 1706
                 true
1707 1707
             );
@@ -1723,15 +1723,15 @@  discard block
 block discarded – undo
1723 1723
     private function _get_help_content()
1724 1724
     {
1725 1725
         // what is the method we're looking for?
1726
-        $method_name = '_help_popup_content_' . $this->_req_action;
1726
+        $method_name = '_help_popup_content_'.$this->_req_action;
1727 1727
         // if method doesn't exist let's get out.
1728
-        if (! method_exists($this, $method_name)) {
1728
+        if ( ! method_exists($this, $method_name)) {
1729 1729
             return [];
1730 1730
         }
1731 1731
         // k we're good to go let's retrieve the help array
1732 1732
         $help_array = $this->{$method_name}();
1733 1733
         // make sure we've got an array!
1734
-        if (! is_array($help_array)) {
1734
+        if ( ! is_array($help_array)) {
1735 1735
             throw new EE_Error(
1736 1736
                 esc_html__(
1737 1737
                     'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
@@ -1763,8 +1763,8 @@  discard block
 block discarded – undo
1763 1763
         // let's check and see if there is any content set for this popup.  If there isn't then we'll include a default title and content so that developers know something needs to be corrected
1764 1764
         $help_array   = $this->_get_help_content();
1765 1765
         $help_content = '';
1766
-        if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1767
-            $help_array[ $trigger_id ] = [
1766
+        if (empty($help_array) || ! isset($help_array[$trigger_id])) {
1767
+            $help_array[$trigger_id] = [
1768 1768
                 'title'   => esc_html__('Missing Content', 'event_espresso'),
1769 1769
                 'content' => esc_html__(
1770 1770
                     'A trigger has been set that doesn\'t have any corresponding content. Make sure you have set the help content. (see the "_set_help_popup_content" method in the EE_Admin_Page for instructions.)',
@@ -1857,7 +1857,7 @@  discard block
 block discarded – undo
1857 1857
         );
1858 1858
         add_filter(
1859 1859
             'admin_body_class',
1860
-            function ($classes) {
1860
+            function($classes) {
1861 1861
                 if (strpos($classes, 'espresso-admin') === false) {
1862 1862
                     $classes .= ' espresso-admin';
1863 1863
                 }
@@ -1948,12 +1948,12 @@  discard block
 block discarded – undo
1948 1948
     protected function _set_list_table()
1949 1949
     {
1950 1950
         // first is this a list_table view?
1951
-        if (! isset($this->_route_config['list_table'])) {
1951
+        if ( ! isset($this->_route_config['list_table'])) {
1952 1952
             return;
1953 1953
         } //not a list_table view so get out.
1954 1954
         // list table functions are per view specific (because some admin pages might have more than one list table!)
1955
-        $list_table_view = '_set_list_table_views_' . $this->_req_action;
1956
-        if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
1955
+        $list_table_view = '_set_list_table_views_'.$this->_req_action;
1956
+        if ( ! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
1957 1957
             // user error msg
1958 1958
             $error_msg = esc_html__(
1959 1959
                 'An error occurred. The requested list table views could not be found.',
@@ -1973,10 +1973,10 @@  discard block
 block discarded – undo
1973 1973
         }
1974 1974
         // let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
1975 1975
         $this->_views = apply_filters(
1976
-            'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
1976
+            'FHEE_list_table_views_'.$this->page_slug.'_'.$this->_req_action,
1977 1977
             $this->_views
1978 1978
         );
1979
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
1979
+        $this->_views = apply_filters('FHEE_list_table_views_'.$this->page_slug, $this->_views);
1980 1980
         $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
1981 1981
         $this->_set_list_table_view();
1982 1982
         $this->_set_list_table_object();
@@ -2011,7 +2011,7 @@  discard block
 block discarded – undo
2011 2011
     protected function _set_list_table_object()
2012 2012
     {
2013 2013
         if (isset($this->_route_config['list_table'])) {
2014
-            if (! class_exists($this->_route_config['list_table'])) {
2014
+            if ( ! class_exists($this->_route_config['list_table'])) {
2015 2015
                 throw new EE_Error(
2016 2016
                     sprintf(
2017 2017
                         esc_html__(
@@ -2049,17 +2049,17 @@  discard block
 block discarded – undo
2049 2049
         foreach ($this->_views as $key => $view) {
2050 2050
             $query_args = [];
2051 2051
             // check for current view
2052
-            $this->_views[ $key ]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2052
+            $this->_views[$key]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2053 2053
             $query_args['action']                        = $this->_req_action;
2054
-            $query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2054
+            $query_args[$this->_req_action.'_nonce'] = wp_create_nonce($query_args['action'].'_nonce');
2055 2055
             $query_args['status']                        = $view['slug'];
2056 2056
             // merge any other arguments sent in.
2057
-            if (isset($extra_query_args[ $view['slug'] ])) {
2058
-                foreach ($extra_query_args[ $view['slug'] ] as $extra_query_arg) {
2057
+            if (isset($extra_query_args[$view['slug']])) {
2058
+                foreach ($extra_query_args[$view['slug']] as $extra_query_arg) {
2059 2059
                     $query_args[] = $extra_query_arg;
2060 2060
                 }
2061 2061
             }
2062
-            $this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2062
+            $this->_views[$key]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2063 2063
         }
2064 2064
         return $this->_views;
2065 2065
     }
@@ -2090,14 +2090,14 @@  discard block
 block discarded – undo
2090 2090
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
2091 2091
         foreach ($values as $value) {
2092 2092
             if ($value < $max_entries) {
2093
-                $selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2093
+                $selected = $value === $per_page ? ' selected="'.$per_page.'"' : '';
2094 2094
                 $entries_per_page_dropdown .= '
2095
-						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
2095
+						<option value="' . $value.'"'.$selected.'>'.$value.'&nbsp;&nbsp;</option>';
2096 2096
             }
2097 2097
         }
2098
-        $selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2098
+        $selected = $max_entries === $per_page ? ' selected="'.$per_page.'"' : '';
2099 2099
         $entries_per_page_dropdown .= '
2100
-						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
2100
+						<option value="' . $max_entries.'"'.$selected.'>All&nbsp;&nbsp;</option>';
2101 2101
         $entries_per_page_dropdown .= '
2102 2102
 					</select>
2103 2103
 					entries
@@ -2121,7 +2121,7 @@  discard block
 block discarded – undo
2121 2121
             empty($this->_search_btn_label) ? $this->page_label
2122 2122
                 : $this->_search_btn_label
2123 2123
         );
2124
-        $this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2124
+        $this->_template_args['search']['callback'] = 'search_'.$this->page_slug;
2125 2125
     }
2126 2126
 
2127 2127
 
@@ -2209,7 +2209,7 @@  discard block
 block discarded – undo
2209 2209
             $total_columns                                       = ! empty($screen_columns)
2210 2210
                 ? $screen_columns
2211 2211
                 : $this->_route_config['columns'][1];
2212
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2212
+            $this->_template_args['current_screen_widget_class'] = 'columns-'.$total_columns;
2213 2213
             $this->_template_args['current_page']                = $this->_wp_page_slug;
2214 2214
             $this->_template_args['screen']                      = $this->_current_screen;
2215 2215
             $this->_column_template_path                         = EE_ADMIN_TEMPLATE
@@ -2255,7 +2255,7 @@  discard block
 block discarded – undo
2255 2255
      */
2256 2256
     protected function _espresso_ratings_request()
2257 2257
     {
2258
-        if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2258
+        if ( ! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2259 2259
             return;
2260 2260
         }
2261 2261
         $ratings_box_title = apply_filters(
@@ -2282,28 +2282,28 @@  discard block
 block discarded – undo
2282 2282
      */
2283 2283
     public function espresso_ratings_request()
2284 2284
     {
2285
-        EEH_Template::display_template(EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php');
2285
+        EEH_Template::display_template(EE_ADMIN_TEMPLATE.'espresso_ratings_request_content.template.php');
2286 2286
     }
2287 2287
 
2288 2288
 
2289 2289
     public static function cached_rss_display($rss_id, $url)
2290 2290
     {
2291
-        $loading   = '<p class="widget-loading hide-if-no-js">'
2291
+        $loading = '<p class="widget-loading hide-if-no-js">'
2292 2292
                      . esc_html__('Loading&#8230;', 'event_espresso')
2293 2293
                      . '</p><p class="hide-if-js">'
2294 2294
                      . esc_html__('This widget requires JavaScript.', 'event_espresso')
2295 2295
                      . '</p>';
2296
-        $pre       = '<div class="espresso-rss-display">' . "\n\t";
2297
-        $pre       .= '<span id="' . esc_attr($rss_id) . '_url" class="hidden">' . esc_url_raw($url) . '</span>';
2298
-        $post      = '</div>' . "\n";
2299
-        $cache_key = 'ee_rss_' . md5($rss_id);
2296
+        $pre       = '<div class="espresso-rss-display">'."\n\t";
2297
+        $pre .= '<span id="'.esc_attr($rss_id).'_url" class="hidden">'.esc_url_raw($url).'</span>';
2298
+        $post      = '</div>'."\n";
2299
+        $cache_key = 'ee_rss_'.md5($rss_id);
2300 2300
         $output    = get_transient($cache_key);
2301 2301
         if ($output !== false) {
2302
-            echo $pre . $output . $post; // already escaped
2302
+            echo $pre.$output.$post; // already escaped
2303 2303
             return true;
2304 2304
         }
2305
-        if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2306
-            echo $pre . $loading . $post; // already escaped
2305
+        if ( ! (defined('DOING_AJAX') && DOING_AJAX)) {
2306
+            echo $pre.$loading.$post; // already escaped
2307 2307
             return false;
2308 2308
         }
2309 2309
         ob_start();
@@ -2370,19 +2370,19 @@  discard block
 block discarded – undo
2370 2370
     public function espresso_sponsors_post_box()
2371 2371
     {
2372 2372
         EEH_Template::display_template(
2373
-            EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2373
+            EE_ADMIN_TEMPLATE.'admin_general_metabox_contents_espresso_sponsors.template.php'
2374 2374
         );
2375 2375
     }
2376 2376
 
2377 2377
 
2378 2378
     private function _publish_post_box()
2379 2379
     {
2380
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2380
+        $meta_box_ref = 'espresso_'.$this->page_slug.'_editor_overview';
2381 2381
         // if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2382 2382
         // then we'll use that for the metabox label.
2383 2383
         // Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2384
-        if (! empty($this->_labels['publishbox'])) {
2385
-            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2384
+        if ( ! empty($this->_labels['publishbox'])) {
2385
+            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action]
2386 2386
                 : $this->_labels['publishbox'];
2387 2387
         } else {
2388 2388
             $box_label = esc_html__('Publish', 'event_espresso');
@@ -2411,7 +2411,7 @@  discard block
 block discarded – undo
2411 2411
             ? $this->_template_args['publish_box_extra_content']
2412 2412
             : '';
2413 2413
         echo EEH_Template::display_template(
2414
-            EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2414
+            EE_ADMIN_TEMPLATE.'admin_details_publish_metabox.template.php',
2415 2415
             $this->_template_args,
2416 2416
             true
2417 2417
         );
@@ -2499,18 +2499,18 @@  discard block
 block discarded – undo
2499 2499
             );
2500 2500
         }
2501 2501
         $this->_template_args['publish_delete_link'] = $delete_link;
2502
-        if (! empty($name) && ! empty($id)) {
2503
-            $hidden_field_arr[ $name ] = [
2502
+        if ( ! empty($name) && ! empty($id)) {
2503
+            $hidden_field_arr[$name] = [
2504 2504
                 'type'  => 'hidden',
2505 2505
                 'value' => $id,
2506 2506
             ];
2507
-            $hf                        = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2507
+            $hf = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2508 2508
         } else {
2509 2509
             $hf = '';
2510 2510
         }
2511 2511
         // add hidden field
2512 2512
         $this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2513
-            ? $hf[ $name ]['field']
2513
+            ? $hf[$name]['field']
2514 2514
             : $hf;
2515 2515
     }
2516 2516
 
@@ -2612,7 +2612,7 @@  discard block
 block discarded – undo
2612 2612
         }
2613 2613
         // if $create_func is true (default) then we automatically create the function for displaying the actual meta box.  If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish)
2614 2614
         $call_back_func = $create_func
2615
-            ? static function ($post, $metabox) {
2615
+            ? static function($post, $metabox) {
2616 2616
                 do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2617 2617
                 echo EEH_Template::display_template(
2618 2618
                     $metabox['args']['template_path'],
@@ -2622,7 +2622,7 @@  discard block
 block discarded – undo
2622 2622
             }
2623 2623
             : $callback;
2624 2624
         $this->addMetaBox(
2625
-            str_replace('_', '-', $action) . '-mbox',
2625
+            str_replace('_', '-', $action).'-mbox',
2626 2626
             $title,
2627 2627
             $call_back_func,
2628 2628
             $this->_wp_page_slug,
@@ -2739,13 +2739,13 @@  discard block
 block discarded – undo
2739 2739
             'event-espresso_page_espresso_',
2740 2740
             '',
2741 2741
             $this->_wp_page_slug
2742
-        ) . ' ' . $this->_req_action . '-route';
2742
+        ).' '.$this->_req_action.'-route';
2743 2743
 
2744 2744
         $template_path = $sidebar
2745 2745
             ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2746
-            : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2746
+            : EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar.template.php';
2747 2747
         if ($this->request->isAjax()) {
2748
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2748
+            $template_path = EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar_ajax.template.php';
2749 2749
         }
2750 2750
         $template_path = ! empty($this->_column_template_path) ? $this->_column_template_path : $template_path;
2751 2751
 
@@ -2779,11 +2779,11 @@  discard block
 block discarded – undo
2779 2779
     public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2780 2780
     {
2781 2781
         // let's generate a default preview action button if there isn't one already present.
2782
-        $this->_labels['buttons']['buy_now']           = esc_html__(
2782
+        $this->_labels['buttons']['buy_now'] = esc_html__(
2783 2783
             'Upgrade to Event Espresso 4 Right Now',
2784 2784
             'event_espresso'
2785 2785
         );
2786
-        $buy_now_url                                   = add_query_arg(
2786
+        $buy_now_url = add_query_arg(
2787 2787
             [
2788 2788
                 'ee_ver'       => 'ee4',
2789 2789
                 'utm_source'   => 'ee4_plugin_admin',
@@ -2803,8 +2803,8 @@  discard block
 block discarded – undo
2803 2803
                 true
2804 2804
             )
2805 2805
             : $this->_template_args['preview_action_button'];
2806
-        $this->_template_args['admin_page_content']    = EEH_Template::display_template(
2807
-            EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2806
+        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2807
+            EE_ADMIN_TEMPLATE.'admin_caf_full_page_preview.template.php',
2808 2808
             $this->_template_args,
2809 2809
             true
2810 2810
         );
@@ -2862,7 +2862,7 @@  discard block
 block discarded – undo
2862 2862
         // setup search attributes
2863 2863
         $this->_set_search_attributes();
2864 2864
         $this->_template_args['current_page']     = $this->_wp_page_slug;
2865
-        $template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2865
+        $template_path                            = EE_ADMIN_TEMPLATE.'admin_list_wrapper.template.php';
2866 2866
         $this->_template_args['table_url']        = $this->request->isAjax()
2867 2867
             ? add_query_arg(['noheader' => 'true', 'route' => $this->_req_action], $this->_admin_base_url)
2868 2868
             : add_query_arg(['route' => $this->_req_action], $this->_admin_base_url);
@@ -2870,10 +2870,10 @@  discard block
 block discarded – undo
2870 2870
         $this->_template_args['current_route']    = $this->_req_action;
2871 2871
         $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2872 2872
         $ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
2873
-        if (! empty($ajax_sorting_callback)) {
2873
+        if ( ! empty($ajax_sorting_callback)) {
2874 2874
             $sortable_list_table_form_fields = wp_nonce_field(
2875
-                $ajax_sorting_callback . '_nonce',
2876
-                $ajax_sorting_callback . '_nonce',
2875
+                $ajax_sorting_callback.'_nonce',
2876
+                $ajax_sorting_callback.'_nonce',
2877 2877
                 false,
2878 2878
                 false
2879 2879
             );
@@ -2890,18 +2890,18 @@  discard block
 block discarded – undo
2890 2890
 
2891 2891
         $hidden_form_fields = $this->_template_args['list_table_hidden_fields'] ?? '';
2892 2892
 
2893
-        $nonce_ref          = $this->_req_action . '_nonce';
2893
+        $nonce_ref          = $this->_req_action.'_nonce';
2894 2894
         $hidden_form_fields .= '
2895
-            <input type="hidden" name="' . $nonce_ref . '" value="' . wp_create_nonce($nonce_ref) . '">';
2895
+            <input type="hidden" name="' . $nonce_ref.'" value="'.wp_create_nonce($nonce_ref).'">';
2896 2896
 
2897
-        $this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
2897
+        $this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
2898 2898
         // display message about search results?
2899 2899
         $search = $this->request->getRequestParam('s');
2900 2900
         $this->_template_args['before_list_table'] .= ! empty($search)
2901
-            ? '<p class="ee-search-results">' . sprintf(
2901
+            ? '<p class="ee-search-results">'.sprintf(
2902 2902
                 esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
2903 2903
                 trim($search, '%')
2904
-            ) . '</p>'
2904
+            ).'</p>'
2905 2905
             : '';
2906 2906
         // filter before_list_table template arg
2907 2907
         $this->_template_args['before_list_table'] = apply_filters(
@@ -2935,7 +2935,7 @@  discard block
 block discarded – undo
2935 2935
         // convert to array and filter again
2936 2936
         // arrays are easier to inject new items in a specific location,
2937 2937
         // but would not be backwards compatible, so we have to add a new filter
2938
-        $this->_template_args['after_list_table']   = implode(
2938
+        $this->_template_args['after_list_table'] = implode(
2939 2939
             " \n",
2940 2940
             (array) apply_filters(
2941 2941
                 'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
@@ -2983,15 +2983,15 @@  discard block
 block discarded – undo
2983 2983
         );
2984 2984
         /** @var EventEspresso\core\admin\StatusChangeNotice $status_change_notice */
2985 2985
         $status_change_notice = $this->loader->getShared('EventEspresso\core\admin\StatusChangeNotice');
2986
-        if (! $status_change_notice->isDismissed()) {
2986
+        if ( ! $status_change_notice->isDismissed()) {
2987 2987
             $this->_template_args['status_change_notice'] = EEH_Template::display_template(
2988
-                EE_ADMIN_TEMPLATE . 'status_change_notice.template.php',
2989
-                [ 'context' => '__admin-legend', 'page_slug' => $this->page_slug ],
2988
+                EE_ADMIN_TEMPLATE.'status_change_notice.template.php',
2989
+                ['context' => '__admin-legend', 'page_slug' => $this->page_slug],
2990 2990
                 true
2991 2991
             );
2992 2992
         }
2993 2993
         return EEH_Template::display_template(
2994
-            EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
2994
+            EE_ADMIN_TEMPLATE.'admin_details_legend.template.php',
2995 2995
             $this->_template_args,
2996 2996
             true
2997 2997
         );
@@ -3107,16 +3107,16 @@  discard block
 block discarded – undo
3107 3107
             $this->_template_args['before_admin_page_content'] ?? ''
3108 3108
         );
3109 3109
 
3110
-        $this->_template_args['after_admin_page_content']  = apply_filters(
3110
+        $this->_template_args['after_admin_page_content'] = apply_filters(
3111 3111
             "FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3112 3112
             $this->_template_args['after_admin_page_content'] ?? ''
3113 3113
         );
3114
-        $this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3114
+        $this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
3115 3115
 
3116 3116
         if ($this->request->isAjax()) {
3117 3117
             $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3118 3118
                 // $template_path,
3119
-                EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php',
3119
+                EE_ADMIN_TEMPLATE.'admin_wrapper_ajax.template.php',
3120 3120
                 $this->_template_args,
3121 3121
                 true
3122 3122
             );
@@ -3125,7 +3125,7 @@  discard block
 block discarded – undo
3125 3125
         // load settings page wrapper template
3126 3126
         $template_path = $about
3127 3127
             ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3128
-            : EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php';
3128
+            : EE_ADMIN_TEMPLATE.'admin_wrapper.template.php';
3129 3129
 
3130 3130
         EEH_Template::display_template($template_path, $this->_template_args);
3131 3131
     }
@@ -3209,12 +3209,12 @@  discard block
 block discarded – undo
3209 3209
         $default_names = ['save', 'save_and_close'];
3210 3210
         $buttons = '';
3211 3211
         foreach ($button_text as $key => $button) {
3212
-            $ref     = $default_names[ $key ];
3213
-            $name    = ! empty($actions) ? $actions[ $key ] : $ref;
3214
-            $buttons .= '<input type="submit" class="button button--primary ' . $ref . '" '
3215
-                        . 'value="' . $button . '" name="' . $name . '" '
3216
-                        . 'id="' . $this->_current_view . '_' . $ref . '" />';
3217
-            if (! $both) {
3212
+            $ref     = $default_names[$key];
3213
+            $name    = ! empty($actions) ? $actions[$key] : $ref;
3214
+            $buttons .= '<input type="submit" class="button button--primary '.$ref.'" '
3215
+                        . 'value="'.$button.'" name="'.$name.'" '
3216
+                        . 'id="'.$this->_current_view.'_'.$ref.'" />';
3217
+            if ( ! $both) {
3218 3218
                 break;
3219 3219
             }
3220 3220
         }
@@ -3254,13 +3254,13 @@  discard block
 block discarded – undo
3254 3254
                 'An error occurred. No action was set for this page\'s form.',
3255 3255
                 'event_espresso'
3256 3256
             );
3257
-            $dev_msg  = $user_msg . "\n"
3257
+            $dev_msg = $user_msg."\n"
3258 3258
                         . sprintf(
3259 3259
                             esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3260 3260
                             __FUNCTION__,
3261 3261
                             __CLASS__
3262 3262
                         );
3263
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3263
+            EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__);
3264 3264
         }
3265 3265
         // open form
3266 3266
         $action = $this->_admin_base_url;
@@ -3268,9 +3268,9 @@  discard block
 block discarded – undo
3268 3268
             <form name='form' method='post' action='{$action}' id='{$route}_event_form' class='ee-admin-page-form' >
3269 3269
             ";
3270 3270
         // add nonce
3271
-        $nonce                                             =
3272
-            wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3273
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3271
+        $nonce =
3272
+            wp_nonce_field($route.'_nonce', $route.'_nonce', false, false);
3273
+        $this->_template_args['before_admin_page_content'] .= "\n\t".$nonce;
3274 3274
         // add REQUIRED form action
3275 3275
         $hidden_fields = [
3276 3276
             'action' => ['type' => 'hidden', 'value' => $route],
@@ -3283,7 +3283,7 @@  discard block
 block discarded – undo
3283 3283
         $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3284 3284
         // add fields to form
3285 3285
         foreach ((array) $form_fields as $form_field) {
3286
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3286
+            $this->_template_args['before_admin_page_content'] .= "\n\t".$form_field['field'];
3287 3287
         }
3288 3288
         // close form
3289 3289
         $this->_template_args['after_admin_page_content'] = '</form>';
@@ -3366,12 +3366,12 @@  discard block
 block discarded – undo
3366 3366
         bool $override_overwrite = false
3367 3367
     ) {
3368 3368
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3369
-        $notices      = EE_Error::get_notices(false);
3369
+        $notices = EE_Error::get_notices(false);
3370 3370
         // overwrite default success messages //BUT ONLY if overwrite not overridden
3371
-        if (! $override_overwrite || ! empty($notices['errors'])) {
3371
+        if ( ! $override_overwrite || ! empty($notices['errors'])) {
3372 3372
             EE_Error::overwrite_success();
3373 3373
         }
3374
-        if (! $override_overwrite && ! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3374
+        if ( ! $override_overwrite && ! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3375 3375
             // how many records affected ? more than one record ? or just one ?
3376 3376
             EE_Error::add_success(
3377 3377
                 sprintf(
@@ -3392,7 +3392,7 @@  discard block
 block discarded – undo
3392 3392
             );
3393 3393
         }
3394 3394
         // check that $query_args isn't something crazy
3395
-        if (! is_array($query_args)) {
3395
+        if ( ! is_array($query_args)) {
3396 3396
             $query_args = [];
3397 3397
         }
3398 3398
         // class name for actions/filters.
@@ -3426,7 +3426,7 @@  discard block
 block discarded – undo
3426 3426
             $redirect_url = admin_url('admin.php');
3427 3427
         }
3428 3428
         // merge any default query_args set in _default_route_query_args property
3429
-        if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3429
+        if ( ! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3430 3430
             $args_to_merge = [];
3431 3431
             foreach ($this->_default_route_query_args as $query_param => $query_value) {
3432 3432
                 // is there a wp_referer array in our _default_route_query_args property?
@@ -3438,15 +3438,15 @@  discard block
 block discarded – undo
3438 3438
                         }
3439 3439
                         // finally we will override any arguments in the referer with
3440 3440
                         // what might be set on the _default_route_query_args array.
3441
-                        if (isset($this->_default_route_query_args[ $reference ])) {
3442
-                            $args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3441
+                        if (isset($this->_default_route_query_args[$reference])) {
3442
+                            $args_to_merge[$reference] = urlencode($this->_default_route_query_args[$reference]);
3443 3443
                         } else {
3444
-                            $args_to_merge[ $reference ] = urlencode($value);
3444
+                            $args_to_merge[$reference] = urlencode($value);
3445 3445
                         }
3446 3446
                     }
3447 3447
                     continue;
3448 3448
                 }
3449
-                $args_to_merge[ $query_param ] = $query_value;
3449
+                $args_to_merge[$query_param] = $query_value;
3450 3450
             }
3451 3451
             // now let's merge these arguments but override with what was specifically sent in to the
3452 3452
             // redirect.
@@ -3458,19 +3458,19 @@  discard block
 block discarded – undo
3458 3458
         if (isset($query_args['action'])) {
3459 3459
             // manually generate wp_nonce and merge that with the query vars
3460 3460
             // becuz the wp_nonce_url function wrecks havoc on some vars
3461
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3461
+            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'].'_nonce');
3462 3462
         }
3463 3463
         // we're adding some hooks and filters in here for processing any things just before redirects
3464 3464
         // (example: an admin page has done an insert or update and we want to run something after that).
3465
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3465
+        do_action('AHEE_redirect_'.$classname.$this->_req_action, $query_args);
3466 3466
         $redirect_url = apply_filters(
3467
-            'FHEE_redirect_' . $classname . $this->_req_action,
3467
+            'FHEE_redirect_'.$classname.$this->_req_action,
3468 3468
             EE_Admin_Page::add_query_args_and_nonce($query_args, $redirect_url),
3469 3469
             $query_args
3470 3470
         );
3471 3471
         // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3472 3472
         if ($this->request->isAjax()) {
3473
-            $default_data                    = [
3473
+            $default_data = [
3474 3474
                 'close'        => true,
3475 3475
                 'redirect_url' => $redirect_url,
3476 3476
                 'where'        => 'main',
@@ -3520,7 +3520,7 @@  discard block
 block discarded – undo
3520 3520
         }
3521 3521
         $this->_template_args['notices'] = EE_Error::get_notices();
3522 3522
         // IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3523
-        if (! $this->request->isAjax() || $sticky_notices) {
3523
+        if ( ! $this->request->isAjax() || $sticky_notices) {
3524 3524
             $route = isset($query_args['action']) ? $query_args['action'] : 'default';
3525 3525
             $this->_add_transient(
3526 3526
                 $route,
@@ -3560,7 +3560,7 @@  discard block
 block discarded – undo
3560 3560
         $exclude_nonce = false
3561 3561
     ) {
3562 3562
         // first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3563
-        if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3563
+        if (empty($base_url) && ! isset($this->_page_routes[$action])) {
3564 3564
             throw new EE_Error(
3565 3565
                 sprintf(
3566 3566
                     esc_html__(
@@ -3571,7 +3571,7 @@  discard block
 block discarded – undo
3571 3571
                 )
3572 3572
             );
3573 3573
         }
3574
-        if (! isset($this->_labels['buttons'][ $type ])) {
3574
+        if ( ! isset($this->_labels['buttons'][$type])) {
3575 3575
             throw new EE_Error(
3576 3576
                 sprintf(
3577 3577
                     esc_html__(
@@ -3584,7 +3584,7 @@  discard block
 block discarded – undo
3584 3584
         }
3585 3585
         // finally check user access for this button.
3586 3586
         $has_access = $this->check_user_access($action, true);
3587
-        if (! $has_access) {
3587
+        if ( ! $has_access) {
3588 3588
             return '';
3589 3589
         }
3590 3590
         $_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
@@ -3592,11 +3592,11 @@  discard block
 block discarded – undo
3592 3592
             'action' => $action,
3593 3593
         ];
3594 3594
         // merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3595
-        if (! empty($extra_request)) {
3595
+        if ( ! empty($extra_request)) {
3596 3596
             $query_args = array_merge($extra_request, $query_args);
3597 3597
         }
3598 3598
         $url = EE_Admin_Page::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3599
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3599
+        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][$type], $class);
3600 3600
     }
3601 3601
 
3602 3602
 
@@ -3622,7 +3622,7 @@  discard block
 block discarded – undo
3622 3622
                 'FHEE__EE_Admin_Page___per_page_screen_options__default',
3623 3623
                 20
3624 3624
             ),
3625
-            'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3625
+            'option'  => $this->_current_page.'_'.$this->_current_view.'_per_page',
3626 3626
         ];
3627 3627
         // ONLY add the screen option if the user has access to it.
3628 3628
         if ($this->check_user_access($this->_current_view, true)) {
@@ -3643,18 +3643,18 @@  discard block
 block discarded – undo
3643 3643
     {
3644 3644
         if ($this->request->requestParamIsSet('wp_screen_options')) {
3645 3645
             check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3646
-            if (! $user = wp_get_current_user()) {
3646
+            if ( ! $user = wp_get_current_user()) {
3647 3647
                 return;
3648 3648
             }
3649 3649
             $option = $this->request->getRequestParam('wp_screen_options[option]', '', 'key');
3650
-            if (! $option) {
3650
+            if ( ! $option) {
3651 3651
                 return;
3652 3652
             }
3653
-            $value  = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3653
+            $value = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3654 3654
             $map_option = $option;
3655 3655
             $option     = str_replace('-', '_', $option);
3656 3656
             switch ($map_option) {
3657
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3657
+                case $this->_current_page.'_'.$this->_current_view.'_per_page':
3658 3658
                     $max_value = apply_filters(
3659 3659
                         'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3660 3660
                         999,
@@ -3711,13 +3711,13 @@  discard block
 block discarded – undo
3711 3711
     protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3712 3712
     {
3713 3713
         $user_id = get_current_user_id();
3714
-        if (! $skip_route_verify) {
3714
+        if ( ! $skip_route_verify) {
3715 3715
             $this->_verify_route($route);
3716 3716
         }
3717 3717
         // now let's set the string for what kind of transient we're setting
3718 3718
         $transient = $notices
3719
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3720
-            : 'rte_tx_' . $route . '_' . $user_id;
3719
+            ? 'ee_rte_n_tx_'.$route.'_'.$user_id
3720
+            : 'rte_tx_'.$route.'_'.$user_id;
3721 3721
         $data      = $notices ? ['notices' => $data] : $data;
3722 3722
         // is there already a transient for this route?  If there is then let's ADD to that transient
3723 3723
         $existing = is_multisite() && is_network_admin()
@@ -3746,8 +3746,8 @@  discard block
 block discarded – undo
3746 3746
         $user_id   = get_current_user_id();
3747 3747
         $route     = ! $route ? $this->_req_action : $route;
3748 3748
         $transient = $notices
3749
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3750
-            : 'rte_tx_' . $route . '_' . $user_id;
3749
+            ? 'ee_rte_n_tx_'.$route.'_'.$user_id
3750
+            : 'rte_tx_'.$route.'_'.$user_id;
3751 3751
         $data      = is_multisite() && is_network_admin()
3752 3752
             ? get_site_transient($transient)
3753 3753
             : get_transient($transient);
@@ -3983,7 +3983,7 @@  discard block
 block discarded – undo
3983 3983
      */
3984 3984
     protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
3985 3985
     {
3986
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3986
+        return '<a class="'.$class.'" href="'.$url.'"></a>';
3987 3987
     }
3988 3988
 
3989 3989
 
@@ -3996,7 +3996,7 @@  discard block
 block discarded – undo
3996 3996
      */
3997 3997
     protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
3998 3998
     {
3999
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3999
+        return '<a class="'.$class.'" href="'.$url.'"></a>';
4000 4000
     }
4001 4001
 
4002 4002
 
@@ -4144,7 +4144,7 @@  discard block
 block discarded – undo
4144 4144
             ?callable $callback = null
4145 4145
     ): bool {
4146 4146
         $entity_ID = absint($entity_ID);
4147
-        if (! $entity_ID) {
4147
+        if ( ! $entity_ID) {
4148 4148
             $this->trashRestoreDeleteError($action, $entity_model);
4149 4149
         }
4150 4150
         $result = 0;
@@ -4190,7 +4190,7 @@  discard block
 block discarded – undo
4190 4190
                     )
4191 4191
             );
4192 4192
         }
4193
-        if (! $entity_model->has_field($delete_column)) {
4193
+        if ( ! $entity_model->has_field($delete_column)) {
4194 4194
             throw new DomainException(
4195 4195
                     sprintf(
4196 4196
                             esc_html__(
Please login to merge, or discard this patch.
core/services/request/Request.php 1 patch
Indentation   +550 added lines, -550 removed lines patch added patch discarded remove patch
@@ -17,554 +17,554 @@
 block discarded – undo
17 17
 class Request implements InterminableInterface, RequestInterface, ReservedInstanceInterface
18 18
 {
19 19
 
20
-    /**
21
-     * $_COOKIE parameters
22
-     *
23
-     * @var array
24
-     */
25
-    protected $cookies;
26
-
27
-    /**
28
-     * $_FILES parameters
29
-     *
30
-     * @var array
31
-     */
32
-    protected $files;
33
-
34
-    /**
35
-     * true if current user appears to be some kind of bot
36
-     *
37
-     * @var bool
38
-     */
39
-    protected $is_bot;
40
-
41
-    /**
42
-     * @var RequestParams
43
-     */
44
-    protected $request_params;
45
-
46
-    /**
47
-     * @var RequestTypeContextCheckerInterface
48
-     */
49
-    protected $request_type;
50
-
51
-    /**
52
-     * @var ServerParams
53
-     */
54
-    protected $server_params;
55
-
56
-
57
-    public function __construct(
58
-        RequestParams $request_params,
59
-        ServerParams $server_params,
60
-        array $cookies = [],
61
-        array $files = []
62
-    ) {
63
-        $this->cookies = ! empty($cookies)
64
-            ? $cookies
65
-            : filter_input_array(INPUT_COOKIE, FILTER_SANITIZE_STRING);
66
-        $this->files          = ! empty($files) ? $files : $_FILES;
67
-        $this->request_params = $request_params;
68
-        $this->server_params  = $server_params;
69
-    }
70
-
71
-
72
-    /**
73
-     * @param RequestTypeContextCheckerInterface $type
74
-     */
75
-    public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type)
76
-    {
77
-        $this->request_type = $type;
78
-    }
79
-
80
-
81
-    /**
82
-     * @return array
83
-     */
84
-    public function getParams()
85
-    {
86
-        return $this->request_params->getParams();
87
-    }
88
-
89
-
90
-    /**
91
-     * @return array
92
-     */
93
-    public function postParams()
94
-    {
95
-        return $this->request_params->postParams();
96
-    }
97
-
98
-
99
-    /**
100
-     * @return array
101
-     */
102
-    public function cookieParams()
103
-    {
104
-        return $this->cookies;
105
-    }
106
-
107
-
108
-    /**
109
-     * @return array
110
-     */
111
-    public function serverParams()
112
-    {
113
-        return $this->server_params->getAllServerParams();
114
-    }
115
-
116
-
117
-    /**
118
-     * @param string $key
119
-     * @param mixed|null $default
120
-     * @return array|int|float|string
121
-     */
122
-    public function getServerParam($key, $default = null)
123
-    {
124
-        return $this->server_params->getServerParam($key, $default);
125
-    }
126
-
127
-
128
-    /**
129
-     * @param string                 $key
130
-     * @param array|int|float|string $value
131
-     * @param bool                   $set_global_too
132
-     * @return void
133
-     */
134
-    public function setServerParam(string $key, $value, bool $set_global_too = false)
135
-    {
136
-        $this->server_params->setServerParam($key, $value, $set_global_too);
137
-    }
138
-
139
-
140
-    /**
141
-     * @param string $key
142
-     * @return bool
143
-     */
144
-    public function serverParamIsSet($key)
145
-    {
146
-        return $this->server_params->serverParamIsSet($key);
147
-    }
148
-
149
-
150
-    /**
151
-     * @return array
152
-     */
153
-    public function filesParams()
154
-    {
155
-        return $this->files;
156
-    }
157
-
158
-
159
-    /**
160
-     * returns sanitized contents of $_REQUEST
161
-     *
162
-     * @return array
163
-     */
164
-    public function requestParams()
165
-    {
166
-        return $this->request_params->requestParams();
167
-    }
168
-
169
-
170
-    /**
171
-     * @param string     $key
172
-     * @param mixed|null $value
173
-     * @param bool       $override_ee
174
-     * @return void
175
-     */
176
-    public function setRequestParam($key, $value, $override_ee = false)
177
-    {
178
-        $this->request_params->setRequestParam($key, $value, $override_ee);
179
-    }
180
-
181
-
182
-    /**
183
-     * merges the incoming array of parameters into the existing request parameters
184
-     *
185
-     * @param array $request_params
186
-     * @return void
187
-     * @since   4.10.24.p
188
-     */
189
-    public function mergeRequestParams(array $request_params)
190
-    {
191
-        $this->request_params->mergeRequestParams($request_params);
192
-    }
193
-
194
-
195
-    /**
196
-     * returns sanitized value for a request param if the given key exists
197
-     *
198
-     * @param string     $key
199
-     * @param mixed|null $default
200
-     * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
201
-     * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
202
-     * @param string     $delimiter for CSV type strings that should be returned as an array
203
-     * @return array|bool|float|int|string
204
-     */
205
-    public function getRequestParam($key, $default = null, $type = DataType::STRING, $is_array = false, $delimiter = '')
206
-    {
207
-        return $this->request_params->getRequestParam($key, $default, $type, $is_array, $delimiter);
208
-    }
209
-
210
-
211
-    /**
212
-     * check if param exists
213
-     *
214
-     * @param string $key
215
-     * @return bool
216
-     */
217
-    public function requestParamIsSet($key)
218
-    {
219
-        return $this->request_params->requestParamIsSet($key);
220
-    }
221
-
222
-
223
-    /**
224
-     * check if a request parameter exists whose key that matches the supplied wildcard pattern
225
-     * and return the sanitized value for the first match found
226
-     * wildcards can be either of the following:
227
-     *      ? to represent a single character of any type
228
-     *      * to represent one or more characters of any type
229
-     *
230
-     * @param string     $pattern
231
-     * @param mixed|null $default
232
-     * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
233
-     * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
234
-     * @param string     $delimiter for CSV type strings that should be returned as an array
235
-     * @return array|bool|float|int|string
236
-     */
237
-    public function getMatch($pattern, $default = null, $type = DataType::STRING, $is_array = false, $delimiter = '')
238
-    {
239
-        return $this->request_params->getMatch($pattern, $default, $type, $is_array, $delimiter);
240
-    }
241
-
242
-
243
-    /**
244
-     * check if a request parameter exists whose key matches the supplied wildcard pattern
245
-     * wildcards can be either of the following:
246
-     *      ? to represent a single character of any type
247
-     *      * to represent one or more characters of any type
248
-     * returns true if a match is found or false if not
249
-     *
250
-     * @param string $pattern
251
-     * @return bool
252
-     */
253
-    public function matches($pattern)
254
-    {
255
-        return $this->request_params->matches($pattern);
256
-    }
257
-
258
-
259
-    /**
260
-     * remove param
261
-     *
262
-     * @param      $key
263
-     * @param bool $unset_from_global_too
264
-     */
265
-    public function unSetRequestParam($key, $unset_from_global_too = false)
266
-    {
267
-        $this->request_params->unSetRequestParam($key, $unset_from_global_too);
268
-    }
269
-
270
-
271
-    /**
272
-     * remove params
273
-     *
274
-     * @param array $keys
275
-     * @param bool  $unset_from_global_too
276
-     */
277
-    public function unSetRequestParams(array $keys, $unset_from_global_too = false)
278
-    {
279
-        $this->request_params->unSetRequestParams($keys, $unset_from_global_too);
280
-    }
281
-
282
-
283
-    /**
284
-     * @param string $key
285
-     * @param bool   $unset_from_global_too
286
-     * @return void
287
-     */
288
-    public function unSetServerParam(string $key, bool $unset_from_global_too = false)
289
-    {
290
-        $this->server_params->unSetServerParam($key, $unset_from_global_too);
291
-    }
292
-
293
-
294
-    /**
295
-     * @return string
296
-     */
297
-    public function ipAddress()
298
-    {
299
-        return $this->server_params->ipAddress();
300
-    }
301
-
302
-
303
-    /**
304
-     * Gets the request's literal URI. Related to `requestUriAfterSiteHomeUri`, see its description for a comparison.
305
-     *
306
-     * @param boolean $relativeToWpRoot    If home_url() is "http://mysite.com/wp/", and a request comes to
307
-     *                                     "http://mysite.com/wp/wp-json", setting $relativeToWpRoot=true will return
308
-     *                                     "/wp-json", whereas $relativeToWpRoot=false will return "/wp/wp-json/".
309
-     * @param boolean $remove_query_params whether or not to return the uri with all query params removed.
310
-     * @return string
311
-     */
312
-    public function requestUri($relativeToWpRoot = false, $remove_query_params = false)
313
-    {
314
-        return $this->server_params->requestUri();
315
-    }
316
-
317
-
318
-    /**
319
-     * @return string
320
-     */
321
-    public function userAgent()
322
-    {
323
-        return $this->server_params->userAgent();
324
-    }
325
-
326
-
327
-    /**
328
-     * @param string $user_agent
329
-     */
330
-    public function setUserAgent($user_agent = '')
331
-    {
332
-        $this->server_params->setUserAgent($user_agent);
333
-    }
334
-
335
-
336
-    /**
337
-     * @return bool
338
-     */
339
-    public function isBot()
340
-    {
341
-        return $this->is_bot;
342
-    }
343
-
344
-
345
-    /**
346
-     * @param bool $is_bot
347
-     */
348
-    public function setIsBot($is_bot)
349
-    {
350
-        $this->is_bot = filter_var($is_bot, FILTER_VALIDATE_BOOLEAN);
351
-    }
352
-
353
-
354
-    /**
355
-     * @return bool
356
-     */
357
-    public function isActivation()
358
-    {
359
-        return $this->request_type->isActivation();
360
-    }
361
-
362
-
363
-    /**
364
-     * @param $is_activation
365
-     * @return bool
366
-     */
367
-    public function setIsActivation($is_activation)
368
-    {
369
-        return $this->request_type->setIsActivation($is_activation);
370
-    }
371
-
372
-
373
-    /**
374
-     * @return bool
375
-     */
376
-    public function isAdmin()
377
-    {
378
-        return $this->request_type->isAdmin();
379
-    }
380
-
381
-
382
-    /**
383
-     * @return bool
384
-     */
385
-    public function isAdminAjax()
386
-    {
387
-        return $this->request_type->isAdminAjax();
388
-    }
389
-
390
-
391
-    /**
392
-     * @return bool
393
-     */
394
-    public function isAjax()
395
-    {
396
-        return $this->request_type->isAjax();
397
-    }
398
-
399
-
400
-    /**
401
-     * @return bool
402
-     */
403
-    public function isEeAjax()
404
-    {
405
-        return $this->request_type->isEeAjax();
406
-    }
407
-
408
-
409
-    /**
410
-     * @return bool
411
-     */
412
-    public function isOtherAjax()
413
-    {
414
-        return $this->request_type->isOtherAjax();
415
-    }
416
-
417
-
418
-    /**
419
-     * @return bool
420
-     */
421
-    public function isApi()
422
-    {
423
-        return $this->request_type->isApi();
424
-    }
425
-
426
-
427
-    /**
428
-     * @return bool
429
-     */
430
-    public function isCli()
431
-    {
432
-        return $this->request_type->isCli();
433
-    }
434
-
435
-
436
-    /**
437
-     * @return bool
438
-     */
439
-    public function isCron()
440
-    {
441
-        return $this->request_type->isCron();
442
-    }
443
-
444
-
445
-    /**
446
-     * @return bool
447
-     */
448
-    public function isFeed()
449
-    {
450
-        return $this->request_type->isFeed();
451
-    }
452
-
453
-
454
-    /**
455
-     * @return bool
456
-     */
457
-    public function isFrontend()
458
-    {
459
-        return $this->request_type->isFrontend();
460
-    }
461
-
462
-
463
-    /**
464
-     * @return bool
465
-     */
466
-    public function isFrontAjax()
467
-    {
468
-        return $this->request_type->isFrontAjax();
469
-    }
470
-
471
-
472
-    /**
473
-     * @return bool
474
-     */
475
-    public function isGQL()
476
-    {
477
-        return $this->request_type->isGQL();
478
-    }
479
-
480
-
481
-    /**
482
-     * @return bool
483
-     */
484
-    public function isIframe()
485
-    {
486
-        return $this->request_type->isIframe();
487
-    }
488
-
489
-
490
-
491
-    /**
492
-     * @return bool
493
-     */
494
-    public function isUnitTesting()
495
-    {
496
-        return $this->request_type->isUnitTesting();
497
-    }
498
-
499
-
500
-    /**
501
-     * @return bool
502
-     */
503
-    public function isWordPressApi()
504
-    {
505
-        return $this->request_type->isWordPressApi();
506
-    }
507
-
508
-
509
-    /**
510
-     * @return bool
511
-     */
512
-    public function isWordPressHeartbeat()
513
-    {
514
-        return $this->request_type->isWordPressHeartbeat();
515
-    }
516
-
517
-
518
-    /**
519
-     * @return bool
520
-     */
521
-    public function isWordPressScrape()
522
-    {
523
-        return $this->request_type->isWordPressScrape();
524
-    }
525
-
526
-
527
-    /**
528
-     * @return string
529
-     */
530
-    public function slug()
531
-    {
532
-        return $this->request_type->slug();
533
-    }
534
-
535
-
536
-    /**
537
-     * returns the path portion of the current request URI with both the WP Root (home_url()) and query params removed
538
-     *
539
-     * @return string
540
-     * @since   $VID:$
541
-     */
542
-    public function requestPath()
543
-    {
544
-        return $this->requestUri(true, true);
545
-    }
546
-
547
-
548
-    /**
549
-     * returns true if the last segment of the current request path (without params) matches the provided string
550
-     *
551
-     * @param string $uri_segment
552
-     * @return bool
553
-     * @since   $VID:$
554
-     */
555
-    public function currentPageIs($uri_segment)
556
-    {
557
-        $request_path = $this->requestPath();
558
-        $current_page = explode('/', $request_path);
559
-        return end($current_page) === $uri_segment;
560
-    }
561
-
562
-
563
-    /**
564
-     * @return RequestTypeContextCheckerInterface
565
-     */
566
-    public function getRequestType(): RequestTypeContextCheckerInterface
567
-    {
568
-        return $this->request_type;
569
-    }
20
+	/**
21
+	 * $_COOKIE parameters
22
+	 *
23
+	 * @var array
24
+	 */
25
+	protected $cookies;
26
+
27
+	/**
28
+	 * $_FILES parameters
29
+	 *
30
+	 * @var array
31
+	 */
32
+	protected $files;
33
+
34
+	/**
35
+	 * true if current user appears to be some kind of bot
36
+	 *
37
+	 * @var bool
38
+	 */
39
+	protected $is_bot;
40
+
41
+	/**
42
+	 * @var RequestParams
43
+	 */
44
+	protected $request_params;
45
+
46
+	/**
47
+	 * @var RequestTypeContextCheckerInterface
48
+	 */
49
+	protected $request_type;
50
+
51
+	/**
52
+	 * @var ServerParams
53
+	 */
54
+	protected $server_params;
55
+
56
+
57
+	public function __construct(
58
+		RequestParams $request_params,
59
+		ServerParams $server_params,
60
+		array $cookies = [],
61
+		array $files = []
62
+	) {
63
+		$this->cookies = ! empty($cookies)
64
+			? $cookies
65
+			: filter_input_array(INPUT_COOKIE, FILTER_SANITIZE_STRING);
66
+		$this->files          = ! empty($files) ? $files : $_FILES;
67
+		$this->request_params = $request_params;
68
+		$this->server_params  = $server_params;
69
+	}
70
+
71
+
72
+	/**
73
+	 * @param RequestTypeContextCheckerInterface $type
74
+	 */
75
+	public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type)
76
+	{
77
+		$this->request_type = $type;
78
+	}
79
+
80
+
81
+	/**
82
+	 * @return array
83
+	 */
84
+	public function getParams()
85
+	{
86
+		return $this->request_params->getParams();
87
+	}
88
+
89
+
90
+	/**
91
+	 * @return array
92
+	 */
93
+	public function postParams()
94
+	{
95
+		return $this->request_params->postParams();
96
+	}
97
+
98
+
99
+	/**
100
+	 * @return array
101
+	 */
102
+	public function cookieParams()
103
+	{
104
+		return $this->cookies;
105
+	}
106
+
107
+
108
+	/**
109
+	 * @return array
110
+	 */
111
+	public function serverParams()
112
+	{
113
+		return $this->server_params->getAllServerParams();
114
+	}
115
+
116
+
117
+	/**
118
+	 * @param string $key
119
+	 * @param mixed|null $default
120
+	 * @return array|int|float|string
121
+	 */
122
+	public function getServerParam($key, $default = null)
123
+	{
124
+		return $this->server_params->getServerParam($key, $default);
125
+	}
126
+
127
+
128
+	/**
129
+	 * @param string                 $key
130
+	 * @param array|int|float|string $value
131
+	 * @param bool                   $set_global_too
132
+	 * @return void
133
+	 */
134
+	public function setServerParam(string $key, $value, bool $set_global_too = false)
135
+	{
136
+		$this->server_params->setServerParam($key, $value, $set_global_too);
137
+	}
138
+
139
+
140
+	/**
141
+	 * @param string $key
142
+	 * @return bool
143
+	 */
144
+	public function serverParamIsSet($key)
145
+	{
146
+		return $this->server_params->serverParamIsSet($key);
147
+	}
148
+
149
+
150
+	/**
151
+	 * @return array
152
+	 */
153
+	public function filesParams()
154
+	{
155
+		return $this->files;
156
+	}
157
+
158
+
159
+	/**
160
+	 * returns sanitized contents of $_REQUEST
161
+	 *
162
+	 * @return array
163
+	 */
164
+	public function requestParams()
165
+	{
166
+		return $this->request_params->requestParams();
167
+	}
168
+
169
+
170
+	/**
171
+	 * @param string     $key
172
+	 * @param mixed|null $value
173
+	 * @param bool       $override_ee
174
+	 * @return void
175
+	 */
176
+	public function setRequestParam($key, $value, $override_ee = false)
177
+	{
178
+		$this->request_params->setRequestParam($key, $value, $override_ee);
179
+	}
180
+
181
+
182
+	/**
183
+	 * merges the incoming array of parameters into the existing request parameters
184
+	 *
185
+	 * @param array $request_params
186
+	 * @return void
187
+	 * @since   4.10.24.p
188
+	 */
189
+	public function mergeRequestParams(array $request_params)
190
+	{
191
+		$this->request_params->mergeRequestParams($request_params);
192
+	}
193
+
194
+
195
+	/**
196
+	 * returns sanitized value for a request param if the given key exists
197
+	 *
198
+	 * @param string     $key
199
+	 * @param mixed|null $default
200
+	 * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
201
+	 * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
202
+	 * @param string     $delimiter for CSV type strings that should be returned as an array
203
+	 * @return array|bool|float|int|string
204
+	 */
205
+	public function getRequestParam($key, $default = null, $type = DataType::STRING, $is_array = false, $delimiter = '')
206
+	{
207
+		return $this->request_params->getRequestParam($key, $default, $type, $is_array, $delimiter);
208
+	}
209
+
210
+
211
+	/**
212
+	 * check if param exists
213
+	 *
214
+	 * @param string $key
215
+	 * @return bool
216
+	 */
217
+	public function requestParamIsSet($key)
218
+	{
219
+		return $this->request_params->requestParamIsSet($key);
220
+	}
221
+
222
+
223
+	/**
224
+	 * check if a request parameter exists whose key that matches the supplied wildcard pattern
225
+	 * and return the sanitized value for the first match found
226
+	 * wildcards can be either of the following:
227
+	 *      ? to represent a single character of any type
228
+	 *      * to represent one or more characters of any type
229
+	 *
230
+	 * @param string     $pattern
231
+	 * @param mixed|null $default
232
+	 * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
233
+	 * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
234
+	 * @param string     $delimiter for CSV type strings that should be returned as an array
235
+	 * @return array|bool|float|int|string
236
+	 */
237
+	public function getMatch($pattern, $default = null, $type = DataType::STRING, $is_array = false, $delimiter = '')
238
+	{
239
+		return $this->request_params->getMatch($pattern, $default, $type, $is_array, $delimiter);
240
+	}
241
+
242
+
243
+	/**
244
+	 * check if a request parameter exists whose key matches the supplied wildcard pattern
245
+	 * wildcards can be either of the following:
246
+	 *      ? to represent a single character of any type
247
+	 *      * to represent one or more characters of any type
248
+	 * returns true if a match is found or false if not
249
+	 *
250
+	 * @param string $pattern
251
+	 * @return bool
252
+	 */
253
+	public function matches($pattern)
254
+	{
255
+		return $this->request_params->matches($pattern);
256
+	}
257
+
258
+
259
+	/**
260
+	 * remove param
261
+	 *
262
+	 * @param      $key
263
+	 * @param bool $unset_from_global_too
264
+	 */
265
+	public function unSetRequestParam($key, $unset_from_global_too = false)
266
+	{
267
+		$this->request_params->unSetRequestParam($key, $unset_from_global_too);
268
+	}
269
+
270
+
271
+	/**
272
+	 * remove params
273
+	 *
274
+	 * @param array $keys
275
+	 * @param bool  $unset_from_global_too
276
+	 */
277
+	public function unSetRequestParams(array $keys, $unset_from_global_too = false)
278
+	{
279
+		$this->request_params->unSetRequestParams($keys, $unset_from_global_too);
280
+	}
281
+
282
+
283
+	/**
284
+	 * @param string $key
285
+	 * @param bool   $unset_from_global_too
286
+	 * @return void
287
+	 */
288
+	public function unSetServerParam(string $key, bool $unset_from_global_too = false)
289
+	{
290
+		$this->server_params->unSetServerParam($key, $unset_from_global_too);
291
+	}
292
+
293
+
294
+	/**
295
+	 * @return string
296
+	 */
297
+	public function ipAddress()
298
+	{
299
+		return $this->server_params->ipAddress();
300
+	}
301
+
302
+
303
+	/**
304
+	 * Gets the request's literal URI. Related to `requestUriAfterSiteHomeUri`, see its description for a comparison.
305
+	 *
306
+	 * @param boolean $relativeToWpRoot    If home_url() is "http://mysite.com/wp/", and a request comes to
307
+	 *                                     "http://mysite.com/wp/wp-json", setting $relativeToWpRoot=true will return
308
+	 *                                     "/wp-json", whereas $relativeToWpRoot=false will return "/wp/wp-json/".
309
+	 * @param boolean $remove_query_params whether or not to return the uri with all query params removed.
310
+	 * @return string
311
+	 */
312
+	public function requestUri($relativeToWpRoot = false, $remove_query_params = false)
313
+	{
314
+		return $this->server_params->requestUri();
315
+	}
316
+
317
+
318
+	/**
319
+	 * @return string
320
+	 */
321
+	public function userAgent()
322
+	{
323
+		return $this->server_params->userAgent();
324
+	}
325
+
326
+
327
+	/**
328
+	 * @param string $user_agent
329
+	 */
330
+	public function setUserAgent($user_agent = '')
331
+	{
332
+		$this->server_params->setUserAgent($user_agent);
333
+	}
334
+
335
+
336
+	/**
337
+	 * @return bool
338
+	 */
339
+	public function isBot()
340
+	{
341
+		return $this->is_bot;
342
+	}
343
+
344
+
345
+	/**
346
+	 * @param bool $is_bot
347
+	 */
348
+	public function setIsBot($is_bot)
349
+	{
350
+		$this->is_bot = filter_var($is_bot, FILTER_VALIDATE_BOOLEAN);
351
+	}
352
+
353
+
354
+	/**
355
+	 * @return bool
356
+	 */
357
+	public function isActivation()
358
+	{
359
+		return $this->request_type->isActivation();
360
+	}
361
+
362
+
363
+	/**
364
+	 * @param $is_activation
365
+	 * @return bool
366
+	 */
367
+	public function setIsActivation($is_activation)
368
+	{
369
+		return $this->request_type->setIsActivation($is_activation);
370
+	}
371
+
372
+
373
+	/**
374
+	 * @return bool
375
+	 */
376
+	public function isAdmin()
377
+	{
378
+		return $this->request_type->isAdmin();
379
+	}
380
+
381
+
382
+	/**
383
+	 * @return bool
384
+	 */
385
+	public function isAdminAjax()
386
+	{
387
+		return $this->request_type->isAdminAjax();
388
+	}
389
+
390
+
391
+	/**
392
+	 * @return bool
393
+	 */
394
+	public function isAjax()
395
+	{
396
+		return $this->request_type->isAjax();
397
+	}
398
+
399
+
400
+	/**
401
+	 * @return bool
402
+	 */
403
+	public function isEeAjax()
404
+	{
405
+		return $this->request_type->isEeAjax();
406
+	}
407
+
408
+
409
+	/**
410
+	 * @return bool
411
+	 */
412
+	public function isOtherAjax()
413
+	{
414
+		return $this->request_type->isOtherAjax();
415
+	}
416
+
417
+
418
+	/**
419
+	 * @return bool
420
+	 */
421
+	public function isApi()
422
+	{
423
+		return $this->request_type->isApi();
424
+	}
425
+
426
+
427
+	/**
428
+	 * @return bool
429
+	 */
430
+	public function isCli()
431
+	{
432
+		return $this->request_type->isCli();
433
+	}
434
+
435
+
436
+	/**
437
+	 * @return bool
438
+	 */
439
+	public function isCron()
440
+	{
441
+		return $this->request_type->isCron();
442
+	}
443
+
444
+
445
+	/**
446
+	 * @return bool
447
+	 */
448
+	public function isFeed()
449
+	{
450
+		return $this->request_type->isFeed();
451
+	}
452
+
453
+
454
+	/**
455
+	 * @return bool
456
+	 */
457
+	public function isFrontend()
458
+	{
459
+		return $this->request_type->isFrontend();
460
+	}
461
+
462
+
463
+	/**
464
+	 * @return bool
465
+	 */
466
+	public function isFrontAjax()
467
+	{
468
+		return $this->request_type->isFrontAjax();
469
+	}
470
+
471
+
472
+	/**
473
+	 * @return bool
474
+	 */
475
+	public function isGQL()
476
+	{
477
+		return $this->request_type->isGQL();
478
+	}
479
+
480
+
481
+	/**
482
+	 * @return bool
483
+	 */
484
+	public function isIframe()
485
+	{
486
+		return $this->request_type->isIframe();
487
+	}
488
+
489
+
490
+
491
+	/**
492
+	 * @return bool
493
+	 */
494
+	public function isUnitTesting()
495
+	{
496
+		return $this->request_type->isUnitTesting();
497
+	}
498
+
499
+
500
+	/**
501
+	 * @return bool
502
+	 */
503
+	public function isWordPressApi()
504
+	{
505
+		return $this->request_type->isWordPressApi();
506
+	}
507
+
508
+
509
+	/**
510
+	 * @return bool
511
+	 */
512
+	public function isWordPressHeartbeat()
513
+	{
514
+		return $this->request_type->isWordPressHeartbeat();
515
+	}
516
+
517
+
518
+	/**
519
+	 * @return bool
520
+	 */
521
+	public function isWordPressScrape()
522
+	{
523
+		return $this->request_type->isWordPressScrape();
524
+	}
525
+
526
+
527
+	/**
528
+	 * @return string
529
+	 */
530
+	public function slug()
531
+	{
532
+		return $this->request_type->slug();
533
+	}
534
+
535
+
536
+	/**
537
+	 * returns the path portion of the current request URI with both the WP Root (home_url()) and query params removed
538
+	 *
539
+	 * @return string
540
+	 * @since   $VID:$
541
+	 */
542
+	public function requestPath()
543
+	{
544
+		return $this->requestUri(true, true);
545
+	}
546
+
547
+
548
+	/**
549
+	 * returns true if the last segment of the current request path (without params) matches the provided string
550
+	 *
551
+	 * @param string $uri_segment
552
+	 * @return bool
553
+	 * @since   $VID:$
554
+	 */
555
+	public function currentPageIs($uri_segment)
556
+	{
557
+		$request_path = $this->requestPath();
558
+		$current_page = explode('/', $request_path);
559
+		return end($current_page) === $uri_segment;
560
+	}
561
+
562
+
563
+	/**
564
+	 * @return RequestTypeContextCheckerInterface
565
+	 */
566
+	public function getRequestType(): RequestTypeContextCheckerInterface
567
+	{
568
+		return $this->request_type;
569
+	}
570 570
 }
Please login to merge, or discard this patch.
core/services/request/RequestInterface.php 1 patch
Indentation   +218 added lines, -218 removed lines patch added patch discarded remove patch
@@ -16,224 +16,224 @@
 block discarded – undo
16 16
 interface RequestInterface extends RequestTypeContextCheckerInterface
17 17
 {
18 18
 
19
-    /**
20
-     * @param RequestTypeContextCheckerInterface $type
21
-     */
22
-    public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type);
19
+	/**
20
+	 * @param RequestTypeContextCheckerInterface $type
21
+	 */
22
+	public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type);
23 23
 
24 24
 
25
-    /**
26
-     * @return array
27
-     */
28
-    public function getParams();
29
-
30
-
31
-    /**
32
-     * @return array
33
-     */
34
-    public function postParams();
35
-
36
-
37
-    /**
38
-     * @return array
39
-     */
40
-    public function cookieParams();
41
-
42
-
43
-    /**
44
-     * @return array
45
-     */
46
-    public function serverParams();
47
-
48
-
49
-    /**
50
-     * @param string $key
51
-     * @param mixed|null $default
52
-     * @return array|int|float|string
53
-     */
54
-    public function getServerParam($key, $default = null);
55
-
56
-
57
-    /**
58
-     * @param string                 $key
59
-     * @param array|int|float|string $value
60
-     * @param bool                   $set_global_too
61
-     * @return void
62
-     */
63
-    public function setServerParam(string $key, $value, bool $set_global_too = false);
64
-
65
-
66
-    /**
67
-     * @param string $key
68
-     * @return bool
69
-     */
70
-    public function serverParamIsSet($key);
71
-
72
-
73
-    /**
74
-     * @return array
75
-     */
76
-    public function filesParams();
77
-
78
-
79
-    /**
80
-     * returns sanitized contents of $_REQUEST
81
-     *
82
-     * @return array
83
-     */
84
-    public function requestParams();
85
-
86
-
87
-    /**
88
-     * @param string $key
89
-     * @param string $value
90
-     * @param bool   $override_ee
91
-     * @return void
92
-     */
93
-    public function setRequestParam($key, $value, $override_ee = false);
94
-
95
-
96
-    /**
97
-     * returns   the value for a request param if the given key exists
98
-     *
99
-     * @param string     $key
100
-     * @param mixed|null $default
101
-     * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
102
-     * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
103
-     * @param string     $delimiter for CSV type strings that should be returned as an array
104
-     * @return array|bool|float|int|string
105
-     */
106
-    public function getRequestParam($key, $default = null, $type = DataType::STRING, $is_array = false, $delimiter = '');
107
-
108
-
109
-    /**
110
-     * check if param exists
111
-     *
112
-     * @param string $key
113
-     * @return bool
114
-     */
115
-    public function requestParamIsSet($key);
116
-
117
-
118
-    /**
119
-     * check if a request parameter exists whose key that matches the supplied wildcard pattern
120
-     * and return the value for the first match found
121
-     * wildcards can be either of the following:
122
-     *      ? to represent a single character of any type
123
-     *      * to represent one or more characters of any type
124
-     *
125
-     * @param string     $pattern
126
-     * @param mixed|null $default
127
-     * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
128
-     * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
129
-     * @param string     $delimiter for CSV type strings that should be returned as an array
130
-     * @return array|bool|float|int|string
131
-     */
132
-    public function getMatch($pattern, $default = null, $type = DataType::STRING, $is_array = false, $delimiter = '');
133
-
134
-
135
-    /**
136
-     * check if a request parameter exists whose key matches the supplied wildcard pattern
137
-     * wildcards can be either of the following:
138
-     *      ? to represent a single character of any type
139
-     *      * to represent one or more characters of any type
140
-     * returns true if a match is found or false if not
141
-     *
142
-     * @param string $pattern
143
-     * @return false|int
144
-     */
145
-    public function matches($pattern);
146
-
147
-
148
-    /**
149
-     * remove param
150
-     *
151
-     * @param string $key
152
-     * @param bool   $unset_from_global_too
153
-     */
154
-    public function unSetRequestParam($key, $unset_from_global_too = false);
155
-
156
-
157
-    /**
158
-     * remove params
159
-     *
160
-     * @param array $keys
161
-     * @param bool  $unset_from_global_too
162
-     */
163
-    public function unSetRequestParams(array $keys, $unset_from_global_too = false);
164
-
165
-
166
-    /**
167
-     * @param string $key
168
-     * @param bool   $unset_from_global_too
169
-     * @return void
170
-     */
171
-    public function unSetServerParam(string $key, bool $unset_from_global_too = false);
172
-
173
-
174
-    /**
175
-     * @return string
176
-     */
177
-    public function ipAddress();
178
-
179
-
180
-    /**
181
-     * @param boolean $relativeToWpRoot    whether or not to return the uri relative to WordPress' home URL.
182
-     * @param boolean $remove_query_params whether or not to return the uri with all query params removed.
183
-     * @return string
184
-     */
185
-    public function requestUri($relativeToWpRoot = false, $remove_query_params = false);
186
-
187
-
188
-    /**
189
-     * @return string
190
-     */
191
-    public function userAgent();
192
-
193
-
194
-    /**
195
-     * @param string $user_agent
196
-     */
197
-    public function setUserAgent($user_agent = '');
198
-
199
-
200
-    /**
201
-     * @return bool
202
-     */
203
-    public function isBot();
204
-
205
-
206
-    /**
207
-     * @param bool $is_bot
208
-     */
209
-    public function setIsBot($is_bot);
210
-
211
-
212
-    /**
213
-     * returns the path portion of the current request URI with both the WP Root (home_url()) and query params removed
214
-     *
215
-     * @return string
216
-     * @since   $VID:$
217
-     */
218
-    public function requestPath();
219
-
220
-
221
-    /**
222
-     * returns true if the last segment of the current request path (without params) matches the provided string
223
-     *
224
-     * @param string $uri_segment
225
-     * @return bool
226
-     * @since   $VID:$
227
-     */
228
-    public function currentPageIs($uri_segment);
229
-
230
-
231
-    /**
232
-     * merges the incoming array of parameters into the existing request parameters
233
-     *
234
-     * @param array $request_params
235
-     * @return mixed
236
-     * @since   4.10.24.p
237
-     */
238
-    public function mergeRequestParams(array $request_params);
25
+	/**
26
+	 * @return array
27
+	 */
28
+	public function getParams();
29
+
30
+
31
+	/**
32
+	 * @return array
33
+	 */
34
+	public function postParams();
35
+
36
+
37
+	/**
38
+	 * @return array
39
+	 */
40
+	public function cookieParams();
41
+
42
+
43
+	/**
44
+	 * @return array
45
+	 */
46
+	public function serverParams();
47
+
48
+
49
+	/**
50
+	 * @param string $key
51
+	 * @param mixed|null $default
52
+	 * @return array|int|float|string
53
+	 */
54
+	public function getServerParam($key, $default = null);
55
+
56
+
57
+	/**
58
+	 * @param string                 $key
59
+	 * @param array|int|float|string $value
60
+	 * @param bool                   $set_global_too
61
+	 * @return void
62
+	 */
63
+	public function setServerParam(string $key, $value, bool $set_global_too = false);
64
+
65
+
66
+	/**
67
+	 * @param string $key
68
+	 * @return bool
69
+	 */
70
+	public function serverParamIsSet($key);
71
+
72
+
73
+	/**
74
+	 * @return array
75
+	 */
76
+	public function filesParams();
77
+
78
+
79
+	/**
80
+	 * returns sanitized contents of $_REQUEST
81
+	 *
82
+	 * @return array
83
+	 */
84
+	public function requestParams();
85
+
86
+
87
+	/**
88
+	 * @param string $key
89
+	 * @param string $value
90
+	 * @param bool   $override_ee
91
+	 * @return void
92
+	 */
93
+	public function setRequestParam($key, $value, $override_ee = false);
94
+
95
+
96
+	/**
97
+	 * returns   the value for a request param if the given key exists
98
+	 *
99
+	 * @param string     $key
100
+	 * @param mixed|null $default
101
+	 * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
102
+	 * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
103
+	 * @param string     $delimiter for CSV type strings that should be returned as an array
104
+	 * @return array|bool|float|int|string
105
+	 */
106
+	public function getRequestParam($key, $default = null, $type = DataType::STRING, $is_array = false, $delimiter = '');
107
+
108
+
109
+	/**
110
+	 * check if param exists
111
+	 *
112
+	 * @param string $key
113
+	 * @return bool
114
+	 */
115
+	public function requestParamIsSet($key);
116
+
117
+
118
+	/**
119
+	 * check if a request parameter exists whose key that matches the supplied wildcard pattern
120
+	 * and return the value for the first match found
121
+	 * wildcards can be either of the following:
122
+	 *      ? to represent a single character of any type
123
+	 *      * to represent one or more characters of any type
124
+	 *
125
+	 * @param string     $pattern
126
+	 * @param mixed|null $default
127
+	 * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
128
+	 * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
129
+	 * @param string     $delimiter for CSV type strings that should be returned as an array
130
+	 * @return array|bool|float|int|string
131
+	 */
132
+	public function getMatch($pattern, $default = null, $type = DataType::STRING, $is_array = false, $delimiter = '');
133
+
134
+
135
+	/**
136
+	 * check if a request parameter exists whose key matches the supplied wildcard pattern
137
+	 * wildcards can be either of the following:
138
+	 *      ? to represent a single character of any type
139
+	 *      * to represent one or more characters of any type
140
+	 * returns true if a match is found or false if not
141
+	 *
142
+	 * @param string $pattern
143
+	 * @return false|int
144
+	 */
145
+	public function matches($pattern);
146
+
147
+
148
+	/**
149
+	 * remove param
150
+	 *
151
+	 * @param string $key
152
+	 * @param bool   $unset_from_global_too
153
+	 */
154
+	public function unSetRequestParam($key, $unset_from_global_too = false);
155
+
156
+
157
+	/**
158
+	 * remove params
159
+	 *
160
+	 * @param array $keys
161
+	 * @param bool  $unset_from_global_too
162
+	 */
163
+	public function unSetRequestParams(array $keys, $unset_from_global_too = false);
164
+
165
+
166
+	/**
167
+	 * @param string $key
168
+	 * @param bool   $unset_from_global_too
169
+	 * @return void
170
+	 */
171
+	public function unSetServerParam(string $key, bool $unset_from_global_too = false);
172
+
173
+
174
+	/**
175
+	 * @return string
176
+	 */
177
+	public function ipAddress();
178
+
179
+
180
+	/**
181
+	 * @param boolean $relativeToWpRoot    whether or not to return the uri relative to WordPress' home URL.
182
+	 * @param boolean $remove_query_params whether or not to return the uri with all query params removed.
183
+	 * @return string
184
+	 */
185
+	public function requestUri($relativeToWpRoot = false, $remove_query_params = false);
186
+
187
+
188
+	/**
189
+	 * @return string
190
+	 */
191
+	public function userAgent();
192
+
193
+
194
+	/**
195
+	 * @param string $user_agent
196
+	 */
197
+	public function setUserAgent($user_agent = '');
198
+
199
+
200
+	/**
201
+	 * @return bool
202
+	 */
203
+	public function isBot();
204
+
205
+
206
+	/**
207
+	 * @param bool $is_bot
208
+	 */
209
+	public function setIsBot($is_bot);
210
+
211
+
212
+	/**
213
+	 * returns the path portion of the current request URI with both the WP Root (home_url()) and query params removed
214
+	 *
215
+	 * @return string
216
+	 * @since   $VID:$
217
+	 */
218
+	public function requestPath();
219
+
220
+
221
+	/**
222
+	 * returns true if the last segment of the current request path (without params) matches the provided string
223
+	 *
224
+	 * @param string $uri_segment
225
+	 * @return bool
226
+	 * @since   $VID:$
227
+	 */
228
+	public function currentPageIs($uri_segment);
229
+
230
+
231
+	/**
232
+	 * merges the incoming array of parameters into the existing request parameters
233
+	 *
234
+	 * @param array $request_params
235
+	 * @return mixed
236
+	 * @since   4.10.24.p
237
+	 */
238
+	public function mergeRequestParams(array $request_params);
239 239
 }
Please login to merge, or discard this patch.
core/services/request/ServerParams.php 2 patches
Indentation   +199 added lines, -199 removed lines patch added patch discarded remove patch
@@ -7,203 +7,203 @@
 block discarded – undo
7 7
 class ServerParams
8 8
 {
9 9
 
10
-    /**
11
-     * IP address for request
12
-     *
13
-     * @var string
14
-     */
15
-    protected $ip_address;
16
-
17
-
18
-    /**
19
-     * @var ServerSanitizer
20
-     */
21
-    protected $sanitizer;
22
-
23
-    /**
24
-     * sanitized $_SERVER parameters
25
-     *
26
-     * @var array
27
-     */
28
-    protected $server;
29
-
30
-    /**
31
-     * @var string
32
-     */
33
-    protected $request_uri;
34
-
35
-    /**
36
-     * @var string
37
-     */
38
-    protected $user_agent;
39
-
40
-
41
-    /**
42
-     * ServerParams constructor.
43
-     *
44
-     * @param ServerSanitizer $sanitizer
45
-     * @param array           $server
46
-     */
47
-    public function __construct(ServerSanitizer $sanitizer, array $server = [])
48
-    {
49
-        $this->sanitizer  = $sanitizer;
50
-        $this->server     = $this->cleanServerParams($server);
51
-        $this->ip_address = $this->setVisitorIp();
52
-    }
53
-
54
-
55
-    /**
56
-     * @return array
57
-     */
58
-    private function cleanServerParams(array $server)
59
-    {
60
-        $cleaned = [];
61
-        $server  = ! empty($server) ? $server : $_SERVER;
62
-        foreach ($server as $key => $value) {
63
-            $cleaned[ $key ] = $this->sanitizer->clean($key, $value);
64
-        }
65
-        return $cleaned;
66
-    }
67
-
68
-
69
-    /**
70
-     * @return array
71
-     */
72
-    public function getAllServerParams()
73
-    {
74
-        return $this->server;
75
-    }
76
-
77
-
78
-    /**
79
-     * @param string $key
80
-     * @param mixed|null $default
81
-     * @return array|int|float|string
82
-     */
83
-    public function getServerParam($key, $default = null)
84
-    {
85
-        return $this->serverParamIsSet($key) ? $this->server[ $key ] : $default;
86
-    }
87
-
88
-
89
-    /**
90
-     * @param string                 $key
91
-     * @param array|int|float|string $value
92
-     * @param bool                   $set_global_too
93
-     * @return void
94
-     */
95
-    public function setServerParam(string $key, $value, bool $set_global_too = false)
96
-    {
97
-        $value = $this->sanitizer->clean($key, $value);
98
-        $this->server[ $key ] = $value;
99
-        if ($set_global_too) {
100
-            $_SERVER[ $key ] = $value;
101
-        }
102
-    }
103
-
104
-
105
-    /**
106
-     * @param string $key
107
-     * @param bool   $unset_from_global_too
108
-     * @return void
109
-     */
110
-    public function unSetServerParam(string $key, bool $unset_from_global_too = false)
111
-    {
112
-        unset($this->server[ $key ]);
113
-        if ($unset_from_global_too) {
114
-            unset($_SERVER[ $key ]);
115
-        }
116
-    }
117
-
118
-
119
-    /**
120
-     * @return bool
121
-     */
122
-    public function serverParamIsSet($key)
123
-    {
124
-        return isset($this->server[ $key ]);
125
-    }
126
-
127
-
128
-    /**
129
-     * @return string
130
-     */
131
-    public function ipAddress()
132
-    {
133
-        return $this->ip_address;
134
-    }
135
-
136
-
137
-    /**
138
-     * attempt to get IP address of current visitor from server
139
-     * plz see: http://stackoverflow.com/a/2031935/1475279
140
-     *
141
-     * @access public
142
-     * @return string
143
-     */
144
-    private function setVisitorIp()
145
-    {
146
-        $visitor_ip  = '0.0.0.0';
147
-        $server_keys = [
148
-            'HTTP_CLIENT_IP',
149
-            'HTTP_FORWARDED',
150
-            'HTTP_FORWARDED_FOR',
151
-            'HTTP_X_CLUSTER_CLIENT_IP',
152
-            'HTTP_X_FORWARDED',
153
-            'HTTP_X_FORWARDED_FOR',
154
-            'REMOTE_ADDR',
155
-        ];
156
-        foreach ($server_keys as $key) {
157
-            if (isset($this->server[ $key ])) {
158
-                $potential_ip = array_map('trim', explode(',', $this->server[ $key ]));
159
-                foreach ($potential_ip as $ip) {
160
-                    if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== false) {
161
-                        $visitor_ip = $ip;
162
-                    }
163
-                }
164
-            }
165
-        }
166
-        return $visitor_ip;
167
-    }
168
-
169
-
170
-    /**
171
-     * Gets the request's literal URI. Related to `requestUriAfterSiteHomeUri`, see its description for a comparison.
172
-     *
173
-     * @param boolean $relativeToWpRoot If home_url() is "http://mysite.com/wp/", and a request comes to
174
-     *                                  "http://mysite.com/wp/wp-json", setting $relativeToWpRoot=true will return
175
-     *                                  "/wp-json", whereas $relativeToWpRoot=false will return "/wp/wp-json/".
176
-     * @return string
177
-     */
178
-    public function requestUri($relativeToWpRoot = false)
179
-    {
180
-        if ($relativeToWpRoot) {
181
-            $home_path = untrailingslashit(parse_url(home_url(), PHP_URL_PATH));
182
-            return str_replace($home_path, '', $this->server['REQUEST_URI']);
183
-        }
184
-        return $this->server['REQUEST_URI'];
185
-    }
186
-
187
-
188
-    /**
189
-     * @return string
190
-     */
191
-    public function userAgent()
192
-    {
193
-        if (empty($this->user_agent)) {
194
-            $this->setUserAgent();
195
-        }
196
-        return $this->user_agent;
197
-    }
198
-
199
-
200
-    /**
201
-     * @param string $user_agent
202
-     */
203
-    public function setUserAgent($user_agent = '')
204
-    {
205
-        $this->user_agent = $user_agent === '' || ! is_string($user_agent)
206
-            ? $this->getServerParam('HTTP_USER_AGENT')
207
-            : esc_attr($user_agent);
208
-    }
10
+	/**
11
+	 * IP address for request
12
+	 *
13
+	 * @var string
14
+	 */
15
+	protected $ip_address;
16
+
17
+
18
+	/**
19
+	 * @var ServerSanitizer
20
+	 */
21
+	protected $sanitizer;
22
+
23
+	/**
24
+	 * sanitized $_SERVER parameters
25
+	 *
26
+	 * @var array
27
+	 */
28
+	protected $server;
29
+
30
+	/**
31
+	 * @var string
32
+	 */
33
+	protected $request_uri;
34
+
35
+	/**
36
+	 * @var string
37
+	 */
38
+	protected $user_agent;
39
+
40
+
41
+	/**
42
+	 * ServerParams constructor.
43
+	 *
44
+	 * @param ServerSanitizer $sanitizer
45
+	 * @param array           $server
46
+	 */
47
+	public function __construct(ServerSanitizer $sanitizer, array $server = [])
48
+	{
49
+		$this->sanitizer  = $sanitizer;
50
+		$this->server     = $this->cleanServerParams($server);
51
+		$this->ip_address = $this->setVisitorIp();
52
+	}
53
+
54
+
55
+	/**
56
+	 * @return array
57
+	 */
58
+	private function cleanServerParams(array $server)
59
+	{
60
+		$cleaned = [];
61
+		$server  = ! empty($server) ? $server : $_SERVER;
62
+		foreach ($server as $key => $value) {
63
+			$cleaned[ $key ] = $this->sanitizer->clean($key, $value);
64
+		}
65
+		return $cleaned;
66
+	}
67
+
68
+
69
+	/**
70
+	 * @return array
71
+	 */
72
+	public function getAllServerParams()
73
+	{
74
+		return $this->server;
75
+	}
76
+
77
+
78
+	/**
79
+	 * @param string $key
80
+	 * @param mixed|null $default
81
+	 * @return array|int|float|string
82
+	 */
83
+	public function getServerParam($key, $default = null)
84
+	{
85
+		return $this->serverParamIsSet($key) ? $this->server[ $key ] : $default;
86
+	}
87
+
88
+
89
+	/**
90
+	 * @param string                 $key
91
+	 * @param array|int|float|string $value
92
+	 * @param bool                   $set_global_too
93
+	 * @return void
94
+	 */
95
+	public function setServerParam(string $key, $value, bool $set_global_too = false)
96
+	{
97
+		$value = $this->sanitizer->clean($key, $value);
98
+		$this->server[ $key ] = $value;
99
+		if ($set_global_too) {
100
+			$_SERVER[ $key ] = $value;
101
+		}
102
+	}
103
+
104
+
105
+	/**
106
+	 * @param string $key
107
+	 * @param bool   $unset_from_global_too
108
+	 * @return void
109
+	 */
110
+	public function unSetServerParam(string $key, bool $unset_from_global_too = false)
111
+	{
112
+		unset($this->server[ $key ]);
113
+		if ($unset_from_global_too) {
114
+			unset($_SERVER[ $key ]);
115
+		}
116
+	}
117
+
118
+
119
+	/**
120
+	 * @return bool
121
+	 */
122
+	public function serverParamIsSet($key)
123
+	{
124
+		return isset($this->server[ $key ]);
125
+	}
126
+
127
+
128
+	/**
129
+	 * @return string
130
+	 */
131
+	public function ipAddress()
132
+	{
133
+		return $this->ip_address;
134
+	}
135
+
136
+
137
+	/**
138
+	 * attempt to get IP address of current visitor from server
139
+	 * plz see: http://stackoverflow.com/a/2031935/1475279
140
+	 *
141
+	 * @access public
142
+	 * @return string
143
+	 */
144
+	private function setVisitorIp()
145
+	{
146
+		$visitor_ip  = '0.0.0.0';
147
+		$server_keys = [
148
+			'HTTP_CLIENT_IP',
149
+			'HTTP_FORWARDED',
150
+			'HTTP_FORWARDED_FOR',
151
+			'HTTP_X_CLUSTER_CLIENT_IP',
152
+			'HTTP_X_FORWARDED',
153
+			'HTTP_X_FORWARDED_FOR',
154
+			'REMOTE_ADDR',
155
+		];
156
+		foreach ($server_keys as $key) {
157
+			if (isset($this->server[ $key ])) {
158
+				$potential_ip = array_map('trim', explode(',', $this->server[ $key ]));
159
+				foreach ($potential_ip as $ip) {
160
+					if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== false) {
161
+						$visitor_ip = $ip;
162
+					}
163
+				}
164
+			}
165
+		}
166
+		return $visitor_ip;
167
+	}
168
+
169
+
170
+	/**
171
+	 * Gets the request's literal URI. Related to `requestUriAfterSiteHomeUri`, see its description for a comparison.
172
+	 *
173
+	 * @param boolean $relativeToWpRoot If home_url() is "http://mysite.com/wp/", and a request comes to
174
+	 *                                  "http://mysite.com/wp/wp-json", setting $relativeToWpRoot=true will return
175
+	 *                                  "/wp-json", whereas $relativeToWpRoot=false will return "/wp/wp-json/".
176
+	 * @return string
177
+	 */
178
+	public function requestUri($relativeToWpRoot = false)
179
+	{
180
+		if ($relativeToWpRoot) {
181
+			$home_path = untrailingslashit(parse_url(home_url(), PHP_URL_PATH));
182
+			return str_replace($home_path, '', $this->server['REQUEST_URI']);
183
+		}
184
+		return $this->server['REQUEST_URI'];
185
+	}
186
+
187
+
188
+	/**
189
+	 * @return string
190
+	 */
191
+	public function userAgent()
192
+	{
193
+		if (empty($this->user_agent)) {
194
+			$this->setUserAgent();
195
+		}
196
+		return $this->user_agent;
197
+	}
198
+
199
+
200
+	/**
201
+	 * @param string $user_agent
202
+	 */
203
+	public function setUserAgent($user_agent = '')
204
+	{
205
+		$this->user_agent = $user_agent === '' || ! is_string($user_agent)
206
+			? $this->getServerParam('HTTP_USER_AGENT')
207
+			: esc_attr($user_agent);
208
+	}
209 209
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
         $cleaned = [];
61 61
         $server  = ! empty($server) ? $server : $_SERVER;
62 62
         foreach ($server as $key => $value) {
63
-            $cleaned[ $key ] = $this->sanitizer->clean($key, $value);
63
+            $cleaned[$key] = $this->sanitizer->clean($key, $value);
64 64
         }
65 65
         return $cleaned;
66 66
     }
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
      */
83 83
     public function getServerParam($key, $default = null)
84 84
     {
85
-        return $this->serverParamIsSet($key) ? $this->server[ $key ] : $default;
85
+        return $this->serverParamIsSet($key) ? $this->server[$key] : $default;
86 86
     }
87 87
 
88 88
 
@@ -95,9 +95,9 @@  discard block
 block discarded – undo
95 95
     public function setServerParam(string $key, $value, bool $set_global_too = false)
96 96
     {
97 97
         $value = $this->sanitizer->clean($key, $value);
98
-        $this->server[ $key ] = $value;
98
+        $this->server[$key] = $value;
99 99
         if ($set_global_too) {
100
-            $_SERVER[ $key ] = $value;
100
+            $_SERVER[$key] = $value;
101 101
         }
102 102
     }
103 103
 
@@ -109,9 +109,9 @@  discard block
 block discarded – undo
109 109
      */
110 110
     public function unSetServerParam(string $key, bool $unset_from_global_too = false)
111 111
     {
112
-        unset($this->server[ $key ]);
112
+        unset($this->server[$key]);
113 113
         if ($unset_from_global_too) {
114
-            unset($_SERVER[ $key ]);
114
+            unset($_SERVER[$key]);
115 115
         }
116 116
     }
117 117
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
      */
122 122
     public function serverParamIsSet($key)
123 123
     {
124
-        return isset($this->server[ $key ]);
124
+        return isset($this->server[$key]);
125 125
     }
126 126
 
127 127
 
@@ -154,8 +154,8 @@  discard block
 block discarded – undo
154 154
             'REMOTE_ADDR',
155 155
         ];
156 156
         foreach ($server_keys as $key) {
157
-            if (isset($this->server[ $key ])) {
158
-                $potential_ip = array_map('trim', explode(',', $this->server[ $key ]));
157
+            if (isset($this->server[$key])) {
158
+                $potential_ip = array_map('trim', explode(',', $this->server[$key]));
159 159
                 foreach ($potential_ip as $ip) {
160 160
                     if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== false) {
161 161
                         $visitor_ip = $ip;
Please login to merge, or discard this patch.
core/EE_Config.core.php 2 patches
Indentation   +3264 added lines, -3264 removed lines patch added patch discarded remove patch
@@ -19,2595 +19,2595 @@  discard block
 block discarded – undo
19 19
 final class EE_Config implements ResettableInterface
20 20
 {
21 21
 
22
-    const OPTION_NAME = 'ee_config';
23
-
24
-    const LOG_NAME = 'ee_config_log';
25
-
26
-    const LOG_LENGTH = 100;
27
-
28
-    const ADDON_OPTION_NAMES = 'ee_config_option_names';
29
-
30
-    /**
31
-     *    instance of the EE_Config object
32
-     *
33
-     * @var    EE_Config $_instance
34
-     * @access    private
35
-     */
36
-    private static $_instance;
37
-
38
-    /**
39
-     * @var boolean $_logging_enabled
40
-     */
41
-    private static $_logging_enabled = false;
42
-
43
-    /**
44
-     * @var LegacyShortcodesManager $legacy_shortcodes_manager
45
-     */
46
-    private $legacy_shortcodes_manager;
47
-
48
-    /**
49
-     * An StdClass whose property names are addon slugs,
50
-     * and values are their config classes
51
-     *
52
-     * @var StdClass
53
-     */
54
-    public $addons;
55
-
56
-    /**
57
-     * @var EE_Admin_Config
58
-     */
59
-    public $admin;
60
-
61
-    /**
62
-     * @var EE_Core_Config
63
-     */
64
-    public $core;
65
-
66
-    /**
67
-     * @var EE_Currency_Config
68
-     */
69
-    public $currency;
70
-
71
-    /**
72
-     * @var EE_Organization_Config
73
-     */
74
-    public $organization;
75
-
76
-    /**
77
-     * @var EE_Registration_Config
78
-     */
79
-    public $registration;
80
-
81
-    /**
82
-     * @var EE_Template_Config
83
-     */
84
-    public $template_settings;
85
-
86
-    /**
87
-     * Holds EE environment values.
88
-     *
89
-     * @var EE_Environment_Config
90
-     */
91
-    public $environment;
92
-
93
-    /**
94
-     * settings pertaining to Google maps
95
-     *
96
-     * @var EE_Map_Config
97
-     */
98
-    public $map_settings;
99
-
100
-    /**
101
-     * settings pertaining to Taxes
102
-     *
103
-     * @var EE_Tax_Config
104
-     */
105
-    public $tax_settings;
106
-
107
-    /**
108
-     * Settings pertaining to global messages settings.
109
-     *
110
-     * @var EE_Messages_Config
111
-     */
112
-    public $messages;
113
-
114
-    /**
115
-     * @deprecated
116
-     * @var EE_Gateway_Config
117
-     */
118
-    public $gateway;
119
-
120
-    /**
121
-     * @var array
122
-     */
123
-    private $_addon_option_names = array();
124
-
125
-    /**
126
-     * @var array
127
-     */
128
-    private static $_module_route_map = array();
129
-
130
-    /**
131
-     * @var array
132
-     */
133
-    private static $_module_forward_map = array();
134
-
135
-    /**
136
-     * @var array
137
-     */
138
-    private static $_module_view_map = array();
139
-
140
-    /**
141
-     * @var bool
142
-     */
143
-    private static $initialized = false;
144
-
145
-
146
-    /**
147
-     * @singleton method used to instantiate class object
148
-     * @access    public
149
-     * @return EE_Config instance
150
-     */
151
-    public static function instance()
152
-    {
153
-        // check if class object is instantiated, and instantiated properly
154
-        if (! self::$_instance instanceof EE_Config) {
155
-            self::$_instance = new self();
156
-        }
157
-        return self::$_instance;
158
-    }
159
-
160
-
161
-    /**
162
-     * Resets the config
163
-     *
164
-     * @param bool    $hard_reset    if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE
165
-     *                               (default) leaves the database alone, and merely resets the EE_Config object to
166
-     *                               reflect its state in the database
167
-     * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave
168
-     *                               $_instance as NULL. Useful in case you want to forget about the old instance on
169
-     *                               EE_Config, but might not be ready to instantiate EE_Config currently (eg if the
170
-     *                               site was put into maintenance mode)
171
-     * @return EE_Config
172
-     */
173
-    public static function reset($hard_reset = false, $reinstantiate = true)
174
-    {
175
-        if (self::$_instance instanceof EE_Config) {
176
-            if ($hard_reset) {
177
-                self::$_instance->legacy_shortcodes_manager = null;
178
-                self::$_instance->_addon_option_names = array();
179
-                self::$_instance->_initialize_config();
180
-                self::$_instance->update_espresso_config();
181
-            }
182
-            self::$_instance->update_addon_option_names();
183
-        }
184
-        self::$_instance = null;
185
-        self::$initialized = false;
186
-        // we don't need to reset the static properties imo because those should
187
-        // only change when a module is added or removed. Currently we don't
188
-        // support removing a module during a request when it previously existed
189
-        if ($reinstantiate) {
190
-            return self::instance();
191
-        } else {
192
-            return null;
193
-        }
194
-    }
195
-
196
-
197
-    private function __construct()
198
-    {
199
-        if (self::$initialized) {
200
-            return;
201
-        }
202
-        self::$initialized = true;
203
-        do_action('AHEE__EE_Config__construct__begin', $this);
204
-        EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false);
205
-        // setup empty config classes
206
-        $this->_initialize_config();
207
-        // load existing EE site settings
208
-        $this->_load_core_config();
209
-        // confirm everything loaded correctly and set filtered defaults if not
210
-        $this->_verify_config();
211
-        //  register shortcodes and modules
212
-        add_action(
213
-            'AHEE__EE_System__register_shortcodes_modules_and_widgets',
214
-            [$this, 'register_shortcodes_and_modules'],
215
-            999
216
-        );
217
-        //  initialize shortcodes and modules
218
-        add_action('AHEE__EE_System__core_loaded_and_ready', [$this, 'initialize_shortcodes_and_modules']);
219
-        // register widgets
220
-        add_action('widgets_init', [$this, 'widgets_init'], 10);
221
-        // shutdown
222
-        add_action('shutdown', [$this, 'shutdown'], 10);
223
-        // construct__end hook
224
-        do_action('AHEE__EE_Config__construct__end', $this);
225
-        // hardcoded hack
226
-        $this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014';
227
-    }
228
-
229
-
230
-    /**
231
-     * @return boolean
232
-     */
233
-    public static function logging_enabled()
234
-    {
235
-        return self::$_logging_enabled;
236
-    }
237
-
238
-
239
-    /**
240
-     * use to get the current theme if needed from static context
241
-     *
242
-     * @return string current theme set.
243
-     */
244
-    public static function get_current_theme()
245
-    {
246
-        return self::$_instance->template_settings->current_espresso_theme ?? 'Espresso_Arabica_2014';
247
-    }
248
-
249
-
250
-    /**
251
-     *        _initialize_config
252
-     *
253
-     * @access private
254
-     * @return void
255
-     */
256
-    private function _initialize_config()
257
-    {
258
-        EE_Config::trim_log();
259
-        // set defaults
260
-        $this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array());
261
-        $this->addons = new stdClass();
262
-        // set _module_route_map
263
-        EE_Config::$_module_route_map = array();
264
-        // set _module_forward_map
265
-        EE_Config::$_module_forward_map = array();
266
-        // set _module_view_map
267
-        EE_Config::$_module_view_map = array();
268
-    }
269
-
270
-
271
-    /**
272
-     *        load core plugin configuration
273
-     *
274
-     * @access private
275
-     * @return void
276
-     */
277
-    private function _load_core_config()
278
-    {
279
-        // load_core_config__start hook
280
-        do_action('AHEE__EE_Config___load_core_config__start', $this);
281
-        $espresso_config = (array) $this->get_espresso_config();
282
-        // need to move the "addons" element to the end of the config array
283
-        // in case an addon config references one of the other config classes
284
-        $addons = $espresso_config['addons'];
285
-        unset($espresso_config['addons']);
286
-        $espresso_config['addons'] = $addons;
287
-        foreach ($espresso_config as $config => $settings) {
288
-            // load_core_config__start hook
289
-            $settings = apply_filters(
290
-                'FHEE__EE_Config___load_core_config__config_settings',
291
-                $settings,
292
-                $config,
293
-                $this
294
-            );
295
-            if (is_object($settings) && property_exists($this, $config)) {
296
-                $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
297
-                // call configs populate method to ensure any defaults are set for empty values.
298
-                if (method_exists($settings, 'populate')) {
299
-                    $this->{$config}->populate();
300
-                }
301
-                if (method_exists($settings, 'do_hooks')) {
302
-                    $this->{$config}->do_hooks();
303
-                }
304
-            }
305
-        }
306
-        if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) {
307
-            $this->update_espresso_config();
308
-        }
309
-        // load_core_config__end hook
310
-        do_action('AHEE__EE_Config___load_core_config__end', $this);
311
-    }
312
-
313
-
314
-    /**
315
-     *    _verify_config
316
-     *
317
-     * @access    protected
318
-     * @return    void
319
-     */
320
-    protected function _verify_config()
321
-    {
322
-        $this->core = $this->core instanceof EE_Core_Config
323
-            ? $this->core
324
-            : new EE_Core_Config();
325
-        $this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core);
326
-        $this->organization = $this->organization instanceof EE_Organization_Config
327
-            ? $this->organization
328
-            : new EE_Organization_Config();
329
-        $this->organization = apply_filters(
330
-            'FHEE__EE_Config___initialize_config__organization',
331
-            $this->organization
332
-        );
333
-        $this->currency = $this->currency instanceof EE_Currency_Config
334
-            ? $this->currency
335
-            : new EE_Currency_Config();
336
-        $this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency);
337
-        $this->registration = $this->registration instanceof EE_Registration_Config
338
-            ? $this->registration
339
-            : new EE_Registration_Config();
340
-        $this->registration = apply_filters(
341
-            'FHEE__EE_Config___initialize_config__registration',
342
-            $this->registration
343
-        );
344
-        $this->admin = $this->admin instanceof EE_Admin_Config
345
-            ? $this->admin
346
-            : new EE_Admin_Config();
347
-        $this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin);
348
-        $this->template_settings = $this->template_settings instanceof EE_Template_Config
349
-            ? $this->template_settings
350
-            : new EE_Template_Config();
351
-        $this->template_settings = apply_filters(
352
-            'FHEE__EE_Config___initialize_config__template_settings',
353
-            $this->template_settings
354
-        );
355
-        $this->map_settings = $this->map_settings instanceof EE_Map_Config
356
-            ? $this->map_settings
357
-            : new EE_Map_Config();
358
-        $this->map_settings = apply_filters(
359
-            'FHEE__EE_Config___initialize_config__map_settings',
360
-            $this->map_settings
361
-        );
362
-        $this->environment = $this->environment instanceof EE_Environment_Config
363
-            ? $this->environment
364
-            : new EE_Environment_Config();
365
-        $this->environment = apply_filters(
366
-            'FHEE__EE_Config___initialize_config__environment',
367
-            $this->environment
368
-        );
369
-        $this->tax_settings = $this->tax_settings instanceof EE_Tax_Config
370
-            ? $this->tax_settings
371
-            : new EE_Tax_Config();
372
-        $this->tax_settings = apply_filters(
373
-            'FHEE__EE_Config___initialize_config__tax_settings',
374
-            $this->tax_settings
375
-        );
376
-        $this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages);
377
-        $this->messages = $this->messages instanceof EE_Messages_Config
378
-            ? $this->messages
379
-            : new EE_Messages_Config();
380
-        $this->gateway = $this->gateway instanceof EE_Gateway_Config
381
-            ? $this->gateway
382
-            : new EE_Gateway_Config();
383
-        $this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway);
384
-        $this->legacy_shortcodes_manager = null;
385
-    }
386
-
387
-
388
-    /**
389
-     *    get_espresso_config
390
-     *
391
-     * @access    public
392
-     * @return    array of espresso config stuff
393
-     */
394
-    public function get_espresso_config()
395
-    {
396
-        // grab espresso configuration
397
-        return apply_filters(
398
-            'FHEE__EE_Config__get_espresso_config__CFG',
399
-            get_option(EE_Config::OPTION_NAME, array())
400
-        );
401
-    }
402
-
403
-
404
-    /**
405
-     *    double_check_config_comparison
406
-     *
407
-     * @access    public
408
-     * @param string $option
409
-     * @param        $old_value
410
-     * @param        $value
411
-     */
412
-    public function double_check_config_comparison($option = '', $old_value, $value)
413
-    {
414
-        // make sure we're checking the ee config
415
-        if ($option === EE_Config::OPTION_NAME) {
416
-            // run a loose comparison of the old value against the new value for type and properties,
417
-            // but NOT exact instance like WP update_option does (ie: NOT type safe comparison)
418
-            if ($value != $old_value) {
419
-                // if they are NOT the same, then remove the hook,
420
-                // which means the subsequent update results will be based solely on the update query results
421
-                // the reason we do this is because, as stated above,
422
-                // WP update_option performs an exact instance comparison (===) on any update values passed to it
423
-                // this happens PRIOR to serialization and any subsequent update.
424
-                // If values are found to match their previous old value,
425
-                // then WP bails before performing any update.
426
-                // Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version
427
-                // it just pulled from the db, with the one being passed to it (which will not match).
428
-                // HOWEVER, once the object is serialized and passed off to MySQL to update,
429
-                // MySQL MAY ALSO NOT perform the update because
430
-                // the string it sees in the db looks the same as the new one it has been passed!!!
431
-                // This results in the query returning an "affected rows" value of ZERO,
432
-                // which gets returned immediately by WP update_option and looks like an error.
433
-                remove_action('update_option', array($this, 'check_config_updated'));
434
-            }
435
-        }
436
-    }
437
-
438
-
439
-    /**
440
-     *    update_espresso_config
441
-     *
442
-     * @access   public
443
-     */
444
-    protected function _reset_espresso_addon_config()
445
-    {
446
-        $this->_addon_option_names = array();
447
-        foreach ($this->addons as $addon_name => $addon_config_obj) {
448
-            $addon_config_obj = maybe_unserialize($addon_config_obj);
449
-            if ($addon_config_obj instanceof EE_Config_Base) {
450
-                $this->update_config('addons', $addon_name, $addon_config_obj, false);
451
-            }
452
-            $this->addons->{$addon_name} = null;
453
-        }
454
-    }
455
-
456
-
457
-    /**
458
-     *    update_espresso_config
459
-     *
460
-     * @access   public
461
-     * @param   bool $add_success
462
-     * @param   bool $add_error
463
-     * @return   bool
464
-     */
465
-    public function update_espresso_config($add_success = false, $add_error = true)
466
-    {
467
-        // don't allow config updates during WP heartbeats
468
-        /** @var RequestInterface $request */
469
-        $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
470
-        if ($request->isWordPressHeartbeat()) {
471
-            return false;
472
-        }
473
-        // commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
474
-        // $clone = clone( self::$_instance );
475
-        // self::$_instance = NULL;
476
-        do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
477
-        $this->_reset_espresso_addon_config();
478
-        // hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
479
-        // but BEFORE the actual update occurs
480
-        add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
481
-        // don't want to persist legacy_shortcodes_manager, but don't want to lose it either
482
-        $legacy_shortcodes_manager = $this->legacy_shortcodes_manager;
483
-        $this->legacy_shortcodes_manager = null;
484
-        // now update "ee_config"
485
-        $saved = update_option(EE_Config::OPTION_NAME, $this);
486
-        $this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
487
-        EE_Config::log(EE_Config::OPTION_NAME);
488
-        // if not saved... check if the hook we just added still exists;
489
-        // if it does, it means one of two things:
490
-        // that update_option bailed at the($value === $old_value) conditional,
491
-        // or...
492
-        // the db update query returned 0 rows affected
493
-        // (probably because the data  value was the same from it's perspective)
494
-        // so the existence of the hook means that a negative result from update_option is NOT an error,
495
-        // but just means no update occurred, so don't display an error to the user.
496
-        // BUT... if update_option returns FALSE, AND the hook is missing,
497
-        // then it means that something truly went wrong
498
-        $saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
499
-        // remove our action since we don't want it in the system anymore
500
-        remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
501
-        do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
502
-        // self::$_instance = $clone;
503
-        // unset( $clone );
504
-        // if config remains the same or was updated successfully
505
-        if ($saved) {
506
-            if ($add_success) {
507
-                EE_Error::add_success(
508
-                    esc_html__('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
509
-                    __FILE__,
510
-                    __FUNCTION__,
511
-                    __LINE__
512
-                );
513
-            }
514
-            return true;
515
-        } else {
516
-            if ($add_error) {
517
-                EE_Error::add_error(
518
-                    esc_html__('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
519
-                    __FILE__,
520
-                    __FUNCTION__,
521
-                    __LINE__
522
-                );
523
-            }
524
-            return false;
525
-        }
526
-    }
527
-
528
-
529
-    /**
530
-     *    _verify_config_params
531
-     *
532
-     * @access    private
533
-     * @param    string         $section
534
-     * @param    string         $name
535
-     * @param    string         $config_class
536
-     * @param    EE_Config_Base $config_obj
537
-     * @param    array          $tests_to_run
538
-     * @param    bool           $display_errors
539
-     * @return    bool    TRUE on success, FALSE on fail
540
-     */
541
-    private function _verify_config_params(
542
-        $section = '',
543
-        $name = '',
544
-        $config_class = '',
545
-        $config_obj = null,
546
-        $tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
547
-        $display_errors = true
548
-    ) {
549
-        try {
550
-            foreach ($tests_to_run as $test) {
551
-                switch ($test) {
552
-                    // TEST #1 : check that section was set
553
-                    case 1:
554
-                        if (empty($section)) {
555
-                            if ($display_errors) {
556
-                                throw new EE_Error(
557
-                                    sprintf(
558
-                                        esc_html__(
559
-                                            'No configuration section has been provided while attempting to save "%s".',
560
-                                            'event_espresso'
561
-                                        ),
562
-                                        $config_class
563
-                                    )
564
-                                );
565
-                            }
566
-                            return false;
567
-                        }
568
-                        break;
569
-                    // TEST #2 : check that settings section exists
570
-                    case 2:
571
-                        if (! isset($this->{$section})) {
572
-                            if ($display_errors) {
573
-                                throw new EE_Error(
574
-                                    sprintf(
575
-                                        esc_html__('The "%s" configuration section does not exist.', 'event_espresso'),
576
-                                        $section
577
-                                    )
578
-                                );
579
-                            }
580
-                            return false;
581
-                        }
582
-                        break;
583
-                    // TEST #3 : check that section is the proper format
584
-                    case 3:
585
-                        if (
586
-                            ! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
587
-                        ) {
588
-                            if ($display_errors) {
589
-                                throw new EE_Error(
590
-                                    sprintf(
591
-                                        esc_html__(
592
-                                            'The "%s" configuration settings have not been formatted correctly.',
593
-                                            'event_espresso'
594
-                                        ),
595
-                                        $section
596
-                                    )
597
-                                );
598
-                            }
599
-                            return false;
600
-                        }
601
-                        break;
602
-                    // TEST #4 : check that config section name has been set
603
-                    case 4:
604
-                        if (empty($name)) {
605
-                            if ($display_errors) {
606
-                                throw new EE_Error(
607
-                                    esc_html__(
608
-                                        'No name has been provided for the specific configuration section.',
609
-                                        'event_espresso'
610
-                                    )
611
-                                );
612
-                            }
613
-                            return false;
614
-                        }
615
-                        break;
616
-                    // TEST #5 : check that a config class name has been set
617
-                    case 5:
618
-                        if (empty($config_class)) {
619
-                            if ($display_errors) {
620
-                                throw new EE_Error(
621
-                                    esc_html__(
622
-                                        'No class name has been provided for the specific configuration section.',
623
-                                        'event_espresso'
624
-                                    )
625
-                                );
626
-                            }
627
-                            return false;
628
-                        }
629
-                        break;
630
-                    // TEST #6 : verify config class is accessible
631
-                    case 6:
632
-                        if (! class_exists($config_class)) {
633
-                            if ($display_errors) {
634
-                                throw new EE_Error(
635
-                                    sprintf(
636
-                                        esc_html__(
637
-                                            'The "%s" class does not exist. Please ensure that an autoloader has been set for it.',
638
-                                            'event_espresso'
639
-                                        ),
640
-                                        $config_class
641
-                                    )
642
-                                );
643
-                            }
644
-                            return false;
645
-                        }
646
-                        break;
647
-                    // TEST #7 : check that config has even been set
648
-                    case 7:
649
-                        if (! isset($this->{$section}->{$name})) {
650
-                            if ($display_errors) {
651
-                                throw new EE_Error(
652
-                                    sprintf(
653
-                                        esc_html__('No configuration has been set for "%1$s->%2$s".', 'event_espresso'),
654
-                                        $section,
655
-                                        $name
656
-                                    )
657
-                                );
658
-                            }
659
-                            return false;
660
-                        } else {
661
-                            // and make sure it's not serialized
662
-                            $this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name});
663
-                        }
664
-                        break;
665
-                    // TEST #8 : check that config is the requested type
666
-                    case 8:
667
-                        if (! $this->{$section}->{$name} instanceof $config_class) {
668
-                            if ($display_errors) {
669
-                                throw new EE_Error(
670
-                                    sprintf(
671
-                                        esc_html__(
672
-                                            'The configuration for "%1$s->%2$s" is not of the "%3$s" class.',
673
-                                            'event_espresso'
674
-                                        ),
675
-                                        $section,
676
-                                        $name,
677
-                                        $config_class
678
-                                    )
679
-                                );
680
-                            }
681
-                            return false;
682
-                        }
683
-                        break;
684
-                    // TEST #9 : verify config object
685
-                    case 9:
686
-                        if (! $config_obj instanceof EE_Config_Base) {
687
-                            if ($display_errors) {
688
-                                throw new EE_Error(
689
-                                    sprintf(
690
-                                        esc_html__('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'),
691
-                                        print_r($config_obj, true)
692
-                                    )
693
-                                );
694
-                            }
695
-                            return false;
696
-                        }
697
-                        break;
698
-                }
699
-            }
700
-        } catch (EE_Error $e) {
701
-            $e->get_error();
702
-        }
703
-        // you have successfully run the gauntlet
704
-        return true;
705
-    }
706
-
707
-
708
-    /**
709
-     *    _generate_config_option_name
710
-     *
711
-     * @access        protected
712
-     * @param        string $section
713
-     * @param        string $name
714
-     * @return        string
715
-     */
716
-    private function _generate_config_option_name($section = '', $name = '')
717
-    {
718
-        return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
719
-    }
720
-
721
-
722
-    /**
723
-     *    _set_config_class
724
-     * ensures that a config class is set, either from a passed config class or one generated from the config name
725
-     *
726
-     * @access    private
727
-     * @param    string $config_class
728
-     * @param    string $name
729
-     * @return    string
730
-     */
731
-    private function _set_config_class($config_class = '', $name = '')
732
-    {
733
-        return ! empty($config_class)
734
-            ? $config_class
735
-            : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
736
-    }
737
-
738
-
739
-    /**
740
-     *    set_config
741
-     *
742
-     * @access    protected
743
-     * @param    string         $section
744
-     * @param    string         $name
745
-     * @param    string         $config_class
746
-     * @param    EE_Config_Base $config_obj
747
-     * @return    EE_Config_Base
748
-     */
749
-    public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null)
750
-    {
751
-        // ensure config class is set to something
752
-        $config_class = $this->_set_config_class($config_class, $name);
753
-        // run tests 1-4, 6, and 7 to verify all config params are set and valid
754
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
755
-            return null;
756
-        }
757
-        $config_option_name = $this->_generate_config_option_name($section, $name);
758
-        // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
759
-        if (! isset($this->_addon_option_names[ $config_option_name ])) {
760
-            $this->_addon_option_names[ $config_option_name ] = $config_class;
761
-            $this->update_addon_option_names();
762
-        }
763
-        // verify the incoming config object but suppress errors
764
-        if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
765
-            $config_obj = new $config_class();
766
-        }
767
-        if (get_option($config_option_name)) {
768
-            EE_Config::log($config_option_name);
769
-            update_option($config_option_name, $config_obj);
770
-            $this->{$section}->{$name} = $config_obj;
771
-            return $this->{$section}->{$name};
772
-        } else {
773
-            // create a wp-option for this config
774
-            if (add_option($config_option_name, $config_obj, '', 'no')) {
775
-                $this->{$section}->{$name} = maybe_unserialize($config_obj);
776
-                return $this->{$section}->{$name};
777
-            } else {
778
-                EE_Error::add_error(
779
-                    sprintf(esc_html__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class),
780
-                    __FILE__,
781
-                    __FUNCTION__,
782
-                    __LINE__
783
-                );
784
-                return null;
785
-            }
786
-        }
787
-    }
788
-
789
-
790
-    /**
791
-     *    update_config
792
-     * Important: the config object must ALREADY be set, otherwise this will produce an error.
793
-     *
794
-     * @access    public
795
-     * @param    string                $section
796
-     * @param    string                $name
797
-     * @param    EE_Config_Base|string $config_obj
798
-     * @param    bool                  $throw_errors
799
-     * @return    bool
800
-     */
801
-    public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true)
802
-    {
803
-        // don't allow config updates during WP heartbeats
804
-        /** @var RequestInterface $request */
805
-        $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
806
-        if ($request->isWordPressHeartbeat()) {
807
-            return false;
808
-        }
809
-        $config_obj = maybe_unserialize($config_obj);
810
-        // get class name of the incoming object
811
-        $config_class = get_class($config_obj);
812
-        // run tests 1-5 and 9 to verify config
813
-        if (
814
-            ! $this->_verify_config_params(
815
-                $section,
816
-                $name,
817
-                $config_class,
818
-                $config_obj,
819
-                array(1, 2, 3, 4, 7, 9)
820
-            )
821
-        ) {
822
-            return false;
823
-        }
824
-        $config_option_name = $this->_generate_config_option_name($section, $name);
825
-        // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
826
-        if (! isset($this->_addon_option_names[ $config_option_name ])) {
827
-            // save new config to db
828
-            if ($this->set_config($section, $name, $config_class, $config_obj)) {
829
-                return true;
830
-            }
831
-        } else {
832
-            // first check if the record already exists
833
-            $existing_config = get_option($config_option_name);
834
-            $config_obj = serialize($config_obj);
835
-            // just return if db record is already up to date (NOT type safe comparison)
836
-            if ($existing_config == $config_obj) {
837
-                $this->{$section}->{$name} = $config_obj;
838
-                return true;
839
-            } elseif (update_option($config_option_name, $config_obj)) {
840
-                EE_Config::log($config_option_name);
841
-                // update wp-option for this config class
842
-                $this->{$section}->{$name} = $config_obj;
843
-                return true;
844
-            } elseif ($throw_errors) {
845
-                EE_Error::add_error(
846
-                    sprintf(
847
-                        esc_html__(
848
-                            'The "%1$s" object stored at"%2$s" was not successfully updated in the database.',
849
-                            'event_espresso'
850
-                        ),
851
-                        $config_class,
852
-                        'EE_Config->' . $section . '->' . $name
853
-                    ),
854
-                    __FILE__,
855
-                    __FUNCTION__,
856
-                    __LINE__
857
-                );
858
-            }
859
-        }
860
-        return false;
861
-    }
862
-
863
-
864
-    /**
865
-     *    get_config
866
-     *
867
-     * @access    public
868
-     * @param    string $section
869
-     * @param    string $name
870
-     * @param    string $config_class
871
-     * @return    mixed EE_Config_Base | NULL
872
-     */
873
-    public function get_config($section = '', $name = '', $config_class = '')
874
-    {
875
-        // ensure config class is set to something
876
-        $config_class = $this->_set_config_class($config_class, $name);
877
-        // run tests 1-4, 6 and 7 to verify that all params have been set
878
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
879
-            return null;
880
-        }
881
-        // now test if the requested config object exists, but suppress errors
882
-        if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) {
883
-            // config already exists, so pass it back
884
-            return $this->{$section}->{$name};
885
-        }
886
-        // load config option from db if it exists
887
-        $config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
888
-        // verify the newly retrieved config object, but suppress errors
889
-        if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
890
-            // config is good, so set it and pass it back
891
-            $this->{$section}->{$name} = $config_obj;
892
-            return $this->{$section}->{$name};
893
-        }
894
-        // oops! $config_obj is not already set and does not exist in the db, so create a new one
895
-        $config_obj = $this->set_config($section, $name, $config_class);
896
-        // verify the newly created config object
897
-        if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
898
-            return $this->{$section}->{$name};
899
-        } else {
900
-            EE_Error::add_error(
901
-                sprintf(esc_html__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
902
-                __FILE__,
903
-                __FUNCTION__,
904
-                __LINE__
905
-            );
906
-        }
907
-        return null;
908
-    }
909
-
910
-
911
-    /**
912
-     *    get_config_option
913
-     *
914
-     * @access    public
915
-     * @param    string $config_option_name
916
-     * @return    mixed EE_Config_Base | FALSE
917
-     */
918
-    public function get_config_option($config_option_name = '')
919
-    {
920
-        // retrieve the wp-option for this config class.
921
-        $config_option = maybe_unserialize(get_option($config_option_name, array()));
922
-        if (empty($config_option)) {
923
-            EE_Config::log($config_option_name . '-NOT-FOUND');
924
-        }
925
-        return $config_option;
926
-    }
927
-
928
-
929
-    /**
930
-     * log
931
-     *
932
-     * @param string $config_option_name
933
-     */
934
-    public static function log($config_option_name = '')
935
-    {
936
-        if (EE_Config::logging_enabled() && ! empty($config_option_name)) {
937
-            $config_log = get_option(EE_Config::LOG_NAME, array());
938
-            /** @var RequestParams $request */
939
-            $request = LoaderFactory::getLoader()->getShared(RequestParams::class);
940
-            $config_log[ (string) microtime(true) ] = array(
941
-                'config_name' => $config_option_name,
942
-                'request'     => $request->requestParams(),
943
-            );
944
-            update_option(EE_Config::LOG_NAME, $config_log);
945
-        }
946
-    }
947
-
948
-
949
-    /**
950
-     * trim_log
951
-     * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH
952
-     */
953
-    public static function trim_log()
954
-    {
955
-        if (! EE_Config::logging_enabled()) {
956
-            return;
957
-        }
958
-        $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
959
-        $log_length = count($config_log);
960
-        if ($log_length > EE_Config::LOG_LENGTH) {
961
-            ksort($config_log);
962
-            $config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true);
963
-            update_option(EE_Config::LOG_NAME, $config_log);
964
-        }
965
-    }
966
-
967
-
968
-    /**
969
-     *    get_page_for_posts
970
-     *    if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the
971
-     *    wp-option "page_for_posts", or "posts" if no page is selected
972
-     *
973
-     * @access    public
974
-     * @return    string
975
-     */
976
-    public static function get_page_for_posts()
977
-    {
978
-        $page_for_posts = get_option('page_for_posts');
979
-        if (! $page_for_posts) {
980
-            return 'posts';
981
-        }
982
-        global $wpdb;
983
-        $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
984
-        return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
985
-    }
986
-
987
-
988
-    /**
989
-     *    register_shortcodes_and_modules.
990
-     *    At this point, it's too early to tell if we're maintenance mode or not.
991
-     *    In fact, this is where we give modules a chance to let core know they exist
992
-     *    so they can help trigger maintenance mode if it's needed
993
-     *
994
-     * @access    public
995
-     * @return    void
996
-     */
997
-    public function register_shortcodes_and_modules()
998
-    {
999
-        // allow modules to set hooks for the rest of the system
1000
-        EE_Registry::instance()->modules = $this->_register_modules();
1001
-    }
1002
-
1003
-
1004
-    /**
1005
-     *    initialize_shortcodes_and_modules
1006
-     *    meaning they can start adding their hooks to get stuff done
1007
-     *
1008
-     * @access    public
1009
-     * @return    void
1010
-     */
1011
-    public function initialize_shortcodes_and_modules()
1012
-    {
1013
-        // allow modules to set hooks for the rest of the system
1014
-        $this->_initialize_modules();
1015
-    }
1016
-
1017
-
1018
-    /**
1019
-     *    widgets_init
1020
-     *
1021
-     * @access private
1022
-     * @return void
1023
-     */
1024
-    public function widgets_init()
1025
-    {
1026
-        // only init widgets on admin pages when not in complete maintenance, and
1027
-        // on frontend when not in any maintenance mode
1028
-        if (
1029
-            ! EE_Maintenance_Mode::instance()->level()
1030
-            || (
1031
-                is_admin()
1032
-                && EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
1033
-            )
1034
-        ) {
1035
-            // grab list of installed widgets
1036
-            $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1037
-            // filter list of modules to register
1038
-            $widgets_to_register = apply_filters(
1039
-                'FHEE__EE_Config__register_widgets__widgets_to_register',
1040
-                $widgets_to_register
1041
-            );
1042
-            if (! empty($widgets_to_register)) {
1043
-                // cycle thru widget folders
1044
-                foreach ($widgets_to_register as $widget_path) {
1045
-                    // add to list of installed widget modules
1046
-                    EE_Config::register_ee_widget($widget_path);
1047
-                }
1048
-            }
1049
-            // filter list of installed modules
1050
-            EE_Registry::instance()->widgets = apply_filters(
1051
-                'FHEE__EE_Config__register_widgets__installed_widgets',
1052
-                EE_Registry::instance()->widgets
1053
-            );
1054
-        }
1055
-    }
1056
-
1057
-
1058
-    /**
1059
-     *    register_ee_widget - makes core aware of this widget
1060
-     *
1061
-     * @access    public
1062
-     * @param    string $widget_path - full path up to and including widget folder
1063
-     * @return    void
1064
-     */
1065
-    public static function register_ee_widget($widget_path = null)
1066
-    {
1067
-        do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
1068
-        $widget_ext = '.widget.php';
1069
-        // make all separators match
1070
-        $widget_path = rtrim(str_replace('\\', DS, $widget_path), DS);
1071
-        // does the file path INCLUDE the actual file name as part of the path ?
1072
-        if (strpos($widget_path, $widget_ext) !== false) {
1073
-            // grab and shortcode file name from directory name and break apart at dots
1074
-            $file_name = explode('.', basename($widget_path));
1075
-            // take first segment from file name pieces and remove class prefix if it exists
1076
-            $widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
1077
-            // sanitize shortcode directory name
1078
-            $widget = sanitize_key($widget);
1079
-            // now we need to rebuild the shortcode path
1080
-            $widget_path = explode('/', $widget_path);
1081
-            // remove last segment
1082
-            array_pop($widget_path);
1083
-            // glue it back together
1084
-            $widget_path = implode(DS, $widget_path);
1085
-        } else {
1086
-            // grab and sanitize widget directory name
1087
-            $widget = sanitize_key(basename($widget_path));
1088
-        }
1089
-        // create classname from widget directory name
1090
-        $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1091
-        // add class prefix
1092
-        $widget_class = 'EEW_' . $widget;
1093
-        // does the widget exist ?
1094
-        if (! is_readable($widget_path . '/' . $widget_class . $widget_ext)) {
1095
-            $msg = sprintf(
1096
-                esc_html__(
1097
-                    'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s',
1098
-                    'event_espresso'
1099
-                ),
1100
-                $widget_class,
1101
-                $widget_path . '/' . $widget_class . $widget_ext
1102
-            );
1103
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1104
-            return;
1105
-        }
1106
-        // load the widget class file
1107
-        require_once($widget_path . '/' . $widget_class . $widget_ext);
1108
-        // verify that class exists
1109
-        if (! class_exists($widget_class)) {
1110
-            $msg = sprintf(esc_html__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1111
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1112
-            return;
1113
-        }
1114
-        register_widget($widget_class);
1115
-        // add to array of registered widgets
1116
-        EE_Registry::instance()->widgets->{$widget_class} = $widget_path . '/' . $widget_class . $widget_ext;
1117
-    }
1118
-
1119
-
1120
-    /**
1121
-     *        _register_modules
1122
-     *
1123
-     * @access private
1124
-     * @return array
1125
-     */
1126
-    private function _register_modules()
1127
-    {
1128
-        // grab list of installed modules
1129
-        $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1130
-        // filter list of modules to register
1131
-        $modules_to_register = apply_filters(
1132
-            'FHEE__EE_Config__register_modules__modules_to_register',
1133
-            $modules_to_register
1134
-        );
1135
-        if (! empty($modules_to_register)) {
1136
-            // loop through folders
1137
-            foreach ($modules_to_register as $module_path) {
1138
-                /**TEMPORARILY EXCLUDE gateways from modules for time being**/
1139
-                if (
1140
-                    $module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1141
-                    && $module_path !== EE_MODULES . 'gateways'
1142
-                ) {
1143
-                    // add to list of installed modules
1144
-                    EE_Config::register_module($module_path);
1145
-                }
1146
-            }
1147
-        }
1148
-        // filter list of installed modules
1149
-        return apply_filters(
1150
-            'FHEE__EE_Config___register_modules__installed_modules',
1151
-            EE_Registry::instance()->modules
1152
-        );
1153
-    }
1154
-
1155
-
1156
-    /**
1157
-     *    register_module - makes core aware of this module
1158
-     *
1159
-     * @access    public
1160
-     * @param    string $module_path - full path up to and including module folder
1161
-     * @return    bool
1162
-     */
1163
-    public static function register_module($module_path = null)
1164
-    {
1165
-        do_action('AHEE__EE_Config__register_module__begin', $module_path);
1166
-        $module_ext = '.module.php';
1167
-        // make all separators match
1168
-        $module_path = str_replace(array('\\', '/'), '/', $module_path);
1169
-        // does the file path INCLUDE the actual file name as part of the path ?
1170
-        if (strpos($module_path, $module_ext) !== false) {
1171
-            // grab and shortcode file name from directory name and break apart at dots
1172
-            $module_file = explode('.', basename($module_path));
1173
-            // now we need to rebuild the shortcode path
1174
-            $module_path = explode('/', $module_path);
1175
-            // remove last segment
1176
-            array_pop($module_path);
1177
-            // glue it back together
1178
-            $module_path = implode('/', $module_path) . '/';
1179
-            // take first segment from file name pieces and sanitize it
1180
-            $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1181
-            // ensure class prefix is added
1182
-            $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1183
-        } else {
1184
-            // we need to generate the filename based off of the folder name
1185
-            // grab and sanitize module name
1186
-            $module = strtolower(basename($module_path));
1187
-            $module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1188
-            // like trailingslashit()
1189
-            $module_path = rtrim($module_path, '/') . '/';
1190
-            // create classname from module directory name
1191
-            $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1192
-            // add class prefix
1193
-            $module_class = 'EED_' . $module;
1194
-        }
1195
-        // does the module exist ?
1196
-        if (! is_readable($module_path . '/' . $module_class . $module_ext)) {
1197
-            $msg = sprintf(
1198
-                esc_html__(
1199
-                    'The requested %s module file could not be found or is not readable due to file permissions.',
1200
-                    'event_espresso'
1201
-                ),
1202
-                $module
1203
-            );
1204
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1205
-            return false;
1206
-        }
1207
-        // load the module class file
1208
-        require_once($module_path . $module_class . $module_ext);
1209
-        // verify that class exists
1210
-        if (! class_exists($module_class)) {
1211
-            $msg = sprintf(esc_html__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1212
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1213
-            return false;
1214
-        }
1215
-        // add to array of registered modules
1216
-        EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1217
-        do_action(
1218
-            'AHEE__EE_Config__register_module__complete',
1219
-            $module_class,
1220
-            EE_Registry::instance()->modules->{$module_class}
1221
-        );
1222
-        return true;
1223
-    }
1224
-
1225
-
1226
-    /**
1227
-     *    _initialize_modules
1228
-     *    allow modules to set hooks for the rest of the system
1229
-     *
1230
-     * @access private
1231
-     * @return void
1232
-     */
1233
-    private function _initialize_modules()
1234
-    {
1235
-        // cycle thru shortcode folders
1236
-        foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1237
-            // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1238
-            // which set hooks ?
1239
-            if (is_admin()) {
1240
-                // fire immediately
1241
-                call_user_func(array($module_class, 'set_hooks_admin'));
1242
-            } else {
1243
-                // delay until other systems are online
1244
-                add_action(
1245
-                    'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1246
-                    array($module_class, 'set_hooks')
1247
-                );
1248
-            }
1249
-        }
1250
-    }
1251
-
1252
-
1253
-    /**
1254
-     *    register_route - adds module method routes to route_map
1255
-     *
1256
-     * @access    public
1257
-     * @param    string $route       - "pretty" public alias for module method
1258
-     * @param    string $module      - module name (classname without EED_ prefix)
1259
-     * @param    string $method_name - the actual module method to be routed to
1260
-     * @param    string $key         - url param key indicating a route is being called
1261
-     * @return    bool
1262
-     */
1263
-    public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee')
1264
-    {
1265
-        do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1266
-        $module = str_replace('EED_', '', $module);
1267
-        $module_class = 'EED_' . $module;
1268
-        if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1269
-            $msg = sprintf(esc_html__('The module %s has not been registered.', 'event_espresso'), $module);
1270
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1271
-            return false;
1272
-        }
1273
-        if (empty($route)) {
1274
-            $msg = sprintf(esc_html__('No route has been supplied.', 'event_espresso'), $route);
1275
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1276
-            return false;
1277
-        }
1278
-        if (! method_exists('EED_' . $module, $method_name)) {
1279
-            $msg = sprintf(
1280
-                esc_html__('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1281
-                $route
1282
-            );
1283
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1284
-            return false;
1285
-        }
1286
-        EE_Config::$_module_route_map[ (string) $key ][ (string) $route ] = array('EED_' . $module, $method_name);
1287
-        return true;
1288
-    }
1289
-
1290
-
1291
-    /**
1292
-     *    get_route - get module method route
1293
-     *
1294
-     * @access    public
1295
-     * @param    string $route - "pretty" public alias for module method
1296
-     * @param    string $key   - url param key indicating a route is being called
1297
-     * @return    string
1298
-     */
1299
-    public static function get_route($route = null, $key = 'ee')
1300
-    {
1301
-        do_action('AHEE__EE_Config__get_route__begin', $route);
1302
-        $route = (string) apply_filters('FHEE__EE_Config__get_route', $route);
1303
-        if (isset(EE_Config::$_module_route_map[ $key ][ $route ])) {
1304
-            return EE_Config::$_module_route_map[ $key ][ $route ];
1305
-        }
1306
-        return null;
1307
-    }
1308
-
1309
-
1310
-    /**
1311
-     *    get_routes - get ALL module method routes
1312
-     *
1313
-     * @access    public
1314
-     * @return    array
1315
-     */
1316
-    public static function get_routes()
1317
-    {
1318
-        return EE_Config::$_module_route_map;
1319
-    }
1320
-
1321
-
1322
-    /**
1323
-     *    register_forward - allows modules to forward request to another module for further processing
1324
-     *
1325
-     * @access    public
1326
-     * @param    string       $route   - "pretty" public alias for module method
1327
-     * @param    integer      $status  - integer value corresponding  to status constant strings set in module parent
1328
-     *                                 class, allows different forwards to be served based on status
1329
-     * @param    array|string $forward - function name or array( class, method )
1330
-     * @param    string       $key     - url param key indicating a route is being called
1331
-     * @return    bool
1332
-     */
1333
-    public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1334
-    {
1335
-        do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1336
-        if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1337
-            $msg = sprintf(
1338
-                esc_html__('The module route %s for this forward has not been registered.', 'event_espresso'),
1339
-                $route
1340
-            );
1341
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1342
-            return false;
1343
-        }
1344
-        if (empty($forward)) {
1345
-            $msg = sprintf(esc_html__('No forwarding route has been supplied.', 'event_espresso'), $route);
1346
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1347
-            return false;
1348
-        }
1349
-        if (is_array($forward)) {
1350
-            if (! isset($forward[1])) {
1351
-                $msg = sprintf(
1352
-                    esc_html__('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1353
-                    $route
1354
-                );
1355
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1356
-                return false;
1357
-            }
1358
-            if (! method_exists($forward[0], $forward[1])) {
1359
-                $msg = sprintf(
1360
-                    esc_html__('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1361
-                    $forward[1],
1362
-                    $route
1363
-                );
1364
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1365
-                return false;
1366
-            }
1367
-        } elseif (! function_exists($forward)) {
1368
-            $msg = sprintf(
1369
-                esc_html__('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1370
-                $forward,
1371
-                $route
1372
-            );
1373
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1374
-            return false;
1375
-        }
1376
-        EE_Config::$_module_forward_map[ $key ][ $route ][ absint($status) ] = $forward;
1377
-        return true;
1378
-    }
1379
-
1380
-
1381
-    /**
1382
-     *    get_forward - get forwarding route
1383
-     *
1384
-     * @access    public
1385
-     * @param    string  $route  - "pretty" public alias for module method
1386
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1387
-     *                           allows different forwards to be served based on status
1388
-     * @param    string  $key    - url param key indicating a route is being called
1389
-     * @return    string
1390
-     */
1391
-    public static function get_forward($route = null, $status = 0, $key = 'ee')
1392
-    {
1393
-        do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1394
-        if (isset(EE_Config::$_module_forward_map[ $key ][ $route ][ $status ])) {
1395
-            return apply_filters(
1396
-                'FHEE__EE_Config__get_forward',
1397
-                EE_Config::$_module_forward_map[ $key ][ $route ][ $status ],
1398
-                $route,
1399
-                $status
1400
-            );
1401
-        }
1402
-        return null;
1403
-    }
1404
-
1405
-
1406
-    /**
1407
-     *    register_forward - allows modules to specify different view templates for different method routes and status
1408
-     *    results
1409
-     *
1410
-     * @access    public
1411
-     * @param    string  $route  - "pretty" public alias for module method
1412
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1413
-     *                           allows different views to be served based on status
1414
-     * @param    string  $view
1415
-     * @param    string  $key    - url param key indicating a route is being called
1416
-     * @return    bool
1417
-     */
1418
-    public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1419
-    {
1420
-        do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1421
-        if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1422
-            $msg = sprintf(
1423
-                esc_html__('The module route %s for this view has not been registered.', 'event_espresso'),
1424
-                $route
1425
-            );
1426
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1427
-            return false;
1428
-        }
1429
-        if (! is_readable($view)) {
1430
-            $msg = sprintf(
1431
-                esc_html__(
1432
-                    'The %s view file could not be found or is not readable due to file permissions.',
1433
-                    'event_espresso'
1434
-                ),
1435
-                $view
1436
-            );
1437
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1438
-            return false;
1439
-        }
1440
-        EE_Config::$_module_view_map[ $key ][ $route ][ absint($status) ] = $view;
1441
-        return true;
1442
-    }
1443
-
1444
-
1445
-    /**
1446
-     *    get_view - get view for route and status
1447
-     *
1448
-     * @access    public
1449
-     * @param    string  $route  - "pretty" public alias for module method
1450
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1451
-     *                           allows different views to be served based on status
1452
-     * @param    string  $key    - url param key indicating a route is being called
1453
-     * @return    string
1454
-     */
1455
-    public static function get_view($route = null, $status = 0, $key = 'ee')
1456
-    {
1457
-        do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1458
-        if (isset(EE_Config::$_module_view_map[ $key ][ $route ][ $status ])) {
1459
-            return apply_filters(
1460
-                'FHEE__EE_Config__get_view',
1461
-                EE_Config::$_module_view_map[ $key ][ $route ][ $status ],
1462
-                $route,
1463
-                $status
1464
-            );
1465
-        }
1466
-        return null;
1467
-    }
1468
-
1469
-
1470
-    public function update_addon_option_names()
1471
-    {
1472
-        update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names);
1473
-    }
1474
-
1475
-
1476
-    public function shutdown()
1477
-    {
1478
-        $this->update_addon_option_names();
1479
-    }
1480
-
1481
-
1482
-    /**
1483
-     * @return LegacyShortcodesManager
1484
-     */
1485
-    public static function getLegacyShortcodesManager()
1486
-    {
1487
-        if (! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1488
-            EE_Config::instance()->legacy_shortcodes_manager = LoaderFactory::getLoader()->getShared(
1489
-                LegacyShortcodesManager::class
1490
-            );
1491
-        }
1492
-        return EE_Config::instance()->legacy_shortcodes_manager;
1493
-    }
1494
-
1495
-
1496
-    /**
1497
-     * register_shortcode - makes core aware of this shortcode
1498
-     *
1499
-     * @deprecated 4.9.26
1500
-     * @param    string $shortcode_path - full path up to and including shortcode folder
1501
-     * @return    bool
1502
-     */
1503
-    public static function register_shortcode($shortcode_path = null)
1504
-    {
1505
-        EE_Error::doing_it_wrong(
1506
-            __METHOD__,
1507
-            esc_html__(
1508
-                'Usage is deprecated. Use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::registerShortcode() as direct replacement, or better yet, please see the new \EventEspresso\core\services\shortcodes\ShortcodesManager class.',
1509
-                'event_espresso'
1510
-            ),
1511
-            '4.9.26'
1512
-        );
1513
-        return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path);
1514
-    }
1515
-}
1516
-
1517
-/**
1518
- * Base class used for config classes. These classes should generally not have
1519
- * magic functions in use, except we'll allow them to magically set and get stuff...
1520
- * basically, they should just be well-defined stdClasses
1521
- */
1522
-class EE_Config_Base
1523
-{
1524
-
1525
-    /**
1526
-     * Utility function for escaping the value of a property and returning.
1527
-     *
1528
-     * @param string $property property name (checks to see if exists).
1529
-     * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1530
-     * @throws EE_Error
1531
-     */
1532
-    public function get_pretty($property)
1533
-    {
1534
-        if (! property_exists($this, $property)) {
1535
-            throw new EE_Error(
1536
-                sprintf(
1537
-                    esc_html__(
1538
-                        '%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.',
1539
-                        'event_espresso'
1540
-                    ),
1541
-                    get_class($this),
1542
-                    $property
1543
-                )
1544
-            );
1545
-        }
1546
-        // just handling escaping of strings for now.
1547
-        if (is_string($this->{$property})) {
1548
-            return stripslashes($this->{$property});
1549
-        }
1550
-        return $this->{$property};
1551
-    }
1552
-
1553
-
1554
-    public function populate()
1555
-    {
1556
-        // grab defaults via a new instance of this class.
1557
-        $class_name = get_class($this);
1558
-        $defaults = new $class_name();
1559
-        // loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1560
-        // default from our $defaults object.
1561
-        foreach (get_object_vars($defaults) as $property => $value) {
1562
-            if ($this->{$property} === null) {
1563
-                $this->{$property} = $value;
1564
-            }
1565
-        }
1566
-        // cleanup
1567
-        unset($defaults);
1568
-    }
1569
-
1570
-
1571
-    /**
1572
-     *        __isset
1573
-     *
1574
-     * @param $a
1575
-     * @return bool
1576
-     */
1577
-    public function __isset($a)
1578
-    {
1579
-        return false;
1580
-    }
1581
-
1582
-
1583
-    /**
1584
-     *        __unset
1585
-     *
1586
-     * @param $a
1587
-     * @return bool
1588
-     */
1589
-    public function __unset($a)
1590
-    {
1591
-        return false;
1592
-    }
1593
-
1594
-
1595
-    /**
1596
-     *        __clone
1597
-     */
1598
-    public function __clone()
1599
-    {
1600
-    }
1601
-
1602
-
1603
-    /**
1604
-     *        __wakeup
1605
-     */
1606
-    public function __wakeup()
1607
-    {
1608
-    }
1609
-
1610
-
1611
-    /**
1612
-     *        __destruct
1613
-     */
1614
-    public function __destruct()
1615
-    {
1616
-    }
1617
-}
1618
-
1619
-/**
1620
- * Class for defining what's in the EE_Config relating to registration settings
1621
- */
1622
-class EE_Core_Config extends EE_Config_Base
1623
-{
1624
-
1625
-    const OPTION_NAME_UXIP = 'ee_ueip_optin';
1626
-
1627
-
1628
-    public $current_blog_id;
1629
-
1630
-    public $ee_ueip_optin;
1631
-
1632
-    public $ee_ueip_has_notified;
1633
-
1634
-    /**
1635
-     * Not to be confused with the 4 critical page variables (See
1636
-     * get_critical_pages_array()), this is just an array of wp posts that have EE
1637
-     * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode
1638
-     * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array.
1639
-     *
1640
-     * @var array
1641
-     */
1642
-    public $post_shortcodes;
1643
-
1644
-    public $module_route_map;
1645
-
1646
-    public $module_forward_map;
1647
-
1648
-    public $module_view_map;
1649
-
1650
-    /**
1651
-     * The next 4 vars are the IDs of critical EE pages.
1652
-     *
1653
-     * @var int
1654
-     */
1655
-    public $reg_page_id;
1656
-
1657
-    public $txn_page_id;
1658
-
1659
-    public $thank_you_page_id;
1660
-
1661
-    public $cancel_page_id;
1662
-
1663
-    /**
1664
-     * The next 4 vars are the URLs of critical EE pages.
1665
-     *
1666
-     * @var int
1667
-     */
1668
-    public $reg_page_url;
1669
-
1670
-    public $txn_page_url;
1671
-
1672
-    public $thank_you_page_url;
1673
-
1674
-    public $cancel_page_url;
1675
-
1676
-    /**
1677
-     * The next vars relate to the custom slugs for EE CPT routes
1678
-     */
1679
-    public $event_cpt_slug;
1680
-
1681
-    /**
1682
-     * This caches the _ee_ueip_option in case this config is reset in the same
1683
-     * request across blog switches in a multisite context.
1684
-     * Avoids extra queries to the db for this option.
1685
-     *
1686
-     * @var bool
1687
-     */
1688
-    public static $ee_ueip_option;
1689
-
1690
-
1691
-    /**
1692
-     *    class constructor
1693
-     *
1694
-     * @access    public
1695
-     */
1696
-    public function __construct()
1697
-    {
1698
-        // set default organization settings
1699
-        $this->current_blog_id = get_current_blog_id();
1700
-        $this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id;
1701
-        $this->ee_ueip_optin = $this->_get_main_ee_ueip_optin();
1702
-        $this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1703
-        $this->post_shortcodes = array();
1704
-        $this->module_route_map = array();
1705
-        $this->module_forward_map = array();
1706
-        $this->module_view_map = array();
1707
-        // critical EE page IDs
1708
-        $this->reg_page_id = 0;
1709
-        $this->txn_page_id = 0;
1710
-        $this->thank_you_page_id = 0;
1711
-        $this->cancel_page_id = 0;
1712
-        // critical EE page URLs
1713
-        $this->reg_page_url = '';
1714
-        $this->txn_page_url = '';
1715
-        $this->thank_you_page_url = '';
1716
-        $this->cancel_page_url = '';
1717
-        // cpt slugs
1718
-        $this->event_cpt_slug = esc_html__('events', 'event_espresso');
1719
-        // ueip constant check
1720
-        if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1721
-            $this->ee_ueip_optin = false;
1722
-            $this->ee_ueip_has_notified = true;
1723
-        }
1724
-    }
1725
-
1726
-
1727
-    /**
1728
-     * @return array
1729
-     */
1730
-    public function get_critical_pages_array()
1731
-    {
1732
-        return array(
1733
-            $this->reg_page_id,
1734
-            $this->txn_page_id,
1735
-            $this->thank_you_page_id,
1736
-            $this->cancel_page_id,
1737
-        );
1738
-    }
1739
-
1740
-
1741
-    /**
1742
-     * @return array
1743
-     */
1744
-    public function get_critical_pages_shortcodes_array()
1745
-    {
1746
-        return array(
1747
-            $this->reg_page_id       => 'ESPRESSO_CHECKOUT',
1748
-            $this->txn_page_id       => 'ESPRESSO_TXN_PAGE',
1749
-            $this->thank_you_page_id => 'ESPRESSO_THANK_YOU',
1750
-            $this->cancel_page_id    => 'ESPRESSO_CANCELLED',
1751
-        );
1752
-    }
1753
-
1754
-
1755
-    /**
1756
-     *  gets/returns URL for EE reg_page
1757
-     *
1758
-     * @access    public
1759
-     * @return    string
1760
-     */
1761
-    public function reg_page_url()
1762
-    {
1763
-        if (! $this->reg_page_url) {
1764
-            $this->reg_page_url = add_query_arg(
1765
-                array('uts' => time()),
1766
-                get_permalink($this->reg_page_id)
1767
-            ) . '#checkout';
1768
-        }
1769
-        return $this->reg_page_url;
1770
-    }
1771
-
1772
-
1773
-    /**
1774
-     *  gets/returns URL for EE txn_page
1775
-     *
1776
-     * @param array $query_args like what gets passed to
1777
-     *                          add_query_arg() as the first argument
1778
-     * @access    public
1779
-     * @return    string
1780
-     */
1781
-    public function txn_page_url($query_args = array())
1782
-    {
1783
-        if (! $this->txn_page_url) {
1784
-            $this->txn_page_url = get_permalink($this->txn_page_id);
1785
-        }
1786
-        if ($query_args) {
1787
-            return add_query_arg($query_args, $this->txn_page_url);
1788
-        } else {
1789
-            return $this->txn_page_url;
1790
-        }
1791
-    }
1792
-
1793
-
1794
-    /**
1795
-     *  gets/returns URL for EE thank_you_page
1796
-     *
1797
-     * @param array $query_args like what gets passed to
1798
-     *                          add_query_arg() as the first argument
1799
-     * @access    public
1800
-     * @return    string
1801
-     */
1802
-    public function thank_you_page_url($query_args = array())
1803
-    {
1804
-        if (! $this->thank_you_page_url) {
1805
-            $this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1806
-        }
1807
-        if ($query_args) {
1808
-            return add_query_arg($query_args, $this->thank_you_page_url);
1809
-        } else {
1810
-            return $this->thank_you_page_url;
1811
-        }
1812
-    }
1813
-
1814
-
1815
-    /**
1816
-     *  gets/returns URL for EE cancel_page
1817
-     *
1818
-     * @access    public
1819
-     * @return    string
1820
-     */
1821
-    public function cancel_page_url()
1822
-    {
1823
-        if (! $this->cancel_page_url) {
1824
-            $this->cancel_page_url = get_permalink($this->cancel_page_id);
1825
-        }
1826
-        return $this->cancel_page_url;
1827
-    }
1828
-
1829
-
1830
-    /**
1831
-     * Resets all critical page urls to their original state.  Used primarily by the __sleep() magic method currently.
1832
-     *
1833
-     * @since 4.7.5
1834
-     */
1835
-    protected function _reset_urls()
1836
-    {
1837
-        $this->reg_page_url = '';
1838
-        $this->txn_page_url = '';
1839
-        $this->cancel_page_url = '';
1840
-        $this->thank_you_page_url = '';
1841
-    }
1842
-
1843
-
1844
-    /**
1845
-     * Used to return what the optin value is set for the EE User Experience Program.
1846
-     * This accounts for multisite and this value being requested for a subsite.  In multisite, the value is set
1847
-     * on the main site only.
1848
-     *
1849
-     * @return bool
1850
-     */
1851
-    protected function _get_main_ee_ueip_optin()
1852
-    {
1853
-        // if this is the main site then we can just bypass our direct query.
1854
-        if (is_main_site()) {
1855
-            return get_option(self::OPTION_NAME_UXIP, false);
1856
-        }
1857
-        // is this already cached for this request?  If so use it.
1858
-        if (EE_Core_Config::$ee_ueip_option !== null) {
1859
-            return EE_Core_Config::$ee_ueip_option;
1860
-        }
1861
-        global $wpdb;
1862
-        $current_network_main_site = is_multisite() ? get_current_site() : null;
1863
-        $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1864
-        $option = self::OPTION_NAME_UXIP;
1865
-        // set correct table for query
1866
-        $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1867
-        // rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1868
-        // get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1869
-        // re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1870
-        // this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1871
-        // for the purpose of caching.
1872
-        $pre = apply_filters('pre_option_' . $option, false, $option);
1873
-        if (false !== $pre) {
1874
-            EE_Core_Config::$ee_ueip_option = $pre;
1875
-            return EE_Core_Config::$ee_ueip_option;
1876
-        }
1877
-        $row = $wpdb->get_row(
1878
-            $wpdb->prepare(
1879
-                "SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1",
1880
-                $option
1881
-            )
1882
-        );
1883
-        if (is_object($row)) {
1884
-            $value = $row->option_value;
1885
-        } else { // option does not exist so use default.
1886
-            EE_Core_Config::$ee_ueip_option =  apply_filters('default_option_' . $option, false, $option);
1887
-            return EE_Core_Config::$ee_ueip_option;
1888
-        }
1889
-        EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1890
-        return EE_Core_Config::$ee_ueip_option;
1891
-    }
1892
-
1893
-
1894
-    /**
1895
-     * Utility function for escaping the value of a property and returning.
1896
-     *
1897
-     * @param string $property property name (checks to see if exists).
1898
-     * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1899
-     * @throws EE_Error
1900
-     */
1901
-    public function get_pretty($property)
1902
-    {
1903
-        if ($property === self::OPTION_NAME_UXIP) {
1904
-            return $this->ee_ueip_optin ? 'yes' : 'no';
1905
-        }
1906
-        return parent::get_pretty($property);
1907
-    }
1908
-
1909
-
1910
-    /**
1911
-     * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values
1912
-     * on the object.
1913
-     *
1914
-     * @return array
1915
-     */
1916
-    public function __sleep()
1917
-    {
1918
-        // reset all url properties
1919
-        $this->_reset_urls();
1920
-        // return what to save to db
1921
-        return array_keys(get_object_vars($this));
1922
-    }
1923
-}
1924
-
1925
-/**
1926
- * Config class for storing info on the Organization
1927
- */
1928
-class EE_Organization_Config extends EE_Config_Base
1929
-{
1930
-
1931
-    /**
1932
-     * @var string $name
1933
-     * eg EE4.1
1934
-     */
1935
-    public $name;
1936
-
1937
-    /**
1938
-     * @var string $address_1
1939
-     * eg 123 Onna Road
1940
-     */
1941
-    public $address_1 = '';
1942
-
1943
-    /**
1944
-     * @var string $address_2
1945
-     * eg PO Box 123
1946
-     */
1947
-    public $address_2 = '';
1948
-
1949
-    /**
1950
-     * @var string $city
1951
-     * eg Inna City
1952
-     */
1953
-    public $city = '';
1954
-
1955
-    /**
1956
-     * @var int $STA_ID
1957
-     * eg 4
1958
-     */
1959
-    public $STA_ID = 0;
1960
-
1961
-    /**
1962
-     * @var string $CNT_ISO
1963
-     * eg US
1964
-     */
1965
-    public $CNT_ISO = '';
1966
-
1967
-    /**
1968
-     * @var string $zip
1969
-     * eg 12345  or V1A 2B3
1970
-     */
1971
-    public $zip = '';
1972
-
1973
-    /**
1974
-     * @var string $email
1975
-     * eg [email protected]
1976
-     */
1977
-    public $email;
1978
-
1979
-    /**
1980
-     * @var string $phone
1981
-     * eg. 111-111-1111
1982
-     */
1983
-    public $phone = '';
1984
-
1985
-    /**
1986
-     * @var string $vat
1987
-     * VAT/Tax Number
1988
-     */
1989
-    public $vat = '';
1990
-
1991
-    /**
1992
-     * @var string $logo_url
1993
-     * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg
1994
-     */
1995
-    public $logo_url = '';
1996
-
1997
-    /**
1998
-     * The below are all various properties for holding links to organization social network profiles
1999
-     *
2000
-     * @var string
2001
-     */
2002
-    /**
2003
-     * facebook (facebook.com/profile.name)
2004
-     *
2005
-     * @var string
2006
-     */
2007
-    public $facebook = '';
2008
-
2009
-    /**
2010
-     * twitter (twitter.com/twitter_handle)
2011
-     *
2012
-     * @var string
2013
-     */
2014
-    public $twitter = '';
2015
-
2016
-    /**
2017
-     * linkedin (linkedin.com/in/profile_name)
2018
-     *
2019
-     * @var string
2020
-     */
2021
-    public $linkedin = '';
2022
-
2023
-    /**
2024
-     * pinterest (www.pinterest.com/profile_name)
2025
-     *
2026
-     * @var string
2027
-     */
2028
-    public $pinterest = '';
2029
-
2030
-    /**
2031
-     * google+ (google.com/+profileName)
2032
-     *
2033
-     * @var string
2034
-     */
2035
-    public $google = '';
2036
-
2037
-    /**
2038
-     * instagram (instagram.com/handle)
2039
-     *
2040
-     * @var string
2041
-     */
2042
-    public $instagram = '';
2043
-
2044
-
2045
-    /**
2046
-     *    class constructor
2047
-     *
2048
-     * @access    public
2049
-     */
2050
-    public function __construct()
2051
-    {
2052
-        // set default organization settings
2053
-        // decode HTML entities from the WP blogname, because it's stored in the DB with HTML entities encoded
2054
-        $this->name = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES);
2055
-        $this->email = get_bloginfo('admin_email');
2056
-    }
2057
-}
2058
-
2059
-/**
2060
- * Class for defining what's in the EE_Config relating to currency
2061
- */
2062
-class EE_Currency_Config extends EE_Config_Base
2063
-{
2064
-
2065
-    /**
2066
-     * @var string $code
2067
-     * eg 'US'
2068
-     */
2069
-    public $code;
2070
-
2071
-    /**
2072
-     * @var string $name
2073
-     * eg 'Dollar'
2074
-     */
2075
-    public $name;
2076
-
2077
-    /**
2078
-     * plural name
2079
-     *
2080
-     * @var string $plural
2081
-     * eg 'Dollars'
2082
-     */
2083
-    public $plural;
2084
-
2085
-    /**
2086
-     * currency sign
2087
-     *
2088
-     * @var string $sign
2089
-     * eg '$'
2090
-     */
2091
-    public $sign;
2092
-
2093
-    /**
2094
-     * Whether the currency sign should come before the number or not
2095
-     *
2096
-     * @var boolean $sign_b4
2097
-     */
2098
-    public $sign_b4;
2099
-
2100
-    /**
2101
-     * How many digits should come after the decimal place
2102
-     *
2103
-     * @var int $dec_plc
2104
-     */
2105
-    public $dec_plc;
2106
-
2107
-    /**
2108
-     * Symbol to use for decimal mark
2109
-     *
2110
-     * @var string $dec_mrk
2111
-     * eg '.'
2112
-     */
2113
-    public $dec_mrk;
2114
-
2115
-    /**
2116
-     * Symbol to use for thousands
2117
-     *
2118
-     * @var string $thsnds
2119
-     * eg ','
2120
-     */
2121
-    public $thsnds;
2122
-
2123
-
2124
-    /**
2125
-     *    class constructor
2126
-     *
2127
-     * @access    public
2128
-     * @param string $CNT_ISO
2129
-     * @throws EE_Error
2130
-     * @throws ReflectionException
2131
-     */
2132
-    public function __construct($CNT_ISO = '')
2133
-    {
2134
-        if ($CNT_ISO && $CNT_ISO === $this->code) {
2135
-            return;
2136
-        }
2137
-        // get country code from organization settings or use default
2138
-        $ORG_CNT = isset(EE_Registry::instance()->CFG->organization)
2139
-                   && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
2140
-            ? EE_Registry::instance()->CFG->organization->CNT_ISO
2141
-            : '';
2142
-        // but override if requested
2143
-        $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2144
-        // so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists
2145
-        $this->setCurrency($CNT_ISO);
2146
-        // fallback to hardcoded defaults, in case the above failed
2147
-        if (empty($this->code)) {
2148
-            $this->setFallbackCurrency();
2149
-        }
2150
-    }
2151
-
2152
-
2153
-    /**
2154
-     * @param string|null $CNT_ISO
2155
-     * @throws EE_Error
2156
-     * @throws ReflectionException
2157
-     */
2158
-    public function setCurrency(?string $CNT_ISO = '')
2159
-    {
2160
-        if (empty($CNT_ISO) || ! EE_Maintenance_Mode::instance()->models_can_query()){
2161
-            return;
2162
-        }
2163
-
2164
-        /** @var TableAnalysis $table_analysis */
2165
-        $table_analysis = EE_Registry::instance()->create('TableAnalysis', [], true);
2166
-        if (! $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())) {
2167
-            return;
2168
-        }
2169
-        // retrieve the country settings from the db, just in case they have been customized
2170
-        $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2171
-        if (! $country instanceof EE_Country) {
2172
-            throw new DomainException(
2173
-                esc_html__('Invalid Country ISO Code.', 'event_espresso')
2174
-            );
2175
-        }
2176
-        $this->code    = $country->currency_code();                  // currency code: USD, CAD, EUR
2177
-        $this->name    = $country->currency_name_single();           // Dollar
2178
-        $this->plural  = $country->currency_name_plural();           // Dollars
2179
-        $this->sign    = $country->currency_sign();                  // currency sign: $
2180
-        $this->sign_b4 = $country->currency_sign_before();           // currency sign before or after
2181
-        $this->dec_plc = $country->currency_decimal_places();        // decimal places: 2 = 0.00  3 = 0.000
2182
-        $this->dec_mrk = $country->currency_decimal_mark();          // decimal mark: ',' = 0,01 or '.' = 0.01
2183
-        $this->thsnds  = $country->currency_thousands_separator();   // thousands sep: ',' = 1,000 or '.' = 1.000
2184
-    }
2185
-
2186
-
2187
-    private function setFallbackCurrency()
2188
-    {
2189
-        // set default currency settings
2190
-        $this->code    = 'USD';
2191
-        $this->name    = esc_html__('Dollar', 'event_espresso');
2192
-        $this->plural  = esc_html__('Dollars', 'event_espresso');
2193
-        $this->sign    = '$';
2194
-        $this->sign_b4 = true;
2195
-        $this->dec_plc = 2;
2196
-        $this->dec_mrk = '.';
2197
-        $this->thsnds  = ',';
2198
-    }
2199
-
2200
-
2201
-    /**
2202
-     * @param string|null $CNT_ISO
2203
-     * @return EE_Currency_Config
2204
-     * @throws EE_Error
2205
-     * @throws ReflectionException
2206
-     */
2207
-    public static function getCurrencyConfig(?string $CNT_ISO = ''): EE_Currency_Config
2208
-    {
2209
-        // if CNT_ISO passed lets try to get currency settings for it.
2210
-        $currency_config = ! empty($CNT_ISO)
2211
-            ? new EE_Currency_Config($CNT_ISO)
2212
-            : null;
2213
-        // default currency settings for site if not set
2214
-        if ($currency_config instanceof EE_Currency_Config) {
2215
-            return $currency_config;
2216
-        }
2217
-        EE_Config::instance()->currency = EE_Config::instance()->currency instanceof EE_Currency_Config
2218
-            ? EE_Config::instance()->currency
2219
-            : new EE_Currency_Config();
2220
-        return EE_Config::instance()->currency;
2221
-    }
2222
-}
2223
-
2224
-/**
2225
- * Class for defining what's in the EE_Config relating to registration settings
2226
- */
2227
-class EE_Registration_Config extends EE_Config_Base
2228
-{
2229
-
2230
-    /**
2231
-     * Default registration status
2232
-     *
2233
-     * @var string $default_STS_ID
2234
-     * eg 'RPP'
2235
-     */
2236
-    public $default_STS_ID;
2237
-
2238
-    /**
2239
-     * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of
2240
-     * registrations)
2241
-     *
2242
-     * @var int
2243
-     */
2244
-    public $default_maximum_number_of_tickets;
2245
-
2246
-    /**
2247
-     * level of validation to apply to email addresses
2248
-     *
2249
-     * @var string $email_validation_level
2250
-     * options: 'basic', 'wp_default', 'i18n', 'i18n_dns'
2251
-     */
2252
-    public $email_validation_level;
2253
-
2254
-    /**
2255
-     *    whether or not to show alternate payment options during the reg process if payment status is pending
2256
-     *
2257
-     * @var boolean $show_pending_payment_options
2258
-     */
2259
-    public $show_pending_payment_options;
2260
-
2261
-    /**
2262
-     * Whether to skip the registration confirmation page
2263
-     *
2264
-     * @var boolean $skip_reg_confirmation
2265
-     */
2266
-    public $skip_reg_confirmation;
2267
-
2268
-    /**
2269
-     * an array of SPCO reg steps where:
2270
-     *        the keys denotes the reg step order
2271
-     *        each element consists of an array with the following elements:
2272
-     *            "file_path" => the file path to the EE_SPCO_Reg_Step class
2273
-     *            "class_name" => the specific EE_SPCO_Reg_Step child class name
2274
-     *            "slug" => the URL param used to trigger the reg step
2275
-     *
2276
-     * @var array $reg_steps
2277
-     */
2278
-    public $reg_steps;
2279
-
2280
-    /**
2281
-     * Whether registration confirmation should be the last page of SPCO
2282
-     *
2283
-     * @var boolean $reg_confirmation_last
2284
-     */
2285
-    public $reg_confirmation_last;
2286
-
2287
-    /**
2288
-     * Whether or not to enable the EE Bot Trap
2289
-     *
2290
-     * @var boolean $use_bot_trap
2291
-     */
2292
-    public $use_bot_trap;
2293
-
2294
-    /**
2295
-     * Whether or not to encrypt some data sent by the EE Bot Trap
2296
-     *
2297
-     * @var boolean $use_encryption
2298
-     */
2299
-    public $use_encryption;
2300
-
2301
-    /**
2302
-     * Whether or not to use ReCaptcha
2303
-     *
2304
-     * @var boolean $use_captcha
2305
-     */
2306
-    public $use_captcha;
2307
-
2308
-    /**
2309
-     * ReCaptcha Theme
2310
-     *
2311
-     * @var string $recaptcha_theme
2312
-     *    options: 'dark', 'light', 'invisible'
2313
-     */
2314
-    public $recaptcha_theme;
2315
-
2316
-    /**
2317
-     * ReCaptcha Badge - determines the position of the reCAPTCHA badge if using Invisible ReCaptcha.
2318
-     *
2319
-     * @var string $recaptcha_badge
2320
-     *    options: 'bottomright', 'bottomleft', 'inline'
2321
-     */
2322
-    public $recaptcha_badge;
22
+	const OPTION_NAME = 'ee_config';
23
+
24
+	const LOG_NAME = 'ee_config_log';
25
+
26
+	const LOG_LENGTH = 100;
27
+
28
+	const ADDON_OPTION_NAMES = 'ee_config_option_names';
29
+
30
+	/**
31
+	 *    instance of the EE_Config object
32
+	 *
33
+	 * @var    EE_Config $_instance
34
+	 * @access    private
35
+	 */
36
+	private static $_instance;
37
+
38
+	/**
39
+	 * @var boolean $_logging_enabled
40
+	 */
41
+	private static $_logging_enabled = false;
42
+
43
+	/**
44
+	 * @var LegacyShortcodesManager $legacy_shortcodes_manager
45
+	 */
46
+	private $legacy_shortcodes_manager;
47
+
48
+	/**
49
+	 * An StdClass whose property names are addon slugs,
50
+	 * and values are their config classes
51
+	 *
52
+	 * @var StdClass
53
+	 */
54
+	public $addons;
55
+
56
+	/**
57
+	 * @var EE_Admin_Config
58
+	 */
59
+	public $admin;
60
+
61
+	/**
62
+	 * @var EE_Core_Config
63
+	 */
64
+	public $core;
65
+
66
+	/**
67
+	 * @var EE_Currency_Config
68
+	 */
69
+	public $currency;
70
+
71
+	/**
72
+	 * @var EE_Organization_Config
73
+	 */
74
+	public $organization;
75
+
76
+	/**
77
+	 * @var EE_Registration_Config
78
+	 */
79
+	public $registration;
80
+
81
+	/**
82
+	 * @var EE_Template_Config
83
+	 */
84
+	public $template_settings;
85
+
86
+	/**
87
+	 * Holds EE environment values.
88
+	 *
89
+	 * @var EE_Environment_Config
90
+	 */
91
+	public $environment;
92
+
93
+	/**
94
+	 * settings pertaining to Google maps
95
+	 *
96
+	 * @var EE_Map_Config
97
+	 */
98
+	public $map_settings;
99
+
100
+	/**
101
+	 * settings pertaining to Taxes
102
+	 *
103
+	 * @var EE_Tax_Config
104
+	 */
105
+	public $tax_settings;
106
+
107
+	/**
108
+	 * Settings pertaining to global messages settings.
109
+	 *
110
+	 * @var EE_Messages_Config
111
+	 */
112
+	public $messages;
113
+
114
+	/**
115
+	 * @deprecated
116
+	 * @var EE_Gateway_Config
117
+	 */
118
+	public $gateway;
119
+
120
+	/**
121
+	 * @var array
122
+	 */
123
+	private $_addon_option_names = array();
124
+
125
+	/**
126
+	 * @var array
127
+	 */
128
+	private static $_module_route_map = array();
129
+
130
+	/**
131
+	 * @var array
132
+	 */
133
+	private static $_module_forward_map = array();
134
+
135
+	/**
136
+	 * @var array
137
+	 */
138
+	private static $_module_view_map = array();
139
+
140
+	/**
141
+	 * @var bool
142
+	 */
143
+	private static $initialized = false;
144
+
145
+
146
+	/**
147
+	 * @singleton method used to instantiate class object
148
+	 * @access    public
149
+	 * @return EE_Config instance
150
+	 */
151
+	public static function instance()
152
+	{
153
+		// check if class object is instantiated, and instantiated properly
154
+		if (! self::$_instance instanceof EE_Config) {
155
+			self::$_instance = new self();
156
+		}
157
+		return self::$_instance;
158
+	}
159
+
160
+
161
+	/**
162
+	 * Resets the config
163
+	 *
164
+	 * @param bool    $hard_reset    if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE
165
+	 *                               (default) leaves the database alone, and merely resets the EE_Config object to
166
+	 *                               reflect its state in the database
167
+	 * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave
168
+	 *                               $_instance as NULL. Useful in case you want to forget about the old instance on
169
+	 *                               EE_Config, but might not be ready to instantiate EE_Config currently (eg if the
170
+	 *                               site was put into maintenance mode)
171
+	 * @return EE_Config
172
+	 */
173
+	public static function reset($hard_reset = false, $reinstantiate = true)
174
+	{
175
+		if (self::$_instance instanceof EE_Config) {
176
+			if ($hard_reset) {
177
+				self::$_instance->legacy_shortcodes_manager = null;
178
+				self::$_instance->_addon_option_names = array();
179
+				self::$_instance->_initialize_config();
180
+				self::$_instance->update_espresso_config();
181
+			}
182
+			self::$_instance->update_addon_option_names();
183
+		}
184
+		self::$_instance = null;
185
+		self::$initialized = false;
186
+		// we don't need to reset the static properties imo because those should
187
+		// only change when a module is added or removed. Currently we don't
188
+		// support removing a module during a request when it previously existed
189
+		if ($reinstantiate) {
190
+			return self::instance();
191
+		} else {
192
+			return null;
193
+		}
194
+	}
195
+
196
+
197
+	private function __construct()
198
+	{
199
+		if (self::$initialized) {
200
+			return;
201
+		}
202
+		self::$initialized = true;
203
+		do_action('AHEE__EE_Config__construct__begin', $this);
204
+		EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false);
205
+		// setup empty config classes
206
+		$this->_initialize_config();
207
+		// load existing EE site settings
208
+		$this->_load_core_config();
209
+		// confirm everything loaded correctly and set filtered defaults if not
210
+		$this->_verify_config();
211
+		//  register shortcodes and modules
212
+		add_action(
213
+			'AHEE__EE_System__register_shortcodes_modules_and_widgets',
214
+			[$this, 'register_shortcodes_and_modules'],
215
+			999
216
+		);
217
+		//  initialize shortcodes and modules
218
+		add_action('AHEE__EE_System__core_loaded_and_ready', [$this, 'initialize_shortcodes_and_modules']);
219
+		// register widgets
220
+		add_action('widgets_init', [$this, 'widgets_init'], 10);
221
+		// shutdown
222
+		add_action('shutdown', [$this, 'shutdown'], 10);
223
+		// construct__end hook
224
+		do_action('AHEE__EE_Config__construct__end', $this);
225
+		// hardcoded hack
226
+		$this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014';
227
+	}
228
+
229
+
230
+	/**
231
+	 * @return boolean
232
+	 */
233
+	public static function logging_enabled()
234
+	{
235
+		return self::$_logging_enabled;
236
+	}
237
+
238
+
239
+	/**
240
+	 * use to get the current theme if needed from static context
241
+	 *
242
+	 * @return string current theme set.
243
+	 */
244
+	public static function get_current_theme()
245
+	{
246
+		return self::$_instance->template_settings->current_espresso_theme ?? 'Espresso_Arabica_2014';
247
+	}
248
+
249
+
250
+	/**
251
+	 *        _initialize_config
252
+	 *
253
+	 * @access private
254
+	 * @return void
255
+	 */
256
+	private function _initialize_config()
257
+	{
258
+		EE_Config::trim_log();
259
+		// set defaults
260
+		$this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array());
261
+		$this->addons = new stdClass();
262
+		// set _module_route_map
263
+		EE_Config::$_module_route_map = array();
264
+		// set _module_forward_map
265
+		EE_Config::$_module_forward_map = array();
266
+		// set _module_view_map
267
+		EE_Config::$_module_view_map = array();
268
+	}
269
+
270
+
271
+	/**
272
+	 *        load core plugin configuration
273
+	 *
274
+	 * @access private
275
+	 * @return void
276
+	 */
277
+	private function _load_core_config()
278
+	{
279
+		// load_core_config__start hook
280
+		do_action('AHEE__EE_Config___load_core_config__start', $this);
281
+		$espresso_config = (array) $this->get_espresso_config();
282
+		// need to move the "addons" element to the end of the config array
283
+		// in case an addon config references one of the other config classes
284
+		$addons = $espresso_config['addons'];
285
+		unset($espresso_config['addons']);
286
+		$espresso_config['addons'] = $addons;
287
+		foreach ($espresso_config as $config => $settings) {
288
+			// load_core_config__start hook
289
+			$settings = apply_filters(
290
+				'FHEE__EE_Config___load_core_config__config_settings',
291
+				$settings,
292
+				$config,
293
+				$this
294
+			);
295
+			if (is_object($settings) && property_exists($this, $config)) {
296
+				$this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
297
+				// call configs populate method to ensure any defaults are set for empty values.
298
+				if (method_exists($settings, 'populate')) {
299
+					$this->{$config}->populate();
300
+				}
301
+				if (method_exists($settings, 'do_hooks')) {
302
+					$this->{$config}->do_hooks();
303
+				}
304
+			}
305
+		}
306
+		if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) {
307
+			$this->update_espresso_config();
308
+		}
309
+		// load_core_config__end hook
310
+		do_action('AHEE__EE_Config___load_core_config__end', $this);
311
+	}
312
+
313
+
314
+	/**
315
+	 *    _verify_config
316
+	 *
317
+	 * @access    protected
318
+	 * @return    void
319
+	 */
320
+	protected function _verify_config()
321
+	{
322
+		$this->core = $this->core instanceof EE_Core_Config
323
+			? $this->core
324
+			: new EE_Core_Config();
325
+		$this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core);
326
+		$this->organization = $this->organization instanceof EE_Organization_Config
327
+			? $this->organization
328
+			: new EE_Organization_Config();
329
+		$this->organization = apply_filters(
330
+			'FHEE__EE_Config___initialize_config__organization',
331
+			$this->organization
332
+		);
333
+		$this->currency = $this->currency instanceof EE_Currency_Config
334
+			? $this->currency
335
+			: new EE_Currency_Config();
336
+		$this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency);
337
+		$this->registration = $this->registration instanceof EE_Registration_Config
338
+			? $this->registration
339
+			: new EE_Registration_Config();
340
+		$this->registration = apply_filters(
341
+			'FHEE__EE_Config___initialize_config__registration',
342
+			$this->registration
343
+		);
344
+		$this->admin = $this->admin instanceof EE_Admin_Config
345
+			? $this->admin
346
+			: new EE_Admin_Config();
347
+		$this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin);
348
+		$this->template_settings = $this->template_settings instanceof EE_Template_Config
349
+			? $this->template_settings
350
+			: new EE_Template_Config();
351
+		$this->template_settings = apply_filters(
352
+			'FHEE__EE_Config___initialize_config__template_settings',
353
+			$this->template_settings
354
+		);
355
+		$this->map_settings = $this->map_settings instanceof EE_Map_Config
356
+			? $this->map_settings
357
+			: new EE_Map_Config();
358
+		$this->map_settings = apply_filters(
359
+			'FHEE__EE_Config___initialize_config__map_settings',
360
+			$this->map_settings
361
+		);
362
+		$this->environment = $this->environment instanceof EE_Environment_Config
363
+			? $this->environment
364
+			: new EE_Environment_Config();
365
+		$this->environment = apply_filters(
366
+			'FHEE__EE_Config___initialize_config__environment',
367
+			$this->environment
368
+		);
369
+		$this->tax_settings = $this->tax_settings instanceof EE_Tax_Config
370
+			? $this->tax_settings
371
+			: new EE_Tax_Config();
372
+		$this->tax_settings = apply_filters(
373
+			'FHEE__EE_Config___initialize_config__tax_settings',
374
+			$this->tax_settings
375
+		);
376
+		$this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages);
377
+		$this->messages = $this->messages instanceof EE_Messages_Config
378
+			? $this->messages
379
+			: new EE_Messages_Config();
380
+		$this->gateway = $this->gateway instanceof EE_Gateway_Config
381
+			? $this->gateway
382
+			: new EE_Gateway_Config();
383
+		$this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway);
384
+		$this->legacy_shortcodes_manager = null;
385
+	}
386
+
387
+
388
+	/**
389
+	 *    get_espresso_config
390
+	 *
391
+	 * @access    public
392
+	 * @return    array of espresso config stuff
393
+	 */
394
+	public function get_espresso_config()
395
+	{
396
+		// grab espresso configuration
397
+		return apply_filters(
398
+			'FHEE__EE_Config__get_espresso_config__CFG',
399
+			get_option(EE_Config::OPTION_NAME, array())
400
+		);
401
+	}
402
+
403
+
404
+	/**
405
+	 *    double_check_config_comparison
406
+	 *
407
+	 * @access    public
408
+	 * @param string $option
409
+	 * @param        $old_value
410
+	 * @param        $value
411
+	 */
412
+	public function double_check_config_comparison($option = '', $old_value, $value)
413
+	{
414
+		// make sure we're checking the ee config
415
+		if ($option === EE_Config::OPTION_NAME) {
416
+			// run a loose comparison of the old value against the new value for type and properties,
417
+			// but NOT exact instance like WP update_option does (ie: NOT type safe comparison)
418
+			if ($value != $old_value) {
419
+				// if they are NOT the same, then remove the hook,
420
+				// which means the subsequent update results will be based solely on the update query results
421
+				// the reason we do this is because, as stated above,
422
+				// WP update_option performs an exact instance comparison (===) on any update values passed to it
423
+				// this happens PRIOR to serialization and any subsequent update.
424
+				// If values are found to match their previous old value,
425
+				// then WP bails before performing any update.
426
+				// Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version
427
+				// it just pulled from the db, with the one being passed to it (which will not match).
428
+				// HOWEVER, once the object is serialized and passed off to MySQL to update,
429
+				// MySQL MAY ALSO NOT perform the update because
430
+				// the string it sees in the db looks the same as the new one it has been passed!!!
431
+				// This results in the query returning an "affected rows" value of ZERO,
432
+				// which gets returned immediately by WP update_option and looks like an error.
433
+				remove_action('update_option', array($this, 'check_config_updated'));
434
+			}
435
+		}
436
+	}
437
+
438
+
439
+	/**
440
+	 *    update_espresso_config
441
+	 *
442
+	 * @access   public
443
+	 */
444
+	protected function _reset_espresso_addon_config()
445
+	{
446
+		$this->_addon_option_names = array();
447
+		foreach ($this->addons as $addon_name => $addon_config_obj) {
448
+			$addon_config_obj = maybe_unserialize($addon_config_obj);
449
+			if ($addon_config_obj instanceof EE_Config_Base) {
450
+				$this->update_config('addons', $addon_name, $addon_config_obj, false);
451
+			}
452
+			$this->addons->{$addon_name} = null;
453
+		}
454
+	}
455
+
456
+
457
+	/**
458
+	 *    update_espresso_config
459
+	 *
460
+	 * @access   public
461
+	 * @param   bool $add_success
462
+	 * @param   bool $add_error
463
+	 * @return   bool
464
+	 */
465
+	public function update_espresso_config($add_success = false, $add_error = true)
466
+	{
467
+		// don't allow config updates during WP heartbeats
468
+		/** @var RequestInterface $request */
469
+		$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
470
+		if ($request->isWordPressHeartbeat()) {
471
+			return false;
472
+		}
473
+		// commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
474
+		// $clone = clone( self::$_instance );
475
+		// self::$_instance = NULL;
476
+		do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
477
+		$this->_reset_espresso_addon_config();
478
+		// hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
479
+		// but BEFORE the actual update occurs
480
+		add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
481
+		// don't want to persist legacy_shortcodes_manager, but don't want to lose it either
482
+		$legacy_shortcodes_manager = $this->legacy_shortcodes_manager;
483
+		$this->legacy_shortcodes_manager = null;
484
+		// now update "ee_config"
485
+		$saved = update_option(EE_Config::OPTION_NAME, $this);
486
+		$this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
487
+		EE_Config::log(EE_Config::OPTION_NAME);
488
+		// if not saved... check if the hook we just added still exists;
489
+		// if it does, it means one of two things:
490
+		// that update_option bailed at the($value === $old_value) conditional,
491
+		// or...
492
+		// the db update query returned 0 rows affected
493
+		// (probably because the data  value was the same from it's perspective)
494
+		// so the existence of the hook means that a negative result from update_option is NOT an error,
495
+		// but just means no update occurred, so don't display an error to the user.
496
+		// BUT... if update_option returns FALSE, AND the hook is missing,
497
+		// then it means that something truly went wrong
498
+		$saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
499
+		// remove our action since we don't want it in the system anymore
500
+		remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
501
+		do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
502
+		// self::$_instance = $clone;
503
+		// unset( $clone );
504
+		// if config remains the same or was updated successfully
505
+		if ($saved) {
506
+			if ($add_success) {
507
+				EE_Error::add_success(
508
+					esc_html__('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
509
+					__FILE__,
510
+					__FUNCTION__,
511
+					__LINE__
512
+				);
513
+			}
514
+			return true;
515
+		} else {
516
+			if ($add_error) {
517
+				EE_Error::add_error(
518
+					esc_html__('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
519
+					__FILE__,
520
+					__FUNCTION__,
521
+					__LINE__
522
+				);
523
+			}
524
+			return false;
525
+		}
526
+	}
527
+
528
+
529
+	/**
530
+	 *    _verify_config_params
531
+	 *
532
+	 * @access    private
533
+	 * @param    string         $section
534
+	 * @param    string         $name
535
+	 * @param    string         $config_class
536
+	 * @param    EE_Config_Base $config_obj
537
+	 * @param    array          $tests_to_run
538
+	 * @param    bool           $display_errors
539
+	 * @return    bool    TRUE on success, FALSE on fail
540
+	 */
541
+	private function _verify_config_params(
542
+		$section = '',
543
+		$name = '',
544
+		$config_class = '',
545
+		$config_obj = null,
546
+		$tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
547
+		$display_errors = true
548
+	) {
549
+		try {
550
+			foreach ($tests_to_run as $test) {
551
+				switch ($test) {
552
+					// TEST #1 : check that section was set
553
+					case 1:
554
+						if (empty($section)) {
555
+							if ($display_errors) {
556
+								throw new EE_Error(
557
+									sprintf(
558
+										esc_html__(
559
+											'No configuration section has been provided while attempting to save "%s".',
560
+											'event_espresso'
561
+										),
562
+										$config_class
563
+									)
564
+								);
565
+							}
566
+							return false;
567
+						}
568
+						break;
569
+					// TEST #2 : check that settings section exists
570
+					case 2:
571
+						if (! isset($this->{$section})) {
572
+							if ($display_errors) {
573
+								throw new EE_Error(
574
+									sprintf(
575
+										esc_html__('The "%s" configuration section does not exist.', 'event_espresso'),
576
+										$section
577
+									)
578
+								);
579
+							}
580
+							return false;
581
+						}
582
+						break;
583
+					// TEST #3 : check that section is the proper format
584
+					case 3:
585
+						if (
586
+							! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
587
+						) {
588
+							if ($display_errors) {
589
+								throw new EE_Error(
590
+									sprintf(
591
+										esc_html__(
592
+											'The "%s" configuration settings have not been formatted correctly.',
593
+											'event_espresso'
594
+										),
595
+										$section
596
+									)
597
+								);
598
+							}
599
+							return false;
600
+						}
601
+						break;
602
+					// TEST #4 : check that config section name has been set
603
+					case 4:
604
+						if (empty($name)) {
605
+							if ($display_errors) {
606
+								throw new EE_Error(
607
+									esc_html__(
608
+										'No name has been provided for the specific configuration section.',
609
+										'event_espresso'
610
+									)
611
+								);
612
+							}
613
+							return false;
614
+						}
615
+						break;
616
+					// TEST #5 : check that a config class name has been set
617
+					case 5:
618
+						if (empty($config_class)) {
619
+							if ($display_errors) {
620
+								throw new EE_Error(
621
+									esc_html__(
622
+										'No class name has been provided for the specific configuration section.',
623
+										'event_espresso'
624
+									)
625
+								);
626
+							}
627
+							return false;
628
+						}
629
+						break;
630
+					// TEST #6 : verify config class is accessible
631
+					case 6:
632
+						if (! class_exists($config_class)) {
633
+							if ($display_errors) {
634
+								throw new EE_Error(
635
+									sprintf(
636
+										esc_html__(
637
+											'The "%s" class does not exist. Please ensure that an autoloader has been set for it.',
638
+											'event_espresso'
639
+										),
640
+										$config_class
641
+									)
642
+								);
643
+							}
644
+							return false;
645
+						}
646
+						break;
647
+					// TEST #7 : check that config has even been set
648
+					case 7:
649
+						if (! isset($this->{$section}->{$name})) {
650
+							if ($display_errors) {
651
+								throw new EE_Error(
652
+									sprintf(
653
+										esc_html__('No configuration has been set for "%1$s->%2$s".', 'event_espresso'),
654
+										$section,
655
+										$name
656
+									)
657
+								);
658
+							}
659
+							return false;
660
+						} else {
661
+							// and make sure it's not serialized
662
+							$this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name});
663
+						}
664
+						break;
665
+					// TEST #8 : check that config is the requested type
666
+					case 8:
667
+						if (! $this->{$section}->{$name} instanceof $config_class) {
668
+							if ($display_errors) {
669
+								throw new EE_Error(
670
+									sprintf(
671
+										esc_html__(
672
+											'The configuration for "%1$s->%2$s" is not of the "%3$s" class.',
673
+											'event_espresso'
674
+										),
675
+										$section,
676
+										$name,
677
+										$config_class
678
+									)
679
+								);
680
+							}
681
+							return false;
682
+						}
683
+						break;
684
+					// TEST #9 : verify config object
685
+					case 9:
686
+						if (! $config_obj instanceof EE_Config_Base) {
687
+							if ($display_errors) {
688
+								throw new EE_Error(
689
+									sprintf(
690
+										esc_html__('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'),
691
+										print_r($config_obj, true)
692
+									)
693
+								);
694
+							}
695
+							return false;
696
+						}
697
+						break;
698
+				}
699
+			}
700
+		} catch (EE_Error $e) {
701
+			$e->get_error();
702
+		}
703
+		// you have successfully run the gauntlet
704
+		return true;
705
+	}
706
+
707
+
708
+	/**
709
+	 *    _generate_config_option_name
710
+	 *
711
+	 * @access        protected
712
+	 * @param        string $section
713
+	 * @param        string $name
714
+	 * @return        string
715
+	 */
716
+	private function _generate_config_option_name($section = '', $name = '')
717
+	{
718
+		return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
719
+	}
720
+
721
+
722
+	/**
723
+	 *    _set_config_class
724
+	 * ensures that a config class is set, either from a passed config class or one generated from the config name
725
+	 *
726
+	 * @access    private
727
+	 * @param    string $config_class
728
+	 * @param    string $name
729
+	 * @return    string
730
+	 */
731
+	private function _set_config_class($config_class = '', $name = '')
732
+	{
733
+		return ! empty($config_class)
734
+			? $config_class
735
+			: str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
736
+	}
737
+
738
+
739
+	/**
740
+	 *    set_config
741
+	 *
742
+	 * @access    protected
743
+	 * @param    string         $section
744
+	 * @param    string         $name
745
+	 * @param    string         $config_class
746
+	 * @param    EE_Config_Base $config_obj
747
+	 * @return    EE_Config_Base
748
+	 */
749
+	public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null)
750
+	{
751
+		// ensure config class is set to something
752
+		$config_class = $this->_set_config_class($config_class, $name);
753
+		// run tests 1-4, 6, and 7 to verify all config params are set and valid
754
+		if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
755
+			return null;
756
+		}
757
+		$config_option_name = $this->_generate_config_option_name($section, $name);
758
+		// if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
759
+		if (! isset($this->_addon_option_names[ $config_option_name ])) {
760
+			$this->_addon_option_names[ $config_option_name ] = $config_class;
761
+			$this->update_addon_option_names();
762
+		}
763
+		// verify the incoming config object but suppress errors
764
+		if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
765
+			$config_obj = new $config_class();
766
+		}
767
+		if (get_option($config_option_name)) {
768
+			EE_Config::log($config_option_name);
769
+			update_option($config_option_name, $config_obj);
770
+			$this->{$section}->{$name} = $config_obj;
771
+			return $this->{$section}->{$name};
772
+		} else {
773
+			// create a wp-option for this config
774
+			if (add_option($config_option_name, $config_obj, '', 'no')) {
775
+				$this->{$section}->{$name} = maybe_unserialize($config_obj);
776
+				return $this->{$section}->{$name};
777
+			} else {
778
+				EE_Error::add_error(
779
+					sprintf(esc_html__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class),
780
+					__FILE__,
781
+					__FUNCTION__,
782
+					__LINE__
783
+				);
784
+				return null;
785
+			}
786
+		}
787
+	}
788
+
789
+
790
+	/**
791
+	 *    update_config
792
+	 * Important: the config object must ALREADY be set, otherwise this will produce an error.
793
+	 *
794
+	 * @access    public
795
+	 * @param    string                $section
796
+	 * @param    string                $name
797
+	 * @param    EE_Config_Base|string $config_obj
798
+	 * @param    bool                  $throw_errors
799
+	 * @return    bool
800
+	 */
801
+	public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true)
802
+	{
803
+		// don't allow config updates during WP heartbeats
804
+		/** @var RequestInterface $request */
805
+		$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
806
+		if ($request->isWordPressHeartbeat()) {
807
+			return false;
808
+		}
809
+		$config_obj = maybe_unserialize($config_obj);
810
+		// get class name of the incoming object
811
+		$config_class = get_class($config_obj);
812
+		// run tests 1-5 and 9 to verify config
813
+		if (
814
+			! $this->_verify_config_params(
815
+				$section,
816
+				$name,
817
+				$config_class,
818
+				$config_obj,
819
+				array(1, 2, 3, 4, 7, 9)
820
+			)
821
+		) {
822
+			return false;
823
+		}
824
+		$config_option_name = $this->_generate_config_option_name($section, $name);
825
+		// check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
826
+		if (! isset($this->_addon_option_names[ $config_option_name ])) {
827
+			// save new config to db
828
+			if ($this->set_config($section, $name, $config_class, $config_obj)) {
829
+				return true;
830
+			}
831
+		} else {
832
+			// first check if the record already exists
833
+			$existing_config = get_option($config_option_name);
834
+			$config_obj = serialize($config_obj);
835
+			// just return if db record is already up to date (NOT type safe comparison)
836
+			if ($existing_config == $config_obj) {
837
+				$this->{$section}->{$name} = $config_obj;
838
+				return true;
839
+			} elseif (update_option($config_option_name, $config_obj)) {
840
+				EE_Config::log($config_option_name);
841
+				// update wp-option for this config class
842
+				$this->{$section}->{$name} = $config_obj;
843
+				return true;
844
+			} elseif ($throw_errors) {
845
+				EE_Error::add_error(
846
+					sprintf(
847
+						esc_html__(
848
+							'The "%1$s" object stored at"%2$s" was not successfully updated in the database.',
849
+							'event_espresso'
850
+						),
851
+						$config_class,
852
+						'EE_Config->' . $section . '->' . $name
853
+					),
854
+					__FILE__,
855
+					__FUNCTION__,
856
+					__LINE__
857
+				);
858
+			}
859
+		}
860
+		return false;
861
+	}
862
+
863
+
864
+	/**
865
+	 *    get_config
866
+	 *
867
+	 * @access    public
868
+	 * @param    string $section
869
+	 * @param    string $name
870
+	 * @param    string $config_class
871
+	 * @return    mixed EE_Config_Base | NULL
872
+	 */
873
+	public function get_config($section = '', $name = '', $config_class = '')
874
+	{
875
+		// ensure config class is set to something
876
+		$config_class = $this->_set_config_class($config_class, $name);
877
+		// run tests 1-4, 6 and 7 to verify that all params have been set
878
+		if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
879
+			return null;
880
+		}
881
+		// now test if the requested config object exists, but suppress errors
882
+		if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) {
883
+			// config already exists, so pass it back
884
+			return $this->{$section}->{$name};
885
+		}
886
+		// load config option from db if it exists
887
+		$config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
888
+		// verify the newly retrieved config object, but suppress errors
889
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
890
+			// config is good, so set it and pass it back
891
+			$this->{$section}->{$name} = $config_obj;
892
+			return $this->{$section}->{$name};
893
+		}
894
+		// oops! $config_obj is not already set and does not exist in the db, so create a new one
895
+		$config_obj = $this->set_config($section, $name, $config_class);
896
+		// verify the newly created config object
897
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
898
+			return $this->{$section}->{$name};
899
+		} else {
900
+			EE_Error::add_error(
901
+				sprintf(esc_html__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
902
+				__FILE__,
903
+				__FUNCTION__,
904
+				__LINE__
905
+			);
906
+		}
907
+		return null;
908
+	}
909
+
910
+
911
+	/**
912
+	 *    get_config_option
913
+	 *
914
+	 * @access    public
915
+	 * @param    string $config_option_name
916
+	 * @return    mixed EE_Config_Base | FALSE
917
+	 */
918
+	public function get_config_option($config_option_name = '')
919
+	{
920
+		// retrieve the wp-option for this config class.
921
+		$config_option = maybe_unserialize(get_option($config_option_name, array()));
922
+		if (empty($config_option)) {
923
+			EE_Config::log($config_option_name . '-NOT-FOUND');
924
+		}
925
+		return $config_option;
926
+	}
927
+
928
+
929
+	/**
930
+	 * log
931
+	 *
932
+	 * @param string $config_option_name
933
+	 */
934
+	public static function log($config_option_name = '')
935
+	{
936
+		if (EE_Config::logging_enabled() && ! empty($config_option_name)) {
937
+			$config_log = get_option(EE_Config::LOG_NAME, array());
938
+			/** @var RequestParams $request */
939
+			$request = LoaderFactory::getLoader()->getShared(RequestParams::class);
940
+			$config_log[ (string) microtime(true) ] = array(
941
+				'config_name' => $config_option_name,
942
+				'request'     => $request->requestParams(),
943
+			);
944
+			update_option(EE_Config::LOG_NAME, $config_log);
945
+		}
946
+	}
947
+
948
+
949
+	/**
950
+	 * trim_log
951
+	 * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH
952
+	 */
953
+	public static function trim_log()
954
+	{
955
+		if (! EE_Config::logging_enabled()) {
956
+			return;
957
+		}
958
+		$config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
959
+		$log_length = count($config_log);
960
+		if ($log_length > EE_Config::LOG_LENGTH) {
961
+			ksort($config_log);
962
+			$config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true);
963
+			update_option(EE_Config::LOG_NAME, $config_log);
964
+		}
965
+	}
966
+
967
+
968
+	/**
969
+	 *    get_page_for_posts
970
+	 *    if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the
971
+	 *    wp-option "page_for_posts", or "posts" if no page is selected
972
+	 *
973
+	 * @access    public
974
+	 * @return    string
975
+	 */
976
+	public static function get_page_for_posts()
977
+	{
978
+		$page_for_posts = get_option('page_for_posts');
979
+		if (! $page_for_posts) {
980
+			return 'posts';
981
+		}
982
+		global $wpdb;
983
+		$SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
984
+		return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
985
+	}
986
+
987
+
988
+	/**
989
+	 *    register_shortcodes_and_modules.
990
+	 *    At this point, it's too early to tell if we're maintenance mode or not.
991
+	 *    In fact, this is where we give modules a chance to let core know they exist
992
+	 *    so they can help trigger maintenance mode if it's needed
993
+	 *
994
+	 * @access    public
995
+	 * @return    void
996
+	 */
997
+	public function register_shortcodes_and_modules()
998
+	{
999
+		// allow modules to set hooks for the rest of the system
1000
+		EE_Registry::instance()->modules = $this->_register_modules();
1001
+	}
1002
+
1003
+
1004
+	/**
1005
+	 *    initialize_shortcodes_and_modules
1006
+	 *    meaning they can start adding their hooks to get stuff done
1007
+	 *
1008
+	 * @access    public
1009
+	 * @return    void
1010
+	 */
1011
+	public function initialize_shortcodes_and_modules()
1012
+	{
1013
+		// allow modules to set hooks for the rest of the system
1014
+		$this->_initialize_modules();
1015
+	}
1016
+
1017
+
1018
+	/**
1019
+	 *    widgets_init
1020
+	 *
1021
+	 * @access private
1022
+	 * @return void
1023
+	 */
1024
+	public function widgets_init()
1025
+	{
1026
+		// only init widgets on admin pages when not in complete maintenance, and
1027
+		// on frontend when not in any maintenance mode
1028
+		if (
1029
+			! EE_Maintenance_Mode::instance()->level()
1030
+			|| (
1031
+				is_admin()
1032
+				&& EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
1033
+			)
1034
+		) {
1035
+			// grab list of installed widgets
1036
+			$widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1037
+			// filter list of modules to register
1038
+			$widgets_to_register = apply_filters(
1039
+				'FHEE__EE_Config__register_widgets__widgets_to_register',
1040
+				$widgets_to_register
1041
+			);
1042
+			if (! empty($widgets_to_register)) {
1043
+				// cycle thru widget folders
1044
+				foreach ($widgets_to_register as $widget_path) {
1045
+					// add to list of installed widget modules
1046
+					EE_Config::register_ee_widget($widget_path);
1047
+				}
1048
+			}
1049
+			// filter list of installed modules
1050
+			EE_Registry::instance()->widgets = apply_filters(
1051
+				'FHEE__EE_Config__register_widgets__installed_widgets',
1052
+				EE_Registry::instance()->widgets
1053
+			);
1054
+		}
1055
+	}
1056
+
1057
+
1058
+	/**
1059
+	 *    register_ee_widget - makes core aware of this widget
1060
+	 *
1061
+	 * @access    public
1062
+	 * @param    string $widget_path - full path up to and including widget folder
1063
+	 * @return    void
1064
+	 */
1065
+	public static function register_ee_widget($widget_path = null)
1066
+	{
1067
+		do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
1068
+		$widget_ext = '.widget.php';
1069
+		// make all separators match
1070
+		$widget_path = rtrim(str_replace('\\', DS, $widget_path), DS);
1071
+		// does the file path INCLUDE the actual file name as part of the path ?
1072
+		if (strpos($widget_path, $widget_ext) !== false) {
1073
+			// grab and shortcode file name from directory name and break apart at dots
1074
+			$file_name = explode('.', basename($widget_path));
1075
+			// take first segment from file name pieces and remove class prefix if it exists
1076
+			$widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
1077
+			// sanitize shortcode directory name
1078
+			$widget = sanitize_key($widget);
1079
+			// now we need to rebuild the shortcode path
1080
+			$widget_path = explode('/', $widget_path);
1081
+			// remove last segment
1082
+			array_pop($widget_path);
1083
+			// glue it back together
1084
+			$widget_path = implode(DS, $widget_path);
1085
+		} else {
1086
+			// grab and sanitize widget directory name
1087
+			$widget = sanitize_key(basename($widget_path));
1088
+		}
1089
+		// create classname from widget directory name
1090
+		$widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1091
+		// add class prefix
1092
+		$widget_class = 'EEW_' . $widget;
1093
+		// does the widget exist ?
1094
+		if (! is_readable($widget_path . '/' . $widget_class . $widget_ext)) {
1095
+			$msg = sprintf(
1096
+				esc_html__(
1097
+					'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s',
1098
+					'event_espresso'
1099
+				),
1100
+				$widget_class,
1101
+				$widget_path . '/' . $widget_class . $widget_ext
1102
+			);
1103
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1104
+			return;
1105
+		}
1106
+		// load the widget class file
1107
+		require_once($widget_path . '/' . $widget_class . $widget_ext);
1108
+		// verify that class exists
1109
+		if (! class_exists($widget_class)) {
1110
+			$msg = sprintf(esc_html__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1111
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1112
+			return;
1113
+		}
1114
+		register_widget($widget_class);
1115
+		// add to array of registered widgets
1116
+		EE_Registry::instance()->widgets->{$widget_class} = $widget_path . '/' . $widget_class . $widget_ext;
1117
+	}
1118
+
1119
+
1120
+	/**
1121
+	 *        _register_modules
1122
+	 *
1123
+	 * @access private
1124
+	 * @return array
1125
+	 */
1126
+	private function _register_modules()
1127
+	{
1128
+		// grab list of installed modules
1129
+		$modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1130
+		// filter list of modules to register
1131
+		$modules_to_register = apply_filters(
1132
+			'FHEE__EE_Config__register_modules__modules_to_register',
1133
+			$modules_to_register
1134
+		);
1135
+		if (! empty($modules_to_register)) {
1136
+			// loop through folders
1137
+			foreach ($modules_to_register as $module_path) {
1138
+				/**TEMPORARILY EXCLUDE gateways from modules for time being**/
1139
+				if (
1140
+					$module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1141
+					&& $module_path !== EE_MODULES . 'gateways'
1142
+				) {
1143
+					// add to list of installed modules
1144
+					EE_Config::register_module($module_path);
1145
+				}
1146
+			}
1147
+		}
1148
+		// filter list of installed modules
1149
+		return apply_filters(
1150
+			'FHEE__EE_Config___register_modules__installed_modules',
1151
+			EE_Registry::instance()->modules
1152
+		);
1153
+	}
1154
+
1155
+
1156
+	/**
1157
+	 *    register_module - makes core aware of this module
1158
+	 *
1159
+	 * @access    public
1160
+	 * @param    string $module_path - full path up to and including module folder
1161
+	 * @return    bool
1162
+	 */
1163
+	public static function register_module($module_path = null)
1164
+	{
1165
+		do_action('AHEE__EE_Config__register_module__begin', $module_path);
1166
+		$module_ext = '.module.php';
1167
+		// make all separators match
1168
+		$module_path = str_replace(array('\\', '/'), '/', $module_path);
1169
+		// does the file path INCLUDE the actual file name as part of the path ?
1170
+		if (strpos($module_path, $module_ext) !== false) {
1171
+			// grab and shortcode file name from directory name and break apart at dots
1172
+			$module_file = explode('.', basename($module_path));
1173
+			// now we need to rebuild the shortcode path
1174
+			$module_path = explode('/', $module_path);
1175
+			// remove last segment
1176
+			array_pop($module_path);
1177
+			// glue it back together
1178
+			$module_path = implode('/', $module_path) . '/';
1179
+			// take first segment from file name pieces and sanitize it
1180
+			$module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1181
+			// ensure class prefix is added
1182
+			$module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1183
+		} else {
1184
+			// we need to generate the filename based off of the folder name
1185
+			// grab and sanitize module name
1186
+			$module = strtolower(basename($module_path));
1187
+			$module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1188
+			// like trailingslashit()
1189
+			$module_path = rtrim($module_path, '/') . '/';
1190
+			// create classname from module directory name
1191
+			$module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1192
+			// add class prefix
1193
+			$module_class = 'EED_' . $module;
1194
+		}
1195
+		// does the module exist ?
1196
+		if (! is_readable($module_path . '/' . $module_class . $module_ext)) {
1197
+			$msg = sprintf(
1198
+				esc_html__(
1199
+					'The requested %s module file could not be found or is not readable due to file permissions.',
1200
+					'event_espresso'
1201
+				),
1202
+				$module
1203
+			);
1204
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1205
+			return false;
1206
+		}
1207
+		// load the module class file
1208
+		require_once($module_path . $module_class . $module_ext);
1209
+		// verify that class exists
1210
+		if (! class_exists($module_class)) {
1211
+			$msg = sprintf(esc_html__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1212
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1213
+			return false;
1214
+		}
1215
+		// add to array of registered modules
1216
+		EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1217
+		do_action(
1218
+			'AHEE__EE_Config__register_module__complete',
1219
+			$module_class,
1220
+			EE_Registry::instance()->modules->{$module_class}
1221
+		);
1222
+		return true;
1223
+	}
1224
+
1225
+
1226
+	/**
1227
+	 *    _initialize_modules
1228
+	 *    allow modules to set hooks for the rest of the system
1229
+	 *
1230
+	 * @access private
1231
+	 * @return void
1232
+	 */
1233
+	private function _initialize_modules()
1234
+	{
1235
+		// cycle thru shortcode folders
1236
+		foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1237
+			// fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1238
+			// which set hooks ?
1239
+			if (is_admin()) {
1240
+				// fire immediately
1241
+				call_user_func(array($module_class, 'set_hooks_admin'));
1242
+			} else {
1243
+				// delay until other systems are online
1244
+				add_action(
1245
+					'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1246
+					array($module_class, 'set_hooks')
1247
+				);
1248
+			}
1249
+		}
1250
+	}
1251
+
1252
+
1253
+	/**
1254
+	 *    register_route - adds module method routes to route_map
1255
+	 *
1256
+	 * @access    public
1257
+	 * @param    string $route       - "pretty" public alias for module method
1258
+	 * @param    string $module      - module name (classname without EED_ prefix)
1259
+	 * @param    string $method_name - the actual module method to be routed to
1260
+	 * @param    string $key         - url param key indicating a route is being called
1261
+	 * @return    bool
1262
+	 */
1263
+	public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee')
1264
+	{
1265
+		do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1266
+		$module = str_replace('EED_', '', $module);
1267
+		$module_class = 'EED_' . $module;
1268
+		if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1269
+			$msg = sprintf(esc_html__('The module %s has not been registered.', 'event_espresso'), $module);
1270
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1271
+			return false;
1272
+		}
1273
+		if (empty($route)) {
1274
+			$msg = sprintf(esc_html__('No route has been supplied.', 'event_espresso'), $route);
1275
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1276
+			return false;
1277
+		}
1278
+		if (! method_exists('EED_' . $module, $method_name)) {
1279
+			$msg = sprintf(
1280
+				esc_html__('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1281
+				$route
1282
+			);
1283
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1284
+			return false;
1285
+		}
1286
+		EE_Config::$_module_route_map[ (string) $key ][ (string) $route ] = array('EED_' . $module, $method_name);
1287
+		return true;
1288
+	}
1289
+
1290
+
1291
+	/**
1292
+	 *    get_route - get module method route
1293
+	 *
1294
+	 * @access    public
1295
+	 * @param    string $route - "pretty" public alias for module method
1296
+	 * @param    string $key   - url param key indicating a route is being called
1297
+	 * @return    string
1298
+	 */
1299
+	public static function get_route($route = null, $key = 'ee')
1300
+	{
1301
+		do_action('AHEE__EE_Config__get_route__begin', $route);
1302
+		$route = (string) apply_filters('FHEE__EE_Config__get_route', $route);
1303
+		if (isset(EE_Config::$_module_route_map[ $key ][ $route ])) {
1304
+			return EE_Config::$_module_route_map[ $key ][ $route ];
1305
+		}
1306
+		return null;
1307
+	}
1308
+
1309
+
1310
+	/**
1311
+	 *    get_routes - get ALL module method routes
1312
+	 *
1313
+	 * @access    public
1314
+	 * @return    array
1315
+	 */
1316
+	public static function get_routes()
1317
+	{
1318
+		return EE_Config::$_module_route_map;
1319
+	}
1320
+
1321
+
1322
+	/**
1323
+	 *    register_forward - allows modules to forward request to another module for further processing
1324
+	 *
1325
+	 * @access    public
1326
+	 * @param    string       $route   - "pretty" public alias for module method
1327
+	 * @param    integer      $status  - integer value corresponding  to status constant strings set in module parent
1328
+	 *                                 class, allows different forwards to be served based on status
1329
+	 * @param    array|string $forward - function name or array( class, method )
1330
+	 * @param    string       $key     - url param key indicating a route is being called
1331
+	 * @return    bool
1332
+	 */
1333
+	public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1334
+	{
1335
+		do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1336
+		if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1337
+			$msg = sprintf(
1338
+				esc_html__('The module route %s for this forward has not been registered.', 'event_espresso'),
1339
+				$route
1340
+			);
1341
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1342
+			return false;
1343
+		}
1344
+		if (empty($forward)) {
1345
+			$msg = sprintf(esc_html__('No forwarding route has been supplied.', 'event_espresso'), $route);
1346
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1347
+			return false;
1348
+		}
1349
+		if (is_array($forward)) {
1350
+			if (! isset($forward[1])) {
1351
+				$msg = sprintf(
1352
+					esc_html__('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1353
+					$route
1354
+				);
1355
+				EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1356
+				return false;
1357
+			}
1358
+			if (! method_exists($forward[0], $forward[1])) {
1359
+				$msg = sprintf(
1360
+					esc_html__('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1361
+					$forward[1],
1362
+					$route
1363
+				);
1364
+				EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1365
+				return false;
1366
+			}
1367
+		} elseif (! function_exists($forward)) {
1368
+			$msg = sprintf(
1369
+				esc_html__('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1370
+				$forward,
1371
+				$route
1372
+			);
1373
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1374
+			return false;
1375
+		}
1376
+		EE_Config::$_module_forward_map[ $key ][ $route ][ absint($status) ] = $forward;
1377
+		return true;
1378
+	}
1379
+
1380
+
1381
+	/**
1382
+	 *    get_forward - get forwarding route
1383
+	 *
1384
+	 * @access    public
1385
+	 * @param    string  $route  - "pretty" public alias for module method
1386
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1387
+	 *                           allows different forwards to be served based on status
1388
+	 * @param    string  $key    - url param key indicating a route is being called
1389
+	 * @return    string
1390
+	 */
1391
+	public static function get_forward($route = null, $status = 0, $key = 'ee')
1392
+	{
1393
+		do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1394
+		if (isset(EE_Config::$_module_forward_map[ $key ][ $route ][ $status ])) {
1395
+			return apply_filters(
1396
+				'FHEE__EE_Config__get_forward',
1397
+				EE_Config::$_module_forward_map[ $key ][ $route ][ $status ],
1398
+				$route,
1399
+				$status
1400
+			);
1401
+		}
1402
+		return null;
1403
+	}
1404
+
1405
+
1406
+	/**
1407
+	 *    register_forward - allows modules to specify different view templates for different method routes and status
1408
+	 *    results
1409
+	 *
1410
+	 * @access    public
1411
+	 * @param    string  $route  - "pretty" public alias for module method
1412
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1413
+	 *                           allows different views to be served based on status
1414
+	 * @param    string  $view
1415
+	 * @param    string  $key    - url param key indicating a route is being called
1416
+	 * @return    bool
1417
+	 */
1418
+	public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1419
+	{
1420
+		do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1421
+		if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1422
+			$msg = sprintf(
1423
+				esc_html__('The module route %s for this view has not been registered.', 'event_espresso'),
1424
+				$route
1425
+			);
1426
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1427
+			return false;
1428
+		}
1429
+		if (! is_readable($view)) {
1430
+			$msg = sprintf(
1431
+				esc_html__(
1432
+					'The %s view file could not be found or is not readable due to file permissions.',
1433
+					'event_espresso'
1434
+				),
1435
+				$view
1436
+			);
1437
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1438
+			return false;
1439
+		}
1440
+		EE_Config::$_module_view_map[ $key ][ $route ][ absint($status) ] = $view;
1441
+		return true;
1442
+	}
1443
+
1444
+
1445
+	/**
1446
+	 *    get_view - get view for route and status
1447
+	 *
1448
+	 * @access    public
1449
+	 * @param    string  $route  - "pretty" public alias for module method
1450
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1451
+	 *                           allows different views to be served based on status
1452
+	 * @param    string  $key    - url param key indicating a route is being called
1453
+	 * @return    string
1454
+	 */
1455
+	public static function get_view($route = null, $status = 0, $key = 'ee')
1456
+	{
1457
+		do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1458
+		if (isset(EE_Config::$_module_view_map[ $key ][ $route ][ $status ])) {
1459
+			return apply_filters(
1460
+				'FHEE__EE_Config__get_view',
1461
+				EE_Config::$_module_view_map[ $key ][ $route ][ $status ],
1462
+				$route,
1463
+				$status
1464
+			);
1465
+		}
1466
+		return null;
1467
+	}
1468
+
1469
+
1470
+	public function update_addon_option_names()
1471
+	{
1472
+		update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names);
1473
+	}
1474
+
1475
+
1476
+	public function shutdown()
1477
+	{
1478
+		$this->update_addon_option_names();
1479
+	}
1480
+
1481
+
1482
+	/**
1483
+	 * @return LegacyShortcodesManager
1484
+	 */
1485
+	public static function getLegacyShortcodesManager()
1486
+	{
1487
+		if (! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1488
+			EE_Config::instance()->legacy_shortcodes_manager = LoaderFactory::getLoader()->getShared(
1489
+				LegacyShortcodesManager::class
1490
+			);
1491
+		}
1492
+		return EE_Config::instance()->legacy_shortcodes_manager;
1493
+	}
1494
+
1495
+
1496
+	/**
1497
+	 * register_shortcode - makes core aware of this shortcode
1498
+	 *
1499
+	 * @deprecated 4.9.26
1500
+	 * @param    string $shortcode_path - full path up to and including shortcode folder
1501
+	 * @return    bool
1502
+	 */
1503
+	public static function register_shortcode($shortcode_path = null)
1504
+	{
1505
+		EE_Error::doing_it_wrong(
1506
+			__METHOD__,
1507
+			esc_html__(
1508
+				'Usage is deprecated. Use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::registerShortcode() as direct replacement, or better yet, please see the new \EventEspresso\core\services\shortcodes\ShortcodesManager class.',
1509
+				'event_espresso'
1510
+			),
1511
+			'4.9.26'
1512
+		);
1513
+		return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path);
1514
+	}
1515
+}
2323 1516
 
2324
-    /**
2325
-     * ReCaptcha Type
2326
-     *
2327
-     * @var string $recaptcha_type
2328
-     *    options: 'audio', 'image'
2329
-     */
2330
-    public $recaptcha_type;
1517
+/**
1518
+ * Base class used for config classes. These classes should generally not have
1519
+ * magic functions in use, except we'll allow them to magically set and get stuff...
1520
+ * basically, they should just be well-defined stdClasses
1521
+ */
1522
+class EE_Config_Base
1523
+{
2331 1524
 
2332
-    /**
2333
-     * ReCaptcha language
2334
-     *
2335
-     * @var string $recaptcha_language
2336
-     * eg 'en'
2337
-     */
2338
-    public $recaptcha_language;
1525
+	/**
1526
+	 * Utility function for escaping the value of a property and returning.
1527
+	 *
1528
+	 * @param string $property property name (checks to see if exists).
1529
+	 * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1530
+	 * @throws EE_Error
1531
+	 */
1532
+	public function get_pretty($property)
1533
+	{
1534
+		if (! property_exists($this, $property)) {
1535
+			throw new EE_Error(
1536
+				sprintf(
1537
+					esc_html__(
1538
+						'%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.',
1539
+						'event_espresso'
1540
+					),
1541
+					get_class($this),
1542
+					$property
1543
+				)
1544
+			);
1545
+		}
1546
+		// just handling escaping of strings for now.
1547
+		if (is_string($this->{$property})) {
1548
+			return stripslashes($this->{$property});
1549
+		}
1550
+		return $this->{$property};
1551
+	}
1552
+
1553
+
1554
+	public function populate()
1555
+	{
1556
+		// grab defaults via a new instance of this class.
1557
+		$class_name = get_class($this);
1558
+		$defaults = new $class_name();
1559
+		// loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1560
+		// default from our $defaults object.
1561
+		foreach (get_object_vars($defaults) as $property => $value) {
1562
+			if ($this->{$property} === null) {
1563
+				$this->{$property} = $value;
1564
+			}
1565
+		}
1566
+		// cleanup
1567
+		unset($defaults);
1568
+	}
1569
+
1570
+
1571
+	/**
1572
+	 *        __isset
1573
+	 *
1574
+	 * @param $a
1575
+	 * @return bool
1576
+	 */
1577
+	public function __isset($a)
1578
+	{
1579
+		return false;
1580
+	}
1581
+
1582
+
1583
+	/**
1584
+	 *        __unset
1585
+	 *
1586
+	 * @param $a
1587
+	 * @return bool
1588
+	 */
1589
+	public function __unset($a)
1590
+	{
1591
+		return false;
1592
+	}
1593
+
1594
+
1595
+	/**
1596
+	 *        __clone
1597
+	 */
1598
+	public function __clone()
1599
+	{
1600
+	}
1601
+
1602
+
1603
+	/**
1604
+	 *        __wakeup
1605
+	 */
1606
+	public function __wakeup()
1607
+	{
1608
+	}
1609
+
1610
+
1611
+	/**
1612
+	 *        __destruct
1613
+	 */
1614
+	public function __destruct()
1615
+	{
1616
+	}
1617
+}
2339 1618
 
2340
-    /**
2341
-     * ReCaptcha public key
2342
-     *
2343
-     * @var string $recaptcha_publickey
2344
-     */
2345
-    public $recaptcha_publickey;
1619
+/**
1620
+ * Class for defining what's in the EE_Config relating to registration settings
1621
+ */
1622
+class EE_Core_Config extends EE_Config_Base
1623
+{
2346 1624
 
2347
-    /**
2348
-     * ReCaptcha private key
2349
-     *
2350
-     * @var string $recaptcha_privatekey
2351
-     */
2352
-    public $recaptcha_privatekey;
1625
+	const OPTION_NAME_UXIP = 'ee_ueip_optin';
1626
+
1627
+
1628
+	public $current_blog_id;
1629
+
1630
+	public $ee_ueip_optin;
1631
+
1632
+	public $ee_ueip_has_notified;
1633
+
1634
+	/**
1635
+	 * Not to be confused with the 4 critical page variables (See
1636
+	 * get_critical_pages_array()), this is just an array of wp posts that have EE
1637
+	 * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode
1638
+	 * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array.
1639
+	 *
1640
+	 * @var array
1641
+	 */
1642
+	public $post_shortcodes;
1643
+
1644
+	public $module_route_map;
1645
+
1646
+	public $module_forward_map;
1647
+
1648
+	public $module_view_map;
1649
+
1650
+	/**
1651
+	 * The next 4 vars are the IDs of critical EE pages.
1652
+	 *
1653
+	 * @var int
1654
+	 */
1655
+	public $reg_page_id;
1656
+
1657
+	public $txn_page_id;
1658
+
1659
+	public $thank_you_page_id;
1660
+
1661
+	public $cancel_page_id;
1662
+
1663
+	/**
1664
+	 * The next 4 vars are the URLs of critical EE pages.
1665
+	 *
1666
+	 * @var int
1667
+	 */
1668
+	public $reg_page_url;
1669
+
1670
+	public $txn_page_url;
1671
+
1672
+	public $thank_you_page_url;
1673
+
1674
+	public $cancel_page_url;
1675
+
1676
+	/**
1677
+	 * The next vars relate to the custom slugs for EE CPT routes
1678
+	 */
1679
+	public $event_cpt_slug;
1680
+
1681
+	/**
1682
+	 * This caches the _ee_ueip_option in case this config is reset in the same
1683
+	 * request across blog switches in a multisite context.
1684
+	 * Avoids extra queries to the db for this option.
1685
+	 *
1686
+	 * @var bool
1687
+	 */
1688
+	public static $ee_ueip_option;
1689
+
1690
+
1691
+	/**
1692
+	 *    class constructor
1693
+	 *
1694
+	 * @access    public
1695
+	 */
1696
+	public function __construct()
1697
+	{
1698
+		// set default organization settings
1699
+		$this->current_blog_id = get_current_blog_id();
1700
+		$this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id;
1701
+		$this->ee_ueip_optin = $this->_get_main_ee_ueip_optin();
1702
+		$this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1703
+		$this->post_shortcodes = array();
1704
+		$this->module_route_map = array();
1705
+		$this->module_forward_map = array();
1706
+		$this->module_view_map = array();
1707
+		// critical EE page IDs
1708
+		$this->reg_page_id = 0;
1709
+		$this->txn_page_id = 0;
1710
+		$this->thank_you_page_id = 0;
1711
+		$this->cancel_page_id = 0;
1712
+		// critical EE page URLs
1713
+		$this->reg_page_url = '';
1714
+		$this->txn_page_url = '';
1715
+		$this->thank_you_page_url = '';
1716
+		$this->cancel_page_url = '';
1717
+		// cpt slugs
1718
+		$this->event_cpt_slug = esc_html__('events', 'event_espresso');
1719
+		// ueip constant check
1720
+		if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1721
+			$this->ee_ueip_optin = false;
1722
+			$this->ee_ueip_has_notified = true;
1723
+		}
1724
+	}
1725
+
1726
+
1727
+	/**
1728
+	 * @return array
1729
+	 */
1730
+	public function get_critical_pages_array()
1731
+	{
1732
+		return array(
1733
+			$this->reg_page_id,
1734
+			$this->txn_page_id,
1735
+			$this->thank_you_page_id,
1736
+			$this->cancel_page_id,
1737
+		);
1738
+	}
1739
+
1740
+
1741
+	/**
1742
+	 * @return array
1743
+	 */
1744
+	public function get_critical_pages_shortcodes_array()
1745
+	{
1746
+		return array(
1747
+			$this->reg_page_id       => 'ESPRESSO_CHECKOUT',
1748
+			$this->txn_page_id       => 'ESPRESSO_TXN_PAGE',
1749
+			$this->thank_you_page_id => 'ESPRESSO_THANK_YOU',
1750
+			$this->cancel_page_id    => 'ESPRESSO_CANCELLED',
1751
+		);
1752
+	}
1753
+
1754
+
1755
+	/**
1756
+	 *  gets/returns URL for EE reg_page
1757
+	 *
1758
+	 * @access    public
1759
+	 * @return    string
1760
+	 */
1761
+	public function reg_page_url()
1762
+	{
1763
+		if (! $this->reg_page_url) {
1764
+			$this->reg_page_url = add_query_arg(
1765
+				array('uts' => time()),
1766
+				get_permalink($this->reg_page_id)
1767
+			) . '#checkout';
1768
+		}
1769
+		return $this->reg_page_url;
1770
+	}
1771
+
1772
+
1773
+	/**
1774
+	 *  gets/returns URL for EE txn_page
1775
+	 *
1776
+	 * @param array $query_args like what gets passed to
1777
+	 *                          add_query_arg() as the first argument
1778
+	 * @access    public
1779
+	 * @return    string
1780
+	 */
1781
+	public function txn_page_url($query_args = array())
1782
+	{
1783
+		if (! $this->txn_page_url) {
1784
+			$this->txn_page_url = get_permalink($this->txn_page_id);
1785
+		}
1786
+		if ($query_args) {
1787
+			return add_query_arg($query_args, $this->txn_page_url);
1788
+		} else {
1789
+			return $this->txn_page_url;
1790
+		}
1791
+	}
1792
+
1793
+
1794
+	/**
1795
+	 *  gets/returns URL for EE thank_you_page
1796
+	 *
1797
+	 * @param array $query_args like what gets passed to
1798
+	 *                          add_query_arg() as the first argument
1799
+	 * @access    public
1800
+	 * @return    string
1801
+	 */
1802
+	public function thank_you_page_url($query_args = array())
1803
+	{
1804
+		if (! $this->thank_you_page_url) {
1805
+			$this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1806
+		}
1807
+		if ($query_args) {
1808
+			return add_query_arg($query_args, $this->thank_you_page_url);
1809
+		} else {
1810
+			return $this->thank_you_page_url;
1811
+		}
1812
+	}
1813
+
1814
+
1815
+	/**
1816
+	 *  gets/returns URL for EE cancel_page
1817
+	 *
1818
+	 * @access    public
1819
+	 * @return    string
1820
+	 */
1821
+	public function cancel_page_url()
1822
+	{
1823
+		if (! $this->cancel_page_url) {
1824
+			$this->cancel_page_url = get_permalink($this->cancel_page_id);
1825
+		}
1826
+		return $this->cancel_page_url;
1827
+	}
1828
+
1829
+
1830
+	/**
1831
+	 * Resets all critical page urls to their original state.  Used primarily by the __sleep() magic method currently.
1832
+	 *
1833
+	 * @since 4.7.5
1834
+	 */
1835
+	protected function _reset_urls()
1836
+	{
1837
+		$this->reg_page_url = '';
1838
+		$this->txn_page_url = '';
1839
+		$this->cancel_page_url = '';
1840
+		$this->thank_you_page_url = '';
1841
+	}
1842
+
1843
+
1844
+	/**
1845
+	 * Used to return what the optin value is set for the EE User Experience Program.
1846
+	 * This accounts for multisite and this value being requested for a subsite.  In multisite, the value is set
1847
+	 * on the main site only.
1848
+	 *
1849
+	 * @return bool
1850
+	 */
1851
+	protected function _get_main_ee_ueip_optin()
1852
+	{
1853
+		// if this is the main site then we can just bypass our direct query.
1854
+		if (is_main_site()) {
1855
+			return get_option(self::OPTION_NAME_UXIP, false);
1856
+		}
1857
+		// is this already cached for this request?  If so use it.
1858
+		if (EE_Core_Config::$ee_ueip_option !== null) {
1859
+			return EE_Core_Config::$ee_ueip_option;
1860
+		}
1861
+		global $wpdb;
1862
+		$current_network_main_site = is_multisite() ? get_current_site() : null;
1863
+		$current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1864
+		$option = self::OPTION_NAME_UXIP;
1865
+		// set correct table for query
1866
+		$table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1867
+		// rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1868
+		// get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1869
+		// re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1870
+		// this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1871
+		// for the purpose of caching.
1872
+		$pre = apply_filters('pre_option_' . $option, false, $option);
1873
+		if (false !== $pre) {
1874
+			EE_Core_Config::$ee_ueip_option = $pre;
1875
+			return EE_Core_Config::$ee_ueip_option;
1876
+		}
1877
+		$row = $wpdb->get_row(
1878
+			$wpdb->prepare(
1879
+				"SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1",
1880
+				$option
1881
+			)
1882
+		);
1883
+		if (is_object($row)) {
1884
+			$value = $row->option_value;
1885
+		} else { // option does not exist so use default.
1886
+			EE_Core_Config::$ee_ueip_option =  apply_filters('default_option_' . $option, false, $option);
1887
+			return EE_Core_Config::$ee_ueip_option;
1888
+		}
1889
+		EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1890
+		return EE_Core_Config::$ee_ueip_option;
1891
+	}
1892
+
1893
+
1894
+	/**
1895
+	 * Utility function for escaping the value of a property and returning.
1896
+	 *
1897
+	 * @param string $property property name (checks to see if exists).
1898
+	 * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1899
+	 * @throws EE_Error
1900
+	 */
1901
+	public function get_pretty($property)
1902
+	{
1903
+		if ($property === self::OPTION_NAME_UXIP) {
1904
+			return $this->ee_ueip_optin ? 'yes' : 'no';
1905
+		}
1906
+		return parent::get_pretty($property);
1907
+	}
1908
+
1909
+
1910
+	/**
1911
+	 * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values
1912
+	 * on the object.
1913
+	 *
1914
+	 * @return array
1915
+	 */
1916
+	public function __sleep()
1917
+	{
1918
+		// reset all url properties
1919
+		$this->_reset_urls();
1920
+		// return what to save to db
1921
+		return array_keys(get_object_vars($this));
1922
+	}
1923
+}
2353 1924
 
2354
-    /**
2355
-     * array of form names protected by ReCaptcha
2356
-     *
2357
-     * @var array $recaptcha_protected_forms
2358
-     */
2359
-    public $recaptcha_protected_forms;
1925
+/**
1926
+ * Config class for storing info on the Organization
1927
+ */
1928
+class EE_Organization_Config extends EE_Config_Base
1929
+{
2360 1930
 
2361
-    /**
2362
-     * ReCaptcha width
2363
-     *
2364
-     * @var int $recaptcha_width
2365
-     * @deprecated
2366
-     */
2367
-    public $recaptcha_width;
1931
+	/**
1932
+	 * @var string $name
1933
+	 * eg EE4.1
1934
+	 */
1935
+	public $name;
1936
+
1937
+	/**
1938
+	 * @var string $address_1
1939
+	 * eg 123 Onna Road
1940
+	 */
1941
+	public $address_1 = '';
1942
+
1943
+	/**
1944
+	 * @var string $address_2
1945
+	 * eg PO Box 123
1946
+	 */
1947
+	public $address_2 = '';
1948
+
1949
+	/**
1950
+	 * @var string $city
1951
+	 * eg Inna City
1952
+	 */
1953
+	public $city = '';
1954
+
1955
+	/**
1956
+	 * @var int $STA_ID
1957
+	 * eg 4
1958
+	 */
1959
+	public $STA_ID = 0;
1960
+
1961
+	/**
1962
+	 * @var string $CNT_ISO
1963
+	 * eg US
1964
+	 */
1965
+	public $CNT_ISO = '';
1966
+
1967
+	/**
1968
+	 * @var string $zip
1969
+	 * eg 12345  or V1A 2B3
1970
+	 */
1971
+	public $zip = '';
1972
+
1973
+	/**
1974
+	 * @var string $email
1975
+	 * eg [email protected]
1976
+	 */
1977
+	public $email;
1978
+
1979
+	/**
1980
+	 * @var string $phone
1981
+	 * eg. 111-111-1111
1982
+	 */
1983
+	public $phone = '';
1984
+
1985
+	/**
1986
+	 * @var string $vat
1987
+	 * VAT/Tax Number
1988
+	 */
1989
+	public $vat = '';
1990
+
1991
+	/**
1992
+	 * @var string $logo_url
1993
+	 * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg
1994
+	 */
1995
+	public $logo_url = '';
1996
+
1997
+	/**
1998
+	 * The below are all various properties for holding links to organization social network profiles
1999
+	 *
2000
+	 * @var string
2001
+	 */
2002
+	/**
2003
+	 * facebook (facebook.com/profile.name)
2004
+	 *
2005
+	 * @var string
2006
+	 */
2007
+	public $facebook = '';
2008
+
2009
+	/**
2010
+	 * twitter (twitter.com/twitter_handle)
2011
+	 *
2012
+	 * @var string
2013
+	 */
2014
+	public $twitter = '';
2015
+
2016
+	/**
2017
+	 * linkedin (linkedin.com/in/profile_name)
2018
+	 *
2019
+	 * @var string
2020
+	 */
2021
+	public $linkedin = '';
2022
+
2023
+	/**
2024
+	 * pinterest (www.pinterest.com/profile_name)
2025
+	 *
2026
+	 * @var string
2027
+	 */
2028
+	public $pinterest = '';
2029
+
2030
+	/**
2031
+	 * google+ (google.com/+profileName)
2032
+	 *
2033
+	 * @var string
2034
+	 */
2035
+	public $google = '';
2036
+
2037
+	/**
2038
+	 * instagram (instagram.com/handle)
2039
+	 *
2040
+	 * @var string
2041
+	 */
2042
+	public $instagram = '';
2043
+
2044
+
2045
+	/**
2046
+	 *    class constructor
2047
+	 *
2048
+	 * @access    public
2049
+	 */
2050
+	public function __construct()
2051
+	{
2052
+		// set default organization settings
2053
+		// decode HTML entities from the WP blogname, because it's stored in the DB with HTML entities encoded
2054
+		$this->name = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES);
2055
+		$this->email = get_bloginfo('admin_email');
2056
+	}
2057
+}
2368 2058
 
2369
-    /**
2370
-     * Whether or not invalid attempts to directly access the registration checkout page should be tracked.
2371
-     *
2372
-     * @var boolean $track_invalid_checkout_access
2373
-     */
2374
-    protected $track_invalid_checkout_access = true;
2059
+/**
2060
+ * Class for defining what's in the EE_Config relating to currency
2061
+ */
2062
+class EE_Currency_Config extends EE_Config_Base
2063
+{
2375 2064
 
2376
-    /**
2377
-     * Whether or not to show the privacy policy consent checkbox
2378
-     *
2379
-     * @var bool
2380
-     */
2381
-    public $consent_checkbox_enabled;
2065
+	/**
2066
+	 * @var string $code
2067
+	 * eg 'US'
2068
+	 */
2069
+	public $code;
2070
+
2071
+	/**
2072
+	 * @var string $name
2073
+	 * eg 'Dollar'
2074
+	 */
2075
+	public $name;
2076
+
2077
+	/**
2078
+	 * plural name
2079
+	 *
2080
+	 * @var string $plural
2081
+	 * eg 'Dollars'
2082
+	 */
2083
+	public $plural;
2084
+
2085
+	/**
2086
+	 * currency sign
2087
+	 *
2088
+	 * @var string $sign
2089
+	 * eg '$'
2090
+	 */
2091
+	public $sign;
2092
+
2093
+	/**
2094
+	 * Whether the currency sign should come before the number or not
2095
+	 *
2096
+	 * @var boolean $sign_b4
2097
+	 */
2098
+	public $sign_b4;
2099
+
2100
+	/**
2101
+	 * How many digits should come after the decimal place
2102
+	 *
2103
+	 * @var int $dec_plc
2104
+	 */
2105
+	public $dec_plc;
2106
+
2107
+	/**
2108
+	 * Symbol to use for decimal mark
2109
+	 *
2110
+	 * @var string $dec_mrk
2111
+	 * eg '.'
2112
+	 */
2113
+	public $dec_mrk;
2114
+
2115
+	/**
2116
+	 * Symbol to use for thousands
2117
+	 *
2118
+	 * @var string $thsnds
2119
+	 * eg ','
2120
+	 */
2121
+	public $thsnds;
2122
+
2123
+
2124
+	/**
2125
+	 *    class constructor
2126
+	 *
2127
+	 * @access    public
2128
+	 * @param string $CNT_ISO
2129
+	 * @throws EE_Error
2130
+	 * @throws ReflectionException
2131
+	 */
2132
+	public function __construct($CNT_ISO = '')
2133
+	{
2134
+		if ($CNT_ISO && $CNT_ISO === $this->code) {
2135
+			return;
2136
+		}
2137
+		// get country code from organization settings or use default
2138
+		$ORG_CNT = isset(EE_Registry::instance()->CFG->organization)
2139
+				   && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
2140
+			? EE_Registry::instance()->CFG->organization->CNT_ISO
2141
+			: '';
2142
+		// but override if requested
2143
+		$CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2144
+		// so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists
2145
+		$this->setCurrency($CNT_ISO);
2146
+		// fallback to hardcoded defaults, in case the above failed
2147
+		if (empty($this->code)) {
2148
+			$this->setFallbackCurrency();
2149
+		}
2150
+	}
2151
+
2152
+
2153
+	/**
2154
+	 * @param string|null $CNT_ISO
2155
+	 * @throws EE_Error
2156
+	 * @throws ReflectionException
2157
+	 */
2158
+	public function setCurrency(?string $CNT_ISO = '')
2159
+	{
2160
+		if (empty($CNT_ISO) || ! EE_Maintenance_Mode::instance()->models_can_query()){
2161
+			return;
2162
+		}
2163
+
2164
+		/** @var TableAnalysis $table_analysis */
2165
+		$table_analysis = EE_Registry::instance()->create('TableAnalysis', [], true);
2166
+		if (! $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())) {
2167
+			return;
2168
+		}
2169
+		// retrieve the country settings from the db, just in case they have been customized
2170
+		$country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2171
+		if (! $country instanceof EE_Country) {
2172
+			throw new DomainException(
2173
+				esc_html__('Invalid Country ISO Code.', 'event_espresso')
2174
+			);
2175
+		}
2176
+		$this->code    = $country->currency_code();                  // currency code: USD, CAD, EUR
2177
+		$this->name    = $country->currency_name_single();           // Dollar
2178
+		$this->plural  = $country->currency_name_plural();           // Dollars
2179
+		$this->sign    = $country->currency_sign();                  // currency sign: $
2180
+		$this->sign_b4 = $country->currency_sign_before();           // currency sign before or after
2181
+		$this->dec_plc = $country->currency_decimal_places();        // decimal places: 2 = 0.00  3 = 0.000
2182
+		$this->dec_mrk = $country->currency_decimal_mark();          // decimal mark: ',' = 0,01 or '.' = 0.01
2183
+		$this->thsnds  = $country->currency_thousands_separator();   // thousands sep: ',' = 1,000 or '.' = 1.000
2184
+	}
2185
+
2186
+
2187
+	private function setFallbackCurrency()
2188
+	{
2189
+		// set default currency settings
2190
+		$this->code    = 'USD';
2191
+		$this->name    = esc_html__('Dollar', 'event_espresso');
2192
+		$this->plural  = esc_html__('Dollars', 'event_espresso');
2193
+		$this->sign    = '$';
2194
+		$this->sign_b4 = true;
2195
+		$this->dec_plc = 2;
2196
+		$this->dec_mrk = '.';
2197
+		$this->thsnds  = ',';
2198
+	}
2199
+
2200
+
2201
+	/**
2202
+	 * @param string|null $CNT_ISO
2203
+	 * @return EE_Currency_Config
2204
+	 * @throws EE_Error
2205
+	 * @throws ReflectionException
2206
+	 */
2207
+	public static function getCurrencyConfig(?string $CNT_ISO = ''): EE_Currency_Config
2208
+	{
2209
+		// if CNT_ISO passed lets try to get currency settings for it.
2210
+		$currency_config = ! empty($CNT_ISO)
2211
+			? new EE_Currency_Config($CNT_ISO)
2212
+			: null;
2213
+		// default currency settings for site if not set
2214
+		if ($currency_config instanceof EE_Currency_Config) {
2215
+			return $currency_config;
2216
+		}
2217
+		EE_Config::instance()->currency = EE_Config::instance()->currency instanceof EE_Currency_Config
2218
+			? EE_Config::instance()->currency
2219
+			: new EE_Currency_Config();
2220
+		return EE_Config::instance()->currency;
2221
+	}
2222
+}
2382 2223
 
2383
-    /**
2384
-     * Label text to show on the checkbox
2385
-     *
2386
-     * @var string
2387
-     */
2388
-    public $consent_checkbox_label_text;
2224
+/**
2225
+ * Class for defining what's in the EE_Config relating to registration settings
2226
+ */
2227
+class EE_Registration_Config extends EE_Config_Base
2228
+{
2389 2229
 
2390
-    /*
2230
+	/**
2231
+	 * Default registration status
2232
+	 *
2233
+	 * @var string $default_STS_ID
2234
+	 * eg 'RPP'
2235
+	 */
2236
+	public $default_STS_ID;
2237
+
2238
+	/**
2239
+	 * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of
2240
+	 * registrations)
2241
+	 *
2242
+	 * @var int
2243
+	 */
2244
+	public $default_maximum_number_of_tickets;
2245
+
2246
+	/**
2247
+	 * level of validation to apply to email addresses
2248
+	 *
2249
+	 * @var string $email_validation_level
2250
+	 * options: 'basic', 'wp_default', 'i18n', 'i18n_dns'
2251
+	 */
2252
+	public $email_validation_level;
2253
+
2254
+	/**
2255
+	 *    whether or not to show alternate payment options during the reg process if payment status is pending
2256
+	 *
2257
+	 * @var boolean $show_pending_payment_options
2258
+	 */
2259
+	public $show_pending_payment_options;
2260
+
2261
+	/**
2262
+	 * Whether to skip the registration confirmation page
2263
+	 *
2264
+	 * @var boolean $skip_reg_confirmation
2265
+	 */
2266
+	public $skip_reg_confirmation;
2267
+
2268
+	/**
2269
+	 * an array of SPCO reg steps where:
2270
+	 *        the keys denotes the reg step order
2271
+	 *        each element consists of an array with the following elements:
2272
+	 *            "file_path" => the file path to the EE_SPCO_Reg_Step class
2273
+	 *            "class_name" => the specific EE_SPCO_Reg_Step child class name
2274
+	 *            "slug" => the URL param used to trigger the reg step
2275
+	 *
2276
+	 * @var array $reg_steps
2277
+	 */
2278
+	public $reg_steps;
2279
+
2280
+	/**
2281
+	 * Whether registration confirmation should be the last page of SPCO
2282
+	 *
2283
+	 * @var boolean $reg_confirmation_last
2284
+	 */
2285
+	public $reg_confirmation_last;
2286
+
2287
+	/**
2288
+	 * Whether or not to enable the EE Bot Trap
2289
+	 *
2290
+	 * @var boolean $use_bot_trap
2291
+	 */
2292
+	public $use_bot_trap;
2293
+
2294
+	/**
2295
+	 * Whether or not to encrypt some data sent by the EE Bot Trap
2296
+	 *
2297
+	 * @var boolean $use_encryption
2298
+	 */
2299
+	public $use_encryption;
2300
+
2301
+	/**
2302
+	 * Whether or not to use ReCaptcha
2303
+	 *
2304
+	 * @var boolean $use_captcha
2305
+	 */
2306
+	public $use_captcha;
2307
+
2308
+	/**
2309
+	 * ReCaptcha Theme
2310
+	 *
2311
+	 * @var string $recaptcha_theme
2312
+	 *    options: 'dark', 'light', 'invisible'
2313
+	 */
2314
+	public $recaptcha_theme;
2315
+
2316
+	/**
2317
+	 * ReCaptcha Badge - determines the position of the reCAPTCHA badge if using Invisible ReCaptcha.
2318
+	 *
2319
+	 * @var string $recaptcha_badge
2320
+	 *    options: 'bottomright', 'bottomleft', 'inline'
2321
+	 */
2322
+	public $recaptcha_badge;
2323
+
2324
+	/**
2325
+	 * ReCaptcha Type
2326
+	 *
2327
+	 * @var string $recaptcha_type
2328
+	 *    options: 'audio', 'image'
2329
+	 */
2330
+	public $recaptcha_type;
2331
+
2332
+	/**
2333
+	 * ReCaptcha language
2334
+	 *
2335
+	 * @var string $recaptcha_language
2336
+	 * eg 'en'
2337
+	 */
2338
+	public $recaptcha_language;
2339
+
2340
+	/**
2341
+	 * ReCaptcha public key
2342
+	 *
2343
+	 * @var string $recaptcha_publickey
2344
+	 */
2345
+	public $recaptcha_publickey;
2346
+
2347
+	/**
2348
+	 * ReCaptcha private key
2349
+	 *
2350
+	 * @var string $recaptcha_privatekey
2351
+	 */
2352
+	public $recaptcha_privatekey;
2353
+
2354
+	/**
2355
+	 * array of form names protected by ReCaptcha
2356
+	 *
2357
+	 * @var array $recaptcha_protected_forms
2358
+	 */
2359
+	public $recaptcha_protected_forms;
2360
+
2361
+	/**
2362
+	 * ReCaptcha width
2363
+	 *
2364
+	 * @var int $recaptcha_width
2365
+	 * @deprecated
2366
+	 */
2367
+	public $recaptcha_width;
2368
+
2369
+	/**
2370
+	 * Whether or not invalid attempts to directly access the registration checkout page should be tracked.
2371
+	 *
2372
+	 * @var boolean $track_invalid_checkout_access
2373
+	 */
2374
+	protected $track_invalid_checkout_access = true;
2375
+
2376
+	/**
2377
+	 * Whether or not to show the privacy policy consent checkbox
2378
+	 *
2379
+	 * @var bool
2380
+	 */
2381
+	public $consent_checkbox_enabled;
2382
+
2383
+	/**
2384
+	 * Label text to show on the checkbox
2385
+	 *
2386
+	 * @var string
2387
+	 */
2388
+	public $consent_checkbox_label_text;
2389
+
2390
+	/*
2391 2391
      * String describing how long to keep payment logs. Passed into DateTime constructor
2392 2392
      * @var string
2393 2393
      */
2394
-    public $gateway_log_lifespan = '1 week';
2395
-
2396
-    /**
2397
-     * Enable copy attendee info at form
2398
-     *
2399
-     * @var boolean $enable_copy_attendee
2400
-     */
2401
-    protected $copy_attendee_info = true;
2402
-
2403
-
2404
-    /**
2405
-     *    class constructor
2406
-     *
2407
-     * @access    public
2408
-     */
2409
-    public function __construct()
2410
-    {
2411
-        // set default registration settings
2412
-        $this->default_STS_ID = EEM_Registration::status_id_pending_payment;
2413
-        $this->email_validation_level = 'wp_default';
2414
-        $this->show_pending_payment_options = true;
2415
-        $this->skip_reg_confirmation = true;
2416
-        $this->reg_steps = array();
2417
-        $this->reg_confirmation_last = false;
2418
-        $this->use_bot_trap = true;
2419
-        $this->use_encryption = true;
2420
-        $this->use_captcha = false;
2421
-        $this->recaptcha_theme = 'light';
2422
-        $this->recaptcha_badge = 'bottomleft';
2423
-        $this->recaptcha_type = 'image';
2424
-        $this->recaptcha_language = 'en';
2425
-        $this->recaptcha_publickey = null;
2426
-        $this->recaptcha_privatekey = null;
2427
-        $this->recaptcha_protected_forms = array();
2428
-        $this->recaptcha_width = 500;
2429
-        $this->default_maximum_number_of_tickets = 10;
2430
-        $this->consent_checkbox_enabled = false;
2431
-        $this->consent_checkbox_label_text = '';
2432
-        $this->gateway_log_lifespan = '7 days';
2433
-        $this->copy_attendee_info = true;
2434
-    }
2435
-
2436
-
2437
-    /**
2438
-     * This is called by the config loader and hooks are initialized AFTER the config has been populated.
2439
-     *
2440
-     * @since 4.8.8.rc.019
2441
-     */
2442
-    public function do_hooks()
2443
-    {
2444
-        add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2445
-        add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event'));
2446
-        add_action('setup_theme', array($this, 'setDefaultCheckboxLabelText'));
2447
-    }
2448
-
2449
-
2450
-    /**
2451
-     * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the
2452
-     * EVT_default_registration_status field matches the config setting for default_STS_ID.
2453
-     */
2454
-    public function set_default_reg_status_on_EEM_Event()
2455
-    {
2456
-        EEM_Event::set_default_reg_status($this->default_STS_ID);
2457
-    }
2458
-
2459
-
2460
-    /**
2461
-     * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field
2462
-     * for Events matches the config setting for default_maximum_number_of_tickets
2463
-     */
2464
-    public function set_default_max_ticket_on_EEM_Event()
2465
-    {
2466
-        EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets);
2467
-    }
2468
-
2469
-
2470
-    /**
2471
-     * Sets the default consent checkbox text. This needs to be done a bit later than when EE_Registration_Config is
2472
-     * constructed because that happens before we can get the privacy policy page's permalink.
2473
-     *
2474
-     * @throws InvalidArgumentException
2475
-     * @throws InvalidDataTypeException
2476
-     * @throws InvalidInterfaceException
2477
-     */
2478
-    public function setDefaultCheckboxLabelText()
2479
-    {
2480
-        if (
2481
-            $this->getConsentCheckboxLabelText() === null
2482
-            || $this->getConsentCheckboxLabelText() === ''
2483
-        ) {
2484
-            $opening_a_tag = '';
2485
-            $closing_a_tag = '';
2486
-            if (function_exists('get_privacy_policy_url')) {
2487
-                $privacy_page_url = get_privacy_policy_url();
2488
-                if (! empty($privacy_page_url)) {
2489
-                    $opening_a_tag = '<a href="' . $privacy_page_url . '" target="_blank">';
2490
-                    $closing_a_tag = '</a>';
2491
-                }
2492
-            }
2493
-            $loader = LoaderFactory::getLoader();
2494
-            $org_config = $loader->getShared('EE_Organization_Config');
2495
-            /**
2496
-             * @var $org_config EE_Organization_Config
2497
-             */
2498
-
2499
-            $this->setConsentCheckboxLabelText(
2500
-                sprintf(
2501
-                    esc_html__(
2502
-                        'I consent to %1$s storing and using my personal information, according to their %2$sprivacy policy%3$s.',
2503
-                        'event_espresso'
2504
-                    ),
2505
-                    $org_config->name,
2506
-                    $opening_a_tag,
2507
-                    $closing_a_tag
2508
-                )
2509
-            );
2510
-        }
2511
-    }
2512
-
2513
-
2514
-    /**
2515
-     * @return boolean
2516
-     */
2517
-    public function track_invalid_checkout_access()
2518
-    {
2519
-        return $this->track_invalid_checkout_access;
2520
-    }
2521
-
2522
-
2523
-    /**
2524
-     * @param boolean $track_invalid_checkout_access
2525
-     */
2526
-    public function set_track_invalid_checkout_access($track_invalid_checkout_access)
2527
-    {
2528
-        $this->track_invalid_checkout_access = filter_var(
2529
-            $track_invalid_checkout_access,
2530
-            FILTER_VALIDATE_BOOLEAN
2531
-        );
2532
-    }
2533
-
2534
-    /**
2535
-     * @return boolean
2536
-     */
2537
-    public function copyAttendeeInfo()
2538
-    {
2539
-        return $this->copy_attendee_info;
2540
-    }
2541
-
2542
-
2543
-    /**
2544
-     * @param boolean $copy_attendee_info
2545
-     */
2546
-    public function setCopyAttendeeInfo($copy_attendee_info)
2547
-    {
2548
-        $this->copy_attendee_info = filter_var(
2549
-            $copy_attendee_info,
2550
-            FILTER_VALIDATE_BOOLEAN
2551
-        );
2552
-    }
2553
-
2554
-
2555
-    /**
2556
-     * Gets the options to make availalbe for the gateway log lifespan
2557
-     * @return array
2558
-     */
2559
-    public function gatewayLogLifespanOptions()
2560
-    {
2561
-        return (array) apply_filters(
2562
-            'FHEE_EE_Admin_Config__gatewayLogLifespanOptions',
2563
-            array(
2564
-                '1 second' => esc_html__('Don\'t Log At All', 'event_espresso'),
2565
-                '1 day' => esc_html__('1 Day', 'event_espresso'),
2566
-                '7 days' => esc_html__('7 Days', 'event_espresso'),
2567
-                '14 days' => esc_html__('14 Days', 'event_espresso'),
2568
-                '30 days' => esc_html__('30 Days', 'event_espresso')
2569
-            )
2570
-        );
2571
-    }
2572
-
2573
-
2574
-    /**
2575
-     * @return bool
2576
-     */
2577
-    public function isConsentCheckboxEnabled()
2578
-    {
2579
-        return $this->consent_checkbox_enabled;
2580
-    }
2581
-
2582
-
2583
-    /**
2584
-     * @param bool $consent_checkbox_enabled
2585
-     */
2586
-    public function setConsentCheckboxEnabled($consent_checkbox_enabled)
2587
-    {
2588
-        $this->consent_checkbox_enabled = filter_var(
2589
-            $consent_checkbox_enabled,
2590
-            FILTER_VALIDATE_BOOLEAN
2591
-        );
2592
-    }
2593
-
2594
-
2595
-    /**
2596
-     * @return string
2597
-     */
2598
-    public function getConsentCheckboxLabelText()
2599
-    {
2600
-        return $this->consent_checkbox_label_text;
2601
-    }
2602
-
2603
-
2604
-    /**
2605
-     * @param string $consent_checkbox_label_text
2606
-     */
2607
-    public function setConsentCheckboxLabelText($consent_checkbox_label_text)
2608
-    {
2609
-        $this->consent_checkbox_label_text = (string) $consent_checkbox_label_text;
2610
-    }
2394
+	public $gateway_log_lifespan = '1 week';
2395
+
2396
+	/**
2397
+	 * Enable copy attendee info at form
2398
+	 *
2399
+	 * @var boolean $enable_copy_attendee
2400
+	 */
2401
+	protected $copy_attendee_info = true;
2402
+
2403
+
2404
+	/**
2405
+	 *    class constructor
2406
+	 *
2407
+	 * @access    public
2408
+	 */
2409
+	public function __construct()
2410
+	{
2411
+		// set default registration settings
2412
+		$this->default_STS_ID = EEM_Registration::status_id_pending_payment;
2413
+		$this->email_validation_level = 'wp_default';
2414
+		$this->show_pending_payment_options = true;
2415
+		$this->skip_reg_confirmation = true;
2416
+		$this->reg_steps = array();
2417
+		$this->reg_confirmation_last = false;
2418
+		$this->use_bot_trap = true;
2419
+		$this->use_encryption = true;
2420
+		$this->use_captcha = false;
2421
+		$this->recaptcha_theme = 'light';
2422
+		$this->recaptcha_badge = 'bottomleft';
2423
+		$this->recaptcha_type = 'image';
2424
+		$this->recaptcha_language = 'en';
2425
+		$this->recaptcha_publickey = null;
2426
+		$this->recaptcha_privatekey = null;
2427
+		$this->recaptcha_protected_forms = array();
2428
+		$this->recaptcha_width = 500;
2429
+		$this->default_maximum_number_of_tickets = 10;
2430
+		$this->consent_checkbox_enabled = false;
2431
+		$this->consent_checkbox_label_text = '';
2432
+		$this->gateway_log_lifespan = '7 days';
2433
+		$this->copy_attendee_info = true;
2434
+	}
2435
+
2436
+
2437
+	/**
2438
+	 * This is called by the config loader and hooks are initialized AFTER the config has been populated.
2439
+	 *
2440
+	 * @since 4.8.8.rc.019
2441
+	 */
2442
+	public function do_hooks()
2443
+	{
2444
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2445
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event'));
2446
+		add_action('setup_theme', array($this, 'setDefaultCheckboxLabelText'));
2447
+	}
2448
+
2449
+
2450
+	/**
2451
+	 * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the
2452
+	 * EVT_default_registration_status field matches the config setting for default_STS_ID.
2453
+	 */
2454
+	public function set_default_reg_status_on_EEM_Event()
2455
+	{
2456
+		EEM_Event::set_default_reg_status($this->default_STS_ID);
2457
+	}
2458
+
2459
+
2460
+	/**
2461
+	 * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field
2462
+	 * for Events matches the config setting for default_maximum_number_of_tickets
2463
+	 */
2464
+	public function set_default_max_ticket_on_EEM_Event()
2465
+	{
2466
+		EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets);
2467
+	}
2468
+
2469
+
2470
+	/**
2471
+	 * Sets the default consent checkbox text. This needs to be done a bit later than when EE_Registration_Config is
2472
+	 * constructed because that happens before we can get the privacy policy page's permalink.
2473
+	 *
2474
+	 * @throws InvalidArgumentException
2475
+	 * @throws InvalidDataTypeException
2476
+	 * @throws InvalidInterfaceException
2477
+	 */
2478
+	public function setDefaultCheckboxLabelText()
2479
+	{
2480
+		if (
2481
+			$this->getConsentCheckboxLabelText() === null
2482
+			|| $this->getConsentCheckboxLabelText() === ''
2483
+		) {
2484
+			$opening_a_tag = '';
2485
+			$closing_a_tag = '';
2486
+			if (function_exists('get_privacy_policy_url')) {
2487
+				$privacy_page_url = get_privacy_policy_url();
2488
+				if (! empty($privacy_page_url)) {
2489
+					$opening_a_tag = '<a href="' . $privacy_page_url . '" target="_blank">';
2490
+					$closing_a_tag = '</a>';
2491
+				}
2492
+			}
2493
+			$loader = LoaderFactory::getLoader();
2494
+			$org_config = $loader->getShared('EE_Organization_Config');
2495
+			/**
2496
+			 * @var $org_config EE_Organization_Config
2497
+			 */
2498
+
2499
+			$this->setConsentCheckboxLabelText(
2500
+				sprintf(
2501
+					esc_html__(
2502
+						'I consent to %1$s storing and using my personal information, according to their %2$sprivacy policy%3$s.',
2503
+						'event_espresso'
2504
+					),
2505
+					$org_config->name,
2506
+					$opening_a_tag,
2507
+					$closing_a_tag
2508
+				)
2509
+			);
2510
+		}
2511
+	}
2512
+
2513
+
2514
+	/**
2515
+	 * @return boolean
2516
+	 */
2517
+	public function track_invalid_checkout_access()
2518
+	{
2519
+		return $this->track_invalid_checkout_access;
2520
+	}
2521
+
2522
+
2523
+	/**
2524
+	 * @param boolean $track_invalid_checkout_access
2525
+	 */
2526
+	public function set_track_invalid_checkout_access($track_invalid_checkout_access)
2527
+	{
2528
+		$this->track_invalid_checkout_access = filter_var(
2529
+			$track_invalid_checkout_access,
2530
+			FILTER_VALIDATE_BOOLEAN
2531
+		);
2532
+	}
2533
+
2534
+	/**
2535
+	 * @return boolean
2536
+	 */
2537
+	public function copyAttendeeInfo()
2538
+	{
2539
+		return $this->copy_attendee_info;
2540
+	}
2541
+
2542
+
2543
+	/**
2544
+	 * @param boolean $copy_attendee_info
2545
+	 */
2546
+	public function setCopyAttendeeInfo($copy_attendee_info)
2547
+	{
2548
+		$this->copy_attendee_info = filter_var(
2549
+			$copy_attendee_info,
2550
+			FILTER_VALIDATE_BOOLEAN
2551
+		);
2552
+	}
2553
+
2554
+
2555
+	/**
2556
+	 * Gets the options to make availalbe for the gateway log lifespan
2557
+	 * @return array
2558
+	 */
2559
+	public function gatewayLogLifespanOptions()
2560
+	{
2561
+		return (array) apply_filters(
2562
+			'FHEE_EE_Admin_Config__gatewayLogLifespanOptions',
2563
+			array(
2564
+				'1 second' => esc_html__('Don\'t Log At All', 'event_espresso'),
2565
+				'1 day' => esc_html__('1 Day', 'event_espresso'),
2566
+				'7 days' => esc_html__('7 Days', 'event_espresso'),
2567
+				'14 days' => esc_html__('14 Days', 'event_espresso'),
2568
+				'30 days' => esc_html__('30 Days', 'event_espresso')
2569
+			)
2570
+		);
2571
+	}
2572
+
2573
+
2574
+	/**
2575
+	 * @return bool
2576
+	 */
2577
+	public function isConsentCheckboxEnabled()
2578
+	{
2579
+		return $this->consent_checkbox_enabled;
2580
+	}
2581
+
2582
+
2583
+	/**
2584
+	 * @param bool $consent_checkbox_enabled
2585
+	 */
2586
+	public function setConsentCheckboxEnabled($consent_checkbox_enabled)
2587
+	{
2588
+		$this->consent_checkbox_enabled = filter_var(
2589
+			$consent_checkbox_enabled,
2590
+			FILTER_VALIDATE_BOOLEAN
2591
+		);
2592
+	}
2593
+
2594
+
2595
+	/**
2596
+	 * @return string
2597
+	 */
2598
+	public function getConsentCheckboxLabelText()
2599
+	{
2600
+		return $this->consent_checkbox_label_text;
2601
+	}
2602
+
2603
+
2604
+	/**
2605
+	 * @param string $consent_checkbox_label_text
2606
+	 */
2607
+	public function setConsentCheckboxLabelText($consent_checkbox_label_text)
2608
+	{
2609
+		$this->consent_checkbox_label_text = (string) $consent_checkbox_label_text;
2610
+	}
2611 2611
 }
2612 2612
 
2613 2613
 /**
@@ -2616,180 +2616,180 @@  discard block
 block discarded – undo
2616 2616
 class EE_Admin_Config extends EE_Config_Base
2617 2617
 {
2618 2618
 
2619
-    /**
2620
-     * @var boolean $useAdvancedEditor
2621
-     */
2622
-    private $useAdvancedEditor;
2623
-
2624
-    /**
2625
-     * @var boolean $use_personnel_manager
2626
-     */
2627
-    public $use_personnel_manager;
2628
-
2629
-    /**
2630
-     * @var boolean $use_dashboard_widget
2631
-     */
2632
-    public $use_dashboard_widget;
2633
-
2634
-    /**
2635
-     * @var int $events_in_dashboard
2636
-     */
2637
-    public $events_in_dashboard;
2638
-
2639
-    /**
2640
-     * @var boolean $use_event_timezones
2641
-     */
2642
-    public $use_event_timezones;
2643
-
2644
-    /**
2645
-     * @var string $log_file_name
2646
-     */
2647
-    public $log_file_name;
2648
-
2649
-    /**
2650
-     * @var string $debug_file_name
2651
-     */
2652
-    public $debug_file_name;
2653
-
2654
-    /**
2655
-     * @var boolean $use_remote_logging
2656
-     */
2657
-    public $use_remote_logging;
2658
-
2659
-    /**
2660
-     * @var string $remote_logging_url
2661
-     */
2662
-    public $remote_logging_url;
2663
-
2664
-    /**
2665
-     * @var boolean $show_reg_footer
2666
-     */
2667
-    public $show_reg_footer;
2668
-
2669
-    /**
2670
-     * @var string $affiliate_id
2671
-     */
2672
-    public $affiliate_id;
2673
-
2674
-    /**
2675
-     * adds extra layer of encoding to session data to prevent serialization errors
2676
-     * but is incompatible with some server configuration errors
2677
-     * if you get "500 internal server errors" during registration, try turning this on
2678
-     * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off
2679
-     *
2680
-     * @var boolean $encode_session_data
2681
-     */
2682
-    private $encode_session_data = false;
2683
-
2684
-    /**
2685
-     * @var boolean
2686
-     */
2687
-    private $is_caffeinated;
2688
-
2689
-
2690
-    /**
2691
-     *    class constructor
2692
-     *
2693
-     * @access    public
2694
-     */
2695
-    public function __construct()
2696
-    {
2697
-        // set default general admin settings
2698
-        $this->useAdvancedEditor = true;
2699
-        $this->use_personnel_manager = true;
2700
-        $this->use_dashboard_widget = true;
2701
-        $this->events_in_dashboard = 30;
2702
-        $this->use_event_timezones = false;
2703
-        $this->use_remote_logging = false;
2704
-        $this->remote_logging_url = null;
2705
-        $this->show_reg_footer = apply_filters(
2706
-            'FHEE__EE_Admin_Config__show_reg_footer__default',
2707
-            false
2708
-        );
2709
-        $this->affiliate_id = 'default';
2710
-        $this->encode_session_data = false;
2711
-    }
2712
-
2713
-
2714
-    /**
2715
-     * @param bool $reset
2716
-     * @return string
2717
-     */
2718
-    public function log_file_name($reset = false)
2719
-    {
2720
-        if (empty($this->log_file_name) || $reset) {
2721
-            $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2722
-            EE_Config::instance()->update_espresso_config(false, false);
2723
-        }
2724
-        return $this->log_file_name;
2725
-    }
2726
-
2727
-
2728
-    /**
2729
-     * @param bool $reset
2730
-     * @return string
2731
-     */
2732
-    public function debug_file_name($reset = false)
2733
-    {
2734
-        if (empty($this->debug_file_name) || $reset) {
2735
-            $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2736
-            EE_Config::instance()->update_espresso_config(false, false);
2737
-        }
2738
-        return $this->debug_file_name;
2739
-    }
2740
-
2741
-
2742
-    /**
2743
-     * @return string
2744
-     */
2745
-    public function affiliate_id()
2746
-    {
2747
-        return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default';
2748
-    }
2749
-
2750
-
2751
-    /**
2752
-     * @return boolean
2753
-     */
2754
-    public function encode_session_data()
2755
-    {
2756
-        return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN);
2757
-    }
2758
-
2759
-
2760
-    /**
2761
-     * @param boolean $encode_session_data
2762
-     */
2763
-    public function set_encode_session_data($encode_session_data)
2764
-    {
2765
-        $this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN);
2766
-    }
2767
-
2768
-    /**
2769
-     * @return boolean
2770
-     */
2771
-    public function useAdvancedEditor()
2772
-    {
2773
-        if ($this->is_caffeinated === null) {
2774
-            $domain = LoaderFactory::getLoader()->getShared('EventEspresso\core\domain\Domain');
2775
-            $this->is_caffeinated = $domain->isCaffeinated();
2776
-        }
2777
-        return $this->useAdvancedEditor && $this->is_caffeinated;
2778
-    }
2779
-
2780
-    /**
2781
-     * @param boolean $use_advanced_editor
2782
-     */
2783
-    public function setUseAdvancedEditor($use_advanced_editor = true)
2784
-    {
2785
-        $this->useAdvancedEditor = filter_var(
2786
-            apply_filters(
2787
-                'FHEE__EE_Admin_Config__setUseAdvancedEditor__use_advanced_editor',
2788
-                $use_advanced_editor
2789
-            ),
2790
-            FILTER_VALIDATE_BOOLEAN
2791
-        );
2792
-    }
2619
+	/**
2620
+	 * @var boolean $useAdvancedEditor
2621
+	 */
2622
+	private $useAdvancedEditor;
2623
+
2624
+	/**
2625
+	 * @var boolean $use_personnel_manager
2626
+	 */
2627
+	public $use_personnel_manager;
2628
+
2629
+	/**
2630
+	 * @var boolean $use_dashboard_widget
2631
+	 */
2632
+	public $use_dashboard_widget;
2633
+
2634
+	/**
2635
+	 * @var int $events_in_dashboard
2636
+	 */
2637
+	public $events_in_dashboard;
2638
+
2639
+	/**
2640
+	 * @var boolean $use_event_timezones
2641
+	 */
2642
+	public $use_event_timezones;
2643
+
2644
+	/**
2645
+	 * @var string $log_file_name
2646
+	 */
2647
+	public $log_file_name;
2648
+
2649
+	/**
2650
+	 * @var string $debug_file_name
2651
+	 */
2652
+	public $debug_file_name;
2653
+
2654
+	/**
2655
+	 * @var boolean $use_remote_logging
2656
+	 */
2657
+	public $use_remote_logging;
2658
+
2659
+	/**
2660
+	 * @var string $remote_logging_url
2661
+	 */
2662
+	public $remote_logging_url;
2663
+
2664
+	/**
2665
+	 * @var boolean $show_reg_footer
2666
+	 */
2667
+	public $show_reg_footer;
2668
+
2669
+	/**
2670
+	 * @var string $affiliate_id
2671
+	 */
2672
+	public $affiliate_id;
2673
+
2674
+	/**
2675
+	 * adds extra layer of encoding to session data to prevent serialization errors
2676
+	 * but is incompatible with some server configuration errors
2677
+	 * if you get "500 internal server errors" during registration, try turning this on
2678
+	 * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off
2679
+	 *
2680
+	 * @var boolean $encode_session_data
2681
+	 */
2682
+	private $encode_session_data = false;
2683
+
2684
+	/**
2685
+	 * @var boolean
2686
+	 */
2687
+	private $is_caffeinated;
2688
+
2689
+
2690
+	/**
2691
+	 *    class constructor
2692
+	 *
2693
+	 * @access    public
2694
+	 */
2695
+	public function __construct()
2696
+	{
2697
+		// set default general admin settings
2698
+		$this->useAdvancedEditor = true;
2699
+		$this->use_personnel_manager = true;
2700
+		$this->use_dashboard_widget = true;
2701
+		$this->events_in_dashboard = 30;
2702
+		$this->use_event_timezones = false;
2703
+		$this->use_remote_logging = false;
2704
+		$this->remote_logging_url = null;
2705
+		$this->show_reg_footer = apply_filters(
2706
+			'FHEE__EE_Admin_Config__show_reg_footer__default',
2707
+			false
2708
+		);
2709
+		$this->affiliate_id = 'default';
2710
+		$this->encode_session_data = false;
2711
+	}
2712
+
2713
+
2714
+	/**
2715
+	 * @param bool $reset
2716
+	 * @return string
2717
+	 */
2718
+	public function log_file_name($reset = false)
2719
+	{
2720
+		if (empty($this->log_file_name) || $reset) {
2721
+			$this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2722
+			EE_Config::instance()->update_espresso_config(false, false);
2723
+		}
2724
+		return $this->log_file_name;
2725
+	}
2726
+
2727
+
2728
+	/**
2729
+	 * @param bool $reset
2730
+	 * @return string
2731
+	 */
2732
+	public function debug_file_name($reset = false)
2733
+	{
2734
+		if (empty($this->debug_file_name) || $reset) {
2735
+			$this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2736
+			EE_Config::instance()->update_espresso_config(false, false);
2737
+		}
2738
+		return $this->debug_file_name;
2739
+	}
2740
+
2741
+
2742
+	/**
2743
+	 * @return string
2744
+	 */
2745
+	public function affiliate_id()
2746
+	{
2747
+		return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default';
2748
+	}
2749
+
2750
+
2751
+	/**
2752
+	 * @return boolean
2753
+	 */
2754
+	public function encode_session_data()
2755
+	{
2756
+		return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN);
2757
+	}
2758
+
2759
+
2760
+	/**
2761
+	 * @param boolean $encode_session_data
2762
+	 */
2763
+	public function set_encode_session_data($encode_session_data)
2764
+	{
2765
+		$this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN);
2766
+	}
2767
+
2768
+	/**
2769
+	 * @return boolean
2770
+	 */
2771
+	public function useAdvancedEditor()
2772
+	{
2773
+		if ($this->is_caffeinated === null) {
2774
+			$domain = LoaderFactory::getLoader()->getShared('EventEspresso\core\domain\Domain');
2775
+			$this->is_caffeinated = $domain->isCaffeinated();
2776
+		}
2777
+		return $this->useAdvancedEditor && $this->is_caffeinated;
2778
+	}
2779
+
2780
+	/**
2781
+	 * @param boolean $use_advanced_editor
2782
+	 */
2783
+	public function setUseAdvancedEditor($use_advanced_editor = true)
2784
+	{
2785
+		$this->useAdvancedEditor = filter_var(
2786
+			apply_filters(
2787
+				'FHEE__EE_Admin_Config__setUseAdvancedEditor__use_advanced_editor',
2788
+				$use_advanced_editor
2789
+			),
2790
+			FILTER_VALIDATE_BOOLEAN
2791
+		);
2792
+	}
2793 2793
 }
2794 2794
 
2795 2795
 /**
@@ -2798,70 +2798,70 @@  discard block
 block discarded – undo
2798 2798
 class EE_Template_Config extends EE_Config_Base
2799 2799
 {
2800 2800
 
2801
-    /**
2802
-     * @var boolean $enable_default_style
2803
-     */
2804
-    public $enable_default_style;
2805
-
2806
-    /**
2807
-     * @var string $custom_style_sheet
2808
-     */
2809
-    public $custom_style_sheet;
2810
-
2811
-    /**
2812
-     * @var boolean $display_address_in_regform
2813
-     */
2814
-    public $display_address_in_regform;
2815
-
2816
-    /**
2817
-     * @var int $display_description_on_multi_reg_page
2818
-     */
2819
-    public $display_description_on_multi_reg_page;
2820
-
2821
-    /**
2822
-     * @var boolean $use_custom_templates
2823
-     */
2824
-    public $use_custom_templates;
2825
-
2826
-    /**
2827
-     * @var string $current_espresso_theme
2828
-     */
2829
-    public $current_espresso_theme;
2830
-
2831
-    /**
2832
-     * @var EE_Ticket_Selector_Config $EED_Ticket_Selector
2833
-     */
2834
-    public $EED_Ticket_Selector;
2835
-
2836
-    /**
2837
-     * @var EE_Event_Single_Config $EED_Event_Single
2838
-     */
2839
-    public $EED_Event_Single;
2840
-
2841
-    /**
2842
-     * @var EE_Events_Archive_Config $EED_Events_Archive
2843
-     */
2844
-    public $EED_Events_Archive;
2845
-
2846
-
2847
-    /**
2848
-     *    class constructor
2849
-     *
2850
-     * @access    public
2851
-     */
2852
-    public function __construct()
2853
-    {
2854
-        // set default template settings
2855
-        $this->enable_default_style = true;
2856
-        $this->custom_style_sheet = null;
2857
-        $this->display_address_in_regform = true;
2858
-        $this->display_description_on_multi_reg_page = false;
2859
-        $this->use_custom_templates = false;
2860
-        $this->current_espresso_theme = 'Espresso_Arabica_2014';
2861
-        $this->EED_Event_Single = null;
2862
-        $this->EED_Events_Archive = null;
2863
-        $this->EED_Ticket_Selector = null;
2864
-    }
2801
+	/**
2802
+	 * @var boolean $enable_default_style
2803
+	 */
2804
+	public $enable_default_style;
2805
+
2806
+	/**
2807
+	 * @var string $custom_style_sheet
2808
+	 */
2809
+	public $custom_style_sheet;
2810
+
2811
+	/**
2812
+	 * @var boolean $display_address_in_regform
2813
+	 */
2814
+	public $display_address_in_regform;
2815
+
2816
+	/**
2817
+	 * @var int $display_description_on_multi_reg_page
2818
+	 */
2819
+	public $display_description_on_multi_reg_page;
2820
+
2821
+	/**
2822
+	 * @var boolean $use_custom_templates
2823
+	 */
2824
+	public $use_custom_templates;
2825
+
2826
+	/**
2827
+	 * @var string $current_espresso_theme
2828
+	 */
2829
+	public $current_espresso_theme;
2830
+
2831
+	/**
2832
+	 * @var EE_Ticket_Selector_Config $EED_Ticket_Selector
2833
+	 */
2834
+	public $EED_Ticket_Selector;
2835
+
2836
+	/**
2837
+	 * @var EE_Event_Single_Config $EED_Event_Single
2838
+	 */
2839
+	public $EED_Event_Single;
2840
+
2841
+	/**
2842
+	 * @var EE_Events_Archive_Config $EED_Events_Archive
2843
+	 */
2844
+	public $EED_Events_Archive;
2845
+
2846
+
2847
+	/**
2848
+	 *    class constructor
2849
+	 *
2850
+	 * @access    public
2851
+	 */
2852
+	public function __construct()
2853
+	{
2854
+		// set default template settings
2855
+		$this->enable_default_style = true;
2856
+		$this->custom_style_sheet = null;
2857
+		$this->display_address_in_regform = true;
2858
+		$this->display_description_on_multi_reg_page = false;
2859
+		$this->use_custom_templates = false;
2860
+		$this->current_espresso_theme = 'Espresso_Arabica_2014';
2861
+		$this->EED_Event_Single = null;
2862
+		$this->EED_Events_Archive = null;
2863
+		$this->EED_Ticket_Selector = null;
2864
+	}
2865 2865
 }
2866 2866
 
2867 2867
 /**
@@ -2870,114 +2870,114 @@  discard block
 block discarded – undo
2870 2870
 class EE_Map_Config extends EE_Config_Base
2871 2871
 {
2872 2872
 
2873
-    /**
2874
-     * @var boolean $use_google_maps
2875
-     */
2876
-    public $use_google_maps;
2877
-
2878
-    /**
2879
-     * @var string $api_key
2880
-     */
2881
-    public $google_map_api_key;
2882
-
2883
-    /**
2884
-     * @var int $event_details_map_width
2885
-     */
2886
-    public $event_details_map_width;
2887
-
2888
-    /**
2889
-     * @var int $event_details_map_height
2890
-     */
2891
-    public $event_details_map_height;
2892
-
2893
-    /**
2894
-     * @var int $event_details_map_zoom
2895
-     */
2896
-    public $event_details_map_zoom;
2897
-
2898
-    /**
2899
-     * @var boolean $event_details_display_nav
2900
-     */
2901
-    public $event_details_display_nav;
2902
-
2903
-    /**
2904
-     * @var boolean $event_details_nav_size
2905
-     */
2906
-    public $event_details_nav_size;
2907
-
2908
-    /**
2909
-     * @var string $event_details_control_type
2910
-     */
2911
-    public $event_details_control_type;
2912
-
2913
-    /**
2914
-     * @var string $event_details_map_align
2915
-     */
2916
-    public $event_details_map_align;
2917
-
2918
-    /**
2919
-     * @var int $event_list_map_width
2920
-     */
2921
-    public $event_list_map_width;
2922
-
2923
-    /**
2924
-     * @var int $event_list_map_height
2925
-     */
2926
-    public $event_list_map_height;
2927
-
2928
-    /**
2929
-     * @var int $event_list_map_zoom
2930
-     */
2931
-    public $event_list_map_zoom;
2932
-
2933
-    /**
2934
-     * @var boolean $event_list_display_nav
2935
-     */
2936
-    public $event_list_display_nav;
2937
-
2938
-    /**
2939
-     * @var boolean $event_list_nav_size
2940
-     */
2941
-    public $event_list_nav_size;
2942
-
2943
-    /**
2944
-     * @var string $event_list_control_type
2945
-     */
2946
-    public $event_list_control_type;
2947
-
2948
-    /**
2949
-     * @var string $event_list_map_align
2950
-     */
2951
-    public $event_list_map_align;
2952
-
2953
-
2954
-    /**
2955
-     *    class constructor
2956
-     *
2957
-     * @access    public
2958
-     */
2959
-    public function __construct()
2960
-    {
2961
-        // set default map settings
2962
-        $this->use_google_maps = true;
2963
-        $this->google_map_api_key = '';
2964
-        // for event details pages (reg page)
2965
-        $this->event_details_map_width = 585;            // ee_map_width_single
2966
-        $this->event_details_map_height = 362;            // ee_map_height_single
2967
-        $this->event_details_map_zoom = 14;            // ee_map_zoom_single
2968
-        $this->event_details_display_nav = true;            // ee_map_nav_display_single
2969
-        $this->event_details_nav_size = false;            // ee_map_nav_size_single
2970
-        $this->event_details_control_type = 'default';        // ee_map_type_control_single
2971
-        $this->event_details_map_align = 'center';            // ee_map_align_single
2972
-        // for event list pages
2973
-        $this->event_list_map_width = 300;            // ee_map_width
2974
-        $this->event_list_map_height = 185;        // ee_map_height
2975
-        $this->event_list_map_zoom = 12;            // ee_map_zoom
2976
-        $this->event_list_display_nav = false;        // ee_map_nav_display
2977
-        $this->event_list_nav_size = true;            // ee_map_nav_size
2978
-        $this->event_list_control_type = 'dropdown';        // ee_map_type_control
2979
-        $this->event_list_map_align = 'center';            // ee_map_align
2980
-    }
2873
+	/**
2874
+	 * @var boolean $use_google_maps
2875
+	 */
2876
+	public $use_google_maps;
2877
+
2878
+	/**
2879
+	 * @var string $api_key
2880
+	 */
2881
+	public $google_map_api_key;
2882
+
2883
+	/**
2884
+	 * @var int $event_details_map_width
2885
+	 */
2886
+	public $event_details_map_width;
2887
+
2888
+	/**
2889
+	 * @var int $event_details_map_height
2890
+	 */
2891
+	public $event_details_map_height;
2892
+
2893
+	/**
2894
+	 * @var int $event_details_map_zoom
2895
+	 */
2896
+	public $event_details_map_zoom;
2897
+
2898
+	/**
2899
+	 * @var boolean $event_details_display_nav
2900
+	 */
2901
+	public $event_details_display_nav;
2902
+
2903
+	/**
2904
+	 * @var boolean $event_details_nav_size
2905
+	 */
2906
+	public $event_details_nav_size;
2907
+
2908
+	/**
2909
+	 * @var string $event_details_control_type
2910
+	 */
2911
+	public $event_details_control_type;
2912
+
2913
+	/**
2914
+	 * @var string $event_details_map_align
2915
+	 */
2916
+	public $event_details_map_align;
2917
+
2918
+	/**
2919
+	 * @var int $event_list_map_width
2920
+	 */
2921
+	public $event_list_map_width;
2922
+
2923
+	/**
2924
+	 * @var int $event_list_map_height
2925
+	 */
2926
+	public $event_list_map_height;
2927
+
2928
+	/**
2929
+	 * @var int $event_list_map_zoom
2930
+	 */
2931
+	public $event_list_map_zoom;
2932
+
2933
+	/**
2934
+	 * @var boolean $event_list_display_nav
2935
+	 */
2936
+	public $event_list_display_nav;
2937
+
2938
+	/**
2939
+	 * @var boolean $event_list_nav_size
2940
+	 */
2941
+	public $event_list_nav_size;
2942
+
2943
+	/**
2944
+	 * @var string $event_list_control_type
2945
+	 */
2946
+	public $event_list_control_type;
2947
+
2948
+	/**
2949
+	 * @var string $event_list_map_align
2950
+	 */
2951
+	public $event_list_map_align;
2952
+
2953
+
2954
+	/**
2955
+	 *    class constructor
2956
+	 *
2957
+	 * @access    public
2958
+	 */
2959
+	public function __construct()
2960
+	{
2961
+		// set default map settings
2962
+		$this->use_google_maps = true;
2963
+		$this->google_map_api_key = '';
2964
+		// for event details pages (reg page)
2965
+		$this->event_details_map_width = 585;            // ee_map_width_single
2966
+		$this->event_details_map_height = 362;            // ee_map_height_single
2967
+		$this->event_details_map_zoom = 14;            // ee_map_zoom_single
2968
+		$this->event_details_display_nav = true;            // ee_map_nav_display_single
2969
+		$this->event_details_nav_size = false;            // ee_map_nav_size_single
2970
+		$this->event_details_control_type = 'default';        // ee_map_type_control_single
2971
+		$this->event_details_map_align = 'center';            // ee_map_align_single
2972
+		// for event list pages
2973
+		$this->event_list_map_width = 300;            // ee_map_width
2974
+		$this->event_list_map_height = 185;        // ee_map_height
2975
+		$this->event_list_map_zoom = 12;            // ee_map_zoom
2976
+		$this->event_list_display_nav = false;        // ee_map_nav_display
2977
+		$this->event_list_nav_size = true;            // ee_map_nav_size
2978
+		$this->event_list_control_type = 'dropdown';        // ee_map_type_control
2979
+		$this->event_list_map_align = 'center';            // ee_map_align
2980
+	}
2981 2981
 }
2982 2982
 
2983 2983
 /**
@@ -2986,46 +2986,46 @@  discard block
 block discarded – undo
2986 2986
 class EE_Events_Archive_Config extends EE_Config_Base
2987 2987
 {
2988 2988
 
2989
-    public $display_status_banner;
2989
+	public $display_status_banner;
2990 2990
 
2991
-    public $display_description;
2991
+	public $display_description;
2992 2992
 
2993
-    public $display_ticket_selector;
2993
+	public $display_ticket_selector;
2994 2994
 
2995
-    public $display_datetimes;
2995
+	public $display_datetimes;
2996 2996
 
2997
-    public $display_venue;
2997
+	public $display_venue;
2998 2998
 
2999
-    public $display_expired_events;
2999
+	public $display_expired_events;
3000 3000
 
3001
-    public $use_sortable_display_order;
3001
+	public $use_sortable_display_order;
3002 3002
 
3003
-    public $display_order_tickets;
3003
+	public $display_order_tickets;
3004 3004
 
3005
-    public $display_order_datetimes;
3005
+	public $display_order_datetimes;
3006 3006
 
3007
-    public $display_order_event;
3007
+	public $display_order_event;
3008 3008
 
3009
-    public $display_order_venue;
3009
+	public $display_order_venue;
3010 3010
 
3011 3011
 
3012
-    /**
3013
-     *    class constructor
3014
-     */
3015
-    public function __construct()
3016
-    {
3017
-        $this->display_status_banner = 0;
3018
-        $this->display_description = 1;
3019
-        $this->display_ticket_selector = 0;
3020
-        $this->display_datetimes = 1;
3021
-        $this->display_venue = 0;
3022
-        $this->display_expired_events = 0;
3023
-        $this->use_sortable_display_order = false;
3024
-        $this->display_order_tickets = 100;
3025
-        $this->display_order_datetimes = 110;
3026
-        $this->display_order_event = 120;
3027
-        $this->display_order_venue = 130;
3028
-    }
3012
+	/**
3013
+	 *    class constructor
3014
+	 */
3015
+	public function __construct()
3016
+	{
3017
+		$this->display_status_banner = 0;
3018
+		$this->display_description = 1;
3019
+		$this->display_ticket_selector = 0;
3020
+		$this->display_datetimes = 1;
3021
+		$this->display_venue = 0;
3022
+		$this->display_expired_events = 0;
3023
+		$this->use_sortable_display_order = false;
3024
+		$this->display_order_tickets = 100;
3025
+		$this->display_order_datetimes = 110;
3026
+		$this->display_order_event = 120;
3027
+		$this->display_order_venue = 130;
3028
+	}
3029 3029
 }
3030 3030
 
3031 3031
 /**
@@ -3034,34 +3034,34 @@  discard block
 block discarded – undo
3034 3034
 class EE_Event_Single_Config extends EE_Config_Base
3035 3035
 {
3036 3036
 
3037
-    public $display_status_banner_single;
3037
+	public $display_status_banner_single;
3038 3038
 
3039
-    public $display_venue;
3039
+	public $display_venue;
3040 3040
 
3041
-    public $use_sortable_display_order;
3041
+	public $use_sortable_display_order;
3042 3042
 
3043
-    public $display_order_tickets;
3043
+	public $display_order_tickets;
3044 3044
 
3045
-    public $display_order_datetimes;
3045
+	public $display_order_datetimes;
3046 3046
 
3047
-    public $display_order_event;
3047
+	public $display_order_event;
3048 3048
 
3049
-    public $display_order_venue;
3049
+	public $display_order_venue;
3050 3050
 
3051 3051
 
3052
-    /**
3053
-     *    class constructor
3054
-     */
3055
-    public function __construct()
3056
-    {
3057
-        $this->display_status_banner_single = 0;
3058
-        $this->display_venue = 1;
3059
-        $this->use_sortable_display_order = false;
3060
-        $this->display_order_tickets = 100;
3061
-        $this->display_order_datetimes = 110;
3062
-        $this->display_order_event = 120;
3063
-        $this->display_order_venue = 130;
3064
-    }
3052
+	/**
3053
+	 *    class constructor
3054
+	 */
3055
+	public function __construct()
3056
+	{
3057
+		$this->display_status_banner_single = 0;
3058
+		$this->display_venue = 1;
3059
+		$this->use_sortable_display_order = false;
3060
+		$this->display_order_tickets = 100;
3061
+		$this->display_order_datetimes = 110;
3062
+		$this->display_order_event = 120;
3063
+		$this->display_order_venue = 130;
3064
+	}
3065 3065
 }
3066 3066
 
3067 3067
 /**
@@ -3070,172 +3070,172 @@  discard block
 block discarded – undo
3070 3070
 class EE_Ticket_Selector_Config extends EE_Config_Base
3071 3071
 {
3072 3072
 
3073
-    /**
3074
-     * constant to indicate that a datetime selector should NEVER be shown for ticket selectors
3075
-     */
3076
-    const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector';
3077
-
3078
-    /**
3079
-     * constant to indicate that a datetime selector should only be shown for ticket selectors
3080
-     * when the number of datetimes for the event matches the value set for $datetime_selector_threshold
3081
-     */
3082
-    const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector';
3083
-
3084
-    /**
3085
-     * @var boolean $show_ticket_sale_columns
3086
-     */
3087
-    public $show_ticket_sale_columns;
3088
-
3089
-    /**
3090
-     * @var boolean $show_ticket_details
3091
-     */
3092
-    public $show_ticket_details;
3093
-
3094
-    /**
3095
-     * @var boolean $show_expired_tickets
3096
-     */
3097
-    public $show_expired_tickets;
3098
-
3099
-    /**
3100
-     * whether or not to display a dropdown box populated with event datetimes
3101
-     * that toggles which tickets are displayed for a ticket selector.
3102
-     * uses one of the *_DATETIME_SELECTOR constants defined above
3103
-     *
3104
-     * @var string $show_datetime_selector
3105
-     */
3106
-    private $show_datetime_selector = 'no_datetime_selector';
3107
-
3108
-    /**
3109
-     * the number of datetimes an event has to have before conditionally displaying a datetime selector
3110
-     *
3111
-     * @var int $datetime_selector_threshold
3112
-     */
3113
-    private $datetime_selector_threshold = 3;
3114
-
3115
-    /**
3116
-     * determines the maximum number of "checked" dates in the date and time filter
3117
-     *
3118
-     * @var int $datetime_selector_checked
3119
-     */
3120
-    private $datetime_selector_max_checked = 10;
3121
-
3122
-
3123
-    /**
3124
-     *    class constructor
3125
-     */
3126
-    public function __construct()
3127
-    {
3128
-        $this->show_ticket_sale_columns = true;
3129
-        $this->show_ticket_details = true;
3130
-        $this->show_expired_tickets = true;
3131
-        $this->show_datetime_selector = EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3132
-        $this->datetime_selector_threshold = 3;
3133
-        $this->datetime_selector_max_checked = 10;
3134
-    }
3135
-
3136
-
3137
-    /**
3138
-     * returns true if a datetime selector should be displayed
3139
-     *
3140
-     * @param array $datetimes
3141
-     * @return bool
3142
-     */
3143
-    public function showDatetimeSelector(array $datetimes)
3144
-    {
3145
-        // if the settings are NOT: don't show OR below threshold, THEN active = true
3146
-        return ! (
3147
-            $this->getShowDatetimeSelector() === EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
3148
-            || (
3149
-                $this->getShowDatetimeSelector() === EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR
3150
-                && count($datetimes) < $this->getDatetimeSelectorThreshold()
3151
-            )
3152
-        );
3153
-    }
3154
-
3155
-
3156
-    /**
3157
-     * @return string
3158
-     */
3159
-    public function getShowDatetimeSelector()
3160
-    {
3161
-        return $this->show_datetime_selector;
3162
-    }
3163
-
3164
-
3165
-    /**
3166
-     * @param bool $keys_only
3167
-     * @return array
3168
-     */
3169
-    public function getShowDatetimeSelectorOptions($keys_only = true)
3170
-    {
3171
-        return $keys_only
3172
-            ? array(
3173
-                EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
3174
-                EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
3175
-            )
3176
-            : array(
3177
-                EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__(
3178
-                    'Do not show date & time filter',
3179
-                    'event_espresso'
3180
-                ),
3181
-                EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR  => esc_html__(
3182
-                    'Maybe show date & time filter',
3183
-                    'event_espresso'
3184
-                ),
3185
-            );
3186
-    }
3187
-
3188
-
3189
-    /**
3190
-     * @param string $show_datetime_selector
3191
-     */
3192
-    public function setShowDatetimeSelector($show_datetime_selector)
3193
-    {
3194
-        $this->show_datetime_selector = in_array(
3195
-            $show_datetime_selector,
3196
-            $this->getShowDatetimeSelectorOptions(),
3197
-            true
3198
-        )
3199
-            ? $show_datetime_selector
3200
-            : EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3201
-    }
3202
-
3203
-
3204
-    /**
3205
-     * @return int
3206
-     */
3207
-    public function getDatetimeSelectorThreshold()
3208
-    {
3209
-        return $this->datetime_selector_threshold;
3210
-    }
3211
-
3212
-
3213
-    /**
3214
-     * @param int $datetime_selector_threshold
3215
-     */
3216
-    public function setDatetimeSelectorThreshold($datetime_selector_threshold)
3217
-    {
3218
-        $datetime_selector_threshold = absint($datetime_selector_threshold);
3219
-        $this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3;
3220
-    }
3221
-
3222
-
3223
-    /**
3224
-     * @return int
3225
-     */
3226
-    public function getDatetimeSelectorMaxChecked()
3227
-    {
3228
-        return $this->datetime_selector_max_checked;
3229
-    }
3230
-
3231
-
3232
-    /**
3233
-     * @param int $datetime_selector_max_checked
3234
-     */
3235
-    public function setDatetimeSelectorMaxChecked($datetime_selector_max_checked)
3236
-    {
3237
-        $this->datetime_selector_max_checked = absint($datetime_selector_max_checked);
3238
-    }
3073
+	/**
3074
+	 * constant to indicate that a datetime selector should NEVER be shown for ticket selectors
3075
+	 */
3076
+	const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector';
3077
+
3078
+	/**
3079
+	 * constant to indicate that a datetime selector should only be shown for ticket selectors
3080
+	 * when the number of datetimes for the event matches the value set for $datetime_selector_threshold
3081
+	 */
3082
+	const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector';
3083
+
3084
+	/**
3085
+	 * @var boolean $show_ticket_sale_columns
3086
+	 */
3087
+	public $show_ticket_sale_columns;
3088
+
3089
+	/**
3090
+	 * @var boolean $show_ticket_details
3091
+	 */
3092
+	public $show_ticket_details;
3093
+
3094
+	/**
3095
+	 * @var boolean $show_expired_tickets
3096
+	 */
3097
+	public $show_expired_tickets;
3098
+
3099
+	/**
3100
+	 * whether or not to display a dropdown box populated with event datetimes
3101
+	 * that toggles which tickets are displayed for a ticket selector.
3102
+	 * uses one of the *_DATETIME_SELECTOR constants defined above
3103
+	 *
3104
+	 * @var string $show_datetime_selector
3105
+	 */
3106
+	private $show_datetime_selector = 'no_datetime_selector';
3107
+
3108
+	/**
3109
+	 * the number of datetimes an event has to have before conditionally displaying a datetime selector
3110
+	 *
3111
+	 * @var int $datetime_selector_threshold
3112
+	 */
3113
+	private $datetime_selector_threshold = 3;
3114
+
3115
+	/**
3116
+	 * determines the maximum number of "checked" dates in the date and time filter
3117
+	 *
3118
+	 * @var int $datetime_selector_checked
3119
+	 */
3120
+	private $datetime_selector_max_checked = 10;
3121
+
3122
+
3123
+	/**
3124
+	 *    class constructor
3125
+	 */
3126
+	public function __construct()
3127
+	{
3128
+		$this->show_ticket_sale_columns = true;
3129
+		$this->show_ticket_details = true;
3130
+		$this->show_expired_tickets = true;
3131
+		$this->show_datetime_selector = EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3132
+		$this->datetime_selector_threshold = 3;
3133
+		$this->datetime_selector_max_checked = 10;
3134
+	}
3135
+
3136
+
3137
+	/**
3138
+	 * returns true if a datetime selector should be displayed
3139
+	 *
3140
+	 * @param array $datetimes
3141
+	 * @return bool
3142
+	 */
3143
+	public function showDatetimeSelector(array $datetimes)
3144
+	{
3145
+		// if the settings are NOT: don't show OR below threshold, THEN active = true
3146
+		return ! (
3147
+			$this->getShowDatetimeSelector() === EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
3148
+			|| (
3149
+				$this->getShowDatetimeSelector() === EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR
3150
+				&& count($datetimes) < $this->getDatetimeSelectorThreshold()
3151
+			)
3152
+		);
3153
+	}
3154
+
3155
+
3156
+	/**
3157
+	 * @return string
3158
+	 */
3159
+	public function getShowDatetimeSelector()
3160
+	{
3161
+		return $this->show_datetime_selector;
3162
+	}
3163
+
3164
+
3165
+	/**
3166
+	 * @param bool $keys_only
3167
+	 * @return array
3168
+	 */
3169
+	public function getShowDatetimeSelectorOptions($keys_only = true)
3170
+	{
3171
+		return $keys_only
3172
+			? array(
3173
+				EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
3174
+				EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
3175
+			)
3176
+			: array(
3177
+				EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__(
3178
+					'Do not show date & time filter',
3179
+					'event_espresso'
3180
+				),
3181
+				EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR  => esc_html__(
3182
+					'Maybe show date & time filter',
3183
+					'event_espresso'
3184
+				),
3185
+			);
3186
+	}
3187
+
3188
+
3189
+	/**
3190
+	 * @param string $show_datetime_selector
3191
+	 */
3192
+	public function setShowDatetimeSelector($show_datetime_selector)
3193
+	{
3194
+		$this->show_datetime_selector = in_array(
3195
+			$show_datetime_selector,
3196
+			$this->getShowDatetimeSelectorOptions(),
3197
+			true
3198
+		)
3199
+			? $show_datetime_selector
3200
+			: EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3201
+	}
3202
+
3203
+
3204
+	/**
3205
+	 * @return int
3206
+	 */
3207
+	public function getDatetimeSelectorThreshold()
3208
+	{
3209
+		return $this->datetime_selector_threshold;
3210
+	}
3211
+
3212
+
3213
+	/**
3214
+	 * @param int $datetime_selector_threshold
3215
+	 */
3216
+	public function setDatetimeSelectorThreshold($datetime_selector_threshold)
3217
+	{
3218
+		$datetime_selector_threshold = absint($datetime_selector_threshold);
3219
+		$this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3;
3220
+	}
3221
+
3222
+
3223
+	/**
3224
+	 * @return int
3225
+	 */
3226
+	public function getDatetimeSelectorMaxChecked()
3227
+	{
3228
+		return $this->datetime_selector_max_checked;
3229
+	}
3230
+
3231
+
3232
+	/**
3233
+	 * @param int $datetime_selector_max_checked
3234
+	 */
3235
+	public function setDatetimeSelectorMaxChecked($datetime_selector_max_checked)
3236
+	{
3237
+		$this->datetime_selector_max_checked = absint($datetime_selector_max_checked);
3238
+	}
3239 3239
 }
3240 3240
 
3241 3241
 /**
@@ -3248,87 +3248,87 @@  discard block
 block discarded – undo
3248 3248
 class EE_Environment_Config extends EE_Config_Base
3249 3249
 {
3250 3250
 
3251
-    /**
3252
-     * Hold any php environment variables that we want to track.
3253
-     *
3254
-     * @var stdClass;
3255
-     */
3256
-    public $php;
3257
-
3258
-
3259
-    /**
3260
-     *    constructor
3261
-     */
3262
-    public function __construct()
3263
-    {
3264
-        $this->php = new stdClass();
3265
-        $this->_set_php_values();
3266
-    }
3267
-
3268
-
3269
-    /**
3270
-     * This sets the php environment variables.
3271
-     *
3272
-     * @since 4.4.0
3273
-     * @return void
3274
-     */
3275
-    protected function _set_php_values()
3276
-    {
3277
-        $this->php->max_input_vars = ini_get('max_input_vars');
3278
-        $this->php->version = phpversion();
3279
-    }
3280
-
3281
-
3282
-    /**
3283
-     * helper method for determining whether input_count is
3284
-     * reaching the potential maximum the server can handle
3285
-     * according to max_input_vars
3286
-     *
3287
-     * @param int   $input_count the count of input vars.
3288
-     * @return array {
3289
-     *                           An array that represents whether available space and if no available space the error
3290
-     *                           message.
3291
-     * @type bool   $has_space   whether more inputs can be added.
3292
-     * @type string $msg         Any message to be displayed.
3293
-     *                           }
3294
-     */
3295
-    public function max_input_vars_limit_check($input_count = 0)
3296
-    {
3297
-        if (
3298
-            ! empty($this->php->max_input_vars)
3299
-            && ($input_count >= $this->php->max_input_vars)
3300
-        ) {
3301
-            // check the server setting because the config value could be stale
3302
-            $max_input_vars = ini_get('max_input_vars');
3303
-            if ($input_count >= $max_input_vars) {
3304
-                return sprintf(
3305
-                    esc_html__(
3306
-                        'The maximum number of inputs on this page has been exceeded. You cannot make edits to this page because of your server\'s PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.%1$sPlease contact your web host and ask them to raise the "max_input_vars" limit.',
3307
-                        'event_espresso'
3308
-                    ),
3309
-                    '<br>',
3310
-                    $input_count,
3311
-                    $max_input_vars
3312
-                );
3313
-            } else {
3314
-                return '';
3315
-            }
3316
-        } else {
3317
-            return '';
3318
-        }
3319
-    }
3320
-
3321
-
3322
-    /**
3323
-     * The purpose of this method is just to force rechecking php values so if they've changed, they get updated.
3324
-     *
3325
-     * @since 4.4.1
3326
-     * @return void
3327
-     */
3328
-    public function recheck_values()
3329
-    {
3330
-        $this->_set_php_values();
3331
-    }
3251
+	/**
3252
+	 * Hold any php environment variables that we want to track.
3253
+	 *
3254
+	 * @var stdClass;
3255
+	 */
3256
+	public $php;
3257
+
3258
+
3259
+	/**
3260
+	 *    constructor
3261
+	 */
3262
+	public function __construct()
3263
+	{
3264
+		$this->php = new stdClass();
3265
+		$this->_set_php_values();
3266
+	}
3267
+
3268
+
3269
+	/**
3270
+	 * This sets the php environment variables.
3271
+	 *
3272
+	 * @since 4.4.0
3273
+	 * @return void
3274
+	 */
3275
+	protected function _set_php_values()
3276
+	{
3277
+		$this->php->max_input_vars = ini_get('max_input_vars');
3278
+		$this->php->version = phpversion();
3279
+	}
3280
+
3281
+
3282
+	/**
3283
+	 * helper method for determining whether input_count is
3284
+	 * reaching the potential maximum the server can handle
3285
+	 * according to max_input_vars
3286
+	 *
3287
+	 * @param int   $input_count the count of input vars.
3288
+	 * @return array {
3289
+	 *                           An array that represents whether available space and if no available space the error
3290
+	 *                           message.
3291
+	 * @type bool   $has_space   whether more inputs can be added.
3292
+	 * @type string $msg         Any message to be displayed.
3293
+	 *                           }
3294
+	 */
3295
+	public function max_input_vars_limit_check($input_count = 0)
3296
+	{
3297
+		if (
3298
+			! empty($this->php->max_input_vars)
3299
+			&& ($input_count >= $this->php->max_input_vars)
3300
+		) {
3301
+			// check the server setting because the config value could be stale
3302
+			$max_input_vars = ini_get('max_input_vars');
3303
+			if ($input_count >= $max_input_vars) {
3304
+				return sprintf(
3305
+					esc_html__(
3306
+						'The maximum number of inputs on this page has been exceeded. You cannot make edits to this page because of your server\'s PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.%1$sPlease contact your web host and ask them to raise the "max_input_vars" limit.',
3307
+						'event_espresso'
3308
+					),
3309
+					'<br>',
3310
+					$input_count,
3311
+					$max_input_vars
3312
+				);
3313
+			} else {
3314
+				return '';
3315
+			}
3316
+		} else {
3317
+			return '';
3318
+		}
3319
+	}
3320
+
3321
+
3322
+	/**
3323
+	 * The purpose of this method is just to force rechecking php values so if they've changed, they get updated.
3324
+	 *
3325
+	 * @since 4.4.1
3326
+	 * @return void
3327
+	 */
3328
+	public function recheck_values()
3329
+	{
3330
+		$this->_set_php_values();
3331
+	}
3332 3332
 }
3333 3333
 
3334 3334
 /**
@@ -3341,21 +3341,21 @@  discard block
 block discarded – undo
3341 3341
 class EE_Tax_Config extends EE_Config_Base
3342 3342
 {
3343 3343
 
3344
-    /*
3344
+	/*
3345 3345
      * flag to indicate whether or not to display ticket prices with the taxes included
3346 3346
      *
3347 3347
      * @var boolean $prices_displayed_including_taxes
3348 3348
      */
3349
-    public $prices_displayed_including_taxes;
3349
+	public $prices_displayed_including_taxes;
3350 3350
 
3351 3351
 
3352
-    /**
3353
-     *    class constructor
3354
-     */
3355
-    public function __construct()
3356
-    {
3357
-        $this->prices_displayed_including_taxes = true;
3358
-    }
3352
+	/**
3353
+	 *    class constructor
3354
+	 */
3355
+	public function __construct()
3356
+	{
3357
+		$this->prices_displayed_including_taxes = true;
3358
+	}
3359 3359
 }
3360 3360
 
3361 3361
 /**
@@ -3369,19 +3369,19 @@  discard block
 block discarded – undo
3369 3369
 class EE_Messages_Config extends EE_Config_Base
3370 3370
 {
3371 3371
 
3372
-    /**
3373
-     * This is an integer representing the deletion threshold in months for when old messages will get deleted.
3374
-     * A value of 0 represents never deleting.  Default is 0.
3375
-     *
3376
-     * @var integer
3377
-     */
3378
-    public $delete_threshold;
3372
+	/**
3373
+	 * This is an integer representing the deletion threshold in months for when old messages will get deleted.
3374
+	 * A value of 0 represents never deleting.  Default is 0.
3375
+	 *
3376
+	 * @var integer
3377
+	 */
3378
+	public $delete_threshold;
3379 3379
 
3380 3380
 
3381
-    public function __construct()
3382
-    {
3383
-        $this->delete_threshold = 0;
3384
-    }
3381
+	public function __construct()
3382
+	{
3383
+		$this->delete_threshold = 0;
3384
+	}
3385 3385
 }
3386 3386
 
3387 3387
 /**
@@ -3392,31 +3392,31 @@  discard block
 block discarded – undo
3392 3392
 class EE_Gateway_Config extends EE_Config_Base
3393 3393
 {
3394 3394
 
3395
-    /**
3396
-     * Array with keys that are payment gateways slugs, and values are arrays
3397
-     * with any config info the gateway wants to store
3398
-     *
3399
-     * @var array
3400
-     */
3401
-    public $payment_settings;
3402
-
3403
-    /**
3404
-     * Where keys are gateway slugs, and values are booleans indicating whether or not
3405
-     * the gateway is stored in the uploads directory
3406
-     *
3407
-     * @var array
3408
-     */
3409
-    public $active_gateways;
3410
-
3411
-
3412
-    /**
3413
-     *    class constructor
3414
-     *
3415
-     * @deprecated
3416
-     */
3417
-    public function __construct()
3418
-    {
3419
-        $this->payment_settings = array();
3420
-        $this->active_gateways = array('Invoice' => false);
3421
-    }
3395
+	/**
3396
+	 * Array with keys that are payment gateways slugs, and values are arrays
3397
+	 * with any config info the gateway wants to store
3398
+	 *
3399
+	 * @var array
3400
+	 */
3401
+	public $payment_settings;
3402
+
3403
+	/**
3404
+	 * Where keys are gateway slugs, and values are booleans indicating whether or not
3405
+	 * the gateway is stored in the uploads directory
3406
+	 *
3407
+	 * @var array
3408
+	 */
3409
+	public $active_gateways;
3410
+
3411
+
3412
+	/**
3413
+	 *    class constructor
3414
+	 *
3415
+	 * @deprecated
3416
+	 */
3417
+	public function __construct()
3418
+	{
3419
+		$this->payment_settings = array();
3420
+		$this->active_gateways = array('Invoice' => false);
3421
+	}
3422 3422
 }
Please login to merge, or discard this patch.
Spacing   +112 added lines, -112 removed lines patch added patch discarded remove patch
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
     public static function instance()
152 152
     {
153 153
         // check if class object is instantiated, and instantiated properly
154
-        if (! self::$_instance instanceof EE_Config) {
154
+        if ( ! self::$_instance instanceof EE_Config) {
155 155
             self::$_instance = new self();
156 156
         }
157 157
         return self::$_instance;
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
                 $this
294 294
             );
295 295
             if (is_object($settings) && property_exists($this, $config)) {
296
-                $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
296
+                $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__'.$config, $settings);
297 297
                 // call configs populate method to ensure any defaults are set for empty values.
298 298
                 if (method_exists($settings, 'populate')) {
299 299
                     $this->{$config}->populate();
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
                         break;
569 569
                     // TEST #2 : check that settings section exists
570 570
                     case 2:
571
-                        if (! isset($this->{$section})) {
571
+                        if ( ! isset($this->{$section})) {
572 572
                             if ($display_errors) {
573 573
                                 throw new EE_Error(
574 574
                                     sprintf(
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
                         break;
630 630
                     // TEST #6 : verify config class is accessible
631 631
                     case 6:
632
-                        if (! class_exists($config_class)) {
632
+                        if ( ! class_exists($config_class)) {
633 633
                             if ($display_errors) {
634 634
                                 throw new EE_Error(
635 635
                                     sprintf(
@@ -646,7 +646,7 @@  discard block
 block discarded – undo
646 646
                         break;
647 647
                     // TEST #7 : check that config has even been set
648 648
                     case 7:
649
-                        if (! isset($this->{$section}->{$name})) {
649
+                        if ( ! isset($this->{$section}->{$name})) {
650 650
                             if ($display_errors) {
651 651
                                 throw new EE_Error(
652 652
                                     sprintf(
@@ -664,7 +664,7 @@  discard block
 block discarded – undo
664 664
                         break;
665 665
                     // TEST #8 : check that config is the requested type
666 666
                     case 8:
667
-                        if (! $this->{$section}->{$name} instanceof $config_class) {
667
+                        if ( ! $this->{$section}->{$name} instanceof $config_class) {
668 668
                             if ($display_errors) {
669 669
                                 throw new EE_Error(
670 670
                                     sprintf(
@@ -683,7 +683,7 @@  discard block
 block discarded – undo
683 683
                         break;
684 684
                     // TEST #9 : verify config object
685 685
                     case 9:
686
-                        if (! $config_obj instanceof EE_Config_Base) {
686
+                        if ( ! $config_obj instanceof EE_Config_Base) {
687 687
                             if ($display_errors) {
688 688
                                 throw new EE_Error(
689 689
                                     sprintf(
@@ -715,7 +715,7 @@  discard block
 block discarded – undo
715 715
      */
716 716
     private function _generate_config_option_name($section = '', $name = '')
717 717
     {
718
-        return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
718
+        return 'ee_config-'.strtolower($section.'-'.str_replace(array('EE_', 'EED_'), '', $name));
719 719
     }
720 720
 
721 721
 
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
     {
733 733
         return ! empty($config_class)
734 734
             ? $config_class
735
-            : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
735
+            : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))).'_Config';
736 736
     }
737 737
 
738 738
 
@@ -751,17 +751,17 @@  discard block
 block discarded – undo
751 751
         // ensure config class is set to something
752 752
         $config_class = $this->_set_config_class($config_class, $name);
753 753
         // run tests 1-4, 6, and 7 to verify all config params are set and valid
754
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
754
+        if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
755 755
             return null;
756 756
         }
757 757
         $config_option_name = $this->_generate_config_option_name($section, $name);
758 758
         // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
759
-        if (! isset($this->_addon_option_names[ $config_option_name ])) {
760
-            $this->_addon_option_names[ $config_option_name ] = $config_class;
759
+        if ( ! isset($this->_addon_option_names[$config_option_name])) {
760
+            $this->_addon_option_names[$config_option_name] = $config_class;
761 761
             $this->update_addon_option_names();
762 762
         }
763 763
         // verify the incoming config object but suppress errors
764
-        if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
764
+        if ( ! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
765 765
             $config_obj = new $config_class();
766 766
         }
767 767
         if (get_option($config_option_name)) {
@@ -823,7 +823,7 @@  discard block
 block discarded – undo
823 823
         }
824 824
         $config_option_name = $this->_generate_config_option_name($section, $name);
825 825
         // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
826
-        if (! isset($this->_addon_option_names[ $config_option_name ])) {
826
+        if ( ! isset($this->_addon_option_names[$config_option_name])) {
827 827
             // save new config to db
828 828
             if ($this->set_config($section, $name, $config_class, $config_obj)) {
829 829
                 return true;
@@ -849,7 +849,7 @@  discard block
 block discarded – undo
849 849
                             'event_espresso'
850 850
                         ),
851 851
                         $config_class,
852
-                        'EE_Config->' . $section . '->' . $name
852
+                        'EE_Config->'.$section.'->'.$name
853 853
                     ),
854 854
                     __FILE__,
855 855
                     __FUNCTION__,
@@ -875,7 +875,7 @@  discard block
 block discarded – undo
875 875
         // ensure config class is set to something
876 876
         $config_class = $this->_set_config_class($config_class, $name);
877 877
         // run tests 1-4, 6 and 7 to verify that all params have been set
878
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
878
+        if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
879 879
             return null;
880 880
         }
881 881
         // now test if the requested config object exists, but suppress errors
@@ -920,7 +920,7 @@  discard block
 block discarded – undo
920 920
         // retrieve the wp-option for this config class.
921 921
         $config_option = maybe_unserialize(get_option($config_option_name, array()));
922 922
         if (empty($config_option)) {
923
-            EE_Config::log($config_option_name . '-NOT-FOUND');
923
+            EE_Config::log($config_option_name.'-NOT-FOUND');
924 924
         }
925 925
         return $config_option;
926 926
     }
@@ -937,7 +937,7 @@  discard block
 block discarded – undo
937 937
             $config_log = get_option(EE_Config::LOG_NAME, array());
938 938
             /** @var RequestParams $request */
939 939
             $request = LoaderFactory::getLoader()->getShared(RequestParams::class);
940
-            $config_log[ (string) microtime(true) ] = array(
940
+            $config_log[(string) microtime(true)] = array(
941 941
                 'config_name' => $config_option_name,
942 942
                 'request'     => $request->requestParams(),
943 943
             );
@@ -952,7 +952,7 @@  discard block
 block discarded – undo
952 952
      */
953 953
     public static function trim_log()
954 954
     {
955
-        if (! EE_Config::logging_enabled()) {
955
+        if ( ! EE_Config::logging_enabled()) {
956 956
             return;
957 957
         }
958 958
         $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
@@ -976,7 +976,7 @@  discard block
 block discarded – undo
976 976
     public static function get_page_for_posts()
977 977
     {
978 978
         $page_for_posts = get_option('page_for_posts');
979
-        if (! $page_for_posts) {
979
+        if ( ! $page_for_posts) {
980 980
             return 'posts';
981 981
         }
982 982
         global $wpdb;
@@ -1033,13 +1033,13 @@  discard block
 block discarded – undo
1033 1033
             )
1034 1034
         ) {
1035 1035
             // grab list of installed widgets
1036
-            $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1036
+            $widgets_to_register = glob(EE_WIDGETS.'*', GLOB_ONLYDIR);
1037 1037
             // filter list of modules to register
1038 1038
             $widgets_to_register = apply_filters(
1039 1039
                 'FHEE__EE_Config__register_widgets__widgets_to_register',
1040 1040
                 $widgets_to_register
1041 1041
             );
1042
-            if (! empty($widgets_to_register)) {
1042
+            if ( ! empty($widgets_to_register)) {
1043 1043
                 // cycle thru widget folders
1044 1044
                 foreach ($widgets_to_register as $widget_path) {
1045 1045
                     // add to list of installed widget modules
@@ -1089,31 +1089,31 @@  discard block
 block discarded – undo
1089 1089
         // create classname from widget directory name
1090 1090
         $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1091 1091
         // add class prefix
1092
-        $widget_class = 'EEW_' . $widget;
1092
+        $widget_class = 'EEW_'.$widget;
1093 1093
         // does the widget exist ?
1094
-        if (! is_readable($widget_path . '/' . $widget_class . $widget_ext)) {
1094
+        if ( ! is_readable($widget_path.'/'.$widget_class.$widget_ext)) {
1095 1095
             $msg = sprintf(
1096 1096
                 esc_html__(
1097 1097
                     'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s',
1098 1098
                     'event_espresso'
1099 1099
                 ),
1100 1100
                 $widget_class,
1101
-                $widget_path . '/' . $widget_class . $widget_ext
1101
+                $widget_path.'/'.$widget_class.$widget_ext
1102 1102
             );
1103
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1103
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1104 1104
             return;
1105 1105
         }
1106 1106
         // load the widget class file
1107
-        require_once($widget_path . '/' . $widget_class . $widget_ext);
1107
+        require_once($widget_path.'/'.$widget_class.$widget_ext);
1108 1108
         // verify that class exists
1109
-        if (! class_exists($widget_class)) {
1109
+        if ( ! class_exists($widget_class)) {
1110 1110
             $msg = sprintf(esc_html__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1111
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1111
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1112 1112
             return;
1113 1113
         }
1114 1114
         register_widget($widget_class);
1115 1115
         // add to array of registered widgets
1116
-        EE_Registry::instance()->widgets->{$widget_class} = $widget_path . '/' . $widget_class . $widget_ext;
1116
+        EE_Registry::instance()->widgets->{$widget_class} = $widget_path.'/'.$widget_class.$widget_ext;
1117 1117
     }
1118 1118
 
1119 1119
 
@@ -1126,19 +1126,19 @@  discard block
 block discarded – undo
1126 1126
     private function _register_modules()
1127 1127
     {
1128 1128
         // grab list of installed modules
1129
-        $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1129
+        $modules_to_register = glob(EE_MODULES.'*', GLOB_ONLYDIR);
1130 1130
         // filter list of modules to register
1131 1131
         $modules_to_register = apply_filters(
1132 1132
             'FHEE__EE_Config__register_modules__modules_to_register',
1133 1133
             $modules_to_register
1134 1134
         );
1135
-        if (! empty($modules_to_register)) {
1135
+        if ( ! empty($modules_to_register)) {
1136 1136
             // loop through folders
1137 1137
             foreach ($modules_to_register as $module_path) {
1138 1138
                 /**TEMPORARILY EXCLUDE gateways from modules for time being**/
1139 1139
                 if (
1140
-                    $module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1141
-                    && $module_path !== EE_MODULES . 'gateways'
1140
+                    $module_path !== EE_MODULES.'zzz-copy-this-module-template'
1141
+                    && $module_path !== EE_MODULES.'gateways'
1142 1142
                 ) {
1143 1143
                     // add to list of installed modules
1144 1144
                     EE_Config::register_module($module_path);
@@ -1175,25 +1175,25 @@  discard block
 block discarded – undo
1175 1175
             // remove last segment
1176 1176
             array_pop($module_path);
1177 1177
             // glue it back together
1178
-            $module_path = implode('/', $module_path) . '/';
1178
+            $module_path = implode('/', $module_path).'/';
1179 1179
             // take first segment from file name pieces and sanitize it
1180 1180
             $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1181 1181
             // ensure class prefix is added
1182
-            $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1182
+            $module_class = strpos($module, 'EED_') !== 0 ? 'EED_'.$module : $module;
1183 1183
         } else {
1184 1184
             // we need to generate the filename based off of the folder name
1185 1185
             // grab and sanitize module name
1186 1186
             $module = strtolower(basename($module_path));
1187 1187
             $module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1188 1188
             // like trailingslashit()
1189
-            $module_path = rtrim($module_path, '/') . '/';
1189
+            $module_path = rtrim($module_path, '/').'/';
1190 1190
             // create classname from module directory name
1191 1191
             $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1192 1192
             // add class prefix
1193
-            $module_class = 'EED_' . $module;
1193
+            $module_class = 'EED_'.$module;
1194 1194
         }
1195 1195
         // does the module exist ?
1196
-        if (! is_readable($module_path . '/' . $module_class . $module_ext)) {
1196
+        if ( ! is_readable($module_path.'/'.$module_class.$module_ext)) {
1197 1197
             $msg = sprintf(
1198 1198
                 esc_html__(
1199 1199
                     'The requested %s module file could not be found or is not readable due to file permissions.',
@@ -1201,19 +1201,19 @@  discard block
 block discarded – undo
1201 1201
                 ),
1202 1202
                 $module
1203 1203
             );
1204
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1204
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1205 1205
             return false;
1206 1206
         }
1207 1207
         // load the module class file
1208
-        require_once($module_path . $module_class . $module_ext);
1208
+        require_once($module_path.$module_class.$module_ext);
1209 1209
         // verify that class exists
1210
-        if (! class_exists($module_class)) {
1210
+        if ( ! class_exists($module_class)) {
1211 1211
             $msg = sprintf(esc_html__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1212
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1212
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1213 1213
             return false;
1214 1214
         }
1215 1215
         // add to array of registered modules
1216
-        EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1216
+        EE_Registry::instance()->modules->{$module_class} = $module_path.$module_class.$module_ext;
1217 1217
         do_action(
1218 1218
             'AHEE__EE_Config__register_module__complete',
1219 1219
             $module_class,
@@ -1264,26 +1264,26 @@  discard block
 block discarded – undo
1264 1264
     {
1265 1265
         do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1266 1266
         $module = str_replace('EED_', '', $module);
1267
-        $module_class = 'EED_' . $module;
1268
-        if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1267
+        $module_class = 'EED_'.$module;
1268
+        if ( ! isset(EE_Registry::instance()->modules->{$module_class})) {
1269 1269
             $msg = sprintf(esc_html__('The module %s has not been registered.', 'event_espresso'), $module);
1270
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1270
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1271 1271
             return false;
1272 1272
         }
1273 1273
         if (empty($route)) {
1274 1274
             $msg = sprintf(esc_html__('No route has been supplied.', 'event_espresso'), $route);
1275
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1275
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1276 1276
             return false;
1277 1277
         }
1278
-        if (! method_exists('EED_' . $module, $method_name)) {
1278
+        if ( ! method_exists('EED_'.$module, $method_name)) {
1279 1279
             $msg = sprintf(
1280 1280
                 esc_html__('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1281 1281
                 $route
1282 1282
             );
1283
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1283
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1284 1284
             return false;
1285 1285
         }
1286
-        EE_Config::$_module_route_map[ (string) $key ][ (string) $route ] = array('EED_' . $module, $method_name);
1286
+        EE_Config::$_module_route_map[(string) $key][(string) $route] = array('EED_'.$module, $method_name);
1287 1287
         return true;
1288 1288
     }
1289 1289
 
@@ -1300,8 +1300,8 @@  discard block
 block discarded – undo
1300 1300
     {
1301 1301
         do_action('AHEE__EE_Config__get_route__begin', $route);
1302 1302
         $route = (string) apply_filters('FHEE__EE_Config__get_route', $route);
1303
-        if (isset(EE_Config::$_module_route_map[ $key ][ $route ])) {
1304
-            return EE_Config::$_module_route_map[ $key ][ $route ];
1303
+        if (isset(EE_Config::$_module_route_map[$key][$route])) {
1304
+            return EE_Config::$_module_route_map[$key][$route];
1305 1305
         }
1306 1306
         return null;
1307 1307
     }
@@ -1333,47 +1333,47 @@  discard block
 block discarded – undo
1333 1333
     public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1334 1334
     {
1335 1335
         do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1336
-        if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1336
+        if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1337 1337
             $msg = sprintf(
1338 1338
                 esc_html__('The module route %s for this forward has not been registered.', 'event_espresso'),
1339 1339
                 $route
1340 1340
             );
1341
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1341
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1342 1342
             return false;
1343 1343
         }
1344 1344
         if (empty($forward)) {
1345 1345
             $msg = sprintf(esc_html__('No forwarding route has been supplied.', 'event_espresso'), $route);
1346
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1346
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1347 1347
             return false;
1348 1348
         }
1349 1349
         if (is_array($forward)) {
1350
-            if (! isset($forward[1])) {
1350
+            if ( ! isset($forward[1])) {
1351 1351
                 $msg = sprintf(
1352 1352
                     esc_html__('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1353 1353
                     $route
1354 1354
                 );
1355
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1355
+                EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1356 1356
                 return false;
1357 1357
             }
1358
-            if (! method_exists($forward[0], $forward[1])) {
1358
+            if ( ! method_exists($forward[0], $forward[1])) {
1359 1359
                 $msg = sprintf(
1360 1360
                     esc_html__('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1361 1361
                     $forward[1],
1362 1362
                     $route
1363 1363
                 );
1364
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1364
+                EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1365 1365
                 return false;
1366 1366
             }
1367
-        } elseif (! function_exists($forward)) {
1367
+        } elseif ( ! function_exists($forward)) {
1368 1368
             $msg = sprintf(
1369 1369
                 esc_html__('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1370 1370
                 $forward,
1371 1371
                 $route
1372 1372
             );
1373
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1373
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1374 1374
             return false;
1375 1375
         }
1376
-        EE_Config::$_module_forward_map[ $key ][ $route ][ absint($status) ] = $forward;
1376
+        EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward;
1377 1377
         return true;
1378 1378
     }
1379 1379
 
@@ -1391,10 +1391,10 @@  discard block
 block discarded – undo
1391 1391
     public static function get_forward($route = null, $status = 0, $key = 'ee')
1392 1392
     {
1393 1393
         do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1394
-        if (isset(EE_Config::$_module_forward_map[ $key ][ $route ][ $status ])) {
1394
+        if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) {
1395 1395
             return apply_filters(
1396 1396
                 'FHEE__EE_Config__get_forward',
1397
-                EE_Config::$_module_forward_map[ $key ][ $route ][ $status ],
1397
+                EE_Config::$_module_forward_map[$key][$route][$status],
1398 1398
                 $route,
1399 1399
                 $status
1400 1400
             );
@@ -1418,15 +1418,15 @@  discard block
 block discarded – undo
1418 1418
     public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1419 1419
     {
1420 1420
         do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1421
-        if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1421
+        if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1422 1422
             $msg = sprintf(
1423 1423
                 esc_html__('The module route %s for this view has not been registered.', 'event_espresso'),
1424 1424
                 $route
1425 1425
             );
1426
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1426
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1427 1427
             return false;
1428 1428
         }
1429
-        if (! is_readable($view)) {
1429
+        if ( ! is_readable($view)) {
1430 1430
             $msg = sprintf(
1431 1431
                 esc_html__(
1432 1432
                     'The %s view file could not be found or is not readable due to file permissions.',
@@ -1434,10 +1434,10 @@  discard block
 block discarded – undo
1434 1434
                 ),
1435 1435
                 $view
1436 1436
             );
1437
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1437
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1438 1438
             return false;
1439 1439
         }
1440
-        EE_Config::$_module_view_map[ $key ][ $route ][ absint($status) ] = $view;
1440
+        EE_Config::$_module_view_map[$key][$route][absint($status)] = $view;
1441 1441
         return true;
1442 1442
     }
1443 1443
 
@@ -1455,10 +1455,10 @@  discard block
 block discarded – undo
1455 1455
     public static function get_view($route = null, $status = 0, $key = 'ee')
1456 1456
     {
1457 1457
         do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1458
-        if (isset(EE_Config::$_module_view_map[ $key ][ $route ][ $status ])) {
1458
+        if (isset(EE_Config::$_module_view_map[$key][$route][$status])) {
1459 1459
             return apply_filters(
1460 1460
                 'FHEE__EE_Config__get_view',
1461
-                EE_Config::$_module_view_map[ $key ][ $route ][ $status ],
1461
+                EE_Config::$_module_view_map[$key][$route][$status],
1462 1462
                 $route,
1463 1463
                 $status
1464 1464
             );
@@ -1484,7 +1484,7 @@  discard block
 block discarded – undo
1484 1484
      */
1485 1485
     public static function getLegacyShortcodesManager()
1486 1486
     {
1487
-        if (! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1487
+        if ( ! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1488 1488
             EE_Config::instance()->legacy_shortcodes_manager = LoaderFactory::getLoader()->getShared(
1489 1489
                 LegacyShortcodesManager::class
1490 1490
             );
@@ -1531,7 +1531,7 @@  discard block
 block discarded – undo
1531 1531
      */
1532 1532
     public function get_pretty($property)
1533 1533
     {
1534
-        if (! property_exists($this, $property)) {
1534
+        if ( ! property_exists($this, $property)) {
1535 1535
             throw new EE_Error(
1536 1536
                 sprintf(
1537 1537
                     esc_html__(
@@ -1760,11 +1760,11 @@  discard block
 block discarded – undo
1760 1760
      */
1761 1761
     public function reg_page_url()
1762 1762
     {
1763
-        if (! $this->reg_page_url) {
1763
+        if ( ! $this->reg_page_url) {
1764 1764
             $this->reg_page_url = add_query_arg(
1765 1765
                 array('uts' => time()),
1766 1766
                 get_permalink($this->reg_page_id)
1767
-            ) . '#checkout';
1767
+            ).'#checkout';
1768 1768
         }
1769 1769
         return $this->reg_page_url;
1770 1770
     }
@@ -1780,7 +1780,7 @@  discard block
 block discarded – undo
1780 1780
      */
1781 1781
     public function txn_page_url($query_args = array())
1782 1782
     {
1783
-        if (! $this->txn_page_url) {
1783
+        if ( ! $this->txn_page_url) {
1784 1784
             $this->txn_page_url = get_permalink($this->txn_page_id);
1785 1785
         }
1786 1786
         if ($query_args) {
@@ -1801,7 +1801,7 @@  discard block
 block discarded – undo
1801 1801
      */
1802 1802
     public function thank_you_page_url($query_args = array())
1803 1803
     {
1804
-        if (! $this->thank_you_page_url) {
1804
+        if ( ! $this->thank_you_page_url) {
1805 1805
             $this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1806 1806
         }
1807 1807
         if ($query_args) {
@@ -1820,7 +1820,7 @@  discard block
 block discarded – undo
1820 1820
      */
1821 1821
     public function cancel_page_url()
1822 1822
     {
1823
-        if (! $this->cancel_page_url) {
1823
+        if ( ! $this->cancel_page_url) {
1824 1824
             $this->cancel_page_url = get_permalink($this->cancel_page_id);
1825 1825
         }
1826 1826
         return $this->cancel_page_url;
@@ -1863,13 +1863,13 @@  discard block
 block discarded – undo
1863 1863
         $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1864 1864
         $option = self::OPTION_NAME_UXIP;
1865 1865
         // set correct table for query
1866
-        $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1866
+        $table_name = $wpdb->get_blog_prefix($current_main_site_id).'options';
1867 1867
         // rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1868 1868
         // get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1869 1869
         // re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1870 1870
         // this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1871 1871
         // for the purpose of caching.
1872
-        $pre = apply_filters('pre_option_' . $option, false, $option);
1872
+        $pre = apply_filters('pre_option_'.$option, false, $option);
1873 1873
         if (false !== $pre) {
1874 1874
             EE_Core_Config::$ee_ueip_option = $pre;
1875 1875
             return EE_Core_Config::$ee_ueip_option;
@@ -1883,10 +1883,10 @@  discard block
 block discarded – undo
1883 1883
         if (is_object($row)) {
1884 1884
             $value = $row->option_value;
1885 1885
         } else { // option does not exist so use default.
1886
-            EE_Core_Config::$ee_ueip_option =  apply_filters('default_option_' . $option, false, $option);
1886
+            EE_Core_Config::$ee_ueip_option = apply_filters('default_option_'.$option, false, $option);
1887 1887
             return EE_Core_Config::$ee_ueip_option;
1888 1888
         }
1889
-        EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1889
+        EE_Core_Config::$ee_ueip_option = apply_filters('option_'.$option, maybe_unserialize($value), $option);
1890 1890
         return EE_Core_Config::$ee_ueip_option;
1891 1891
     }
1892 1892
 
@@ -2157,30 +2157,30 @@  discard block
 block discarded – undo
2157 2157
      */
2158 2158
     public function setCurrency(?string $CNT_ISO = '')
2159 2159
     {
2160
-        if (empty($CNT_ISO) || ! EE_Maintenance_Mode::instance()->models_can_query()){
2160
+        if (empty($CNT_ISO) || ! EE_Maintenance_Mode::instance()->models_can_query()) {
2161 2161
             return;
2162 2162
         }
2163 2163
 
2164 2164
         /** @var TableAnalysis $table_analysis */
2165 2165
         $table_analysis = EE_Registry::instance()->create('TableAnalysis', [], true);
2166
-        if (! $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())) {
2166
+        if ( ! $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())) {
2167 2167
             return;
2168 2168
         }
2169 2169
         // retrieve the country settings from the db, just in case they have been customized
2170 2170
         $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2171
-        if (! $country instanceof EE_Country) {
2171
+        if ( ! $country instanceof EE_Country) {
2172 2172
             throw new DomainException(
2173 2173
                 esc_html__('Invalid Country ISO Code.', 'event_espresso')
2174 2174
             );
2175 2175
         }
2176
-        $this->code    = $country->currency_code();                  // currency code: USD, CAD, EUR
2177
-        $this->name    = $country->currency_name_single();           // Dollar
2178
-        $this->plural  = $country->currency_name_plural();           // Dollars
2179
-        $this->sign    = $country->currency_sign();                  // currency sign: $
2180
-        $this->sign_b4 = $country->currency_sign_before();           // currency sign before or after
2181
-        $this->dec_plc = $country->currency_decimal_places();        // decimal places: 2 = 0.00  3 = 0.000
2182
-        $this->dec_mrk = $country->currency_decimal_mark();          // decimal mark: ',' = 0,01 or '.' = 0.01
2183
-        $this->thsnds  = $country->currency_thousands_separator();   // thousands sep: ',' = 1,000 or '.' = 1.000
2176
+        $this->code    = $country->currency_code(); // currency code: USD, CAD, EUR
2177
+        $this->name    = $country->currency_name_single(); // Dollar
2178
+        $this->plural  = $country->currency_name_plural(); // Dollars
2179
+        $this->sign    = $country->currency_sign(); // currency sign: $
2180
+        $this->sign_b4 = $country->currency_sign_before(); // currency sign before or after
2181
+        $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00  3 = 0.000
2182
+        $this->dec_mrk = $country->currency_decimal_mark(); // decimal mark: ',' = 0,01 or '.' = 0.01
2183
+        $this->thsnds  = $country->currency_thousands_separator(); // thousands sep: ',' = 1,000 or '.' = 1.000
2184 2184
     }
2185 2185
 
2186 2186
 
@@ -2485,8 +2485,8 @@  discard block
 block discarded – undo
2485 2485
             $closing_a_tag = '';
2486 2486
             if (function_exists('get_privacy_policy_url')) {
2487 2487
                 $privacy_page_url = get_privacy_policy_url();
2488
-                if (! empty($privacy_page_url)) {
2489
-                    $opening_a_tag = '<a href="' . $privacy_page_url . '" target="_blank">';
2488
+                if ( ! empty($privacy_page_url)) {
2489
+                    $opening_a_tag = '<a href="'.$privacy_page_url.'" target="_blank">';
2490 2490
                     $closing_a_tag = '</a>';
2491 2491
                 }
2492 2492
             }
@@ -2718,7 +2718,7 @@  discard block
 block discarded – undo
2718 2718
     public function log_file_name($reset = false)
2719 2719
     {
2720 2720
         if (empty($this->log_file_name) || $reset) {
2721
-            $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2721
+            $this->log_file_name = sanitize_key('espresso_log_'.md5(uniqid('', true))).'.txt';
2722 2722
             EE_Config::instance()->update_espresso_config(false, false);
2723 2723
         }
2724 2724
         return $this->log_file_name;
@@ -2732,7 +2732,7 @@  discard block
 block discarded – undo
2732 2732
     public function debug_file_name($reset = false)
2733 2733
     {
2734 2734
         if (empty($this->debug_file_name) || $reset) {
2735
-            $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2735
+            $this->debug_file_name = sanitize_key('espresso_debug_'.md5(uniqid('', true))).'.txt';
2736 2736
             EE_Config::instance()->update_espresso_config(false, false);
2737 2737
         }
2738 2738
         return $this->debug_file_name;
@@ -2962,21 +2962,21 @@  discard block
 block discarded – undo
2962 2962
         $this->use_google_maps = true;
2963 2963
         $this->google_map_api_key = '';
2964 2964
         // for event details pages (reg page)
2965
-        $this->event_details_map_width = 585;            // ee_map_width_single
2966
-        $this->event_details_map_height = 362;            // ee_map_height_single
2967
-        $this->event_details_map_zoom = 14;            // ee_map_zoom_single
2968
-        $this->event_details_display_nav = true;            // ee_map_nav_display_single
2969
-        $this->event_details_nav_size = false;            // ee_map_nav_size_single
2970
-        $this->event_details_control_type = 'default';        // ee_map_type_control_single
2971
-        $this->event_details_map_align = 'center';            // ee_map_align_single
2965
+        $this->event_details_map_width = 585; // ee_map_width_single
2966
+        $this->event_details_map_height = 362; // ee_map_height_single
2967
+        $this->event_details_map_zoom = 14; // ee_map_zoom_single
2968
+        $this->event_details_display_nav = true; // ee_map_nav_display_single
2969
+        $this->event_details_nav_size = false; // ee_map_nav_size_single
2970
+        $this->event_details_control_type = 'default'; // ee_map_type_control_single
2971
+        $this->event_details_map_align = 'center'; // ee_map_align_single
2972 2972
         // for event list pages
2973
-        $this->event_list_map_width = 300;            // ee_map_width
2974
-        $this->event_list_map_height = 185;        // ee_map_height
2975
-        $this->event_list_map_zoom = 12;            // ee_map_zoom
2976
-        $this->event_list_display_nav = false;        // ee_map_nav_display
2977
-        $this->event_list_nav_size = true;            // ee_map_nav_size
2978
-        $this->event_list_control_type = 'dropdown';        // ee_map_type_control
2979
-        $this->event_list_map_align = 'center';            // ee_map_align
2973
+        $this->event_list_map_width = 300; // ee_map_width
2974
+        $this->event_list_map_height = 185; // ee_map_height
2975
+        $this->event_list_map_zoom = 12; // ee_map_zoom
2976
+        $this->event_list_display_nav = false; // ee_map_nav_display
2977
+        $this->event_list_nav_size = true; // ee_map_nav_size
2978
+        $this->event_list_control_type = 'dropdown'; // ee_map_type_control
2979
+        $this->event_list_map_align = 'center'; // ee_map_align
2980 2980
     }
2981 2981
 }
2982 2982
 
Please login to merge, or discard this patch.
core/db_classes/EE_Checkin.class.php 1 patch
Indentation   +127 added lines, -127 removed lines patch added patch discarded remove patch
@@ -9,131 +9,131 @@
 block discarded – undo
9 9
  */
10 10
 class EE_Checkin extends EE_Base_Class
11 11
 {
12
-    /**
13
-     * Registration can NOT be checked in or out
14
-     *
15
-     * @type int
16
-     */
17
-    const status_invalid = -1;
18
-
19
-    /**
20
-     * Registration has been checked out.
21
-     *
22
-     * @type int
23
-     */
24
-    const status_checked_out = 0;
25
-
26
-    /**
27
-     * Registration has been checked in.
28
-     *
29
-     * @type int
30
-     */
31
-    const status_checked_in = 1;
32
-
33
-    /**
34
-     * Registration has never been checked in.
35
-     *
36
-     * @type int
37
-     */
38
-    const status_checked_never = 2;
39
-
40
-
41
-    /**
42
-     *
43
-     * @param array|null  $props_n_values incoming values
44
-     * @param string|null $timezone       incoming timezone (if not set the timezone set for the website will be used.)
45
-     * @param array|null  $date_formats   incoming date_formats in an array
46
-     *                                    where the first value is the date_format
47
-     *                                    and the second value is the time format
48
-     * @return EE_Checkin
49
-     * @throws EE_Error
50
-     * @throws ReflectionException
51
-     */
52
-    public static function new_instance(
53
-        ?array $props_n_values = [],
54
-        ?string $timezone = '',
55
-        ?array $date_formats = []
56
-    ): EE_Checkin {
57
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
58
-        return $has_object ?: new self($props_n_values, false, $timezone, $date_formats);
59
-    }
60
-
61
-
62
-    /**
63
-     * @param array|null  $props_n_values incoming values from the database
64
-     * @param string|null $timezone       incoming timezone as set by the model.  If not set the timezone for
65
-     *                                    the website will be used.
66
-     * @return EE_Checkin
67
-     * @throws EE_Error
68
-     * @throws ReflectionException
69
-     */
70
-    public static function new_instance_from_db(?array $props_n_values = [], ?string $timezone = ''): EE_Checkin
71
-    {
72
-        return new self($props_n_values, true, $timezone);
73
-    }
74
-
75
-
76
-    public function ID()
77
-    {
78
-        return $this->get('CHK_ID');
79
-    }
80
-
81
-
82
-    /**
83
-     * @throws EE_Error
84
-     * @throws ReflectionException
85
-     */
86
-    public function registration_id(): int
87
-    {
88
-        return (int) $this->get('REG_ID');
89
-    }
90
-
91
-
92
-    /**
93
-     * @throws EE_Error
94
-     * @throws ReflectionException
95
-     */
96
-    public function datetime_id(): int
97
-    {
98
-        return (int) $this->get('DTT_ID');
99
-    }
100
-
101
-
102
-    /**
103
-     * @throws EE_Error
104
-     * @throws ReflectionException
105
-     */
106
-    public function status(): int
107
-    {
108
-        return (int) $this->get('CHK_in');
109
-    }
110
-
111
-
112
-    /**
113
-     * @throws ReflectionException
114
-     * @throws EE_Error
115
-     */
116
-    public function timestamp()
117
-    {
118
-        return $this->get('CHK_timestamp');
119
-    }
120
-
121
-
122
-    /**
123
-     * @throws EE_Error
124
-     * @throws ReflectionException
125
-     */
126
-    public function getCheckInText(): string
127
-    {
128
-        switch ($this->status()) {
129
-            case EE_Checkin::status_checked_in:
130
-                return esc_html__('Checked In', 'event_espresso');
131
-            case EE_Checkin::status_checked_out:
132
-                return esc_html__('Checked Out', 'event_espresso');
133
-            case EE_Checkin::status_checked_never:
134
-                return esc_html__('Never Checked In', 'event_espresso');
135
-            default:
136
-                return esc_html__('Can Not Check-in', 'event_espresso');
137
-        }
138
-    }
12
+	/**
13
+	 * Registration can NOT be checked in or out
14
+	 *
15
+	 * @type int
16
+	 */
17
+	const status_invalid = -1;
18
+
19
+	/**
20
+	 * Registration has been checked out.
21
+	 *
22
+	 * @type int
23
+	 */
24
+	const status_checked_out = 0;
25
+
26
+	/**
27
+	 * Registration has been checked in.
28
+	 *
29
+	 * @type int
30
+	 */
31
+	const status_checked_in = 1;
32
+
33
+	/**
34
+	 * Registration has never been checked in.
35
+	 *
36
+	 * @type int
37
+	 */
38
+	const status_checked_never = 2;
39
+
40
+
41
+	/**
42
+	 *
43
+	 * @param array|null  $props_n_values incoming values
44
+	 * @param string|null $timezone       incoming timezone (if not set the timezone set for the website will be used.)
45
+	 * @param array|null  $date_formats   incoming date_formats in an array
46
+	 *                                    where the first value is the date_format
47
+	 *                                    and the second value is the time format
48
+	 * @return EE_Checkin
49
+	 * @throws EE_Error
50
+	 * @throws ReflectionException
51
+	 */
52
+	public static function new_instance(
53
+		?array $props_n_values = [],
54
+		?string $timezone = '',
55
+		?array $date_formats = []
56
+	): EE_Checkin {
57
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
58
+		return $has_object ?: new self($props_n_values, false, $timezone, $date_formats);
59
+	}
60
+
61
+
62
+	/**
63
+	 * @param array|null  $props_n_values incoming values from the database
64
+	 * @param string|null $timezone       incoming timezone as set by the model.  If not set the timezone for
65
+	 *                                    the website will be used.
66
+	 * @return EE_Checkin
67
+	 * @throws EE_Error
68
+	 * @throws ReflectionException
69
+	 */
70
+	public static function new_instance_from_db(?array $props_n_values = [], ?string $timezone = ''): EE_Checkin
71
+	{
72
+		return new self($props_n_values, true, $timezone);
73
+	}
74
+
75
+
76
+	public function ID()
77
+	{
78
+		return $this->get('CHK_ID');
79
+	}
80
+
81
+
82
+	/**
83
+	 * @throws EE_Error
84
+	 * @throws ReflectionException
85
+	 */
86
+	public function registration_id(): int
87
+	{
88
+		return (int) $this->get('REG_ID');
89
+	}
90
+
91
+
92
+	/**
93
+	 * @throws EE_Error
94
+	 * @throws ReflectionException
95
+	 */
96
+	public function datetime_id(): int
97
+	{
98
+		return (int) $this->get('DTT_ID');
99
+	}
100
+
101
+
102
+	/**
103
+	 * @throws EE_Error
104
+	 * @throws ReflectionException
105
+	 */
106
+	public function status(): int
107
+	{
108
+		return (int) $this->get('CHK_in');
109
+	}
110
+
111
+
112
+	/**
113
+	 * @throws ReflectionException
114
+	 * @throws EE_Error
115
+	 */
116
+	public function timestamp()
117
+	{
118
+		return $this->get('CHK_timestamp');
119
+	}
120
+
121
+
122
+	/**
123
+	 * @throws EE_Error
124
+	 * @throws ReflectionException
125
+	 */
126
+	public function getCheckInText(): string
127
+	{
128
+		switch ($this->status()) {
129
+			case EE_Checkin::status_checked_in:
130
+				return esc_html__('Checked In', 'event_espresso');
131
+			case EE_Checkin::status_checked_out:
132
+				return esc_html__('Checked Out', 'event_espresso');
133
+			case EE_Checkin::status_checked_never:
134
+				return esc_html__('Never Checked In', 'event_espresso');
135
+			default:
136
+				return esc_html__('Can Not Check-in', 'event_espresso');
137
+		}
138
+	}
139 139
 }
Please login to merge, or discard this patch.