Completed
Branch dev (3710f0)
by
unknown
25:03 queued 15:31
created
admin_pages/venues/Venues_Admin_Page.core.php 1 patch
Indentation   +1562 added lines, -1562 removed lines patch added patch discarded remove patch
@@ -13,1572 +13,1572 @@
 block discarded – undo
13 13
  */
14 14
 class Venues_Admin_Page extends EE_Admin_Page_CPT
15 15
 {
16
-    /**
17
-     * _venue
18
-     * This will hold the venue object for venue_details screen.
19
-     *
20
-     * @access protected
21
-     * @var object
22
-     */
23
-    protected $_venue;
24
-
25
-
26
-    /**
27
-     * This will hold the category object for category_details screen.
28
-     *
29
-     * @var object
30
-     */
31
-    protected $_category;
32
-
33
-
34
-    /**
35
-     * This property will hold the venue model instance
36
-     *
37
-     * @var object
38
-     */
39
-    protected $_venue_model;
40
-
41
-
42
-    /**
43
-     * @throws EE_Error
44
-     */
45
-    protected function _init_page_props()
46
-    {
47
-        require_once(EE_MODELS . 'EEM_Venue.model.php');
48
-        $this->page_slug        = EE_VENUES_PG_SLUG;
49
-        $this->_admin_base_url  = EE_VENUES_ADMIN_URL;
50
-        $this->_admin_base_path = EE_ADMIN_PAGES . 'venues';
51
-        $this->page_label       = esc_html__('Event Venues', 'event_espresso');
52
-        $this->_cpt_model_names = [
53
-            'create_new' => 'EEM_Venue',
54
-            'edit'       => 'EEM_Venue',
55
-        ];
56
-        $this->_cpt_edit_routes = [
57
-            'espresso_venues' => 'edit',
58
-        ];
59
-        $this->_venue_model     = EEM_Venue::instance();
60
-    }
61
-
62
-
63
-    protected function _ajax_hooks()
64
-    {
65
-        // todo: all hooks for ee_venues ajax goes in here.
66
-    }
67
-
68
-
69
-    protected function _define_page_props()
70
-    {
71
-        $this->_admin_page_title = $this->page_label;
72
-        $this->_labels           = [
73
-            'buttons'      => [
74
-                'add'             => esc_html__('Add New Venue', 'event_espresso'),
75
-                'edit'            => esc_html__('Edit Venue', 'event_espresso'),
76
-                'delete'          => esc_html__('Delete Venue', 'event_espresso'),
77
-                'add_category'    => esc_html__('Add New Category', 'event_espresso'),
78
-                'edit_category'   => esc_html__('Edit Category', 'event_espresso'),
79
-                'delete_category' => esc_html__('Delete Category', 'event_espresso'),
80
-            ],
81
-            'editor_title' => [
82
-                'espresso_venues' => esc_html__('Enter Venue name here', 'event_espresso'),
83
-            ],
84
-            'publishbox'   => [
85
-                'create_new'          => esc_html__('Save New Venue', 'event_espresso'),
86
-                'edit'                => esc_html__('Update Venue', 'event_espresso'),
87
-                'add_category'        => esc_html__('Save New Category', 'event_espresso'),
88
-                'edit_category'       => esc_html__('Update Category', 'event_espresso'),
89
-                'google_map_settings' => esc_html__('Update Settings', 'event_espresso'),
90
-            ],
91
-        ];
92
-    }
93
-
94
-
95
-    protected function _set_page_routes()
96
-    {
97
-
98
-        // load formatter helper
99
-        // load field generator helper
100
-
101
-        // is there a vnu_id in the request?
102
-        $VNU_ID = $this->request->getRequestParam('VNU_ID', 0, 'int');
103
-        $VNU_ID = $this->request->getRequestParam('post', $VNU_ID, 'int');
104
-
105
-        $this->_page_routes = [
106
-            'default'                    => [
107
-                'func'       => [$this, '_overview_list_table'],
108
-                'capability' => 'ee_read_venues',
109
-            ],
110
-            'create_new'                 => [
111
-                'func'       => [$this, '_create_new_cpt_item'],
112
-                'capability' => 'ee_edit_venues',
113
-            ],
114
-            'edit'                       => [
115
-                'func'       => [$this, '_edit_cpt_item'],
116
-                'capability' => 'ee_edit_venue',
117
-                'obj_id'     => $VNU_ID,
118
-            ],
119
-            'trash_venue'                => [
120
-                'func'       => [$this, '_trash_or_restore_venue'],
121
-                'args'       => ['venue_status' => 'trash'],
122
-                'noheader'   => true,
123
-                'capability' => 'ee_delete_venue',
124
-                'obj_id'     => $VNU_ID,
125
-            ],
126
-            'trash_venues'               => [
127
-                'func'       => [$this, '_trash_or_restore_venues'],
128
-                'args'       => ['venue_status' => 'trash'],
129
-                'noheader'   => true,
130
-                'capability' => 'ee_delete_venues',
131
-            ],
132
-            'restore_venue'              => [
133
-                'func'       => [$this, '_trash_or_restore_venue'],
134
-                'args'       => ['venue_status' => 'draft'],
135
-                'noheader'   => true,
136
-                'capability' => 'ee_delete_venue',
137
-                'obj_id'     => $VNU_ID,
138
-            ],
139
-            'restore_venues'             => [
140
-                'func'       => [$this, '_trash_or_restore_venues'],
141
-                'args'       => ['venue_status' => 'draft'],
142
-                'noheader'   => true,
143
-                'capability' => 'ee_delete_venues',
144
-            ],
145
-            'delete_venues'              => [
146
-                'func'       => [$this, '_delete_venues'],
147
-                'noheader'   => true,
148
-                'capability' => 'ee_delete_venues',
149
-            ],
150
-            'delete_venue'               => [
151
-                'func'       => [$this, '_delete_venue'],
152
-                'noheader'   => true,
153
-                'capability' => 'ee_delete_venue',
154
-                'obj_id'     => $VNU_ID,
155
-            ],
156
-            // settings related
157
-            'google_map_settings'        => [
158
-                'func'       => [$this, '_google_map_settings'],
159
-                'capability' => 'manage_options',
160
-            ],
161
-            'update_google_map_settings' => [
162
-                'func'       => [$this, '_update_google_map_settings'],
163
-                'capability' => 'manage_options',
164
-                'noheader'   => true,
165
-            ],
166
-            // venue category tab related
167
-            'add_category'               => [
168
-                'func'       => [$this, '_category_details'],
169
-                'args'       => ['add'],
170
-                'capability' => 'ee_edit_venue_category',
171
-            ],
172
-            'edit_category'              => [
173
-                'func'       => [$this, '_category_details'],
174
-                'args'       => ['edit'],
175
-                'capability' => 'ee_edit_venue_category',
176
-            ],
177
-            'delete_categories'          => [
178
-                'func'       => [$this, '_delete_categories'],
179
-                'noheader'   => true,
180
-                'capability' => 'ee_delete_venue_category',
181
-            ],
182
-
183
-            'delete_category' => [
184
-                'func'       => [$this, '_delete_categories'],
185
-                'noheader'   => true,
186
-                'capability' => 'ee_delete_venue_category',
187
-            ],
188
-
189
-            'insert_category' => [
190
-                'func'       => [$this, '_insert_or_update_category'],
191
-                'args'       => ['new_category' => true],
192
-                'noheader'   => true,
193
-                'capability' => 'ee_edit_venue_category',
194
-            ],
195
-
196
-            'update_category'   => [
197
-                'func'       => [$this, '_insert_or_update_category'],
198
-                'args'       => ['new_category' => false],
199
-                'noheader'   => true,
200
-                'capability' => 'ee_edit_venue_category',
201
-            ],
202
-            'export_categories' => [
203
-                'func'       => [$this, '_categories_export'],
204
-                'noheader'   => true,
205
-                'capability' => 'export',
206
-            ],
207
-            'import_categories' => [
208
-                'func'       => [$this, '_import_categories'],
209
-                'capability' => 'import',
210
-            ],
211
-            'category_list'     => [
212
-                'func'       => [$this, '_category_list_table'],
213
-                'capability' => 'ee_manage_venue_categories',
214
-            ],
215
-        ];
216
-    }
217
-
218
-
219
-    protected function _set_page_config()
220
-    {
221
-        $VNU_ID     = $this->request->getRequestParam('post', 0, 'int');
222
-        $EVT_CAT_ID = $this->request->getRequestParam('EVT_CAT_ID', 0, 'int');
223
-
224
-        $this->_page_config = [
225
-            'default'             => [
226
-                'nav'           => [
227
-                    'label' => esc_html__('Overview', 'event_espresso'),
228
-                    'icon' => 'dashicons-list-view',
229
-                    'order' => 10,
230
-                ],
231
-                'list_table'    => 'Venues_Admin_List_Table',
232
-                'help_tabs'     => [
233
-                    'venues_overview_help_tab'                           => [
234
-                        'title'    => esc_html__('Venues Overview', 'event_espresso'),
235
-                        'filename' => 'venues_overview',
236
-                    ],
237
-                    'venues_overview_table_column_headings_help_tab'     => [
238
-                        'title'    => esc_html__('Venues Overview Table Column Headings', 'event_espresso'),
239
-                        'filename' => 'venues_overview_table_column_headings',
240
-                    ],
241
-                    'venues_overview_views_bulk_actions_search_help_tab' => [
242
-                        'title'    => esc_html__('Venues Overview Views & Bulk Actions & Search', 'event_espresso'),
243
-                        'filename' => 'venues_overview_views_bulk_actions_search',
244
-                    ],
245
-                ],
246
-                'metaboxes'     => ['_espresso_news_post_box', '_espresso_links_post_box'],
247
-                'require_nonce' => false,
248
-            ],
249
-            'create_new'          => [
250
-                'nav'           => [
251
-                    'label'      => esc_html__('Add Venue', 'event_espresso'),
252
-                    'icon' => 'dashicons-plus-alt',
253
-                    'order'      => 15,
254
-                    'persistent' => false,
255
-                ],
256
-                'help_tabs'     => [
257
-                    'venues_editor_help_tab'                                               => [
258
-                        'title'    => esc_html__('Venue Editor', 'event_espresso'),
259
-                        'filename' => 'venues_editor',
260
-                    ],
261
-                    'venues_editor_title_richtexteditor_help_tab'                          => [
262
-                        'title'    => esc_html__('Venue Title & Rich Text Editor', 'event_espresso'),
263
-                        'filename' => 'venues_editor_title_richtexteditor',
264
-                    ],
265
-                    'venues_editor_tags_categories_help_tab'                               => [
266
-                        'title'    => esc_html__('Venue Tags & Categories', 'event_espresso'),
267
-                        'filename' => 'venues_editor_tags_categories',
268
-                    ],
269
-                    'venues_editor_physical_location_google_map_virtual_location_help_tab' => [
270
-                        'title'    => esc_html__(
271
-                            'Venue Editor Physical Location & Google Map & Virtual Location',
272
-                            'event_espresso'
273
-                        ),
274
-                        'filename' => 'venues_editor_physical_location_google_map_virtual_location',
275
-                    ],
276
-                    'venues_editor_save_new_venue_help_tab'                                => [
277
-                        'title'    => esc_html__('Save New Venue', 'event_espresso'),
278
-                        'filename' => 'venues_editor_save_new_venue',
279
-                    ],
280
-                    'venues_editor_other_help_tab'                                         => [
281
-                        'title'    => esc_html__('Venue Editor Other', 'event_espresso'),
282
-                        'filename' => 'venues_editor_other',
283
-                    ],
284
-                ],
285
-                'metaboxes'     => ['_venue_editor_metaboxes'],
286
-                'require_nonce' => false,
287
-            ],
288
-            'edit'                => [
289
-                'nav'           => [
290
-                    'label'      => esc_html__('Edit Venue', 'event_espresso'),
291
-                    'icon' => 'dashicons-edit-large',
292
-                    'order'      => 15,
293
-                    'persistent' => false,
294
-                    'url'        => $VNU_ID
295
-                        ? add_query_arg(['post' => $VNU_ID], $this->_current_page_view_url)
296
-                        : $this->_admin_base_url,
297
-                ],
298
-                'help_tabs'     => [
299
-                    'venues_editor_help_tab'                                               => [
300
-                        'title'    => esc_html__('Venue Editor', 'event_espresso'),
301
-                        'filename' => 'venues_editor',
302
-                    ],
303
-                    'venues_editor_title_richtexteditor_help_tab'                          => [
304
-                        'title'    => esc_html__('Venue Title & Rich Text Editor', 'event_espresso'),
305
-                        'filename' => 'venues_editor_title_richtexteditor',
306
-                    ],
307
-                    'venues_editor_tags_categories_help_tab'                               => [
308
-                        'title'    => esc_html__('Venue Tags & Categories', 'event_espresso'),
309
-                        'filename' => 'venues_editor_tags_categories',
310
-                    ],
311
-                    'venues_editor_physical_location_google_map_virtual_location_help_tab' => [
312
-                        'title'    => esc_html__(
313
-                            'Venue Editor Physical Location & Google Map & Virtual Location',
314
-                            'event_espresso'
315
-                        ),
316
-                        'filename' => 'venues_editor_physical_location_google_map_virtual_location',
317
-                    ],
318
-                    'venues_editor_save_new_venue_help_tab'                                => [
319
-                        'title'    => esc_html__('Save New Venue', 'event_espresso'),
320
-                        'filename' => 'venues_editor_save_new_venue',
321
-                    ],
322
-                    'venues_editor_other_help_tab'                                         => [
323
-                        'title'    => esc_html__('Venue Editor Other', 'event_espresso'),
324
-                        'filename' => 'venues_editor_other',
325
-                    ],
326
-                ],
327
-                'metaboxes'     => ['_venue_editor_metaboxes'],
328
-                'require_nonce' => false,
329
-            ],
330
-            'google_map_settings' => [
331
-                'nav'           => [
332
-                    'label' => esc_html__('Google Maps', 'event_espresso'),
333
-                    'icon' => 'dashicons-location-alt',
334
-                    'order' => 40,
335
-                ],
336
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
337
-                'help_tabs'     => [
338
-                    'general_settings_google_maps_help_tab' => [
339
-                        'title'    => esc_html__('Google Maps', 'event_espresso'),
340
-                        'filename' => 'general_settings_google_maps',
341
-                    ],
342
-                ],
343
-                'require_nonce' => false,
344
-            ],
345
-            // venue category stuff
346
-            'add_category'        => [
347
-                'nav'           => [
348
-                    'label'      => esc_html__('Add Category', 'event_espresso'),
349
-                    'icon' => 'dashicons-plus-alt',
350
-                    'order'      => 25,
351
-                    'persistent' => false,
352
-                ],
353
-                'metaboxes'     => ['_publish_post_box'],
354
-                'help_tabs'     => [
355
-                    'venues_add_category_help_tab' => [
356
-                        'title'    => esc_html__('Add New Venue Category', 'event_espresso'),
357
-                        'filename' => 'venues_add_category',
358
-                    ],
359
-                ],
360
-                'require_nonce' => false,
361
-            ],
362
-            'edit_category'       => [
363
-                'nav'           => [
364
-                    'label'      => esc_html__('Edit Category', 'event_espresso'),
365
-                    'icon' => 'dashicons-edit-large',
366
-                    'order'      => 25,
367
-                    'persistent' => false,
368
-                    'url'        => $EVT_CAT_ID
369
-                        ? add_query_arg(['EVT_CAT_ID' => $EVT_CAT_ID], $this->_current_page_view_url)
370
-                        : $this->_admin_base_url,
371
-                ],
372
-                'metaboxes'     => ['_publish_post_box'],
373
-                'help_tabs'     => [
374
-                    'venues_edit_category_help_tab' => [
375
-                        'title'    => esc_html__('Edit Venue Category', 'event_espresso'),
376
-                        'filename' => 'venues_edit_category',
377
-                    ],
378
-                ],
379
-                'require_nonce' => false,
380
-            ],
381
-            'category_list'       => [
382
-                'nav'           => [
383
-                    'label' => esc_html__('Categories', 'event_espresso'),
384
-                    'icon' => 'dashicons-networking',
385
-                    'order' => 20,
386
-                ],
387
-                'list_table'    => 'Venue_Categories_Admin_List_Table',
388
-                'help_tabs'     => [
389
-                    'venues_categories_help_tab'                       => [
390
-                        'title'    => esc_html__('Venue Categories', 'event_espresso'),
391
-                        'filename' => 'venues_categories',
392
-                    ],
393
-                    'venues_categories_table_column_headings_help_tab' => [
394
-                        'title'    => esc_html__('Venue Categories Table Column Headings', 'event_espresso'),
395
-                        'filename' => 'venues_categories_table_column_headings',
396
-                    ],
397
-                    'venues_categories_views_help_tab'                 => [
398
-                        'title'    => esc_html__('Venue Categories Views', 'event_espresso'),
399
-                        'filename' => 'venues_categories_views',
400
-                    ],
401
-                    'venues_categories_other_help_tab'                 => [
402
-                        'title'    => esc_html__('Venue Categories Other', 'event_espresso'),
403
-                        'filename' => 'venues_categories_other',
404
-                    ],
405
-                ],
406
-                'metaboxes'     => $this->_default_espresso_metaboxes,
407
-                'require_nonce' => false,
408
-            ],
409
-        ];
410
-    }
411
-
412
-
413
-    protected function _add_screen_options()
414
-    {
415
-        // todo
416
-    }
417
-
418
-
419
-    protected function _add_screen_options_default()
420
-    {
421
-        $this->_per_page_screen_option();
422
-    }
423
-
424
-
425
-    protected function _add_screen_options_category_list()
426
-    {
427
-        $page_title              = $this->_admin_page_title;
428
-        $this->_admin_page_title = esc_html__('Venue Categories', 'event_espresso');
429
-        $this->_per_page_screen_option();
430
-        $this->_admin_page_title = $page_title;
431
-    }
432
-
433
-
434
-    // none of the below group are currently used for Event Venues
435
-    protected function _add_feature_pointers()
436
-    {
437
-    }
438
-
439
-
440
-    public function admin_init()
441
-    {
442
-    }
443
-
444
-
445
-    public function admin_notices()
446
-    {
447
-    }
448
-
449
-
450
-    public function admin_footer_scripts()
451
-    {
452
-    }
453
-
454
-
455
-    public function load_scripts_styles_create_new()
456
-    {
457
-        $this->load_scripts_styles_edit();
458
-    }
459
-
460
-
461
-    public function load_scripts_styles()
462
-    {
463
-        wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', [], EVENT_ESPRESSO_VERSION);
464
-        wp_enqueue_style('ee-cat-admin');
465
-    }
466
-
467
-
468
-    public function load_scripts_styles_add_category()
469
-    {
470
-        $this->load_scripts_styles_edit_category();
471
-    }
472
-
473
-
474
-    public function load_scripts_styles_edit_category()
475
-    {
476
-    }
477
-
478
-
479
-    public function load_scripts_styles_edit()
480
-    {
481
-        // styles
482
-        wp_enqueue_style('espresso-ui-theme');
483
-        wp_register_style(
484
-            'espresso_venues',
485
-            EE_VENUES_ASSETS_URL . 'ee-venues-admin.css',
486
-            [],
487
-            EVENT_ESPRESSO_VERSION
488
-        );
489
-        wp_enqueue_style('espresso_venues');
490
-    }
491
-
492
-
493
-    protected function _set_list_table_views_default()
494
-    {
495
-        $this->_views = [
496
-            'all' => [
497
-                'slug'        => 'all',
498
-                'label'       => esc_html__('View All Venues', 'event_espresso'),
499
-                'count'       => 0,
500
-                'bulk_action' => [],
501
-            ],
502
-        ];
503
-
504
-        if (EE_Registry::instance()->CAP->current_user_can('ee_delete_venues', 'espresso_venues_trash_venues')) {
505
-            $this->_views['all']['bulk_action'] = [
506
-                'trash_venues' => esc_html__('Move to Trash', 'event_espresso'),
507
-            ];
508
-            $this->_views['trash']              = [
509
-                'slug'        => 'trash',
510
-                'label'       => esc_html__('Trash', 'event_espresso'),
511
-                'count'       => 0,
512
-                'bulk_action' => [
513
-                    'restore_venues' => esc_html__('Restore from Trash', 'event_espresso'),
514
-                    'delete_venues'  => esc_html__('Delete', 'event_espresso'),
515
-                ],
516
-            ];
517
-        }
518
-    }
519
-
520
-
521
-    protected function _set_list_table_views_category_list()
522
-    {
523
-        $this->_views = [
524
-            'all' => [
525
-                'slug'        => 'all',
526
-                'label'       => esc_html__('All', 'event_espresso'),
527
-                'count'       => 0,
528
-                'bulk_action' => [
529
-                    'delete_categories' => esc_html__('Delete Permanently', 'event_espresso'),
530
-                ],
531
-            ],
532
-        ];
533
-    }
534
-
535
-
536
-    /**
537
-     * @throws EE_Error
538
-     */
539
-    protected function _overview_list_table()
540
-    {
541
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
542
-        $this->_template_args['after_list_table'] = EEH_Template::get_button_or_link(
543
-            get_post_type_archive_link('espresso_venues'),
544
-            esc_html__("View Venue Archive Page", "event_espresso"),
545
-            'button'
546
-        );
547
-
548
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
549
-            'create_new',
550
-            'add',
551
-            [],
552
-            'add-new-h2'
553
-        );
554
-
555
-        $this->_search_btn_label  = esc_html__('Venues', 'event_espresso');
556
-        $this->display_admin_list_table_page_with_sidebar();
557
-    }
558
-
559
-
560
-    /**
561
-     * @throws EE_Error
562
-     * @throws ReflectionException
563
-     */
564
-    public function extra_misc_actions_publish_box()
565
-    {
566
-        $extra_rows = [
567
-            'vnu_capacity' => $this->_cpt_model_obj->get_f('VNU_capacity'),
568
-            'vnu_url'      => $this->_cpt_model_obj->get_f('VNU_url'),
569
-            'vnu_phone'    => $this->_cpt_model_obj->get_f('VNU_phone'),
570
-        ];
571
-        $template   = EE_VENUES_TEMPLATE_PATH . 'venue_publish_box_extras.template.php';
572
-        EEH_Template::display_template($template, $extra_rows);
573
-    }
574
-
575
-
576
-    /*************        Google Maps        *************
16
+	/**
17
+	 * _venue
18
+	 * This will hold the venue object for venue_details screen.
19
+	 *
20
+	 * @access protected
21
+	 * @var object
22
+	 */
23
+	protected $_venue;
24
+
25
+
26
+	/**
27
+	 * This will hold the category object for category_details screen.
28
+	 *
29
+	 * @var object
30
+	 */
31
+	protected $_category;
32
+
33
+
34
+	/**
35
+	 * This property will hold the venue model instance
36
+	 *
37
+	 * @var object
38
+	 */
39
+	protected $_venue_model;
40
+
41
+
42
+	/**
43
+	 * @throws EE_Error
44
+	 */
45
+	protected function _init_page_props()
46
+	{
47
+		require_once(EE_MODELS . 'EEM_Venue.model.php');
48
+		$this->page_slug        = EE_VENUES_PG_SLUG;
49
+		$this->_admin_base_url  = EE_VENUES_ADMIN_URL;
50
+		$this->_admin_base_path = EE_ADMIN_PAGES . 'venues';
51
+		$this->page_label       = esc_html__('Event Venues', 'event_espresso');
52
+		$this->_cpt_model_names = [
53
+			'create_new' => 'EEM_Venue',
54
+			'edit'       => 'EEM_Venue',
55
+		];
56
+		$this->_cpt_edit_routes = [
57
+			'espresso_venues' => 'edit',
58
+		];
59
+		$this->_venue_model     = EEM_Venue::instance();
60
+	}
61
+
62
+
63
+	protected function _ajax_hooks()
64
+	{
65
+		// todo: all hooks for ee_venues ajax goes in here.
66
+	}
67
+
68
+
69
+	protected function _define_page_props()
70
+	{
71
+		$this->_admin_page_title = $this->page_label;
72
+		$this->_labels           = [
73
+			'buttons'      => [
74
+				'add'             => esc_html__('Add New Venue', 'event_espresso'),
75
+				'edit'            => esc_html__('Edit Venue', 'event_espresso'),
76
+				'delete'          => esc_html__('Delete Venue', 'event_espresso'),
77
+				'add_category'    => esc_html__('Add New Category', 'event_espresso'),
78
+				'edit_category'   => esc_html__('Edit Category', 'event_espresso'),
79
+				'delete_category' => esc_html__('Delete Category', 'event_espresso'),
80
+			],
81
+			'editor_title' => [
82
+				'espresso_venues' => esc_html__('Enter Venue name here', 'event_espresso'),
83
+			],
84
+			'publishbox'   => [
85
+				'create_new'          => esc_html__('Save New Venue', 'event_espresso'),
86
+				'edit'                => esc_html__('Update Venue', 'event_espresso'),
87
+				'add_category'        => esc_html__('Save New Category', 'event_espresso'),
88
+				'edit_category'       => esc_html__('Update Category', 'event_espresso'),
89
+				'google_map_settings' => esc_html__('Update Settings', 'event_espresso'),
90
+			],
91
+		];
92
+	}
93
+
94
+
95
+	protected function _set_page_routes()
96
+	{
97
+
98
+		// load formatter helper
99
+		// load field generator helper
100
+
101
+		// is there a vnu_id in the request?
102
+		$VNU_ID = $this->request->getRequestParam('VNU_ID', 0, 'int');
103
+		$VNU_ID = $this->request->getRequestParam('post', $VNU_ID, 'int');
104
+
105
+		$this->_page_routes = [
106
+			'default'                    => [
107
+				'func'       => [$this, '_overview_list_table'],
108
+				'capability' => 'ee_read_venues',
109
+			],
110
+			'create_new'                 => [
111
+				'func'       => [$this, '_create_new_cpt_item'],
112
+				'capability' => 'ee_edit_venues',
113
+			],
114
+			'edit'                       => [
115
+				'func'       => [$this, '_edit_cpt_item'],
116
+				'capability' => 'ee_edit_venue',
117
+				'obj_id'     => $VNU_ID,
118
+			],
119
+			'trash_venue'                => [
120
+				'func'       => [$this, '_trash_or_restore_venue'],
121
+				'args'       => ['venue_status' => 'trash'],
122
+				'noheader'   => true,
123
+				'capability' => 'ee_delete_venue',
124
+				'obj_id'     => $VNU_ID,
125
+			],
126
+			'trash_venues'               => [
127
+				'func'       => [$this, '_trash_or_restore_venues'],
128
+				'args'       => ['venue_status' => 'trash'],
129
+				'noheader'   => true,
130
+				'capability' => 'ee_delete_venues',
131
+			],
132
+			'restore_venue'              => [
133
+				'func'       => [$this, '_trash_or_restore_venue'],
134
+				'args'       => ['venue_status' => 'draft'],
135
+				'noheader'   => true,
136
+				'capability' => 'ee_delete_venue',
137
+				'obj_id'     => $VNU_ID,
138
+			],
139
+			'restore_venues'             => [
140
+				'func'       => [$this, '_trash_or_restore_venues'],
141
+				'args'       => ['venue_status' => 'draft'],
142
+				'noheader'   => true,
143
+				'capability' => 'ee_delete_venues',
144
+			],
145
+			'delete_venues'              => [
146
+				'func'       => [$this, '_delete_venues'],
147
+				'noheader'   => true,
148
+				'capability' => 'ee_delete_venues',
149
+			],
150
+			'delete_venue'               => [
151
+				'func'       => [$this, '_delete_venue'],
152
+				'noheader'   => true,
153
+				'capability' => 'ee_delete_venue',
154
+				'obj_id'     => $VNU_ID,
155
+			],
156
+			// settings related
157
+			'google_map_settings'        => [
158
+				'func'       => [$this, '_google_map_settings'],
159
+				'capability' => 'manage_options',
160
+			],
161
+			'update_google_map_settings' => [
162
+				'func'       => [$this, '_update_google_map_settings'],
163
+				'capability' => 'manage_options',
164
+				'noheader'   => true,
165
+			],
166
+			// venue category tab related
167
+			'add_category'               => [
168
+				'func'       => [$this, '_category_details'],
169
+				'args'       => ['add'],
170
+				'capability' => 'ee_edit_venue_category',
171
+			],
172
+			'edit_category'              => [
173
+				'func'       => [$this, '_category_details'],
174
+				'args'       => ['edit'],
175
+				'capability' => 'ee_edit_venue_category',
176
+			],
177
+			'delete_categories'          => [
178
+				'func'       => [$this, '_delete_categories'],
179
+				'noheader'   => true,
180
+				'capability' => 'ee_delete_venue_category',
181
+			],
182
+
183
+			'delete_category' => [
184
+				'func'       => [$this, '_delete_categories'],
185
+				'noheader'   => true,
186
+				'capability' => 'ee_delete_venue_category',
187
+			],
188
+
189
+			'insert_category' => [
190
+				'func'       => [$this, '_insert_or_update_category'],
191
+				'args'       => ['new_category' => true],
192
+				'noheader'   => true,
193
+				'capability' => 'ee_edit_venue_category',
194
+			],
195
+
196
+			'update_category'   => [
197
+				'func'       => [$this, '_insert_or_update_category'],
198
+				'args'       => ['new_category' => false],
199
+				'noheader'   => true,
200
+				'capability' => 'ee_edit_venue_category',
201
+			],
202
+			'export_categories' => [
203
+				'func'       => [$this, '_categories_export'],
204
+				'noheader'   => true,
205
+				'capability' => 'export',
206
+			],
207
+			'import_categories' => [
208
+				'func'       => [$this, '_import_categories'],
209
+				'capability' => 'import',
210
+			],
211
+			'category_list'     => [
212
+				'func'       => [$this, '_category_list_table'],
213
+				'capability' => 'ee_manage_venue_categories',
214
+			],
215
+		];
216
+	}
217
+
218
+
219
+	protected function _set_page_config()
220
+	{
221
+		$VNU_ID     = $this->request->getRequestParam('post', 0, 'int');
222
+		$EVT_CAT_ID = $this->request->getRequestParam('EVT_CAT_ID', 0, 'int');
223
+
224
+		$this->_page_config = [
225
+			'default'             => [
226
+				'nav'           => [
227
+					'label' => esc_html__('Overview', 'event_espresso'),
228
+					'icon' => 'dashicons-list-view',
229
+					'order' => 10,
230
+				],
231
+				'list_table'    => 'Venues_Admin_List_Table',
232
+				'help_tabs'     => [
233
+					'venues_overview_help_tab'                           => [
234
+						'title'    => esc_html__('Venues Overview', 'event_espresso'),
235
+						'filename' => 'venues_overview',
236
+					],
237
+					'venues_overview_table_column_headings_help_tab'     => [
238
+						'title'    => esc_html__('Venues Overview Table Column Headings', 'event_espresso'),
239
+						'filename' => 'venues_overview_table_column_headings',
240
+					],
241
+					'venues_overview_views_bulk_actions_search_help_tab' => [
242
+						'title'    => esc_html__('Venues Overview Views & Bulk Actions & Search', 'event_espresso'),
243
+						'filename' => 'venues_overview_views_bulk_actions_search',
244
+					],
245
+				],
246
+				'metaboxes'     => ['_espresso_news_post_box', '_espresso_links_post_box'],
247
+				'require_nonce' => false,
248
+			],
249
+			'create_new'          => [
250
+				'nav'           => [
251
+					'label'      => esc_html__('Add Venue', 'event_espresso'),
252
+					'icon' => 'dashicons-plus-alt',
253
+					'order'      => 15,
254
+					'persistent' => false,
255
+				],
256
+				'help_tabs'     => [
257
+					'venues_editor_help_tab'                                               => [
258
+						'title'    => esc_html__('Venue Editor', 'event_espresso'),
259
+						'filename' => 'venues_editor',
260
+					],
261
+					'venues_editor_title_richtexteditor_help_tab'                          => [
262
+						'title'    => esc_html__('Venue Title & Rich Text Editor', 'event_espresso'),
263
+						'filename' => 'venues_editor_title_richtexteditor',
264
+					],
265
+					'venues_editor_tags_categories_help_tab'                               => [
266
+						'title'    => esc_html__('Venue Tags & Categories', 'event_espresso'),
267
+						'filename' => 'venues_editor_tags_categories',
268
+					],
269
+					'venues_editor_physical_location_google_map_virtual_location_help_tab' => [
270
+						'title'    => esc_html__(
271
+							'Venue Editor Physical Location & Google Map & Virtual Location',
272
+							'event_espresso'
273
+						),
274
+						'filename' => 'venues_editor_physical_location_google_map_virtual_location',
275
+					],
276
+					'venues_editor_save_new_venue_help_tab'                                => [
277
+						'title'    => esc_html__('Save New Venue', 'event_espresso'),
278
+						'filename' => 'venues_editor_save_new_venue',
279
+					],
280
+					'venues_editor_other_help_tab'                                         => [
281
+						'title'    => esc_html__('Venue Editor Other', 'event_espresso'),
282
+						'filename' => 'venues_editor_other',
283
+					],
284
+				],
285
+				'metaboxes'     => ['_venue_editor_metaboxes'],
286
+				'require_nonce' => false,
287
+			],
288
+			'edit'                => [
289
+				'nav'           => [
290
+					'label'      => esc_html__('Edit Venue', 'event_espresso'),
291
+					'icon' => 'dashicons-edit-large',
292
+					'order'      => 15,
293
+					'persistent' => false,
294
+					'url'        => $VNU_ID
295
+						? add_query_arg(['post' => $VNU_ID], $this->_current_page_view_url)
296
+						: $this->_admin_base_url,
297
+				],
298
+				'help_tabs'     => [
299
+					'venues_editor_help_tab'                                               => [
300
+						'title'    => esc_html__('Venue Editor', 'event_espresso'),
301
+						'filename' => 'venues_editor',
302
+					],
303
+					'venues_editor_title_richtexteditor_help_tab'                          => [
304
+						'title'    => esc_html__('Venue Title & Rich Text Editor', 'event_espresso'),
305
+						'filename' => 'venues_editor_title_richtexteditor',
306
+					],
307
+					'venues_editor_tags_categories_help_tab'                               => [
308
+						'title'    => esc_html__('Venue Tags & Categories', 'event_espresso'),
309
+						'filename' => 'venues_editor_tags_categories',
310
+					],
311
+					'venues_editor_physical_location_google_map_virtual_location_help_tab' => [
312
+						'title'    => esc_html__(
313
+							'Venue Editor Physical Location & Google Map & Virtual Location',
314
+							'event_espresso'
315
+						),
316
+						'filename' => 'venues_editor_physical_location_google_map_virtual_location',
317
+					],
318
+					'venues_editor_save_new_venue_help_tab'                                => [
319
+						'title'    => esc_html__('Save New Venue', 'event_espresso'),
320
+						'filename' => 'venues_editor_save_new_venue',
321
+					],
322
+					'venues_editor_other_help_tab'                                         => [
323
+						'title'    => esc_html__('Venue Editor Other', 'event_espresso'),
324
+						'filename' => 'venues_editor_other',
325
+					],
326
+				],
327
+				'metaboxes'     => ['_venue_editor_metaboxes'],
328
+				'require_nonce' => false,
329
+			],
330
+			'google_map_settings' => [
331
+				'nav'           => [
332
+					'label' => esc_html__('Google Maps', 'event_espresso'),
333
+					'icon' => 'dashicons-location-alt',
334
+					'order' => 40,
335
+				],
336
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
337
+				'help_tabs'     => [
338
+					'general_settings_google_maps_help_tab' => [
339
+						'title'    => esc_html__('Google Maps', 'event_espresso'),
340
+						'filename' => 'general_settings_google_maps',
341
+					],
342
+				],
343
+				'require_nonce' => false,
344
+			],
345
+			// venue category stuff
346
+			'add_category'        => [
347
+				'nav'           => [
348
+					'label'      => esc_html__('Add Category', 'event_espresso'),
349
+					'icon' => 'dashicons-plus-alt',
350
+					'order'      => 25,
351
+					'persistent' => false,
352
+				],
353
+				'metaboxes'     => ['_publish_post_box'],
354
+				'help_tabs'     => [
355
+					'venues_add_category_help_tab' => [
356
+						'title'    => esc_html__('Add New Venue Category', 'event_espresso'),
357
+						'filename' => 'venues_add_category',
358
+					],
359
+				],
360
+				'require_nonce' => false,
361
+			],
362
+			'edit_category'       => [
363
+				'nav'           => [
364
+					'label'      => esc_html__('Edit Category', 'event_espresso'),
365
+					'icon' => 'dashicons-edit-large',
366
+					'order'      => 25,
367
+					'persistent' => false,
368
+					'url'        => $EVT_CAT_ID
369
+						? add_query_arg(['EVT_CAT_ID' => $EVT_CAT_ID], $this->_current_page_view_url)
370
+						: $this->_admin_base_url,
371
+				],
372
+				'metaboxes'     => ['_publish_post_box'],
373
+				'help_tabs'     => [
374
+					'venues_edit_category_help_tab' => [
375
+						'title'    => esc_html__('Edit Venue Category', 'event_espresso'),
376
+						'filename' => 'venues_edit_category',
377
+					],
378
+				],
379
+				'require_nonce' => false,
380
+			],
381
+			'category_list'       => [
382
+				'nav'           => [
383
+					'label' => esc_html__('Categories', 'event_espresso'),
384
+					'icon' => 'dashicons-networking',
385
+					'order' => 20,
386
+				],
387
+				'list_table'    => 'Venue_Categories_Admin_List_Table',
388
+				'help_tabs'     => [
389
+					'venues_categories_help_tab'                       => [
390
+						'title'    => esc_html__('Venue Categories', 'event_espresso'),
391
+						'filename' => 'venues_categories',
392
+					],
393
+					'venues_categories_table_column_headings_help_tab' => [
394
+						'title'    => esc_html__('Venue Categories Table Column Headings', 'event_espresso'),
395
+						'filename' => 'venues_categories_table_column_headings',
396
+					],
397
+					'venues_categories_views_help_tab'                 => [
398
+						'title'    => esc_html__('Venue Categories Views', 'event_espresso'),
399
+						'filename' => 'venues_categories_views',
400
+					],
401
+					'venues_categories_other_help_tab'                 => [
402
+						'title'    => esc_html__('Venue Categories Other', 'event_espresso'),
403
+						'filename' => 'venues_categories_other',
404
+					],
405
+				],
406
+				'metaboxes'     => $this->_default_espresso_metaboxes,
407
+				'require_nonce' => false,
408
+			],
409
+		];
410
+	}
411
+
412
+
413
+	protected function _add_screen_options()
414
+	{
415
+		// todo
416
+	}
417
+
418
+
419
+	protected function _add_screen_options_default()
420
+	{
421
+		$this->_per_page_screen_option();
422
+	}
423
+
424
+
425
+	protected function _add_screen_options_category_list()
426
+	{
427
+		$page_title              = $this->_admin_page_title;
428
+		$this->_admin_page_title = esc_html__('Venue Categories', 'event_espresso');
429
+		$this->_per_page_screen_option();
430
+		$this->_admin_page_title = $page_title;
431
+	}
432
+
433
+
434
+	// none of the below group are currently used for Event Venues
435
+	protected function _add_feature_pointers()
436
+	{
437
+	}
438
+
439
+
440
+	public function admin_init()
441
+	{
442
+	}
443
+
444
+
445
+	public function admin_notices()
446
+	{
447
+	}
448
+
449
+
450
+	public function admin_footer_scripts()
451
+	{
452
+	}
453
+
454
+
455
+	public function load_scripts_styles_create_new()
456
+	{
457
+		$this->load_scripts_styles_edit();
458
+	}
459
+
460
+
461
+	public function load_scripts_styles()
462
+	{
463
+		wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', [], EVENT_ESPRESSO_VERSION);
464
+		wp_enqueue_style('ee-cat-admin');
465
+	}
466
+
467
+
468
+	public function load_scripts_styles_add_category()
469
+	{
470
+		$this->load_scripts_styles_edit_category();
471
+	}
472
+
473
+
474
+	public function load_scripts_styles_edit_category()
475
+	{
476
+	}
477
+
478
+
479
+	public function load_scripts_styles_edit()
480
+	{
481
+		// styles
482
+		wp_enqueue_style('espresso-ui-theme');
483
+		wp_register_style(
484
+			'espresso_venues',
485
+			EE_VENUES_ASSETS_URL . 'ee-venues-admin.css',
486
+			[],
487
+			EVENT_ESPRESSO_VERSION
488
+		);
489
+		wp_enqueue_style('espresso_venues');
490
+	}
491
+
492
+
493
+	protected function _set_list_table_views_default()
494
+	{
495
+		$this->_views = [
496
+			'all' => [
497
+				'slug'        => 'all',
498
+				'label'       => esc_html__('View All Venues', 'event_espresso'),
499
+				'count'       => 0,
500
+				'bulk_action' => [],
501
+			],
502
+		];
503
+
504
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_venues', 'espresso_venues_trash_venues')) {
505
+			$this->_views['all']['bulk_action'] = [
506
+				'trash_venues' => esc_html__('Move to Trash', 'event_espresso'),
507
+			];
508
+			$this->_views['trash']              = [
509
+				'slug'        => 'trash',
510
+				'label'       => esc_html__('Trash', 'event_espresso'),
511
+				'count'       => 0,
512
+				'bulk_action' => [
513
+					'restore_venues' => esc_html__('Restore from Trash', 'event_espresso'),
514
+					'delete_venues'  => esc_html__('Delete', 'event_espresso'),
515
+				],
516
+			];
517
+		}
518
+	}
519
+
520
+
521
+	protected function _set_list_table_views_category_list()
522
+	{
523
+		$this->_views = [
524
+			'all' => [
525
+				'slug'        => 'all',
526
+				'label'       => esc_html__('All', 'event_espresso'),
527
+				'count'       => 0,
528
+				'bulk_action' => [
529
+					'delete_categories' => esc_html__('Delete Permanently', 'event_espresso'),
530
+				],
531
+			],
532
+		];
533
+	}
534
+
535
+
536
+	/**
537
+	 * @throws EE_Error
538
+	 */
539
+	protected function _overview_list_table()
540
+	{
541
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
542
+		$this->_template_args['after_list_table'] = EEH_Template::get_button_or_link(
543
+			get_post_type_archive_link('espresso_venues'),
544
+			esc_html__("View Venue Archive Page", "event_espresso"),
545
+			'button'
546
+		);
547
+
548
+		$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
549
+			'create_new',
550
+			'add',
551
+			[],
552
+			'add-new-h2'
553
+		);
554
+
555
+		$this->_search_btn_label  = esc_html__('Venues', 'event_espresso');
556
+		$this->display_admin_list_table_page_with_sidebar();
557
+	}
558
+
559
+
560
+	/**
561
+	 * @throws EE_Error
562
+	 * @throws ReflectionException
563
+	 */
564
+	public function extra_misc_actions_publish_box()
565
+	{
566
+		$extra_rows = [
567
+			'vnu_capacity' => $this->_cpt_model_obj->get_f('VNU_capacity'),
568
+			'vnu_url'      => $this->_cpt_model_obj->get_f('VNU_url'),
569
+			'vnu_phone'    => $this->_cpt_model_obj->get_f('VNU_phone'),
570
+		];
571
+		$template   = EE_VENUES_TEMPLATE_PATH . 'venue_publish_box_extras.template.php';
572
+		EEH_Template::display_template($template, $extra_rows);
573
+	}
574
+
575
+
576
+	/*************        Google Maps        *************
577 577
      *
578 578
      * @throws EE_Error
579 579
      * @throws EE_Error
580 580
      */
