Completed
Branch BUG-10381-asset-loading (154302)
by
unknown
40:06 queued 28:16
created
core/libraries/rest_api/controllers/config/Read.php 1 patch
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 namespace EventEspresso\core\libraries\rest_api\controllers\config;
3 3
 
4 4
 if (! defined('EVENT_ESPRESSO_VERSION')) {
5
-    exit('No direct script access allowed');
5
+	exit('No direct script access allowed');
6 6
 }
7 7
 
8 8
 
@@ -18,74 +18,74 @@  discard block
 block discarded – undo
18 18
 class Read
19 19
 {
20 20
 
21
-    /**
22
-     * @param \WP_REST_Request $request
23
-     * @return \EE_Config|\WP_Error
24
-     */
25
-    public static function handle_request(\WP_REST_Request $request)
26
-    {
27
-        $cap = \EE_Restriction_Generator_Base::get_default_restrictions_cap();
28
-        if (\EE_Capabilities::instance()->current_user_can($cap, 'read_over_api')) {
29
-            return \EE_Config::instance();
30
-        } else {
31
-            return new \WP_Error(
32
-                'cannot_read_config',
33
-                sprintf(
34
-                    __(
35
-                        'You do not have the necessary capabilities (%s) to read Event Espresso Configuration data',
36
-                        'event_espresso'
37
-                    ),
38
-                    $cap
39
-                ),
40
-                array('status' => 403)
41
-            );
42
-        }
43
-    }
21
+	/**
22
+	 * @param \WP_REST_Request $request
23
+	 * @return \EE_Config|\WP_Error
24
+	 */
25
+	public static function handle_request(\WP_REST_Request $request)
26
+	{
27
+		$cap = \EE_Restriction_Generator_Base::get_default_restrictions_cap();
28
+		if (\EE_Capabilities::instance()->current_user_can($cap, 'read_over_api')) {
29
+			return \EE_Config::instance();
30
+		} else {
31
+			return new \WP_Error(
32
+				'cannot_read_config',
33
+				sprintf(
34
+					__(
35
+						'You do not have the necessary capabilities (%s) to read Event Espresso Configuration data',
36
+						'event_espresso'
37
+					),
38
+					$cap
39
+				),
40
+				array('status' => 403)
41
+			);
42
+		}
43
+	}
44 44
 
45 45
 
46 46
 
47
-    /**
48
-     * Handles the request for public site info
49
-     *
50
-     * @global                 $wp_json_basic_auth_success       boolean set by the basic auth plugin, indicates if the
51
-     *                         current user could be authenticated using basic auth data
52
-     * @global                 $wp_json_basic_auth_received_data boolean set by the basic auth plugin, indicates if
53
-     *                         basic auth data was somehow received
54
-     * @param \WP_REST_Request $request
55
-     * @return \EE_Config|\WP_Error
56
-     */
57
-    public static function handle_request_site_info(\WP_REST_Request $request)
58
-    {
59
-        global $wp_json_basic_auth_success, $wp_json_basic_auth_received_data;
60
-        $insecure_usage_of_basic_auth = apply_filters(
61
-            'EventEspresso__core__libraries__rest_api__controllers__config__handle_request_site_info__insecure_usage_of_basic_auth',
62
-            $wp_json_basic_auth_success && ! is_ssl(),
63
-            $request
64
-        );
65
-        if ($insecure_usage_of_basic_auth) {
66
-            $warning = sprintf(
67
-                esc_html__('Notice: We strongly recommend installing an SSL Certificate on your website to keep your data secure. %1$sPlease see our recommendations.%2$s',
68
-                    'event_espresso'),
69
-                '<a href="https://eventespresso.com/wiki/rest-api-security-recommendations/">',
70
-                '</a>'
71
-            );
72
-        } else {
73
-            $warning = '';
74
-        }
75
-        return array(
76
-            'default_timezone' => array(
77
-                'pretty' => \EEH_DTT_Helper::get_timezone_string_for_display(),
78
-                'string' => get_option('timezone_string'),
79
-                'offset' => \EEH_DTT_Helper::get_site_timezone_gmt_offset(),
80
-            ),
81
-            'default_currency' => \EE_Config::instance()->currency,
82
-            'authentication'   => array(
83
-                'received_basic_auth_data'     => (bool)$wp_json_basic_auth_received_data,
84
-                'insecure_usage_of_basic_auth' => (bool)$insecure_usage_of_basic_auth,
85
-                'warning'                      => $warning
86
-            )
87
-        );
88
-    }
47
+	/**
48
+	 * Handles the request for public site info
49
+	 *
50
+	 * @global                 $wp_json_basic_auth_success       boolean set by the basic auth plugin, indicates if the
51
+	 *                         current user could be authenticated using basic auth data
52
+	 * @global                 $wp_json_basic_auth_received_data boolean set by the basic auth plugin, indicates if
53
+	 *                         basic auth data was somehow received
54
+	 * @param \WP_REST_Request $request
55
+	 * @return \EE_Config|\WP_Error
56
+	 */
57
+	public static function handle_request_site_info(\WP_REST_Request $request)
58
+	{
59
+		global $wp_json_basic_auth_success, $wp_json_basic_auth_received_data;
60
+		$insecure_usage_of_basic_auth = apply_filters(
61
+			'EventEspresso__core__libraries__rest_api__controllers__config__handle_request_site_info__insecure_usage_of_basic_auth',
62
+			$wp_json_basic_auth_success && ! is_ssl(),
63
+			$request
64
+		);
65
+		if ($insecure_usage_of_basic_auth) {
66
+			$warning = sprintf(
67
+				esc_html__('Notice: We strongly recommend installing an SSL Certificate on your website to keep your data secure. %1$sPlease see our recommendations.%2$s',
68
+					'event_espresso'),
69
+				'<a href="https://eventespresso.com/wiki/rest-api-security-recommendations/">',
70
+				'</a>'
71
+			);
72
+		} else {
73
+			$warning = '';
74
+		}
75
+		return array(
76
+			'default_timezone' => array(
77
+				'pretty' => \EEH_DTT_Helper::get_timezone_string_for_display(),
78
+				'string' => get_option('timezone_string'),
79
+				'offset' => \EEH_DTT_Helper::get_site_timezone_gmt_offset(),
80
+			),
81
+			'default_currency' => \EE_Config::instance()->currency,
82
+			'authentication'   => array(
83
+				'received_basic_auth_data'     => (bool)$wp_json_basic_auth_received_data,
84
+				'insecure_usage_of_basic_auth' => (bool)$insecure_usage_of_basic_auth,
85
+				'warning'                      => $warning
86
+			)
87
+		);
88
+	}
89 89
 }
90 90
 
91 91
 // End of file Read.php
92 92
\ No newline at end of file
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
 }
399 399
\ No newline at end of file
Please login to merge, or discard this patch.
admin/new/pricing/templates/event_tickets_datetime_ticket_row.template.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1
-    <tr valign="top" class="ee-ticket-sortable ticket-row<?php echo $ticket_archive_class; if(WP_DEBUG){ echo ' ee-wp-debug'; } ?>" id="display-ticketrow-<?php echo $tkt_row; ?>">
1
+    <tr valign="top" class="ee-ticket-sortable ticket-row<?php echo $ticket_archive_class; if (WP_DEBUG) { echo ' ee-wp-debug'; } ?>" id="display-ticketrow-<?php echo $tkt_row; ?>">
2 2
 	<!--<td class="ee-tkt-order-field"><span class="dashicons dashicons-sort<?php echo $tkt_status_class; ?>"><input type="hidden" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_order]" class="edit-ticket-TKT_order" value ="<?php echo $TKT_order; ?>" ></span></td>-->
3 3
 	<td class="ee-tkt-order-field"><span class="ee-status-strip-td ee-status-strip<?php echo $tkt_status_class; ?>"></span><input type="hidden" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_order]" class="edit-ticket-TKT_order" value ="<?php echo $TKT_order; ?>"></td>
4 4
 	<td><input maxlength="245" type="text" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_name]" class="edit-ticket-TKT_name ee-large-text-inp" placeholder="Ticket Title" value="<?php echo $TKT_name; ?>"></td>
5 5
 	<td>
6
-		<?php if ( $disabled ) : ?>
6
+		<?php if ($disabled) : ?>
7 7
 			<input type="hidden" id="edit-ticket-TKT_start_date-<?php echo $tkt_row; ?>"  name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_start_date]" class="edit-ticket-TKT_start_date ee-text-inp" value="<?php echo $TKT_start_date; ?>" >
8 8
 			<input type="text" name="archived_ticket[TKT_start_date]" class="edit-ticket-TKT_start_date ee-text-inp" value="<?php echo $TKT_start_date; ?>" disabled>
9 9
 		<?php else : ?>
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 		<?php endif; ?>
12 12
 	</td>
13 13
 	<td>
14
-		<?php if ( $disabled ) : ?>
14
+		<?php if ($disabled) : ?>
15 15
 			<input type="hidden" id="edit-ticket-TKT_end_date-<?php echo $tkt_row; ?>"  name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_end_date]" class="edit-ticket-TKT_end_date ee-text-inp" value="<?php echo $TKT_end_date; ?>" >
16 16
 			<input type="text" name="archived_ticket[TKT_end_date]" class="edit-ticket-TKT_end_date ee-text-inp" value="<?php echo $TKT_end_date; ?>" disabled>
17 17
 		<?php else : ?>
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 		<?php endif; ?>
20 20
 	</td>
21 21
 	<td>
22
-		<?php if ( $disabled ) : ?>
22
+		<?php if ($disabled) : ?>
23 23
 			<input id="edit-ticket-TKT_base_price-<?php echo $tkt_row; ?>" type="hidden" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_base_price]" class="edit-ticket-TKT_base_price ee-small-text-inp edit-price-PRC_amount ee-numeric" value="<?php echo $TKT_base_price; ?>">
24 24
 			<input type="text" name="archived_ticket[<?php echo $tkt_row; ?>][TKT_base_price]" class="edit-ticket-TKT_base_price ee-small-text-inp edit-price-PRC_amount ee-numeric" value="<?php echo $TKT_base_price; ?>" disabled>
25 25
 		<?php else : ?>
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 		<input type="hidden" id="edit-ticket-TKT_base_price_ID-<?php echo $tkt_row; ?>" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_base_price_ID]" value="<?php echo $TKT_base_price_ID; ?>">
29 29
 	</td>
30 30
 	<td>
31
-		<?php if ( $disabled ) : ?>
31
+		<?php if ($disabled) : ?>
32 32
 			<input type="hidden" class="edit-ticket-TKT_qty ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_qty]" value="<?php echo $TKT_qty_for_input; ?>">
33 33
 			<input type="text" class="edit-ticket-TKT_qty ee-small-text-inp ee-numeric" name="archived_ticket[<?php echo $tkt_row; ?>][TKT_qty]" value="<?php echo $TKT_qty_for_input; ?>" disabled>
34 34
 		<?php else : ?>
@@ -56,10 +56,10 @@  discard block
 block discarded – undo
56 56
 			<input type="hidden" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_ID]" class="edit-ticket-TKT_ID" value="<?php echo $TKT_ID; ?>">
57 57
 			<input type="hidden" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_row]" class="edit-ticket-TKT_row" value="<?php echo $tkt_row; ?>">
58 58
 
59
-			<!--<div class="total-price-container"><?php printf( esc_html__('Total Final Price: %s', 'event_espresso'), '<span class="ticket-price-amount">' . $TKT_price . '</span>'); ?> </div>-->
59
+			<!--<div class="total-price-container"><?php printf(esc_html__('Total Final Price: %s', 'event_espresso'), '<span class="ticket-price-amount">'.$TKT_price.'</span>'); ?> </div>-->
60 60
 			<textarea name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_description]" class="edit-ticket-TKT_description ee-full-textarea-inp" placeholder="Ticket Description"><?php echo $TKT_description; ?></textarea>
61 61
 
62
-			<?php do_action( 'AHEE__event_tickets_datetime_ticket_row_template_after_desc', $tkt_row, $TKT_ID ); ?>
62
+			<?php do_action('AHEE__event_tickets_datetime_ticket_row_template_after_desc', $tkt_row, $TKT_ID); ?>
63 63
 
64 64
 			<div class="basic-ticket-container">
65 65
 				<h4 class="tickets-heading"><?php esc_html_e('Ticket Details', 'event_espresso'); ?></h4>
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 					<tbody>
76 76
 						<tr>
77 77
 							<td>
78
-								<?php if ( $disabled ) : ?>
78
+								<?php if ($disabled) : ?>
79 79
 									<input type="hidden" class="edit-ticket-TKT_uses ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_uses]" value="<?php echo $TKT_uses; ?>">
80 80
 									<input type="text" class="edit-ticket-TKT_uses ee-small-text-inp ee-numeric" name="archived_ticket[<?php echo $tkt_row; ?>][TKT_uses]" value="<?php echo $TKT_uses; ?>" disabled>
81 81
 								<?php else : ?>
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 								<?php endif; ?>
84 84
 							</td>
85 85
 							<td>
86
-								<?php if ( $disabled ) : ?>
86
+								<?php if ($disabled) : ?>
87 87
 									<input type="hidden" class="edit-ticket-TKT_min ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_min]" value="<?php echo $TKT_min; ?>">
88 88
 									<input type="text" class="edit-ticket-TKT_min ee-small-text-inp ee-numeric" name="archived_ticket[<?php echo $tkt_row; ?>][TKT_min]" value="<?php echo $TKT_min; ?>" disabled>
89 89
 								<?php else: ?>
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 								<?php endif; ?>
92 92
 							</td>
93 93
 							<td>
94
-								<?php if ( $disabled ) : ?>
94
+								<?php if ($disabled) : ?>
95 95
 									<input type="hidden" class="edit-ticket-TKT_max ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_max]" value="<?php echo $TKT_max; ?>">
96 96
 									<input type="text" class="edit-ticket-TKT_max ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_max]" value="<?php echo $TKT_max; ?>" disabled>
97 97
 								<?php else : ?>
@@ -109,15 +109,15 @@  discard block
 block discarded – undo
109 109
 					<label for="edit-ticket-TKT_required"><?php esc_html_e('This ticket is required (will appear first in frontend ticket lists).', 'event_espresso'); ?></label>
110 110
 				</div>
111 111
 				<div class="ticket-is-taxable-container">
112
-					<?php if ( !empty($tax_rows) ) { ?>
113
-						<?php if ( $disabled ) : ?>
112
+					<?php if ( ! empty($tax_rows)) { ?>
113
+						<?php if ($disabled) : ?>
114 114
 							<?php
115
-								$tax_value = !empty( $TKT_taxable ) ? 1 : 0;
115
+								$tax_value = ! empty($TKT_taxable) ? 1 : 0;
116 116
 							?>
117
-							<input class="TKT-taxable-checkbox" type="hidden" name="<?php echo $edit_tickets_name;?>[<?php echo $tkt_row; ?>][TKT_taxable]" value="<?php echo $tax_value; ?>">
117
+							<input class="TKT-taxable-checkbox" type="hidden" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_taxable]" value="<?php echo $tax_value; ?>">
118 118
 							<input class="TKT-taxable-checkbox" id="edit-ticket-TKT_taxable-<?php echo $tkt_row; ?>" type="checkbox" name="archived_ticket[<?php echo $tkt_row; ?>][TKT_taxable]" value="1"<?php echo $TKT_taxable; ?> disabled>
119 119
 						<?php else : ?>
120
-							<input class="TKT-taxable-checkbox" id="edit-ticket-TKT_taxable-<?php echo $tkt_row; ?>" type="checkbox" name="<?php echo $edit_tickets_name;?>[<?php echo $tkt_row; ?>][TKT_taxable]" value="1"<?php echo $TKT_taxable; ?>>
120
+							<input class="TKT-taxable-checkbox" id="edit-ticket-TKT_taxable-<?php echo $tkt_row; ?>" type="checkbox" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_taxable]" value="1"<?php echo $TKT_taxable; ?>>
121 121
 						<?php endif; ?>
122 122
 						<label for="edit-ticket-TKT_taxable-<?php echo $tkt_row; ?>"> <?php esc_html_e('This ticket is taxable.', 'event_espresso'); ?>
123 123
 					<?php } //end tax_rows check ?>
@@ -174,10 +174,10 @@  discard block
 block discarded – undo
174 174
 				<?php echo $ticket_datetimes_list; ?>
175 175
 			</ul>
176 176
 
177
-			<?php do_action( 'AHEE__event_tickets_datetime_ticket_row_template__advanced_details_end', $tkt_row, $TKT_ID ); ?>
177
+			<?php do_action('AHEE__event_tickets_datetime_ticket_row_template__advanced_details_end', $tkt_row, $TKT_ID); ?>
178 178
 			<div class="ee-editor-footer-container">
179 179
 				<div class="ee-editor-id-container">
180
-					<span class="ee-item-id"><?php echo $TKT_ID ? sprintf( esc_html__( 'Ticket ID: %d', 'event_espresso' ), $TKT_ID ) : ''; ?></span>
180
+					<span class="ee-item-id"><?php echo $TKT_ID ? sprintf(esc_html__('Ticket ID: %d', 'event_espresso'), $TKT_ID) : ''; ?></span>
181 181
 				</div>
182 182
 				<div class="save-cancel-button-container">
183 183
 					<label for="edit-ticket-TKT_is_default_selector"><?php esc_html_e('use this new ticket as a default ticket for any new events', 'event_espresso'); ?></label>
Please login to merge, or discard this patch.
admin_pages/events/Events_Admin_Page.core.php 2 patches
Indentation   +2628 added lines, -2628 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
-    exit('NO direct script access allowed');
3
+	exit('NO direct script access allowed');
4 4
 }
5 5
 
6 6
 
@@ -17,2634 +17,2634 @@  discard block
 block discarded – undo
17 17
 class Events_Admin_Page extends EE_Admin_Page_CPT
