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