581 581
 
582 582
 
583
-    protected function _google_map_settings()
584
-    {
585
-
586
-
587
-        $this->_template_args['values']           = $this->_yes_no_values;
588
-        $default_map_settings                     = new stdClass();
589
-        $default_map_settings->use_google_maps    = true;
590
-        $default_map_settings->google_map_api_key = '';
591
-        // for event details pages (reg page)
592
-        $default_map_settings->event_details_map_width    = 585;
593
-        // ee_map_width_single
594
-        $default_map_settings->event_details_map_height   = 362;
595
-        // ee_map_height_single
596
-        $default_map_settings->event_details_map_zoom     = 14;
597
-        // ee_map_zoom_single
598
-        $default_map_settings->event_details_display_nav  = true;
599
-        // ee_map_nav_display_single
600
-        $default_map_settings->event_details_nav_size     = false;
601
-        // ee_map_nav_size_single
602
-        $default_map_settings->event_details_control_type = 'default';
603
-        // ee_map_type_control_single
604
-        $default_map_settings->event_details_map_align    = 'center';
605
-        // ee_map_align_single
606
-
607
-        // for event list pages
608
-        $default_map_settings->event_list_map_width    = 300;
609
-        // ee_map_width
610
-        $default_map_settings->event_list_map_height   = 185;
611
-        // ee_map_height
612
-        $default_map_settings->event_list_map_zoom     = 12;
613
-        // ee_map_zoom
614
-        $default_map_settings->event_list_display_nav  = false;
615
-        // ee_map_nav_display
616
-        $default_map_settings->event_list_nav_size     = true;
617
-        // ee_map_nav_size
618
-        $default_map_settings->event_list_control_type = 'dropdown';
619
-        // ee_map_type_control
620
-        $default_map_settings->event_list_map_align    = 'center';
621
-        // ee_map_align
622
-
623
-        $this->_template_args['map_settings'] =
624
-            isset(EE_Registry::instance()->CFG->map_settings)
625
-            && ! empty(EE_Registry::instance()->CFG->map_settings)
626
-                ? (object) array_merge(
627
-                    (array) $default_map_settings,
628
-                    (array) EE_Registry::instance()->CFG->map_settings
629
-                )
630
-                : $default_map_settings;
631
-
632
-        $this->_set_add_edit_form_tags('update_google_map_settings');
633
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
634
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
635
-            EE_VENUES_TEMPLATE_PATH . 'google_map.template.php',
636
-            $this->_template_args,
637
-            true
638
-        );
639
-        $this->display_admin_page_with_sidebar();
640
-    }
641
-
642
-
643
-    /**
644
-     * @throws EE_Error
645
-     */
646
-    protected function _update_google_map_settings()
647
-    {
648
-        $map_settings = EE_Registry::instance()->CFG->map_settings;
649
-
650
-        $settings = [
651
-            'use_google_maps'            => 'int',
652
-            'google_map_api_key'         => 'string',
653
-            'event_details_map_width'    => 'int',
654
-            'event_details_map_zoom'     => 'int',
655
-            'event_details_display_nav'  => 'int',
656
-            'event_details_nav_size'     => 'int',
657
-            'event_details_control_type' => 'string',
658
-            'event_details_map_align'    => 'string',
659
-            'event_list_map_width'       => 'int',
660
-            'event_list_map_height'      => 'int',
661
-            'event_list_map_zoom'        => 'int',
662
-            'event_list_display_nav'     => 'int',
663
-            'event_list_nav_size'        => 'int',
664
-            'event_list_control_type'    => 'string',
665
-            'event_list_map_align'       => 'string',
666
-        ];
667
-
668
-        foreach ($settings as $setting => $type) {
669
-            $map_settings->{$setting} = $this->request->getRequestParam($setting, $map_settings->{$setting}, $type);
670
-        }
671
-
672
-        EE_Registry::instance()->CFG->map_settings = apply_filters(
673
-            'FHEE__Extend_General_Settings_Admin_Page___update_google_map_settings__CFG_map_settings',
674
-            $map_settings
675
-        );
676
-
677
-        $what    = 'Google Map Settings';
678
-        $success = $this->_update_espresso_configuration(
679
-            $what,
680
-            EE_Registry::instance()->CFG->map_settings,
681
-            __FILE__,
682
-            __FUNCTION__,
683
-            __LINE__
684
-        );
685
-        $this->_redirect_after_action($success, $what, 'updated', ['action' => 'google_map_settings']);
686
-    }
687
-
688
-
689
-    /**
690
-     * @throws EE_Error
691
-     * @throws ReflectionException
692
-     */
693
-    protected function _venue_editor_metaboxes()
694
-    {
695
-        $this->verify_cpt_object();
696
-
697
-        $this->addMetaBox(
698
-            'espresso_venue_address_options',
699
-            esc_html__('Physical Location', 'event_espresso'),
700
-            [$this, 'venue_address_metabox'],
701
-            $this->page_slug,
702
-            'side'
703
-        );
704
-        $this->addMetaBox(
705
-            'espresso_venue_gmap_options',
706
-            esc_html__('Google Map', 'event_espresso'),
707
-            [$this, 'venue_gmap_metabox'],
708
-            $this->page_slug,
709
-            'side'
710
-        );
711
-        $this->addMetaBox(
712
-            'espresso_venue_virtual_loc_options',
713
-            esc_html__('Virtual Location', 'event_espresso'),
714
-            [$this, 'venue_virtual_loc_metabox'],
715
-            $this->page_slug,
716
-            'side'
717
-        );
718
-    }
719
-
720
-
721
-    public function venue_gmap_metabox()
722
-    {
723
-        $template_args = [
724
-            'vnu_enable_for_gmap' => EEH_Form_Fields::select_input(
725
-                'vnu_enable_for_gmap',
726
-                $this->get_yes_no_values(),
727
-                $this->_cpt_model_obj instanceof EE_Venue ? $this->_cpt_model_obj->enable_for_gmap() : false
728
-            ),
729
-            'vnu_google_map_link' => $this->_cpt_model_obj->google_map_link(),
730
-        ];
731
-        $template      = EE_VENUES_TEMPLATE_PATH . 'venue_gmap_metabox_content.template.php';
732
-        EEH_Template::display_template($template, $template_args);
733
-    }
734
-
735
-
736
-    /**
737
-     * @throws EE_Error
738
-     * @throws ReflectionException
739
-     */
740
-    public function venue_address_metabox()
741
-    {
742
-        $template_args['_venue'] = $this->_cpt_model_obj;
743
-
744
-        $template_args['states_dropdown']    = EEH_Form_Fields::generate_form_input(
745
-            new EE_Question_Form_Input(
746
-                EE_Question::new_instance(
747
-                    ['QST_display_text' => esc_html__('State', 'event_espresso'), 'QST_system' => 'state']
748
-                ),
749
-                EE_Answer::new_instance(
750
-                    [
751
-                        'ANS_value' => $this->_cpt_model_obj instanceof EE_Venue
752
-                            ? $this->_cpt_model_obj->state_ID()
753
-                            : 0,
754
-                    ]
755
-                ),
756
-                [
757
-                    'input_name'     => 'sta_id',
758
-                    'input_id'       => 'sta_id',
759
-                    'input_class'    => '',
760
-                    'input_prefix'   => '',
761
-                    'append_qstn_id' => false,
762
-                ]
763
-            )
764
-        );
765
-        $template_args['countries_dropdown'] = EEH_Form_Fields::generate_form_input(
766
-            new EE_Question_Form_Input(
767
-                EE_Question::new_instance(
768
-                    ['QST_display_text' => esc_html__('Country', 'event_espresso'), 'QST_system' => 'country']
769
-                ),
770
-                EE_Answer::new_instance(
771
-                    [
772
-                        'ANS_value' => $this->_cpt_model_obj instanceof EE_Venue
773
-                            ? $this->_cpt_model_obj->country_ID()
774
-                            : 0,
775
-                    ]
776
-                ),
777
-                [
778
-                    'input_name'     => 'cnt_iso',
779
-                    'input_id'       => 'cnt_iso',
780
-                    'input_class'    => '',
781
-                    'input_prefix'   => '',
782
-                    'append_qstn_id' => false,
783
-                ]
784
-            )
785
-        );
786
-
787
-        $template = EE_VENUES_TEMPLATE_PATH . 'venue_address_metabox_content.template.php';
788
-        EEH_Template::display_template($template, $template_args);
789
-    }
790
-
791
-
792
-    public function venue_virtual_loc_metabox()
793
-    {
794
-        $template_args = [
795
-            '_venue' => $this->_cpt_model_obj,
796
-        ];
797
-        $template      = EE_VENUES_TEMPLATE_PATH . 'venue_virtual_location_metabox_content.template.php';
798
-        EEH_Template::display_template($template, $template_args);
799
-    }
800
-
801
-
802
-    protected function _restore_cpt_item($post_id, $revision_id)
803
-    {
804
-        $venue_obj = $this->_venue_model->get_one_by_ID($post_id);
805
-
806
-        // meta revision restore
807
-        $venue_obj->restore_revision($revision_id);
808
-    }
809
-
810
-
811
-    /**
812
-     * Handles updates for venue cpts
813
-     *
814
-     * @param int    $post_id ID of Venue CPT
815
-     * @param WP_Post $post    Post object (with "blessed" WP properties)
816
-     * @return void
817
-     */
818
-    protected function _insert_update_cpt_item($post_id, $post)
819
-    {
820
-
821
-        if ($post instanceof WP_Post && $post->post_type !== 'espresso_venues') {
822
-            return;// get out we're not processing the saving of venues.
823
-        }
824
-
825
-        $wheres = [$this->_venue_model->primary_key_name() => $post_id];
826
-
827
-        $venue_values = [
828
-            'VNU_address'         => $this->request->getRequestParam('vnu_address'),
829
-            'VNU_address2'        => $this->request->getRequestParam('vnu_address2'),
830
-            'VNU_city'            => $this->request->getRequestParam('vnu_city'),
831
-            'STA_ID'              => $this->request->getRequestParam('sta_id'),
832
-            'CNT_ISO'             => $this->request->getRequestParam('cnt_iso'),
833
-            'VNU_zip'             => $this->request->getRequestParam('vnu_zip'),
834
-            'VNU_phone'           => $this->request->getRequestParam('vnu_phone'),
835
-            'VNU_capacity'        => $this->request->requestParamIsSet('vnu_capacity')
836
-                ? str_replace(',', '', $this->request->getRequestParam('vnu_capacity'))
837
-                : EE_INF,
838
-            'VNU_url'             => $this->request->getRequestParam('vnu_url'),
839
-            'VNU_virtual_phone'   => $this->request->getRequestParam('vnu_virtual_phone'),
840
-            'VNU_virtual_url'     => $this->request->getRequestParam('vnu_virtual_url'),
841
-            'VNU_enable_for_gmap' => $this->request->getRequestParam('vnu_enable_for_gmap', false, 'bool'),
842
-            'VNU_google_map_link' => $this->request->getRequestParam('vnu_google_map_link'),
843
-        ];
844
-
845
-        // update venue
846
-        $success = $this->_venue_model->update($venue_values, [$wheres]);
847
-
848
-        // get venue_object for other metaboxes that might be added via the filter... though it would seem to make sense to just use $this->_venue_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!
849
-        $get_one_where = [$this->_venue_model->primary_key_name() => $post_id, 'status' => $post->post_status];
850
-        $venue         = $this->_venue_model->get_one([$get_one_where]);
851
-
852
-        // notice we've applied a filter for venue metabox callbacks but we don't actually have any default venue metaboxes in use.  So this is just here for addons to more easily hook into venue saves.
853
-        $venue_update_callbacks = apply_filters(
854
-            'FHEE__Venues_Admin_Page___insert_update_cpt_item__venue_update_callbacks',
855
-            []
856
-        );
857
-        $att_success            = true;
858
-        foreach ($venue_update_callbacks as $v_callback) {
859
-            // if ANY of these updates fail then we want the appropriate global error message
860
-            $att_success = call_user_func_array($v_callback, [$venue, $this->request->requestParams()])
861
-                ? $att_success
862
-                : false;
863
-        }
864
-
865
-        // any errors?
866
-        if ($success && ! $att_success) {
867
-            EE_Error::add_error(
868
-                esc_html__(
869
-                    'Venue Details saved successfully but something went wrong with saving attachments.',
870
-                    'event_espresso'
871
-                ),
872
-                __FILE__,
873
-                __FUNCTION__,
874
-                __LINE__
875
-            );
876
-        } elseif ($success === false) {
877
-            EE_Error::add_error(
878
-                esc_html__('Venue Details did not save successfully.', 'event_espresso'),
879
-                __FILE__,
880
-                __FUNCTION__,
881
-                __LINE__
882
-            );
883
-        }
884
-    }
885
-
886
-
887
-    /**
888
-     * @param int $post_id
889
-     * @throws EE_Error
890
-     * @throws ReflectionException
891
-     */
892
-    public function trash_cpt_item($post_id)
893
-    {
894
-        $this->request->setRequestParam('VNU_ID', $post_id);
895
-        $this->_trash_or_restore_venue('trash', false);
896
-    }
897
-
898
-
899
-    /**
900
-     * @param int $post_id
901
-     * @throws EE_Error
902
-     * @throws ReflectionException
903
-     */
904
-    public function restore_cpt_item($post_id)
905
-    {
906
-        $this->request->setRequestParam('VNU_ID', $post_id);
907
-        $this->_trash_or_restore_venue('draft', false);
908
-    }
909
-
910
-
911
-    /**
912
-     * @param int $post_id
913
-     * @throws EE_Error
914
-     * @throws ReflectionException
915
-     */
916
-    public function delete_cpt_item($post_id)
917
-    {
918
-        $this->request->setRequestParam('VNU_ID', $post_id);
919
-        $this->_delete_venue(false);
920
-    }
921
-
922
-
923
-    public function get_venue_object()
924
-    {
925
-        return $this->_cpt_model_obj;
926
-    }
927
-
928
-
929
-    /**
930
-     * @throws EE_Error
931
-     * @throws ReflectionException
932
-     */
933
-    protected function _trash_or_restore_venue($venue_status = 'trash', $redirect_after = true)
934
-    {
935
-        $VNU_ID = $this->request->getRequestParam('VNU_ID', 0, 'int');
936
-        // loop thru venues
937
-        if ($VNU_ID) {
938
-            // clean status
939
-            $venue_status = sanitize_key($venue_status);
940
-            // grab status
941
-            if (! empty($venue_status)) {
942
-                $success = $this->_change_venue_status($VNU_ID, $venue_status);
943
-            } else {
944
-                $success = false;
945
-                $msg     = esc_html__(
946
-                    'An error occurred. The venue could not be moved to the trash because a valid venue status was not not supplied.',
947
-                    'event_espresso'
948
-                );
949
-                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
950
-            }
951
-        } else {
952
-            $success = false;
953
-            $msg     = esc_html__(
954
-                'An error occurred. The venue could not be moved to the trash because a valid venue ID was not not supplied.',
955
-                'event_espresso'
956
-            );
957
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
958
-        }
959
-        $action = $venue_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
960
-
961
-        if ($redirect_after) {
962
-            $this->_redirect_after_action($success, 'Venue', $action, ['action' => 'default']);
963
-        }
964
-    }
965
-
966
-
967
-    /**
968
-     * @throws EE_Error
969
-     * @throws ReflectionException
970
-     */
971
-    protected function _trash_or_restore_venues($venue_status = 'trash')
972
-    {
973
-        // clean status
974
-        $venue_status = sanitize_key($venue_status);
975
-        // grab status
976
-        if (! empty($venue_status)) {
977
-            $success = true;
978
-            // determine the event id and set to array.
979
-            $VNU_IDs = $this->request->getRequestParam('venue_id', [], 'int', true);
980
-            // loop thru events
981
-            foreach ($VNU_IDs as $VNU_ID) {
982
-                if ($VNU_ID = absint($VNU_ID)) {
983
-                    $results = $this->_change_venue_status($VNU_ID, $venue_status);
984
-                    $success = $results !== false ? $success : false;
985
-                } else {
986
-                    $msg = sprintf(
987
-                        esc_html__(
988
-                            'An error occurred. Venue #%d could not be moved to the trash because a valid venue ID was not not supplied.',
989
-                            'event_espresso'
990
-                        ),
991
-                        $VNU_ID
992
-                    );
993
-                    EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
994
-                    $success = false;
995
-                }
996
-            }
997
-        } else {
998
-            $success = false;
999
-            $msg     = esc_html__(
1000
-                'An error occurred. The venue could not be moved to the trash because a valid venue status was not not supplied.',
1001
-                'event_espresso'
1002
-            );
1003
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1004
-        }
1005
-        // in order to force a pluralized result message we need to send back a success status greater than 1
1006
-        $success = $success ? 2 : false;
1007
-        $action  = $venue_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
1008
-        $this->_redirect_after_action($success, 'Venues', $action, ['action' => 'default']);
1009
-    }
1010
-
1011
-
1012
-    /**
1013
-     * _trash_or_restore_venues
1014
-     *
1015
-     * //todo this is pretty much the same as the corresponding change_event_status method in Events_Admin_Page.  We
1016
-     * should probably abstract this up to the EE_Admin_Page_CPT (or even EE_Admin_Page) and make this a common method
1017
-     * accepting a certain number of params.
1018
-     *
1019
-     * @access  private
1020
-     * @param int    $VNU_ID
1021
-     * @param string $venue_status
1022
-     * @return bool
1023
-     * @throws EE_Error
1024
-     * @throws ReflectionException
1025
-     */
1026
-    private function _change_venue_status($VNU_ID = 0, $venue_status = '')
1027
-    {
1028
-        // grab venue id
1029
-        if (! $VNU_ID) {
1030
-            $msg = esc_html__('An error occurred. No Venue ID or an invalid Venue ID was received.', 'event_espresso');
1031
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1032
-            return false;
1033
-        }
1034
-
1035
-        $this->_cpt_model_obj = EEM_Venue::instance()->get_one_by_ID($VNU_ID);
1036
-
1037
-        // clean status
1038
-        $venue_status = sanitize_key($venue_status);
1039
-        // grab status
1040
-        if (! $venue_status) {
1041
-            $msg = esc_html__(
1042
-                'An error occurred. No Venue Status or an invalid Venue Status was received.',
1043
-                'event_espresso'
1044
-            );
1045
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1046
-            return false;
1047
-        }
1048
-
1049
-        // was event trashed or restored ?
1050
-        switch ($venue_status) {
1051
-            case 'draft':
1052
-                $action = 'restored from the trash';
1053
-                $hook   = 'AHEE_venue_restored_from_trash';
1054
-                break;
1055
-            case 'trash':
1056
-                $action = 'moved to the trash';
1057
-                $hook   = 'AHEE_venue_moved_to_trash';
1058
-                break;
1059
-            default:
1060
-                $action = 'updated';
1061
-                $hook   = false;
1062
-        }
1063
-        // use class to change status
1064
-        $this->_cpt_model_obj->set_status($venue_status);
1065
-        $success = $this->_cpt_model_obj->save();
1066
-
1067
-        if ($success === false) {
1068
-            $msg = sprintf(esc_html__('An error occurred. The venue could not be %s.', 'event_espresso'), $action);
1069
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1070
-            return false;
1071
-        }
1072
-        if ($hook) {
1073
-            do_action($hook);
1074
-        }
1075
-        return true;
1076
-    }
1077
-
1078
-
1079
-    /**
1080
-     * @param bool $redirect_after
1081
-     * @return void
1082
-     * @throws EE_Error
1083
-     * @throws ReflectionException
1084
-     */
1085
-    protected function _delete_venue($redirect_after = true)
1086
-    {
1087
-        // determine the venue id and set to array.
1088
-        $VNU_ID = $this->request->getRequestParam('VNU_ID', 0, 'int');
1089
-        $VNU_ID = $this->request->getRequestParam('post', $VNU_ID, 'int');
1090
-
1091
-        // loop thru venues
1092
-        if ($VNU_ID) {
1093
-            $success = $this->_delete_or_trash_venue($VNU_ID);
1094
-        } else {
1095
-            $success = false;
1096
-            $msg     = esc_html__(
1097
-                'An error occurred. An venue could not be deleted because a valid venue ID was not not supplied.',
1098
-                'event_espresso'
1099
-            );
1100
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1101
-        }
1102
-        if ($redirect_after) {
1103
-            $this->_redirect_after_action($success, 'Venue', 'deleted', ['action' => 'default']);
1104
-        }
1105
-    }
1106
-
1107
-
1108
-    /**
1109
-     * @throws EE_Error
1110
-     * @throws ReflectionException
1111
-     */
1112
-    protected function _delete_venues()
1113
-    {
1114
-        $success = true;
1115
-        // determine the event id and set to array.
1116
-        $VNU_IDs = $this->request->getRequestParam('venue_id', [], 'int', true);
1117
-        // loop thru events
1118
-        foreach ($VNU_IDs as $VNU_ID) {
1119
-            if ($VNU_ID = absint($VNU_ID)) {
1120
-                $results = $this->_delete_or_trash_venue($VNU_ID);
1121
-                $success = $results !== false ? $success : false;
1122
-            } else {
1123
-                $success = false;
1124
-                $msg     = esc_html__(
1125
-                    'An error occurred. An venue could not be deleted because a valid venue ID was not not supplied.',
1126
-                    'event_espresso'
1127
-                );
1128
-                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1129
-            }
1130
-        }
1131
-        // in order to force a pluralized result message we need to send back a success status greater than 1
1132
-        $success = $success ? 2 : false;
1133
-        $this->_redirect_after_action(
1134
-            $success,
1135
-            esc_html__('Venues', 'event_espresso'),
1136
-            esc_html__('deleted', 'event_espresso'),
1137
-            ['action' => 'default']
1138
-        );
1139
-    }
1140
-
1141
-
1142
-    // todo: put in parent
1143
-
1144
-
1145
-    /**
1146
-     * @throws EE_Error
1147
-     * @throws ReflectionException
1148
-     */
1149
-    private function _delete_or_trash_venue($VNU_ID = false)
1150
-    {
1151
-        // grab event id
1152
-        if (! $VNU_ID = absint($VNU_ID)) {
1153
-            $msg = esc_html__('An error occurred. No Venue ID or an invalid Venue ID was received.', 'event_espresso');
1154
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1155
-            return false;
1156
-        }
1157
-
1158
-
1159
-        $venue = EEM_Venue::instance()->get_one_by_ID($VNU_ID);
1160
-        // first need to remove all term relationships
1161
-        $venue->_remove_relations('Term_Taxonomy');
1162
-        $success = $venue->delete_permanently();
1163
-        // did it all go as planned ?
1164
-        if ($success) {
1165
-            $msg = sprintf(esc_html__('Venue ID # %d has been deleted.', 'event_espresso'), $VNU_ID);
1166
-            EE_Error::add_success($msg);
1167
-        } else {
1168
-            $msg =
1169
-                sprintf(
1170
-                    esc_html__('An error occurred. Venue ID # %d could not be deleted.', 'event_espresso'),
1171
-                    $VNU_ID
1172
-                );
1173
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1174
-            return false;
1175
-        }
1176
-        do_action('AHEE__Venues_Admin_Page___delete_or_trash_venue__after_venue_deleted');
1177
-        return true;
1178
-    }
1179
-
1180
-
1181
-
1182
-
1183
-    /***********/
1184
-    /* QUERIES */
1185
-
1186
-
1187
-    public function get_venues($per_page = 10, $count = false)
1188
-    {
1189
-
1190
-        $orderby = $this->request->getRequestParam('orderby', '');
1191
-
1192
-        switch ($orderby) {
1193
-            case 'id':
1194
-                $orderby = 'VNU_ID';
1195
-                break;
1196
-
1197
-            case 'capacity':
1198
-                $orderby = 'VNU_capacity';
1199
-                break;
1200
-
1201
-            case 'city':
1202
-                $orderby = 'VNU_city';
1203
-                break;
1204
-
1205
-            default:
1206
-                $orderby = 'VNU_name';
1207
-        }
1208
-
1209
-        $sort         = $this->request->getRequestParam('order', 'ASC');
1210
-        $current_page = $this->request->getRequestParam('paged', 1, 'int');
1211
-        $per_page     = ! empty($per_page) ? $per_page : 10;
1212
-        $per_page     = $this->request->getRequestParam('perpage', $per_page, 'int');
1213
-
1214
-        $offset = ($current_page - 1) * $per_page;
1215
-        $limit  = [$offset, $per_page];
1216
-
1217
-        $category = $this->request->getRequestParam('category');
1218
-        $category = $category > 0 ? $category : null;
1219
-
1220
-        $where = [];
1221
-
1222
-        // only set initial status if it is in the incoming request.  Otherwise the "all" view display's all statuses.
1223
-        $status = $this->request->getRequestParam('status');
1224
-        if ($status && $status !== 'all') {
1225
-            $where['status'] = $status;
1226
-        }
1227
-
1228
-        $venue_status = $this->request->getRequestParam('venue_status');
1229
-        if ($venue_status) {
1230
-            $where['status'] = $venue_status;
1231
-        }
1232
-
1233
-
1234
-        if ($category) {
1235
-            $where['Term_Taxonomy.taxonomy'] = 'espresso_venue_categories';
1236
-            $where['Term_Taxonomy.term_id']  = $category;
1237
-        }
1238
-
1239
-
1240
-        if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_venues', 'get_venues')) {
1241
-            $where['VNU_wp_user'] = get_current_user_id();
1242
-        } else {
1243
-            if (! EE_Registry::instance()->CAP->current_user_can('ee_read_private_venues', 'get_venues')) {
1244
-                $where['OR'] = [
1245
-                    'status*restrict_private' => ['!=', 'private'],
1246
-                    'AND'                     => [
1247
-                        'status*inclusive' => ['=', 'private'],
1248
-                        'VNU_wp_user'      => get_current_user_id(),
1249
-                    ],
1250
-                ];
1251
-            }
1252
-        }
1253
-
1254
-        $search_term = $this->request->getRequestParam('s');
1255
-        if ($search_term) {
1256
-            $search_term = '%' . $search_term . '%';
1257
-            $where['OR'] = [
1258
-                'VNU_name'               => ['LIKE', $search_term],
1259
-                'VNU_desc'               => ['LIKE', $search_term],
1260
-                'VNU_short_desc'         => ['LIKE', $search_term],
1261
-                'VNU_address'            => ['LIKE', $search_term],
1262
-                'VNU_address2'           => ['LIKE', $search_term],
1263
-                'VNU_city'               => ['LIKE', $search_term],
1264
-                'VNU_zip'                => ['LIKE', $search_term],
1265
-                'VNU_phone'              => ['LIKE', $search_term],
1266
-                'VNU_url'                => ['LIKE', $search_term],
1267
-                'VNU_virtual_phone'      => ['LIKE', $search_term],
1268
-                'VNU_virtual_url'        => ['LIKE', $search_term],
1269
-                'VNU_google_map_link'    => ['LIKE', $search_term],
1270
-                'Event.EVT_name'         => ['LIKE', $search_term],
1271
-                'Event.EVT_desc'         => ['LIKE', $search_term],
1272
-                'Event.EVT_phone'        => ['LIKE', $search_term],
1273
-                'Event.EVT_external_URL' => ['LIKE', $search_term],
1274
-            ];
1275
-        }
1276
-
1277
-
1278
-        return $count
1279
-            ? $this->_venue_model->count([$where], 'VNU_ID')
1280
-            : $this->_venue_model->get_all(
1281
-                [$where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $sort]
1282
-            );
1283
-    }
1284
-
1285
-
1286
-
1287
-
1288
-    /** Venue Category Stuff **/
1289
-
1290
-    /**
1291
-     * set the _category property with the category object for the loaded page.
1292
-     *
1293
-     * @access private
1294
-     * @return void
1295
-     */
1296
-    private function _set_category_object()
1297
-    {
1298
-        if (isset($this->_category->id) && ! empty($this->_category->id)) {
1299
-            return;
1300
-        } // already have the category object so get out.
1301
-
1302
-        // set default category object
1303
-        $this->_set_empty_category_object();
1304
-
1305
-        // only set if we've got an id
1306
-        $category_ID = $this->request->getRequestParam('VEN_CAT_ID', 0, 'int');
1307
-        if (! $category_ID) {
1308
-            return;
1309
-        }
1310
-
1311
-        $term = get_term($category_ID, 'espresso_venue_categories');
1312
-
1313
-
1314
-        if (! empty($term)) {
1315
-            $this->_category->category_name       = $term->name;
1316
-            $this->_category->category_identifier = $term->slug;
1317
-            $this->_category->category_desc       = $term->description;
1318
-            $this->_category->id                  = $term->term_id;
1319
-            $this->_category->parent              = $term->parent;
1320
-        }
1321
-    }
1322
-
1323
-
1324
-    private function _set_empty_category_object()
1325
-    {
1326
-        $this->_category                = new stdClass();
1327
-        $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = '';
1328
-        $this->_category->id            = $this->_category->parent = 0;
1329
-    }
1330
-
1331
-
1332
-    /**
1333
-     * @throws EE_Error
1334
-     */
1335
-    protected function _category_list_table()
1336
-    {
1337
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1338
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1339
-            'add_category',
1340
-            'add_category',
1341
-            [],
1342
-            'add-new-h2'
1343
-        );
1344
-        $this->_search_btn_label = esc_html__('Venue Categories', 'event_espresso');
1345
-        $this->display_admin_list_table_page_with_sidebar();
1346
-    }
1347
-
1348
-
1349
-    /**
1350
-     * @throws EE_Error
1351
-     */
1352
-    protected function _category_details($view)
1353
-    {
1354
-
1355
-        // load formatter helper
1356
-        // load field generator helper
1357
-
1358
-        $route = $view == 'edit' ? 'update_category' : 'insert_category';
1359
-        $this->_set_add_edit_form_tags($route);
1360
-
1361
-        $this->_set_category_object();
1362
-        $id = ! empty($this->_category->id) ? $this->_category->id : '';
1363
-
1364
-        $delete_action = 'delete_category';
1365
-
1366
-        $redirect = EE_Admin_Page::add_query_args_and_nonce(['action' => 'category_list'], $this->_admin_base_url);
1367
-
1368
-        $this->_set_publish_post_box_vars('VEN_CAT_ID', $id, $delete_action, $redirect);
1369
-
1370
-        // take care of contents
1371
-        $this->_template_args['admin_page_content'] = $this->_category_details_content();
1372
-        $this->display_admin_page_with_sidebar();
1373
-    }
1374
-
1375
-
1376
-    protected function _category_details_content()
1377
-    {
1378
-        $editor_args['category_desc'] = [
1379
-            'type'          => 'wp_editor',
1380
-            'value'         => EEH_Formatter::admin_format_content($this->_category->category_desc),
1381
-            'class'         => 'my_editor_custom',
1382
-            'wpeditor_args' => ['media_buttons' => false],
1383
-        ];
1384
-        $_wp_editor                   = $this->_generate_admin_form_fields($editor_args, 'array');
1385
-
1386
-        $all_terms = get_terms(
1387
-            ['espresso_venue_categories'],
1388
-            ['hide_empty' => 0, 'exclude' => [$this->_category->id]]
1389
-        );
1390
-
1391
-        // setup category select for term parents.
1392
-        $category_select_values[] = [
1393
-            'text' => esc_html__('No Parent', 'event_espresso'),
1394
-            'id'   => 0,
1395
-        ];
1396
-        foreach ($all_terms as $term) {
1397
-            $category_select_values[] = [
1398
-                'text' => $term->name,
1399
-                'id'   => $term->term_id,
1400
-            ];
1401
-        }
1402
-
1403
-        $category_select = EEH_Form_Fields::select_input(
1404
-            'category_parent',
1405
-            $category_select_values,
1406
-            $this->_category->parent
1407
-        );
1408
-        $template_args   = [
1409
-            'category'                 => $this->_category,
1410
-            'category_select'          => $category_select,
1411
-            'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'),
1412
-            'category_desc_editor'     => $_wp_editor['category_desc']['field'],
1413
-            'disable'                  => '',
1414
-            'disabled_message'         => false,
1415
-        ];
1416
-        $template        = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php';
1417
-        return EEH_Template::display_template($template, $template_args, true);
1418
-    }
1419
-
1420
-
1421
-    /**
1422
-     * @throws EE_Error
1423
-     */
1424
-    protected function _delete_categories()
1425
-    {
1426
-        $category_ID  = $this->request->getRequestParam('category_id', 0, 'int');
1427
-        $category_IDs = $this->request->getRequestParam('VEN_CAT_ID', [$category_ID], 'int', true);
1428
-
1429
-        foreach ($category_IDs as $cat_id) {
1430
-            $this->_delete_category($cat_id);
1431
-        }
1432
-
1433
-        // doesn't matter what page we're coming from... we're going to the same place after delete.
1434
-        $query_args = [
1435
-            'action' => 'category_list',
1436
-        ];
1437
-        $this->_redirect_after_action(0, '', '', $query_args);
1438
-    }
1439
-
1440
-
1441
-    protected function _delete_category($cat_id)
1442
-    {
1443
-        $cat_id = absint($cat_id);
1444
-        wp_delete_term($cat_id, 'espresso_venue_categories');
1445
-    }
1446
-
1447
-
1448
-    /**
1449
-     * @throws EE_Error
1450
-     */
1451
-    protected function _insert_or_update_category($new_category)
1452
-    {
1453
-
1454
-        $cat_id  = $new_category ? $this->_insert_category() : $this->_insert_category(true);
1455
-        $success = 0; // we already have a success message so lets not send another.
1456
-        if ($cat_id) {
1457
-            $query_args = [
1458
-                'action'     => 'edit_category',
1459
-                'VEN_CAT_ID' => $cat_id,
1460
-            ];
1461
-        } else {
1462
-            $query_args = ['action' => 'add_category'];
1463
-        }
1464
-        $this->_redirect_after_action($success, '', '', $query_args, true);
1465
-    }
1466
-
1467
-
1468
-    private function _insert_category($update = false)
1469
-    {
1470
-        $category_ID     = $update ? $this->request->getRequestParam('VEN_CAT_ID', '', 'int') : '';
1471
-        $category_name   = $this->request->getRequestParam('category_name', '');
1472
-        $category_desc   = $this->request->getRequestParam('category_desc', '', 'html');
1473
-        $category_parent = $this->request->getRequestParam('category_parent', 0, 'int');
1474
-
1475
-        if (empty($category_name)) {
1476
-            $msg = esc_html__('You must add a name for the category.', 'event_espresso');
1477
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1478
-            return false;
1479
-        }
1480
-
1481
-
1482
-        $term_args = [
1483
-            'name'        => $category_name,
1484
-            'description' => $category_desc,
1485
-            'parent'      => $category_parent,
1486
-        ];
1487
-
1488
-        $insert_ids = $update
1489
-            ? wp_update_term($category_ID, 'espresso_venue_categories', $term_args)
1490
-            : wp_insert_term(
1491
-                $category_name,
1492
-                'espresso_venue_categories',
1493
-                $term_args
1494
-            );
1495
-
1496
-        if (! is_array($insert_ids)) {
1497
-            EE_Error::add_error(
1498
-                esc_html__('An error occurred and the category has not been saved to the database.', 'event_espresso'),
1499
-                __FILE__,
1500
-                __FUNCTION__,
1501
-                __LINE__
1502
-            );
1503
-        } else {
1504
-            $category_ID = $insert_ids['term_id'];
1505
-            EE_Error::add_success(
1506
-                sprintf(
1507
-                    esc_html__('The category %s was successfully created', 'event_espresso'),
1508
-                    $category_name
1509
-                )
1510
-            );
1511
-        }
1512
-
1513
-        return $category_ID;
1514
-    }
1515
-
1516
-
1517
-    /**
1518
-     * TODO handle category exports()
1519
-     *
1520
-     * @return void
1521
-     */
1522
-    protected function _categories_export()
1523
-    {
1524
-        // todo: I don't like doing this but it'll do until we modify EE_Export Class.
1525
-        $this->request->mergeRequestParams(
1526
-            [
1527
-                'export'       => 'report',
1528
-                'action'       => 'categories',
1529
-                'category_ids' => $this->request->getRequestParam('VEN_CAT_ID', 0, 'int'),
1530
-            ]
1531
-        );
1532
-
1533
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
1534
-            require_once(EE_CLASSES . 'EE_Export.class.php');
1535
-            $EE_Export = EE_Export::instance($this->request->requestParams());
1536
-            $EE_Export->export();
1537
-        }
1538
-    }
1539
-
1540
-
1541
-    protected function _import_categories()
1542
-    {
1543
-
1544
-        require_once(EE_CLASSES . 'EE_Import.class.php');
1545
-        EE_Import::instance()->import();
1546
-    }
1547
-
1548
-
1549
-    /**
1550
-     * @throws EE_Error
1551
-     */
1552
-    public function get_categories($per_page = 10, $current_page = 1, $count = false)
1553
-    {
1554
-
1555
-        // testing term stuff
1556
-        $orderby     = $this->request->getRequestParam('orderby', 'Term.term_id');
1557
-        $order       = $this->request->getRequestParam('order', 'DESC');
1558
-        $limit       = ($current_page - 1) * $per_page;
1559
-        $where       = ['taxonomy' => 'espresso_venue_categories'];
1560
-        $search_term = $this->request->getRequestParam('s');
1561
-        if ($search_term) {
1562
-            $search_term = '%' . $search_term . '%';
1563
-            $where['OR'] = [
1564
-                'Term.name'   => ['LIKE', $search_term],
1565
-                'description' => ['LIKE', $search_term],
1566
-            ];
1567
-        }
1568
-
1569
-        $query_params = [
1570
-            $where,
1571
-            'order_by'   => [$orderby => $order],
1572
-            'limit'      => $limit . ',' . $per_page,
1573
-            'force_join' => ['Term'],
1574
-        ];
1575
-
1576
-        return $count
1577
-            ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id')
1578
-            : EEM_Term_Taxonomy::instance()->get_all($query_params);
1579
-    }
1580
-
1581
-
1582
-    /* end category stuff */
1583
-    /**************/
583
+	protected function _google_map_settings()
584
+	{
585
+
586
+
587
+		$this->_template_args['values']           = $this->_yes_no_values;
588
+		$default_map_settings                     = new stdClass();
589
+		$default_map_settings->use_google_maps    = true;
590
+		$default_map_settings->google_map_api_key = '';
591
+		// for event details pages (reg page)
592
+		$default_map_settings->event_details_map_width    = 585;
593
+		// ee_map_width_single
594
+		$default_map_settings->event_details_map_height   = 362;
595
+		// ee_map_height_single
596
+		$default_map_settings->event_details_map_zoom     = 14;
597
+		// ee_map_zoom_single
598
+		$default_map_settings->event_details_display_nav  = true;
599
+		// ee_map_nav_display_single
600
+		$default_map_settings->event_details_nav_size     = false;
601
+		// ee_map_nav_size_single
602
+		$default_map_settings->event_details_control_type = 'default';
603
+		// ee_map_type_control_single
604
+		$default_map_settings->event_details_map_align    = 'center';
605
+		// ee_map_align_single
606
+
607
+		// for event list pages
608
+		$default_map_settings->event_list_map_width    = 300;
609
+		// ee_map_width
610
+		$default_map_settings->event_list_map_height   = 185;
611
+		// ee_map_height
612
+		$default_map_settings->event_list_map_zoom     = 12;
613
+		// ee_map_zoom
614
+		$default_map_settings->event_list_display_nav  = false;
615
+		// ee_map_nav_display
616
+		$default_map_settings->event_list_nav_size     = true;
617
+		// ee_map_nav_size
618
+		$default_map_settings->event_list_control_type = 'dropdown';
619
+		// ee_map_type_control
620
+		$default_map_settings->event_list_map_align    = 'center';
621
+		// ee_map_align
622
+
623
+		$this->_template_args['map_settings'] =
624
+			isset(EE_Registry::instance()->CFG->map_settings)
625
+			&& ! empty(EE_Registry::instance()->CFG->map_settings)
626
+				? (object) array_merge(
627
+					(array) $default_map_settings,
628
+					(array) EE_Registry::instance()->CFG->map_settings
629
+				)
630
+				: $default_map_settings;
631
+
632
+		$this->_set_add_edit_form_tags('update_google_map_settings');
633
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
634
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
635
+			EE_VENUES_TEMPLATE_PATH . 'google_map.template.php',
636
+			$this->_template_args,
637
+			true
638
+		);
639
+		$this->display_admin_page_with_sidebar();
640
+	}
641
+
642
+
643
+	/**
644
+	 * @throws EE_Error
645
+	 */
646
+	protected function _update_google_map_settings()
647
+	{
648
+		$map_settings = EE_Registry::instance()->CFG->map_settings;
649
+
650
+		$settings = [
651
+			'use_google_maps'            => 'int',
652
+			'google_map_api_key'         => 'string',
653
+			'event_details_map_width'    => 'int',
654
+			'event_details_map_zoom'     => 'int',
655
+			'event_details_display_nav'  => 'int',
656
+			'event_details_nav_size'     => 'int',
657
+			'event_details_control_type' => 'string',
658
+			'event_details_map_align'    => 'string',
659
+			'event_list_map_width'       => 'int',
660
+			'event_list_map_height'      => 'int',
661
+			'event_list_map_zoom'        => 'int',
662
+			'event_list_display_nav'     => 'int',
663
+			'event_list_nav_size'        => 'int',
664
+			'event_list_control_type'    => 'string',
665
+			'event_list_map_align'       => 'string',
666
+		];
667
+
668
+		foreach ($settings as $setting => $type) {
669
+			$map_settings->{$setting} = $this->request->getRequestParam($setting, $map_settings->{$setting}, $type);
670
+		}
671
+
672
+		EE_Registry::instance()->CFG->map_settings = apply_filters(
673
+			'FHEE__Extend_General_Settings_Admin_Page___update_google_map_settings__CFG_map_settings',
674
+			$map_settings
675
+		);
676
+
677
+		$what    = 'Google Map Settings';
678
+		$success = $this->_update_espresso_configuration(
679
+			$what,
680
+			EE_Registry::instance()->CFG->map_settings,
681
+			__FILE__,
682
+			__FUNCTION__,
683
+			__LINE__
684
+		);
685
+		$this->_redirect_after_action($success, $what, 'updated', ['action' => 'google_map_settings']);
686
+	}
687
+
688
+
689
+	/**
690
+	 * @throws EE_Error
691
+	 * @throws ReflectionException
692
+	 */
693
+	protected function _venue_editor_metaboxes()
694
+	{
695
+		$this->verify_cpt_object();
696
+
697
+		$this->addMetaBox(
698
+			'espresso_venue_address_options',
699
+			esc_html__('Physical Location', 'event_espresso'),
700
+			[$this, 'venue_address_metabox'],
701
+			$this->page_slug,
702
+			'side'
703
+		);
704
+		$this->addMetaBox(
705
+			'espresso_venue_gmap_options',
706
+			esc_html__('Google Map', 'event_espresso'),
707
+			[$this, 'venue_gmap_metabox'],
708
+			$this->page_slug,
709
+			'side'
710
+		);
711
+		$this->addMetaBox(
712
+			'espresso_venue_virtual_loc_options',
713
+			esc_html__('Virtual Location', 'event_espresso'),
714
+			[$this, 'venue_virtual_loc_metabox'],
715
+			$this->page_slug,
716
+			'side'
717
+		);
718
+	}
719
+
720
+
721
+	public function venue_gmap_metabox()
722
+	{
723
+		$template_args = [
724
+			'vnu_enable_for_gmap' => EEH_Form_Fields::select_input(
725
+				'vnu_enable_for_gmap',
726
+				$this->get_yes_no_values(),
727
+				$this->_cpt_model_obj instanceof EE_Venue ? $this->_cpt_model_obj->enable_for_gmap() : false
728
+			),
729
+			'vnu_google_map_link' => $this->_cpt_model_obj->google_map_link(),
730
+		];
731
+		$template      = EE_VENUES_TEMPLATE_PATH . 'venue_gmap_metabox_content.template.php';
732
+		EEH_Template::display_template($template, $template_args);
733
+	}
734
+
735
+
736
+	/**
737
+	 * @throws EE_Error
738
+	 * @throws ReflectionException
739
+	 */
740
+	public function venue_address_metabox()
741
+	{
742
+		$template_args['_venue'] = $this->_cpt_model_obj;
743
+
744
+		$template_args['states_dropdown']    = EEH_Form_Fields::generate_form_input(
745
+			new EE_Question_Form_Input(
746
+				EE_Question::new_instance(
747
+					['QST_display_text' => esc_html__('State', 'event_espresso'), 'QST_system' => 'state']
748
+				),
749
+				EE_Answer::new_instance(
750
+					[
751
+						'ANS_value' => $this->_cpt_model_obj instanceof EE_Venue
752
+							? $this->_cpt_model_obj->state_ID()
753
+							: 0,
754
+					]
755
+				),
756
+				[
757
+					'input_name'     => 'sta_id',
758
+					'input_id'       => 'sta_id',
759
+					'input_class'    => '',
760
+					'input_prefix'   => '',
761
+					'append_qstn_id' => false,
762
+				]
763
+			)
764
+		);
765
+		$template_args['countries_dropdown'] = EEH_Form_Fields::generate_form_input(
766
+			new EE_Question_Form_Input(
767
+				EE_Question::new_instance(
768
+					['QST_display_text' => esc_html__('Country', 'event_espresso'), 'QST_system' => 'country']
769
+				),
770
+				EE_Answer::new_instance(
771
+					[
772
+						'ANS_value' => $this->_cpt_model_obj instanceof EE_Venue
773
+							? $this->_cpt_model_obj->country_ID()
774
+							: 0,
775
+					]
776
+				),
777
+				[
778
+					'input_name'     => 'cnt_iso',
779
+					'input_id'       => 'cnt_iso',
780
+					'input_class'    => '',
781
+					'input_prefix'   => '',
782
+					'append_qstn_id' => false,
783
+				]
784
+			)
785
+		);
786
+
787
+		$template = EE_VENUES_TEMPLATE_PATH . 'venue_address_metabox_content.template.php';
788
+		EEH_Template::display_template($template, $template_args);
789
+	}
790
+
791
+
792
+	public function venue_virtual_loc_metabox()
793
+	{
794
+		$template_args = [
795
+			'_venue' => $this->_cpt_model_obj,
796
+		];
797
+		$template      = EE_VENUES_TEMPLATE_PATH . 'venue_virtual_location_metabox_content.template.php';
798
+		EEH_Template::display_template($template, $template_args);
799
+	}
800
+
801
+
802
+	protected function _restore_cpt_item($post_id, $revision_id)
803
+	{
804
+		$venue_obj = $this->_venue_model->get_one_by_ID($post_id);
805
+
806
+		// meta revision restore
807
+		$venue_obj->restore_revision($revision_id);
808
+	}
809
+
810
+
811
+	/**
812
+	 * Handles updates for venue cpts
813
+	 *
814
+	 * @param int    $post_id ID of Venue CPT
815
+	 * @param WP_Post $post    Post object (with "blessed" WP properties)
816
+	 * @return void
817
+	 */
818
+	protected function _insert_update_cpt_item($post_id, $post)
819
+	{
820
+
821
+		if ($post instanceof WP_Post && $post->post_type !== 'espresso_venues') {
822
+			return;// get out we're not processing the saving of venues.
823
+		}
824
+
825
+		$wheres = [$this->_venue_model->primary_key_name() => $post_id];
826
+
827
+		$venue_values = [
828
+			'VNU_address'         => $this->request->getRequestParam('vnu_address'),
829
+			'VNU_address2'        => $this->request->getRequestParam('vnu_address2'),
830
+			'VNU_city'            => $this->request->getRequestParam('vnu_city'),
831
+			'STA_ID'              => $this->request->getRequestParam('sta_id'),
832
+			'CNT_ISO'             => $this->request->getRequestParam('cnt_iso'),
833
+			'VNU_zip'             => $this->request->getRequestParam('vnu_zip'),
834
+			'VNU_phone'           => $this->request->getRequestParam('vnu_phone'),
835
+			'VNU_capacity'        => $this->request->requestParamIsSet('vnu_capacity')
836
+				? str_replace(',', '', $this->request->getRequestParam('vnu_capacity'))
837
+				: EE_INF,
838
+			'VNU_url'             => $this->request->getRequestParam('vnu_url'),
839
+			'VNU_virtual_phone'   => $this->request->getRequestParam('vnu_virtual_phone'),
840
+			'VNU_virtual_url'     => $this->request->getRequestParam('vnu_virtual_url'),
841
+			'VNU_enable_for_gmap' => $this->request->getRequestParam('vnu_enable_for_gmap', false, 'bool'),
842
+			'VNU_google_map_link' => $this->request->getRequestParam('vnu_google_map_link'),
843
+		];
844
+
845
+		// update venue
846
+		$success = $this->_venue_model->update($venue_values, [$wheres]);
847
+
848
+		// get venue_object for other metaboxes that might be added via the filter... though it would seem to make sense to just use $this->_venue_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!
849
+		$get_one_where = [$this->_venue_model->primary_key_name() => $post_id, 'status' => $post->post_status];
850
+		$venue         = $this->_venue_model->get_one([$get_one_where]);
851
+
852
+		// notice we've applied a filter for venue metabox callbacks but we don't actually have any default venue metaboxes in use.  So this is just here for addons to more easily hook into venue saves.
853
+		$venue_update_callbacks = apply_filters(
854
+			'FHEE__Venues_Admin_Page___insert_update_cpt_item__venue_update_callbacks',
855
+			[]
856
+		);
857
+		$att_success            = true;
858
+		foreach ($venue_update_callbacks as $v_callback) {
859
+			// if ANY of these updates fail then we want the appropriate global error message
860
+			$att_success = call_user_func_array($v_callback, [$venue, $this->request->requestParams()])
861
+				? $att_success
862
+				: false;
863
+		}
864
+
865
+		// any errors?
866
+		if ($success && ! $att_success) {
867
+			EE_Error::add_error(
868
+				esc_html__(
869
+					'Venue Details saved successfully but something went wrong with saving attachments.',
870
+					'event_espresso'
871
+				),
872
+				__FILE__,
873
+				__FUNCTION__,
874
+				__LINE__
875
+			);
876
+		} elseif ($success === false) {
877
+			EE_Error::add_error(
878
+				esc_html__('Venue Details did not save successfully.', 'event_espresso'),
879
+				__FILE__,
880
+				__FUNCTION__,
881
+				__LINE__
882
+			);
883
+		}
884
+	}
885
+
886
+
887
+	/**
888
+	 * @param int $post_id
889
+	 * @throws EE_Error
890
+	 * @throws ReflectionException
891
+	 */
892
+	public function trash_cpt_item($post_id)
893
+	{
894
+		$this->request->setRequestParam('VNU_ID', $post_id);
895
+		$this->_trash_or_restore_venue('trash', false);
896
+	}
897
+
898
+
899
+	/**
900
+	 * @param int $post_id
901
+	 * @throws EE_Error
902
+	 * @throws ReflectionException
903
+	 */
904
+	public function restore_cpt_item($post_id)
905
+	{
906
+		$this->request->setRequestParam('VNU_ID', $post_id);
907
+		$this->_trash_or_restore_venue('draft', false);
908
+	}
909
+
910
+
911
+	/**
912
+	 * @param int $post_id
913
+	 * @throws EE_Error
914
+	 * @throws ReflectionException
915
+	 */
916
+	public function delete_cpt_item($post_id)
917
+	{
918
+		$this->request->setRequestParam('VNU_ID', $post_id);
919
+		$this->_delete_venue(false);
920
+	}
921
+
922
+
923
+	public function get_venue_object()
924
+	{
925
+		return $this->_cpt_model_obj;
926
+	}
927
+
928
+
929
+	/**
930
+	 * @throws EE_Error
931
+	 * @throws ReflectionException
932
+	 */
933
+	protected function _trash_or_restore_venue($venue_status = 'trash', $redirect_after = true)
934
+	{
935
+		$VNU_ID = $this->request->getRequestParam('VNU_ID', 0, 'int');
936
+		// loop thru venues
937
+		if ($VNU_ID) {
938
+			// clean status
939
+			$venue_status = sanitize_key($venue_status);
940
+			// grab status
941
+			if (! empty($venue_status)) {
942
+				$success = $this->_change_venue_status($VNU_ID, $venue_status);
943
+			} else {
944
+				$success = false;
945
+				$msg     = esc_html__(
946
+					'An error occurred. The venue could not be moved to the trash because a valid venue status was not not supplied.',
947
+					'event_espresso'
948
+				);
949
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
950
+			}
951
+		} else {
952
+			$success = false;
953
+			$msg     = esc_html__(
954
+				'An error occurred. The venue could not be moved to the trash because a valid venue ID was not not supplied.',
955
+				'event_espresso'
956
+			);
957
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
958
+		}
959
+		$action = $venue_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
960
+
961
+		if ($redirect_after) {
962
+			$this->_redirect_after_action($success, 'Venue', $action, ['action' => 'default']);
963
+		}
964
+	}
965
+
966
+
967
+	/**
968
+	 * @throws EE_Error
969
+	 * @throws ReflectionException
970
+	 */
971
+	protected function _trash_or_restore_venues($venue_status = 'trash')
972
+	{
973
+		// clean status
974
+		$venue_status = sanitize_key($venue_status);
975
+		// grab status
976
+		if (! empty($venue_status)) {
977
+			$success = true;
978
+			// determine the event id and set to array.
979
+			$VNU_IDs = $this->request->getRequestParam('venue_id', [], 'int', true);
980
+			// loop thru events
981
+			foreach ($VNU_IDs as $VNU_ID) {
982
+				if ($VNU_ID = absint($VNU_ID)) {
983
+					$results = $this->_change_venue_status($VNU_ID, $venue_status);
984
+					$success = $results !== false ? $success : false;
985
+				} else {
986
+					$msg = sprintf(
987
+						esc_html__(
988
+							'An error occurred. Venue #%d could not be moved to the trash because a valid venue ID was not not supplied.',
989
+							'event_espresso'
990
+						),
991
+						$VNU_ID
992
+					);
993
+					EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
994
+					$success = false;
995
+				}
996
+			}
997
+		} else {
998
+			$success = false;
999
+			$msg     = esc_html__(
1000
+				'An error occurred. The venue could not be moved to the trash because a valid venue status was not not supplied.',
1001
+				'event_espresso'
1002
+			);
1003
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1004
+		}
1005
+		// in order to force a pluralized result message we need to send back a success status greater than 1
1006
+		$success = $success ? 2 : false;
1007
+		$action  = $venue_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
1008
+		$this->_redirect_after_action($success, 'Venues', $action, ['action' => 'default']);
1009
+	}
1010
+
1011
+
1012
+	/**
1013
+	 * _trash_or_restore_venues
1014
+	 *
1015
+	 * //todo this is pretty much the same as the corresponding change_event_status method in Events_Admin_Page.  We
1016
+	 * should probably abstract this up to the EE_Admin_Page_CPT (or even EE_Admin_Page) and make this a common method
1017
+	 * accepting a certain number of params.
1018
+	 *
1019
+	 * @access  private
1020
+	 * @param int    $VNU_ID
1021
+	 * @param string $venue_status
1022
+	 * @return bool
1023
+	 * @throws EE_Error
1024
+	 * @throws ReflectionException
1025
+	 */
1026
+	private function _change_venue_status($VNU_ID = 0, $venue_status = '')
1027
+	{
1028
+		// grab venue id
1029
+		if (! $VNU_ID) {
1030
+			$msg = esc_html__('An error occurred. No Venue ID or an invalid Venue ID was received.', 'event_espresso');
1031
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1032
+			return false;
1033
+		}
1034
+
1035
+		$this->_cpt_model_obj = EEM_Venue::instance()->get_one_by_ID($VNU_ID);
1036
+
1037
+		// clean status
1038
+		$venue_status = sanitize_key($venue_status);
1039
+		// grab status
1040
+		if (! $venue_status) {
1041
+			$msg = esc_html__(
1042
+				'An error occurred. No Venue Status or an invalid Venue Status was received.',
1043
+				'event_espresso'
1044
+			);
1045
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1046
+			return false;
1047
+		}
1048
+
1049
+		// was event trashed or restored ?
1050
+		switch ($venue_status) {
1051
+			case 'draft':
1052
+				$action = 'restored from the trash';
1053
+				$hook   = 'AHEE_venue_restored_from_trash';
1054
+				break;
1055
+			case 'trash':
1056
+				$action = 'moved to the trash';
1057
+				$hook   = 'AHEE_venue_moved_to_trash';
1058
+				break;
1059
+			default:
1060
+				$action = 'updated';
1061
+				$hook   = false;
1062
+		}
1063
+		// use class to change status
1064
+		$this->_cpt_model_obj->set_status($venue_status);
1065
+		$success = $this->_cpt_model_obj->save();
1066
+
1067
+		if ($success === false) {
1068
+			$msg = sprintf(esc_html__('An error occurred. The venue could not be %s.', 'event_espresso'), $action);
1069
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1070
+			return false;
1071
+		}
1072
+		if ($hook) {
1073
+			do_action($hook);
1074
+		}
1075
+		return true;
1076
+	}
1077
+
1078
+
1079
+	/**
1080
+	 * @param bool $redirect_after
1081
+	 * @return void
1082
+	 * @throws EE_Error
1083
+	 * @throws ReflectionException
1084
+	 */
1085
+	protected function _delete_venue($redirect_after = true)
1086
+	{
1087
+		// determine the venue id and set to array.
1088
+		$VNU_ID = $this->request->getRequestParam('VNU_ID', 0, 'int');
1089
+		$VNU_ID = $this->request->getRequestParam('post', $VNU_ID, 'int');
1090
+
1091
+		// loop thru venues
1092
+		if ($VNU_ID) {
1093
+			$success = $this->_delete_or_trash_venue($VNU_ID);
1094
+		} else {
1095
+			$success = false;
1096
+			$msg     = esc_html__(
1097
+				'An error occurred. An venue could not be deleted because a valid venue ID was not not supplied.',
1098
+				'event_espresso'
1099
+			);
1100
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1101
+		}
1102
+		if ($redirect_after) {
1103
+			$this->_redirect_after_action($success, 'Venue', 'deleted', ['action' => 'default']);
1104
+		}
1105
+	}
1106
+
1107
+
1108
+	/**
1109
+	 * @throws EE_Error
1110
+	 * @throws ReflectionException
1111
+	 */
1112
+	protected function _delete_venues()
1113
+	{
1114
+		$success = true;
1115
+		// determine the event id and set to array.
1116
+		$VNU_IDs = $this->request->getRequestParam('venue_id', [], 'int', true);
1117
+		// loop thru events
1118
+		foreach ($VNU_IDs as $VNU_ID) {
1119
+			if ($VNU_ID = absint($VNU_ID)) {
1120
+				$results = $this->_delete_or_trash_venue($VNU_ID);
1121
+				$success = $results !== false ? $success : false;
1122
+			} else {
1123
+				$success = false;
1124
+				$msg     = esc_html__(
1125
+					'An error occurred. An venue could not be deleted because a valid venue ID was not not supplied.',
1126
+					'event_espresso'
1127
+				);
1128
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1129
+			}
1130
+		}
1131
+		// in order to force a pluralized result message we need to send back a success status greater than 1
1132
+		$success = $success ? 2 : false;
1133
+		$this->_redirect_after_action(
1134
+			$success,
1135
+			esc_html__('Venues', 'event_espresso'),
1136
+			esc_html__('deleted', 'event_espresso'),
1137
+			['action' => 'default']
1138
+		);
1139
+	}
1140
+
1141
+
1142
+	// todo: put in parent
1143
+
1144
+
1145
+	/**
1146
+	 * @throws EE_Error
1147
+	 * @throws ReflectionException
1148
+	 */
1149
+	private function _delete_or_trash_venue($VNU_ID = false)
1150
+	{
1151
+		// grab event id
1152
+		if (! $VNU_ID = absint($VNU_ID)) {
1153
+			$msg = esc_html__('An error occurred. No Venue ID or an invalid Venue ID was received.', 'event_espresso');
1154
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1155
+			return false;
1156
+		}
1157
+
1158
+
1159
+		$venue = EEM_Venue::instance()->get_one_by_ID($VNU_ID);
1160
+		// first need to remove all term relationships
1161
+		$venue->_remove_relations('Term_Taxonomy');
1162
+		$success = $venue->delete_permanently();
1163
+		// did it all go as planned ?
1164
+		if ($success) {
1165
+			$msg = sprintf(esc_html__('Venue ID # %d has been deleted.', 'event_espresso'), $VNU_ID);
1166
+			EE_Error::add_success($msg);
1167
+		} else {
1168
+			$msg =
1169
+				sprintf(
1170
+					esc_html__('An error occurred. Venue ID # %d could not be deleted.', 'event_espresso'),
1171
+					$VNU_ID
1172
+				);
1173
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1174
+			return false;
1175
+		}
1176
+		do_action('AHEE__Venues_Admin_Page___delete_or_trash_venue__after_venue_deleted');
1177
+		return true;
1178
+	}
1179
+
1180
+
1181
+
1182
+
1183
+	/***********/
1184
+	/* QUERIES */
1185
+
1186
+
1187
+	public function get_venues($per_page = 10, $count = false)
1188
+	{
1189
+
1190
+		$orderby = $this->request->getRequestParam('orderby', '');
1191
+
1192
+		switch ($orderby) {
1193
+			case 'id':
1194
+				$orderby = 'VNU_ID';
1195
+				break;
1196
+
1197
+			case 'capacity':
1198
+				$orderby = 'VNU_capacity';
1199
+				break;
1200
+
1201
+			case 'city':
1202
+				$orderby = 'VNU_city';
1203
+				break;
1204
+
1205
+			default:
1206
+				$orderby = 'VNU_name';
1207
+		}
1208
+
1209
+		$sort         = $this->request->getRequestParam('order', 'ASC');
1210
+		$current_page = $this->request->getRequestParam('paged', 1, 'int');
1211
+		$per_page     = ! empty($per_page) ? $per_page : 10;
1212
+		$per_page     = $this->request->getRequestParam('perpage', $per_page, 'int');
1213
+
1214
+		$offset = ($current_page - 1) * $per_page;
1215
+		$limit  = [$offset, $per_page];
1216
+
1217
+		$category = $this->request->getRequestParam('category');
1218
+		$category = $category > 0 ? $category : null;
1219
+
1220
+		$where = [];
1221
+
1222
+		// only set initial status if it is in the incoming request.  Otherwise the "all" view display's all statuses.
1223
+		$status = $this->request->getRequestParam('status');
1224
+		if ($status && $status !== 'all') {
1225
+			$where['status'] = $status;
1226
+		}
1227
+
1228
+		$venue_status = $this->request->getRequestParam('venue_status');
1229
+		if ($venue_status) {
1230
+			$where['status'] = $venue_status;
1231
+		}
1232
+
1233
+
1234
+		if ($category) {
1235
+			$where['Term_Taxonomy.taxonomy'] = 'espresso_venue_categories';
1236
+			$where['Term_Taxonomy.term_id']  = $category;
1237
+		}
1238
+
1239
+
1240
+		if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_venues', 'get_venues')) {
1241
+			$where['VNU_wp_user'] = get_current_user_id();
1242
+		} else {
1243
+			if (! EE_Registry::instance()->CAP->current_user_can('ee_read_private_venues', 'get_venues')) {
1244
+				$where['OR'] = [
1245
+					'status*restrict_private' => ['!=', 'private'],
1246
+					'AND'                     => [
1247
+						'status*inclusive' => ['=', 'private'],
1248
+						'VNU_wp_user'      => get_current_user_id(),
1249
+					],
1250
+				];
1251
+			}
1252
+		}
1253
+
1254
+		$search_term = $this->request->getRequestParam('s');
1255
+		if ($search_term) {
1256
+			$search_term = '%' . $search_term . '%';
1257
+			$where['OR'] = [
1258
+				'VNU_name'               => ['LIKE', $search_term],
1259
+				'VNU_desc'               => ['LIKE', $search_term],
1260
+				'VNU_short_desc'         => ['LIKE', $search_term],
1261
+				'VNU_address'            => ['LIKE', $search_term],
1262
+				'VNU_address2'           => ['LIKE', $search_term],
1263
+				'VNU_city'               => ['LIKE', $search_term],
1264
+				'VNU_zip'                => ['LIKE', $search_term],
1265
+				'VNU_phone'              => ['LIKE', $search_term],
1266
+				'VNU_url'                => ['LIKE', $search_term],
1267
+				'VNU_virtual_phone'      => ['LIKE', $search_term],
1268
+				'VNU_virtual_url'        => ['LIKE', $search_term],
1269
+				'VNU_google_map_link'    => ['LIKE', $search_term],
1270
+				'Event.EVT_name'         => ['LIKE', $search_term],
1271
+				'Event.EVT_desc'         => ['LIKE', $search_term],
1272
+				'Event.EVT_phone'        => ['LIKE', $search_term],
1273
+				'Event.EVT_external_URL' => ['LIKE', $search_term],
1274
+			];
1275
+		}
1276
+
1277
+
1278
+		return $count
1279
+			? $this->_venue_model->count([$where], 'VNU_ID')
1280
+			: $this->_venue_model->get_all(
1281
+				[$where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $sort]
1282
+			);
1283
+	}
1284
+
1285
+
1286
+
1287
+
1288
+	/** Venue Category Stuff **/
1289
+
1290
+	/**
1291
+	 * set the _category property with the category object for the loaded page.
1292
+	 *
1293
+	 * @access private
1294
+	 * @return void
1295
+	 */
1296
+	private function _set_category_object()
1297
+	{
1298
+		if (isset($this->_category->id) && ! empty($this->_category->id)) {
1299
+			return;
1300
+		} // already have the category object so get out.
1301
+
1302
+		// set default category object
1303
+		$this->_set_empty_category_object();
1304
+
1305
+		// only set if we've got an id
1306
+		$category_ID = $this->request->getRequestParam('VEN_CAT_ID', 0, 'int');
1307
+		if (! $category_ID) {
1308
+			return;
1309
+		}
1310
+
1311
+		$term = get_term($category_ID, 'espresso_venue_categories');
1312
+
1313
+
1314
+		if (! empty($term)) {
1315
+			$this->_category->category_name       = $term->name;
1316
+			$this->_category->category_identifier = $term->slug;
1317
+			$this->_category->category_desc       = $term->description;
1318
+			$this->_category->id                  = $term->term_id;
1319
+			$this->_category->parent              = $term->parent;
1320
+		}
1321
+	}
1322
+
1323
+
1324
+	private function _set_empty_category_object()
1325
+	{
1326
+		$this->_category                = new stdClass();
1327
+		$this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = '';
1328
+		$this->_category->id            = $this->_category->parent = 0;
1329
+	}
1330
+
1331
+
1332
+	/**
1333
+	 * @throws EE_Error
1334
+	 */
1335
+	protected function _category_list_table()
1336
+	{
1337
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1338
+		$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1339
+			'add_category',
1340
+			'add_category',
1341
+			[],
1342
+			'add-new-h2'
1343
+		);
1344
+		$this->_search_btn_label = esc_html__('Venue Categories', 'event_espresso');
1345
+		$this->display_admin_list_table_page_with_sidebar();
1346
+	}
1347
+
1348
+
1349
+	/**
1350
+	 * @throws EE_Error
1351
+	 */
1352
+	protected function _category_details($view)
1353
+	{
1354
+
1355
+		// load formatter helper
1356
+		// load field generator helper
1357
+
1358
+		$route = $view == 'edit' ? 'update_category' : 'insert_category';
1359
+		$this->_set_add_edit_form_tags($route);
1360
+
1361
+		$this->_set_category_object();
1362
+		$id = ! empty($this->_category->id) ? $this->_category->id : '';
1363
+
1364
+		$delete_action = 'delete_category';
1365
+
1366
+		$redirect = EE_Admin_Page::add_query_args_and_nonce(['action' => 'category_list'], $this->_admin_base_url);
1367
+
1368
+		$this->_set_publish_post_box_vars('VEN_CAT_ID', $id, $delete_action, $redirect);
1369
+
1370
+		// take care of contents
1371
+		$this->_template_args['admin_page_content'] = $this->_category_details_content();
1372
+		$this->display_admin_page_with_sidebar();
1373
+	}
1374
+
1375
+
1376
+	protected function _category_details_content()
1377
+	{
1378
+		$editor_args['category_desc'] = [
1379
+			'type'          => 'wp_editor',
1380
+			'value'         => EEH_Formatter::admin_format_content($this->_category->category_desc),
1381
+			'class'         => 'my_editor_custom',
1382
+			'wpeditor_args' => ['media_buttons' => false],
1383
+		];
1384
+		$_wp_editor                   = $this->_generate_admin_form_fields($editor_args, 'array');
1385
+
1386
+		$all_terms = get_terms(
1387
+			['espresso_venue_categories'],
1388
+			['hide_empty' => 0, 'exclude' => [$this->_category->id]]
1389
+		);
1390
+
1391
+		// setup category select for term parents.
1392
+		$category_select_values[] = [
1393
+			'text' => esc_html__('No Parent', 'event_espresso'),
1394
+			'id'   => 0,
1395
+		];
1396
+		foreach ($all_terms as $term) {
1397
+			$category_select_values[] = [
1398
+				'text' => $term->name,
1399
+				'id'   => $term->term_id,
1400
+			];
1401
+		}
1402
+
1403
+		$category_select = EEH_Form_Fields::select_input(
1404
+			'category_parent',
1405
+			$category_select_values,
1406
+			$this->_category->parent
1407
+		);
1408
+		$template_args   = [
1409
+			'category'                 => $this->_category,
1410
+			'category_select'          => $category_select,
1411
+			'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'),
1412
+			'category_desc_editor'     => $_wp_editor['category_desc']['field'],
1413
+			'disable'                  => '',
1414
+			'disabled_message'         => false,
1415
+		];
1416
+		$template        = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php';
1417
+		return EEH_Template::display_template($template, $template_args, true);
1418
+	}
1419
+
1420
+
1421
+	/**
1422
+	 * @throws EE_Error
1423
+	 */
1424
+	protected function _delete_categories()
1425
+	{
1426
+		$category_ID  = $this->request->getRequestParam('category_id', 0, 'int');
1427
+		$category_IDs = $this->request->getRequestParam('VEN_CAT_ID', [$category_ID], 'int', true);
1428
+
1429
+		foreach ($category_IDs as $cat_id) {
1430
+			$this->_delete_category($cat_id);
1431
+		}
1432
+
1433
+		// doesn't matter what page we're coming from... we're going to the same place after delete.
1434
+		$query_args = [
1435
+			'action' => 'category_list',
1436
+		];
1437
+		$this->_redirect_after_action(0, '', '', $query_args);
1438
+	}
1439
+
1440
+
1441
+	protected function _delete_category($cat_id)
1442
+	{
1443
+		$cat_id = absint($cat_id);
1444
+		wp_delete_term($cat_id, 'espresso_venue_categories');
1445
+	}
1446
+
1447
+
1448
+	/**
1449
+	 * @throws EE_Error
1450
+	 */
1451
+	protected function _insert_or_update_category($new_category)
1452
+	{
1453
+
1454
+		$cat_id  = $new_category ? $this->_insert_category() : $this->_insert_category(true);
1455
+		$success = 0; // we already have a success message so lets not send another.
1456
+		if ($cat_id) {
1457
+			$query_args = [
1458
+				'action'     => 'edit_category',
1459
+				'VEN_CAT_ID' => $cat_id,
1460
+			];
1461
+		} else {
1462
+			$query_args = ['action' => 'add_category'];
1463
+		}
1464
+		$this->_redirect_after_action($success, '', '', $query_args, true);
1465
+	}
1466
+
1467
+
1468
+	private function _insert_category($update = false)
1469
+	{
1470
+		$category_ID     = $update ? $this->request->getRequestParam('VEN_CAT_ID', '', 'int') : '';
1471
+		$category_name   = $this->request->getRequestParam('category_name', '');
1472
+		$category_desc   = $this->request->getRequestParam('category_desc', '', 'html');
1473
+		$category_parent = $this->request->getRequestParam('category_parent', 0, 'int');
1474
+
1475
+		if (empty($category_name)) {
1476
+			$msg = esc_html__('You must add a name for the category.', 'event_espresso');
1477
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1478
+			return false;
1479
+		}
1480
+
1481
+
1482
+		$term_args = [
1483
+			'name'        => $category_name,
1484
+			'description' => $category_desc,
1485
+			'parent'      => $category_parent,
1486
+		];
1487
+
1488
+		$insert_ids = $update
1489
+			? wp_update_term($category_ID, 'espresso_venue_categories', $term_args)
1490
+			: wp_insert_term(
1491
+				$category_name,
1492
+				'espresso_venue_categories',
1493
+				$term_args
1494
+			);
1495
+
1496
+		if (! is_array($insert_ids)) {
1497
+			EE_Error::add_error(
1498
+				esc_html__('An error occurred and the category has not been saved to the database.', 'event_espresso'),
1499
+				__FILE__,
1500
+				__FUNCTION__,
1501
+				__LINE__
1502
+			);
1503
+		} else {
1504
+			$category_ID = $insert_ids['term_id'];
1505
+			EE_Error::add_success(
1506
+				sprintf(
1507
+					esc_html__('The category %s was successfully created', 'event_espresso'),
1508
+					$category_name
1509
+				)
1510
+			);
1511
+		}
1512
+
1513
+		return $category_ID;
1514
+	}
1515
+
1516
+
1517
+	/**
1518
+	 * TODO handle category exports()
1519
+	 *
1520
+	 * @return void
1521
+	 */
1522
+	protected function _categories_export()
1523
+	{
1524
+		// todo: I don't like doing this but it'll do until we modify EE_Export Class.
1525
+		$this->request->mergeRequestParams(
1526
+			[
1527
+				'export'       => 'report',
1528
+				'action'       => 'categories',
1529
+				'category_ids' => $this->request->getRequestParam('VEN_CAT_ID', 0, 'int'),
1530
+			]
1531
+		);
1532
+
1533
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
1534
+			require_once(EE_CLASSES . 'EE_Export.class.php');
1535
+			$EE_Export = EE_Export::instance($this->request->requestParams());
1536
+			$EE_Export->export();
1537
+		}
1538
+	}
1539
+
1540
+
1541
+	protected function _import_categories()
1542
+	{
1543
+
1544
+		require_once(EE_CLASSES . 'EE_Import.class.php');
1545
+		EE_Import::instance()->import();
1546
+	}
1547
+
1548
+
1549
+	/**
1550
+	 * @throws EE_Error
1551
+	 */
1552
+	public function get_categories($per_page = 10, $current_page = 1, $count = false)
1553
+	{
1554
+
1555
+		// testing term stuff
1556
+		$orderby     = $this->request->getRequestParam('orderby', 'Term.term_id');
1557
+		$order       = $this->request->getRequestParam('order', 'DESC');
1558
+		$limit       = ($current_page - 1) * $per_page;
1559
+		$where       = ['taxonomy' => 'espresso_venue_categories'];
1560
+		$search_term = $this->request->getRequestParam('s');
1561
+		if ($search_term) {
1562
+			$search_term = '%' . $search_term . '%';
1563
+			$where['OR'] = [
1564
+				'Term.name'   => ['LIKE', $search_term],
1565
+				'description' => ['LIKE', $search_term],
1566
+			];
1567
+		}
1568
+
1569
+		$query_params = [
1570
+			$where,
1571
+			'order_by'   => [$orderby => $order],
1572
+			'limit'      => $limit . ',' . $per_page,
1573
+			'force_join' => ['Term'],
1574
+		];
1575
+
1576
+		return $count
1577
+			? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id')
1578
+			: EEM_Term_Taxonomy::instance()->get_all($query_params);
1579
+	}
1580
+
1581
+
1582
+	/* end category stuff */
1583
+	/**************/
1584 1584
 }
