Completed
Branch dev (02312e)
by
unknown
11:42 queued 04:50
created
admin_pages/registrations/EE_Registrations_List_Table.class.php 2 patches
Indentation   +1030 added lines, -1030 removed lines patch added patch discarded remove patch
@@ -14,599 +14,599 @@  discard block
 block discarded – undo
14 14
  */
15 15
 class EE_Registrations_List_Table extends EE_Admin_List_Table
16 16
 {
17
-    /**
18
-     * @var Registrations_Admin_Page
19
-     */
20
-    protected $_admin_page;
21
-
22
-    /**
23
-     * @var RegistrationsListTableUserCapabilities
24
-     */
25
-    protected $caps_handler;
26
-
27
-    /**
28
-     * @var array
29
-     */
30
-    private $_status;
31
-
32
-    /**
33
-     * An array of transaction details for the related transaction to the registration being processed.
34
-     * This is set via the _set_related_details method.
35
-     *
36
-     * @var array
37
-     */
38
-    protected $_transaction_details = [];
39
-
40
-    /**
41
-     * An array of event details for the related event to the registration being processed.
42
-     * This is set via the _set_related_details method.
43
-     *
44
-     * @var array
45
-     */
46
-    protected $_event_details = [];
47
-
48
-
49
-    /**
50
-     * @param Registrations_Admin_Page $admin_page
51
-     */
52
-    public function __construct(Registrations_Admin_Page $admin_page)
53
-    {
54
-        $this->caps_handler = new RegistrationsListTableUserCapabilities(EE_Registry::instance()->CAP);
55
-        $req_data = $admin_page->get_request_data();
56
-        if (! empty($req_data['event_id'])) {
57
-            $extra_query_args = [];
58
-            foreach ($admin_page->get_views() as $view_details) {
59
-                $extra_query_args[ $view_details['slug'] ] = ['event_id' => $req_data['event_id']];
60
-            }
61
-            $this->_views = $admin_page->get_list_table_view_RLs($extra_query_args);
62
-        }
63
-        parent::__construct($admin_page);
64
-        $this->_status = $this->_admin_page->get_registration_status_array();
65
-    }
66
-
67
-
68
-    /**
69
-     * @return void
70
-     * @throws EE_Error
71
-     */
72
-    protected function _setup_data()
73
-    {
74
-        $this->_data           = $this->_admin_page->get_registrations($this->_per_page);
75
-        $this->_all_data_count = $this->_admin_page->get_registrations($this->_per_page, true);
76
-    }
77
-
78
-
79
-    /**
80
-     * @return void
81
-     */
82
-    protected function _set_properties()
83
-    {
84
-        $return_url          = $this->getReturnUrl();
85
-        $this->_wp_list_args = [
86
-            'singular' => esc_html__('registration', 'event_espresso'),
87
-            'plural'   => esc_html__('registrations', 'event_espresso'),
88
-            'ajax'     => true,
89
-            'screen'   => $this->_admin_page->get_current_screen()->id,
90
-        ];
91
-        $req_data            = $this->_admin_page->get_request_data();
92
-        if (isset($req_data['event_id'])) {
93
-            $this->_columns        = [
94
-                'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
95
-                'id'               => esc_html__('ID', 'event_espresso'),
96
-                'ATT_fname'        => esc_html__('Name', 'event_espresso'),
97
-                'ATT_email'        => esc_html__('Email', 'event_espresso'),
98
-                '_REG_date'        => esc_html__('Reg Date', 'event_espresso'),
99
-                'PRC_amount'       => esc_html__('TKT Price', 'event_espresso'),
100
-                '_REG_final_price' => esc_html__('Final Price', 'event_espresso'),
101
-                'TXN_total'        => esc_html__('Total Txn', 'event_espresso'),
102
-                'TXN_paid'         => esc_html__('Paid', 'event_espresso'),
103
-                'actions'          => $this->actionsColumnHeader(),
104
-            ];
105
-            $route_details = [
106
-                'route'         => 'registrations_report',
107
-                'extra_request' => [
108
-                    'EVT_ID'     => $this->_req_data['event_id'],
109
-                    'return_url' => $return_url,
110
-                ]
111
-            ];
112
-            if (isset($req_data['datetime_id']) && $req_data['datetime_id']) {
113
-                $route_details['extra_request']['DTT_ID'] = $req_data['datetime_id'];
114
-                $this->_bottom_buttons['report_datetime'] = $route_details;
115
-            } else {
116
-                $this->_bottom_buttons['report'] = $route_details;
117
-            }
118
-        } else {
119
-            $this->_columns        = [
120
-                'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
121
-                'id'               => esc_html__('ID', 'event_espresso'),
122
-                'ATT_fname'        => esc_html__('Name', 'event_espresso'),
123
-                '_REG_date'        => esc_html__('TXN Date', 'event_espresso'),
124
-                'event_name'       => esc_html__('Event', 'event_espresso'),
125
-                'DTT_EVT_start'    => esc_html__('Event Date', 'event_espresso'),
126
-                '_REG_final_price' => esc_html__('Price', 'event_espresso'),
127
-                '_REG_paid'        => esc_html__('Paid', 'event_espresso'),
128
-                'actions'          => $this->actionsColumnHeader(),
129
-            ];
130
-            $this->_bottom_buttons = [
131
-                'report_all' => [
132
-                    'route'         => 'registrations_report',
133
-                    'extra_request' => [
134
-                        'return_url' => $return_url,
135
-                    ],
136
-                ],
137
-            ];
138
-        }
139
-        $this->_bottom_buttons['report_filtered'] = [
140
-            'route'         => 'registrations_report',
141
-            'extra_request' => [
142
-                'use_filters' => true,
143
-                'return_url'  => $return_url,
144
-            ],
145
-        ];
146
-        $filters                                  = array_diff_key(
147
-            $this->_req_data,
148
-            array_flip(
149
-                [
150
-                    'page',
151
-                    'action',
152
-                    'default_nonce',
153
-                ]
154
-            )
155
-        );
156
-        if (! empty($filters)) {
157
-            $this->_bottom_buttons['report_filtered']['extra_request']['filters'] = $filters;
158
-        }
159
-        $this->_primary_column   = 'id';
160
-        $this->_sortable_columns = [
161
-            '_REG_date'     => ['_REG_date' => true],   // true means its already sorted
162
-            /**
163
-             * Allows users to change the default sort if they wish.
164
-             * Returning a falsey on this filter will result in the default sort to be by firstname rather than last
165
-             * name.
166
-             */
167
-            'ATT_fname'     => [
168
-                'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name',
169
-                true,
170
-                $this,
171
-            ]
172
-                ? ['ATT_lname' => false]
173
-                : ['ATT_fname' => false],
174
-            'event_name'    => ['event_name' => false],
175
-            'DTT_EVT_start' => ['DTT_EVT_start' => false],
176
-            'id'            => ['REG_ID' => false],
177
-        ];
178
-        $this->_hidden_columns   = [];
179
-    }
180
-
181
-
182
-    /**
183
-     * This simply sets up the row class for the table rows.
184
-     * Allows for easier overriding of child methods for setting up sorting.
185
-     *
186
-     * @param EE_Registration $item the current item
187
-     * @return string
188
-     */
189
-    protected function _get_row_class($item): string
190
-    {
191
-        $class = parent::_get_row_class($item);
192
-        if ($this->_has_checkbox_column) {
193
-            $class .= ' has-checkbox-column';
194
-        }
195
-        return $class;
196
-    }
197
-
198
-
199
-    /**
200
-     * Set the $_transaction_details property if not set yet.
201
-     *
202
-     * @param EE_Registration $registration
203
-     * @throws EE_Error
204
-     * @throws InvalidArgumentException
205
-     * @throws ReflectionException
206
-     * @throws InvalidDataTypeException
207
-     * @throws InvalidInterfaceException
208
-     */
209
-    protected function _set_related_details(EE_Registration $registration)
210
-    {
211
-        $transaction                = $registration->get_first_related('Transaction');
212
-        $status                     = $transaction instanceof EE_Transaction
213
-            ? $transaction->status_ID()
214
-            : EEM_Transaction::failed_status_code;
215
-        $this->_transaction_details = [
216
-            'transaction' => $transaction,
217
-            'status'      => $status,
218
-            'id'          => $transaction instanceof EE_Transaction
219
-                ? $transaction->ID()
220
-                : 0,
221
-            'title_attr'  => sprintf(
222
-                esc_html__('View Transaction Details (%s)', 'event_espresso'),
223
-                EEH_Template::pretty_status($status, false, 'sentence')
224
-            ),
225
-        ];
226
-        try {
227
-            $event = $registration->event();
228
-        } catch (EntityNotFoundException $e) {
229
-            $event = null;
230
-        }
231
-        $status               = $event instanceof EE_Event
232
-            ? $event->get_active_status()
233
-            : EE_Datetime::inactive;
234
-        $this->_event_details = [
235
-            'event'      => $event,
236
-            'status'     => $status,
237
-            'id'         => $event instanceof EE_Event
238
-                ? $event->ID()
239
-                : 0,
240
-            'title_attr' => sprintf(
241
-                esc_html__('Edit Event (%s)', 'event_espresso'),
242
-                EEH_Template::pretty_status($status, false, 'sentence')
243
-            ),
244
-        ];
245
-    }
246
-
247
-
248
-    /**
249
-     * @return array
250
-     * @throws EE_Error
251
-     * @throws ReflectionException
252
-     */
253
-    protected function _get_table_filters(): array
254
-    {
255
-        $filters = [];
256
-        // todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as
257
-        // methods.
258
-        $cur_date     = $this->_req_data['month_range'] ?? '';
259
-        $cur_category = $this->_req_data['EVT_CAT'] ?? -1;
260
-        $reg_status   = $this->_req_data['_reg_status'] ?? '';
261
-        $filters[]    = EEH_Form_Fields::generate_registration_months_dropdown($cur_date, $reg_status, $cur_category);
262
-        $filters[]    = EEH_Form_Fields::generate_event_category_dropdown($cur_category);
263
-        $status       = [];
264
-        $status[]     = ['id' => 0, 'text' => esc_html__('Select Status', 'event_espresso')];
265
-        foreach ($this->_status as $key => $value) {
266
-            $status[] = ['id' => $key, 'text' => $value];
267
-        }
268
-        if ($this->_view !== 'incomplete') {
269
-            $filters[] = EEH_Form_Fields::select_input(
270
-                '_reg_status',
271
-                $status,
272
-                isset($this->_req_data['_reg_status'])
273
-                    ? strtoupper(sanitize_key($this->_req_data['_reg_status']))
274
-                    : ''
275
-            );
276
-        }
277
-        if (isset($this->_req_data['event_id'])) {
278
-            $filters[] = EEH_Form_Fields::hidden_input('event_id', $this->_req_data['event_id'], 'reg_event_id');
279
-        }
280
-        return $filters;
281
-    }
282
-
283
-
284
-    /**
285
-     * @return void
286
-     * @throws EE_Error
287
-     * @throws InvalidArgumentException
288
-     * @throws InvalidDataTypeException
289
-     * @throws InvalidInterfaceException
290
-     * @throws ReflectionException
291
-     */
292
-    protected function _add_view_counts()
293
-    {
294
-        $this->_views['all']['count']   = $this->_total_registrations();
295
-        $this->_views['month']['count'] = $this->_total_registrations_this_month();
296
-        $this->_views['today']['count'] = $this->_total_registrations_today();
297
-        if ($this->caps_handler->userCanTrashRegistrations()) {
298
-            $this->_views['incomplete']['count'] = $this->_total_registrations('incomplete');
299
-            $this->_views['trash']['count']      = $this->_total_registrations('trash');
300
-        }
301
-    }
302
-
303
-
304
-    /**
305
-     * @param string $view
306
-     * @return int
307
-     * @throws EE_Error
308
-     * @throws ReflectionException
309
-     */
310
-    protected function _total_registrations(string $view = ''): int
311
-    {
312
-        $_where = [];
313
-        $EVT_ID = isset($this->_req_data['event_id'])
314
-            ? absint($this->_req_data['event_id'])
315
-            : false;
316
-        if ($EVT_ID) {
317
-            $_where['EVT_ID'] = $EVT_ID;
318
-        }
319
-        switch ($view) {
320
-            case 'trash':
321
-                return EEM_Registration::instance()->count_deleted([$_where]);
322
-            case 'incomplete':
323
-                $_where['STS_ID'] = EEM_Registration::status_id_incomplete;
324
-                break;
325
-            default:
326
-                $_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete];
327
-        }
328
-        return EEM_Registration::instance()->count([$_where]);
329
-    }
330
-
331
-
332
-    /**
333
-     * @return int
334
-     * @throws EE_Error
335
-     * @throws ReflectionException
336
-     */
337
-    protected function _total_registrations_this_month(): int
338
-    {
339
-        $EVT_ID          = isset($this->_req_data['event_id'])
340
-            ? absint($this->_req_data['event_id'])
341
-            : false;
342
-        $_where          = $EVT_ID
343
-            ? ['EVT_ID' => $EVT_ID]
344
-            : [];
345
-        $this_year_r     = date('Y', current_time('timestamp'));
346
-        $time_start      = ' 00:00:00';
347
-        $time_end        = ' 23:59:59';
348
-        $this_month_r    = date('m', current_time('timestamp'));
349
-        $days_this_month = date('t', current_time('timestamp'));
350
-        // setup date query.
351
-        $beginning_string   = EEM_Registration::instance()->convert_datetime_for_query(
352
-            'REG_date',
353
-            $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start,
354
-            'Y-m-d H:i:s'
355
-        );
356
-        $end_string         = EEM_Registration::instance()->convert_datetime_for_query(
357
-            'REG_date',
358
-            $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
359
-            'Y-m-d H:i:s'
360
-        );
361
-        $_where['REG_date'] = [
362
-            'BETWEEN',
363
-            [
364
-                $beginning_string,
365
-                $end_string,
366
-            ],
367
-        ];
368
-        $_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
369
-        return EEM_Registration::instance()->count([$_where]);
370
-    }
371
-
372
-
373
-    /**
374
-     * @return int
375
-     * @throws EE_Error
376
-     * @throws ReflectionException
377
-     */
378
-    protected function _total_registrations_today(): int
379
-    {
380
-        $EVT_ID             = isset($this->_req_data['event_id'])
381
-            ? absint($this->_req_data['event_id'])
382
-            : false;
383
-        $_where             = $EVT_ID
384
-            ? ['EVT_ID' => $EVT_ID]
385
-            : [];
386
-        $current_date       = date('Y-m-d', current_time('timestamp'));
387
-        $time_start         = ' 00:00:00';
388
-        $time_end           = ' 23:59:59';
389
-        $_where['REG_date'] = [
390
-            'BETWEEN',
391
-            [
392
-                EEM_Registration::instance()->convert_datetime_for_query(
393
-                    'REG_date',
394
-                    $current_date . $time_start,
395
-                    'Y-m-d H:i:s'
396
-                ),
397
-                EEM_Registration::instance()->convert_datetime_for_query(
398
-                    'REG_date',
399
-                    $current_date . $time_end,
400
-                    'Y-m-d H:i:s'
401
-                ),
402
-            ],
403
-        ];
404
-        $_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
405
-        return EEM_Registration::instance()->count([$_where]);
406
-    }
407
-
408
-
409
-    /**
410
-     * @param EE_Registration $item
411
-     * @return string
412
-     * @throws EE_Error
413
-     * @throws InvalidArgumentException
414
-     * @throws InvalidDataTypeException
415
-     * @throws InvalidInterfaceException
416
-     * @throws ReflectionException
417
-     */
418
-    public function column_cb($item): string
419
-    {
420
-        /** checkbox/lock **/
421
-        $REG_ID        = $item->ID();
422
-        $transaction   = $item->get_first_related('Transaction');
423
-        $payment_count = $transaction instanceof EE_Transaction
424
-            ? $transaction->count_related('Payment')
425
-            : 0;
426
-
427
-        $content = '<input type="checkbox" name="_REG_ID[]" value="' . $REG_ID . '" />';
428
-        $content .= $payment_count > 0 || ! $this->caps_handler->userCanEditRegistration($item)
429
-            ? '<span class="ee-locked-entity dashicons dashicons-lock ee-aria-tooltip ee-aria-tooltip--big-box"
17
+	/**
18
+	 * @var Registrations_Admin_Page
19
+	 */
20
+	protected $_admin_page;
21
+
22
+	/**
23
+	 * @var RegistrationsListTableUserCapabilities
24
+	 */
25
+	protected $caps_handler;
26
+
27
+	/**
28
+	 * @var array
29
+	 */
30
+	private $_status;
31
+
32
+	/**
33
+	 * An array of transaction details for the related transaction to the registration being processed.
34
+	 * This is set via the _set_related_details method.
35
+	 *
36
+	 * @var array
37
+	 */
38
+	protected $_transaction_details = [];
39
+
40
+	/**
41
+	 * An array of event details for the related event to the registration being processed.
42
+	 * This is set via the _set_related_details method.
43
+	 *
44
+	 * @var array
45
+	 */
46
+	protected $_event_details = [];
47
+
48
+
49
+	/**
50
+	 * @param Registrations_Admin_Page $admin_page
51
+	 */
52
+	public function __construct(Registrations_Admin_Page $admin_page)
53
+	{
54
+		$this->caps_handler = new RegistrationsListTableUserCapabilities(EE_Registry::instance()->CAP);
55
+		$req_data = $admin_page->get_request_data();
56
+		if (! empty($req_data['event_id'])) {
57
+			$extra_query_args = [];
58
+			foreach ($admin_page->get_views() as $view_details) {
59
+				$extra_query_args[ $view_details['slug'] ] = ['event_id' => $req_data['event_id']];
60
+			}
61
+			$this->_views = $admin_page->get_list_table_view_RLs($extra_query_args);
62
+		}
63
+		parent::__construct($admin_page);
64
+		$this->_status = $this->_admin_page->get_registration_status_array();
65
+	}
66
+
67
+
68
+	/**
69
+	 * @return void
70
+	 * @throws EE_Error
71
+	 */
72
+	protected function _setup_data()
73
+	{
74
+		$this->_data           = $this->_admin_page->get_registrations($this->_per_page);
75
+		$this->_all_data_count = $this->_admin_page->get_registrations($this->_per_page, true);
76
+	}
77
+
78
+
79
+	/**
80
+	 * @return void
81
+	 */
82
+	protected function _set_properties()
83
+	{
84
+		$return_url          = $this->getReturnUrl();
85
+		$this->_wp_list_args = [
86
+			'singular' => esc_html__('registration', 'event_espresso'),
87
+			'plural'   => esc_html__('registrations', 'event_espresso'),
88
+			'ajax'     => true,
89
+			'screen'   => $this->_admin_page->get_current_screen()->id,
90
+		];
91
+		$req_data            = $this->_admin_page->get_request_data();
92
+		if (isset($req_data['event_id'])) {
93
+			$this->_columns        = [
94
+				'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
95
+				'id'               => esc_html__('ID', 'event_espresso'),
96
+				'ATT_fname'        => esc_html__('Name', 'event_espresso'),
97
+				'ATT_email'        => esc_html__('Email', 'event_espresso'),
98
+				'_REG_date'        => esc_html__('Reg Date', 'event_espresso'),
99
+				'PRC_amount'       => esc_html__('TKT Price', 'event_espresso'),
100
+				'_REG_final_price' => esc_html__('Final Price', 'event_espresso'),
101
+				'TXN_total'        => esc_html__('Total Txn', 'event_espresso'),
102
+				'TXN_paid'         => esc_html__('Paid', 'event_espresso'),
103
+				'actions'          => $this->actionsColumnHeader(),
104
+			];
105
+			$route_details = [
106
+				'route'         => 'registrations_report',
107
+				'extra_request' => [
108
+					'EVT_ID'     => $this->_req_data['event_id'],
109
+					'return_url' => $return_url,
110
+				]
111
+			];
112
+			if (isset($req_data['datetime_id']) && $req_data['datetime_id']) {
113
+				$route_details['extra_request']['DTT_ID'] = $req_data['datetime_id'];
114
+				$this->_bottom_buttons['report_datetime'] = $route_details;
115
+			} else {
116
+				$this->_bottom_buttons['report'] = $route_details;
117
+			}
118
+		} else {
119
+			$this->_columns        = [
120
+				'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
121
+				'id'               => esc_html__('ID', 'event_espresso'),
122
+				'ATT_fname'        => esc_html__('Name', 'event_espresso'),
123
+				'_REG_date'        => esc_html__('TXN Date', 'event_espresso'),
124
+				'event_name'       => esc_html__('Event', 'event_espresso'),
125
+				'DTT_EVT_start'    => esc_html__('Event Date', 'event_espresso'),
126
+				'_REG_final_price' => esc_html__('Price', 'event_espresso'),
127
+				'_REG_paid'        => esc_html__('Paid', 'event_espresso'),
128
+				'actions'          => $this->actionsColumnHeader(),
129
+			];
130
+			$this->_bottom_buttons = [
131
+				'report_all' => [
132
+					'route'         => 'registrations_report',
133
+					'extra_request' => [
134
+						'return_url' => $return_url,
135
+					],
136
+				],
137
+			];
138
+		}
139
+		$this->_bottom_buttons['report_filtered'] = [
140
+			'route'         => 'registrations_report',
141
+			'extra_request' => [
142
+				'use_filters' => true,
143
+				'return_url'  => $return_url,
144
+			],
145
+		];
146
+		$filters                                  = array_diff_key(
147
+			$this->_req_data,
148
+			array_flip(
149
+				[
150
+					'page',
151
+					'action',
152
+					'default_nonce',
153
+				]
154
+			)
155
+		);
156
+		if (! empty($filters)) {
157
+			$this->_bottom_buttons['report_filtered']['extra_request']['filters'] = $filters;
158
+		}
159
+		$this->_primary_column   = 'id';
160
+		$this->_sortable_columns = [
161
+			'_REG_date'     => ['_REG_date' => true],   // true means its already sorted
162
+			/**
163
+			 * Allows users to change the default sort if they wish.
164
+			 * Returning a falsey on this filter will result in the default sort to be by firstname rather than last
165
+			 * name.
166
+			 */
167
+			'ATT_fname'     => [
168
+				'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name',
169
+				true,
170
+				$this,
171
+			]
172
+				? ['ATT_lname' => false]
173
+				: ['ATT_fname' => false],
174
+			'event_name'    => ['event_name' => false],
175
+			'DTT_EVT_start' => ['DTT_EVT_start' => false],
176
+			'id'            => ['REG_ID' => false],
177
+		];
178
+		$this->_hidden_columns   = [];
179
+	}
180
+
181
+
182
+	/**
183
+	 * This simply sets up the row class for the table rows.
184
+	 * Allows for easier overriding of child methods for setting up sorting.
185
+	 *
186
+	 * @param EE_Registration $item the current item
187
+	 * @return string
188
+	 */
189
+	protected function _get_row_class($item): string
190
+	{
191
+		$class = parent::_get_row_class($item);
192
+		if ($this->_has_checkbox_column) {
193
+			$class .= ' has-checkbox-column';
194
+		}
195
+		return $class;
196
+	}
197
+
198
+
199
+	/**
200
+	 * Set the $_transaction_details property if not set yet.
201
+	 *
202
+	 * @param EE_Registration $registration
203
+	 * @throws EE_Error
204
+	 * @throws InvalidArgumentException
205
+	 * @throws ReflectionException
206
+	 * @throws InvalidDataTypeException
207
+	 * @throws InvalidInterfaceException
208
+	 */
209
+	protected function _set_related_details(EE_Registration $registration)
210
+	{
211
+		$transaction                = $registration->get_first_related('Transaction');
212
+		$status                     = $transaction instanceof EE_Transaction
213
+			? $transaction->status_ID()
214
+			: EEM_Transaction::failed_status_code;
215
+		$this->_transaction_details = [
216
+			'transaction' => $transaction,
217
+			'status'      => $status,
218
+			'id'          => $transaction instanceof EE_Transaction
219
+				? $transaction->ID()
220
+				: 0,
221
+			'title_attr'  => sprintf(
222
+				esc_html__('View Transaction Details (%s)', 'event_espresso'),
223
+				EEH_Template::pretty_status($status, false, 'sentence')
224
+			),
225
+		];
226
+		try {
227
+			$event = $registration->event();
228
+		} catch (EntityNotFoundException $e) {
229
+			$event = null;
230
+		}
231
+		$status               = $event instanceof EE_Event
232
+			? $event->get_active_status()
233
+			: EE_Datetime::inactive;
234
+		$this->_event_details = [
235
+			'event'      => $event,
236
+			'status'     => $status,
237
+			'id'         => $event instanceof EE_Event
238
+				? $event->ID()
239
+				: 0,
240
+			'title_attr' => sprintf(
241
+				esc_html__('Edit Event (%s)', 'event_espresso'),
242
+				EEH_Template::pretty_status($status, false, 'sentence')
243
+			),
244
+		];
245
+	}
246
+
247
+
248
+	/**
249
+	 * @return array
250
+	 * @throws EE_Error
251
+	 * @throws ReflectionException
252
+	 */
253
+	protected function _get_table_filters(): array
254
+	{
255
+		$filters = [];
256
+		// todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as
257
+		// methods.
258
+		$cur_date     = $this->_req_data['month_range'] ?? '';
259
+		$cur_category = $this->_req_data['EVT_CAT'] ?? -1;
260
+		$reg_status   = $this->_req_data['_reg_status'] ?? '';
261
+		$filters[]    = EEH_Form_Fields::generate_registration_months_dropdown($cur_date, $reg_status, $cur_category);
262
+		$filters[]    = EEH_Form_Fields::generate_event_category_dropdown($cur_category);
263
+		$status       = [];
264
+		$status[]     = ['id' => 0, 'text' => esc_html__('Select Status', 'event_espresso')];
265
+		foreach ($this->_status as $key => $value) {
266
+			$status[] = ['id' => $key, 'text' => $value];
267
+		}
268
+		if ($this->_view !== 'incomplete') {
269
+			$filters[] = EEH_Form_Fields::select_input(
270
+				'_reg_status',
271
+				$status,
272
+				isset($this->_req_data['_reg_status'])
273
+					? strtoupper(sanitize_key($this->_req_data['_reg_status']))
274
+					: ''
275
+			);
276
+		}
277
+		if (isset($this->_req_data['event_id'])) {
278
+			$filters[] = EEH_Form_Fields::hidden_input('event_id', $this->_req_data['event_id'], 'reg_event_id');
279
+		}
280
+		return $filters;
281
+	}
282
+
283
+
284
+	/**
285
+	 * @return void
286
+	 * @throws EE_Error
287
+	 * @throws InvalidArgumentException
288
+	 * @throws InvalidDataTypeException
289
+	 * @throws InvalidInterfaceException
290
+	 * @throws ReflectionException
291
+	 */
292
+	protected function _add_view_counts()
293
+	{
294
+		$this->_views['all']['count']   = $this->_total_registrations();
295
+		$this->_views['month']['count'] = $this->_total_registrations_this_month();
296
+		$this->_views['today']['count'] = $this->_total_registrations_today();
297
+		if ($this->caps_handler->userCanTrashRegistrations()) {
298
+			$this->_views['incomplete']['count'] = $this->_total_registrations('incomplete');
299
+			$this->_views['trash']['count']      = $this->_total_registrations('trash');
300
+		}
301
+	}
302
+
303
+
304
+	/**
305
+	 * @param string $view
306
+	 * @return int
307
+	 * @throws EE_Error
308
+	 * @throws ReflectionException
309
+	 */
310
+	protected function _total_registrations(string $view = ''): int
311
+	{
312
+		$_where = [];
313
+		$EVT_ID = isset($this->_req_data['event_id'])
314
+			? absint($this->_req_data['event_id'])
315
+			: false;
316
+		if ($EVT_ID) {
317
+			$_where['EVT_ID'] = $EVT_ID;
318
+		}
319
+		switch ($view) {
320
+			case 'trash':
321
+				return EEM_Registration::instance()->count_deleted([$_where]);
322
+			case 'incomplete':
323
+				$_where['STS_ID'] = EEM_Registration::status_id_incomplete;
324
+				break;
325
+			default:
326
+				$_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete];
327
+		}
328
+		return EEM_Registration::instance()->count([$_where]);
329
+	}
330
+
331
+
332
+	/**
333
+	 * @return int
334
+	 * @throws EE_Error
335
+	 * @throws ReflectionException
336
+	 */
337
+	protected function _total_registrations_this_month(): int
338
+	{
339
+		$EVT_ID          = isset($this->_req_data['event_id'])
340
+			? absint($this->_req_data['event_id'])
341
+			: false;
342
+		$_where          = $EVT_ID
343
+			? ['EVT_ID' => $EVT_ID]
344
+			: [];
345
+		$this_year_r     = date('Y', current_time('timestamp'));
346
+		$time_start      = ' 00:00:00';
347
+		$time_end        = ' 23:59:59';
348
+		$this_month_r    = date('m', current_time('timestamp'));
349
+		$days_this_month = date('t', current_time('timestamp'));
350
+		// setup date query.
351
+		$beginning_string   = EEM_Registration::instance()->convert_datetime_for_query(
352
+			'REG_date',
353
+			$this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start,
354
+			'Y-m-d H:i:s'
355
+		);
356
+		$end_string         = EEM_Registration::instance()->convert_datetime_for_query(
357
+			'REG_date',
358
+			$this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
359
+			'Y-m-d H:i:s'
360
+		);
361
+		$_where['REG_date'] = [
362
+			'BETWEEN',
363
+			[
364
+				$beginning_string,
365
+				$end_string,
366
+			],
367
+		];
368
+		$_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
369
+		return EEM_Registration::instance()->count([$_where]);
370
+	}
371
+
372
+
373
+	/**
374
+	 * @return int
375
+	 * @throws EE_Error
376
+	 * @throws ReflectionException
377
+	 */
378
+	protected function _total_registrations_today(): int
379
+	{
380
+		$EVT_ID             = isset($this->_req_data['event_id'])
381
+			? absint($this->_req_data['event_id'])
382
+			: false;
383
+		$_where             = $EVT_ID
384
+			? ['EVT_ID' => $EVT_ID]
385
+			: [];
386
+		$current_date       = date('Y-m-d', current_time('timestamp'));
387
+		$time_start         = ' 00:00:00';
388
+		$time_end           = ' 23:59:59';
389
+		$_where['REG_date'] = [
390
+			'BETWEEN',
391
+			[
392
+				EEM_Registration::instance()->convert_datetime_for_query(
393
+					'REG_date',
394
+					$current_date . $time_start,
395
+					'Y-m-d H:i:s'
396
+				),
397
+				EEM_Registration::instance()->convert_datetime_for_query(
398
+					'REG_date',
399
+					$current_date . $time_end,
400
+					'Y-m-d H:i:s'
401
+				),
402
+			],
403
+		];
404
+		$_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
405
+		return EEM_Registration::instance()->count([$_where]);
406
+	}
407
+
408
+
409
+	/**
410
+	 * @param EE_Registration $item
411
+	 * @return string
412
+	 * @throws EE_Error
413
+	 * @throws InvalidArgumentException
414
+	 * @throws InvalidDataTypeException
415
+	 * @throws InvalidInterfaceException
416
+	 * @throws ReflectionException
417
+	 */
418
+	public function column_cb($item): string
419
+	{
420
+		/** checkbox/lock **/
421
+		$REG_ID        = $item->ID();
422
+		$transaction   = $item->get_first_related('Transaction');
423
+		$payment_count = $transaction instanceof EE_Transaction
424
+			? $transaction->count_related('Payment')
425
+			: 0;
426
+
427
+		$content = '<input type="checkbox" name="_REG_ID[]" value="' . $REG_ID . '" />';
428
+		$content .= $payment_count > 0 || ! $this->caps_handler->userCanEditRegistration($item)
429
+			? '<span class="ee-locked-entity dashicons dashicons-lock ee-aria-tooltip ee-aria-tooltip--big-box"
430 430
                     aria-label="' . $this->lockedRegMessage() . '"></span>'
431
-            : '';
432
-        return $this->columnContent('cb', $content, 'center');
433
-    }
434
-
435
-
436
-    private function lockedRegMessage(): string
437
-    {
438
-        return esc_html__(
439
-            'This lock-icon means that this registration cannot be trashed.  Registrations that belong to a transaction that has payments cannot be trashed.  If you wish to trash this registration then you must delete all payments attached to the related transaction first.',
440
-            'event_espresso'
441
-        );
442
-    }
443
-
444
-
445
-    /**
446
-     * @param EE_Registration $registration
447
-     * @return string
448
-     * @throws EE_Error
449
-     * @throws InvalidArgumentException
450
-     * @throws InvalidDataTypeException
451
-     * @throws InvalidInterfaceException
452
-     * @throws ReflectionException
453
-     */
454
-    public function column_id(EE_Registration $registration): string
455
-    {
456
-        $content = '<span class="ee-entity-id">' . $registration->ID() . '</span>';
457
-        $content .= '<span class="show-on-mobile-view-only">';
458
-        $content .= $this->column_ATT_fname($registration, false);
459
-        $content .= '</span>';
460
-
461
-        return $this->columnContent('id', $content, 'end');
462
-    }
463
-
464
-
465
-    /**
466
-     * @param EE_Registration $registration
467
-     * @param bool            $prep_content
468
-     * @return string
469
-     * @throws EE_Error
470
-     * @throws ReflectionException
471
-     */
472
-    public function column_ATT_fname(EE_Registration $registration, bool $prep_content = true): string
473
-    {
474
-
475
-        $status         = esc_attr($registration->status_ID());
476
-        $pretty_status  = EEH_Template::pretty_status($status, false, 'sentence');
477
-        $prime_reg_star = $registration->count() === 1
478
-            ? '<sup><span class="dashicons dashicons-star-filled gold-icon"></span></sup>'
479
-            : '';
480
-
481
-        $group_count = '
431
+			: '';
432
+		return $this->columnContent('cb', $content, 'center');
433
+	}
434
+
435
+
436
+	private function lockedRegMessage(): string
437
+	{
438
+		return esc_html__(
439
+			'This lock-icon means that this registration cannot be trashed.  Registrations that belong to a transaction that has payments cannot be trashed.  If you wish to trash this registration then you must delete all payments attached to the related transaction first.',
440
+			'event_espresso'
441
+		);
442
+	}
443
+
444
+
445
+	/**
446
+	 * @param EE_Registration $registration
447
+	 * @return string
448
+	 * @throws EE_Error
449
+	 * @throws InvalidArgumentException
450
+	 * @throws InvalidDataTypeException
451
+	 * @throws InvalidInterfaceException
452
+	 * @throws ReflectionException
453
+	 */
454
+	public function column_id(EE_Registration $registration): string
455
+	{
456
+		$content = '<span class="ee-entity-id">' . $registration->ID() . '</span>';
457
+		$content .= '<span class="show-on-mobile-view-only">';
458
+		$content .= $this->column_ATT_fname($registration, false);
459
+		$content .= '</span>';
460
+
461
+		return $this->columnContent('id', $content, 'end');
462
+	}
463
+
464
+
465
+	/**
466
+	 * @param EE_Registration $registration
467
+	 * @param bool            $prep_content
468
+	 * @return string
469
+	 * @throws EE_Error
470
+	 * @throws ReflectionException
471
+	 */
472
+	public function column_ATT_fname(EE_Registration $registration, bool $prep_content = true): string
473
+	{
474
+
475
+		$status         = esc_attr($registration->status_ID());
476
+		$pretty_status  = EEH_Template::pretty_status($status, false, 'sentence');
477
+		$prime_reg_star = $registration->count() === 1
478
+			? '<sup><span class="dashicons dashicons-star-filled gold-icon"></span></sup>'
479
+			: '';
480
+
481
+		$group_count = '
482 482
             <span class="reg-count-group-size" >
483 483
                 ' . sprintf(
484
-            esc_html__('(%1$s / %2$s)', 'event_espresso'),
485
-            $registration->count(),
486
-            $registration->group_size()
487
-        ) . '
484
+			esc_html__('(%1$s / %2$s)', 'event_espresso'),
485
+			$registration->count(),
486
+			$registration->group_size()
487
+		) . '
488 488
             </span >';
489 489
 
490
-        $content = '
490
+		$content = '
491 491
         <div class="ee-layout-row">
492 492
             <span aria-label="' . $pretty_status . '"
493 493
                   class="ee-status-dot ee-status-bg--' . $status . ' ee-aria-tooltip"
494 494
             ></span>
495 495
             ' . $this->viewRegistrationLink($registration, $status)
496
-                   . $prime_reg_star
497
-                   . $group_count . '
496
+				   . $prime_reg_star
497
+				   . $group_count . '
498 498
             <span class="spacer"></span>
499 499
             <span>
500 500
                 ' . sprintf(
501
-                       esc_html__('Reg Code: %s', 'event_espresso'),
502
-                       $registration->get('REG_code')
503
-                   ) . '
501
+					   esc_html__('Reg Code: %s', 'event_espresso'),
502
+					   $registration->get('REG_code')
503
+				   ) . '
504 504
             </span>
505 505
         </div>';
506 506
 
507
-        $url_params = ['_REG_ID' => $registration->ID()];
508
-        if (isset($this->_req_data['event_id'])) {
509
-            $url_params['event_id'] = $registration->event_ID();
510
-        }
511
-        // trash/restore/delete actions
512
-        $actions = $this->trashRegistrationLink($registration, $url_params);
513
-        $actions = $this->restoreRegistrationLink($registration, $url_params, $actions);
514
-        $actions = $this->deleteRegistrationLink($registration, $url_params, $actions);
515
-
516
-        $content = sprintf('%1$s %2$s', $content, $this->row_actions($actions));
517
-
518
-        return $prep_content ? $this->columnContent('ATT_fname', $content) : $content;
519
-    }
520
-
521
-
522
-    /**
523
-     * @param EE_Registration $registration
524
-     * @param bool            $prep_content
525
-     * @return string
526
-     * @throws EE_Error
527
-     * @throws ReflectionException
528
-     */
529
-    public function column__REG_date(EE_Registration $registration, bool $prep_content = true): string
530
-    {
531
-        $this->_set_related_details($registration);
532
-        // Build row actions
533
-        $content = $this->caps_handler->userCanViewTransaction()
534
-            ? '<a class="ee-aria-tooltip ee-status-color--' . $this->_transaction_details['status'] . '" href="'
535
-              . $this->viewTransactionUrl()
536
-              . '" aria-label="'
537
-              . esc_attr($this->_transaction_details['title_attr'])
538
-              . '">'
539
-              . $registration->get_i18n_datetime('REG_date', 'M jS Y g:i a')
540
-              . '</a>'
541
-            : $registration->get_i18n_datetime('REG_date');
542
-
543
-        return $prep_content ? $this->columnContent('_REG_date', $content) : $content;
544
-    }
545
-
546
-
547
-    /**
548
-     * @param EE_Registration $registration
549
-     * @return string
550
-     * @throws EE_Error
551
-     * @throws InvalidArgumentException
552
-     * @throws InvalidDataTypeException
553
-     * @throws InvalidInterfaceException
554
-     * @throws ReflectionException
555
-     */
556
-    public function column_event_name(EE_Registration $registration): string
557
-    {
558
-        $this->_set_related_details($registration);
559
-        $EVT_ID     = $registration->event_ID();
560
-        $event_name = $registration->event_name();
561
-        $event_name = $event_name ?: esc_html__("No Associated Event", 'event_espresso');
562
-        $event_name = wp_trim_words($event_name, 30, '...');
563
-        $edit_event = $this->editEventLink($EVT_ID, $event_name);
564
-        $actions['event_filter'] = $this->eventFilterLink($EVT_ID, $event_name);
565
-        $content = sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions));
566
-
567
-        return $this->columnContent('event_name', $content);
568
-    }
569
-
570
-
571
-    /**
572
-     * @param EE_Registration $registration
573
-     * @return string
574
-     * @throws EE_Error
575
-     * @throws InvalidArgumentException
576
-     * @throws InvalidDataTypeException
577
-     * @throws InvalidInterfaceException
578
-     * @throws ReflectionException
579
-     */
580
-    public function column_DTT_EVT_start(EE_Registration $registration): string
581
-    {
582
-        $datetime_strings = [];
583
-        $ticket           = $registration->ticket();
584
-        if ($ticket instanceof EE_Ticket) {
585
-            $remove_defaults = ['default_where_conditions' => 'none'];
586
-            $datetimes       = $ticket->datetimes($remove_defaults);
587
-            foreach ($datetimes as $datetime) {
588
-                $datetime_strings[] = $datetime->get_i18n_datetime('DTT_EVT_start', 'M jS Y g:i a');
589
-            }
590
-            $content = $this->generateDisplayForDatetimes($datetime_strings);
591
-        } else {
592
-            $content = esc_html__('There is no ticket on this registration', 'event_espresso');
593
-        }
594
-        return $this->columnContent('DTT_EVT_start', $content);
595
-    }
596
-
597
-
598
-    /**
599
-     * Receives an array of datetime strings to display and converts them to the html container for the column.
600
-     *
601
-     * @param array $datetime_strings
602
-     * @return string
603
-     */
604
-    public function generateDisplayForDatetimes(array $datetime_strings): string
605
-    {
606
-        // get first item for initial visibility
607
-        $content = (string) array_shift($datetime_strings);
608
-        if (! empty($datetime_strings)) {
609
-            $content .= '
507
+		$url_params = ['_REG_ID' => $registration->ID()];
508
+		if (isset($this->_req_data['event_id'])) {
509
+			$url_params['event_id'] = $registration->event_ID();
510
+		}
511
+		// trash/restore/delete actions
512
+		$actions = $this->trashRegistrationLink($registration, $url_params);
513
+		$actions = $this->restoreRegistrationLink($registration, $url_params, $actions);
514
+		$actions = $this->deleteRegistrationLink($registration, $url_params, $actions);
515
+
516
+		$content = sprintf('%1$s %2$s', $content, $this->row_actions($actions));
517
+
518
+		return $prep_content ? $this->columnContent('ATT_fname', $content) : $content;
519
+	}
520
+
521
+
522
+	/**
523
+	 * @param EE_Registration $registration
524
+	 * @param bool            $prep_content
525
+	 * @return string
526
+	 * @throws EE_Error
527
+	 * @throws ReflectionException
528
+	 */
529
+	public function column__REG_date(EE_Registration $registration, bool $prep_content = true): string
530
+	{
531
+		$this->_set_related_details($registration);
532
+		// Build row actions
533
+		$content = $this->caps_handler->userCanViewTransaction()
534
+			? '<a class="ee-aria-tooltip ee-status-color--' . $this->_transaction_details['status'] . '" href="'
535
+			  . $this->viewTransactionUrl()
536
+			  . '" aria-label="'
537
+			  . esc_attr($this->_transaction_details['title_attr'])
538
+			  . '">'
539
+			  . $registration->get_i18n_datetime('REG_date', 'M jS Y g:i a')
540
+			  . '</a>'
541
+			: $registration->get_i18n_datetime('REG_date');
542
+
543
+		return $prep_content ? $this->columnContent('_REG_date', $content) : $content;
544
+	}
545
+
546
+
547
+	/**
548
+	 * @param EE_Registration $registration
549
+	 * @return string
550
+	 * @throws EE_Error
551
+	 * @throws InvalidArgumentException
552
+	 * @throws InvalidDataTypeException
553
+	 * @throws InvalidInterfaceException
554
+	 * @throws ReflectionException
555
+	 */
556
+	public function column_event_name(EE_Registration $registration): string
557
+	{
558
+		$this->_set_related_details($registration);
559
+		$EVT_ID     = $registration->event_ID();
560
+		$event_name = $registration->event_name();
561
+		$event_name = $event_name ?: esc_html__("No Associated Event", 'event_espresso');
562
+		$event_name = wp_trim_words($event_name, 30, '...');
563
+		$edit_event = $this->editEventLink($EVT_ID, $event_name);
564
+		$actions['event_filter'] = $this->eventFilterLink($EVT_ID, $event_name);
565
+		$content = sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions));
566
+
567
+		return $this->columnContent('event_name', $content);
568
+	}
569
+
570
+
571
+	/**
572
+	 * @param EE_Registration $registration
573
+	 * @return string
574
+	 * @throws EE_Error
575
+	 * @throws InvalidArgumentException
576
+	 * @throws InvalidDataTypeException
577
+	 * @throws InvalidInterfaceException
578
+	 * @throws ReflectionException
579
+	 */
580
+	public function column_DTT_EVT_start(EE_Registration $registration): string
581
+	{
582
+		$datetime_strings = [];
583
+		$ticket           = $registration->ticket();
584
+		if ($ticket instanceof EE_Ticket) {
585
+			$remove_defaults = ['default_where_conditions' => 'none'];
586
+			$datetimes       = $ticket->datetimes($remove_defaults);
587
+			foreach ($datetimes as $datetime) {
588
+				$datetime_strings[] = $datetime->get_i18n_datetime('DTT_EVT_start', 'M jS Y g:i a');
589
+			}
590
+			$content = $this->generateDisplayForDatetimes($datetime_strings);
591
+		} else {
592
+			$content = esc_html__('There is no ticket on this registration', 'event_espresso');
593
+		}
594
+		return $this->columnContent('DTT_EVT_start', $content);
595
+	}
596
+
597
+
598
+	/**
599
+	 * Receives an array of datetime strings to display and converts them to the html container for the column.
600
+	 *
601
+	 * @param array $datetime_strings
602
+	 * @return string
603
+	 */
604
+	public function generateDisplayForDatetimes(array $datetime_strings): string
605
+	{
606
+		// get first item for initial visibility
607
+		$content = (string) array_shift($datetime_strings);
608
+		if (! empty($datetime_strings)) {
609
+			$content .= '
610 610
                 <div class="ee-registration-event-datetimes-container-wrap">
611 611
                     <button aria-label="' . esc_attr__('Click to view all dates', 'event_espresso') . '"
612 612
                           class="ee-aria-tooltip button button--secondary button--tiny button--icon-only ee-js ee-more-datetimes-toggle"
@@ -617,539 +617,539 @@  discard block
 block discarded – undo
617 617
                         ' . implode("", $datetime_strings) . '
618 618
                     </div>
619 619
                 </div>';
620
-        }
621
-        return $content;
622
-    }
623
-
624
-
625
-    /**
626
-     * @param EE_Registration $registration
627
-     * @return string
628
-     * @throws EE_Error
629
-     * @throws InvalidArgumentException
630
-     * @throws InvalidDataTypeException
631
-     * @throws InvalidInterfaceException
632
-     * @throws ReflectionException
633
-     */
634
-    public function column_ATT_email(EE_Registration $registration): string
635
-    {
636
-        $attendee = $registration->get_first_related('Attendee');
637
-        $content  = ! $attendee instanceof EE_Attendee
638
-            ? esc_html__('No attached contact record.', 'event_espresso')
639
-            : $attendee->email();
640
-        return $this->columnContent('ATT_email', $content);
641
-    }
642
-
643
-
644
-    /**
645
-     * @param EE_Registration $registration
646
-     * @return string
647
-     */
648
-    public function column__REG_count(EE_Registration $registration): string
649
-    {
650
-        $content =
651
-            sprintf(esc_html__('%1$s / %2$s', 'event_espresso'), $registration->count(), $registration->group_size());
652
-        return $this->columnContent('_REG_count', $content);
653
-    }
654
-
655
-
656
-    /**
657
-     * @param EE_Registration $registration
658
-     * @return string
659
-     * @throws EE_Error
660
-     * @throws ReflectionException
661
-     */
662
-    public function column_PRC_amount(EE_Registration $registration): string
663
-    {
664
-        $ticket   = $registration->ticket();
665
-        $req_data = $this->_admin_page->get_request_data();
666
-
667
-        $content = isset($req_data['event_id']) && $ticket instanceof EE_Ticket
668
-            ? '<div class="TKT_name">' . $ticket->name() . '</div>'
669
-            : '';
670
-
671
-        $payment_status = $registration->owes_monies_and_can_pay() ? 'TFL' : 'TCM';
672
-        $content        .= $registration->final_price() > 0
673
-            ? '<span class="reg-overview-paid-event-spn ee-status-color--' . $payment_status . '">
620
+		}
621
+		return $content;
622
+	}
623
+
624
+
625
+	/**
626
+	 * @param EE_Registration $registration
627
+	 * @return string
628
+	 * @throws EE_Error
629
+	 * @throws InvalidArgumentException
630
+	 * @throws InvalidDataTypeException
631
+	 * @throws InvalidInterfaceException
632
+	 * @throws ReflectionException
633
+	 */
634
+	public function column_ATT_email(EE_Registration $registration): string
635
+	{
636
+		$attendee = $registration->get_first_related('Attendee');
637
+		$content  = ! $attendee instanceof EE_Attendee
638
+			? esc_html__('No attached contact record.', 'event_espresso')
639
+			: $attendee->email();
640
+		return $this->columnContent('ATT_email', $content);
641
+	}
642
+
643
+
644
+	/**
645
+	 * @param EE_Registration $registration
646
+	 * @return string
647
+	 */
648
+	public function column__REG_count(EE_Registration $registration): string
649
+	{
650
+		$content =
651
+			sprintf(esc_html__('%1$s / %2$s', 'event_espresso'), $registration->count(), $registration->group_size());
652
+		return $this->columnContent('_REG_count', $content);
653
+	}
654
+
655
+
656
+	/**
657
+	 * @param EE_Registration $registration
658
+	 * @return string
659
+	 * @throws EE_Error
660
+	 * @throws ReflectionException
661
+	 */
662
+	public function column_PRC_amount(EE_Registration $registration): string
663
+	{
664
+		$ticket   = $registration->ticket();
665
+		$req_data = $this->_admin_page->get_request_data();
666
+
667
+		$content = isset($req_data['event_id']) && $ticket instanceof EE_Ticket
668
+			? '<div class="TKT_name">' . $ticket->name() . '</div>'
669
+			: '';
670
+
671
+		$payment_status = $registration->owes_monies_and_can_pay() ? 'TFL' : 'TCM';
672
+		$content        .= $registration->final_price() > 0
673
+			? '<span class="reg-overview-paid-event-spn ee-status-color--' . $payment_status . '">
674 674
                 ' . $registration->pretty_final_price() . '
675 675
                </span>'
676
-            // free event
677
-            : '<span class="reg-overview-free-event-spn">' . esc_html__('free', 'event_espresso') . '</span>';
678
-
679
-        return $this->columnContent('PRC_amount', $content, 'end');
680
-    }
681
-
682
-
683
-    /**
684
-     * @param EE_Registration $registration
685
-     * @return string
686
-     * @throws EE_Error
687
-     * @throws ReflectionException
688
-     */
689
-    public function column__REG_final_price(EE_Registration $registration): string
690
-    {
691
-        $ticket   = $registration->ticket();
692
-        $req_data = $this->_admin_page->get_request_data();
693
-        $content  = isset($req_data['event_id']) || ! $ticket instanceof EE_Ticket
694
-            ? ''
695
-            : '<span class="TKT_name ee-status-color--'
696
-              . $ticket->ticket_status()
697
-              . '">'
698
-              . $ticket->name()
699
-              . '</span> ';
700
-
701
-        $content .= '
676
+			// free event
677
+			: '<span class="reg-overview-free-event-spn">' . esc_html__('free', 'event_espresso') . '</span>';
678
+
679
+		return $this->columnContent('PRC_amount', $content, 'end');
680
+	}
681
+
682
+
683
+	/**
684
+	 * @param EE_Registration $registration
685
+	 * @return string
686
+	 * @throws EE_Error
687
+	 * @throws ReflectionException
688
+	 */
689
+	public function column__REG_final_price(EE_Registration $registration): string
690
+	{
691
+		$ticket   = $registration->ticket();
692
+		$req_data = $this->_admin_page->get_request_data();
693
+		$content  = isset($req_data['event_id']) || ! $ticket instanceof EE_Ticket
694
+			? ''
695
+			: '<span class="TKT_name ee-status-color--'
696
+			  . $ticket->ticket_status()
697
+			  . '">'
698
+			  . $ticket->name()
699
+			  . '</span> ';
700
+
701
+		$content .= '
702 702
             <span class="reg-overview-paid-event-spn">
703 703
                 ' . $registration->pretty_final_price() . '
704 704
             </span>';
705
-        return $this->columnContent('_REG_final_price', $content, 'end');
706
-    }
707
-
708
-
709
-    /**
710
-     * @param EE_Registration $registration
711
-     * @return string
712
-     * @throws EE_Error
713
-     */
714
-    public function column__REG_paid(EE_Registration $registration): string
715
-    {
716
-        $payment_method      = $registration->payment_method();
717
-        $payment_method_name = $payment_method instanceof EE_Payment_Method
718
-            ? $payment_method->admin_name()
719
-            : esc_html__('Unknown', 'event_espresso');
720
-
721
-        $payment_status = $registration->owes_monies_and_can_pay() ? 'TFL' : 'TCM';
722
-        $content        = '
705
+		return $this->columnContent('_REG_final_price', $content, 'end');
706
+	}
707
+
708
+
709
+	/**
710
+	 * @param EE_Registration $registration
711
+	 * @return string
712
+	 * @throws EE_Error
713
+	 */
714
+	public function column__REG_paid(EE_Registration $registration): string
715
+	{
716
+		$payment_method      = $registration->payment_method();
717
+		$payment_method_name = $payment_method instanceof EE_Payment_Method
718
+			? $payment_method->admin_name()
719
+			: esc_html__('Unknown', 'event_espresso');
720
+
721
+		$payment_status = $registration->owes_monies_and_can_pay() ? 'TFL' : 'TCM';
722
+		$content        = '
723 723
             <span class="reg-overview-paid-event-spn ee-status-color--' . $payment_status . '">
724 724
                 ' . $registration->pretty_paid() . '
725 725
             </span>';
726
-        if ($registration->paid() > 0) {
727
-            $content .= '<span class="ee-status-text-small">'
728
-                        . sprintf(
729
-                            esc_html__('...via %s', 'event_espresso'),
730
-                            $payment_method_name
731
-                        )
732
-                        . '</span>';
733
-        }
734
-        return $this->columnContent('_REG_paid', $content, 'end');
735
-    }
736
-
737
-
738
-    /**
739
-     * @param EE_Registration $registration
740
-     * @return string
741
-     * @throws EE_Error
742
-     * @throws EntityNotFoundException
743
-     * @throws InvalidArgumentException
744
-     * @throws InvalidDataTypeException
745
-     * @throws InvalidInterfaceException
746
-     * @throws ReflectionException
747
-     */
748
-    public function column_TXN_total(EE_Registration $registration): string
749
-    {
750
-        if ($registration->transaction()) {
751
-            $content = $this->caps_handler->userCanViewTransaction()
752
-                ? '
726
+		if ($registration->paid() > 0) {
727
+			$content .= '<span class="ee-status-text-small">'
728
+						. sprintf(
729
+							esc_html__('...via %s', 'event_espresso'),
730
+							$payment_method_name
731
+						)
732
+						. '</span>';
733
+		}
734
+		return $this->columnContent('_REG_paid', $content, 'end');
735
+	}
736
+
737
+
738
+	/**
739
+	 * @param EE_Registration $registration
740
+	 * @return string
741
+	 * @throws EE_Error
742
+	 * @throws EntityNotFoundException
743
+	 * @throws InvalidArgumentException
744
+	 * @throws InvalidDataTypeException
745
+	 * @throws InvalidInterfaceException
746
+	 * @throws ReflectionException
747
+	 */
748
+	public function column_TXN_total(EE_Registration $registration): string
749
+	{
750
+		if ($registration->transaction()) {
751
+			$content = $this->caps_handler->userCanViewTransaction()
752
+				? '
753 753
                     <a class="ee-aria-tooltip ee-status-color--' . $registration->transaction()->status_ID() . '"
754 754
                         href="' . $this->viewTransactionUrl() . '"
755 755
                         aria-label="' . esc_attr__('View Transaction', 'event_espresso') . '"
756 756
                     >
757 757
                         ' . $registration->transaction()->pretty_total() . '
758 758
                     </a>'
759
-                : $registration->transaction()->pretty_total();
760
-        } else {
761
-            $content = esc_html__("None", "event_espresso");
762
-        }
763
-        return $this->columnContent('TXN_total', $content, 'end');
764
-    }
765
-
766
-
767
-    /**
768
-     * @param EE_Registration $registration
769
-     * @return string
770
-     * @throws EE_Error
771
-     * @throws EntityNotFoundException
772
-     * @throws InvalidArgumentException
773
-     * @throws InvalidDataTypeException
774
-     * @throws InvalidInterfaceException
775
-     * @throws ReflectionException
776
-     */
777
-    public function column_TXN_paid(EE_Registration $registration): string
778
-    {
779
-        $content = '&nbsp;';
780
-        $align   = 'end';
781
-        if ($registration->count() === 1) {
782
-            $transaction = $registration->transaction()
783
-                ? $registration->transaction()
784
-                : EE_Transaction::new_instance();
785
-            if ($transaction->paid() >= $transaction->total()) {
786
-                $align   = 'center';
787
-                $content = '<span class="dashicons dashicons-yes green-icon"></span>';
788
-            } else {
789
-                $content = $this->caps_handler->userCanViewTransaction()
790
-                    ? '
759
+				: $registration->transaction()->pretty_total();
760
+		} else {
761
+			$content = esc_html__("None", "event_espresso");
762
+		}
763
+		return $this->columnContent('TXN_total', $content, 'end');
764
+	}
765
+
766
+
767
+	/**
768
+	 * @param EE_Registration $registration
769
+	 * @return string
770
+	 * @throws EE_Error
771
+	 * @throws EntityNotFoundException
772
+	 * @throws InvalidArgumentException
773
+	 * @throws InvalidDataTypeException
774
+	 * @throws InvalidInterfaceException
775
+	 * @throws ReflectionException
776
+	 */
777
+	public function column_TXN_paid(EE_Registration $registration): string
778
+	{
779
+		$content = '&nbsp;';
780
+		$align   = 'end';
781
+		if ($registration->count() === 1) {
782
+			$transaction = $registration->transaction()
783
+				? $registration->transaction()
784
+				: EE_Transaction::new_instance();
785
+			if ($transaction->paid() >= $transaction->total()) {
786
+				$align   = 'center';
787
+				$content = '<span class="dashicons dashicons-yes green-icon"></span>';
788
+			} else {
789
+				$content = $this->caps_handler->userCanViewTransaction()
790
+					? '
791 791
                     <a class="ee-aria-tooltip ee-status-color--' . $transaction->status_ID() . '"
792 792
                         href="' . $this->viewTransactionUrl() . '"
793 793
                         aria-label="' . esc_attr__('View Transaction', 'event_espresso') . '"
794 794
                     >
795 795
                         ' . $registration->transaction()->pretty_paid() . '
796 796
                     </a>'
797
-                    : $registration->transaction()->pretty_paid();
798
-            }
799
-        }
800
-        return $this->columnContent('TXN_paid', $content, $align);
801
-    }
802
-
803
-
804
-    /**
805
-     * @param EE_Registration $registration
806
-     * @return string
807
-     * @throws EE_Error
808
-     * @throws InvalidArgumentException
809
-     * @throws InvalidDataTypeException
810
-     * @throws InvalidInterfaceException
811
-     * @throws ReflectionException
812
-     */
813
-    public function column_actions(EE_Registration $registration): string
814
-    {
815
-        $attendee = $registration->attendee();
816
-        $this->_set_related_details($registration);
817
-
818
-        // Build and filter row actions
819
-        $actions = apply_filters(
820
-            'FHEE__EE_Registrations_List_Table__column_actions__actions',
821
-            [
822
-                'view_lnk'               => $this->viewRegistrationAction($registration),
823
-                'edit_lnk'               => $this->editContactAction($registration, $attendee),
824
-                'resend_reg_lnk'         => $this->resendRegistrationMessageAction($registration, $attendee),
825
-                'view_txn_lnk'           => $this->viewTransactionAction(),
826
-                'dl_invoice_lnk'         => $this->viewTransactionInvoiceAction($registration, $attendee),
827
-                'filtered_messages_link' => $this->viewNotificationsAction($registration),
828
-            ],
829
-            $registration,
830
-            $this
831
-        );
832
-
833
-        $content = $this->_action_string(
834
-            implode('', $actions),
835
-            $registration,
836
-            'div',
837
-            'reg-overview-actions ee-list-table-actions'
838
-        );
839
-
840
-        return $this->columnContent('actions', $this->actionsModalMenu($content));
841
-    }
842
-
843
-
844
-    /**
845
-     * @throws EE_Error
846
-     * @throws ReflectionException
847
-     */
848
-    private function viewRegistrationUrl(EE_Registration $registration): string
849
-    {
850
-        return EE_Admin_Page::add_query_args_and_nonce(
851
-            [
852
-                'action'  => 'view_registration',
853
-                '_REG_ID' => $registration->ID(),
854
-            ],
855
-            REG_ADMIN_URL
856
-        );
857
-    }
858
-
859
-
860
-    /**
861
-     * @throws EE_Error
862
-     * @throws ReflectionException
863
-     */
864
-    private function viewRegistrationLink(
865
-        EE_Registration $registration,
866
-        string $status
867
-    ): string {
868
-        $attendee      = $registration->attendee();
869
-        $attendee_name = $attendee instanceof EE_Attendee
870
-            ? $attendee->full_name()
871
-            : '';
872
-        return $this->caps_handler->userCanReadRegistration($registration)
873
-            ? '
797
+					: $registration->transaction()->pretty_paid();
798
+			}
799
+		}
800
+		return $this->columnContent('TXN_paid', $content, $align);
801
+	}
802
+
803
+
804
+	/**
805
+	 * @param EE_Registration $registration
806
+	 * @return string
807
+	 * @throws EE_Error
808
+	 * @throws InvalidArgumentException
809
+	 * @throws InvalidDataTypeException
810
+	 * @throws InvalidInterfaceException
811
+	 * @throws ReflectionException
812
+	 */
813
+	public function column_actions(EE_Registration $registration): string
814
+	{
815
+		$attendee = $registration->attendee();
816
+		$this->_set_related_details($registration);
817
+
818
+		// Build and filter row actions
819
+		$actions = apply_filters(
820
+			'FHEE__EE_Registrations_List_Table__column_actions__actions',
821
+			[
822
+				'view_lnk'               => $this->viewRegistrationAction($registration),
823
+				'edit_lnk'               => $this->editContactAction($registration, $attendee),
824
+				'resend_reg_lnk'         => $this->resendRegistrationMessageAction($registration, $attendee),
825
+				'view_txn_lnk'           => $this->viewTransactionAction(),
826
+				'dl_invoice_lnk'         => $this->viewTransactionInvoiceAction($registration, $attendee),
827
+				'filtered_messages_link' => $this->viewNotificationsAction($registration),
828
+			],
829
+			$registration,
830
+			$this
831
+		);
832
+
833
+		$content = $this->_action_string(
834
+			implode('', $actions),
835
+			$registration,
836
+			'div',
837
+			'reg-overview-actions ee-list-table-actions'
838
+		);
839
+
840
+		return $this->columnContent('actions', $this->actionsModalMenu($content));
841
+	}
842
+
843
+
844
+	/**
845
+	 * @throws EE_Error
846
+	 * @throws ReflectionException
847
+	 */
848
+	private function viewRegistrationUrl(EE_Registration $registration): string
849
+	{
850
+		return EE_Admin_Page::add_query_args_and_nonce(
851
+			[
852
+				'action'  => 'view_registration',
853
+				'_REG_ID' => $registration->ID(),
854
+			],
855
+			REG_ADMIN_URL
856
+		);
857
+	}
858
+
859
+
860
+	/**
861
+	 * @throws EE_Error
862
+	 * @throws ReflectionException
863
+	 */
864
+	private function viewRegistrationLink(
865
+		EE_Registration $registration,
866
+		string $status
867
+	): string {
868
+		$attendee      = $registration->attendee();
869
+		$attendee_name = $attendee instanceof EE_Attendee
870
+			? $attendee->full_name()
871
+			: '';
872
+		return $this->caps_handler->userCanReadRegistration($registration)
873
+			? '
874 874
             <a  href="' . $this->viewRegistrationUrl($registration) . '"
875 875
                 class="row-title ee-status-color--' . $status . ' ee-aria-tooltip"
876 876
                 aria-label="' . esc_attr__('View Registration Details', 'event_espresso') . '"
877 877
             >
878 878
                 ' . $attendee_name . '
879 879
             </a>'
880
-            : $attendee_name;
881
-    }
882
-
883
-
884
-    /**
885
-     * @throws EE_Error
886
-     * @throws ReflectionException
887
-     */
888
-    private function viewRegistrationAction(EE_Registration $registration): string
889
-    {
890
-        return $this->caps_handler->userCanReadRegistration($registration)
891
-            ? '
880
+			: $attendee_name;
881
+	}
882
+
883
+
884
+	/**
885
+	 * @throws EE_Error
886
+	 * @throws ReflectionException
887
+	 */
888
+	private function viewRegistrationAction(EE_Registration $registration): string
889
+	{
890
+		return $this->caps_handler->userCanReadRegistration($registration)
891
+			? '
892 892
             <a  href="' . $this->viewRegistrationUrl($registration) . '"
893 893
                 class="ee-aria-tooltip button button--icon-only"
894 894
                 aria-label="' . esc_attr__('View Registration Details', 'event_espresso') . '"
895 895
             >
896 896
                 <span class="dashicons dashicons-clipboard"></span>
897 897
             </a>'
898
-            : '';
899
-    }
900
-
901
-
902
-    private function editContactAction(EE_Registration $registration, ?EE_Attendee $attendee = null): string
903
-    {
904
-
905
-        if ($attendee instanceof EE_Attendee && $this->caps_handler->userCanEditContacts()) {
906
-            $edit_link_url = EE_Admin_Page::add_query_args_and_nonce(
907
-                [
908
-                    'action' => 'edit_attendee',
909
-                    'post'   => $registration->attendee_ID(),
910
-                ],
911
-                REG_ADMIN_URL
912
-            );
913
-            return '
898
+			: '';
899
+	}
900
+
901
+
902
+	private function editContactAction(EE_Registration $registration, ?EE_Attendee $attendee = null): string
903
+	{
904
+
905
+		if ($attendee instanceof EE_Attendee && $this->caps_handler->userCanEditContacts()) {
906
+			$edit_link_url = EE_Admin_Page::add_query_args_and_nonce(
907
+				[
908
+					'action' => 'edit_attendee',
909
+					'post'   => $registration->attendee_ID(),
910
+				],
911
+				REG_ADMIN_URL
912
+			);
913
+			return '
914 914
                 <a href="' . $edit_link_url . '"
915 915
                    aria-label="' . esc_attr__('Edit Contact Details', 'event_espresso') . '"
916 916
                    class="ee-aria-tooltip button button--secondary button--icon-only"
917 917
                 >
918 918
                     <span class="dashicons dashicons-admin-users"></span>
919 919
                 </a>';
920
-        }
921
-        return '';
922
-    }
923
-
924
-
925
-    /**
926
-     * @throws EE_Error
927
-     * @throws ReflectionException
928
-     */
929
-    private function resendRegistrationMessageAction(
930
-        EE_Registration $registration,
931
-        ?EE_Attendee $attendee = null
932
-    ): string {
933
-        if ($attendee instanceof EE_Attendee && $this->caps_handler->userCanResendMessage($registration)) {
934
-            $resend_reg_link_url = EE_Admin_Page::add_query_args_and_nonce(
935
-                [
936
-                    'action'  => 'resend_registration',
937
-                    '_REG_ID' => $registration->ID(),
938
-                ],
939
-                REG_ADMIN_URL,
940
-                true
941
-            );
942
-            return '
920
+		}
921
+		return '';
922
+	}
923
+
924
+
925
+	/**
926
+	 * @throws EE_Error
927
+	 * @throws ReflectionException
928
+	 */
929
+	private function resendRegistrationMessageAction(
930
+		EE_Registration $registration,
931
+		?EE_Attendee $attendee = null
932
+	): string {
933
+		if ($attendee instanceof EE_Attendee && $this->caps_handler->userCanResendMessage($registration)) {
934
+			$resend_reg_link_url = EE_Admin_Page::add_query_args_and_nonce(
935
+				[
936
+					'action'  => 'resend_registration',
937
+					'_REG_ID' => $registration->ID(),
938
+				],
939
+				REG_ADMIN_URL,
940
+				true
941
+			);
942
+			return '
943 943
 			    <a href="' . $resend_reg_link_url . '" aria-label="'
944
-                                         . esc_attr__('Resend Registration Details', 'event_espresso')
945
-                                         . '" class="ee-aria-tooltip button button--icon-only">
944
+										 . esc_attr__('Resend Registration Details', 'event_espresso')
945
+										 . '" class="ee-aria-tooltip button button--icon-only">
946 946
 			        <span class="dashicons dashicons-email-alt"></span>
947 947
 			    </a>';
948
-        }
949
-        return '';
950
-    }
951
-
952
-
953
-    private function viewTransactionUrl(): string
954
-    {
955
-        return EE_Admin_Page::add_query_args_and_nonce(
956
-            [
957
-                    'action' => 'view_transaction',
958
-                    'TXN_ID' => $this->_transaction_details['id'],
959
-                ],
960
-            TXN_ADMIN_URL
961
-        );
962
-    }
963
-
964
-
965
-    private function viewTransactionAction(): string
966
-    {
967
-        if ($this->caps_handler->userCanViewTransaction()) {
968
-            return '
948
+		}
949
+		return '';
950
+	}
951
+
952
+
953
+	private function viewTransactionUrl(): string
954
+	{
955
+		return EE_Admin_Page::add_query_args_and_nonce(
956
+			[
957
+					'action' => 'view_transaction',
958
+					'TXN_ID' => $this->_transaction_details['id'],
959
+				],
960
+			TXN_ADMIN_URL
961
+		);
962
+	}
963
+
964
+
965
+	private function viewTransactionAction(): string
966
+	{
967
+		if ($this->caps_handler->userCanViewTransaction()) {
968
+			return '
969 969
                 <a class="ee-aria-tooltip button button--icon-only"
970 970
                    href="' . $this->viewTransactionUrl() . '"
971 971
                    aria-label="' . $this->_transaction_details['title_attr'] . '"
972 972
                 >
973 973
                     <span class="dashicons dashicons-cart"></span>
974 974
                 </a>';
975
-        }
976
-        return '';
977
-    }
978
-
979
-
980
-    /**
981
-     * @throws EE_Error
982
-     * @throws ReflectionException
983
-     */
984
-    private function viewTransactionInvoiceAction(
985
-        EE_Registration $registration,
986
-        ?EE_Attendee $attendee = null
987
-    ): string {
988
-        // only show invoice link if message type is active.
989
-        if (
990
-            $attendee instanceof EE_Attendee
991
-            && $registration->is_primary_registrant()
992
-            && EEH_MSG_Template::is_mt_active('invoice')
993
-        ) {
994
-            return '
975
+		}
976
+		return '';
977
+	}
978
+
979
+
980
+	/**
981
+	 * @throws EE_Error
982
+	 * @throws ReflectionException
983
+	 */
984
+	private function viewTransactionInvoiceAction(
985
+		EE_Registration $registration,
986
+		?EE_Attendee $attendee = null
987
+	): string {
988
+		// only show invoice link if message type is active.
989
+		if (
990
+			$attendee instanceof EE_Attendee
991
+			&& $registration->is_primary_registrant()
992
+			&& EEH_MSG_Template::is_mt_active('invoice')
993
+		) {
994
+			return '
995 995
                 <a aria-label="' . esc_attr__('View Transaction Invoice', 'event_espresso')
996
-                                         . '" target="_blank" href="' . $registration->invoice_url() . '" class="ee-aria-tooltip button button--icon-only">
996
+										 . '" target="_blank" href="' . $registration->invoice_url() . '" class="ee-aria-tooltip button button--icon-only">
997 997
                     <span class="dashicons dashicons-media-spreadsheet"></span>
998 998
                 </a>';
999
-        }
1000
-        return '';
1001
-    }
1002
-
1003
-
1004
-    /**
1005
-     * @throws ReflectionException
1006
-     * @throws EE_Error
1007
-     */
1008
-    private function viewNotificationsAction(EE_Registration $registration): string
1009
-    {
1010
-        // message list table link (filtered by REG_ID
1011
-        return $this->caps_handler->userCanReadGlobalMessages()
1012
-            ? EEH_MSG_Template::get_message_action_link(
1013
-                'see_notifications_for',
1014
-                null,
1015
-                ['_REG_ID' => $registration->ID()]
1016
-            )
1017
-            : '';
1018
-    }
1019
-
1020
-
1021
-    /**
1022
-     * @throws EE_Error
1023
-     * @throws ReflectionException
1024
-     */
1025
-    private function trashRegistrationLink(
1026
-        EE_Registration $registration,
1027
-        array $url_params
1028
-    ): array {
1029
-        $actions = [];
1030
-        // can't trash what's already trashed
1031
-        if ($this->_view === 'trash') {
1032
-            return $actions;
1033
-        }
1034
-
1035
-        // check caps
1036
-        if (! $this->caps_handler->userCanTrashRegistration($registration)) {
1037
-            return $actions;
1038
-        }
1039
-
1040
-        // don't delete registrations that have payments applied
1041
-        $transaction   = $registration->get_first_related('Transaction');
1042
-        $payment_count = $transaction instanceof EE_Transaction
1043
-            ? $transaction->count_related('Payment')
1044
-            : 0;
1045
-
1046
-        if ($payment_count > 0) {
1047
-            return $actions;
1048
-        }
1049
-
1050
-        $url_params['action'] = 'trash_registrations';
1051
-        $trash_link_url       = EE_Admin_Page::add_query_args_and_nonce($url_params, REG_ADMIN_URL);
1052
-        $actions['trash']     = '
999
+		}
1000
+		return '';
1001
+	}
1002
+
1003
+
1004
+	/**
1005
+	 * @throws ReflectionException
1006
+	 * @throws EE_Error
1007
+	 */
1008
+	private function viewNotificationsAction(EE_Registration $registration): string
1009
+	{
1010
+		// message list table link (filtered by REG_ID
1011
+		return $this->caps_handler->userCanReadGlobalMessages()
1012
+			? EEH_MSG_Template::get_message_action_link(
1013
+				'see_notifications_for',
1014
+				null,
1015
+				['_REG_ID' => $registration->ID()]
1016
+			)
1017
+			: '';
1018
+	}
1019
+
1020
+
1021
+	/**
1022
+	 * @throws EE_Error
1023
+	 * @throws ReflectionException
1024
+	 */
1025
+	private function trashRegistrationLink(
1026
+		EE_Registration $registration,
1027
+		array $url_params
1028
+	): array {
1029
+		$actions = [];
1030
+		// can't trash what's already trashed
1031
+		if ($this->_view === 'trash') {
1032
+			return $actions;
1033
+		}
1034
+
1035
+		// check caps
1036
+		if (! $this->caps_handler->userCanTrashRegistration($registration)) {
1037
+			return $actions;
1038
+		}
1039
+
1040
+		// don't delete registrations that have payments applied
1041
+		$transaction   = $registration->get_first_related('Transaction');
1042
+		$payment_count = $transaction instanceof EE_Transaction
1043
+			? $transaction->count_related('Payment')
1044
+			: 0;
1045
+
1046
+		if ($payment_count > 0) {
1047
+			return $actions;
1048
+		}
1049
+
1050
+		$url_params['action'] = 'trash_registrations';
1051
+		$trash_link_url       = EE_Admin_Page::add_query_args_and_nonce($url_params, REG_ADMIN_URL);
1052
+		$actions['trash']     = '
1053 1053
             <a class="ee-aria-tooltip"
1054 1054
                 href="' . $trash_link_url . '"
1055 1055
                 aria-label="' . esc_attr__('Trash Registration', 'event_espresso') . '"
1056 1056
             >
1057 1057
                 ' . esc_html__('Trash', 'event_espresso') . '
1058 1058
             </a>';
1059
-        return $actions;
1060
-    }
1061
-
1062
-
1063
-    /**
1064
-     * @throws EE_Error
1065
-     * @throws ReflectionException
1066
-     */
1067
-    private function restoreRegistrationLink(
1068
-        EE_Registration $registration,
1069
-        array $url_params,
1070
-        array $actions
1071
-    ): array {
1072
-        // can't restore what's not trashed
1073
-        if ($this->_view !== 'trash') {
1074
-            return $actions;
1075
-        }
1076
-
1077
-        // restore registration link
1078
-        if ($this->caps_handler->userCanRestoreRegistration($registration)) {
1079
-            $url_params['action'] = 'restore_registrations';
1080
-            $restore_link_url     = EE_Admin_Page::add_query_args_and_nonce($url_params, REG_ADMIN_URL);
1081
-            $actions['restore']   = '
1059
+		return $actions;
1060
+	}
1061
+
1062
+
1063
+	/**
1064
+	 * @throws EE_Error
1065
+	 * @throws ReflectionException
1066
+	 */
1067
+	private function restoreRegistrationLink(
1068
+		EE_Registration $registration,
1069
+		array $url_params,
1070
+		array $actions
1071
+	): array {
1072
+		// can't restore what's not trashed
1073
+		if ($this->_view !== 'trash') {
1074
+			return $actions;
1075
+		}
1076
+
1077
+		// restore registration link
1078
+		if ($this->caps_handler->userCanRestoreRegistration($registration)) {
1079
+			$url_params['action'] = 'restore_registrations';
1080
+			$restore_link_url     = EE_Admin_Page::add_query_args_and_nonce($url_params, REG_ADMIN_URL);
1081
+			$actions['restore']   = '
1082 1082
                 <a class="ee-aria-tooltip"
1083 1083
                     href="' . $restore_link_url . '"
1084 1084
                     aria-label="' . esc_attr__('Restore Registration', 'event_espresso') . '"
1085 1085
                 >
1086 1086
                     ' . esc_html__('Restore', 'event_espresso') . '
1087 1087
                 </a>';
1088
-        }
1089
-
1090
-        return $actions;
1091
-    }
1092
-
1093
-
1094
-    /**
1095
-     * @throws EE_Error
1096
-     * @throws ReflectionException
1097
-     */
1098
-    private function deleteRegistrationLink(
1099
-        EE_Registration $registration,
1100
-        array $url_params,
1101
-        array $actions
1102
-    ): array {
1103
-        if ($this->_view === 'trash' && $this->caps_handler->userCanDeleteRegistration($registration)) {
1104
-            $url_params['action'] = 'delete_registrations';
1105
-            $delete_link_url      = EE_Admin_Page::add_query_args_and_nonce($url_params, REG_ADMIN_URL);
1106
-            $actions['delete']    = '
1088
+		}
1089
+
1090
+		return $actions;
1091
+	}
1092
+
1093
+
1094
+	/**
1095
+	 * @throws EE_Error
1096
+	 * @throws ReflectionException
1097
+	 */
1098
+	private function deleteRegistrationLink(
1099
+		EE_Registration $registration,
1100
+		array $url_params,
1101
+		array $actions
1102
+	): array {
1103
+		if ($this->_view === 'trash' && $this->caps_handler->userCanDeleteRegistration($registration)) {
1104
+			$url_params['action'] = 'delete_registrations';
1105
+			$delete_link_url      = EE_Admin_Page::add_query_args_and_nonce($url_params, REG_ADMIN_URL);
1106
+			$actions['delete']    = '
1107 1107
                 <a class="ee-aria-tooltip"
1108 1108
                     href="' . $delete_link_url . '"
1109 1109
                     aria-label="' . esc_attr__('Delete Registration Permanently', 'event_espresso') . '"
1110 1110
                 >
1111 1111
                     ' . esc_html__('Delete', 'event_espresso') . '
1112 1112
                 </a>';
1113
-        }
1114
-        return $actions;
1115
-    }
1116
-
1117
-
1118
-    private function editEventLink(int $EVT_ID, string $event_name): string
1119
-    {
1120
-        if (! $EVT_ID || ! $this->caps_handler->userCanEditEvent($EVT_ID)) {
1121
-            return $event_name;
1122
-        }
1123
-        $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(
1124
-            ['action' => 'edit', 'post' => $EVT_ID],
1125
-            EVENTS_ADMIN_URL
1126
-        );
1127
-        return '
1113
+		}
1114
+		return $actions;
1115
+	}
1116
+
1117
+
1118
+	private function editEventLink(int $EVT_ID, string $event_name): string
1119
+	{
1120
+		if (! $EVT_ID || ! $this->caps_handler->userCanEditEvent($EVT_ID)) {
1121
+			return $event_name;
1122
+		}
1123
+		$edit_event_url = EE_Admin_Page::add_query_args_and_nonce(
1124
+			['action' => 'edit', 'post' => $EVT_ID],
1125
+			EVENTS_ADMIN_URL
1126
+		);
1127
+		return '
1128 1128
             <a class="ee-aria-tooltip ee-status-color--' . $this->_event_details['status'] . '"
1129 1129
                 href="' . $edit_event_url . '"
1130 1130
                 aria-label="' . esc_attr($this->_event_details['title_attr']) . '"
1131 1131
             >
1132 1132
                 ' . $event_name . '
1133 1133
             </a>';
1134
-    }
1134
+	}
1135 1135
 
1136 1136
 
1137
-    private function eventFilterLink(int $EVT_ID, string $event_name): string
1138
-    {
1139
-        if (!$EVT_ID) {
1140
-            return '';
1141
-        }
1142
-        $event_filter_url = EE_Admin_Page::add_query_args_and_nonce(['event_id' => $EVT_ID], REG_ADMIN_URL);
1143
-        return '
1137
+	private function eventFilterLink(int $EVT_ID, string $event_name): string
1138
+	{
1139
+		if (!$EVT_ID) {
1140
+			return '';
1141
+		}
1142
+		$event_filter_url = EE_Admin_Page::add_query_args_and_nonce(['event_id' => $EVT_ID], REG_ADMIN_URL);
1143
+		return '
1144 1144
             <a  class="ee-aria-tooltip ee-event-filter-link"
1145 1145
                 href="' . $event_filter_url . '"
1146 1146
                 aria-label="' . sprintf(
1147
-                    esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'),
1148
-                    $event_name
1149
-                ) . '"
1147
+					esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'),
1148
+					$event_name
1149
+				) . '"
1150 1150
             >
1151 1151
                 <span class="dashicons dashicons-groups dashicons--small"></span>'
1152
-                . esc_html__('View Registrations', 'event_espresso') . '
1152
+				. esc_html__('View Registrations', 'event_espresso') . '
1153 1153
             </a>';
1154
-    }
1154
+	}
1155 1155
 }
Please login to merge, or discard this patch.
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
53 53
     {
54 54
         $this->caps_handler = new RegistrationsListTableUserCapabilities(EE_Registry::instance()->CAP);
55 55
         $req_data = $admin_page->get_request_data();
56
-        if (! empty($req_data['event_id'])) {
56
+        if ( ! empty($req_data['event_id'])) {
57 57
             $extra_query_args = [];
58 58
             foreach ($admin_page->get_views() as $view_details) {
59
-                $extra_query_args[ $view_details['slug'] ] = ['event_id' => $req_data['event_id']];
59
+                $extra_query_args[$view_details['slug']] = ['event_id' => $req_data['event_id']];
60 60
             }
61 61
             $this->_views = $admin_page->get_list_table_view_RLs($extra_query_args);
62 62
         }
@@ -88,9 +88,9 @@  discard block
 block discarded – undo
88 88
             'ajax'     => true,
89 89
             'screen'   => $this->_admin_page->get_current_screen()->id,
90 90
         ];
91
-        $req_data            = $this->_admin_page->get_request_data();
91
+        $req_data = $this->_admin_page->get_request_data();
92 92
         if (isset($req_data['event_id'])) {
93
-            $this->_columns        = [
93
+            $this->_columns = [
94 94
                 'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
95 95
                 'id'               => esc_html__('ID', 'event_espresso'),
96 96
                 'ATT_fname'        => esc_html__('Name', 'event_espresso'),
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
                 $this->_bottom_buttons['report'] = $route_details;
117 117
             }
118 118
         } else {
119
-            $this->_columns        = [
119
+            $this->_columns = [
120 120
                 'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
121 121
                 'id'               => esc_html__('ID', 'event_espresso'),
122 122
                 'ATT_fname'        => esc_html__('Name', 'event_espresso'),
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
                 'return_url'  => $return_url,
144 144
             ],
145 145
         ];
146
-        $filters                                  = array_diff_key(
146
+        $filters = array_diff_key(
147 147
             $this->_req_data,
148 148
             array_flip(
149 149
                 [
@@ -153,12 +153,12 @@  discard block
 block discarded – undo
153 153
                 ]
154 154
             )
155 155
         );
156
-        if (! empty($filters)) {
156
+        if ( ! empty($filters)) {
157 157
             $this->_bottom_buttons['report_filtered']['extra_request']['filters'] = $filters;
158 158
         }
159 159
         $this->_primary_column   = 'id';
160 160
         $this->_sortable_columns = [
161
-            '_REG_date'     => ['_REG_date' => true],   // true means its already sorted
161
+            '_REG_date'     => ['_REG_date' => true], // true means its already sorted
162 162
             /**
163 163
              * Allows users to change the default sort if they wish.
164 164
              * Returning a falsey on this filter will result in the default sort to be by firstname rather than last
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
             'DTT_EVT_start' => ['DTT_EVT_start' => false],
176 176
             'id'            => ['REG_ID' => false],
177 177
         ];
178
-        $this->_hidden_columns   = [];
178
+        $this->_hidden_columns = [];
179 179
     }
180 180
 
181 181
 
@@ -348,14 +348,14 @@  discard block
 block discarded – undo
348 348
         $this_month_r    = date('m', current_time('timestamp'));
349 349
         $days_this_month = date('t', current_time('timestamp'));
350 350
         // setup date query.
351
-        $beginning_string   = EEM_Registration::instance()->convert_datetime_for_query(
351
+        $beginning_string = EEM_Registration::instance()->convert_datetime_for_query(
352 352
             'REG_date',
353
-            $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start,
353
+            $this_year_r.'-'.$this_month_r.'-01'.' '.$time_start,
354 354
             'Y-m-d H:i:s'
355 355
         );
356
-        $end_string         = EEM_Registration::instance()->convert_datetime_for_query(
356
+        $end_string = EEM_Registration::instance()->convert_datetime_for_query(
357 357
             'REG_date',
358
-            $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
358
+            $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' '.$time_end,
359 359
             'Y-m-d H:i:s'
360 360
         );
361 361
         $_where['REG_date'] = [
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
                 $end_string,
366 366
             ],
367 367
         ];
368
-        $_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
368
+        $_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete];
369 369
         return EEM_Registration::instance()->count([$_where]);
370 370
     }
371 371
 
@@ -391,17 +391,17 @@  discard block
 block discarded – undo
391 391
             [
392 392
                 EEM_Registration::instance()->convert_datetime_for_query(
393 393
                     'REG_date',
394
-                    $current_date . $time_start,
394
+                    $current_date.$time_start,
395 395
                     'Y-m-d H:i:s'
396 396
                 ),
397 397
                 EEM_Registration::instance()->convert_datetime_for_query(
398 398
                     'REG_date',
399
-                    $current_date . $time_end,
399
+                    $current_date.$time_end,
400 400
                     'Y-m-d H:i:s'
401 401
                 ),
402 402
             ],
403 403
         ];
404
-        $_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
404
+        $_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete];
405 405
         return EEM_Registration::instance()->count([$_where]);
406 406
     }
407 407
 
@@ -424,10 +424,10 @@  discard block
 block discarded – undo
424 424
             ? $transaction->count_related('Payment')
425 425
             : 0;
426 426
 
427
-        $content = '<input type="checkbox" name="_REG_ID[]" value="' . $REG_ID . '" />';
427
+        $content = '<input type="checkbox" name="_REG_ID[]" value="'.$REG_ID.'" />';
428 428
         $content .= $payment_count > 0 || ! $this->caps_handler->userCanEditRegistration($item)
429 429
             ? '<span class="ee-locked-entity dashicons dashicons-lock ee-aria-tooltip ee-aria-tooltip--big-box"
430
-                    aria-label="' . $this->lockedRegMessage() . '"></span>'
430
+                    aria-label="' . $this->lockedRegMessage().'"></span>'
431 431
             : '';
432 432
         return $this->columnContent('cb', $content, 'center');
433 433
     }
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
      */
454 454
     public function column_id(EE_Registration $registration): string
455 455
     {
456
-        $content = '<span class="ee-entity-id">' . $registration->ID() . '</span>';
456
+        $content = '<span class="ee-entity-id">'.$registration->ID().'</span>';
457 457
         $content .= '<span class="show-on-mobile-view-only">';
458 458
         $content .= $this->column_ATT_fname($registration, false);
459 459
         $content .= '</span>';
@@ -484,23 +484,23 @@  discard block
 block discarded – undo
484 484
             esc_html__('(%1$s / %2$s)', 'event_espresso'),
485 485
             $registration->count(),
486 486
             $registration->group_size()
487
-        ) . '
487
+        ).'
488 488
             </span >';
489 489
 
490 490
         $content = '
491 491
         <div class="ee-layout-row">
492
-            <span aria-label="' . $pretty_status . '"
493
-                  class="ee-status-dot ee-status-bg--' . $status . ' ee-aria-tooltip"
492
+            <span aria-label="' . $pretty_status.'"
493
+                  class="ee-status-dot ee-status-bg--' . $status.' ee-aria-tooltip"
494 494
             ></span>
495 495
             ' . $this->viewRegistrationLink($registration, $status)
496 496
                    . $prime_reg_star
497
-                   . $group_count . '
497
+                   . $group_count.'
498 498
             <span class="spacer"></span>
499 499
             <span>
500 500
                 ' . sprintf(
501 501
                        esc_html__('Reg Code: %s', 'event_espresso'),
502 502
                        $registration->get('REG_code')
503
-                   ) . '
503
+                   ).'
504 504
             </span>
505 505
         </div>';
506 506
 
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
         $this->_set_related_details($registration);
532 532
         // Build row actions
533 533
         $content = $this->caps_handler->userCanViewTransaction()
534
-            ? '<a class="ee-aria-tooltip ee-status-color--' . $this->_transaction_details['status'] . '" href="'
534
+            ? '<a class="ee-aria-tooltip ee-status-color--'.$this->_transaction_details['status'].'" href="'
535 535
               . $this->viewTransactionUrl()
536 536
               . '" aria-label="'
537 537
               . esc_attr($this->_transaction_details['title_attr'])
@@ -605,16 +605,16 @@  discard block
 block discarded – undo
605 605
     {
606 606
         // get first item for initial visibility
607 607
         $content = (string) array_shift($datetime_strings);
608
-        if (! empty($datetime_strings)) {
608
+        if ( ! empty($datetime_strings)) {
609 609
             $content .= '
610 610
                 <div class="ee-registration-event-datetimes-container-wrap">
611
-                    <button aria-label="' . esc_attr__('Click to view all dates', 'event_espresso') . '"
611
+                    <button aria-label="' . esc_attr__('Click to view all dates', 'event_espresso').'"
612 612
                           class="ee-aria-tooltip button button--secondary button--tiny button--icon-only ee-js ee-more-datetimes-toggle"
613 613
                     >
614 614
                         <span class="dashicons dashicons-admin-collapse"></span>
615 615
                     </button>
616 616
                     <div class="ee-registration-event-datetimes-container more-items hidden">
617
-                        ' . implode("", $datetime_strings) . '
617
+                        ' . implode("", $datetime_strings).'
618 618
                     </div>
619 619
                 </div>';
620 620
         }
@@ -665,16 +665,16 @@  discard block
 block discarded – undo
665 665
         $req_data = $this->_admin_page->get_request_data();
666 666
 
667 667
         $content = isset($req_data['event_id']) && $ticket instanceof EE_Ticket
668
-            ? '<div class="TKT_name">' . $ticket->name() . '</div>'
668
+            ? '<div class="TKT_name">'.$ticket->name().'</div>'
669 669
             : '';
670 670
 
671 671
         $payment_status = $registration->owes_monies_and_can_pay() ? 'TFL' : 'TCM';
672
-        $content        .= $registration->final_price() > 0
673
-            ? '<span class="reg-overview-paid-event-spn ee-status-color--' . $payment_status . '">
674
-                ' . $registration->pretty_final_price() . '
672
+        $content .= $registration->final_price() > 0
673
+            ? '<span class="reg-overview-paid-event-spn ee-status-color--'.$payment_status.'">
674
+                ' . $registration->pretty_final_price().'
675 675
                </span>'
676 676
             // free event
677
-            : '<span class="reg-overview-free-event-spn">' . esc_html__('free', 'event_espresso') . '</span>';
677
+            : '<span class="reg-overview-free-event-spn">'.esc_html__('free', 'event_espresso').'</span>';
678 678
 
679 679
         return $this->columnContent('PRC_amount', $content, 'end');
680 680
     }
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
 
701 701
         $content .= '
702 702
             <span class="reg-overview-paid-event-spn">
703
-                ' . $registration->pretty_final_price() . '
703
+                ' . $registration->pretty_final_price().'
704 704
             </span>';
705 705
         return $this->columnContent('_REG_final_price', $content, 'end');
706 706
     }
@@ -720,8 +720,8 @@  discard block
 block discarded – undo
720 720
 
721 721
         $payment_status = $registration->owes_monies_and_can_pay() ? 'TFL' : 'TCM';
722 722
         $content        = '
723
-            <span class="reg-overview-paid-event-spn ee-status-color--' . $payment_status . '">
724
-                ' . $registration->pretty_paid() . '
723
+            <span class="reg-overview-paid-event-spn ee-status-color--' . $payment_status.'">
724
+                ' . $registration->pretty_paid().'
725 725
             </span>';
726 726
         if ($registration->paid() > 0) {
727 727
             $content .= '<span class="ee-status-text-small">'
@@ -750,11 +750,11 @@  discard block
 block discarded – undo
750 750
         if ($registration->transaction()) {
751 751
             $content = $this->caps_handler->userCanViewTransaction()
752 752
                 ? '
753
-                    <a class="ee-aria-tooltip ee-status-color--' . $registration->transaction()->status_ID() . '"
754
-                        href="' . $this->viewTransactionUrl() . '"
755
-                        aria-label="' . esc_attr__('View Transaction', 'event_espresso') . '"
753
+                    <a class="ee-aria-tooltip ee-status-color--' . $registration->transaction()->status_ID().'"
754
+                        href="' . $this->viewTransactionUrl().'"
755
+                        aria-label="' . esc_attr__('View Transaction', 'event_espresso').'"
756 756
                     >
757
-                        ' . $registration->transaction()->pretty_total() . '
757
+                        ' . $registration->transaction()->pretty_total().'
758 758
                     </a>'
759 759
                 : $registration->transaction()->pretty_total();
760 760
         } else {
@@ -788,11 +788,11 @@  discard block
 block discarded – undo
788 788
             } else {
789 789
                 $content = $this->caps_handler->userCanViewTransaction()
790 790
                     ? '
791
-                    <a class="ee-aria-tooltip ee-status-color--' . $transaction->status_ID() . '"
792
-                        href="' . $this->viewTransactionUrl() . '"
793
-                        aria-label="' . esc_attr__('View Transaction', 'event_espresso') . '"
791
+                    <a class="ee-aria-tooltip ee-status-color--' . $transaction->status_ID().'"
792
+                        href="' . $this->viewTransactionUrl().'"
793
+                        aria-label="' . esc_attr__('View Transaction', 'event_espresso').'"
794 794
                     >
795
-                        ' . $registration->transaction()->pretty_paid() . '
795
+                        ' . $registration->transaction()->pretty_paid().'
796 796
                     </a>'
797 797
                     : $registration->transaction()->pretty_paid();
798 798
             }
@@ -871,11 +871,11 @@  discard block
 block discarded – undo
871 871
             : '';
872 872
         return $this->caps_handler->userCanReadRegistration($registration)
873 873
             ? '
874
-            <a  href="' . $this->viewRegistrationUrl($registration) . '"
875
-                class="row-title ee-status-color--' . $status . ' ee-aria-tooltip"
876
-                aria-label="' . esc_attr__('View Registration Details', 'event_espresso') . '"
874
+            <a  href="' . $this->viewRegistrationUrl($registration).'"
875
+                class="row-title ee-status-color--' . $status.' ee-aria-tooltip"
876
+                aria-label="' . esc_attr__('View Registration Details', 'event_espresso').'"
877 877
             >
878
-                ' . $attendee_name . '
878
+                ' . $attendee_name.'
879 879
             </a>'
880 880
             : $attendee_name;
881 881
     }
@@ -889,9 +889,9 @@  discard block
 block discarded – undo
889 889
     {
890 890
         return $this->caps_handler->userCanReadRegistration($registration)
891 891
             ? '
892
-            <a  href="' . $this->viewRegistrationUrl($registration) . '"
892
+            <a  href="' . $this->viewRegistrationUrl($registration).'"
893 893
                 class="ee-aria-tooltip button button--icon-only"
894
-                aria-label="' . esc_attr__('View Registration Details', 'event_espresso') . '"
894
+                aria-label="' . esc_attr__('View Registration Details', 'event_espresso').'"
895 895
             >
896 896
                 <span class="dashicons dashicons-clipboard"></span>
897 897
             </a>'
@@ -911,8 +911,8 @@  discard block
 block discarded – undo
911 911
                 REG_ADMIN_URL
912 912
             );
913 913
             return '
914
-                <a href="' . $edit_link_url . '"
915
-                   aria-label="' . esc_attr__('Edit Contact Details', 'event_espresso') . '"
914
+                <a href="' . $edit_link_url.'"
915
+                   aria-label="' . esc_attr__('Edit Contact Details', 'event_espresso').'"
916 916
                    class="ee-aria-tooltip button button--secondary button--icon-only"
917 917
                 >
918 918
                     <span class="dashicons dashicons-admin-users"></span>
@@ -940,7 +940,7 @@  discard block
 block discarded – undo
940 940
                 true
941 941
             );
942 942
             return '
943
-			    <a href="' . $resend_reg_link_url . '" aria-label="'
943
+			    <a href="' . $resend_reg_link_url.'" aria-label="'
944 944
                                          . esc_attr__('Resend Registration Details', 'event_espresso')
945 945
                                          . '" class="ee-aria-tooltip button button--icon-only">
946 946
 			        <span class="dashicons dashicons-email-alt"></span>
@@ -967,8 +967,8 @@  discard block
 block discarded – undo
967 967
         if ($this->caps_handler->userCanViewTransaction()) {
968 968
             return '
969 969
                 <a class="ee-aria-tooltip button button--icon-only"
970
-                   href="' . $this->viewTransactionUrl() . '"
971
-                   aria-label="' . $this->_transaction_details['title_attr'] . '"
970
+                   href="' . $this->viewTransactionUrl().'"
971
+                   aria-label="' . $this->_transaction_details['title_attr'].'"
972 972
                 >
973 973
                     <span class="dashicons dashicons-cart"></span>
974 974
                 </a>';
@@ -993,7 +993,7 @@  discard block
 block discarded – undo
993 993
         ) {
994 994
             return '
995 995
                 <a aria-label="' . esc_attr__('View Transaction Invoice', 'event_espresso')
996
-                                         . '" target="_blank" href="' . $registration->invoice_url() . '" class="ee-aria-tooltip button button--icon-only">
996
+                                         . '" target="_blank" href="'.$registration->invoice_url().'" class="ee-aria-tooltip button button--icon-only">
997 997
                     <span class="dashicons dashicons-media-spreadsheet"></span>
998 998
                 </a>';
999 999
         }
@@ -1033,7 +1033,7 @@  discard block
 block discarded – undo
1033 1033
         }
1034 1034
 
1035 1035
         // check caps
1036
-        if (! $this->caps_handler->userCanTrashRegistration($registration)) {
1036
+        if ( ! $this->caps_handler->userCanTrashRegistration($registration)) {
1037 1037
             return $actions;
1038 1038
         }
1039 1039
 
@@ -1051,10 +1051,10 @@  discard block
 block discarded – undo
1051 1051
         $trash_link_url       = EE_Admin_Page::add_query_args_and_nonce($url_params, REG_ADMIN_URL);
1052 1052
         $actions['trash']     = '
1053 1053
             <a class="ee-aria-tooltip"
1054
-                href="' . $trash_link_url . '"
1055
-                aria-label="' . esc_attr__('Trash Registration', 'event_espresso') . '"
1054
+                href="' . $trash_link_url.'"
1055
+                aria-label="' . esc_attr__('Trash Registration', 'event_espresso').'"
1056 1056
             >
1057
-                ' . esc_html__('Trash', 'event_espresso') . '
1057
+                ' . esc_html__('Trash', 'event_espresso').'
1058 1058
             </a>';
1059 1059
         return $actions;
1060 1060
     }
@@ -1080,10 +1080,10 @@  discard block
 block discarded – undo
1080 1080
             $restore_link_url     = EE_Admin_Page::add_query_args_and_nonce($url_params, REG_ADMIN_URL);
1081 1081
             $actions['restore']   = '
1082 1082
                 <a class="ee-aria-tooltip"
1083
-                    href="' . $restore_link_url . '"
1084
-                    aria-label="' . esc_attr__('Restore Registration', 'event_espresso') . '"
1083
+                    href="' . $restore_link_url.'"
1084
+                    aria-label="' . esc_attr__('Restore Registration', 'event_espresso').'"
1085 1085
                 >
1086
-                    ' . esc_html__('Restore', 'event_espresso') . '
1086
+                    ' . esc_html__('Restore', 'event_espresso').'
1087 1087
                 </a>';
1088 1088
         }
1089 1089
 
@@ -1105,10 +1105,10 @@  discard block
 block discarded – undo
1105 1105
             $delete_link_url      = EE_Admin_Page::add_query_args_and_nonce($url_params, REG_ADMIN_URL);
1106 1106
             $actions['delete']    = '
1107 1107
                 <a class="ee-aria-tooltip"
1108
-                    href="' . $delete_link_url . '"
1109
-                    aria-label="' . esc_attr__('Delete Registration Permanently', 'event_espresso') . '"
1108
+                    href="' . $delete_link_url.'"
1109
+                    aria-label="' . esc_attr__('Delete Registration Permanently', 'event_espresso').'"
1110 1110
                 >
1111
-                    ' . esc_html__('Delete', 'event_espresso') . '
1111
+                    ' . esc_html__('Delete', 'event_espresso').'
1112 1112
                 </a>';
1113 1113
         }
1114 1114
         return $actions;
@@ -1117,7 +1117,7 @@  discard block
 block discarded – undo
1117 1117
 
1118 1118
     private function editEventLink(int $EVT_ID, string $event_name): string
1119 1119
     {
1120
-        if (! $EVT_ID || ! $this->caps_handler->userCanEditEvent($EVT_ID)) {
1120
+        if ( ! $EVT_ID || ! $this->caps_handler->userCanEditEvent($EVT_ID)) {
1121 1121
             return $event_name;
1122 1122
         }
1123 1123
         $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(
@@ -1125,31 +1125,31 @@  discard block
 block discarded – undo
1125 1125
             EVENTS_ADMIN_URL
1126 1126
         );
1127 1127
         return '
1128
-            <a class="ee-aria-tooltip ee-status-color--' . $this->_event_details['status'] . '"
1129
-                href="' . $edit_event_url . '"
1130
-                aria-label="' . esc_attr($this->_event_details['title_attr']) . '"
1128
+            <a class="ee-aria-tooltip ee-status-color--' . $this->_event_details['status'].'"
1129
+                href="' . $edit_event_url.'"
1130
+                aria-label="' . esc_attr($this->_event_details['title_attr']).'"
1131 1131
             >
1132
-                ' . $event_name . '
1132
+                ' . $event_name.'
1133 1133
             </a>';
1134 1134
     }
1135 1135
 
1136 1136
 
1137 1137
     private function eventFilterLink(int $EVT_ID, string $event_name): string
1138 1138
     {
1139
-        if (!$EVT_ID) {
1139
+        if ( ! $EVT_ID) {
1140 1140
             return '';
1141 1141
         }
1142 1142
         $event_filter_url = EE_Admin_Page::add_query_args_and_nonce(['event_id' => $EVT_ID], REG_ADMIN_URL);
1143 1143
         return '
1144 1144
             <a  class="ee-aria-tooltip ee-event-filter-link"
1145
-                href="' . $event_filter_url . '"
1145
+                href="' . $event_filter_url.'"
1146 1146
                 aria-label="' . sprintf(
1147 1147
                     esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'),
1148 1148
                     $event_name
1149
-                ) . '"
1149
+                ).'"
1150 1150
             >
1151 1151
                 <span class="dashicons dashicons-groups dashicons--small"></span>'
1152
-                . esc_html__('View Registrations', 'event_espresso') . '
1152
+                . esc_html__('View Registrations', 'event_espresso').'
1153 1153
             </a>';
1154 1154
     }
1155 1155
 }
Please login to merge, or discard this patch.
caffeinated/admin/new/pricing/espresso_events_Pricing_Hooks.class.php 2 patches
Indentation   +2139 added lines, -2139 removed lines patch added patch discarded remove patch
@@ -14,2201 +14,2201 @@
 block discarded – undo
14 14
  */
15 15
 class espresso_events_Pricing_Hooks extends EE_Admin_Hooks
16 16
 {
17
-    /**
18
-     * This property is just used to hold the status of whether an event is currently being
19
-     * created (true) or edited (false)
20
-     *
21
-     * @access protected
22
-     * @var bool
23
-     */
24
-    protected $_is_creating_event;
17
+	/**
18
+	 * This property is just used to hold the status of whether an event is currently being
19
+	 * created (true) or edited (false)
20
+	 *
21
+	 * @access protected
22
+	 * @var bool
23
+	 */
24
+	protected $_is_creating_event;
25 25
 
26
-    /**
27
-     * Used to contain the format strings for date and time that will be used for php date and
28
-     * time.
29
-     * Is set in the _set_hooks_properties() method.
30
-     *
31
-     * @var array
32
-     */
33
-    protected $_date_format_strings;
26
+	/**
27
+	 * Used to contain the format strings for date and time that will be used for php date and
28
+	 * time.
29
+	 * Is set in the _set_hooks_properties() method.
30
+	 *
31
+	 * @var array
32
+	 */
33
+	protected $_date_format_strings;
34 34
 
35
-    /**
36
-     * @var string $_date_time_format
37
-     */
38
-    protected $_date_time_format;
35
+	/**
36
+	 * @var string $_date_time_format
37
+	 */
38
+	protected $_date_time_format;
39 39
 
40 40
 
41
-    /**
42
-     * @throws InvalidArgumentException
43
-     * @throws InvalidInterfaceException
44
-     * @throws InvalidDataTypeException
45
-     */
46
-    protected function _set_hooks_properties()
47
-    {
48
-        $this->_name = 'pricing';
49
-        // capability check
50
-        if (
51
-            $this->_adminpage_obj->adminConfig()->useAdvancedEditor()
52
-            || ! EE_Registry::instance()->CAP->current_user_can(
53
-                'ee_read_default_prices',
54
-                'advanced_ticket_datetime_metabox'
55
-            )
56
-        ) {
57
-            $this->_metaboxes      = [];
58
-            $this->_scripts_styles = [];
59
-            return;
60
-        }
61
-        $this->_setup_metaboxes();
62
-        $this->_set_date_time_formats();
63
-        $this->_validate_format_strings();
64
-        $this->_set_scripts_styles();
65
-        // commented out temporarily until logic is implemented in callback
66
-        // add_action(
67
-        //     'AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_Extend_Events_Admin_Page',
68
-        //     array($this, 'autosave_handling')
69
-        // );
70
-        add_filter(
71
-            'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',
72
-            array($this, 'caf_updates')
73
-        );
74
-    }
41
+	/**
42
+	 * @throws InvalidArgumentException
43
+	 * @throws InvalidInterfaceException
44
+	 * @throws InvalidDataTypeException
45
+	 */
46
+	protected function _set_hooks_properties()
47
+	{
48
+		$this->_name = 'pricing';
49
+		// capability check
50
+		if (
51
+			$this->_adminpage_obj->adminConfig()->useAdvancedEditor()
52
+			|| ! EE_Registry::instance()->CAP->current_user_can(
53
+				'ee_read_default_prices',
54
+				'advanced_ticket_datetime_metabox'
55
+			)
56
+		) {
57
+			$this->_metaboxes      = [];
58
+			$this->_scripts_styles = [];
59
+			return;
60
+		}
61
+		$this->_setup_metaboxes();
62
+		$this->_set_date_time_formats();
63
+		$this->_validate_format_strings();
64
+		$this->_set_scripts_styles();
65
+		// commented out temporarily until logic is implemented in callback
66
+		// add_action(
67
+		//     'AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_Extend_Events_Admin_Page',
68
+		//     array($this, 'autosave_handling')
69
+		// );
70
+		add_filter(
71
+			'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',
72
+			array($this, 'caf_updates')
73
+		);
74
+	}
75 75
 
76 76
 
77
-    /**
78
-     * @return void
79
-     */
80
-    protected function _setup_metaboxes()
81
-    {
82
-        // if we were going to add our own metaboxes we'd use the below.
83
-        $this->_metaboxes = array(
84
-            0 => array(
85
-                'page_route' => array('edit', 'create_new'),
86
-                'func'       => 'pricing_metabox',
87
-                'label'      => esc_html__('Event Tickets & Datetimes', 'event_espresso'),
88
-                'priority'   => 'high',
89
-                'context'    => 'normal',
90
-            ),
91
-        );
92
-        $this->_remove_metaboxes = array(
93
-            0 => array(
94
-                'page_route' => array('edit', 'create_new'),
95
-                'id'         => 'espresso_event_editor_tickets',
96
-                'context'    => 'normal',
97
-            ),
98
-        );
99
-    }
77
+	/**
78
+	 * @return void
79
+	 */
80
+	protected function _setup_metaboxes()
81
+	{
82
+		// if we were going to add our own metaboxes we'd use the below.
83
+		$this->_metaboxes = array(
84
+			0 => array(
85
+				'page_route' => array('edit', 'create_new'),
86
+				'func'       => 'pricing_metabox',
87
+				'label'      => esc_html__('Event Tickets & Datetimes', 'event_espresso'),
88
+				'priority'   => 'high',
89
+				'context'    => 'normal',
90
+			),
91
+		);
92
+		$this->_remove_metaboxes = array(
93
+			0 => array(
94
+				'page_route' => array('edit', 'create_new'),
95
+				'id'         => 'espresso_event_editor_tickets',
96
+				'context'    => 'normal',
97
+			),
98
+		);
99
+	}
100 100
 
101 101
 
102
-    /**
103
-     * @return void
104
-     */
105
-    protected function _set_date_time_formats()
106
-    {
107
-        /**
108
-         * Format strings for date and time.  Defaults are existing behaviour from 4.1.
109
-         * Note, that if you return null as the value for 'date', and 'time' in the array, then
110
-         * EE will automatically use the set wp_options, 'date_format', and 'time_format'.
111
-         *
112
-         * @since 4.6.7
113
-         * @var array  Expected an array returned with 'date' and 'time' keys.
114
-         */
115
-        $this->_date_format_strings = apply_filters(
116
-            'FHEE__espresso_events_Pricing_Hooks___set_hooks_properties__date_format_strings',
117
-            array(
118
-                'date' => 'Y-m-d',
119
-                'time' => 'h:i a',
120
-            )
121
-        );
122
-        // validate
123
-        $this->_date_format_strings['date'] = isset($this->_date_format_strings['date'])
124
-            ? $this->_date_format_strings['date']
125
-            : null;
126
-        $this->_date_format_strings['time'] = isset($this->_date_format_strings['time'])
127
-            ? $this->_date_format_strings['time']
128
-            : null;
129
-        $this->_date_time_format = $this->_date_format_strings['date']
130
-                                   . ' '
131
-                                   . $this->_date_format_strings['time'];
132
-    }
102
+	/**
103
+	 * @return void
104
+	 */
105
+	protected function _set_date_time_formats()
106
+	{
107
+		/**
108
+		 * Format strings for date and time.  Defaults are existing behaviour from 4.1.
109
+		 * Note, that if you return null as the value for 'date', and 'time' in the array, then
110
+		 * EE will automatically use the set wp_options, 'date_format', and 'time_format'.
111
+		 *
112
+		 * @since 4.6.7
113
+		 * @var array  Expected an array returned with 'date' and 'time' keys.
114
+		 */
115
+		$this->_date_format_strings = apply_filters(
116
+			'FHEE__espresso_events_Pricing_Hooks___set_hooks_properties__date_format_strings',
117
+			array(
118
+				'date' => 'Y-m-d',
119
+				'time' => 'h:i a',
120
+			)
121
+		);
122
+		// validate
123
+		$this->_date_format_strings['date'] = isset($this->_date_format_strings['date'])
124
+			? $this->_date_format_strings['date']
125
+			: null;
126
+		$this->_date_format_strings['time'] = isset($this->_date_format_strings['time'])
127
+			? $this->_date_format_strings['time']
128
+			: null;
129
+		$this->_date_time_format = $this->_date_format_strings['date']
130
+								   . ' '
131
+								   . $this->_date_format_strings['time'];
132
+	}
133 133
 
134 134
 
135
-    /**
136
-     * @return void
137
-     */
138
-    protected function _validate_format_strings()
139
-    {
140
-        // validate format strings
141
-        $format_validation = EEH_DTT_Helper::validate_format_string(
142
-            $this->_date_time_format
143
-        );
144
-        if (is_array($format_validation)) {
145
-            $msg = '<p>';
146
-            $msg .= sprintf(
147
-                esc_html__(
148
-                    'The format "%s" was likely added via a filter and is invalid for the following reasons:',
149
-                    'event_espresso'
150
-                ),
151
-                $this->_date_time_format
152
-            );
153
-            $msg .= '</p><ul>';
154
-            foreach ($format_validation as $error) {
155
-                $msg .= '<li>' . $error . '</li>';
156
-            }
157
-            $msg .= '</ul><p>';
158
-            $msg .= sprintf(
159
-                esc_html__(
160
-                    '%sPlease note that your date and time formats have been reset to "Y-m-d" and "h:i a" respectively.%s',
161
-                    'event_espresso'
162
-                ),
163
-                '<span style="color:#D54E21;">',
164
-                '</span>'
165
-            );
166
-            $msg .= '</p>';
167
-            EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__);
168
-            $this->_date_format_strings = array(
169
-                'date' => 'Y-m-d',
170
-                'time' => 'h:i a',
171
-            );
172
-        }
173
-    }
135
+	/**
136
+	 * @return void
137
+	 */
138
+	protected function _validate_format_strings()
139
+	{
140
+		// validate format strings
141
+		$format_validation = EEH_DTT_Helper::validate_format_string(
142
+			$this->_date_time_format
143
+		);
144
+		if (is_array($format_validation)) {
145
+			$msg = '<p>';
146
+			$msg .= sprintf(
147
+				esc_html__(
148
+					'The format "%s" was likely added via a filter and is invalid for the following reasons:',
149
+					'event_espresso'
150
+				),
151
+				$this->_date_time_format
152
+			);
153
+			$msg .= '</p><ul>';
154
+			foreach ($format_validation as $error) {
155
+				$msg .= '<li>' . $error . '</li>';
156
+			}
157
+			$msg .= '</ul><p>';
158
+			$msg .= sprintf(
159
+				esc_html__(
160
+					'%sPlease note that your date and time formats have been reset to "Y-m-d" and "h:i a" respectively.%s',
161
+					'event_espresso'
162
+				),
163
+				'<span style="color:#D54E21;">',
164
+				'</span>'
165
+			);
166
+			$msg .= '</p>';
167
+			EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__);
168
+			$this->_date_format_strings = array(
169
+				'date' => 'Y-m-d',
170
+				'time' => 'h:i a',
171
+			);
172
+		}
173
+	}
174 174
 
175 175
 
176
-    /**
177
-     * @return void
178
-     */
179
-    protected function _set_scripts_styles()
180
-    {
181
-        $this->_scripts_styles = array(
182
-            'registers'   => array(
183
-                'ee-tickets-datetimes-css' => array(
184
-                    'url'  => PRICING_ASSETS_URL . 'event-tickets-datetimes.css',
185
-                    'type' => 'css',
186
-                ),
187
-                'ee-dtt-ticket-metabox'    => array(
188
-                    'url'     => PRICING_ASSETS_URL . 'ee-datetime-ticket-metabox.js',
189
-                    'depends' => array('ee-datepicker', 'ee-dialog', 'underscore'),
190
-                ),
191
-            ),
192
-            'deregisters' => array(
193
-                'event-editor-css'       => array('type' => 'css'),
194
-                'event-datetime-metabox' => array('type' => 'js'),
195
-            ),
196
-            'enqueues'    => array(
197
-                'ee-tickets-datetimes-css' => array('edit', 'create_new'),
198
-                'ee-dtt-ticket-metabox'    => array('edit', 'create_new'),
199
-            ),
200
-            'localize'    => array(
201
-                'ee-dtt-ticket-metabox' => array(
202
-                    'DTT_TRASH_BLOCK'       => array(
203
-                        'main_warning'            => esc_html__(
204
-                            'The Datetime you are attempting to trash is the only datetime selected for the following ticket(s):',
205
-                            'event_espresso'
206
-                        ),
207
-                        'after_warning'           => esc_html__(
208
-                            'In order to trash this datetime you must first make sure the above ticket(s) are assigned to other datetimes.',
209
-                            'event_espresso'
210
-                        ),
211
-                        'cancel_button'           => '<button class="button--secondary ee-modal-cancel">'
212
-                                                     . esc_html__('Cancel', 'event_espresso') . '</button>',
213
-                        'close_button'            => '<button class="button--secondary ee-modal-cancel">'
214
-                                                     . esc_html__('Close', 'event_espresso') . '</button>',
215
-                        'single_warning_from_tkt' => esc_html__(
216
-                            'The Datetime you are attempting to unassign from this ticket is the only remaining datetime for this ticket. Tickets must always have at least one datetime assigned to them.',
217
-                            'event_espresso'
218
-                        ),
219
-                        'single_warning_from_dtt' => esc_html__(
220
-                            'The ticket you are attempting to unassign from this datetime cannot be unassigned because the datetime is the only remaining datetime for the ticket.  Tickets must always have at least one datetime assigned to them.',
221
-                            'event_espresso'
222
-                        ),
223
-                        'dismiss_button'          => '<button class="button--secondary ee-modal-cancel">'
224
-                                                     . esc_html__('Dismiss', 'event_espresso') . '</button>',
225
-                    ),
226
-                    'DTT_ERROR_MSG'         => array(
227
-                        'no_ticket_name' => esc_html__('General Admission', 'event_espresso'),
228
-                        'dismiss_button' => '<div class="save-cancel-button-container">'
229
-                                            . '<button class="button--secondary ee-modal-cancel">'
230
-                                            . esc_html__('Dismiss', 'event_espresso')
231
-                                            . '</button></div>',
232
-                    ),
233
-                    'DTT_OVERSELL_WARNING'  => array(
234
-                        'datetime_ticket' => esc_html__(
235
-                            'You cannot add this ticket to this datetime because it has a sold amount that is greater than the amount of spots remaining for this datetime.',
236
-                            'event_espresso'
237
-                        ),
238
-                        'ticket_datetime' => esc_html__(
239
-                            'You cannot add this datetime to this ticket because the ticket has a sold amount that is greater than the amount of spots remaining on the datetime.',
240
-                            'event_espresso'
241
-                        ),
242
-                    ),
243
-                    'DTT_CONVERTED_FORMATS' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats(
244
-                        $this->_date_format_strings['date'],
245
-                        $this->_date_format_strings['time']
246
-                    ),
247
-                    'DTT_START_OF_WEEK'     => array('dayValue' => (int) get_option('start_of_week')),
248
-                ),
249
-            ),
250
-        );
251
-    }
176
+	/**
177
+	 * @return void
178
+	 */
179
+	protected function _set_scripts_styles()
180
+	{
181
+		$this->_scripts_styles = array(
182
+			'registers'   => array(
183
+				'ee-tickets-datetimes-css' => array(
184
+					'url'  => PRICING_ASSETS_URL . 'event-tickets-datetimes.css',
185
+					'type' => 'css',
186
+				),
187
+				'ee-dtt-ticket-metabox'    => array(
188
+					'url'     => PRICING_ASSETS_URL . 'ee-datetime-ticket-metabox.js',
189
+					'depends' => array('ee-datepicker', 'ee-dialog', 'underscore'),
190
+				),
191
+			),
192
+			'deregisters' => array(
193
+				'event-editor-css'       => array('type' => 'css'),
194
+				'event-datetime-metabox' => array('type' => 'js'),
195
+			),
196
+			'enqueues'    => array(
197
+				'ee-tickets-datetimes-css' => array('edit', 'create_new'),
198
+				'ee-dtt-ticket-metabox'    => array('edit', 'create_new'),
199
+			),
200
+			'localize'    => array(
201
+				'ee-dtt-ticket-metabox' => array(
202
+					'DTT_TRASH_BLOCK'       => array(
203
+						'main_warning'            => esc_html__(
204
+							'The Datetime you are attempting to trash is the only datetime selected for the following ticket(s):',
205
+							'event_espresso'
206
+						),
207
+						'after_warning'           => esc_html__(
208
+							'In order to trash this datetime you must first make sure the above ticket(s) are assigned to other datetimes.',
209
+							'event_espresso'
210
+						),
211
+						'cancel_button'           => '<button class="button--secondary ee-modal-cancel">'
212
+													 . esc_html__('Cancel', 'event_espresso') . '</button>',
213
+						'close_button'            => '<button class="button--secondary ee-modal-cancel">'
214
+													 . esc_html__('Close', 'event_espresso') . '</button>',
215
+						'single_warning_from_tkt' => esc_html__(
216
+							'The Datetime you are attempting to unassign from this ticket is the only remaining datetime for this ticket. Tickets must always have at least one datetime assigned to them.',
217
+							'event_espresso'
218
+						),
219
+						'single_warning_from_dtt' => esc_html__(
220
+							'The ticket you are attempting to unassign from this datetime cannot be unassigned because the datetime is the only remaining datetime for the ticket.  Tickets must always have at least one datetime assigned to them.',
221
+							'event_espresso'
222
+						),
223
+						'dismiss_button'          => '<button class="button--secondary ee-modal-cancel">'
224
+													 . esc_html__('Dismiss', 'event_espresso') . '</button>',
225
+					),
226
+					'DTT_ERROR_MSG'         => array(
227
+						'no_ticket_name' => esc_html__('General Admission', 'event_espresso'),
228
+						'dismiss_button' => '<div class="save-cancel-button-container">'
229
+											. '<button class="button--secondary ee-modal-cancel">'
230
+											. esc_html__('Dismiss', 'event_espresso')
231
+											. '</button></div>',
232
+					),
233
+					'DTT_OVERSELL_WARNING'  => array(
234
+						'datetime_ticket' => esc_html__(
235
+							'You cannot add this ticket to this datetime because it has a sold amount that is greater than the amount of spots remaining for this datetime.',
236
+							'event_espresso'
237
+						),
238
+						'ticket_datetime' => esc_html__(
239
+							'You cannot add this datetime to this ticket because the ticket has a sold amount that is greater than the amount of spots remaining on the datetime.',
240
+							'event_espresso'
241
+						),
242
+					),
243
+					'DTT_CONVERTED_FORMATS' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats(
244
+						$this->_date_format_strings['date'],
245
+						$this->_date_format_strings['time']
246
+					),
247
+					'DTT_START_OF_WEEK'     => array('dayValue' => (int) get_option('start_of_week')),
248
+				),
249
+			),
250
+		);
251
+	}
252 252
 
253 253
 
254
-    /**
255
-     * @param array $update_callbacks
256
-     * @return array
257
-     */
258
-    public function caf_updates(array $update_callbacks)
259
-    {
260
-        unset($update_callbacks['_default_tickets_update']);
261
-        $update_callbacks['datetime_and_tickets_caf_update'] = array($this, 'datetime_and_tickets_caf_update');
262
-        return $update_callbacks;
263
-    }
254
+	/**
255
+	 * @param array $update_callbacks
256
+	 * @return array
257
+	 */
258
+	public function caf_updates(array $update_callbacks)
259
+	{
260
+		unset($update_callbacks['_default_tickets_update']);
261
+		$update_callbacks['datetime_and_tickets_caf_update'] = array($this, 'datetime_and_tickets_caf_update');
262
+		return $update_callbacks;
263
+	}
264 264
 
265 265
 
266
-    /**
267
-     * Handles saving everything related to Tickets (datetimes, tickets, prices)
268
-     *
269
-     * @param  EE_Event $event The Event object we're attaching data to
270
-     * @param  array    $data  The request data from the form
271
-     * @throws ReflectionException
272
-     * @throws Exception
273
-     * @throws InvalidInterfaceException
274
-     * @throws InvalidDataTypeException
275
-     * @throws EE_Error
276
-     * @throws InvalidArgumentException
277
-     */
278
-    public function datetime_and_tickets_caf_update($event, $data)
279
-    {
280
-        // first we need to start with datetimes cause they are the "root" items attached to events.
281
-        $saved_datetimes = $this->_update_datetimes($event, $data);
282
-        // next tackle the tickets (and prices?)
283
-        $this->_update_tickets($event, $saved_datetimes, $data);
284
-    }
266
+	/**
267
+	 * Handles saving everything related to Tickets (datetimes, tickets, prices)
268
+	 *
269
+	 * @param  EE_Event $event The Event object we're attaching data to
270
+	 * @param  array    $data  The request data from the form
271
+	 * @throws ReflectionException
272
+	 * @throws Exception
273
+	 * @throws InvalidInterfaceException
274
+	 * @throws InvalidDataTypeException
275
+	 * @throws EE_Error
276
+	 * @throws InvalidArgumentException
277
+	 */
278
+	public function datetime_and_tickets_caf_update($event, $data)
279
+	{
280
+		// first we need to start with datetimes cause they are the "root" items attached to events.
281
+		$saved_datetimes = $this->_update_datetimes($event, $data);
282
+		// next tackle the tickets (and prices?)
283
+		$this->_update_tickets($event, $saved_datetimes, $data);
284
+	}
285 285
 
286 286
 
287
-    /**
288
-     * update event_datetimes
289
-     *
290
-     * @param  EE_Event $event Event being updated
291
-     * @param  array    $data  the request data from the form
292
-     * @return EE_Datetime[]
293
-     * @throws Exception
294
-     * @throws ReflectionException
295
-     * @throws InvalidInterfaceException
296
-     * @throws InvalidDataTypeException
297
-     * @throws InvalidArgumentException
298
-     * @throws EE_Error
299
-     */
300
-    protected function _update_datetimes($event, $data)
301
-    {
302
-        $timezone = isset($data['timezone_string']) ? $data['timezone_string'] : null;
303
-        $saved_dtt_ids = array();
304
-        $saved_dtt_objs = array();
305
-        if (empty($data['edit_event_datetimes']) || ! is_array($data['edit_event_datetimes'])) {
306
-            throw new InvalidArgumentException(
307
-                esc_html__(
308
-                    'The "edit_event_datetimes" array is invalid therefore the event can not be updated.',
309
-                    'event_espresso'
310
-                )
311
-            );
312
-        }
313
-        foreach ($data['edit_event_datetimes'] as $row => $datetime_data) {
314
-            // trim all values to ensure any excess whitespace is removed.
315
-            $datetime_data = array_map(
316
-                function ($datetime_data) {
317
-                    return is_array($datetime_data) ? $datetime_data : trim($datetime_data);
318
-                },
319
-                $datetime_data
320
-            );
321
-            $datetime_data['DTT_EVT_end'] = isset($datetime_data['DTT_EVT_end'])
322
-                                            && ! empty($datetime_data['DTT_EVT_end'])
323
-                ? $datetime_data['DTT_EVT_end']
324
-                : $datetime_data['DTT_EVT_start'];
325
-            $datetime_values = array(
326
-                'DTT_ID'          => ! empty($datetime_data['DTT_ID'])
327
-                    ? $datetime_data['DTT_ID']
328
-                    : null,
329
-                'DTT_name'        => ! empty($datetime_data['DTT_name'])
330
-                    ? $datetime_data['DTT_name']
331
-                    : '',
332
-                'DTT_description' => ! empty($datetime_data['DTT_description'])
333
-                    ? $datetime_data['DTT_description']
334
-                    : '',
335
-                'DTT_EVT_start'   => $datetime_data['DTT_EVT_start'],
336
-                'DTT_EVT_end'     => $datetime_data['DTT_EVT_end'],
337
-                'DTT_reg_limit'   => empty($datetime_data['DTT_reg_limit'])
338
-                    ? EE_INF
339
-                    : $datetime_data['DTT_reg_limit'],
340
-                'DTT_order'       => ! isset($datetime_data['DTT_order'])
341
-                    ? $row
342
-                    : $datetime_data['DTT_order'],
343
-            );
344
-            // if we have an id then let's get existing object first and then set the new values.
345
-            // Otherwise we instantiate a new object for save.
346
-            if (! empty($datetime_data['DTT_ID'])) {
347
-                $datetime = EE_Registry::instance()
348
-                                       ->load_model('Datetime', array($timezone))
349
-                                       ->get_one_by_ID($datetime_data['DTT_ID']);
350
-                // set date and time format according to what is set in this class.
351
-                $datetime->set_date_format($this->_date_format_strings['date']);
352
-                $datetime->set_time_format($this->_date_format_strings['time']);
353
-                foreach ($datetime_values as $field => $value) {
354
-                    $datetime->set($field, $value);
355
-                }
356
-                // make sure the $dtt_id here is saved just in case
357
-                // after the add_relation_to() the autosave replaces it.
358
-                // We need to do this so we dont' TRASH the parent DTT.
359
-                // (save the ID for both key and value to avoid duplications)
360
-                $saved_dtt_ids[ $datetime->ID() ] = $datetime->ID();
361
-            } else {
362
-                $datetime = EE_Registry::instance()->load_class(
363
-                    'Datetime',
364
-                    array(
365
-                        $datetime_values,
366
-                        $timezone,
367
-                        array($this->_date_format_strings['date'], $this->_date_format_strings['time']),
368
-                    ),
369
-                    false,
370
-                    false
371
-                );
372
-                foreach ($datetime_values as $field => $value) {
373
-                    $datetime->set($field, $value);
374
-                }
375
-            }
376
-            $datetime->save();
377
-            do_action(
378
-                'AHEE__espresso_events_Pricing_Hooks___update_datetimes_after_save',
379
-                $datetime,
380
-                $row,
381
-                $datetime_data,
382
-                $data
383
-            );
384
-            $datetime = $event->_add_relation_to($datetime, 'Datetime');
385
-            // before going any further make sure our dates are setup correctly
386
-            // so that the end date is always equal or greater than the start date.
387
-            if ($datetime->get_raw('DTT_EVT_start') > $datetime->get_raw('DTT_EVT_end')) {
388
-                $datetime->set('DTT_EVT_end', $datetime->get('DTT_EVT_start'));
389
-                $datetime = EEH_DTT_Helper::date_time_add($datetime, 'DTT_EVT_end', 'days');
390
-                $datetime->save();
391
-            }
392
-            // now we have to make sure we add the new DTT_ID to the $saved_dtt_ids array
393
-            // because it is possible there was a new one created for the autosave.
394
-            // (save the ID for both key and value to avoid duplications)
395
-            $DTT_ID = $datetime->ID();
396
-            $saved_dtt_ids[ $DTT_ID ] = $DTT_ID;
397
-            $saved_dtt_objs[ $row ] = $datetime;
398
-            // @todo if ANY of these updates fail then we want the appropriate global error message.
399
-        }
400
-        $event->save();
401
-        // now we need to REMOVE any datetimes that got deleted.
402
-        // Keep in mind that this process will only kick in for datetimes that don't have any DTT_sold on them.
403
-        // So its safe to permanently delete at this point.
404
-        $old_datetimes = explode(',', $data['datetime_IDs']);
405
-        $old_datetimes = $old_datetimes[0] === '' ? array() : $old_datetimes;
406
-        if (is_array($old_datetimes)) {
407
-            $datetimes_to_delete = array_diff($old_datetimes, $saved_dtt_ids);
408
-            foreach ($datetimes_to_delete as $id) {
409
-                $id = absint($id);
410
-                if (empty($id)) {
411
-                    continue;
412
-                }
413
-                $dtt_to_remove = EE_Registry::instance()->load_model('Datetime')->get_one_by_ID($id);
414
-                // remove tkt relationships.
415
-                $related_tickets = $dtt_to_remove->get_many_related('Ticket');
416
-                foreach ($related_tickets as $tkt) {
417
-                    $dtt_to_remove->_remove_relation_to($tkt, 'Ticket');
418
-                }
419
-                $event->_remove_relation_to($id, 'Datetime');
420
-                $dtt_to_remove->refresh_cache_of_related_objects();
421
-            }
422
-        }
423
-        return $saved_dtt_objs;
424
-    }
287
+	/**
288
+	 * update event_datetimes
289
+	 *
290
+	 * @param  EE_Event $event Event being updated
291
+	 * @param  array    $data  the request data from the form
292
+	 * @return EE_Datetime[]
293
+	 * @throws Exception
294
+	 * @throws ReflectionException
295
+	 * @throws InvalidInterfaceException
296
+	 * @throws InvalidDataTypeException
297
+	 * @throws InvalidArgumentException
298
+	 * @throws EE_Error
299
+	 */
300
+	protected function _update_datetimes($event, $data)
301
+	{
302
+		$timezone = isset($data['timezone_string']) ? $data['timezone_string'] : null;
303
+		$saved_dtt_ids = array();
304
+		$saved_dtt_objs = array();
305
+		if (empty($data['edit_event_datetimes']) || ! is_array($data['edit_event_datetimes'])) {
306
+			throw new InvalidArgumentException(
307
+				esc_html__(
308
+					'The "edit_event_datetimes" array is invalid therefore the event can not be updated.',
309
+					'event_espresso'
310
+				)
311
+			);
312
+		}
313
+		foreach ($data['edit_event_datetimes'] as $row => $datetime_data) {
314
+			// trim all values to ensure any excess whitespace is removed.
315
+			$datetime_data = array_map(
316
+				function ($datetime_data) {
317
+					return is_array($datetime_data) ? $datetime_data : trim($datetime_data);
318
+				},
319
+				$datetime_data
320
+			);
321
+			$datetime_data['DTT_EVT_end'] = isset($datetime_data['DTT_EVT_end'])
322
+											&& ! empty($datetime_data['DTT_EVT_end'])
323
+				? $datetime_data['DTT_EVT_end']
324
+				: $datetime_data['DTT_EVT_start'];
325
+			$datetime_values = array(
326
+				'DTT_ID'          => ! empty($datetime_data['DTT_ID'])
327
+					? $datetime_data['DTT_ID']
328
+					: null,
329
+				'DTT_name'        => ! empty($datetime_data['DTT_name'])
330
+					? $datetime_data['DTT_name']
331
+					: '',
332
+				'DTT_description' => ! empty($datetime_data['DTT_description'])
333
+					? $datetime_data['DTT_description']
334
+					: '',
335
+				'DTT_EVT_start'   => $datetime_data['DTT_EVT_start'],
336
+				'DTT_EVT_end'     => $datetime_data['DTT_EVT_end'],
337
+				'DTT_reg_limit'   => empty($datetime_data['DTT_reg_limit'])
338
+					? EE_INF
339
+					: $datetime_data['DTT_reg_limit'],
340
+				'DTT_order'       => ! isset($datetime_data['DTT_order'])
341
+					? $row
342
+					: $datetime_data['DTT_order'],
343
+			);
344
+			// if we have an id then let's get existing object first and then set the new values.
345
+			// Otherwise we instantiate a new object for save.
346
+			if (! empty($datetime_data['DTT_ID'])) {
347
+				$datetime = EE_Registry::instance()
348
+									   ->load_model('Datetime', array($timezone))
349
+									   ->get_one_by_ID($datetime_data['DTT_ID']);
350
+				// set date and time format according to what is set in this class.
351
+				$datetime->set_date_format($this->_date_format_strings['date']);
352
+				$datetime->set_time_format($this->_date_format_strings['time']);
353
+				foreach ($datetime_values as $field => $value) {
354
+					$datetime->set($field, $value);
355
+				}
356
+				// make sure the $dtt_id here is saved just in case
357
+				// after the add_relation_to() the autosave replaces it.
358
+				// We need to do this so we dont' TRASH the parent DTT.
359
+				// (save the ID for both key and value to avoid duplications)
360
+				$saved_dtt_ids[ $datetime->ID() ] = $datetime->ID();
361
+			} else {
362
+				$datetime = EE_Registry::instance()->load_class(
363
+					'Datetime',
364
+					array(
365
+						$datetime_values,
366
+						$timezone,
367
+						array($this->_date_format_strings['date'], $this->_date_format_strings['time']),
368
+					),
369
+					false,
370
+					false
371
+				);
372
+				foreach ($datetime_values as $field => $value) {
373
+					$datetime->set($field, $value);
374
+				}
375
+			}
376
+			$datetime->save();
377
+			do_action(
378
+				'AHEE__espresso_events_Pricing_Hooks___update_datetimes_after_save',
379
+				$datetime,
380
+				$row,
381
+				$datetime_data,
382
+				$data
383
+			);
384
+			$datetime = $event->_add_relation_to($datetime, 'Datetime');
385
+			// before going any further make sure our dates are setup correctly
386
+			// so that the end date is always equal or greater than the start date.
387
+			if ($datetime->get_raw('DTT_EVT_start') > $datetime->get_raw('DTT_EVT_end')) {
388
+				$datetime->set('DTT_EVT_end', $datetime->get('DTT_EVT_start'));
389
+				$datetime = EEH_DTT_Helper::date_time_add($datetime, 'DTT_EVT_end', 'days');
390
+				$datetime->save();
391
+			}
392
+			// now we have to make sure we add the new DTT_ID to the $saved_dtt_ids array
393
+			// because it is possible there was a new one created for the autosave.
394
+			// (save the ID for both key and value to avoid duplications)
395
+			$DTT_ID = $datetime->ID();
396
+			$saved_dtt_ids[ $DTT_ID ] = $DTT_ID;
397
+			$saved_dtt_objs[ $row ] = $datetime;
398
+			// @todo if ANY of these updates fail then we want the appropriate global error message.
399
+		}
400
+		$event->save();
401
+		// now we need to REMOVE any datetimes that got deleted.
402
+		// Keep in mind that this process will only kick in for datetimes that don't have any DTT_sold on them.
403
+		// So its safe to permanently delete at this point.
404
+		$old_datetimes = explode(',', $data['datetime_IDs']);
405
+		$old_datetimes = $old_datetimes[0] === '' ? array() : $old_datetimes;
406
+		if (is_array($old_datetimes)) {
407
+			$datetimes_to_delete = array_diff($old_datetimes, $saved_dtt_ids);
408
+			foreach ($datetimes_to_delete as $id) {
409
+				$id = absint($id);
410
+				if (empty($id)) {
411
+					continue;
412
+				}
413
+				$dtt_to_remove = EE_Registry::instance()->load_model('Datetime')->get_one_by_ID($id);
414
+				// remove tkt relationships.
415
+				$related_tickets = $dtt_to_remove->get_many_related('Ticket');
416
+				foreach ($related_tickets as $tkt) {
417
+					$dtt_to_remove->_remove_relation_to($tkt, 'Ticket');
418
+				}
419
+				$event->_remove_relation_to($id, 'Datetime');
420
+				$dtt_to_remove->refresh_cache_of_related_objects();
421
+			}
422
+		}
423
+		return $saved_dtt_objs;
424
+	}
425 425
 
426 426
 
427
-    /**
428
-     * update tickets
429
-     *
430
-     * @param  EE_Event      $event           Event object being updated
431
-     * @param  EE_Datetime[] $saved_datetimes an array of datetime ids being updated
432
-     * @param  array         $data            incoming request data
433
-     * @return EE_Ticket[]
434
-     * @throws Exception
435
-     * @throws ReflectionException
436
-     * @throws InvalidInterfaceException
437
-     * @throws InvalidDataTypeException
438
-     * @throws InvalidArgumentException
439
-     * @throws EE_Error
440
-     */
441
-    protected function _update_tickets($event, $saved_datetimes, $data)
442
-    {
443
-        $new_tkt = null;
444
-        // stripslashes because WP filtered the $_POST ($data) array to add slashes
445
-        $data = stripslashes_deep($data);
446
-        $timezone = $data['timezone_string'] ?? null;
447
-        $saved_tickets = array();
448
-        $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array();
449
-        if (empty($data['edit_tickets']) || ! is_array($data['edit_tickets'])) {
450
-            throw new InvalidArgumentException(
451
-                esc_html__(
452
-                    'The "edit_tickets" array is invalid therefore the event can not be updated.',
453
-                    'event_espresso'
454
-                )
455
-            );
456
-        }
457
-        foreach ($data['edit_tickets'] as $row => $tkt) {
458
-            $update_prices = $create_new_TKT = false;
459
-            // figure out what datetimes were added to the ticket
460
-            // and what datetimes were removed from the ticket in the session.
461
-            $starting_tkt_dtt_rows = explode(',', $data['starting_ticket_datetime_rows'][ $row ]);
462
-            $tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][ $row ]);
463
-            $datetimes_added = array_diff($tkt_dtt_rows, $starting_tkt_dtt_rows);
464
-            $datetimes_removed = array_diff($starting_tkt_dtt_rows, $tkt_dtt_rows);
465
-            // trim inputs to ensure any excess whitespace is removed.
466
-            $tkt = array_map(
467
-                function ($ticket_data) {
468
-                    return is_array($ticket_data) ? $ticket_data : trim($ticket_data);
469
-                },
470
-                $tkt
471
-            );
472
-            // note we are doing conversions to floats here instead of allowing EE_Money_Field to handle
473
-            // because we're doing calculations prior to using the models.
474
-            // note incoming ['TKT_price'] value is already in standard notation (via js).
475
-            $ticket_price = isset($tkt['TKT_price'])
476
-                ? round((float) $tkt['TKT_price'], 3)
477
-                : 0;
478
-            // note incoming base price needs converted from localized value.
479
-            $base_price = isset($tkt['TKT_base_price'])
480
-                ? EEH_Money::convert_to_float_from_localized_money($tkt['TKT_base_price'])
481
-                : 0;
482
-            // if ticket price == 0 and $base_price != 0 then ticket price == base_price
483
-            $ticket_price = $ticket_price === 0 && $base_price !== 0
484
-                ? $base_price
485
-                : $ticket_price;
486
-            $base_price_id = $tkt['TKT_base_price_ID'] ?? 0;
487
-            $price_rows = is_array($data['edit_prices']) && isset($data['edit_prices'][ $row ])
488
-                ? $data['edit_prices'][ $row ]
489
-                : array();
490
-            $now = null;
491
-            if (empty($tkt['TKT_start_date'])) {
492
-                // lets' use now in the set timezone.
493
-                $now = new DateTime('now', new DateTimeZone($event->get_timezone()));
494
-                $tkt['TKT_start_date'] = $now->format($this->_date_time_format);
495
-            }
496
-            if (empty($tkt['TKT_end_date'])) {
497
-                /**
498
-                 * set the TKT_end_date to the first datetime attached to the ticket.
499
-                 */
500
-                $first_dtt = $saved_datetimes[ reset($tkt_dtt_rows) ];
501
-                $tkt['TKT_end_date'] = $first_dtt->start_date_and_time($this->_date_time_format);
502
-            }
503
-            $TKT_values = array(
504
-                'TKT_ID'          => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null,
505
-                'TTM_ID'          => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0,
506
-                'TKT_name'        => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '',
507
-                'TKT_description' => ! empty($tkt['TKT_description'])
508
-                                     && $tkt['TKT_description'] !== esc_html__(
509
-                                         'You can modify this description',
510
-                                         'event_espresso'
511
-                                     )
512
-                    ? $tkt['TKT_description']
513
-                    : '',
514
-                'TKT_start_date'  => $tkt['TKT_start_date'],
515
-                'TKT_end_date'    => $tkt['TKT_end_date'],
516
-                'TKT_qty'         => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === ''
517
-                    ? EE_INF
518
-                    : $tkt['TKT_qty'],
519
-                'TKT_uses'        => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === ''
520
-                    ? EE_INF
521
-                    : $tkt['TKT_uses'],
522
-                'TKT_min'         => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'],
523
-                'TKT_max'         => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'],
524
-                'TKT_row'         => $row,
525
-                'TKT_order'       => $tkt['TKT_order'] ?? 0,
526
-                'TKT_taxable'     => ! empty($tkt['TKT_taxable']) ? 1 : 0,
527
-                'TKT_required'    => ! empty($tkt['TKT_required']) ? 1 : 0,
528
-                'TKT_price'       => $ticket_price,
529
-            );
530
-            // if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly,
531
-            // which means in turn that the prices will become new prices as well.
532
-            if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) {
533
-                $TKT_values['TKT_ID'] = 0;
534
-                $TKT_values['TKT_is_default'] = 0;
535
-                $update_prices = true;
536
-            }
537
-            // if we have a TKT_ID then we need to get that existing TKT_obj and update it
538
-            // we actually do our saves ahead of doing any add_relations to
539
-            // because its entirely possible that this ticket wasn't removed or added to any datetime in the session
540
-            // but DID have it's items modified.
541
-            // keep in mind that if the TKT has been sold (and we have changed pricing information),
542
-            // then we won't be updating the tkt but instead a new tkt will be created and the old one archived.
543
-            if (absint($TKT_values['TKT_ID'])) {
544
-                $ticket = EE_Registry::instance()
545
-                                     ->load_model('Ticket', array($timezone))
546
-                                     ->get_one_by_ID($tkt['TKT_ID']);
547
-                if ($ticket instanceof EE_Ticket) {
548
-                    $ticket = $this->_update_ticket_datetimes(
549
-                        $ticket,
550
-                        $saved_datetimes,
551
-                        $datetimes_added,
552
-                        $datetimes_removed
553
-                    );
554
-                    // are there any registrations using this ticket ?
555
-                    $tickets_sold = $ticket->count_related(
556
-                        'Registration',
557
-                        array(
558
-                            array(
559
-                                'STS_ID' => array('NOT IN', array(EEM_Registration::status_id_incomplete)),
560
-                            ),
561
-                        )
562
-                    );
563
-                    // set ticket formats
564
-                    $ticket->set_date_format($this->_date_format_strings['date']);
565
-                    $ticket->set_time_format($this->_date_format_strings['time']);
566
-                    // let's just check the total price for the existing ticket
567
-                    // and determine if it matches the new total price.
568
-                    // if they are different then we create a new ticket (if tickets sold)
569
-                    // if they aren't different then we go ahead and modify existing ticket.
570
-                    $create_new_TKT = $tickets_sold > 0 && $ticket_price !== $ticket->price() && ! $ticket->deleted();
571
-                    // set new values
572
-                    foreach ($TKT_values as $field => $value) {
573
-                        if ($field === 'TKT_qty') {
574
-                            $ticket->set_qty($value);
575
-                        } else {
576
-                            $ticket->set($field, $value);
577
-                        }
578
-                    }
579
-                    // if $create_new_TKT is false then we can safely update the existing ticket.
580
-                    // Otherwise we have to create a new ticket.
581
-                    if ($create_new_TKT) {
582
-                        $new_tkt = $this->_duplicate_ticket(
583
-                            $ticket,
584
-                            $price_rows,
585
-                            $ticket_price,
586
-                            $base_price,
587
-                            $base_price_id
588
-                        );
589
-                    }
590
-                }
591
-            } else {
592
-                // no TKT_id so a new TKT
593
-                $ticket = EE_Ticket::new_instance(
594
-                    $TKT_values,
595
-                    $timezone,
596
-                    array($this->_date_format_strings['date'], $this->_date_format_strings['time'])
597
-                );
598
-                if ($ticket instanceof EE_Ticket) {
599
-                    // make sure ticket has an ID of setting relations won't work
600
-                    $ticket->save();
601
-                    $ticket = $this->_update_ticket_datetimes(
602
-                        $ticket,
603
-                        $saved_datetimes,
604
-                        $datetimes_added,
605
-                        $datetimes_removed
606
-                    );
607
-                    $update_prices = true;
608
-                }
609
-            }
610
-            // make sure any current values have been saved.
611
-            // $ticket->save();
612
-            // before going any further make sure our dates are setup correctly
613
-            // so that the end date is always equal or greater than the start date.
614
-            if ($ticket->get_raw('TKT_start_date') > $ticket->get_raw('TKT_end_date')) {
615
-                $ticket->set('TKT_end_date', $ticket->get('TKT_start_date'));
616
-                $ticket = EEH_DTT_Helper::date_time_add($ticket, 'TKT_end_date', 'days');
617
-            }
618
-            // let's make sure the base price is handled
619
-            $ticket = ! $create_new_TKT
620
-                ? $this->_add_prices_to_ticket(
621
-                    array(),
622
-                    $ticket,
623
-                    $update_prices,
624
-                    $base_price,
625
-                    $base_price_id
626
-                )
627
-                : $ticket;
628
-            // add/update price_modifiers
629
-            $ticket = ! $create_new_TKT
630
-                ? $this->_add_prices_to_ticket($price_rows, $ticket, $update_prices)
631
-                : $ticket;
632
-            // need to make sue that the TKT_price is accurate after saving the prices.
633
-            $ticket->ensure_TKT_Price_correct();
634
-            // handle CREATING a default tkt from the incoming tkt but ONLY if this isn't an autosave.
635
-            if (! defined('DOING_AUTOSAVE') && ! empty($tkt['TKT_is_default_selector'])) {
636
-                $update_prices = true;
637
-                $new_default = clone $ticket;
638
-                $new_default->set('TKT_ID', 0);
639
-                $new_default->set('TKT_is_default', 1);
640
-                $new_default->set('TKT_row', 1);
641
-                $new_default->set('TKT_price', $ticket_price);
642
-                // remove any dtt relations cause we DON'T want dtt relations attached
643
-                // (note this is just removing the cached relations in the object)
644
-                $new_default->_remove_relations('Datetime');
645
-                // @todo we need to add the current attached prices as new prices to the new default ticket.
646
-                $new_default = $this->_add_prices_to_ticket(
647
-                    $price_rows,
648
-                    $new_default,
649
-                    $update_prices
650
-                );
651
-                // don't forget the base price!
652
-                $new_default = $this->_add_prices_to_ticket(
653
-                    array(),
654
-                    $new_default,
655
-                    $update_prices,
656
-                    $base_price,
657
-                    $base_price_id
658
-                );
659
-                $new_default->save();
660
-                do_action(
661
-                    'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket',
662
-                    $new_default,
663
-                    $row,
664
-                    $ticket,
665
-                    $data
666
-                );
667
-            }
668
-            // DO ALL dtt relationships for both current tickets and any archived tickets
669
-            // for the given dtt that are related to the current ticket.
670
-            // TODO... not sure exactly how we're going to do this considering we don't know
671
-            // what current ticket the archived tickets are related to
672
-            // (and TKT_parent is used for autosaves so that's not a field we can reliably use).
673
-            // let's assign any tickets that have been setup to the saved_tickets tracker
674
-            // save existing TKT
675
-            $ticket->save();
676
-            if ($create_new_TKT && $new_tkt instanceof EE_Ticket) {
677
-                // save new TKT
678
-                $new_tkt->save();
679
-                // add new ticket to array
680
-                $saved_tickets[ $new_tkt->ID() ] = $new_tkt;
681
-                do_action(
682
-                    'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket',
683
-                    $new_tkt,
684
-                    $row,
685
-                    $tkt,
686
-                    $data
687
-                );
688
-            } else {
689
-                // add tkt to saved tkts
690
-                $saved_tickets[ $ticket->ID() ] = $ticket;
691
-                do_action(
692
-                    'AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket',
693
-                    $ticket,
694
-                    $row,
695
-                    $tkt,
696
-                    $data
697
-                );
698
-            }
699
-        }
700
-        // now we need to handle tickets actually "deleted permanently".
701
-        // There are cases where we'd want this to happen
702
-        // (i.e. autosaves are happening and then in between autosaves the user trashes a ticket).
703
-        // Or a draft event was saved and in the process of editing a ticket is trashed.
704
-        // No sense in keeping all the related data in the db!
705
-        $old_tickets = isset($old_tickets[0]) && $old_tickets[0] === '' ? array() : $old_tickets;
706
-        $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets));
707
-        foreach ($tickets_removed as $id) {
708
-            $id = absint($id);
709
-            // get the ticket for this id
710
-            $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id);
711
-            // if this tkt is a default tkt we leave it alone cause it won't be attached to the datetime
712
-            if ($tkt_to_remove->get('TKT_is_default')) {
713
-                continue;
714
-            }
715
-            // if this tkt has any registrations attached so then we just ARCHIVE
716
-            // because we don't actually permanently delete these tickets.
717
-            if ($tkt_to_remove->count_related('Registration') > 0) {
718
-                $tkt_to_remove->delete();
719
-                continue;
720
-            }
721
-            // need to get all the related datetimes on this ticket and remove from every single one of them
722
-            // (remember this process can ONLY kick off if there are NO tkts_sold)
723
-            $datetimes = $tkt_to_remove->get_many_related('Datetime');
724
-            foreach ($datetimes as $datetime) {
725
-                $tkt_to_remove->_remove_relation_to($datetime, 'Datetime');
726
-            }
727
-            // need to do the same for prices (except these prices can also be deleted because again,
728
-            // tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived))
729
-            $tkt_to_remove->delete_related_permanently('Price');
730
-            do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $tkt_to_remove);
731
-            // finally let's delete this ticket
732
-            // (which should not be blocked at this point b/c we've removed all our relationships)
733
-            $tkt_to_remove->delete_permanently();
734
-        }
735
-        return $saved_tickets;
736
-    }
427
+	/**
428
+	 * update tickets
429
+	 *
430
+	 * @param  EE_Event      $event           Event object being updated
431
+	 * @param  EE_Datetime[] $saved_datetimes an array of datetime ids being updated
432
+	 * @param  array         $data            incoming request data
433
+	 * @return EE_Ticket[]
434
+	 * @throws Exception
435
+	 * @throws ReflectionException
436
+	 * @throws InvalidInterfaceException
437
+	 * @throws InvalidDataTypeException
438
+	 * @throws InvalidArgumentException
439
+	 * @throws EE_Error
440
+	 */
441
+	protected function _update_tickets($event, $saved_datetimes, $data)
442
+	{
443
+		$new_tkt = null;
444
+		// stripslashes because WP filtered the $_POST ($data) array to add slashes
445
+		$data = stripslashes_deep($data);
446
+		$timezone = $data['timezone_string'] ?? null;
447
+		$saved_tickets = array();
448
+		$old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array();
449
+		if (empty($data['edit_tickets']) || ! is_array($data['edit_tickets'])) {
450
+			throw new InvalidArgumentException(
451
+				esc_html__(
452
+					'The "edit_tickets" array is invalid therefore the event can not be updated.',
453
+					'event_espresso'
454
+				)
455
+			);
456
+		}
457
+		foreach ($data['edit_tickets'] as $row => $tkt) {
458
+			$update_prices = $create_new_TKT = false;
459
+			// figure out what datetimes were added to the ticket
460
+			// and what datetimes were removed from the ticket in the session.
461
+			$starting_tkt_dtt_rows = explode(',', $data['starting_ticket_datetime_rows'][ $row ]);
462
+			$tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][ $row ]);
463
+			$datetimes_added = array_diff($tkt_dtt_rows, $starting_tkt_dtt_rows);
464
+			$datetimes_removed = array_diff($starting_tkt_dtt_rows, $tkt_dtt_rows);
465
+			// trim inputs to ensure any excess whitespace is removed.
466
+			$tkt = array_map(
467
+				function ($ticket_data) {
468
+					return is_array($ticket_data) ? $ticket_data : trim($ticket_data);
469
+				},
470
+				$tkt
471
+			);
472
+			// note we are doing conversions to floats here instead of allowing EE_Money_Field to handle
473
+			// because we're doing calculations prior to using the models.
474
+			// note incoming ['TKT_price'] value is already in standard notation (via js).
475
+			$ticket_price = isset($tkt['TKT_price'])
476
+				? round((float) $tkt['TKT_price'], 3)
477
+				: 0;
478
+			// note incoming base price needs converted from localized value.
479
+			$base_price = isset($tkt['TKT_base_price'])
480
+				? EEH_Money::convert_to_float_from_localized_money($tkt['TKT_base_price'])
481
+				: 0;
482
+			// if ticket price == 0 and $base_price != 0 then ticket price == base_price
483
+			$ticket_price = $ticket_price === 0 && $base_price !== 0
484
+				? $base_price
485
+				: $ticket_price;
486
+			$base_price_id = $tkt['TKT_base_price_ID'] ?? 0;
487
+			$price_rows = is_array($data['edit_prices']) && isset($data['edit_prices'][ $row ])
488
+				? $data['edit_prices'][ $row ]
489
+				: array();
490
+			$now = null;
491
+			if (empty($tkt['TKT_start_date'])) {
492
+				// lets' use now in the set timezone.
493
+				$now = new DateTime('now', new DateTimeZone($event->get_timezone()));
494
+				$tkt['TKT_start_date'] = $now->format($this->_date_time_format);
495
+			}
496
+			if (empty($tkt['TKT_end_date'])) {
497
+				/**
498
+				 * set the TKT_end_date to the first datetime attached to the ticket.
499
+				 */
500
+				$first_dtt = $saved_datetimes[ reset($tkt_dtt_rows) ];
501
+				$tkt['TKT_end_date'] = $first_dtt->start_date_and_time($this->_date_time_format);
502
+			}
503
+			$TKT_values = array(
504
+				'TKT_ID'          => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null,
505
+				'TTM_ID'          => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0,
506
+				'TKT_name'        => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '',
507
+				'TKT_description' => ! empty($tkt['TKT_description'])
508
+									 && $tkt['TKT_description'] !== esc_html__(
509
+										 'You can modify this description',
510
+										 'event_espresso'
511
+									 )
512
+					? $tkt['TKT_description']
513
+					: '',
514
+				'TKT_start_date'  => $tkt['TKT_start_date'],
515
+				'TKT_end_date'    => $tkt['TKT_end_date'],
516
+				'TKT_qty'         => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === ''
517
+					? EE_INF
518
+					: $tkt['TKT_qty'],
519
+				'TKT_uses'        => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === ''
520
+					? EE_INF
521
+					: $tkt['TKT_uses'],
522
+				'TKT_min'         => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'],
523
+				'TKT_max'         => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'],
524
+				'TKT_row'         => $row,
525
+				'TKT_order'       => $tkt['TKT_order'] ?? 0,
526
+				'TKT_taxable'     => ! empty($tkt['TKT_taxable']) ? 1 : 0,
527
+				'TKT_required'    => ! empty($tkt['TKT_required']) ? 1 : 0,
528
+				'TKT_price'       => $ticket_price,
529
+			);
530
+			// if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly,
531
+			// which means in turn that the prices will become new prices as well.
532
+			if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) {
533
+				$TKT_values['TKT_ID'] = 0;
534
+				$TKT_values['TKT_is_default'] = 0;
535
+				$update_prices = true;
536
+			}
537
+			// if we have a TKT_ID then we need to get that existing TKT_obj and update it
538
+			// we actually do our saves ahead of doing any add_relations to
539
+			// because its entirely possible that this ticket wasn't removed or added to any datetime in the session
540
+			// but DID have it's items modified.
541
+			// keep in mind that if the TKT has been sold (and we have changed pricing information),
542
+			// then we won't be updating the tkt but instead a new tkt will be created and the old one archived.
543
+			if (absint($TKT_values['TKT_ID'])) {
544
+				$ticket = EE_Registry::instance()
545
+									 ->load_model('Ticket', array($timezone))
546
+									 ->get_one_by_ID($tkt['TKT_ID']);
547
+				if ($ticket instanceof EE_Ticket) {
548
+					$ticket = $this->_update_ticket_datetimes(
549
+						$ticket,
550
+						$saved_datetimes,
551
+						$datetimes_added,
552
+						$datetimes_removed
553
+					);
554
+					// are there any registrations using this ticket ?
555
+					$tickets_sold = $ticket->count_related(
556
+						'Registration',
557
+						array(
558
+							array(
559
+								'STS_ID' => array('NOT IN', array(EEM_Registration::status_id_incomplete)),
560
+							),
561
+						)
562
+					);
563
+					// set ticket formats
564
+					$ticket->set_date_format($this->_date_format_strings['date']);
565
+					$ticket->set_time_format($this->_date_format_strings['time']);
566
+					// let's just check the total price for the existing ticket
567
+					// and determine if it matches the new total price.
568
+					// if they are different then we create a new ticket (if tickets sold)
569
+					// if they aren't different then we go ahead and modify existing ticket.
570
+					$create_new_TKT = $tickets_sold > 0 && $ticket_price !== $ticket->price() && ! $ticket->deleted();
571
+					// set new values
572
+					foreach ($TKT_values as $field => $value) {
573
+						if ($field === 'TKT_qty') {
574
+							$ticket->set_qty($value);
575
+						} else {
576
+							$ticket->set($field, $value);
577
+						}
578
+					}
579
+					// if $create_new_TKT is false then we can safely update the existing ticket.
580
+					// Otherwise we have to create a new ticket.
581
+					if ($create_new_TKT) {
582
+						$new_tkt = $this->_duplicate_ticket(
583
+							$ticket,
584
+							$price_rows,
585
+							$ticket_price,
586
+							$base_price,
587
+							$base_price_id
588
+						);
589
+					}
590
+				}
591
+			} else {
592
+				// no TKT_id so a new TKT
593
+				$ticket = EE_Ticket::new_instance(
594
+					$TKT_values,
595
+					$timezone,
596
+					array($this->_date_format_strings['date'], $this->_date_format_strings['time'])
597
+				);
598
+				if ($ticket instanceof EE_Ticket) {
599
+					// make sure ticket has an ID of setting relations won't work
600
+					$ticket->save();
601
+					$ticket = $this->_update_ticket_datetimes(
602
+						$ticket,
603
+						$saved_datetimes,
604
+						$datetimes_added,
605
+						$datetimes_removed
606
+					);
607
+					$update_prices = true;
608
+				}
609
+			}
610
+			// make sure any current values have been saved.
611
+			// $ticket->save();
612
+			// before going any further make sure our dates are setup correctly
613
+			// so that the end date is always equal or greater than the start date.
614
+			if ($ticket->get_raw('TKT_start_date') > $ticket->get_raw('TKT_end_date')) {
615
+				$ticket->set('TKT_end_date', $ticket->get('TKT_start_date'));
616
+				$ticket = EEH_DTT_Helper::date_time_add($ticket, 'TKT_end_date', 'days');
617
+			}
618
+			// let's make sure the base price is handled
619
+			$ticket = ! $create_new_TKT
620
+				? $this->_add_prices_to_ticket(
621
+					array(),
622
+					$ticket,
623
+					$update_prices,
624
+					$base_price,
625
+					$base_price_id
626
+				)
627
+				: $ticket;
628
+			// add/update price_modifiers
629
+			$ticket = ! $create_new_TKT
630
+				? $this->_add_prices_to_ticket($price_rows, $ticket, $update_prices)
631
+				: $ticket;
632
+			// need to make sue that the TKT_price is accurate after saving the prices.
633
+			$ticket->ensure_TKT_Price_correct();
634
+			// handle CREATING a default tkt from the incoming tkt but ONLY if this isn't an autosave.
635
+			if (! defined('DOING_AUTOSAVE') && ! empty($tkt['TKT_is_default_selector'])) {
636
+				$update_prices = true;
637
+				$new_default = clone $ticket;
638
+				$new_default->set('TKT_ID', 0);
639
+				$new_default->set('TKT_is_default', 1);
640
+				$new_default->set('TKT_row', 1);
641
+				$new_default->set('TKT_price', $ticket_price);
642
+				// remove any dtt relations cause we DON'T want dtt relations attached
643
+				// (note this is just removing the cached relations in the object)
644
+				$new_default->_remove_relations('Datetime');
645
+				// @todo we need to add the current attached prices as new prices to the new default ticket.
646
+				$new_default = $this->_add_prices_to_ticket(
647
+					$price_rows,
648
+					$new_default,
649
+					$update_prices
650
+				);
651
+				// don't forget the base price!
652
+				$new_default = $this->_add_prices_to_ticket(
653
+					array(),
654
+					$new_default,
655
+					$update_prices,
656
+					$base_price,
657
+					$base_price_id
658
+				);
659
+				$new_default->save();
660
+				do_action(
661
+					'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket',
662
+					$new_default,
663
+					$row,
664
+					$ticket,
665
+					$data
666
+				);
667
+			}
668
+			// DO ALL dtt relationships for both current tickets and any archived tickets
669
+			// for the given dtt that are related to the current ticket.
670
+			// TODO... not sure exactly how we're going to do this considering we don't know
671
+			// what current ticket the archived tickets are related to
672
+			// (and TKT_parent is used for autosaves so that's not a field we can reliably use).
673
+			// let's assign any tickets that have been setup to the saved_tickets tracker
674
+			// save existing TKT
675
+			$ticket->save();
676
+			if ($create_new_TKT && $new_tkt instanceof EE_Ticket) {
677
+				// save new TKT
678
+				$new_tkt->save();
679
+				// add new ticket to array
680
+				$saved_tickets[ $new_tkt->ID() ] = $new_tkt;
681
+				do_action(
682
+					'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket',
683
+					$new_tkt,
684
+					$row,
685
+					$tkt,
686
+					$data
687
+				);
688
+			} else {
689
+				// add tkt to saved tkts
690
+				$saved_tickets[ $ticket->ID() ] = $ticket;
691
+				do_action(
692
+					'AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket',
693
+					$ticket,
694
+					$row,
695
+					$tkt,
696
+					$data
697
+				);
698
+			}
699
+		}
700
+		// now we need to handle tickets actually "deleted permanently".
701
+		// There are cases where we'd want this to happen
702
+		// (i.e. autosaves are happening and then in between autosaves the user trashes a ticket).
703
+		// Or a draft event was saved and in the process of editing a ticket is trashed.
704
+		// No sense in keeping all the related data in the db!
705
+		$old_tickets = isset($old_tickets[0]) && $old_tickets[0] === '' ? array() : $old_tickets;
706
+		$tickets_removed = array_diff($old_tickets, array_keys($saved_tickets));
707
+		foreach ($tickets_removed as $id) {
708
+			$id = absint($id);
709
+			// get the ticket for this id
710
+			$tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id);
711
+			// if this tkt is a default tkt we leave it alone cause it won't be attached to the datetime
712
+			if ($tkt_to_remove->get('TKT_is_default')) {
713
+				continue;
714
+			}
715
+			// if this tkt has any registrations attached so then we just ARCHIVE
716
+			// because we don't actually permanently delete these tickets.
717
+			if ($tkt_to_remove->count_related('Registration') > 0) {
718
+				$tkt_to_remove->delete();
719
+				continue;
720
+			}
721
+			// need to get all the related datetimes on this ticket and remove from every single one of them
722
+			// (remember this process can ONLY kick off if there are NO tkts_sold)
723
+			$datetimes = $tkt_to_remove->get_many_related('Datetime');
724
+			foreach ($datetimes as $datetime) {
725
+				$tkt_to_remove->_remove_relation_to($datetime, 'Datetime');
726
+			}
727
+			// need to do the same for prices (except these prices can also be deleted because again,
728
+			// tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived))
729
+			$tkt_to_remove->delete_related_permanently('Price');
730
+			do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $tkt_to_remove);
731
+			// finally let's delete this ticket
732
+			// (which should not be blocked at this point b/c we've removed all our relationships)
733
+			$tkt_to_remove->delete_permanently();
734
+		}
735
+		return $saved_tickets;
736
+	}
737 737
 
738 738
 
739
-    /**
740
-     * @access  protected
741
-     * @param EE_Ticket      $ticket
742
-     * @param \EE_Datetime[] $saved_datetimes
743
-     * @param \EE_Datetime[] $added_datetimes
744
-     * @param \EE_Datetime[] $removed_datetimes
745
-     * @return EE_Ticket
746
-     * @throws EE_Error
747
-     */
748
-    protected function _update_ticket_datetimes(
749
-        EE_Ticket $ticket,
750
-        $saved_datetimes = array(),
751
-        $added_datetimes = array(),
752
-        $removed_datetimes = array()
753
-    ) {
754
-        // to start we have to add the ticket to all the datetimes its supposed to be with,
755
-        // and removing the ticket from datetimes it got removed from.
756
-        // first let's add datetimes
757
-        if (! empty($added_datetimes) && is_array($added_datetimes)) {
758
-            foreach ($added_datetimes as $row_id) {
759
-                $row_id = (int) $row_id;
760
-                if (isset($saved_datetimes[ $row_id ]) && $saved_datetimes[ $row_id ] instanceof EE_Datetime) {
761
-                    $ticket->_add_relation_to($saved_datetimes[ $row_id ], 'Datetime');
762
-                }
763
-            }
764
-        }
765
-        // then remove datetimes
766
-        if (! empty($removed_datetimes) && is_array($removed_datetimes)) {
767
-            foreach ($removed_datetimes as $row_id) {
768
-                $row_id = (int) $row_id;
769
-                // its entirely possible that a datetime got deleted (instead of just removed from relationship.
770
-                // So make sure we skip over this if the dtt isn't in the $saved_datetimes array)
771
-                if (isset($saved_datetimes[ $row_id ]) && $saved_datetimes[ $row_id ] instanceof EE_Datetime) {
772
-                    $ticket->_remove_relation_to($saved_datetimes[ $row_id ], 'Datetime');
773
-                }
774
-            }
775
-        }
776
-        // cap ticket qty by datetime reg limits
777
-        $ticket->set_qty(min($ticket->qty(), $ticket->qty('reg_limit')));
778
-        return $ticket;
779
-    }
739
+	/**
740
+	 * @access  protected
741
+	 * @param EE_Ticket      $ticket
742
+	 * @param \EE_Datetime[] $saved_datetimes
743
+	 * @param \EE_Datetime[] $added_datetimes
744
+	 * @param \EE_Datetime[] $removed_datetimes
745
+	 * @return EE_Ticket
746
+	 * @throws EE_Error
747
+	 */
748
+	protected function _update_ticket_datetimes(
749
+		EE_Ticket $ticket,
750
+		$saved_datetimes = array(),
751
+		$added_datetimes = array(),
752
+		$removed_datetimes = array()
753
+	) {
754
+		// to start we have to add the ticket to all the datetimes its supposed to be with,
755
+		// and removing the ticket from datetimes it got removed from.
756
+		// first let's add datetimes
757
+		if (! empty($added_datetimes) && is_array($added_datetimes)) {
758
+			foreach ($added_datetimes as $row_id) {
759
+				$row_id = (int) $row_id;
760
+				if (isset($saved_datetimes[ $row_id ]) && $saved_datetimes[ $row_id ] instanceof EE_Datetime) {
761
+					$ticket->_add_relation_to($saved_datetimes[ $row_id ], 'Datetime');
762
+				}
763
+			}
764
+		}
765
+		// then remove datetimes
766
+		if (! empty($removed_datetimes) && is_array($removed_datetimes)) {
767
+			foreach ($removed_datetimes as $row_id) {
768
+				$row_id = (int) $row_id;
769
+				// its entirely possible that a datetime got deleted (instead of just removed from relationship.
770
+				// So make sure we skip over this if the dtt isn't in the $saved_datetimes array)
771
+				if (isset($saved_datetimes[ $row_id ]) && $saved_datetimes[ $row_id ] instanceof EE_Datetime) {
772
+					$ticket->_remove_relation_to($saved_datetimes[ $row_id ], 'Datetime');
773
+				}
774
+			}
775
+		}
776
+		// cap ticket qty by datetime reg limits
777
+		$ticket->set_qty(min($ticket->qty(), $ticket->qty('reg_limit')));
778
+		return $ticket;
779
+	}
780 780
 
781 781
 
782
-    /**
783
-     * @access  protected
784
-     * @param EE_Ticket $ticket
785
-     * @param array     $price_rows
786
-     * @param int       $ticket_price
787
-     * @param int       $base_price
788
-     * @param int       $base_price_id
789
-     * @return EE_Ticket
790
-     * @throws ReflectionException
791
-     * @throws InvalidArgumentException
792
-     * @throws InvalidInterfaceException
793
-     * @throws InvalidDataTypeException
794
-     * @throws EE_Error
795
-     */
796
-    protected function _duplicate_ticket(
797
-        EE_Ticket $ticket,
798
-        $price_rows = array(),
799
-        $ticket_price = 0,
800
-        $base_price = 0,
801
-        $base_price_id = 0
802
-    ) {
803
-        // create new ticket that's a copy of the existing
804
-        // except a new id of course (and not archived)
805
-        // AND has the new TKT_price associated with it.
806
-        $new_ticket = clone $ticket;
807
-        $new_ticket->set('TKT_ID', 0);
808
-        $new_ticket->set_deleted(0);
809
-        $new_ticket->set_price($ticket_price);
810
-        $new_ticket->set_sold(0);
811
-        // let's get a new ID for this ticket
812
-        $new_ticket->save();
813
-        // we also need to make sure this new ticket gets the same datetime attachments as the archived ticket
814
-        $datetimes_on_existing = $ticket->datetimes();
815
-        $new_ticket = $this->_update_ticket_datetimes(
816
-            $new_ticket,
817
-            $datetimes_on_existing,
818
-            array_keys($datetimes_on_existing)
819
-        );
820
-        // $ticket will get archived later b/c we are NOT adding it to the saved_tickets array.
821
-        // if existing $ticket has sold amount, then we need to adjust the qty for the new TKT to = the remaining
822
-        // available.
823
-        if ($ticket->sold() > 0) {
824
-            $new_qty = $ticket->qty() - $ticket->sold();
825
-            $new_ticket->set_qty($new_qty);
826
-        }
827
-        // now we update the prices just for this ticket
828
-        $new_ticket = $this->_add_prices_to_ticket($price_rows, $new_ticket, true);
829
-        // and we update the base price
830
-        $new_ticket = $this->_add_prices_to_ticket(
831
-            array(),
832
-            $new_ticket,
833
-            true,
834
-            $base_price,
835
-            $base_price_id
836
-        );
837
-        return $new_ticket;
838
-    }
782
+	/**
783
+	 * @access  protected
784
+	 * @param EE_Ticket $ticket
785
+	 * @param array     $price_rows
786
+	 * @param int       $ticket_price
787
+	 * @param int       $base_price
788
+	 * @param int       $base_price_id
789
+	 * @return EE_Ticket
790
+	 * @throws ReflectionException
791
+	 * @throws InvalidArgumentException
792
+	 * @throws InvalidInterfaceException
793
+	 * @throws InvalidDataTypeException
794
+	 * @throws EE_Error
795
+	 */
796
+	protected function _duplicate_ticket(
797
+		EE_Ticket $ticket,
798
+		$price_rows = array(),
799
+		$ticket_price = 0,
800
+		$base_price = 0,
801
+		$base_price_id = 0
802
+	) {
803
+		// create new ticket that's a copy of the existing
804
+		// except a new id of course (and not archived)
805
+		// AND has the new TKT_price associated with it.
806
+		$new_ticket = clone $ticket;
807
+		$new_ticket->set('TKT_ID', 0);
808
+		$new_ticket->set_deleted(0);
809
+		$new_ticket->set_price($ticket_price);
810
+		$new_ticket->set_sold(0);
811
+		// let's get a new ID for this ticket
812
+		$new_ticket->save();
813
+		// we also need to make sure this new ticket gets the same datetime attachments as the archived ticket
814
+		$datetimes_on_existing = $ticket->datetimes();
815
+		$new_ticket = $this->_update_ticket_datetimes(
816
+			$new_ticket,
817
+			$datetimes_on_existing,
818
+			array_keys($datetimes_on_existing)
819
+		);
820
+		// $ticket will get archived later b/c we are NOT adding it to the saved_tickets array.
821
+		// if existing $ticket has sold amount, then we need to adjust the qty for the new TKT to = the remaining
822
+		// available.
823
+		if ($ticket->sold() > 0) {
824
+			$new_qty = $ticket->qty() - $ticket->sold();
825
+			$new_ticket->set_qty($new_qty);
826
+		}
827
+		// now we update the prices just for this ticket
828
+		$new_ticket = $this->_add_prices_to_ticket($price_rows, $new_ticket, true);
829
+		// and we update the base price
830
+		$new_ticket = $this->_add_prices_to_ticket(
831
+			array(),
832
+			$new_ticket,
833
+			true,
834
+			$base_price,
835
+			$base_price_id
836
+		);
837
+		return $new_ticket;
838
+	}
839 839
 
840 840
 
841
-    /**
842
-     * This attaches a list of given prices to a ticket.
843
-     * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change
844
-     * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old
845
-     * price info and prices are automatically "archived" via the ticket.
846
-     *
847
-     * @access  private
848
-     * @param array     $prices        Array of prices from the form.
849
-     * @param EE_Ticket $ticket        EE_Ticket object that prices are being attached to.
850
-     * @param bool      $new_prices    Whether attach existing incoming prices or create new ones.
851
-     * @param int|bool  $base_price    if FALSE then NOT doing a base price add.
852
-     * @param int|bool  $base_price_id if present then this is the base_price_id being updated.
853
-     * @return EE_Ticket
854
-     * @throws ReflectionException
855
-     * @throws InvalidArgumentException
856
-     * @throws InvalidInterfaceException
857
-     * @throws InvalidDataTypeException
858
-     * @throws EE_Error
859
-     */
860
-    protected function _add_prices_to_ticket(
861
-        $prices = array(),
862
-        EE_Ticket $ticket,
863
-        $new_prices = false,
864
-        $base_price = false,
865
-        $base_price_id = false
866
-    ) {
867
-        // let's just get any current prices that may exist on the given ticket
868
-        // so we can remove any prices that got trashed in this session.
869
-        $current_prices_on_ticket = $base_price !== false
870
-            ? $ticket->base_price(true)
871
-            : $ticket->price_modifiers();
872
-        $updated_prices = array();
873
-        // if $base_price ! FALSE then updating a base price.
874
-        if ($base_price !== false) {
875
-            $prices[1] = array(
876
-                'PRC_ID'     => $new_prices || $base_price_id === 1 ? null : $base_price_id,
877
-                'PRT_ID'     => 1,
878
-                'PRC_amount' => $base_price,
879
-                'PRC_name'   => $ticket->get('TKT_name'),
880
-                'PRC_desc'   => $ticket->get('TKT_description'),
881
-            );
882
-        }
883
-        // possibly need to save tkt
884
-        if (! $ticket->ID()) {
885
-            $ticket->save();
886
-        }
887
-        foreach ($prices as $row => $prc) {
888
-            $prt_id = ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null;
889
-            if (empty($prt_id)) {
890
-                continue;
891
-            } //prices MUST have a price type id.
892
-            $PRC_values = array(
893
-                'PRC_ID'         => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null,
894
-                'PRT_ID'         => $prt_id,
895
-                'PRC_amount'     => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0,
896
-                'PRC_name'       => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '',
897
-                'PRC_desc'       => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '',
898
-                'PRC_is_default' => false,
899
-                // make sure we set PRC_is_default to false for all ticket saves from event_editor
900
-                'PRC_order'      => $row,
901
-            );
902
-            if ($new_prices || empty($PRC_values['PRC_ID'])) {
903
-                $PRC_values['PRC_ID'] = 0;
904
-                $price = EE_Registry::instance()->load_class(
905
-                    'Price',
906
-                    array($PRC_values),
907
-                    false,
908
-                    false
909
-                );
910
-            } else {
911
-                $price = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']);
912
-                // update this price with new values
913
-                foreach ($PRC_values as $field => $value) {
914
-                    $price->set($field, $value);
915
-                }
916
-            }
917
-            $price->save();
918
-            $updated_prices[ $price->ID() ] = $price;
919
-            $ticket->_add_relation_to($price, 'Price');
920
-        }
921
-        // now let's remove any prices that got removed from the ticket
922
-        if (! empty($current_prices_on_ticket)) {
923
-            $current = array_keys($current_prices_on_ticket);
924
-            $updated = array_keys($updated_prices);
925
-            $prices_to_remove = array_diff($current, $updated);
926
-            if (! empty($prices_to_remove)) {
927
-                foreach ($prices_to_remove as $prc_id) {
928
-                    $p = $current_prices_on_ticket[ $prc_id ];
929
-                    $ticket->_remove_relation_to($p, 'Price');
930
-                    // delete permanently the price
931
-                    $p->delete_permanently();
932
-                }
933
-            }
934
-        }
935
-        return $ticket;
936
-    }
841
+	/**
842
+	 * This attaches a list of given prices to a ticket.
843
+	 * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change
844
+	 * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old
845
+	 * price info and prices are automatically "archived" via the ticket.
846
+	 *
847
+	 * @access  private
848
+	 * @param array     $prices        Array of prices from the form.
849
+	 * @param EE_Ticket $ticket        EE_Ticket object that prices are being attached to.
850
+	 * @param bool      $new_prices    Whether attach existing incoming prices or create new ones.
851
+	 * @param int|bool  $base_price    if FALSE then NOT doing a base price add.
852
+	 * @param int|bool  $base_price_id if present then this is the base_price_id being updated.
853
+	 * @return EE_Ticket
854
+	 * @throws ReflectionException
855
+	 * @throws InvalidArgumentException
856
+	 * @throws InvalidInterfaceException
857
+	 * @throws InvalidDataTypeException
858
+	 * @throws EE_Error
859
+	 */
860
+	protected function _add_prices_to_ticket(
861
+		$prices = array(),
862
+		EE_Ticket $ticket,
863
+		$new_prices = false,
864
+		$base_price = false,
865
+		$base_price_id = false
866
+	) {
867
+		// let's just get any current prices that may exist on the given ticket
868
+		// so we can remove any prices that got trashed in this session.
869
+		$current_prices_on_ticket = $base_price !== false
870
+			? $ticket->base_price(true)
871
+			: $ticket->price_modifiers();
872
+		$updated_prices = array();
873
+		// if $base_price ! FALSE then updating a base price.
874
+		if ($base_price !== false) {
875
+			$prices[1] = array(
876
+				'PRC_ID'     => $new_prices || $base_price_id === 1 ? null : $base_price_id,
877
+				'PRT_ID'     => 1,
878
+				'PRC_amount' => $base_price,
879
+				'PRC_name'   => $ticket->get('TKT_name'),
880
+				'PRC_desc'   => $ticket->get('TKT_description'),
881
+			);
882
+		}
883
+		// possibly need to save tkt
884
+		if (! $ticket->ID()) {
885
+			$ticket->save();
886
+		}
887
+		foreach ($prices as $row => $prc) {
888
+			$prt_id = ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null;
889
+			if (empty($prt_id)) {
890
+				continue;
891
+			} //prices MUST have a price type id.
892
+			$PRC_values = array(
893
+				'PRC_ID'         => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null,
894
+				'PRT_ID'         => $prt_id,
895
+				'PRC_amount'     => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0,
896
+				'PRC_name'       => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '',
897
+				'PRC_desc'       => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '',
898
+				'PRC_is_default' => false,
899
+				// make sure we set PRC_is_default to false for all ticket saves from event_editor
900
+				'PRC_order'      => $row,
901
+			);
902
+			if ($new_prices || empty($PRC_values['PRC_ID'])) {
903
+				$PRC_values['PRC_ID'] = 0;
904
+				$price = EE_Registry::instance()->load_class(
905
+					'Price',
906
+					array($PRC_values),
907
+					false,
908
+					false
909
+				);
910
+			} else {
911
+				$price = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']);
912
+				// update this price with new values
913
+				foreach ($PRC_values as $field => $value) {
914
+					$price->set($field, $value);
915
+				}
916
+			}
917
+			$price->save();
918
+			$updated_prices[ $price->ID() ] = $price;
919
+			$ticket->_add_relation_to($price, 'Price');
920
+		}
921
+		// now let's remove any prices that got removed from the ticket
922
+		if (! empty($current_prices_on_ticket)) {
923
+			$current = array_keys($current_prices_on_ticket);
924
+			$updated = array_keys($updated_prices);
925
+			$prices_to_remove = array_diff($current, $updated);
926
+			if (! empty($prices_to_remove)) {
927
+				foreach ($prices_to_remove as $prc_id) {
928
+					$p = $current_prices_on_ticket[ $prc_id ];
929
+					$ticket->_remove_relation_to($p, 'Price');
930
+					// delete permanently the price
931
+					$p->delete_permanently();
932
+				}
933
+			}
934
+		}
935
+		return $ticket;
936
+	}
937 937
 
938 938
 
939
-    /**
940
-     * @param Events_Admin_Page $event_admin_obj
941
-     * @return Events_Admin_Page
942
-     */
943
-    public function autosave_handling(Events_Admin_Page $event_admin_obj)
944
-    {
945
-        return $event_admin_obj;
946
-        // doing nothing for the moment.
947
-        // todo when I get to this remember that I need to set the template args on the $event_admin_obj
948
-        // (use the set_template_args() method)
949
-        /**
950
-         * need to remember to handle TICKET DEFAULT saves correctly:  I've got two input fields in the dom:
951
-         * 1. TKT_is_default_selector (visible)
952
-         * 2. TKT_is_default (hidden)
953
-         * I think we'll use the TKT_is_default for recording whether the ticket displayed IS a default ticket
954
-         * (on new event creations). Whereas the TKT_is_default_selector is for the user to indicate they want
955
-         * this ticket to be saved as a default.
956
-         * The tricky part is, on an initial display on create or edit (or after manually updating),
957
-         * the TKT_is_default_selector will always be unselected and the TKT_is_default will only be true
958
-         * if this is a create.  However, after an autosave, users will want some sort of indicator that
959
-         * the TKT HAS been saved as a default..
960
-         * in other words we don't want to remove the check on TKT_is_default_selector. So here's what I'm thinking.
961
-         * On Autosave:
962
-         * 1. If TKT_is_default is true: we create a new TKT, send back the new id and add id to related elements,
963
-         * then set the TKT_is_default to false.
964
-         * 2. If TKT_is_default_selector is true: we create/edit existing ticket (following conditions above as well).
965
-         *  We do NOT create a new default ticket.  The checkbox stays selected after autosave.
966
-         * 3. only on MANUAL update do we check for the selection and if selected create the new default ticket.
967
-         */
968
-    }
939
+	/**
940
+	 * @param Events_Admin_Page $event_admin_obj
941
+	 * @return Events_Admin_Page
942
+	 */
943
+	public function autosave_handling(Events_Admin_Page $event_admin_obj)
944
+	{
945
+		return $event_admin_obj;
946
+		// doing nothing for the moment.
947
+		// todo when I get to this remember that I need to set the template args on the $event_admin_obj
948
+		// (use the set_template_args() method)
949
+		/**
950
+		 * need to remember to handle TICKET DEFAULT saves correctly:  I've got two input fields in the dom:
951
+		 * 1. TKT_is_default_selector (visible)
952
+		 * 2. TKT_is_default (hidden)
953
+		 * I think we'll use the TKT_is_default for recording whether the ticket displayed IS a default ticket
954
+		 * (on new event creations). Whereas the TKT_is_default_selector is for the user to indicate they want
955
+		 * this ticket to be saved as a default.
956
+		 * The tricky part is, on an initial display on create or edit (or after manually updating),
957
+		 * the TKT_is_default_selector will always be unselected and the TKT_is_default will only be true
958
+		 * if this is a create.  However, after an autosave, users will want some sort of indicator that
959
+		 * the TKT HAS been saved as a default..
960
+		 * in other words we don't want to remove the check on TKT_is_default_selector. So here's what I'm thinking.
961
+		 * On Autosave:
962
+		 * 1. If TKT_is_default is true: we create a new TKT, send back the new id and add id to related elements,
963
+		 * then set the TKT_is_default to false.
964
+		 * 2. If TKT_is_default_selector is true: we create/edit existing ticket (following conditions above as well).
965
+		 *  We do NOT create a new default ticket.  The checkbox stays selected after autosave.
966
+		 * 3. only on MANUAL update do we check for the selection and if selected create the new default ticket.
967
+		 */
968
+	}
969 969
 
970 970
 
971
-    /**
972
-     * @throws ReflectionException
973
-     * @throws InvalidArgumentException
974
-     * @throws InvalidInterfaceException
975
-     * @throws InvalidDataTypeException
976
-     * @throws DomainException
977
-     * @throws EE_Error
978
-     */
979
-    public function pricing_metabox()
980
-    {
981
-        $existing_datetime_ids = $existing_ticket_ids = $datetime_tickets = $ticket_datetimes = array();
982
-        $event = $this->_adminpage_obj->get_cpt_model_obj();
983
-        // set is_creating_event property.
984
-        $EVT_ID = $event->ID();
985
-        $this->_is_creating_event = empty($this->_req_data['post']);
986
-        // default main template args
987
-        $main_template_args = array(
988
-            'event_datetime_help_link' => EEH_Template::get_help_tab_link(
989
-                'event_editor_event_datetimes_help_tab',
990
-                $this->_adminpage_obj->page_slug,
991
-                $this->_adminpage_obj->get_req_action(),
992
-                false,
993
-                false
994
-            ),
995
-            // todo need to add a filter to the template for the help text
996
-            // in the Events_Admin_Page core file so we can add further help
997
-            'existing_datetime_ids'    => '',
998
-            'total_dtt_rows'           => 1,
999
-            'add_new_dtt_help_link'    => EEH_Template::get_help_tab_link(
1000
-                'add_new_dtt_info',
1001
-                $this->_adminpage_obj->page_slug,
1002
-                $this->_adminpage_obj->get_req_action(),
1003
-                false,
1004
-                false
1005
-            ),
1006
-            // todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
1007
-            'datetime_rows'            => '',
1008
-            'show_tickets_container'   => '',
1009
-            // $this->_adminpage_obj->get_cpt_model_obj()->ID() > 1 ? ' style="display:none;"' : '',
1010
-            'ticket_rows'              => '',
1011
-            'existing_ticket_ids'      => '',
1012
-            'total_ticket_rows'        => 1,
1013
-            'ticket_js_structure'      => '',
1014
-            'ee_collapsible_status'    => ' ee-collapsible-open'
1015
-            // $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? ' ee-collapsible-closed' : ' ee-collapsible-open'
1016
-        );
1017
-        $timezone = $event instanceof EE_Event ? $event->timezone_string() : null;
1018
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1019
-        /**
1020
-         * 1. Start with retrieving Datetimes
1021
-         * 2. For each datetime get related tickets
1022
-         * 3. For each ticket get related prices
1023
-         */
1024
-        /** @var EEM_Datetime $datetime_model */
1025
-        $datetime_model = EE_Registry::instance()->load_model('Datetime', array($timezone));
1026
-        $datetimes = $datetime_model->get_all_event_dates($EVT_ID);
1027
-        $main_template_args['total_dtt_rows'] = count($datetimes);
1028
-        /**
1029
-         * @see https://events.codebasehq.com/projects/event-espresso/tickets/9486
1030
-         * for why we are counting $datetime_row and then setting that on the Datetime object
1031
-         */
1032
-        $datetime_row = 1;
1033
-        foreach ($datetimes as $datetime) {
1034
-            $DTT_ID = $datetime->get('DTT_ID');
1035
-            $datetime->set('DTT_order', $datetime_row);
1036
-            $existing_datetime_ids[] = $DTT_ID;
1037
-            // tickets attached
1038
-            $related_tickets = $datetime->ID() > 0
1039
-                ? $datetime->get_many_related(
1040
-                    'Ticket',
1041
-                    array(
1042
-                        array(
1043
-                            'OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0),
1044
-                        ),
1045
-                        'default_where_conditions' => 'none',
1046
-                        'order_by'                 => array('TKT_order' => 'ASC'),
1047
-                    )
1048
-                )
1049
-                : array();
1050
-            // if there are no related tickets this is likely a new event OR autodraft
1051
-            // event so we need to generate the default tickets because datetimes
1052
-            // ALWAYS have at least one related ticket!!.  EXCEPT, we dont' do this if there is already more than one
1053
-            // datetime on the event.
1054
-            if (empty($related_tickets) && count($datetimes) < 2) {
1055
-                /** @var EEM_Ticket $ticket_model */
1056
-                $ticket_model = EE_Registry::instance()->load_model('Ticket');
1057
-                $related_tickets = $ticket_model->get_all_default_tickets();
1058
-                // this should be ordered by TKT_ID, so let's grab the first default ticket
1059
-                // (which will be the main default) and ensure it has any default prices added to it (but do NOT save).
1060
-                $default_prices = EEM_Price::instance()->get_all_default_prices();
1061
-                $main_default_ticket = reset($related_tickets);
1062
-                if ($main_default_ticket instanceof EE_Ticket) {
1063
-                    foreach ($default_prices as $default_price) {
1064
-                        if ($default_price instanceof EE_Price && $default_price->is_base_price()) {
1065
-                            continue;
1066
-                        }
1067
-                        $main_default_ticket->cache('Price', $default_price);
1068
-                    }
1069
-                }
1070
-            }
1071
-            // we can't actually setup rows in this loop yet cause we don't know all
1072
-            // the unique tickets for this event yet (tickets are linked through all datetimes).
1073
-            // So we're going to temporarily cache some of that information.
1074
-            // loop through and setup the ticket rows and make sure the order is set.
1075
-            foreach ($related_tickets as $ticket) {
1076
-                $TKT_ID = $ticket->get('TKT_ID');
1077
-                $ticket_row = $ticket->get('TKT_row');
1078
-                // we only want unique tickets in our final display!!
1079
-                if (! in_array($TKT_ID, $existing_ticket_ids, true)) {
1080
-                    $existing_ticket_ids[] = $TKT_ID;
1081
-                    $all_tickets[] = $ticket;
1082
-                }
1083
-                // temporary cache of this ticket info for this datetime for later processing of datetime rows.
1084
-                $datetime_tickets[ $DTT_ID ][] = $ticket_row;
1085
-                // temporary cache of this datetime info for this ticket for later processing of ticket rows.
1086
-                if (
1087
-                    ! isset($ticket_datetimes[ $TKT_ID ])
1088
-                    || ! in_array($datetime_row, $ticket_datetimes[ $TKT_ID ], true)
1089
-                ) {
1090
-                    $ticket_datetimes[ $TKT_ID ][] = $datetime_row;
1091
-                }
1092
-            }
1093
-            $datetime_row++;
1094
-        }
1095
-        $main_template_args['total_ticket_rows'] = count($existing_ticket_ids);
1096
-        $main_template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids);
1097
-        $main_template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids);
1098
-        // sort $all_tickets by order
1099
-        usort(
1100
-            $all_tickets,
1101
-            function (EE_Ticket $a, EE_Ticket $b) {
1102
-                $a_order = (int) $a->get('TKT_order');
1103
-                $b_order = (int) $b->get('TKT_order');
1104
-                if ($a_order === $b_order) {
1105
-                    return 0;
1106
-                }
1107
-                return ($a_order < $b_order) ? -1 : 1;
1108
-            }
1109
-        );
1110
-        // k NOW we have all the data we need for setting up the dtt rows
1111
-        // and ticket rows so we start our dtt loop again.
1112
-        $datetime_row = 1;
1113
-        foreach ($datetimes as $datetime) {
1114
-            $main_template_args['datetime_rows'] .= $this->_get_datetime_row(
1115
-                $datetime_row,
1116
-                $datetime,
1117
-                $datetime_tickets,
1118
-                $all_tickets,
1119
-                false,
1120
-                $datetimes
1121
-            );
1122
-            $datetime_row++;
1123
-        }
1124
-        // then loop through all tickets for the ticket rows.
1125
-        $ticket_row = 1;
1126
-        foreach ($all_tickets as $ticket) {
1127
-            $main_template_args['ticket_rows'] .= $this->_get_ticket_row(
1128
-                $ticket_row,
1129
-                $ticket,
1130
-                $ticket_datetimes,
1131
-                $datetimes,
1132
-                false,
1133
-                $all_tickets
1134
-            );
1135
-            $ticket_row++;
1136
-        }
1137
-        $main_template_args['ticket_js_structure'] = $this->_get_ticket_js_structure($datetimes, $all_tickets);
971
+	/**
972
+	 * @throws ReflectionException
973
+	 * @throws InvalidArgumentException
974
+	 * @throws InvalidInterfaceException
975
+	 * @throws InvalidDataTypeException
976
+	 * @throws DomainException
977
+	 * @throws EE_Error
978
+	 */
979
+	public function pricing_metabox()
980
+	{
981
+		$existing_datetime_ids = $existing_ticket_ids = $datetime_tickets = $ticket_datetimes = array();
982
+		$event = $this->_adminpage_obj->get_cpt_model_obj();
983
+		// set is_creating_event property.
984
+		$EVT_ID = $event->ID();
985
+		$this->_is_creating_event = empty($this->_req_data['post']);
986
+		// default main template args
987
+		$main_template_args = array(
988
+			'event_datetime_help_link' => EEH_Template::get_help_tab_link(
989
+				'event_editor_event_datetimes_help_tab',
990
+				$this->_adminpage_obj->page_slug,
991
+				$this->_adminpage_obj->get_req_action(),
992
+				false,
993
+				false
994
+			),
995
+			// todo need to add a filter to the template for the help text
996
+			// in the Events_Admin_Page core file so we can add further help
997
+			'existing_datetime_ids'    => '',
998
+			'total_dtt_rows'           => 1,
999
+			'add_new_dtt_help_link'    => EEH_Template::get_help_tab_link(
1000
+				'add_new_dtt_info',
1001
+				$this->_adminpage_obj->page_slug,
1002
+				$this->_adminpage_obj->get_req_action(),
1003
+				false,
1004
+				false
1005
+			),
1006
+			// todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
1007
+			'datetime_rows'            => '',
1008
+			'show_tickets_container'   => '',
1009
+			// $this->_adminpage_obj->get_cpt_model_obj()->ID() > 1 ? ' style="display:none;"' : '',
1010
+			'ticket_rows'              => '',
1011
+			'existing_ticket_ids'      => '',
1012
+			'total_ticket_rows'        => 1,
1013
+			'ticket_js_structure'      => '',
1014
+			'ee_collapsible_status'    => ' ee-collapsible-open'
1015
+			// $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? ' ee-collapsible-closed' : ' ee-collapsible-open'
1016
+		);
1017
+		$timezone = $event instanceof EE_Event ? $event->timezone_string() : null;
1018
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1019
+		/**
1020
+		 * 1. Start with retrieving Datetimes
1021
+		 * 2. For each datetime get related tickets
1022
+		 * 3. For each ticket get related prices
1023
+		 */
1024
+		/** @var EEM_Datetime $datetime_model */
1025
+		$datetime_model = EE_Registry::instance()->load_model('Datetime', array($timezone));
1026
+		$datetimes = $datetime_model->get_all_event_dates($EVT_ID);
1027
+		$main_template_args['total_dtt_rows'] = count($datetimes);
1028
+		/**
1029
+		 * @see https://events.codebasehq.com/projects/event-espresso/tickets/9486
1030
+		 * for why we are counting $datetime_row and then setting that on the Datetime object
1031
+		 */
1032
+		$datetime_row = 1;
1033
+		foreach ($datetimes as $datetime) {
1034
+			$DTT_ID = $datetime->get('DTT_ID');
1035
+			$datetime->set('DTT_order', $datetime_row);
1036
+			$existing_datetime_ids[] = $DTT_ID;
1037
+			// tickets attached
1038
+			$related_tickets = $datetime->ID() > 0
1039
+				? $datetime->get_many_related(
1040
+					'Ticket',
1041
+					array(
1042
+						array(
1043
+							'OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0),
1044
+						),
1045
+						'default_where_conditions' => 'none',
1046
+						'order_by'                 => array('TKT_order' => 'ASC'),
1047
+					)
1048
+				)
1049
+				: array();
1050
+			// if there are no related tickets this is likely a new event OR autodraft
1051
+			// event so we need to generate the default tickets because datetimes
1052
+			// ALWAYS have at least one related ticket!!.  EXCEPT, we dont' do this if there is already more than one
1053
+			// datetime on the event.
1054
+			if (empty($related_tickets) && count($datetimes) < 2) {
1055
+				/** @var EEM_Ticket $ticket_model */
1056
+				$ticket_model = EE_Registry::instance()->load_model('Ticket');
1057
+				$related_tickets = $ticket_model->get_all_default_tickets();
1058
+				// this should be ordered by TKT_ID, so let's grab the first default ticket
1059
+				// (which will be the main default) and ensure it has any default prices added to it (but do NOT save).
1060
+				$default_prices = EEM_Price::instance()->get_all_default_prices();
1061
+				$main_default_ticket = reset($related_tickets);
1062
+				if ($main_default_ticket instanceof EE_Ticket) {
1063
+					foreach ($default_prices as $default_price) {
1064
+						if ($default_price instanceof EE_Price && $default_price->is_base_price()) {
1065
+							continue;
1066
+						}
1067
+						$main_default_ticket->cache('Price', $default_price);
1068
+					}
1069
+				}
1070
+			}
1071
+			// we can't actually setup rows in this loop yet cause we don't know all
1072
+			// the unique tickets for this event yet (tickets are linked through all datetimes).
1073
+			// So we're going to temporarily cache some of that information.
1074
+			// loop through and setup the ticket rows and make sure the order is set.
1075
+			foreach ($related_tickets as $ticket) {
1076
+				$TKT_ID = $ticket->get('TKT_ID');
1077
+				$ticket_row = $ticket->get('TKT_row');
1078
+				// we only want unique tickets in our final display!!
1079
+				if (! in_array($TKT_ID, $existing_ticket_ids, true)) {
1080
+					$existing_ticket_ids[] = $TKT_ID;
1081
+					$all_tickets[] = $ticket;
1082
+				}
1083
+				// temporary cache of this ticket info for this datetime for later processing of datetime rows.
1084
+				$datetime_tickets[ $DTT_ID ][] = $ticket_row;
1085
+				// temporary cache of this datetime info for this ticket for later processing of ticket rows.
1086
+				if (
1087
+					! isset($ticket_datetimes[ $TKT_ID ])
1088
+					|| ! in_array($datetime_row, $ticket_datetimes[ $TKT_ID ], true)
1089
+				) {
1090
+					$ticket_datetimes[ $TKT_ID ][] = $datetime_row;
1091
+				}
1092
+			}
1093
+			$datetime_row++;
1094
+		}
1095
+		$main_template_args['total_ticket_rows'] = count($existing_ticket_ids);
1096
+		$main_template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids);
1097
+		$main_template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids);
1098
+		// sort $all_tickets by order
1099
+		usort(
1100
+			$all_tickets,
1101
+			function (EE_Ticket $a, EE_Ticket $b) {
1102
+				$a_order = (int) $a->get('TKT_order');
1103
+				$b_order = (int) $b->get('TKT_order');
1104
+				if ($a_order === $b_order) {
1105
+					return 0;
1106
+				}
1107
+				return ($a_order < $b_order) ? -1 : 1;
1108
+			}
1109
+		);
1110
+		// k NOW we have all the data we need for setting up the dtt rows
1111
+		// and ticket rows so we start our dtt loop again.
1112
+		$datetime_row = 1;
1113
+		foreach ($datetimes as $datetime) {
1114
+			$main_template_args['datetime_rows'] .= $this->_get_datetime_row(
1115
+				$datetime_row,
1116
+				$datetime,
1117
+				$datetime_tickets,
1118
+				$all_tickets,
1119
+				false,
1120
+				$datetimes
1121
+			);
1122
+			$datetime_row++;
1123
+		}
1124
+		// then loop through all tickets for the ticket rows.
1125
+		$ticket_row = 1;
1126
+		foreach ($all_tickets as $ticket) {
1127
+			$main_template_args['ticket_rows'] .= $this->_get_ticket_row(
1128
+				$ticket_row,
1129
+				$ticket,
1130
+				$ticket_datetimes,
1131
+				$datetimes,
1132
+				false,
1133
+				$all_tickets
1134
+			);
1135
+			$ticket_row++;
1136
+		}
1137
+		$main_template_args['ticket_js_structure'] = $this->_get_ticket_js_structure($datetimes, $all_tickets);
1138 1138
 
1139
-        $status_change_notice = EventEspresso\core\services\loaders\LoaderFactory::getLoader()->getShared(
1140
-            'EventEspresso\core\domain\services\admin\notices\status_change\StatusChangeNotice'
1141
-        );
1142
-        $main_template_args['status_change_notice'] = $status_change_notice->display(
1143
-            '__event-editor',
1144
-            'espresso-events'
1145
-        );
1139
+		$status_change_notice = EventEspresso\core\services\loaders\LoaderFactory::getLoader()->getShared(
1140
+			'EventEspresso\core\domain\services\admin\notices\status_change\StatusChangeNotice'
1141
+		);
1142
+		$main_template_args['status_change_notice'] = $status_change_notice->display(
1143
+			'__event-editor',
1144
+			'espresso-events'
1145
+		);
1146 1146
 
1147
-        EEH_Template::display_template(
1148
-            PRICING_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php',
1149
-            $main_template_args
1150
-        );
1151
-    }
1147
+		EEH_Template::display_template(
1148
+			PRICING_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php',
1149
+			$main_template_args
1150
+		);
1151
+	}
1152 1152
 
1153 1153
 
1154
-    /**
1155
-     * @param int         $datetime_row
1156
-     * @param EE_Datetime $datetime
1157
-     * @param array       $datetime_tickets
1158
-     * @param array       $all_tickets
1159
-     * @param bool        $default
1160
-     * @param array       $all_datetimes
1161
-     * @return mixed
1162
-     * @throws DomainException
1163
-     * @throws EE_Error
1164
-     */
1165
-    protected function _get_datetime_row(
1166
-        $datetime_row,
1167
-        EE_Datetime $datetime,
1168
-        $datetime_tickets = array(),
1169
-        $all_tickets = array(),
1170
-        $default = false,
1171
-        $all_datetimes = array()
1172
-    ) {
1173
-        $dtt_display_template_args = array(
1174
-            'dtt_edit_row'             => $this->_get_dtt_edit_row(
1175
-                $datetime_row,
1176
-                $datetime,
1177
-                $default,
1178
-                $all_datetimes
1179
-            ),
1180
-            'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row(
1181
-                $datetime_row,
1182
-                $datetime,
1183
-                $datetime_tickets,
1184
-                $all_tickets,
1185
-                $default
1186
-            ),
1187
-            'dtt_row'                  => $default ? 'DTTNUM' : $datetime_row,
1188
-        );
1189
-        return EEH_Template::display_template(
1190
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_row_wrapper.template.php',
1191
-            $dtt_display_template_args,
1192
-            true
1193
-        );
1194
-    }
1154
+	/**
1155
+	 * @param int         $datetime_row
1156
+	 * @param EE_Datetime $datetime
1157
+	 * @param array       $datetime_tickets
1158
+	 * @param array       $all_tickets
1159
+	 * @param bool        $default
1160
+	 * @param array       $all_datetimes
1161
+	 * @return mixed
1162
+	 * @throws DomainException
1163
+	 * @throws EE_Error
1164
+	 */
1165
+	protected function _get_datetime_row(
1166
+		$datetime_row,
1167
+		EE_Datetime $datetime,
1168
+		$datetime_tickets = array(),
1169
+		$all_tickets = array(),
1170
+		$default = false,
1171
+		$all_datetimes = array()
1172
+	) {
1173
+		$dtt_display_template_args = array(
1174
+			'dtt_edit_row'             => $this->_get_dtt_edit_row(
1175
+				$datetime_row,
1176
+				$datetime,
1177
+				$default,
1178
+				$all_datetimes
1179
+			),
1180
+			'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row(
1181
+				$datetime_row,
1182
+				$datetime,
1183
+				$datetime_tickets,
1184
+				$all_tickets,
1185
+				$default
1186
+			),
1187
+			'dtt_row'                  => $default ? 'DTTNUM' : $datetime_row,
1188
+		);
1189
+		return EEH_Template::display_template(
1190
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_row_wrapper.template.php',
1191
+			$dtt_display_template_args,
1192
+			true
1193
+		);
1194
+	}
1195 1195
 
1196 1196
 
1197
-    /**
1198
-     * This method is used to generate a dtt fields  edit row.
1199
-     * The same row is used to generate a row with valid DTT objects
1200
-     * and the default row that is used as the skeleton by the js.
1201
-     *
1202
-     * @param int           $datetime_row  The row number for the row being generated.
1203
-     * @param EE_Datetime   $datetime
1204
-     * @param bool          $default       Whether a default row is being generated or not.
1205
-     * @param EE_Datetime[] $all_datetimes This is the array of all datetimes used in the editor.
1206
-     * @return string
1207
-     * @throws DomainException
1208
-     * @throws EE_Error
1209
-     */
1210
-    protected function _get_dtt_edit_row($datetime_row, $datetime, $default, $all_datetimes)
1211
-    {
1212
-        // if the incoming $datetime object is NOT an instance of EE_Datetime then force default to true.
1213
-        $default = ! $datetime instanceof EE_Datetime ? true : $default;
1214
-        $template_args = array(
1215
-            'dtt_row'              => $default ? 'DTTNUM' : $datetime_row,
1216
-            'event_datetimes_name' => $default ? 'DTTNAMEATTR' : 'edit_event_datetimes',
1217
-            'edit_dtt_expanded'    => '',
1218
-            'DTT_ID'               => $default ? '' : $datetime->ID(),
1219
-            'DTT_name'             => $default ? '' : $datetime->get_f('DTT_name'),
1220
-            'DTT_description'      => $default ? '' : $datetime->get_f('DTT_description'),
1221
-            'DTT_EVT_start'        => $default ? '' : $datetime->start_date($this->_date_time_format),
1222
-            'DTT_EVT_end'          => $default ? '' : $datetime->end_date($this->_date_time_format),
1223
-            'DTT_reg_limit'        => $default
1224
-                ? ''
1225
-                : $datetime->get_pretty(
1226
-                    'DTT_reg_limit',
1227
-                    'input'
1228
-                ),
1229
-            'DTT_order'            => $default ? 'DTTNUM' : $datetime_row,
1230
-            'dtt_sold'             => $default ? '0' : $datetime->get('DTT_sold'),
1231
-            'dtt_reserved'         => $default ? '0' : $datetime->reserved(),
1232
-            'clone_icon'           => ! empty($datetime) && $datetime->get('DTT_sold') > 0
1233
-                ? ''
1234
-                : 'clone-icon ee-icon ee-icon-clone clickable',
1235
-            'trash_icon'           => ! empty($datetime) && $datetime->get('DTT_sold') > 0
1236
-                ? 'dashicons dashicons-lock'
1237
-                : 'trash-icon dashicons dashicons-post-trash clickable',
1238
-            'reg_list_url'         => $default || ! $datetime->event() instanceof \EE_Event
1239
-                ? ''
1240
-                : EE_Admin_Page::add_query_args_and_nonce(
1241
-                    array('event_id' => $datetime->event()->ID(), 'datetime_id' => $datetime->ID()),
1242
-                    REG_ADMIN_URL
1243
-                ),
1244
-        );
1245
-        $template_args['show_trash'] = count($all_datetimes) === 1
1246
-                                       && $template_args['trash_icon'] !== 'dashicons dashicons-lock'
1247
-            ? 'display:none'
1248
-            : '';
1249
-        // allow filtering of template args at this point.
1250
-        $template_args = apply_filters(
1251
-            'FHEE__espresso_events_Pricing_Hooks___get_dtt_edit_row__template_args',
1252
-            $template_args,
1253
-            $datetime_row,
1254
-            $datetime,
1255
-            $default,
1256
-            $all_datetimes,
1257
-            $this->_is_creating_event
1258
-        );
1259
-        return EEH_Template::display_template(
1260
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_edit_row.template.php',
1261
-            $template_args,
1262
-            true
1263
-        );
1264
-    }
1197
+	/**
1198
+	 * This method is used to generate a dtt fields  edit row.
1199
+	 * The same row is used to generate a row with valid DTT objects
1200
+	 * and the default row that is used as the skeleton by the js.
1201
+	 *
1202
+	 * @param int           $datetime_row  The row number for the row being generated.
1203
+	 * @param EE_Datetime   $datetime
1204
+	 * @param bool          $default       Whether a default row is being generated or not.
1205
+	 * @param EE_Datetime[] $all_datetimes This is the array of all datetimes used in the editor.
1206
+	 * @return string
1207
+	 * @throws DomainException
1208
+	 * @throws EE_Error
1209
+	 */
1210
+	protected function _get_dtt_edit_row($datetime_row, $datetime, $default, $all_datetimes)
1211
+	{
1212
+		// if the incoming $datetime object is NOT an instance of EE_Datetime then force default to true.
1213
+		$default = ! $datetime instanceof EE_Datetime ? true : $default;
1214
+		$template_args = array(
1215
+			'dtt_row'              => $default ? 'DTTNUM' : $datetime_row,
1216
+			'event_datetimes_name' => $default ? 'DTTNAMEATTR' : 'edit_event_datetimes',
1217
+			'edit_dtt_expanded'    => '',
1218
+			'DTT_ID'               => $default ? '' : $datetime->ID(),
1219
+			'DTT_name'             => $default ? '' : $datetime->get_f('DTT_name'),
1220
+			'DTT_description'      => $default ? '' : $datetime->get_f('DTT_description'),
1221
+			'DTT_EVT_start'        => $default ? '' : $datetime->start_date($this->_date_time_format),
1222
+			'DTT_EVT_end'          => $default ? '' : $datetime->end_date($this->_date_time_format),
1223
+			'DTT_reg_limit'        => $default
1224
+				? ''
1225
+				: $datetime->get_pretty(
1226
+					'DTT_reg_limit',
1227
+					'input'
1228
+				),
1229
+			'DTT_order'            => $default ? 'DTTNUM' : $datetime_row,
1230
+			'dtt_sold'             => $default ? '0' : $datetime->get('DTT_sold'),
1231
+			'dtt_reserved'         => $default ? '0' : $datetime->reserved(),
1232
+			'clone_icon'           => ! empty($datetime) && $datetime->get('DTT_sold') > 0
1233
+				? ''
1234
+				: 'clone-icon ee-icon ee-icon-clone clickable',
1235
+			'trash_icon'           => ! empty($datetime) && $datetime->get('DTT_sold') > 0
1236
+				? 'dashicons dashicons-lock'
1237
+				: 'trash-icon dashicons dashicons-post-trash clickable',
1238
+			'reg_list_url'         => $default || ! $datetime->event() instanceof \EE_Event
1239
+				? ''
1240
+				: EE_Admin_Page::add_query_args_and_nonce(
1241
+					array('event_id' => $datetime->event()->ID(), 'datetime_id' => $datetime->ID()),
1242
+					REG_ADMIN_URL
1243
+				),
1244
+		);
1245
+		$template_args['show_trash'] = count($all_datetimes) === 1
1246
+									   && $template_args['trash_icon'] !== 'dashicons dashicons-lock'
1247
+			? 'display:none'
1248
+			: '';
1249
+		// allow filtering of template args at this point.
1250
+		$template_args = apply_filters(
1251
+			'FHEE__espresso_events_Pricing_Hooks___get_dtt_edit_row__template_args',
1252
+			$template_args,
1253
+			$datetime_row,
1254
+			$datetime,
1255
+			$default,
1256
+			$all_datetimes,
1257
+			$this->_is_creating_event
1258
+		);
1259
+		return EEH_Template::display_template(
1260
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_edit_row.template.php',
1261
+			$template_args,
1262
+			true
1263
+		);
1264
+	}
1265 1265
 
1266 1266
 
1267
-    /**
1268
-     * @param int         $datetime_row
1269
-     * @param EE_Datetime $datetime
1270
-     * @param array       $datetime_tickets
1271
-     * @param array       $all_tickets
1272
-     * @param bool        $default
1273
-     * @return mixed
1274
-     * @throws DomainException
1275
-     * @throws EE_Error
1276
-     */
1277
-    protected function _get_dtt_attached_tickets_row(
1278
-        $datetime_row,
1279
-        $datetime,
1280
-        $datetime_tickets = array(),
1281
-        $all_tickets = array(),
1282
-        $default
1283
-    ) {
1284
-        $template_args = array(
1285
-            'dtt_row'                           => $default ? 'DTTNUM' : $datetime_row,
1286
-            'event_datetimes_name'              => $default ? 'DTTNAMEATTR' : 'edit_event_datetimes',
1287
-            'DTT_description'                   => $default ? '' : $datetime->get_f('DTT_description'),
1288
-            'datetime_tickets_list'             => $default ? '<li class="hidden"></li>' : '',
1289
-            'show_tickets_row'                  => 'display:none;',
1290
-            'add_new_datetime_ticket_help_link' => EEH_Template::get_help_tab_link(
1291
-                'add_new_ticket_via_datetime',
1292
-                $this->_adminpage_obj->page_slug,
1293
-                $this->_adminpage_obj->get_req_action(),
1294
-                false,
1295
-                false
1296
-            ),
1297
-            // todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
1298
-            'DTT_ID'                            => $default ? '' : $datetime->ID(),
1299
-        );
1300
-        // need to setup the list items (but only if this isn't a default skeleton setup)
1301
-        if (! $default) {
1302
-            $ticket_row = 1;
1303
-            foreach ($all_tickets as $ticket) {
1304
-                $template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item(
1305
-                    $datetime_row,
1306
-                    $ticket_row,
1307
-                    $datetime,
1308
-                    $ticket,
1309
-                    $datetime_tickets,
1310
-                    $default
1311
-                );
1312
-                $ticket_row++;
1313
-            }
1314
-        }
1315
-        // filter template args at this point
1316
-        $template_args = apply_filters(
1317
-            'FHEE__espresso_events_Pricing_Hooks___get_dtt_attached_ticket_row__template_args',
1318
-            $template_args,
1319
-            $datetime_row,
1320
-            $datetime,
1321
-            $datetime_tickets,
1322
-            $all_tickets,
1323
-            $default,
1324
-            $this->_is_creating_event
1325
-        );
1326
-        return EEH_Template::display_template(
1327
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_attached_tickets_row.template.php',
1328
-            $template_args,
1329
-            true
1330
-        );
1331
-    }
1267
+	/**
1268
+	 * @param int         $datetime_row
1269
+	 * @param EE_Datetime $datetime
1270
+	 * @param array       $datetime_tickets
1271
+	 * @param array       $all_tickets
1272
+	 * @param bool        $default
1273
+	 * @return mixed
1274
+	 * @throws DomainException
1275
+	 * @throws EE_Error
1276
+	 */
1277
+	protected function _get_dtt_attached_tickets_row(
1278
+		$datetime_row,
1279
+		$datetime,
1280
+		$datetime_tickets = array(),
1281
+		$all_tickets = array(),
1282
+		$default
1283
+	) {
1284
+		$template_args = array(
1285
+			'dtt_row'                           => $default ? 'DTTNUM' : $datetime_row,
1286
+			'event_datetimes_name'              => $default ? 'DTTNAMEATTR' : 'edit_event_datetimes',
1287
+			'DTT_description'                   => $default ? '' : $datetime->get_f('DTT_description'),
1288
+			'datetime_tickets_list'             => $default ? '<li class="hidden"></li>' : '',
1289
+			'show_tickets_row'                  => 'display:none;',
1290
+			'add_new_datetime_ticket_help_link' => EEH_Template::get_help_tab_link(
1291
+				'add_new_ticket_via_datetime',
1292
+				$this->_adminpage_obj->page_slug,
1293
+				$this->_adminpage_obj->get_req_action(),
1294
+				false,
1295
+				false
1296
+			),
1297
+			// todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
1298
+			'DTT_ID'                            => $default ? '' : $datetime->ID(),
1299
+		);
1300
+		// need to setup the list items (but only if this isn't a default skeleton setup)
1301
+		if (! $default) {
1302
+			$ticket_row = 1;
1303
+			foreach ($all_tickets as $ticket) {
1304
+				$template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item(
1305
+					$datetime_row,
1306
+					$ticket_row,
1307
+					$datetime,
1308
+					$ticket,
1309
+					$datetime_tickets,
1310
+					$default
1311
+				);
1312
+				$ticket_row++;
1313
+			}
1314
+		}
1315
+		// filter template args at this point
1316
+		$template_args = apply_filters(
1317
+			'FHEE__espresso_events_Pricing_Hooks___get_dtt_attached_ticket_row__template_args',
1318
+			$template_args,
1319
+			$datetime_row,
1320
+			$datetime,
1321
+			$datetime_tickets,
1322
+			$all_tickets,
1323
+			$default,
1324
+			$this->_is_creating_event
1325
+		);
1326
+		return EEH_Template::display_template(
1327
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_attached_tickets_row.template.php',
1328
+			$template_args,
1329
+			true
1330
+		);
1331
+	}
1332 1332
 
1333 1333
 
1334
-    /**
1335
-     * @param int         $datetime_row
1336
-     * @param int         $ticket_row
1337
-     * @param EE_Datetime $datetime
1338
-     * @param EE_Ticket   $ticket
1339
-     * @param array       $datetime_tickets
1340
-     * @param bool        $default
1341
-     * @return mixed
1342
-     * @throws DomainException
1343
-     * @throws EE_Error
1344
-     */
1345
-    protected function _get_datetime_tickets_list_item(
1346
-        $datetime_row,
1347
-        $ticket_row,
1348
-        $datetime,
1349
-        $ticket,
1350
-        $datetime_tickets = array(),
1351
-        $default
1352
-    ) {
1353
-        $dtt_tkts = $datetime instanceof EE_Datetime && isset($datetime_tickets[ $datetime->ID() ])
1354
-            ? $datetime_tickets[ $datetime->ID() ]
1355
-            : array();
1356
-        $display_row = $ticket instanceof EE_Ticket ? $ticket->get('TKT_row') : 0;
1357
-        $no_ticket = $default && empty($ticket);
1358
-        $template_args = array(
1359
-            'dtt_row'                 => $default
1360
-                ? 'DTTNUM'
1361
-                : $datetime_row,
1362
-            'tkt_row'                 => $no_ticket
1363
-                ? 'TICKETNUM'
1364
-                : $ticket_row,
1365
-            'datetime_ticket_checked' => in_array($display_row, $dtt_tkts, true)
1366
-                ? ' checked'
1367
-                : '',
1368
-            'ticket_selected'         => in_array($display_row, $dtt_tkts, true)
1369
-                ? ' ticket-selected'
1370
-                : '',
1371
-            'TKT_name'                => $no_ticket
1372
-                ? 'TKTNAME'
1373
-                : $ticket->get('TKT_name'),
1374
-            'tkt_status_class'        => $no_ticket || $this->_is_creating_event
1375
-                ? ' tkt-status-' . EE_Ticket::onsale
1376
-                : ' tkt-status-' . $ticket->ticket_status(),
1377
-        );
1378
-        // filter template args
1379
-        $template_args = apply_filters(
1380
-            'FHEE__espresso_events_Pricing_Hooks___get_datetime_tickets_list_item__template_args',
1381
-            $template_args,
1382
-            $datetime_row,
1383
-            $ticket_row,
1384
-            $datetime,
1385
-            $ticket,
1386
-            $datetime_tickets,
1387
-            $default,
1388
-            $this->_is_creating_event
1389
-        );
1390
-        return EEH_Template::display_template(
1391
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_dtt_tickets_list.template.php',
1392
-            $template_args,
1393
-            true
1394
-        );
1395
-    }
1334
+	/**
1335
+	 * @param int         $datetime_row
1336
+	 * @param int         $ticket_row
1337
+	 * @param EE_Datetime $datetime
1338
+	 * @param EE_Ticket   $ticket
1339
+	 * @param array       $datetime_tickets
1340
+	 * @param bool        $default
1341
+	 * @return mixed
1342
+	 * @throws DomainException
1343
+	 * @throws EE_Error
1344
+	 */
1345
+	protected function _get_datetime_tickets_list_item(
1346
+		$datetime_row,
1347
+		$ticket_row,
1348
+		$datetime,
1349
+		$ticket,
1350
+		$datetime_tickets = array(),
1351
+		$default
1352
+	) {
1353
+		$dtt_tkts = $datetime instanceof EE_Datetime && isset($datetime_tickets[ $datetime->ID() ])
1354
+			? $datetime_tickets[ $datetime->ID() ]
1355
+			: array();
1356
+		$display_row = $ticket instanceof EE_Ticket ? $ticket->get('TKT_row') : 0;
1357
+		$no_ticket = $default && empty($ticket);
1358
+		$template_args = array(
1359
+			'dtt_row'                 => $default
1360
+				? 'DTTNUM'
1361
+				: $datetime_row,
1362
+			'tkt_row'                 => $no_ticket
1363
+				? 'TICKETNUM'
1364
+				: $ticket_row,
1365
+			'datetime_ticket_checked' => in_array($display_row, $dtt_tkts, true)
1366
+				? ' checked'
1367
+				: '',
1368
+			'ticket_selected'         => in_array($display_row, $dtt_tkts, true)
1369
+				? ' ticket-selected'
1370
+				: '',
1371
+			'TKT_name'                => $no_ticket
1372
+				? 'TKTNAME'
1373
+				: $ticket->get('TKT_name'),
1374
+			'tkt_status_class'        => $no_ticket || $this->_is_creating_event
1375
+				? ' tkt-status-' . EE_Ticket::onsale
1376
+				: ' tkt-status-' . $ticket->ticket_status(),
1377
+		);
1378
+		// filter template args
1379
+		$template_args = apply_filters(
1380
+			'FHEE__espresso_events_Pricing_Hooks___get_datetime_tickets_list_item__template_args',
1381
+			$template_args,
1382
+			$datetime_row,
1383
+			$ticket_row,
1384
+			$datetime,
1385
+			$ticket,
1386
+			$datetime_tickets,
1387
+			$default,
1388
+			$this->_is_creating_event
1389
+		);
1390
+		return EEH_Template::display_template(
1391
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_dtt_tickets_list.template.php',
1392
+			$template_args,
1393
+			true
1394
+		);
1395
+	}
1396 1396
 
1397 1397
 
1398
-    /**
1399
-     * This generates the ticket row for tickets.
1400
-     * This same method is used to generate both the actual rows and the js skeleton row
1401
-     * (when default === true)
1402
-     *
1403
-     * @param int           $ticket_row       Represents the row number being generated.
1404
-     * @param               $ticket
1405
-     * @param EE_Datetime[] $ticket_datetimes Either an array of all datetimes on all tickets indexed by each ticket
1406
-     *                                        or empty for default
1407
-     * @param EE_Datetime[] $all_datetimes    All Datetimes on the event or empty for default.
1408
-     * @param bool          $default          Whether default row being generated or not.
1409
-     * @param EE_Ticket[]   $all_tickets      This is an array of all tickets attached to the event
1410
-     *                                        (or empty in the case of defaults)
1411
-     * @return mixed
1412
-     * @throws InvalidArgumentException
1413
-     * @throws InvalidInterfaceException
1414
-     * @throws InvalidDataTypeException
1415
-     * @throws DomainException
1416
-     * @throws EE_Error
1417
-     * @throws ReflectionException
1418
-     */
1419
-    protected function _get_ticket_row(
1420
-        $ticket_row,
1421
-        $ticket,
1422
-        $ticket_datetimes,
1423
-        $all_datetimes,
1424
-        $default = false,
1425
-        $all_tickets = array()
1426
-    ) {
1427
-        // if $ticket is not an instance of EE_Ticket then force default to true.
1428
-        $default = ! $ticket instanceof EE_Ticket ? true : $default;
1429
-        $prices = ! empty($ticket) && ! $default
1430
-            ? $ticket->get_many_related(
1431
-                'Price',
1432
-                array('default_where_conditions' => 'none', 'order_by' => array('PRC_order' => 'ASC'))
1433
-            )
1434
-            : array();
1435
-        // if there is only one price (which would be the base price)
1436
-        // or NO prices and this ticket is a default ticket,
1437
-        // let's just make sure there are no cached default prices on the object.
1438
-        // This is done by not including any query_params.
1439
-        if ($ticket instanceof EE_Ticket && $ticket->is_default() && (count($prices) === 1 || empty($prices))) {
1440
-            $prices = $ticket->prices();
1441
-        }
1442
-        // check if we're dealing with a default ticket in which case
1443
-        // we don't want any starting_ticket_datetime_row values set
1444
-        // (otherwise there won't be any new relationships created for tickets based off of the default ticket).
1445
-        // This will future proof in case there is ever any behaviour change between what the primary_key defaults to.
1446
-        $default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->is_default());
1447
-        $tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[ $ticket->ID() ])
1448
-            ? $ticket_datetimes[ $ticket->ID() ]
1449
-            : array();
1450
-        $ticket_subtotal = $default ? 0 : $ticket->get_ticket_subtotal();
1451
-        $base_price = $default ? null : $ticket->base_price();
1452
-        $count_price_mods = EEM_Price::instance()->get_all_default_prices(true);
1453
-        // breaking out complicated condition for ticket_status
1454
-        if ($default) {
1455
-            $ticket_status_class = ' tkt-status-' . EE_Ticket::onsale;
1456
-        } else {
1457
-            $ticket_status_class = $ticket->is_default()
1458
-                ? ' tkt-status-' . EE_Ticket::onsale
1459
-                : ' tkt-status-' . $ticket->ticket_status();
1460
-        }
1461
-        // breaking out complicated condition for TKT_taxable
1462
-        if ($default) {
1463
-            $TKT_taxable = '';
1464
-        } else {
1465
-            $TKT_taxable = $ticket->taxable()
1466
-                ? 'checked'
1467
-                : '';
1468
-        }
1469
-        if ($default) {
1470
-            $TKT_status = EEH_Template::pretty_status(EE_Ticket::onsale, false, 'sentence');
1471
-        } elseif ($ticket->is_default()) {
1472
-            $TKT_status = EEH_Template::pretty_status(EE_Ticket::onsale, false, 'sentence');
1473
-        } else {
1474
-            $TKT_status = $ticket->ticket_status(true);
1475
-        }
1476
-        if ($default) {
1477
-            $TKT_min = '';
1478
-        } else {
1479
-            $TKT_min = $ticket->min();
1480
-            if ($TKT_min === -1 || $TKT_min === 0) {
1481
-                $TKT_min = '';
1482
-            }
1483
-        }
1484
-        $template_args = array(
1485
-            'tkt_row'                       => $default ? 'TICKETNUM' : $ticket_row,
1486
-            'TKT_order'                     => $default ? 'TICKETNUM' : $ticket_row,
1487
-            // on initial page load this will always be the correct order.
1488
-            'tkt_status_class'              => $ticket_status_class,
1489
-            'display_edit_tkt_row'          => 'display:none;',
1490
-            'edit_tkt_expanded'             => '',
1491
-            'edit_tickets_name'             => $default ? 'TICKETNAMEATTR' : 'edit_tickets',
1492
-            'TKT_name'                      => $default ? '' : $ticket->get_f('TKT_name'),
1493
-            'TKT_start_date'                => $default
1494
-                ? ''
1495
-                : $ticket->get_date('TKT_start_date', $this->_date_time_format),
1496
-            'TKT_end_date'                  => $default
1497
-                ? ''
1498
-                : $ticket->get_date('TKT_end_date', $this->_date_time_format),
1499
-            'TKT_status'                    => $TKT_status,
1500
-            'TKT_price'                     => $default
1501
-                ? ''
1502
-                : EEH_Template::format_currency(
1503
-                    $ticket->get_ticket_total_with_taxes(),
1504
-                    false,
1505
-                    false
1506
-                ),
1507
-            'TKT_price_code'                => EE_Registry::instance()->CFG->currency->code,
1508
-            'TKT_price_amount'              => $default ? 0 : $ticket_subtotal,
1509
-            'TKT_qty'                       => $default
1510
-                ? ''
1511
-                : $ticket->get_pretty('TKT_qty', 'symbol'),
1512
-            'TKT_qty_for_input'             => $default
1513
-                ? ''
1514
-                : $ticket->get_pretty('TKT_qty', 'input'),
1515
-            'TKT_uses'                      => $default
1516
-                ? ''
1517
-                : $ticket->get_pretty('TKT_uses', 'input'),
1518
-            'TKT_min'                       => $TKT_min,
1519
-            'TKT_max'                       => $default
1520
-                ? ''
1521
-                : $ticket->get_pretty('TKT_max', 'input'),
1522
-            'TKT_sold'                      => $default ? 0 : $ticket->tickets_sold('ticket'),
1523
-            'TKT_reserved'                  => $default ? 0 : $ticket->reserved(),
1524
-            'TKT_registrations'             => $default
1525
-                ? 0
1526
-                : $ticket->count_registrations(
1527
-                    array(
1528
-                        array(
1529
-                            'STS_ID' => array(
1530
-                                '!=',
1531
-                                EEM_Registration::status_id_incomplete,
1532
-                            ),
1533
-                        ),
1534
-                    )
1535
-                ),
1536
-            'TKT_ID'                        => $default ? 0 : $ticket->ID(),
1537
-            'TKT_description'               => $default ? '' : $ticket->get_f('TKT_description'),
1538
-            'TKT_is_default'                => $default ? 0 : $ticket->is_default(),
1539
-            'TKT_required'                  => $default ? 0 : $ticket->required(),
1540
-            'TKT_is_default_selector'       => '',
1541
-            'ticket_price_rows'             => '',
1542
-            'TKT_base_price'                => $default || ! $base_price instanceof EE_Price
1543
-                ? ''
1544
-                : $base_price->get_pretty('PRC_amount', 'localized_float'),
1545
-            'TKT_base_price_ID'             => $default || ! $base_price instanceof EE_Price ? 0 : $base_price->ID(),
1546
-            'show_price_modifier'           => count($prices) > 1 || ($default && $count_price_mods > 0)
1547
-                ? ''
1548
-                : 'display:none;',
1549
-            'show_price_mod_button'         => count($prices) > 1
1550
-                                               || ($default && $count_price_mods > 0)
1551
-                                               || (! $default && $ticket->deleted())
1552
-                ? 'display:none;'
1553
-                : '',
1554
-            'total_price_rows'              => count($prices) > 1 ? count($prices) : 1,
1555
-            'ticket_datetimes_list'         => $default ? '<li class="hidden"></li>' : '',
1556
-            'starting_ticket_datetime_rows' => $default || $default_dtt ? '' : implode(',', $tkt_datetimes),
1557
-            'ticket_datetime_rows'          => $default ? '' : implode(',', $tkt_datetimes),
1558
-            'existing_ticket_price_ids'     => $default ? '' : implode(',', array_keys($prices)),
1559
-            'ticket_template_id'            => $default ? 0 : $ticket->get('TTM_ID'),
1560
-            'TKT_taxable'                   => $TKT_taxable,
1561
-            'display_subtotal'              => $ticket instanceof EE_Ticket && $ticket->taxable()
1562
-                ? ''
1563
-                : 'display:none;',
1564
-            'price_currency_symbol'         => EE_Registry::instance()->CFG->currency->sign,
1565
-            'TKT_subtotal_amount_display'   => EEH_Template::format_currency(
1566
-                $ticket_subtotal,
1567
-                false,
1568
-                false
1569
-            ),
1570
-            'TKT_subtotal_amount'           => $ticket_subtotal,
1571
-            'tax_rows'                      => $this->_get_tax_rows($ticket_row, $ticket),
1572
-            'disabled'                      => $ticket instanceof EE_Ticket && $ticket->deleted(),
1573
-            'ticket_archive_class'          => $ticket instanceof EE_Ticket && $ticket->deleted()
1574
-                ? ' ticket-archived'
1575
-                : '',
1576
-            'trash_icon'                    => $ticket instanceof EE_Ticket
1577
-                                               && $ticket->deleted()
1578
-                                               && ! $ticket->is_permanently_deleteable()
1579
-                ? 'dashicons dashicons-lock '
1580
-                : 'trash-icon dashicons dashicons-post-trash clickable',
1581
-            'clone_icon'                    => $ticket instanceof EE_Ticket && $ticket->deleted()
1582
-                ? ''
1583
-                : 'clone-icon ee-icon ee-icon-clone clickable',
1584
-        );
1585
-        $template_args['trash_hidden'] = count($all_tickets) === 1
1586
-                                         && $template_args['trash_icon'] !== 'dashicons dashicons-lock'
1587
-            ? 'display:none'
1588
-            : '';
1589
-        // handle rows that should NOT be empty
1590
-        if (empty($template_args['TKT_start_date'])) {
1591
-            // if empty then the start date will be now.
1592
-            $template_args['TKT_start_date'] = date(
1593
-                $this->_date_time_format,
1594
-                current_time('timestamp')
1595
-            );
1596
-            $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1597
-        }
1598
-        if (empty($template_args['TKT_end_date'])) {
1599
-            // get the earliest datetime (if present);
1600
-            $earliest_dtt = $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0
1601
-                ? $this->_adminpage_obj->get_cpt_model_obj()->get_first_related(
1602
-                    'Datetime',
1603
-                    array('order_by' => array('DTT_EVT_start' => 'ASC'))
1604
-                )
1605
-                : null;
1606
-            if (! empty($earliest_dtt)) {
1607
-                $template_args['TKT_end_date'] = $earliest_dtt->get_datetime(
1608
-                    'DTT_EVT_start',
1609
-                    $this->_date_time_format
1610
-                );
1611
-            } else {
1612
-                // default so let's just use what's been set for the default date-time which is 30 days from now.
1613
-                $template_args['TKT_end_date'] = date(
1614
-                    $this->_date_time_format,
1615
-                    mktime(
1616
-                        24,
1617
-                        0,
1618
-                        0,
1619
-                        date('m'),
1620
-                        date('d') + 29,
1621
-                        date('Y')
1622
-                    )
1623
-                );
1624
-            }
1625
-            $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1626
-        }
1627
-        // generate ticket_datetime items
1628
-        if (! $default) {
1629
-            $datetime_row = 1;
1630
-            foreach ($all_datetimes as $datetime) {
1631
-                $template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item(
1632
-                    $datetime_row,
1633
-                    $ticket_row,
1634
-                    $datetime,
1635
-                    $ticket,
1636
-                    $ticket_datetimes,
1637
-                    $default
1638
-                );
1639
-                $datetime_row++;
1640
-            }
1641
-        }
1642
-        $price_row = 1;
1643
-        foreach ($prices as $price) {
1644
-            if (! $price instanceof EE_Price) {
1645
-                continue;
1646
-            }
1647
-            if ($price->is_base_price()) {
1648
-                $price_row++;
1649
-                continue;
1650
-            }
1651
-            $show_trash = ! ((count($prices) > 1 && $price_row === 1) || count($prices) === 1);
1652
-            $show_create = ! (count($prices) > 1 && count($prices) !== $price_row);
1653
-            $template_args['ticket_price_rows'] .= $this->_get_ticket_price_row(
1654
-                $ticket_row,
1655
-                $price_row,
1656
-                $price,
1657
-                $default,
1658
-                $ticket,
1659
-                $show_trash,
1660
-                $show_create
1661
-            );
1662
-            $price_row++;
1663
-        }
1664
-        // filter $template_args
1665
-        $template_args = apply_filters(
1666
-            'FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args',
1667
-            $template_args,
1668
-            $ticket_row,
1669
-            $ticket,
1670
-            $ticket_datetimes,
1671
-            $all_datetimes,
1672
-            $default,
1673
-            $all_tickets,
1674
-            $this->_is_creating_event
1675
-        );
1676
-        return EEH_Template::display_template(
1677
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_row.template.php',
1678
-            $template_args,
1679
-            true
1680
-        );
1681
-    }
1398
+	/**
1399
+	 * This generates the ticket row for tickets.
1400
+	 * This same method is used to generate both the actual rows and the js skeleton row
1401
+	 * (when default === true)
1402
+	 *
1403
+	 * @param int           $ticket_row       Represents the row number being generated.
1404
+	 * @param               $ticket
1405
+	 * @param EE_Datetime[] $ticket_datetimes Either an array of all datetimes on all tickets indexed by each ticket
1406
+	 *                                        or empty for default
1407
+	 * @param EE_Datetime[] $all_datetimes    All Datetimes on the event or empty for default.
1408
+	 * @param bool          $default          Whether default row being generated or not.
1409
+	 * @param EE_Ticket[]   $all_tickets      This is an array of all tickets attached to the event
1410
+	 *                                        (or empty in the case of defaults)
1411
+	 * @return mixed
1412
+	 * @throws InvalidArgumentException
1413
+	 * @throws InvalidInterfaceException
1414
+	 * @throws InvalidDataTypeException
1415
+	 * @throws DomainException
1416
+	 * @throws EE_Error
1417
+	 * @throws ReflectionException
1418
+	 */
1419
+	protected function _get_ticket_row(
1420
+		$ticket_row,
1421
+		$ticket,
1422
+		$ticket_datetimes,
1423
+		$all_datetimes,
1424
+		$default = false,
1425
+		$all_tickets = array()
1426
+	) {
1427
+		// if $ticket is not an instance of EE_Ticket then force default to true.
1428
+		$default = ! $ticket instanceof EE_Ticket ? true : $default;
1429
+		$prices = ! empty($ticket) && ! $default
1430
+			? $ticket->get_many_related(
1431
+				'Price',
1432
+				array('default_where_conditions' => 'none', 'order_by' => array('PRC_order' => 'ASC'))
1433
+			)
1434
+			: array();
1435
+		// if there is only one price (which would be the base price)
1436
+		// or NO prices and this ticket is a default ticket,
1437
+		// let's just make sure there are no cached default prices on the object.
1438
+		// This is done by not including any query_params.
1439
+		if ($ticket instanceof EE_Ticket && $ticket->is_default() && (count($prices) === 1 || empty($prices))) {
1440
+			$prices = $ticket->prices();
1441
+		}
1442
+		// check if we're dealing with a default ticket in which case
1443
+		// we don't want any starting_ticket_datetime_row values set
1444
+		// (otherwise there won't be any new relationships created for tickets based off of the default ticket).
1445
+		// This will future proof in case there is ever any behaviour change between what the primary_key defaults to.
1446
+		$default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->is_default());
1447
+		$tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[ $ticket->ID() ])
1448
+			? $ticket_datetimes[ $ticket->ID() ]
1449
+			: array();
1450
+		$ticket_subtotal = $default ? 0 : $ticket->get_ticket_subtotal();
1451
+		$base_price = $default ? null : $ticket->base_price();
1452
+		$count_price_mods = EEM_Price::instance()->get_all_default_prices(true);
1453
+		// breaking out complicated condition for ticket_status
1454
+		if ($default) {
1455
+			$ticket_status_class = ' tkt-status-' . EE_Ticket::onsale;
1456
+		} else {
1457
+			$ticket_status_class = $ticket->is_default()
1458
+				? ' tkt-status-' . EE_Ticket::onsale
1459
+				: ' tkt-status-' . $ticket->ticket_status();
1460
+		}
1461
+		// breaking out complicated condition for TKT_taxable
1462
+		if ($default) {
1463
+			$TKT_taxable = '';
1464
+		} else {
1465
+			$TKT_taxable = $ticket->taxable()
1466
+				? 'checked'
1467
+				: '';
1468
+		}
1469
+		if ($default) {
1470
+			$TKT_status = EEH_Template::pretty_status(EE_Ticket::onsale, false, 'sentence');
1471
+		} elseif ($ticket->is_default()) {
1472
+			$TKT_status = EEH_Template::pretty_status(EE_Ticket::onsale, false, 'sentence');
1473
+		} else {
1474
+			$TKT_status = $ticket->ticket_status(true);
1475
+		}
1476
+		if ($default) {
1477
+			$TKT_min = '';
1478
+		} else {
1479
+			$TKT_min = $ticket->min();
1480
+			if ($TKT_min === -1 || $TKT_min === 0) {
1481
+				$TKT_min = '';
1482
+			}
1483
+		}
1484
+		$template_args = array(
1485
+			'tkt_row'                       => $default ? 'TICKETNUM' : $ticket_row,
1486
+			'TKT_order'                     => $default ? 'TICKETNUM' : $ticket_row,
1487
+			// on initial page load this will always be the correct order.
1488
+			'tkt_status_class'              => $ticket_status_class,
1489
+			'display_edit_tkt_row'          => 'display:none;',
1490
+			'edit_tkt_expanded'             => '',
1491
+			'edit_tickets_name'             => $default ? 'TICKETNAMEATTR' : 'edit_tickets',
1492
+			'TKT_name'                      => $default ? '' : $ticket->get_f('TKT_name'),
1493
+			'TKT_start_date'                => $default
1494
+				? ''
1495
+				: $ticket->get_date('TKT_start_date', $this->_date_time_format),
1496
+			'TKT_end_date'                  => $default
1497
+				? ''
1498
+				: $ticket->get_date('TKT_end_date', $this->_date_time_format),
1499
+			'TKT_status'                    => $TKT_status,
1500
+			'TKT_price'                     => $default
1501
+				? ''
1502
+				: EEH_Template::format_currency(
1503
+					$ticket->get_ticket_total_with_taxes(),
1504
+					false,
1505
+					false
1506
+				),
1507
+			'TKT_price_code'                => EE_Registry::instance()->CFG->currency->code,
1508
+			'TKT_price_amount'              => $default ? 0 : $ticket_subtotal,
1509
+			'TKT_qty'                       => $default
1510
+				? ''
1511
+				: $ticket->get_pretty('TKT_qty', 'symbol'),
1512
+			'TKT_qty_for_input'             => $default
1513
+				? ''
1514
+				: $ticket->get_pretty('TKT_qty', 'input'),
1515
+			'TKT_uses'                      => $default
1516
+				? ''
1517
+				: $ticket->get_pretty('TKT_uses', 'input'),
1518
+			'TKT_min'                       => $TKT_min,
1519
+			'TKT_max'                       => $default
1520
+				? ''
1521
+				: $ticket->get_pretty('TKT_max', 'input'),
1522
+			'TKT_sold'                      => $default ? 0 : $ticket->tickets_sold('ticket'),
1523
+			'TKT_reserved'                  => $default ? 0 : $ticket->reserved(),
1524
+			'TKT_registrations'             => $default
1525
+				? 0
1526
+				: $ticket->count_registrations(
1527
+					array(
1528
+						array(
1529
+							'STS_ID' => array(
1530
+								'!=',
1531
+								EEM_Registration::status_id_incomplete,
1532
+							),
1533
+						),
1534
+					)
1535
+				),
1536
+			'TKT_ID'                        => $default ? 0 : $ticket->ID(),
1537
+			'TKT_description'               => $default ? '' : $ticket->get_f('TKT_description'),
1538
+			'TKT_is_default'                => $default ? 0 : $ticket->is_default(),
1539
+			'TKT_required'                  => $default ? 0 : $ticket->required(),
1540
+			'TKT_is_default_selector'       => '',
1541
+			'ticket_price_rows'             => '',
1542
+			'TKT_base_price'                => $default || ! $base_price instanceof EE_Price
1543
+				? ''
1544
+				: $base_price->get_pretty('PRC_amount', 'localized_float'),
1545
+			'TKT_base_price_ID'             => $default || ! $base_price instanceof EE_Price ? 0 : $base_price->ID(),
1546
+			'show_price_modifier'           => count($prices) > 1 || ($default && $count_price_mods > 0)
1547
+				? ''
1548
+				: 'display:none;',
1549
+			'show_price_mod_button'         => count($prices) > 1
1550
+											   || ($default && $count_price_mods > 0)
1551
+											   || (! $default && $ticket->deleted())
1552
+				? 'display:none;'
1553
+				: '',
1554
+			'total_price_rows'              => count($prices) > 1 ? count($prices) : 1,
1555
+			'ticket_datetimes_list'         => $default ? '<li class="hidden"></li>' : '',
1556
+			'starting_ticket_datetime_rows' => $default || $default_dtt ? '' : implode(',', $tkt_datetimes),
1557
+			'ticket_datetime_rows'          => $default ? '' : implode(',', $tkt_datetimes),
1558
+			'existing_ticket_price_ids'     => $default ? '' : implode(',', array_keys($prices)),
1559
+			'ticket_template_id'            => $default ? 0 : $ticket->get('TTM_ID'),
1560
+			'TKT_taxable'                   => $TKT_taxable,
1561
+			'display_subtotal'              => $ticket instanceof EE_Ticket && $ticket->taxable()
1562
+				? ''
1563
+				: 'display:none;',
1564
+			'price_currency_symbol'         => EE_Registry::instance()->CFG->currency->sign,
1565
+			'TKT_subtotal_amount_display'   => EEH_Template::format_currency(
1566
+				$ticket_subtotal,
1567
+				false,
1568
+				false
1569
+			),
1570
+			'TKT_subtotal_amount'           => $ticket_subtotal,
1571
+			'tax_rows'                      => $this->_get_tax_rows($ticket_row, $ticket),
1572
+			'disabled'                      => $ticket instanceof EE_Ticket && $ticket->deleted(),
1573
+			'ticket_archive_class'          => $ticket instanceof EE_Ticket && $ticket->deleted()
1574
+				? ' ticket-archived'
1575
+				: '',
1576
+			'trash_icon'                    => $ticket instanceof EE_Ticket
1577
+											   && $ticket->deleted()
1578
+											   && ! $ticket->is_permanently_deleteable()
1579
+				? 'dashicons dashicons-lock '
1580
+				: 'trash-icon dashicons dashicons-post-trash clickable',
1581
+			'clone_icon'                    => $ticket instanceof EE_Ticket && $ticket->deleted()
1582
+				? ''
1583
+				: 'clone-icon ee-icon ee-icon-clone clickable',
1584
+		);
1585
+		$template_args['trash_hidden'] = count($all_tickets) === 1
1586
+										 && $template_args['trash_icon'] !== 'dashicons dashicons-lock'
1587
+			? 'display:none'
1588
+			: '';
1589
+		// handle rows that should NOT be empty
1590
+		if (empty($template_args['TKT_start_date'])) {
1591
+			// if empty then the start date will be now.
1592
+			$template_args['TKT_start_date'] = date(
1593
+				$this->_date_time_format,
1594
+				current_time('timestamp')
1595
+			);
1596
+			$template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1597
+		}
1598
+		if (empty($template_args['TKT_end_date'])) {
1599
+			// get the earliest datetime (if present);
1600
+			$earliest_dtt = $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0
1601
+				? $this->_adminpage_obj->get_cpt_model_obj()->get_first_related(
1602
+					'Datetime',
1603
+					array('order_by' => array('DTT_EVT_start' => 'ASC'))
1604
+				)
1605
+				: null;
1606
+			if (! empty($earliest_dtt)) {
1607
+				$template_args['TKT_end_date'] = $earliest_dtt->get_datetime(
1608
+					'DTT_EVT_start',
1609
+					$this->_date_time_format
1610
+				);
1611
+			} else {
1612
+				// default so let's just use what's been set for the default date-time which is 30 days from now.
1613
+				$template_args['TKT_end_date'] = date(
1614
+					$this->_date_time_format,
1615
+					mktime(
1616
+						24,
1617
+						0,
1618
+						0,
1619
+						date('m'),
1620
+						date('d') + 29,
1621
+						date('Y')
1622
+					)
1623
+				);
1624
+			}
1625
+			$template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1626
+		}
1627
+		// generate ticket_datetime items
1628
+		if (! $default) {
1629
+			$datetime_row = 1;
1630
+			foreach ($all_datetimes as $datetime) {
1631
+				$template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item(
1632
+					$datetime_row,
1633
+					$ticket_row,
1634
+					$datetime,
1635
+					$ticket,
1636
+					$ticket_datetimes,
1637
+					$default
1638
+				);
1639
+				$datetime_row++;
1640
+			}
1641
+		}
1642
+		$price_row = 1;
1643
+		foreach ($prices as $price) {
1644
+			if (! $price instanceof EE_Price) {
1645
+				continue;
1646
+			}
1647
+			if ($price->is_base_price()) {
1648
+				$price_row++;
1649
+				continue;
1650
+			}
1651
+			$show_trash = ! ((count($prices) > 1 && $price_row === 1) || count($prices) === 1);
1652
+			$show_create = ! (count($prices) > 1 && count($prices) !== $price_row);
1653
+			$template_args['ticket_price_rows'] .= $this->_get_ticket_price_row(
1654
+				$ticket_row,
1655
+				$price_row,
1656
+				$price,
1657
+				$default,
1658
+				$ticket,
1659
+				$show_trash,
1660
+				$show_create
1661
+			);
1662
+			$price_row++;
1663
+		}
1664
+		// filter $template_args
1665
+		$template_args = apply_filters(
1666
+			'FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args',
1667
+			$template_args,
1668
+			$ticket_row,
1669
+			$ticket,
1670
+			$ticket_datetimes,
1671
+			$all_datetimes,
1672
+			$default,
1673
+			$all_tickets,
1674
+			$this->_is_creating_event
1675
+		);
1676
+		return EEH_Template::display_template(
1677
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_row.template.php',
1678
+			$template_args,
1679
+			true
1680
+		);
1681
+	}
1682 1682
 
1683 1683
 
1684
-    /**
1685
-     * @param int            $ticket_row
1686
-     * @param EE_Ticket|null $ticket
1687
-     * @return string
1688
-     * @throws DomainException
1689
-     * @throws EE_Error
1690
-     */
1691
-    protected function _get_tax_rows($ticket_row, $ticket)
1692
-    {
1693
-        $tax_rows = '';
1694
-        /** @var EE_Price[] $taxes */
1695
-        $taxes = empty($ticket) ? EE_Taxes::get_taxes_for_admin() : $ticket->get_ticket_taxes_for_admin();
1696
-        foreach ($taxes as $tax) {
1697
-            $tax_added = $this->_get_tax_added($tax, $ticket);
1698
-            $template_args = array(
1699
-                'display_tax'       => ! empty($ticket) && $ticket->get('TKT_taxable')
1700
-                    ? ''
1701
-                    : 'display:none;',
1702
-                'tax_id'            => $tax->ID(),
1703
-                'tkt_row'           => $ticket_row,
1704
-                'tax_label'         => $tax->get('PRC_name'),
1705
-                'tax_added'         => $tax_added,
1706
-                'tax_added_display' => EEH_Template::format_currency($tax_added, false, false),
1707
-                'tax_amount'        => $tax->get('PRC_amount'),
1708
-            );
1709
-            $template_args = apply_filters(
1710
-                'FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args',
1711
-                $template_args,
1712
-                $ticket_row,
1713
-                $ticket,
1714
-                $this->_is_creating_event
1715
-            );
1716
-            $tax_rows .= EEH_Template::display_template(
1717
-                PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_tax_row.template.php',
1718
-                $template_args,
1719
-                true
1720
-            );
1721
-        }
1722
-        return $tax_rows;
1723
-    }
1684
+	/**
1685
+	 * @param int            $ticket_row
1686
+	 * @param EE_Ticket|null $ticket
1687
+	 * @return string
1688
+	 * @throws DomainException
1689
+	 * @throws EE_Error
1690
+	 */
1691
+	protected function _get_tax_rows($ticket_row, $ticket)
1692
+	{
1693
+		$tax_rows = '';
1694
+		/** @var EE_Price[] $taxes */
1695
+		$taxes = empty($ticket) ? EE_Taxes::get_taxes_for_admin() : $ticket->get_ticket_taxes_for_admin();
1696
+		foreach ($taxes as $tax) {
1697
+			$tax_added = $this->_get_tax_added($tax, $ticket);
1698
+			$template_args = array(
1699
+				'display_tax'       => ! empty($ticket) && $ticket->get('TKT_taxable')
1700
+					? ''
1701
+					: 'display:none;',
1702
+				'tax_id'            => $tax->ID(),
1703
+				'tkt_row'           => $ticket_row,
1704
+				'tax_label'         => $tax->get('PRC_name'),
1705
+				'tax_added'         => $tax_added,
1706
+				'tax_added_display' => EEH_Template::format_currency($tax_added, false, false),
1707
+				'tax_amount'        => $tax->get('PRC_amount'),
1708
+			);
1709
+			$template_args = apply_filters(
1710
+				'FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args',
1711
+				$template_args,
1712
+				$ticket_row,
1713
+				$ticket,
1714
+				$this->_is_creating_event
1715
+			);
1716
+			$tax_rows .= EEH_Template::display_template(
1717
+				PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_tax_row.template.php',
1718
+				$template_args,
1719
+				true
1720
+			);
1721
+		}
1722
+		return $tax_rows;
1723
+	}
1724 1724
 
1725 1725
 
1726
-    /**
1727
-     * @param EE_Price       $tax
1728
-     * @param EE_Ticket|null $ticket
1729
-     * @return float|int
1730
-     * @throws EE_Error
1731
-     */
1732
-    protected function _get_tax_added(EE_Price $tax, $ticket)
1733
-    {
1734
-        $subtotal = empty($ticket) ? 0 : $ticket->get_ticket_subtotal();
1735
-        return $subtotal * $tax->get('PRC_amount') / 100;
1736
-    }
1726
+	/**
1727
+	 * @param EE_Price       $tax
1728
+	 * @param EE_Ticket|null $ticket
1729
+	 * @return float|int
1730
+	 * @throws EE_Error
1731
+	 */
1732
+	protected function _get_tax_added(EE_Price $tax, $ticket)
1733
+	{
1734
+		$subtotal = empty($ticket) ? 0 : $ticket->get_ticket_subtotal();
1735
+		return $subtotal * $tax->get('PRC_amount') / 100;
1736
+	}
1737 1737
 
1738 1738
 
1739
-    /**
1740
-     * @param int            $ticket_row
1741
-     * @param int            $price_row
1742
-     * @param EE_Price|null  $price
1743
-     * @param bool           $default
1744
-     * @param EE_Ticket|null $ticket
1745
-     * @param bool           $show_trash
1746
-     * @param bool           $show_create
1747
-     * @return mixed
1748
-     * @throws InvalidArgumentException
1749
-     * @throws InvalidInterfaceException
1750
-     * @throws InvalidDataTypeException
1751
-     * @throws DomainException
1752
-     * @throws EE_Error
1753
-     * @throws ReflectionException
1754
-     */
1755
-    protected function _get_ticket_price_row(
1756
-        $ticket_row,
1757
-        $price_row,
1758
-        $price,
1759
-        $default,
1760
-        $ticket,
1761
-        $show_trash = true,
1762
-        $show_create = true
1763
-    ) {
1764
-        $send_disabled = ! empty($ticket) && $ticket->get('TKT_deleted');
1765
-        $template_args = array(
1766
-            'tkt_row'               => $default && empty($ticket)
1767
-                ? 'TICKETNUM'
1768
-                : $ticket_row,
1769
-            'PRC_order'             => $default && empty($price)
1770
-                ? 'PRICENUM'
1771
-                : $price_row,
1772
-            'edit_prices_name'      => $default && empty($price)
1773
-                ? 'PRICENAMEATTR'
1774
-                : 'edit_prices',
1775
-            'price_type_selector'   => $default && empty($price)
1776
-                ? $this->_get_base_price_template($ticket_row, $price_row, $price, $default)
1777
-                : $this->_get_price_type_selector(
1778
-                    $ticket_row,
1779
-                    $price_row,
1780
-                    $price,
1781
-                    $default,
1782
-                    $send_disabled
1783
-                ),
1784
-            'PRC_ID'                => $default && empty($price)
1785
-                ? 0
1786
-                : $price->ID(),
1787
-            'PRC_is_default'        => $default && empty($price)
1788
-                ? 0
1789
-                : $price->get('PRC_is_default'),
1790
-            'PRC_name'              => $default && empty($price)
1791
-                ? ''
1792
-                : $price->get('PRC_name'),
1793
-            'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,
1794
-            'show_plus_or_minus'    => $default && empty($price)
1795
-                ? ''
1796
-                : 'display:none;',
1797
-            'show_plus'             => ($default && empty($price)) || ($price->is_discount() || $price->is_base_price())
1798
-                ? 'display:none;'
1799
-                : '',
1800
-            'show_minus'            => ($default && empty($price)) || ! $price->is_discount()
1801
-                ? 'display:none;'
1802
-                : '',
1803
-            'show_currency_symbol'  => ($default && empty($price)) || $price->is_percent()
1804
-                ? 'display:none'
1805
-                : '',
1806
-            'PRC_amount'            => $default && empty($price)
1807
-                ? 0
1808
-                : $price->get_pretty('PRC_amount', 'localized_float'),
1809
-            'show_percentage'       => ($default && empty($price)) || ! $price->is_percent()
1810
-                ? 'display:none;'
1811
-                : '',
1812
-            'show_trash_icon'       => $show_trash
1813
-                ? ''
1814
-                : ' style="display:none;"',
1815
-            'show_create_button'    => $show_create
1816
-                ? ''
1817
-                : ' style="display:none;"',
1818
-            'PRC_desc'              => $default && empty($price)
1819
-                ? ''
1820
-                : $price->get('PRC_desc'),
1821
-            'disabled'              => ! empty($ticket) && $ticket->get('TKT_deleted'),
1822
-        );
1823
-        $template_args = apply_filters(
1824
-            'FHEE__espresso_events_Pricing_Hooks___get_ticket_price_row__template_args',
1825
-            $template_args,
1826
-            $ticket_row,
1827
-            $price_row,
1828
-            $price,
1829
-            $default,
1830
-            $ticket,
1831
-            $show_trash,
1832
-            $show_create,
1833
-            $this->_is_creating_event
1834
-        );
1835
-        return EEH_Template::display_template(
1836
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_price_row.template.php',
1837
-            $template_args,
1838
-            true
1839
-        );
1840
-    }
1739
+	/**
1740
+	 * @param int            $ticket_row
1741
+	 * @param int            $price_row
1742
+	 * @param EE_Price|null  $price
1743
+	 * @param bool           $default
1744
+	 * @param EE_Ticket|null $ticket
1745
+	 * @param bool           $show_trash
1746
+	 * @param bool           $show_create
1747
+	 * @return mixed
1748
+	 * @throws InvalidArgumentException
1749
+	 * @throws InvalidInterfaceException
1750
+	 * @throws InvalidDataTypeException
1751
+	 * @throws DomainException
1752
+	 * @throws EE_Error
1753
+	 * @throws ReflectionException
1754
+	 */
1755
+	protected function _get_ticket_price_row(
1756
+		$ticket_row,
1757
+		$price_row,
1758
+		$price,
1759
+		$default,
1760
+		$ticket,
1761
+		$show_trash = true,
1762
+		$show_create = true
1763
+	) {
1764
+		$send_disabled = ! empty($ticket) && $ticket->get('TKT_deleted');
1765
+		$template_args = array(
1766
+			'tkt_row'               => $default && empty($ticket)
1767
+				? 'TICKETNUM'
1768
+				: $ticket_row,
1769
+			'PRC_order'             => $default && empty($price)
1770
+				? 'PRICENUM'
1771
+				: $price_row,
1772
+			'edit_prices_name'      => $default && empty($price)
1773
+				? 'PRICENAMEATTR'
1774
+				: 'edit_prices',
1775
+			'price_type_selector'   => $default && empty($price)
1776
+				? $this->_get_base_price_template($ticket_row, $price_row, $price, $default)
1777
+				: $this->_get_price_type_selector(
1778
+					$ticket_row,
1779
+					$price_row,
1780
+					$price,
1781
+					$default,
1782
+					$send_disabled
1783
+				),
1784
+			'PRC_ID'                => $default && empty($price)
1785
+				? 0
1786
+				: $price->ID(),
1787
+			'PRC_is_default'        => $default && empty($price)
1788
+				? 0
1789
+				: $price->get('PRC_is_default'),
1790
+			'PRC_name'              => $default && empty($price)
1791
+				? ''
1792
+				: $price->get('PRC_name'),
1793
+			'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,
1794
+			'show_plus_or_minus'    => $default && empty($price)
1795
+				? ''
1796
+				: 'display:none;',
1797
+			'show_plus'             => ($default && empty($price)) || ($price->is_discount() || $price->is_base_price())
1798
+				? 'display:none;'
1799
+				: '',
1800
+			'show_minus'            => ($default && empty($price)) || ! $price->is_discount()
1801
+				? 'display:none;'
1802
+				: '',
1803
+			'show_currency_symbol'  => ($default && empty($price)) || $price->is_percent()
1804
+				? 'display:none'
1805
+				: '',
1806
+			'PRC_amount'            => $default && empty($price)
1807
+				? 0
1808
+				: $price->get_pretty('PRC_amount', 'localized_float'),
1809
+			'show_percentage'       => ($default && empty($price)) || ! $price->is_percent()
1810
+				? 'display:none;'
1811
+				: '',
1812
+			'show_trash_icon'       => $show_trash
1813
+				? ''
1814
+				: ' style="display:none;"',
1815
+			'show_create_button'    => $show_create
1816
+				? ''
1817
+				: ' style="display:none;"',
1818
+			'PRC_desc'              => $default && empty($price)
1819
+				? ''
1820
+				: $price->get('PRC_desc'),
1821
+			'disabled'              => ! empty($ticket) && $ticket->get('TKT_deleted'),
1822
+		);
1823
+		$template_args = apply_filters(
1824
+			'FHEE__espresso_events_Pricing_Hooks___get_ticket_price_row__template_args',
1825
+			$template_args,
1826
+			$ticket_row,
1827
+			$price_row,
1828
+			$price,
1829
+			$default,
1830
+			$ticket,
1831
+			$show_trash,
1832
+			$show_create,
1833
+			$this->_is_creating_event
1834
+		);
1835
+		return EEH_Template::display_template(
1836
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_price_row.template.php',
1837
+			$template_args,
1838
+			true
1839
+		);
1840
+	}
1841 1841
 
1842 1842
 
1843
-    /**
1844
-     * @param int      $ticket_row
1845
-     * @param int      $price_row
1846
-     * @param EE_Price $price
1847
-     * @param bool     $default
1848
-     * @param bool     $disabled
1849
-     * @return mixed
1850
-     * @throws ReflectionException
1851
-     * @throws InvalidArgumentException
1852
-     * @throws InvalidInterfaceException
1853
-     * @throws InvalidDataTypeException
1854
-     * @throws DomainException
1855
-     * @throws EE_Error
1856
-     */
1857
-    protected function _get_price_type_selector($ticket_row, $price_row, $price, $default, $disabled = false)
1858
-    {
1859
-        if ($price->is_base_price()) {
1860
-            return $this->_get_base_price_template(
1861
-                $ticket_row,
1862
-                $price_row,
1863
-                $price,
1864
-                $default
1865
-            );
1866
-        }
1867
-        return $this->_get_price_modifier_template(
1868
-            $ticket_row,
1869
-            $price_row,
1870
-            $price,
1871
-            $default,
1872
-            $disabled
1873
-        );
1874
-    }
1843
+	/**
1844
+	 * @param int      $ticket_row
1845
+	 * @param int      $price_row
1846
+	 * @param EE_Price $price
1847
+	 * @param bool     $default
1848
+	 * @param bool     $disabled
1849
+	 * @return mixed
1850
+	 * @throws ReflectionException
1851
+	 * @throws InvalidArgumentException
1852
+	 * @throws InvalidInterfaceException
1853
+	 * @throws InvalidDataTypeException
1854
+	 * @throws DomainException
1855
+	 * @throws EE_Error
1856
+	 */
1857
+	protected function _get_price_type_selector($ticket_row, $price_row, $price, $default, $disabled = false)
1858
+	{
1859
+		if ($price->is_base_price()) {
1860
+			return $this->_get_base_price_template(
1861
+				$ticket_row,
1862
+				$price_row,
1863
+				$price,
1864
+				$default
1865
+			);
1866
+		}
1867
+		return $this->_get_price_modifier_template(
1868
+			$ticket_row,
1869
+			$price_row,
1870
+			$price,
1871
+			$default,
1872
+			$disabled
1873
+		);
1874
+	}
1875 1875
 
1876 1876
 
1877
-    /**
1878
-     * @param int      $ticket_row
1879
-     * @param int      $price_row
1880
-     * @param EE_Price $price
1881
-     * @param bool     $default
1882
-     * @return mixed
1883
-     * @throws DomainException
1884
-     * @throws EE_Error
1885
-     */
1886
-    protected function _get_base_price_template($ticket_row, $price_row, $price, $default)
1887
-    {
1888
-        $template_args = array(
1889
-            'tkt_row'                   => $default ? 'TICKETNUM' : $ticket_row,
1890
-            'PRC_order'                 => $default && empty($price) ? 'PRICENUM' : $price_row,
1891
-            'PRT_ID'                    => $default && empty($price) ? 1 : $price->get('PRT_ID'),
1892
-            'PRT_name'                  => esc_html__('Price', 'event_espresso'),
1893
-            'price_selected_operator'   => '+',
1894
-            'price_selected_is_percent' => 0,
1895
-        );
1896
-        $template_args = apply_filters(
1897
-            'FHEE__espresso_events_Pricing_Hooks___get_base_price_template__template_args',
1898
-            $template_args,
1899
-            $ticket_row,
1900
-            $price_row,
1901
-            $price,
1902
-            $default,
1903
-            $this->_is_creating_event
1904
-        );
1905
-        return EEH_Template::display_template(
1906
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_type_base.template.php',
1907
-            $template_args,
1908
-            true
1909
-        );
1910
-    }
1877
+	/**
1878
+	 * @param int      $ticket_row
1879
+	 * @param int      $price_row
1880
+	 * @param EE_Price $price
1881
+	 * @param bool     $default
1882
+	 * @return mixed
1883
+	 * @throws DomainException
1884
+	 * @throws EE_Error
1885
+	 */
1886
+	protected function _get_base_price_template($ticket_row, $price_row, $price, $default)
1887
+	{
1888
+		$template_args = array(
1889
+			'tkt_row'                   => $default ? 'TICKETNUM' : $ticket_row,
1890
+			'PRC_order'                 => $default && empty($price) ? 'PRICENUM' : $price_row,
1891
+			'PRT_ID'                    => $default && empty($price) ? 1 : $price->get('PRT_ID'),
1892
+			'PRT_name'                  => esc_html__('Price', 'event_espresso'),
1893
+			'price_selected_operator'   => '+',
1894
+			'price_selected_is_percent' => 0,
1895
+		);
1896
+		$template_args = apply_filters(
1897
+			'FHEE__espresso_events_Pricing_Hooks___get_base_price_template__template_args',
1898
+			$template_args,
1899
+			$ticket_row,
1900
+			$price_row,
1901
+			$price,
1902
+			$default,
1903
+			$this->_is_creating_event
1904
+		);
1905
+		return EEH_Template::display_template(
1906
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_type_base.template.php',
1907
+			$template_args,
1908
+			true
1909
+		);
1910
+	}
1911 1911
 
1912 1912
 
1913
-    /**
1914
-     * @param int      $ticket_row
1915
-     * @param int      $price_row
1916
-     * @param EE_Price $price
1917
-     * @param bool     $default
1918
-     * @param bool     $disabled
1919
-     * @return mixed
1920
-     * @throws ReflectionException
1921
-     * @throws InvalidArgumentException
1922
-     * @throws InvalidInterfaceException
1923
-     * @throws InvalidDataTypeException
1924
-     * @throws DomainException
1925
-     * @throws EE_Error
1926
-     */
1927
-    protected function _get_price_modifier_template(
1928
-        $ticket_row,
1929
-        $price_row,
1930
-        $price,
1931
-        $default,
1932
-        $disabled = false
1933
-    ) {
1934
-        $select_name = $default && ! $price instanceof EE_Price
1935
-            ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]'
1936
-            : 'edit_prices[' . esc_attr($ticket_row) . '][' . esc_attr($price_row) . '][PRT_ID]';
1937
-        /** @var EEM_Price_Type $price_type_model */
1938
-        $price_type_model = EE_Registry::instance()->load_model('Price_Type');
1939
-        $price_types = $price_type_model->get_all(array(
1940
-            array(
1941
-                'OR' => array(
1942
-                    'PBT_ID'  => '2',
1943
-                    'PBT_ID*' => '3',
1944
-                ),
1945
-            ),
1946
-        ));
1947
-        $all_price_types = $default && ! $price instanceof EE_Price
1948
-            ? array(esc_html__('Select Modifier', 'event_espresso'))
1949
-            : array();
1950
-        $selected_price_type_id = $default && ! $price instanceof EE_Price ? 0 : $price->type();
1951
-        $price_option_spans = '';
1952
-        // setup price types for selector
1953
-        foreach ($price_types as $price_type) {
1954
-            if (! $price_type instanceof EE_Price_Type) {
1955
-                continue;
1956
-            }
1957
-            $all_price_types[ $price_type->ID() ] = $price_type->get('PRT_name');
1958
-            // while we're in the loop let's setup the option spans used by js
1959
-            $span_args = array(
1960
-                'PRT_ID'         => $price_type->ID(),
1961
-                'PRT_operator'   => $price_type->is_discount() ? '-' : '+',
1962
-                'PRT_is_percent' => $price_type->get('PRT_is_percent') ? 1 : 0,
1963
-            );
1964
-            $price_option_spans .= EEH_Template::display_template(
1965
-                PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_option_span.template.php',
1966
-                $span_args,
1967
-                true
1968
-            );
1969
-        }
1970
-        $select_name = $disabled ? 'archive_price[' . $ticket_row . '][' . $price_row . '][PRT_ID]'
1971
-            : $select_name;
1972
-        $select_input = new EE_Select_Input(
1973
-            $all_price_types,
1974
-            array(
1975
-                'default'               => $selected_price_type_id,
1976
-                'html_name'             => $select_name,
1977
-                'html_class'            => 'edit-price-PRT_ID',
1978
-                'other_html_attributes' => $disabled ? 'style="width:auto;" disabled' : 'style="width:auto;"',
1979
-            )
1980
-        );
1981
-        $price_selected_operator = $price instanceof EE_Price && $price->is_discount() ? '-' : '+';
1982
-        $price_selected_operator = $default && ! $price instanceof EE_Price ? '' : $price_selected_operator;
1983
-        $price_selected_is_percent = $price instanceof EE_Price && $price->is_percent() ? 1 : 0;
1984
-        $price_selected_is_percent = $default && ! $price instanceof EE_Price ? '' : $price_selected_is_percent;
1985
-        $template_args = array(
1986
-            'tkt_row'                   => $default ? 'TICKETNUM' : $ticket_row,
1987
-            'PRC_order'                 => $default && ! $price instanceof EE_Price ? 'PRICENUM' : $price_row,
1988
-            'price_modifier_selector'   => $select_input->get_html_for_input(),
1989
-            'main_name'                 => $select_name,
1990
-            'selected_price_type_id'    => $selected_price_type_id,
1991
-            'price_option_spans'        => $price_option_spans,
1992
-            'price_selected_operator'   => $price_selected_operator,
1993
-            'price_selected_is_percent' => $price_selected_is_percent,
1994
-            'disabled'                  => $disabled,
1995
-        );
1996
-        $template_args = apply_filters(
1997
-            'FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args',
1998
-            $template_args,
1999
-            $ticket_row,
2000
-            $price_row,
2001
-            $price,
2002
-            $default,
2003
-            $disabled,
2004
-            $this->_is_creating_event
2005
-        );
2006
-        return EEH_Template::display_template(
2007
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_modifier_selector.template.php',
2008
-            $template_args,
2009
-            true
2010
-        );
2011
-    }
1913
+	/**
1914
+	 * @param int      $ticket_row
1915
+	 * @param int      $price_row
1916
+	 * @param EE_Price $price
1917
+	 * @param bool     $default
1918
+	 * @param bool     $disabled
1919
+	 * @return mixed
1920
+	 * @throws ReflectionException
1921
+	 * @throws InvalidArgumentException
1922
+	 * @throws InvalidInterfaceException
1923
+	 * @throws InvalidDataTypeException
1924
+	 * @throws DomainException
1925
+	 * @throws EE_Error
1926
+	 */
1927
+	protected function _get_price_modifier_template(
1928
+		$ticket_row,
1929
+		$price_row,
1930
+		$price,
1931
+		$default,
1932
+		$disabled = false
1933
+	) {
1934
+		$select_name = $default && ! $price instanceof EE_Price
1935
+			? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]'
1936
+			: 'edit_prices[' . esc_attr($ticket_row) . '][' . esc_attr($price_row) . '][PRT_ID]';
1937
+		/** @var EEM_Price_Type $price_type_model */
1938
+		$price_type_model = EE_Registry::instance()->load_model('Price_Type');
1939
+		$price_types = $price_type_model->get_all(array(
1940
+			array(
1941
+				'OR' => array(
1942
+					'PBT_ID'  => '2',
1943
+					'PBT_ID*' => '3',
1944
+				),
1945
+			),
1946
+		));
1947
+		$all_price_types = $default && ! $price instanceof EE_Price
1948
+			? array(esc_html__('Select Modifier', 'event_espresso'))
1949
+			: array();
1950
+		$selected_price_type_id = $default && ! $price instanceof EE_Price ? 0 : $price->type();
1951
+		$price_option_spans = '';
1952
+		// setup price types for selector
1953
+		foreach ($price_types as $price_type) {
1954
+			if (! $price_type instanceof EE_Price_Type) {
1955
+				continue;
1956
+			}
1957
+			$all_price_types[ $price_type->ID() ] = $price_type->get('PRT_name');
1958
+			// while we're in the loop let's setup the option spans used by js
1959
+			$span_args = array(
1960
+				'PRT_ID'         => $price_type->ID(),
1961
+				'PRT_operator'   => $price_type->is_discount() ? '-' : '+',
1962
+				'PRT_is_percent' => $price_type->get('PRT_is_percent') ? 1 : 0,
1963
+			);
1964
+			$price_option_spans .= EEH_Template::display_template(
1965
+				PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_option_span.template.php',
1966
+				$span_args,
1967
+				true
1968
+			);
1969
+		}
1970
+		$select_name = $disabled ? 'archive_price[' . $ticket_row . '][' . $price_row . '][PRT_ID]'
1971
+			: $select_name;
1972
+		$select_input = new EE_Select_Input(
1973
+			$all_price_types,
1974
+			array(
1975
+				'default'               => $selected_price_type_id,
1976
+				'html_name'             => $select_name,
1977
+				'html_class'            => 'edit-price-PRT_ID',
1978
+				'other_html_attributes' => $disabled ? 'style="width:auto;" disabled' : 'style="width:auto;"',
1979
+			)
1980
+		);
1981
+		$price_selected_operator = $price instanceof EE_Price && $price->is_discount() ? '-' : '+';
1982
+		$price_selected_operator = $default && ! $price instanceof EE_Price ? '' : $price_selected_operator;
1983
+		$price_selected_is_percent = $price instanceof EE_Price && $price->is_percent() ? 1 : 0;
1984
+		$price_selected_is_percent = $default && ! $price instanceof EE_Price ? '' : $price_selected_is_percent;
1985
+		$template_args = array(
1986
+			'tkt_row'                   => $default ? 'TICKETNUM' : $ticket_row,
1987
+			'PRC_order'                 => $default && ! $price instanceof EE_Price ? 'PRICENUM' : $price_row,
1988
+			'price_modifier_selector'   => $select_input->get_html_for_input(),
1989
+			'main_name'                 => $select_name,
1990
+			'selected_price_type_id'    => $selected_price_type_id,
1991
+			'price_option_spans'        => $price_option_spans,
1992
+			'price_selected_operator'   => $price_selected_operator,
1993
+			'price_selected_is_percent' => $price_selected_is_percent,
1994
+			'disabled'                  => $disabled,
1995
+		);
1996
+		$template_args = apply_filters(
1997
+			'FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args',
1998
+			$template_args,
1999
+			$ticket_row,
2000
+			$price_row,
2001
+			$price,
2002
+			$default,
2003
+			$disabled,
2004
+			$this->_is_creating_event
2005
+		);
2006
+		return EEH_Template::display_template(
2007
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_modifier_selector.template.php',
2008
+			$template_args,
2009
+			true
2010
+		);
2011
+	}
2012 2012
 
2013 2013
 
2014
-    /**
2015
-     * @param int              $datetime_row
2016
-     * @param int              $ticket_row
2017
-     * @param EE_Datetime|null $datetime
2018
-     * @param EE_Ticket|null   $ticket
2019
-     * @param array            $ticket_datetimes
2020
-     * @param bool             $default
2021
-     * @return mixed
2022
-     * @throws DomainException
2023
-     * @throws EE_Error
2024
-     */
2025
-    protected function _get_ticket_datetime_list_item(
2026
-        $datetime_row,
2027
-        $ticket_row,
2028
-        $datetime,
2029
-        $ticket,
2030
-        $ticket_datetimes = array(),
2031
-        $default
2032
-    ) {
2033
-        $tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[ $ticket->ID() ])
2034
-            ? $ticket_datetimes[ $ticket->ID() ]
2035
-            : array();
2036
-        $template_args = array(
2037
-            'dtt_row'                  => $default && ! $datetime instanceof EE_Datetime
2038
-                ? 'DTTNUM'
2039
-                : $datetime_row,
2040
-            'tkt_row'                  => $default
2041
-                ? 'TICKETNUM'
2042
-                : $ticket_row,
2043
-            'ticket_datetime_selected' => in_array($datetime_row, $tkt_datetimes, true)
2044
-                ? ' ticket-selected'
2045
-                : '',
2046
-            'ticket_datetime_checked'  => in_array($datetime_row, $tkt_datetimes, true)
2047
-                ? ' checked'
2048
-                : '',
2049
-            'DTT_name'                 => $default && empty($datetime)
2050
-                ? 'DTTNAME'
2051
-                : $datetime->get_dtt_display_name(true),
2052
-            'tkt_status_class'         => '',
2053
-        );
2054
-        $template_args = apply_filters(
2055
-            'FHEE__espresso_events_Pricing_Hooks___get_ticket_datetime_list_item__template_args',
2056
-            $template_args,
2057
-            $datetime_row,
2058
-            $ticket_row,
2059
-            $datetime,
2060
-            $ticket,
2061
-            $ticket_datetimes,
2062
-            $default,
2063
-            $this->_is_creating_event
2064
-        );
2065
-        return EEH_Template::display_template(
2066
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_datetimes_list_item.template.php',
2067
-            $template_args,
2068
-            true
2069
-        );
2070
-    }
2014
+	/**
2015
+	 * @param int              $datetime_row
2016
+	 * @param int              $ticket_row
2017
+	 * @param EE_Datetime|null $datetime
2018
+	 * @param EE_Ticket|null   $ticket
2019
+	 * @param array            $ticket_datetimes
2020
+	 * @param bool             $default
2021
+	 * @return mixed
2022
+	 * @throws DomainException
2023
+	 * @throws EE_Error
2024
+	 */
2025
+	protected function _get_ticket_datetime_list_item(
2026
+		$datetime_row,
2027
+		$ticket_row,
2028
+		$datetime,
2029
+		$ticket,
2030
+		$ticket_datetimes = array(),
2031
+		$default
2032
+	) {
2033
+		$tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[ $ticket->ID() ])
2034
+			? $ticket_datetimes[ $ticket->ID() ]
2035
+			: array();
2036
+		$template_args = array(
2037
+			'dtt_row'                  => $default && ! $datetime instanceof EE_Datetime
2038
+				? 'DTTNUM'
2039
+				: $datetime_row,
2040
+			'tkt_row'                  => $default
2041
+				? 'TICKETNUM'
2042
+				: $ticket_row,
2043
+			'ticket_datetime_selected' => in_array($datetime_row, $tkt_datetimes, true)
2044
+				? ' ticket-selected'
2045
+				: '',
2046
+			'ticket_datetime_checked'  => in_array($datetime_row, $tkt_datetimes, true)
2047
+				? ' checked'
2048
+				: '',
2049
+			'DTT_name'                 => $default && empty($datetime)
2050
+				? 'DTTNAME'
2051
+				: $datetime->get_dtt_display_name(true),
2052
+			'tkt_status_class'         => '',
2053
+		);
2054
+		$template_args = apply_filters(
2055
+			'FHEE__espresso_events_Pricing_Hooks___get_ticket_datetime_list_item__template_args',
2056
+			$template_args,
2057
+			$datetime_row,
2058
+			$ticket_row,
2059
+			$datetime,
2060
+			$ticket,
2061
+			$ticket_datetimes,
2062
+			$default,
2063
+			$this->_is_creating_event
2064
+		);
2065
+		return EEH_Template::display_template(
2066
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_datetimes_list_item.template.php',
2067
+			$template_args,
2068
+			true
2069
+		);
2070
+	}
2071 2071
 
2072 2072
 
2073
-    /**
2074
-     * @param array $all_datetimes
2075
-     * @param array $all_tickets
2076
-     * @return mixed
2077
-     * @throws ReflectionException
2078
-     * @throws InvalidArgumentException
2079
-     * @throws InvalidInterfaceException
2080
-     * @throws InvalidDataTypeException
2081
-     * @throws DomainException
2082
-     * @throws EE_Error
2083
-     */
2084
-    protected function _get_ticket_js_structure($all_datetimes = array(), $all_tickets = array())
2085
-    {
2086
-        $template_args = array(
2087
-            'default_datetime_edit_row'                => $this->_get_dtt_edit_row(
2088
-                'DTTNUM',
2089
-                null,
2090
-                true,
2091
-                $all_datetimes
2092
-            ),
2093
-            'default_ticket_row'                       => $this->_get_ticket_row(
2094
-                'TICKETNUM',
2095
-                null,
2096
-                array(),
2097
-                array(),
2098
-                true
2099
-            ),
2100
-            'default_price_row'                        => $this->_get_ticket_price_row(
2101
-                'TICKETNUM',
2102
-                'PRICENUM',
2103
-                null,
2104
-                true,
2105
-                null
2106
-            ),
2107
-            'default_price_rows'                       => '',
2108
-            'default_base_price_amount'                => 0,
2109
-            'default_base_price_name'                  => '',
2110
-            'default_base_price_description'           => '',
2111
-            'default_price_modifier_selector_row'      => $this->_get_price_modifier_template(
2112
-                'TICKETNUM',
2113
-                'PRICENUM',
2114
-                null,
2115
-                true
2116
-            ),
2117
-            'default_available_tickets_for_datetime'   => $this->_get_dtt_attached_tickets_row(
2118
-                'DTTNUM',
2119
-                null,
2120
-                array(),
2121
-                array(),
2122
-                true
2123
-            ),
2124
-            'existing_available_datetime_tickets_list' => '',
2125
-            'existing_available_ticket_datetimes_list' => '',
2126
-            'new_available_datetime_ticket_list_item'  => $this->_get_datetime_tickets_list_item(
2127
-                'DTTNUM',
2128
-                'TICKETNUM',
2129
-                null,
2130
-                null,
2131
-                array(),
2132
-                true
2133
-            ),
2134
-            'new_available_ticket_datetime_list_item'  => $this->_get_ticket_datetime_list_item(
2135
-                'DTTNUM',
2136
-                'TICKETNUM',
2137
-                null,
2138
-                null,
2139
-                array(),
2140
-                true
2141
-            ),
2142
-        );
2143
-        $ticket_row = 1;
2144
-        foreach ($all_tickets as $ticket) {
2145
-            $template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item(
2146
-                'DTTNUM',
2147
-                $ticket_row,
2148
-                null,
2149
-                $ticket,
2150
-                array(),
2151
-                true
2152
-            );
2153
-            $ticket_row++;
2154
-        }
2155
-        $datetime_row = 1;
2156
-        foreach ($all_datetimes as $datetime) {
2157
-            $template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item(
2158
-                $datetime_row,
2159
-                'TICKETNUM',
2160
-                $datetime,
2161
-                null,
2162
-                array(),
2163
-                true
2164
-            );
2165
-            $datetime_row++;
2166
-        }
2167
-        /** @var EEM_Price $price_model */
2168
-        $price_model = EE_Registry::instance()->load_model('Price');
2169
-        $default_prices = $price_model->get_all_default_prices();
2170
-        $price_row = 1;
2171
-        foreach ($default_prices as $price) {
2172
-            if (! $price instanceof EE_Price) {
2173
-                continue;
2174
-            }
2175
-            if ($price->is_base_price()) {
2176
-                $template_args['default_base_price_amount'] = $price->get_pretty(
2177
-                    'PRC_amount',
2178
-                    'localized_float'
2179
-                );
2180
-                $template_args['default_base_price_name'] = $price->get('PRC_name');
2181
-                $template_args['default_base_price_description'] = $price->get('PRC_desc');
2182
-                $price_row++;
2183
-                continue;
2184
-            }
2185
-            $show_trash = ! ((count($default_prices) > 1 && $price_row === 1)
2186
-                             || count($default_prices) === 1);
2187
-            $show_create = ! (count($default_prices) > 1
2188
-                              && count($default_prices)
2189
-                                 !== $price_row);
2190
-            $template_args['default_price_rows'] .= $this->_get_ticket_price_row(
2191
-                'TICKETNUM',
2192
-                $price_row,
2193
-                $price,
2194
-                true,
2195
-                null,
2196
-                $show_trash,
2197
-                $show_create
2198
-            );
2199
-            $price_row++;
2200
-        }
2201
-        $template_args = apply_filters(
2202
-            'FHEE__espresso_events_Pricing_Hooks___get_ticket_js_structure__template_args',
2203
-            $template_args,
2204
-            $all_datetimes,
2205
-            $all_tickets,
2206
-            $this->_is_creating_event
2207
-        );
2208
-        return EEH_Template::display_template(
2209
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_js_structure.template.php',
2210
-            $template_args,
2211
-            true
2212
-        );
2213
-    }
2073
+	/**
2074
+	 * @param array $all_datetimes
2075
+	 * @param array $all_tickets
2076
+	 * @return mixed
2077
+	 * @throws ReflectionException
2078
+	 * @throws InvalidArgumentException
2079
+	 * @throws InvalidInterfaceException
2080
+	 * @throws InvalidDataTypeException
2081
+	 * @throws DomainException
2082
+	 * @throws EE_Error
2083
+	 */
2084
+	protected function _get_ticket_js_structure($all_datetimes = array(), $all_tickets = array())
2085
+	{
2086
+		$template_args = array(
2087
+			'default_datetime_edit_row'                => $this->_get_dtt_edit_row(
2088
+				'DTTNUM',
2089
+				null,
2090
+				true,
2091
+				$all_datetimes
2092
+			),
2093
+			'default_ticket_row'                       => $this->_get_ticket_row(
2094
+				'TICKETNUM',
2095
+				null,
2096
+				array(),
2097
+				array(),
2098
+				true
2099
+			),
2100
+			'default_price_row'                        => $this->_get_ticket_price_row(
2101
+				'TICKETNUM',
2102
+				'PRICENUM',
2103
+				null,
2104
+				true,
2105
+				null
2106
+			),
2107
+			'default_price_rows'                       => '',
2108
+			'default_base_price_amount'                => 0,
2109
+			'default_base_price_name'                  => '',
2110
+			'default_base_price_description'           => '',
2111
+			'default_price_modifier_selector_row'      => $this->_get_price_modifier_template(
2112
+				'TICKETNUM',
2113
+				'PRICENUM',
2114
+				null,
2115
+				true
2116
+			),
2117
+			'default_available_tickets_for_datetime'   => $this->_get_dtt_attached_tickets_row(
2118
+				'DTTNUM',
2119
+				null,
2120
+				array(),
2121
+				array(),
2122
+				true
2123
+			),
2124
+			'existing_available_datetime_tickets_list' => '',
2125
+			'existing_available_ticket_datetimes_list' => '',
2126
+			'new_available_datetime_ticket_list_item'  => $this->_get_datetime_tickets_list_item(
2127
+				'DTTNUM',
2128
+				'TICKETNUM',
2129
+				null,
2130
+				null,
2131
+				array(),
2132
+				true
2133
+			),
2134
+			'new_available_ticket_datetime_list_item'  => $this->_get_ticket_datetime_list_item(
2135
+				'DTTNUM',
2136
+				'TICKETNUM',
2137
+				null,
2138
+				null,
2139
+				array(),
2140
+				true
2141
+			),
2142
+		);
2143
+		$ticket_row = 1;
2144
+		foreach ($all_tickets as $ticket) {
2145
+			$template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item(
2146
+				'DTTNUM',
2147
+				$ticket_row,
2148
+				null,
2149
+				$ticket,
2150
+				array(),
2151
+				true
2152
+			);
2153
+			$ticket_row++;
2154
+		}
2155
+		$datetime_row = 1;
2156
+		foreach ($all_datetimes as $datetime) {
2157
+			$template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item(
2158
+				$datetime_row,
2159
+				'TICKETNUM',
2160
+				$datetime,
2161
+				null,
2162
+				array(),
2163
+				true
2164
+			);
2165
+			$datetime_row++;
2166
+		}
2167
+		/** @var EEM_Price $price_model */
2168
+		$price_model = EE_Registry::instance()->load_model('Price');
2169
+		$default_prices = $price_model->get_all_default_prices();
2170
+		$price_row = 1;
2171
+		foreach ($default_prices as $price) {
2172
+			if (! $price instanceof EE_Price) {
2173
+				continue;
2174
+			}
2175
+			if ($price->is_base_price()) {
2176
+				$template_args['default_base_price_amount'] = $price->get_pretty(
2177
+					'PRC_amount',
2178
+					'localized_float'
2179
+				);
2180
+				$template_args['default_base_price_name'] = $price->get('PRC_name');
2181
+				$template_args['default_base_price_description'] = $price->get('PRC_desc');
2182
+				$price_row++;
2183
+				continue;
2184
+			}
2185
+			$show_trash = ! ((count($default_prices) > 1 && $price_row === 1)
2186
+							 || count($default_prices) === 1);
2187
+			$show_create = ! (count($default_prices) > 1
2188
+							  && count($default_prices)
2189
+								 !== $price_row);
2190
+			$template_args['default_price_rows'] .= $this->_get_ticket_price_row(
2191
+				'TICKETNUM',
2192
+				$price_row,
2193
+				$price,
2194
+				true,
2195
+				null,
2196
+				$show_trash,
2197
+				$show_create
2198
+			);
2199
+			$price_row++;
2200
+		}
2201
+		$template_args = apply_filters(
2202
+			'FHEE__espresso_events_Pricing_Hooks___get_ticket_js_structure__template_args',
2203
+			$template_args,
2204
+			$all_datetimes,
2205
+			$all_tickets,
2206
+			$this->_is_creating_event
2207
+		);
2208
+		return EEH_Template::display_template(
2209
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_js_structure.template.php',
2210
+			$template_args,
2211
+			true
2212
+		);
2213
+	}
2214 2214
 }
Please login to merge, or discard this patch.
Spacing   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
             );
153 153
             $msg .= '</p><ul>';
154 154
             foreach ($format_validation as $error) {
155
-                $msg .= '<li>' . $error . '</li>';
155
+                $msg .= '<li>'.$error.'</li>';
156 156
             }
157 157
             $msg .= '</ul><p>';
158 158
             $msg .= sprintf(
@@ -181,11 +181,11 @@  discard block
 block discarded – undo
181 181
         $this->_scripts_styles = array(
182 182
             'registers'   => array(
183 183
                 'ee-tickets-datetimes-css' => array(
184
-                    'url'  => PRICING_ASSETS_URL . 'event-tickets-datetimes.css',
184
+                    'url'  => PRICING_ASSETS_URL.'event-tickets-datetimes.css',
185 185
                     'type' => 'css',
186 186
                 ),
187 187
                 'ee-dtt-ticket-metabox'    => array(
188
-                    'url'     => PRICING_ASSETS_URL . 'ee-datetime-ticket-metabox.js',
188
+                    'url'     => PRICING_ASSETS_URL.'ee-datetime-ticket-metabox.js',
189 189
                     'depends' => array('ee-datepicker', 'ee-dialog', 'underscore'),
190 190
                 ),
191 191
             ),
@@ -209,9 +209,9 @@  discard block
 block discarded – undo
209 209
                             'event_espresso'
210 210
                         ),
211 211
                         'cancel_button'           => '<button class="button--secondary ee-modal-cancel">'
212
-                                                     . esc_html__('Cancel', 'event_espresso') . '</button>',
212
+                                                     . esc_html__('Cancel', 'event_espresso').'</button>',
213 213
                         'close_button'            => '<button class="button--secondary ee-modal-cancel">'
214
-                                                     . esc_html__('Close', 'event_espresso') . '</button>',
214
+                                                     . esc_html__('Close', 'event_espresso').'</button>',
215 215
                         'single_warning_from_tkt' => esc_html__(
216 216
                             'The Datetime you are attempting to unassign from this ticket is the only remaining datetime for this ticket. Tickets must always have at least one datetime assigned to them.',
217 217
                             'event_espresso'
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
                             'event_espresso'
222 222
                         ),
223 223
                         'dismiss_button'          => '<button class="button--secondary ee-modal-cancel">'
224
-                                                     . esc_html__('Dismiss', 'event_espresso') . '</button>',
224
+                                                     . esc_html__('Dismiss', 'event_espresso').'</button>',
225 225
                     ),
226 226
                     'DTT_ERROR_MSG'         => array(
227 227
                         'no_ticket_name' => esc_html__('General Admission', 'event_espresso'),
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
         foreach ($data['edit_event_datetimes'] as $row => $datetime_data) {
314 314
             // trim all values to ensure any excess whitespace is removed.
315 315
             $datetime_data = array_map(
316
-                function ($datetime_data) {
316
+                function($datetime_data) {
317 317
                     return is_array($datetime_data) ? $datetime_data : trim($datetime_data);
318 318
                 },
319 319
                 $datetime_data
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
             );
344 344
             // if we have an id then let's get existing object first and then set the new values.
345 345
             // Otherwise we instantiate a new object for save.
346
-            if (! empty($datetime_data['DTT_ID'])) {
346
+            if ( ! empty($datetime_data['DTT_ID'])) {
347 347
                 $datetime = EE_Registry::instance()
348 348
                                        ->load_model('Datetime', array($timezone))
349 349
                                        ->get_one_by_ID($datetime_data['DTT_ID']);
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
                 // after the add_relation_to() the autosave replaces it.
358 358
                 // We need to do this so we dont' TRASH the parent DTT.
359 359
                 // (save the ID for both key and value to avoid duplications)
360
-                $saved_dtt_ids[ $datetime->ID() ] = $datetime->ID();
360
+                $saved_dtt_ids[$datetime->ID()] = $datetime->ID();
361 361
             } else {
362 362
                 $datetime = EE_Registry::instance()->load_class(
363 363
                     'Datetime',
@@ -393,8 +393,8 @@  discard block
 block discarded – undo
393 393
             // because it is possible there was a new one created for the autosave.
394 394
             // (save the ID for both key and value to avoid duplications)
395 395
             $DTT_ID = $datetime->ID();
396
-            $saved_dtt_ids[ $DTT_ID ] = $DTT_ID;
397
-            $saved_dtt_objs[ $row ] = $datetime;
396
+            $saved_dtt_ids[$DTT_ID] = $DTT_ID;
397
+            $saved_dtt_objs[$row] = $datetime;
398 398
             // @todo if ANY of these updates fail then we want the appropriate global error message.
399 399
         }
400 400
         $event->save();
@@ -458,13 +458,13 @@  discard block
 block discarded – undo
458 458
             $update_prices = $create_new_TKT = false;
459 459
             // figure out what datetimes were added to the ticket
460 460
             // and what datetimes were removed from the ticket in the session.
461
-            $starting_tkt_dtt_rows = explode(',', $data['starting_ticket_datetime_rows'][ $row ]);
462
-            $tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][ $row ]);
461
+            $starting_tkt_dtt_rows = explode(',', $data['starting_ticket_datetime_rows'][$row]);
462
+            $tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][$row]);
463 463
             $datetimes_added = array_diff($tkt_dtt_rows, $starting_tkt_dtt_rows);
464 464
             $datetimes_removed = array_diff($starting_tkt_dtt_rows, $tkt_dtt_rows);
465 465
             // trim inputs to ensure any excess whitespace is removed.
466 466
             $tkt = array_map(
467
-                function ($ticket_data) {
467
+                function($ticket_data) {
468 468
                     return is_array($ticket_data) ? $ticket_data : trim($ticket_data);
469 469
                 },
470 470
                 $tkt
@@ -484,8 +484,8 @@  discard block
 block discarded – undo
484 484
                 ? $base_price
485 485
                 : $ticket_price;
486 486
             $base_price_id = $tkt['TKT_base_price_ID'] ?? 0;
487
-            $price_rows = is_array($data['edit_prices']) && isset($data['edit_prices'][ $row ])
488
-                ? $data['edit_prices'][ $row ]
487
+            $price_rows = is_array($data['edit_prices']) && isset($data['edit_prices'][$row])
488
+                ? $data['edit_prices'][$row]
489 489
                 : array();
490 490
             $now = null;
491 491
             if (empty($tkt['TKT_start_date'])) {
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
                 /**
498 498
                  * set the TKT_end_date to the first datetime attached to the ticket.
499 499
                  */
500
-                $first_dtt = $saved_datetimes[ reset($tkt_dtt_rows) ];
500
+                $first_dtt = $saved_datetimes[reset($tkt_dtt_rows)];
501 501
                 $tkt['TKT_end_date'] = $first_dtt->start_date_and_time($this->_date_time_format);
502 502
             }
503 503
             $TKT_values = array(
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
             // need to make sue that the TKT_price is accurate after saving the prices.
633 633
             $ticket->ensure_TKT_Price_correct();
634 634
             // handle CREATING a default tkt from the incoming tkt but ONLY if this isn't an autosave.
635
-            if (! defined('DOING_AUTOSAVE') && ! empty($tkt['TKT_is_default_selector'])) {
635
+            if ( ! defined('DOING_AUTOSAVE') && ! empty($tkt['TKT_is_default_selector'])) {
636 636
                 $update_prices = true;
637 637
                 $new_default = clone $ticket;
638 638
                 $new_default->set('TKT_ID', 0);
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
                 // save new TKT
678 678
                 $new_tkt->save();
679 679
                 // add new ticket to array
680
-                $saved_tickets[ $new_tkt->ID() ] = $new_tkt;
680
+                $saved_tickets[$new_tkt->ID()] = $new_tkt;
681 681
                 do_action(
682 682
                     'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket',
683 683
                     $new_tkt,
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
                 );
688 688
             } else {
689 689
                 // add tkt to saved tkts
690
-                $saved_tickets[ $ticket->ID() ] = $ticket;
690
+                $saved_tickets[$ticket->ID()] = $ticket;
691 691
                 do_action(
692 692
                     'AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket',
693 693
                     $ticket,
@@ -754,22 +754,22 @@  discard block
 block discarded – undo
754 754
         // to start we have to add the ticket to all the datetimes its supposed to be with,
755 755
         // and removing the ticket from datetimes it got removed from.
756 756
         // first let's add datetimes
757
-        if (! empty($added_datetimes) && is_array($added_datetimes)) {
757
+        if ( ! empty($added_datetimes) && is_array($added_datetimes)) {
758 758
             foreach ($added_datetimes as $row_id) {
759 759
                 $row_id = (int) $row_id;
760
-                if (isset($saved_datetimes[ $row_id ]) && $saved_datetimes[ $row_id ] instanceof EE_Datetime) {
761
-                    $ticket->_add_relation_to($saved_datetimes[ $row_id ], 'Datetime');
760
+                if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) {
761
+                    $ticket->_add_relation_to($saved_datetimes[$row_id], 'Datetime');
762 762
                 }
763 763
             }
764 764
         }
765 765
         // then remove datetimes
766
-        if (! empty($removed_datetimes) && is_array($removed_datetimes)) {
766
+        if ( ! empty($removed_datetimes) && is_array($removed_datetimes)) {
767 767
             foreach ($removed_datetimes as $row_id) {
768 768
                 $row_id = (int) $row_id;
769 769
                 // its entirely possible that a datetime got deleted (instead of just removed from relationship.
770 770
                 // So make sure we skip over this if the dtt isn't in the $saved_datetimes array)
771
-                if (isset($saved_datetimes[ $row_id ]) && $saved_datetimes[ $row_id ] instanceof EE_Datetime) {
772
-                    $ticket->_remove_relation_to($saved_datetimes[ $row_id ], 'Datetime');
771
+                if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) {
772
+                    $ticket->_remove_relation_to($saved_datetimes[$row_id], 'Datetime');
773 773
                 }
774 774
             }
775 775
         }
@@ -881,7 +881,7 @@  discard block
 block discarded – undo
881 881
             );
882 882
         }
883 883
         // possibly need to save tkt
884
-        if (! $ticket->ID()) {
884
+        if ( ! $ticket->ID()) {
885 885
             $ticket->save();
886 886
         }
887 887
         foreach ($prices as $row => $prc) {
@@ -915,17 +915,17 @@  discard block
 block discarded – undo
915 915
                 }
916 916
             }
917 917
             $price->save();
918
-            $updated_prices[ $price->ID() ] = $price;
918
+            $updated_prices[$price->ID()] = $price;
919 919
             $ticket->_add_relation_to($price, 'Price');
920 920
         }
921 921
         // now let's remove any prices that got removed from the ticket
922
-        if (! empty($current_prices_on_ticket)) {
922
+        if ( ! empty($current_prices_on_ticket)) {
923 923
             $current = array_keys($current_prices_on_ticket);
924 924
             $updated = array_keys($updated_prices);
925 925
             $prices_to_remove = array_diff($current, $updated);
926
-            if (! empty($prices_to_remove)) {
926
+            if ( ! empty($prices_to_remove)) {
927 927
                 foreach ($prices_to_remove as $prc_id) {
928
-                    $p = $current_prices_on_ticket[ $prc_id ];
928
+                    $p = $current_prices_on_ticket[$prc_id];
929 929
                     $ticket->_remove_relation_to($p, 'Price');
930 930
                     // delete permanently the price
931 931
                     $p->delete_permanently();
@@ -1076,18 +1076,18 @@  discard block
 block discarded – undo
1076 1076
                 $TKT_ID = $ticket->get('TKT_ID');
1077 1077
                 $ticket_row = $ticket->get('TKT_row');
1078 1078
                 // we only want unique tickets in our final display!!
1079
-                if (! in_array($TKT_ID, $existing_ticket_ids, true)) {
1079
+                if ( ! in_array($TKT_ID, $existing_ticket_ids, true)) {
1080 1080
                     $existing_ticket_ids[] = $TKT_ID;
1081 1081
                     $all_tickets[] = $ticket;
1082 1082
                 }
1083 1083
                 // temporary cache of this ticket info for this datetime for later processing of datetime rows.
1084
-                $datetime_tickets[ $DTT_ID ][] = $ticket_row;
1084
+                $datetime_tickets[$DTT_ID][] = $ticket_row;
1085 1085
                 // temporary cache of this datetime info for this ticket for later processing of ticket rows.
1086 1086
                 if (
1087
-                    ! isset($ticket_datetimes[ $TKT_ID ])
1088
-                    || ! in_array($datetime_row, $ticket_datetimes[ $TKT_ID ], true)
1087
+                    ! isset($ticket_datetimes[$TKT_ID])
1088
+                    || ! in_array($datetime_row, $ticket_datetimes[$TKT_ID], true)
1089 1089
                 ) {
1090
-                    $ticket_datetimes[ $TKT_ID ][] = $datetime_row;
1090
+                    $ticket_datetimes[$TKT_ID][] = $datetime_row;
1091 1091
                 }
1092 1092
             }
1093 1093
             $datetime_row++;
@@ -1098,7 +1098,7 @@  discard block
 block discarded – undo
1098 1098
         // sort $all_tickets by order
1099 1099
         usort(
1100 1100
             $all_tickets,
1101
-            function (EE_Ticket $a, EE_Ticket $b) {
1101
+            function(EE_Ticket $a, EE_Ticket $b) {
1102 1102
                 $a_order = (int) $a->get('TKT_order');
1103 1103
                 $b_order = (int) $b->get('TKT_order');
1104 1104
                 if ($a_order === $b_order) {
@@ -1145,7 +1145,7 @@  discard block
 block discarded – undo
1145 1145
         );
1146 1146
 
1147 1147
         EEH_Template::display_template(
1148
-            PRICING_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php',
1148
+            PRICING_TEMPLATE_PATH.'event_tickets_metabox_main.template.php',
1149 1149
             $main_template_args
1150 1150
         );
1151 1151
     }
@@ -1187,7 +1187,7 @@  discard block
 block discarded – undo
1187 1187
             'dtt_row'                  => $default ? 'DTTNUM' : $datetime_row,
1188 1188
         );
1189 1189
         return EEH_Template::display_template(
1190
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_row_wrapper.template.php',
1190
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_row_wrapper.template.php',
1191 1191
             $dtt_display_template_args,
1192 1192
             true
1193 1193
         );
@@ -1257,7 +1257,7 @@  discard block
 block discarded – undo
1257 1257
             $this->_is_creating_event
1258 1258
         );
1259 1259
         return EEH_Template::display_template(
1260
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_edit_row.template.php',
1260
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_edit_row.template.php',
1261 1261
             $template_args,
1262 1262
             true
1263 1263
         );
@@ -1298,7 +1298,7 @@  discard block
 block discarded – undo
1298 1298
             'DTT_ID'                            => $default ? '' : $datetime->ID(),
1299 1299
         );
1300 1300
         // need to setup the list items (but only if this isn't a default skeleton setup)
1301
-        if (! $default) {
1301
+        if ( ! $default) {
1302 1302
             $ticket_row = 1;
1303 1303
             foreach ($all_tickets as $ticket) {
1304 1304
                 $template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item(
@@ -1324,7 +1324,7 @@  discard block
 block discarded – undo
1324 1324
             $this->_is_creating_event
1325 1325
         );
1326 1326
         return EEH_Template::display_template(
1327
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_attached_tickets_row.template.php',
1327
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_attached_tickets_row.template.php',
1328 1328
             $template_args,
1329 1329
             true
1330 1330
         );
@@ -1350,8 +1350,8 @@  discard block
 block discarded – undo
1350 1350
         $datetime_tickets = array(),
1351 1351
         $default
1352 1352
     ) {
1353
-        $dtt_tkts = $datetime instanceof EE_Datetime && isset($datetime_tickets[ $datetime->ID() ])
1354
-            ? $datetime_tickets[ $datetime->ID() ]
1353
+        $dtt_tkts = $datetime instanceof EE_Datetime && isset($datetime_tickets[$datetime->ID()])
1354
+            ? $datetime_tickets[$datetime->ID()]
1355 1355
             : array();
1356 1356
         $display_row = $ticket instanceof EE_Ticket ? $ticket->get('TKT_row') : 0;
1357 1357
         $no_ticket = $default && empty($ticket);
@@ -1372,8 +1372,8 @@  discard block
 block discarded – undo
1372 1372
                 ? 'TKTNAME'
1373 1373
                 : $ticket->get('TKT_name'),
1374 1374
             'tkt_status_class'        => $no_ticket || $this->_is_creating_event
1375
-                ? ' tkt-status-' . EE_Ticket::onsale
1376
-                : ' tkt-status-' . $ticket->ticket_status(),
1375
+                ? ' tkt-status-'.EE_Ticket::onsale
1376
+                : ' tkt-status-'.$ticket->ticket_status(),
1377 1377
         );
1378 1378
         // filter template args
1379 1379
         $template_args = apply_filters(
@@ -1388,7 +1388,7 @@  discard block
 block discarded – undo
1388 1388
             $this->_is_creating_event
1389 1389
         );
1390 1390
         return EEH_Template::display_template(
1391
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_dtt_tickets_list.template.php',
1391
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_dtt_tickets_list.template.php',
1392 1392
             $template_args,
1393 1393
             true
1394 1394
         );
@@ -1444,19 +1444,19 @@  discard block
 block discarded – undo
1444 1444
         // (otherwise there won't be any new relationships created for tickets based off of the default ticket).
1445 1445
         // This will future proof in case there is ever any behaviour change between what the primary_key defaults to.
1446 1446
         $default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->is_default());
1447
-        $tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[ $ticket->ID() ])
1448
-            ? $ticket_datetimes[ $ticket->ID() ]
1447
+        $tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()])
1448
+            ? $ticket_datetimes[$ticket->ID()]
1449 1449
             : array();
1450 1450
         $ticket_subtotal = $default ? 0 : $ticket->get_ticket_subtotal();
1451 1451
         $base_price = $default ? null : $ticket->base_price();
1452 1452
         $count_price_mods = EEM_Price::instance()->get_all_default_prices(true);
1453 1453
         // breaking out complicated condition for ticket_status
1454 1454
         if ($default) {
1455
-            $ticket_status_class = ' tkt-status-' . EE_Ticket::onsale;
1455
+            $ticket_status_class = ' tkt-status-'.EE_Ticket::onsale;
1456 1456
         } else {
1457 1457
             $ticket_status_class = $ticket->is_default()
1458
-                ? ' tkt-status-' . EE_Ticket::onsale
1459
-                : ' tkt-status-' . $ticket->ticket_status();
1458
+                ? ' tkt-status-'.EE_Ticket::onsale
1459
+                : ' tkt-status-'.$ticket->ticket_status();
1460 1460
         }
1461 1461
         // breaking out complicated condition for TKT_taxable
1462 1462
         if ($default) {
@@ -1548,7 +1548,7 @@  discard block
 block discarded – undo
1548 1548
                 : 'display:none;',
1549 1549
             'show_price_mod_button'         => count($prices) > 1
1550 1550
                                                || ($default && $count_price_mods > 0)
1551
-                                               || (! $default && $ticket->deleted())
1551
+                                               || ( ! $default && $ticket->deleted())
1552 1552
                 ? 'display:none;'
1553 1553
                 : '',
1554 1554
             'total_price_rows'              => count($prices) > 1 ? count($prices) : 1,
@@ -1593,7 +1593,7 @@  discard block
 block discarded – undo
1593 1593
                 $this->_date_time_format,
1594 1594
                 current_time('timestamp')
1595 1595
             );
1596
-            $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1596
+            $template_args['tkt_status_class'] = ' tkt-status-'.EE_Ticket::onsale;
1597 1597
         }
1598 1598
         if (empty($template_args['TKT_end_date'])) {
1599 1599
             // get the earliest datetime (if present);
@@ -1603,7 +1603,7 @@  discard block
 block discarded – undo
1603 1603
                     array('order_by' => array('DTT_EVT_start' => 'ASC'))
1604 1604
                 )
1605 1605
                 : null;
1606
-            if (! empty($earliest_dtt)) {
1606
+            if ( ! empty($earliest_dtt)) {
1607 1607
                 $template_args['TKT_end_date'] = $earliest_dtt->get_datetime(
1608 1608
                     'DTT_EVT_start',
1609 1609
                     $this->_date_time_format
@@ -1622,10 +1622,10 @@  discard block
 block discarded – undo
1622 1622
                     )
1623 1623
                 );
1624 1624
             }
1625
-            $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1625
+            $template_args['tkt_status_class'] = ' tkt-status-'.EE_Ticket::onsale;
1626 1626
         }
1627 1627
         // generate ticket_datetime items
1628
-        if (! $default) {
1628
+        if ( ! $default) {
1629 1629
             $datetime_row = 1;
1630 1630
             foreach ($all_datetimes as $datetime) {
1631 1631
                 $template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item(
@@ -1641,7 +1641,7 @@  discard block
 block discarded – undo
1641 1641
         }
1642 1642
         $price_row = 1;
1643 1643
         foreach ($prices as $price) {
1644
-            if (! $price instanceof EE_Price) {
1644
+            if ( ! $price instanceof EE_Price) {
1645 1645
                 continue;
1646 1646
             }
1647 1647
             if ($price->is_base_price()) {
@@ -1674,7 +1674,7 @@  discard block
 block discarded – undo
1674 1674
             $this->_is_creating_event
1675 1675
         );
1676 1676
         return EEH_Template::display_template(
1677
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_row.template.php',
1677
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_row.template.php',
1678 1678
             $template_args,
1679 1679
             true
1680 1680
         );
@@ -1714,7 +1714,7 @@  discard block
 block discarded – undo
1714 1714
                 $this->_is_creating_event
1715 1715
             );
1716 1716
             $tax_rows .= EEH_Template::display_template(
1717
-                PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_tax_row.template.php',
1717
+                PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_tax_row.template.php',
1718 1718
                 $template_args,
1719 1719
                 true
1720 1720
             );
@@ -1833,7 +1833,7 @@  discard block
 block discarded – undo
1833 1833
             $this->_is_creating_event
1834 1834
         );
1835 1835
         return EEH_Template::display_template(
1836
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_price_row.template.php',
1836
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_price_row.template.php',
1837 1837
             $template_args,
1838 1838
             true
1839 1839
         );
@@ -1903,7 +1903,7 @@  discard block
 block discarded – undo
1903 1903
             $this->_is_creating_event
1904 1904
         );
1905 1905
         return EEH_Template::display_template(
1906
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_type_base.template.php',
1906
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_type_base.template.php',
1907 1907
             $template_args,
1908 1908
             true
1909 1909
         );
@@ -1933,7 +1933,7 @@  discard block
 block discarded – undo
1933 1933
     ) {
1934 1934
         $select_name = $default && ! $price instanceof EE_Price
1935 1935
             ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]'
1936
-            : 'edit_prices[' . esc_attr($ticket_row) . '][' . esc_attr($price_row) . '][PRT_ID]';
1936
+            : 'edit_prices['.esc_attr($ticket_row).']['.esc_attr($price_row).'][PRT_ID]';
1937 1937
         /** @var EEM_Price_Type $price_type_model */
1938 1938
         $price_type_model = EE_Registry::instance()->load_model('Price_Type');
1939 1939
         $price_types = $price_type_model->get_all(array(
@@ -1951,10 +1951,10 @@  discard block
 block discarded – undo
1951 1951
         $price_option_spans = '';
1952 1952
         // setup price types for selector
1953 1953
         foreach ($price_types as $price_type) {
1954
-            if (! $price_type instanceof EE_Price_Type) {
1954
+            if ( ! $price_type instanceof EE_Price_Type) {
1955 1955
                 continue;
1956 1956
             }
1957
-            $all_price_types[ $price_type->ID() ] = $price_type->get('PRT_name');
1957
+            $all_price_types[$price_type->ID()] = $price_type->get('PRT_name');
1958 1958
             // while we're in the loop let's setup the option spans used by js
1959 1959
             $span_args = array(
1960 1960
                 'PRT_ID'         => $price_type->ID(),
@@ -1962,12 +1962,12 @@  discard block
 block discarded – undo
1962 1962
                 'PRT_is_percent' => $price_type->get('PRT_is_percent') ? 1 : 0,
1963 1963
             );
1964 1964
             $price_option_spans .= EEH_Template::display_template(
1965
-                PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_option_span.template.php',
1965
+                PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_option_span.template.php',
1966 1966
                 $span_args,
1967 1967
                 true
1968 1968
             );
1969 1969
         }
1970
-        $select_name = $disabled ? 'archive_price[' . $ticket_row . '][' . $price_row . '][PRT_ID]'
1970
+        $select_name = $disabled ? 'archive_price['.$ticket_row.']['.$price_row.'][PRT_ID]'
1971 1971
             : $select_name;
1972 1972
         $select_input = new EE_Select_Input(
1973 1973
             $all_price_types,
@@ -2004,7 +2004,7 @@  discard block
 block discarded – undo
2004 2004
             $this->_is_creating_event
2005 2005
         );
2006 2006
         return EEH_Template::display_template(
2007
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_modifier_selector.template.php',
2007
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_modifier_selector.template.php',
2008 2008
             $template_args,
2009 2009
             true
2010 2010
         );
@@ -2030,8 +2030,8 @@  discard block
 block discarded – undo
2030 2030
         $ticket_datetimes = array(),
2031 2031
         $default
2032 2032
     ) {
2033
-        $tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[ $ticket->ID() ])
2034
-            ? $ticket_datetimes[ $ticket->ID() ]
2033
+        $tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()])
2034
+            ? $ticket_datetimes[$ticket->ID()]
2035 2035
             : array();
2036 2036
         $template_args = array(
2037 2037
             'dtt_row'                  => $default && ! $datetime instanceof EE_Datetime
@@ -2063,7 +2063,7 @@  discard block
 block discarded – undo
2063 2063
             $this->_is_creating_event
2064 2064
         );
2065 2065
         return EEH_Template::display_template(
2066
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_datetimes_list_item.template.php',
2066
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_datetimes_list_item.template.php',
2067 2067
             $template_args,
2068 2068
             true
2069 2069
         );
@@ -2169,7 +2169,7 @@  discard block
 block discarded – undo
2169 2169
         $default_prices = $price_model->get_all_default_prices();
2170 2170
         $price_row = 1;
2171 2171
         foreach ($default_prices as $price) {
2172
-            if (! $price instanceof EE_Price) {
2172
+            if ( ! $price instanceof EE_Price) {
2173 2173
                 continue;
2174 2174
             }
2175 2175
             if ($price->is_base_price()) {
@@ -2206,7 +2206,7 @@  discard block
 block discarded – undo
2206 2206
             $this->_is_creating_event
2207 2207
         );
2208 2208
         return EEH_Template::display_template(
2209
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_js_structure.template.php',
2209
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_js_structure.template.php',
2210 2210
             $template_args,
2211 2211
             true
2212 2212
         );
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page_Init.core.php 2 patches
Indentation   +490 added lines, -490 removed lines patch added patch discarded remove patch
@@ -18,497 +18,497 @@
 block discarded – undo
18 18
  */
19 19
 abstract class EE_Admin_Page_Init extends EE_Base
20 20
 {
21
-    // identity properties (set in _set_defaults and _set_init_properties)
22
-    public $label;
21
+	// identity properties (set in _set_defaults and _set_init_properties)
22
+	public $label;
23 23
 
24
-    /**
25
-     * Menu map has a capability.  However, this allows admin pages to have separate capability requirements for menus
26
-     * and accessing pages.  If capability is NOT set, then it defaults to the menu_map capability.
27
-     *
28
-     * @var string
29
-     */
30
-    public $capability;
24
+	/**
25
+	 * Menu map has a capability.  However, this allows admin pages to have separate capability requirements for menus
26
+	 * and accessing pages.  If capability is NOT set, then it defaults to the menu_map capability.
27
+	 *
28
+	 * @var string
29
+	 */
30
+	public $capability;
31 31
 
32 32
 
33
-    /**
34
-     * This holds the menu map object for this admin page.
35
-     *
36
-     * @var AdminMenuItem
37
-     */
38
-    protected $_menu_map = null;
39
-
40
-    /**
41
-     * deprecated
42
-     */
43
-    public $menu_label;
44
-
45
-    public $menu_slug;
46
-
47
-
48
-    // set in _set_defaults
49
-    protected $_folder_name;
50
-
51
-    protected $_folder_path;
52
-
53
-    protected $_file_name;
54
-
55
-    public $hook_file;
56
-
57
-    protected $_wp_page_slug;
58
-
59
-    protected $_routing;
60
-
61
-
62
-    /**
63
-     * This holds the page object.
64
-     *
65
-     * @var EE_Admin_Page
66
-     */
67
-    protected $_loaded_page_object;
68
-
69
-
70
-    // for caf
71
-    protected $_files_hooked;
72
-
73
-    protected $_hook_paths;
74
-
75
-    // load_page?
76
-    private $_load_page;
77
-
78
-    /**
79
-     * @var LoaderInterface
80
-     */
81
-    protected $loader;
82
-
83
-    /**
84
-     * @var RequestInterface
85
-     */
86
-    protected $request;
87
-
88
-
89
-    /**
90
-     * @throws InvalidArgumentException
91
-     * @throws InvalidDataTypeException
92
-     * @throws InvalidInterfaceException
93
-     */
94
-    public function __construct(RequestInterface $request = null)
95
-    {
96
-        $this->loader  = LoaderFactory::getLoader();
97
-        $this->request = $request instanceof RequestInterface
98
-            ? $request
99
-            : $this->loader->getShared(RequestInterface::class);
100
-        // set global defaults
101
-        $this->_set_defaults();
102
-        // set properties that are always available with objects.
103
-        $this->_set_init_properties();
104
-        // global styles/scripts across all wp admin pages
105
-        add_action('admin_enqueue_scripts', [$this, 'load_wp_global_scripts_styles'], 5);
106
-        // load initial stuff.
107
-        $this->_set_file_and_folder_name();
108
-    }
109
-
110
-
111
-    /**
112
-     * _set_init_properties
113
-     * Child classes use to set the following properties:
114
-     * $label
115
-     *
116
-     * @abstract
117
-     * @return void
118
-     */
119
-    abstract protected function _set_init_properties();
120
-
121
-
122
-    /**
123
-     * @return AdminMenuItem|null
124
-     * @since       4.4.0
125
-     * @deprecated  $VID:$
126
-     */
127
-    public function get_menu_map()
128
-    {
129
-        return $this->adminMenu();
130
-    }
131
-
132
-
133
-    /**
134
-     * _set_menu_map is a function that child classes use to set the menu_map property (which should be an instance of
135
-     * EE_Admin_Page_Menu_Map.  Their menu can either be EE_Admin_Page_Main_Menu or AdminMenuSubItem.
136
-     *
137
-     * @since       4.4.0
138
-     * @deprecated  $VID:$
139
-     */
140
-    protected function _set_menu_map()
141
-    {
142
-        $this->_menu_map = null;
143
-    }
144
-
145
-
146
-    /**
147
-     * @since   $VID:$
148
-     */
149
-    public function setupLegacyAdminMenuItem()
150
-    {
151
-        // will be overridden by child classes not using new system
152
-        $this->_set_menu_map();
153
-    }
154
-
155
-
156
-    /**
157
-     * Child classes should return an array of properties used to construct the AdminMenuItem
158
-     *
159
-     * @return array
160
-     * @since $VID:$
161
-     */
162
-    public function getMenuProperties(): array
163
-    {
164
-        return [];
165
-    }
166
-
167
-
168
-    /**
169
-     * @param AdminMenuItem $menu
170
-     * @return void
171
-     * @since $VID:$
172
-     */
173
-    public function setAdminMenu(AdminMenuItem $menu): void
174
-    {
175
-        $this->_menu_map = $menu;
176
-    }
177
-
178
-
179
-    /**
180
-     * returns the menu map for this admin page
181
-     *
182
-     * @return AdminMenuItem|null
183
-     * @since $VID:$
184
-     */
185
-    public function adminMenu(): ?AdminMenuItem
186
-    {
187
-        return $this->_menu_map;
188
-    }
189
-
190
-
191
-    /**
192
-     * @param string $wp_page_slug
193
-     * @since $VID:$
194
-     */
195
-    public function setWpPageSlug(string $wp_page_slug): void
196
-    {
197
-        $this->_wp_page_slug = $wp_page_slug;
198
-    }
199
-
200
-
201
-    /**
202
-     * This loads scripts and styles for the EE_Admin system
203
-     * that must be available on ALL WP admin pages (i.e. EE_menu items)
204
-     *
205
-     * @return void
206
-     */
207
-    public function load_wp_global_scripts_styles()
208
-    {
209
-        wp_register_style(
210
-            'espresso_menu',
211
-            EE_ADMIN_URL . 'assets/admin-menu-styles.css',
212
-            ['dashicons'],
213
-            EVENT_ESPRESSO_VERSION
214
-        );
215
-        wp_enqueue_style('espresso_menu');
216
-    }
217
-
218
-
219
-    /**
220
-     * this sets default properties (might be overridden in _set_init_properties);
221
-     *
222
-     * @return  void
223
-     */
224
-    private function _set_defaults()
225
-    {
226
-        $this->_file_name    = $this->_folder_name = $this->_wp_page_slug = $this->capability = null;
227
-        $this->_routing      = true;
228
-        $this->_load_page    = false;
229
-        $this->_files_hooked = $this->_hook_paths = [];
230
-    }
231
-
232
-
233
-    public function setCapability($capability, $menu_slug)
234
-    {
235
-        $this->capability = apply_filters('FHEE_' . $menu_slug . '_capability', $capability);
236
-    }
237
-
238
-
239
-    /**
240
-     * @deprecated $VID:$
241
-     */
242
-    protected function _set_capability()
243
-    {
244
-        if ($this->_menu_map instanceof AdminMenuItem) {
245
-            $this->setCapability($this->_menu_map->capability(), $this->_menu_map->menuSlug());
246
-        }
247
-    }
248
-
249
-
250
-    /**
251
-     * initialize_admin_page
252
-     * This method is what executes the loading of the specific page class for the given dir_name as called by the
253
-     * EE_Admin_Init class.
254
-     *
255
-     * @return void
256
-     * @throws EE_Error
257
-     * @throws ReflectionException
258
-     */
259
-    public function initialize_admin_page()
260
-    {
261
-        // let's check user access first
262
-        $this->_check_user_access();
263
-        if (! $this->_loaded_page_object instanceof EE_Admin_Page) {
264
-            return;
265
-        }
266
-        $this->_loaded_page_object->route_admin_request();
267
-    }
268
-
269
-
270
-    /**
271
-     * @param string $wp_page_slug
272
-     * @throws EE_Error
273
-     */
274
-    public function set_page_dependencies(string $wp_page_slug)
275
-    {
276
-        if (! $this->_load_page) {
277
-            return;
278
-        }
279
-        if (! $this->_loaded_page_object instanceof EE_Admin_Page) {
280
-            $msg[] = esc_html__(
281
-                'We can\'t load the page because we\'re missing a valid page object that tells us what to load',
282
-                'event_espresso'
283
-            );
284
-            $msg[] = $msg[0] . "\r\n"
285
-                     . sprintf(
286
-                         esc_html__(
287
-                             'The custom slug you have set for this page is %s. This means we\'re looking for the class %s_Admin_Page (found in %s_Admin_Page.core.php) within your %s directory',
288
-                             'event_espresso'
289
-                         ),
290
-                         $this->_file_name,
291
-                         $this->_file_name,
292
-                         $this->_folder_path . $this->_file_name,
293
-                         $this->_menu_map->menuSlug()
294
-                     );
295
-            throw new EE_Error(implode('||', $msg));
296
-        }
297
-        $this->_loaded_page_object->set_wp_page_slug($wp_page_slug);
298
-        $page_hook = "load-$wp_page_slug";
299
-        // hook into page load hook so all page specific stuff gets loaded.
300
-        if (! empty($wp_page_slug)) {
301
-            add_action($page_hook, [$this->_loaded_page_object, 'load_page_dependencies']);
302
-        }
303
-    }
304
-
305
-
306
-    /**
307
-     * This executes the initial page loads for EE_Admin pages to take care of any ajax or other code needing to run
308
-     * before the load-page... hook. Note, the page loads are happening around the wp_init hook.
309
-     *
310
-     * @return void
311
-     * @throws InvalidArgumentException
312
-     * @throws InvalidDataTypeException
313
-     * @throws InvalidInterfaceException
314
-     * @throws EE_Error
315
-     * @throws ReflectionException
316
-     */
317
-    public function do_initial_loads()
318
-    {
319
-        // no loading or initializing if menu map is setup incorrectly.
320
-        if (! $this->_menu_map instanceof AdminMenuItem) {
321
-            return;
322
-        }
323
-        $this->_initialize_admin_page();
324
-    }
325
-
326
-
327
-    /**
328
-     * all we're doing here is setting the $_file_name property for later use.
329
-     *
330
-     * @return void
331
-     */
332
-    private function _set_file_and_folder_name()
333
-    {
334
-        $bt = debug_backtrace();
335
-        // for more reliable determination of folder name
336
-        // we're using this to get the actual folder name of the CALLING class (i.e. the child class that extends this).  Why?  Because $this->menu_slug may be different than the folder name (to avoid conflicts with other plugins)
337
-        $class = get_class($this);
338
-        foreach ($bt as $index => $values) {
339
-            if (isset($values['class']) && $values['class'] == $class) {
340
-                $file_index         = $index - 1;
341
-                $this->_folder_name = basename(dirname($bt[ $file_index ]['file']));
342
-                if (! empty($this->_folder_name)) {
343
-                    break;
344
-                }
345
-            }
346
-        }
347
-        $this->_folder_path = EE_ADMIN_PAGES . $this->_folder_name . '/';
348
-        $this->_file_name   = preg_replace('/^ee/', 'EE', $this->_folder_name);
349
-        $this->_file_name   = ucwords(str_replace('_', ' ', $this->_file_name));
350
-        $this->_file_name   = str_replace(' ', '_', $this->_file_name);
351
-    }
352
-
353
-
354
-    /**
355
-     * This automatically checks if we have a hook class in the loaded child directory.  If we DO then we will register
356
-     * it with the appropriate pages.  That way all we have to do is make sure the file is named correctly and
357
-     * "dropped" in. Example: if we wanted to set this up for Messages hooking into Events then we would do:
358
-     * events_Messages_Hooks.class.php
359
-     *
360
-     * @param bool $extend This indicates whether we're checking the extend directory for any register_hooks
361
-     *                     files/classes
362
-     * @return array
363
-     */
364
-    public function register_hooks(bool $extend = false): array
365
-    {
366
-        // get a list of files in the directory that have the "Hook" in their name an
367
-        // if this is an extended check (i.e. caf is active) then we will scan the caffeinated/extend directory first and any hook files that are found will be have their reference added to the $_files_hook array property.  Then, we make sure that when we loop through the core decaf directories to find hook files that we skip over any hooks files that have already been set by caf.
368
-        if ($extend) {
369
-            $hook_files_glob_path = apply_filters(
370
-                'FHEE__EE_Admin_Page_Init__register_hooks__hook_files_glob_path__extend',
371
-                EE_CORE_CAF_ADMIN_EXTEND
372
-                . $this->_folder_name
373
-                . '/*'
374
-                . $this->_file_name
375
-                . '_Hooks_Extend.class.php'
376
-            );
377
-            $this->_hook_paths    = $this->_register_hook_files($hook_files_glob_path, $extend);
378
-        }
379
-        // loop through decaf folders
380
-        $hook_files_glob_path = apply_filters(
381
-            'FHEE__EE_Admin_Page_Init__register_hooks__hook_files_glob_path',
382
-            $this->_folder_path . '*' . $this->_file_name . '_Hooks.class.php'
383
-        );
384
-        $this->_hook_paths    = array_merge(
385
-            $this->_register_hook_files($hook_files_glob_path),
386
-            $this->_hook_paths
387
-        );  // making sure any extended hook paths are later in the array than the core hook paths!
388
-        return $this->_hook_paths;
389
-    }
390
-
391
-
392
-    protected function _register_hook_files($hook_files_glob_path, $extend = false): array
393
-    {
394
-        $hook_paths = glob($hook_files_glob_path);
395
-        if (empty($hook_paths)) {
396
-            return [];
397
-        }
398
-        foreach ($hook_paths as $file) {
399
-            // lets get the linked admin.
400
-            $hook_file = $extend
401
-                ? str_replace(EE_CORE_CAF_ADMIN_EXTEND . $this->_folder_name . '/', '', $file)
402
-                : str_replace($this->_folder_path, '', $file);
403
-            $replace   = $extend
404
-                ? '_' . $this->_file_name . '_Hooks_Extend.class.php'
405
-                : '_' . $this->_file_name . '_Hooks.class.php';
406
-            $rel_admin = str_replace($replace, '', $hook_file);
407
-            $rel_admin = strtolower($rel_admin);
408
-            // make sure we haven't already got a hook setup for this page path
409
-            if (in_array($rel_admin, $this->_files_hooked)) {
410
-                continue;
411
-            }
412
-            require_once $file;
413
-            $this->hook_file = $hook_file;
414
-            $rel_admin_hook  = 'FHEE_do_other_page_hooks_' . $rel_admin;
415
-            add_filter($rel_admin_hook, [$this, 'load_admin_hook']);
416
-            $this->_files_hooked[] = $rel_admin;
417
-        }
418
-        return $hook_paths;
419
-    }
420
-
421
-
422
-    public function load_admin_hook($registered_pages)
423
-    {
424
-        return array_merge((array) $this->hook_file, $registered_pages);
425
-    }
426
-
427
-
428
-    /**
429
-     * _initialize_admin_page
430
-     *
431
-     * @throws EE_Error
432
-     * @throws ReflectionException
433
-     * @see  initialize_admin_page() for info
434
-     */
435
-    protected function _initialize_admin_page()
436
-    {
437
-        // JUST CHECK WE'RE ON RIGHT PAGE.
438
-        $page      = $this->request->getRequestParam('page');
439
-        $page      = $this->request->getRequestParam('current_page', $page);
440
-        $menu_slug = $this->_menu_map->menuSlug();
441
-
442
-
443
-        if ($this->_routing && ($page === '' || $page !== $menu_slug)) {
444
-            // not on the right page so let's get out.
445
-            return;
446
-        }
447
-        $this->_load_page = true;
448
-
449
-        // we don't need to do a page_request check here because it's only called via WP menu system.
450
-        $admin_page  = $this->_file_name . '_Admin_Page';
451
-        $hook_suffix = "{$menu_slug}_$admin_page";
452
-        $admin_page  = apply_filters(
453
-            "FHEE__EE_Admin_Page_Init___initialize_admin_page__admin_page__$hook_suffix",
454
-            $admin_page
455
-        );
456
-        if (empty($admin_page)) {
457
-            return;
458
-        }
459
-        // define requested admin page class name then load the file and instantiate
460
-        $path_to_file = str_replace(['\\', '/'], '/', $this->_folder_path . $admin_page . '.core.php');
461
-        // so if the file would be in EE_ADMIN/attendees/Attendee_Admin_Page.core.php, the filter would be:
462
-        // FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__attendees_Attendee_Admin_Page
463
-        $path_to_file = apply_filters(
464
-            "FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__$hook_suffix",
465
-            $path_to_file
466
-        );
467
-        if (! is_readable($path_to_file)) {
468
-            return;
469
-        }
470
-        // This is a place where EE plugins can hook in to make sure their own files are required in the appropriate place
471
-        do_action('AHEE__EE_Admin_Page___initialize_admin_page__before_initialization');
472
-        do_action("AHEE__EE_Admin_Page___initialize_admin_page__before_initialization_$menu_slug");
473
-        require_once($path_to_file);
474
-        $this->_loaded_page_object = $this->loader->getShared($admin_page, [$this->_routing]);
475
-        $this->_loaded_page_object->initializePage();
476
-
477
-        do_action('AHEE__EE_Admin_Page___initialize_admin_page__after_initialization');
478
-        do_action("AHEE__EE_Admin_Page___initialize_admin_page__after_initialization_$menu_slug");
479
-    }
480
-
481
-
482
-    public function get_admin_page_name(): string
483
-    {
484
-        return $this->_file_name . '_Admin_Page';
485
-    }
486
-
487
-
488
-    /**
489
-     * @return EE_Admin_Page|null
490
-     */
491
-    public function loaded_page_object(): ?EE_Admin_Page
492
-    {
493
-        return $this->_loaded_page_object;
494
-    }
495
-
496
-
497
-    /**
498
-     * _check_user_access
499
-     * verifies user access for this admin page.  If no user access is available then let's gracefully exit with a
500
-     * WordPress die message.
501
-     *
502
-     * @return void  wp_die if fail
503
-     */
504
-    private function _check_user_access()
505
-    {
506
-        if (! $this->_menu_map->currentUserHasAccess()) {
507
-            wp_die(
508
-                esc_html__('You don\'t have access to this page.', 'event_espresso'),
509
-                '',
510
-                ['back_link' => true]
511
-            );
512
-        }
513
-    }
33
+	/**
34
+	 * This holds the menu map object for this admin page.
35
+	 *
36
+	 * @var AdminMenuItem
37
+	 */
38
+	protected $_menu_map = null;
39
+
40
+	/**
41
+	 * deprecated
42
+	 */
43
+	public $menu_label;
44
+
45
+	public $menu_slug;
46
+
47
+
48
+	// set in _set_defaults
49
+	protected $_folder_name;
50
+
51
+	protected $_folder_path;
52
+
53
+	protected $_file_name;
54
+
55
+	public $hook_file;
56
+
57
+	protected $_wp_page_slug;
58
+
59
+	protected $_routing;
60
+
61
+
62
+	/**
63
+	 * This holds the page object.
64
+	 *
65
+	 * @var EE_Admin_Page
66
+	 */
67
+	protected $_loaded_page_object;
68
+
69
+
70
+	// for caf
71
+	protected $_files_hooked;
72
+
73
+	protected $_hook_paths;
74
+
75
+	// load_page?
76
+	private $_load_page;
77
+
78
+	/**
79
+	 * @var LoaderInterface
80
+	 */
81
+	protected $loader;
82
+
83
+	/**
84
+	 * @var RequestInterface
85
+	 */
86
+	protected $request;
87
+
88
+
89
+	/**
90
+	 * @throws InvalidArgumentException
91
+	 * @throws InvalidDataTypeException
92
+	 * @throws InvalidInterfaceException
93
+	 */
94
+	public function __construct(RequestInterface $request = null)
95
+	{
96
+		$this->loader  = LoaderFactory::getLoader();
97
+		$this->request = $request instanceof RequestInterface
98
+			? $request
99
+			: $this->loader->getShared(RequestInterface::class);
100
+		// set global defaults
101
+		$this->_set_defaults();
102
+		// set properties that are always available with objects.
103
+		$this->_set_init_properties();
104
+		// global styles/scripts across all wp admin pages
105
+		add_action('admin_enqueue_scripts', [$this, 'load_wp_global_scripts_styles'], 5);
106
+		// load initial stuff.
107
+		$this->_set_file_and_folder_name();
108
+	}
109
+
110
+
111
+	/**
112
+	 * _set_init_properties
113
+	 * Child classes use to set the following properties:
114
+	 * $label
115
+	 *
116
+	 * @abstract
117
+	 * @return void
118
+	 */
119
+	abstract protected function _set_init_properties();
120
+
121
+
122
+	/**
123
+	 * @return AdminMenuItem|null
124
+	 * @since       4.4.0
125
+	 * @deprecated  $VID:$
126
+	 */
127
+	public function get_menu_map()
128
+	{
129
+		return $this->adminMenu();
130
+	}
131
+
132
+
133
+	/**
134
+	 * _set_menu_map is a function that child classes use to set the menu_map property (which should be an instance of
135
+	 * EE_Admin_Page_Menu_Map.  Their menu can either be EE_Admin_Page_Main_Menu or AdminMenuSubItem.
136
+	 *
137
+	 * @since       4.4.0
138
+	 * @deprecated  $VID:$
139
+	 */
140
+	protected function _set_menu_map()
141
+	{
142
+		$this->_menu_map = null;
143
+	}
144
+
145
+
146
+	/**
147
+	 * @since   $VID:$
148
+	 */
149
+	public function setupLegacyAdminMenuItem()
150
+	{
151
+		// will be overridden by child classes not using new system
152
+		$this->_set_menu_map();
153
+	}
154
+
155
+
156
+	/**
157
+	 * Child classes should return an array of properties used to construct the AdminMenuItem
158
+	 *
159
+	 * @return array
160
+	 * @since $VID:$
161
+	 */
162
+	public function getMenuProperties(): array
163
+	{
164
+		return [];
165
+	}
166
+
167
+
168
+	/**
169
+	 * @param AdminMenuItem $menu
170
+	 * @return void
171
+	 * @since $VID:$
172
+	 */
173
+	public function setAdminMenu(AdminMenuItem $menu): void
174
+	{
175
+		$this->_menu_map = $menu;
176
+	}
177
+
178
+
179
+	/**
180
+	 * returns the menu map for this admin page
181
+	 *
182
+	 * @return AdminMenuItem|null
183
+	 * @since $VID:$
184
+	 */
185
+	public function adminMenu(): ?AdminMenuItem
186
+	{
187
+		return $this->_menu_map;
188
+	}
189
+
190
+
191
+	/**
192
+	 * @param string $wp_page_slug
193
+	 * @since $VID:$
194
+	 */
195
+	public function setWpPageSlug(string $wp_page_slug): void
196
+	{
197
+		$this->_wp_page_slug = $wp_page_slug;
198
+	}
199
+
200
+
201
+	/**
202
+	 * This loads scripts and styles for the EE_Admin system
203
+	 * that must be available on ALL WP admin pages (i.e. EE_menu items)
204
+	 *
205
+	 * @return void
206
+	 */
207
+	public function load_wp_global_scripts_styles()
208
+	{
209
+		wp_register_style(
210
+			'espresso_menu',
211
+			EE_ADMIN_URL . 'assets/admin-menu-styles.css',
212
+			['dashicons'],
213
+			EVENT_ESPRESSO_VERSION
214
+		);
215
+		wp_enqueue_style('espresso_menu');
216
+	}
217
+
218
+
219
+	/**
220
+	 * this sets default properties (might be overridden in _set_init_properties);
221
+	 *
222
+	 * @return  void
223
+	 */
224
+	private function _set_defaults()
225
+	{
226
+		$this->_file_name    = $this->_folder_name = $this->_wp_page_slug = $this->capability = null;
227
+		$this->_routing      = true;
228
+		$this->_load_page    = false;
229
+		$this->_files_hooked = $this->_hook_paths = [];
230
+	}
231
+
232
+
233
+	public function setCapability($capability, $menu_slug)
234
+	{
235
+		$this->capability = apply_filters('FHEE_' . $menu_slug . '_capability', $capability);
236
+	}
237
+
238
+
239
+	/**
240
+	 * @deprecated $VID:$
241
+	 */
242
+	protected function _set_capability()
243
+	{
244
+		if ($this->_menu_map instanceof AdminMenuItem) {
245
+			$this->setCapability($this->_menu_map->capability(), $this->_menu_map->menuSlug());
246
+		}
247
+	}
248
+
249
+
250
+	/**
251
+	 * initialize_admin_page
252
+	 * This method is what executes the loading of the specific page class for the given dir_name as called by the
253
+	 * EE_Admin_Init class.
254
+	 *
255
+	 * @return void
256
+	 * @throws EE_Error
257
+	 * @throws ReflectionException
258
+	 */
259
+	public function initialize_admin_page()
260
+	{
261
+		// let's check user access first
262
+		$this->_check_user_access();
263
+		if (! $this->_loaded_page_object instanceof EE_Admin_Page) {
264
+			return;
265
+		}
266
+		$this->_loaded_page_object->route_admin_request();
267
+	}
268
+
269
+
270
+	/**
271
+	 * @param string $wp_page_slug
272
+	 * @throws EE_Error
273
+	 */
274
+	public function set_page_dependencies(string $wp_page_slug)
275
+	{
276
+		if (! $this->_load_page) {
277
+			return;
278
+		}
279
+		if (! $this->_loaded_page_object instanceof EE_Admin_Page) {
280
+			$msg[] = esc_html__(
281
+				'We can\'t load the page because we\'re missing a valid page object that tells us what to load',
282
+				'event_espresso'
283
+			);
284
+			$msg[] = $msg[0] . "\r\n"
285
+					 . sprintf(
286
+						 esc_html__(
287
+							 'The custom slug you have set for this page is %s. This means we\'re looking for the class %s_Admin_Page (found in %s_Admin_Page.core.php) within your %s directory',
288
+							 'event_espresso'
289
+						 ),
290
+						 $this->_file_name,
291
+						 $this->_file_name,
292
+						 $this->_folder_path . $this->_file_name,
293
+						 $this->_menu_map->menuSlug()
294
+					 );
295
+			throw new EE_Error(implode('||', $msg));
296
+		}
297
+		$this->_loaded_page_object->set_wp_page_slug($wp_page_slug);
298
+		$page_hook = "load-$wp_page_slug";
299
+		// hook into page load hook so all page specific stuff gets loaded.
300
+		if (! empty($wp_page_slug)) {
301
+			add_action($page_hook, [$this->_loaded_page_object, 'load_page_dependencies']);
302
+		}
303
+	}
304
+
305
+
306
+	/**
307
+	 * This executes the initial page loads for EE_Admin pages to take care of any ajax or other code needing to run
308
+	 * before the load-page... hook. Note, the page loads are happening around the wp_init hook.
309
+	 *
310
+	 * @return void
311
+	 * @throws InvalidArgumentException
312
+	 * @throws InvalidDataTypeException
313
+	 * @throws InvalidInterfaceException
314
+	 * @throws EE_Error
315
+	 * @throws ReflectionException
316
+	 */
317
+	public function do_initial_loads()
318
+	{
319
+		// no loading or initializing if menu map is setup incorrectly.
320
+		if (! $this->_menu_map instanceof AdminMenuItem) {
321
+			return;
322
+		}
323
+		$this->_initialize_admin_page();
324
+	}
325
+
326
+
327
+	/**
328
+	 * all we're doing here is setting the $_file_name property for later use.
329
+	 *
330
+	 * @return void
331
+	 */
332
+	private function _set_file_and_folder_name()
333
+	{
334
+		$bt = debug_backtrace();
335
+		// for more reliable determination of folder name
336
+		// we're using this to get the actual folder name of the CALLING class (i.e. the child class that extends this).  Why?  Because $this->menu_slug may be different than the folder name (to avoid conflicts with other plugins)
337
+		$class = get_class($this);
338
+		foreach ($bt as $index => $values) {
339
+			if (isset($values['class']) && $values['class'] == $class) {
340
+				$file_index         = $index - 1;
341
+				$this->_folder_name = basename(dirname($bt[ $file_index ]['file']));
342
+				if (! empty($this->_folder_name)) {
343
+					break;
344
+				}
345
+			}
346
+		}
347
+		$this->_folder_path = EE_ADMIN_PAGES . $this->_folder_name . '/';
348
+		$this->_file_name   = preg_replace('/^ee/', 'EE', $this->_folder_name);
349
+		$this->_file_name   = ucwords(str_replace('_', ' ', $this->_file_name));
350
+		$this->_file_name   = str_replace(' ', '_', $this->_file_name);
351
+	}
352
+
353
+
354
+	/**
355
+	 * This automatically checks if we have a hook class in the loaded child directory.  If we DO then we will register
356
+	 * it with the appropriate pages.  That way all we have to do is make sure the file is named correctly and
357
+	 * "dropped" in. Example: if we wanted to set this up for Messages hooking into Events then we would do:
358
+	 * events_Messages_Hooks.class.php
359
+	 *
360
+	 * @param bool $extend This indicates whether we're checking the extend directory for any register_hooks
361
+	 *                     files/classes
362
+	 * @return array
363
+	 */
364
+	public function register_hooks(bool $extend = false): array
365
+	{
366
+		// get a list of files in the directory that have the "Hook" in their name an
367
+		// if this is an extended check (i.e. caf is active) then we will scan the caffeinated/extend directory first and any hook files that are found will be have their reference added to the $_files_hook array property.  Then, we make sure that when we loop through the core decaf directories to find hook files that we skip over any hooks files that have already been set by caf.
368
+		if ($extend) {
369
+			$hook_files_glob_path = apply_filters(
370
+				'FHEE__EE_Admin_Page_Init__register_hooks__hook_files_glob_path__extend',
371
+				EE_CORE_CAF_ADMIN_EXTEND
372
+				. $this->_folder_name
373
+				. '/*'
374
+				. $this->_file_name
375
+				. '_Hooks_Extend.class.php'
376
+			);
377
+			$this->_hook_paths    = $this->_register_hook_files($hook_files_glob_path, $extend);
378
+		}
379
+		// loop through decaf folders
380
+		$hook_files_glob_path = apply_filters(
381
+			'FHEE__EE_Admin_Page_Init__register_hooks__hook_files_glob_path',
382
+			$this->_folder_path . '*' . $this->_file_name . '_Hooks.class.php'
383
+		);
384
+		$this->_hook_paths    = array_merge(
385
+			$this->_register_hook_files($hook_files_glob_path),
386
+			$this->_hook_paths
387
+		);  // making sure any extended hook paths are later in the array than the core hook paths!
388
+		return $this->_hook_paths;
389
+	}
390
+
391
+
392
+	protected function _register_hook_files($hook_files_glob_path, $extend = false): array
393
+	{
394
+		$hook_paths = glob($hook_files_glob_path);
395
+		if (empty($hook_paths)) {
396
+			return [];
397
+		}
398
+		foreach ($hook_paths as $file) {
399
+			// lets get the linked admin.
400
+			$hook_file = $extend
401
+				? str_replace(EE_CORE_CAF_ADMIN_EXTEND . $this->_folder_name . '/', '', $file)
402
+				: str_replace($this->_folder_path, '', $file);
403
+			$replace   = $extend
404
+				? '_' . $this->_file_name . '_Hooks_Extend.class.php'
405
+				: '_' . $this->_file_name . '_Hooks.class.php';
406
+			$rel_admin = str_replace($replace, '', $hook_file);
407
+			$rel_admin = strtolower($rel_admin);
408
+			// make sure we haven't already got a hook setup for this page path
409
+			if (in_array($rel_admin, $this->_files_hooked)) {
410
+				continue;
411
+			}
412
+			require_once $file;
413
+			$this->hook_file = $hook_file;
414
+			$rel_admin_hook  = 'FHEE_do_other_page_hooks_' . $rel_admin;
415
+			add_filter($rel_admin_hook, [$this, 'load_admin_hook']);
416
+			$this->_files_hooked[] = $rel_admin;
417
+		}
418
+		return $hook_paths;
419
+	}
420
+
421
+
422
+	public function load_admin_hook($registered_pages)
423
+	{
424
+		return array_merge((array) $this->hook_file, $registered_pages);
425
+	}
426
+
427
+
428
+	/**
429
+	 * _initialize_admin_page
430
+	 *
431
+	 * @throws EE_Error
432
+	 * @throws ReflectionException
433
+	 * @see  initialize_admin_page() for info
434
+	 */
435
+	protected function _initialize_admin_page()
436
+	{
437
+		// JUST CHECK WE'RE ON RIGHT PAGE.
438
+		$page      = $this->request->getRequestParam('page');
439
+		$page      = $this->request->getRequestParam('current_page', $page);
440
+		$menu_slug = $this->_menu_map->menuSlug();
441
+
442
+
443
+		if ($this->_routing && ($page === '' || $page !== $menu_slug)) {
444
+			// not on the right page so let's get out.
445
+			return;
446
+		}
447
+		$this->_load_page = true;
448
+
449
+		// we don't need to do a page_request check here because it's only called via WP menu system.
450
+		$admin_page  = $this->_file_name . '_Admin_Page';
451
+		$hook_suffix = "{$menu_slug}_$admin_page";
452
+		$admin_page  = apply_filters(
453
+			"FHEE__EE_Admin_Page_Init___initialize_admin_page__admin_page__$hook_suffix",
454
+			$admin_page
455
+		);
456
+		if (empty($admin_page)) {
457
+			return;
458
+		}
459
+		// define requested admin page class name then load the file and instantiate
460
+		$path_to_file = str_replace(['\\', '/'], '/', $this->_folder_path . $admin_page . '.core.php');
461
+		// so if the file would be in EE_ADMIN/attendees/Attendee_Admin_Page.core.php, the filter would be:
462
+		// FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__attendees_Attendee_Admin_Page
463
+		$path_to_file = apply_filters(
464
+			"FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__$hook_suffix",
465
+			$path_to_file
466
+		);
467
+		if (! is_readable($path_to_file)) {
468
+			return;
469
+		}
470
+		// This is a place where EE plugins can hook in to make sure their own files are required in the appropriate place
471
+		do_action('AHEE__EE_Admin_Page___initialize_admin_page__before_initialization');
472
+		do_action("AHEE__EE_Admin_Page___initialize_admin_page__before_initialization_$menu_slug");
473
+		require_once($path_to_file);
474
+		$this->_loaded_page_object = $this->loader->getShared($admin_page, [$this->_routing]);
475
+		$this->_loaded_page_object->initializePage();
476
+
477
+		do_action('AHEE__EE_Admin_Page___initialize_admin_page__after_initialization');
478
+		do_action("AHEE__EE_Admin_Page___initialize_admin_page__after_initialization_$menu_slug");
479
+	}
480
+
481
+
482
+	public function get_admin_page_name(): string
483
+	{
484
+		return $this->_file_name . '_Admin_Page';
485
+	}
486
+
487
+
488
+	/**
489
+	 * @return EE_Admin_Page|null
490
+	 */
491
+	public function loaded_page_object(): ?EE_Admin_Page
492
+	{
493
+		return $this->_loaded_page_object;
494
+	}
495
+
496
+
497
+	/**
498
+	 * _check_user_access
499
+	 * verifies user access for this admin page.  If no user access is available then let's gracefully exit with a
500
+	 * WordPress die message.
501
+	 *
502
+	 * @return void  wp_die if fail
503
+	 */
504
+	private function _check_user_access()
505
+	{
506
+		if (! $this->_menu_map->currentUserHasAccess()) {
507
+			wp_die(
508
+				esc_html__('You don\'t have access to this page.', 'event_espresso'),
509
+				'',
510
+				['back_link' => true]
511
+			);
512
+		}
513
+	}
514 514
 }
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
     {
209 209
         wp_register_style(
210 210
             'espresso_menu',
211
-            EE_ADMIN_URL . 'assets/admin-menu-styles.css',
211
+            EE_ADMIN_URL.'assets/admin-menu-styles.css',
212 212
             ['dashicons'],
213 213
             EVENT_ESPRESSO_VERSION
214 214
         );
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 
233 233
     public function setCapability($capability, $menu_slug)
234 234
     {
235
-        $this->capability = apply_filters('FHEE_' . $menu_slug . '_capability', $capability);
235
+        $this->capability = apply_filters('FHEE_'.$menu_slug.'_capability', $capability);
236 236
     }
237 237
 
238 238
 
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
     {
261 261
         // let's check user access first
262 262
         $this->_check_user_access();
263
-        if (! $this->_loaded_page_object instanceof EE_Admin_Page) {
263
+        if ( ! $this->_loaded_page_object instanceof EE_Admin_Page) {
264 264
             return;
265 265
         }
266 266
         $this->_loaded_page_object->route_admin_request();
@@ -273,15 +273,15 @@  discard block
 block discarded – undo
273 273
      */
274 274
     public function set_page_dependencies(string $wp_page_slug)
275 275
     {
276
-        if (! $this->_load_page) {
276
+        if ( ! $this->_load_page) {
277 277
             return;
278 278
         }
279
-        if (! $this->_loaded_page_object instanceof EE_Admin_Page) {
279
+        if ( ! $this->_loaded_page_object instanceof EE_Admin_Page) {
280 280
             $msg[] = esc_html__(
281 281
                 'We can\'t load the page because we\'re missing a valid page object that tells us what to load',
282 282
                 'event_espresso'
283 283
             );
284
-            $msg[] = $msg[0] . "\r\n"
284
+            $msg[] = $msg[0]."\r\n"
285 285
                      . sprintf(
286 286
                          esc_html__(
287 287
                              'The custom slug you have set for this page is %s. This means we\'re looking for the class %s_Admin_Page (found in %s_Admin_Page.core.php) within your %s directory',
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
                          ),
290 290
                          $this->_file_name,
291 291
                          $this->_file_name,
292
-                         $this->_folder_path . $this->_file_name,
292
+                         $this->_folder_path.$this->_file_name,
293 293
                          $this->_menu_map->menuSlug()
294 294
                      );
295 295
             throw new EE_Error(implode('||', $msg));
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
         $this->_loaded_page_object->set_wp_page_slug($wp_page_slug);
298 298
         $page_hook = "load-$wp_page_slug";
299 299
         // hook into page load hook so all page specific stuff gets loaded.
300
-        if (! empty($wp_page_slug)) {
300
+        if ( ! empty($wp_page_slug)) {
301 301
             add_action($page_hook, [$this->_loaded_page_object, 'load_page_dependencies']);
302 302
         }
303 303
     }
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
     public function do_initial_loads()
318 318
     {
319 319
         // no loading or initializing if menu map is setup incorrectly.
320
-        if (! $this->_menu_map instanceof AdminMenuItem) {
320
+        if ( ! $this->_menu_map instanceof AdminMenuItem) {
321 321
             return;
322 322
         }
323 323
         $this->_initialize_admin_page();
@@ -338,13 +338,13 @@  discard block
 block discarded – undo
338 338
         foreach ($bt as $index => $values) {
339 339
             if (isset($values['class']) && $values['class'] == $class) {
340 340
                 $file_index         = $index - 1;
341
-                $this->_folder_name = basename(dirname($bt[ $file_index ]['file']));
342
-                if (! empty($this->_folder_name)) {
341
+                $this->_folder_name = basename(dirname($bt[$file_index]['file']));
342
+                if ( ! empty($this->_folder_name)) {
343 343
                     break;
344 344
                 }
345 345
             }
346 346
         }
347
-        $this->_folder_path = EE_ADMIN_PAGES . $this->_folder_name . '/';
347
+        $this->_folder_path = EE_ADMIN_PAGES.$this->_folder_name.'/';
348 348
         $this->_file_name   = preg_replace('/^ee/', 'EE', $this->_folder_name);
349 349
         $this->_file_name   = ucwords(str_replace('_', ' ', $this->_file_name));
350 350
         $this->_file_name   = str_replace(' ', '_', $this->_file_name);
@@ -374,17 +374,17 @@  discard block
 block discarded – undo
374 374
                 . $this->_file_name
375 375
                 . '_Hooks_Extend.class.php'
376 376
             );
377
-            $this->_hook_paths    = $this->_register_hook_files($hook_files_glob_path, $extend);
377
+            $this->_hook_paths = $this->_register_hook_files($hook_files_glob_path, $extend);
378 378
         }
379 379
         // loop through decaf folders
380 380
         $hook_files_glob_path = apply_filters(
381 381
             'FHEE__EE_Admin_Page_Init__register_hooks__hook_files_glob_path',
382
-            $this->_folder_path . '*' . $this->_file_name . '_Hooks.class.php'
382
+            $this->_folder_path.'*'.$this->_file_name.'_Hooks.class.php'
383 383
         );
384
-        $this->_hook_paths    = array_merge(
384
+        $this->_hook_paths = array_merge(
385 385
             $this->_register_hook_files($hook_files_glob_path),
386 386
             $this->_hook_paths
387
-        );  // making sure any extended hook paths are later in the array than the core hook paths!
387
+        ); // making sure any extended hook paths are later in the array than the core hook paths!
388 388
         return $this->_hook_paths;
389 389
     }
390 390
 
@@ -398,11 +398,11 @@  discard block
 block discarded – undo
398 398
         foreach ($hook_paths as $file) {
399 399
             // lets get the linked admin.
400 400
             $hook_file = $extend
401
-                ? str_replace(EE_CORE_CAF_ADMIN_EXTEND . $this->_folder_name . '/', '', $file)
401
+                ? str_replace(EE_CORE_CAF_ADMIN_EXTEND.$this->_folder_name.'/', '', $file)
402 402
                 : str_replace($this->_folder_path, '', $file);
403 403
             $replace   = $extend
404
-                ? '_' . $this->_file_name . '_Hooks_Extend.class.php'
405
-                : '_' . $this->_file_name . '_Hooks.class.php';
404
+                ? '_'.$this->_file_name.'_Hooks_Extend.class.php'
405
+                : '_'.$this->_file_name.'_Hooks.class.php';
406 406
             $rel_admin = str_replace($replace, '', $hook_file);
407 407
             $rel_admin = strtolower($rel_admin);
408 408
             // make sure we haven't already got a hook setup for this page path
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
             }
412 412
             require_once $file;
413 413
             $this->hook_file = $hook_file;
414
-            $rel_admin_hook  = 'FHEE_do_other_page_hooks_' . $rel_admin;
414
+            $rel_admin_hook  = 'FHEE_do_other_page_hooks_'.$rel_admin;
415 415
             add_filter($rel_admin_hook, [$this, 'load_admin_hook']);
416 416
             $this->_files_hooked[] = $rel_admin;
417 417
         }
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
         $this->_load_page = true;
448 448
 
449 449
         // we don't need to do a page_request check here because it's only called via WP menu system.
450
-        $admin_page  = $this->_file_name . '_Admin_Page';
450
+        $admin_page  = $this->_file_name.'_Admin_Page';
451 451
         $hook_suffix = "{$menu_slug}_$admin_page";
452 452
         $admin_page  = apply_filters(
453 453
             "FHEE__EE_Admin_Page_Init___initialize_admin_page__admin_page__$hook_suffix",
@@ -457,14 +457,14 @@  discard block
 block discarded – undo
457 457
             return;
458 458
         }
459 459
         // define requested admin page class name then load the file and instantiate
460
-        $path_to_file = str_replace(['\\', '/'], '/', $this->_folder_path . $admin_page . '.core.php');
460
+        $path_to_file = str_replace(['\\', '/'], '/', $this->_folder_path.$admin_page.'.core.php');
461 461
         // so if the file would be in EE_ADMIN/attendees/Attendee_Admin_Page.core.php, the filter would be:
462 462
         // FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__attendees_Attendee_Admin_Page
463 463
         $path_to_file = apply_filters(
464 464
             "FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__$hook_suffix",
465 465
             $path_to_file
466 466
         );
467
-        if (! is_readable($path_to_file)) {
467
+        if ( ! is_readable($path_to_file)) {
468 468
             return;
469 469
         }
470 470
         // This is a place where EE plugins can hook in to make sure their own files are required in the appropriate place
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
 
482 482
     public function get_admin_page_name(): string
483 483
     {
484
-        return $this->_file_name . '_Admin_Page';
484
+        return $this->_file_name.'_Admin_Page';
485 485
     }
486 486
 
487 487
 
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
      */
504 504
     private function _check_user_access()
505 505
     {
506
-        if (! $this->_menu_map->currentUserHasAccess()) {
506
+        if ( ! $this->_menu_map->currentUserHasAccess()) {
507 507
             wp_die(
508 508
                 esc_html__('You don\'t have access to this page.', 'event_espresso'),
509 509
                 '',
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page_Loader.core.php 2 patches
Indentation   +433 added lines, -433 removed lines patch added patch discarded remove patch
@@ -16,437 +16,437 @@
 block discarded – undo
16 16
  */
17 17
 class EE_Admin_Page_Loader
18 18
 {
19
-    /**
20
-     * @var AdminMenuManager $menu_manager
21
-     */
22
-    protected $menu_manager;
23
-
24
-    /**
25
-     * @var LoaderInterface $loader
26
-     */
27
-    protected $loader;
28
-
29
-    /**
30
-     * _installed_pages
31
-     * objects for page_init objects detected and loaded
32
-     *
33
-     * @access private
34
-     * @var EE_Admin_Page_Init[]
35
-     */
36
-    private $_installed_pages = [];
37
-
38
-
39
-    /**
40
-     * this is used to hold the registry of menu slugs for all the installed admin pages
41
-     *
42
-     * @var array
43
-     */
44
-    private $_menu_slugs = [];
45
-
46
-
47
-    /**
48
-     * _caffeinated_extends
49
-     * This array is the generated configuration array for which core EE_Admin pages are extended (and the bits and
50
-     * pieces needed to do so).  This property is defined in the _set_caffeinated method.
51
-     *
52
-     * @var array
53
-     */
54
-    private $_caffeinated_extends = [];
55
-
56
-
57
-    /**
58
-     * This property will hold the hook file for setting up the filter that does all the connections between admin
59
-     * pages.
60
-     *
61
-     * @var string
62
-     */
63
-    public $hook_file;
64
-
65
-    /**
66
-     * @var   int
67
-     * @since $VID:$
68
-     */
69
-    private $maintenance_mode = 0;
70
-
71
-
72
-    /**
73
-     * @throws InvalidArgumentException
74
-     * @throws InvalidDataTypeException
75
-     * @throws InvalidInterfaceException
76
-     */
77
-    public function __construct(?LoaderInterface $loader)
78
-    {
79
-        $this->loader = $loader instanceof LoaderInterface ? $loader : LoaderFactory::getLoader();
80
-        $this->menu_manager = $this->loader->getShared(AdminMenuManager::class, [$this->loader]);
81
-    }
82
-
83
-
84
-    /**
85
-     * @throws EE_Error
86
-     * @throws ReflectionException
87
-     * @since $VID:$
88
-     */
89
-    public function init()
90
-    {
91
-        $this->menu_manager->initialize();
92
-        $this->maintenance_mode = EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance;
93
-        // let's do a scan and see what installed pages we have
94
-        $this->findAndLoadAdminPages();
95
-    }
96
-
97
-
98
-    /**
99
-     * When caffeinated system is detected, this method is called to setup the caffeinated directory constants used by
100
-     * files in the caffeinated folder.
101
-     *
102
-     * @access private
103
-     * @return void
104
-     */
105
-    private function defineCaffeinatedConstants()
106
-    {
107
-        if (! defined('EE_CORE_CAF_ADMIN')) {
108
-            define('EE_CORE_CAF_ADMIN', EE_PLUGIN_DIR_PATH . 'caffeinated/admin/');
109
-            define('EE_CORE_CAF_ADMIN_URL', EE_PLUGIN_DIR_URL . 'caffeinated/admin/');
110
-            define('EE_CORE_CAF_ADMIN_NEW', EE_CORE_CAF_ADMIN . 'new/');
111
-            define('EE_CORE_CAF_ADMIN_EXTEND', EE_CORE_CAF_ADMIN . 'extend/');
112
-            define('EE_CORE_CAF_ADMIN_EXTEND_URL', EE_CORE_CAF_ADMIN_URL . 'extend/');
113
-            define('EE_CORE_CAF_ADMIN_HOOKS', EE_CORE_CAF_ADMIN . 'hooks/');
114
-        }
115
-    }
116
-
117
-
118
-    /**
119
-     * This just gets the list of installed EE_Admin_pages.
120
-     *
121
-     * @access private
122
-     * @return void
123
-     * @throws EE_Error
124
-     * @throws InvalidArgumentException
125
-     * @throws InvalidDataTypeException
126
-     * @throws InvalidInterfaceException
127
-     * @throws ReflectionException
128
-     */
129
-    private function findAndLoadAdminPages()
130
-    {
131
-        $admin_pages = $this->findAdminPages();
132
-        // this just checks the caffeinated folder and takes care of setting up any caffeinated stuff.
133
-        $admin_pages = $this->findCaffeinatedAdminPages($admin_pages);
134
-        // then extensions and hooks, although they don't get added to the admin pages array
135
-        $this->findAdminPageExtensions();
136
-        $this->findAdminPageHooks();
137
-        // allow plugins to add in their own pages (note at this point they will need to have an autoloader defined for their class) OR hook into EEH_Autoloader::load_admin_page() to add their path.;
138
-        // loop through admin pages and setup the $_installed_pages array.
139
-        $hooks_ref = [];
140
-        $menu_pages = [];
141
-        foreach ($admin_pages as $page => $path) {
142
-            // don't load the page init class IF IT's ALREADY LOADED !!!
143
-            if (
144
-                isset($this->_installed_pages[ $page ])
145
-                && $this->_installed_pages[ $page ] instanceof EE_Admin_Page_Init
146
-            ) {
147
-                continue;
148
-            }
149
-            // build list of installed pages
150
-            $admin_page_init = $this->loadAdminPageInit($page);
151
-            $this->_installed_pages[ $page ] = $admin_page_init;
152
-            $admin_menu = $this->menu_manager->getAdminMenu($admin_page_init);
153
-            $admin_page_init->setCapability($admin_menu->capability(), $admin_menu->menuSlug());
154
-            // skip if in full maintenance mode and maintenance_mode_parent is NOT set
155
-            if ($this->maintenance_mode && ! $admin_menu->maintenanceModeParent()) {
156
-                unset($admin_pages[ $page ]);
157
-                continue;
158
-            }
159
-            $menu_slug = $admin_menu->menuSlug();
160
-            $this->_menu_slugs[ $menu_slug ] = $page;
161
-            $menu_pages[ $menu_slug ] = $admin_page_init;
162
-            // now that we've got the admin_init objects...
163
-            // lets see if there are any caffeinated pages extending the originals.
164
-            // If there are then let's hook into the init admin filter and load our extend instead.
165
-            // Set flag for register hooks on extended pages b/c extended pages use the default INIT.
166
-            $extended_hooks = $admin_page_init->register_hooks(
167
-                $this->loadCaffeinatedExtensions($admin_page_init, $page, $menu_slug)
168
-            );
169
-            $hooks_ref      += $extended_hooks;
170
-        }
171
-        // the hooks_ref is all the pages where we have $extended _Hooks files
172
-        // that will extend a class in a different folder.
173
-        // So we want to make sure we load the file for the parent.
174
-        // first make sure we've got unique values
175
-        $hooks_ref = array_unique($hooks_ref);
176
-        // now let's loop and require!
177
-        foreach ($hooks_ref as $path) {
178
-            require_once($path);
179
-        }
180
-        // make sure we have menu slugs global setup. Used in EE_Admin_Page->page_setup() to ensure we don't do a full class load for an admin page that isn't requested.
181
-        global $ee_menu_slugs;
182
-        $ee_menu_slugs = $this->_menu_slugs;
183
-        // we need to loop again to run any early code
184
-        foreach ($this->_installed_pages as $page) {
185
-            $page->do_initial_loads();
186
-        }
187
-        $this->menu_manager->setInstalledPages($menu_pages);
188
-        do_action('AHEE__EE_Admin_Page_Loader___get_installed_pages_loaded', $this->_installed_pages);
189
-    }
190
-
191
-
192
-    /**
193
-     * @return array
194
-     * @throws EE_Error
195
-     * @since   $VID:$
196
-     */
197
-    private function findAdminPages(): array
198
-    {
199
-
200
-        // grab everything in the  admin core directory
201
-        $admin_page_folders = $this->findAdminPageFolders(EE_ADMIN_PAGES . '*');
202
-        $admin_page_folders = apply_filters(
203
-            'FHEE__EE_Admin_Page_Loader__findAdminPages__admin_page_folders',
204
-            $admin_page_folders
205
-        );
206
-        if (! empty($admin_page_folders)) {
207
-            return $admin_page_folders;
208
-        }
209
-        $error_msg = esc_html__(
210
-            'There are no EE_Admin pages detected, it looks like EE did not install properly',
211
-            'event_espresso'
212
-        );
213
-        $error_msg .= '||';
214
-        $error_msg .= sprintf(
215
-            esc_html__(
216
-                'Check that the %s folder exists and is writable. Maybe try deactivating, then reactivating Event Espresso again.',
217
-                'event_espresso'
218
-            ),
219
-            EE_ADMIN_PAGES
220
-        );
221
-        throw new RuntimeException($error_msg);
222
-    }
223
-
224
-
225
-    /**
226
-     * get_admin_page_object
227
-     *
228
-     * @param string $page_slug
229
-     * @return EE_Admin_Page
230
-     */
231
-    public function get_admin_page_object(string $page_slug = ''): ?EE_Admin_Page
232
-    {
233
-        return isset($this->_installed_pages[ $page_slug ])
234
-               && $this->_installed_pages[ $page_slug ] instanceof EE_Admin_Page_Init
235
-            ? $this->_installed_pages[ $page_slug ]->loaded_page_object()
236
-            : null;
237
-    }
238
-
239
-
240
-    /**
241
-     * generates an "Admin Page Init" class based on the directory  name
242
-     *
243
-     * @param string $dir_name
244
-     * @return string
245
-     */
246
-    private function getClassnameForAdminPageInit(string $dir_name = ''): string
247
-    {
248
-        $class_name = str_replace('_', ' ', strtolower($dir_name));
249
-        return str_replace(' ', '_', ucwords($class_name)) . '_Admin_Page_Init';
250
-    }
251
-
252
-
253
-    /**
254
-     * _load_admin_page
255
-     * Loads and instantiates page_init object for a single EE_admin page.
256
-     *
257
-     * @param string $page page_reference
258
-     * @return EE_Admin_Page_Init
259
-     * @throws EE_Error
260
-     */
261
-    private function loadAdminPageInit(string $page = ''): EE_Admin_Page_Init
262
-    {
263
-        $class_name = $this->getClassnameForAdminPageInit($page);
264
-        if (class_exists($class_name)) {
265
-            $admin_page_init = $this->loader->getShared($class_name);
266
-            // verify returned object
267
-            if ($admin_page_init instanceof EE_Admin_Page_Init) {
268
-                return $admin_page_init;
269
-            }
270
-        }
271
-        $error_msg = sprintf(
272
-            esc_html__('Something went wrong with loading the %s admin page.', 'event_espresso'),
273
-            $page
274
-        );
275
-        $error_msg .= '||'; // separates public from developer messages
276
-        $error_msg .= "\r\n";
277
-        $error_msg .= sprintf(
278
-            esc_html__('There is no Init class in place for the %s admin page.', 'event_espresso'),
279
-            $page
280
-        );
281
-        $error_msg .= '<br />';
282
-        $error_msg .= sprintf(
283
-            esc_html__(
284
-                'Make sure you have %1$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
285
-                'event_espresso'
286
-            ),
287
-            '<strong>' . $class_name . '</strong>'
288
-        );
289
-        throw new EE_Error($error_msg);
290
-    }
291
-
292
-
293
-    /**
294
-     * This method is the "workhorse" for detecting and setting up caffeinated functionality.
295
-     * In this method there are three checks being done:
296
-     * 1. Do we have any NEW admin page sets.  If we do, lets add them into the menu setup (via the $admin_pages
297
-     * array) etc.  (new page sets are found in caffeinated/new/{page})
298
-     * 2. Do we have any EXTENDED page sets.  Basically an extended EE_Admin Page extends the core {child}_Admin_Page
299
-     * class.  eg. would be caffeinated/extend/events/Extend_Events_Admin_Page.core.php and in there would be a class:
300
-     * Extend_Events_Admin_Page extends Events_Admin_Page.
301
-     * 3. Do we have any files just for setting up hooks into other core pages.  The files can be any name in
302
-     * "caffeinated/hooks" EXCEPT they need a ".class.php" extension and the file name must correspond with the
303
-     * classname inside.  These classes are instantiated really early so that any hooks in them are run before the
304
-     * corresponding apply_filters/do_actions that are found in any future loaded EE_Admin pages (INCLUDING caffeinated
305
-     * admin_pages)
306
-     *
307
-     * @param array $admin_pages the original installed_refs array that may contain our NEW EE_Admin_Pages to be
308
-     *                              loaded.
309
-     * @return array
310
-     * @throws EE_Error
311
-     */
312
-    private function findCaffeinatedAdminPages(array $admin_pages): array
313
-    {
314
-        // first let's check if there IS a caffeinated folder. If there is not then lets get out.
315
-        if ((defined('EE_DECAF') && EE_DECAF) || ! is_dir(EE_PLUGIN_DIR_PATH . 'caffeinated/admin')) {
316
-            return $admin_pages;
317
-        }
318
-        $this->defineCaffeinatedConstants();
319
-        // okay let's setup an "New" pages first (we'll return installed refs later)
320
-        $admin_pages += $this->findAdminPageFolders(EE_CORE_CAF_ADMIN . 'new/*', ['tickets']);
321
-
322
-        return apply_filters(
323
-            'FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs',
324
-            $admin_pages
325
-        );
326
-    }
327
-
328
-
329
-    /**
330
-     * @throws EE_Error
331
-     * @since   $VID:$
332
-     */
333
-    private function findAdminPageExtensions()
334
-    {
335
-        // let's see if there are any EXTENDS to setup in the $_caffeinated_extends array
336
-        // (that will be used later for hooking into the _initialize_admin_age in the related core_init admin page)
337
-        $extensions = $this->findAdminPageFolders(EE_CORE_CAF_ADMIN . 'extend/*');
338
-        if ($extensions) {
339
-            foreach ($extensions as $folder => $extension) {
340
-                // convert lowercase_snake_case to Uppercase_Snake_Case
341
-                $filename = str_replace(' ', '_', ucwords(str_replace('_', ' ', $folder)));
342
-                $filename = "Extend_{$filename}_Admin_Page";
343
-                $filepath = EE_CORE_CAF_ADMIN . "extend/$folder/$filename.core.php";
344
-                // save filename and filepath for later
345
-                $this->_caffeinated_extends[ $folder ]['path']       = str_replace(['\\', '/'], '/', $filepath);
346
-                $this->_caffeinated_extends[ $folder ]['admin_page'] = $filename;
347
-            }
348
-        }
349
-        $this->_caffeinated_extends = apply_filters(
350
-            'FHEE__EE_Admin_Page_Loader___get_installed_pages__caffeinated_extends',
351
-            $this->_caffeinated_extends
352
-        );
353
-    }
354
-
355
-
356
-    private function loadCaffeinatedExtensions(
357
-        EE_Admin_Page_Init $admin_page_init,
358
-        string $page,
359
-        string $menu_slug
360
-    ): bool {
361
-        if (! isset($this->_caffeinated_extends[ $page ])) {
362
-            return false;
363
-        }
364
-        $admin_page_name = $admin_page_init->get_admin_page_name();
365
-        $caf_path        = $this->_caffeinated_extends[ $page ]['path'];
366
-        $caf_admin_page  = $this->_caffeinated_extends[ $page ]['admin_page'];
367
-        add_filter(
368
-            "FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__{$menu_slug}_$admin_page_name",
369
-            static function ($path_to_file) use ($caf_path) {
370
-                return $caf_path;
371
-            }
372
-        );
373
-        add_filter(
374
-            "FHEE__EE_Admin_Page_Init___initialize_admin_page__admin_page__{$menu_slug}_$admin_page_name",
375
-            static function ($admin_page) use ($caf_admin_page) {
376
-                return $caf_admin_page;
377
-            }
378
-        );
379
-        return true;
380
-    }
381
-
382
-
383
-    /**
384
-     * @throws EE_Error
385
-     * @since   $VID:$
386
-     */
387
-    private function findAdminPageHooks()
388
-    {
389
-        // let's see if there are any HOOK files and instantiate them if there are (so that hooks are loaded early!).
390
-        $ee_admin_hooks   = [];
391
-        $admin_page_hooks = $this->findAdminPageFolders(EE_CORE_CAF_ADMIN . 'hooks/*.class.php', [], 0, false);
392
-        if ($admin_page_hooks) {
393
-            foreach ($admin_page_hooks as $hook) {
394
-                if (is_readable($hook)) {
395
-                    require_once $hook;
396
-                    $classname = str_replace([EE_CORE_CAF_ADMIN . 'hooks/', '.class.php'], '', $hook);
397
-                    if (class_exists($classname)) {
398
-                        $ee_admin_hooks[] = $this->loader->getShared($classname);
399
-                    }
400
-                }
401
-            }
402
-        }
403
-        apply_filters('FHEE__EE_Admin_Page_Loader__set_caffeinated__ee_admin_hooks', $ee_admin_hooks);
404
-    }
405
-
406
-
407
-    /**
408
-     * _default_header_link
409
-     * This is just a dummy method to use with header submenu items
410
-     *
411
-     * @return bool false
412
-     */
413
-    public function _default_header_link(): bool
414
-    {
415
-        return false;
416
-    }
417
-
418
-
419
-    /**
420
-     * @param string $path
421
-     * @param int    $flags
422
-     * @param array  $exclude
423
-     * @param bool   $register_autoloaders
424
-     * @return array
425
-     * @throws EE_Error
426
-     * @since $VID:$
427
-     */
428
-    private function findAdminPageFolders(
429
-        string $path,
430
-        array $exclude = [],
431
-        int $flags = GLOB_ONLYDIR,
432
-        bool $register_autoloaders = true
433
-    ): array {
434
-        $folders = [];
435
-        $subfolders = glob($path, $flags);
436
-        if ($subfolders) {
437
-            foreach ($subfolders as $admin_screen) {
438
-                $admin_screen_name = basename($admin_screen);
439
-                // files and anything in the exclude array need not apply
440
-                if (! in_array($admin_screen_name, $exclude, true)) {
441
-                    // these folders represent the different EE admin pages
442
-                    $folders[ $admin_screen_name ] = $admin_screen;
443
-                    if ($register_autoloaders) {
444
-                        // set autoloaders for our admin page classes based on included path information
445
-                        EEH_Autoloader::register_autoloaders_for_each_file_in_folder($admin_screen);
446
-                    }
447
-                }
448
-            }
449
-        }
450
-        return $folders;
451
-    }
19
+	/**
20
+	 * @var AdminMenuManager $menu_manager
21
+	 */
22
+	protected $menu_manager;
23
+
24
+	/**
25
+	 * @var LoaderInterface $loader
26
+	 */
27
+	protected $loader;
28
+
29
+	/**
30
+	 * _installed_pages
31
+	 * objects for page_init objects detected and loaded
32
+	 *
33
+	 * @access private
34
+	 * @var EE_Admin_Page_Init[]
35
+	 */
36
+	private $_installed_pages = [];
37
+
38
+
39
+	/**
40
+	 * this is used to hold the registry of menu slugs for all the installed admin pages
41
+	 *
42
+	 * @var array
43
+	 */
44
+	private $_menu_slugs = [];
45
+
46
+
47
+	/**
48
+	 * _caffeinated_extends
49
+	 * This array is the generated configuration array for which core EE_Admin pages are extended (and the bits and
50
+	 * pieces needed to do so).  This property is defined in the _set_caffeinated method.
51
+	 *
52
+	 * @var array
53
+	 */
54
+	private $_caffeinated_extends = [];
55
+
56
+
57
+	/**
58
+	 * This property will hold the hook file for setting up the filter that does all the connections between admin
59
+	 * pages.
60
+	 *
61
+	 * @var string
62
+	 */
63
+	public $hook_file;
64
+
65
+	/**
66
+	 * @var   int
67
+	 * @since $VID:$
68
+	 */
69
+	private $maintenance_mode = 0;
70
+
71
+
72
+	/**
73
+	 * @throws InvalidArgumentException
74
+	 * @throws InvalidDataTypeException
75
+	 * @throws InvalidInterfaceException
76
+	 */
77
+	public function __construct(?LoaderInterface $loader)
78
+	{
79
+		$this->loader = $loader instanceof LoaderInterface ? $loader : LoaderFactory::getLoader();
80
+		$this->menu_manager = $this->loader->getShared(AdminMenuManager::class, [$this->loader]);
81
+	}
82
+
83
+
84
+	/**
85
+	 * @throws EE_Error
86
+	 * @throws ReflectionException
87
+	 * @since $VID:$
88
+	 */
89
+	public function init()
90
+	{
91
+		$this->menu_manager->initialize();
92
+		$this->maintenance_mode = EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance;
93
+		// let's do a scan and see what installed pages we have
94
+		$this->findAndLoadAdminPages();
95
+	}
96
+
97
+
98
+	/**
99
+	 * When caffeinated system is detected, this method is called to setup the caffeinated directory constants used by
100
+	 * files in the caffeinated folder.
101
+	 *
102
+	 * @access private
103
+	 * @return void
104
+	 */
105
+	private function defineCaffeinatedConstants()
106
+	{
107
+		if (! defined('EE_CORE_CAF_ADMIN')) {
108
+			define('EE_CORE_CAF_ADMIN', EE_PLUGIN_DIR_PATH . 'caffeinated/admin/');
109
+			define('EE_CORE_CAF_ADMIN_URL', EE_PLUGIN_DIR_URL . 'caffeinated/admin/');
110
+			define('EE_CORE_CAF_ADMIN_NEW', EE_CORE_CAF_ADMIN . 'new/');
111
+			define('EE_CORE_CAF_ADMIN_EXTEND', EE_CORE_CAF_ADMIN . 'extend/');
112
+			define('EE_CORE_CAF_ADMIN_EXTEND_URL', EE_CORE_CAF_ADMIN_URL . 'extend/');
113
+			define('EE_CORE_CAF_ADMIN_HOOKS', EE_CORE_CAF_ADMIN . 'hooks/');
114
+		}
115
+	}
116
+
117
+
118
+	/**
119
+	 * This just gets the list of installed EE_Admin_pages.
120
+	 *
121
+	 * @access private
122
+	 * @return void
123
+	 * @throws EE_Error
124
+	 * @throws InvalidArgumentException
125
+	 * @throws InvalidDataTypeException
126
+	 * @throws InvalidInterfaceException
127
+	 * @throws ReflectionException
128
+	 */
129
+	private function findAndLoadAdminPages()
130
+	{
131
+		$admin_pages = $this->findAdminPages();
132
+		// this just checks the caffeinated folder and takes care of setting up any caffeinated stuff.
133
+		$admin_pages = $this->findCaffeinatedAdminPages($admin_pages);
134
+		// then extensions and hooks, although they don't get added to the admin pages array
135
+		$this->findAdminPageExtensions();
136
+		$this->findAdminPageHooks();
137
+		// allow plugins to add in their own pages (note at this point they will need to have an autoloader defined for their class) OR hook into EEH_Autoloader::load_admin_page() to add their path.;
138
+		// loop through admin pages and setup the $_installed_pages array.
139
+		$hooks_ref = [];
140
+		$menu_pages = [];
141
+		foreach ($admin_pages as $page => $path) {
142
+			// don't load the page init class IF IT's ALREADY LOADED !!!
143
+			if (
144
+				isset($this->_installed_pages[ $page ])
145
+				&& $this->_installed_pages[ $page ] instanceof EE_Admin_Page_Init
146
+			) {
147
+				continue;
148
+			}
149
+			// build list of installed pages
150
+			$admin_page_init = $this->loadAdminPageInit($page);
151
+			$this->_installed_pages[ $page ] = $admin_page_init;
152
+			$admin_menu = $this->menu_manager->getAdminMenu($admin_page_init);
153
+			$admin_page_init->setCapability($admin_menu->capability(), $admin_menu->menuSlug());
154
+			// skip if in full maintenance mode and maintenance_mode_parent is NOT set
155
+			if ($this->maintenance_mode && ! $admin_menu->maintenanceModeParent()) {
156
+				unset($admin_pages[ $page ]);
157
+				continue;
158
+			}
159
+			$menu_slug = $admin_menu->menuSlug();
160
+			$this->_menu_slugs[ $menu_slug ] = $page;
161
+			$menu_pages[ $menu_slug ] = $admin_page_init;
162
+			// now that we've got the admin_init objects...
163
+			// lets see if there are any caffeinated pages extending the originals.
164
+			// If there are then let's hook into the init admin filter and load our extend instead.
165
+			// Set flag for register hooks on extended pages b/c extended pages use the default INIT.
166
+			$extended_hooks = $admin_page_init->register_hooks(
167
+				$this->loadCaffeinatedExtensions($admin_page_init, $page, $menu_slug)
168
+			);
169
+			$hooks_ref      += $extended_hooks;
170
+		}
171
+		// the hooks_ref is all the pages where we have $extended _Hooks files
172
+		// that will extend a class in a different folder.
173
+		// So we want to make sure we load the file for the parent.
174
+		// first make sure we've got unique values
175
+		$hooks_ref = array_unique($hooks_ref);
176
+		// now let's loop and require!
177
+		foreach ($hooks_ref as $path) {
178
+			require_once($path);
179
+		}
180
+		// make sure we have menu slugs global setup. Used in EE_Admin_Page->page_setup() to ensure we don't do a full class load for an admin page that isn't requested.
181
+		global $ee_menu_slugs;
182
+		$ee_menu_slugs = $this->_menu_slugs;
183
+		// we need to loop again to run any early code
184
+		foreach ($this->_installed_pages as $page) {
185
+			$page->do_initial_loads();
186
+		}
187
+		$this->menu_manager->setInstalledPages($menu_pages);
188
+		do_action('AHEE__EE_Admin_Page_Loader___get_installed_pages_loaded', $this->_installed_pages);
189
+	}
190
+
191
+
192
+	/**
193
+	 * @return array
194
+	 * @throws EE_Error
195
+	 * @since   $VID:$
196
+	 */
197
+	private function findAdminPages(): array
198
+	{
199
+
200
+		// grab everything in the  admin core directory
201
+		$admin_page_folders = $this->findAdminPageFolders(EE_ADMIN_PAGES . '*');
202
+		$admin_page_folders = apply_filters(
203
+			'FHEE__EE_Admin_Page_Loader__findAdminPages__admin_page_folders',
204
+			$admin_page_folders
205
+		);
206
+		if (! empty($admin_page_folders)) {
207
+			return $admin_page_folders;
208
+		}
209
+		$error_msg = esc_html__(
210
+			'There are no EE_Admin pages detected, it looks like EE did not install properly',
211
+			'event_espresso'
212
+		);
213
+		$error_msg .= '||';
214
+		$error_msg .= sprintf(
215
+			esc_html__(
216
+				'Check that the %s folder exists and is writable. Maybe try deactivating, then reactivating Event Espresso again.',
217
+				'event_espresso'
218
+			),
219
+			EE_ADMIN_PAGES
220
+		);
221
+		throw new RuntimeException($error_msg);
222
+	}
223
+
224
+
225
+	/**
226
+	 * get_admin_page_object
227
+	 *
228
+	 * @param string $page_slug
229
+	 * @return EE_Admin_Page
230
+	 */
231
+	public function get_admin_page_object(string $page_slug = ''): ?EE_Admin_Page
232
+	{
233
+		return isset($this->_installed_pages[ $page_slug ])
234
+			   && $this->_installed_pages[ $page_slug ] instanceof EE_Admin_Page_Init
235
+			? $this->_installed_pages[ $page_slug ]->loaded_page_object()
236
+			: null;
237
+	}
238
+
239
+
240
+	/**
241
+	 * generates an "Admin Page Init" class based on the directory  name
242
+	 *
243
+	 * @param string $dir_name
244
+	 * @return string
245
+	 */
246
+	private function getClassnameForAdminPageInit(string $dir_name = ''): string
247
+	{
248
+		$class_name = str_replace('_', ' ', strtolower($dir_name));
249
+		return str_replace(' ', '_', ucwords($class_name)) . '_Admin_Page_Init';
250
+	}
251
+
252
+
253
+	/**
254
+	 * _load_admin_page
255
+	 * Loads and instantiates page_init object for a single EE_admin page.
256
+	 *
257
+	 * @param string $page page_reference
258
+	 * @return EE_Admin_Page_Init
259
+	 * @throws EE_Error
260
+	 */
261
+	private function loadAdminPageInit(string $page = ''): EE_Admin_Page_Init
262
+	{
263
+		$class_name = $this->getClassnameForAdminPageInit($page);
264
+		if (class_exists($class_name)) {
265
+			$admin_page_init = $this->loader->getShared($class_name);
266
+			// verify returned object
267
+			if ($admin_page_init instanceof EE_Admin_Page_Init) {
268
+				return $admin_page_init;
269
+			}
270
+		}
271
+		$error_msg = sprintf(
272
+			esc_html__('Something went wrong with loading the %s admin page.', 'event_espresso'),
273
+			$page
274
+		);
275
+		$error_msg .= '||'; // separates public from developer messages
276
+		$error_msg .= "\r\n";
277
+		$error_msg .= sprintf(
278
+			esc_html__('There is no Init class in place for the %s admin page.', 'event_espresso'),
279
+			$page
280
+		);
281
+		$error_msg .= '<br />';
282
+		$error_msg .= sprintf(
283
+			esc_html__(
284
+				'Make sure you have %1$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
285
+				'event_espresso'
286
+			),
287
+			'<strong>' . $class_name . '</strong>'
288
+		);
289
+		throw new EE_Error($error_msg);
290
+	}
291
+
292
+
293
+	/**
294
+	 * This method is the "workhorse" for detecting and setting up caffeinated functionality.
295
+	 * In this method there are three checks being done:
296
+	 * 1. Do we have any NEW admin page sets.  If we do, lets add them into the menu setup (via the $admin_pages
297
+	 * array) etc.  (new page sets are found in caffeinated/new/{page})
298
+	 * 2. Do we have any EXTENDED page sets.  Basically an extended EE_Admin Page extends the core {child}_Admin_Page
299
+	 * class.  eg. would be caffeinated/extend/events/Extend_Events_Admin_Page.core.php and in there would be a class:
300
+	 * Extend_Events_Admin_Page extends Events_Admin_Page.
301
+	 * 3. Do we have any files just for setting up hooks into other core pages.  The files can be any name in
302
+	 * "caffeinated/hooks" EXCEPT they need a ".class.php" extension and the file name must correspond with the
303
+	 * classname inside.  These classes are instantiated really early so that any hooks in them are run before the
304
+	 * corresponding apply_filters/do_actions that are found in any future loaded EE_Admin pages (INCLUDING caffeinated
305
+	 * admin_pages)
306
+	 *
307
+	 * @param array $admin_pages the original installed_refs array that may contain our NEW EE_Admin_Pages to be
308
+	 *                              loaded.
309
+	 * @return array
310
+	 * @throws EE_Error
311
+	 */
312
+	private function findCaffeinatedAdminPages(array $admin_pages): array
313
+	{
314
+		// first let's check if there IS a caffeinated folder. If there is not then lets get out.
315
+		if ((defined('EE_DECAF') && EE_DECAF) || ! is_dir(EE_PLUGIN_DIR_PATH . 'caffeinated/admin')) {
316
+			return $admin_pages;
317
+		}
318
+		$this->defineCaffeinatedConstants();
319
+		// okay let's setup an "New" pages first (we'll return installed refs later)
320
+		$admin_pages += $this->findAdminPageFolders(EE_CORE_CAF_ADMIN . 'new/*', ['tickets']);
321
+
322
+		return apply_filters(
323
+			'FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs',
324
+			$admin_pages
325
+		);
326
+	}
327
+
328
+
329
+	/**
330
+	 * @throws EE_Error
331
+	 * @since   $VID:$
332
+	 */
333
+	private function findAdminPageExtensions()
334
+	{
335
+		// let's see if there are any EXTENDS to setup in the $_caffeinated_extends array
336
+		// (that will be used later for hooking into the _initialize_admin_age in the related core_init admin page)
337
+		$extensions = $this->findAdminPageFolders(EE_CORE_CAF_ADMIN . 'extend/*');
338
+		if ($extensions) {
339
+			foreach ($extensions as $folder => $extension) {
340
+				// convert lowercase_snake_case to Uppercase_Snake_Case
341
+				$filename = str_replace(' ', '_', ucwords(str_replace('_', ' ', $folder)));
342
+				$filename = "Extend_{$filename}_Admin_Page";
343
+				$filepath = EE_CORE_CAF_ADMIN . "extend/$folder/$filename.core.php";
344
+				// save filename and filepath for later
345
+				$this->_caffeinated_extends[ $folder ]['path']       = str_replace(['\\', '/'], '/', $filepath);
346
+				$this->_caffeinated_extends[ $folder ]['admin_page'] = $filename;
347
+			}
348
+		}
349
+		$this->_caffeinated_extends = apply_filters(
350
+			'FHEE__EE_Admin_Page_Loader___get_installed_pages__caffeinated_extends',
351
+			$this->_caffeinated_extends
352
+		);
353
+	}
354
+
355
+
356
+	private function loadCaffeinatedExtensions(
357
+		EE_Admin_Page_Init $admin_page_init,
358
+		string $page,
359
+		string $menu_slug
360
+	): bool {
361
+		if (! isset($this->_caffeinated_extends[ $page ])) {
362
+			return false;
363
+		}
364
+		$admin_page_name = $admin_page_init->get_admin_page_name();
365
+		$caf_path        = $this->_caffeinated_extends[ $page ]['path'];
366
+		$caf_admin_page  = $this->_caffeinated_extends[ $page ]['admin_page'];
367
+		add_filter(
368
+			"FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__{$menu_slug}_$admin_page_name",
369
+			static function ($path_to_file) use ($caf_path) {
370
+				return $caf_path;
371
+			}
372
+		);
373
+		add_filter(
374
+			"FHEE__EE_Admin_Page_Init___initialize_admin_page__admin_page__{$menu_slug}_$admin_page_name",
375
+			static function ($admin_page) use ($caf_admin_page) {
376
+				return $caf_admin_page;
377
+			}
378
+		);
379
+		return true;
380
+	}
381
+
382
+
383
+	/**
384
+	 * @throws EE_Error
385
+	 * @since   $VID:$
386
+	 */
387
+	private function findAdminPageHooks()
388
+	{
389
+		// let's see if there are any HOOK files and instantiate them if there are (so that hooks are loaded early!).
390
+		$ee_admin_hooks   = [];
391
+		$admin_page_hooks = $this->findAdminPageFolders(EE_CORE_CAF_ADMIN . 'hooks/*.class.php', [], 0, false);
392
+		if ($admin_page_hooks) {
393
+			foreach ($admin_page_hooks as $hook) {
394
+				if (is_readable($hook)) {
395
+					require_once $hook;
396
+					$classname = str_replace([EE_CORE_CAF_ADMIN . 'hooks/', '.class.php'], '', $hook);
397
+					if (class_exists($classname)) {
398
+						$ee_admin_hooks[] = $this->loader->getShared($classname);
399
+					}
400
+				}
401
+			}
402
+		}
403
+		apply_filters('FHEE__EE_Admin_Page_Loader__set_caffeinated__ee_admin_hooks', $ee_admin_hooks);
404
+	}
405
+
406
+
407
+	/**
408
+	 * _default_header_link
409
+	 * This is just a dummy method to use with header submenu items
410
+	 *
411
+	 * @return bool false
412
+	 */
413
+	public function _default_header_link(): bool
414
+	{
415
+		return false;
416
+	}
417
+
418
+
419
+	/**
420
+	 * @param string $path
421
+	 * @param int    $flags
422
+	 * @param array  $exclude
423
+	 * @param bool   $register_autoloaders
424
+	 * @return array
425
+	 * @throws EE_Error
426
+	 * @since $VID:$
427
+	 */
428
+	private function findAdminPageFolders(
429
+		string $path,
430
+		array $exclude = [],
431
+		int $flags = GLOB_ONLYDIR,
432
+		bool $register_autoloaders = true
433
+	): array {
434
+		$folders = [];
435
+		$subfolders = glob($path, $flags);
436
+		if ($subfolders) {
437
+			foreach ($subfolders as $admin_screen) {
438
+				$admin_screen_name = basename($admin_screen);
439
+				// files and anything in the exclude array need not apply
440
+				if (! in_array($admin_screen_name, $exclude, true)) {
441
+					// these folders represent the different EE admin pages
442
+					$folders[ $admin_screen_name ] = $admin_screen;
443
+					if ($register_autoloaders) {
444
+						// set autoloaders for our admin page classes based on included path information
445
+						EEH_Autoloader::register_autoloaders_for_each_file_in_folder($admin_screen);
446
+					}
447
+				}
448
+			}
449
+		}
450
+		return $folders;
451
+	}
452 452
 }
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -104,13 +104,13 @@  discard block
 block discarded – undo
104 104
      */
105 105
     private function defineCaffeinatedConstants()
106 106
     {
107
-        if (! defined('EE_CORE_CAF_ADMIN')) {
108
-            define('EE_CORE_CAF_ADMIN', EE_PLUGIN_DIR_PATH . 'caffeinated/admin/');
109
-            define('EE_CORE_CAF_ADMIN_URL', EE_PLUGIN_DIR_URL . 'caffeinated/admin/');
110
-            define('EE_CORE_CAF_ADMIN_NEW', EE_CORE_CAF_ADMIN . 'new/');
111
-            define('EE_CORE_CAF_ADMIN_EXTEND', EE_CORE_CAF_ADMIN . 'extend/');
112
-            define('EE_CORE_CAF_ADMIN_EXTEND_URL', EE_CORE_CAF_ADMIN_URL . 'extend/');
113
-            define('EE_CORE_CAF_ADMIN_HOOKS', EE_CORE_CAF_ADMIN . 'hooks/');
107
+        if ( ! defined('EE_CORE_CAF_ADMIN')) {
108
+            define('EE_CORE_CAF_ADMIN', EE_PLUGIN_DIR_PATH.'caffeinated/admin/');
109
+            define('EE_CORE_CAF_ADMIN_URL', EE_PLUGIN_DIR_URL.'caffeinated/admin/');
110
+            define('EE_CORE_CAF_ADMIN_NEW', EE_CORE_CAF_ADMIN.'new/');
111
+            define('EE_CORE_CAF_ADMIN_EXTEND', EE_CORE_CAF_ADMIN.'extend/');
112
+            define('EE_CORE_CAF_ADMIN_EXTEND_URL', EE_CORE_CAF_ADMIN_URL.'extend/');
113
+            define('EE_CORE_CAF_ADMIN_HOOKS', EE_CORE_CAF_ADMIN.'hooks/');
114 114
         }
115 115
     }
116 116
 
@@ -141,24 +141,24 @@  discard block
 block discarded – undo
141 141
         foreach ($admin_pages as $page => $path) {
142 142
             // don't load the page init class IF IT's ALREADY LOADED !!!
143 143
             if (
144
-                isset($this->_installed_pages[ $page ])
145
-                && $this->_installed_pages[ $page ] instanceof EE_Admin_Page_Init
144
+                isset($this->_installed_pages[$page])
145
+                && $this->_installed_pages[$page] instanceof EE_Admin_Page_Init
146 146
             ) {
147 147
                 continue;
148 148
             }
149 149
             // build list of installed pages
150 150
             $admin_page_init = $this->loadAdminPageInit($page);
151
-            $this->_installed_pages[ $page ] = $admin_page_init;
151
+            $this->_installed_pages[$page] = $admin_page_init;
152 152
             $admin_menu = $this->menu_manager->getAdminMenu($admin_page_init);
153 153
             $admin_page_init->setCapability($admin_menu->capability(), $admin_menu->menuSlug());
154 154
             // skip if in full maintenance mode and maintenance_mode_parent is NOT set
155 155
             if ($this->maintenance_mode && ! $admin_menu->maintenanceModeParent()) {
156
-                unset($admin_pages[ $page ]);
156
+                unset($admin_pages[$page]);
157 157
                 continue;
158 158
             }
159 159
             $menu_slug = $admin_menu->menuSlug();
160
-            $this->_menu_slugs[ $menu_slug ] = $page;
161
-            $menu_pages[ $menu_slug ] = $admin_page_init;
160
+            $this->_menu_slugs[$menu_slug] = $page;
161
+            $menu_pages[$menu_slug] = $admin_page_init;
162 162
             // now that we've got the admin_init objects...
163 163
             // lets see if there are any caffeinated pages extending the originals.
164 164
             // If there are then let's hook into the init admin filter and load our extend instead.
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
             $extended_hooks = $admin_page_init->register_hooks(
167 167
                 $this->loadCaffeinatedExtensions($admin_page_init, $page, $menu_slug)
168 168
             );
169
-            $hooks_ref      += $extended_hooks;
169
+            $hooks_ref += $extended_hooks;
170 170
         }
171 171
         // the hooks_ref is all the pages where we have $extended _Hooks files
172 172
         // that will extend a class in a different folder.
@@ -198,12 +198,12 @@  discard block
 block discarded – undo
198 198
     {
199 199
 
200 200
         // grab everything in the  admin core directory
201
-        $admin_page_folders = $this->findAdminPageFolders(EE_ADMIN_PAGES . '*');
201
+        $admin_page_folders = $this->findAdminPageFolders(EE_ADMIN_PAGES.'*');
202 202
         $admin_page_folders = apply_filters(
203 203
             'FHEE__EE_Admin_Page_Loader__findAdminPages__admin_page_folders',
204 204
             $admin_page_folders
205 205
         );
206
-        if (! empty($admin_page_folders)) {
206
+        if ( ! empty($admin_page_folders)) {
207 207
             return $admin_page_folders;
208 208
         }
209 209
         $error_msg = esc_html__(
@@ -230,9 +230,9 @@  discard block
 block discarded – undo
230 230
      */
231 231
     public function get_admin_page_object(string $page_slug = ''): ?EE_Admin_Page
232 232
     {
233
-        return isset($this->_installed_pages[ $page_slug ])
234
-               && $this->_installed_pages[ $page_slug ] instanceof EE_Admin_Page_Init
235
-            ? $this->_installed_pages[ $page_slug ]->loaded_page_object()
233
+        return isset($this->_installed_pages[$page_slug])
234
+               && $this->_installed_pages[$page_slug] instanceof EE_Admin_Page_Init
235
+            ? $this->_installed_pages[$page_slug]->loaded_page_object()
236 236
             : null;
237 237
     }
238 238
 
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
     private function getClassnameForAdminPageInit(string $dir_name = ''): string
247 247
     {
248 248
         $class_name = str_replace('_', ' ', strtolower($dir_name));
249
-        return str_replace(' ', '_', ucwords($class_name)) . '_Admin_Page_Init';
249
+        return str_replace(' ', '_', ucwords($class_name)).'_Admin_Page_Init';
250 250
     }
251 251
 
252 252
 
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
                 'Make sure you have %1$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
285 285
                 'event_espresso'
286 286
             ),
287
-            '<strong>' . $class_name . '</strong>'
287
+            '<strong>'.$class_name.'</strong>'
288 288
         );
289 289
         throw new EE_Error($error_msg);
290 290
     }
@@ -312,12 +312,12 @@  discard block
 block discarded – undo
312 312
     private function findCaffeinatedAdminPages(array $admin_pages): array
313 313
     {
314 314
         // first let's check if there IS a caffeinated folder. If there is not then lets get out.
315
-        if ((defined('EE_DECAF') && EE_DECAF) || ! is_dir(EE_PLUGIN_DIR_PATH . 'caffeinated/admin')) {
315
+        if ((defined('EE_DECAF') && EE_DECAF) || ! is_dir(EE_PLUGIN_DIR_PATH.'caffeinated/admin')) {
316 316
             return $admin_pages;
317 317
         }
318 318
         $this->defineCaffeinatedConstants();
319 319
         // okay let's setup an "New" pages first (we'll return installed refs later)
320
-        $admin_pages += $this->findAdminPageFolders(EE_CORE_CAF_ADMIN . 'new/*', ['tickets']);
320
+        $admin_pages += $this->findAdminPageFolders(EE_CORE_CAF_ADMIN.'new/*', ['tickets']);
321 321
 
322 322
         return apply_filters(
323 323
             'FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs',
@@ -334,16 +334,16 @@  discard block
 block discarded – undo
334 334
     {
335 335
         // let's see if there are any EXTENDS to setup in the $_caffeinated_extends array
336 336
         // (that will be used later for hooking into the _initialize_admin_age in the related core_init admin page)
337
-        $extensions = $this->findAdminPageFolders(EE_CORE_CAF_ADMIN . 'extend/*');
337
+        $extensions = $this->findAdminPageFolders(EE_CORE_CAF_ADMIN.'extend/*');
338 338
         if ($extensions) {
339 339
             foreach ($extensions as $folder => $extension) {
340 340
                 // convert lowercase_snake_case to Uppercase_Snake_Case
341 341
                 $filename = str_replace(' ', '_', ucwords(str_replace('_', ' ', $folder)));
342 342
                 $filename = "Extend_{$filename}_Admin_Page";
343
-                $filepath = EE_CORE_CAF_ADMIN . "extend/$folder/$filename.core.php";
343
+                $filepath = EE_CORE_CAF_ADMIN."extend/$folder/$filename.core.php";
344 344
                 // save filename and filepath for later
345
-                $this->_caffeinated_extends[ $folder ]['path']       = str_replace(['\\', '/'], '/', $filepath);
346
-                $this->_caffeinated_extends[ $folder ]['admin_page'] = $filename;
345
+                $this->_caffeinated_extends[$folder]['path']       = str_replace(['\\', '/'], '/', $filepath);
346
+                $this->_caffeinated_extends[$folder]['admin_page'] = $filename;
347 347
             }
348 348
         }
349 349
         $this->_caffeinated_extends = apply_filters(
@@ -358,21 +358,21 @@  discard block
 block discarded – undo
358 358
         string $page,
359 359
         string $menu_slug
360 360
     ): bool {
361
-        if (! isset($this->_caffeinated_extends[ $page ])) {
361
+        if ( ! isset($this->_caffeinated_extends[$page])) {
362 362
             return false;
363 363
         }
364 364
         $admin_page_name = $admin_page_init->get_admin_page_name();
365
-        $caf_path        = $this->_caffeinated_extends[ $page ]['path'];
366
-        $caf_admin_page  = $this->_caffeinated_extends[ $page ]['admin_page'];
365
+        $caf_path        = $this->_caffeinated_extends[$page]['path'];
366
+        $caf_admin_page  = $this->_caffeinated_extends[$page]['admin_page'];
367 367
         add_filter(
368 368
             "FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__{$menu_slug}_$admin_page_name",
369
-            static function ($path_to_file) use ($caf_path) {
369
+            static function($path_to_file) use ($caf_path) {
370 370
                 return $caf_path;
371 371
             }
372 372
         );
373 373
         add_filter(
374 374
             "FHEE__EE_Admin_Page_Init___initialize_admin_page__admin_page__{$menu_slug}_$admin_page_name",
375
-            static function ($admin_page) use ($caf_admin_page) {
375
+            static function($admin_page) use ($caf_admin_page) {
376 376
                 return $caf_admin_page;
377 377
             }
378 378
         );
@@ -388,12 +388,12 @@  discard block
 block discarded – undo
388 388
     {
389 389
         // let's see if there are any HOOK files and instantiate them if there are (so that hooks are loaded early!).
390 390
         $ee_admin_hooks   = [];
391
-        $admin_page_hooks = $this->findAdminPageFolders(EE_CORE_CAF_ADMIN . 'hooks/*.class.php', [], 0, false);
391
+        $admin_page_hooks = $this->findAdminPageFolders(EE_CORE_CAF_ADMIN.'hooks/*.class.php', [], 0, false);
392 392
         if ($admin_page_hooks) {
393 393
             foreach ($admin_page_hooks as $hook) {
394 394
                 if (is_readable($hook)) {
395 395
                     require_once $hook;
396
-                    $classname = str_replace([EE_CORE_CAF_ADMIN . 'hooks/', '.class.php'], '', $hook);
396
+                    $classname = str_replace([EE_CORE_CAF_ADMIN.'hooks/', '.class.php'], '', $hook);
397 397
                     if (class_exists($classname)) {
398 398
                         $ee_admin_hooks[] = $this->loader->getShared($classname);
399 399
                     }
@@ -437,9 +437,9 @@  discard block
 block discarded – undo
437 437
             foreach ($subfolders as $admin_screen) {
438 438
                 $admin_screen_name = basename($admin_screen);
439 439
                 // files and anything in the exclude array need not apply
440
-                if (! in_array($admin_screen_name, $exclude, true)) {
440
+                if ( ! in_array($admin_screen_name, $exclude, true)) {
441 441
                     // these folders represent the different EE admin pages
442
-                    $folders[ $admin_screen_name ] = $admin_screen;
442
+                    $folders[$admin_screen_name] = $admin_screen;
443 443
                     if ($register_autoloaders) {
444 444
                         // set autoloaders for our admin page classes based on included path information
445 445
                         EEH_Autoloader::register_autoloaders_for_each_file_in_folder($admin_screen);
Please login to merge, or discard this patch.
core/libraries/iframe_display/IframeEmbedButton.php 1 patch
Indentation   +241 added lines, -241 removed lines patch added patch discarded remove patch
@@ -16,271 +16,271 @@
 block discarded – undo
16 16
  */
17 17
 abstract class IframeEmbedButton
18 18
 {
19
-    /**
20
-     * @var string $iframe_name
21
-     */
22
-    private $iframe_name;
19
+	/**
20
+	 * @var string $iframe_name
21
+	 */
22
+	private $iframe_name;
23 23
 
24
-    /**
25
-     * @var string $route_name
26
-     */
27
-    private $route_name;
24
+	/**
25
+	 * @var string $route_name
26
+	 */
27
+	private $route_name;
28 28
 
29
-    /**
30
-     * @var string $slug
31
-     */
32
-    private $slug;
29
+	/**
30
+	 * @var string $slug
31
+	 */
32
+	private $slug;
33 33
 
34
-    /**
35
-     * @var boolean $append_filterable_content
36
-     */
37
-    private $append_filterable_content;
34
+	/**
35
+	 * @var boolean $append_filterable_content
36
+	 */
37
+	private $append_filterable_content;
38 38
 
39 39
 
40
-    /**
41
-     * IframeEmbedButton constructor.
42
-     *
43
-     * @param string $iframe_name i18n name for the iframe. This will be used in HTML
44
-     * @param string $route_name  the name of the registered route
45
-     * @param string $slug        URL slug used for the thing the iframe button is being embedded in.
46
-     *                            will most likely be "event" since that's the only usage atm
47
-     */
48
-    public function __construct($iframe_name, $route_name, $slug = 'event')
49
-    {
50
-        $this->iframe_name = $iframe_name;
51
-        $this->route_name = $route_name;
52
-        $this->slug = $slug;
53
-    }
40
+	/**
41
+	 * IframeEmbedButton constructor.
42
+	 *
43
+	 * @param string $iframe_name i18n name for the iframe. This will be used in HTML
44
+	 * @param string $route_name  the name of the registered route
45
+	 * @param string $slug        URL slug used for the thing the iframe button is being embedded in.
46
+	 *                            will most likely be "event" since that's the only usage atm
47
+	 */
48
+	public function __construct($iframe_name, $route_name, $slug = 'event')
49
+	{
50
+		$this->iframe_name = $iframe_name;
51
+		$this->route_name = $route_name;
52
+		$this->slug = $slug;
53
+	}
54 54
 
55 55
 
56
-    /**
57
-     * Adds an iframe embed code button to the Event editor.
58
-     */
59
-    public function addEventEditorIframeEmbedButtonFilter()
60
-    {
61
-        // add button for iframe code to event editor.
62
-        add_filter(
63
-            'get_sample_permalink_html',
64
-            array($this, 'appendIframeEmbedButtonToSamplePermalinkHtml'),
65
-            10,
66
-            2
67
-        );
68
-        add_action(
69
-            'admin_enqueue_scripts',
70
-            array($this, 'embedButtonAssets'),
71
-            10
72
-        );
73
-    }
56
+	/**
57
+	 * Adds an iframe embed code button to the Event editor.
58
+	 */
59
+	public function addEventEditorIframeEmbedButtonFilter()
60
+	{
61
+		// add button for iframe code to event editor.
62
+		add_filter(
63
+			'get_sample_permalink_html',
64
+			array($this, 'appendIframeEmbedButtonToSamplePermalinkHtml'),
65
+			10,
66
+			2
67
+		);
68
+		add_action(
69
+			'admin_enqueue_scripts',
70
+			array($this, 'embedButtonAssets'),
71
+			10
72
+		);
73
+	}
74 74
 
75 75
 
76
-    /**
77
-     * @param $permalink_string
78
-     * @param $id
79
-     * @return string
80
-     */
81
-    public function appendIframeEmbedButtonToSamplePermalinkHtml($permalink_string, $id)
82
-    {
83
-        return $this->eventEditorIframeEmbedButton(
84
-            $permalink_string,
85
-            $id
86
-        );
87
-    }
76
+	/**
77
+	 * @param $permalink_string
78
+	 * @param $id
79
+	 * @return string
80
+	 */
81
+	public function appendIframeEmbedButtonToSamplePermalinkHtml($permalink_string, $id)
82
+	{
83
+		return $this->eventEditorIframeEmbedButton(
84
+			$permalink_string,
85
+			$id
86
+		);
87
+	}
88 88
 
89 89
 
90
-    /**
91
-     * iframe embed code button to the Event editor.
92
-     *
93
-     * @param string $permalink_string
94
-     * @param int    $id
95
-     * @return string
96
-     */
97
-    public function eventEditorIframeEmbedButton(
98
-        $permalink_string,
99
-        $id
100
-    ) {
101
-        // make sure this is ONLY when editing and the event id has been set.
102
-        if (! empty($id)) {
103
-            $post = get_post($id);
104
-            // if NOT event then let's get out.
105
-            if ($post->post_type !== 'espresso_events') {
106
-                return $permalink_string;
107
-            }
108
-            $permalink_string .= $this->embedButtonHtml([$this->slug => $id]);
109
-        }
110
-        return $permalink_string;
111
-    }
90
+	/**
91
+	 * iframe embed code button to the Event editor.
92
+	 *
93
+	 * @param string $permalink_string
94
+	 * @param int    $id
95
+	 * @return string
96
+	 */
97
+	public function eventEditorIframeEmbedButton(
98
+		$permalink_string,
99
+		$id
100
+	) {
101
+		// make sure this is ONLY when editing and the event id has been set.
102
+		if (! empty($id)) {
103
+			$post = get_post($id);
104
+			// if NOT event then let's get out.
105
+			if ($post->post_type !== 'espresso_events') {
106
+				return $permalink_string;
107
+			}
108
+			$permalink_string .= $this->embedButtonHtml([$this->slug => $id]);
109
+		}
110
+		return $permalink_string;
111
+	}
112 112
 
113 113
 
114
-    /**
115
-     * Adds an iframe embed code button via a WP do_action() as determined by the first parameter
116
-     *
117
-     * @param string $action name of the WP do_action() to hook into
118
-     */
119
-    public function addActionIframeEmbedButton($action)
120
-    {
121
-        // add button for iframe code to event editor.
122
-        add_action(
123
-            $action,
124
-            array($this, 'addActionIframeEmbedButtonCallback'),
125
-            10,
126
-            2
127
-        );
128
-    }
114
+	/**
115
+	 * Adds an iframe embed code button via a WP do_action() as determined by the first parameter
116
+	 *
117
+	 * @param string $action name of the WP do_action() to hook into
118
+	 */
119
+	public function addActionIframeEmbedButton($action)
120
+	{
121
+		// add button for iframe code to event editor.
122
+		add_action(
123
+			$action,
124
+			array($this, 'addActionIframeEmbedButtonCallback'),
125
+			10,
126
+			2
127
+		);
128
+	}
129 129
 
130 130
 
131
-    /**
132
-     * @return void
133
-     */
134
-    public function addActionIframeEmbedButtonCallback()
135
-    {
136
-        echo wp_kses($this->embedButtonHtml(), AllowedTags::getWithFormTags());
137
-    }
131
+	/**
132
+	 * @return void
133
+	 */
134
+	public function addActionIframeEmbedButtonCallback()
135
+	{
136
+		echo wp_kses($this->embedButtonHtml(), AllowedTags::getWithFormTags());
137
+	}
138 138
 
139 139
 
140
-    /**
141
-     * Adds an iframe embed code button via a WP apply_filters() as determined by the first parameter
142
-     *
143
-     * @param string $filter     name of the WP apply_filters() to hook into
144
-     * @param bool   $append     if true, will add iframe embed button to end of content,
145
-     *                           else if false, will add to the beginning of the content
146
-     */
147
-    public function addFilterIframeEmbedButton($filter, $append = true)
148
-    {
149
-        $this->append_filterable_content = $append;
150
-        // add button for iframe code to event editor.
151
-        add_filter(
152
-            $filter,
153
-            array($this, 'addFilterIframeEmbedButtonCallback'),
154
-            10
155
-        );
156
-    }
140
+	/**
141
+	 * Adds an iframe embed code button via a WP apply_filters() as determined by the first parameter
142
+	 *
143
+	 * @param string $filter     name of the WP apply_filters() to hook into
144
+	 * @param bool   $append     if true, will add iframe embed button to end of content,
145
+	 *                           else if false, will add to the beginning of the content
146
+	 */
147
+	public function addFilterIframeEmbedButton($filter, $append = true)
148
+	{
149
+		$this->append_filterable_content = $append;
150
+		// add button for iframe code to event editor.
151
+		add_filter(
152
+			$filter,
153
+			array($this, 'addFilterIframeEmbedButtonCallback'),
154
+			10
155
+		);
156
+	}
157 157
 
158 158
 
159
-    /**
160
-     * @param array|string $filterable_content
161
-     * @return array|string
162
-     */
163
-    public function addFilterIframeEmbedButtonCallback($filterable_content)
164
-    {
165
-        $embedButtonHtml = $this->embedButtonHtml();
166
-        if (is_array($filterable_content)) {
167
-            $filterable_content = $this->append_filterable_content
168
-                ? $filterable_content + array($this->route_name => $embedButtonHtml)
169
-                : array($this->route_name => $embedButtonHtml) + $filterable_content;
170
-        } else {
171
-            $filterable_content = $this->append_filterable_content
172
-                ? $filterable_content . $embedButtonHtml
173
-                : $embedButtonHtml . $filterable_content;
174
-        }
175
-        return $filterable_content;
176
-    }
159
+	/**
160
+	 * @param array|string $filterable_content
161
+	 * @return array|string
162
+	 */
163
+	public function addFilterIframeEmbedButtonCallback($filterable_content)
164
+	{
165
+		$embedButtonHtml = $this->embedButtonHtml();
166
+		if (is_array($filterable_content)) {
167
+			$filterable_content = $this->append_filterable_content
168
+				? $filterable_content + array($this->route_name => $embedButtonHtml)
169
+				: array($this->route_name => $embedButtonHtml) + $filterable_content;
170
+		} else {
171
+			$filterable_content = $this->append_filterable_content
172
+				? $filterable_content . $embedButtonHtml
173
+				: $embedButtonHtml . $filterable_content;
174
+		}
175
+		return $filterable_content;
176
+	}
177 177
 
178 178
 
179
-    /**
180
-     * iframe_embed_html
181
-     *
182
-     * @param array  $query_args
183
-     * @param string $button_class
184
-     * @return string
185
-     */
186
-    public function embedButtonHtml($query_args = array(), $button_class = '')
187
-    {
188
-        // incoming args will replace the defaults listed here in the second array (union preserves first array)
189
-        $query_args = (array) $query_args + array($this->route_name => 'iframe');
190
-        $query_args = (array) apply_filters(
191
-            'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__embedButtonHtml__query_args',
192
-            $query_args
193
-        );
194
-        // add this route to our localized vars
195
-        $iframe_module_routes                      = EE_Registry::$i18n_js_strings['iframe_module_routes'] ?? [];
196
-        $iframe_module_routes[ $this->route_name ] = $this->route_name;
197
-        EE_Registry::$i18n_js_strings['iframe_module_routes'] = $iframe_module_routes;
198
-        $route_name = esc_attr($this->route_name);
199
-        $iframe_url = esc_url_raw(add_query_arg($query_args, site_url()));
179
+	/**
180
+	 * iframe_embed_html
181
+	 *
182
+	 * @param array  $query_args
183
+	 * @param string $button_class
184
+	 * @return string
185
+	 */
186
+	public function embedButtonHtml($query_args = array(), $button_class = '')
187
+	{
188
+		// incoming args will replace the defaults listed here in the second array (union preserves first array)
189
+		$query_args = (array) $query_args + array($this->route_name => 'iframe');
190
+		$query_args = (array) apply_filters(
191
+			'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__embedButtonHtml__query_args',
192
+			$query_args
193
+		);
194
+		// add this route to our localized vars
195
+		$iframe_module_routes                      = EE_Registry::$i18n_js_strings['iframe_module_routes'] ?? [];
196
+		$iframe_module_routes[ $this->route_name ] = $this->route_name;
197
+		EE_Registry::$i18n_js_strings['iframe_module_routes'] = $iframe_module_routes;
198
+		$route_name = esc_attr($this->route_name);
199
+		$iframe_url = esc_url_raw(add_query_arg($query_args, site_url()));
200 200
 
201
-        return EEH_HTML::div(
202
-            EEH_HTML::link(
203
-                '#',
204
-                sprintf(esc_html__('Embed %1$s', 'event_espresso'), $this->iframe_name),
205
-                sprintf(
206
-                    esc_html__(
207
-                        'click here to generate code for embedding %1$s iframe into another site.',
208
-                        'event_espresso'
209
-                    ),
210
-                    EEH_Inflector::add_indefinite_article($this->iframe_name)
211
-                ),
212
-                $route_name . '-iframe-embed-trigger-js',
213
-                'iframe-embed-trigger-js button button--small button--secondary ' . esc_attr($button_class),
214
-                '',
215
-                ' data-iframe_embed_button="#' . $route_name . '-iframe-js" tabindex="-1"'
216
-            ),
217
-            '',
218
-            'ee-admin-button-row ee-admin-button-row--align-start'
219
-        )
220
-        . EEH_HTML::div(
221
-            EEH_HTML::div(
222
-                '<iframe src="' . $iframe_url . '" width="100%" height="100%"></iframe>',
223
-                '',
224
-                '',
225
-                'width:100%; height: 500px;'
226
-            ),
227
-            $route_name . '-iframe-js',
228
-            'iframe-embed-wrapper-js',
229
-            'display:none;'
230
-        );
231
-    }
201
+		return EEH_HTML::div(
202
+			EEH_HTML::link(
203
+				'#',
204
+				sprintf(esc_html__('Embed %1$s', 'event_espresso'), $this->iframe_name),
205
+				sprintf(
206
+					esc_html__(
207
+						'click here to generate code for embedding %1$s iframe into another site.',
208
+						'event_espresso'
209
+					),
210
+					EEH_Inflector::add_indefinite_article($this->iframe_name)
211
+				),
212
+				$route_name . '-iframe-embed-trigger-js',
213
+				'iframe-embed-trigger-js button button--small button--secondary ' . esc_attr($button_class),
214
+				'',
215
+				' data-iframe_embed_button="#' . $route_name . '-iframe-js" tabindex="-1"'
216
+			),
217
+			'',
218
+			'ee-admin-button-row ee-admin-button-row--align-start'
219
+		)
220
+		. EEH_HTML::div(
221
+			EEH_HTML::div(
222
+				'<iframe src="' . $iframe_url . '" width="100%" height="100%"></iframe>',
223
+				'',
224
+				'',
225
+				'width:100%; height: 500px;'
226
+			),
227
+			$route_name . '-iframe-js',
228
+			'iframe-embed-wrapper-js',
229
+			'display:none;'
230
+		);
231
+	}
232 232
 
233 233
 
234
-    /**
235
-     * enqueue iframe button js
236
-     */
237
-    public function embedButtonAssets()
238
-    {
239
-        EE_Registry::$i18n_js_strings['iframe_embed_title'] = esc_html__(
240
-            'copy and paste the following into any other site\'s content to display this event:',
241
-            'event_espresso'
242
-        );
243
-        EE_Registry::$i18n_js_strings['iframe_embed_close_msg'] = esc_html__(
244
-            'click anywhere outside of this window to close it.',
245
-            'event_espresso'
246
-        );
247
-        wp_register_script(
248
-            'iframe_embed_button',
249
-            plugin_dir_url(__FILE__) . 'iframe-embed-button.js',
250
-            array('ee-dialog'),
251
-            EVENT_ESPRESSO_VERSION,
252
-            true
253
-        );
254
-        wp_enqueue_script('iframe_embed_button');
255
-    }
234
+	/**
235
+	 * enqueue iframe button js
236
+	 */
237
+	public function embedButtonAssets()
238
+	{
239
+		EE_Registry::$i18n_js_strings['iframe_embed_title'] = esc_html__(
240
+			'copy and paste the following into any other site\'s content to display this event:',
241
+			'event_espresso'
242
+		);
243
+		EE_Registry::$i18n_js_strings['iframe_embed_close_msg'] = esc_html__(
244
+			'click anywhere outside of this window to close it.',
245
+			'event_espresso'
246
+		);
247
+		wp_register_script(
248
+			'iframe_embed_button',
249
+			plugin_dir_url(__FILE__) . 'iframe-embed-button.js',
250
+			array('ee-dialog'),
251
+			EVENT_ESPRESSO_VERSION,
252
+			true
253
+		);
254
+		wp_enqueue_script('iframe_embed_button');
255
+	}
256 256
 
257 257
 
258
-    /**
259
-     * generates embed button sections for admin pages
260
-     *
261
-     * @param array $embed_buttons
262
-     * @return string
263
-     */
264
-    public function addIframeEmbedButtonsSection(array $embed_buttons)
265
-    {
266
-        $embed_buttons = (array) apply_filters(
267
-            'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__addIframeEmbedButtonsSection__embed_buttons',
268
-            $embed_buttons
269
-        );
270
-        if (empty($embed_buttons)) {
271
-            return '';
272
-        }
273
-        // add button for iframe code to event editor.
274
-        $html = EEH_HTML::div('', '', 'ee-admin-section ee-iframe-embed-buttons');
275
-        $html .= EEH_HTML::h3(esc_html__('iFrame Embed Code', 'event_espresso'));
276
-        $html .= EEH_HTML::p(
277
-            esc_html__(
278
-                'Click the following button(s) to generate iframe HTML that will allow you to embed your event content within the content of other websites.',
279
-                'event_espresso'
280
-            )
281
-        );
282
-        $html .= ' &nbsp; ' . implode(' &nbsp; ', $embed_buttons) . ' ';
283
-        $html .= EEH_HTML::divx();
284
-        return $html;
285
-    }
258
+	/**
259
+	 * generates embed button sections for admin pages
260
+	 *
261
+	 * @param array $embed_buttons
262
+	 * @return string
263
+	 */
264
+	public function addIframeEmbedButtonsSection(array $embed_buttons)
265
+	{
266
+		$embed_buttons = (array) apply_filters(
267
+			'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__addIframeEmbedButtonsSection__embed_buttons',
268
+			$embed_buttons
269
+		);
270
+		if (empty($embed_buttons)) {
271
+			return '';
272
+		}
273
+		// add button for iframe code to event editor.
274
+		$html = EEH_HTML::div('', '', 'ee-admin-section ee-iframe-embed-buttons');
275
+		$html .= EEH_HTML::h3(esc_html__('iFrame Embed Code', 'event_espresso'));
276
+		$html .= EEH_HTML::p(
277
+			esc_html__(
278
+				'Click the following button(s) to generate iframe HTML that will allow you to embed your event content within the content of other websites.',
279
+				'event_espresso'
280
+			)
281
+		);
282
+		$html .= ' &nbsp; ' . implode(' &nbsp; ', $embed_buttons) . ' ';
283
+		$html .= EEH_HTML::divx();
284
+		return $html;
285
+	}
286 286
 }
Please login to merge, or discard this patch.