18 18
 {
19 19
 
20
-    /**
21
-     * This will hold the event object for event_details screen.
22
-     *
23
-     * @access protected
24
-     * @var EE_Event $_event
25
-     */
26
-    protected $_event;
27
-
28
-
29
-    /**
30
-     * This will hold the category object for category_details screen.
31
-     *
32
-     * @var stdClass $_category
33
-     */
34
-    protected $_category;
35
-
36
-
37
-    /**
38
-     * This will hold the event model instance
39
-     *
40
-     * @var EEM_Event $_event_model
41
-     */
42
-    protected $_event_model;
43
-
44
-
45
-
46
-    /**
47
-     * @var EE_Event
48
-     */
49
-    protected $_cpt_model_obj = false;
50
-
51
-
52
-
53
-    protected function _init_page_props()
54
-    {
55
-        $this->page_slug = EVENTS_PG_SLUG;
56
-        $this->page_label = EVENTS_LABEL;
57
-        $this->_admin_base_url = EVENTS_ADMIN_URL;
58
-        $this->_admin_base_path = EVENTS_ADMIN;
59
-        $this->_cpt_model_names = array(
60
-            'create_new' => 'EEM_Event',
61
-            'edit'       => 'EEM_Event',
62
-        );
63
-        $this->_cpt_edit_routes = array(
64
-            'espresso_events' => 'edit',
65
-        );
66
-        add_action(
67
-            'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object',
68
-            array($this, 'verify_event_edit')
69
-        );
70
-    }
71
-
72
-
73
-
74
-    protected function _ajax_hooks()
75
-    {
76
-        //todo: all hooks for events ajax goes in here.
77
-    }
78
-
79
-
80
-
81
-    protected function _define_page_props()
82
-    {
83
-        $this->_admin_page_title = EVENTS_LABEL;
84
-        $this->_labels = array(
85
-            'buttons'      => array(
86
-                'add'             => esc_html__('Add New Event', 'event_espresso'),
87
-                'edit'            => esc_html__('Edit Event', 'event_espresso'),
88
-                'delete'          => esc_html__('Delete Event', 'event_espresso'),
89
-                'add_category'    => esc_html__('Add New Category', 'event_espresso'),
90
-                'edit_category'   => esc_html__('Edit Category', 'event_espresso'),
91
-                'delete_category' => esc_html__('Delete Category', 'event_espresso'),
92
-            ),
93
-            'editor_title' => array(
94
-                'espresso_events' => esc_html__('Enter event title here', 'event_espresso'),
95
-            ),
96
-            'publishbox'   => array(
97
-                'create_new'        => esc_html__('Save New Event', 'event_espresso'),
98
-                'edit'              => esc_html__('Update Event', 'event_espresso'),
99
-                'add_category'      => esc_html__('Save New Category', 'event_espresso'),
100
-                'edit_category'     => esc_html__('Update Category', 'event_espresso'),
101
-                'template_settings' => esc_html__('Update Settings', 'event_espresso'),
102
-            ),
103
-        );
104
-    }
105
-
106
-
107
-
108
-    protected function _set_page_routes()
109
-    {
110
-        //load formatter helper
111
-        //load field generator helper
112
-        //is there a evt_id in the request?
113
-        $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID'])
114
-            ? $this->_req_data['EVT_ID'] : 0;
115
-        $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id;
116
-        $this->_page_routes = array(
117
-            'default'                       => array(
118
-                'func'       => '_events_overview_list_table',
119
-                'capability' => 'ee_read_events',
120
-            ),
121
-            'create_new'                    => array(
122
-                'func'       => '_create_new_cpt_item',
123
-                'capability' => 'ee_edit_events',
124
-            ),
125
-            'edit'                          => array(
126
-                'func'       => '_edit_cpt_item',
127
-                'capability' => 'ee_edit_event',
128
-                'obj_id'     => $evt_id,
129
-            ),
130
-            'copy_event'                    => array(
131
-                'func'       => '_copy_events',
132
-                'capability' => 'ee_edit_event',
133
-                'obj_id'     => $evt_id,
134
-                'noheader'   => true,
135
-            ),
136
-            'trash_event'                   => array(
137
-                'func'       => '_trash_or_restore_event',
138
-                'args'       => array('event_status' => 'trash'),
139
-                'capability' => 'ee_delete_event',
140
-                'obj_id'     => $evt_id,
141
-                'noheader'   => true,
142
-            ),
143
-            'trash_events'                  => array(
144
-                'func'       => '_trash_or_restore_events',
145
-                'args'       => array('event_status' => 'trash'),
146
-                'capability' => 'ee_delete_events',
147
-                'noheader'   => true,
148
-            ),
149
-            'restore_event'                 => array(
150
-                'func'       => '_trash_or_restore_event',
151
-                'args'       => array('event_status' => 'draft'),
152
-                'capability' => 'ee_delete_event',
153
-                'obj_id'     => $evt_id,
154
-                'noheader'   => true,
155
-            ),
156
-            'restore_events'                => array(
157
-                'func'       => '_trash_or_restore_events',
158
-                'args'       => array('event_status' => 'draft'),
159
-                'capability' => 'ee_delete_events',
160
-                'noheader'   => true,
161
-            ),
162
-            'delete_event'                  => array(
163
-                'func'       => '_delete_event',
164
-                'capability' => 'ee_delete_event',
165
-                'obj_id'     => $evt_id,
166
-                'noheader'   => true,
167
-            ),
168
-            'delete_events'                 => array(
169
-                'func'       => '_delete_events',
170
-                'capability' => 'ee_delete_events',
171
-                'noheader'   => true,
172
-            ),
173
-            'view_report'                   => array(
174
-                'func'      => '_view_report',
175
-                'capablity' => 'ee_edit_events',
176
-            ),
177
-            'default_event_settings'        => array(
178
-                'func'       => '_default_event_settings',
179
-                'capability' => 'manage_options',
180
-            ),
181
-            'update_default_event_settings' => array(
182
-                'func'       => '_update_default_event_settings',
183
-                'capability' => 'manage_options',
184
-                'noheader'   => true,
185
-            ),
186
-            'template_settings'             => array(
187
-                'func'       => '_template_settings',
188
-                'capability' => 'manage_options',
189
-            ),
190
-            //event category tab related
191
-            'add_category'                  => array(
192
-                'func'       => '_category_details',
193
-                'capability' => 'ee_edit_event_category',
194
-                'args'       => array('add'),
195
-            ),
196
-            'edit_category'                 => array(
197
-                'func'       => '_category_details',
198
-                'capability' => 'ee_edit_event_category',
199
-                'args'       => array('edit'),
200
-            ),
201
-            'delete_categories'             => array(
202
-                'func'       => '_delete_categories',
203
-                'capability' => 'ee_delete_event_category',
204
-                'noheader'   => true,
205
-            ),
206
-            'delete_category'               => array(
207
-                'func'       => '_delete_categories',
208
-                'capability' => 'ee_delete_event_category',
209
-                'noheader'   => true,
210
-            ),
211
-            'insert_category'               => array(
212
-                'func'       => '_insert_or_update_category',
213
-                'args'       => array('new_category' => true),
214
-                'capability' => 'ee_edit_event_category',
215
-                'noheader'   => true,
216
-            ),
217
-            'update_category'               => array(
218
-                'func'       => '_insert_or_update_category',
219
-                'args'       => array('new_category' => false),
220
-                'capability' => 'ee_edit_event_category',
221
-                'noheader'   => true,
222
-            ),
223
-            'category_list'                 => array(
224
-                'func'       => '_category_list_table',
225
-                'capability' => 'ee_manage_event_categories',
226
-            ),
227
-        );
228
-    }
229
-
230
-
231
-
232
-    protected function _set_page_config()
233
-    {
234
-        $this->_page_config = array(
235
-            'default'                => array(
236
-                'nav'           => array(
237
-                    'label' => esc_html__('Overview', 'event_espresso'),
238
-                    'order' => 10,
239
-                ),
240
-                'list_table'    => 'Events_Admin_List_Table',
241
-                'help_tabs'     => array(
242
-                    'events_overview_help_tab'                       => array(
243
-                        'title'    => esc_html__('Events Overview', 'event_espresso'),
244
-                        'filename' => 'events_overview',
245
-                    ),
246
-                    'events_overview_table_column_headings_help_tab' => array(
247
-                        'title'    => esc_html__('Events Overview Table Column Headings', 'event_espresso'),
248
-                        'filename' => 'events_overview_table_column_headings',
249
-                    ),
250
-                    'events_overview_filters_help_tab'               => array(
251
-                        'title'    => esc_html__('Events Overview Filters', 'event_espresso'),
252
-                        'filename' => 'events_overview_filters',
253
-                    ),
254
-                    'events_overview_view_help_tab'                  => array(
255
-                        'title'    => esc_html__('Events Overview Views', 'event_espresso'),
256
-                        'filename' => 'events_overview_views',
257
-                    ),
258
-                    'events_overview_other_help_tab'                 => array(
259
-                        'title'    => esc_html__('Events Overview Other', 'event_espresso'),
260
-                        'filename' => 'events_overview_other',
261
-                    ),
262
-                ),
263
-                'help_tour'     => array(
264
-                    'Event_Overview_Help_Tour',
265
-                    //'New_Features_Test_Help_Tour' for testing multiple help tour
266
-                ),
267
-                'qtips'         => array(
268
-                    'EE_Event_List_Table_Tips',
269
-                ),
270
-                'require_nonce' => false,
271
-            ),
272
-            'create_new'             => array(
273
-                'nav'           => array(
274
-                    'label'      => esc_html__('Add Event', 'event_espresso'),
275
-                    'order'      => 5,
276
-                    'persistent' => false,
277
-                ),
278
-                'metaboxes'     => array('_register_event_editor_meta_boxes'),
279
-                'help_tabs'     => array(
280
-                    'event_editor_help_tab'                            => array(
281
-                        'title'    => esc_html__('Event Editor', 'event_espresso'),
282
-                        'filename' => 'event_editor',
283
-                    ),
284
-                    'event_editor_title_richtexteditor_help_tab'       => array(
285
-                        'title'    => esc_html__('Event Title & Rich Text Editor', 'event_espresso'),
286
-                        'filename' => 'event_editor_title_richtexteditor',
287
-                    ),
288
-                    'event_editor_venue_details_help_tab'              => array(
289
-                        'title'    => esc_html__('Event Venue Details', 'event_espresso'),
290
-                        'filename' => 'event_editor_venue_details',
291
-                    ),
292
-                    'event_editor_event_datetimes_help_tab'            => array(
293
-                        'title'    => esc_html__('Event Datetimes', 'event_espresso'),
294
-                        'filename' => 'event_editor_event_datetimes',
295
-                    ),
296
-                    'event_editor_event_tickets_help_tab'              => array(
297
-                        'title'    => esc_html__('Event Tickets', 'event_espresso'),
298
-                        'filename' => 'event_editor_event_tickets',
299
-                    ),
300
-                    'event_editor_event_registration_options_help_tab' => array(
301
-                        'title'    => esc_html__('Event Registration Options', 'event_espresso'),
302
-                        'filename' => 'event_editor_event_registration_options',
303
-                    ),
304
-                    'event_editor_tags_categories_help_tab'            => array(
305
-                        'title'    => esc_html__('Event Tags & Categories', 'event_espresso'),
306
-                        'filename' => 'event_editor_tags_categories',
307
-                    ),
308
-                    'event_editor_questions_registrants_help_tab'      => array(
309
-                        'title'    => esc_html__('Questions for Registrants', 'event_espresso'),
310
-                        'filename' => 'event_editor_questions_registrants',
311
-                    ),
312
-                    'event_editor_save_new_event_help_tab'             => array(
313
-                        'title'    => esc_html__('Save New Event', 'event_espresso'),
314
-                        'filename' => 'event_editor_save_new_event',
315
-                    ),
316
-                    'event_editor_other_help_tab'                      => array(
317
-                        'title'    => esc_html__('Event Other', 'event_espresso'),
318
-                        'filename' => 'event_editor_other',
319
-                    ),
320
-                ),
321
-                'help_tour'     => array(
322
-                    'Event_Editor_Help_Tour',
323
-                ),
324
-                'qtips'         => array('EE_Event_Editor_Decaf_Tips'),
325
-                'require_nonce' => false,
326
-            ),
327
-            'edit'                   => array(
328
-                'nav'           => array(
329
-                    'label'      => esc_html__('Edit Event', 'event_espresso'),
330
-                    'order'      => 5,
331
-                    'persistent' => false,
332
-                    'url'        => isset($this->_req_data['post'])
333
-                        ? EE_Admin_Page::add_query_args_and_nonce(
334
-                            array('post' => $this->_req_data['post'], 'action' => 'edit'),
335
-                            $this->_current_page_view_url
336
-                        )
337
-                        : $this->_admin_base_url,
338
-                ),
339
-                'metaboxes'     => array('_register_event_editor_meta_boxes'),
340
-                'help_tabs'     => array(
341
-                    'event_editor_help_tab'                            => array(
342
-                        'title'    => esc_html__('Event Editor', 'event_espresso'),
343
-                        'filename' => 'event_editor',
344
-                    ),
345
-                    'event_editor_title_richtexteditor_help_tab'       => array(
346
-                        'title'    => esc_html__('Event Title & Rich Text Editor', 'event_espresso'),
347
-                        'filename' => 'event_editor_title_richtexteditor',
348
-                    ),
349
-                    'event_editor_venue_details_help_tab'              => array(
350
-                        'title'    => esc_html__('Event Venue Details', 'event_espresso'),
351
-                        'filename' => 'event_editor_venue_details',
352
-                    ),
353
-                    'event_editor_event_datetimes_help_tab'            => array(
354
-                        'title'    => esc_html__('Event Datetimes', 'event_espresso'),
355
-                        'filename' => 'event_editor_event_datetimes',
356
-                    ),
357
-                    'event_editor_event_tickets_help_tab'              => array(
358
-                        'title'    => esc_html__('Event Tickets', 'event_espresso'),
359
-                        'filename' => 'event_editor_event_tickets',
360
-                    ),
361
-                    'event_editor_event_registration_options_help_tab' => array(
362
-                        'title'    => esc_html__('Event Registration Options', 'event_espresso'),
363
-                        'filename' => 'event_editor_event_registration_options',
364
-                    ),
365
-                    'event_editor_tags_categories_help_tab'            => array(
366
-                        'title'    => esc_html__('Event Tags & Categories', 'event_espresso'),
367
-                        'filename' => 'event_editor_tags_categories',
368
-                    ),
369
-                    'event_editor_questions_registrants_help_tab'      => array(
370
-                        'title'    => esc_html__('Questions for Registrants', 'event_espresso'),
371
-                        'filename' => 'event_editor_questions_registrants',
372
-                    ),
373
-                    'event_editor_save_new_event_help_tab'             => array(
374
-                        'title'    => esc_html__('Save New Event', 'event_espresso'),
375
-                        'filename' => 'event_editor_save_new_event',
376
-                    ),
377
-                    'event_editor_other_help_tab'                      => array(
378
-                        'title'    => esc_html__('Event Other', 'event_espresso'),
379
-                        'filename' => 'event_editor_other',
380
-                    ),
381
-                ),
382
-                /*'help_tour' => array(
20
+	/**
21
+	 * This will hold the event object for event_details screen.
22
+	 *
23
+	 * @access protected
24
+	 * @var EE_Event $_event
25
+	 */
26
+	protected $_event;
27
+
28
+
29
+	/**
30
+	 * This will hold the category object for category_details screen.
31
+	 *
32
+	 * @var stdClass $_category
33
+	 */
34
+	protected $_category;
35
+
36
+
37
+	/**
38
+	 * This will hold the event model instance
39
+	 *
40
+	 * @var EEM_Event $_event_model
41
+	 */
42
+	protected $_event_model;
43
+
44
+
45
+
46
+	/**
47
+	 * @var EE_Event
48
+	 */
49
+	protected $_cpt_model_obj = false;
50
+
51
+
52
+
53
+	protected function _init_page_props()
54
+	{
55
+		$this->page_slug = EVENTS_PG_SLUG;
56
+		$this->page_label = EVENTS_LABEL;
57
+		$this->_admin_base_url = EVENTS_ADMIN_URL;
58
+		$this->_admin_base_path = EVENTS_ADMIN;
59
+		$this->_cpt_model_names = array(
60
+			'create_new' => 'EEM_Event',
61
+			'edit'       => 'EEM_Event',
62
+		);
63
+		$this->_cpt_edit_routes = array(
64
+			'espresso_events' => 'edit',
65
+		);
66
+		add_action(
67
+			'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object',
68
+			array($this, 'verify_event_edit')
69
+		);
70
+	}
71
+
72
+
73
+
74
+	protected function _ajax_hooks()
75
+	{
76
+		//todo: all hooks for events ajax goes in here.
77
+	}
78
+
79
+
80
+
81
+	protected function _define_page_props()
82
+	{
83
+		$this->_admin_page_title = EVENTS_LABEL;
84
+		$this->_labels = array(
85
+			'buttons'      => array(
86
+				'add'             => esc_html__('Add New Event', 'event_espresso'),
87
+				'edit'            => esc_html__('Edit Event', 'event_espresso'),
88
+				'delete'          => esc_html__('Delete Event', 'event_espresso'),
89
+				'add_category'    => esc_html__('Add New Category', 'event_espresso'),
90
+				'edit_category'   => esc_html__('Edit Category', 'event_espresso'),
91
+				'delete_category' => esc_html__('Delete Category', 'event_espresso'),
92
+			),
93
+			'editor_title' => array(
94
+				'espresso_events' => esc_html__('Enter event title here', 'event_espresso'),
95
+			),
96
+			'publishbox'   => array(
97
+				'create_new'        => esc_html__('Save New Event', 'event_espresso'),
98
+				'edit'              => esc_html__('Update Event', 'event_espresso'),
99
+				'add_category'      => esc_html__('Save New Category', 'event_espresso'),
100
+				'edit_category'     => esc_html__('Update Category', 'event_espresso'),
101
+				'template_settings' => esc_html__('Update Settings', 'event_espresso'),
102
+			),
103
+		);
104
+	}
105
+
106
+
107
+
108
+	protected function _set_page_routes()
109
+	{
110
+		//load formatter helper
111
+		//load field generator helper
112
+		//is there a evt_id in the request?
113
+		$evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID'])
114
+			? $this->_req_data['EVT_ID'] : 0;
115
+		$evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id;
116
+		$this->_page_routes = array(
117
+			'default'                       => array(
118
+				'func'       => '_events_overview_list_table',
119
+				'capability' => 'ee_read_events',
120
+			),
121
+			'create_new'                    => array(
122
+				'func'       => '_create_new_cpt_item',
123
+				'capability' => 'ee_edit_events',
124
+			),
125
+			'edit'                          => array(
126
+				'func'       => '_edit_cpt_item',
127
+				'capability' => 'ee_edit_event',
128
+				'obj_id'     => $evt_id,
129
+			),
130
+			'copy_event'                    => array(
131
+				'func'       => '_copy_events',
132
+				'capability' => 'ee_edit_event',
133
+				'obj_id'     => $evt_id,
134
+				'noheader'   => true,
135
+			),
136
+			'trash_event'                   => array(
137
+				'func'       => '_trash_or_restore_event',
138
+				'args'       => array('event_status' => 'trash'),
139
+				'capability' => 'ee_delete_event',
140
+				'obj_id'     => $evt_id,
141
+				'noheader'   => true,
142
+			),
143
+			'trash_events'                  => array(
144
+				'func'       => '_trash_or_restore_events',
145
+				'args'       => array('event_status' => 'trash'),
146
+				'capability' => 'ee_delete_events',
147
+				'noheader'   => true,
148
+			),
149
+			'restore_event'                 => array(
150
+				'func'       => '_trash_or_restore_event',
151
+				'args'       => array('event_status' => 'draft'),
152
+				'capability' => 'ee_delete_event',
153
+				'obj_id'     => $evt_id,
154
+				'noheader'   => true,
155
+			),
156
+			'restore_events'                => array(
157
+				'func'       => '_trash_or_restore_events',
158
+				'args'       => array('event_status' => 'draft'),
159
+				'capability' => 'ee_delete_events',
160
+				'noheader'   => true,
161
+			),
162
+			'delete_event'                  => array(
163
+				'func'       => '_delete_event',
164
+				'capability' => 'ee_delete_event',
165
+				'obj_id'     => $evt_id,
166
+				'noheader'   => true,
167
+			),
168
+			'delete_events'                 => array(
169
+				'func'       => '_delete_events',
170
+				'capability' => 'ee_delete_events',
171
+				'noheader'   => true,
172
+			),
173
+			'view_report'                   => array(
174
+				'func'      => '_view_report',
175
+				'capablity' => 'ee_edit_events',
176
+			),
177
+			'default_event_settings'        => array(
178
+				'func'       => '_default_event_settings',
179
+				'capability' => 'manage_options',
180
+			),
181
+			'update_default_event_settings' => array(
182
+				'func'       => '_update_default_event_settings',
183
+				'capability' => 'manage_options',
184
+				'noheader'   => true,
185
+			),
186
+			'template_settings'             => array(
187
+				'func'       => '_template_settings',
188
+				'capability' => 'manage_options',
189
+			),
190
+			//event category tab related
191
+			'add_category'                  => array(
192
+				'func'       => '_category_details',
193
+				'capability' => 'ee_edit_event_category',
194
+				'args'       => array('add'),
195
+			),
196
+			'edit_category'                 => array(
197
+				'func'       => '_category_details',
198
+				'capability' => 'ee_edit_event_category',
199
+				'args'       => array('edit'),
200
+			),
201
+			'delete_categories'             => array(
202
+				'func'       => '_delete_categories',
203
+				'capability' => 'ee_delete_event_category',
204
+				'noheader'   => true,
205
+			),
206
+			'delete_category'               => array(
207
+				'func'       => '_delete_categories',
208
+				'capability' => 'ee_delete_event_category',
209
+				'noheader'   => true,
210
+			),
211
+			'insert_category'               => array(
212
+				'func'       => '_insert_or_update_category',
213
+				'args'       => array('new_category' => true),
214
+				'capability' => 'ee_edit_event_category',
215
+				'noheader'   => true,
216
+			),
217
+			'update_category'               => array(
218
+				'func'       => '_insert_or_update_category',
219
+				'args'       => array('new_category' => false),
220
+				'capability' => 'ee_edit_event_category',
221
+				'noheader'   => true,
222
+			),
223
+			'category_list'                 => array(
224
+				'func'       => '_category_list_table',
225
+				'capability' => 'ee_manage_event_categories',
226
+			),
227
+		);
228
+	}
229
+
230
+
231
+
232
+	protected function _set_page_config()
233
+	{
234
+		$this->_page_config = array(
235
+			'default'                => array(
236
+				'nav'           => array(
237
+					'label' => esc_html__('Overview', 'event_espresso'),
238
+					'order' => 10,
239
+				),
240
+				'list_table'    => 'Events_Admin_List_Table',
241
+				'help_tabs'     => array(
242
+					'events_overview_help_tab'                       => array(
243
+						'title'    => esc_html__('Events Overview', 'event_espresso'),
244
+						'filename' => 'events_overview',
245
+					),
246
+					'events_overview_table_column_headings_help_tab' => array(
247
+						'title'    => esc_html__('Events Overview Table Column Headings', 'event_espresso'),
248
+						'filename' => 'events_overview_table_column_headings',
249
+					),
250
+					'events_overview_filters_help_tab'               => array(
251
+						'title'    => esc_html__('Events Overview Filters', 'event_espresso'),
252
+						'filename' => 'events_overview_filters',
253
+					),
254
+					'events_overview_view_help_tab'                  => array(
255
+						'title'    => esc_html__('Events Overview Views', 'event_espresso'),
256
+						'filename' => 'events_overview_views',
257
+					),
258
+					'events_overview_other_help_tab'                 => array(
259
+						'title'    => esc_html__('Events Overview Other', 'event_espresso'),
260
+						'filename' => 'events_overview_other',
261
+					),
262
+				),
263
+				'help_tour'     => array(
264
+					'Event_Overview_Help_Tour',
265
+					//'New_Features_Test_Help_Tour' for testing multiple help tour
266
+				),
267
+				'qtips'         => array(
268
+					'EE_Event_List_Table_Tips',
269
+				),
270
+				'require_nonce' => false,
271
+			),
272
+			'create_new'             => array(
273
+				'nav'           => array(
274
+					'label'      => esc_html__('Add Event', 'event_espresso'),
275
+					'order'      => 5,
276
+					'persistent' => false,
277
+				),
278
+				'metaboxes'     => array('_register_event_editor_meta_boxes'),
279
+				'help_tabs'     => array(
280
+					'event_editor_help_tab'                            => array(
281
+						'title'    => esc_html__('Event Editor', 'event_espresso'),
282
+						'filename' => 'event_editor',
283
+					),
284
+					'event_editor_title_richtexteditor_help_tab'       => array(
285
+						'title'    => esc_html__('Event Title & Rich Text Editor', 'event_espresso'),
286
+						'filename' => 'event_editor_title_richtexteditor',
287
+					),
288
+					'event_editor_venue_details_help_tab'              => array(
289
+						'title'    => esc_html__('Event Venue Details', 'event_espresso'),
290
+						'filename' => 'event_editor_venue_details',
291
+					),
292
+					'event_editor_event_datetimes_help_tab'            => array(
293
+						'title'    => esc_html__('Event Datetimes', 'event_espresso'),
294
+						'filename' => 'event_editor_event_datetimes',
295
+					),
296
+					'event_editor_event_tickets_help_tab'              => array(
297
+						'title'    => esc_html__('Event Tickets', 'event_espresso'),
298
+						'filename' => 'event_editor_event_tickets',
299
+					),
300
+					'event_editor_event_registration_options_help_tab' => array(
301
+						'title'    => esc_html__('Event Registration Options', 'event_espresso'),
302
+						'filename' => 'event_editor_event_registration_options',
303
+					),
304
+					'event_editor_tags_categories_help_tab'            => array(
305
+						'title'    => esc_html__('Event Tags & Categories', 'event_espresso'),
306
+						'filename' => 'event_editor_tags_categories',
307
+					),
308
+					'event_editor_questions_registrants_help_tab'      => array(
309
+						'title'    => esc_html__('Questions for Registrants', 'event_espresso'),
310
+						'filename' => 'event_editor_questions_registrants',
311
+					),
312
+					'event_editor_save_new_event_help_tab'             => array(
313
+						'title'    => esc_html__('Save New Event', 'event_espresso'),
314
+						'filename' => 'event_editor_save_new_event',
315
+					),
316
+					'event_editor_other_help_tab'                      => array(
317
+						'title'    => esc_html__('Event Other', 'event_espresso'),
318
+						'filename' => 'event_editor_other',
319
+					),
320
+				),
321
+				'help_tour'     => array(
322
+					'Event_Editor_Help_Tour',
323
+				),
324
+				'qtips'         => array('EE_Event_Editor_Decaf_Tips'),
325
+				'require_nonce' => false,
326
+			),
327
+			'edit'                   => array(
328
+				'nav'           => array(
329
+					'label'      => esc_html__('Edit Event', 'event_espresso'),
330
+					'order'      => 5,
331
+					'persistent' => false,
332
+					'url'        => isset($this->_req_data['post'])
333
+						? EE_Admin_Page::add_query_args_and_nonce(
334
+							array('post' => $this->_req_data['post'], 'action' => 'edit'),
335
+							$this->_current_page_view_url
336
+						)
337
+						: $this->_admin_base_url,
338
+				),
339
+				'metaboxes'     => array('_register_event_editor_meta_boxes'),
340
+				'help_tabs'     => array(
341
+					'event_editor_help_tab'                            => array(
342
+						'title'    => esc_html__('Event Editor', 'event_espresso'),
343
+						'filename' => 'event_editor',
344
+					),
345
+					'event_editor_title_richtexteditor_help_tab'       => array(
346
+						'title'    => esc_html__('Event Title & Rich Text Editor', 'event_espresso'),
347
+						'filename' => 'event_editor_title_richtexteditor',
348
+					),
349
+					'event_editor_venue_details_help_tab'              => array(
350
+						'title'    => esc_html__('Event Venue Details', 'event_espresso'),
351
+						'filename' => 'event_editor_venue_details',
352
+					),
353
+					'event_editor_event_datetimes_help_tab'            => array(
354
+						'title'    => esc_html__('Event Datetimes', 'event_espresso'),
355
+						'filename' => 'event_editor_event_datetimes',
356
+					),
357
+					'event_editor_event_tickets_help_tab'              => array(
358
+						'title'    => esc_html__('Event Tickets', 'event_espresso'),
359
+						'filename' => 'event_editor_event_tickets',
360
+					),
361
+					'event_editor_event_registration_options_help_tab' => array(
362
+						'title'    => esc_html__('Event Registration Options', 'event_espresso'),
363
+						'filename' => 'event_editor_event_registration_options',
364
+					),
365
+					'event_editor_tags_categories_help_tab'            => array(
366
+						'title'    => esc_html__('Event Tags & Categories', 'event_espresso'),
367
+						'filename' => 'event_editor_tags_categories',
368
+					),
369
+					'event_editor_questions_registrants_help_tab'      => array(
370
+						'title'    => esc_html__('Questions for Registrants', 'event_espresso'),
371
+						'filename' => 'event_editor_questions_registrants',
372
+					),
373
+					'event_editor_save_new_event_help_tab'             => array(
374
+						'title'    => esc_html__('Save New Event', 'event_espresso'),
375
+						'filename' => 'event_editor_save_new_event',
376
+					),
377
+					'event_editor_other_help_tab'                      => array(
378
+						'title'    => esc_html__('Event Other', 'event_espresso'),
379
+						'filename' => 'event_editor_other',
380
+					),
381
+				),
382
+				/*'help_tour' => array(
383 383
 					'Event_Edit_Help_Tour'
384 384
 				),*/
385
-                'qtips'         => array('EE_Event_Editor_Decaf_Tips'),
386
-                'require_nonce' => false,
387
-            ),
388
-            'default_event_settings' => array(
389
-                'nav'           => array(
390
-                    'label' => esc_html__('Default Settings', 'event_espresso'),
391
-                    'order' => 40,
392
-                ),
393
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
394
-                'labels'        => array(
395
-                    'publishbox' => esc_html__('Update Settings', 'event_espresso'),
396
-                ),
397
-                'help_tabs'     => array(
398
-                    'default_settings_help_tab'        => array(
399
-                        'title'    => esc_html__('Default Event Settings', 'event_espresso'),
400
-                        'filename' => 'events_default_settings',
401
-                    ),
402
-                    'default_settings_status_help_tab' => array(
403
-                        'title'    => esc_html__('Default Registration Status', 'event_espresso'),
404
-                        'filename' => 'events_default_settings_status',
405
-                    ),
406
-                    'default_maximum_tickets_help_tab' => array(
407
-                        'title' => esc_html__('Default Maximum Tickets Per Order', 'event_espresso'),
408
-                        'filename' => 'events_default_settings_max_tickets',
409
-                    )
410
-                ),
411
-                'help_tour'     => array('Event_Default_Settings_Help_Tour'),
412
-                'require_nonce' => false,
413
-            ),
414
-            //template settings
415
-            'template_settings'      => array(
416
-                'nav'           => array(
417
-                    'label' => esc_html__('Templates', 'event_espresso'),
418
-                    'order' => 30,
419
-                ),
420
-                'metaboxes'     => $this->_default_espresso_metaboxes,
421
-                'help_tabs'     => array(
422
-                    'general_settings_templates_help_tab' => array(
423
-                        'title'    => esc_html__('Templates', 'event_espresso'),
424
-                        'filename' => 'general_settings_templates',
425
-                    ),
426
-                ),
427
-                'help_tour'     => array('Templates_Help_Tour'),
428
-                'require_nonce' => false,
429
-            ),
430
-            //event category stuff
431
-            'add_category'           => array(
432
-                'nav'           => array(
433
-                    'label'      => esc_html__('Add Category', 'event_espresso'),
434
-                    'order'      => 15,
435
-                    'persistent' => false,
436
-                ),
437
-                'help_tabs'     => array(
438
-                    'add_category_help_tab' => array(
439
-                        'title'    => esc_html__('Add New Event Category', 'event_espresso'),
440
-                        'filename' => 'events_add_category',
441
-                    ),
442
-                ),
443
-                'help_tour'     => array('Event_Add_Category_Help_Tour'),
444
-                'metaboxes'     => array('_publish_post_box'),
445
-                'require_nonce' => false,
446
-            ),
447
-            'edit_category'          => array(
448
-                'nav'           => array(
449
-                    'label'      => esc_html__('Edit Category', 'event_espresso'),
450
-                    'order'      => 15,
451
-                    'persistent' => false,
452
-                    'url'        => isset($this->_req_data['EVT_CAT_ID'])
453
-                        ? add_query_arg(
454
-                            array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']),
455
-                            $this->_current_page_view_url
456
-                        )
457
-                        : $this->_admin_base_url,
458
-                ),
459
-                'help_tabs'     => array(
460
-                    'edit_category_help_tab' => array(
461
-                        'title'    => esc_html__('Edit Event Category', 'event_espresso'),
462
-                        'filename' => 'events_edit_category',
463
-                    ),
464
-                ),
465
-                /*'help_tour' => array('Event_Edit_Category_Help_Tour'),*/
466
-                'metaboxes'     => array('_publish_post_box'),
467
-                'require_nonce' => false,
468
-            ),
469
-            'category_list'          => array(
470
-                'nav'           => array(
471
-                    'label' => esc_html__('Categories', 'event_espresso'),
472
-                    'order' => 20,
473
-                ),
474
-                'list_table'    => 'Event_Categories_Admin_List_Table',
475
-                'help_tabs'     => array(
476
-                    'events_categories_help_tab'                       => array(
477
-                        'title'    => esc_html__('Event Categories', 'event_espresso'),
478
-                        'filename' => 'events_categories',
479
-                    ),
480
-                    'events_categories_table_column_headings_help_tab' => array(
481
-                        'title'    => esc_html__('Event Categories Table Column Headings', 'event_espresso'),
482
-                        'filename' => 'events_categories_table_column_headings',
483
-                    ),
484
-                    'events_categories_view_help_tab'                  => array(
485
-                        'title'    => esc_html__('Event Categories Views', 'event_espresso'),
486
-                        'filename' => 'events_categories_views',
487
-                    ),
488
-                    'events_categories_other_help_tab'                 => array(
489
-                        'title'    => esc_html__('Event Categories Other', 'event_espresso'),
490
-                        'filename' => 'events_categories_other',
491
-                    ),
492
-                ),
493
-                'help_tour'     => array(
494
-                    'Event_Categories_Help_Tour',
495
-                ),
496
-                'metaboxes'     => $this->_default_espresso_metaboxes,
497
-                'require_nonce' => false,
498
-            ),
499
-        );
500
-    }
501
-
502
-
503
-
504
-    protected function _add_screen_options()
505
-    {
506
-        //todo
507
-    }
508
-
509
-
510
-
511
-    protected function _add_screen_options_default()
512
-    {
513
-        $this->_per_page_screen_option();
514
-    }
515
-
516
-
517
-
518
-    protected function _add_screen_options_category_list()
519
-    {
520
-        $page_title = $this->_admin_page_title;
521
-        $this->_admin_page_title = esc_html__('Categories', 'event_espresso');
522
-        $this->_per_page_screen_option();
523
-        $this->_admin_page_title = $page_title;
524
-    }
525
-
526
-
527
-
528
-    protected function _add_feature_pointers()
529
-    {
530
-        //todo
531
-    }
532
-
533
-
534
-
535
-    public function load_scripts_styles()
536
-    {
537
-        wp_register_style(
538
-            'events-admin-css',
539
-            EVENTS_ASSETS_URL . 'events-admin-page.css',
540
-            array(),
541
-            EVENT_ESPRESSO_VERSION
542
-        );
543
-        wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION);
544
-        wp_enqueue_style('events-admin-css');
545
-        wp_enqueue_style('ee-cat-admin');
546
-        //todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details
547
-        //registers for all views
548
-        //scripts
549
-        wp_register_script(
550
-            'event_editor_js',
551
-            EVENTS_ASSETS_URL . 'event_editor.js',
552
-            array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'),
553
-            EVENT_ESPRESSO_VERSION,
554
-            true
555
-        );
556
-    }
557
-
558
-
559
-
560
-    /**
561
-     * enqueuing scripts and styles specific to this view
562
-     *
563
-     * @return void
564
-     */
565
-    public function load_scripts_styles_create_new()
566
-    {
567
-        $this->load_scripts_styles_edit();
568
-    }
569
-
570
-
571
-
572
-    /**
573
-     * enqueuing scripts and styles specific to this view
574
-     *
575
-     * @return void
576
-     */
577
-    public function load_scripts_styles_edit()
578
-    {
579
-        //styles
580
-        wp_enqueue_style('espresso-ui-theme');
581
-        wp_register_style(
582
-            'event-editor-css',
583
-            EVENTS_ASSETS_URL . 'event-editor.css',
584
-            array('ee-admin-css'),
585
-            EVENT_ESPRESSO_VERSION
586
-        );
587
-        wp_enqueue_style('event-editor-css');
588
-        //scripts
589
-        wp_register_script(
590
-            'event-datetime-metabox',
591
-            EVENTS_ASSETS_URL . 'event-datetime-metabox.js',
592
-            array('event_editor_js', 'ee-datepicker'),
593
-            EVENT_ESPRESSO_VERSION
594
-        );
595
-        wp_enqueue_script('event-datetime-metabox');
596
-    }
597
-
598
-
599
-
600
-    public function load_scripts_styles_add_category()
601
-    {
602
-        $this->load_scripts_styles_edit_category();
603
-    }
604
-
605
-
606
-
607
-    public function load_scripts_styles_edit_category()
608
-    {
609
-    }
610
-
611
-
612
-
613
-    protected function _set_list_table_views_category_list()
614
-    {
615
-        $this->_views = array(
616
-            'all' => array(
617
-                'slug'        => 'all',
618
-                'label'       => esc_html__('All', 'event_espresso'),
619
-                'count'       => 0,
620
-                'bulk_action' => array(
621
-                    'delete_categories' => esc_html__('Delete Permanently', 'event_espresso'),
622
-                ),
623
-            ),
624
-        );
625
-    }
626
-
627
-
628
-
629
-    public function admin_init()
630
-    {
631
-        EE_Registry::$i18n_js_strings['image_confirm'] = esc_html__(
632
-            'Do you really want to delete this image? Please remember to update your event to complete the removal.',
633
-            'event_espresso'
634
-        );
635
-    }
636
-
637
-
638
-
639
-    //nothing needed for events with these methods.
640
-    public function admin_notices()
641
-    {
642
-    }
643
-
644
-
645
-
646
-    public function admin_footer_scripts()
647
-    {
648
-    }
649
-
650
-
651
-
652
-    /**
653
-     * Call this function to verify if an event is public and has tickets for sale.  If it does, then we need to show a
654
-     * warning (via EE_Error::add_error());
655
-     *
656
-     * @param  EE_Event $event Event object
657
-     * @access public
658
-     * @return void
659
-     */
660
-    public function verify_event_edit($event = null)
661
-    {
662
-        // no event?
663
-        if (empty($event)) {
664
-            // set event
665
-            $event = $this->_cpt_model_obj;
666
-        }
667
-        // STILL no event?
668
-        if (empty ($event)) {
669
-            return;
670
-        }
671
-        $orig_status = $event->status();
672
-        // first check if event is active.
673
-        if (
674
-            $orig_status === EEM_Event::cancelled
675
-            || $orig_status === EEM_Event::postponed
676
-            || $event->is_expired()
677
-            || $event->is_inactive()
678
-        ) {
679
-            return;
680
-        }
681
-        //made it here so it IS active... next check that any of the tickets are sold.
682
-        if ($event->is_sold_out(true)) {
683
-            if ($orig_status !== EEM_Event::sold_out && $event->status() !== $orig_status) {
684
-                EE_Error::add_attention(
685
-                    sprintf(
686
-                        esc_html__(
687
-                            '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.',
688
-                            'event_espresso'
689
-                        ),
690
-                        EEH_Template::pretty_status(EEM_Event::sold_out, false, 'sentence')
691
-                    )
692
-                );
693
-            }
694
-            return;
695
-        } else if ($orig_status === EEM_Event::sold_out) {
696
-            EE_Error::add_attention(
697
-                sprintf(
698
-                    esc_html__(
699
-                        '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.',
700
-                        'event_espresso'
701
-                    ),
702
-                    EEH_Template::pretty_status($event->status(), false, 'sentence')
703
-                )
704
-            );
705
-        }
706
-        //now we need to determine if the event has any tickets on sale.  If not then we dont' show the error
707
-        if ( ! $event->tickets_on_sale()) {
708
-            return;
709
-        }
710
-        //made it here so show warning
711
-        $this->_edit_event_warning();
712
-    }
713
-
714
-
715
-
716
-    /**
717
-     * This is the text used for when an event is being edited that is public and has tickets for sale.
718
-     * When needed, hook this into a EE_Error::add_error() notice.
719
-     *
720
-     * @access protected
721
-     * @return void
722
-     */
723
-    protected function _edit_event_warning()
724
-    {
725
-        // we don't want to add warnings during these requests
726
-        if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'editpost') {
727
-            return;
728
-        }
729
-        EE_Error::add_attention(
730
-            esc_html__(
731
-                '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.',
732
-                'event_espresso'
733
-            )
734
-        );
735
-    }
736
-
737
-
738
-
739
-    /**
740
-     * When a user is creating a new event, notify them if they haven't set their timezone.
741
-     * Otherwise, do the normal logic
742
-     *
743
-     * @return string
744
-     * @throws \EE_Error
745
-     */
746
-    protected function _create_new_cpt_item()
747
-    {
748
-        $gmt_offset = get_option('gmt_offset');
749
-        //only nag them about setting their timezone if it's their first event, and they haven't already done it
750
-        if ($gmt_offset === '0' && ! EEM_Event::instance()->exists(array())) {
751
-            EE_Error::add_attention(
752
-                sprintf(
753
-                    __(
754
-                        'Your website\'s timezone is currently set to UTC + 0. We recommend updating your timezone to a city or region near you before you create an event. Your timezone can be updated through the %1$sGeneral Settings%2$s page.',
755
-                        'event_espresso'
756
-                    ),
757
-                    '<a href="' . admin_url('options-general.php') . '">',
758
-                    '</a>'
759
-                ),
760
-                __FILE__,
761
-                __FUNCTION__,
762
-                __LINE__
763
-            );
764
-        }
765
-        return parent::_create_new_cpt_item();
766
-    }
767
-
768
-
769
-
770
-    protected function _set_list_table_views_default()
771
-    {
772
-        $this->_views = array(
773
-            'all'   => array(
774
-                'slug'        => 'all',
775
-                'label'       => esc_html__('View All Events', 'event_espresso'),
776
-                'count'       => 0,
777
-                'bulk_action' => array(
778
-                    'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
779
-                ),
780
-            ),
781
-            'draft' => array(
782
-                'slug'        => 'draft',
783
-                'label'       => esc_html__('Draft', 'event_espresso'),
784
-                'count'       => 0,
785
-                'bulk_action' => array(
786
-                    'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
787
-                ),
788
-            ),
789
-        );
790
-        if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) {
791
-            $this->_views['trash'] = array(
792
-                'slug'        => 'trash',
793
-                'label'       => esc_html__('Trash', 'event_espresso'),
794
-                'count'       => 0,
795
-                'bulk_action' => array(
796
-                    'restore_events' => esc_html__('Restore From Trash', 'event_espresso'),
797
-                    'delete_events'  => esc_html__('Delete Permanently', 'event_espresso'),
798
-                ),
799
-            );
800
-        }
801
-    }
802
-
803
-
804
-
805
-    /**
806
-     * @return array
807
-     */
808
-    protected function _event_legend_items()
809
-    {
810
-        $items = array(
811
-            'view_details'   => array(
812
-                'class' => 'dashicons dashicons-search',
813
-                'desc'  => esc_html__('View Event', 'event_espresso'),
814
-            ),
815
-            'edit_event'     => array(
816
-                'class' => 'ee-icon ee-icon-calendar-edit',
817
-                'desc'  => esc_html__('Edit Event Details', 'event_espresso'),
818
-            ),
819
-            'view_attendees' => array(
820
-                'class' => 'dashicons dashicons-groups',
821
-                'desc'  => esc_html__('View Registrations for Event', 'event_espresso'),
822
-            ),
823
-        );
824
-        $items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items);
825
-        $statuses = array(
826
-            'sold_out_status'  => array(
827
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out,
828
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::sold_out, false, 'sentence'),
829
-            ),
830
-            'active_status'    => array(
831
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active,
832
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::active, false, 'sentence'),
833
-            ),
834
-            'upcoming_status'  => array(
835
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming,
836
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::upcoming, false, 'sentence'),
837
-            ),
838
-            'postponed_status' => array(
839
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed,
840
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::postponed, false, 'sentence'),
841
-            ),
842
-            'cancelled_status' => array(
843
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled,
844
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::cancelled, false, 'sentence'),
845
-            ),
846
-            'expired_status'   => array(
847
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired,
848
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::expired, false, 'sentence'),
849
-            ),
850
-            'inactive_status'  => array(
851
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive,
852
-                'desc'  => EEH_Template::pretty_status(EE_Datetime::inactive, false, 'sentence'),
853
-            ),
854
-        );
855
-        $statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses);
856
-        return array_merge($items, $statuses);
857
-    }
858
-
859
-
860
-
861
-    /**
862
-     * _event_model
863
-     *
864
-     * @return EEM_Event
865
-     */
866
-    private function _event_model()
867
-    {
868
-        if ( ! $this->_event_model instanceof EEM_Event) {
869
-            $this->_event_model = EE_Registry::instance()->load_model('Event');
870
-        }
871
-        return $this->_event_model;
872
-    }
873
-
874
-
875
-
876
-    /**
877
-     * Adds extra buttons to the WP CPT permalink field row.
878
-     * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter.
879
-     *
880
-     * @param  string $return    the current html
881
-     * @param  int    $id        the post id for the page
882
-     * @param  string $new_title What the title is
883
-     * @param  string $new_slug  what the slug is
884
-     * @return string            The new html string for the permalink area
885
-     */
886
-    public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug)
887
-    {
888
-        //make sure this is only when editing
889
-        if ( ! empty($id)) {
890
-            $post = get_post($id);
891
-            $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#"  tabindex="-1">'
892
-                       . esc_html__('Shortcode', 'event_espresso')
893
-                       . '</a> ';
894
-            $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id='
895
-                       . $post->ID
896
-                       . ']">';
897
-        }
898
-        return $return;
899
-    }
900
-
901
-
902
-
903
-    /**
904
-     * _events_overview_list_table
905
-     * This contains the logic for showing the events_overview list
906
-     *
907
-     * @access protected
908
-     * @return void
909
-     * @throws \EE_Error
910
-     */
911
-    protected function _events_overview_list_table()
912
-    {
913
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
914
-        $this->_template_args['after_list_table'] = ! empty($this->_template_args['after_list_table'])
915
-            ? (array)$this->_template_args['after_list_table']
916
-            : array();
917
-        $this->_template_args['after_list_table']['view_event_list_button'] = EEH_HTML::br()
918
-                                                                              . EEH_Template::get_button_or_link(
919
-                get_post_type_archive_link('espresso_events'),
920
-                esc_html__("View Event Archive Page", "event_espresso"),
921
-                'button'
922
-            );
923
-        $this->_template_args['after_list_table']['legend'] = $this->_display_legend($this->_event_legend_items());
924
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
925
-                'create_new',
926
-                'add',
927
-                array(),
928
-                'add-new-h2'
929
-            );
930
-        $this->display_admin_list_table_page_with_no_sidebar();
931
-    }
932
-
933
-
934
-
935
-    /**
936
-     * this allows for extra misc actions in the default WP publish box
937
-     *
938
-     * @return void
939
-     */
940
-    public function extra_misc_actions_publish_box()
941
-    {
942
-        $this->_generate_publish_box_extra_content();
943
-    }
944
-
945
-
946
-
947
-    /**
948
-     * This is hooked into the WordPress do_action('save_post') hook and runs after the custom post type has been
949
-     * saved.  Child classes are required to declare this method.  Typically you would use this to save any additional
950
-     * data.
951
-     * Keep in mind also that "save_post" runs on EVERY post update to the database.
952
-     * ALSO very important.  When a post transitions from scheduled to published, the save_post action is fired but you
953
-     * will NOT have any _POST data containing any extra info you may have from other meta saves.  So MAKE sure that
954
-     * you handle this accordingly.
955
-     *
956
-     * @access protected
957
-     * @abstract
958
-     * @param  string $post_id The ID of the cpt that was saved (so you can link relationally)
959
-     * @param  object $post    The post object of the cpt that was saved.
960
-     * @return void
961
-     */
962
-    protected function _insert_update_cpt_item($post_id, $post)
963
-    {
964
-        if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') {
965
-            //get out we're not processing an event save.
966
-            return;
967
-        }
968
-        $event_values = array(
969
-            'EVT_display_desc'                => ! empty($this->_req_data['display_desc']) ? 1 : 0,
970
-            'EVT_display_ticket_selector'     => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0,
971
-            'EVT_additional_limit'            => min(
972
-                apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255),
973
-                ! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : null
974
-            ),
975
-            'EVT_default_registration_status' => ! empty($this->_req_data['EVT_default_registration_status'])
976
-                ? $this->_req_data['EVT_default_registration_status']
977
-                : EE_Registry::instance()->CFG->registration->default_STS_ID,
978
-            'EVT_member_only'                 => ! empty($this->_req_data['member_only']) ? 1 : 0,
979
-            'EVT_allow_overflow'              => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0,
980
-            'EVT_timezone_string'             => ! empty($this->_req_data['timezone_string'])
981
-                ? $this->_req_data['timezone_string'] : null,
982
-            'EVT_external_URL'                => ! empty($this->_req_data['externalURL'])
983
-                ? $this->_req_data['externalURL'] : null,
984
-            'EVT_phone'                       => ! empty($this->_req_data['event_phone'])
985
-                ? $this->_req_data['event_phone'] : null,
986
-        );
987
-        //update event
988
-        $success = $this->_event_model()->update_by_ID($event_values, $post_id);
989
-        //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!
990
-        $get_one_where = array($this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status);
991
-        $event = $this->_event_model()->get_one(array($get_one_where));
992
-        //the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons.
993
-        $event_update_callbacks = apply_filters(
994
-            'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',
995
-            array(array($this, '_default_venue_update'), array($this, '_default_tickets_update'))
996
-        );
997
-        $att_success = true;
998
-        foreach ($event_update_callbacks as $e_callback) {
999
-            $_succ = call_user_func_array($e_callback, array($event, $this->_req_data));
1000
-            $att_success = ! $att_success ? $att_success
1001
-                : $_succ; //if ANY of these updates fail then we want the appropriate global error message
1002
-        }
1003
-        //any errors?
1004
-        if ($success && false === $att_success) {
1005
-            EE_Error::add_error(
1006
-                esc_html__(
1007
-                    'Event Details saved successfully but something went wrong with saving attachments.',
1008
-                    'event_espresso'
1009
-                ),
1010
-                __FILE__,
1011
-                __FUNCTION__,
1012
-                __LINE__
1013
-            );
1014
-        } else if ($success === false) {
1015
-            EE_Error::add_error(
1016
-                esc_html__('Event Details did not save successfully.', 'event_espresso'),
1017
-                __FILE__,
1018
-                __FUNCTION__,
1019
-                __LINE__
1020
-            );
1021
-        }
1022
-    }
1023
-
1024
-
1025
-
1026
-    /**
1027
-     * @see parent::restore_item()
1028
-     * @param int $post_id
1029
-     * @param int $revision_id
1030
-     */
1031
-    protected function _restore_cpt_item($post_id, $revision_id)
1032
-    {
1033
-        //copy existing event meta to new post
1034
-        $post_evt = $this->_event_model()->get_one_by_ID($post_id);
1035
-        if ($post_evt instanceof EE_Event) {
1036
-            //meta revision restore
1037
-            $post_evt->restore_revision($revision_id);
1038
-            //related objs restore
1039
-            $post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price'));
1040
-        }
1041
-    }
1042
-
1043
-
1044
-
1045
-    /**
1046
-     * Attach the venue to the Event
1047
-     *
1048
-     * @param  \EE_Event $evtobj Event Object to add the venue to
1049
-     * @param  array     $data   The request data from the form
1050
-     * @return bool           Success or fail.
1051
-     */
1052
-    protected function _default_venue_update(\EE_Event $evtobj, $data)
1053
-    {
1054
-        require_once(EE_MODELS . 'EEM_Venue.model.php');
1055
-        $venue_model = EE_Registry::instance()->load_model('Venue');
1056
-        $rows_affected = null;
1057
-        $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null;
1058
-        // very important.  If we don't have a venue name...
1059
-        // then we'll get out because not necessary to create empty venue
1060
-        if (empty($data['venue_title'])) {
1061
-            return false;
1062
-        }
1063
-        $venue_array = array(
1064
-            'VNU_wp_user'         => $evtobj->get('EVT_wp_user'),
1065
-            'VNU_name'            => ! empty($data['venue_title']) ? $data['venue_title'] : null,
1066
-            'VNU_desc'            => ! empty($data['venue_description']) ? $data['venue_description'] : null,
1067
-            'VNU_identifier'      => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : null,
1068
-            'VNU_short_desc'      => ! empty($data['venue_short_description']) ? $data['venue_short_description']
1069
-                : null,
1070
-            'VNU_address'         => ! empty($data['address']) ? $data['address'] : null,
1071
-            'VNU_address2'        => ! empty($data['address2']) ? $data['address2'] : null,
1072
-            'VNU_city'            => ! empty($data['city']) ? $data['city'] : null,
1073
-            'STA_ID'              => ! empty($data['state']) ? $data['state'] : null,
1074
-            'CNT_ISO'             => ! empty($data['countries']) ? $data['countries'] : null,
1075
-            'VNU_zip'             => ! empty($data['zip']) ? $data['zip'] : null,
1076
-            'VNU_phone'           => ! empty($data['venue_phone']) ? $data['venue_phone'] : null,
1077
-            'VNU_capacity'        => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : null,
1078
-            'VNU_url'             => ! empty($data['venue_url']) ? $data['venue_url'] : null,
1079
-            'VNU_virtual_phone'   => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : null,
1080
-            'VNU_virtual_url'     => ! empty($data['virtual_url']) ? $data['virtual_url'] : null,
1081
-            'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0,
1082
-            'status'              => 'publish',
1083
-        );
1084
-        //if we've got the venue_id then we're just updating the existing venue so let's do that and then get out.
1085
-        if ( ! empty($venue_id)) {
1086
-            $update_where = array($venue_model->primary_key_name() => $venue_id);
1087
-            $rows_affected = $venue_model->update($venue_array, array($update_where));
1088
-            //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.
1089
-            $evtobj->_add_relation_to($venue_id, 'Venue');
1090
-            return $rows_affected > 0 ? true : false;
1091
-        } else {
1092
-            //we insert the venue
1093
-            $venue_id = $venue_model->insert($venue_array);
1094
-            $evtobj->_add_relation_to($venue_id, 'Venue');
1095
-            return ! empty($venue_id) ? true : false;
1096
-        }
1097
-        //when we have the ancestor come in it's already been handled by the revision save.
1098
-    }
1099
-
1100
-
1101
-
1102
-    /**
1103
-     * Handles saving everything related to Tickets (datetimes, tickets, prices)
1104
-     *
1105
-     * @param  EE_Event $evtobj The Event object we're attaching data to
1106
-     * @param  array    $data   The request data from the form
1107
-     * @return array
1108
-     */
1109
-    protected function _default_tickets_update(EE_Event $evtobj, $data)
1110
-    {
1111
-        $success = true;
1112
-        $saved_dtt = null;
1113
-        $saved_tickets = array();
1114
-        $incoming_date_formats = array('Y-m-d', 'h:i a');
1115
-        foreach ($data['edit_event_datetimes'] as $row => $dtt) {
1116
-            //trim all values to ensure any excess whitespace is removed.
1117
-            $dtt = array_map('trim', $dtt);
1118
-            $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end']
1119
-                : $dtt['DTT_EVT_start'];
1120
-            $datetime_values = array(
1121
-                'DTT_ID'        => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : null,
1122
-                'DTT_EVT_start' => $dtt['DTT_EVT_start'],
1123
-                'DTT_EVT_end'   => $dtt['DTT_EVT_end'],
1124
-                'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'],
1125
-                'DTT_order'     => $row,
1126
-            );
1127
-            //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.
1128
-            if ( ! empty($dtt['DTT_ID'])) {
1129
-                $DTM = EE_Registry::instance()
1130
-                                  ->load_model('Datetime', array($evtobj->get_timezone()))
1131
-                                  ->get_one_by_ID($dtt['DTT_ID']);
1132
-                $DTM->set_date_format($incoming_date_formats[0]);
1133
-                $DTM->set_time_format($incoming_date_formats[1]);
1134
-                foreach ($datetime_values as $field => $value) {
1135
-                    $DTM->set($field, $value);
1136
-                }
1137
-                //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.
1138
-                $saved_dtts[$DTM->ID()] = $DTM;
1139
-            } else {
1140
-                $DTM = EE_Registry::instance()->load_class(
1141
-                    'Datetime',
1142
-                    array($datetime_values, $evtobj->get_timezone(), $incoming_date_formats),
1143
-                    false,
1144
-                    false
1145
-                );
1146
-                foreach ($datetime_values as $field => $value) {
1147
-                    $DTM->set($field, $value);
1148
-                }
1149
-            }
1150
-            $DTM->save();
1151
-            $DTT = $evtobj->_add_relation_to($DTM, 'Datetime');
1152
-            //load DTT helper
1153
-            //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.
1154
-            if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) {
1155
-                $DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start'));
1156
-                $DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days');
1157
-                $DTT->save();
1158
-            }
1159
-            //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.
1160
-            $saved_dtt = $DTT;
1161
-            $success = ! $success ? $success : $DTT;
1162
-            //if ANY of these updates fail then we want the appropriate global error message.
1163
-            // //todo this is actually sucky we need a better error message but this is what it is for now.
1164
-        }
1165
-        //no dtts get deleted so we don't do any of that logic here.
1166
-        //update tickets next
1167
-        $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array();
1168
-        foreach ($data['edit_tickets'] as $row => $tkt) {
1169
-            $incoming_date_formats = array('Y-m-d', 'h:i a');
1170
-            $update_prices = false;
1171
-            $ticket_price = isset($data['edit_prices'][$row][1]['PRC_amount'])
1172
-                ? $data['edit_prices'][$row][1]['PRC_amount'] : 0;
1173
-            // trim inputs to ensure any excess whitespace is removed.
1174
-            $tkt = array_map('trim', $tkt);
1175
-            if (empty($tkt['TKT_start_date'])) {
1176
-                //let's use now in the set timezone.
1177
-                $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone()));
1178
-                $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0] . ' ' . $incoming_date_formats[1]);
1179
-            }
1180
-            if (empty($tkt['TKT_end_date'])) {
1181
-                //use the start date of the first datetime
1182
-                $dtt = $evtobj->first_datetime();
1183
-                $tkt['TKT_end_date'] = $dtt->start_date_and_time(
1184
-                    $incoming_date_formats[0],
1185
-                    $incoming_date_formats[1]
1186
-                );
1187
-            }
1188
-            $TKT_values = array(
1189
-                'TKT_ID'          => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null,
1190
-                'TTM_ID'          => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0,
1191
-                'TKT_name'        => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '',
1192
-                'TKT_description' => ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '',
1193
-                'TKT_start_date'  => $tkt['TKT_start_date'],
1194
-                'TKT_end_date'    => $tkt['TKT_end_date'],
1195
-                'TKT_qty'         => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'],
1196
-                'TKT_uses'        => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'],
1197
-                'TKT_min'         => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'],
1198
-                'TKT_max'         => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'],
1199
-                'TKT_row'         => $row,
1200
-                'TKT_order'       => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row,
1201
-                'TKT_price'       => $ticket_price,
1202
-            );
1203
-            //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.
1204
-            if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) {
1205
-                $TKT_values['TKT_ID'] = 0;
1206
-                $TKT_values['TKT_is_default'] = 0;
1207
-                $TKT_values['TKT_price'] = $ticket_price;
1208
-                $update_prices = true;
1209
-            }
1210
-            //if we have a TKT_ID then we need to get that existing TKT_obj and update it
1211
-            //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.
1212
-            //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.
1213
-            if ( ! empty($tkt['TKT_ID'])) {
1214
-                $TKT = EE_Registry::instance()
1215
-                                  ->load_model('Ticket', array($evtobj->get_timezone()))
1216
-                                  ->get_one_by_ID($tkt['TKT_ID']);
1217
-                if ($TKT instanceof EE_Ticket) {
1218
-                    $ticket_sold = $TKT->count_related(
1219
-                        'Registration',
1220
-                        array(
1221
-                            array(
1222
-                                'STS_ID' => array(
1223
-                                    'NOT IN',
1224
-                                    array(EEM_Registration::status_id_incomplete),
1225
-                                ),
1226
-                            ),
1227
-                        )
1228
-                    ) > 0 ? true : false;
1229
-                    //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.
1230
-                    $create_new_TKT = $ticket_sold && $ticket_price != $TKT->get('TKT_price')
1231
-                                      && ! $TKT->get(
1232
-                        'TKT_deleted'
1233
-                    ) ? true : false;
1234
-                    $TKT->set_date_format($incoming_date_formats[0]);
1235
-                    $TKT->set_time_format($incoming_date_formats[1]);
1236
-                    //set new values
1237
-                    foreach ($TKT_values as $field => $value) {
1238
-                        if ($field == 'TKT_qty') {
1239
-                            $TKT->set_qty($value);
1240
-                        } else {
1241
-                            $TKT->set($field, $value);
1242
-                        }
1243
-                    }
1244
-                    //if $create_new_TKT is false then we can safely update the existing ticket.  Otherwise we have to create a new ticket.
1245
-                    if ($create_new_TKT) {
1246
-                        //archive the old ticket first
1247
-                        $TKT->set('TKT_deleted', 1);
1248
-                        $TKT->save();
1249
-                        //make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine.
1250
-                        $saved_tickets[$TKT->ID()] = $TKT;
1251
-                        //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.
1252
-                        $TKT = clone $TKT;
1253
-                        $TKT->set('TKT_ID', 0);
1254
-                        $TKT->set('TKT_deleted', 0);
1255
-                        $TKT->set('TKT_price', $ticket_price);
1256
-                        $TKT->set('TKT_sold', 0);
1257
-                        //now we need to make sure that $new prices are created as well and attached to new ticket.
1258
-                        $update_prices = true;
1259
-                    }
1260
-                    //make sure price is set if it hasn't been already
1261
-                    $TKT->set('TKT_price', $ticket_price);
1262
-                }
1263
-            } else {
1264
-                //no TKT_id so a new TKT
1265
-                $TKT_values['TKT_price'] = $ticket_price;
1266
-                $TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), false, false);
1267
-                if ($TKT instanceof EE_Ticket) {
1268
-                    //need to reset values to properly account for the date formats
1269
-                    $TKT->set_date_format($incoming_date_formats[0]);
1270
-                    $TKT->set_time_format($incoming_date_formats[1]);
1271
-                    $TKT->set_timezone($evtobj->get_timezone());
1272
-                    //set new values
1273
-                    foreach ($TKT_values as $field => $value) {
1274
-                        if ($field == 'TKT_qty') {
1275
-                            $TKT->set_qty($value);
1276
-                        } else {
1277
-                            $TKT->set($field, $value);
1278
-                        }
1279
-                    }
1280
-                    $update_prices = true;
1281
-                }
1282
-            }
1283
-            // cap ticket qty by datetime reg limits
1284
-            $TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit')));
1285
-            //update ticket.
1286
-            $TKT->save();
1287
-            //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.
1288
-            if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) {
1289
-                $TKT->set('TKT_end_date', $TKT->get('TKT_start_date'));
1290
-                $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days');
1291
-                $TKT->save();
1292
-            }
1293
-            //initially let's add the ticket to the dtt
1294
-            $saved_dtt->_add_relation_to($TKT, 'Ticket');
1295
-            $saved_tickets[$TKT->ID()] = $TKT;
1296
-            //add prices to ticket
1297
-            $this->_add_prices_to_ticket($data['edit_prices'][$row], $TKT, $update_prices);
1298
-        }
1299
-        //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.
1300
-        $old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets;
1301
-        $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets));
1302
-        foreach ($tickets_removed as $id) {
1303
-            $id = absint($id);
1304
-            //get the ticket for this id
1305
-            $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id);
1306
-            //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)
1307
-            $dtts = $tkt_to_remove->get_many_related('Datetime');
1308
-            foreach ($dtts as $dtt) {
1309
-                $tkt_to_remove->_remove_relation_to($dtt, 'Datetime');
1310
-            }
1311
-            //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))
1312
-            $tkt_to_remove->delete_related_permanently('Price');
1313
-            //finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships)
1314
-            $tkt_to_remove->delete_permanently();
1315
-        }
1316
-        return array($saved_dtt, $saved_tickets);
1317
-    }
1318
-
1319
-
1320
-
1321
-    /**
1322
-     * This attaches a list of given prices to a ticket.
1323
-     * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change
1324
-     * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old
1325
-     * price info and prices are automatically "archived" via the ticket.
1326
-     *
1327
-     * @access  private
1328
-     * @param array     $prices     Array of prices from the form.
1329
-     * @param EE_Ticket $ticket     EE_Ticket object that prices are being attached to.
1330
-     * @param bool      $new_prices Whether attach existing incoming prices or create new ones.
1331
-     * @return  void
1332
-     */
1333
-    private function _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = false)
1334
-    {
1335
-        foreach ($prices as $row => $prc) {
1336
-            $PRC_values = array(
1337
-                'PRC_ID'         => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null,
1338
-                'PRT_ID'         => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null,
1339
-                'PRC_amount'     => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0,
1340
-                'PRC_name'       => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '',
1341
-                'PRC_desc'       => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '',
1342
-                'PRC_is_default' => 0, //make sure prices are NOT set as default from this context
1343
-                'PRC_order'      => $row,
1344
-            );
1345
-            if ($new_prices || empty($PRC_values['PRC_ID'])) {
1346
-                $PRC_values['PRC_ID'] = 0;
1347
-                $PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), false, false);
1348
-            } else {
1349
-                $PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']);
1350
-                //update this price with new values
1351
-                foreach ($PRC_values as $field => $newprc) {
1352
-                    $PRC->set($field, $newprc);
1353
-                }
1354
-                $PRC->save();
1355
-            }
1356
-            $ticket->_add_relation_to($PRC, 'Price');
1357
-        }
1358
-    }
1359
-
1360
-
1361
-
1362
-    /**
1363
-     * Add in our autosave ajax handlers
1364
-     *
1365
-     * @return void
1366
-     */
1367
-    protected function _ee_autosave_create_new()
1368
-    {
1369
-        // $this->_ee_autosave_edit();
1370
-    }
1371
-
1372
-
1373
-
1374
-    protected function _ee_autosave_edit()
1375
-    {
1376
-        return; //TEMPORARILY EXITING CAUSE THIS IS A TODO
1377
-    }
1378
-
1379
-
1380
-
1381
-    /**
1382
-     *    _generate_publish_box_extra_content
1383
-     *
1384
-     * @access private
1385
-     * @return void
1386
-     */
1387
-    private function _generate_publish_box_extra_content()
1388
-    {
1389
-        //load formatter helper
1390
-        //args for getting related registrations
1391
-        $approved_query_args = array(
1392
-            array(
1393
-                'REG_deleted' => 0,
1394
-                'STS_ID'      => EEM_Registration::status_id_approved,
1395
-            ),
1396
-        );
1397
-        $not_approved_query_args = array(
1398
-            array(
1399
-                'REG_deleted' => 0,
1400
-                'STS_ID'      => EEM_Registration::status_id_not_approved,
1401
-            ),
1402
-        );
1403
-        $pending_payment_query_args = array(
1404
-            array(
1405
-                'REG_deleted' => 0,
1406
-                'STS_ID'      => EEM_Registration::status_id_pending_payment,
1407
-            ),
1408
-        );
1409
-        // publish box
1410
-        $publish_box_extra_args = array(
1411
-            'view_approved_reg_url'        => add_query_arg(
1412
-                array(
1413
-                    'action'      => 'default',
1414
-                    'event_id'    => $this->_cpt_model_obj->ID(),
1415
-                    '_reg_status' => EEM_Registration::status_id_approved,
1416
-                ),
1417
-                REG_ADMIN_URL
1418
-            ),
1419
-            'view_not_approved_reg_url'    => add_query_arg(
1420
-                array(
1421
-                    'action'      => 'default',
1422
-                    'event_id'    => $this->_cpt_model_obj->ID(),
1423
-                    '_reg_status' => EEM_Registration::status_id_not_approved,
1424
-                ),
1425
-                REG_ADMIN_URL
1426
-            ),
1427
-            'view_pending_payment_reg_url' => add_query_arg(
1428
-                array(
1429
-                    'action'      => 'default',
1430
-                    'event_id'    => $this->_cpt_model_obj->ID(),
1431
-                    '_reg_status' => EEM_Registration::status_id_pending_payment,
1432
-                ),
1433
-                REG_ADMIN_URL
1434
-            ),
1435
-            'approved_regs'                => $this->_cpt_model_obj->count_related(
1436
-                'Registration',
1437
-                $approved_query_args
1438
-            ),
1439
-            'not_approved_regs'            => $this->_cpt_model_obj->count_related(
1440
-                'Registration',
1441
-                $not_approved_query_args
1442
-            ),
1443
-            'pending_payment_regs'         => $this->_cpt_model_obj->count_related(
1444
-                'Registration',
1445
-                $pending_payment_query_args
1446
-            ),
1447
-            'misc_pub_section_class'       => apply_filters(
1448
-                'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class',
1449
-                'misc-pub-section'
1450
-            ),
1451
-            //'email_attendees_url' => add_query_arg(
1452
-            //	array(
1453
-            //		'event_admin_reports' => 'event_newsletter',
1454
-            //		'event_id' => $this->_cpt_model_obj->id
1455
-            //	),
1456
-            //	'admin.php?page=espresso_registrations'
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
-    /**
1475
-     * This just returns whatever is set as the _event object property
1476
-     * //todo this will become obsolete once the models are in place
1477
-     *
1478
-     * @return object
1479
-     */
1480
-    public function get_event_object()
1481
-    {
1482
-        return $this->_cpt_model_obj;
1483
-    }
1484
-
1485
-
1486
-
1487
-
1488
-    /** METABOXES * */
1489
-    /**
1490
-     * _register_event_editor_meta_boxes
1491
-     * add all metaboxes related to the event_editor
1492
-     *
1493
-     * @return void
1494
-     */
1495
-    protected function _register_event_editor_meta_boxes()
1496
-    {
1497
-        $this->verify_cpt_object();
1498
-        add_meta_box(
1499
-            'espresso_event_editor_tickets',
1500
-            esc_html__('Event Datetime & Ticket', 'event_espresso'),
1501
-            array($this, 'ticket_metabox'),
1502
-            $this->page_slug,
1503
-            'normal',
1504
-            'high'
1505
-        );
1506
-        add_meta_box(
1507
-            'espresso_event_editor_event_options',
1508
-            esc_html__('Event Registration Options', 'event_espresso'),
1509
-            array($this, 'registration_options_meta_box'),
1510
-            $this->page_slug,
1511
-            'side',
1512
-            'default'
1513
-        );
1514
-        // NOTE: if you're looking for other metaboxes in here,
1515
-        // where a metabox has a related management page in the admin
1516
-        // you will find it setup in the related management page's "_Hooks" file.
1517
-        // i.e. messages metabox is found in "espresso_events_Messages_Hooks.class.php".
1518
-    }
1519
-
1520
-
1521
-
1522
-    public function ticket_metabox()
1523
-    {
1524
-        $existing_datetime_ids = $existing_ticket_ids = array();
1525
-        //defaults for template args
1526
-        $template_args = array(
1527
-            'existing_datetime_ids'    => '',
1528
-            'event_datetime_help_link' => '',
1529
-            'ticket_options_help_link' => '',
1530
-            'time'                     => null,
1531
-            'ticket_rows'              => '',
1532
-            'existing_ticket_ids'      => '',
1533
-            'total_ticket_rows'        => 1,
1534
-            'ticket_js_structure'      => '',
1535
-            'trash_icon'               => 'ee-lock-icon',
1536
-            'disabled'                 => '',
1537
-        );
1538
-        $event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : null;
1539
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1540
-        /**
1541
-         * 1. Start with retrieving Datetimes
1542
-         * 2. Fore each datetime get related tickets
1543
-         * 3. For each ticket get related prices
1544
-         */
1545
-        $times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id);
1546
-        /** @type EE_Datetime $first_datetime */
1547
-        $first_datetime = reset($times);
1548
-        //do we get related tickets?
1549
-        if ($first_datetime instanceof EE_Datetime
1550
-            && $first_datetime->ID() !== 0
1551
-        ) {
1552
-            $existing_datetime_ids[] = $first_datetime->get('DTT_ID');
1553
-            $template_args['time'] = $first_datetime;
1554
-            $related_tickets = $first_datetime->tickets(
1555
-                array(
1556
-                    array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)),
1557
-                    'default_where_conditions' => 'none',
1558
-                )
1559
-            );
1560
-            if ( ! empty($related_tickets)) {
1561
-                $template_args['total_ticket_rows'] = count($related_tickets);
1562
-                $row = 0;
1563
-                foreach ($related_tickets as $ticket) {
1564
-                    $existing_ticket_ids[] = $ticket->get('TKT_ID');
1565
-                    $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, false, $row);
1566
-                    $row++;
1567
-                }
1568
-            } else {
1569
-                $template_args['total_ticket_rows'] = 1;
1570
-                /** @type EE_Ticket $ticket */
1571
-                $ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object();
1572
-                $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket);
1573
-            }
1574
-        } else {
1575
-            $template_args['time'] = $times[0];
1576
-            /** @type EE_Ticket $ticket */
1577
-            $ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets();
1578
-            $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]);
1579
-            // NOTE: we're just sending the first default row
1580
-            // (decaf can't manage default tickets so this should be sufficient);
1581
-        }
1582
-        $template_args['event_datetime_help_link'] = $this->_get_help_tab_link(
1583
-            'event_editor_event_datetimes_help_tab'
1584
-        );
1585
-        $template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info');
1586
-        $template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids);
1587
-        $template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids);
1588
-        $template_args['ticket_js_structure'] = $this->_get_ticket_row(
1589
-            EE_Registry::instance()->load_model('Ticket')->create_default_object(),
1590
-            true
1591
-        );
1592
-        $template = apply_filters(
1593
-            'FHEE__Events_Admin_Page__ticket_metabox__template',
1594
-            EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php'
1595
-        );
1596
-        EEH_Template::display_template($template, $template_args);
1597
-    }
1598
-
1599
-
1600
-
1601
-    /**
1602
-     * Setup an individual ticket form for the decaf event editor page
1603
-     *
1604
-     * @access private
1605
-     * @param  EE_Ticket $ticket   the ticket object
1606
-     * @param  boolean   $skeleton whether we're generating a skeleton for js manipulation
1607
-     * @param int        $row
1608
-     * @return string generated html for the ticket row.
1609
-     */
1610
-    private function _get_ticket_row($ticket, $skeleton = false, $row = 0)
1611
-    {
1612
-        $template_args = array(
1613
-            'tkt_status_class'    => ' tkt-status-' . $ticket->ticket_status(),
1614
-            'tkt_archive_class'   => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived'
1615
-                : '',
1616
-            'ticketrow'           => $skeleton ? 'TICKETNUM' : $row,
1617
-            'TKT_ID'              => $ticket->get('TKT_ID'),
1618
-            'TKT_name'            => $ticket->get('TKT_name'),
1619
-            'TKT_start_date'      => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'),
1620
-            'TKT_end_date'        => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'),
1621
-            'TKT_is_default'      => $ticket->get('TKT_is_default'),
1622
-            'TKT_qty'             => $ticket->get_pretty('TKT_qty', 'input'),
1623
-            'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets',
1624
-            'TKT_sold'            => $skeleton ? 0 : $ticket->get('TKT_sold'),
1625
-            'trash_icon'          => ($skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')))
1626
-                                     && ( ! empty($ticket) && $ticket->get('TKT_sold') === 0)
1627
-                ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon',
1628
-            'disabled'            => $skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')) ? ''
1629
-                : ' disabled=disabled',
1630
-        );
1631
-        $price = $ticket->ID() !== 0
1632
-            ? $ticket->get_first_related('Price', array('default_where_conditions' => 'none'))
1633
-            : EE_Registry::instance()->load_model('Price')->create_default_object();
1634
-        $price_args = array(
1635
-            'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,
1636
-            'PRC_amount'            => $price->get('PRC_amount'),
1637
-            'PRT_ID'                => $price->get('PRT_ID'),
1638
-            'PRC_ID'                => $price->get('PRC_ID'),
1639
-            'PRC_is_default'        => $price->get('PRC_is_default'),
1640
-        );
1641
-        //make sure we have default start and end dates if skeleton
1642
-        //handle rows that should NOT be empty
1643
-        if (empty($template_args['TKT_start_date'])) {
1644
-            //if empty then the start date will be now.
1645
-            $template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp'));
1646
-        }
1647
-        if (empty($template_args['TKT_end_date'])) {
1648
-            //get the earliest datetime (if present);
1649
-            $earliest_dtt = $this->_cpt_model_obj->ID() > 0
1650
-                ? $this->_cpt_model_obj->get_first_related(
1651
-                    'Datetime',
1652
-                    array('order_by' => array('DTT_EVT_start' => 'ASC'))
1653
-                )
1654
-                : null;
1655
-            if ( ! empty($earliest_dtt)) {
1656
-                $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a');
1657
-            } else {
1658
-                $template_args['TKT_end_date'] = date(
1659
-                    'Y-m-d h:i a',
1660
-                    mktime(0, 0, 0, date("m"), date("d") + 7, date("Y"))
1661
-                );
1662
-            }
1663
-        }
1664
-        $template_args = array_merge($template_args, $price_args);
1665
-        $template = apply_filters(
1666
-            'FHEE__Events_Admin_Page__get_ticket_row__template',
1667
-            EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php',
1668
-            $ticket
1669
-        );
1670
-        return EEH_Template::display_template($template, $template_args, true);
1671
-    }
1672
-
1673
-
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
-    /**
1727
-     * _get_events()
1728
-     * This method simply returns all the events (for the given _view and paging)
1729
-     *
1730
-     * @access public
1731
-     * @param int  $per_page     count of items per page (20 default);
1732
-     * @param int  $current_page what is the current page being viewed.
1733
-     * @param bool $count        if TRUE then we just return a count of ALL events matching the given _view.
1734
-     *                           If FALSE then we return an array of event objects
1735
-     *                           that match the given _view and paging parameters.
1736
-     * @return array an array of event objects.
1737
-     */
1738
-    public function get_events($per_page = 10, $current_page = 1, $count = false)
1739
-    {
1740
-        $EEME = $this->_event_model();
1741
-        $offset = ($current_page - 1) * $per_page;
1742
-        $limit = $count ? null : $offset . ',' . $per_page;
1743
-        $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID';
1744
-        $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC";
1745
-        if (isset($this->_req_data['month_range'])) {
1746
-            $pieces = explode(' ', $this->_req_data['month_range'], 3);
1747
-            //simulate the FIRST day of the month, that fixes issues for months like February
1748
-            //where PHP doesn't know what to assume for date.
1749
-            //@see https://events.codebasehq.com/projects/event-espresso/tickets/10437
1750
-            $month_r = ! empty($pieces[0]) ? date('m', \EEH_DTT_Helper::first_of_month_timestamp($pieces[0])) : '';
1751
-            $year_r = ! empty($pieces[1]) ? $pieces[1] : '';
1752
-        }
1753
-        $where = array();
1754
-        $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
1755
-        //determine what post_status our condition will have for the query.
1756
-        switch ($status) {
1757
-            case 'month' :
1758
-            case 'today' :
1759
-            case null :
1760
-            case 'all' :
1761
-                break;
1762
-            case 'draft' :
1763
-                $where['status'] = array('IN', array('draft', 'auto-draft'));
1764
-                break;
1765
-            default :
1766
-                $where['status'] = $status;
1767
-        }
1768
-        //categories?
1769
-        $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0
1770
-            ? $this->_req_data['EVT_CAT'] : null;
1771
-        if ( ! empty ($category)) {
1772
-            $where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories';
1773
-            $where['Term_Taxonomy.term_id'] = $category;
1774
-        }
1775
-        //date where conditions
1776
-        $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start');
1777
-        if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') {
1778
-            $DateTime = new DateTime(
1779
-                $year_r . '-' . $month_r . '-01 00:00:00',
1780
-                new DateTimeZone(EEM_Datetime::instance()->get_timezone())
1781
-            );
1782
-            $start = $DateTime->format(implode(' ', $start_formats));
1783
-            $end = $DateTime->setDate($year_r, $month_r, $DateTime
1784
-                ->format('t'))->setTime(23, 59, 59)
1785
-                            ->format(implode(' ', $start_formats));
1786
-            $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1787
-        } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') {
1788
-            $DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone()));
1789
-            $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats));
1790
-            $end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats));
1791
-            $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1792
-        } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') {
1793
-            $now = date('Y-m-01');
1794
-            $DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone()));
1795
-            $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats));
1796
-            $end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t'))
1797
-                            ->setTime(23, 59, 59)
1798
-                            ->format(implode(' ', $start_formats));
1799
-            $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1800
-        }
1801
-        if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
1802
-            $where['EVT_wp_user'] = get_current_user_id();
1803
-        } else {
1804
-            if ( ! isset($where['status'])) {
1805
-                if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) {
1806
-                    $where['OR'] = array(
1807
-                        'status*restrict_private' => array('!=', 'private'),
1808
-                        'AND'                     => array(
1809
-                            'status*inclusive' => array('=', 'private'),
1810
-                            'EVT_wp_user'      => get_current_user_id(),
1811
-                        ),
1812
-                    );
1813
-                }
1814
-            }
1815
-        }
1816
-        if (isset($this->_req_data['EVT_wp_user'])) {
1817
-            if ($this->_req_data['EVT_wp_user'] != get_current_user_id()
1818
-                && EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')
1819
-            ) {
1820
-                $where['EVT_wp_user'] = $this->_req_data['EVT_wp_user'];
1821
-            }
1822
-        }
1823
-        //search query handling
1824
-        if (isset($this->_req_data['s'])) {
1825
-            $search_string = '%' . $this->_req_data['s'] . '%';
1826
-            $where['OR'] = array(
1827
-                'EVT_name'       => array('LIKE', $search_string),
1828
-                'EVT_desc'       => array('LIKE', $search_string),
1829
-                'EVT_short_desc' => array('LIKE', $search_string),
1830
-            );
1831
-        }
1832
-        $where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data);
1833
-        $query_params = apply_filters(
1834
-            'FHEE__Events_Admin_Page__get_events__query_params',
1835
-            array(
1836
-                $where,
1837
-                'limit'    => $limit,
1838
-                'order_by' => $orderby,
1839
-                'order'    => $order,
1840
-                'group_by' => 'EVT_ID',
1841
-            ),
1842
-            $this->_req_data
1843
-        );
1844
-        //let's first check if we have special requests coming in.
1845
-        if (isset($this->_req_data['active_status'])) {
1846
-            switch ($this->_req_data['active_status']) {
1847
-                case 'upcoming' :
1848
-                    return $EEME->get_upcoming_events($query_params, $count);
1849
-                    break;
1850
-                case 'expired' :
1851
-                    return $EEME->get_expired_events($query_params, $count);
1852
-                    break;
1853
-                case 'active' :
1854
-                    return $EEME->get_active_events($query_params, $count);
1855
-                    break;
1856
-                case 'inactive' :
1857
-                    return $EEME->get_inactive_events($query_params, $count);
1858
-                    break;
1859
-            }
1860
-        }
1861
-        $events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params);
1862
-        return $events;
1863
-    }
1864
-
1865
-
1866
-
1867
-    /**
1868
-     * handling for WordPress CPT actions (trash, restore, delete)
1869
-     *
1870
-     * @param string $post_id
1871
-     */
1872
-    public function trash_cpt_item($post_id)
1873
-    {
1874
-        $this->_req_data['EVT_ID'] = $post_id;
1875
-        $this->_trash_or_restore_event('trash', false);
1876
-    }
1877
-
1878
-
1879
-
1880
-    /**
1881
-     * @param string $post_id
1882
-     */
1883
-    public function restore_cpt_item($post_id)
1884
-    {
1885
-        $this->_req_data['EVT_ID'] = $post_id;
1886
-        $this->_trash_or_restore_event('draft', false);
1887
-    }
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
-    /**
1903
-     * _trash_or_restore_event
1904
-     *
1905
-     * @access protected
1906
-     * @param  string $event_status
1907
-     * @param bool    $redirect_after
1908
-     */
1909
-    protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = true)
1910
-    {
1911
-        //determine the event id and set to array.
1912
-        $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : false;
1913
-        // loop thru events
1914
-        if ($EVT_ID) {
1915
-            // clean status
1916
-            $event_status = sanitize_key($event_status);
1917
-            // grab status
1918
-            if ( ! empty($event_status)) {
1919
-                $success = $this->_change_event_status($EVT_ID, $event_status);
1920
-            } else {
1921
-                $success = false;
1922
-                $msg = esc_html__(
1923
-                    'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.',
1924
-                    'event_espresso'
1925
-                );
1926
-                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1927
-            }
1928
-        } else {
1929
-            $success = false;
1930
-            $msg = esc_html__(
1931
-                'An error occurred. The event could not be moved to the trash because a valid event ID was not not supplied.',
1932
-                'event_espresso'
1933
-            );
1934
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1935
-        }
1936
-        $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
1937
-        if ($redirect_after) {
1938
-            $this->_redirect_after_action($success, 'Event', $action, array('action' => 'default'));
1939
-        }
1940
-    }
1941
-
1942
-
1943
-
1944
-    /**
1945
-     * _trash_or_restore_events
1946
-     *
1947
-     * @access protected
1948
-     * @param  string $event_status
1949
-     * @return void
1950
-     */
1951
-    protected function _trash_or_restore_events($event_status = 'trash')
1952
-    {
1953
-        // clean status
1954
-        $event_status = sanitize_key($event_status);
1955
-        // grab status
1956
-        if ( ! empty($event_status)) {
1957
-            $success = true;
1958
-            //determine the event id and set to array.
1959
-            $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array();
1960
-            // loop thru events
1961
-            foreach ($EVT_IDs as $EVT_ID) {
1962
-                if ($EVT_ID = absint($EVT_ID)) {
1963
-                    $results = $this->_change_event_status($EVT_ID, $event_status);
1964
-                    $success = $results !== false ? $success : false;
1965
-                } else {
1966
-                    $msg = sprintf(
1967
-                        esc_html__(
1968
-                            'An error occurred. Event #%d could not be moved to the trash because a valid event ID was not not supplied.',
1969
-                            'event_espresso'
1970
-                        ),
1971
-                        $EVT_ID
1972
-                    );
1973
-                    EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1974
-                    $success = false;
1975
-                }
1976
-            }
1977
-        } else {
1978
-            $success = false;
1979
-            $msg = esc_html__(
1980
-                'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.',
1981
-                'event_espresso'
1982
-            );
1983
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1984
-        }
1985
-        // in order to force a pluralized result message we need to send back a success status greater than 1
1986
-        $success = $success ? 2 : false;
1987
-        $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
1988
-        $this->_redirect_after_action($success, 'Events', $action, array('action' => 'default'));
1989
-    }
1990
-
1991
-
1992
-
1993
-    /**
1994
-     * _trash_or_restore_events
1995
-     *
1996
-     * @access  private
1997
-     * @param  int    $EVT_ID
1998
-     * @param  string $event_status
1999
-     * @return bool
2000
-     */
2001
-    private function _change_event_status($EVT_ID = 0, $event_status = '')
2002
-    {
2003
-        // grab event id
2004
-        if ( ! $EVT_ID) {
2005
-            $msg = esc_html__(
2006
-                'An error occurred. No Event ID or an invalid Event ID was received.',
2007
-                'event_espresso'
2008
-            );
2009
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2010
-            return false;
2011
-        }
2012
-        $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID);
2013
-        // clean status
2014
-        $event_status = sanitize_key($event_status);
2015
-        // grab status
2016
-        if (empty($event_status)) {
2017
-            $msg = esc_html__(
2018
-                'An error occurred. No Event Status or an invalid Event Status was received.',
2019
-                'event_espresso'
2020
-            );
2021
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2022
-            return false;
2023
-        }
2024
-        // was event trashed or restored ?
2025
-        switch ($event_status) {
2026
-            case 'draft' :
2027
-                $action = 'restored from the trash';
2028
-                $hook = 'AHEE_event_restored_from_trash';
2029
-                break;
2030
-            case 'trash' :
2031
-                $action = 'moved to the trash';
2032
-                $hook = 'AHEE_event_moved_to_trash';
2033
-                break;
2034
-            default :
2035
-                $action = 'updated';
2036
-                $hook = false;
2037
-        }
2038
-        //use class to change status
2039
-        $this->_cpt_model_obj->set_status($event_status);
2040
-        $success = $this->_cpt_model_obj->save();
2041
-        if ($success === false) {
2042
-            $msg = sprintf(esc_html__('An error occurred. The event could not be %s.', 'event_espresso'), $action);
2043
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2044
-            return false;
2045
-        }
2046
-        if ($hook) {
2047
-            do_action($hook);
2048
-        }
2049
-        return true;
2050
-    }
2051
-
2052
-
2053
-
2054
-    /**
2055
-     * _delete_event
2056
-     *
2057
-     * @access protected
2058
-     * @param bool $redirect_after
2059
-     */
2060
-    protected function _delete_event($redirect_after = true)
2061
-    {
2062
-        //determine the event id and set to array.
2063
-        $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : null;
2064
-        $EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID;
2065
-        // loop thru events
2066
-        if ($EVT_ID) {
2067
-            $success = $this->_permanently_delete_event($EVT_ID);
2068
-            // get list of events with no prices
2069
-            $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array());
2070
-            // remove this event from the list of events with no prices
2071
-            if (isset($espresso_no_ticket_prices[$EVT_ID])) {
2072
-                unset($espresso_no_ticket_prices[$EVT_ID]);
2073
-            }
2074
-            update_option('ee_no_ticket_prices', $espresso_no_ticket_prices);
2075
-        } else {
2076
-            $success = false;
2077
-            $msg = esc_html__(
2078
-                'An error occurred. An event could not be deleted because a valid event ID was not not supplied.',
2079
-                'event_espresso'
2080
-            );
2081
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2082
-        }
2083
-        if ($redirect_after) {
2084
-            $this->_redirect_after_action(
2085
-                $success,
2086
-                'Event',
2087
-                'deleted',
2088
-                array('action' => 'default', 'status' => 'trash')
2089
-            );
2090
-        }
2091
-    }
2092
-
2093
-
2094
-
2095
-    /**
2096
-     * _delete_events
2097
-     *
2098
-     * @access protected
2099
-     * @return void
2100
-     */
2101
-    protected function _delete_events()
2102
-    {
2103
-        $success = true;
2104
-        // get list of events with no prices
2105
-        $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array());
2106
-        //determine the event id and set to array.
2107
-        $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array();
2108
-        // loop thru events
2109
-        foreach ($EVT_IDs as $EVT_ID) {
2110
-            $EVT_ID = absint($EVT_ID);
2111
-            if ($EVT_ID) {
2112
-                $results = $this->_permanently_delete_event($EVT_ID);
2113
-                $success = $results !== false ? $success : false;
2114
-                // remove this event from the list of events with no prices
2115
-                unset($espresso_no_ticket_prices[$EVT_ID]);
2116
-            } else {
2117
-                $success = false;
2118
-                $msg = esc_html__(
2119
-                    'An error occurred. An event could not be deleted because a valid event ID was not not supplied.',
2120
-                    'event_espresso'
2121
-                );
2122
-                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2123
-            }
2124
-        }
2125
-        update_option('ee_no_ticket_prices', $espresso_no_ticket_prices);
2126
-        // in order to force a pluralized result message we need to send back a success status greater than 1
2127
-        $success = $success ? 2 : false;
2128
-        $this->_redirect_after_action($success, 'Events', 'deleted', array('action' => 'default'));
2129
-    }
2130
-
2131
-
2132
-
2133
-    /**
2134
-     * _permanently_delete_event
2135
-     *
2136
-     * @access  private
2137
-     * @param  int $EVT_ID
2138
-     * @return bool
2139
-     */
2140
-    private function _permanently_delete_event($EVT_ID = 0)
2141
-    {
2142
-        // grab event id
2143
-        if ( ! $EVT_ID) {
2144
-            $msg = esc_html__(
2145
-                'An error occurred. No Event ID or an invalid Event ID was received.',
2146
-                'event_espresso'
2147
-            );
2148
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2149
-            return false;
2150
-        }
2151
-        if (
2152
-            ! $this->_cpt_model_obj instanceof EE_Event
2153
-            || $this->_cpt_model_obj->ID() !== $EVT_ID
2154
-        ) {
2155
-            $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID);
2156
-        }
2157
-        if ( ! $this->_cpt_model_obj instanceof EE_Event) {
2158
-            return false;
2159
-        }
2160
-        //need to delete related tickets and prices first.
2161
-        $datetimes = $this->_cpt_model_obj->get_many_related('Datetime');
2162
-        foreach ($datetimes as $datetime) {
2163
-            $this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime');
2164
-            $tickets = $datetime->get_many_related('Ticket');
2165
-            foreach ($tickets as $ticket) {
2166
-                $ticket->_remove_relation_to($datetime, 'Datetime');
2167
-                $ticket->delete_related_permanently('Price');
2168
-                $ticket->delete_permanently();
2169
-            }
2170
-            $datetime->delete();
2171
-        }
2172
-        //what about related venues or terms?
2173
-        $venues = $this->_cpt_model_obj->get_many_related('Venue');
2174
-        foreach ($venues as $venue) {
2175
-            $this->_cpt_model_obj->_remove_relation_to($venue, 'Venue');
2176
-        }
2177
-        //any attached question groups?
2178
-        $question_groups = $this->_cpt_model_obj->get_many_related('Question_Group');
2179
-        if ( ! empty($question_groups)) {
2180
-            foreach ($question_groups as $question_group) {
2181
-                $this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group');
2182
-            }
2183
-        }
2184
-        //Message Template Groups
2185
-        $this->_cpt_model_obj->_remove_relations('Message_Template_Group');
2186
-        /** @type EE_Term_Taxonomy[] $term_taxonomies */
2187
-        $term_taxonomies = $this->_cpt_model_obj->term_taxonomies();
2188
-        foreach ($term_taxonomies as $term_taxonomy) {
2189
-            $this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy);
2190
-        }
2191
-        $success = $this->_cpt_model_obj->delete_permanently();
2192
-        // did it all go as planned ?
2193
-        if ($success) {
2194
-            $msg = sprintf(esc_html__('Event ID # %d has been deleted.', 'event_espresso'), $EVT_ID);
2195
-            EE_Error::add_success($msg);
2196
-        } else {
2197
-            $msg = sprintf(
2198
-                esc_html__('An error occurred. Event ID # %d could not be deleted.', 'event_espresso'),
2199
-                $EVT_ID
2200
-            );
2201
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2202
-            return false;
2203
-        }
2204
-        do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID);
2205
-        return true;
2206
-    }
2207
-
2208
-
2209
-
2210
-    /**
2211
-     * get total number of events
2212
-     *
2213
-     * @access public
2214
-     * @return int
2215
-     */
2216
-    public function total_events()
2217
-    {
2218
-        $count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true);
2219
-        return $count;
2220
-    }
2221
-
2222
-
2223
-
2224
-    /**
2225
-     * get total number of draft events
2226
-     *
2227
-     * @access public
2228
-     * @return int
2229
-     */
2230
-    public function total_events_draft()
2231
-    {
2232
-        $where = array(
2233
-            'status' => array('IN', array('draft', 'auto-draft')),
2234
-        );
2235
-        $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
2236
-        return $count;
2237
-    }
2238
-
2239
-
2240
-
2241
-    /**
2242
-     * get total number of trashed events
2243
-     *
2244
-     * @access public
2245
-     * @return int
2246
-     */
2247
-    public function total_trashed_events()
2248
-    {
2249
-        $where = array(
2250
-            'status' => 'trash',
2251
-        );
2252
-        $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
2253
-        return $count;
2254
-    }
2255
-
2256
-
2257
-    /**
2258
-     *    _default_event_settings
2259
-     *    This generates the Default Settings Tab
2260
-     *
2261
-     * @return void
2262
-     * @throws \EE_Error
2263
-     */
2264
-    protected function _default_event_settings()
2265
-    {
2266
-        $this->_set_add_edit_form_tags('update_default_event_settings');
2267
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
2268
-        $this->_template_args['admin_page_content'] = $this->_default_event_settings_form()->get_html();
2269
-        $this->display_admin_page_with_sidebar();
2270
-    }
2271
-
2272
-
2273
-    /**
2274
-     * Return the form for event settings.
2275
-     * @return \EE_Form_Section_Proper
2276
-     */
2277
-    protected function _default_event_settings_form()
2278
-    {
2279
-        $registration_config = EE_Registry::instance()->CFG->registration;
2280
-        $registration_stati_for_selection = EEM_Registration::reg_status_array(
2281
-        //exclude
2282
-            array(
2283
-                EEM_Registration::status_id_cancelled,
2284
-                EEM_Registration::status_id_declined,
2285
-                EEM_Registration::status_id_incomplete,
2286
-                EEM_Registration::status_id_wait_list,
2287
-            ),
2288
-            true
2289
-        );
2290
-        return new EE_Form_Section_Proper(
2291
-            array(
2292
-                'name' => 'update_default_event_settings',
2293
-                'html_id' => 'update_default_event_settings',
2294
-                'html_class' => 'form-table',
2295
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
2296
-                'subsections' => apply_filters(
2297
-                    'FHEE__Events_Admin_Page___default_event_settings_form__form_subsections',
2298
-                    array(
2299
-                        'default_reg_status' => new EE_Select_Input(
2300
-                            $registration_stati_for_selection,
2301
-                            array(
2302
-                                'default' => isset($registration_config->default_STS_ID)
2303
-                                             && array_key_exists(
2304
-                                                $registration_config->default_STS_ID,
2305
-                                                $registration_stati_for_selection
2306
-                                             )
2307
-                                            ? sanitize_text_field($registration_config->default_STS_ID)
2308
-                                            : EEM_Registration::status_id_pending_payment,
2309
-                                'html_label_text' => esc_html__('Default Registration Status', 'event_espresso')
2310
-                                                    . EEH_Template::get_help_tab_link(
2311
-                                                        'default_settings_status_help_tab'
2312
-                                                    ),
2313
-                                'html_help_text' => esc_html__(
2314
-                                    '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.',
2315
-                                    'event_espresso'
2316
-                                )
2317
-                            )
2318
-                        ),
2319
-                        'default_max_tickets' => new EE_Integer_Input(
2320
-                            array(
2321
-                                'default' => isset($registration_config->default_maximum_number_of_tickets)
2322
-                                    ? $registration_config->default_maximum_number_of_tickets
2323
-                                    : EEM_Event::get_default_additional_limit(),
2324
-                                'html_label_text' => esc_html__(
2325
-                                    'Default Maximum Tickets Allowed Per Order:',
2326
-                                    'event_espresso'
2327
-                                ) . EEH_Template::get_help_tab_link(
2328
-                                    'default_maximum_tickets_help_tab"'
2329
-                                    ),
2330
-                                'html_help_text' => esc_html__(
2331
-                                    'This setting allows you to indicate what will be the default for the maximum number of tickets per order when creating new events.',
2332
-                                    'event_espresso'
2333
-                                )
2334
-                            )
2335
-                        )
2336
-                    )
2337
-                )
2338
-            )
2339
-        );
2340
-    }
2341
-
2342
-
2343
-    /**
2344
-     * _update_default_event_settings
2345
-     *
2346
-     * @access protected
2347
-     * @return void
2348
-     * @throws \EE_Error
2349
-     */
2350
-    protected function _update_default_event_settings()
2351
-    {
2352
-        $registration_config = EE_Registry::instance()->CFG->registration;
2353
-        $form = $this->_default_event_settings_form();
2354
-        if ($form->was_submitted()) {
2355
-            $form->receive_form_submission();
2356
-            if ($form->is_valid()) {
2357
-                $valid_data = $form->valid_data();
2358
-                if (isset($valid_data['default_reg_status'])) {
2359
-                    $registration_config->default_STS_ID = $valid_data['default_reg_status'];
2360
-                }
2361
-                if (isset($valid_data['default_max_tickets'])) {
2362
-                    $registration_config->default_maximum_number_of_tickets = $valid_data['default_max_tickets'];
2363
-                }
2364
-                //update because data was valid!
2365
-                EE_Registry::instance()->CFG->update_espresso_config();
2366
-                EE_Error::overwrite_success();
2367
-                EE_Error::add_success(
2368
-                    __('Default Event Settings were updated', 'event_espresso')
2369
-                );
2370
-            }
2371
-        }
2372
-        $this->_redirect_after_action(0, '', '', array('action' => 'default_event_settings'), true);
2373
-    }
2374
-
2375
-
2376
-
2377
-    /*************        Templates        *************/
2378
-    protected function _template_settings()
2379
-    {
2380
-        $this->_admin_page_title = esc_html__('Template Settings (Preview)', 'event_espresso');
2381
-        $this->_template_args['preview_img'] = '<img src="'
2382
-                                               . EVENTS_ASSETS_URL
2383
-                                               . DS
2384
-                                               . 'images'
2385
-                                               . DS
2386
-                                               . 'caffeinated_template_features.jpg" alt="'
2387
-                                               . esc_attr__('Template Settings Preview screenshot', 'event_espresso')
2388
-                                               . '" />';
2389
-        $this->_template_args['preview_text'] = '<strong>' . esc_html__(
2390
-                '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.',
2391
-                'event_espresso'
2392
-            ) . '</strong>';
2393
-        $this->display_admin_caf_preview_page('template_settings_tab');
2394
-    }
2395
-
2396
-
2397
-    /** Event Category Stuff **/
2398
-    /**
2399
-     * set the _category property with the category object for the loaded page.
2400
-     *
2401
-     * @access private
2402
-     * @return void
2403
-     */
2404
-    private function _set_category_object()
2405
-    {
2406
-        if (isset($this->_category->id) && ! empty($this->_category->id)) {
2407
-            return;
2408
-        } //already have the category object so get out.
2409
-        //set default category object
2410
-        $this->_set_empty_category_object();
2411
-        //only set if we've got an id
2412
-        if ( ! isset($this->_req_data['EVT_CAT_ID'])) {
2413
-            return;
2414
-        }
2415
-        $category_id = absint($this->_req_data['EVT_CAT_ID']);
2416
-        $term = get_term($category_id, 'espresso_event_categories');
2417
-        if ( ! empty($term)) {
2418
-            $this->_category->category_name = $term->name;
2419
-            $this->_category->category_identifier = $term->slug;
2420
-            $this->_category->category_desc = $term->description;
2421
-            $this->_category->id = $term->term_id;
2422
-            $this->_category->parent = $term->parent;
2423
-        }
2424
-    }
2425
-
2426
-
2427
-
2428
-    private function _set_empty_category_object()
2429
-    {
2430
-        $this->_category = new stdClass();
2431
-        $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = '';
2432
-        $this->_category->id = $this->_category->parent = 0;
2433
-    }
2434
-
2435
-
2436
-
2437
-    protected function _category_list_table()
2438
-    {
2439
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2440
-        $this->_search_btn_label = esc_html__('Categories', 'event_espresso');
2441
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
2442
-                'add_category',
2443
-                'add_category',
2444
-                array(),
2445
-                'add-new-h2'
2446
-            );
2447
-        $this->display_admin_list_table_page_with_sidebar();
2448
-    }
2449
-
2450
-
2451
-
2452
-    /**
2453
-     * @param $view
2454
-     */
2455
-    protected function _category_details($view)
2456
-    {
2457
-        //load formatter helper
2458
-        //load field generator helper
2459
-        $route = $view == 'edit' ? 'update_category' : 'insert_category';
2460
-        $this->_set_add_edit_form_tags($route);
2461
-        $this->_set_category_object();
2462
-        $id = ! empty($this->_category->id) ? $this->_category->id : '';
2463
-        $delete_action = 'delete_category';
2464
-        //custom redirect
2465
-        $redirect = EE_Admin_Page::add_query_args_and_nonce(
2466
-            array('action' => 'category_list'),
2467
-            $this->_admin_base_url
2468
-        );
2469
-        $this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect);
2470
-        //take care of contents
2471
-        $this->_template_args['admin_page_content'] = $this->_category_details_content();
2472
-        $this->display_admin_page_with_sidebar();
2473
-    }
2474
-
2475
-
2476
-
2477
-    /**
2478
-     * @return mixed
2479
-     */
2480
-    protected function _category_details_content()
2481
-    {
2482
-        $editor_args['category_desc'] = array(
2483
-            'type'          => 'wp_editor',
2484
-            'value'         => EEH_Formatter::admin_format_content($this->_category->category_desc),
2485
-            'class'         => 'my_editor_custom',
2486
-            'wpeditor_args' => array('media_buttons' => false),
2487
-        );
2488
-        $_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array');
2489
-        $all_terms = get_terms(
2490
-            array('espresso_event_categories'),
2491
-            array('hide_empty' => 0, 'exclude' => array($this->_category->id))
2492
-        );
2493
-        //setup category select for term parents.
2494
-        $category_select_values[] = array(
2495
-            'text' => esc_html__('No Parent', 'event_espresso'),
2496
-            'id'   => 0,
2497
-        );
2498
-        foreach ($all_terms as $term) {
2499
-            $category_select_values[] = array(
2500
-                'text' => $term->name,
2501
-                'id'   => $term->term_id,
2502
-            );
2503
-        }
2504
-        $category_select = EEH_Form_Fields::select_input(
2505
-            'category_parent',
2506
-            $category_select_values,
2507
-            $this->_category->parent
2508
-        );
2509
-        $template_args = array(
2510
-            'category'                 => $this->_category,
2511
-            'category_select'          => $category_select,
2512
-            'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'),
2513
-            'category_desc_editor'     => $_wp_editor['category_desc']['field'],
2514
-            'disable'                  => '',
2515
-            'disabled_message'         => false,
2516
-        );
2517
-        $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php';
2518
-        return EEH_Template::display_template($template, $template_args, true);
2519
-    }
2520
-
2521
-
2522
-
2523
-    protected function _delete_categories()
2524
-    {
2525
-        $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array)$this->_req_data['EVT_CAT_ID']
2526
-            : (array)$this->_req_data['category_id'];
2527
-        foreach ($cat_ids as $cat_id) {
2528
-            $this->_delete_category($cat_id);
2529
-        }
2530
-        //doesn't matter what page we're coming from... we're going to the same place after delete.
2531
-        $query_args = array(
2532
-            'action' => 'category_list',
2533
-        );
2534
-        $this->_redirect_after_action(0, '', '', $query_args);
2535
-    }
2536
-
2537
-
2538
-
2539
-    /**
2540
-     * @param $cat_id
2541
-     */
2542
-    protected function _delete_category($cat_id)
2543
-    {
2544
-        $cat_id = absint($cat_id);
2545
-        wp_delete_term($cat_id, 'espresso_event_categories');
2546
-    }
2547
-
2548
-
2549
-
2550
-    /**
2551
-     * @param $new_category
2552
-     */
2553
-    protected function _insert_or_update_category($new_category)
2554
-    {
2555
-        $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(true);
2556
-        $success = 0; //we already have a success message so lets not send another.
2557
-        if ($cat_id) {
2558
-            $query_args = array(
2559
-                'action'     => 'edit_category',
2560
-                'EVT_CAT_ID' => $cat_id,
2561
-            );
2562
-        } else {
2563
-            $query_args = array('action' => 'add_category');
2564
-        }
2565
-        $this->_redirect_after_action($success, '', '', $query_args, true);
2566
-    }
2567
-
2568
-
2569
-
2570
-    /**
2571
-     * @param bool $update
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
-    /**
2614
-     * @param int  $per_page
2615
-     * @param int  $current_page
2616
-     * @param bool $count
2617
-     * @return \EE_Base_Class[]|int
2618
-     */
2619
-    public function get_categories($per_page = 10, $current_page = 1, $count = false)
2620
-    {
2621
-        //testing term stuff
2622
-        $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id';
2623
-        $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC';
2624
-        $limit = ($current_page - 1) * $per_page;
2625
-        $where = array('taxonomy' => 'espresso_event_categories');
2626
-        if (isset($this->_req_data['s'])) {
2627
-            $sstr = '%' . $this->_req_data['s'] . '%';
2628
-            $where['OR'] = array(
2629
-                'Term.name'   => array('LIKE', $sstr),
2630
-                'description' => array('LIKE', $sstr),
2631
-            );
2632
-        }
2633
-        $query_params = array(
2634
-            $where,
2635
-            'order_by'   => array($orderby => $order),
2636
-            'limit'      => $limit . ',' . $per_page,
2637
-            'force_join' => array('Term'),
2638
-        );
2639
-        $categories = $count
2640
-            ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id')
2641
-            : EEM_Term_Taxonomy::instance()->get_all($query_params);
2642
-        return $categories;
2643
-    }
2644
-
2645
-
2646
-
2647
-    /* end category stuff */
2648
-    /**************/
385
+				'qtips'         => array('EE_Event_Editor_Decaf_Tips'),
386
+				'require_nonce' => false,
387
+			),
388
+			'default_event_settings' => array(
389
+				'nav'           => array(
390
+					'label' => esc_html__('Default Settings', 'event_espresso'),
391
+					'order' => 40,
392
+				),
393
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
394
+				'labels'        => array(
395
+					'publishbox' => esc_html__('Update Settings', 'event_espresso'),
396
+				),
397
+				'help_tabs'     => array(
398
+					'default_settings_help_tab'        => array(
399
+						'title'    => esc_html__('Default Event Settings', 'event_espresso'),
400
+						'filename' => 'events_default_settings',
401
+					),
402
+					'default_settings_status_help_tab' => array(
403
+						'title'    => esc_html__('Default Registration Status', 'event_espresso'),
404
+						'filename' => 'events_default_settings_status',
405
+					),
406
+					'default_maximum_tickets_help_tab' => array(
407
+						'title' => esc_html__('Default Maximum Tickets Per Order', 'event_espresso'),
408
+						'filename' => 'events_default_settings_max_tickets',
409
+					)
410
+				),
411
+				'help_tour'     => array('Event_Default_Settings_Help_Tour'),
412
+				'require_nonce' => false,
413
+			),
414
+			//template settings
415
+			'template_settings'      => array(
416
+				'nav'           => array(
417
+					'label' => esc_html__('Templates', 'event_espresso'),
418
+					'order' => 30,
419
+				),
420
+				'metaboxes'     => $this->_default_espresso_metaboxes,
421
+				'help_tabs'     => array(
422
+					'general_settings_templates_help_tab' => array(
423
+						'title'    => esc_html__('Templates', 'event_espresso'),
424
+						'filename' => 'general_settings_templates',
425
+					),
426
+				),
427
+				'help_tour'     => array('Templates_Help_Tour'),
428
+				'require_nonce' => false,
429
+			),
430
+			//event category stuff
431
+			'add_category'           => array(
432
+				'nav'           => array(
433
+					'label'      => esc_html__('Add Category', 'event_espresso'),
434
+					'order'      => 15,
435
+					'persistent' => false,
436
+				),
437
+				'help_tabs'     => array(
438
+					'add_category_help_tab' => array(
439
+						'title'    => esc_html__('Add New Event Category', 'event_espresso'),
440
+						'filename' => 'events_add_category',
441
+					),
442
+				),
443
+				'help_tour'     => array('Event_Add_Category_Help_Tour'),
444
+				'metaboxes'     => array('_publish_post_box'),
445
+				'require_nonce' => false,
446
+			),
447
+			'edit_category'          => array(
448
+				'nav'           => array(
449
+					'label'      => esc_html__('Edit Category', 'event_espresso'),
450
+					'order'      => 15,
451
+					'persistent' => false,
452
+					'url'        => isset($this->_req_data['EVT_CAT_ID'])
453
+						? add_query_arg(
454
+							array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']),
455
+							$this->_current_page_view_url
456
+						)
457
+						: $this->_admin_base_url,
458
+				),
459
+				'help_tabs'     => array(
460
+					'edit_category_help_tab' => array(
461
+						'title'    => esc_html__('Edit Event Category', 'event_espresso'),
462
+						'filename' => 'events_edit_category',
463
+					),
464
+				),
465
+				/*'help_tour' => array('Event_Edit_Category_Help_Tour'),*/
466
+				'metaboxes'     => array('_publish_post_box'),
467
+				'require_nonce' => false,
468
+			),
469
+			'category_list'          => array(
470
+				'nav'           => array(
471
+					'label' => esc_html__('Categories', 'event_espresso'),
472
+					'order' => 20,
473
+				),
474
+				'list_table'    => 'Event_Categories_Admin_List_Table',
475
+				'help_tabs'     => array(
476
+					'events_categories_help_tab'                       => array(
477
+						'title'    => esc_html__('Event Categories', 'event_espresso'),
478
+						'filename' => 'events_categories',
479
+					),
480
+					'events_categories_table_column_headings_help_tab' => array(
481
+						'title'    => esc_html__('Event Categories Table Column Headings', 'event_espresso'),
482
+						'filename' => 'events_categories_table_column_headings',
483
+					),
484
+					'events_categories_view_help_tab'                  => array(
485
+						'title'    => esc_html__('Event Categories Views', 'event_espresso'),
486
+						'filename' => 'events_categories_views',
487
+					),
488
+					'events_categories_other_help_tab'                 => array(
489
+						'title'    => esc_html__('Event Categories Other', 'event_espresso'),
490
+						'filename' => 'events_categories_other',
491
+					),
492
+				),
493
+				'help_tour'     => array(
494
+					'Event_Categories_Help_Tour',
495
+				),
496
+				'metaboxes'     => $this->_default_espresso_metaboxes,
497
+				'require_nonce' => false,
498
+			),
499
+		);
500
+	}
501
+
502
+
503
+
504
+	protected function _add_screen_options()
505
+	{
506
+		//todo
507
+	}
508
+
509
+
510
+
511
+	protected function _add_screen_options_default()
512
+	{
513
+		$this->_per_page_screen_option();
514
+	}
515
+
516
+
517
+
518
+	protected function _add_screen_options_category_list()
519
+	{
520
+		$page_title = $this->_admin_page_title;
521
+		$this->_admin_page_title = esc_html__('Categories', 'event_espresso');
522
+		$this->_per_page_screen_option();
523
+		$this->_admin_page_title = $page_title;
524
+	}
525
+
526
+
527
+
528
+	protected function _add_feature_pointers()
529
+	{
530
+		//todo
531
+	}
532
+
533
+
534
+
535
+	public function load_scripts_styles()
536
+	{
537
+		wp_register_style(
538
+			'events-admin-css',
539
+			EVENTS_ASSETS_URL . 'events-admin-page.css',
540
+			array(),
541
+			EVENT_ESPRESSO_VERSION
542
+		);
543
+		wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION);
544
+		wp_enqueue_style('events-admin-css');
545
+		wp_enqueue_style('ee-cat-admin');
546
+		//todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details
547
+		//registers for all views
548
+		//scripts
549
+		wp_register_script(
550
+			'event_editor_js',
551
+			EVENTS_ASSETS_URL . 'event_editor.js',
552
+			array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'),
553
+			EVENT_ESPRESSO_VERSION,
554
+			true
555
+		);
556
+	}
557
+
558
+
559
+
560
+	/**
561
+	 * enqueuing scripts and styles specific to this view
562
+	 *
563
+	 * @return void
564
+	 */
565
+	public function load_scripts_styles_create_new()
566
+	{
567
+		$this->load_scripts_styles_edit();
568
+	}
569
+
570
+
571
+
572
+	/**
573
+	 * enqueuing scripts and styles specific to this view
574
+	 *
575
+	 * @return void
576
+	 */
577
+	public function load_scripts_styles_edit()
578
+	{
579
+		//styles
580
+		wp_enqueue_style('espresso-ui-theme');
581
+		wp_register_style(
582
+			'event-editor-css',
583
+			EVENTS_ASSETS_URL . 'event-editor.css',
584
+			array('ee-admin-css'),
585
+			EVENT_ESPRESSO_VERSION
586
+		);
587
+		wp_enqueue_style('event-editor-css');
588
+		//scripts
589
+		wp_register_script(
590
+			'event-datetime-metabox',
591
+			EVENTS_ASSETS_URL . 'event-datetime-metabox.js',
592
+			array('event_editor_js', 'ee-datepicker'),
593
+			EVENT_ESPRESSO_VERSION
594
+		);
595
+		wp_enqueue_script('event-datetime-metabox');
596
+	}
597
+
598
+
599
+
600
+	public function load_scripts_styles_add_category()
601
+	{
602
+		$this->load_scripts_styles_edit_category();
603
+	}
604
+
605
+
606
+
607
+	public function load_scripts_styles_edit_category()
608
+	{
609
+	}
610
+
611
+
612
+
613
+	protected function _set_list_table_views_category_list()
614
+	{
615
+		$this->_views = array(
616
+			'all' => array(
617
+				'slug'        => 'all',
618
+				'label'       => esc_html__('All', 'event_espresso'),
619
+				'count'       => 0,
620
+				'bulk_action' => array(
621
+					'delete_categories' => esc_html__('Delete Permanently', 'event_espresso'),
622
+				),
623
+			),
624
+		);
625
+	}
626
+
627
+
628
+
629
+	public function admin_init()
630
+	{
631
+		EE_Registry::$i18n_js_strings['image_confirm'] = esc_html__(
632
+			'Do you really want to delete this image? Please remember to update your event to complete the removal.',
633
+			'event_espresso'
634
+		);
635
+	}
636
+
637
+
638
+
639
+	//nothing needed for events with these methods.
640
+	public function admin_notices()
641
+	{
642
+	}
643
+
644
+
645
+
646
+	public function admin_footer_scripts()
647
+	{
648
+	}
649
+
650
+
651
+
652
+	/**
653
+	 * Call this function to verify if an event is public and has tickets for sale.  If it does, then we need to show a
654
+	 * warning (via EE_Error::add_error());
655
+	 *
656
+	 * @param  EE_Event $event Event object
657
+	 * @access public
658
+	 * @return void
659
+	 */
660
+	public function verify_event_edit($event = null)
661
+	{
662
+		// no event?
663
+		if (empty($event)) {
664
+			// set event
665
+			$event = $this->_cpt_model_obj;
666
+		}
667
+		// STILL no event?
668
+		if (empty ($event)) {
669
+			return;
670
+		}
671
+		$orig_status = $event->status();
672
+		// first check if event is active.
673
+		if (
674
+			$orig_status === EEM_Event::cancelled
675
+			|| $orig_status === EEM_Event::postponed
676
+			|| $event->is_expired()
677
+			|| $event->is_inactive()
678
+		) {
679
+			return;
680
+		}
681
+		//made it here so it IS active... next check that any of the tickets are sold.
682
+		if ($event->is_sold_out(true)) {
683
+			if ($orig_status !== EEM_Event::sold_out && $event->status() !== $orig_status) {
684
+				EE_Error::add_attention(
685
+					sprintf(
686
+						esc_html__(
687
+							'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.',
688
+							'event_espresso'
689
+						),
690
+						EEH_Template::pretty_status(EEM_Event::sold_out, false, 'sentence')
691
+					)
692
+				);
693
+			}
694
+			return;
695
+		} else if ($orig_status === EEM_Event::sold_out) {
696
+			EE_Error::add_attention(
697
+				sprintf(
698
+					esc_html__(
699
+						'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.',
700
+						'event_espresso'
701
+					),
702
+					EEH_Template::pretty_status($event->status(), false, 'sentence')
703
+				)
704
+			);
705
+		}
706
+		//now we need to determine if the event has any tickets on sale.  If not then we dont' show the error
707
+		if ( ! $event->tickets_on_sale()) {
708
+			return;
709
+		}
710
+		//made it here so show warning
711
+		$this->_edit_event_warning();
712
+	}
713
+
714
+
715
+
716
+	/**
717
+	 * This is the text used for when an event is being edited that is public and has tickets for sale.
718
+	 * When needed, hook this into a EE_Error::add_error() notice.
719
+	 *
720
+	 * @access protected
721
+	 * @return void
722
+	 */
723
+	protected function _edit_event_warning()
724
+	{
725
+		// we don't want to add warnings during these requests
726
+		if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'editpost') {
727
+			return;
728
+		}
729
+		EE_Error::add_attention(
730
+			esc_html__(
731
+				'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.',
732
+				'event_espresso'
733
+			)
734
+		);
735
+	}
736
+
737
+
738
+
739
+	/**
740
+	 * When a user is creating a new event, notify them if they haven't set their timezone.
741
+	 * Otherwise, do the normal logic
742
+	 *
743
+	 * @return string
744
+	 * @throws \EE_Error
745
+	 */
746
+	protected function _create_new_cpt_item()
747
+	{
748
+		$gmt_offset = get_option('gmt_offset');
749
+		//only nag them about setting their timezone if it's their first event, and they haven't already done it
750
+		if ($gmt_offset === '0' && ! EEM_Event::instance()->exists(array())) {
751
+			EE_Error::add_attention(
752
+				sprintf(
753
+					__(
754
+						'Your website\'s timezone is currently set to UTC + 0. We recommend updating your timezone to a city or region near you before you create an event. Your timezone can be updated through the %1$sGeneral Settings%2$s page.',
755
+						'event_espresso'
756
+					),
757
+					'<a href="' . admin_url('options-general.php') . '">',
758
+					'</a>'
759
+				),
760
+				__FILE__,
761
+				__FUNCTION__,
762
+				__LINE__
763
+			);
764
+		}
765
+		return parent::_create_new_cpt_item();
766
+	}
767
+
768
+
769
+
770
+	protected function _set_list_table_views_default()
771
+	{
772
+		$this->_views = array(
773
+			'all'   => array(
774
+				'slug'        => 'all',
775
+				'label'       => esc_html__('View All Events', 'event_espresso'),
776
+				'count'       => 0,
777
+				'bulk_action' => array(
778
+					'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
779
+				),
780
+			),
781
+			'draft' => array(
782
+				'slug'        => 'draft',
783
+				'label'       => esc_html__('Draft', 'event_espresso'),
784
+				'count'       => 0,
785
+				'bulk_action' => array(
786
+					'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
787
+				),
788
+			),
789
+		);
790
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) {
791
+			$this->_views['trash'] = array(
792
+				'slug'        => 'trash',
793
+				'label'       => esc_html__('Trash', 'event_espresso'),
794
+				'count'       => 0,
795
+				'bulk_action' => array(
796
+					'restore_events' => esc_html__('Restore From Trash', 'event_espresso'),
797
+					'delete_events'  => esc_html__('Delete Permanently', 'event_espresso'),
798
+				),
799
+			);
800
+		}
801
+	}
802
+
803
+
804
+
805
+	/**
806
+	 * @return array
807
+	 */
808
+	protected function _event_legend_items()
809
+	{
810
+		$items = array(
811
+			'view_details'   => array(
812
+				'class' => 'dashicons dashicons-search',
813
+				'desc'  => esc_html__('View Event', 'event_espresso'),
814
+			),
815
+			'edit_event'     => array(
816
+				'class' => 'ee-icon ee-icon-calendar-edit',
817
+				'desc'  => esc_html__('Edit Event Details', 'event_espresso'),
818
+			),
819
+			'view_attendees' => array(
820
+				'class' => 'dashicons dashicons-groups',
821
+				'desc'  => esc_html__('View Registrations for Event', 'event_espresso'),
822
+			),
823
+		);
824
+		$items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items);
825
+		$statuses = array(
826
+			'sold_out_status'  => array(
827
+				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out,
828
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::sold_out, false, 'sentence'),
829
+			),
830
+			'active_status'    => array(
831
+				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active,
832
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::active, false, 'sentence'),
833
+			),
834
+			'upcoming_status'  => array(
835
+				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming,
836
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::upcoming, false, 'sentence'),
837
+			),
838
+			'postponed_status' => array(
839
+				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed,
840
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::postponed, false, 'sentence'),
841
+			),
842
+			'cancelled_status' => array(
843
+				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled,
844
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::cancelled, false, 'sentence'),
845
+			),
846
+			'expired_status'   => array(
847
+				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired,
848
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::expired, false, 'sentence'),
849
+			),
850
+			'inactive_status'  => array(
851
+				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive,
852
+				'desc'  => EEH_Template::pretty_status(EE_Datetime::inactive, false, 'sentence'),
853
+			),
854
+		);
855
+		$statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses);
856
+		return array_merge($items, $statuses);
857
+	}
858
+
859
+
860
+
861
+	/**
862
+	 * _event_model
863
+	 *
864
+	 * @return EEM_Event
865
+	 */
866
+	private function _event_model()
867
+	{
868
+		if ( ! $this->_event_model instanceof EEM_Event) {
869
+			$this->_event_model = EE_Registry::instance()->load_model('Event');
870
+		}
871
+		return $this->_event_model;
872
+	}
873
+
874
+
875
+
876
+	/**
877
+	 * Adds extra buttons to the WP CPT permalink field row.
878
+	 * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter.
879
+	 *
880
+	 * @param  string $return    the current html
881
+	 * @param  int    $id        the post id for the page
882
+	 * @param  string $new_title What the title is
883
+	 * @param  string $new_slug  what the slug is
884
+	 * @return string            The new html string for the permalink area
885
+	 */
886
+	public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug)
887
+	{
888
+		//make sure this is only when editing
889
+		if ( ! empty($id)) {
890
+			$post = get_post($id);
891
+			$return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#"  tabindex="-1">'
892
+					   . esc_html__('Shortcode', 'event_espresso')
893
+					   . '</a> ';
894
+			$return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id='
895
+					   . $post->ID
896
+					   . ']">';
897
+		}
898
+		return $return;
899
+	}
900
+
901
+
902
+
903
+	/**
904
+	 * _events_overview_list_table
905
+	 * This contains the logic for showing the events_overview list
906
+	 *
907
+	 * @access protected
908
+	 * @return void
909
+	 * @throws \EE_Error
910
+	 */
911
+	protected function _events_overview_list_table()
912
+	{
913
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
914
+		$this->_template_args['after_list_table'] = ! empty($this->_template_args['after_list_table'])
915
+			? (array)$this->_template_args['after_list_table']
916
+			: array();
917
+		$this->_template_args['after_list_table']['view_event_list_button'] = EEH_HTML::br()
918
+																			  . EEH_Template::get_button_or_link(
919
+				get_post_type_archive_link('espresso_events'),
920
+				esc_html__("View Event Archive Page", "event_espresso"),
921
+				'button'
922
+			);
923
+		$this->_template_args['after_list_table']['legend'] = $this->_display_legend($this->_event_legend_items());
924
+		$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
925
+				'create_new',
926
+				'add',
927
+				array(),
928
+				'add-new-h2'
929
+			);
930
+		$this->display_admin_list_table_page_with_no_sidebar();
931
+	}
932
+
933
+
934
+
935
+	/**
936
+	 * this allows for extra misc actions in the default WP publish box
937
+	 *
938
+	 * @return void
939
+	 */
940
+	public function extra_misc_actions_publish_box()
941
+	{
942
+		$this->_generate_publish_box_extra_content();
943
+	}
944
+
945
+
946
+
947
+	/**
948
+	 * This is hooked into the WordPress do_action('save_post') hook and runs after the custom post type has been
949
+	 * saved.  Child classes are required to declare this method.  Typically you would use this to save any additional
950
+	 * data.
951
+	 * Keep in mind also that "save_post" runs on EVERY post update to the database.
952
+	 * ALSO very important.  When a post transitions from scheduled to published, the save_post action is fired but you
953
+	 * will NOT have any _POST data containing any extra info you may have from other meta saves.  So MAKE sure that
954
+	 * you handle this accordingly.
955
+	 *
956
+	 * @access protected
957
+	 * @abstract
958
+	 * @param  string $post_id The ID of the cpt that was saved (so you can link relationally)
959
+	 * @param  object $post    The post object of the cpt that was saved.
960
+	 * @return void
961
+	 */
962
+	protected function _insert_update_cpt_item($post_id, $post)
963
+	{
964
+		if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') {
965
+			//get out we're not processing an event save.
966
+			return;
967
+		}
968
+		$event_values = array(
969
+			'EVT_display_desc'                => ! empty($this->_req_data['display_desc']) ? 1 : 0,
970
+			'EVT_display_ticket_selector'     => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0,
971
+			'EVT_additional_limit'            => min(
972
+				apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255),
973
+				! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : null
974
+			),
975
+			'EVT_default_registration_status' => ! empty($this->_req_data['EVT_default_registration_status'])
976
+				? $this->_req_data['EVT_default_registration_status']
977
+				: EE_Registry::instance()->CFG->registration->default_STS_ID,
978
+			'EVT_member_only'                 => ! empty($this->_req_data['member_only']) ? 1 : 0,
979
+			'EVT_allow_overflow'              => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0,
980
+			'EVT_timezone_string'             => ! empty($this->_req_data['timezone_string'])
981
+				? $this->_req_data['timezone_string'] : null,
982
+			'EVT_external_URL'                => ! empty($this->_req_data['externalURL'])
983
+				? $this->_req_data['externalURL'] : null,
984
+			'EVT_phone'                       => ! empty($this->_req_data['event_phone'])
985
+				? $this->_req_data['event_phone'] : null,
986
+		);
987
+		//update event
988
+		$success = $this->_event_model()->update_by_ID($event_values, $post_id);
989
+		//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!
990
+		$get_one_where = array($this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status);
991
+		$event = $this->_event_model()->get_one(array($get_one_where));
992
+		//the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons.
993
+		$event_update_callbacks = apply_filters(
994
+			'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',
995
+			array(array($this, '_default_venue_update'), array($this, '_default_tickets_update'))
996
+		);
997
+		$att_success = true;
998
+		foreach ($event_update_callbacks as $e_callback) {
999
+			$_succ = call_user_func_array($e_callback, array($event, $this->_req_data));
1000
+			$att_success = ! $att_success ? $att_success
1001
+				: $_succ; //if ANY of these updates fail then we want the appropriate global error message
1002
+		}
1003
+		//any errors?
1004
+		if ($success && false === $att_success) {
1005
+			EE_Error::add_error(
1006
+				esc_html__(
1007
+					'Event Details saved successfully but something went wrong with saving attachments.',
1008
+					'event_espresso'
1009
+				),
1010
+				__FILE__,
1011
+				__FUNCTION__,
1012
+				__LINE__
1013
+			);
1014
+		} else if ($success === false) {
1015
+			EE_Error::add_error(
1016
+				esc_html__('Event Details did not save successfully.', 'event_espresso'),
1017
+				__FILE__,
1018
+				__FUNCTION__,
1019
+				__LINE__
1020
+			);
1021
+		}
1022
+	}
1023
+
1024
+
1025
+
1026
+	/**
1027
+	 * @see parent::restore_item()
1028
+	 * @param int $post_id
1029
+	 * @param int $revision_id
1030
+	 */
1031
+	protected function _restore_cpt_item($post_id, $revision_id)
1032
+	{
1033
+		//copy existing event meta to new post
1034
+		$post_evt = $this->_event_model()->get_one_by_ID($post_id);
1035
+		if ($post_evt instanceof EE_Event) {
1036
+			//meta revision restore
1037
+			$post_evt->restore_revision($revision_id);
1038
+			//related objs restore
1039
+			$post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price'));
1040
+		}
1041
+	}
1042
+
1043
+
1044
+
1045
+	/**
1046
+	 * Attach the venue to the Event
1047
+	 *
1048
+	 * @param  \EE_Event $evtobj Event Object to add the venue to
1049
+	 * @param  array     $data   The request data from the form
1050
+	 * @return bool           Success or fail.
1051
+	 */
1052
+	protected function _default_venue_update(\EE_Event $evtobj, $data)
1053
+	{
1054
+		require_once(EE_MODELS . 'EEM_Venue.model.php');
1055
+		$venue_model = EE_Registry::instance()->load_model('Venue');
1056
+		$rows_affected = null;
1057
+		$venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null;
1058
+		// very important.  If we don't have a venue name...
1059
+		// then we'll get out because not necessary to create empty venue
1060
+		if (empty($data['venue_title'])) {
1061
+			return false;
1062
+		}
1063
+		$venue_array = array(
1064
+			'VNU_wp_user'         => $evtobj->get('EVT_wp_user'),
1065
+			'VNU_name'            => ! empty($data['venue_title']) ? $data['venue_title'] : null,
1066
+			'VNU_desc'            => ! empty($data['venue_description']) ? $data['venue_description'] : null,
1067
+			'VNU_identifier'      => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : null,
1068
+			'VNU_short_desc'      => ! empty($data['venue_short_description']) ? $data['venue_short_description']
1069
+				: null,
1070
+			'VNU_address'         => ! empty($data['address']) ? $data['address'] : null,
1071
+			'VNU_address2'        => ! empty($data['address2']) ? $data['address2'] : null,
1072
+			'VNU_city'            => ! empty($data['city']) ? $data['city'] : null,
1073
+			'STA_ID'              => ! empty($data['state']) ? $data['state'] : null,
1074
+			'CNT_ISO'             => ! empty($data['countries']) ? $data['countries'] : null,
1075
+			'VNU_zip'             => ! empty($data['zip']) ? $data['zip'] : null,
1076
+			'VNU_phone'           => ! empty($data['venue_phone']) ? $data['venue_phone'] : null,
1077
+			'VNU_capacity'        => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : null,
1078
+			'VNU_url'             => ! empty($data['venue_url']) ? $data['venue_url'] : null,
1079
+			'VNU_virtual_phone'   => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : null,
1080
+			'VNU_virtual_url'     => ! empty($data['virtual_url']) ? $data['virtual_url'] : null,
1081
+			'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0,
1082
+			'status'              => 'publish',
1083
+		);
1084
+		//if we've got the venue_id then we're just updating the existing venue so let's do that and then get out.
1085
+		if ( ! empty($venue_id)) {
1086
+			$update_where = array($venue_model->primary_key_name() => $venue_id);
1087
+			$rows_affected = $venue_model->update($venue_array, array($update_where));
1088
+			//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.
1089
+			$evtobj->_add_relation_to($venue_id, 'Venue');
1090
+			return $rows_affected > 0 ? true : false;
1091
+		} else {
1092
+			//we insert the venue
1093
+			$venue_id = $venue_model->insert($venue_array);
1094
+			$evtobj->_add_relation_to($venue_id, 'Venue');
1095
+			return ! empty($venue_id) ? true : false;
1096
+		}
1097
+		//when we have the ancestor come in it's already been handled by the revision save.
1098
+	}
1099
+
1100
+
1101
+
1102
+	/**
1103
+	 * Handles saving everything related to Tickets (datetimes, tickets, prices)
1104
+	 *
1105
+	 * @param  EE_Event $evtobj The Event object we're attaching data to
1106
+	 * @param  array    $data   The request data from the form
1107
+	 * @return array
1108
+	 */
1109
+	protected function _default_tickets_update(EE_Event $evtobj, $data)
1110
+	{
1111
+		$success = true;
1112
+		$saved_dtt = null;
1113
+		$saved_tickets = array();
1114
+		$incoming_date_formats = array('Y-m-d', 'h:i a');
1115
+		foreach ($data['edit_event_datetimes'] as $row => $dtt) {
1116
+			//trim all values to ensure any excess whitespace is removed.
1117
+			$dtt = array_map('trim', $dtt);
1118
+			$dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end']
1119
+				: $dtt['DTT_EVT_start'];
1120
+			$datetime_values = array(
1121
+				'DTT_ID'        => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : null,
1122
+				'DTT_EVT_start' => $dtt['DTT_EVT_start'],
1123
+				'DTT_EVT_end'   => $dtt['DTT_EVT_end'],
1124
+				'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'],
1125
+				'DTT_order'     => $row,
1126
+			);
1127
+			//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.
1128
+			if ( ! empty($dtt['DTT_ID'])) {
1129
+				$DTM = EE_Registry::instance()
1130
+								  ->load_model('Datetime', array($evtobj->get_timezone()))
1131
+								  ->get_one_by_ID($dtt['DTT_ID']);
1132
+				$DTM->set_date_format($incoming_date_formats[0]);
1133
+				$DTM->set_time_format($incoming_date_formats[1]);
1134
+				foreach ($datetime_values as $field => $value) {
1135
+					$DTM->set($field, $value);
1136
+				}
1137
+				//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.
1138
+				$saved_dtts[$DTM->ID()] = $DTM;
1139
+			} else {
1140
+				$DTM = EE_Registry::instance()->load_class(
1141
+					'Datetime',
1142
+					array($datetime_values, $evtobj->get_timezone(), $incoming_date_formats),
1143
+					false,
1144
+					false
1145
+				);
1146
+				foreach ($datetime_values as $field => $value) {
1147
+					$DTM->set($field, $value);
1148
+				}
1149
+			}
1150
+			$DTM->save();
1151
+			$DTT = $evtobj->_add_relation_to($DTM, 'Datetime');
1152
+			//load DTT helper
1153
+			//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.
1154
+			if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) {
1155
+				$DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start'));
1156
+				$DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days');
1157
+				$DTT->save();
1158
+			}
1159
+			//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.
1160
+			$saved_dtt = $DTT;
1161
+			$success = ! $success ? $success : $DTT;
1162
+			//if ANY of these updates fail then we want the appropriate global error message.
1163
+			// //todo this is actually sucky we need a better error message but this is what it is for now.
1164
+		}
1165
+		//no dtts get deleted so we don't do any of that logic here.
1166
+		//update tickets next
1167
+		$old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array();
1168
+		foreach ($data['edit_tickets'] as $row => $tkt) {
1169
+			$incoming_date_formats = array('Y-m-d', 'h:i a');
1170
+			$update_prices = false;
1171
+			$ticket_price = isset($data['edit_prices'][$row][1]['PRC_amount'])
1172
+				? $data['edit_prices'][$row][1]['PRC_amount'] : 0;
1173
+			// trim inputs to ensure any excess whitespace is removed.
1174
+			$tkt = array_map('trim', $tkt);
1175
+			if (empty($tkt['TKT_start_date'])) {
1176
+				//let's use now in the set timezone.
1177
+				$now = new DateTime('now', new DateTimeZone($evtobj->get_timezone()));
1178
+				$tkt['TKT_start_date'] = $now->format($incoming_date_formats[0] . ' ' . $incoming_date_formats[1]);
1179
+			}
1180
+			if (empty($tkt['TKT_end_date'])) {
1181
+				//use the start date of the first datetime
1182
+				$dtt = $evtobj->first_datetime();
1183
+				$tkt['TKT_end_date'] = $dtt->start_date_and_time(
1184
+					$incoming_date_formats[0],
1185
+					$incoming_date_formats[1]
1186
+				);
1187
+			}
1188
+			$TKT_values = array(
1189
+				'TKT_ID'          => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null,
1190
+				'TTM_ID'          => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0,
1191
+				'TKT_name'        => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '',
1192
+				'TKT_description' => ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '',
1193
+				'TKT_start_date'  => $tkt['TKT_start_date'],
1194
+				'TKT_end_date'    => $tkt['TKT_end_date'],
1195
+				'TKT_qty'         => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'],
1196
+				'TKT_uses'        => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'],
1197
+				'TKT_min'         => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'],
1198
+				'TKT_max'         => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'],
1199
+				'TKT_row'         => $row,
1200
+				'TKT_order'       => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row,
1201
+				'TKT_price'       => $ticket_price,
1202
+			);
1203
+			//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.
1204
+			if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) {
1205
+				$TKT_values['TKT_ID'] = 0;
1206
+				$TKT_values['TKT_is_default'] = 0;
1207
+				$TKT_values['TKT_price'] = $ticket_price;
1208
+				$update_prices = true;
1209
+			}
1210
+			//if we have a TKT_ID then we need to get that existing TKT_obj and update it
1211
+			//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.
1212
+			//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.
1213
+			if ( ! empty($tkt['TKT_ID'])) {
1214
+				$TKT = EE_Registry::instance()
1215
+								  ->load_model('Ticket', array($evtobj->get_timezone()))
1216
+								  ->get_one_by_ID($tkt['TKT_ID']);
1217
+				if ($TKT instanceof EE_Ticket) {
1218
+					$ticket_sold = $TKT->count_related(
1219
+						'Registration',
1220
+						array(
1221
+							array(
1222
+								'STS_ID' => array(
1223
+									'NOT IN',
1224
+									array(EEM_Registration::status_id_incomplete),
1225
+								),
1226
+							),
1227
+						)
1228
+					) > 0 ? true : false;
1229
+					//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.
1230
+					$create_new_TKT = $ticket_sold && $ticket_price != $TKT->get('TKT_price')
1231
+									  && ! $TKT->get(
1232
+						'TKT_deleted'
1233
+					) ? true : false;
1234
+					$TKT->set_date_format($incoming_date_formats[0]);
1235
+					$TKT->set_time_format($incoming_date_formats[1]);
1236
+					//set new values
1237
+					foreach ($TKT_values as $field => $value) {
1238
+						if ($field == 'TKT_qty') {
1239
+							$TKT->set_qty($value);
1240
+						} else {
1241
+							$TKT->set($field, $value);
1242
+						}
1243
+					}
1244
+					//if $create_new_TKT is false then we can safely update the existing ticket.  Otherwise we have to create a new ticket.
1245
+					if ($create_new_TKT) {
1246
+						//archive the old ticket first
1247
+						$TKT->set('TKT_deleted', 1);
1248
+						$TKT->save();
1249
+						//make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine.
1250
+						$saved_tickets[$TKT->ID()] = $TKT;
1251
+						//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.
1252
+						$TKT = clone $TKT;
1253
+						$TKT->set('TKT_ID', 0);
1254
+						$TKT->set('TKT_deleted', 0);
1255
+						$TKT->set('TKT_price', $ticket_price);
1256
+						$TKT->set('TKT_sold', 0);
1257
+						//now we need to make sure that $new prices are created as well and attached to new ticket.
1258
+						$update_prices = true;
1259
+					}
1260
+					//make sure price is set if it hasn't been already
1261
+					$TKT->set('TKT_price', $ticket_price);
1262
+				}
1263
+			} else {
1264
+				//no TKT_id so a new TKT
1265
+				$TKT_values['TKT_price'] = $ticket_price;
1266
+				$TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), false, false);
1267
+				if ($TKT instanceof EE_Ticket) {
1268
+					//need to reset values to properly account for the date formats
1269
+					$TKT->set_date_format($incoming_date_formats[0]);
1270
+					$TKT->set_time_format($incoming_date_formats[1]);
1271
+					$TKT->set_timezone($evtobj->get_timezone());
1272
+					//set new values
1273
+					foreach ($TKT_values as $field => $value) {
1274
+						if ($field == 'TKT_qty') {
1275
+							$TKT->set_qty($value);
1276
+						} else {
1277
+							$TKT->set($field, $value);
1278
+						}
1279
+					}
1280
+					$update_prices = true;
1281
+				}
1282
+			}
1283
+			// cap ticket qty by datetime reg limits
1284
+			$TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit')));
1285
+			//update ticket.
1286
+			$TKT->save();
1287
+			//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.
1288
+			if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) {
1289
+				$TKT->set('TKT_end_date', $TKT->get('TKT_start_date'));
1290
+				$TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days');
1291
+				$TKT->save();
1292
+			}
1293
+			//initially let's add the ticket to the dtt
1294
+			$saved_dtt->_add_relation_to($TKT, 'Ticket');
1295
+			$saved_tickets[$TKT->ID()] = $TKT;
1296
+			//add prices to ticket
1297
+			$this->_add_prices_to_ticket($data['edit_prices'][$row], $TKT, $update_prices);
1298
+		}
1299
+		//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.
1300
+		$old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets;
1301
+		$tickets_removed = array_diff($old_tickets, array_keys($saved_tickets));
1302
+		foreach ($tickets_removed as $id) {
1303
+			$id = absint($id);
1304
+			//get the ticket for this id
1305
+			$tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id);
1306
+			//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)
1307
+			$dtts = $tkt_to_remove->get_many_related('Datetime');
1308
+			foreach ($dtts as $dtt) {
1309
+				$tkt_to_remove->_remove_relation_to($dtt, 'Datetime');
1310
+			}
1311
+			//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))
1312
+			$tkt_to_remove->delete_related_permanently('Price');
1313
+			//finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships)
1314
+			$tkt_to_remove->delete_permanently();
1315
+		}
1316
+		return array($saved_dtt, $saved_tickets);
1317
+	}
1318
+
1319
+
1320
+
1321
+	/**
1322
+	 * This attaches a list of given prices to a ticket.
1323
+	 * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change
1324
+	 * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old
1325
+	 * price info and prices are automatically "archived" via the ticket.
1326
+	 *
1327
+	 * @access  private
1328
+	 * @param array     $prices     Array of prices from the form.
1329
+	 * @param EE_Ticket $ticket     EE_Ticket object that prices are being attached to.
1330
+	 * @param bool      $new_prices Whether attach existing incoming prices or create new ones.
1331
+	 * @return  void
1332
+	 */
1333
+	private function _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = false)
1334
+	{
1335
+		foreach ($prices as $row => $prc) {
1336
+			$PRC_values = array(
1337
+				'PRC_ID'         => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null,
1338
+				'PRT_ID'         => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null,
1339
+				'PRC_amount'     => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0,
1340
+				'PRC_name'       => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '',
1341
+				'PRC_desc'       => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '',
1342
+				'PRC_is_default' => 0, //make sure prices are NOT set as default from this context
1343
+				'PRC_order'      => $row,
1344
+			);
1345
+			if ($new_prices || empty($PRC_values['PRC_ID'])) {
1346
+				$PRC_values['PRC_ID'] = 0;
1347
+				$PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), false, false);
1348
+			} else {
1349
+				$PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']);
1350
+				//update this price with new values
1351
+				foreach ($PRC_values as $field => $newprc) {
1352
+					$PRC->set($field, $newprc);
1353
+				}
1354
+				$PRC->save();
1355
+			}
1356
+			$ticket->_add_relation_to($PRC, 'Price');
1357
+		}
1358
+	}
1359
+
1360
+
1361
+
1362
+	/**
1363
+	 * Add in our autosave ajax handlers
1364
+	 *
1365
+	 * @return void
1366
+	 */
1367
+	protected function _ee_autosave_create_new()
1368
+	{
1369
+		// $this->_ee_autosave_edit();
1370
+	}
1371
+
1372
+
1373
+
1374
+	protected function _ee_autosave_edit()
1375
+	{
1376
+		return; //TEMPORARILY EXITING CAUSE THIS IS A TODO
1377
+	}
1378
+
1379
+
1380
+
1381
+	/**
1382
+	 *    _generate_publish_box_extra_content
1383
+	 *
1384
+	 * @access private
1385
+	 * @return void
1386
+	 */
1387
+	private function _generate_publish_box_extra_content()
1388
+	{
1389
+		//load formatter helper
1390
+		//args for getting related registrations
1391
+		$approved_query_args = array(
1392
+			array(
1393
+				'REG_deleted' => 0,
1394
+				'STS_ID'      => EEM_Registration::status_id_approved,
1395
+			),
1396
+		);
1397
+		$not_approved_query_args = array(
1398
+			array(
1399
+				'REG_deleted' => 0,
1400
+				'STS_ID'      => EEM_Registration::status_id_not_approved,
1401
+			),
1402
+		);
1403
+		$pending_payment_query_args = array(
1404
+			array(
1405
+				'REG_deleted' => 0,
1406
+				'STS_ID'      => EEM_Registration::status_id_pending_payment,
1407
+			),
1408
+		);
1409
+		// publish box
1410
+		$publish_box_extra_args = array(
1411
+			'view_approved_reg_url'        => add_query_arg(
1412
+				array(
1413
+					'action'      => 'default',
1414
+					'event_id'    => $this->_cpt_model_obj->ID(),
1415
+					'_reg_status' => EEM_Registration::status_id_approved,
1416
+				),
1417
+				REG_ADMIN_URL
1418
+			),
1419
+			'view_not_approved_reg_url'    => add_query_arg(
1420
+				array(
1421
+					'action'      => 'default',
1422
+					'event_id'    => $this->_cpt_model_obj->ID(),
1423
+					'_reg_status' => EEM_Registration::status_id_not_approved,
1424
+				),
1425
+				REG_ADMIN_URL
1426
+			),
1427
+			'view_pending_payment_reg_url' => add_query_arg(
1428
+				array(
1429
+					'action'      => 'default',
1430
+					'event_id'    => $this->_cpt_model_obj->ID(),
1431
+					'_reg_status' => EEM_Registration::status_id_pending_payment,
1432
+				),
1433
+				REG_ADMIN_URL
1434
+			),
1435
+			'approved_regs'                => $this->_cpt_model_obj->count_related(
1436
+				'Registration',
1437
+				$approved_query_args
1438
+			),
1439
+			'not_approved_regs'            => $this->_cpt_model_obj->count_related(
1440
+				'Registration',
1441
+				$not_approved_query_args
1442
+			),
1443
+			'pending_payment_regs'         => $this->_cpt_model_obj->count_related(
1444
+				'Registration',
1445
+				$pending_payment_query_args
1446
+			),
1447
+			'misc_pub_section_class'       => apply_filters(
1448
+				'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class',
1449
+				'misc-pub-section'
1450
+			),
1451
+			//'email_attendees_url' => add_query_arg(
1452
+			//	array(
1453
+			//		'event_admin_reports' => 'event_newsletter',
1454
+			//		'event_id' => $this->_cpt_model_obj->id
1455
+			//	),
1456
+			//	'admin.php?page=espresso_registrations'
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
+	/**
1475
+	 * This just returns whatever is set as the _event object property
1476
+	 * //todo this will become obsolete once the models are in place
1477
+	 *
1478
+	 * @return object
1479
+	 */
1480
+	public function get_event_object()
1481
+	{
1482
+		return $this->_cpt_model_obj;
1483
+	}
1484
+
1485
+
1486
+
1487
+
1488
+	/** METABOXES * */
1489
+	/**
1490
+	 * _register_event_editor_meta_boxes
1491
+	 * add all metaboxes related to the event_editor
1492
+	 *
1493
+	 * @return void
1494
+	 */
1495
+	protected function _register_event_editor_meta_boxes()
1496
+	{
1497
+		$this->verify_cpt_object();
1498
+		add_meta_box(
1499
+			'espresso_event_editor_tickets',
1500
+			esc_html__('Event Datetime & Ticket', 'event_espresso'),
1501
+			array($this, 'ticket_metabox'),
1502
+			$this->page_slug,
1503
+			'normal',
1504
+			'high'
1505
+		);
1506
+		add_meta_box(
1507
+			'espresso_event_editor_event_options',
1508
+			esc_html__('Event Registration Options', 'event_espresso'),
1509
+			array($this, 'registration_options_meta_box'),
1510
+			$this->page_slug,
1511
+			'side',
1512
+			'default'
1513
+		);
1514
+		// NOTE: if you're looking for other metaboxes in here,
1515
+		// where a metabox has a related management page in the admin
1516
+		// you will find it setup in the related management page's "_Hooks" file.
1517
+		// i.e. messages metabox is found in "espresso_events_Messages_Hooks.class.php".
1518
+	}
1519
+
1520
+
1521
+
1522
+	public function ticket_metabox()
1523
+	{
1524
+		$existing_datetime_ids = $existing_ticket_ids = array();
1525
+		//defaults for template args
1526
+		$template_args = array(
1527
+			'existing_datetime_ids'    => '',
1528
+			'event_datetime_help_link' => '',
1529
+			'ticket_options_help_link' => '',
1530
+			'time'                     => null,
1531
+			'ticket_rows'              => '',
1532
+			'existing_ticket_ids'      => '',
1533
+			'total_ticket_rows'        => 1,
1534
+			'ticket_js_structure'      => '',
1535
+			'trash_icon'               => 'ee-lock-icon',
1536
+			'disabled'                 => '',
1537
+		);
1538
+		$event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : null;
1539
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1540
+		/**
1541
+		 * 1. Start with retrieving Datetimes
1542
+		 * 2. Fore each datetime get related tickets
1543
+		 * 3. For each ticket get related prices
1544
+		 */
1545
+		$times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id);
1546
+		/** @type EE_Datetime $first_datetime */
1547
+		$first_datetime = reset($times);
1548
+		//do we get related tickets?
1549
+		if ($first_datetime instanceof EE_Datetime
1550
+			&& $first_datetime->ID() !== 0
1551
+		) {
1552
+			$existing_datetime_ids[] = $first_datetime->get('DTT_ID');
1553
+			$template_args['time'] = $first_datetime;
1554
+			$related_tickets = $first_datetime->tickets(
1555
+				array(
1556
+					array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)),
1557
+					'default_where_conditions' => 'none',
1558
+				)
1559
+			);
1560
+			if ( ! empty($related_tickets)) {
1561
+				$template_args['total_ticket_rows'] = count($related_tickets);
1562
+				$row = 0;
1563
+				foreach ($related_tickets as $ticket) {
1564
+					$existing_ticket_ids[] = $ticket->get('TKT_ID');
1565
+					$template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, false, $row);
1566
+					$row++;
1567
+				}
1568
+			} else {
1569
+				$template_args['total_ticket_rows'] = 1;
1570
+				/** @type EE_Ticket $ticket */
1571
+				$ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object();
1572
+				$template_args['ticket_rows'] .= $this->_get_ticket_row($ticket);
1573
+			}
1574
+		} else {
1575
+			$template_args['time'] = $times[0];
1576
+			/** @type EE_Ticket $ticket */
1577
+			$ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets();
1578
+			$template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]);
1579
+			// NOTE: we're just sending the first default row
1580
+			// (decaf can't manage default tickets so this should be sufficient);
1581
+		}
1582
+		$template_args['event_datetime_help_link'] = $this->_get_help_tab_link(
1583
+			'event_editor_event_datetimes_help_tab'
1584
+		);
1585
+		$template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info');
1586
+		$template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids);
1587
+		$template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids);
1588
+		$template_args['ticket_js_structure'] = $this->_get_ticket_row(
1589
+			EE_Registry::instance()->load_model('Ticket')->create_default_object(),
1590
+			true
1591
+		);
1592
+		$template = apply_filters(
1593
+			'FHEE__Events_Admin_Page__ticket_metabox__template',
1594
+			EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php'
1595
+		);
1596
+		EEH_Template::display_template($template, $template_args);
1597
+	}
1598
+
1599
+
1600
+
1601
+	/**
1602
+	 * Setup an individual ticket form for the decaf event editor page
1603
+	 *
1604
+	 * @access private
1605
+	 * @param  EE_Ticket $ticket   the ticket object
1606
+	 * @param  boolean   $skeleton whether we're generating a skeleton for js manipulation
1607
+	 * @param int        $row
1608
+	 * @return string generated html for the ticket row.
1609
+	 */
1610
+	private function _get_ticket_row($ticket, $skeleton = false, $row = 0)
1611
+	{
1612
+		$template_args = array(
1613
+			'tkt_status_class'    => ' tkt-status-' . $ticket->ticket_status(),
1614
+			'tkt_archive_class'   => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived'
1615
+				: '',
1616
+			'ticketrow'           => $skeleton ? 'TICKETNUM' : $row,
1617
+			'TKT_ID'              => $ticket->get('TKT_ID'),
1618
+			'TKT_name'            => $ticket->get('TKT_name'),
1619
+			'TKT_start_date'      => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'),
1620
+			'TKT_end_date'        => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'),
1621
+			'TKT_is_default'      => $ticket->get('TKT_is_default'),
1622
+			'TKT_qty'             => $ticket->get_pretty('TKT_qty', 'input'),
1623
+			'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets',
1624
+			'TKT_sold'            => $skeleton ? 0 : $ticket->get('TKT_sold'),
1625
+			'trash_icon'          => ($skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')))
1626
+									 && ( ! empty($ticket) && $ticket->get('TKT_sold') === 0)
1627
+				? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon',
1628
+			'disabled'            => $skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')) ? ''
1629
+				: ' disabled=disabled',
1630
+		);
1631
+		$price = $ticket->ID() !== 0
1632
+			? $ticket->get_first_related('Price', array('default_where_conditions' => 'none'))
1633
+			: EE_Registry::instance()->load_model('Price')->create_default_object();
1634
+		$price_args = array(
1635
+			'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,
1636
+			'PRC_amount'            => $price->get('PRC_amount'),
1637
+			'PRT_ID'                => $price->get('PRT_ID'),
1638
+			'PRC_ID'                => $price->get('PRC_ID'),
1639
+			'PRC_is_default'        => $price->get('PRC_is_default'),
1640
+		);
1641
+		//make sure we have default start and end dates if skeleton
1642
+		//handle rows that should NOT be empty
1643
+		if (empty($template_args['TKT_start_date'])) {
1644
+			//if empty then the start date will be now.
1645
+			$template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp'));
1646
+		}
1647
+		if (empty($template_args['TKT_end_date'])) {
1648
+			//get the earliest datetime (if present);
1649
+			$earliest_dtt = $this->_cpt_model_obj->ID() > 0
1650
+				? $this->_cpt_model_obj->get_first_related(
1651
+					'Datetime',
1652
+					array('order_by' => array('DTT_EVT_start' => 'ASC'))
1653
+				)
1654
+				: null;
1655
+			if ( ! empty($earliest_dtt)) {
1656
+				$template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a');
1657
+			} else {
1658
+				$template_args['TKT_end_date'] = date(
1659
+					'Y-m-d h:i a',
1660
+					mktime(0, 0, 0, date("m"), date("d") + 7, date("Y"))
1661
+				);
1662
+			}
1663
+		}
1664
+		$template_args = array_merge($template_args, $price_args);
1665
+		$template = apply_filters(
1666
+			'FHEE__Events_Admin_Page__get_ticket_row__template',
1667
+			EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php',
1668
+			$ticket
1669
+		);
1670
+		return EEH_Template::display_template($template, $template_args, true);
1671
+	}
1672
+
1673
+
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
+	/**
1727
+	 * _get_events()
1728
+	 * This method simply returns all the events (for the given _view and paging)
1729
+	 *
1730
+	 * @access public
1731
+	 * @param int  $per_page     count of items per page (20 default);
1732
+	 * @param int  $current_page what is the current page being viewed.
1733
+	 * @param bool $count        if TRUE then we just return a count of ALL events matching the given _view.
1734
+	 *                           If FALSE then we return an array of event objects
1735
+	 *                           that match the given _view and paging parameters.
1736
+	 * @return array an array of event objects.
1737
+	 */
1738
+	public function get_events($per_page = 10, $current_page = 1, $count = false)
1739
+	{
1740
+		$EEME = $this->_event_model();
1741
+		$offset = ($current_page - 1) * $per_page;
1742
+		$limit = $count ? null : $offset . ',' . $per_page;
1743
+		$orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID';
1744
+		$order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC";
1745
+		if (isset($this->_req_data['month_range'])) {
1746
+			$pieces = explode(' ', $this->_req_data['month_range'], 3);
1747
+			//simulate the FIRST day of the month, that fixes issues for months like February
1748
+			//where PHP doesn't know what to assume for date.
1749
+			//@see https://events.codebasehq.com/projects/event-espresso/tickets/10437
1750
+			$month_r = ! empty($pieces[0]) ? date('m', \EEH_DTT_Helper::first_of_month_timestamp($pieces[0])) : '';
1751
+			$year_r = ! empty($pieces[1]) ? $pieces[1] : '';
1752
+		}
1753
+		$where = array();
1754
+		$status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
1755
+		//determine what post_status our condition will have for the query.
1756
+		switch ($status) {
1757
+			case 'month' :
1758
+			case 'today' :
1759
+			case null :
1760
+			case 'all' :
1761
+				break;
1762
+			case 'draft' :
1763
+				$where['status'] = array('IN', array('draft', 'auto-draft'));
1764
+				break;
1765
+			default :
1766
+				$where['status'] = $status;
1767
+		}
1768
+		//categories?
1769
+		$category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0
1770
+			? $this->_req_data['EVT_CAT'] : null;
1771
+		if ( ! empty ($category)) {
1772
+			$where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories';
1773
+			$where['Term_Taxonomy.term_id'] = $category;
1774
+		}
1775
+		//date where conditions
1776
+		$start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start');
1777
+		if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') {
1778
+			$DateTime = new DateTime(
1779
+				$year_r . '-' . $month_r . '-01 00:00:00',
1780
+				new DateTimeZone(EEM_Datetime::instance()->get_timezone())
1781
+			);
1782
+			$start = $DateTime->format(implode(' ', $start_formats));
1783
+			$end = $DateTime->setDate($year_r, $month_r, $DateTime
1784
+				->format('t'))->setTime(23, 59, 59)
1785
+							->format(implode(' ', $start_formats));
1786
+			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1787
+		} else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') {
1788
+			$DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone()));
1789
+			$start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats));
1790
+			$end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats));
1791
+			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1792
+		} else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') {
1793
+			$now = date('Y-m-01');
1794
+			$DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone()));
1795
+			$start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats));
1796
+			$end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t'))
1797
+							->setTime(23, 59, 59)
1798
+							->format(implode(' ', $start_formats));
1799
+			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1800
+		}
1801
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
1802
+			$where['EVT_wp_user'] = get_current_user_id();
1803
+		} else {
1804
+			if ( ! isset($where['status'])) {
1805
+				if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) {
1806
+					$where['OR'] = array(
1807
+						'status*restrict_private' => array('!=', 'private'),
1808
+						'AND'                     => array(
1809
+							'status*inclusive' => array('=', 'private'),
1810
+							'EVT_wp_user'      => get_current_user_id(),
1811
+						),
1812
+					);
1813
+				}
1814
+			}
1815
+		}
1816
+		if (isset($this->_req_data['EVT_wp_user'])) {
1817
+			if ($this->_req_data['EVT_wp_user'] != get_current_user_id()
1818
+				&& EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')
1819
+			) {
1820
+				$where['EVT_wp_user'] = $this->_req_data['EVT_wp_user'];
1821
+			}
1822
+		}
1823
+		//search query handling
1824
+		if (isset($this->_req_data['s'])) {
1825
+			$search_string = '%' . $this->_req_data['s'] . '%';
1826
+			$where['OR'] = array(
1827
+				'EVT_name'       => array('LIKE', $search_string),
1828
+				'EVT_desc'       => array('LIKE', $search_string),
1829
+				'EVT_short_desc' => array('LIKE', $search_string),
1830
+			);
1831
+		}
1832
+		$where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data);
1833
+		$query_params = apply_filters(
1834
+			'FHEE__Events_Admin_Page__get_events__query_params',
1835
+			array(
1836
+				$where,
1837
+				'limit'    => $limit,
1838
+				'order_by' => $orderby,
1839
+				'order'    => $order,
1840
+				'group_by' => 'EVT_ID',
1841
+			),
1842
+			$this->_req_data
1843
+		);
1844
+		//let's first check if we have special requests coming in.
1845
+		if (isset($this->_req_data['active_status'])) {
1846
+			switch ($this->_req_data['active_status']) {
1847
+				case 'upcoming' :
1848
+					return $EEME->get_upcoming_events($query_params, $count);
1849
+					break;
1850
+				case 'expired' :
1851
+					return $EEME->get_expired_events($query_params, $count);
1852
+					break;
1853
+				case 'active' :
1854
+					return $EEME->get_active_events($query_params, $count);
1855
+					break;
1856
+				case 'inactive' :
1857
+					return $EEME->get_inactive_events($query_params, $count);
1858
+					break;
1859
+			}
1860
+		}
1861
+		$events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params);
1862
+		return $events;
1863
+	}
1864
+
1865
+
1866
+
1867
+	/**
1868
+	 * handling for WordPress CPT actions (trash, restore, delete)
1869
+	 *
1870
+	 * @param string $post_id
1871
+	 */
1872
+	public function trash_cpt_item($post_id)
1873
+	{
1874
+		$this->_req_data['EVT_ID'] = $post_id;
1875
+		$this->_trash_or_restore_event('trash', false);
1876
+	}
1877
+
1878
+
1879
+
1880
+	/**
1881
+	 * @param string $post_id
1882
+	 */
1883
+	public function restore_cpt_item($post_id)
1884
+	{
1885
+		$this->_req_data['EVT_ID'] = $post_id;
1886
+		$this->_trash_or_restore_event('draft', false);
1887
+	}
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
+	/**
1903
+	 * _trash_or_restore_event
1904
+	 *
1905
+	 * @access protected
1906
+	 * @param  string $event_status
1907
+	 * @param bool    $redirect_after
1908
+	 */
1909
+	protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = true)
1910
+	{
1911
+		//determine the event id and set to array.
1912
+		$EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : false;
1913
+		// loop thru events
1914
+		if ($EVT_ID) {
1915
+			// clean status
1916
+			$event_status = sanitize_key($event_status);
1917
+			// grab status
1918
+			if ( ! empty($event_status)) {
1919
+				$success = $this->_change_event_status($EVT_ID, $event_status);
1920
+			} else {
1921
+				$success = false;
1922
+				$msg = esc_html__(
1923
+					'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.',
1924
+					'event_espresso'
1925
+				);
1926
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1927
+			}
1928
+		} else {
1929
+			$success = false;
1930
+			$msg = esc_html__(
1931
+				'An error occurred. The event could not be moved to the trash because a valid event ID was not not supplied.',
1932
+				'event_espresso'
1933
+			);
1934
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1935
+		}
1936
+		$action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
1937
+		if ($redirect_after) {
1938
+			$this->_redirect_after_action($success, 'Event', $action, array('action' => 'default'));
1939
+		}
1940
+	}
1941
+
1942
+
1943
+
1944
+	/**
1945
+	 * _trash_or_restore_events
1946
+	 *
1947
+	 * @access protected
1948
+	 * @param  string $event_status
1949
+	 * @return void
1950
+	 */
1951
+	protected function _trash_or_restore_events($event_status = 'trash')
1952
+	{
1953
+		// clean status
1954
+		$event_status = sanitize_key($event_status);
1955
+		// grab status
1956
+		if ( ! empty($event_status)) {
1957
+			$success = true;
1958
+			//determine the event id and set to array.
1959
+			$EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array();
1960
+			// loop thru events
1961
+			foreach ($EVT_IDs as $EVT_ID) {
1962
+				if ($EVT_ID = absint($EVT_ID)) {
1963
+					$results = $this->_change_event_status($EVT_ID, $event_status);
1964
+					$success = $results !== false ? $success : false;
1965
+				} else {
1966
+					$msg = sprintf(
1967
+						esc_html__(
1968
+							'An error occurred. Event #%d could not be moved to the trash because a valid event ID was not not supplied.',
1969
+							'event_espresso'
1970
+						),
1971
+						$EVT_ID
1972
+					);
1973
+					EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1974
+					$success = false;
1975
+				}
1976
+			}
1977
+		} else {
1978
+			$success = false;
1979
+			$msg = esc_html__(
1980
+				'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.',
1981
+				'event_espresso'
1982
+			);
1983
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1984
+		}
1985
+		// in order to force a pluralized result message we need to send back a success status greater than 1
1986
+		$success = $success ? 2 : false;
1987
+		$action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
1988
+		$this->_redirect_after_action($success, 'Events', $action, array('action' => 'default'));
1989
+	}
1990
+
1991
+
1992
+
1993
+	/**
1994
+	 * _trash_or_restore_events
1995
+	 *
1996
+	 * @access  private
1997
+	 * @param  int    $EVT_ID
1998
+	 * @param  string $event_status
1999
+	 * @return bool
2000
+	 */
2001
+	private function _change_event_status($EVT_ID = 0, $event_status = '')
2002
+	{
2003
+		// grab event id
2004
+		if ( ! $EVT_ID) {
2005
+			$msg = esc_html__(
2006
+				'An error occurred. No Event ID or an invalid Event ID was received.',
2007
+				'event_espresso'
2008
+			);
2009
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2010
+			return false;
2011
+		}
2012
+		$this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID);
2013
+		// clean status
2014
+		$event_status = sanitize_key($event_status);
2015
+		// grab status
2016
+		if (empty($event_status)) {
2017
+			$msg = esc_html__(
2018
+				'An error occurred. No Event Status or an invalid Event Status was received.',
2019
+				'event_espresso'
2020
+			);
2021
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2022
+			return false;
2023
+		}
2024
+		// was event trashed or restored ?
2025
+		switch ($event_status) {
2026
+			case 'draft' :
2027
+				$action = 'restored from the trash';
2028
+				$hook = 'AHEE_event_restored_from_trash';
2029
+				break;
2030
+			case 'trash' :
2031
+				$action = 'moved to the trash';
2032
+				$hook = 'AHEE_event_moved_to_trash';
2033
+				break;
2034
+			default :
2035
+				$action = 'updated';
2036
+				$hook = false;
2037
+		}
2038
+		//use class to change status
2039
+		$this->_cpt_model_obj->set_status($event_status);
2040
+		$success = $this->_cpt_model_obj->save();
2041
+		if ($success === false) {
2042
+			$msg = sprintf(esc_html__('An error occurred. The event could not be %s.', 'event_espresso'), $action);
2043
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2044
+			return false;
2045
+		}
2046
+		if ($hook) {
2047
+			do_action($hook);
2048
+		}
2049
+		return true;
2050
+	}
2051
+
2052
+
2053
+
2054
+	/**
2055
+	 * _delete_event
2056
+	 *
2057
+	 * @access protected
2058
+	 * @param bool $redirect_after
2059
+	 */
2060
+	protected function _delete_event($redirect_after = true)
2061
+	{
2062
+		//determine the event id and set to array.
2063
+		$EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : null;
2064
+		$EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID;
2065
+		// loop thru events
2066
+		if ($EVT_ID) {
2067
+			$success = $this->_permanently_delete_event($EVT_ID);
2068
+			// get list of events with no prices
2069
+			$espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array());
2070
+			// remove this event from the list of events with no prices
2071
+			if (isset($espresso_no_ticket_prices[$EVT_ID])) {
2072
+				unset($espresso_no_ticket_prices[$EVT_ID]);
2073
+			}
2074
+			update_option('ee_no_ticket_prices', $espresso_no_ticket_prices);
2075
+		} else {
2076
+			$success = false;
2077
+			$msg = esc_html__(
2078
+				'An error occurred. An event could not be deleted because a valid event ID was not not supplied.',
2079
+				'event_espresso'
2080
+			);
2081
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2082
+		}
2083
+		if ($redirect_after) {
2084
+			$this->_redirect_after_action(
2085
+				$success,
2086
+				'Event',
2087
+				'deleted',
2088
+				array('action' => 'default', 'status' => 'trash')
2089
+			);
2090
+		}
2091
+	}
2092
+
2093
+
2094
+
2095
+	/**
2096
+	 * _delete_events
2097
+	 *
2098
+	 * @access protected
2099
+	 * @return void
2100
+	 */
2101
+	protected function _delete_events()
2102
+	{
2103
+		$success = true;
2104
+		// get list of events with no prices
2105
+		$espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array());
2106
+		//determine the event id and set to array.
2107
+		$EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array();
2108
+		// loop thru events
2109
+		foreach ($EVT_IDs as $EVT_ID) {
2110
+			$EVT_ID = absint($EVT_ID);
2111
+			if ($EVT_ID) {
2112
+				$results = $this->_permanently_delete_event($EVT_ID);
2113
+				$success = $results !== false ? $success : false;
2114
+				// remove this event from the list of events with no prices
2115
+				unset($espresso_no_ticket_prices[$EVT_ID]);
2116
+			} else {
2117
+				$success = false;
2118
+				$msg = esc_html__(
2119
+					'An error occurred. An event could not be deleted because a valid event ID was not not supplied.',
2120
+					'event_espresso'
2121
+				);
2122
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2123
+			}
2124
+		}
2125
+		update_option('ee_no_ticket_prices', $espresso_no_ticket_prices);
2126
+		// in order to force a pluralized result message we need to send back a success status greater than 1
2127
+		$success = $success ? 2 : false;
2128
+		$this->_redirect_after_action($success, 'Events', 'deleted', array('action' => 'default'));
2129
+	}
2130
+
2131
+
2132
+
2133
+	/**
2134
+	 * _permanently_delete_event
2135
+	 *
2136
+	 * @access  private
2137
+	 * @param  int $EVT_ID
2138
+	 * @return bool
2139
+	 */
2140
+	private function _permanently_delete_event($EVT_ID = 0)
2141
+	{
2142
+		// grab event id
2143
+		if ( ! $EVT_ID) {
2144
+			$msg = esc_html__(
2145
+				'An error occurred. No Event ID or an invalid Event ID was received.',
2146
+				'event_espresso'
2147
+			);
2148
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2149
+			return false;
2150
+		}
2151
+		if (
2152
+			! $this->_cpt_model_obj instanceof EE_Event
2153
+			|| $this->_cpt_model_obj->ID() !== $EVT_ID
2154
+		) {
2155
+			$this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID);
2156
+		}
2157
+		if ( ! $this->_cpt_model_obj instanceof EE_Event) {
2158
+			return false;
2159
+		}
2160
+		//need to delete related tickets and prices first.
2161
+		$datetimes = $this->_cpt_model_obj->get_many_related('Datetime');
2162
+		foreach ($datetimes as $datetime) {
2163
+			$this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime');
2164
+			$tickets = $datetime->get_many_related('Ticket');
2165
+			foreach ($tickets as $ticket) {
2166
+				$ticket->_remove_relation_to($datetime, 'Datetime');
2167
+				$ticket->delete_related_permanently('Price');
2168
+				$ticket->delete_permanently();
2169
+			}
2170
+			$datetime->delete();
2171
+		}
2172
+		//what about related venues or terms?
2173
+		$venues = $this->_cpt_model_obj->get_many_related('Venue');
2174
+		foreach ($venues as $venue) {
2175
+			$this->_cpt_model_obj->_remove_relation_to($venue, 'Venue');
2176
+		}
2177
+		//any attached question groups?
2178
+		$question_groups = $this->_cpt_model_obj->get_many_related('Question_Group');
2179
+		if ( ! empty($question_groups)) {
2180
+			foreach ($question_groups as $question_group) {
2181
+				$this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group');
2182
+			}
2183
+		}
2184
+		//Message Template Groups
2185
+		$this->_cpt_model_obj->_remove_relations('Message_Template_Group');
2186
+		/** @type EE_Term_Taxonomy[] $term_taxonomies */
2187
+		$term_taxonomies = $this->_cpt_model_obj->term_taxonomies();
2188
+		foreach ($term_taxonomies as $term_taxonomy) {
2189
+			$this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy);
2190
+		}
2191
+		$success = $this->_cpt_model_obj->delete_permanently();
2192
+		// did it all go as planned ?
2193
+		if ($success) {
2194
+			$msg = sprintf(esc_html__('Event ID # %d has been deleted.', 'event_espresso'), $EVT_ID);
2195
+			EE_Error::add_success($msg);
2196
+		} else {
2197
+			$msg = sprintf(
2198
+				esc_html__('An error occurred. Event ID # %d could not be deleted.', 'event_espresso'),
2199
+				$EVT_ID
2200
+			);
2201
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2202
+			return false;
2203
+		}
2204
+		do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID);
2205
+		return true;
2206
+	}
2207
+
2208
+
2209
+
2210
+	/**
2211
+	 * get total number of events
2212
+	 *
2213
+	 * @access public
2214
+	 * @return int
2215
+	 */
2216
+	public function total_events()
2217
+	{
2218
+		$count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true);
2219
+		return $count;
2220
+	}
2221
+
2222
+
2223
+
2224
+	/**
2225
+	 * get total number of draft events
2226
+	 *
2227
+	 * @access public
2228
+	 * @return int
2229
+	 */
2230
+	public function total_events_draft()
2231
+	{
2232
+		$where = array(
2233
+			'status' => array('IN', array('draft', 'auto-draft')),
2234
+		);
2235
+		$count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
2236
+		return $count;
2237
+	}
2238
+
2239
+
2240
+
2241
+	/**
2242
+	 * get total number of trashed events
2243
+	 *
2244
+	 * @access public
2245
+	 * @return int
2246
+	 */
2247
+	public function total_trashed_events()
2248
+	{
2249
+		$where = array(
2250
+			'status' => 'trash',
2251
+		);
2252
+		$count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
2253
+		return $count;
2254
+	}
2255
+
2256
+
2257
+	/**
2258
+	 *    _default_event_settings
2259
+	 *    This generates the Default Settings Tab
2260
+	 *
2261
+	 * @return void
2262
+	 * @throws \EE_Error
2263
+	 */
2264
+	protected function _default_event_settings()
2265
+	{
2266
+		$this->_set_add_edit_form_tags('update_default_event_settings');
2267
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
2268
+		$this->_template_args['admin_page_content'] = $this->_default_event_settings_form()->get_html();
2269
+		$this->display_admin_page_with_sidebar();
2270
+	}
2271
+
2272
+
2273
+	/**
2274
+	 * Return the form for event settings.
2275
+	 * @return \EE_Form_Section_Proper
2276
+	 */
2277
+	protected function _default_event_settings_form()
2278
+	{
2279
+		$registration_config = EE_Registry::instance()->CFG->registration;
2280
+		$registration_stati_for_selection = EEM_Registration::reg_status_array(
2281
+		//exclude
2282
+			array(
2283
+				EEM_Registration::status_id_cancelled,
2284
+				EEM_Registration::status_id_declined,
2285
+				EEM_Registration::status_id_incomplete,
2286
+				EEM_Registration::status_id_wait_list,
2287
+			),
2288
+			true
2289
+		);
2290
+		return new EE_Form_Section_Proper(
2291
+			array(
2292
+				'name' => 'update_default_event_settings',
2293
+				'html_id' => 'update_default_event_settings',
2294
+				'html_class' => 'form-table',
2295
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
2296
+				'subsections' => apply_filters(
2297
+					'FHEE__Events_Admin_Page___default_event_settings_form__form_subsections',
2298
+					array(
2299
+						'default_reg_status' => new EE_Select_Input(
2300
+							$registration_stati_for_selection,
2301
+							array(
2302
+								'default' => isset($registration_config->default_STS_ID)
2303
+											 && array_key_exists(
2304
+												$registration_config->default_STS_ID,
2305
+												$registration_stati_for_selection
2306
+											 )
2307
+											? sanitize_text_field($registration_config->default_STS_ID)
2308
+											: EEM_Registration::status_id_pending_payment,
2309
+								'html_label_text' => esc_html__('Default Registration Status', 'event_espresso')
2310
+													. EEH_Template::get_help_tab_link(
2311
+														'default_settings_status_help_tab'
2312
+													),
2313
+								'html_help_text' => esc_html__(
2314
+									'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.',
2315
+									'event_espresso'
2316
+								)
2317
+							)
2318
+						),
2319
+						'default_max_tickets' => new EE_Integer_Input(
2320
+							array(
2321
+								'default' => isset($registration_config->default_maximum_number_of_tickets)
2322
+									? $registration_config->default_maximum_number_of_tickets
2323
+									: EEM_Event::get_default_additional_limit(),
2324
+								'html_label_text' => esc_html__(
2325
+									'Default Maximum Tickets Allowed Per Order:',
2326
+									'event_espresso'
2327
+								) . EEH_Template::get_help_tab_link(
2328
+									'default_maximum_tickets_help_tab"'
2329
+									),
2330
+								'html_help_text' => esc_html__(
2331
+									'This setting allows you to indicate what will be the default for the maximum number of tickets per order when creating new events.',
2332
+									'event_espresso'
2333
+								)
2334
+							)
2335
+						)
2336
+					)
2337
+				)
2338
+			)
2339
+		);
2340
+	}
2341
+
2342
+
2343
+	/**
2344
+	 * _update_default_event_settings
2345
+	 *
2346
+	 * @access protected
2347
+	 * @return void
2348
+	 * @throws \EE_Error
2349
+	 */
2350
+	protected function _update_default_event_settings()
2351
+	{
2352
+		$registration_config = EE_Registry::instance()->CFG->registration;
2353
+		$form = $this->_default_event_settings_form();
2354
+		if ($form->was_submitted()) {
2355
+			$form->receive_form_submission();
2356
+			if ($form->is_valid()) {
2357
+				$valid_data = $form->valid_data();
2358
+				if (isset($valid_data['default_reg_status'])) {
2359
+					$registration_config->default_STS_ID = $valid_data['default_reg_status'];
2360
+				}
2361
+				if (isset($valid_data['default_max_tickets'])) {
2362
+					$registration_config->default_maximum_number_of_tickets = $valid_data['default_max_tickets'];
2363
+				}
2364
+				//update because data was valid!
2365
+				EE_Registry::instance()->CFG->update_espresso_config();
2366
+				EE_Error::overwrite_success();
2367
+				EE_Error::add_success(
2368
+					__('Default Event Settings were updated', 'event_espresso')
2369
+				);
2370
+			}
2371
+		}
2372
+		$this->_redirect_after_action(0, '', '', array('action' => 'default_event_settings'), true);
2373
+	}
2374
+
2375
+
2376
+
2377
+	/*************        Templates        *************/
2378
+	protected function _template_settings()
2379
+	{
2380
+		$this->_admin_page_title = esc_html__('Template Settings (Preview)', 'event_espresso');
2381
+		$this->_template_args['preview_img'] = '<img src="'
2382
+											   . EVENTS_ASSETS_URL
2383
+											   . DS
2384
+											   . 'images'
2385
+											   . DS
2386
+											   . 'caffeinated_template_features.jpg" alt="'
2387
+											   . esc_attr__('Template Settings Preview screenshot', 'event_espresso')
2388
+											   . '" />';
2389
+		$this->_template_args['preview_text'] = '<strong>' . esc_html__(
2390
+				'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.',
2391
+				'event_espresso'
2392
+			) . '</strong>';
2393
+		$this->display_admin_caf_preview_page('template_settings_tab');
2394
+	}
2395
+
2396
+
2397
+	/** Event Category Stuff **/
2398
+	/**
2399
+	 * set the _category property with the category object for the loaded page.
2400
+	 *
2401
+	 * @access private
2402
+	 * @return void
2403
+	 */
2404
+	private function _set_category_object()
2405
+	{
2406
+		if (isset($this->_category->id) && ! empty($this->_category->id)) {
2407
+			return;
2408
+		} //already have the category object so get out.
2409
+		//set default category object
2410
+		$this->_set_empty_category_object();
2411
+		//only set if we've got an id
2412
+		if ( ! isset($this->_req_data['EVT_CAT_ID'])) {
2413
+			return;
2414
+		}
2415
+		$category_id = absint($this->_req_data['EVT_CAT_ID']);
2416
+		$term = get_term($category_id, 'espresso_event_categories');
2417
+		if ( ! empty($term)) {
2418
+			$this->_category->category_name = $term->name;
2419
+			$this->_category->category_identifier = $term->slug;
2420
+			$this->_category->category_desc = $term->description;
2421
+			$this->_category->id = $term->term_id;
2422
+			$this->_category->parent = $term->parent;
2423
+		}
2424
+	}
2425
+
2426
+
2427
+
2428
+	private function _set_empty_category_object()
2429
+	{
2430
+		$this->_category = new stdClass();
2431
+		$this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = '';
2432
+		$this->_category->id = $this->_category->parent = 0;
2433
+	}
2434
+
2435
+
2436
+
2437
+	protected function _category_list_table()
2438
+	{
2439
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2440
+		$this->_search_btn_label = esc_html__('Categories', 'event_espresso');
2441
+		$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
2442
+				'add_category',
2443
+				'add_category',
2444
+				array(),
2445
+				'add-new-h2'
2446
+			);
2447
+		$this->display_admin_list_table_page_with_sidebar();
2448
+	}
2449
+
2450
+
2451
+
2452
+	/**
2453
+	 * @param $view
2454
+	 */
2455
+	protected function _category_details($view)
2456
+	{
2457
+		//load formatter helper
2458
+		//load field generator helper
2459
+		$route = $view == 'edit' ? 'update_category' : 'insert_category';
2460
+		$this->_set_add_edit_form_tags($route);
2461
+		$this->_set_category_object();
2462
+		$id = ! empty($this->_category->id) ? $this->_category->id : '';
2463
+		$delete_action = 'delete_category';
2464
+		//custom redirect
2465
+		$redirect = EE_Admin_Page::add_query_args_and_nonce(
2466
+			array('action' => 'category_list'),
2467
+			$this->_admin_base_url
2468
+		);
2469
+		$this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect);
2470
+		//take care of contents
2471
+		$this->_template_args['admin_page_content'] = $this->_category_details_content();
2472
+		$this->display_admin_page_with_sidebar();
2473
+	}
2474
+
2475
+
2476
+
2477
+	/**
2478
+	 * @return mixed
2479
+	 */
2480
+	protected function _category_details_content()
2481
+	{
2482
+		$editor_args['category_desc'] = array(
2483
+			'type'          => 'wp_editor',
2484
+			'value'         => EEH_Formatter::admin_format_content($this->_category->category_desc),
2485
+			'class'         => 'my_editor_custom',
2486
+			'wpeditor_args' => array('media_buttons' => false),
2487
+		);
2488
+		$_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array');
2489
+		$all_terms = get_terms(
2490
+			array('espresso_event_categories'),
2491
+			array('hide_empty' => 0, 'exclude' => array($this->_category->id))
2492
+		);
2493
+		//setup category select for term parents.
2494
+		$category_select_values[] = array(
2495
+			'text' => esc_html__('No Parent', 'event_espresso'),
2496
+			'id'   => 0,
2497
+		);
2498
+		foreach ($all_terms as $term) {
2499
+			$category_select_values[] = array(
2500
+				'text' => $term->name,
2501
+				'id'   => $term->term_id,
2502
+			);
2503
+		}
2504
+		$category_select = EEH_Form_Fields::select_input(
2505
+			'category_parent',
2506
+			$category_select_values,
2507
+			$this->_category->parent
2508
+		);
2509
+		$template_args = array(
2510
+			'category'                 => $this->_category,
2511
+			'category_select'          => $category_select,
2512
+			'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'),
2513
+			'category_desc_editor'     => $_wp_editor['category_desc']['field'],
2514
+			'disable'                  => '',
2515
+			'disabled_message'         => false,
2516
+		);
2517
+		$template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php';
2518
+		return EEH_Template::display_template($template, $template_args, true);
2519
+	}
2520
+
2521
+
2522
+
2523
+	protected function _delete_categories()
2524
+	{
2525
+		$cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array)$this->_req_data['EVT_CAT_ID']
2526
+			: (array)$this->_req_data['category_id'];
2527
+		foreach ($cat_ids as $cat_id) {
2528
+			$this->_delete_category($cat_id);
2529
+		}
2530
+		//doesn't matter what page we're coming from... we're going to the same place after delete.
2531
+		$query_args = array(
2532
+			'action' => 'category_list',
2533
+		);
2534
+		$this->_redirect_after_action(0, '', '', $query_args);
2535
+	}
2536
+
2537
+
2538
+
2539
+	/**
2540
+	 * @param $cat_id
2541
+	 */
2542
+	protected function _delete_category($cat_id)
2543
+	{
2544
+		$cat_id = absint($cat_id);
2545
+		wp_delete_term($cat_id, 'espresso_event_categories');
2546
+	}
2547
+
2548
+
2549
+
2550
+	/**
2551
+	 * @param $new_category
2552
+	 */
2553
+	protected function _insert_or_update_category($new_category)
2554
+	{
2555
+		$cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(true);
2556
+		$success = 0; //we already have a success message so lets not send another.
2557
+		if ($cat_id) {
2558
+			$query_args = array(
2559
+				'action'     => 'edit_category',
2560
+				'EVT_CAT_ID' => $cat_id,
2561
+			);
2562
+		} else {
2563
+			$query_args = array('action' => 'add_category');
2564
+		}
2565
+		$this->_redirect_after_action($success, '', '', $query_args, true);
2566
+	}
2567
+
2568
+
2569
+
2570
+	/**
2571
+	 * @param bool $update
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
+	/**
2614
+	 * @param int  $per_page
2615
+	 * @param int  $current_page
2616
+	 * @param bool $count
2617
+	 * @return \EE_Base_Class[]|int
2618
+	 */
2619
+	public function get_categories($per_page = 10, $current_page = 1, $count = false)
2620
+	{
2621
+		//testing term stuff
2622
+		$orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id';
2623
+		$order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC';
2624
+		$limit = ($current_page - 1) * $per_page;
2625
+		$where = array('taxonomy' => 'espresso_event_categories');
2626
+		if (isset($this->_req_data['s'])) {
2627
+			$sstr = '%' . $this->_req_data['s'] . '%';
2628
+			$where['OR'] = array(
2629
+				'Term.name'   => array('LIKE', $sstr),
2630
+				'description' => array('LIKE', $sstr),
2631
+			);
2632
+		}
2633
+		$query_params = array(
2634
+			$where,
2635
+			'order_by'   => array($orderby => $order),
2636
+			'limit'      => $limit . ',' . $per_page,
2637
+			'force_join' => array('Term'),
2638
+		);
2639
+		$categories = $count
2640
+			? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id')
2641
+			: EEM_Term_Taxonomy::instance()->get_all($query_params);
2642
+		return $categories;
2643
+	}
2644
+
2645
+
2646
+
2647
+	/* end category stuff */
2648
+	/**************/
2649 2649
 }