Please login to merge, or discard this patch.
admin_pages/venues/Venues_Admin_List_Table.class.php 2 patches
Indentation   +258 added lines, -258 removed lines patch added patch discarded remove patch
@@ -13,269 +13,269 @@
 block discarded – undo
13 13
  */
14 14
 class Venues_Admin_List_Table extends EE_Admin_List_Table
15 15
 {
16
-    /**
17
-     * @var Venues_Admin_Page $_admin_page
18
-     */
19
-    protected $_admin_page;
20
-
21
-
22
-    protected function _setup_data()
23
-    {
24
-        $this->_data           = $this->_admin_page->get_venues($this->_per_page);
25
-        $this->_all_data_count = $this->_admin_page->get_venues($this->_per_page, true);
26
-    }
27
-
28
-
29
-    protected function _set_properties()
30
-    {
31
-        $this->_wp_list_args = [
32
-            'singular' => esc_html__('Event Venue', 'event_espresso'),
33
-            'plural'   => esc_html__('Event Venues', 'event_espresso'),
34
-            'ajax'     => true, // for now,
35
-            'screen'   => $this->_admin_page->get_current_screen()->id,
36
-        ];
37
-
38
-        $this->_columns = [
39
-            'cb'       => '<input type="checkbox" />',
40
-            'id'       => esc_html__('ID', 'event_espresso'),
41
-            'name'     => esc_html__('Name', 'event_espresso'),
42
-            'address'  => esc_html__('Address', 'event_espresso'),
43
-            'city'     => esc_html__('City', 'event_espresso'),
44
-            'capacity' => esc_html__('Capacity', 'event_espresso'),
45
-            // 'shortcode' => esc_html__('Shortcode', 'event_espresso'),
46
-        ];
47
-
48
-        $this->_sortable_columns = [
49
-            'id'       => ['id' => true],
50
-            'name'     => ['name' => false],
51
-            'city'     => ['city' => false],
52
-            'capacity' => ['capacity' => false],
53
-        ];
54
-
55
-        $this->_hidden_columns = [];
56
-    }
57
-
58
-
59
-    // todo... add _venue_status in here (which we'll define a EE_Admin_CPT_List_Table for common properties)
60
-
61
-
62
-    /**
63
-     * @return array
64
-     */
65
-    protected function _get_table_filters(): array
66
-    {
67
-        return [];
68
-    }
69
-
70
-
71
-    /**
72
-     * @throws EE_Error
73
-     * @throws ReflectionException
74
-     */
75
-    protected function _add_view_counts()
76
-    {
77
-        $this->_views['all']['count'] = EEM_Venue::instance()->count();
78
-        if (EE_Registry::instance()->CAP->current_user_can('ee_delete_venues', 'espresso_venues_trash_venues')) {
79
-            $this->_views['trash']['count'] = EEM_Venue::instance()->count_deleted();
80
-        }
81
-    }
82
-
83
-
84
-    /**
85
-     * @param EE_Venue|null $item
86
-     * @return string
87
-     * @throws EE_Error
88
-     * @throws ReflectionException
89
-     */
90
-    public function column_cb($item): string
91
-    {
92
-        return $item->count_related('Event') > 0 && $item->get('status') === 'trash'
93
-            ? '<span class="dashicons dashicons-lock"></span>'
94
-            : sprintf(
95
-                '<input type="checkbox" name="venue_id[]" value="%s" />',
96
-                $item->ID()
97
-            );
98
-    }
99
-
100
-
101
-    /**
102
-     * @param EE_Venue $venue
103
-     * @return string
104
-     * @throws EE_Error
105
-     * @throws ReflectionException
106
-     */
107
-    public function column_id(EE_Venue $venue): string
108
-    {
109
-        $content = '
16
+	/**
17
+	 * @var Venues_Admin_Page $_admin_page
18
+	 */
19
+	protected $_admin_page;
20
+
21
+
22
+	protected function _setup_data()
23
+	{
24
+		$this->_data           = $this->_admin_page->get_venues($this->_per_page);
25
+		$this->_all_data_count = $this->_admin_page->get_venues($this->_per_page, true);
26
+	}
27
+
28
+
29
+	protected function _set_properties()
30
+	{
31
+		$this->_wp_list_args = [
32
+			'singular' => esc_html__('Event Venue', 'event_espresso'),
33
+			'plural'   => esc_html__('Event Venues', 'event_espresso'),
34
+			'ajax'     => true, // for now,
35
+			'screen'   => $this->_admin_page->get_current_screen()->id,
36
+		];
37
+
38
+		$this->_columns = [
39
+			'cb'       => '<input type="checkbox" />',
40
+			'id'       => esc_html__('ID', 'event_espresso'),
41
+			'name'     => esc_html__('Name', 'event_espresso'),
42
+			'address'  => esc_html__('Address', 'event_espresso'),
43
+			'city'     => esc_html__('City', 'event_espresso'),
44
+			'capacity' => esc_html__('Capacity', 'event_espresso'),
45
+			// 'shortcode' => esc_html__('Shortcode', 'event_espresso'),
46
+		];
47
+
48
+		$this->_sortable_columns = [
49
+			'id'       => ['id' => true],
50
+			'name'     => ['name' => false],
51
+			'city'     => ['city' => false],
52
+			'capacity' => ['capacity' => false],
53
+		];
54
+
55
+		$this->_hidden_columns = [];
56
+	}
57
+
58
+
59
+	// todo... add _venue_status in here (which we'll define a EE_Admin_CPT_List_Table for common properties)
60
+
61
+
62
+	/**
63
+	 * @return array
64
+	 */
65
+	protected function _get_table_filters(): array
66
+	{
67
+		return [];
68
+	}
69
+
70
+
71
+	/**
72
+	 * @throws EE_Error
73
+	 * @throws ReflectionException
74
+	 */
75
+	protected function _add_view_counts()
76
+	{
77
+		$this->_views['all']['count'] = EEM_Venue::instance()->count();
78
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_venues', 'espresso_venues_trash_venues')) {
79
+			$this->_views['trash']['count'] = EEM_Venue::instance()->count_deleted();
80
+		}
81
+	}
82
+
83
+
84
+	/**
85
+	 * @param EE_Venue|null $item
86
+	 * @return string
87
+	 * @throws EE_Error
88
+	 * @throws ReflectionException
89
+	 */
90
+	public function column_cb($item): string
91
+	{
92
+		return $item->count_related('Event') > 0 && $item->get('status') === 'trash'
93
+			? '<span class="dashicons dashicons-lock"></span>'
94
+			: sprintf(
95
+				'<input type="checkbox" name="venue_id[]" value="%s" />',
96
+				$item->ID()
97
+			);
98
+	}
99
+
100
+
101
+	/**
102
+	 * @param EE_Venue $venue
103
+	 * @return string
104
+	 * @throws EE_Error
105
+	 * @throws ReflectionException
106
+	 */
107
+	public function column_id(EE_Venue $venue): string
108
+	{
109
+		$content = '
110 110
             <span class="ee-entity-id">' . $venue->ID() . '</span>
111 111
             <span class="show-on-mobile-view-only">' . $this->column_name($venue, false) . '</span>';
112
-        return $this->columnContent('id', $content, 'end');
113
-    }
114
-
115
-
116
-    /**
117
-     * @param EE_Venue $venue
118
-     * @param bool     $prep_content
119
-     * @return string
120
-     * @throws EE_Error
121
-     * @throws ReflectionException
122
-     */
123
-    public function column_name(EE_Venue $venue, bool $prep_content = true): string
124
-    {
125
-        $edit_link = EE_Admin_Page::add_query_args_and_nonce(
126
-            [
127
-                'action' => 'edit',
128
-                'post'   => $venue->ID(),
129
-            ],
130
-            EE_VENUES_ADMIN_URL
131
-        );
132
-
133
-        $statuses = EEM_Venue::instance()->get_status_array();
134
-        $actions  = $prep_content ? $this->_column_name_action_setup($venue) : [];
135
-        $content  =
136
-            EE_Registry::instance()->CAP->current_user_can('ee_edit_venue', 'espresso_venues_edit', $venue->ID())
137
-                ? '<strong><a class="row-title" href="' . $edit_link . '">' . stripslashes_deep(
138
-                    $venue->name()
139
-                ) . '</a></strong>' : $venue->name();
140
-        $content  .= $venue->status() == 'draft' ? ' - <span class="post-state">' . $statuses['draft'] . '</span>' : '';
141
-
142
-        $content .= $prep_content ? $this->row_actions($actions) : '';
143
-        return $prep_content ? $this->columnContent('name', $content) : $content;
144
-    }
145
-
146
-
147
-    /**
148
-     * Used to setup the actions for the Venue name column
149
-     *
150
-     * @param EE_Venue $venue
151
-     * @return array()
152
-     * @throws EE_Error
153
-     * @throws ReflectionException
154
-     * @throws EE_Error
155
-     * @throws ReflectionException
156
-     */
157
-    protected function _column_name_action_setup(EE_Venue $venue): array
158
-    {
159
-        $actions = [];
160
-
161
-        if (EE_Registry::instance()->CAP->current_user_can('ee_edit_venue', 'espresso_venues_edit', $venue->ID())) {
162
-            $edit_query_args = [
163
-                'action' => 'edit',
164
-                'post'   => $venue->ID(),
165
-            ];
166
-            $edit_link       = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EE_VENUES_ADMIN_URL);
167
-            $actions['edit'] = '<a href="' . $edit_link . '" title="' . esc_attr__(
168
-                    'Edit Venue',
169
-                    'event_espresso'
170
-                ) . '">' . esc_html__('Edit', 'event_espresso') . '</a>';
171
-        }
172
-
173
-
174
-        switch ($venue->get('status')) {
175
-            case 'trash':
176
-                if (
177
-                    EE_Registry::instance()->CAP->current_user_can(
178
-                        'ee_delete_venue',
179
-                        'espresso_venues_restore_venue',
180
-                        $venue->ID()
181
-                    )
182
-                ) {
183
-                    $restore_venue_link = EE_Admin_Page::add_query_args_and_nonce(
184
-                        [
185
-                            'action' => 'restore_venue',
186
-                            'VNU_ID' => $venue->ID(),
187
-                        ],
188
-                        EE_VENUES_ADMIN_URL
189
-                    );
190
-
191
-                    $actions['restore_from_trash'] = '<a href="' . $restore_venue_link . '" title="' . esc_attr__(
192
-                            'Restore from Trash',
193
-                            'event_espresso'
194
-                        ) . '">' . esc_html__('Restore from Trash', 'event_espresso') . '</a>';
195
-                }
196
-                if (
197
-                    $venue->count_related('Event') === 0
198
-                    && EE_Registry::instance()->CAP->current_user_can(
199
-                        'ee_delete_venue',
200
-                        'espresso_venues_delete_venue',
201
-                        $venue->ID()
202
-                    )
203
-                ) {
204
-                    $delete_venue_link = EE_Admin_Page::add_query_args_and_nonce(
205
-                        [
206
-                            'action' => 'delete_venue',
207
-                            'VNU_ID' => $venue->ID(),
208
-                        ],
209
-                        EE_VENUES_ADMIN_URL
210
-                    );
211
-
212
-                    $actions['delete permanently'] = '<a href="' . $delete_venue_link . '" title="' . esc_attr__(
213
-                            'Delete Permanently',
214
-                            'event_espresso'
215
-                        ) . '">' . esc_html__('Delete Permanently', 'event_espresso') . '</a>';
216
-                }
217
-                break;
218
-            default:
219
-                $actions['view'] = '
112
+		return $this->columnContent('id', $content, 'end');
113
+	}
114
+
115
+
116
+	/**
117
+	 * @param EE_Venue $venue
118
+	 * @param bool     $prep_content
119
+	 * @return string
120
+	 * @throws EE_Error
121
+	 * @throws ReflectionException
122
+	 */
123
+	public function column_name(EE_Venue $venue, bool $prep_content = true): string
124
+	{
125
+		$edit_link = EE_Admin_Page::add_query_args_and_nonce(
126
+			[
127
+				'action' => 'edit',
128
+				'post'   => $venue->ID(),
129
+			],
130
+			EE_VENUES_ADMIN_URL
131
+		);
132
+
133
+		$statuses = EEM_Venue::instance()->get_status_array();
134
+		$actions  = $prep_content ? $this->_column_name_action_setup($venue) : [];
135
+		$content  =
136
+			EE_Registry::instance()->CAP->current_user_can('ee_edit_venue', 'espresso_venues_edit', $venue->ID())
137
+				? '<strong><a class="row-title" href="' . $edit_link . '">' . stripslashes_deep(
138
+					$venue->name()
139
+				) . '</a></strong>' : $venue->name();
140
+		$content  .= $venue->status() == 'draft' ? ' - <span class="post-state">' . $statuses['draft'] . '</span>' : '';
141
+
142
+		$content .= $prep_content ? $this->row_actions($actions) : '';
143
+		return $prep_content ? $this->columnContent('name', $content) : $content;
144
+	}
145
+
146
+
147
+	/**
148
+	 * Used to setup the actions for the Venue name column
149
+	 *
150
+	 * @param EE_Venue $venue
151
+	 * @return array()
152
+	 * @throws EE_Error
153
+	 * @throws ReflectionException
154
+	 * @throws EE_Error
155
+	 * @throws ReflectionException
156
+	 */
157
+	protected function _column_name_action_setup(EE_Venue $venue): array
158
+	{
159
+		$actions = [];
160
+
161
+		if (EE_Registry::instance()->CAP->current_user_can('ee_edit_venue', 'espresso_venues_edit', $venue->ID())) {
162
+			$edit_query_args = [
163
+				'action' => 'edit',
164
+				'post'   => $venue->ID(),
165
+			];
166
+			$edit_link       = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EE_VENUES_ADMIN_URL);
167
+			$actions['edit'] = '<a href="' . $edit_link . '" title="' . esc_attr__(
168
+					'Edit Venue',
169
+					'event_espresso'
170
+				) . '">' . esc_html__('Edit', 'event_espresso') . '</a>';
171
+		}
172
+
173
+
174
+		switch ($venue->get('status')) {
175
+			case 'trash':
176
+				if (
177
+					EE_Registry::instance()->CAP->current_user_can(
178
+						'ee_delete_venue',
179
+						'espresso_venues_restore_venue',
180
+						$venue->ID()
181
+					)
182
+				) {
183
+					$restore_venue_link = EE_Admin_Page::add_query_args_and_nonce(
184
+						[
185
+							'action' => 'restore_venue',
186
+							'VNU_ID' => $venue->ID(),
187
+						],
188
+						EE_VENUES_ADMIN_URL
189
+					);
190
+
191
+					$actions['restore_from_trash'] = '<a href="' . $restore_venue_link . '" title="' . esc_attr__(
192
+							'Restore from Trash',
193
+							'event_espresso'
194
+						) . '">' . esc_html__('Restore from Trash', 'event_espresso') . '</a>';
195
+				}
196
+				if (
197
+					$venue->count_related('Event') === 0
198
+					&& EE_Registry::instance()->CAP->current_user_can(
199
+						'ee_delete_venue',
200
+						'espresso_venues_delete_venue',
201
+						$venue->ID()
202
+					)
203
+				) {
204
+					$delete_venue_link = EE_Admin_Page::add_query_args_and_nonce(
205
+						[
206
+							'action' => 'delete_venue',
207
+							'VNU_ID' => $venue->ID(),
208
+						],
209
+						EE_VENUES_ADMIN_URL
210
+					);
211
+
212
+					$actions['delete permanently'] = '<a href="' . $delete_venue_link . '" title="' . esc_attr__(
213
+							'Delete Permanently',
214
+							'event_espresso'
215
+						) . '">' . esc_html__('Delete Permanently', 'event_espresso') . '</a>';
216
+				}
217
+				break;
218
+			default:
219
+				$actions['view'] = '
220 220
                     <a  href="' . get_permalink($venue->ID()) . '"
221 221
                         title="' . esc_attr__('View Venue', 'event_espresso') . '"
222 222
                     >
223 223
                         ' . esc_html__('View', 'event_espresso') . '
224 224
                     </a>';
225
-                if (
226
-                    EE_Registry::instance()->CAP->current_user_can(
227
-                        'ee_delete_venue',
228
-                        'espresso_venues_trash_venue',
229
-                        $venue->ID()
230
-                    )
231
-                ) {
232
-                    $trash_venue_link = EE_Admin_Page::add_query_args_and_nonce(
233
-                        [
234
-                            'action' => 'trash_venue',
235
-                            'VNU_ID' => $venue->ID(),
236
-                        ],
237
-                        EE_VENUES_ADMIN_URL
238
-                    );
239
-
240
-                    $actions['move to trash'] = '<a href="' . $trash_venue_link . '" title="' . esc_attr__(
241
-                            'Trash Event',
242
-                            'event_espresso'
243
-                        ) . '">' . esc_html__('Trash', 'event_espresso') . '</a>';
244
-                }
245
-        }
246
-        return $actions;
247
-    }
248
-
249
-
250
-    public function column_address(EE_Venue $venue): string
251
-    {
252
-        return $this->columnContent('address', $venue->address());
253
-    }
254
-
255
-
256
-    public function column_city(EE_Venue $venue): string
257
-    {
258
-        return $this->columnContent('city', $venue->city());
259
-    }
260
-
261
-
262
-    /**
263
-     * @throws EE_Error
264
-     * @throws ReflectionException
265
-     */
266
-    public function column_capacity(EE_Venue $venue): string
267
-    {
268
-        return $this->columnContent('capacity', $venue->capacity());
269
-    }
270
-
271
-
272
-    /**
273
-     * @throws ReflectionException
274
-     * @throws EE_Error
275
-     */
276
-    public function column_shortcode(EE_Venue $venue): string
277
-    {
278
-        $content = '[ESPRESSO_VENUE id=' . $venue->ID() . ']';
279
-        return $this->columnContent('shortcode', $content);
280
-    }
225
+				if (
226
+					EE_Registry::instance()->CAP->current_user_can(
227
+						'ee_delete_venue',
228
+						'espresso_venues_trash_venue',
229
+						$venue->ID()
230
+					)
231
+				) {
232
+					$trash_venue_link = EE_Admin_Page::add_query_args_and_nonce(
233
+						[
234
+							'action' => 'trash_venue',
235
+							'VNU_ID' => $venue->ID(),
236
+						],
237
+						EE_VENUES_ADMIN_URL
238
+					);
239
+
240
+					$actions['move to trash'] = '<a href="' . $trash_venue_link . '" title="' . esc_attr__(
241
+							'Trash Event',
242
+							'event_espresso'
243
+						) . '">' . esc_html__('Trash', 'event_espresso') . '</a>';
244
+				}
245
+		}
246
+		return $actions;
247
+	}
248
+
249
+
250
+	public function column_address(EE_Venue $venue): string
251
+	{
252
+		return $this->columnContent('address', $venue->address());
253
+	}
254
+
255
+
256
+	public function column_city(EE_Venue $venue): string
257
+	{
258
+		return $this->columnContent('city', $venue->city());
259
+	}
260
+
261
+
262
+	/**
263
+	 * @throws EE_Error
264
+	 * @throws ReflectionException
265
+	 */
266
+	public function column_capacity(EE_Venue $venue): string
267
+	{
268
+		return $this->columnContent('capacity', $venue->capacity());
269
+	}
270
+
271
+
272
+	/**
273
+	 * @throws ReflectionException
274
+	 * @throws EE_Error
275
+	 */
276
+	public function column_shortcode(EE_Venue $venue): string
277
+	{
278
+		$content = '[ESPRESSO_VENUE id=' . $venue->ID() . ']';
279
+		return $this->columnContent('shortcode', $content);
280
+	}
281 281
 }
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -107,8 +107,8 @@  discard block
 block discarded – undo
