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