2650 2650
 //end class Events_Admin_Page
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -536,11 +536,11 @@  discard block
 block discarded – undo
536 536
     {
537 537
         wp_register_style(
538 538
             'events-admin-css',
539
-            EVENTS_ASSETS_URL . 'events-admin-page.css',
539
+            EVENTS_ASSETS_URL.'events-admin-page.css',
540 540
             array(),
541 541
             EVENT_ESPRESSO_VERSION
542 542
         );
543
-        wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION);
543
+        wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL.'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION);
544 544
         wp_enqueue_style('events-admin-css');
545 545
         wp_enqueue_style('ee-cat-admin');
546 546
         //todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
         //scripts
549 549
         wp_register_script(
550 550
             'event_editor_js',
551
-            EVENTS_ASSETS_URL . 'event_editor.js',
551
+            EVENTS_ASSETS_URL.'event_editor.js',
552 552
             array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'),
553 553
             EVENT_ESPRESSO_VERSION,
554 554
             true
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
         wp_enqueue_style('espresso-ui-theme');
581 581
         wp_register_style(
582 582
             'event-editor-css',
583
-            EVENTS_ASSETS_URL . 'event-editor.css',
583
+            EVENTS_ASSETS_URL.'event-editor.css',
584 584
             array('ee-admin-css'),
585 585
             EVENT_ESPRESSO_VERSION
586 586
         );
@@ -588,7 +588,7 @@  discard block
 block discarded – undo
588 588
         //scripts
589 589
         wp_register_script(
590 590
             'event-datetime-metabox',
591
-            EVENTS_ASSETS_URL . 'event-datetime-metabox.js',
591
+            EVENTS_ASSETS_URL.'event-datetime-metabox.js',
592 592
             array('event_editor_js', 'ee-datepicker'),
593 593
             EVENT_ESPRESSO_VERSION
594 594
         );
@@ -754,7 +754,7 @@  discard block
 block discarded – undo
754 754
                         'Your website\'s timezone is currently set to UTC + 0. We recommend updating your timezone to a city or region near you before you create an event. Your timezone can be updated through the %1$sGeneral Settings%2$s page.',
755 755
                         'event_espresso'
756 756
                     ),