107 107
     public function column_id(EE_Venue $venue): string
108 108
     {
109 109
         $content = '
110
-            <span class="ee-entity-id">' . $venue->ID() . '</span>
111
-            <span class="show-on-mobile-view-only">' . $this->column_name($venue, false) . '</span>';
110
+            <span class="ee-entity-id">' . $venue->ID().'</span>
111
+            <span class="show-on-mobile-view-only">' . $this->column_name($venue, false).'</span>';
112 112
         return $this->columnContent('id', $content, 'end');
113 113
     }
114 114
 
@@ -134,10 +134,10 @@  discard block
 block discarded – undo
134 134
         $actions  = $prep_content ? $this->_column_name_action_setup($venue) : [];
135 135
         $content  =
136 136
             EE_Registry::instance()->CAP->current_user_can('ee_edit_venue', 'espresso_venues_edit', $venue->ID())
137
-                ? '<strong><a class="row-title" href="' . $edit_link . '">' . stripslashes_deep(
137
+                ? '<strong><a class="row-title" href="'.$edit_link.'">'.stripslashes_deep(
138 138
                     $venue->name()
139
-                ) . '</a></strong>' : $venue->name();
140
-        $content  .= $venue->status() == 'draft' ? ' - <span class="post-state">' . $statuses['draft'] . '</span>' : '';
139
+                ).'</a></strong>' : $venue->name();
140
+        $content .= $venue->status() == 'draft' ? ' - <span class="post-state">'.$statuses['draft'].'</span>' : '';
141 141
 
