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