757
-                    '<a href="' . admin_url('options-general.php') . '">',
757
+                    '<a href="'.admin_url('options-general.php').'">',
758 758
                     '</a>'
759 759
                 ),
760 760
                 __FILE__,
@@ -824,31 +824,31 @@  discard block
 block discarded – undo
824 824
         $items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items);
825 825
         $statuses = array(
826 826
             'sold_out_status'  => array(
827
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out,
827
+                'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::sold_out,
828 828
                 'desc'  => EEH_Template::pretty_status(EE_Datetime::sold_out, false, 'sentence'),
829 829
             ),
830 830
             'active_status'    => array(
831
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active,
831
+                'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::active,
832 832
                 'desc'  => EEH_Template::pretty_status(EE_Datetime::active, false, 'sentence'),
833 833
             ),
834 834
             'upcoming_status'  => array(
835
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming,
835
+                'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::upcoming,
836 836
                 'desc'  => EEH_Template::pretty_status(EE_Datetime::upcoming, false, 'sentence'),
837 837
             ),
838 838
             'postponed_status' => array(
839
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed,
839
+                'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::postponed,
840 840
                 'desc'  => EEH_Template::pretty_status(EE_Datetime::postponed, false, 'sentence'),
841 841
             ),
842 842
             'cancelled_status' => array(
843
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled,
843
+                'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::cancelled,
844 844
                 'desc'  => EEH_Template::pretty_status(EE_Datetime::cancelled, false, 'sentence'),
845 845
             ),
846 846
             'expired_status'   => array(
847
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired,
847
+                'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::expired,
848 848
                 'desc'  => EEH_Template::pretty_status(EE_Datetime::expired, false, 'sentence'),
849 849
             ),
850 850
             'inactive_status'  => array(
851
-                'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive,
851
+                'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::inactive,
852 852
                 'desc'  => EEH_Template::pretty_status(EE_Datetime::inactive, false, 'sentence'),
853 853
             ),
854 854
         );