142 142
         $content .= $prep_content ? $this->row_actions($actions) : '';
143 143
         return $prep_content ? $this->columnContent('name', $content) : $content;
@@ -164,10 +164,10 @@  discard block
 block discarded – undo
164 164
                 'post'   => $venue->ID(),
165 165
             ];
166 166
             $edit_link       = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EE_VENUES_ADMIN_URL);
167
-            $actions['edit'] = '<a href="' . $edit_link . '" title="' . esc_attr__(
167
+            $actions['edit'] = '<a href="'.$edit_link.'" title="'.esc_attr__(
168 168
                     'Edit Venue',
169 169
                     'event_espresso'
170
-                ) . '">' . esc_html__('Edit', 'event_espresso') . '</a>';
170
+                ).'">'.esc_html__('Edit', 'event_espresso').'</a>';
171 171
         }
172 172
 
173 173
 
@@ -188,10 +188,10 @@  discard block
 block discarded – undo
188 188
                         EE_VENUES_ADMIN_URL
189 189
                     );
190 190
 
191
-                    $actions['restore_from_trash'] = '<a href="' . $restore_venue_link . '" title="' . esc_attr__(
191
+                    $actions['restore_from_trash'] = '<a href="'.$restore_venue_link.'" title="'.esc_attr__(
192 192
                             'Restore from Trash',
193 193
                             'event_espresso'
194
-                        ) . '">' . esc_html__('Restore from Trash', 'event_espresso') . '</a>';
194
+                        ).'">'.esc_html__('Restore from Trash', 'event_espresso').'</a>';
195 195
                 }