@@ -912,7 +912,7 @@  discard block
 block discarded – undo
912 912
     {
913 913
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
914 914
         $this->_template_args['after_list_table'] = ! empty($this->_template_args['after_list_table'])
915
-            ? (array)$this->_template_args['after_list_table']
915
+            ? (array) $this->_template_args['after_list_table']
916 916
             : array();
917 917
         $this->_template_args['after_list_table']['view_event_list_button'] = EEH_HTML::br()
918 918
                                                                               . EEH_Template::get_button_or_link(
@@ -921,7 +921,7 @@  discard block
 block discarded – undo
921 921
                 'button'
922 922
             );
923 923
         $this->_template_args['after_list_table']['legend'] = $this->_display_legend($this->_event_legend_items());
924
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
924
+        $this->_admin_page_title .= ' '.$this->get_action_link_or_button(
925 925
                 'create_new',
926 926
                 'add',
927 927
                 array(),
@@ -1051,7 +1051,7 @@  discard block
 block discarded – undo
1051 1051
      */
1052 1052
     protected function _default_venue_update(\EE_Event $evtobj, $data)
1053 1053
     {
1054
-        require_once(EE_MODELS . 'EEM_Venue.model.php');
1054
+        require_once(EE_MODELS.'EEM_Venue.model.php');
1055 1055
         $venue_model = EE_Registry::instance()->load_model('Venue');
1056 1056
         $rows_affected = null;
1057 1057
         $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null;
@@ -1175,7 +1175,7 @@  discard block
 block discarded – undo
1175 1175
             if (empty($tkt['TKT_start_date'])) {
1176 1176
                 //let's use now in the set timezone.
1177 1177
                 $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone()));
1178
-                $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0] . ' ' . $incoming_date_formats[1]);
1178
+                $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0].' '.$incoming_date_formats[1]);
1179 1179
             }
1180 1180
             if (empty($tkt['TKT_end_date'])) {
1181 1181
                 //use the start date of the first datetime
@@ -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
     }
@@ -1591,7 +1591,7 @@  discard block
 block discarded – undo
1591 1591
         );
1592 1592
         $template = apply_filters(
1593 1593
             'FHEE__Events_Admin_Page__ticket_metabox__template',
1594
-            EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php'
1594
+            EVENTS_TEMPLATE_PATH.'event_tickets_metabox_main.template.php'
1595 1595
         );
1596 1596
         EEH_Template::display_template($template, $template_args);
1597 1597
     }
@@ -1610,7 +1610,7 @@  discard block
 block discarded – undo
1610 1610
     private function _get_ticket_row($ticket, $skeleton = false, $row = 0)
1611 1611
     {
1612 1612
         $template_args = array(
1613
-            'tkt_status_class'    => ' tkt-status-' . $ticket->ticket_status(),
1613
+            'tkt_status_class'    => ' tkt-status-'.$ticket->ticket_status(),
1614 1614
             'tkt_archive_class'   => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived'
1615 1615
                 : '',
1616 1616
             'ticketrow'           => $skeleton ? 'TICKETNUM' : $row,
@@ -1664,7 +1664,7 @@  discard block
 block discarded – undo
1664 1664
         $template_args = array_merge($template_args, $price_args);
1665 1665
         $template = apply_filters(
1666 1666
             'FHEE__Events_Admin_Page__get_ticket_row__template',
1667
-            EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php',
1667
+            EVENTS_TEMPLATE_PATH.'event_tickets_metabox_ticket_row.template.php',
1668 1668
             $ticket
1669 1669
         );
1670 1670
         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
     }
@@ -1739,7 +1739,7 @@  discard block
 block discarded – undo
1739 1739
     {
1740 1740
         $EEME = $this->_event_model();
1741 1741
         $offset = ($current_page - 1) * $per_page;
1742
-        $limit = $count ? null : $offset . ',' . $per_page;
1742
+        $limit = $count ? null : $offset.','.$per_page;
1743 1743
         $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID';
1744 1744
         $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC";
1745 1745
         if (isset($this->_req_data['month_range'])) {
@@ -1776,7 +1776,7 @@  discard block
 block discarded – undo
1776 1776
         $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start');
1777 1777
         if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') {
1778 1778
             $DateTime = new DateTime(
1779
-                $year_r . '-' . $month_r . '-01 00:00:00',
1779
+                $year_r.'-'.$month_r.'-01 00:00:00',
1780 1780
                 new DateTimeZone(EEM_Datetime::instance()->get_timezone())
1781 1781
             );
1782 1782
             $start = $DateTime->format(implode(' ', $start_formats));
@@ -1822,7 +1822,7 @@  discard block
 block discarded – undo
1822 1822
         }
1823 1823
         //search query handling
1824 1824
         if (isset($this->_req_data['s'])) {
1825
-            $search_string = '%' . $this->_req_data['s'] . '%';
1825
+            $search_string = '%'.$this->_req_data['s'].'%';
1826 1826
             $where['OR'] = array(
1827 1827
                 'EVT_name'       => array('LIKE', $search_string),
1828 1828
                 'EVT_desc'       => array('LIKE', $search_string),
@@ -1956,7 +1956,7 @@  discard block
 block discarded – undo
1956 1956
         if ( ! empty($event_status)) {
1957 1957
             $success = true;
1958 1958
             //determine the event id and set to array.
1959
-            $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array();
1959
+            $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array();
1960 1960
             // loop thru events
1961 1961
             foreach ($EVT_IDs as $EVT_ID) {
1962 1962
                 if ($EVT_ID = absint($EVT_ID)) {
@@ -2104,7 +2104,7 @@  discard block
 block discarded – undo
2104 2104
         // get list of events with no prices
2105 2105
         $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array());
2106 2106
         //determine the event id and set to array.
2107
-        $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array();
2107
+        $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array();
2108 2108
         // loop thru events
2109 2109
         foreach ($EVT_IDs as $EVT_ID) {
2110 2110
             $EVT_ID = absint($EVT_ID);
@@ -2324,7 +2324,7 @@  discard block
 block discarded – undo
2324 2324
                                 'html_label_text' => esc_html__(
2325 2325
                                     'Default Maximum Tickets Allowed Per Order:',
2326 2326
                                     'event_espresso'
2327
-                                ) . EEH_Template::get_help_tab_link(
2327
+                                ).EEH_Template::get_help_tab_link(
2328 2328
                                     'default_maximum_tickets_help_tab"'
2329 2329
                                     ),
2330 2330
                                 'html_help_text' => esc_html__(
@@ -2386,10 +2386,10 @@  discard block
 block discarded – undo
2386 2386
                                                . 'caffeinated_template_features.jpg" alt="'
2387 2387
                                                . esc_attr__('Template Settings Preview screenshot', 'event_espresso')
2388 2388
                                                . '" />';
2389
-        $this->_template_args['preview_text'] = '<strong>' . esc_html__(
2389
+        $this->_template_args['preview_text'] = '<strong>'.esc_html__(
2390 2390
                 '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.',
2391 2391
                 'event_espresso'
2392
-            ) . '</strong>';
2392
+            ).'</strong>';
2393 2393
         $this->display_admin_caf_preview_page('template_settings_tab');
2394 2394
     }
2395 2395
 
@@ -2438,7 +2438,7 @@  discard block
 block discarded – undo
2438 2438
     {
2439 2439
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2440 2440
         $this->_search_btn_label = esc_html__('Categories', 'event_espresso');
2441
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
2441
+        $this->_admin_page_title .= ' '.$this->get_action_link_or_button(
2442 2442
                 'add_category',
2443 2443
                 'add_category',
2444 2444
                 array(),
@@ -2514,7 +2514,7 @@  discard block
 block discarded – undo
2514 2514
             'disable'                  => '',
2515 2515
             'disabled_message'         => false,
2516 2516
         );
2517
-        $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php';
2517
+        $template = EVENTS_TEMPLATE_PATH.'event_category_details.template.php';
2518 2518
         return EEH_Template::display_template($template, $template_args, true);
2519 2519
     }
2520 2520
 
@@ -2522,8 +2522,8 @@  discard block
 block discarded – undo
2522 2522
 
2523 2523
     protected function _delete_categories()
2524 2524
     {
2525
-        $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array)$this->_req_data['EVT_CAT_ID']
2526
-            : (array)$this->_req_data['category_id'];
2525
+        $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array) $this->_req_data['EVT_CAT_ID']
2526
+            : (array) $this->_req_data['category_id'];
2527 2527
         foreach ($cat_ids as $cat_id) {
2528 2528
             $this->_delete_category($cat_id);
2529 2529
         }
@@ -2624,7 +2624,7 @@  discard block
 block discarded – undo
2624 2624
         $limit = ($current_page - 1) * $per_page;
2625 2625
         $where = array('taxonomy' => 'espresso_event_categories');
2626 2626
         if (isset($this->_req_data['s'])) {
2627
-            $sstr = '%' . $this->_req_data['s'] . '%';
2627
+            $sstr = '%'.$this->_req_data['s'].'%';
2628 2628
             $where['OR'] = array(
2629 2629
                 'Term.name'   => array('LIKE', $sstr),
2630 2630
                 'description' => array('LIKE', $sstr),
@@ -2633,7 +2633,7 @@  discard block
 block discarded – undo
2633 2633
         $query_params = array(
2634 2634
             $where,
2635 2635
             'order_by'   => array($orderby => $order),
2636
-            'limit'      => $limit . ',' . $per_page,
2636
+            'limit'      => $limit.','.$per_page,
2637 2637
             'force_join' => array('Term'),
2638 2638
         );
2639 2639
         $categories = $count
Please login to merge, or discard this patch.
events/help_tabs/events_default_settings_max_tickets.help_tab.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <p>
2 2
     <?php esc_html_e(
3
-        'Use this to control what the default will be for maximum tickets on an order when creating a new event.',
4
-        'event_espresso'
5
-    ); ?>
3
+		'Use this to control what the default will be for maximum tickets on an order when creating a new event.',
4
+		'event_espresso'
5
+	); ?>
6 6
 </p>
7 7
\ No newline at end of file
Please login to merge, or discard this patch.
core/EE_Load_Espresso_Core.core.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (! defined('EVENT_ESPRESSO_VERSION')) {
3
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
4 4
     exit('No direct script access allowed');
5 5
 }
6 6
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      */
49 49
     public function __construct()
50 50
     {
51
-        espresso_load_required('EventEspresso\core\Factory', EE_CORE . 'Factory.php');
51
+        espresso_load_required('EventEspresso\core\Factory', EE_CORE.'Factory.php');
52 52
     }
53 53
 
54 54
 
@@ -98,9 +98,9 @@  discard block
 block discarded – undo
98 98
         $this->_load_class_tools();
99 99
         // load interfaces
100 100
         espresso_load_required('EEI_Payment_Method_Interfaces',
101
-            EE_LIBRARIES . 'payment_methods' . DS . 'EEI_Payment_Method_Interfaces.php');
101
+            EE_LIBRARIES.'payment_methods'.DS.'EEI_Payment_Method_Interfaces.php');
102 102
         // deprecated functions
103
-        espresso_load_required('EE_Deprecated', EE_CORE . 'EE_Deprecated.core.php');
103
+        espresso_load_required('EE_Deprecated', EE_CORE.'EE_Deprecated.core.php');
104 104
         // WP cron jobs
105 105
         $this->registry->load_core('Cron_Tasks');
106 106
         $this->registry->load_core('EE_Request_Handler');
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
      */
137 137
     public function dependency_map()
138 138
     {
139
-        if (! $this->dependency_map instanceof EE_Dependency_Map) {
139
+        if ( ! $this->dependency_map instanceof EE_Dependency_Map) {
140 140
             throw new EE_Error(
141 141
                 sprintf(
142 142
                     __('Invalid EE_Dependency_Map: "%1$s"', 'event_espresso'),
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
      */
156 156
     public function registry()
157 157
     {
158
-        if (! $this->registry instanceof EE_Registry) {
158
+        if ( ! $this->registry instanceof EE_Registry) {
159 159
             throw new EE_Error(
160 160
                 sprintf(
161 161
                     __('Invalid EE_Registry: "%1$s"', 'event_espresso'),
@@ -173,14 +173,14 @@  discard block
 block discarded – undo
173 173
      */
174 174
     private function _load_dependency_map()
175 175
     {
176
-        if (! is_readable(EE_CORE . 'EE_Dependency_Map.core.php')) {
176
+        if ( ! is_readable(EE_CORE.'EE_Dependency_Map.core.php')) {
177 177
             EE_Error::add_error(
178 178
                 __('The EE_Dependency_Map core class could not be loaded.', 'event_espresso'),
179 179
                 __FILE__, __FUNCTION__, __LINE__
180 180
             );
181 181
             wp_die(EE_Error::get_notices());
182 182
         }
183
-        require_once(EE_CORE . 'EE_Dependency_Map.core.php');
183
+        require_once(EE_CORE.'EE_Dependency_Map.core.php');
184 184
         return EE_Dependency_Map::instance($this->request, $this->response);
185 185
     }
186 186
 
@@ -191,14 +191,14 @@  discard block
 block discarded – undo
191 191
      */
192 192
     private function _load_registry()
193 193
     {
194
-        if (! is_readable(EE_CORE . 'EE_Registry.core.php')) {
194
+        if ( ! is_readable(EE_CORE.'EE_Registry.core.php')) {
195 195
             EE_Error::add_error(
196 196
                 __('The EE_Registry core class could not be loaded.', 'event_espresso'),
197 197
                 __FILE__, __FUNCTION__, __LINE__
198 198
             );
199 199
             wp_die(EE_Error::get_notices());
200 200
         }
201
-        require_once(EE_CORE . 'EE_Registry.core.php');
201
+        require_once(EE_CORE.'EE_Registry.core.php');
202 202
         return EE_Registry::instance($this->dependency_map);
203 203
     }
204 204
 
@@ -209,13 +209,13 @@  discard block
 block discarded – undo
209 209
      */
210 210
     private function _load_class_tools()
211 211
     {
212
-        if (! is_readable(EE_HELPERS . 'EEH_Class_Tools.helper.php')) {
212
+        if ( ! is_readable(EE_HELPERS.'EEH_Class_Tools.helper.php')) {
213 213
             EE_Error::add_error(
214 214
                 __('The EEH_Class_Tools helper could not be loaded.', 'event_espresso'),
215 215
                 __FILE__, __FUNCTION__, __LINE__
216 216
             );
217 217
         }
218
-        require_once(EE_HELPERS . 'EEH_Class_Tools.helper.php');
218
+        require_once(EE_HELPERS.'EEH_Class_Tools.helper.php');
219 219
     }
220 220
 
221 221
 
Please login to merge, or discard this patch.
Indentation   +207 added lines, -207 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if (! defined('EVENT_ESPRESSO_VERSION')) {
4
-    exit('No direct script access allowed');
4
+	exit('No direct script access allowed');
5 5
 }
6 6
 
7 7
 
@@ -21,212 +21,212 @@  discard block
 block discarded – undo
21 21
 class EE_Load_Espresso_Core implements EEI_Request_Decorator, EEI_Request_Stack_Core_App
22 22
 {
23 23
 
24
-    /**
25
-     * @var EE_Request $request
26
-     */
27
-    protected $request;
28
-
29
-    /**
30
-     * @var EE_Response $response
31
-     */
32
-    protected $response;
33
-
34
-    /**
35
-     * @var EE_Dependency_Map $dependency_map
36
-     */
37
-    protected $dependency_map;
38
-
39
-    /**
40
-     * @var EE_Registry $registry
41
-     */
42
-    protected $registry;
43
-
44
-
45
-
46
-    /**
47
-     * EE_Load_Espresso_Core constructor
48
-     */
49
-    public function __construct()
50
-    {
51
-        espresso_load_required('EventEspresso\core\Factory', EE_CORE . 'Factory.php');
52
-    }
53
-
54
-
55
-
56
-    /**
57
-     * handle
58
-     * sets hooks for running rest of system
59
-     * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point
60
-     * starting EE Addons from any other point may lead to problems
61
-     *
62
-     * @param EE_Request  $request
63
-     * @param EE_Response $response
64
-     * @return EE_Response
65
-     * @throws EE_Error
66
-     */
67
-    public function handle_request(EE_Request $request, EE_Response $response)
68
-    {
69
-        $this->request = $request;
70
-        $this->response = $response;
71
-        // info about how to load classes required by other classes
72
-        $this->dependency_map = $this->_load_dependency_map();
73
-        // central repository for classes
74
-        $this->registry = $this->_load_registry();
75
-        do_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading');
76
-        // PSR4 Autoloaders
77
-        $this->registry->load_core('EE_Psr4AutoloaderInit');
78
-        // build DI container
79
-        $OpenCoffeeShop = new EventEspresso\core\services\container\OpenCoffeeShop();
80
-        $OpenCoffeeShop->addRecipes();
81
-        // $CoffeeShop = $OpenCoffeeShop->CoffeeShop();
82
-        // create and cache the CommandBus, and also add the CapChecker middleware
83
-        $this->registry->create(
84
-            'CommandBusInterface',
85
-            array(
86
-                null,
87
-                $this->registry->create('CapChecker'),
88
-            ),
89
-            true
90
-        );
91
-        // workarounds for PHP < 5.3
92
-        $this->_load_class_tools();
93
-        // load interfaces
94
-        espresso_load_required('EEI_Payment_Method_Interfaces',
95
-            EE_LIBRARIES . 'payment_methods' . DS . 'EEI_Payment_Method_Interfaces.php');
96
-        // deprecated functions
97
-        espresso_load_required('EE_Deprecated', EE_CORE . 'EE_Deprecated.core.php');
98
-        // WP cron jobs
99
-        $this->registry->load_core('Cron_Tasks');
100
-        $this->registry->load_core('EE_Request_Handler');
101
-        $this->registry->load_core('EE_System');
102
-        return $this->response;
103
-    }
104
-
105
-
106
-
107
-    /**
108
-     * @return EE_Request
109
-     */
110
-    public function request()
111
-    {
112
-        return $this->request;
113
-    }
114
-
115
-
116
-
117
-    /**
118
-     * @return EE_Response
119
-     */
120
-    public function response()
121
-    {
122
-        return $this->response;
123
-    }
124
-
125
-
126
-
127
-    /**
128
-     * @return EE_Dependency_Map
129
-     * @throws EE_Error
130
-     */
131
-    public function dependency_map()
132
-    {
133
-        if (! $this->dependency_map instanceof EE_Dependency_Map) {
134
-            throw new EE_Error(
135
-                sprintf(
136
-                    __('Invalid EE_Dependency_Map: "%1$s"', 'event_espresso'),
137
-                    print_r($this->dependency_map, true)
138
-                )
139
-            );
140
-        }
141
-        return $this->dependency_map;
142
-    }
143
-
144
-
145
-
146
-    /**
147
-     * @return EE_Registry
148
-     * @throws EE_Error
149
-     */
150
-    public function registry()
151
-    {
152
-        if (! $this->registry instanceof EE_Registry) {
153
-            throw new EE_Error(
154
-                sprintf(
155
-                    __('Invalid EE_Registry: "%1$s"', 'event_espresso'),
156
-                    print_r($this->registry, true)
157
-                )
158
-            );
159
-        }
160
-        return $this->registry;
161
-    }
162
-
163
-
164
-
165
-    /**
166
-     * @return EE_Dependency_Map
167
-     */
168
-    private function _load_dependency_map()
169
-    {
170
-        if (! is_readable(EE_CORE . 'EE_Dependency_Map.core.php')) {
171
-            EE_Error::add_error(
172
-                __('The EE_Dependency_Map core class could not be loaded.', 'event_espresso'),
173
-                __FILE__, __FUNCTION__, __LINE__
174
-            );
175
-            wp_die(EE_Error::get_notices());
176
-        }
177
-        require_once(EE_CORE . 'EE_Dependency_Map.core.php');
178
-        return EE_Dependency_Map::instance($this->request, $this->response);
179
-    }
180
-
181
-
182
-
183
-    /**
184
-     * @return EE_Registry
185
-     */
186
-    private function _load_registry()
187
-    {
188
-        if (! is_readable(EE_CORE . 'EE_Registry.core.php')) {
189
-            EE_Error::add_error(
190
-                __('The EE_Registry core class could not be loaded.', 'event_espresso'),
191
-                __FILE__, __FUNCTION__, __LINE__
192
-            );
193
-            wp_die(EE_Error::get_notices());
194
-        }
195
-        require_once(EE_CORE . 'EE_Registry.core.php');
196
-        return EE_Registry::instance($this->dependency_map);
197
-    }
198
-
199
-
200
-
201
-    /**
202
-     * @return void
203
-     */
204
-    private function _load_class_tools()
205
-    {
206
-        if (! is_readable(EE_HELPERS . 'EEH_Class_Tools.helper.php')) {
207
-            EE_Error::add_error(
208
-                __('The EEH_Class_Tools helper could not be loaded.', 'event_espresso'),
209
-                __FILE__, __FUNCTION__, __LINE__
210
-            );
211
-        }
212
-        require_once(EE_HELPERS . 'EEH_Class_Tools.helper.php');
213
-    }
214
-
215
-
216
-
217
-    /**
218
-     * called after the request stack has been fully processed
219
-     * if any of the middleware apps has requested the plugin be deactivated, then we do that now
220
-     *
221
-     * @param EE_Request  $request
222
-     * @param EE_Response $response
223
-     */
224
-    public function handle_response(EE_Request $request, EE_Response $response)
225
-    {
226
-        if ($response->plugin_deactivated()) {
227
-            espresso_deactivate_plugin(EE_PLUGIN_BASENAME);
228
-        }
229
-    }
24
+	/**
25
+	 * @var EE_Request $request
26
+	 */
27
+	protected $request;
28
+
29
+	/**
30
+	 * @var EE_Response $response
31
+	 */
32
+	protected $response;
33
+
34
+	/**
35
+	 * @var EE_Dependency_Map $dependency_map
36
+	 */
37
+	protected $dependency_map;
38
+
39
+	/**
40
+	 * @var EE_Registry $registry
41
+	 */
42
+	protected $registry;
43
+
44
+
45
+
46
+	/**
47
+	 * EE_Load_Espresso_Core constructor
48
+	 */
49
+	public function __construct()
50
+	{
51
+		espresso_load_required('EventEspresso\core\Factory', EE_CORE . 'Factory.php');
52
+	}
53
+
54
+
55
+
56
+	/**
57
+	 * handle
58
+	 * sets hooks for running rest of system
59
+	 * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point
60
+	 * starting EE Addons from any other point may lead to problems
61
+	 *
62
+	 * @param EE_Request  $request
63
+	 * @param EE_Response $response
64
+	 * @return EE_Response
65
+	 * @throws EE_Error
66
+	 */
67
+	public function handle_request(EE_Request $request, EE_Response $response)
68
+	{
69
+		$this->request = $request;
70
+		$this->response = $response;
71
+		// info about how to load classes required by other classes
72
+		$this->dependency_map = $this->_load_dependency_map();
73
+		// central repository for classes
74
+		$this->registry = $this->_load_registry();
75
+		do_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading');
76
+		// PSR4 Autoloaders
77
+		$this->registry->load_core('EE_Psr4AutoloaderInit');
78
+		// build DI container
79
+		$OpenCoffeeShop = new EventEspresso\core\services\container\OpenCoffeeShop();
80
+		$OpenCoffeeShop->addRecipes();
81
+		// $CoffeeShop = $OpenCoffeeShop->CoffeeShop();
82
+		// create and cache the CommandBus, and also add the CapChecker middleware
83
+		$this->registry->create(
84
+			'CommandBusInterface',
85
+			array(
86
+				null,
87
+				$this->registry->create('CapChecker'),
88
+			),
89
+			true
90
+		);
91
+		// workarounds for PHP < 5.3
92
+		$this->_load_class_tools();
93
+		// load interfaces
94
+		espresso_load_required('EEI_Payment_Method_Interfaces',
95
+			EE_LIBRARIES . 'payment_methods' . DS . 'EEI_Payment_Method_Interfaces.php');
96
+		// deprecated functions
97
+		espresso_load_required('EE_Deprecated', EE_CORE . 'EE_Deprecated.core.php');
98
+		// WP cron jobs
99
+		$this->registry->load_core('Cron_Tasks');
100
+		$this->registry->load_core('EE_Request_Handler');
101
+		$this->registry->load_core('EE_System');
102
+		return $this->response;
103
+	}
104
+
105
+
106
+
107
+	/**
108
+	 * @return EE_Request
109
+	 */
110
+	public function request()
111
+	{
112
+		return $this->request;
113
+	}
114
+
115
+
116
+
117
+	/**
118
+	 * @return EE_Response
119
+	 */
120
+	public function response()
121
+	{
122
+		return $this->response;
123
+	}
124
+
125
+
126
+
127
+	/**
128
+	 * @return EE_Dependency_Map
129
+	 * @throws EE_Error
130
+	 */
131
+	public function dependency_map()
132
+	{
133
+		if (! $this->dependency_map instanceof EE_Dependency_Map) {
134
+			throw new EE_Error(
135
+				sprintf(
136
+					__('Invalid EE_Dependency_Map: "%1$s"', 'event_espresso'),
137
+					print_r($this->dependency_map, true)
138
+				)
139
+			);
140
+		}
141
+		return $this->dependency_map;
142
+	}
143
+
144
+
145
+
146
+	/**
147
+	 * @return EE_Registry
148
+	 * @throws EE_Error
149
+	 */
150
+	public function registry()
151
+	{
152
+		if (! $this->registry instanceof EE_Registry) {
153
+			throw new EE_Error(
154
+				sprintf(
155
+					__('Invalid EE_Registry: "%1$s"', 'event_espresso'),
156
+					print_r($this->registry, true)
157
+				)
158
+			);
159
+		}
160
+		return $this->registry;
161
+	}
162
+
163
+
164
+
165
+	/**
166
+	 * @return EE_Dependency_Map
167
+	 */
168
+	private function _load_dependency_map()
169
+	{
170
+		if (! is_readable(EE_CORE . 'EE_Dependency_Map.core.php')) {
171
+			EE_Error::add_error(
172
+				__('The EE_Dependency_Map core class could not be loaded.', 'event_espresso'),
173
+				__FILE__, __FUNCTION__, __LINE__
174
+			);
175
+			wp_die(EE_Error::get_notices());
176
+		}
177
+		require_once(EE_CORE . 'EE_Dependency_Map.core.php');
178
+		return EE_Dependency_Map::instance($this->request, $this->response);
179
+	}
180
+
181
+
182
+
183
+	/**
184
+	 * @return EE_Registry
185
+	 */
186
+	private function _load_registry()
187
+	{
188
+		if (! is_readable(EE_CORE . 'EE_Registry.core.php')) {
189
+			EE_Error::add_error(
190
+				__('The EE_Registry core class could not be loaded.', 'event_espresso'),
191
+				__FILE__, __FUNCTION__, __LINE__
192
+			);
193
+			wp_die(EE_Error::get_notices());
194
+		}
195
+		require_once(EE_CORE . 'EE_Registry.core.php');
196
+		return EE_Registry::instance($this->dependency_map);
197
+	}
198
+
199
+
200
+
201
+	/**
202
+	 * @return void
203
+	 */
204
+	private function _load_class_tools()
205
+	{
206
+		if (! is_readable(EE_HELPERS . 'EEH_Class_Tools.helper.php')) {
207
+			EE_Error::add_error(
208
+				__('The EEH_Class_Tools helper could not be loaded.', 'event_espresso'),
209
+				__FILE__, __FUNCTION__, __LINE__
210
+			);
211
+		}
212
+		require_once(EE_HELPERS . 'EEH_Class_Tools.helper.php');
213
+	}
214
+
215
+
216
+
217
+	/**
218
+	 * called after the request stack has been fully processed
219
+	 * if any of the middleware apps has requested the plugin be deactivated, then we do that now
220
+	 *
221
+	 * @param EE_Request  $request
222
+	 * @param EE_Response $response
223
+	 */
224
+	public function handle_response(EE_Request $request, EE_Response $response)
225
+	{
226
+		if ($response->plugin_deactivated()) {
227
+			espresso_deactivate_plugin(EE_PLUGIN_BASENAME);
228
+		}
229
+	}
230 230
 
231 231
 
232 232
 
Please login to merge, or discard this patch.
core/EE_Dependency_Map.core.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (! defined('EVENT_ESPRESSO_VERSION')) {
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3 3
     exit('No direct script access allowed');
4 4
 }
5 5
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
     public static function instance(EE_Request $request = null, EE_Response $response = null)
106 106
     {
107 107
         // check if class object is instantiated, and instantiated properly
108
-        if (! self::$_instance instanceof EE_Dependency_Map) {
108
+        if ( ! self::$_instance instanceof EE_Dependency_Map) {
109 109
             self::$_instance = new EE_Dependency_Map($request, $response);
110 110
         }
111 111
         return self::$_instance;
@@ -120,15 +120,15 @@  discard block
 block discarded – undo
120 120
      */
121 121
     public static function register_dependencies($class, $dependencies)
122 122
     {
123
-        if (! isset(self::$_instance->_dependency_map[$class])) {
123
+        if ( ! isset(self::$_instance->_dependency_map[$class])) {
124 124
             // we need to make sure that any aliases used when registering a dependency
125 125
             // get resolved to the correct class name
126
-            foreach ((array)$dependencies as $dependency => $load_source) {
126
+            foreach ((array) $dependencies as $dependency => $load_source) {
127 127
                 $alias = self::$_instance->get_alias($dependency);
128 128
                 unset($dependencies[$dependency]);
129 129
                 $dependencies[$alias] = $load_source;
130 130
             }
131
-            self::$_instance->_dependency_map[$class] = (array)$dependencies;
131
+            self::$_instance->_dependency_map[$class] = (array) $dependencies;
132 132
             return true;
133 133
         }
134 134
         return false;
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
             );
155 155
         }
156 156
         $class_name = self::$_instance->get_alias($class_name);
157
-        if (! isset(self::$_instance->_class_loaders[$class_name])) {
157
+        if ( ! isset(self::$_instance->_class_loaders[$class_name])) {
158 158
             self::$_instance->_class_loaders[$class_name] = $loader;
159 159
             return true;
160 160
         }
@@ -476,10 +476,10 @@  discard block
 block discarded – undo
476 476
             'EE_Front_Controller'                  => 'load_core',
477 477
             'EE_Module_Request_Router'             => 'load_core',
478 478
             'EE_Registry'                          => 'load_core',
479
-            'EE_Request'                           => function () use (&$request) {
479
+            'EE_Request'                           => function() use (&$request) {
480 480
                 return $request;
481 481
             },
482
-            'EE_Response'                          => function () use (&$response) {
482
+            'EE_Response'                          => function() use (&$response) {
483 483
                 return $response;
484 484
             },
485 485
             'EE_Request_Handler'                   => 'load_core',
@@ -496,17 +496,17 @@  discard block
 block discarded – undo
496 496
             'EE_Messages_Queue'                    => 'load_lib',
497 497
             'EE_Messages_Data_Handler_Collection'  => 'load_lib',
498 498
             'EE_Message_Template_Group_Collection' => 'load_lib',
499
-            'EE_Messages_Generator'                => function () {
499
+            'EE_Messages_Generator'                => function() {
500 500
                 return EE_Registry::instance()->load_lib('Messages_Generator', array(), false, false);
501 501
             },
502
-            'EE_Messages_Template_Defaults'        => function ($arguments = array()) {
502
+            'EE_Messages_Template_Defaults'        => function($arguments = array()) {
503 503
                 return EE_Registry::instance()->load_lib('Messages_Template_Defaults', $arguments, false, false);
504 504
             },
505 505
             //load_model
506 506
             'EEM_Message_Template_Group'           => 'load_model',
507 507
             'EEM_Message_Template'                 => 'load_model',
508 508
             //load_helper
509
-            'EEH_Parse_Shortcodes'                 => function () {
509
+            'EEH_Parse_Shortcodes'                 => function() {
510 510
                 if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
511 511
                     return new EEH_Parse_Shortcodes();
512 512
                 }
Please login to merge, or discard this patch.
Indentation   +570 added lines, -570 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if (! defined('EVENT_ESPRESSO_VERSION')) {
3
-    exit('No direct script access allowed');
3
+	exit('No direct script access allowed');
4 4
 }
5 5
 
6 6
 
@@ -18,575 +18,575 @@  discard block
 block discarded – undo
18 18
 {
19 19
 
20 20
 
21
-    /**
22
-     * This means that the requested class dependency is not present in the dependency map
23
-     */
24
-    const not_registered = 0;
25
-
26
-
27
-    /**
28
-     * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
29
-     */
30
-    const load_new_object = 1;
31
-
32
-    /**
33
-     * This instructs class loaders to return a previously instantiated and cached object for the requested class.
34
-     * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
35
-     */
36
-    const load_from_cache = 2;
37
-
38
-    /**
39
-     * @type EE_Dependency_Map $_instance
40
-     */
41
-    protected static $_instance;
42
-
43
-    /**
44
-     * @type EE_Request $request
45
-     */
46
-    protected $_request;
47
-
48
-    /**
49
-     * @type EE_Response $response
50
-     */
51
-    protected $_response;
52
-
53
-
54
-    /**
55
-     * @type array $_dependency_map
56
-     */
57
-    protected $_dependency_map = array();
58
-
59
-    /**
60
-     * @type array $_class_loaders
61
-     */
62
-    protected $_class_loaders = array();
63
-
64
-    /**
65
-     * @type array $_aliases
66
-     */
67
-    protected $_aliases = array();
68
-
69
-
70
-
71
-    /**
72
-     * EE_Dependency_Map constructor.
73
-     *
74
-     * @param EE_Request  $request
75
-     * @param EE_Response $response
76
-     */
77
-    protected function __construct(EE_Request $request, EE_Response $response)
78
-    {
79
-        $this->_request = $request;
80
-        $this->_response = $response;
81
-        add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize'));
82
-        do_action('EE_Dependency_Map____construct');
83
-    }
84
-
85
-
86
-
87
-    /**
88
-     */
89
-    public function initialize()
90
-    {
91
-        $this->_register_core_dependencies();
92
-        $this->_register_core_class_loaders();
93
-        $this->_register_core_aliases();
94
-    }
95
-
96
-
97
-
98
-    /**
99
-     * @singleton method used to instantiate class object
100
-     * @access    public
101
-     * @param EE_Request  $request
102
-     * @param EE_Response $response
103
-     * @return EE_Dependency_Map instance
104
-     */
105
-    public static function instance(EE_Request $request = null, EE_Response $response = null)
106
-    {
107
-        // check if class object is instantiated, and instantiated properly
108
-        if (! self::$_instance instanceof EE_Dependency_Map) {
109
-            self::$_instance = new EE_Dependency_Map($request, $response);
110
-        }
111
-        return self::$_instance;
112
-    }
113
-
114
-
115
-
116
-    /**
117
-     * @param string $class
118
-     * @param array  $dependencies
119
-     * @return boolean
120
-     */
121
-    public static function register_dependencies($class, $dependencies)
122
-    {
123
-        if (! isset(self::$_instance->_dependency_map[$class])) {
124
-            // we need to make sure that any aliases used when registering a dependency
125
-            // get resolved to the correct class name
126
-            foreach ((array)$dependencies as $dependency => $load_source) {
127
-                $alias = self::$_instance->get_alias($dependency);
128
-                unset($dependencies[$dependency]);
129
-                $dependencies[$alias] = $load_source;
130
-            }
131
-            self::$_instance->_dependency_map[$class] = (array)$dependencies;
132
-            return true;
133
-        }
134
-        return false;
135
-    }
136
-
137
-
138
-
139
-    /**
140
-     * @param string $class_name
141
-     * @param string $loader
142
-     * @return bool
143
-     * @throws EE_Error
144
-     */
145
-    public static function register_class_loader($class_name, $loader = 'load_core')
146
-    {
147
-        // check that loader method starts with "load_" and exists in EE_Registry
148
-        if (strpos($loader, 'load_') !== 0 || ! method_exists('EE_Registry', $loader)) {
149
-            throw new EE_Error(
150
-                sprintf(
151
-                    __('"%1$s" is not a valid loader method on EE_Registry.', 'event_espresso'),
152
-                    $loader
153
-                )
154
-            );
155
-        }
156
-        $class_name = self::$_instance->get_alias($class_name);
157
-        if (! isset(self::$_instance->_class_loaders[$class_name])) {
158
-            self::$_instance->_class_loaders[$class_name] = $loader;
159
-            return true;
160
-        }
161
-        return false;
162
-    }
163
-
164
-
165
-
166
-    /**
167
-     * @return array
168
-     */
169
-    public function dependency_map()
170
-    {
171
-        return $this->_dependency_map;
172
-    }
173
-
174
-
175
-
176
-    /**
177
-     * returns TRUE if dependency map contains a listing for the provided class name
178
-     *
179
-     * @param string $class_name
180
-     * @return boolean
181
-     */
182
-    public function has($class_name = '')
183
-    {
184
-        return isset($this->_dependency_map[$class_name]) ? true : false;
185
-    }
186
-
187
-
188
-
189
-    /**
190
-     * returns TRUE if dependency map contains a listing for the provided class name AND dependency
191
-     *
192
-     * @param string $class_name
193
-     * @param string $dependency
194
-     * @return bool
195
-     */
196
-    public function has_dependency_for_class($class_name = '', $dependency = '')
197
-    {
198
-        $dependency = $this->get_alias($dependency);
199
-        return isset($this->_dependency_map[$class_name], $this->_dependency_map[$class_name][$dependency])
200
-            ? true
201
-            : false;
202
-    }
203
-
204
-
205
-
206
-    /**
207
-     * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
208
-     *
209
-     * @param string $class_name
210
-     * @param string $dependency
211
-     * @return int
212
-     */
213
-    public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
214
-    {
215
-        $dependency = $this->get_alias($dependency);
216
-        return $this->has_dependency_for_class($class_name, $dependency)
217
-            ? $this->_dependency_map[$class_name][$dependency]
218
-            : EE_Dependency_Map::not_registered;
219
-    }
220
-
221
-
222
-
223
-    /**
224
-     * @param string $class_name
225
-     * @return string | Closure
226
-     */
227
-    public function class_loader($class_name)
228
-    {
229
-        $class_name = $this->get_alias($class_name);
230
-        return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : '';
231
-    }
232
-
233
-
234
-
235
-    /**
236
-     * @return array
237
-     */
238
-    public function class_loaders()
239
-    {
240
-        return $this->_class_loaders;
241
-    }
242
-
243
-
244
-
245
-    /**
246
-     * adds an alias for a classname
247
-     *
248
-     * @param string $class_name
249
-     * @param string $alias
250
-     */
251
-    public function add_alias($class_name, $alias)
252
-    {
253
-        $this->_aliases[$class_name] = $alias;
254
-    }
255
-
256
-
257
-
258
-    /**
259
-     * returns TRUE if the provided class name has an alias
260
-     *
261
-     * @param string $class_name
262
-     * @return boolean
263
-     */
264
-    public function has_alias($class_name = '')
265
-    {
266
-        return isset($this->_aliases[$class_name]) ? true : false;
267
-    }
268
-
269
-
270
-
271
-    /**
272
-     * returns alias for class name if one exists, otherwise returns the original classname
273
-     * functions recursively, so that multiple aliases can be used to drill down to a classname
274
-     *  for example:
275
-     *      if the following two entries were added to the _aliases array:
276
-     *          array(
277
-     *              'interface_alias'           => 'some\namespace\interface'
278
-     *              'some\namespace\interface'  => 'some\namespace\classname'
279
-     *          )
280
-     *      then one could use EE_Registry::instance()->create( 'interface_alias' )
281
-     *      to load an instance of 'some\namespace\classname'
282
-     *
283
-     * @param string $class_name
284
-     * @return string
285
-     */
286
-    public function get_alias($class_name = '')
287
-    {
288
-        return $this->has_alias($class_name)
289
-            ? $this->get_alias($this->_aliases[$class_name])
290
-            : $class_name;
291
-    }
292
-
293
-
294
-
295
-    /**
296
-     * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
297
-     * if one exists, or whether a new object should be generated every time the requested class is loaded.
298
-     * This is done by using the following class constants:
299
-     *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
300
-     *        EE_Dependency_Map::load_new_object - generates a new object every time
301
-     */
302
-    protected function _register_core_dependencies()
303
-    {
304
-        $this->_dependency_map = array(
305
-            'EE_Request_Handler'                                                                                          => array(
306
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
307
-            ),
308
-            'EE_System'                                                                                                   => array(
309
-                'EE_Registry' => EE_Dependency_Map::load_from_cache,
310
-            ),
311
-            'EE_Session'                                                                                                  => array(
312
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
313
-                'EE_Encryption'                                           => EE_Dependency_Map::load_from_cache,
314
-            ),
315
-            'EE_Cart'                                                                                                     => array(
316
-                'EE_Session' => EE_Dependency_Map::load_from_cache,
317
-            ),
318
-            'EE_Front_Controller'                                                                                         => array(
319
-                'EE_Registry'              => EE_Dependency_Map::load_from_cache,
320
-                'EE_Request_Handler'       => EE_Dependency_Map::load_from_cache,
321
-                'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache,
322
-            ),
323
-            'EE_Messenger_Collection_Loader'                                                                              => array(
324
-                'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
325
-            ),
326
-            'EE_Message_Type_Collection_Loader'                                                                           => array(
327
-                'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
328
-            ),
329
-            'EE_Message_Resource_Manager'                                                                                 => array(
330
-                'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
331
-                'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
332
-                'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
333
-            ),
334
-            'EE_Message_Factory'                                                                                          => array(
335
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
336
-            ),
337
-            'EE_messages'                                                                                                 => array(
338
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
339
-            ),
340
-            'EE_Messages_Generator'                                                                                       => array(
341
-                'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
342
-                'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
343
-                'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
344
-                'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
345
-            ),
346
-            'EE_Messages_Processor'                                                                                       => array(
347
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
348
-            ),
349
-            'EE_Messages_Queue'                                                                                           => array(
350
-                'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
351
-            ),
352
-            'EE_Messages_Template_Defaults'                                                                               => array(
353
-                'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
354
-                'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
355
-            ),
356
-            'EE_Message_To_Generate_From_Request'                                                                         => array(
357
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
358
-                'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
359
-            ),
360
-            'EventEspresso\core\services\commands\CommandBus'                                                             => array(
361
-                'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
362
-            ),
363
-            'EventEspresso\services\commands\CommandHandler'                                                              => array(
364
-                'EE_Registry'         => EE_Dependency_Map::load_from_cache,
365
-                'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
366
-            ),
367
-            'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => array(
368
-                'EE_Registry' => EE_Dependency_Map::load_from_cache,
369
-            ),
370
-            'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => array(
371
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
372
-            ),
373
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => array(
374
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
375
-            ),
376
-            'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => array(
377
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
378
-            ),
379
-            'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => array(
380
-                'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
381
-            ),
382
-            'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => array(
383
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
384
-            ),
385
-            'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => array(
386
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
387
-            ),
388
-            'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => array(
389
-                'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
390
-            ),
391
-            'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array(
392
-                'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
393
-            ),
394
-            'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => array(
395
-                'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
396
-            ),
397
-            'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => array(
398
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
399
-            ),
400
-            'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => array(
401
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
402
-            ),
403
-            'EventEspresso\core\services\database\TableManager'                                                           => array(
404
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
405
-            ),
406
-            'EE_Data_Migration_Class_Base'                                                                                => array(
407
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
408
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
409
-            ),
410
-            'EE_DMS_Core_4_1_0'                                                                                           => array(
411
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
412
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
413
-            ),
414
-            'EE_DMS_Core_4_2_0'                                                                                           => array(
415
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
416
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
417
-            ),
418
-            'EE_DMS_Core_4_3_0'                                                                                           => array(
419
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
420
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
421
-            ),
422
-            'EE_DMS_Core_4_4_0'                                                                                           => array(
423
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
424
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
425
-            ),
426
-            'EE_DMS_Core_4_5_0'                                                                                           => array(
427
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
428
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
429
-            ),
430
-            'EE_DMS_Core_4_6_0'                                                                                           => array(
431
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
432
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
433
-            ),
434
-            'EE_DMS_Core_4_7_0'                                                                                           => array(
435
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
436
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
437
-            ),
438
-            'EE_DMS_Core_4_8_0'                                                                                           => array(
439
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
440
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
441
-            ),
442
-            'EE_DMS_Core_4_9_0'                                                                                           => array(
443
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
444
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
445
-            ),
446
-            'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled'                                             => array(
447
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
448
-            ),
449
-            'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout'                                              => array(
450
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
451
-            ),
452
-            'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees'                                        => array(
453
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
454
-            ),
455
-            'EventEspresso\core\domain\entities\shortcodes\EspressoEvents'                                                => array(
456
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
457
-            ),
458
-            'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou'                                              => array(
459
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
460
-            ),
461
-            'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector'                                        => array(
462
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
463
-            ),
464
-            'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage'                                               => array(
465
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
466
-            ),
467
-            'EventEspresso\core\services\cache\BasicCacheManager'                                                         => array(
468
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
469
-            ),
470
-            'EventEspresso\core\services\cache\PostRelatedCacheManager'                                                   => array(
471
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
472
-            ),
473
-        );
474
-    }
475
-
476
-
477
-
478
-    /**
479
-     * Registers how core classes are loaded.
480
-     * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
481
-     *        'EE_Request_Handler' => 'load_core'
482
-     *        'EE_Messages_Queue'  => 'load_lib'
483
-     *        'EEH_Debug_Tools'    => 'load_helper'
484
-     * or, if greater control is required, by providing a custom closure. For example:
485
-     *        'Some_Class' => function () {
486
-     *            return new Some_Class();
487
-     *        },
488
-     * This is required for instantiating dependencies
489
-     * where an interface has been type hinted in a class constructor. For example:
490
-     *        'Required_Interface' => function () {
491
-     *            return new A_Class_That_Implements_Required_Interface();
492
-     *        },
493
-     */
494
-    protected function _register_core_class_loaders()
495
-    {
496
-        //for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot
497
-        //be used in a closure.
498
-        $request = &$this->_request;
499
-        $response = &$this->_response;
500
-        $this->_class_loaders = array(
501
-            //load_core
502
-            'EE_Capabilities'                      => 'load_core',
503
-            'EE_Encryption'                        => 'load_core',
504
-            'EE_Front_Controller'                  => 'load_core',
505
-            'EE_Module_Request_Router'             => 'load_core',
506
-            'EE_Registry'                          => 'load_core',
507
-            'EE_Request'                           => function () use (&$request) {
508
-                return $request;
509
-            },
510
-            'EE_Response'                          => function () use (&$response) {
511
-                return $response;
512
-            },
513
-            'EE_Request_Handler'                   => 'load_core',
514
-            'EE_Session'                           => 'load_core',
515
-            'EE_System'                            => 'load_core',
516
-            //load_lib
517
-            'EE_Message_Resource_Manager'          => 'load_lib',
518
-            'EE_Message_Type_Collection'           => 'load_lib',
519
-            'EE_Message_Type_Collection_Loader'    => 'load_lib',
520
-            'EE_Messenger_Collection'              => 'load_lib',
521
-            'EE_Messenger_Collection_Loader'       => 'load_lib',
522
-            'EE_Messages_Processor'                => 'load_lib',
523
-            'EE_Message_Repository'                => 'load_lib',
524
-            'EE_Messages_Queue'                    => 'load_lib',
525
-            'EE_Messages_Data_Handler_Collection'  => 'load_lib',
526
-            'EE_Message_Template_Group_Collection' => 'load_lib',
527
-            'EE_Messages_Generator'                => function () {
528
-                return EE_Registry::instance()->load_lib('Messages_Generator', array(), false, false);
529
-            },
530
-            'EE_Messages_Template_Defaults'        => function ($arguments = array()) {
531
-                return EE_Registry::instance()->load_lib('Messages_Template_Defaults', $arguments, false, false);
532
-            },
533
-            //load_model
534
-            'EEM_Message_Template_Group'           => 'load_model',
535
-            'EEM_Message_Template'                 => 'load_model',
536
-            //load_helper
537
-            'EEH_Parse_Shortcodes'                 => function () {
538
-                if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
539
-                    return new EEH_Parse_Shortcodes();
540
-                }
541
-                return null;
542
-            },
543
-        );
544
-    }
545
-
546
-
547
-
548
-    /**
549
-     * can be used for supplying alternate names for classes,
550
-     * or for connecting interface names to instantiable classes
551
-     */
552
-    protected function _register_core_aliases()
553
-    {
554
-        $this->_aliases = array(
555
-            'CommandBusInterface'                                                 => 'EventEspresso\core\services\commands\CommandBusInterface',
556
-            'EventEspresso\core\services\commands\CommandBusInterface'            => 'EventEspresso\core\services\commands\CommandBus',
557
-            'CommandHandlerManagerInterface'                                      => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
558
-            'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager',
559
-            'CapChecker'                                                          => 'EventEspresso\core\services\commands\middleware\CapChecker',
560
-            'CapabilitiesChecker'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
561
-            'CreateRegistrationService'                                           => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
562
-            'CreateRegCodeCommandHandler'                                         => 'EventEspresso\core\services\commands\registration\CreateRegCodeCommand',
563
-            'CreateRegUrlLinkCommandHandler'                                      => 'EventEspresso\core\services\commands\registration\CreateRegUrlLinkCommand',
564
-            'CreateRegistrationCommandHandler'                                    => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
565
-            'CopyRegistrationDetailsCommandHandler'                               => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
566
-            'CopyRegistrationPaymentsCommandHandler'                              => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
567
-            'CancelRegistrationAndTicketLineItemCommandHandler'                   => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
568
-            'UpdateRegistrationAndTransactionAfterChangeCommandHandler'           => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
569
-            'CreateTicketLineItemCommandHandler'                                  => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
570
-            'TableManager'                                                        => 'EventEspresso\core\services\database\TableManager',
571
-            'TableAnalysis'                                                       => 'EventEspresso\core\services\database\TableAnalysis',
572
-            'EspressoShortcode'                                                   => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
573
-            'ShortcodeInterface'                                                  => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
574
-            'EventEspresso\core\services\shortcodes\ShortcodeInterface'           => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
575
-            'EventEspresso\core\services\cache\CacheStorageInterface'             => 'EventEspresso\core\services\cache\TransientCacheStorage',
576
-        );
577
-    }
578
-
579
-
580
-
581
-    /**
582
-     * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
583
-     * request Primarily used by unit tests.
584
-     */
585
-    public function reset()
586
-    {
587
-        $this->_register_core_class_loaders();
588
-        $this->_register_core_dependencies();
589
-    }
21
+	/**
22
+	 * This means that the requested class dependency is not present in the dependency map
23
+	 */
24
+	const not_registered = 0;
25
+
26
+
27
+	/**
28
+	 * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
29
+	 */
30
+	const load_new_object = 1;
31
+
32
+	/**
33
+	 * This instructs class loaders to return a previously instantiated and cached object for the requested class.
34
+	 * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
35
+	 */
36
+	const load_from_cache = 2;
37
+
38
+	/**
39
+	 * @type EE_Dependency_Map $_instance
40
+	 */
41
+	protected static $_instance;
42
+
43
+	/**
44
+	 * @type EE_Request $request
45
+	 */
46
+	protected $_request;
47
+
48
+	/**
49
+	 * @type EE_Response $response
50
+	 */
51
+	protected $_response;
52
+
53
+
54
+	/**
55
+	 * @type array $_dependency_map
56
+	 */
57
+	protected $_dependency_map = array();
58
+
59
+	/**
60
+	 * @type array $_class_loaders
61
+	 */
62
+	protected $_class_loaders = array();
63
+
64
+	/**
65
+	 * @type array $_aliases
66
+	 */
67
+	protected $_aliases = array();
68
+
69
+
70
+
71
+	/**
72
+	 * EE_Dependency_Map constructor.
73
+	 *
74
+	 * @param EE_Request  $request
75
+	 * @param EE_Response $response
76
+	 */
77
+	protected function __construct(EE_Request $request, EE_Response $response)
78
+	{
79
+		$this->_request = $request;
80
+		$this->_response = $response;
81
+		add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize'));
82
+		do_action('EE_Dependency_Map____construct');
83
+	}
84
+
85
+
86
+
87
+	/**
88
+	 */
89
+	public function initialize()
90
+	{
91
+		$this->_register_core_dependencies();
92
+		$this->_register_core_class_loaders();
93
+		$this->_register_core_aliases();
94
+	}
95
+
96
+
97
+
98
+	/**
99
+	 * @singleton method used to instantiate class object
100
+	 * @access    public
101
+	 * @param EE_Request  $request
102
+	 * @param EE_Response $response
103
+	 * @return EE_Dependency_Map instance
104
+	 */
105
+	public static function instance(EE_Request $request = null, EE_Response $response = null)
106
+	{
107
+		// check if class object is instantiated, and instantiated properly
108
+		if (! self::$_instance instanceof EE_Dependency_Map) {
109
+			self::$_instance = new EE_Dependency_Map($request, $response);
110
+		}
111
+		return self::$_instance;
112
+	}
113
+
114
+
115
+
116
+	/**
117
+	 * @param string $class
118
+	 * @param array  $dependencies
119
+	 * @return boolean
120
+	 */
121
+	public static function register_dependencies($class, $dependencies)
122
+	{
123
+		if (! isset(self::$_instance->_dependency_map[$class])) {
124
+			// we need to make sure that any aliases used when registering a dependency
125
+			// get resolved to the correct class name
126
+			foreach ((array)$dependencies as $dependency => $load_source) {
127
+				$alias = self::$_instance->get_alias($dependency);
128
+				unset($dependencies[$dependency]);
129
+				$dependencies[$alias] = $load_source;
130
+			}
131
+			self::$_instance->_dependency_map[$class] = (array)$dependencies;
132
+			return true;
133
+		}
134
+		return false;
135
+	}
136
+
137
+
138
+
139
+	/**
140
+	 * @param string $class_name
141
+	 * @param string $loader
142
+	 * @return bool
143
+	 * @throws EE_Error
144
+	 */
145
+	public static function register_class_loader($class_name, $loader = 'load_core')
146
+	{
147
+		// check that loader method starts with "load_" and exists in EE_Registry
148
+		if (strpos($loader, 'load_') !== 0 || ! method_exists('EE_Registry', $loader)) {
149
+			throw new EE_Error(
150
+				sprintf(
151
+					__('"%1$s" is not a valid loader method on EE_Registry.', 'event_espresso'),
152
+					$loader
153
+				)
154
+			);
155
+		}
156
+		$class_name = self::$_instance->get_alias($class_name);
157
+		if (! isset(self::$_instance->_class_loaders[$class_name])) {
158
+			self::$_instance->_class_loaders[$class_name] = $loader;
159
+			return true;
160
+		}
161
+		return false;
162
+	}
163
+
164
+
165
+
166
+	/**
167
+	 * @return array
168
+	 */
169
+	public function dependency_map()
170
+	{
171
+		return $this->_dependency_map;
172
+	}
173
+
174
+
175
+
176
+	/**
177
+	 * returns TRUE if dependency map contains a listing for the provided class name
178
+	 *
179
+	 * @param string $class_name
180
+	 * @return boolean
181
+	 */
182
+	public function has($class_name = '')
183
+	{
184
+		return isset($this->_dependency_map[$class_name]) ? true : false;
185
+	}
186
+
187
+
188
+
189
+	/**
190
+	 * returns TRUE if dependency map contains a listing for the provided class name AND dependency
191
+	 *
192
+	 * @param string $class_name
193
+	 * @param string $dependency
194
+	 * @return bool
195
+	 */
196
+	public function has_dependency_for_class($class_name = '', $dependency = '')
197
+	{
198
+		$dependency = $this->get_alias($dependency);
199
+		return isset($this->_dependency_map[$class_name], $this->_dependency_map[$class_name][$dependency])
200
+			? true
201
+			: false;
202
+	}
203
+
204
+
205
+
206
+	/**
207
+	 * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
208
+	 *
209
+	 * @param string $class_name
210
+	 * @param string $dependency
211
+	 * @return int
212
+	 */
213
+	public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
214
+	{
215
+		$dependency = $this->get_alias($dependency);
216
+		return $this->has_dependency_for_class($class_name, $dependency)
217
+			? $this->_dependency_map[$class_name][$dependency]
218
+			: EE_Dependency_Map::not_registered;
219
+	}
220
+
221
+
222
+
223
+	/**
224
+	 * @param string $class_name
225
+	 * @return string | Closure
226
+	 */
227
+	public function class_loader($class_name)
228
+	{
229
+		$class_name = $this->get_alias($class_name);
230
+		return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : '';
231
+	}
232
+
233
+
234
+
235
+	/**
236
+	 * @return array
237
+	 */
238
+	public function class_loaders()
239
+	{
240
+		return $this->_class_loaders;
241
+	}
242
+
243
+
244
+
245
+	/**
246
+	 * adds an alias for a classname
247
+	 *
248
+	 * @param string $class_name
249
+	 * @param string $alias
250
+	 */
251
+	public function add_alias($class_name, $alias)
252
+	{
253
+		$this->_aliases[$class_name] = $alias;
254
+	}
255
+
256
+
257
+
258
+	/**
259
+	 * returns TRUE if the provided class name has an alias
260
+	 *
261
+	 * @param string $class_name
262
+	 * @return boolean
263
+	 */
264
+	public function has_alias($class_name = '')
265
+	{
266
+		return isset($this->_aliases[$class_name]) ? true : false;
267
+	}
268
+
269
+
270
+
271
+	/**
272
+	 * returns alias for class name if one exists, otherwise returns the original classname
273
+	 * functions recursively, so that multiple aliases can be used to drill down to a classname
274
+	 *  for example:
275
+	 *      if the following two entries were added to the _aliases array:
276
+	 *          array(
277
+	 *              'interface_alias'           => 'some\namespace\interface'
278
+	 *              'some\namespace\interface'  => 'some\namespace\classname'
279
+	 *          )
280
+	 *      then one could use EE_Registry::instance()->create( 'interface_alias' )
281
+	 *      to load an instance of 'some\namespace\classname'
282
+	 *
283
+	 * @param string $class_name
284
+	 * @return string
285
+	 */
286
+	public function get_alias($class_name = '')
287
+	{
288
+		return $this->has_alias($class_name)
289
+			? $this->get_alias($this->_aliases[$class_name])
290
+			: $class_name;
291
+	}
292
+
293
+
294
+
295
+	/**
296
+	 * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
297
+	 * if one exists, or whether a new object should be generated every time the requested class is loaded.
298
+	 * This is done by using the following class constants:
299
+	 *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
300
+	 *        EE_Dependency_Map::load_new_object - generates a new object every time
301
+	 */
302
+	protected function _register_core_dependencies()
303
+	{
304
+		$this->_dependency_map = array(
305
+			'EE_Request_Handler'                                                                                          => array(
306
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
307
+			),
308
+			'EE_System'                                                                                                   => array(
309
+				'EE_Registry' => EE_Dependency_Map::load_from_cache,
310
+			),
311
+			'EE_Session'                                                                                                  => array(
312
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
313
+				'EE_Encryption'                                           => EE_Dependency_Map::load_from_cache,
314
+			),
315
+			'EE_Cart'                                                                                                     => array(
316
+				'EE_Session' => EE_Dependency_Map::load_from_cache,
317
+			),
318
+			'EE_Front_Controller'                                                                                         => array(
319
+				'EE_Registry'              => EE_Dependency_Map::load_from_cache,
320
+				'EE_Request_Handler'       => EE_Dependency_Map::load_from_cache,
321
+				'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache,
322
+			),
323
+			'EE_Messenger_Collection_Loader'                                                                              => array(
324
+				'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
325
+			),
326
+			'EE_Message_Type_Collection_Loader'                                                                           => array(
327
+				'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
328
+			),
329
+			'EE_Message_Resource_Manager'                                                                                 => array(
330
+				'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
331
+				'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
332
+				'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
333
+			),
334
+			'EE_Message_Factory'                                                                                          => array(
335
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
336
+			),
337
+			'EE_messages'                                                                                                 => array(
338
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
339
+			),
340
+			'EE_Messages_Generator'                                                                                       => array(
341
+				'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
342
+				'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
343
+				'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
344
+				'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
345
+			),
346
+			'EE_Messages_Processor'                                                                                       => array(
347
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
348
+			),
349
+			'EE_Messages_Queue'                                                                                           => array(
350
+				'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
351
+			),
352
+			'EE_Messages_Template_Defaults'                                                                               => array(
353
+				'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
354
+				'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
355
+			),
356
+			'EE_Message_To_Generate_From_Request'                                                                         => array(
357
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
358
+				'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
359
+			),
360
+			'EventEspresso\core\services\commands\CommandBus'                                                             => array(
361
+				'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
362
+			),
363
+			'EventEspresso\services\commands\CommandHandler'                                                              => array(
364
+				'EE_Registry'         => EE_Dependency_Map::load_from_cache,
365
+				'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
366
+			),
367
+			'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => array(
368
+				'EE_Registry' => EE_Dependency_Map::load_from_cache,
369
+			),
370
+			'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => array(
371
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
372
+			),
373
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => array(
374
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
375
+			),
376
+			'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => array(
377
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
378
+			),
379
+			'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => array(
380
+				'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
381
+			),
382
+			'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => array(
383
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
384
+			),
385
+			'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => array(
386
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
387
+			),
388
+			'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => array(
389
+				'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
390
+			),
391
+			'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array(
392
+				'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
393
+			),
394
+			'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => array(
395
+				'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
396
+			),
397
+			'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => array(
398
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
399
+			),
400
+			'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => array(
401
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
402
+			),
403
+			'EventEspresso\core\services\database\TableManager'                                                           => array(
404
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
405
+			),
406
+			'EE_Data_Migration_Class_Base'                                                                                => array(
407
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
408
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
409
+			),
410
+			'EE_DMS_Core_4_1_0'                                                                                           => array(
411
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
412
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
413
+			),
414
+			'EE_DMS_Core_4_2_0'                                                                                           => array(
415
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
416
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
417
+			),
418
+			'EE_DMS_Core_4_3_0'                                                                                           => array(
419
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
420
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
421
+			),
422
+			'EE_DMS_Core_4_4_0'                                                                                           => array(
423
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
424
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
425
+			),
426
+			'EE_DMS_Core_4_5_0'                                                                                           => array(
427
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
428
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
429
+			),
430
+			'EE_DMS_Core_4_6_0'                                                                                           => array(
431
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
432
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
433
+			),
434
+			'EE_DMS_Core_4_7_0'                                                                                           => array(
435
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
436
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
437
+			),
438
+			'EE_DMS_Core_4_8_0'                                                                                           => array(
439
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
440
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
441
+			),
442
+			'EE_DMS_Core_4_9_0'                                                                                           => array(
443
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
444
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
445
+			),
446
+			'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled'                                             => array(
447
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
448
+			),
449
+			'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout'                                              => array(
450
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
451
+			),
452
+			'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees'                                        => array(
453
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
454
+			),
455
+			'EventEspresso\core\domain\entities\shortcodes\EspressoEvents'                                                => array(
456
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
457
+			),
458
+			'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou'                                              => array(
459
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
460
+			),
461
+			'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector'                                        => array(
462
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
463
+			),
464
+			'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage'                                               => array(
465
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
466
+			),
467
+			'EventEspresso\core\services\cache\BasicCacheManager'                                                         => array(
468
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
469
+			),
470
+			'EventEspresso\core\services\cache\PostRelatedCacheManager'                                                   => array(
471
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
472
+			),
473
+		);
474
+	}
475
+
476
+
477
+
478
+	/**
479
+	 * Registers how core classes are loaded.
480
+	 * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
481
+	 *        'EE_Request_Handler' => 'load_core'
482
+	 *        'EE_Messages_Queue'  => 'load_lib'
483
+	 *        'EEH_Debug_Tools'    => 'load_helper'
484
+	 * or, if greater control is required, by providing a custom closure. For example:
485
+	 *        'Some_Class' => function () {
486
+	 *            return new Some_Class();
487
+	 *        },
488
+	 * This is required for instantiating dependencies
489
+	 * where an interface has been type hinted in a class constructor. For example:
490
+	 *        'Required_Interface' => function () {
491
+	 *            return new A_Class_That_Implements_Required_Interface();
492
+	 *        },
493
+	 */
494
+	protected function _register_core_class_loaders()
495
+	{
496
+		//for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot
497
+		//be used in a closure.
498
+		$request = &$this->_request;
499
+		$response = &$this->_response;
500
+		$this->_class_loaders = array(
501
+			//load_core
502
+			'EE_Capabilities'                      => 'load_core',
503
+			'EE_Encryption'                        => 'load_core',
504
+			'EE_Front_Controller'                  => 'load_core',
505
+			'EE_Module_Request_Router'             => 'load_core',
506
+			'EE_Registry'                          => 'load_core',
507
+			'EE_Request'                           => function () use (&$request) {
508
+				return $request;
509
+			},
510
+			'EE_Response'                          => function () use (&$response) {
511
+				return $response;
512
+			},
513
+			'EE_Request_Handler'                   => 'load_core',
514
+			'EE_Session'                           => 'load_core',
515
+			'EE_System'                            => 'load_core',
516
+			//load_lib
517
+			'EE_Message_Resource_Manager'          => 'load_lib',
518
+			'EE_Message_Type_Collection'           => 'load_lib',
519
+			'EE_Message_Type_Collection_Loader'    => 'load_lib',
520
+			'EE_Messenger_Collection'              => 'load_lib',
521
+			'EE_Messenger_Collection_Loader'       => 'load_lib',
522
+			'EE_Messages_Processor'                => 'load_lib',
523
+			'EE_Message_Repository'                => 'load_lib',
524
+			'EE_Messages_Queue'                    => 'load_lib',
525
+			'EE_Messages_Data_Handler_Collection'  => 'load_lib',
526
+			'EE_Message_Template_Group_Collection' => 'load_lib',
527
+			'EE_Messages_Generator'                => function () {
528
+				return EE_Registry::instance()->load_lib('Messages_Generator', array(), false, false);
529
+			},
530
+			'EE_Messages_Template_Defaults'        => function ($arguments = array()) {
531
+				return EE_Registry::instance()->load_lib('Messages_Template_Defaults', $arguments, false, false);
532
+			},
533
+			//load_model
534
+			'EEM_Message_Template_Group'           => 'load_model',
535
+			'EEM_Message_Template'                 => 'load_model',
536
+			//load_helper
537
+			'EEH_Parse_Shortcodes'                 => function () {
538
+				if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
539
+					return new EEH_Parse_Shortcodes();
540
+				}
541
+				return null;
542
+			},
543
+		);
544
+	}
545
+
546
+
547
+
548
+	/**
549
+	 * can be used for supplying alternate names for classes,
550
+	 * or for connecting interface names to instantiable classes
551
+	 */
552
+	protected function _register_core_aliases()
553
+	{
554
+		$this->_aliases = array(
555
+			'CommandBusInterface'                                                 => 'EventEspresso\core\services\commands\CommandBusInterface',
556
+			'EventEspresso\core\services\commands\CommandBusInterface'            => 'EventEspresso\core\services\commands\CommandBus',
557
+			'CommandHandlerManagerInterface'                                      => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
558
+			'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager',
559
+			'CapChecker'                                                          => 'EventEspresso\core\services\commands\middleware\CapChecker',
560
+			'CapabilitiesChecker'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
561
+			'CreateRegistrationService'                                           => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
562
+			'CreateRegCodeCommandHandler'                                         => 'EventEspresso\core\services\commands\registration\CreateRegCodeCommand',
563
+			'CreateRegUrlLinkCommandHandler'                                      => 'EventEspresso\core\services\commands\registration\CreateRegUrlLinkCommand',
564
+			'CreateRegistrationCommandHandler'                                    => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
565
+			'CopyRegistrationDetailsCommandHandler'                               => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
566
+			'CopyRegistrationPaymentsCommandHandler'                              => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
567
+			'CancelRegistrationAndTicketLineItemCommandHandler'                   => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
568
+			'UpdateRegistrationAndTransactionAfterChangeCommandHandler'           => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
569
+			'CreateTicketLineItemCommandHandler'                                  => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
570
+			'TableManager'                                                        => 'EventEspresso\core\services\database\TableManager',
571
+			'TableAnalysis'                                                       => 'EventEspresso\core\services\database\TableAnalysis',
572
+			'EspressoShortcode'                                                   => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
573
+			'ShortcodeInterface'                                                  => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
574
+			'EventEspresso\core\services\shortcodes\ShortcodeInterface'           => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
575
+			'EventEspresso\core\services\cache\CacheStorageInterface'             => 'EventEspresso\core\services\cache\TransientCacheStorage',
576
+		);
577
+	}
578
+
579
+
580
+
581
+	/**
582
+	 * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
583
+	 * request Primarily used by unit tests.
584
+	 */
585
+	public function reset()
586
+	{
587
+		$this->_register_core_class_loaders();
588
+		$this->_register_core_dependencies();
589
+	}
590 590
 
591 591
 
592 592
 }
Please login to merge, or discard this patch.
core/domain/ConstantsAbstract.php 2 patches
Indentation   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -14,72 +14,72 @@
 block discarded – undo
14 14
  */
15 15
 abstract class ConstantsAbstract
16 16
 {
17
-    /**
18
-     * Equivalent to `__FILE__` for main plugin file.
19
-     * @var string
20
-     */
21
-    private static $plugin_file ='';
22
-
23
-
24
-    /**
25
-     * String indicating version for plugin
26
-     * @var string
27
-     */
28
-    private static $version = '';
29
-
30
-
31
-    /**
32
-     * Initializes internal static properties.
33
-     * @param $plugin_file
34
-     * @param $version
35
-     */
36
-    public static function init($plugin_file, $version)
37
-    {
38
-        self::$plugin_file = $plugin_file;
39
-        self::$version     = $version;
40
-    }
41
-
42
-
43
-    /**
44
-     * @return string
45
-     */
46
-    public static function pluginFile()
47
-    {
48
-        return self::$plugin_file;
49
-    }
50
-
51
-    /**
52
-     * @return string
53
-     */
54
-    public static function pluginBasename()
55
-    {
56
-        return plugin_basename(self::$plugin_file);
57
-    }
58
-
59
-    /**
60
-     * @return string
61
-     */
62
-    public static function pluginPath()
63
-    {
64
-        return plugin_dir_path(self::$plugin_file);
65
-    }
66
-
67
-
68
-    /**
69
-     * @return string
70
-     */
71
-    public static function pluginUrl()
72
-    {
73
-        return plugin_dir_url(self::$plugin_file);
74
-    }
75
-
76
-
77
-    /**
78
-     * @return string
79
-     */
80
-    public static function version()
81
-    {
82
-        return self::$version;
83
-    }
17
+	/**
18
+	 * Equivalent to `__FILE__` for main plugin file.
19
+	 * @var string
20
+	 */
21
+	private static $plugin_file ='';
22
+
23
+
24
+	/**
25
+	 * String indicating version for plugin
26
+	 * @var string
27
+	 */
28
+	private static $version = '';
29
+
30
+
31
+	/**
32
+	 * Initializes internal static properties.
33
+	 * @param $plugin_file
34
+	 * @param $version
35
+	 */
36
+	public static function init($plugin_file, $version)
37
+	{
38
+		self::$plugin_file = $plugin_file;
39
+		self::$version     = $version;
40
+	}
41
+
42
+
43
+	/**
44
+	 * @return string
45
+	 */
46
+	public static function pluginFile()
47
+	{
48
+		return self::$plugin_file;
49
+	}
50
+
51
+	/**
52
+	 * @return string
53
+	 */
54
+	public static function pluginBasename()
55
+	{
56
+		return plugin_basename(self::$plugin_file);
57
+	}
58
+
59
+	/**
60
+	 * @return string
61
+	 */
62
+	public static function pluginPath()
63
+	{
64
+		return plugin_dir_path(self::$plugin_file);
65
+	}
66
+
67
+
68
+	/**
69
+	 * @return string
70
+	 */
71
+	public static function pluginUrl()
72
+	{
73
+		return plugin_dir_url(self::$plugin_file);
74
+	}
75
+
76
+
77
+	/**
78
+	 * @return string
79
+	 */
80
+	public static function version()
81
+	{
82
+		return self::$version;
83
+	}
84 84
 
85 85
 }
86 86
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
      * Equivalent to `__FILE__` for main plugin file.
19 19
      * @var string
20 20
      */
21
-    private static $plugin_file ='';
21
+    private static $plugin_file = '';
22 22
 
23 23
 
24 24
     /**
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +219 added lines, -219 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('ABSPATH')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /*
5 5
   Plugin Name:		Event Espresso
@@ -40,243 +40,243 @@  discard block
 block discarded – undo
40 40
  * @since            4.0
41 41
  */
42 42
 if (function_exists('espresso_version')) {
43
-    /**
44
-     *    espresso_duplicate_plugin_error
45
-     *    displays if more than one version of EE is activated at the same time
46
-     */
47
-    function espresso_duplicate_plugin_error()
48
-    {
49
-        ?>
43
+	/**
44
+	 *    espresso_duplicate_plugin_error
45
+	 *    displays if more than one version of EE is activated at the same time
46
+	 */
47
+	function espresso_duplicate_plugin_error()
48
+	{
49
+		?>
50 50
         <div class="error">
51 51
             <p>
52 52
                 <?php echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                ); ?>
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+				); ?>
56 56
             </p>
57 57
         </div>
58 58
         <?php
59
-        espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-    }
59
+		espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+	}
61 61
 
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
65
-    if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
65
+	if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                            esc_html__(
79
-                                    'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                                    'event_espresso'
81
-                            ),
82
-                            EE_MIN_PHP_VER_REQUIRED,
83
-                            PHP_VERSION,
84
-                            '<br/>',
85
-                            '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+							esc_html__(
79
+									'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+									'event_espresso'
81
+							),
82
+							EE_MIN_PHP_VER_REQUIRED,
83
+							PHP_VERSION,
84
+							'<br/>',
85
+							'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        /**
97
-         * espresso_version
98
-         * Returns the plugin version
99
-         *
100
-         * @return string
101
-         */
102
-        function espresso_version()
103
-        {
104
-            return apply_filters('FHEE__espresso__espresso_version', '4.9.38.rc.035');
105
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		/**
97
+		 * espresso_version
98
+		 * Returns the plugin version
99
+		 *
100
+		 * @return string
101
+		 */
102
+		function espresso_version()
103
+		{
104
+			return apply_filters('FHEE__espresso__espresso_version', '4.9.38.rc.035');
105
+		}
106 106
 
107
-        // define versions
108
-        define('EVENT_ESPRESSO_VERSION', espresso_version());
109
-        define('EE_MIN_WP_VER_REQUIRED', '4.1');
110
-        define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2');
111
-        define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44');
112
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
113
-        //used to be DIRECTORY_SEPARATOR, but that caused issues on windows
114
-        if ( ! defined('DS')) {
115
-            define('DS', '/');
116
-        }
117
-        if ( ! defined('PS')) {
118
-            define('PS', PATH_SEPARATOR);
119
-        }
120
-        if ( ! defined('SP')) {
121
-            define('SP', ' ');
122
-        }
123
-        if ( ! defined('EENL')) {
124
-            define('EENL', "\n");
125
-        }
126
-        define('EE_SUPPORT_EMAIL', '[email protected]');
127
-        // define the plugin directory and URL
128
-        define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE));
129
-        define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE));
130
-        define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE));
131
-        // main root folder paths
132
-        define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS);
133
-        define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS);
134
-        define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS);
135
-        define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS);
136
-        define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS);
137
-        define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS);
138
-        define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS);
139
-        define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS);
140
-        // core system paths
141
-        define('EE_ADMIN', EE_CORE . 'admin' . DS);
142
-        define('EE_CPTS', EE_CORE . 'CPTs' . DS);
143
-        define('EE_CLASSES', EE_CORE . 'db_classes' . DS);
144
-        define('EE_INTERFACES', EE_CORE . 'interfaces' . DS);
145
-        define('EE_BUSINESS', EE_CORE . 'business' . DS);
146
-        define('EE_MODELS', EE_CORE . 'db_models' . DS);
147
-        define('EE_HELPERS', EE_CORE . 'helpers' . DS);
148
-        define('EE_LIBRARIES', EE_CORE . 'libraries' . DS);
149
-        define('EE_TEMPLATES', EE_CORE . 'templates' . DS);
150
-        define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS);
151
-        define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS);
152
-        define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS);
153
-        // gateways
154
-        define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS);
155
-        define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS);
156
-        // asset URL paths
157
-        define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS);
158
-        define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS);
159
-        define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS);
160
-        define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS);
161
-        define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/');
162
-        define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/');
163
-        // define upload paths
164
-        $uploads = wp_upload_dir();
165
-        // define the uploads directory and URL
166
-        define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS);
167
-        define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS);
168
-        // define the templates directory and URL
169
-        define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS);
170
-        define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS);
171
-        // define the gateway directory and URL
172
-        define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS);
173
-        define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS);
174
-        // languages folder/path
175
-        define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS);
176
-        define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS);
177
-        //check for dompdf fonts in uploads
178
-        if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) {
179
-            define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS);
180
-        }
181
-        //ajax constants
182
-        define(
183
-                'EE_FRONT_AJAX',
184
-                isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false
185
-        );
186
-        define(
187
-                'EE_ADMIN_AJAX',
188
-                isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false
189
-        );
190
-        //just a handy constant occasionally needed for finding values representing infinity in the DB
191
-        //you're better to use this than its straight value (currently -1) in case you ever
192
-        //want to change its default value! or find when -1 means infinity
193
-        define('EE_INF_IN_DB', -1);
194
-        define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX);
195
-        define('EE_DEBUG', false);
196
-        // for older WP versions
197
-        if ( ! defined('MONTH_IN_SECONDS')) {
198
-            define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30);
199
-        }
200
-        /**
201
-         *    espresso_plugin_activation
202
-         *    adds a wp-option to indicate that EE has been activated via the WP admin plugins page
203
-         */
204
-        function espresso_plugin_activation()
205
-        {
206
-            update_option('ee_espresso_activation', true);
207
-        }
107
+		// define versions
108
+		define('EVENT_ESPRESSO_VERSION', espresso_version());
109
+		define('EE_MIN_WP_VER_REQUIRED', '4.1');
110
+		define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2');
111
+		define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44');
112
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
113
+		//used to be DIRECTORY_SEPARATOR, but that caused issues on windows
114
+		if ( ! defined('DS')) {
115
+			define('DS', '/');
116
+		}
117
+		if ( ! defined('PS')) {
118
+			define('PS', PATH_SEPARATOR);
119
+		}
120
+		if ( ! defined('SP')) {
121
+			define('SP', ' ');
122
+		}
123
+		if ( ! defined('EENL')) {
124
+			define('EENL', "\n");
125
+		}
126
+		define('EE_SUPPORT_EMAIL', '[email protected]');
127
+		// define the plugin directory and URL
128
+		define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE));
129
+		define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE));
130
+		define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE));
131
+		// main root folder paths
132
+		define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS);
133
+		define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS);
134
+		define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS);
135
+		define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS);
136
+		define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS);
137
+		define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS);
138
+		define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS);
139
+		define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS);
140
+		// core system paths
141
+		define('EE_ADMIN', EE_CORE . 'admin' . DS);
142
+		define('EE_CPTS', EE_CORE . 'CPTs' . DS);
143
+		define('EE_CLASSES', EE_CORE . 'db_classes' . DS);
144
+		define('EE_INTERFACES', EE_CORE . 'interfaces' . DS);
145
+		define('EE_BUSINESS', EE_CORE . 'business' . DS);
146
+		define('EE_MODELS', EE_CORE . 'db_models' . DS);
147
+		define('EE_HELPERS', EE_CORE . 'helpers' . DS);
148
+		define('EE_LIBRARIES', EE_CORE . 'libraries' . DS);
149
+		define('EE_TEMPLATES', EE_CORE . 'templates' . DS);
150
+		define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS);
151
+		define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS);
152
+		define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS);
153
+		// gateways
154
+		define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS);
155
+		define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS);
156
+		// asset URL paths
157
+		define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS);
158
+		define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS);
159
+		define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS);
160
+		define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS);
161
+		define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/');
162
+		define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/');
163
+		// define upload paths
164
+		$uploads = wp_upload_dir();
165
+		// define the uploads directory and URL
166
+		define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS);
167
+		define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS);
168
+		// define the templates directory and URL
169
+		define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS);
170
+		define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS);
171
+		// define the gateway directory and URL
172
+		define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS);
173
+		define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS);
174
+		// languages folder/path
175
+		define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS);
176
+		define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS);
177
+		//check for dompdf fonts in uploads
178
+		if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) {
179
+			define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS);
180
+		}
181
+		//ajax constants
182
+		define(
183
+				'EE_FRONT_AJAX',
184
+				isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false
185
+		);
186
+		define(
187
+				'EE_ADMIN_AJAX',
188
+				isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false
189
+		);
190
+		//just a handy constant occasionally needed for finding values representing infinity in the DB
191
+		//you're better to use this than its straight value (currently -1) in case you ever
192
+		//want to change its default value! or find when -1 means infinity
193
+		define('EE_INF_IN_DB', -1);
194
+		define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX);
195
+		define('EE_DEBUG', false);
196
+		// for older WP versions
197
+		if ( ! defined('MONTH_IN_SECONDS')) {
198
+			define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30);
199
+		}
200
+		/**
201
+		 *    espresso_plugin_activation
202
+		 *    adds a wp-option to indicate that EE has been activated via the WP admin plugins page
203
+		 */
204
+		function espresso_plugin_activation()
205
+		{
206
+			update_option('ee_espresso_activation', true);
207
+		}
208 208
 