196 196
                 if (
197 197
                     $venue->count_related('Event') === 0
@@ -209,18 +209,18 @@  discard block
 block discarded – undo
209 209
                         EE_VENUES_ADMIN_URL
210 210
                     );
211 211
 
212
-                    $actions['delete permanently'] = '<a href="' . $delete_venue_link . '" title="' . esc_attr__(
212
+                    $actions['delete permanently'] = '<a href="'.$delete_venue_link.'" title="'.esc_attr__(
213 213
                             'Delete Permanently',
214 214
                             'event_espresso'
215
-                        ) . '">' . esc_html__('Delete Permanently', 'event_espresso') . '</a>';
215
+                        ).'">'.esc_html__('Delete Permanently', 'event_espresso').'</a>';
216 216
                 }
217 217
                 break;
218 218
             default:
219 219
                 $actions['view'] = '
220
-                    <a  href="' . get_permalink($venue->ID()) . '"
221
-                        title="' . esc_attr__('View Venue', 'event_espresso') . '"
220
+                    <a  href="' . get_permalink($venue->ID()).'"
221
+                        title="' . esc_attr__('View Venue', 'event_espresso').'"
222 222
                     >
223
-                        ' . esc_html__('View', 'event_espresso') . '
223
+                        ' . esc_html__('View', 'event_espresso').'
224 224
                     </a>';
225 225
                 if (
226 226
                     EE_Registry::instance()->CAP->current_user_can(
@@ -237,10 +237,10 @@  discard block
 block discarded – undo
237 237
                         EE_VENUES_ADMIN_URL
238 238
                     );
239 239
 
240
-                    $actions['move to trash'] = '<a href="' . $trash_venue_link . '" title="' . esc_attr__(
240
+                    $actions['move to trash'] = '<a href="'.$trash_venue_link.'" title="'.esc_attr__(
241 241
                             'Trash Event',
242 242
                             'event_espresso'
243
-                        ) . '">' . esc_html__('Trash', 'event_espresso') . '</a>';
243
+                        ).'">'.esc_html__('Trash', 'event_espresso').'</a>';
244 244
                 }
245 245
         }
246 246
         return $actions;
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
      */
276 276
     public function column_shortcode(EE_Venue $venue): string
277 277
     {
278
-        $content = '[ESPRESSO_VENUE id=' . $venue->ID() . ']';
278
+        $content = '[ESPRESSO_VENUE id='.$venue->ID().']';
279 279
         return $this->columnContent('shortcode', $content);
280 280
     }
281 281
 }
Please login to merge, or discard this patch.
admin_pages/venues/Venue_Categories_Admin_List_Table.class.php 2 patches
Indentation   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -13,137 +13,137 @@
 block discarded – undo