209
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
210
-        /**
211
-         *    espresso_load_error_handling
212
-         *    this function loads EE's class for handling exceptions and errors
213
-         */
214
-        function espresso_load_error_handling()
215
-        {
216
-            // load debugging tools
217
-            if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
218
-                require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');
219
-                EEH_Debug_Tools::instance();
220
-            }
221
-            // load error handling
222
-            if (is_readable(EE_CORE . 'EE_Error.core.php')) {
223
-                require_once(EE_CORE . 'EE_Error.core.php');
224
-            } else {
225
-                wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
226
-            }
227
-        }
209
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
210
+		/**
211
+		 *    espresso_load_error_handling
212
+		 *    this function loads EE's class for handling exceptions and errors
213
+		 */
214
+		function espresso_load_error_handling()
215
+		{
216
+			// load debugging tools
217
+			if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
218
+				require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');
219
+				EEH_Debug_Tools::instance();
220
+			}
221
+			// load error handling
222
+			if (is_readable(EE_CORE . 'EE_Error.core.php')) {
223
+				require_once(EE_CORE . 'EE_Error.core.php');
224
+			} else {
225
+				wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
226
+			}
227
+		}
228 228
 
229
-        /**
230
-         *    espresso_load_required
231
-         *    given a class name and path, this function will load that file or throw an exception
232
-         *
233
-         * @param    string $classname
234
-         * @param    string $full_path_to_file
235
-         * @throws    EE_Error
236
-         */
237
-        function espresso_load_required($classname, $full_path_to_file)
238
-        {
239
-            static $error_handling_loaded = false;
240
-            if ( ! $error_handling_loaded) {
241
-                espresso_load_error_handling();
242
-                $error_handling_loaded = true;
243
-            }
244
-            if (is_readable($full_path_to_file)) {
245
-                require_once($full_path_to_file);
246
-            } else {
247
-                throw new EE_Error (
248
-                        sprintf(
249
-                                esc_html__(
250
-                                        'The %s class file could not be located or is not readable due to file permissions.',
251
-                                        'event_espresso'
252
-                                ),
253
-                                $classname
254
-                        )
255
-                );
256
-            }
257
-        }
229
+		/**
230
+		 *    espresso_load_required
231
+		 *    given a class name and path, this function will load that file or throw an exception
232
+		 *
233
+		 * @param    string $classname
234
+		 * @param    string $full_path_to_file
235
+		 * @throws    EE_Error
236
+		 */
237
+		function espresso_load_required($classname, $full_path_to_file)
238
+		{
239
+			static $error_handling_loaded = false;
240
+			if ( ! $error_handling_loaded) {
241
+				espresso_load_error_handling();
242
+				$error_handling_loaded = true;
243
+			}
244
+			if (is_readable($full_path_to_file)) {
245
+				require_once($full_path_to_file);
246
+			} else {
247
+				throw new EE_Error (
248
+						sprintf(
249
+								esc_html__(
250
+										'The %s class file could not be located or is not readable due to file permissions.',
251
+										'event_espresso'
252
+								),
253
+								$classname
254
+						)
255
+				);
256
+			}
257
+		}
258 258
 
259
-        espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php');
260
-        espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php');
261
-        espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
262
-        new EE_Bootstrap();
263
-    }
259
+		espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php');
260
+		espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php');
261
+		espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
262
+		new EE_Bootstrap();
263
+	}
264 264
 }
265 265
 if ( ! function_exists('espresso_deactivate_plugin')) {
266
-    /**
267
-     *    deactivate_plugin
268
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
269
-     *
270
-     * @access public
271
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
272
-     * @return    void
273
-     */
274
-    function espresso_deactivate_plugin($plugin_basename = '')
275
-    {
276
-        if ( ! function_exists('deactivate_plugins')) {
277
-            require_once(ABSPATH . 'wp-admin/includes/plugin.php');
278
-        }
279
-        unset($_GET['activate'], $_REQUEST['activate']);
280
-        deactivate_plugins($plugin_basename);
281
-    }
266
+	/**
267
+	 *    deactivate_plugin
268
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
269
+	 *
270
+	 * @access public
271
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
272
+	 * @return    void
273
+	 */
274
+	function espresso_deactivate_plugin($plugin_basename = '')
275
+	{
276
+		if ( ! function_exists('deactivate_plugins')) {
277
+			require_once(ABSPATH . 'wp-admin/includes/plugin.php');
278
+		}
279
+		unset($_GET['activate'], $_REQUEST['activate']);
280
+		deactivate_plugins($plugin_basename);
281
+	}
282 282
 }
283 283
\ No newline at end of file
Please login to merge, or discard this patch.