13 13
  */
14 14
 class Venue_Categories_Admin_List_Table extends EE_Admin_List_Table
15 15
 {
16
-    protected function _setup_data()
17
-    {
18
-        $this->_data = $this->_admin_page->get_categories($this->_per_page, $this->_current_page);
19
-        $this->_all_data_count = $this->_admin_page->get_categories($this->_per_page, $this->_current_page, true);
20
-    }
21
-
22
-
23
-    protected function _set_properties()
24
-    {
25
-        $this->_wp_list_args = array(
26
-            'singular' => esc_html__('venue category', 'event_espresso'),
27
-            'plural'   => esc_html__('venue categories', 'event_espresso'),
28
-            'ajax'     => true, // for now,
29
-            'screen'   => $this->_admin_page->get_current_screen()->id,
30
-        );
31
-
32
-        $this->_columns = array(
33
-            'cb'    => '<input type="checkbox" />',
34
-            'id'    => esc_html__('ID', 'event_espresso'),
35
-            'name'  => esc_html__('Name', 'event_espresso'),
36
-            'count' => esc_html__('Venues', 'event_espresso'),
37
-        );
38
-
39
-        $this->_sortable_columns = array(
40
-            'id'    => array('Term.term_id' => true),
41
-            'name'  => array('Term.slug' => false),
42
-            'count' => array('term_count' => false),
43
-        );
44
-
45
-        $this->_hidden_columns = array();
46
-    }
47
-
48
-
49
-    // not needed
50
-    protected function _get_table_filters()
51
-    {
52
-        return array();
53
-    }
54
-
55
-
56
-    protected function _add_view_counts()
57
-    {
58
-        $this->_views['all']['count'] = $this->_all_data_count;
59
-    }
60
-
61
-
62
-    public function column_cb($item)
63
-    {
64
-        return sprintf('<input type="checkbox" name="VEN_CAT_ID[]" value="%s" />', $item->get('term_id'));
65
-    }
66
-
67
-
68
-    public function column_id($item)
69
-    {
70
-        $content = '<span class="ee-entity-id">' . $item->get('term_id') . '</span>';
71
-        $content .= '
16
+	protected function _setup_data()
17
+	{
18
+		$this->_data = $this->_admin_page->get_categories($this->_per_page, $this->_current_page);
19
+		$this->_all_data_count = $this->_admin_page->get_categories($this->_per_page, $this->_current_page, true);
20
+	}
21
+
22
+
23
+	protected function _set_properties()
24
+	{
25
+		$this->_wp_list_args = array(
26
+			'singular' => esc_html__('venue category', 'event_espresso'),
27
+			'plural'   => esc_html__('venue categories', 'event_espresso'),
28
+			'ajax'     => true, // for now,
29
+			'screen'   => $this->_admin_page->get_current_screen()->id,
30
+		);
31
+
32
+		$this->_columns = array(
33
+			'cb'    => '<input type="checkbox" />',
34
+			'id'    => esc_html__('ID', 'event_espresso'),
35
+			'name'  => esc_html__('Name', 'event_espresso'),
36
+			'count' => esc_html__('Venues', 'event_espresso'),
37
+		);
38
+
39
+		$this->_sortable_columns = array(
40
+			'id'    => array('Term.term_id' => true),
41
+			'name'  => array('Term.slug' => false),
42
+			'count' => array('term_count' => false),
43
+		);
44
+
45
+		$this->_hidden_columns = array();
46
+	}
47
+
48
+
49
+	// not needed
50
+	protected function _get_table_filters()
51
+	{
52
+		return array();
53
+	}
54
+
55
+
56
+	protected function _add_view_counts()
57
+	{
58
+		$this->_views['all']['count'] = $this->_all_data_count;
59
+	}
60
+
61
+
62
+	public function column_cb($item)
63
+	{
64
+		return sprintf('<input type="checkbox" name="VEN_CAT_ID[]" value="%s" />', $item->get('term_id'));
65
+	}
66
+
67
+
68
+	public function column_id($item)
69
+	{
70
+		$content = '<span class="ee-entity-id">' . $item->get('term_id') . '</span>';
71
+		$content .= '
72 72
             <span class="show-on-mobile-view-only">
73 73
                 ' . $this->column_name($item, false) . '
74 74
             </span>';
75
-        return $this->columnContent('id', $content, 'end');
76
-    }
77
-
78
-
79
-    public function column_name(EE_Term_Taxonomy $item, bool $prep_content = true): string
80
-    {
81
-        $VEN_CAT_ID = $item->get('term_id');
82
-        $edit_query_args = array(
83
-            'action'     => 'edit_category',
84
-            'VEN_CAT_ID' => $VEN_CAT_ID,
85
-        );
86
-
87
-        $delete_query_args = array(
88
-            'action'     => 'delete_category',
89
-            'VEN_CAT_ID' => $VEN_CAT_ID,
90
-        );
91
-
92
-        $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EE_VENUES_ADMIN_URL);
93
-        $delete_link = EE_Admin_Page::add_query_args_and_nonce($delete_query_args, EE_VENUES_ADMIN_URL);
94
-
95
-        $term_name = $item->get_first_related('Term')->get('name');
96
-
97
-        $actions = array(
98
-            'edit' => '<a href="' . $edit_link . '" aria-label="' . sprintf(
99
-                /* translators: The name of the venue category */
100
-                esc_attr__(
101
-                    'Edit Category (%s)',
102
-                    'event_espresso'
103
-                ),
104
-                $term_name
105
-            ) . '">' . esc_html__('Edit', 'event_espresso') . '</a>',
106
-        );
107
-
108
-
109
-        $actions['delete'] = '<a href="' . $delete_link . '" aria-label="' . sprintf(
110
-            /* translators: The name of the venue category */
111
-            esc_attr__(
112
-                'Delete Category (%s)',
113
-                'event_espresso'
114
-            ),
115
-            $term_name
116
-        ) . '">' . esc_html__('Delete', 'event_espresso') . '</a>';
117
-
118
-        $content = '
75
+		return $this->columnContent('id', $content, 'end');
76
+	}
77
+
78
+
79
+	public function column_name(EE_Term_Taxonomy $item, bool $prep_content = true): string
80
+	{
81
+		$VEN_CAT_ID = $item->get('term_id');
82
+		$edit_query_args = array(
83
+			'action'     => 'edit_category',
84
+			'VEN_CAT_ID' => $VEN_CAT_ID,
85
+		);
86
+
87
+		$delete_query_args = array(
88
+			'action'     => 'delete_category',
89
+			'VEN_CAT_ID' => $VEN_CAT_ID,
90
+		);
91
+
92
+		$edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EE_VENUES_ADMIN_URL);
93
+		$delete_link = EE_Admin_Page::add_query_args_and_nonce($delete_query_args, EE_VENUES_ADMIN_URL);
94
+
95
+		$term_name = $item->get_first_related('Term')->get('name');
96
+
97
+		$actions = array(
98
+			'edit' => '<a href="' . $edit_link . '" aria-label="' . sprintf(
99
+				/* translators: The name of the venue category */
100
+				esc_attr__(
101
+					'Edit Category (%s)',
102
+					'event_espresso'
103
+				),
104
+				$term_name
105
+			) . '">' . esc_html__('Edit', 'event_espresso') . '</a>',
106
+		);
107
+
108
+
109
+		$actions['delete'] = '<a href="' . $delete_link . '" aria-label="' . sprintf(
110
+			/* translators: The name of the venue category */
111
+			esc_attr__(
112
+				'Delete Category (%s)',
113
+				'event_espresso'
114
+			),
115
+			$term_name
116
+		) . '">' . esc_html__('Delete', 'event_espresso') . '</a>';
117
+
118
+		$content = '
119 119
             <strong>
120 120
                 <a class="row-title" href="' . $edit_link . '">
121 121
                     ' . $item->get_first_related('Term')->get('name') . '
122 122
                 </a>
123 123
             </strong>';
124 124
 
125
-        $content .= $prep_content ? $this->row_actions($actions) : '';
126
-        return $prep_content ? $this->columnContent('name', $content) : $content;
127
-    }
125
+		$content .= $prep_content ? $this->row_actions($actions) : '';
126
+		return $prep_content ? $this->columnContent('name', $content) : $content;
127
+	}
128 128
 
129 129
 
130
-    public function column_shortcode(EE_Term_Taxonomy $item): string
131
-    {
132
-        $content = '[EVENT_ESPRESSO_CATEGORY category_id="' . $item->get_first_related('Term')->get('slug') . '"]';
133
-        return $this->columnContent('shortcode', $content);
134
-    }
130
+	public function column_shortcode(EE_Term_Taxonomy $item): string
131
+	{
132
+		$content = '[EVENT_ESPRESSO_CATEGORY category_id="' . $item->get_first_related('Term')->get('slug') . '"]';
133
+		return $this->columnContent('shortcode', $content);
134
+	}
135 135
 
136 136
 
137
-    public function column_count(EE_Term_Taxonomy $item): string
138
-    {
139
-        $args = array(
140
-            'action'   => 'default',
141
-            'category' => $item->get_first_related('Term')->ID(),
142
-        );
143
-        $content = '
137
+	public function column_count(EE_Term_Taxonomy $item): string
138
+	{
139
+		$args = array(
140
+			'action'   => 'default',
141
+			'category' => $item->get_first_related('Term')->ID(),
142
+		);
143
+		$content = '
144 144
         <a href="' . EE_Admin_Page::add_query_args_and_nonce($args, EE_VENUES_ADMIN_URL) . '">
145 145
             ' . $item->get('term_count') . '
146 146
         </a>';
147
-        return $this->columnContent('count', $content, 'end');
148
-    }
147
+		return $this->columnContent('count', $content, 'end');
148
+	}
149 149
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -67,10 +67,10 @@  discard block
 block discarded – undo
67 67
 
68 68
     public function column_id($item)
69 69
     {
70
-        $content = '<span class="ee-entity-id">' . $item->get('term_id') . '</span>';
70
+        $content = '<span class="ee-entity-id">'.$item->get('term_id').'</span>';
71 71
         $content .= '
72 72
             <span class="show-on-mobile-view-only">
73
-                ' . $this->column_name($item, false) . '
73
+                ' . $this->column_name($item, false).'
74 74
             </span>';
75 75
         return $this->columnContent('id', $content, 'end');
76 76
     }
@@ -95,30 +95,30 @@  discard block
 block discarded – undo
95 95
         $term_name = $item->get_first_related('Term')->get('name');
96 96
 
97 97
         $actions = array(
98
-            'edit' => '<a href="' . $edit_link . '" aria-label="' . sprintf(
98
+            'edit' => '<a href="'.$edit_link.'" aria-label="'.sprintf(
99 99
                 /* translators: The name of the venue category */
100 100
                 esc_attr__(
101 101
                     'Edit Category (%s)',
102 102
                     'event_espresso'
103 103
                 ),
104 104
                 $term_name
105
-            ) . '">' . esc_html__('Edit', 'event_espresso') . '</a>',
105
+            ).'">'.esc_html__('Edit', 'event_espresso').'</a>',
106 106
         );
107 107
 
108 108
 
109
-        $actions['delete'] = '<a href="' . $delete_link . '" aria-label="' . sprintf(
109
+        $actions['delete'] = '<a href="'.$delete_link.'" aria-label="'.sprintf(
110 110
             /* translators: The name of the venue category */
111 111
             esc_attr__(
112 112
                 'Delete Category (%s)',
113 113
                 'event_espresso'
114 114
             ),
115 115
             $term_name
116
-        ) . '">' . esc_html__('Delete', 'event_espresso') . '</a>';
116
+        ).'">'.esc_html__('Delete', 'event_espresso').'</a>';
117 117
 
118 118
         $content = '
119 119
             <strong>
120
-                <a class="row-title" href="' . $edit_link . '">
121
-                    ' . $item->get_first_related('Term')->get('name') . '
120
+                <a class="row-title" href="' . $edit_link.'">
121
+                    ' . $item->get_first_related('Term')->get('name').'
122 122
                 </a>
123 123
             </strong>';
124 124
 
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 
130 130
     public function column_shortcode(EE_Term_Taxonomy $item): string
131 131
     {
132
-        $content = '[EVENT_ESPRESSO_CATEGORY category_id="' . $item->get_first_related('Term')->get('slug') . '"]';
132
+        $content = '[EVENT_ESPRESSO_CATEGORY category_id="'.$item->get_first_related('Term')->get('slug').'"]';
133 133
         return $this->columnContent('shortcode', $content);
134 134
     }
135 135
 
@@ -141,8 +141,8 @@  discard block
 block discarded – undo
141 141
             'category' => $item->get_first_related('Term')->ID(),
142 142
         );
143 143
         $content = '
144
-        <a href="' . EE_Admin_Page::add_query_args_and_nonce($args, EE_VENUES_ADMIN_URL) . '">
145
-            ' . $item->get('term_count') . '
144
+        <a href="' . EE_Admin_Page::add_query_args_and_nonce($args, EE_VENUES_ADMIN_URL).'">
145
+            ' . $item->get('term_count').'
146 146
         </a>';
147 147
         return $this->columnContent('count', $content, 'end');
148 148
     }
Please login to merge, or discard this patch.