Completed
Branch GDPR/deactivate-payment-loggin... (ba9bd0)
by
unknown
65:41 queued 52:27
created
acceptance_tests/Page/Checkout.php 1 patch
Indentation   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -13,71 +13,71 @@
 block discarded – undo
13 13
 class Checkout
14 14
 {
15 15
 
16
-    /**
17
-     * The class selector for the next step button in the checkout.
18
-     * @var string
19
-     */
20
-    const NEXT_STEP_BUTTON_SELECTOR = '.spco-next-step-btn';
21
-
22
-
23
-    const PAYMENT_METHOD_STEP_FORM = '#ee-spco-payment_options-reg-step-form';
24
-
25
-
26
-    const SELECTOR_PAYMENT_OPTIONS_CONTAINER = '#spco-available-methods-of-payment-dv';
27
-
28
-
29
-    /**
30
-     * @param int $attendee_number
31
-     * @param bool  $admin  Used to indicate whether we're retrieving the selector from the context of the admin or not.
32
-     * @return string
33
-     */
34
-    public static function firstNameFieldSelectorForAttendeeNumber($attendee_number = 1, $admin = false)
35
-    {
36
-        return self::fieldSelectorForAttendeeNumber('fname', $attendee_number, $admin);
37
-    }
38
-
39
-
40
-    /**
41
-     * @param int $attendee_number
42
-     * @param bool  $admin  Used to indicate whether we're retrieving the selector from the context of the admin or not.
43
-     * @return string
44
-     */
45
-    public static function lastNameFieldSelectorForAttendeeNumber($attendee_number = 1, $admin = false)
46
-    {
47
-        return self::fieldSelectorForAttendeeNumber('lname', $attendee_number, $admin);
48
-    }
49
-
50
-
51
-    /**
52
-     * @param int $attendee_number
53
-     * @param bool  $admin  Used to indicate whether we're retrieving the selector from the context of the admin or not.
54
-     * @return string
55
-     */
56
-    public static function emailFieldSelectorForAttendeeNumber($attendee_number = 1, $admin = false)
57
-    {
58
-        return self::fieldSelectorForAttendeeNumber('email', $attendee_number, $admin);
59
-    }
60
-
61
-    /**
62
-     * @param string    $field_name
63
-     * @param int $attendee_number
64
-     * @param bool  $admin  Used to indicate whether we're retrieving the selector from the context of the admin or not.
65
-     * @return string
66
-     */
67
-    public static function fieldSelectorForAttendeeNumber($field_name, $attendee_number = 1, $admin = false)
68
-    {
69
-        return $admin
70
-                ? "//fieldset[starts-with(@id, 'ee-registration-$attendee_number')]//input[contains(@class, 'ee-reg-qstn-$field_name')]"
71
-                : "//div[starts-with(@id, 'spco-attendee-panel-dv-$attendee_number')]//input[contains(@class, 'ee-reg-qstn-$field_name')]";
72
-    }
73
-
74
-
75
-    /**
76
-     * @param string $payment_method_slug Slug for the payment method.
77
-     * @return string
78
-     */
79
-    public static function fieldSelectorForPaymentOption($payment_method_slug)
80
-    {
81
-        return "#ee-available-payment-method-inputs-{$payment_method_slug}";
82
-    }
16
+	/**
17
+	 * The class selector for the next step button in the checkout.
18
+	 * @var string
19
+	 */
20
+	const NEXT_STEP_BUTTON_SELECTOR = '.spco-next-step-btn';
21
+
22
+
23
+	const PAYMENT_METHOD_STEP_FORM = '#ee-spco-payment_options-reg-step-form';
24
+
25
+
26
+	const SELECTOR_PAYMENT_OPTIONS_CONTAINER = '#spco-available-methods-of-payment-dv';
27
+
28
+
29
+	/**
30
+	 * @param int $attendee_number
31
+	 * @param bool  $admin  Used to indicate whether we're retrieving the selector from the context of the admin or not.
32
+	 * @return string
33
+	 */
34
+	public static function firstNameFieldSelectorForAttendeeNumber($attendee_number = 1, $admin = false)
35
+	{
36
+		return self::fieldSelectorForAttendeeNumber('fname', $attendee_number, $admin);
37
+	}
38
+
39
+
40
+	/**
41
+	 * @param int $attendee_number
42
+	 * @param bool  $admin  Used to indicate whether we're retrieving the selector from the context of the admin or not.
43
+	 * @return string
44
+	 */
45
+	public static function lastNameFieldSelectorForAttendeeNumber($attendee_number = 1, $admin = false)
46
+	{
47
+		return self::fieldSelectorForAttendeeNumber('lname', $attendee_number, $admin);
48
+	}
49
+
50
+
51
+	/**
52
+	 * @param int $attendee_number
53
+	 * @param bool  $admin  Used to indicate whether we're retrieving the selector from the context of the admin or not.
54
+	 * @return string
55
+	 */
56
+	public static function emailFieldSelectorForAttendeeNumber($attendee_number = 1, $admin = false)
57
+	{
58
+		return self::fieldSelectorForAttendeeNumber('email', $attendee_number, $admin);
59
+	}
60
+
61
+	/**
62
+	 * @param string    $field_name
63
+	 * @param int $attendee_number
64
+	 * @param bool  $admin  Used to indicate whether we're retrieving the selector from the context of the admin or not.
65
+	 * @return string
66
+	 */
67
+	public static function fieldSelectorForAttendeeNumber($field_name, $attendee_number = 1, $admin = false)
68
+	{
69
+		return $admin
70
+				? "//fieldset[starts-with(@id, 'ee-registration-$attendee_number')]//input[contains(@class, 'ee-reg-qstn-$field_name')]"
71
+				: "//div[starts-with(@id, 'spco-attendee-panel-dv-$attendee_number')]//input[contains(@class, 'ee-reg-qstn-$field_name')]";
72
+	}
73
+
74
+
75
+	/**
76
+	 * @param string $payment_method_slug Slug for the payment method.
77
+	 * @return string
78
+	 */
79
+	public static function fieldSelectorForPaymentOption($payment_method_slug)
80
+	{
81
+		return "#ee-available-payment-method-inputs-{$payment_method_slug}";
82
+	}
83 83
 }
Please login to merge, or discard this patch.
admin_pages/transactions/Transactions_Admin_Page.core.php 3 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -2166,6 +2166,7 @@
 block discarded – undo
2166 2166
      *
2167 2167
      * @access protected
2168 2168
      * @param \EE_Payment | null $payment
2169
+     * @param EE_Payment $payment
2169 2170
      */
2170 2171
     protected function _maybe_send_notifications($payment = null)
2171 2172
     {
Please login to merge, or discard this patch.
Indentation   +2456 added lines, -2456 removed lines patch added patch discarded remove patch
@@ -14,2460 +14,2460 @@
 block discarded – undo
14 14
 class Transactions_Admin_Page extends EE_Admin_Page
15 15
 {
16 16
 
17
-    /**
18
-     * @var EE_Transaction
19
-     */
20
-    private $_transaction;
21
-
22
-    /**
23
-     * @var EE_Session
24
-     */
25
-    private $_session;
26
-
27
-    /**
28
-     * @var array $_txn_status
29
-     */
30
-    private static $_txn_status;
31
-
32
-    /**
33
-     * @var array $_pay_status
34
-     */
35
-    private static $_pay_status;
36
-
37
-    /**
38
-     * @var array $_existing_reg_payment_REG_IDs
39
-     */
40
-    protected $_existing_reg_payment_REG_IDs = null;
41
-
42
-
43
-    /**
44
-     * @Constructor
45
-     * @access public
46
-     * @param bool $routing
47
-     * @throws EE_Error
48
-     * @throws InvalidArgumentException
49
-     * @throws ReflectionException
50
-     * @throws InvalidDataTypeException
51
-     * @throws InvalidInterfaceException
52
-     */
53
-    public function __construct($routing = true)
54
-    {
55
-        parent::__construct($routing);
56
-    }
57
-
58
-
59
-    /**
60
-     *    _init_page_props
61
-     *
62
-     * @return void
63
-     */
64
-    protected function _init_page_props()
65
-    {
66
-        $this->page_slug = TXN_PG_SLUG;
67
-        $this->page_label = esc_html__('Transactions', 'event_espresso');
68
-        $this->_admin_base_url = TXN_ADMIN_URL;
69
-        $this->_admin_base_path = TXN_ADMIN;
70
-    }
71
-
72
-
73
-    /**
74
-     *    _ajax_hooks
75
-     *
76
-     * @return void
77
-     */
78
-    protected function _ajax_hooks()
79
-    {
80
-        add_action('wp_ajax_espresso_apply_payment', array($this, 'apply_payments_or_refunds'));
81
-        add_action('wp_ajax_espresso_apply_refund', array($this, 'apply_payments_or_refunds'));
82
-        add_action('wp_ajax_espresso_delete_payment', array($this, 'delete_payment'));
83
-    }
84
-
85
-
86
-    /**
87
-     *    _define_page_props
88
-     *
89
-     * @return void
90
-     */
91
-    protected function _define_page_props()
92
-    {
93
-        $this->_admin_page_title = $this->page_label;
94
-        $this->_labels = array(
95
-            'buttons' => array(
96
-                'add'    => esc_html__('Add New Transaction', 'event_espresso'),
97
-                'edit'   => esc_html__('Edit Transaction', 'event_espresso'),
98
-                'delete' => esc_html__('Delete Transaction', 'event_espresso'),
99
-            ),
100
-        );
101
-    }
102
-
103
-
104
-    /**
105
-     *        grab url requests and route them
106
-     *
107
-     * @access private
108
-     * @return void
109
-     * @throws EE_Error
110
-     * @throws InvalidArgumentException
111
-     * @throws InvalidDataTypeException
112
-     * @throws InvalidInterfaceException
113
-     */
114
-    public function _set_page_routes()
115
-    {
116
-
117
-        $this->_set_transaction_status_array();
118
-
119
-        $txn_id = ! empty($this->_req_data['TXN_ID'])
120
-                  && ! is_array($this->_req_data['TXN_ID'])
121
-            ? $this->_req_data['TXN_ID']
122
-            : 0;
123
-
124
-        $this->_page_routes = array(
125
-
126
-            'default' => array(
127
-                'func'       => '_transactions_overview_list_table',
128
-                'capability' => 'ee_read_transactions',
129
-            ),
130
-
131
-            'view_transaction' => array(
132
-                'func'       => '_transaction_details',
133
-                'capability' => 'ee_read_transaction',
134
-                'obj_id'     => $txn_id,
135
-            ),
136
-
137
-            'send_payment_reminder' => array(
138
-                'func'       => '_send_payment_reminder',
139
-                'noheader'   => true,
140
-                'capability' => 'ee_send_message',
141
-            ),
142
-
143
-            'espresso_apply_payment' => array(
144
-                'func'       => 'apply_payments_or_refunds',
145
-                'noheader'   => true,
146
-                'capability' => 'ee_edit_payments',
147
-            ),
148
-
149
-            'espresso_apply_refund' => array(
150
-                'func'       => 'apply_payments_or_refunds',
151
-                'noheader'   => true,
152
-                'capability' => 'ee_edit_payments',
153
-            ),
154
-
155
-            'espresso_delete_payment' => array(
156
-                'func'       => 'delete_payment',
157
-                'noheader'   => true,
158
-                'capability' => 'ee_delete_payments',
159
-            ),
160
-
161
-        );
162
-    }
163
-
164
-
165
-    protected function _set_page_config()
166
-    {
167
-        $this->_page_config = array(
168
-            'default'          => array(
169
-                'nav'           => array(
170
-                    'label' => esc_html__('Overview', 'event_espresso'),
171
-                    'order' => 10,
172
-                ),
173
-                'list_table'    => 'EE_Admin_Transactions_List_Table',
174
-                'help_tabs'     => array(
175
-                    'transactions_overview_help_tab'                       => array(
176
-                        'title'    => esc_html__('Transactions Overview', 'event_espresso'),
177
-                        'filename' => 'transactions_overview',
178
-                    ),
179
-                    'transactions_overview_table_column_headings_help_tab' => array(
180
-                        'title'    => esc_html__('Transactions Table Column Headings', 'event_espresso'),
181
-                        'filename' => 'transactions_overview_table_column_headings',
182
-                    ),
183
-                    'transactions_overview_views_filters_help_tab'         => array(
184
-                        'title'    => esc_html__('Transaction Views & Filters & Search', 'event_espresso'),
185
-                        'filename' => 'transactions_overview_views_filters_search',
186
-                    ),
187
-                ),
188
-                'help_tour'     => array('Transactions_Overview_Help_Tour'),
189
-                /**
190
-                 * commented out because currently we are not displaying tips for transaction list table status but this
191
-                 * may change in a later iteration so want to keep the code for then.
192
-                 */
193
-                // 'qtips' => array( 'Transactions_List_Table_Tips' ),
194
-                'require_nonce' => false,
195
-            ),
196
-            'view_transaction' => array(
197
-                'nav'       => array(
198
-                    'label'      => esc_html__('View Transaction', 'event_espresso'),
199
-                    'order'      => 5,
200
-                    'url'        => isset($this->_req_data['TXN_ID'])
201
-                        ? add_query_arg(array('TXN_ID' => $this->_req_data['TXN_ID']), $this->_current_page_view_url)
202
-                        : $this->_admin_base_url,
203
-                    'persistent' => false,
204
-                ),
205
-                'help_tabs' => array(
206
-                    'transactions_view_transaction_help_tab'                                              => array(
207
-                        'title'    => esc_html__('View Transaction', 'event_espresso'),
208
-                        'filename' => 'transactions_view_transaction',
209
-                    ),
210
-                    'transactions_view_transaction_transaction_details_table_help_tab'                    => array(
211
-                        'title'    => esc_html__('Transaction Details Table', 'event_espresso'),
212
-                        'filename' => 'transactions_view_transaction_transaction_details_table',
213
-                    ),
214
-                    'transactions_view_transaction_attendees_registered_help_tab'                         => array(
215
-                        'title'    => esc_html__('Attendees Registered', 'event_espresso'),
216
-                        'filename' => 'transactions_view_transaction_attendees_registered',
217
-                    ),
218
-                    'transactions_view_transaction_views_primary_registrant_billing_information_help_tab' => array(
219
-                        'title'    => esc_html__('Primary Registrant & Billing Information', 'event_espresso'),
220
-                        'filename' => 'transactions_view_transaction_primary_registrant_billing_information',
221
-                    ),
222
-                ),
223
-                'qtips'     => array('Transaction_Details_Tips'),
224
-                'help_tour' => array('Transaction_Details_Help_Tour'),
225
-                'metaboxes' => array('_transaction_details_metaboxes'),
226
-
227
-                'require_nonce' => false,
228
-            ),
229
-        );
230
-    }
231
-
232
-
233
-    /**
234
-     * The below methods aren't used by this class currently
235
-     */
236
-    protected function _add_screen_options()
237
-    {
238
-        // noop
239
-    }
240
-
241
-    protected function _add_feature_pointers()
242
-    {
243
-        // noop
244
-    }
245
-
246
-    public function admin_init()
247
-    {
248
-        // IF a registration was JUST added via the admin...
249
-        if (isset(
250
-            $this->_req_data['redirect_from'],
251
-            $this->_req_data['EVT_ID'],
252
-            $this->_req_data['event_name']
253
-        )) {
254
-            // then set a cookie so that we can block any attempts to use
255
-            // the back button as a way to enter another registration.
256
-            setcookie(
257
-                'ee_registration_added',
258
-                $this->_req_data['EVT_ID'],
259
-                time() + WEEK_IN_SECONDS,
260
-                '/'
261
-            );
262
-            // and update the global
263
-            $_COOKIE['ee_registration_added'] = $this->_req_data['EVT_ID'];
264
-        }
265
-        EE_Registry::$i18n_js_strings['invalid_server_response'] = esc_html__(
266
-            'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.',
267
-            'event_espresso'
268
-        );
269
-        EE_Registry::$i18n_js_strings['error_occurred'] = esc_html__(
270
-            'An error occurred! Please refresh the page and try again.',
271
-            'event_espresso'
272
-        );
273
-        EE_Registry::$i18n_js_strings['txn_status_array'] = self::$_txn_status;
274
-        EE_Registry::$i18n_js_strings['pay_status_array'] = self::$_pay_status;
275
-        EE_Registry::$i18n_js_strings['payments_total'] = esc_html__('Payments Total', 'event_espresso');
276
-        EE_Registry::$i18n_js_strings['transaction_overpaid'] = esc_html__(
277
-            'This transaction has been overpaid ! Payments Total',
278
-            'event_espresso'
279
-        );
280
-    }
281
-
282
-    public function admin_notices()
283
-    {
284
-        // noop
285
-    }
286
-
287
-    public function admin_footer_scripts()
288
-    {
289
-        // noop
290
-    }
291
-
292
-
293
-    /**
294
-     * _set_transaction_status_array
295
-     * sets list of transaction statuses
296
-     *
297
-     * @access private
298
-     * @return void
299
-     * @throws EE_Error
300
-     * @throws InvalidArgumentException
301
-     * @throws InvalidDataTypeException
302
-     * @throws InvalidInterfaceException
303
-     */
304
-    private function _set_transaction_status_array()
305
-    {
306
-        self::$_txn_status = EEM_Transaction::instance()->status_array(true);
307
-    }
308
-
309
-
310
-    /**
311
-     * get_transaction_status_array
312
-     * return the transaction status array for wp_list_table
313
-     *
314
-     * @access public
315
-     * @return array
316
-     */
317
-    public function get_transaction_status_array()
318
-    {
319
-        return self::$_txn_status;
320
-    }
321
-
322
-
323
-    /**
324
-     *    get list of payment statuses
325
-     *
326
-     * @access private
327
-     * @return void
328
-     * @throws EE_Error
329
-     * @throws InvalidArgumentException
330
-     * @throws InvalidDataTypeException
331
-     * @throws InvalidInterfaceException
332
-     */
333
-    private function _get_payment_status_array()
334
-    {
335
-        self::$_pay_status = EEM_Payment::instance()->status_array(true);
336
-        $this->_template_args['payment_status'] = self::$_pay_status;
337
-    }
338
-
339
-
340
-    /**
341
-     *    _add_screen_options_default
342
-     *
343
-     * @access protected
344
-     * @return void
345
-     * @throws InvalidArgumentException
346
-     * @throws InvalidDataTypeException
347
-     * @throws InvalidInterfaceException
348
-     */
349
-    protected function _add_screen_options_default()
350
-    {
351
-        $this->_per_page_screen_option();
352
-    }
353
-
354
-
355
-    /**
356
-     * load_scripts_styles
357
-     *
358
-     * @access public
359
-     * @return void
360
-     */
361
-    public function load_scripts_styles()
362
-    {
363
-        // enqueue style
364
-        wp_register_style(
365
-            'espresso_txn',
366
-            TXN_ASSETS_URL . 'espresso_transactions_admin.css',
367
-            array(),
368
-            EVENT_ESPRESSO_VERSION
369
-        );
370
-        wp_enqueue_style('espresso_txn');
371
-        // scripts
372
-        wp_register_script(
373
-            'espresso_txn',
374
-            TXN_ASSETS_URL . 'espresso_transactions_admin.js',
375
-            array(
376
-                'ee_admin_js',
377
-                'ee-datepicker',
378
-                'jquery-ui-datepicker',
379
-                'jquery-ui-draggable',
380
-                'ee-dialog',
381
-                'ee-accounting',
382
-                'ee-serialize-full-array',
383
-            ),
384
-            EVENT_ESPRESSO_VERSION,
385
-            true
386
-        );
387
-        wp_enqueue_script('espresso_txn');
388
-    }
389
-
390
-
391
-    /**
392
-     *    load_scripts_styles_view_transaction
393
-     *
394
-     * @access public
395
-     * @return void
396
-     */
397
-    public function load_scripts_styles_view_transaction()
398
-    {
399
-        // styles
400
-        wp_enqueue_style('espresso-ui-theme');
401
-    }
402
-
403
-
404
-    /**
405
-     *    load_scripts_styles_default
406
-     *
407
-     * @access public
408
-     * @return void
409
-     */
410
-    public function load_scripts_styles_default()
411
-    {
412
-        // styles
413
-        wp_enqueue_style('espresso-ui-theme');
414
-    }
415
-
416
-
417
-    /**
418
-     *    _set_list_table_views_default
419
-     *
420
-     * @access protected
421
-     * @return void
422
-     */
423
-    protected function _set_list_table_views_default()
424
-    {
425
-        $this->_views = array(
426
-            'all'       => array(
427
-                'slug'  => 'all',
428
-                'label' => esc_html__('View All Transactions', 'event_espresso'),
429
-                'count' => 0,
430
-            ),
431
-            'abandoned' => array(
432
-                'slug'  => 'abandoned',
433
-                'label' => esc_html__('Abandoned Transactions', 'event_espresso'),
434
-                'count' => 0,
435
-            ),
436
-            'failed'    => array(
437
-                'slug'  => 'failed',
438
-                'label' => esc_html__('Failed Transactions', 'event_espresso'),
439
-                'count' => 0,
440
-            ),
441
-        );
442
-    }
443
-
444
-
445
-    /**
446
-     * _set_transaction_object
447
-     * This sets the _transaction property for the transaction details screen
448
-     *
449
-     * @access private
450
-     * @return void
451
-     * @throws EE_Error
452
-     * @throws InvalidArgumentException
453
-     * @throws RuntimeException
454
-     * @throws InvalidDataTypeException
455
-     * @throws InvalidInterfaceException
456
-     * @throws ReflectionException
457
-     */
458
-    private function _set_transaction_object()
459
-    {
460
-        if ($this->_transaction instanceof EE_Transaction) {
461
-            return;
462
-        } //get out we've already set the object
463
-
464
-        $TXN_ID = ! empty($this->_req_data['TXN_ID'])
465
-            ? absint($this->_req_data['TXN_ID'])
466
-            : false;
467
-
468
-        // get transaction object
469
-        $this->_transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
470
-        $this->_session = $this->_transaction instanceof EE_Transaction
471
-            ? $this->_transaction->get('TXN_session_data')
472
-            : null;
473
-        $this->_transaction->verify_abandoned_transaction_status();
474
-
475
-        if (! $this->_transaction instanceof EE_Transaction) {
476
-            $error_msg = sprintf(
477
-                esc_html__(
478
-                    'An error occurred and the details for the transaction with the ID # %d could not be retrieved.',
479
-                    'event_espresso'
480
-                ),
481
-                $TXN_ID
482
-            );
483
-            EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
484
-        }
485
-    }
486
-
487
-
488
-    /**
489
-     *    _transaction_legend_items
490
-     *
491
-     * @access protected
492
-     * @return array
493
-     * @throws EE_Error
494
-     * @throws InvalidArgumentException
495
-     * @throws ReflectionException
496
-     * @throws InvalidDataTypeException
497
-     * @throws InvalidInterfaceException
498
-     */
499
-    protected function _transaction_legend_items()
500
-    {
501
-        EE_Registry::instance()->load_helper('MSG_Template');
502
-        $items = array();
503
-
504
-        if (EE_Registry::instance()->CAP->current_user_can(
505
-            'ee_read_global_messages',
506
-            'view_filtered_messages'
507
-        )) {
508
-            $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
509
-            if (is_array($related_for_icon)
510
-                && isset($related_for_icon['css_class'], $related_for_icon['label'])
511
-            ) {
512
-                $items['view_related_messages'] = array(
513
-                    'class' => $related_for_icon['css_class'],
514
-                    'desc'  => $related_for_icon['label'],
515
-                );
516
-            }
517
-        }
518
-
519
-        $items = apply_filters(
520
-            'FHEE__Transactions_Admin_Page___transaction_legend_items__items',
521
-            array_merge(
522
-                $items,
523
-                array(
524
-                    'view_details'          => array(
525
-                        'class' => 'dashicons dashicons-cart',
526
-                        'desc'  => esc_html__('View Transaction Details', 'event_espresso'),
527
-                    ),
528
-                    'view_invoice'          => array(
529
-                        'class' => 'dashicons dashicons-media-spreadsheet',
530
-                        'desc'  => esc_html__('View Transaction Invoice', 'event_espresso'),
531
-                    ),
532
-                    'view_receipt'          => array(
533
-                        'class' => 'dashicons dashicons-media-default',
534
-                        'desc'  => esc_html__('View Transaction Receipt', 'event_espresso'),
535
-                    ),
536
-                    'view_registration'     => array(
537
-                        'class' => 'dashicons dashicons-clipboard',
538
-                        'desc'  => esc_html__('View Registration Details', 'event_espresso'),
539
-                    ),
540
-                    'payment_overview_link' => array(
541
-                        'class' => 'dashicons dashicons-money',
542
-                        'desc'  => esc_html__('Make Payment on Frontend', 'event_espresso'),
543
-                    ),
544
-                )
545
-            )
546
-        );
547
-
548
-        if (EE_Registry::instance()->CAP->current_user_can(
549
-            'ee_send_message',
550
-            'espresso_transactions_send_payment_reminder'
551
-        )) {
552
-            if (EEH_MSG_Template::is_mt_active('payment_reminder')) {
553
-                $items['send_payment_reminder'] = array(
554
-                    'class' => 'dashicons dashicons-email-alt',
555
-                    'desc'  => esc_html__('Send Payment Reminder', 'event_espresso'),
556
-                );
557
-            } else {
558
-                $items['blank*'] = array(
559
-                    'class' => '',
560
-                    'desc'  => '',
561
-                );
562
-            }
563
-        } else {
564
-            $items['blank*'] = array(
565
-                'class' => '',
566
-                'desc'  => '',
567
-            );
568
-        }
569
-        $more_items = apply_filters(
570
-            'FHEE__Transactions_Admin_Page___transaction_legend_items__more_items',
571
-            array(
572
-                'overpaid'   => array(
573
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::overpaid_status_code,
574
-                    'desc'  => EEH_Template::pretty_status(
575
-                        EEM_Transaction::overpaid_status_code,
576
-                        false,
577
-                        'sentence'
578
-                    ),
579
-                ),
580
-                'complete'   => array(
581
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::complete_status_code,
582
-                    'desc'  => EEH_Template::pretty_status(
583
-                        EEM_Transaction::complete_status_code,
584
-                        false,
585
-                        'sentence'
586
-                    ),
587
-                ),
588
-                'incomplete' => array(
589
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::incomplete_status_code,
590
-                    'desc'  => EEH_Template::pretty_status(
591
-                        EEM_Transaction::incomplete_status_code,
592
-                        false,
593
-                        'sentence'
594
-                    ),
595
-                ),
596
-                'abandoned'  => array(
597
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::abandoned_status_code,
598
-                    'desc'  => EEH_Template::pretty_status(
599
-                        EEM_Transaction::abandoned_status_code,
600
-                        false,
601
-                        'sentence'
602
-                    ),
603
-                ),
604
-                'failed'     => array(
605
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::failed_status_code,
606
-                    'desc'  => EEH_Template::pretty_status(
607
-                        EEM_Transaction::failed_status_code,
608
-                        false,
609
-                        'sentence'
610
-                    ),
611
-                ),
612
-            )
613
-        );
614
-
615
-        return array_merge($items, $more_items);
616
-    }
617
-
618
-
619
-    /**
620
-     *    _transactions_overview_list_table
621
-     *
622
-     * @access protected
623
-     * @return void
624
-     * @throws DomainException
625
-     * @throws EE_Error
626
-     * @throws InvalidArgumentException
627
-     * @throws InvalidDataTypeException
628
-     * @throws InvalidInterfaceException
629
-     * @throws ReflectionException
630
-     */
631
-    protected function _transactions_overview_list_table()
632
-    {
633
-        $this->_admin_page_title = esc_html__('Transactions', 'event_espresso');
634
-        $event = isset($this->_req_data['EVT_ID'])
635
-            ? EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID'])
636
-            : null;
637
-        $this->_template_args['admin_page_header'] = $event instanceof EE_Event
638
-            ? sprintf(
639
-                esc_html__(
640
-                    '%sViewing Transactions for the Event: %s%s',
641
-                    'event_espresso'
642
-                ),
643
-                '<h3>',
644
-                '<a href="'
645
-                . EE_Admin_Page::add_query_args_and_nonce(
646
-                    array('action' => 'edit', 'post' => $event->ID()),
647
-                    EVENTS_ADMIN_URL
648
-                )
649
-                . '" title="'
650
-                . esc_attr__(
651
-                    'Click to Edit event',
652
-                    'event_espresso'
653
-                )
654
-                . '">' . $event->get('EVT_name') . '</a>',
655
-                '</h3>'
656
-            )
657
-            : '';
658
-        $this->_template_args['after_list_table'] = $this->_display_legend($this->_transaction_legend_items());
659
-        $this->display_admin_list_table_page_with_no_sidebar();
660
-    }
661
-
662
-
663
-    /**
664
-     *    _transaction_details
665
-     * generates HTML for the View Transaction Details Admin page
666
-     *
667
-     * @access protected
668
-     * @return void
669
-     * @throws DomainException
670
-     * @throws EE_Error
671
-     * @throws InvalidArgumentException
672
-     * @throws InvalidDataTypeException
673
-     * @throws InvalidInterfaceException
674
-     * @throws RuntimeException
675
-     * @throws ReflectionException
676
-     */
677
-    protected function _transaction_details()
678
-    {
679
-        do_action('AHEE__Transactions_Admin_Page__transaction_details__start', $this->_transaction);
680
-
681
-        $this->_set_transaction_status_array();
682
-
683
-        $this->_template_args = array();
684
-        $this->_template_args['transactions_page'] = $this->_wp_page_slug;
685
-
686
-        $this->_set_transaction_object();
687
-
688
-        $primary_registration = $this->_transaction->primary_registration();
689
-        $attendee = $primary_registration instanceof EE_Registration
690
-            ? $primary_registration->attendee()
691
-            : null;
692
-
693
-        $this->_template_args['txn_nmbr']['value'] = $this->_transaction->ID();
694
-        $this->_template_args['txn_nmbr']['label'] = esc_html__('Transaction Number', 'event_espresso');
695
-
696
-        $this->_template_args['txn_datetime']['value'] = $this->_transaction->get_i18n_datetime('TXN_timestamp');
697
-        $this->_template_args['txn_datetime']['label'] = esc_html__('Date', 'event_espresso');
698
-
699
-        $this->_template_args['txn_status']['value'] = self::$_txn_status[ $this->_transaction->get('STS_ID') ];
700
-        $this->_template_args['txn_status']['label'] = esc_html__('Transaction Status', 'event_espresso');
701
-        $this->_template_args['txn_status']['class'] = 'status-' . $this->_transaction->get('STS_ID');
702
-
703
-        $this->_template_args['grand_total'] = $this->_transaction->get('TXN_total');
704
-        $this->_template_args['total_paid'] = $this->_transaction->get('TXN_paid');
705
-
706
-        $amount_due = $this->_transaction->get('TXN_total') - $this->_transaction->get('TXN_paid');
707
-        $this->_template_args['amount_due'] = EEH_Template::format_currency(
708
-            $amount_due,
709
-            true
710
-        );
711
-        if (EE_Registry::instance()->CFG->currency->sign_b4) {
712
-            $this->_template_args['amount_due'] = EE_Registry::instance()->CFG->currency->sign
713
-                                                  . $this->_template_args['amount_due'];
714
-        } else {
715
-            $this->_template_args['amount_due'] .= EE_Registry::instance()->CFG->currency->sign;
716
-        }
717
-        $this->_template_args['amount_due_class'] = '';
718
-
719
-        if ($this->_transaction->get('TXN_paid') == $this->_transaction->get('TXN_total')) {
720
-            // paid in full
721
-            $this->_template_args['amount_due'] = false;
722
-        } elseif ($this->_transaction->get('TXN_paid') > $this->_transaction->get('TXN_total')) {
723
-            // overpaid
724
-            $this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn';
725
-        } elseif ($this->_transaction->get('TXN_total') > 0
726
-                  && $this->_transaction->get('TXN_paid') > 0
727
-        ) {
728
-            // monies owing
729
-            $this->_template_args['amount_due_class'] = 'txn-overview-part-payment-spn';
730
-        } elseif ($this->_transaction->get('TXN_total') > 0
731
-                  && $this->_transaction->get('TXN_paid') == 0
732
-        ) {
733
-            // no payments made yet
734
-            $this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn';
735
-        } elseif ($this->_transaction->get('TXN_total') == 0) {
736
-            // free event
737
-            $this->_template_args['amount_due'] = false;
738
-        }
739
-
740
-        $payment_method = $this->_transaction->payment_method();
741
-
742
-        $this->_template_args['method_of_payment_name'] = $payment_method instanceof EE_Payment_Method
743
-            ? $payment_method->admin_name()
744
-            : esc_html__('Unknown', 'event_espresso');
745
-
746
-        $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
747
-        // link back to overview
748
-        $this->_template_args['txn_overview_url'] = ! empty($_SERVER['HTTP_REFERER'])
749
-            ? $_SERVER['HTTP_REFERER']
750
-            : TXN_ADMIN_URL;
751
-
752
-
753
-        // next link
754
-        $next_txn = $this->_transaction->next(
755
-            null,
756
-            array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))),
757
-            'TXN_ID'
758
-        );
759
-        $this->_template_args['next_transaction'] = $next_txn
760
-            ? $this->_next_link(
761
-                EE_Admin_Page::add_query_args_and_nonce(
762
-                    array('action' => 'view_transaction', 'TXN_ID' => $next_txn['TXN_ID']),
763
-                    TXN_ADMIN_URL
764
-                ),
765
-                'dashicons dashicons-arrow-right ee-icon-size-22'
766
-            )
767
-            : '';
768
-        // previous link
769
-        $previous_txn = $this->_transaction->previous(
770
-            null,
771
-            array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))),
772
-            'TXN_ID'
773
-        );
774
-        $this->_template_args['previous_transaction'] = $previous_txn
775
-            ? $this->_previous_link(
776
-                EE_Admin_Page::add_query_args_and_nonce(
777
-                    array('action' => 'view_transaction', 'TXN_ID' => $previous_txn['TXN_ID']),
778
-                    TXN_ADMIN_URL
779
-                ),
780
-                'dashicons dashicons-arrow-left ee-icon-size-22'
781
-            )
782
-            : '';
783
-
784
-        // were we just redirected here after adding a new registration ???
785
-        if (isset(
786
-            $this->_req_data['redirect_from'],
787
-            $this->_req_data['EVT_ID'],
788
-            $this->_req_data['event_name']
789
-        )) {
790
-            if (EE_Registry::instance()->CAP->current_user_can(
791
-                'ee_edit_registrations',
792
-                'espresso_registrations_new_registration',
793
-                $this->_req_data['EVT_ID']
794
-            )) {
795
-                $this->_admin_page_title .= '<a id="add-new-registration" class="add-new-h2 button-primary" href="';
796
-                $this->_admin_page_title .= EE_Admin_Page::add_query_args_and_nonce(
797
-                    array(
798
-                        'page'     => 'espresso_registrations',
799
-                        'action'   => 'new_registration',
800
-                        'return'   => 'default',
801
-                        'TXN_ID'   => $this->_transaction->ID(),
802
-                        'event_id' => $this->_req_data['EVT_ID'],
803
-                    ),
804
-                    REG_ADMIN_URL
805
-                );
806
-                $this->_admin_page_title .= '">';
807
-
808
-                $this->_admin_page_title .= sprintf(
809
-                    esc_html__('Add Another New Registration to Event: "%1$s" ?', 'event_espresso'),
810
-                    htmlentities(urldecode($this->_req_data['event_name']), ENT_QUOTES, 'UTF-8')
811
-                );
812
-                $this->_admin_page_title .= '</a>';
813
-            }
814
-            EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
815
-        }
816
-        // grab messages at the last second
817
-        $this->_template_args['notices'] = EE_Error::get_notices();
818
-        // path to template
819
-        $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_header.template.php';
820
-        $this->_template_args['admin_page_header'] = EEH_Template::display_template(
821
-            $template_path,
822
-            $this->_template_args,
823
-            true
824
-        );
825
-
826
-        // the details template wrapper
827
-        $this->display_admin_page_with_sidebar();
828
-    }
829
-
830
-
831
-    /**
832
-     *        _transaction_details_metaboxes
833
-     *
834
-     * @access protected
835
-     * @return void
836
-     * @throws EE_Error
837
-     * @throws InvalidArgumentException
838
-     * @throws InvalidDataTypeException
839
-     * @throws InvalidInterfaceException
840
-     * @throws RuntimeException
841
-     * @throws ReflectionException
842
-     */
843
-    protected function _transaction_details_metaboxes()
844
-    {
845
-
846
-        $this->_set_transaction_object();
847
-
848
-        add_meta_box(
849
-            'edit-txn-details-mbox',
850
-            esc_html__('Transaction Details', 'event_espresso'),
851
-            array($this, 'txn_details_meta_box'),
852
-            $this->_wp_page_slug,
853
-            'normal',
854
-            'high'
855
-        );
856
-        add_meta_box(
857
-            'edit-txn-attendees-mbox',
858
-            esc_html__('Attendees Registered in this Transaction', 'event_espresso'),
859
-            array($this, 'txn_attendees_meta_box'),
860
-            $this->_wp_page_slug,
861
-            'normal',
862
-            'high',
863
-            array('TXN_ID' => $this->_transaction->ID())
864
-        );
865
-        add_meta_box(
866
-            'edit-txn-registrant-mbox',
867
-            esc_html__('Primary Contact', 'event_espresso'),
868
-            array($this, 'txn_registrant_side_meta_box'),
869
-            $this->_wp_page_slug,
870
-            'side',
871
-            'high'
872
-        );
873
-        add_meta_box(
874
-            'edit-txn-billing-info-mbox',
875
-            esc_html__('Billing Information', 'event_espresso'),
876
-            array($this, 'txn_billing_info_side_meta_box'),
877
-            $this->_wp_page_slug,
878
-            'side',
879
-            'high'
880
-        );
881
-    }
882
-
883
-
884
-    /**
885
-     * Callback for transaction actions metabox.
886
-     *
887
-     * @param EE_Transaction|null $transaction
888
-     * @throws DomainException
889
-     * @throws EE_Error
890
-     * @throws InvalidArgumentException
891
-     * @throws InvalidDataTypeException
892
-     * @throws InvalidInterfaceException
893
-     * @throws ReflectionException
894
-     * @throws RuntimeException
895
-     */
896
-    public function getActionButtons(EE_Transaction $transaction = null)
897
-    {
898
-        $content = '';
899
-        $actions = array();
900
-        if (! $transaction instanceof EE_Transaction) {
901
-            return $content;
902
-        }
903
-        /** @var EE_Registration $primary_registration */
904
-        $primary_registration = $transaction->primary_registration();
905
-        $attendee = $primary_registration instanceof EE_Registration
906
-            ? $primary_registration->attendee()
907
-            : null;
908
-
909
-        if ($attendee instanceof EE_Attendee
910
-            && EE_Registry::instance()->CAP->current_user_can(
911
-                'ee_send_message',
912
-                'espresso_transactions_send_payment_reminder'
913
-            )
914
-        ) {
915
-            $actions['payment_reminder'] =
916
-                EEH_MSG_Template::is_mt_active('payment_reminder')
917
-                && $this->_transaction->get('STS_ID') !== EEM_Transaction::complete_status_code
918
-                && $this->_transaction->get('STS_ID') !== EEM_Transaction::overpaid_status_code
919
-                    ? EEH_Template::get_button_or_link(
920
-                        EE_Admin_Page::add_query_args_and_nonce(
921
-                            array(
922
-                                'action'      => 'send_payment_reminder',
923
-                                'TXN_ID'      => $this->_transaction->ID(),
924
-                                'redirect_to' => 'view_transaction',
925
-                            ),
926
-                            TXN_ADMIN_URL
927
-                        ),
928
-                        esc_html__(' Send Payment Reminder', 'event_espresso'),
929
-                        'button secondary-button',
930
-                        'dashicons dashicons-email-alt'
931
-                    )
932
-                    : '';
933
-        }
934
-
935
-        if ($primary_registration instanceof EE_Registration
936
-            && EEH_MSG_Template::is_mt_active('receipt')
937
-        ) {
938
-            $actions['receipt'] = EEH_Template::get_button_or_link(
939
-                $primary_registration->receipt_url(),
940
-                esc_html__('View Receipt', 'event_espresso'),
941
-                'button secondary-button',
942
-                'dashicons dashicons-media-default'
943
-            );
944
-        }
945
-
946
-        if ($primary_registration instanceof EE_Registration
947
-            && EEH_MSG_Template::is_mt_active('invoice')
948
-        ) {
949
-            $actions['invoice'] = EEH_Template::get_button_or_link(
950
-                $primary_registration->invoice_url(),
951
-                esc_html__('View Invoice', 'event_espresso'),
952
-                'button secondary-button',
953
-                'dashicons dashicons-media-spreadsheet'
954
-            );
955
-        }
956
-        $actions = array_filter(
957
-            apply_filters('FHEE__Transactions_Admin_Page__getActionButtons__actions', $actions, $transaction)
958
-        );
959
-        if ($actions) {
960
-            $content = '<ul>';
961
-            $content .= '<li>' . implode('</li><li>', $actions) . '</li>';
962
-            $content .= '</uL>';
963
-        }
964
-        return $content;
965
-    }
966
-
967
-
968
-    /**
969
-     * txn_details_meta_box
970
-     * generates HTML for the Transaction main meta box
971
-     *
972
-     * @return void
973
-     * @throws DomainException
974
-     * @throws EE_Error
975
-     * @throws InvalidArgumentException
976
-     * @throws InvalidDataTypeException
977
-     * @throws InvalidInterfaceException
978
-     * @throws RuntimeException
979
-     * @throws ReflectionException
980
-     */
981
-    public function txn_details_meta_box()
982
-    {
983
-        $this->_set_transaction_object();
984
-        $this->_template_args['TXN_ID'] = $this->_transaction->ID();
985
-        $this->_template_args['attendee'] = $this->_transaction->primary_registration() instanceof EE_Registration
986
-            ? $this->_transaction->primary_registration()->attendee()
987
-            : null;
988
-        $this->_template_args['can_edit_payments'] = EE_Registry::instance()->CAP->current_user_can(
989
-            'ee_edit_payments',
990
-            'apply_payment_or_refund_from_registration_details'
991
-        );
992
-        $this->_template_args['can_delete_payments'] = EE_Registry::instance()->CAP->current_user_can(
993
-            'ee_delete_payments',
994
-            'delete_payment_from_registration_details'
995
-        );
996
-
997
-        // get line table
998
-        EEH_Autoloader::register_line_item_display_autoloaders();
999
-        $Line_Item_Display = new EE_Line_Item_Display(
1000
-            'admin_table',
1001
-            'EE_Admin_Table_Line_Item_Display_Strategy'
1002
-        );
1003
-        $this->_template_args['line_item_table'] = $Line_Item_Display->display_line_item(
1004
-            $this->_transaction->total_line_item()
1005
-        );
1006
-        $this->_template_args['REG_code'] = $this->_transaction->get_first_related('Registration')
1007
-                                                               ->get('REG_code');
1008
-
1009
-        // process taxes
1010
-        $taxes = $this->_transaction->get_many_related(
1011
-            'Line_Item',
1012
-            array(array('LIN_type' => EEM_Line_Item::type_tax))
1013
-        );
1014
-        $this->_template_args['taxes'] = ! empty($taxes) ? $taxes : false;
1015
-
1016
-        $this->_template_args['grand_total'] = EEH_Template::format_currency(
1017
-            $this->_transaction->get('TXN_total'),
1018
-            false,
1019
-            false
1020
-        );
1021
-        $this->_template_args['grand_raw_total'] = $this->_transaction->get('TXN_total');
1022
-        $this->_template_args['TXN_status'] = $this->_transaction->get('STS_ID');
1023
-
1024
-        // process payment details
1025
-        $payments = $this->_transaction->get_many_related('Payment');
1026
-        if (! empty($payments)) {
1027
-            $this->_template_args['payments'] = $payments;
1028
-            $this->_template_args['existing_reg_payments'] = $this->_get_registration_payment_IDs($payments);
1029
-        } else {
1030
-            $this->_template_args['payments'] = false;
1031
-            $this->_template_args['existing_reg_payments'] = array();
1032
-        }
1033
-
1034
-        $this->_template_args['edit_payment_url'] = add_query_arg(array('action' => 'edit_payment'), TXN_ADMIN_URL);
1035
-        $this->_template_args['delete_payment_url'] = add_query_arg(
1036
-            array('action' => 'espresso_delete_payment'),
1037
-            TXN_ADMIN_URL
1038
-        );
1039
-
1040
-        if (isset($txn_details['invoice_number'])) {
1041
-            $this->_template_args['txn_details']['invoice_number']['value'] = $this->_template_args['REG_code'];
1042
-            $this->_template_args['txn_details']['invoice_number']['label'] = esc_html__(
1043
-                'Invoice Number',
1044
-                'event_espresso'
1045
-            );
1046
-        }
1047
-
1048
-        $this->_template_args['txn_details']['registration_session']['value'] = $this->_transaction
1049
-            ->get_first_related('Registration')
1050
-            ->get('REG_session');
1051
-        $this->_template_args['txn_details']['registration_session']['label'] = esc_html__(
1052
-            'Registration Session',
1053
-            'event_espresso'
1054
-        );
1055
-
1056
-        $this->_template_args['txn_details']['ip_address']['value'] = isset($this->_session['ip_address'])
1057
-            ? $this->_session['ip_address']
1058
-            : '';
1059
-        $this->_template_args['txn_details']['ip_address']['label'] = esc_html__(
1060
-            'Transaction placed from IP',
1061
-            'event_espresso'
1062
-        );
1063
-
1064
-        $this->_template_args['txn_details']['user_agent']['value'] = isset($this->_session['user_agent'])
1065
-            ? $this->_session['user_agent']
1066
-            : '';
1067
-        $this->_template_args['txn_details']['user_agent']['label'] = esc_html__(
1068
-            'Registrant User Agent',
1069
-            'event_espresso'
1070
-        );
1071
-
1072
-        $reg_steps = '<ul>';
1073
-        foreach ($this->_transaction->reg_steps() as $reg_step => $reg_step_status) {
1074
-            if ($reg_step_status === true) {
1075
-                $reg_steps .= '<li style="color:#70cc50">'
1076
-                              . sprintf(
1077
-                                  esc_html__('%1$s : Completed', 'event_espresso'),
1078
-                                  ucwords(str_replace('_', ' ', $reg_step))
1079
-                              )
1080
-                              . '</li>';
1081
-            } elseif (is_numeric($reg_step_status) && $reg_step_status !== false) {
1082
-                $reg_steps .= '<li style="color:#2EA2CC">'
1083
-                              . sprintf(
1084
-                                  esc_html__('%1$s : Initiated %2$s', 'event_espresso'),
1085
-                                  ucwords(str_replace('_', ' ', $reg_step)),
1086
-                                  date(
1087
-                                      get_option('date_format') . ' ' . get_option('time_format'),
1088
-                                      ($reg_step_status + (get_option('gmt_offset') * HOUR_IN_SECONDS))
1089
-                                  )
1090
-                              )
1091
-                              . '</li>';
1092
-            } else {
1093
-                $reg_steps .= '<li style="color:#E76700">'
1094
-                              . sprintf(
1095
-                                  esc_html__('%1$s : Never Initiated', 'event_espresso'),
1096
-                                  ucwords(str_replace('_', ' ', $reg_step))
1097
-                              )
1098
-                              . '</li>';
1099
-            }
1100
-        }
1101
-        $reg_steps .= '</ul>';
1102
-        $this->_template_args['txn_details']['reg_steps']['value'] = $reg_steps;
1103
-        $this->_template_args['txn_details']['reg_steps']['label'] = esc_html__(
1104
-            'Registration Step Progress',
1105
-            'event_espresso'
1106
-        );
1107
-
1108
-
1109
-        $this->_get_registrations_to_apply_payment_to();
1110
-        $this->_get_payment_methods($payments);
1111
-        $this->_get_payment_status_array();
1112
-        $this->_get_reg_status_selection(); // sets up the template args for the reg status array for the transaction.
1113
-
1114
-        $this->_template_args['transaction_form_url'] = add_query_arg(
1115
-            array(
1116
-                'action'  => 'edit_transaction',
1117
-                'process' => 'transaction',
1118
-            ),
1119
-            TXN_ADMIN_URL
1120
-        );
1121
-        $this->_template_args['apply_payment_form_url'] = add_query_arg(
1122
-            array(
1123
-                'page'   => 'espresso_transactions',
1124
-                'action' => 'espresso_apply_payment',
1125
-            ),
1126
-            WP_AJAX_URL
1127
-        );
1128
-        $this->_template_args['delete_payment_form_url'] = add_query_arg(
1129
-            array(
1130
-                'page'   => 'espresso_transactions',
1131
-                'action' => 'espresso_delete_payment',
1132
-            ),
1133
-            WP_AJAX_URL
1134
-        );
1135
-
1136
-        $this->_template_args['action_buttons'] = $this->getActionButtons($this->_transaction);
1137
-
1138
-        // 'espresso_delete_payment_nonce'
1139
-
1140
-        $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_txn_details.template.php';
1141
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);
1142
-    }
1143
-
1144
-
1145
-    /**
1146
-     * _get_registration_payment_IDs
1147
-     *    generates an array of Payment IDs and their corresponding Registration IDs
1148
-     *
1149
-     * @access protected
1150
-     * @param EE_Payment[] $payments
1151
-     * @return array
1152
-     * @throws EE_Error
1153
-     * @throws InvalidArgumentException
1154
-     * @throws InvalidDataTypeException
1155
-     * @throws InvalidInterfaceException
1156
-     * @throws ReflectionException
1157
-     */
1158
-    protected function _get_registration_payment_IDs($payments = array())
1159
-    {
1160
-        $existing_reg_payments = array();
1161
-        // get all reg payments for these payments
1162
-        $reg_payments = EEM_Registration_Payment::instance()->get_all(
1163
-            array(
1164
-                array(
1165
-                    'PAY_ID' => array(
1166
-                        'IN',
1167
-                        array_keys($payments),
1168
-                    ),
1169
-                ),
1170
-            )
1171
-        );
1172
-        if (! empty($reg_payments)) {
1173
-            foreach ($payments as $payment) {
1174
-                if (! $payment instanceof EE_Payment) {
1175
-                    continue;
1176
-                } elseif (! isset($existing_reg_payments[ $payment->ID() ])) {
1177
-                    $existing_reg_payments[ $payment->ID() ] = array();
1178
-                }
1179
-                foreach ($reg_payments as $reg_payment) {
1180
-                    if ($reg_payment instanceof EE_Registration_Payment
1181
-                        && $reg_payment->payment_ID() === $payment->ID()
1182
-                    ) {
1183
-                        $existing_reg_payments[ $payment->ID() ][] = $reg_payment->registration_ID();
1184
-                    }
1185
-                }
1186
-            }
1187
-        }
1188
-
1189
-        return $existing_reg_payments;
1190
-    }
1191
-
1192
-
1193
-    /**
1194
-     * _get_registrations_to_apply_payment_to
1195
-     *    generates HTML for displaying a series of checkboxes in the admin payment modal window
1196
-     * which allows the admin to only apply the payment to the specific registrations
1197
-     *
1198
-     * @access protected
1199
-     * @return void
1200
-     * @throws \EE_Error
1201
-     */
1202
-    protected function _get_registrations_to_apply_payment_to()
1203
-    {
1204
-        // we want any registration with an active status (ie: not deleted or cancelled)
1205
-        $query_params = array(
1206
-            array(
1207
-                'STS_ID' => array(
1208
-                    'IN',
1209
-                    array(
1210
-                        EEM_Registration::status_id_approved,
1211
-                        EEM_Registration::status_id_pending_payment,
1212
-                        EEM_Registration::status_id_not_approved,
1213
-                    ),
1214
-                ),
1215
-            ),
1216
-        );
1217
-        $registrations_to_apply_payment_to = EEH_HTML::br()
1218
-                                             . EEH_HTML::div(
1219
-                                                 '',
1220
-                                                 'txn-admin-apply-payment-to-registrations-dv',
1221
-                                                 '',
1222
-                                                 'clear: both; margin: 1.5em 0 0; display: none;'
1223
-                                             );
1224
-        $registrations_to_apply_payment_to .= EEH_HTML::br() . EEH_HTML::div('', '', 'admin-primary-mbox-tbl-wrap');
1225
-        $registrations_to_apply_payment_to .= EEH_HTML::table('', '', 'admin-primary-mbox-tbl');
1226
-        $registrations_to_apply_payment_to .= EEH_HTML::thead(
1227
-            EEH_HTML::tr(
1228
-                EEH_HTML::th(esc_html__('ID', 'event_espresso')) .
1229
-                EEH_HTML::th(esc_html__('Registrant', 'event_espresso')) .
1230
-                EEH_HTML::th(esc_html__('Ticket', 'event_espresso')) .
1231
-                EEH_HTML::th(esc_html__('Event', 'event_espresso')) .
1232
-                EEH_HTML::th(esc_html__('Paid', 'event_espresso'), '', 'txn-admin-payment-paid-td jst-cntr') .
1233
-                EEH_HTML::th(esc_html__('Owing', 'event_espresso'), '', 'txn-admin-payment-owing-td jst-cntr') .
1234
-                EEH_HTML::th(esc_html__('Apply', 'event_espresso'), '', 'jst-cntr')
1235
-            )
1236
-        );
1237
-        $registrations_to_apply_payment_to .= EEH_HTML::tbody();
1238
-        // get registrations for TXN
1239
-        $registrations = $this->_transaction->registrations($query_params);
1240
-        $existing_reg_payments = $this->_template_args['existing_reg_payments'];
1241
-        foreach ($registrations as $registration) {
1242
-            if ($registration instanceof EE_Registration) {
1243
-                $attendee_name = $registration->attendee() instanceof EE_Attendee
1244
-                    ? $registration->attendee()->full_name()
1245
-                    : esc_html__('Unknown Attendee', 'event_espresso');
1246
-                $owing = $registration->final_price() - $registration->paid();
1247
-                $taxable = $registration->ticket()->taxable()
1248
-                    ? ' <span class="smaller-text lt-grey-text"> ' . esc_html__('+ tax', 'event_espresso') . '</span>'
1249
-                    : '';
1250
-                $checked = empty($existing_reg_payments) || in_array($registration->ID(), $existing_reg_payments)
1251
-                    ? ' checked="checked"'
1252
-                    : '';
1253
-                $disabled = $registration->final_price() > 0 ? '' : ' disabled';
1254
-                $registrations_to_apply_payment_to .= EEH_HTML::tr(
1255
-                    EEH_HTML::td($registration->ID()) .
1256
-                    EEH_HTML::td($attendee_name) .
1257
-                    EEH_HTML::td(
1258
-                        $registration->ticket()->name() . ' : ' . $registration->ticket()->pretty_price() . $taxable
1259
-                    ) .
1260
-                    EEH_HTML::td($registration->event_name()) .
1261
-                    EEH_HTML::td($registration->pretty_paid(), '', 'txn-admin-payment-paid-td jst-cntr') .
1262
-                    EEH_HTML::td(EEH_Template::format_currency($owing), '', 'txn-admin-payment-owing-td jst-cntr') .
1263
-                    EEH_HTML::td(
1264
-                        '<input type="checkbox" value="' . $registration->ID()
1265
-                        . '" name="txn_admin_payment[registrations]"'
1266
-                        . $checked . $disabled . '>',
1267
-                        '',
1268
-                        'jst-cntr'
1269
-                    ),
1270
-                    'apply-payment-registration-row-' . $registration->ID()
1271
-                );
1272
-            }
1273
-        }
1274
-        $registrations_to_apply_payment_to .= EEH_HTML::tbodyx();
1275
-        $registrations_to_apply_payment_to .= EEH_HTML::tablex();
1276
-        $registrations_to_apply_payment_to .= EEH_HTML::divx();
1277
-        $registrations_to_apply_payment_to .= EEH_HTML::p(
1278
-            esc_html__(
1279
-                'The payment will only be applied to the registrations that have a check mark in their corresponding check box. Checkboxes for free registrations have been disabled.',
1280
-                'event_espresso'
1281
-            ),
1282
-            '',
1283
-            'clear description'
1284
-        );
1285
-        $registrations_to_apply_payment_to .= EEH_HTML::divx();
1286
-        $this->_template_args['registrations_to_apply_payment_to'] = $registrations_to_apply_payment_to;
1287
-    }
1288
-
1289
-
1290
-    /**
1291
-     * _get_reg_status_selection
1292
-     *
1293
-     * @todo   this will need to be adjusted either once MER comes along OR we move default reg status to tickets
1294
-     *         instead of events.
1295
-     * @access protected
1296
-     * @return void
1297
-     * @throws EE_Error
1298
-     */
1299
-    protected function _get_reg_status_selection()
1300
-    {
1301
-        // first get all possible statuses
1302
-        $statuses = EEM_Registration::reg_status_array(array(), true);
1303
-        // let's add a "don't change" option.
1304
-        $status_array['NAN'] = esc_html__('Leave the Same', 'event_espresso');
1305
-        $status_array = array_merge($status_array, $statuses);
1306
-        $this->_template_args['status_change_select'] = EEH_Form_Fields::select_input(
1307
-            'txn_reg_status_change[reg_status]',
1308
-            $status_array,
1309
-            'NAN',
1310
-            'id="txn-admin-payment-reg-status-inp"',
1311
-            'txn-reg-status-change-reg-status'
1312
-        );
1313
-        $this->_template_args['delete_status_change_select'] = EEH_Form_Fields::select_input(
1314
-            'delete_txn_reg_status_change[reg_status]',
1315
-            $status_array,
1316
-            'NAN',
1317
-            'delete-txn-admin-payment-reg-status-inp',
1318
-            'delete-txn-reg-status-change-reg-status'
1319
-        );
1320
-    }
1321
-
1322
-
1323
-    /**
1324
-     *    _get_payment_methods
1325
-     * Gets all the payment methods available generally, or the ones that are already
1326
-     * selected on these payments (in case their payment methods are no longer active).
1327
-     * Has the side-effect of updating the template args' payment_methods item
1328
-     *
1329
-     * @access private
1330
-     * @param EE_Payment[] to show on this page
1331
-     * @return void
1332
-     * @throws EE_Error
1333
-     * @throws InvalidArgumentException
1334
-     * @throws InvalidDataTypeException
1335
-     * @throws InvalidInterfaceException
1336
-     * @throws ReflectionException
1337
-     */
1338
-    private function _get_payment_methods($payments = array())
1339
-    {
1340
-        $payment_methods_of_payments = array();
1341
-        foreach ($payments as $payment) {
1342
-            if ($payment instanceof EE_Payment) {
1343
-                $payment_methods_of_payments[] = $payment->get('PMD_ID');
1344
-            }
1345
-        }
1346
-        if ($payment_methods_of_payments) {
1347
-            $query_args = array(
1348
-                array(
1349
-                    'OR*payment_method_for_payment' => array(
1350
-                        'PMD_ID'    => array('IN', $payment_methods_of_payments),
1351
-                        'PMD_scope' => array('LIKE', '%' . EEM_Payment_Method::scope_admin . '%'),
1352
-                    ),
1353
-                ),
1354
-            );
1355
-        } else {
1356
-            $query_args = array(array('PMD_scope' => array('LIKE', '%' . EEM_Payment_Method::scope_admin . '%')));
1357
-        }
1358
-        $this->_template_args['payment_methods'] = EEM_Payment_Method::instance()->get_all($query_args);
1359
-    }
1360
-
1361
-
1362
-    /**
1363
-     * txn_attendees_meta_box
1364
-     *    generates HTML for the Attendees Transaction main meta box
1365
-     *
1366
-     * @access public
1367
-     * @param WP_Post $post
1368
-     * @param array   $metabox
1369
-     * @return void
1370
-     * @throws DomainException
1371
-     * @throws EE_Error
1372
-     */
1373
-    public function txn_attendees_meta_box($post, $metabox = array('args' => array()))
1374
-    {
1375
-
1376
-        /** @noinspection NonSecureExtractUsageInspection */
1377
-        extract($metabox['args']);
1378
-        $this->_template_args['post'] = $post;
1379
-        $this->_template_args['event_attendees'] = array();
1380
-        // process items in cart
1381
-        $line_items = $this->_transaction->get_many_related(
1382
-            'Line_Item',
1383
-            array(array('LIN_type' => 'line-item'))
1384
-        );
1385
-        if (! empty($line_items)) {
1386
-            foreach ($line_items as $item) {
1387
-                if ($item instanceof EE_Line_Item) {
1388
-                    switch ($item->OBJ_type()) {
1389
-                        case 'Event':
1390
-                            break;
1391
-                        case 'Ticket':
1392
-                            $ticket = $item->ticket();
1393
-                            // right now we're only handling tickets here.
1394
-                            // Cause its expected that only tickets will have attendees right?
1395
-                            if (! $ticket instanceof EE_Ticket) {
1396
-                                continue;
1397
-                            }
1398
-                            try {
1399
-                                $event_name = $ticket->get_event_name();
1400
-                            } catch (Exception $e) {
1401
-                                EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1402
-                                $event_name = esc_html__('Unknown Event', 'event_espresso');
1403
-                            }
1404
-                            $event_name .= ' - ' . $item->get('LIN_name');
1405
-                            $ticket_price = EEH_Template::format_currency($item->get('LIN_unit_price'));
1406
-                            // now get all of the registrations for this transaction that use this ticket
1407
-                            $registrations = $ticket->get_many_related(
1408
-                                'Registration',
1409
-                                array(array('TXN_ID' => $this->_transaction->ID()))
1410
-                            );
1411
-                            foreach ($registrations as $registration) {
1412
-                                if (! $registration instanceof EE_Registration) {
1413
-                                    continue;
1414
-                                }
1415
-                                $this->_template_args['event_attendees'][ $registration->ID() ]['STS_ID']
1416
-                                    = $registration->status_ID();
1417
-                                $this->_template_args['event_attendees'][ $registration->ID() ]['att_num']
1418
-                                    = $registration->count();
1419
-                                $this->_template_args['event_attendees'][ $registration->ID() ]['event_ticket_name']
1420
-                                    = $event_name;
1421
-                                $this->_template_args['event_attendees'][ $registration->ID() ]['ticket_price']
1422
-                                    = $ticket_price;
1423
-                                // attendee info
1424
-                                $attendee = $registration->get_first_related('Attendee');
1425
-                                if ($attendee instanceof EE_Attendee) {
1426
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['att_id']
1427
-                                        = $attendee->ID();
1428
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['attendee']
1429
-                                        = $attendee->full_name();
1430
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['email']
1431
-                                        = '<a href="mailto:' . $attendee->email() . '?subject=' . $event_name
1432
-                                          . esc_html__(
1433
-                                              ' Event',
1434
-                                              'event_espresso'
1435
-                                          )
1436
-                                          . '">' . $attendee->email() . '</a>';
1437
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['address']
1438
-                                        = EEH_Address::format($attendee, 'inline', false, false);
1439
-                                } else {
1440
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['att_id'] = '';
1441
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['attendee'] = '';
1442
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['email'] = '';
1443
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['address'] = '';
1444
-                                }
1445
-                            }
1446
-                            break;
1447
-                    }
1448
-                }
1449
-            }
1450
-
1451
-            $this->_template_args['transaction_form_url'] = add_query_arg(
1452
-                array(
1453
-                    'action'  => 'edit_transaction',
1454
-                    'process' => 'attendees',
1455
-                ),
1456
-                TXN_ADMIN_URL
1457
-            );
1458
-            echo EEH_Template::display_template(
1459
-                TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_attendees.template.php',
1460
-                $this->_template_args,
1461
-                true
1462
-            );
1463
-        } else {
1464
-            echo sprintf(
1465
-                esc_html__(
1466
-                    '%1$sFor some reason, there are no attendees registered for this transaction. Likely the registration was abandoned in process.%2$s',
1467
-                    'event_espresso'
1468
-                ),
1469
-                '<p class="important-notice">',
1470
-                '</p>'
1471
-            );
1472
-        }
1473
-    }
1474
-
1475
-
1476
-    /**
1477
-     * txn_registrant_side_meta_box
1478
-     * generates HTML for the Edit Transaction side meta box
1479
-     *
1480
-     * @access public
1481
-     * @return void
1482
-     * @throws DomainException
1483
-     * @throws EE_Error
1484
-     * @throws InvalidArgumentException
1485
-     * @throws InvalidDataTypeException
1486
-     * @throws InvalidInterfaceException
1487
-     * @throws ReflectionException
1488
-     */
1489
-    public function txn_registrant_side_meta_box()
1490
-    {
1491
-        $primary_att = $this->_transaction->primary_registration() instanceof EE_Registration
1492
-            ? $this->_transaction->primary_registration()->get_first_related('Attendee')
1493
-            : null;
1494
-        if (! $primary_att instanceof EE_Attendee) {
1495
-            $this->_template_args['no_attendee_message'] = esc_html__(
1496
-                'There is no attached contact for this transaction.  The transaction either failed due to an error or was abandoned.',
1497
-                'event_espresso'
1498
-            );
1499
-            $primary_att = EEM_Attendee::instance()->create_default_object();
1500
-        }
1501
-        $this->_template_args['ATT_ID'] = $primary_att->ID();
1502
-        $this->_template_args['prime_reg_fname'] = $primary_att->fname();
1503
-        $this->_template_args['prime_reg_lname'] = $primary_att->lname();
1504
-        $this->_template_args['prime_reg_email'] = $primary_att->email();
1505
-        $this->_template_args['prime_reg_phone'] = $primary_att->phone();
1506
-        $this->_template_args['edit_attendee_url'] = EE_Admin_Page::add_query_args_and_nonce(
1507
-            array(
1508
-                'action' => 'edit_attendee',
1509
-                'post'   => $primary_att->ID(),
1510
-            ),
1511
-            REG_ADMIN_URL
1512
-        );
1513
-        // get formatted address for registrant
1514
-        $this->_template_args['formatted_address'] = EEH_Address::format($primary_att);
1515
-        echo EEH_Template::display_template(
1516
-            TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_registrant.template.php',
1517
-            $this->_template_args,
1518
-            true
1519
-        );
1520
-    }
1521
-
1522
-
1523
-    /**
1524
-     * txn_billing_info_side_meta_box
1525
-     *    generates HTML for the Edit Transaction side meta box
1526
-     *
1527
-     * @access public
1528
-     * @return void
1529
-     * @throws DomainException
1530
-     * @throws EE_Error
1531
-     */
1532
-    public function txn_billing_info_side_meta_box()
1533
-    {
1534
-
1535
-        $this->_template_args['billing_form'] = $this->_transaction->billing_info();
1536
-        $this->_template_args['billing_form_url'] = add_query_arg(
1537
-            array('action' => 'edit_transaction', 'process' => 'billing'),
1538
-            TXN_ADMIN_URL
1539
-        );
1540
-
1541
-        $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_billing_info.template.php';
1542
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);/**/
1543
-    }
1544
-
1545
-
1546
-    /**
1547
-     * apply_payments_or_refunds
1548
-     *    registers a payment or refund made towards a transaction
1549
-     *
1550
-     * @access public
1551
-     * @return void
1552
-     * @throws EE_Error
1553
-     * @throws InvalidArgumentException
1554
-     * @throws ReflectionException
1555
-     * @throws RuntimeException
1556
-     * @throws InvalidDataTypeException
1557
-     * @throws InvalidInterfaceException
1558
-     */
1559
-    public function apply_payments_or_refunds()
1560
-    {
1561
-        $json_response_data = array('return_data' => false);
1562
-        $valid_data = $this->_validate_payment_request_data();
1563
-        $has_access = EE_Registry::instance()->CAP->current_user_can(
1564
-            'ee_edit_payments',
1565
-            'apply_payment_or_refund_from_registration_details'
1566
-        );
1567
-        if (! empty($valid_data) && $has_access) {
1568
-            $PAY_ID = $valid_data['PAY_ID'];
1569
-            // save  the new payment
1570
-            $payment = $this->_create_payment_from_request_data($valid_data);
1571
-            // get the TXN for this payment
1572
-            $transaction = $payment->transaction();
1573
-            // verify transaction
1574
-            if ($transaction instanceof EE_Transaction) {
1575
-                // calculate_total_payments_and_update_status
1576
-                $this->_process_transaction_payments($transaction);
1577
-                $REG_IDs = $this->_get_REG_IDs_to_apply_payment_to($payment);
1578
-                $this->_remove_existing_registration_payments($payment, $PAY_ID);
1579
-                // apply payment to registrations (if applicable)
1580
-                if (! empty($REG_IDs)) {
1581
-                    $this->_update_registration_payments($transaction, $payment, $REG_IDs);
1582
-                    $this->_maybe_send_notifications();
1583
-                    // now process status changes for the same registrations
1584
-                    $this->_process_registration_status_change($transaction, $REG_IDs);
1585
-                }
1586
-                $this->_maybe_send_notifications($payment);
1587
-                // prepare to render page
1588
-                $json_response_data['return_data'] = $this->_build_payment_json_response($payment, $REG_IDs);
1589
-                do_action(
1590
-                    'AHEE__Transactions_Admin_Page__apply_payments_or_refund__after_recording',
1591
-                    $transaction,
1592
-                    $payment
1593
-                );
1594
-            } else {
1595
-                EE_Error::add_error(
1596
-                    esc_html__(
1597
-                        'A valid Transaction for this payment could not be retrieved.',
1598
-                        'event_espresso'
1599
-                    ),
1600
-                    __FILE__,
1601
-                    __FUNCTION__,
1602
-                    __LINE__
1603
-                );
1604
-            }
1605
-        } else {
1606
-            if ($has_access) {
1607
-                EE_Error::add_error(
1608
-                    esc_html__(
1609
-                        'The payment form data could not be processed. Please try again.',
1610
-                        'event_espresso'
1611
-                    ),
1612
-                    __FILE__,
1613
-                    __FUNCTION__,
1614
-                    __LINE__
1615
-                );
1616
-            } else {
1617
-                EE_Error::add_error(
1618
-                    esc_html__(
1619
-                        'You do not have access to apply payments or refunds to a registration.',
1620
-                        'event_espresso'
1621
-                    ),
1622
-                    __FILE__,
1623
-                    __FUNCTION__,
1624
-                    __LINE__
1625
-                );
1626
-            }
1627
-        }
1628
-        $notices = EE_Error::get_notices(
1629
-            false,
1630
-            false,
1631
-            false
1632
-        );
1633
-        $this->_template_args = array(
1634
-            'data'    => $json_response_data,
1635
-            'error'   => $notices['errors'],
1636
-            'success' => $notices['success'],
1637
-        );
1638
-        $this->_return_json();
1639
-    }
1640
-
1641
-
1642
-    /**
1643
-     * _validate_payment_request_data
1644
-     *
1645
-     * @return array
1646
-     * @throws EE_Error
1647
-     */
1648
-    protected function _validate_payment_request_data()
1649
-    {
1650
-        if (! isset($this->_req_data['txn_admin_payment'])) {
1651
-            return false;
1652
-        }
1653
-        $payment_form = $this->_generate_payment_form_section();
1654
-        try {
1655
-            if ($payment_form->was_submitted()) {
1656
-                $payment_form->receive_form_submission();
1657
-                if (! $payment_form->is_valid()) {
1658
-                    $submission_error_messages = array();
1659
-                    foreach ($payment_form->get_validation_errors_accumulated() as $validation_error) {
1660
-                        if ($validation_error instanceof EE_Validation_Error) {
1661
-                            $submission_error_messages[] = sprintf(
1662
-                                _x('%s : %s', 'Form Section Name : Form Validation Error', 'event_espresso'),
1663
-                                $validation_error->get_form_section()->html_label_text(),
1664
-                                $validation_error->getMessage()
1665
-                            );
1666
-                        }
1667
-                    }
1668
-                    EE_Error::add_error(
1669
-                        implode('<br />', $submission_error_messages),
1670
-                        __FILE__,
1671
-                        __FUNCTION__,
1672
-                        __LINE__
1673
-                    );
1674
-
1675
-                    return array();
1676
-                }
1677
-            }
1678
-        } catch (EE_Error $e) {
1679
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1680
-
1681
-            return array();
1682
-        }
1683
-
1684
-        return $payment_form->valid_data();
1685
-    }
1686
-
1687
-
1688
-    /**
1689
-     * _generate_payment_form_section
1690
-     *
1691
-     * @return EE_Form_Section_Proper
1692
-     * @throws EE_Error
1693
-     */
1694
-    protected function _generate_payment_form_section()
1695
-    {
1696
-        return new EE_Form_Section_Proper(
1697
-            array(
1698
-                'name'        => 'txn_admin_payment',
1699
-                'subsections' => array(
1700
-                    'PAY_ID'          => new EE_Text_Input(
1701
-                        array(
1702
-                            'default'               => 0,
1703
-                            'required'              => false,
1704
-                            'html_label_text'       => esc_html__('Payment ID', 'event_espresso'),
1705
-                            'validation_strategies' => array(new EE_Int_Normalization()),
1706
-                        )
1707
-                    ),
1708
-                    'TXN_ID'          => new EE_Text_Input(
1709
-                        array(
1710
-                            'default'               => 0,
1711
-                            'required'              => true,
1712
-                            'html_label_text'       => esc_html__('Transaction ID', 'event_espresso'),
1713
-                            'validation_strategies' => array(new EE_Int_Normalization()),
1714
-                        )
1715
-                    ),
1716
-                    'type'            => new EE_Text_Input(
1717
-                        array(
1718
-                            'default'               => 1,
1719
-                            'required'              => true,
1720
-                            'html_label_text'       => esc_html__('Payment or Refund', 'event_espresso'),
1721
-                            'validation_strategies' => array(new EE_Int_Normalization()),
1722
-                        )
1723
-                    ),
1724
-                    'amount'          => new EE_Text_Input(
1725
-                        array(
1726
-                            'default'               => 0,
1727
-                            'required'              => true,
1728
-                            'html_label_text'       => esc_html__('Payment amount', 'event_espresso'),
1729
-                            'validation_strategies' => array(new EE_Float_Normalization()),
1730
-                        )
1731
-                    ),
1732
-                    'status'          => new EE_Text_Input(
1733
-                        array(
1734
-                            'default'         => EEM_Payment::status_id_approved,
1735
-                            'required'        => true,
1736
-                            'html_label_text' => esc_html__('Payment status', 'event_espresso'),
1737
-                        )
1738
-                    ),
1739
-                    'PMD_ID'          => new EE_Text_Input(
1740
-                        array(
1741
-                            'default'               => 2,
1742
-                            'required'              => true,
1743
-                            'html_label_text'       => esc_html__('Payment Method', 'event_espresso'),
1744
-                            'validation_strategies' => array(new EE_Int_Normalization()),
1745
-                        )
1746
-                    ),
1747
-                    'date'            => new EE_Text_Input(
1748
-                        array(
1749
-                            'default'         => time(),
1750
-                            'required'        => true,
1751
-                            'html_label_text' => esc_html__('Payment date', 'event_espresso'),
1752
-                        )
1753
-                    ),
1754
-                    'txn_id_chq_nmbr' => new EE_Text_Input(
1755
-                        array(
1756
-                            'default'               => '',
1757
-                            'required'              => false,
1758
-                            'html_label_text'       => esc_html__('Transaction or Cheque Number', 'event_espresso'),
1759
-                            'validation_strategies' => array(
1760
-                                new EE_Max_Length_Validation_Strategy(
1761
-                                    esc_html__('Input too long', 'event_espresso'),
1762
-                                    100
1763
-                                ),
1764
-                            ),
1765
-                        )
1766
-                    ),
1767
-                    'po_number'       => new EE_Text_Input(
1768
-                        array(
1769
-                            'default'               => '',
1770
-                            'required'              => false,
1771
-                            'html_label_text'       => esc_html__('Purchase Order Number', 'event_espresso'),
1772
-                            'validation_strategies' => array(
1773
-                                new EE_Max_Length_Validation_Strategy(
1774
-                                    esc_html__('Input too long', 'event_espresso'),
1775
-                                    100
1776
-                                ),
1777
-                            ),
1778
-                        )
1779
-                    ),
1780
-                    'accounting'      => new EE_Text_Input(
1781
-                        array(
1782
-                            'default'               => '',
1783
-                            'required'              => false,
1784
-                            'html_label_text'       => esc_html__('Extra Field for Accounting', 'event_espresso'),
1785
-                            'validation_strategies' => array(
1786
-                                new EE_Max_Length_Validation_Strategy(
1787
-                                    esc_html__('Input too long', 'event_espresso'),
1788
-                                    100
1789
-                                ),
1790
-                            ),
1791
-                        )
1792
-                    ),
1793
-                ),
1794
-            )
1795
-        );
1796
-    }
1797
-
1798
-
1799
-    /**
1800
-     * _create_payment_from_request_data
1801
-     *
1802
-     * @param array $valid_data
1803
-     * @return EE_Payment
1804
-     * @throws EE_Error
1805
-     */
1806
-    protected function _create_payment_from_request_data($valid_data)
1807
-    {
1808
-        $PAY_ID = $valid_data['PAY_ID'];
1809
-        // get payment amount
1810
-        $amount = $valid_data['amount'] ? abs($valid_data['amount']) : 0;
1811
-        // payments have a type value of 1 and refunds have a type value of -1
1812
-        // so multiplying amount by type will give a positive value for payments, and negative values for refunds
1813
-        $amount = $valid_data['type'] < 0 ? $amount * -1 : $amount;
1814
-        // for some reason the date string coming in has extra spaces between the date and time.  This fixes that.
1815
-        $date = $valid_data['date']
1816
-            ? preg_replace('/\s+/', ' ', $valid_data['date'])
1817
-            : date('Y-m-d g:i a', current_time('timestamp'));
1818
-        $payment = EE_Payment::new_instance(
1819
-            array(
1820
-                'TXN_ID'              => $valid_data['TXN_ID'],
1821
-                'STS_ID'              => $valid_data['status'],
1822
-                'PAY_timestamp'       => $date,
1823
-                'PAY_source'          => EEM_Payment_Method::scope_admin,
1824
-                'PMD_ID'              => $valid_data['PMD_ID'],
1825
-                'PAY_amount'          => $amount,
1826
-                'PAY_txn_id_chq_nmbr' => $valid_data['txn_id_chq_nmbr'],
1827
-                'PAY_po_number'       => $valid_data['po_number'],
1828
-                'PAY_extra_accntng'   => $valid_data['accounting'],
1829
-                'PAY_details'         => $valid_data,
1830
-                'PAY_ID'              => $PAY_ID,
1831
-            ),
1832
-            '',
1833
-            array('Y-m-d', 'g:i a')
1834
-        );
1835
-
1836
-        if (! $payment->save()) {
1837
-            EE_Error::add_error(
1838
-                sprintf(
1839
-                    esc_html__('Payment %1$d has not been successfully saved to the database.', 'event_espresso'),
1840
-                    $payment->ID()
1841
-                ),
1842
-                __FILE__,
1843
-                __FUNCTION__,
1844
-                __LINE__
1845
-            );
1846
-        }
1847
-
1848
-        return $payment;
1849
-    }
1850
-
1851
-
1852
-    /**
1853
-     * _process_transaction_payments
1854
-     *
1855
-     * @param \EE_Transaction $transaction
1856
-     * @return void
1857
-     * @throws EE_Error
1858
-     * @throws InvalidArgumentException
1859
-     * @throws ReflectionException
1860
-     * @throws InvalidDataTypeException
1861
-     * @throws InvalidInterfaceException
1862
-     */
1863
-    protected function _process_transaction_payments(EE_Transaction $transaction)
1864
-    {
1865
-        /** @type EE_Transaction_Payments $transaction_payments */
1866
-        $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
1867
-        // update the transaction with this payment
1868
-        if ($transaction_payments->calculate_total_payments_and_update_status($transaction)) {
1869
-            EE_Error::add_success(
1870
-                esc_html__(
1871
-                    'The payment has been processed successfully.',
1872
-                    'event_espresso'
1873
-                ),
1874
-                __FILE__,
1875
-                __FUNCTION__,
1876
-                __LINE__
1877
-            );
1878
-        } else {
1879
-            EE_Error::add_error(
1880
-                esc_html__(
1881
-                    'The payment was processed successfully but the amount paid for the transaction was not updated.',
1882
-                    'event_espresso'
1883
-                ),
1884
-                __FILE__,
1885
-                __FUNCTION__,
1886
-                __LINE__
1887
-            );
1888
-        }
1889
-    }
1890
-
1891
-
1892
-    /**
1893
-     * _get_REG_IDs_to_apply_payment_to
1894
-     * returns a list of registration IDs that the payment will apply to
1895
-     *
1896
-     * @param \EE_Payment $payment
1897
-     * @return array
1898
-     * @throws EE_Error
1899
-     */
1900
-    protected function _get_REG_IDs_to_apply_payment_to(EE_Payment $payment)
1901
-    {
1902
-        $REG_IDs = array();
1903
-        // grab array of IDs for specific registrations to apply changes to
1904
-        if (isset($this->_req_data['txn_admin_payment']['registrations'])) {
1905
-            $REG_IDs = (array) $this->_req_data['txn_admin_payment']['registrations'];
1906
-        }
1907
-        // nothing specified ? then get all reg IDs
1908
-        if (empty($REG_IDs)) {
1909
-            $registrations = $payment->transaction()->registrations();
1910
-            $REG_IDs = ! empty($registrations)
1911
-                ? array_keys($registrations)
1912
-                : $this->_get_existing_reg_payment_REG_IDs($payment);
1913
-        }
1914
-
1915
-        // ensure that REG_IDs are integers and NOT strings
1916
-        return array_map('intval', $REG_IDs);
1917
-    }
1918
-
1919
-
1920
-    /**
1921
-     * @return array
1922
-     */
1923
-    public function existing_reg_payment_REG_IDs()
1924
-    {
1925
-        return $this->_existing_reg_payment_REG_IDs;
1926
-    }
1927
-
1928
-
1929
-    /**
1930
-     * @param array $existing_reg_payment_REG_IDs
1931
-     */
1932
-    public function set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs = null)
1933
-    {
1934
-        $this->_existing_reg_payment_REG_IDs = $existing_reg_payment_REG_IDs;
1935
-    }
1936
-
1937
-
1938
-    /**
1939
-     * _get_existing_reg_payment_REG_IDs
1940
-     * returns a list of registration IDs that the payment is currently related to
1941
-     * as recorded in the database
1942
-     *
1943
-     * @param \EE_Payment $payment
1944
-     * @return array
1945
-     * @throws EE_Error
1946
-     */
1947
-    protected function _get_existing_reg_payment_REG_IDs(EE_Payment $payment)
1948
-    {
1949
-        if ($this->existing_reg_payment_REG_IDs() === null) {
1950
-            // let's get any existing reg payment records for this payment
1951
-            $existing_reg_payment_REG_IDs = $payment->get_many_related('Registration');
1952
-            // but we only want the REG IDs, so grab the array keys
1953
-            $existing_reg_payment_REG_IDs = ! empty($existing_reg_payment_REG_IDs)
1954
-                ? array_keys($existing_reg_payment_REG_IDs)
1955
-                : array();
1956
-            $this->set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs);
1957
-        }
1958
-
1959
-        return $this->existing_reg_payment_REG_IDs();
1960
-    }
1961
-
1962
-
1963
-    /**
1964
-     * _remove_existing_registration_payments
1965
-     * this calculates the difference between existing relations
1966
-     * to the supplied payment and the new list registration IDs,
1967
-     * removes any related registrations that no longer apply,
1968
-     * and then updates the registration paid fields
1969
-     *
1970
-     * @param \EE_Payment $payment
1971
-     * @param int         $PAY_ID
1972
-     * @return bool;
1973
-     * @throws EE_Error
1974
-     * @throws InvalidArgumentException
1975
-     * @throws ReflectionException
1976
-     * @throws InvalidDataTypeException
1977
-     * @throws InvalidInterfaceException
1978
-     */
1979
-    protected function _remove_existing_registration_payments(EE_Payment $payment, $PAY_ID = 0)
1980
-    {
1981
-        // newly created payments will have nothing recorded for $PAY_ID
1982
-        if ($PAY_ID == 0) {
1983
-            return false;
1984
-        }
1985
-        $existing_reg_payment_REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment);
1986
-        if (empty($existing_reg_payment_REG_IDs)) {
1987
-            return false;
1988
-        }
1989
-        /** @type EE_Transaction_Payments $transaction_payments */
1990
-        $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
1991
-
1992
-        return $transaction_payments->delete_registration_payments_and_update_registrations(
1993
-            $payment,
1994
-            array(
1995
-                array(
1996
-                    'PAY_ID' => $payment->ID(),
1997
-                    'REG_ID' => array('IN', $existing_reg_payment_REG_IDs),
1998
-                ),
1999
-            )
2000
-        );
2001
-    }
2002
-
2003
-
2004
-    /**
2005
-     * _update_registration_payments
2006
-     * this applies the payments to the selected registrations
2007
-     * but only if they have not already been paid for
2008
-     *
2009
-     * @param  EE_Transaction $transaction
2010
-     * @param \EE_Payment     $payment
2011
-     * @param array           $REG_IDs
2012
-     * @return void
2013
-     * @throws EE_Error
2014
-     * @throws InvalidArgumentException
2015
-     * @throws ReflectionException
2016
-     * @throws RuntimeException
2017
-     * @throws InvalidDataTypeException
2018
-     * @throws InvalidInterfaceException
2019
-     */
2020
-    protected function _update_registration_payments(
2021
-        EE_Transaction $transaction,
2022
-        EE_Payment $payment,
2023
-        $REG_IDs = array()
2024
-    ) {
2025
-        // we can pass our own custom set of registrations to EE_Payment_Processor::process_registration_payments()
2026
-        // so let's do that using our set of REG_IDs from the form
2027
-        $registration_query_where_params = array(
2028
-            'REG_ID' => array('IN', $REG_IDs),
2029
-        );
2030
-        // but add in some conditions regarding payment,
2031
-        // so that we don't apply payments to registrations that are free or have already been paid for
2032
-        // but ONLY if the payment is NOT a refund ( ie: the payment amount is not negative )
2033
-        if (! $payment->is_a_refund()) {
2034
-            $registration_query_where_params['REG_final_price'] = array('!=', 0);
2035
-            $registration_query_where_params['REG_final_price*'] = array('!=', 'REG_paid', true);
2036
-        }
2037
-        $registrations = $transaction->registrations(array($registration_query_where_params));
2038
-        if (! empty($registrations)) {
2039
-            /** @type EE_Payment_Processor $payment_processor */
2040
-            $payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
2041
-            $payment_processor->process_registration_payments($transaction, $payment, $registrations);
2042
-        }
2043
-    }
2044
-
2045
-
2046
-    /**
2047
-     * _process_registration_status_change
2048
-     * This processes requested registration status changes for all the registrations
2049
-     * on a given transaction and (optionally) sends out notifications for the changes.
2050
-     *
2051
-     * @param  EE_Transaction $transaction
2052
-     * @param array           $REG_IDs
2053
-     * @return bool
2054
-     * @throws EE_Error
2055
-     * @throws InvalidArgumentException
2056
-     * @throws ReflectionException
2057
-     * @throws InvalidDataTypeException
2058
-     * @throws InvalidInterfaceException
2059
-     */
2060
-    protected function _process_registration_status_change(EE_Transaction $transaction, $REG_IDs = array())
2061
-    {
2062
-        // first if there is no change in status then we get out.
2063
-        if (! isset($this->_req_data['txn_reg_status_change']['reg_status'])
2064
-            || $this->_req_data['txn_reg_status_change']['reg_status'] === 'NAN'
2065
-        ) {
2066
-            // no error message, no change requested, just nothing to do man.
2067
-            return false;
2068
-        }
2069
-        /** @type EE_Transaction_Processor $transaction_processor */
2070
-        $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
2071
-
2072
-        // made it here dude?  Oh WOW.  K, let's take care of changing the statuses
2073
-        return $transaction_processor->manually_update_registration_statuses(
2074
-            $transaction,
2075
-            sanitize_text_field($this->_req_data['txn_reg_status_change']['reg_status']),
2076
-            array(array('REG_ID' => array('IN', $REG_IDs)))
2077
-        );
2078
-    }
2079
-
2080
-
2081
-    /**
2082
-     * _build_payment_json_response
2083
-     *
2084
-     * @access public
2085
-     * @param \EE_Payment $payment
2086
-     * @param array       $REG_IDs
2087
-     * @param bool | null $delete_txn_reg_status_change
2088
-     * @return array
2089
-     * @throws EE_Error
2090
-     * @throws InvalidArgumentException
2091
-     * @throws InvalidDataTypeException
2092
-     * @throws InvalidInterfaceException
2093
-     * @throws ReflectionException
2094
-     */
2095
-    protected function _build_payment_json_response(
2096
-        EE_Payment $payment,
2097
-        $REG_IDs = array(),
2098
-        $delete_txn_reg_status_change = null
2099
-    ) {
2100
-        // was the payment deleted ?
2101
-        if (is_bool($delete_txn_reg_status_change)) {
2102
-            return array(
2103
-                'PAY_ID'                       => $payment->ID(),
2104
-                'amount'                       => $payment->amount(),
2105
-                'total_paid'                   => $payment->transaction()->paid(),
2106
-                'txn_status'                   => $payment->transaction()->status_ID(),
2107
-                'pay_status'                   => $payment->STS_ID(),
2108
-                'registrations'                => $this->_registration_payment_data_array($REG_IDs),
2109
-                'delete_txn_reg_status_change' => $delete_txn_reg_status_change,
2110
-            );
2111
-        } else {
2112
-            $this->_get_payment_status_array();
2113
-
2114
-            return array(
2115
-                'amount'           => $payment->amount(),
2116
-                'total_paid'       => $payment->transaction()->paid(),
2117
-                'txn_status'       => $payment->transaction()->status_ID(),
2118
-                'pay_status'       => $payment->STS_ID(),
2119
-                'PAY_ID'           => $payment->ID(),
2120
-                'STS_ID'           => $payment->STS_ID(),
2121
-                'status'           => self::$_pay_status[ $payment->STS_ID() ],
2122
-                'date'             => $payment->timestamp('Y-m-d', 'h:i a'),
2123
-                'method'           => strtoupper($payment->source()),
2124
-                'PM_ID'            => $payment->payment_method() ? $payment->payment_method()->ID() : 1,
2125
-                'gateway'          => $payment->payment_method()
2126
-                    ? $payment->payment_method()->admin_name()
2127
-                    : esc_html__("Unknown", 'event_espresso'),
2128
-                'gateway_response' => $payment->gateway_response(),
2129
-                'txn_id_chq_nmbr'  => $payment->txn_id_chq_nmbr(),
2130
-                'po_number'        => $payment->po_number(),
2131
-                'extra_accntng'    => $payment->extra_accntng(),
2132
-                'registrations'    => $this->_registration_payment_data_array($REG_IDs),
2133
-            );
2134
-        }
2135
-    }
2136
-
2137
-
2138
-    /**
2139
-     * delete_payment
2140
-     *    delete a payment or refund made towards a transaction
2141
-     *
2142
-     * @access public
2143
-     * @return void
2144
-     * @throws EE_Error
2145
-     * @throws InvalidArgumentException
2146
-     * @throws ReflectionException
2147
-     * @throws InvalidDataTypeException
2148
-     * @throws InvalidInterfaceException
2149
-     */
2150
-    public function delete_payment()
2151
-    {
2152
-        $json_response_data = array('return_data' => false);
2153
-        $PAY_ID = isset($this->_req_data['delete_txn_admin_payment']['PAY_ID'])
2154
-            ? absint($this->_req_data['delete_txn_admin_payment']['PAY_ID'])
2155
-            : 0;
2156
-        $can_delete = EE_Registry::instance()->CAP->current_user_can(
2157
-            'ee_delete_payments',
2158
-            'delete_payment_from_registration_details'
2159
-        );
2160
-        if ($PAY_ID && $can_delete) {
2161
-            $delete_txn_reg_status_change = isset($this->_req_data['delete_txn_reg_status_change'])
2162
-                ? $this->_req_data['delete_txn_reg_status_change']
2163
-                : false;
2164
-            $payment = EEM_Payment::instance()->get_one_by_ID($PAY_ID);
2165
-            if ($payment instanceof EE_Payment) {
2166
-                $REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment);
2167
-                /** @type EE_Transaction_Payments $transaction_payments */
2168
-                $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
2169
-                if ($transaction_payments->delete_payment_and_update_transaction($payment)) {
2170
-                    $json_response_data['return_data'] = $this->_build_payment_json_response(
2171
-                        $payment,
2172
-                        $REG_IDs,
2173
-                        $delete_txn_reg_status_change
2174
-                    );
2175
-                    if ($delete_txn_reg_status_change) {
2176
-                        $this->_req_data['txn_reg_status_change'] = $delete_txn_reg_status_change;
2177
-                        // MAKE sure we also add the delete_txn_req_status_change to the
2178
-                        // $_REQUEST global because that's how messages will be looking for it.
2179
-                        $_REQUEST['txn_reg_status_change'] = $delete_txn_reg_status_change;
2180
-                        $this->_maybe_send_notifications();
2181
-                        $this->_process_registration_status_change($payment->transaction(), $REG_IDs);
2182
-                    }
2183
-                }
2184
-            } else {
2185
-                EE_Error::add_error(
2186
-                    esc_html__('Valid Payment data could not be retrieved from the database.', 'event_espresso'),
2187
-                    __FILE__,
2188
-                    __FUNCTION__,
2189
-                    __LINE__
2190
-                );
2191
-            }
2192
-        } else {
2193
-            if ($can_delete) {
2194
-                EE_Error::add_error(
2195
-                    esc_html__(
2196
-                        'A valid Payment ID was not received, therefore payment form data could not be loaded.',
2197
-                        'event_espresso'
2198
-                    ),
2199
-                    __FILE__,
2200
-                    __FUNCTION__,
2201
-                    __LINE__
2202
-                );
2203
-            } else {
2204
-                EE_Error::add_error(
2205
-                    esc_html__(
2206
-                        'You do not have access to delete a payment.',
2207
-                        'event_espresso'
2208
-                    ),
2209
-                    __FILE__,
2210
-                    __FUNCTION__,
2211
-                    __LINE__
2212
-                );
2213
-            }
2214
-        }
2215
-        $notices = EE_Error::get_notices(false, false, false);
2216
-        $this->_template_args = array(
2217
-            'data'      => $json_response_data,
2218
-            'success'   => $notices['success'],
2219
-            'error'     => $notices['errors'],
2220
-            'attention' => $notices['attention'],
2221
-        );
2222
-        $this->_return_json();
2223
-    }
2224
-
2225
-
2226
-    /**
2227
-     * _registration_payment_data_array
2228
-     * adds info for 'owing' and 'paid' for each registration to the json response
2229
-     *
2230
-     * @access protected
2231
-     * @param array $REG_IDs
2232
-     * @return array
2233
-     * @throws EE_Error
2234
-     * @throws InvalidArgumentException
2235
-     * @throws InvalidDataTypeException
2236
-     * @throws InvalidInterfaceException
2237
-     * @throws ReflectionException
2238
-     */
2239
-    protected function _registration_payment_data_array($REG_IDs)
2240
-    {
2241
-        $registration_payment_data = array();
2242
-        // if non empty reg_ids lets get an array of registrations and update the values for the apply_payment/refund rows.
2243
-        if (! empty($REG_IDs)) {
2244
-            $registrations = EEM_Registration::instance()->get_all(array(array('REG_ID' => array('IN', $REG_IDs))));
2245
-            foreach ($registrations as $registration) {
2246
-                if ($registration instanceof EE_Registration) {
2247
-                    $registration_payment_data[ $registration->ID() ] = array(
2248
-                        'paid'  => $registration->pretty_paid(),
2249
-                        'owing' => EEH_Template::format_currency($registration->final_price() - $registration->paid()),
2250
-                    );
2251
-                }
2252
-            }
2253
-        }
2254
-
2255
-        return $registration_payment_data;
2256
-    }
2257
-
2258
-
2259
-    /**
2260
-     * _maybe_send_notifications
2261
-     * determines whether or not the admin has indicated that notifications should be sent.
2262
-     * If so, will toggle a filter switch for delivering registration notices.
2263
-     * If passed an EE_Payment object, then it will trigger payment notifications instead.
2264
-     *
2265
-     * @access protected
2266
-     * @param \EE_Payment | null $payment
2267
-     */
2268
-    protected function _maybe_send_notifications($payment = null)
2269
-    {
2270
-        switch ($payment instanceof EE_Payment) {
2271
-            // payment notifications
2272
-            case true:
2273
-                if (isset(
2274
-                    $this->_req_data['txn_payments'],
2275
-                    $this->_req_data['txn_payments']['send_notifications']
2276
-                )
2277
-                    && filter_var($this->_req_data['txn_payments']['send_notifications'], FILTER_VALIDATE_BOOLEAN)
2278
-                ) {
2279
-                    $this->_process_payment_notification($payment);
2280
-                }
2281
-                break;
2282
-            // registration notifications
2283
-            case false:
2284
-                if (isset(
2285
-                    $this->_req_data['txn_reg_status_change'],
2286
-                    $this->_req_data['txn_reg_status_change']['send_notifications']
2287
-                )
2288
-                    && filter_var($this->_req_data['txn_reg_status_change']['send_notifications'], FILTER_VALIDATE_BOOLEAN)
2289
-                ) {
2290
-                    add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true');
2291
-                }
2292
-                break;
2293
-        }
2294
-    }
2295
-
2296
-
2297
-    /**
2298
-     * _send_payment_reminder
2299
-     *    generates HTML for the View Transaction Details Admin page
2300
-     *
2301
-     * @access protected
2302
-     * @return void
2303
-     * @throws EE_Error
2304
-     * @throws InvalidArgumentException
2305
-     * @throws InvalidDataTypeException
2306
-     * @throws InvalidInterfaceException
2307
-     */
2308
-    protected function _send_payment_reminder()
2309
-    {
2310
-        $TXN_ID = ! empty($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : false;
2311
-        $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
2312
-        $query_args = isset($this->_req_data['redirect_to']) ? array(
2313
-            'action' => $this->_req_data['redirect_to'],
2314
-            'TXN_ID' => $this->_req_data['TXN_ID'],
2315
-        ) : array();
2316
-        do_action(
2317
-            'AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder',
2318
-            $transaction
2319
-        );
2320
-        $this->_redirect_after_action(
2321
-            false,
2322
-            esc_html__('payment reminder', 'event_espresso'),
2323
-            esc_html__('sent', 'event_espresso'),
2324
-            $query_args,
2325
-            true
2326
-        );
2327
-    }
2328
-
2329
-
2330
-    /**
2331
-     *  get_transactions
2332
-     *    get transactions for given parameters (used by list table)
2333
-     *
2334
-     * @param  int     $perpage how many transactions displayed per page
2335
-     * @param  boolean $count   return the count or objects
2336
-     * @param string   $view
2337
-     * @return mixed int = count || array of transaction objects
2338
-     * @throws EE_Error
2339
-     * @throws InvalidArgumentException
2340
-     * @throws InvalidDataTypeException
2341
-     * @throws InvalidInterfaceException
2342
-     */
2343
-    public function get_transactions($perpage, $count = false, $view = '')
2344
-    {
2345
-
2346
-        $TXN = EEM_Transaction::instance();
2347
-
2348
-        $start_date = isset($this->_req_data['txn-filter-start-date'])
2349
-            ? wp_strip_all_tags($this->_req_data['txn-filter-start-date'])
2350
-            : date(
2351
-                'm/d/Y',
2352
-                strtotime('-10 year')
2353
-            );
2354
-        $end_date = isset($this->_req_data['txn-filter-end-date'])
2355
-            ? wp_strip_all_tags($this->_req_data['txn-filter-end-date'])
2356
-            : date('m/d/Y');
2357
-
2358
-        // make sure our timestamps start and end right at the boundaries for each day
2359
-        $start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00';
2360
-        $end_date = date('Y-m-d', strtotime($end_date)) . ' 23:59:59';
2361
-
2362
-
2363
-        // convert to timestamps
2364
-        $start_date = strtotime($start_date);
2365
-        $end_date = strtotime($end_date);
2366
-
2367
-        // makes sure start date is the lowest value and vice versa
2368
-        $start_date = min($start_date, $end_date);
2369
-        $end_date = max($start_date, $end_date);
2370
-
2371
-        // convert to correct format for query
2372
-        $start_date = EEM_Transaction::instance()->convert_datetime_for_query(
2373
-            'TXN_timestamp',
2374
-            date('Y-m-d H:i:s', $start_date),
2375
-            'Y-m-d H:i:s'
2376
-        );
2377
-        $end_date = EEM_Transaction::instance()->convert_datetime_for_query(
2378
-            'TXN_timestamp',
2379
-            date('Y-m-d H:i:s', $end_date),
2380
-            'Y-m-d H:i:s'
2381
-        );
2382
-
2383
-
2384
-        // set orderby
2385
-        $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
2386
-
2387
-        switch ($this->_req_data['orderby']) {
2388
-            case 'TXN_ID':
2389
-                $orderby = 'TXN_ID';
2390
-                break;
2391
-            case 'ATT_fname':
2392
-                $orderby = 'Registration.Attendee.ATT_fname';
2393
-                break;
2394
-            case 'event_name':
2395
-                $orderby = 'Registration.Event.EVT_name';
2396
-                break;
2397
-            default: // 'TXN_timestamp'
2398
-                $orderby = 'TXN_timestamp';
2399
-        }
2400
-
2401
-        $sort = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC';
2402
-        $current_page = ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1;
2403
-        $per_page = ! empty($perpage) ? $perpage : 10;
2404
-        $per_page = ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page;
2405
-
2406
-        $offset = ($current_page - 1) * $per_page;
2407
-        $limit = array($offset, $per_page);
2408
-
2409
-        $_where = array(
2410
-            'TXN_timestamp'          => array('BETWEEN', array($start_date, $end_date)),
2411
-            'Registration.REG_count' => 1,
2412
-        );
2413
-
2414
-        if (isset($this->_req_data['EVT_ID'])) {
2415
-            $_where['Registration.EVT_ID'] = $this->_req_data['EVT_ID'];
2416
-        }
2417
-
2418
-        if (isset($this->_req_data['s'])) {
2419
-            $search_string = '%' . $this->_req_data['s'] . '%';
2420
-            $_where['OR'] = array(
2421
-                'Registration.Event.EVT_name'         => array('LIKE', $search_string),
2422
-                'Registration.Event.EVT_desc'         => array('LIKE', $search_string),
2423
-                'Registration.Event.EVT_short_desc'   => array('LIKE', $search_string),
2424
-                'Registration.Attendee.ATT_full_name' => array('LIKE', $search_string),
2425
-                'Registration.Attendee.ATT_fname'     => array('LIKE', $search_string),
2426
-                'Registration.Attendee.ATT_lname'     => array('LIKE', $search_string),
2427
-                'Registration.Attendee.ATT_short_bio' => array('LIKE', $search_string),
2428
-                'Registration.Attendee.ATT_email'     => array('LIKE', $search_string),
2429
-                'Registration.Attendee.ATT_address'   => array('LIKE', $search_string),
2430
-                'Registration.Attendee.ATT_address2'  => array('LIKE', $search_string),
2431
-                'Registration.Attendee.ATT_city'      => array('LIKE', $search_string),
2432
-                'Registration.REG_final_price'        => array('LIKE', $search_string),
2433
-                'Registration.REG_code'               => array('LIKE', $search_string),
2434
-                'Registration.REG_count'              => array('LIKE', $search_string),
2435
-                'Registration.REG_group_size'         => array('LIKE', $search_string),
2436
-                'Registration.Ticket.TKT_name'        => array('LIKE', $search_string),
2437
-                'Registration.Ticket.TKT_description' => array('LIKE', $search_string),
2438
-                'Payment.PAY_source'                  => array('LIKE', $search_string),
2439
-                'Payment.Payment_Method.PMD_name'     => array('LIKE', $search_string),
2440
-                'TXN_session_data'                    => array('LIKE', $search_string),
2441
-                'Payment.PAY_txn_id_chq_nmbr'         => array('LIKE', $search_string),
2442
-            );
2443
-        }
2444
-
2445
-        // failed transactions
2446
-        $failed = (! empty($this->_req_data['status']) && $this->_req_data['status'] === 'failed' && ! $count)
2447
-                  || ($count && $view === 'failed');
2448
-        $abandoned = (! empty($this->_req_data['status']) && $this->_req_data['status'] === 'abandoned' && ! $count)
2449
-                     || ($count && $view === 'abandoned');
2450
-
2451
-        if ($failed) {
2452
-            $_where['STS_ID'] = EEM_Transaction::failed_status_code;
2453
-        } elseif ($abandoned) {
2454
-            $_where['STS_ID'] = EEM_Transaction::abandoned_status_code;
2455
-        } else {
2456
-            $_where['STS_ID'] = array('!=', EEM_Transaction::failed_status_code);
2457
-            $_where['STS_ID*'] = array('!=', EEM_Transaction::abandoned_status_code);
2458
-        }
2459
-
2460
-        $query_params = array(
2461
-            $_where,
2462
-            'order_by'                 => array($orderby => $sort),
2463
-            'limit'                    => $limit,
2464
-            'default_where_conditions' => EEM_Base::default_where_conditions_this_only,
2465
-        );
2466
-
2467
-        $transactions = $count
2468
-            ? $TXN->count(array($_where), 'TXN_ID', true)
2469
-            : $TXN->get_all($query_params);
2470
-
2471
-        return $transactions;
2472
-    }
17
+	/**
18
+	 * @var EE_Transaction
19
+	 */
20
+	private $_transaction;
21
+
22
+	/**
23
+	 * @var EE_Session
24
+	 */
25
+	private $_session;
26
+
27
+	/**
28
+	 * @var array $_txn_status
29
+	 */
30
+	private static $_txn_status;
31
+
32
+	/**
33
+	 * @var array $_pay_status
34
+	 */
35
+	private static $_pay_status;
36
+
37
+	/**
38
+	 * @var array $_existing_reg_payment_REG_IDs
39
+	 */
40
+	protected $_existing_reg_payment_REG_IDs = null;
41
+
42
+
43
+	/**
44
+	 * @Constructor
45
+	 * @access public
46
+	 * @param bool $routing
47
+	 * @throws EE_Error
48
+	 * @throws InvalidArgumentException
49
+	 * @throws ReflectionException
50
+	 * @throws InvalidDataTypeException
51
+	 * @throws InvalidInterfaceException
52
+	 */
53
+	public function __construct($routing = true)
54
+	{
55
+		parent::__construct($routing);
56
+	}
57
+
58
+
59
+	/**
60
+	 *    _init_page_props
61
+	 *
62
+	 * @return void
63
+	 */
64
+	protected function _init_page_props()
65
+	{
66
+		$this->page_slug = TXN_PG_SLUG;
67
+		$this->page_label = esc_html__('Transactions', 'event_espresso');
68
+		$this->_admin_base_url = TXN_ADMIN_URL;
69
+		$this->_admin_base_path = TXN_ADMIN;
70
+	}
71
+
72
+
73
+	/**
74
+	 *    _ajax_hooks
75
+	 *
76
+	 * @return void
77
+	 */
78
+	protected function _ajax_hooks()
79
+	{
80
+		add_action('wp_ajax_espresso_apply_payment', array($this, 'apply_payments_or_refunds'));
81
+		add_action('wp_ajax_espresso_apply_refund', array($this, 'apply_payments_or_refunds'));
82
+		add_action('wp_ajax_espresso_delete_payment', array($this, 'delete_payment'));
83
+	}
84
+
85
+
86
+	/**
87
+	 *    _define_page_props
88
+	 *
89
+	 * @return void
90
+	 */
91
+	protected function _define_page_props()
92
+	{
93
+		$this->_admin_page_title = $this->page_label;
94
+		$this->_labels = array(
95
+			'buttons' => array(
96
+				'add'    => esc_html__('Add New Transaction', 'event_espresso'),
97
+				'edit'   => esc_html__('Edit Transaction', 'event_espresso'),
98
+				'delete' => esc_html__('Delete Transaction', 'event_espresso'),
99
+			),
100
+		);
101
+	}
102
+
103
+
104
+	/**
105
+	 *        grab url requests and route them
106
+	 *
107
+	 * @access private
108
+	 * @return void
109
+	 * @throws EE_Error
110
+	 * @throws InvalidArgumentException
111
+	 * @throws InvalidDataTypeException
112
+	 * @throws InvalidInterfaceException
113
+	 */
114
+	public function _set_page_routes()
115
+	{
116
+
117
+		$this->_set_transaction_status_array();
118
+
119
+		$txn_id = ! empty($this->_req_data['TXN_ID'])
120
+				  && ! is_array($this->_req_data['TXN_ID'])
121
+			? $this->_req_data['TXN_ID']
122
+			: 0;
123
+
124
+		$this->_page_routes = array(
125
+
126
+			'default' => array(
127
+				'func'       => '_transactions_overview_list_table',
128
+				'capability' => 'ee_read_transactions',
129
+			),
130
+
131
+			'view_transaction' => array(
132
+				'func'       => '_transaction_details',
133
+				'capability' => 'ee_read_transaction',
134
+				'obj_id'     => $txn_id,
135
+			),
136
+
137
+			'send_payment_reminder' => array(
138
+				'func'       => '_send_payment_reminder',
139
+				'noheader'   => true,
140
+				'capability' => 'ee_send_message',
141
+			),
142
+
143
+			'espresso_apply_payment' => array(
144
+				'func'       => 'apply_payments_or_refunds',
145
+				'noheader'   => true,
146
+				'capability' => 'ee_edit_payments',
147
+			),
148
+
149
+			'espresso_apply_refund' => array(
150
+				'func'       => 'apply_payments_or_refunds',
151
+				'noheader'   => true,
152
+				'capability' => 'ee_edit_payments',
153
+			),
154
+
155
+			'espresso_delete_payment' => array(
156
+				'func'       => 'delete_payment',
157
+				'noheader'   => true,
158
+				'capability' => 'ee_delete_payments',
159
+			),
160
+
161
+		);
162
+	}
163
+
164
+
165
+	protected function _set_page_config()
166
+	{
167
+		$this->_page_config = array(
168
+			'default'          => array(
169
+				'nav'           => array(
170
+					'label' => esc_html__('Overview', 'event_espresso'),
171
+					'order' => 10,
172
+				),
173
+				'list_table'    => 'EE_Admin_Transactions_List_Table',
174
+				'help_tabs'     => array(
175
+					'transactions_overview_help_tab'                       => array(
176
+						'title'    => esc_html__('Transactions Overview', 'event_espresso'),
177
+						'filename' => 'transactions_overview',
178
+					),
179
+					'transactions_overview_table_column_headings_help_tab' => array(
180
+						'title'    => esc_html__('Transactions Table Column Headings', 'event_espresso'),
181
+						'filename' => 'transactions_overview_table_column_headings',
182
+					),
183
+					'transactions_overview_views_filters_help_tab'         => array(
184
+						'title'    => esc_html__('Transaction Views & Filters & Search', 'event_espresso'),
185
+						'filename' => 'transactions_overview_views_filters_search',
186
+					),
187
+				),
188
+				'help_tour'     => array('Transactions_Overview_Help_Tour'),
189
+				/**
190
+				 * commented out because currently we are not displaying tips for transaction list table status but this
191
+				 * may change in a later iteration so want to keep the code for then.
192
+				 */
193
+				// 'qtips' => array( 'Transactions_List_Table_Tips' ),
194
+				'require_nonce' => false,
195
+			),
196
+			'view_transaction' => array(
197
+				'nav'       => array(
198
+					'label'      => esc_html__('View Transaction', 'event_espresso'),
199
+					'order'      => 5,
200
+					'url'        => isset($this->_req_data['TXN_ID'])
201
+						? add_query_arg(array('TXN_ID' => $this->_req_data['TXN_ID']), $this->_current_page_view_url)
202
+						: $this->_admin_base_url,
203
+					'persistent' => false,
204
+				),
205
+				'help_tabs' => array(
206
+					'transactions_view_transaction_help_tab'                                              => array(
207
+						'title'    => esc_html__('View Transaction', 'event_espresso'),
208
+						'filename' => 'transactions_view_transaction',
209
+					),
210
+					'transactions_view_transaction_transaction_details_table_help_tab'                    => array(
211
+						'title'    => esc_html__('Transaction Details Table', 'event_espresso'),
212
+						'filename' => 'transactions_view_transaction_transaction_details_table',
213
+					),
214
+					'transactions_view_transaction_attendees_registered_help_tab'                         => array(
215
+						'title'    => esc_html__('Attendees Registered', 'event_espresso'),
216
+						'filename' => 'transactions_view_transaction_attendees_registered',
217
+					),
218
+					'transactions_view_transaction_views_primary_registrant_billing_information_help_tab' => array(
219
+						'title'    => esc_html__('Primary Registrant & Billing Information', 'event_espresso'),
220
+						'filename' => 'transactions_view_transaction_primary_registrant_billing_information',
221
+					),
222
+				),
223
+				'qtips'     => array('Transaction_Details_Tips'),
224
+				'help_tour' => array('Transaction_Details_Help_Tour'),
225
+				'metaboxes' => array('_transaction_details_metaboxes'),
226
+
227
+				'require_nonce' => false,
228
+			),
229
+		);
230
+	}
231
+
232
+
233
+	/**
234
+	 * The below methods aren't used by this class currently
235
+	 */
236
+	protected function _add_screen_options()
237
+	{
238
+		// noop
239
+	}
240
+
241
+	protected function _add_feature_pointers()
242
+	{
243
+		// noop
244
+	}
245
+
246
+	public function admin_init()
247
+	{
248
+		// IF a registration was JUST added via the admin...
249
+		if (isset(
250
+			$this->_req_data['redirect_from'],
251
+			$this->_req_data['EVT_ID'],
252
+			$this->_req_data['event_name']
253
+		)) {
254
+			// then set a cookie so that we can block any attempts to use
255
+			// the back button as a way to enter another registration.
256
+			setcookie(
257
+				'ee_registration_added',
258
+				$this->_req_data['EVT_ID'],
259
+				time() + WEEK_IN_SECONDS,
260
+				'/'
261
+			);
262
+			// and update the global
263
+			$_COOKIE['ee_registration_added'] = $this->_req_data['EVT_ID'];
264
+		}
265
+		EE_Registry::$i18n_js_strings['invalid_server_response'] = esc_html__(
266
+			'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.',
267
+			'event_espresso'
268
+		);
269
+		EE_Registry::$i18n_js_strings['error_occurred'] = esc_html__(
270
+			'An error occurred! Please refresh the page and try again.',
271
+			'event_espresso'
272
+		);
273
+		EE_Registry::$i18n_js_strings['txn_status_array'] = self::$_txn_status;
274
+		EE_Registry::$i18n_js_strings['pay_status_array'] = self::$_pay_status;
275
+		EE_Registry::$i18n_js_strings['payments_total'] = esc_html__('Payments Total', 'event_espresso');
276
+		EE_Registry::$i18n_js_strings['transaction_overpaid'] = esc_html__(
277
+			'This transaction has been overpaid ! Payments Total',
278
+			'event_espresso'
279
+		);
280
+	}
281
+
282
+	public function admin_notices()
283
+	{
284
+		// noop
285
+	}
286
+
287
+	public function admin_footer_scripts()
288
+	{
289
+		// noop
290
+	}
291
+
292
+
293
+	/**
294
+	 * _set_transaction_status_array
295
+	 * sets list of transaction statuses
296
+	 *
297
+	 * @access private
298
+	 * @return void
299
+	 * @throws EE_Error
300
+	 * @throws InvalidArgumentException
301
+	 * @throws InvalidDataTypeException
302
+	 * @throws InvalidInterfaceException
303
+	 */
304
+	private function _set_transaction_status_array()
305
+	{
306
+		self::$_txn_status = EEM_Transaction::instance()->status_array(true);
307
+	}
308
+
309
+
310
+	/**
311
+	 * get_transaction_status_array
312
+	 * return the transaction status array for wp_list_table
313
+	 *
314
+	 * @access public
315
+	 * @return array
316
+	 */
317
+	public function get_transaction_status_array()
318
+	{
319
+		return self::$_txn_status;
320
+	}
321
+
322
+
323
+	/**
324
+	 *    get list of payment statuses
325
+	 *
326
+	 * @access private
327
+	 * @return void
328
+	 * @throws EE_Error
329
+	 * @throws InvalidArgumentException
330
+	 * @throws InvalidDataTypeException
331
+	 * @throws InvalidInterfaceException
332
+	 */
333
+	private function _get_payment_status_array()
334
+	{
335
+		self::$_pay_status = EEM_Payment::instance()->status_array(true);
336
+		$this->_template_args['payment_status'] = self::$_pay_status;
337
+	}
338
+
339
+
340
+	/**
341
+	 *    _add_screen_options_default
342
+	 *
343
+	 * @access protected
344
+	 * @return void
345
+	 * @throws InvalidArgumentException
346
+	 * @throws InvalidDataTypeException
347
+	 * @throws InvalidInterfaceException
348
+	 */
349
+	protected function _add_screen_options_default()
350
+	{
351
+		$this->_per_page_screen_option();
352
+	}
353
+
354
+
355
+	/**
356
+	 * load_scripts_styles
357
+	 *
358
+	 * @access public
359
+	 * @return void
360
+	 */
361
+	public function load_scripts_styles()
362
+	{
363
+		// enqueue style
364
+		wp_register_style(
365
+			'espresso_txn',
366
+			TXN_ASSETS_URL . 'espresso_transactions_admin.css',
367
+			array(),
368
+			EVENT_ESPRESSO_VERSION
369
+		);
370
+		wp_enqueue_style('espresso_txn');
371
+		// scripts
372
+		wp_register_script(
373
+			'espresso_txn',
374
+			TXN_ASSETS_URL . 'espresso_transactions_admin.js',
375
+			array(
376
+				'ee_admin_js',
377
+				'ee-datepicker',
378
+				'jquery-ui-datepicker',
379
+				'jquery-ui-draggable',
380
+				'ee-dialog',
381
+				'ee-accounting',
382
+				'ee-serialize-full-array',
383
+			),
384
+			EVENT_ESPRESSO_VERSION,
385
+			true
386
+		);
387
+		wp_enqueue_script('espresso_txn');
388
+	}
389
+
390
+
391
+	/**
392
+	 *    load_scripts_styles_view_transaction
393
+	 *
394
+	 * @access public
395
+	 * @return void
396
+	 */
397
+	public function load_scripts_styles_view_transaction()
398
+	{
399
+		// styles
400
+		wp_enqueue_style('espresso-ui-theme');
401
+	}
402
+
403
+
404
+	/**
405
+	 *    load_scripts_styles_default
406
+	 *
407
+	 * @access public
408
+	 * @return void
409
+	 */
410
+	public function load_scripts_styles_default()
411
+	{
412
+		// styles
413
+		wp_enqueue_style('espresso-ui-theme');
414
+	}
415
+
416
+
417
+	/**
418
+	 *    _set_list_table_views_default
419
+	 *
420
+	 * @access protected
421
+	 * @return void
422
+	 */
423
+	protected function _set_list_table_views_default()
424
+	{
425
+		$this->_views = array(
426
+			'all'       => array(
427
+				'slug'  => 'all',
428
+				'label' => esc_html__('View All Transactions', 'event_espresso'),
429
+				'count' => 0,
430
+			),
431
+			'abandoned' => array(
432
+				'slug'  => 'abandoned',
433
+				'label' => esc_html__('Abandoned Transactions', 'event_espresso'),
434
+				'count' => 0,
435
+			),
436
+			'failed'    => array(
437
+				'slug'  => 'failed',
438
+				'label' => esc_html__('Failed Transactions', 'event_espresso'),
439
+				'count' => 0,
440
+			),
441
+		);
442
+	}
443
+
444
+
445
+	/**
446
+	 * _set_transaction_object
447
+	 * This sets the _transaction property for the transaction details screen
448
+	 *
449
+	 * @access private
450
+	 * @return void
451
+	 * @throws EE_Error
452
+	 * @throws InvalidArgumentException
453
+	 * @throws RuntimeException
454
+	 * @throws InvalidDataTypeException
455
+	 * @throws InvalidInterfaceException
456
+	 * @throws ReflectionException
457
+	 */
458
+	private function _set_transaction_object()
459
+	{
460
+		if ($this->_transaction instanceof EE_Transaction) {
461
+			return;
462
+		} //get out we've already set the object
463
+
464
+		$TXN_ID = ! empty($this->_req_data['TXN_ID'])
465
+			? absint($this->_req_data['TXN_ID'])
466
+			: false;
467
+
468
+		// get transaction object
469
+		$this->_transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
470
+		$this->_session = $this->_transaction instanceof EE_Transaction
471
+			? $this->_transaction->get('TXN_session_data')
472
+			: null;
473
+		$this->_transaction->verify_abandoned_transaction_status();
474
+
475
+		if (! $this->_transaction instanceof EE_Transaction) {
476
+			$error_msg = sprintf(
477
+				esc_html__(
478
+					'An error occurred and the details for the transaction with the ID # %d could not be retrieved.',
479
+					'event_espresso'
480
+				),
481
+				$TXN_ID
482
+			);
483
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
484
+		}
485
+	}
486
+
487
+
488
+	/**
489
+	 *    _transaction_legend_items
490
+	 *
491
+	 * @access protected
492
+	 * @return array
493
+	 * @throws EE_Error
494
+	 * @throws InvalidArgumentException
495
+	 * @throws ReflectionException
496
+	 * @throws InvalidDataTypeException
497
+	 * @throws InvalidInterfaceException
498
+	 */
499
+	protected function _transaction_legend_items()
500
+	{
501
+		EE_Registry::instance()->load_helper('MSG_Template');
502
+		$items = array();
503
+
504
+		if (EE_Registry::instance()->CAP->current_user_can(
505
+			'ee_read_global_messages',
506
+			'view_filtered_messages'
507
+		)) {
508
+			$related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
509
+			if (is_array($related_for_icon)
510
+				&& isset($related_for_icon['css_class'], $related_for_icon['label'])
511
+			) {
512
+				$items['view_related_messages'] = array(
513
+					'class' => $related_for_icon['css_class'],
514
+					'desc'  => $related_for_icon['label'],
515
+				);
516
+			}
517
+		}
518
+
519
+		$items = apply_filters(
520
+			'FHEE__Transactions_Admin_Page___transaction_legend_items__items',
521
+			array_merge(
522
+				$items,
523
+				array(
524
+					'view_details'          => array(
525
+						'class' => 'dashicons dashicons-cart',
526
+						'desc'  => esc_html__('View Transaction Details', 'event_espresso'),
527
+					),
528
+					'view_invoice'          => array(
529
+						'class' => 'dashicons dashicons-media-spreadsheet',
530
+						'desc'  => esc_html__('View Transaction Invoice', 'event_espresso'),
531
+					),
532
+					'view_receipt'          => array(
533
+						'class' => 'dashicons dashicons-media-default',
534
+						'desc'  => esc_html__('View Transaction Receipt', 'event_espresso'),
535
+					),
536
+					'view_registration'     => array(
537
+						'class' => 'dashicons dashicons-clipboard',
538
+						'desc'  => esc_html__('View Registration Details', 'event_espresso'),
539
+					),
540
+					'payment_overview_link' => array(
541
+						'class' => 'dashicons dashicons-money',
542
+						'desc'  => esc_html__('Make Payment on Frontend', 'event_espresso'),
543
+					),
544
+				)
545
+			)
546
+		);
547
+
548
+		if (EE_Registry::instance()->CAP->current_user_can(
549
+			'ee_send_message',
550
+			'espresso_transactions_send_payment_reminder'
551
+		)) {
552
+			if (EEH_MSG_Template::is_mt_active('payment_reminder')) {
553
+				$items['send_payment_reminder'] = array(
554
+					'class' => 'dashicons dashicons-email-alt',
555
+					'desc'  => esc_html__('Send Payment Reminder', 'event_espresso'),
556
+				);
557
+			} else {
558
+				$items['blank*'] = array(
559
+					'class' => '',
560
+					'desc'  => '',
561
+				);
562
+			}
563
+		} else {
564
+			$items['blank*'] = array(
565
+				'class' => '',
566
+				'desc'  => '',
567
+			);
568
+		}
569
+		$more_items = apply_filters(
570
+			'FHEE__Transactions_Admin_Page___transaction_legend_items__more_items',
571
+			array(
572
+				'overpaid'   => array(
573
+					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::overpaid_status_code,
574
+					'desc'  => EEH_Template::pretty_status(
575
+						EEM_Transaction::overpaid_status_code,
576
+						false,
577
+						'sentence'
578
+					),
579
+				),
580
+				'complete'   => array(
581
+					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::complete_status_code,
582
+					'desc'  => EEH_Template::pretty_status(
583
+						EEM_Transaction::complete_status_code,
584
+						false,
585
+						'sentence'
586
+					),
587
+				),
588
+				'incomplete' => array(
589
+					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::incomplete_status_code,
590
+					'desc'  => EEH_Template::pretty_status(
591
+						EEM_Transaction::incomplete_status_code,
592
+						false,
593
+						'sentence'
594
+					),
595
+				),
596
+				'abandoned'  => array(
597
+					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::abandoned_status_code,
598
+					'desc'  => EEH_Template::pretty_status(
599
+						EEM_Transaction::abandoned_status_code,
600
+						false,
601
+						'sentence'
602
+					),
603
+				),
604
+				'failed'     => array(
605
+					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::failed_status_code,
606
+					'desc'  => EEH_Template::pretty_status(
607
+						EEM_Transaction::failed_status_code,
608
+						false,
609
+						'sentence'
610
+					),
611
+				),
612
+			)
613
+		);
614
+
615
+		return array_merge($items, $more_items);
616
+	}
617
+
618
+
619
+	/**
620
+	 *    _transactions_overview_list_table
621
+	 *
622
+	 * @access protected
623
+	 * @return void
624
+	 * @throws DomainException
625
+	 * @throws EE_Error
626
+	 * @throws InvalidArgumentException
627
+	 * @throws InvalidDataTypeException
628
+	 * @throws InvalidInterfaceException
629
+	 * @throws ReflectionException
630
+	 */
631
+	protected function _transactions_overview_list_table()
632
+	{
633
+		$this->_admin_page_title = esc_html__('Transactions', 'event_espresso');
634
+		$event = isset($this->_req_data['EVT_ID'])
635
+			? EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID'])
636
+			: null;
637
+		$this->_template_args['admin_page_header'] = $event instanceof EE_Event
638
+			? sprintf(
639
+				esc_html__(
640
+					'%sViewing Transactions for the Event: %s%s',
641
+					'event_espresso'
642
+				),
643
+				'<h3>',
644
+				'<a href="'
645
+				. EE_Admin_Page::add_query_args_and_nonce(
646
+					array('action' => 'edit', 'post' => $event->ID()),
647
+					EVENTS_ADMIN_URL
648
+				)
649
+				. '" title="'
650
+				. esc_attr__(
651
+					'Click to Edit event',
652
+					'event_espresso'
653
+				)
654
+				. '">' . $event->get('EVT_name') . '</a>',
655
+				'</h3>'
656
+			)
657
+			: '';
658
+		$this->_template_args['after_list_table'] = $this->_display_legend($this->_transaction_legend_items());
659
+		$this->display_admin_list_table_page_with_no_sidebar();
660
+	}
661
+
662
+
663
+	/**
664
+	 *    _transaction_details
665
+	 * generates HTML for the View Transaction Details Admin page
666
+	 *
667
+	 * @access protected
668
+	 * @return void
669
+	 * @throws DomainException
670
+	 * @throws EE_Error
671
+	 * @throws InvalidArgumentException
672
+	 * @throws InvalidDataTypeException
673
+	 * @throws InvalidInterfaceException
674
+	 * @throws RuntimeException
675
+	 * @throws ReflectionException
676
+	 */
677
+	protected function _transaction_details()
678
+	{
679
+		do_action('AHEE__Transactions_Admin_Page__transaction_details__start', $this->_transaction);
680
+
681
+		$this->_set_transaction_status_array();
682
+
683
+		$this->_template_args = array();
684
+		$this->_template_args['transactions_page'] = $this->_wp_page_slug;
685
+
686
+		$this->_set_transaction_object();
687
+
688
+		$primary_registration = $this->_transaction->primary_registration();
689
+		$attendee = $primary_registration instanceof EE_Registration
690
+			? $primary_registration->attendee()
691
+			: null;
692
+
693
+		$this->_template_args['txn_nmbr']['value'] = $this->_transaction->ID();
694
+		$this->_template_args['txn_nmbr']['label'] = esc_html__('Transaction Number', 'event_espresso');
695
+
696
+		$this->_template_args['txn_datetime']['value'] = $this->_transaction->get_i18n_datetime('TXN_timestamp');
697
+		$this->_template_args['txn_datetime']['label'] = esc_html__('Date', 'event_espresso');
698
+
699
+		$this->_template_args['txn_status']['value'] = self::$_txn_status[ $this->_transaction->get('STS_ID') ];
700
+		$this->_template_args['txn_status']['label'] = esc_html__('Transaction Status', 'event_espresso');
701
+		$this->_template_args['txn_status']['class'] = 'status-' . $this->_transaction->get('STS_ID');
702
+
703
+		$this->_template_args['grand_total'] = $this->_transaction->get('TXN_total');
704
+		$this->_template_args['total_paid'] = $this->_transaction->get('TXN_paid');
705
+
706
+		$amount_due = $this->_transaction->get('TXN_total') - $this->_transaction->get('TXN_paid');
707
+		$this->_template_args['amount_due'] = EEH_Template::format_currency(
708
+			$amount_due,
709
+			true
710
+		);
711
+		if (EE_Registry::instance()->CFG->currency->sign_b4) {
712
+			$this->_template_args['amount_due'] = EE_Registry::instance()->CFG->currency->sign
713
+												  . $this->_template_args['amount_due'];
714
+		} else {
715
+			$this->_template_args['amount_due'] .= EE_Registry::instance()->CFG->currency->sign;
716
+		}
717
+		$this->_template_args['amount_due_class'] = '';
718
+
719
+		if ($this->_transaction->get('TXN_paid') == $this->_transaction->get('TXN_total')) {
720
+			// paid in full
721
+			$this->_template_args['amount_due'] = false;
722
+		} elseif ($this->_transaction->get('TXN_paid') > $this->_transaction->get('TXN_total')) {
723
+			// overpaid
724
+			$this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn';
725
+		} elseif ($this->_transaction->get('TXN_total') > 0
726
+				  && $this->_transaction->get('TXN_paid') > 0
727
+		) {
728
+			// monies owing
729
+			$this->_template_args['amount_due_class'] = 'txn-overview-part-payment-spn';
730
+		} elseif ($this->_transaction->get('TXN_total') > 0
731
+				  && $this->_transaction->get('TXN_paid') == 0
732
+		) {
733
+			// no payments made yet
734
+			$this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn';
735
+		} elseif ($this->_transaction->get('TXN_total') == 0) {
736
+			// free event
737
+			$this->_template_args['amount_due'] = false;
738
+		}
739
+
740
+		$payment_method = $this->_transaction->payment_method();
741
+
742
+		$this->_template_args['method_of_payment_name'] = $payment_method instanceof EE_Payment_Method
743
+			? $payment_method->admin_name()
744
+			: esc_html__('Unknown', 'event_espresso');
745
+
746
+		$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
747
+		// link back to overview
748
+		$this->_template_args['txn_overview_url'] = ! empty($_SERVER['HTTP_REFERER'])
749
+			? $_SERVER['HTTP_REFERER']
750
+			: TXN_ADMIN_URL;
751
+
752
+
753
+		// next link
754
+		$next_txn = $this->_transaction->next(
755
+			null,
756
+			array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))),
757
+			'TXN_ID'
758
+		);
759
+		$this->_template_args['next_transaction'] = $next_txn
760
+			? $this->_next_link(
761
+				EE_Admin_Page::add_query_args_and_nonce(
762
+					array('action' => 'view_transaction', 'TXN_ID' => $next_txn['TXN_ID']),
763
+					TXN_ADMIN_URL
764
+				),
765
+				'dashicons dashicons-arrow-right ee-icon-size-22'
766
+			)
767
+			: '';
768
+		// previous link
769
+		$previous_txn = $this->_transaction->previous(
770
+			null,
771
+			array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))),
772
+			'TXN_ID'
773
+		);
774
+		$this->_template_args['previous_transaction'] = $previous_txn
775
+			? $this->_previous_link(
776
+				EE_Admin_Page::add_query_args_and_nonce(
777
+					array('action' => 'view_transaction', 'TXN_ID' => $previous_txn['TXN_ID']),
778
+					TXN_ADMIN_URL
779
+				),
780
+				'dashicons dashicons-arrow-left ee-icon-size-22'
781
+			)
782
+			: '';
783
+
784
+		// were we just redirected here after adding a new registration ???
785
+		if (isset(
786
+			$this->_req_data['redirect_from'],
787
+			$this->_req_data['EVT_ID'],
788
+			$this->_req_data['event_name']
789
+		)) {
790
+			if (EE_Registry::instance()->CAP->current_user_can(
791
+				'ee_edit_registrations',
792
+				'espresso_registrations_new_registration',
793
+				$this->_req_data['EVT_ID']
794
+			)) {
795
+				$this->_admin_page_title .= '<a id="add-new-registration" class="add-new-h2 button-primary" href="';
796
+				$this->_admin_page_title .= EE_Admin_Page::add_query_args_and_nonce(
797
+					array(
798
+						'page'     => 'espresso_registrations',
799
+						'action'   => 'new_registration',
800
+						'return'   => 'default',
801
+						'TXN_ID'   => $this->_transaction->ID(),
802
+						'event_id' => $this->_req_data['EVT_ID'],
803
+					),
804
+					REG_ADMIN_URL
805
+				);
806
+				$this->_admin_page_title .= '">';
807
+
808
+				$this->_admin_page_title .= sprintf(
809
+					esc_html__('Add Another New Registration to Event: "%1$s" ?', 'event_espresso'),
810
+					htmlentities(urldecode($this->_req_data['event_name']), ENT_QUOTES, 'UTF-8')
811
+				);
812
+				$this->_admin_page_title .= '</a>';
813
+			}
814
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
815
+		}
816
+		// grab messages at the last second
817
+		$this->_template_args['notices'] = EE_Error::get_notices();
818
+		// path to template
819
+		$template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_header.template.php';
820
+		$this->_template_args['admin_page_header'] = EEH_Template::display_template(
821
+			$template_path,
822
+			$this->_template_args,
823
+			true
824
+		);
825
+
826
+		// the details template wrapper
827
+		$this->display_admin_page_with_sidebar();
828
+	}
829
+
830
+
831
+	/**
832
+	 *        _transaction_details_metaboxes
833
+	 *
834
+	 * @access protected
835
+	 * @return void
836
+	 * @throws EE_Error
837
+	 * @throws InvalidArgumentException
838
+	 * @throws InvalidDataTypeException
839
+	 * @throws InvalidInterfaceException
840
+	 * @throws RuntimeException
841
+	 * @throws ReflectionException
842
+	 */
843
+	protected function _transaction_details_metaboxes()
844
+	{
845
+
846
+		$this->_set_transaction_object();
847
+
848
+		add_meta_box(
849
+			'edit-txn-details-mbox',
850
+			esc_html__('Transaction Details', 'event_espresso'),
851
+			array($this, 'txn_details_meta_box'),
852
+			$this->_wp_page_slug,
853
+			'normal',
854
+			'high'
855
+		);
856
+		add_meta_box(
857
+			'edit-txn-attendees-mbox',
858
+			esc_html__('Attendees Registered in this Transaction', 'event_espresso'),
859
+			array($this, 'txn_attendees_meta_box'),
860
+			$this->_wp_page_slug,
861
+			'normal',
862
+			'high',
863
+			array('TXN_ID' => $this->_transaction->ID())
864
+		);
865
+		add_meta_box(
866
+			'edit-txn-registrant-mbox',
867
+			esc_html__('Primary Contact', 'event_espresso'),
868
+			array($this, 'txn_registrant_side_meta_box'),
869
+			$this->_wp_page_slug,
870
+			'side',
871
+			'high'
872
+		);
873
+		add_meta_box(
874
+			'edit-txn-billing-info-mbox',
875
+			esc_html__('Billing Information', 'event_espresso'),
876
+			array($this, 'txn_billing_info_side_meta_box'),
877
+			$this->_wp_page_slug,
878
+			'side',
879
+			'high'
880
+		);
881
+	}
882
+
883
+
884
+	/**
885
+	 * Callback for transaction actions metabox.
886
+	 *
887
+	 * @param EE_Transaction|null $transaction
888
+	 * @throws DomainException
889
+	 * @throws EE_Error
890
+	 * @throws InvalidArgumentException
891
+	 * @throws InvalidDataTypeException
892
+	 * @throws InvalidInterfaceException
893
+	 * @throws ReflectionException
894
+	 * @throws RuntimeException
895
+	 */
896
+	public function getActionButtons(EE_Transaction $transaction = null)
897
+	{
898
+		$content = '';
899
+		$actions = array();
900
+		if (! $transaction instanceof EE_Transaction) {
901
+			return $content;
902
+		}
903
+		/** @var EE_Registration $primary_registration */
904
+		$primary_registration = $transaction->primary_registration();
905
+		$attendee = $primary_registration instanceof EE_Registration
906
+			? $primary_registration->attendee()
907
+			: null;
908
+
909
+		if ($attendee instanceof EE_Attendee
910
+			&& EE_Registry::instance()->CAP->current_user_can(
911
+				'ee_send_message',
912
+				'espresso_transactions_send_payment_reminder'
913
+			)
914
+		) {
915
+			$actions['payment_reminder'] =
916
+				EEH_MSG_Template::is_mt_active('payment_reminder')
917
+				&& $this->_transaction->get('STS_ID') !== EEM_Transaction::complete_status_code
918
+				&& $this->_transaction->get('STS_ID') !== EEM_Transaction::overpaid_status_code
919
+					? EEH_Template::get_button_or_link(
920
+						EE_Admin_Page::add_query_args_and_nonce(
921
+							array(
922
+								'action'      => 'send_payment_reminder',
923
+								'TXN_ID'      => $this->_transaction->ID(),
924
+								'redirect_to' => 'view_transaction',
925
+							),
926
+							TXN_ADMIN_URL
927
+						),
928
+						esc_html__(' Send Payment Reminder', 'event_espresso'),
929
+						'button secondary-button',
930
+						'dashicons dashicons-email-alt'
931
+					)
932
+					: '';
933
+		}
934
+
935
+		if ($primary_registration instanceof EE_Registration
936
+			&& EEH_MSG_Template::is_mt_active('receipt')
937
+		) {
938
+			$actions['receipt'] = EEH_Template::get_button_or_link(
939
+				$primary_registration->receipt_url(),
940
+				esc_html__('View Receipt', 'event_espresso'),
941
+				'button secondary-button',
942
+				'dashicons dashicons-media-default'
943
+			);
944
+		}
945
+
946
+		if ($primary_registration instanceof EE_Registration
947
+			&& EEH_MSG_Template::is_mt_active('invoice')
948
+		) {
949
+			$actions['invoice'] = EEH_Template::get_button_or_link(
950
+				$primary_registration->invoice_url(),
951
+				esc_html__('View Invoice', 'event_espresso'),
952
+				'button secondary-button',
953
+				'dashicons dashicons-media-spreadsheet'
954
+			);
955
+		}
956
+		$actions = array_filter(
957
+			apply_filters('FHEE__Transactions_Admin_Page__getActionButtons__actions', $actions, $transaction)
958
+		);
959
+		if ($actions) {
960
+			$content = '<ul>';
961
+			$content .= '<li>' . implode('</li><li>', $actions) . '</li>';
962
+			$content .= '</uL>';
963
+		}
964
+		return $content;
965
+	}
966
+
967
+
968
+	/**
969
+	 * txn_details_meta_box
970
+	 * generates HTML for the Transaction main meta box
971
+	 *
972
+	 * @return void
973
+	 * @throws DomainException
974
+	 * @throws EE_Error
975
+	 * @throws InvalidArgumentException
976
+	 * @throws InvalidDataTypeException
977
+	 * @throws InvalidInterfaceException
978
+	 * @throws RuntimeException
979
+	 * @throws ReflectionException
980
+	 */
981
+	public function txn_details_meta_box()
982
+	{
983
+		$this->_set_transaction_object();
984
+		$this->_template_args['TXN_ID'] = $this->_transaction->ID();
985
+		$this->_template_args['attendee'] = $this->_transaction->primary_registration() instanceof EE_Registration
986
+			? $this->_transaction->primary_registration()->attendee()
987
+			: null;
988
+		$this->_template_args['can_edit_payments'] = EE_Registry::instance()->CAP->current_user_can(
989
+			'ee_edit_payments',
990
+			'apply_payment_or_refund_from_registration_details'
991
+		);
992
+		$this->_template_args['can_delete_payments'] = EE_Registry::instance()->CAP->current_user_can(
993
+			'ee_delete_payments',
994
+			'delete_payment_from_registration_details'
995
+		);
996
+
997
+		// get line table
998
+		EEH_Autoloader::register_line_item_display_autoloaders();
999
+		$Line_Item_Display = new EE_Line_Item_Display(
1000
+			'admin_table',
1001
+			'EE_Admin_Table_Line_Item_Display_Strategy'
1002
+		);
1003
+		$this->_template_args['line_item_table'] = $Line_Item_Display->display_line_item(
1004
+			$this->_transaction->total_line_item()
1005
+		);
1006
+		$this->_template_args['REG_code'] = $this->_transaction->get_first_related('Registration')
1007
+															   ->get('REG_code');
1008
+
1009
+		// process taxes
1010
+		$taxes = $this->_transaction->get_many_related(
1011
+			'Line_Item',
1012
+			array(array('LIN_type' => EEM_Line_Item::type_tax))
1013
+		);
1014
+		$this->_template_args['taxes'] = ! empty($taxes) ? $taxes : false;
1015
+
1016
+		$this->_template_args['grand_total'] = EEH_Template::format_currency(
1017
+			$this->_transaction->get('TXN_total'),
1018
+			false,
1019
+			false
1020
+		);
1021
+		$this->_template_args['grand_raw_total'] = $this->_transaction->get('TXN_total');
1022
+		$this->_template_args['TXN_status'] = $this->_transaction->get('STS_ID');
1023
+
1024
+		// process payment details
1025
+		$payments = $this->_transaction->get_many_related('Payment');
1026
+		if (! empty($payments)) {
1027
+			$this->_template_args['payments'] = $payments;
1028
+			$this->_template_args['existing_reg_payments'] = $this->_get_registration_payment_IDs($payments);
1029
+		} else {
1030
+			$this->_template_args['payments'] = false;
1031
+			$this->_template_args['existing_reg_payments'] = array();
1032
+		}
1033
+
1034
+		$this->_template_args['edit_payment_url'] = add_query_arg(array('action' => 'edit_payment'), TXN_ADMIN_URL);
1035
+		$this->_template_args['delete_payment_url'] = add_query_arg(
1036
+			array('action' => 'espresso_delete_payment'),
1037
+			TXN_ADMIN_URL
1038
+		);
1039
+
1040
+		if (isset($txn_details['invoice_number'])) {
1041
+			$this->_template_args['txn_details']['invoice_number']['value'] = $this->_template_args['REG_code'];
1042
+			$this->_template_args['txn_details']['invoice_number']['label'] = esc_html__(
1043
+				'Invoice Number',
1044
+				'event_espresso'
1045
+			);
1046
+		}
1047
+
1048
+		$this->_template_args['txn_details']['registration_session']['value'] = $this->_transaction
1049
+			->get_first_related('Registration')
1050
+			->get('REG_session');
1051
+		$this->_template_args['txn_details']['registration_session']['label'] = esc_html__(
1052
+			'Registration Session',
1053
+			'event_espresso'
1054
+		);
1055
+
1056
+		$this->_template_args['txn_details']['ip_address']['value'] = isset($this->_session['ip_address'])
1057
+			? $this->_session['ip_address']
1058
+			: '';
1059
+		$this->_template_args['txn_details']['ip_address']['label'] = esc_html__(
1060
+			'Transaction placed from IP',
1061
+			'event_espresso'
1062
+		);
1063
+
1064
+		$this->_template_args['txn_details']['user_agent']['value'] = isset($this->_session['user_agent'])
1065
+			? $this->_session['user_agent']
1066
+			: '';
1067
+		$this->_template_args['txn_details']['user_agent']['label'] = esc_html__(
1068
+			'Registrant User Agent',
1069
+			'event_espresso'
1070
+		);
1071
+
1072
+		$reg_steps = '<ul>';
1073
+		foreach ($this->_transaction->reg_steps() as $reg_step => $reg_step_status) {
1074
+			if ($reg_step_status === true) {
1075
+				$reg_steps .= '<li style="color:#70cc50">'
1076
+							  . sprintf(
1077
+								  esc_html__('%1$s : Completed', 'event_espresso'),
1078
+								  ucwords(str_replace('_', ' ', $reg_step))
1079
+							  )
1080
+							  . '</li>';
1081
+			} elseif (is_numeric($reg_step_status) && $reg_step_status !== false) {
1082
+				$reg_steps .= '<li style="color:#2EA2CC">'
1083
+							  . sprintf(
1084
+								  esc_html__('%1$s : Initiated %2$s', 'event_espresso'),
1085
+								  ucwords(str_replace('_', ' ', $reg_step)),
1086
+								  date(
1087
+									  get_option('date_format') . ' ' . get_option('time_format'),
1088
+									  ($reg_step_status + (get_option('gmt_offset') * HOUR_IN_SECONDS))
1089
+								  )
1090
+							  )
1091
+							  . '</li>';
1092
+			} else {
1093
+				$reg_steps .= '<li style="color:#E76700">'
1094
+							  . sprintf(
1095
+								  esc_html__('%1$s : Never Initiated', 'event_espresso'),
1096
+								  ucwords(str_replace('_', ' ', $reg_step))
1097
+							  )
1098
+							  . '</li>';
1099
+			}
1100
+		}
1101
+		$reg_steps .= '</ul>';
1102
+		$this->_template_args['txn_details']['reg_steps']['value'] = $reg_steps;
1103
+		$this->_template_args['txn_details']['reg_steps']['label'] = esc_html__(
1104
+			'Registration Step Progress',
1105
+			'event_espresso'
1106
+		);
1107
+
1108
+
1109
+		$this->_get_registrations_to_apply_payment_to();
1110
+		$this->_get_payment_methods($payments);
1111
+		$this->_get_payment_status_array();
1112
+		$this->_get_reg_status_selection(); // sets up the template args for the reg status array for the transaction.
1113
+
1114
+		$this->_template_args['transaction_form_url'] = add_query_arg(
1115
+			array(
1116
+				'action'  => 'edit_transaction',
1117
+				'process' => 'transaction',
1118
+			),
1119
+			TXN_ADMIN_URL
1120
+		);
1121
+		$this->_template_args['apply_payment_form_url'] = add_query_arg(
1122
+			array(
1123
+				'page'   => 'espresso_transactions',
1124
+				'action' => 'espresso_apply_payment',
1125
+			),
1126
+			WP_AJAX_URL
1127
+		);
1128
+		$this->_template_args['delete_payment_form_url'] = add_query_arg(
1129
+			array(
1130
+				'page'   => 'espresso_transactions',
1131
+				'action' => 'espresso_delete_payment',
1132
+			),
1133
+			WP_AJAX_URL
1134
+		);
1135
+
1136
+		$this->_template_args['action_buttons'] = $this->getActionButtons($this->_transaction);
1137
+
1138
+		// 'espresso_delete_payment_nonce'
1139
+
1140
+		$template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_txn_details.template.php';
1141
+		echo EEH_Template::display_template($template_path, $this->_template_args, true);
1142
+	}
1143
+
1144
+
1145
+	/**
1146
+	 * _get_registration_payment_IDs
1147
+	 *    generates an array of Payment IDs and their corresponding Registration IDs
1148
+	 *
1149
+	 * @access protected
1150
+	 * @param EE_Payment[] $payments
1151
+	 * @return array
1152
+	 * @throws EE_Error
1153
+	 * @throws InvalidArgumentException
1154
+	 * @throws InvalidDataTypeException
1155
+	 * @throws InvalidInterfaceException
1156
+	 * @throws ReflectionException
1157
+	 */
1158
+	protected function _get_registration_payment_IDs($payments = array())
1159
+	{
1160
+		$existing_reg_payments = array();
1161
+		// get all reg payments for these payments
1162
+		$reg_payments = EEM_Registration_Payment::instance()->get_all(
1163
+			array(
1164
+				array(
1165
+					'PAY_ID' => array(
1166
+						'IN',
1167
+						array_keys($payments),
1168
+					),
1169
+				),
1170
+			)
1171
+		);
1172
+		if (! empty($reg_payments)) {
1173
+			foreach ($payments as $payment) {
1174
+				if (! $payment instanceof EE_Payment) {
1175
+					continue;
1176
+				} elseif (! isset($existing_reg_payments[ $payment->ID() ])) {
1177
+					$existing_reg_payments[ $payment->ID() ] = array();
1178
+				}
1179
+				foreach ($reg_payments as $reg_payment) {
1180
+					if ($reg_payment instanceof EE_Registration_Payment
1181
+						&& $reg_payment->payment_ID() === $payment->ID()
1182
+					) {
1183
+						$existing_reg_payments[ $payment->ID() ][] = $reg_payment->registration_ID();
1184
+					}
1185
+				}
1186
+			}
1187
+		}
1188
+
1189
+		return $existing_reg_payments;
1190
+	}
1191
+
1192
+
1193
+	/**
1194
+	 * _get_registrations_to_apply_payment_to
1195
+	 *    generates HTML for displaying a series of checkboxes in the admin payment modal window
1196
+	 * which allows the admin to only apply the payment to the specific registrations
1197
+	 *
1198
+	 * @access protected
1199
+	 * @return void
1200
+	 * @throws \EE_Error
1201
+	 */
1202
+	protected function _get_registrations_to_apply_payment_to()
1203
+	{
1204
+		// we want any registration with an active status (ie: not deleted or cancelled)
1205
+		$query_params = array(
1206
+			array(
1207
+				'STS_ID' => array(
1208
+					'IN',
1209
+					array(
1210
+						EEM_Registration::status_id_approved,
1211
+						EEM_Registration::status_id_pending_payment,
1212
+						EEM_Registration::status_id_not_approved,
1213
+					),
1214
+				),
1215
+			),
1216
+		);
1217
+		$registrations_to_apply_payment_to = EEH_HTML::br()
1218
+											 . EEH_HTML::div(
1219
+												 '',
1220
+												 'txn-admin-apply-payment-to-registrations-dv',
1221
+												 '',
1222
+												 'clear: both; margin: 1.5em 0 0; display: none;'
1223
+											 );
1224
+		$registrations_to_apply_payment_to .= EEH_HTML::br() . EEH_HTML::div('', '', 'admin-primary-mbox-tbl-wrap');
1225
+		$registrations_to_apply_payment_to .= EEH_HTML::table('', '', 'admin-primary-mbox-tbl');
1226
+		$registrations_to_apply_payment_to .= EEH_HTML::thead(
1227
+			EEH_HTML::tr(
1228
+				EEH_HTML::th(esc_html__('ID', 'event_espresso')) .
1229
+				EEH_HTML::th(esc_html__('Registrant', 'event_espresso')) .
1230
+				EEH_HTML::th(esc_html__('Ticket', 'event_espresso')) .
1231
+				EEH_HTML::th(esc_html__('Event', 'event_espresso')) .
1232
+				EEH_HTML::th(esc_html__('Paid', 'event_espresso'), '', 'txn-admin-payment-paid-td jst-cntr') .
1233
+				EEH_HTML::th(esc_html__('Owing', 'event_espresso'), '', 'txn-admin-payment-owing-td jst-cntr') .
1234
+				EEH_HTML::th(esc_html__('Apply', 'event_espresso'), '', 'jst-cntr')
1235
+			)
1236
+		);
1237
+		$registrations_to_apply_payment_to .= EEH_HTML::tbody();
1238
+		// get registrations for TXN
1239
+		$registrations = $this->_transaction->registrations($query_params);
1240
+		$existing_reg_payments = $this->_template_args['existing_reg_payments'];
1241
+		foreach ($registrations as $registration) {
1242
+			if ($registration instanceof EE_Registration) {
1243
+				$attendee_name = $registration->attendee() instanceof EE_Attendee
1244
+					? $registration->attendee()->full_name()
1245
+					: esc_html__('Unknown Attendee', 'event_espresso');
1246
+				$owing = $registration->final_price() - $registration->paid();
1247
+				$taxable = $registration->ticket()->taxable()
1248
+					? ' <span class="smaller-text lt-grey-text"> ' . esc_html__('+ tax', 'event_espresso') . '</span>'
1249
+					: '';
1250
+				$checked = empty($existing_reg_payments) || in_array($registration->ID(), $existing_reg_payments)
1251
+					? ' checked="checked"'
1252
+					: '';
1253
+				$disabled = $registration->final_price() > 0 ? '' : ' disabled';
1254
+				$registrations_to_apply_payment_to .= EEH_HTML::tr(
1255
+					EEH_HTML::td($registration->ID()) .
1256
+					EEH_HTML::td($attendee_name) .
1257
+					EEH_HTML::td(
1258
+						$registration->ticket()->name() . ' : ' . $registration->ticket()->pretty_price() . $taxable
1259
+					) .
1260
+					EEH_HTML::td($registration->event_name()) .
1261
+					EEH_HTML::td($registration->pretty_paid(), '', 'txn-admin-payment-paid-td jst-cntr') .
1262
+					EEH_HTML::td(EEH_Template::format_currency($owing), '', 'txn-admin-payment-owing-td jst-cntr') .
1263
+					EEH_HTML::td(
1264
+						'<input type="checkbox" value="' . $registration->ID()
1265
+						. '" name="txn_admin_payment[registrations]"'
1266
+						. $checked . $disabled . '>',
1267
+						'',
1268
+						'jst-cntr'
1269
+					),
1270
+					'apply-payment-registration-row-' . $registration->ID()
1271
+				);
1272
+			}
1273
+		}
1274
+		$registrations_to_apply_payment_to .= EEH_HTML::tbodyx();
1275
+		$registrations_to_apply_payment_to .= EEH_HTML::tablex();
1276
+		$registrations_to_apply_payment_to .= EEH_HTML::divx();
1277
+		$registrations_to_apply_payment_to .= EEH_HTML::p(
1278
+			esc_html__(
1279
+				'The payment will only be applied to the registrations that have a check mark in their corresponding check box. Checkboxes for free registrations have been disabled.',
1280
+				'event_espresso'
1281
+			),
1282
+			'',
1283
+			'clear description'
1284
+		);
1285
+		$registrations_to_apply_payment_to .= EEH_HTML::divx();
1286
+		$this->_template_args['registrations_to_apply_payment_to'] = $registrations_to_apply_payment_to;
1287
+	}
1288
+
1289
+
1290
+	/**
1291
+	 * _get_reg_status_selection
1292
+	 *
1293
+	 * @todo   this will need to be adjusted either once MER comes along OR we move default reg status to tickets
1294
+	 *         instead of events.
1295
+	 * @access protected
1296
+	 * @return void
1297
+	 * @throws EE_Error
1298
+	 */
1299
+	protected function _get_reg_status_selection()
1300
+	{
1301
+		// first get all possible statuses
1302
+		$statuses = EEM_Registration::reg_status_array(array(), true);
1303
+		// let's add a "don't change" option.
1304
+		$status_array['NAN'] = esc_html__('Leave the Same', 'event_espresso');
1305
+		$status_array = array_merge($status_array, $statuses);
1306
+		$this->_template_args['status_change_select'] = EEH_Form_Fields::select_input(
1307
+			'txn_reg_status_change[reg_status]',
1308
+			$status_array,
1309
+			'NAN',
1310
+			'id="txn-admin-payment-reg-status-inp"',
1311
+			'txn-reg-status-change-reg-status'
1312
+		);
1313
+		$this->_template_args['delete_status_change_select'] = EEH_Form_Fields::select_input(
1314
+			'delete_txn_reg_status_change[reg_status]',
1315
+			$status_array,
1316
+			'NAN',
1317
+			'delete-txn-admin-payment-reg-status-inp',
1318
+			'delete-txn-reg-status-change-reg-status'
1319
+		);
1320
+	}
1321
+
1322
+
1323
+	/**
1324
+	 *    _get_payment_methods
1325
+	 * Gets all the payment methods available generally, or the ones that are already
1326
+	 * selected on these payments (in case their payment methods are no longer active).
1327
+	 * Has the side-effect of updating the template args' payment_methods item
1328
+	 *
1329
+	 * @access private
1330
+	 * @param EE_Payment[] to show on this page
1331
+	 * @return void
1332
+	 * @throws EE_Error
1333
+	 * @throws InvalidArgumentException
1334
+	 * @throws InvalidDataTypeException
1335
+	 * @throws InvalidInterfaceException
1336
+	 * @throws ReflectionException
1337
+	 */
1338
+	private function _get_payment_methods($payments = array())
1339
+	{
1340
+		$payment_methods_of_payments = array();
1341
+		foreach ($payments as $payment) {
1342
+			if ($payment instanceof EE_Payment) {
1343
+				$payment_methods_of_payments[] = $payment->get('PMD_ID');
1344
+			}
1345
+		}
1346
+		if ($payment_methods_of_payments) {
1347
+			$query_args = array(
1348
+				array(
1349
+					'OR*payment_method_for_payment' => array(
1350
+						'PMD_ID'    => array('IN', $payment_methods_of_payments),
1351
+						'PMD_scope' => array('LIKE', '%' . EEM_Payment_Method::scope_admin . '%'),
1352
+					),
1353
+				),
1354
+			);
1355
+		} else {
1356
+			$query_args = array(array('PMD_scope' => array('LIKE', '%' . EEM_Payment_Method::scope_admin . '%')));
1357
+		}
1358
+		$this->_template_args['payment_methods'] = EEM_Payment_Method::instance()->get_all($query_args);
1359
+	}
1360
+
1361
+
1362
+	/**
1363
+	 * txn_attendees_meta_box
1364
+	 *    generates HTML for the Attendees Transaction main meta box
1365
+	 *
1366
+	 * @access public
1367
+	 * @param WP_Post $post
1368
+	 * @param array   $metabox
1369
+	 * @return void
1370
+	 * @throws DomainException
1371
+	 * @throws EE_Error
1372
+	 */
1373
+	public function txn_attendees_meta_box($post, $metabox = array('args' => array()))
1374
+	{
1375
+
1376
+		/** @noinspection NonSecureExtractUsageInspection */
1377
+		extract($metabox['args']);
1378
+		$this->_template_args['post'] = $post;
1379
+		$this->_template_args['event_attendees'] = array();
1380
+		// process items in cart
1381
+		$line_items = $this->_transaction->get_many_related(
1382
+			'Line_Item',
1383
+			array(array('LIN_type' => 'line-item'))
1384
+		);
1385
+		if (! empty($line_items)) {
1386
+			foreach ($line_items as $item) {
1387
+				if ($item instanceof EE_Line_Item) {
1388
+					switch ($item->OBJ_type()) {
1389
+						case 'Event':
1390
+							break;
1391
+						case 'Ticket':
1392
+							$ticket = $item->ticket();
1393
+							// right now we're only handling tickets here.
1394
+							// Cause its expected that only tickets will have attendees right?
1395
+							if (! $ticket instanceof EE_Ticket) {
1396
+								continue;
1397
+							}
1398
+							try {
1399
+								$event_name = $ticket->get_event_name();
1400
+							} catch (Exception $e) {
1401
+								EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1402
+								$event_name = esc_html__('Unknown Event', 'event_espresso');
1403
+							}
1404
+							$event_name .= ' - ' . $item->get('LIN_name');
1405
+							$ticket_price = EEH_Template::format_currency($item->get('LIN_unit_price'));
1406
+							// now get all of the registrations for this transaction that use this ticket
1407
+							$registrations = $ticket->get_many_related(
1408
+								'Registration',
1409
+								array(array('TXN_ID' => $this->_transaction->ID()))
1410
+							);
1411
+							foreach ($registrations as $registration) {
1412
+								if (! $registration instanceof EE_Registration) {
1413
+									continue;
1414
+								}
1415
+								$this->_template_args['event_attendees'][ $registration->ID() ]['STS_ID']
1416
+									= $registration->status_ID();
1417
+								$this->_template_args['event_attendees'][ $registration->ID() ]['att_num']
1418
+									= $registration->count();
1419
+								$this->_template_args['event_attendees'][ $registration->ID() ]['event_ticket_name']
1420
+									= $event_name;
1421
+								$this->_template_args['event_attendees'][ $registration->ID() ]['ticket_price']
1422
+									= $ticket_price;
1423
+								// attendee info
1424
+								$attendee = $registration->get_first_related('Attendee');
1425
+								if ($attendee instanceof EE_Attendee) {
1426
+									$this->_template_args['event_attendees'][ $registration->ID() ]['att_id']
1427
+										= $attendee->ID();
1428
+									$this->_template_args['event_attendees'][ $registration->ID() ]['attendee']
1429
+										= $attendee->full_name();
1430
+									$this->_template_args['event_attendees'][ $registration->ID() ]['email']
1431
+										= '<a href="mailto:' . $attendee->email() . '?subject=' . $event_name
1432
+										  . esc_html__(
1433
+											  ' Event',
1434
+											  'event_espresso'
1435
+										  )
1436
+										  . '">' . $attendee->email() . '</a>';
1437
+									$this->_template_args['event_attendees'][ $registration->ID() ]['address']
1438
+										= EEH_Address::format($attendee, 'inline', false, false);
1439
+								} else {
1440
+									$this->_template_args['event_attendees'][ $registration->ID() ]['att_id'] = '';
1441
+									$this->_template_args['event_attendees'][ $registration->ID() ]['attendee'] = '';
1442
+									$this->_template_args['event_attendees'][ $registration->ID() ]['email'] = '';
1443
+									$this->_template_args['event_attendees'][ $registration->ID() ]['address'] = '';
1444
+								}
1445
+							}
1446
+							break;
1447
+					}
1448
+				}
1449
+			}
1450
+
1451
+			$this->_template_args['transaction_form_url'] = add_query_arg(
1452
+				array(
1453
+					'action'  => 'edit_transaction',
1454
+					'process' => 'attendees',
1455
+				),
1456
+				TXN_ADMIN_URL
1457
+			);
1458
+			echo EEH_Template::display_template(
1459
+				TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_attendees.template.php',
1460
+				$this->_template_args,
1461
+				true
1462
+			);
1463
+		} else {
1464
+			echo sprintf(
1465
+				esc_html__(
1466
+					'%1$sFor some reason, there are no attendees registered for this transaction. Likely the registration was abandoned in process.%2$s',
1467
+					'event_espresso'
1468
+				),
1469
+				'<p class="important-notice">',
1470
+				'</p>'
1471
+			);
1472
+		}
1473
+	}
1474
+
1475
+
1476
+	/**
1477
+	 * txn_registrant_side_meta_box
1478
+	 * generates HTML for the Edit Transaction side meta box
1479
+	 *
1480
+	 * @access public
1481
+	 * @return void
1482
+	 * @throws DomainException
1483
+	 * @throws EE_Error
1484
+	 * @throws InvalidArgumentException
1485
+	 * @throws InvalidDataTypeException
1486
+	 * @throws InvalidInterfaceException
1487
+	 * @throws ReflectionException
1488
+	 */
1489
+	public function txn_registrant_side_meta_box()
1490
+	{
1491
+		$primary_att = $this->_transaction->primary_registration() instanceof EE_Registration
1492
+			? $this->_transaction->primary_registration()->get_first_related('Attendee')
1493
+			: null;
1494
+		if (! $primary_att instanceof EE_Attendee) {
1495
+			$this->_template_args['no_attendee_message'] = esc_html__(
1496
+				'There is no attached contact for this transaction.  The transaction either failed due to an error or was abandoned.',
1497
+				'event_espresso'
1498
+			);
1499
+			$primary_att = EEM_Attendee::instance()->create_default_object();
1500
+		}
1501
+		$this->_template_args['ATT_ID'] = $primary_att->ID();
1502
+		$this->_template_args['prime_reg_fname'] = $primary_att->fname();
1503
+		$this->_template_args['prime_reg_lname'] = $primary_att->lname();
1504
+		$this->_template_args['prime_reg_email'] = $primary_att->email();
1505
+		$this->_template_args['prime_reg_phone'] = $primary_att->phone();
1506
+		$this->_template_args['edit_attendee_url'] = EE_Admin_Page::add_query_args_and_nonce(
1507
+			array(
1508
+				'action' => 'edit_attendee',
1509
+				'post'   => $primary_att->ID(),
1510
+			),
1511
+			REG_ADMIN_URL
1512
+		);
1513
+		// get formatted address for registrant
1514
+		$this->_template_args['formatted_address'] = EEH_Address::format($primary_att);
1515
+		echo EEH_Template::display_template(
1516
+			TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_registrant.template.php',
1517
+			$this->_template_args,
1518
+			true
1519
+		);
1520
+	}
1521
+
1522
+
1523
+	/**
1524
+	 * txn_billing_info_side_meta_box
1525
+	 *    generates HTML for the Edit Transaction side meta box
1526
+	 *
1527
+	 * @access public
1528
+	 * @return void
1529
+	 * @throws DomainException
1530
+	 * @throws EE_Error
1531
+	 */
1532
+	public function txn_billing_info_side_meta_box()
1533
+	{
1534
+
1535
+		$this->_template_args['billing_form'] = $this->_transaction->billing_info();
1536
+		$this->_template_args['billing_form_url'] = add_query_arg(
1537
+			array('action' => 'edit_transaction', 'process' => 'billing'),
1538
+			TXN_ADMIN_URL
1539
+		);
1540
+
1541
+		$template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_billing_info.template.php';
1542
+		echo EEH_Template::display_template($template_path, $this->_template_args, true);/**/
1543
+	}
1544
+
1545
+
1546
+	/**
1547
+	 * apply_payments_or_refunds
1548
+	 *    registers a payment or refund made towards a transaction
1549
+	 *
1550
+	 * @access public
1551
+	 * @return void
1552
+	 * @throws EE_Error
1553
+	 * @throws InvalidArgumentException
1554
+	 * @throws ReflectionException
1555
+	 * @throws RuntimeException
1556
+	 * @throws InvalidDataTypeException
1557
+	 * @throws InvalidInterfaceException
1558
+	 */
1559
+	public function apply_payments_or_refunds()
1560
+	{
1561
+		$json_response_data = array('return_data' => false);
1562
+		$valid_data = $this->_validate_payment_request_data();
1563
+		$has_access = EE_Registry::instance()->CAP->current_user_can(
1564
+			'ee_edit_payments',
1565
+			'apply_payment_or_refund_from_registration_details'
1566
+		);
1567
+		if (! empty($valid_data) && $has_access) {
1568
+			$PAY_ID = $valid_data['PAY_ID'];
1569
+			// save  the new payment
1570
+			$payment = $this->_create_payment_from_request_data($valid_data);
1571
+			// get the TXN for this payment
1572
+			$transaction = $payment->transaction();
1573
+			// verify transaction
1574
+			if ($transaction instanceof EE_Transaction) {
1575
+				// calculate_total_payments_and_update_status
1576
+				$this->_process_transaction_payments($transaction);
1577
+				$REG_IDs = $this->_get_REG_IDs_to_apply_payment_to($payment);
1578
+				$this->_remove_existing_registration_payments($payment, $PAY_ID);
1579
+				// apply payment to registrations (if applicable)
1580
+				if (! empty($REG_IDs)) {
1581
+					$this->_update_registration_payments($transaction, $payment, $REG_IDs);
1582
+					$this->_maybe_send_notifications();
1583
+					// now process status changes for the same registrations
1584
+					$this->_process_registration_status_change($transaction, $REG_IDs);
1585
+				}
1586
+				$this->_maybe_send_notifications($payment);
1587
+				// prepare to render page
1588
+				$json_response_data['return_data'] = $this->_build_payment_json_response($payment, $REG_IDs);
1589
+				do_action(
1590
+					'AHEE__Transactions_Admin_Page__apply_payments_or_refund__after_recording',
1591
+					$transaction,
1592
+					$payment
1593
+				);
1594
+			} else {
1595
+				EE_Error::add_error(
1596
+					esc_html__(
1597
+						'A valid Transaction for this payment could not be retrieved.',
1598
+						'event_espresso'
1599
+					),
1600
+					__FILE__,
1601
+					__FUNCTION__,
1602
+					__LINE__
1603
+				);
1604
+			}
1605
+		} else {
1606
+			if ($has_access) {
1607
+				EE_Error::add_error(
1608
+					esc_html__(
1609
+						'The payment form data could not be processed. Please try again.',
1610
+						'event_espresso'
1611
+					),
1612
+					__FILE__,
1613
+					__FUNCTION__,
1614
+					__LINE__
1615
+				);
1616
+			} else {
1617
+				EE_Error::add_error(
1618
+					esc_html__(
1619
+						'You do not have access to apply payments or refunds to a registration.',
1620
+						'event_espresso'
1621
+					),
1622
+					__FILE__,
1623
+					__FUNCTION__,
1624
+					__LINE__
1625
+				);
1626
+			}
1627
+		}
1628
+		$notices = EE_Error::get_notices(
1629
+			false,
1630
+			false,
1631
+			false
1632
+		);
1633
+		$this->_template_args = array(
1634
+			'data'    => $json_response_data,
1635
+			'error'   => $notices['errors'],
1636
+			'success' => $notices['success'],
1637
+		);
1638
+		$this->_return_json();
1639
+	}
1640
+
1641
+
1642
+	/**
1643
+	 * _validate_payment_request_data
1644
+	 *
1645
+	 * @return array
1646
+	 * @throws EE_Error
1647
+	 */
1648
+	protected function _validate_payment_request_data()
1649
+	{
1650
+		if (! isset($this->_req_data['txn_admin_payment'])) {
1651
+			return false;
1652
+		}
1653
+		$payment_form = $this->_generate_payment_form_section();
1654
+		try {
1655
+			if ($payment_form->was_submitted()) {
1656
+				$payment_form->receive_form_submission();
1657
+				if (! $payment_form->is_valid()) {
1658
+					$submission_error_messages = array();
1659
+					foreach ($payment_form->get_validation_errors_accumulated() as $validation_error) {
1660
+						if ($validation_error instanceof EE_Validation_Error) {
1661
+							$submission_error_messages[] = sprintf(
1662
+								_x('%s : %s', 'Form Section Name : Form Validation Error', 'event_espresso'),
1663
+								$validation_error->get_form_section()->html_label_text(),
1664
+								$validation_error->getMessage()
1665
+							);
1666
+						}
1667
+					}
1668
+					EE_Error::add_error(
1669
+						implode('<br />', $submission_error_messages),
1670
+						__FILE__,
1671
+						__FUNCTION__,
1672
+						__LINE__
1673
+					);
1674
+
1675
+					return array();
1676
+				}
1677
+			}
1678
+		} catch (EE_Error $e) {
1679
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1680
+
1681
+			return array();
1682
+		}
1683
+
1684
+		return $payment_form->valid_data();
1685
+	}
1686
+
1687
+
1688
+	/**
1689
+	 * _generate_payment_form_section
1690
+	 *
1691
+	 * @return EE_Form_Section_Proper
1692
+	 * @throws EE_Error
1693
+	 */
1694
+	protected function _generate_payment_form_section()
1695
+	{
1696
+		return new EE_Form_Section_Proper(
1697
+			array(
1698
+				'name'        => 'txn_admin_payment',
1699
+				'subsections' => array(
1700
+					'PAY_ID'          => new EE_Text_Input(
1701
+						array(
1702
+							'default'               => 0,
1703
+							'required'              => false,
1704
+							'html_label_text'       => esc_html__('Payment ID', 'event_espresso'),
1705
+							'validation_strategies' => array(new EE_Int_Normalization()),
1706
+						)
1707
+					),
1708
+					'TXN_ID'          => new EE_Text_Input(
1709
+						array(
1710
+							'default'               => 0,
1711
+							'required'              => true,
1712
+							'html_label_text'       => esc_html__('Transaction ID', 'event_espresso'),
1713
+							'validation_strategies' => array(new EE_Int_Normalization()),
1714
+						)
1715
+					),
1716
+					'type'            => new EE_Text_Input(
1717
+						array(
1718
+							'default'               => 1,
1719
+							'required'              => true,
1720
+							'html_label_text'       => esc_html__('Payment or Refund', 'event_espresso'),
1721
+							'validation_strategies' => array(new EE_Int_Normalization()),
1722
+						)
1723
+					),
1724
+					'amount'          => new EE_Text_Input(
1725
+						array(
1726
+							'default'               => 0,
1727
+							'required'              => true,
1728
+							'html_label_text'       => esc_html__('Payment amount', 'event_espresso'),
1729
+							'validation_strategies' => array(new EE_Float_Normalization()),
1730
+						)
1731
+					),
1732
+					'status'          => new EE_Text_Input(
1733
+						array(
1734
+							'default'         => EEM_Payment::status_id_approved,
1735
+							'required'        => true,
1736
+							'html_label_text' => esc_html__('Payment status', 'event_espresso'),
1737
+						)
1738
+					),
1739
+					'PMD_ID'          => new EE_Text_Input(
1740
+						array(
1741
+							'default'               => 2,
1742
+							'required'              => true,
1743
+							'html_label_text'       => esc_html__('Payment Method', 'event_espresso'),
1744
+							'validation_strategies' => array(new EE_Int_Normalization()),
1745
+						)
1746
+					),
1747
+					'date'            => new EE_Text_Input(
1748
+						array(
1749
+							'default'         => time(),
1750
+							'required'        => true,
1751
+							'html_label_text' => esc_html__('Payment date', 'event_espresso'),
1752
+						)
1753
+					),
1754
+					'txn_id_chq_nmbr' => new EE_Text_Input(
1755
+						array(
1756
+							'default'               => '',
1757
+							'required'              => false,
1758
+							'html_label_text'       => esc_html__('Transaction or Cheque Number', 'event_espresso'),
1759
+							'validation_strategies' => array(
1760
+								new EE_Max_Length_Validation_Strategy(
1761
+									esc_html__('Input too long', 'event_espresso'),
1762
+									100
1763
+								),
1764
+							),
1765
+						)
1766
+					),
1767
+					'po_number'       => new EE_Text_Input(
1768
+						array(
1769
+							'default'               => '',
1770
+							'required'              => false,
1771
+							'html_label_text'       => esc_html__('Purchase Order Number', 'event_espresso'),
1772
+							'validation_strategies' => array(
1773
+								new EE_Max_Length_Validation_Strategy(
1774
+									esc_html__('Input too long', 'event_espresso'),
1775
+									100
1776
+								),
1777
+							),
1778
+						)
1779
+					),
1780
+					'accounting'      => new EE_Text_Input(
1781
+						array(
1782
+							'default'               => '',
1783
+							'required'              => false,
1784
+							'html_label_text'       => esc_html__('Extra Field for Accounting', 'event_espresso'),
1785
+							'validation_strategies' => array(
1786
+								new EE_Max_Length_Validation_Strategy(
1787
+									esc_html__('Input too long', 'event_espresso'),
1788
+									100
1789
+								),
1790
+							),
1791
+						)
1792
+					),
1793
+				),
1794
+			)
1795
+		);
1796
+	}
1797
+
1798
+
1799
+	/**
1800
+	 * _create_payment_from_request_data
1801
+	 *
1802
+	 * @param array $valid_data
1803
+	 * @return EE_Payment
1804
+	 * @throws EE_Error
1805
+	 */
1806
+	protected function _create_payment_from_request_data($valid_data)
1807
+	{
1808
+		$PAY_ID = $valid_data['PAY_ID'];
1809
+		// get payment amount
1810
+		$amount = $valid_data['amount'] ? abs($valid_data['amount']) : 0;
1811
+		// payments have a type value of 1 and refunds have a type value of -1
1812
+		// so multiplying amount by type will give a positive value for payments, and negative values for refunds
1813
+		$amount = $valid_data['type'] < 0 ? $amount * -1 : $amount;
1814
+		// for some reason the date string coming in has extra spaces between the date and time.  This fixes that.
1815
+		$date = $valid_data['date']
1816
+			? preg_replace('/\s+/', ' ', $valid_data['date'])
1817
+			: date('Y-m-d g:i a', current_time('timestamp'));
1818
+		$payment = EE_Payment::new_instance(
1819
+			array(
1820
+				'TXN_ID'              => $valid_data['TXN_ID'],
1821
+				'STS_ID'              => $valid_data['status'],
1822
+				'PAY_timestamp'       => $date,
1823
+				'PAY_source'          => EEM_Payment_Method::scope_admin,
1824
+				'PMD_ID'              => $valid_data['PMD_ID'],
1825
+				'PAY_amount'          => $amount,
1826
+				'PAY_txn_id_chq_nmbr' => $valid_data['txn_id_chq_nmbr'],
1827
+				'PAY_po_number'       => $valid_data['po_number'],
1828
+				'PAY_extra_accntng'   => $valid_data['accounting'],
1829
+				'PAY_details'         => $valid_data,
1830
+				'PAY_ID'              => $PAY_ID,
1831
+			),
1832
+			'',
1833
+			array('Y-m-d', 'g:i a')
1834
+		);
1835
+
1836
+		if (! $payment->save()) {
1837
+			EE_Error::add_error(
1838
+				sprintf(
1839
+					esc_html__('Payment %1$d has not been successfully saved to the database.', 'event_espresso'),
1840
+					$payment->ID()
1841
+				),
1842
+				__FILE__,
1843
+				__FUNCTION__,
1844
+				__LINE__
1845
+			);
1846
+		}
1847
+
1848
+		return $payment;
1849
+	}
1850
+
1851
+
1852
+	/**
1853
+	 * _process_transaction_payments
1854
+	 *
1855
+	 * @param \EE_Transaction $transaction
1856
+	 * @return void
1857
+	 * @throws EE_Error
1858
+	 * @throws InvalidArgumentException
1859
+	 * @throws ReflectionException
1860
+	 * @throws InvalidDataTypeException
1861
+	 * @throws InvalidInterfaceException
1862
+	 */
1863
+	protected function _process_transaction_payments(EE_Transaction $transaction)
1864
+	{
1865
+		/** @type EE_Transaction_Payments $transaction_payments */
1866
+		$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
1867
+		// update the transaction with this payment
1868
+		if ($transaction_payments->calculate_total_payments_and_update_status($transaction)) {
1869
+			EE_Error::add_success(
1870
+				esc_html__(
1871
+					'The payment has been processed successfully.',
1872
+					'event_espresso'
1873
+				),
1874
+				__FILE__,
1875
+				__FUNCTION__,
1876
+				__LINE__
1877
+			);
1878
+		} else {
1879
+			EE_Error::add_error(
1880
+				esc_html__(
1881
+					'The payment was processed successfully but the amount paid for the transaction was not updated.',
1882
+					'event_espresso'
1883
+				),
1884
+				__FILE__,
1885
+				__FUNCTION__,
1886
+				__LINE__
1887
+			);
1888
+		}
1889
+	}
1890
+
1891
+
1892
+	/**
1893
+	 * _get_REG_IDs_to_apply_payment_to
1894
+	 * returns a list of registration IDs that the payment will apply to
1895
+	 *
1896
+	 * @param \EE_Payment $payment
1897
+	 * @return array
1898
+	 * @throws EE_Error
1899
+	 */
1900
+	protected function _get_REG_IDs_to_apply_payment_to(EE_Payment $payment)
1901
+	{
1902
+		$REG_IDs = array();
1903
+		// grab array of IDs for specific registrations to apply changes to
1904
+		if (isset($this->_req_data['txn_admin_payment']['registrations'])) {
1905
+			$REG_IDs = (array) $this->_req_data['txn_admin_payment']['registrations'];
1906
+		}
1907
+		// nothing specified ? then get all reg IDs
1908
+		if (empty($REG_IDs)) {
1909
+			$registrations = $payment->transaction()->registrations();
1910
+			$REG_IDs = ! empty($registrations)
1911
+				? array_keys($registrations)
1912
+				: $this->_get_existing_reg_payment_REG_IDs($payment);
1913
+		}
1914
+
1915
+		// ensure that REG_IDs are integers and NOT strings
1916
+		return array_map('intval', $REG_IDs);
1917
+	}
1918
+
1919
+
1920
+	/**
1921
+	 * @return array
1922
+	 */
1923
+	public function existing_reg_payment_REG_IDs()
1924
+	{
1925
+		return $this->_existing_reg_payment_REG_IDs;
1926
+	}
1927
+
1928
+
1929
+	/**
1930
+	 * @param array $existing_reg_payment_REG_IDs
1931
+	 */
1932
+	public function set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs = null)
1933
+	{
1934
+		$this->_existing_reg_payment_REG_IDs = $existing_reg_payment_REG_IDs;
1935
+	}
1936
+
1937
+
1938
+	/**
1939
+	 * _get_existing_reg_payment_REG_IDs
1940
+	 * returns a list of registration IDs that the payment is currently related to
1941
+	 * as recorded in the database
1942
+	 *
1943
+	 * @param \EE_Payment $payment
1944
+	 * @return array
1945
+	 * @throws EE_Error
1946
+	 */
1947
+	protected function _get_existing_reg_payment_REG_IDs(EE_Payment $payment)
1948
+	{
1949
+		if ($this->existing_reg_payment_REG_IDs() === null) {
1950
+			// let's get any existing reg payment records for this payment
1951
+			$existing_reg_payment_REG_IDs = $payment->get_many_related('Registration');
1952
+			// but we only want the REG IDs, so grab the array keys
1953
+			$existing_reg_payment_REG_IDs = ! empty($existing_reg_payment_REG_IDs)
1954
+				? array_keys($existing_reg_payment_REG_IDs)
1955
+				: array();
1956
+			$this->set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs);
1957
+		}
1958
+
1959
+		return $this->existing_reg_payment_REG_IDs();
1960
+	}
1961
+
1962
+
1963
+	/**
1964
+	 * _remove_existing_registration_payments
1965
+	 * this calculates the difference between existing relations
1966
+	 * to the supplied payment and the new list registration IDs,
1967
+	 * removes any related registrations that no longer apply,
1968
+	 * and then updates the registration paid fields
1969
+	 *
1970
+	 * @param \EE_Payment $payment
1971
+	 * @param int         $PAY_ID
1972
+	 * @return bool;
1973
+	 * @throws EE_Error
1974
+	 * @throws InvalidArgumentException
1975
+	 * @throws ReflectionException
1976
+	 * @throws InvalidDataTypeException
1977
+	 * @throws InvalidInterfaceException
1978
+	 */
1979
+	protected function _remove_existing_registration_payments(EE_Payment $payment, $PAY_ID = 0)
1980
+	{
1981
+		// newly created payments will have nothing recorded for $PAY_ID
1982
+		if ($PAY_ID == 0) {
1983
+			return false;
1984
+		}
1985
+		$existing_reg_payment_REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment);
1986
+		if (empty($existing_reg_payment_REG_IDs)) {
1987
+			return false;
1988
+		}
1989
+		/** @type EE_Transaction_Payments $transaction_payments */
1990
+		$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
1991
+
1992
+		return $transaction_payments->delete_registration_payments_and_update_registrations(
1993
+			$payment,
1994
+			array(
1995
+				array(
1996
+					'PAY_ID' => $payment->ID(),
1997
+					'REG_ID' => array('IN', $existing_reg_payment_REG_IDs),
1998
+				),
1999
+			)
2000
+		);
2001
+	}
2002
+
2003
+
2004
+	/**
2005
+	 * _update_registration_payments
2006
+	 * this applies the payments to the selected registrations
2007
+	 * but only if they have not already been paid for
2008
+	 *
2009
+	 * @param  EE_Transaction $transaction
2010
+	 * @param \EE_Payment     $payment
2011
+	 * @param array           $REG_IDs
2012
+	 * @return void
2013
+	 * @throws EE_Error
2014
+	 * @throws InvalidArgumentException
2015
+	 * @throws ReflectionException
2016
+	 * @throws RuntimeException
2017
+	 * @throws InvalidDataTypeException
2018
+	 * @throws InvalidInterfaceException
2019
+	 */
2020
+	protected function _update_registration_payments(
2021
+		EE_Transaction $transaction,
2022
+		EE_Payment $payment,
2023
+		$REG_IDs = array()
2024
+	) {
2025
+		// we can pass our own custom set of registrations to EE_Payment_Processor::process_registration_payments()
2026
+		// so let's do that using our set of REG_IDs from the form
2027
+		$registration_query_where_params = array(
2028
+			'REG_ID' => array('IN', $REG_IDs),
2029
+		);
2030
+		// but add in some conditions regarding payment,
2031
+		// so that we don't apply payments to registrations that are free or have already been paid for
2032
+		// but ONLY if the payment is NOT a refund ( ie: the payment amount is not negative )
2033
+		if (! $payment->is_a_refund()) {
2034
+			$registration_query_where_params['REG_final_price'] = array('!=', 0);
2035
+			$registration_query_where_params['REG_final_price*'] = array('!=', 'REG_paid', true);
2036
+		}
2037
+		$registrations = $transaction->registrations(array($registration_query_where_params));
2038
+		if (! empty($registrations)) {
2039
+			/** @type EE_Payment_Processor $payment_processor */
2040
+			$payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
2041
+			$payment_processor->process_registration_payments($transaction, $payment, $registrations);
2042
+		}
2043
+	}
2044
+
2045
+
2046
+	/**
2047
+	 * _process_registration_status_change
2048
+	 * This processes requested registration status changes for all the registrations
2049
+	 * on a given transaction and (optionally) sends out notifications for the changes.
2050
+	 *
2051
+	 * @param  EE_Transaction $transaction
2052
+	 * @param array           $REG_IDs
2053
+	 * @return bool
2054
+	 * @throws EE_Error
2055
+	 * @throws InvalidArgumentException
2056
+	 * @throws ReflectionException
2057
+	 * @throws InvalidDataTypeException
2058
+	 * @throws InvalidInterfaceException
2059
+	 */
2060
+	protected function _process_registration_status_change(EE_Transaction $transaction, $REG_IDs = array())
2061
+	{
2062
+		// first if there is no change in status then we get out.
2063
+		if (! isset($this->_req_data['txn_reg_status_change']['reg_status'])
2064
+			|| $this->_req_data['txn_reg_status_change']['reg_status'] === 'NAN'
2065
+		) {
2066
+			// no error message, no change requested, just nothing to do man.
2067
+			return false;
2068
+		}
2069
+		/** @type EE_Transaction_Processor $transaction_processor */
2070
+		$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
2071
+
2072
+		// made it here dude?  Oh WOW.  K, let's take care of changing the statuses
2073
+		return $transaction_processor->manually_update_registration_statuses(
2074
+			$transaction,
2075
+			sanitize_text_field($this->_req_data['txn_reg_status_change']['reg_status']),
2076
+			array(array('REG_ID' => array('IN', $REG_IDs)))
2077
+		);
2078
+	}
2079
+
2080
+
2081
+	/**
2082
+	 * _build_payment_json_response
2083
+	 *
2084
+	 * @access public
2085
+	 * @param \EE_Payment $payment
2086
+	 * @param array       $REG_IDs
2087
+	 * @param bool | null $delete_txn_reg_status_change
2088
+	 * @return array
2089
+	 * @throws EE_Error
2090
+	 * @throws InvalidArgumentException
2091
+	 * @throws InvalidDataTypeException
2092
+	 * @throws InvalidInterfaceException
2093
+	 * @throws ReflectionException
2094
+	 */
2095
+	protected function _build_payment_json_response(
2096
+		EE_Payment $payment,
2097
+		$REG_IDs = array(),
2098
+		$delete_txn_reg_status_change = null
2099
+	) {
2100
+		// was the payment deleted ?
2101
+		if (is_bool($delete_txn_reg_status_change)) {
2102
+			return array(
2103
+				'PAY_ID'                       => $payment->ID(),
2104
+				'amount'                       => $payment->amount(),
2105
+				'total_paid'                   => $payment->transaction()->paid(),
2106
+				'txn_status'                   => $payment->transaction()->status_ID(),
2107
+				'pay_status'                   => $payment->STS_ID(),
2108
+				'registrations'                => $this->_registration_payment_data_array($REG_IDs),
2109
+				'delete_txn_reg_status_change' => $delete_txn_reg_status_change,
2110
+			);
2111
+		} else {
2112
+			$this->_get_payment_status_array();
2113
+
2114
+			return array(
2115
+				'amount'           => $payment->amount(),
2116
+				'total_paid'       => $payment->transaction()->paid(),
2117
+				'txn_status'       => $payment->transaction()->status_ID(),
2118
+				'pay_status'       => $payment->STS_ID(),
2119
+				'PAY_ID'           => $payment->ID(),
2120
+				'STS_ID'           => $payment->STS_ID(),
2121
+				'status'           => self::$_pay_status[ $payment->STS_ID() ],
2122
+				'date'             => $payment->timestamp('Y-m-d', 'h:i a'),
2123
+				'method'           => strtoupper($payment->source()),
2124
+				'PM_ID'            => $payment->payment_method() ? $payment->payment_method()->ID() : 1,
2125
+				'gateway'          => $payment->payment_method()
2126
+					? $payment->payment_method()->admin_name()
2127
+					: esc_html__("Unknown", 'event_espresso'),
2128
+				'gateway_response' => $payment->gateway_response(),
2129
+				'txn_id_chq_nmbr'  => $payment->txn_id_chq_nmbr(),
2130
+				'po_number'        => $payment->po_number(),
2131
+				'extra_accntng'    => $payment->extra_accntng(),
2132
+				'registrations'    => $this->_registration_payment_data_array($REG_IDs),
2133
+			);
2134
+		}
2135
+	}
2136
+
2137
+
2138
+	/**
2139
+	 * delete_payment
2140
+	 *    delete a payment or refund made towards a transaction
2141
+	 *
2142
+	 * @access public
2143
+	 * @return void
2144
+	 * @throws EE_Error
2145
+	 * @throws InvalidArgumentException
2146
+	 * @throws ReflectionException
2147
+	 * @throws InvalidDataTypeException
2148
+	 * @throws InvalidInterfaceException
2149
+	 */
2150
+	public function delete_payment()
2151
+	{
2152
+		$json_response_data = array('return_data' => false);
2153
+		$PAY_ID = isset($this->_req_data['delete_txn_admin_payment']['PAY_ID'])
2154
+			? absint($this->_req_data['delete_txn_admin_payment']['PAY_ID'])
2155
+			: 0;
2156
+		$can_delete = EE_Registry::instance()->CAP->current_user_can(
2157
+			'ee_delete_payments',
2158
+			'delete_payment_from_registration_details'
2159
+		);
2160
+		if ($PAY_ID && $can_delete) {
2161
+			$delete_txn_reg_status_change = isset($this->_req_data['delete_txn_reg_status_change'])
2162
+				? $this->_req_data['delete_txn_reg_status_change']
2163
+				: false;
2164
+			$payment = EEM_Payment::instance()->get_one_by_ID($PAY_ID);
2165
+			if ($payment instanceof EE_Payment) {
2166
+				$REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment);
2167
+				/** @type EE_Transaction_Payments $transaction_payments */
2168
+				$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
2169
+				if ($transaction_payments->delete_payment_and_update_transaction($payment)) {
2170
+					$json_response_data['return_data'] = $this->_build_payment_json_response(
2171
+						$payment,
2172
+						$REG_IDs,
2173
+						$delete_txn_reg_status_change
2174
+					);
2175
+					if ($delete_txn_reg_status_change) {
2176
+						$this->_req_data['txn_reg_status_change'] = $delete_txn_reg_status_change;
2177
+						// MAKE sure we also add the delete_txn_req_status_change to the
2178
+						// $_REQUEST global because that's how messages will be looking for it.
2179
+						$_REQUEST['txn_reg_status_change'] = $delete_txn_reg_status_change;
2180
+						$this->_maybe_send_notifications();
2181
+						$this->_process_registration_status_change($payment->transaction(), $REG_IDs);
2182
+					}
2183
+				}
2184
+			} else {
2185
+				EE_Error::add_error(
2186
+					esc_html__('Valid Payment data could not be retrieved from the database.', 'event_espresso'),
2187
+					__FILE__,
2188
+					__FUNCTION__,
2189
+					__LINE__
2190
+				);
2191
+			}
2192
+		} else {
2193
+			if ($can_delete) {
2194
+				EE_Error::add_error(
2195
+					esc_html__(
2196
+						'A valid Payment ID was not received, therefore payment form data could not be loaded.',
2197
+						'event_espresso'
2198
+					),
2199
+					__FILE__,
2200
+					__FUNCTION__,
2201
+					__LINE__
2202
+				);
2203
+			} else {
2204
+				EE_Error::add_error(
2205
+					esc_html__(
2206
+						'You do not have access to delete a payment.',
2207
+						'event_espresso'
2208
+					),
2209
+					__FILE__,
2210
+					__FUNCTION__,
2211
+					__LINE__
2212
+				);
2213
+			}
2214
+		}
2215
+		$notices = EE_Error::get_notices(false, false, false);
2216
+		$this->_template_args = array(
2217
+			'data'      => $json_response_data,
2218
+			'success'   => $notices['success'],
2219
+			'error'     => $notices['errors'],
2220
+			'attention' => $notices['attention'],
2221
+		);
2222
+		$this->_return_json();
2223
+	}
2224
+
2225
+
2226
+	/**
2227
+	 * _registration_payment_data_array
2228
+	 * adds info for 'owing' and 'paid' for each registration to the json response
2229
+	 *
2230
+	 * @access protected
2231
+	 * @param array $REG_IDs
2232
+	 * @return array
2233
+	 * @throws EE_Error
2234
+	 * @throws InvalidArgumentException
2235
+	 * @throws InvalidDataTypeException
2236
+	 * @throws InvalidInterfaceException
2237
+	 * @throws ReflectionException
2238
+	 */
2239
+	protected function _registration_payment_data_array($REG_IDs)
2240
+	{
2241
+		$registration_payment_data = array();
2242
+		// if non empty reg_ids lets get an array of registrations and update the values for the apply_payment/refund rows.
2243
+		if (! empty($REG_IDs)) {
2244
+			$registrations = EEM_Registration::instance()->get_all(array(array('REG_ID' => array('IN', $REG_IDs))));
2245
+			foreach ($registrations as $registration) {
2246
+				if ($registration instanceof EE_Registration) {
2247
+					$registration_payment_data[ $registration->ID() ] = array(
2248
+						'paid'  => $registration->pretty_paid(),
2249
+						'owing' => EEH_Template::format_currency($registration->final_price() - $registration->paid()),
2250
+					);
2251
+				}
2252
+			}
2253
+		}
2254
+
2255
+		return $registration_payment_data;
2256
+	}
2257
+
2258
+
2259
+	/**
2260
+	 * _maybe_send_notifications
2261
+	 * determines whether or not the admin has indicated that notifications should be sent.
2262
+	 * If so, will toggle a filter switch for delivering registration notices.
2263
+	 * If passed an EE_Payment object, then it will trigger payment notifications instead.
2264
+	 *
2265
+	 * @access protected
2266
+	 * @param \EE_Payment | null $payment
2267
+	 */
2268
+	protected function _maybe_send_notifications($payment = null)
2269
+	{
2270
+		switch ($payment instanceof EE_Payment) {
2271
+			// payment notifications
2272
+			case true:
2273
+				if (isset(
2274
+					$this->_req_data['txn_payments'],
2275
+					$this->_req_data['txn_payments']['send_notifications']
2276
+				)
2277
+					&& filter_var($this->_req_data['txn_payments']['send_notifications'], FILTER_VALIDATE_BOOLEAN)
2278
+				) {
2279
+					$this->_process_payment_notification($payment);
2280
+				}
2281
+				break;
2282
+			// registration notifications
2283
+			case false:
2284
+				if (isset(
2285
+					$this->_req_data['txn_reg_status_change'],
2286
+					$this->_req_data['txn_reg_status_change']['send_notifications']
2287
+				)
2288
+					&& filter_var($this->_req_data['txn_reg_status_change']['send_notifications'], FILTER_VALIDATE_BOOLEAN)
2289
+				) {
2290
+					add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true');
2291
+				}
2292
+				break;
2293
+		}
2294
+	}
2295
+
2296
+
2297
+	/**
2298
+	 * _send_payment_reminder
2299
+	 *    generates HTML for the View Transaction Details Admin page
2300
+	 *
2301
+	 * @access protected
2302
+	 * @return void
2303
+	 * @throws EE_Error
2304
+	 * @throws InvalidArgumentException
2305
+	 * @throws InvalidDataTypeException
2306
+	 * @throws InvalidInterfaceException
2307
+	 */
2308
+	protected function _send_payment_reminder()
2309
+	{
2310
+		$TXN_ID = ! empty($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : false;
2311
+		$transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
2312
+		$query_args = isset($this->_req_data['redirect_to']) ? array(
2313
+			'action' => $this->_req_data['redirect_to'],
2314
+			'TXN_ID' => $this->_req_data['TXN_ID'],
2315
+		) : array();
2316
+		do_action(
2317
+			'AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder',
2318
+			$transaction
2319
+		);
2320
+		$this->_redirect_after_action(
2321
+			false,
2322
+			esc_html__('payment reminder', 'event_espresso'),
2323
+			esc_html__('sent', 'event_espresso'),
2324
+			$query_args,
2325
+			true
2326
+		);
2327
+	}
2328
+
2329
+
2330
+	/**
2331
+	 *  get_transactions
2332
+	 *    get transactions for given parameters (used by list table)
2333
+	 *
2334
+	 * @param  int     $perpage how many transactions displayed per page
2335
+	 * @param  boolean $count   return the count or objects
2336
+	 * @param string   $view
2337
+	 * @return mixed int = count || array of transaction objects
2338
+	 * @throws EE_Error
2339
+	 * @throws InvalidArgumentException
2340
+	 * @throws InvalidDataTypeException
2341
+	 * @throws InvalidInterfaceException
2342
+	 */
2343
+	public function get_transactions($perpage, $count = false, $view = '')
2344
+	{
2345
+
2346
+		$TXN = EEM_Transaction::instance();
2347
+
2348
+		$start_date = isset($this->_req_data['txn-filter-start-date'])
2349
+			? wp_strip_all_tags($this->_req_data['txn-filter-start-date'])
2350
+			: date(
2351
+				'm/d/Y',
2352
+				strtotime('-10 year')
2353
+			);
2354
+		$end_date = isset($this->_req_data['txn-filter-end-date'])
2355
+			? wp_strip_all_tags($this->_req_data['txn-filter-end-date'])
2356
+			: date('m/d/Y');
2357
+
2358
+		// make sure our timestamps start and end right at the boundaries for each day
2359
+		$start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00';
2360
+		$end_date = date('Y-m-d', strtotime($end_date)) . ' 23:59:59';
2361
+
2362
+
2363
+		// convert to timestamps
2364
+		$start_date = strtotime($start_date);
2365
+		$end_date = strtotime($end_date);
2366
+
2367
+		// makes sure start date is the lowest value and vice versa
2368
+		$start_date = min($start_date, $end_date);
2369
+		$end_date = max($start_date, $end_date);
2370
+
2371
+		// convert to correct format for query
2372
+		$start_date = EEM_Transaction::instance()->convert_datetime_for_query(
2373
+			'TXN_timestamp',
2374
+			date('Y-m-d H:i:s', $start_date),
2375
+			'Y-m-d H:i:s'
2376
+		);
2377
+		$end_date = EEM_Transaction::instance()->convert_datetime_for_query(
2378
+			'TXN_timestamp',
2379
+			date('Y-m-d H:i:s', $end_date),
2380
+			'Y-m-d H:i:s'
2381
+		);
2382
+
2383
+
2384
+		// set orderby
2385
+		$this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
2386
+
2387
+		switch ($this->_req_data['orderby']) {
2388
+			case 'TXN_ID':
2389
+				$orderby = 'TXN_ID';
2390
+				break;
2391
+			case 'ATT_fname':
2392
+				$orderby = 'Registration.Attendee.ATT_fname';
2393
+				break;
2394
+			case 'event_name':
2395
+				$orderby = 'Registration.Event.EVT_name';
2396
+				break;
2397
+			default: // 'TXN_timestamp'
2398
+				$orderby = 'TXN_timestamp';
2399
+		}
2400
+
2401
+		$sort = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC';
2402
+		$current_page = ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1;
2403
+		$per_page = ! empty($perpage) ? $perpage : 10;
2404
+		$per_page = ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page;
2405
+
2406
+		$offset = ($current_page - 1) * $per_page;
2407
+		$limit = array($offset, $per_page);
2408
+
2409
+		$_where = array(
2410
+			'TXN_timestamp'          => array('BETWEEN', array($start_date, $end_date)),
2411
+			'Registration.REG_count' => 1,
2412
+		);
2413
+
2414
+		if (isset($this->_req_data['EVT_ID'])) {
2415
+			$_where['Registration.EVT_ID'] = $this->_req_data['EVT_ID'];
2416
+		}
2417
+
2418
+		if (isset($this->_req_data['s'])) {
2419
+			$search_string = '%' . $this->_req_data['s'] . '%';
2420
+			$_where['OR'] = array(
2421
+				'Registration.Event.EVT_name'         => array('LIKE', $search_string),
2422
+				'Registration.Event.EVT_desc'         => array('LIKE', $search_string),
2423
+				'Registration.Event.EVT_short_desc'   => array('LIKE', $search_string),
2424
+				'Registration.Attendee.ATT_full_name' => array('LIKE', $search_string),
2425
+				'Registration.Attendee.ATT_fname'     => array('LIKE', $search_string),
2426
+				'Registration.Attendee.ATT_lname'     => array('LIKE', $search_string),
2427
+				'Registration.Attendee.ATT_short_bio' => array('LIKE', $search_string),
2428
+				'Registration.Attendee.ATT_email'     => array('LIKE', $search_string),
2429
+				'Registration.Attendee.ATT_address'   => array('LIKE', $search_string),
2430
+				'Registration.Attendee.ATT_address2'  => array('LIKE', $search_string),
2431
+				'Registration.Attendee.ATT_city'      => array('LIKE', $search_string),
2432
+				'Registration.REG_final_price'        => array('LIKE', $search_string),
2433
+				'Registration.REG_code'               => array('LIKE', $search_string),
2434
+				'Registration.REG_count'              => array('LIKE', $search_string),
2435
+				'Registration.REG_group_size'         => array('LIKE', $search_string),
2436
+				'Registration.Ticket.TKT_name'        => array('LIKE', $search_string),
2437
+				'Registration.Ticket.TKT_description' => array('LIKE', $search_string),
2438
+				'Payment.PAY_source'                  => array('LIKE', $search_string),
2439
+				'Payment.Payment_Method.PMD_name'     => array('LIKE', $search_string),
2440
+				'TXN_session_data'                    => array('LIKE', $search_string),
2441
+				'Payment.PAY_txn_id_chq_nmbr'         => array('LIKE', $search_string),
2442
+			);
2443
+		}
2444
+
2445
+		// failed transactions
2446
+		$failed = (! empty($this->_req_data['status']) && $this->_req_data['status'] === 'failed' && ! $count)
2447
+				  || ($count && $view === 'failed');
2448
+		$abandoned = (! empty($this->_req_data['status']) && $this->_req_data['status'] === 'abandoned' && ! $count)
2449
+					 || ($count && $view === 'abandoned');
2450
+
2451
+		if ($failed) {
2452
+			$_where['STS_ID'] = EEM_Transaction::failed_status_code;
2453
+		} elseif ($abandoned) {
2454
+			$_where['STS_ID'] = EEM_Transaction::abandoned_status_code;
2455
+		} else {
2456
+			$_where['STS_ID'] = array('!=', EEM_Transaction::failed_status_code);
2457
+			$_where['STS_ID*'] = array('!=', EEM_Transaction::abandoned_status_code);
2458
+		}
2459
+
2460
+		$query_params = array(
2461
+			$_where,
2462
+			'order_by'                 => array($orderby => $sort),
2463
+			'limit'                    => $limit,
2464
+			'default_where_conditions' => EEM_Base::default_where_conditions_this_only,
2465
+		);
2466
+
2467
+		$transactions = $count
2468
+			? $TXN->count(array($_where), 'TXN_ID', true)
2469
+			: $TXN->get_all($query_params);
2470
+
2471
+		return $transactions;
2472
+	}
2473 2473
 }
Please login to merge, or discard this patch.
Spacing   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
         // enqueue style
364 364
         wp_register_style(
365 365
             'espresso_txn',
366
-            TXN_ASSETS_URL . 'espresso_transactions_admin.css',
366
+            TXN_ASSETS_URL.'espresso_transactions_admin.css',
367 367
             array(),
368 368
             EVENT_ESPRESSO_VERSION
369 369
         );
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
         // scripts
372 372
         wp_register_script(
373 373
             'espresso_txn',
374
-            TXN_ASSETS_URL . 'espresso_transactions_admin.js',
374
+            TXN_ASSETS_URL.'espresso_transactions_admin.js',
375 375
             array(
376 376
                 'ee_admin_js',
377 377
                 'ee-datepicker',
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
             : null;
473 473
         $this->_transaction->verify_abandoned_transaction_status();
474 474
 
475
-        if (! $this->_transaction instanceof EE_Transaction) {
475
+        if ( ! $this->_transaction instanceof EE_Transaction) {
476 476
             $error_msg = sprintf(
477 477
                 esc_html__(
478 478
                     'An error occurred and the details for the transaction with the ID # %d could not be retrieved.',
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
             'FHEE__Transactions_Admin_Page___transaction_legend_items__more_items',
571 571
             array(
572 572
                 'overpaid'   => array(
573
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::overpaid_status_code,
573
+                    'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::overpaid_status_code,
574 574
                     'desc'  => EEH_Template::pretty_status(
575 575
                         EEM_Transaction::overpaid_status_code,
576 576
                         false,
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
                     ),
579 579
                 ),
580 580
                 'complete'   => array(
581
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::complete_status_code,
581
+                    'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::complete_status_code,
582 582
                     'desc'  => EEH_Template::pretty_status(
583 583
                         EEM_Transaction::complete_status_code,
584 584
                         false,
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
                     ),
587 587
                 ),
588 588
                 'incomplete' => array(
589
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::incomplete_status_code,
589
+                    'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::incomplete_status_code,
590 590
                     'desc'  => EEH_Template::pretty_status(
591 591
                         EEM_Transaction::incomplete_status_code,
592 592
                         false,
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
                     ),
595 595
                 ),
596 596
                 'abandoned'  => array(
597
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::abandoned_status_code,
597
+                    'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::abandoned_status_code,
598 598
                     'desc'  => EEH_Template::pretty_status(
599 599
                         EEM_Transaction::abandoned_status_code,
600 600
                         false,
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
                     ),
603 603
                 ),
604 604
                 'failed'     => array(
605
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::failed_status_code,
605
+                    'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::failed_status_code,
606 606
                     'desc'  => EEH_Template::pretty_status(
607 607
                         EEM_Transaction::failed_status_code,
608 608
                         false,
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
                     'Click to Edit event',
652 652
                     'event_espresso'
653 653
                 )
654
-                . '">' . $event->get('EVT_name') . '</a>',
654
+                . '">'.$event->get('EVT_name').'</a>',
655 655
                 '</h3>'
656 656
             )
657 657
             : '';
@@ -696,9 +696,9 @@  discard block
 block discarded – undo
696 696
         $this->_template_args['txn_datetime']['value'] = $this->_transaction->get_i18n_datetime('TXN_timestamp');
697 697
         $this->_template_args['txn_datetime']['label'] = esc_html__('Date', 'event_espresso');
698 698
 
699
-        $this->_template_args['txn_status']['value'] = self::$_txn_status[ $this->_transaction->get('STS_ID') ];
699
+        $this->_template_args['txn_status']['value'] = self::$_txn_status[$this->_transaction->get('STS_ID')];
700 700
         $this->_template_args['txn_status']['label'] = esc_html__('Transaction Status', 'event_espresso');
701
-        $this->_template_args['txn_status']['class'] = 'status-' . $this->_transaction->get('STS_ID');
701
+        $this->_template_args['txn_status']['class'] = 'status-'.$this->_transaction->get('STS_ID');
702 702
 
703 703
         $this->_template_args['grand_total'] = $this->_transaction->get('TXN_total');
704 704
         $this->_template_args['total_paid'] = $this->_transaction->get('TXN_paid');
@@ -816,7 +816,7 @@  discard block
 block discarded – undo
816 816
         // grab messages at the last second
817 817
         $this->_template_args['notices'] = EE_Error::get_notices();
818 818
         // path to template
819
-        $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_header.template.php';
819
+        $template_path = TXN_TEMPLATE_PATH.'txn_admin_details_header.template.php';
820 820
         $this->_template_args['admin_page_header'] = EEH_Template::display_template(
821 821
             $template_path,
822 822
             $this->_template_args,
@@ -897,7 +897,7 @@  discard block
 block discarded – undo
897 897
     {
898 898
         $content = '';
899 899
         $actions = array();
900
-        if (! $transaction instanceof EE_Transaction) {
900
+        if ( ! $transaction instanceof EE_Transaction) {
901 901
             return $content;
902 902
         }
903 903
         /** @var EE_Registration $primary_registration */
@@ -958,7 +958,7 @@  discard block
 block discarded – undo
958 958
         );
959 959
         if ($actions) {
960 960
             $content = '<ul>';
961
-            $content .= '<li>' . implode('</li><li>', $actions) . '</li>';
961
+            $content .= '<li>'.implode('</li><li>', $actions).'</li>';
962 962
             $content .= '</uL>';
963 963
         }
964 964
         return $content;
@@ -1023,7 +1023,7 @@  discard block
 block discarded – undo
1023 1023
 
1024 1024
         // process payment details
1025 1025
         $payments = $this->_transaction->get_many_related('Payment');
1026
-        if (! empty($payments)) {
1026
+        if ( ! empty($payments)) {
1027 1027
             $this->_template_args['payments'] = $payments;
1028 1028
             $this->_template_args['existing_reg_payments'] = $this->_get_registration_payment_IDs($payments);
1029 1029
         } else {
@@ -1084,7 +1084,7 @@  discard block
 block discarded – undo
1084 1084
                                   esc_html__('%1$s : Initiated %2$s', 'event_espresso'),
1085 1085
                                   ucwords(str_replace('_', ' ', $reg_step)),
1086 1086
                                   date(
1087
-                                      get_option('date_format') . ' ' . get_option('time_format'),
1087
+                                      get_option('date_format').' '.get_option('time_format'),
1088 1088
                                       ($reg_step_status + (get_option('gmt_offset') * HOUR_IN_SECONDS))
1089 1089
                                   )
1090 1090
                               )
@@ -1137,7 +1137,7 @@  discard block
 block discarded – undo
1137 1137
 
1138 1138
         // 'espresso_delete_payment_nonce'
1139 1139
 
1140
-        $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_txn_details.template.php';
1140
+        $template_path = TXN_TEMPLATE_PATH.'txn_admin_details_main_meta_box_txn_details.template.php';
1141 1141
         echo EEH_Template::display_template($template_path, $this->_template_args, true);
1142 1142
     }
1143 1143
 
@@ -1169,18 +1169,18 @@  discard block
 block discarded – undo
1169 1169
                 ),
1170 1170
             )
1171 1171
         );
1172
-        if (! empty($reg_payments)) {
1172
+        if ( ! empty($reg_payments)) {
1173 1173
             foreach ($payments as $payment) {
1174
-                if (! $payment instanceof EE_Payment) {
1174
+                if ( ! $payment instanceof EE_Payment) {
1175 1175
                     continue;
1176
-                } elseif (! isset($existing_reg_payments[ $payment->ID() ])) {
1177
-                    $existing_reg_payments[ $payment->ID() ] = array();
1176
+                } elseif ( ! isset($existing_reg_payments[$payment->ID()])) {
1177
+                    $existing_reg_payments[$payment->ID()] = array();
1178 1178
                 }
1179 1179
                 foreach ($reg_payments as $reg_payment) {
1180 1180
                     if ($reg_payment instanceof EE_Registration_Payment
1181 1181
                         && $reg_payment->payment_ID() === $payment->ID()
1182 1182
                     ) {
1183
-                        $existing_reg_payments[ $payment->ID() ][] = $reg_payment->registration_ID();
1183
+                        $existing_reg_payments[$payment->ID()][] = $reg_payment->registration_ID();
1184 1184
                     }
1185 1185
                 }
1186 1186
             }
@@ -1221,16 +1221,16 @@  discard block
 block discarded – undo
1221 1221
                                                  '',
1222 1222
                                                  'clear: both; margin: 1.5em 0 0; display: none;'
1223 1223
                                              );
1224
-        $registrations_to_apply_payment_to .= EEH_HTML::br() . EEH_HTML::div('', '', 'admin-primary-mbox-tbl-wrap');
1224
+        $registrations_to_apply_payment_to .= EEH_HTML::br().EEH_HTML::div('', '', 'admin-primary-mbox-tbl-wrap');
1225 1225
         $registrations_to_apply_payment_to .= EEH_HTML::table('', '', 'admin-primary-mbox-tbl');
1226 1226
         $registrations_to_apply_payment_to .= EEH_HTML::thead(
1227 1227
             EEH_HTML::tr(
1228
-                EEH_HTML::th(esc_html__('ID', 'event_espresso')) .
1229
-                EEH_HTML::th(esc_html__('Registrant', 'event_espresso')) .
1230
-                EEH_HTML::th(esc_html__('Ticket', 'event_espresso')) .
1231
-                EEH_HTML::th(esc_html__('Event', 'event_espresso')) .
1232
-                EEH_HTML::th(esc_html__('Paid', 'event_espresso'), '', 'txn-admin-payment-paid-td jst-cntr') .
1233
-                EEH_HTML::th(esc_html__('Owing', 'event_espresso'), '', 'txn-admin-payment-owing-td jst-cntr') .
1228
+                EEH_HTML::th(esc_html__('ID', 'event_espresso')).
1229
+                EEH_HTML::th(esc_html__('Registrant', 'event_espresso')).
1230
+                EEH_HTML::th(esc_html__('Ticket', 'event_espresso')).
1231
+                EEH_HTML::th(esc_html__('Event', 'event_espresso')).
1232
+                EEH_HTML::th(esc_html__('Paid', 'event_espresso'), '', 'txn-admin-payment-paid-td jst-cntr').
1233
+                EEH_HTML::th(esc_html__('Owing', 'event_espresso'), '', 'txn-admin-payment-owing-td jst-cntr').
1234 1234
                 EEH_HTML::th(esc_html__('Apply', 'event_espresso'), '', 'jst-cntr')
1235 1235
             )
1236 1236
         );
@@ -1245,29 +1245,29 @@  discard block
 block discarded – undo
1245 1245
                     : esc_html__('Unknown Attendee', 'event_espresso');
1246 1246
                 $owing = $registration->final_price() - $registration->paid();
1247 1247
                 $taxable = $registration->ticket()->taxable()
1248
-                    ? ' <span class="smaller-text lt-grey-text"> ' . esc_html__('+ tax', 'event_espresso') . '</span>'
1248
+                    ? ' <span class="smaller-text lt-grey-text"> '.esc_html__('+ tax', 'event_espresso').'</span>'
1249 1249
                     : '';
1250 1250
                 $checked = empty($existing_reg_payments) || in_array($registration->ID(), $existing_reg_payments)
1251 1251
                     ? ' checked="checked"'
1252 1252
                     : '';
1253 1253
                 $disabled = $registration->final_price() > 0 ? '' : ' disabled';
1254 1254
                 $registrations_to_apply_payment_to .= EEH_HTML::tr(
1255
-                    EEH_HTML::td($registration->ID()) .
1256
-                    EEH_HTML::td($attendee_name) .
1255
+                    EEH_HTML::td($registration->ID()).
1256
+                    EEH_HTML::td($attendee_name).
1257 1257
                     EEH_HTML::td(
1258
-                        $registration->ticket()->name() . ' : ' . $registration->ticket()->pretty_price() . $taxable
1259
-                    ) .
1260
-                    EEH_HTML::td($registration->event_name()) .
1261
-                    EEH_HTML::td($registration->pretty_paid(), '', 'txn-admin-payment-paid-td jst-cntr') .
1262
-                    EEH_HTML::td(EEH_Template::format_currency($owing), '', 'txn-admin-payment-owing-td jst-cntr') .
1258
+                        $registration->ticket()->name().' : '.$registration->ticket()->pretty_price().$taxable
1259
+                    ).
1260
+                    EEH_HTML::td($registration->event_name()).
1261
+                    EEH_HTML::td($registration->pretty_paid(), '', 'txn-admin-payment-paid-td jst-cntr').
1262
+                    EEH_HTML::td(EEH_Template::format_currency($owing), '', 'txn-admin-payment-owing-td jst-cntr').
1263 1263
                     EEH_HTML::td(
1264
-                        '<input type="checkbox" value="' . $registration->ID()
1264
+                        '<input type="checkbox" value="'.$registration->ID()
1265 1265
                         . '" name="txn_admin_payment[registrations]"'
1266
-                        . $checked . $disabled . '>',
1266
+                        . $checked.$disabled.'>',
1267 1267
                         '',
1268 1268
                         'jst-cntr'
1269 1269
                     ),
1270
-                    'apply-payment-registration-row-' . $registration->ID()
1270
+                    'apply-payment-registration-row-'.$registration->ID()
1271 1271
                 );
1272 1272
             }
1273 1273
         }
@@ -1348,12 +1348,12 @@  discard block
 block discarded – undo
1348 1348
                 array(
1349 1349
                     'OR*payment_method_for_payment' => array(
1350 1350
                         'PMD_ID'    => array('IN', $payment_methods_of_payments),
1351
-                        'PMD_scope' => array('LIKE', '%' . EEM_Payment_Method::scope_admin . '%'),
1351
+                        'PMD_scope' => array('LIKE', '%'.EEM_Payment_Method::scope_admin.'%'),
1352 1352
                     ),
1353 1353
                 ),
1354 1354
             );
1355 1355
         } else {
1356
-            $query_args = array(array('PMD_scope' => array('LIKE', '%' . EEM_Payment_Method::scope_admin . '%')));
1356
+            $query_args = array(array('PMD_scope' => array('LIKE', '%'.EEM_Payment_Method::scope_admin.'%')));
1357 1357
         }
1358 1358
         $this->_template_args['payment_methods'] = EEM_Payment_Method::instance()->get_all($query_args);
1359 1359
     }
@@ -1382,7 +1382,7 @@  discard block
 block discarded – undo
1382 1382
             'Line_Item',
1383 1383
             array(array('LIN_type' => 'line-item'))
1384 1384
         );
1385
-        if (! empty($line_items)) {
1385
+        if ( ! empty($line_items)) {
1386 1386
             foreach ($line_items as $item) {
1387 1387
                 if ($item instanceof EE_Line_Item) {
1388 1388
                     switch ($item->OBJ_type()) {
@@ -1392,7 +1392,7 @@  discard block
 block discarded – undo
1392 1392
                             $ticket = $item->ticket();
1393 1393
                             // right now we're only handling tickets here.
1394 1394
                             // Cause its expected that only tickets will have attendees right?
1395
-                            if (! $ticket instanceof EE_Ticket) {
1395
+                            if ( ! $ticket instanceof EE_Ticket) {
1396 1396
                                 continue;
1397 1397
                             }
1398 1398
                             try {
@@ -1401,7 +1401,7 @@  discard block
 block discarded – undo
1401 1401
                                 EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1402 1402
                                 $event_name = esc_html__('Unknown Event', 'event_espresso');
1403 1403
                             }
1404
-                            $event_name .= ' - ' . $item->get('LIN_name');
1404
+                            $event_name .= ' - '.$item->get('LIN_name');
1405 1405
                             $ticket_price = EEH_Template::format_currency($item->get('LIN_unit_price'));
1406 1406
                             // now get all of the registrations for this transaction that use this ticket
1407 1407
                             $registrations = $ticket->get_many_related(
@@ -1409,38 +1409,38 @@  discard block
 block discarded – undo
1409 1409
                                 array(array('TXN_ID' => $this->_transaction->ID()))
1410 1410
                             );
1411 1411
                             foreach ($registrations as $registration) {
1412
-                                if (! $registration instanceof EE_Registration) {
1412
+                                if ( ! $registration instanceof EE_Registration) {
1413 1413
                                     continue;
1414 1414
                                 }
1415
-                                $this->_template_args['event_attendees'][ $registration->ID() ]['STS_ID']
1415
+                                $this->_template_args['event_attendees'][$registration->ID()]['STS_ID']
1416 1416
                                     = $registration->status_ID();
1417
-                                $this->_template_args['event_attendees'][ $registration->ID() ]['att_num']
1417
+                                $this->_template_args['event_attendees'][$registration->ID()]['att_num']
1418 1418
                                     = $registration->count();
1419
-                                $this->_template_args['event_attendees'][ $registration->ID() ]['event_ticket_name']
1419
+                                $this->_template_args['event_attendees'][$registration->ID()]['event_ticket_name']
1420 1420
                                     = $event_name;
1421
-                                $this->_template_args['event_attendees'][ $registration->ID() ]['ticket_price']
1421
+                                $this->_template_args['event_attendees'][$registration->ID()]['ticket_price']
1422 1422
                                     = $ticket_price;
1423 1423
                                 // attendee info
1424 1424
                                 $attendee = $registration->get_first_related('Attendee');
1425 1425
                                 if ($attendee instanceof EE_Attendee) {
1426
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['att_id']
1426
+                                    $this->_template_args['event_attendees'][$registration->ID()]['att_id']
1427 1427
                                         = $attendee->ID();
1428
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['attendee']
1428
+                                    $this->_template_args['event_attendees'][$registration->ID()]['attendee']
1429 1429
                                         = $attendee->full_name();
1430
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['email']
1431
-                                        = '<a href="mailto:' . $attendee->email() . '?subject=' . $event_name
1430
+                                    $this->_template_args['event_attendees'][$registration->ID()]['email']
1431
+                                        = '<a href="mailto:'.$attendee->email().'?subject='.$event_name
1432 1432
                                           . esc_html__(
1433 1433
                                               ' Event',
1434 1434
                                               'event_espresso'
1435 1435
                                           )
1436
-                                          . '">' . $attendee->email() . '</a>';
1437
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['address']
1436
+                                          . '">'.$attendee->email().'</a>';
1437
+                                    $this->_template_args['event_attendees'][$registration->ID()]['address']
1438 1438
                                         = EEH_Address::format($attendee, 'inline', false, false);
1439 1439
                                 } else {
1440
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['att_id'] = '';
1441
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['attendee'] = '';
1442
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['email'] = '';
1443
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['address'] = '';
1440
+                                    $this->_template_args['event_attendees'][$registration->ID()]['att_id'] = '';
1441
+                                    $this->_template_args['event_attendees'][$registration->ID()]['attendee'] = '';
1442
+                                    $this->_template_args['event_attendees'][$registration->ID()]['email'] = '';
1443
+                                    $this->_template_args['event_attendees'][$registration->ID()]['address'] = '';
1444 1444
                                 }
1445 1445
                             }
1446 1446
                             break;
@@ -1456,7 +1456,7 @@  discard block
 block discarded – undo
1456 1456
                 TXN_ADMIN_URL
1457 1457
             );
1458 1458
             echo EEH_Template::display_template(
1459
-                TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_attendees.template.php',
1459
+                TXN_TEMPLATE_PATH.'txn_admin_details_main_meta_box_attendees.template.php',
1460 1460
                 $this->_template_args,
1461 1461
                 true
1462 1462
             );
@@ -1491,7 +1491,7 @@  discard block
 block discarded – undo
1491 1491
         $primary_att = $this->_transaction->primary_registration() instanceof EE_Registration
1492 1492
             ? $this->_transaction->primary_registration()->get_first_related('Attendee')
1493 1493
             : null;
1494
-        if (! $primary_att instanceof EE_Attendee) {
1494
+        if ( ! $primary_att instanceof EE_Attendee) {
1495 1495
             $this->_template_args['no_attendee_message'] = esc_html__(
1496 1496
                 'There is no attached contact for this transaction.  The transaction either failed due to an error or was abandoned.',
1497 1497
                 'event_espresso'
@@ -1513,7 +1513,7 @@  discard block
 block discarded – undo
1513 1513
         // get formatted address for registrant
1514 1514
         $this->_template_args['formatted_address'] = EEH_Address::format($primary_att);
1515 1515
         echo EEH_Template::display_template(
1516
-            TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_registrant.template.php',
1516
+            TXN_TEMPLATE_PATH.'txn_admin_details_side_meta_box_registrant.template.php',
1517 1517
             $this->_template_args,
1518 1518
             true
1519 1519
         );
@@ -1538,8 +1538,8 @@  discard block
 block discarded – undo
1538 1538
             TXN_ADMIN_URL
1539 1539
         );
1540 1540
 
1541
-        $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_billing_info.template.php';
1542
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);/**/
1541
+        $template_path = TXN_TEMPLATE_PATH.'txn_admin_details_side_meta_box_billing_info.template.php';
1542
+        echo EEH_Template::display_template($template_path, $this->_template_args, true); /**/
1543 1543
     }
1544 1544
 
1545 1545
 
@@ -1564,7 +1564,7 @@  discard block
 block discarded – undo
1564 1564
             'ee_edit_payments',
1565 1565
             'apply_payment_or_refund_from_registration_details'
1566 1566
         );
1567
-        if (! empty($valid_data) && $has_access) {
1567
+        if ( ! empty($valid_data) && $has_access) {
1568 1568
             $PAY_ID = $valid_data['PAY_ID'];
1569 1569
             // save  the new payment
1570 1570
             $payment = $this->_create_payment_from_request_data($valid_data);
@@ -1577,7 +1577,7 @@  discard block
 block discarded – undo
1577 1577
                 $REG_IDs = $this->_get_REG_IDs_to_apply_payment_to($payment);
1578 1578
                 $this->_remove_existing_registration_payments($payment, $PAY_ID);
1579 1579
                 // apply payment to registrations (if applicable)
1580
-                if (! empty($REG_IDs)) {
1580
+                if ( ! empty($REG_IDs)) {
1581 1581
                     $this->_update_registration_payments($transaction, $payment, $REG_IDs);
1582 1582
                     $this->_maybe_send_notifications();
1583 1583
                     // now process status changes for the same registrations
@@ -1647,14 +1647,14 @@  discard block
 block discarded – undo
1647 1647
      */
1648 1648
     protected function _validate_payment_request_data()
1649 1649
     {
1650
-        if (! isset($this->_req_data['txn_admin_payment'])) {
1650
+        if ( ! isset($this->_req_data['txn_admin_payment'])) {
1651 1651
             return false;
1652 1652
         }
1653 1653
         $payment_form = $this->_generate_payment_form_section();
1654 1654
         try {
1655 1655
             if ($payment_form->was_submitted()) {
1656 1656
                 $payment_form->receive_form_submission();
1657
-                if (! $payment_form->is_valid()) {
1657
+                if ( ! $payment_form->is_valid()) {
1658 1658
                     $submission_error_messages = array();
1659 1659
                     foreach ($payment_form->get_validation_errors_accumulated() as $validation_error) {
1660 1660
                         if ($validation_error instanceof EE_Validation_Error) {
@@ -1833,7 +1833,7 @@  discard block
 block discarded – undo
1833 1833
             array('Y-m-d', 'g:i a')
1834 1834
         );
1835 1835
 
1836
-        if (! $payment->save()) {
1836
+        if ( ! $payment->save()) {
1837 1837
             EE_Error::add_error(
1838 1838
                 sprintf(
1839 1839
                     esc_html__('Payment %1$d has not been successfully saved to the database.', 'event_espresso'),
@@ -2030,12 +2030,12 @@  discard block
 block discarded – undo
2030 2030
         // but add in some conditions regarding payment,
2031 2031
         // so that we don't apply payments to registrations that are free or have already been paid for
2032 2032
         // but ONLY if the payment is NOT a refund ( ie: the payment amount is not negative )
2033
-        if (! $payment->is_a_refund()) {
2033
+        if ( ! $payment->is_a_refund()) {
2034 2034
             $registration_query_where_params['REG_final_price'] = array('!=', 0);
2035 2035
             $registration_query_where_params['REG_final_price*'] = array('!=', 'REG_paid', true);
2036 2036
         }
2037 2037
         $registrations = $transaction->registrations(array($registration_query_where_params));
2038
-        if (! empty($registrations)) {
2038
+        if ( ! empty($registrations)) {
2039 2039
             /** @type EE_Payment_Processor $payment_processor */
2040 2040
             $payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
2041 2041
             $payment_processor->process_registration_payments($transaction, $payment, $registrations);
@@ -2060,7 +2060,7 @@  discard block
 block discarded – undo
2060 2060
     protected function _process_registration_status_change(EE_Transaction $transaction, $REG_IDs = array())
2061 2061
     {
2062 2062
         // first if there is no change in status then we get out.
2063
-        if (! isset($this->_req_data['txn_reg_status_change']['reg_status'])
2063
+        if ( ! isset($this->_req_data['txn_reg_status_change']['reg_status'])
2064 2064
             || $this->_req_data['txn_reg_status_change']['reg_status'] === 'NAN'
2065 2065
         ) {
2066 2066
             // no error message, no change requested, just nothing to do man.
@@ -2118,7 +2118,7 @@  discard block
 block discarded – undo
2118 2118
                 'pay_status'       => $payment->STS_ID(),
2119 2119
                 'PAY_ID'           => $payment->ID(),
2120 2120
                 'STS_ID'           => $payment->STS_ID(),
2121
-                'status'           => self::$_pay_status[ $payment->STS_ID() ],
2121
+                'status'           => self::$_pay_status[$payment->STS_ID()],
2122 2122
                 'date'             => $payment->timestamp('Y-m-d', 'h:i a'),
2123 2123
                 'method'           => strtoupper($payment->source()),
2124 2124
                 'PM_ID'            => $payment->payment_method() ? $payment->payment_method()->ID() : 1,
@@ -2240,11 +2240,11 @@  discard block
 block discarded – undo
2240 2240
     {
2241 2241
         $registration_payment_data = array();
2242 2242
         // if non empty reg_ids lets get an array of registrations and update the values for the apply_payment/refund rows.
2243
-        if (! empty($REG_IDs)) {
2243
+        if ( ! empty($REG_IDs)) {
2244 2244
             $registrations = EEM_Registration::instance()->get_all(array(array('REG_ID' => array('IN', $REG_IDs))));
2245 2245
             foreach ($registrations as $registration) {
2246 2246
                 if ($registration instanceof EE_Registration) {
2247
-                    $registration_payment_data[ $registration->ID() ] = array(
2247
+                    $registration_payment_data[$registration->ID()] = array(
2248 2248
                         'paid'  => $registration->pretty_paid(),
2249 2249
                         'owing' => EEH_Template::format_currency($registration->final_price() - $registration->paid()),
2250 2250
                     );
@@ -2356,8 +2356,8 @@  discard block
 block discarded – undo
2356 2356
             : date('m/d/Y');
2357 2357
 
2358 2358
         // make sure our timestamps start and end right at the boundaries for each day
2359
-        $start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00';
2360
-        $end_date = date('Y-m-d', strtotime($end_date)) . ' 23:59:59';
2359
+        $start_date = date('Y-m-d', strtotime($start_date)).' 00:00:00';
2360
+        $end_date = date('Y-m-d', strtotime($end_date)).' 23:59:59';
2361 2361
 
2362 2362
 
2363 2363
         // convert to timestamps
@@ -2416,7 +2416,7 @@  discard block
 block discarded – undo
2416 2416
         }
2417 2417
 
2418 2418
         if (isset($this->_req_data['s'])) {
2419
-            $search_string = '%' . $this->_req_data['s'] . '%';
2419
+            $search_string = '%'.$this->_req_data['s'].'%';
2420 2420
             $_where['OR'] = array(
2421 2421
                 'Registration.Event.EVT_name'         => array('LIKE', $search_string),
2422 2422
                 'Registration.Event.EVT_desc'         => array('LIKE', $search_string),
@@ -2443,9 +2443,9 @@  discard block
 block discarded – undo
2443 2443
         }
2444 2444
 
2445 2445
         // failed transactions
2446
-        $failed = (! empty($this->_req_data['status']) && $this->_req_data['status'] === 'failed' && ! $count)
2446
+        $failed = ( ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'failed' && ! $count)
2447 2447
                   || ($count && $view === 'failed');
2448
-        $abandoned = (! empty($this->_req_data['status']) && $this->_req_data['status'] === 'abandoned' && ! $count)
2448
+        $abandoned = ( ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'abandoned' && ! $count)
2449 2449
                      || ($count && $view === 'abandoned');
2450 2450
 
2451 2451
         if ($failed) {
Please login to merge, or discard this patch.
core/domain/services/factories/CartFactory.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -23,14 +23,14 @@
 block discarded – undo
23 23
 class CartFactory
24 24
 {
25 25
 
26
-    /**
27
-     * @return EE_Cart
28
-     * @throws InvalidArgumentException
29
-     * @throws InvalidInterfaceException
30
-     * @throws InvalidDataTypeException
31
-     */
32
-    public static function getCart()
33
-    {
34
-        return LoaderFactory::getLoader()->getShared('EE_Cart');
35
-    }
26
+	/**
27
+	 * @return EE_Cart
28
+	 * @throws InvalidArgumentException
29
+	 * @throws InvalidInterfaceException
30
+	 * @throws InvalidDataTypeException
31
+	 */
32
+	public static function getCart()
33
+	{
34
+		return LoaderFactory::getLoader()->getShared('EE_Cart');
35
+	}
36 36
 }
Please login to merge, or discard this patch.
core/EE_Config.core.php 3 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
      * @param    string         $name
534 534
      * @param    string         $config_class
535 535
      * @param    EE_Config_Base $config_obj
536
-     * @param    array          $tests_to_run
536
+     * @param    integer[]          $tests_to_run
537 537
      * @param    bool           $display_errors
538 538
      * @return    bool    TRUE on success, FALSE on fail
539 539
      */
@@ -797,7 +797,7 @@  discard block
 block discarded – undo
797 797
      * @access    public
798 798
      * @param    string                $section
799 799
      * @param    string                $name
800
-     * @param    EE_Config_Base|string $config_obj
800
+     * @param    EE_Config_Base $config_obj
801 801
      * @param    bool                  $throw_errors
802 802
      * @return    bool
803 803
      */
@@ -1764,7 +1764,7 @@  discard block
 block discarded – undo
1764 1764
 
1765 1765
 
1766 1766
     /**
1767
-     * @return array
1767
+     * @return integer[]
1768 1768
      */
1769 1769
     public function get_critical_pages_array()
1770 1770
     {
@@ -1779,7 +1779,7 @@  discard block
 block discarded – undo
1779 1779
 
1780 1780
 
1781 1781
     /**
1782
-     * @return array
1782
+     * @return string[]
1783 1783
      */
1784 1784
     public function get_critical_pages_shortcodes_array()
1785 1785
     {
@@ -3122,7 +3122,7 @@  discard block
 block discarded – undo
3122 3122
      * according to max_input_vars
3123 3123
      *
3124 3124
      * @param int   $input_count the count of input vars.
3125
-     * @return array {
3125
+     * @return string {
3126 3126
      *                           An array that represents whether available space and if no available space the error
3127 3127
      *                           message.
3128 3128
      * @type bool   $has_space   whether more inputs can be added.
Please login to merge, or discard this patch.
Spacing   +121 added lines, -121 removed lines patch added patch discarded remove patch
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
     public static function instance()
147 147
     {
148 148
         // check if class object is instantiated, and instantiated properly
149
-        if (! self::$_instance instanceof EE_Config) {
149
+        if ( ! self::$_instance instanceof EE_Config) {
150 150
             self::$_instance = new self();
151 151
         }
152 152
         return self::$_instance;
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
                 $this
285 285
             );
286 286
             if (is_object($settings) && property_exists($this, $config)) {
287
-                $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
287
+                $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__'.$config, $settings);
288 288
                 // call configs populate method to ensure any defaults are set for empty values.
289 289
                 if (method_exists($settings, 'populate')) {
290 290
                     $this->{$config}->populate();
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
                         break;
558 558
                     // TEST #2 : check that settings section exists
559 559
                     case 2:
560
-                        if (! isset($this->{$section})) {
560
+                        if ( ! isset($this->{$section})) {
561 561
                             if ($display_errors) {
562 562
                                 throw new EE_Error(
563 563
                                     sprintf(
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
                         break;
572 572
                     // TEST #3 : check that section is the proper format
573 573
                     case 3:
574
-                        if (! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
574
+                        if ( ! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
575 575
                         ) {
576 576
                             if ($display_errors) {
577 577
                                 throw new EE_Error(
@@ -617,7 +617,7 @@  discard block
 block discarded – undo
617 617
                         break;
618 618
                     // TEST #6 : verify config class is accessible
619 619
                     case 6:
620
-                        if (! class_exists($config_class)) {
620
+                        if ( ! class_exists($config_class)) {
621 621
                             if ($display_errors) {
622 622
                                 throw new EE_Error(
623 623
                                     sprintf(
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
                         break;
635 635
                     // TEST #7 : check that config has even been set
636 636
                     case 7:
637
-                        if (! isset($this->{$section}->{$name})) {
637
+                        if ( ! isset($this->{$section}->{$name})) {
638 638
                             if ($display_errors) {
639 639
                                 throw new EE_Error(
640 640
                                     sprintf(
@@ -652,7 +652,7 @@  discard block
 block discarded – undo
652 652
                         break;
653 653
                     // TEST #8 : check that config is the requested type
654 654
                     case 8:
655
-                        if (! $this->{$section}->{$name} instanceof $config_class) {
655
+                        if ( ! $this->{$section}->{$name} instanceof $config_class) {
656 656
                             if ($display_errors) {
657 657
                                 throw new EE_Error(
658 658
                                     sprintf(
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
                         break;
672 672
                     // TEST #9 : verify config object
673 673
                     case 9:
674
-                        if (! $config_obj instanceof EE_Config_Base) {
674
+                        if ( ! $config_obj instanceof EE_Config_Base) {
675 675
                             if ($display_errors) {
676 676
                                 throw new EE_Error(
677 677
                                     sprintf(
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
      */
704 704
     private function _generate_config_option_name($section = '', $name = '')
705 705
     {
706
-        return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
706
+        return 'ee_config-'.strtolower($section.'-'.str_replace(array('EE_', 'EED_'), '', $name));
707 707
     }
708 708
 
709 709
 
@@ -720,7 +720,7 @@  discard block
 block discarded – undo
720 720
     {
721 721
         return ! empty($config_class)
722 722
             ? $config_class
723
-            : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
723
+            : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))).'_Config';
724 724
     }
725 725
 
726 726
 
@@ -739,17 +739,17 @@  discard block
 block discarded – undo
739 739
         // ensure config class is set to something
740 740
         $config_class = $this->_set_config_class($config_class, $name);
741 741
         // run tests 1-4, 6, and 7 to verify all config params are set and valid
742
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
742
+        if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
743 743
             return null;
744 744
         }
745 745
         $config_option_name = $this->_generate_config_option_name($section, $name);
746 746
         // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
747
-        if (! isset($this->_addon_option_names[ $config_option_name ])) {
748
-            $this->_addon_option_names[ $config_option_name ] = $config_class;
747
+        if ( ! isset($this->_addon_option_names[$config_option_name])) {
748
+            $this->_addon_option_names[$config_option_name] = $config_class;
749 749
             $this->update_addon_option_names();
750 750
         }
751 751
         // verify the incoming config object but suppress errors
752
-        if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
752
+        if ( ! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
753 753
             $config_obj = new $config_class();
754 754
         }
755 755
         if (get_option($config_option_name)) {
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
         // get class name of the incoming object
797 797
         $config_class = get_class($config_obj);
798 798
         // run tests 1-5 and 9 to verify config
799
-        if (! $this->_verify_config_params(
799
+        if ( ! $this->_verify_config_params(
800 800
             $section,
801 801
             $name,
802 802
             $config_class,
@@ -808,7 +808,7 @@  discard block
 block discarded – undo
808 808
         }
809 809
         $config_option_name = $this->_generate_config_option_name($section, $name);
810 810
         // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
811
-        if (! isset($this->_addon_option_names[ $config_option_name ])) {
811
+        if ( ! isset($this->_addon_option_names[$config_option_name])) {
812 812
             // save new config to db
813 813
             if ($this->set_config($section, $name, $config_class, $config_obj)) {
814 814
                 return true;
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
                             'event_espresso'
835 835
                         ),
836 836
                         $config_class,
837
-                        'EE_Config->' . $section . '->' . $name
837
+                        'EE_Config->'.$section.'->'.$name
838 838
                     ),
839 839
                     __FILE__,
840 840
                     __FUNCTION__,
@@ -860,7 +860,7 @@  discard block
 block discarded – undo
860 860
         // ensure config class is set to something
861 861
         $config_class = $this->_set_config_class($config_class, $name);
862 862
         // run tests 1-4, 6 and 7 to verify that all params have been set
863
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
863
+        if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
864 864
             return null;
865 865
         }
866 866
         // now test if the requested config object exists, but suppress errors
@@ -905,7 +905,7 @@  discard block
 block discarded – undo
905 905
         // retrieve the wp-option for this config class.
906 906
         $config_option = maybe_unserialize(get_option($config_option_name, array()));
907 907
         if (empty($config_option)) {
908
-            EE_Config::log($config_option_name . '-NOT-FOUND');
908
+            EE_Config::log($config_option_name.'-NOT-FOUND');
909 909
         }
910 910
         return $config_option;
911 911
     }
@@ -923,7 +923,7 @@  discard block
 block discarded – undo
923 923
             // copy incoming $_REQUEST and sanitize it so we can save it
924 924
             $_request = $_REQUEST;
925 925
             array_walk_recursive($_request, 'sanitize_text_field');
926
-            $config_log[ (string) microtime(true) ] = array(
926
+            $config_log[(string) microtime(true)] = array(
927 927
                 'config_name' => $config_option_name,
928 928
                 'request'     => $_request,
929 929
             );
@@ -938,7 +938,7 @@  discard block
 block discarded – undo
938 938
      */
939 939
     public static function trim_log()
940 940
     {
941
-        if (! EE_Config::logging_enabled()) {
941
+        if ( ! EE_Config::logging_enabled()) {
942 942
             return;
943 943
         }
944 944
         $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
@@ -962,7 +962,7 @@  discard block
 block discarded – undo
962 962
     public static function get_page_for_posts()
963 963
     {
964 964
         $page_for_posts = get_option('page_for_posts');
965
-        if (! $page_for_posts) {
965
+        if ( ! $page_for_posts) {
966 966
             return 'posts';
967 967
         }
968 968
         /** @type WPDB $wpdb */
@@ -1012,20 +1012,20 @@  discard block
 block discarded – undo
1012 1012
     {
1013 1013
         // only init widgets on admin pages when not in complete maintenance, and
1014 1014
         // on frontend when not in any maintenance mode
1015
-        if (! EE_Maintenance_Mode::instance()->level()
1015
+        if ( ! EE_Maintenance_Mode::instance()->level()
1016 1016
             || (
1017 1017
                 is_admin()
1018 1018
                 && EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
1019 1019
             )
1020 1020
         ) {
1021 1021
             // grab list of installed widgets
1022
-            $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1022
+            $widgets_to_register = glob(EE_WIDGETS.'*', GLOB_ONLYDIR);
1023 1023
             // filter list of modules to register
1024 1024
             $widgets_to_register = apply_filters(
1025 1025
                 'FHEE__EE_Config__register_widgets__widgets_to_register',
1026 1026
                 $widgets_to_register
1027 1027
             );
1028
-            if (! empty($widgets_to_register)) {
1028
+            if ( ! empty($widgets_to_register)) {
1029 1029
                 // cycle thru widget folders
1030 1030
                 foreach ($widgets_to_register as $widget_path) {
1031 1031
                     // add to list of installed widget modules
@@ -1075,31 +1075,31 @@  discard block
 block discarded – undo
1075 1075
         // create classname from widget directory name
1076 1076
         $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1077 1077
         // add class prefix
1078
-        $widget_class = 'EEW_' . $widget;
1078
+        $widget_class = 'EEW_'.$widget;
1079 1079
         // does the widget exist ?
1080
-        if (! is_readable($widget_path . DS . $widget_class . $widget_ext)) {
1080
+        if ( ! is_readable($widget_path.DS.$widget_class.$widget_ext)) {
1081 1081
             $msg = sprintf(
1082 1082
                 __(
1083 1083
                     'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s',
1084 1084
                     'event_espresso'
1085 1085
                 ),
1086 1086
                 $widget_class,
1087
-                $widget_path . DS . $widget_class . $widget_ext
1087
+                $widget_path.DS.$widget_class.$widget_ext
1088 1088
             );
1089
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1089
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1090 1090
             return;
1091 1091
         }
1092 1092
         // load the widget class file
1093
-        require_once($widget_path . DS . $widget_class . $widget_ext);
1093
+        require_once($widget_path.DS.$widget_class.$widget_ext);
1094 1094
         // verify that class exists
1095
-        if (! class_exists($widget_class)) {
1095
+        if ( ! class_exists($widget_class)) {
1096 1096
             $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1097
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1097
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1098 1098
             return;
1099 1099
         }
1100 1100
         register_widget($widget_class);
1101 1101
         // add to array of registered widgets
1102
-        EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext;
1102
+        EE_Registry::instance()->widgets->{$widget_class} = $widget_path.DS.$widget_class.$widget_ext;
1103 1103
     }
1104 1104
 
1105 1105
 
@@ -1112,18 +1112,18 @@  discard block
 block discarded – undo
1112 1112
     private function _register_modules()
1113 1113
     {
1114 1114
         // grab list of installed modules
1115
-        $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1115
+        $modules_to_register = glob(EE_MODULES.'*', GLOB_ONLYDIR);
1116 1116
         // filter list of modules to register
1117 1117
         $modules_to_register = apply_filters(
1118 1118
             'FHEE__EE_Config__register_modules__modules_to_register',
1119 1119
             $modules_to_register
1120 1120
         );
1121
-        if (! empty($modules_to_register)) {
1121
+        if ( ! empty($modules_to_register)) {
1122 1122
             // loop through folders
1123 1123
             foreach ($modules_to_register as $module_path) {
1124 1124
                 /**TEMPORARILY EXCLUDE gateways from modules for time being**/
1125
-                if ($module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1126
-                    && $module_path !== EE_MODULES . 'gateways'
1125
+                if ($module_path !== EE_MODULES.'zzz-copy-this-module-template'
1126
+                    && $module_path !== EE_MODULES.'gateways'
1127 1127
                 ) {
1128 1128
                     // add to list of installed modules
1129 1129
                     EE_Config::register_module($module_path);
@@ -1160,25 +1160,25 @@  discard block
 block discarded – undo
1160 1160
             // remove last segment
1161 1161
             array_pop($module_path);
1162 1162
             // glue it back together
1163
-            $module_path = implode(DS, $module_path) . DS;
1163
+            $module_path = implode(DS, $module_path).DS;
1164 1164
             // take first segment from file name pieces and sanitize it
1165 1165
             $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1166 1166
             // ensure class prefix is added
1167
-            $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1167
+            $module_class = strpos($module, 'EED_') !== 0 ? 'EED_'.$module : $module;
1168 1168
         } else {
1169 1169
             // we need to generate the filename based off of the folder name
1170 1170
             // grab and sanitize module name
1171 1171
             $module = strtolower(basename($module_path));
1172 1172
             $module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1173 1173
             // like trailingslashit()
1174
-            $module_path = rtrim($module_path, DS) . DS;
1174
+            $module_path = rtrim($module_path, DS).DS;
1175 1175
             // create classname from module directory name
1176 1176
             $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1177 1177
             // add class prefix
1178
-            $module_class = 'EED_' . $module;
1178
+            $module_class = 'EED_'.$module;
1179 1179
         }
1180 1180
         // does the module exist ?
1181
-        if (! is_readable($module_path . DS . $module_class . $module_ext)) {
1181
+        if ( ! is_readable($module_path.DS.$module_class.$module_ext)) {
1182 1182
             $msg = sprintf(
1183 1183
                 __(
1184 1184
                     'The requested %s module file could not be found or is not readable due to file permissions.',
@@ -1186,19 +1186,19 @@  discard block
 block discarded – undo
1186 1186
                 ),
1187 1187
                 $module
1188 1188
             );
1189
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1189
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1190 1190
             return false;
1191 1191
         }
1192 1192
         // load the module class file
1193
-        require_once($module_path . $module_class . $module_ext);
1193
+        require_once($module_path.$module_class.$module_ext);
1194 1194
         // verify that class exists
1195
-        if (! class_exists($module_class)) {
1195
+        if ( ! class_exists($module_class)) {
1196 1196
             $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1197
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1197
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1198 1198
             return false;
1199 1199
         }
1200 1200
         // add to array of registered modules
1201
-        EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1201
+        EE_Registry::instance()->modules->{$module_class} = $module_path.$module_class.$module_ext;
1202 1202
         do_action(
1203 1203
             'AHEE__EE_Config__register_module__complete',
1204 1204
             $module_class,
@@ -1249,26 +1249,26 @@  discard block
 block discarded – undo
1249 1249
     {
1250 1250
         do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1251 1251
         $module = str_replace('EED_', '', $module);
1252
-        $module_class = 'EED_' . $module;
1253
-        if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1252
+        $module_class = 'EED_'.$module;
1253
+        if ( ! isset(EE_Registry::instance()->modules->{$module_class})) {
1254 1254
             $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1255
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1255
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1256 1256
             return false;
1257 1257
         }
1258 1258
         if (empty($route)) {
1259 1259
             $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1260
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1260
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1261 1261
             return false;
1262 1262
         }
1263
-        if (! method_exists('EED_' . $module, $method_name)) {
1263
+        if ( ! method_exists('EED_'.$module, $method_name)) {
1264 1264
             $msg = sprintf(
1265 1265
                 __('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1266 1266
                 $route
1267 1267
             );
1268
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1268
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1269 1269
             return false;
1270 1270
         }
1271
-        EE_Config::$_module_route_map[ $key ][ $route ] = array('EED_' . $module, $method_name);
1271
+        EE_Config::$_module_route_map[$key][$route] = array('EED_'.$module, $method_name);
1272 1272
         return true;
1273 1273
     }
1274 1274
 
@@ -1285,8 +1285,8 @@  discard block
 block discarded – undo
1285 1285
     {
1286 1286
         do_action('AHEE__EE_Config__get_route__begin', $route);
1287 1287
         $route = (string) apply_filters('FHEE__EE_Config__get_route', $route);
1288
-        if (isset(EE_Config::$_module_route_map[ $key ][ $route ])) {
1289
-            return EE_Config::$_module_route_map[ $key ][ $route ];
1288
+        if (isset(EE_Config::$_module_route_map[$key][$route])) {
1289
+            return EE_Config::$_module_route_map[$key][$route];
1290 1290
         }
1291 1291
         return null;
1292 1292
     }
@@ -1318,47 +1318,47 @@  discard block
 block discarded – undo
1318 1318
     public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1319 1319
     {
1320 1320
         do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1321
-        if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1321
+        if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1322 1322
             $msg = sprintf(
1323 1323
                 __('The module route %s for this forward has not been registered.', 'event_espresso'),
1324 1324
                 $route
1325 1325
             );
1326
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1326
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1327 1327
             return false;
1328 1328
         }
1329 1329
         if (empty($forward)) {
1330 1330
             $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1331
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1331
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1332 1332
             return false;
1333 1333
         }
1334 1334
         if (is_array($forward)) {
1335
-            if (! isset($forward[1])) {
1335
+            if ( ! isset($forward[1])) {
1336 1336
                 $msg = sprintf(
1337 1337
                     __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1338 1338
                     $route
1339 1339
                 );
1340
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1340
+                EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1341 1341
                 return false;
1342 1342
             }
1343
-            if (! method_exists($forward[0], $forward[1])) {
1343
+            if ( ! method_exists($forward[0], $forward[1])) {
1344 1344
                 $msg = sprintf(
1345 1345
                     __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1346 1346
                     $forward[1],
1347 1347
                     $route
1348 1348
                 );
1349
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1349
+                EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1350 1350
                 return false;
1351 1351
             }
1352
-        } elseif (! function_exists($forward)) {
1352
+        } elseif ( ! function_exists($forward)) {
1353 1353
             $msg = sprintf(
1354 1354
                 __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1355 1355
                 $forward,
1356 1356
                 $route
1357 1357
             );
1358
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1358
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1359 1359
             return false;
1360 1360
         }
1361
-        EE_Config::$_module_forward_map[ $key ][ $route ][ absint($status) ] = $forward;
1361
+        EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward;
1362 1362
         return true;
1363 1363
     }
1364 1364
 
@@ -1376,10 +1376,10 @@  discard block
 block discarded – undo
1376 1376
     public static function get_forward($route = null, $status = 0, $key = 'ee')
1377 1377
     {
1378 1378
         do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1379
-        if (isset(EE_Config::$_module_forward_map[ $key ][ $route ][ $status ])) {
1379
+        if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) {
1380 1380
             return apply_filters(
1381 1381
                 'FHEE__EE_Config__get_forward',
1382
-                EE_Config::$_module_forward_map[ $key ][ $route ][ $status ],
1382
+                EE_Config::$_module_forward_map[$key][$route][$status],
1383 1383
                 $route,
1384 1384
                 $status
1385 1385
             );
@@ -1403,15 +1403,15 @@  discard block
 block discarded – undo
1403 1403
     public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1404 1404
     {
1405 1405
         do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1406
-        if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1406
+        if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1407 1407
             $msg = sprintf(
1408 1408
                 __('The module route %s for this view has not been registered.', 'event_espresso'),
1409 1409
                 $route
1410 1410
             );
1411
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1411
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1412 1412
             return false;
1413 1413
         }
1414
-        if (! is_readable($view)) {
1414
+        if ( ! is_readable($view)) {
1415 1415
             $msg = sprintf(
1416 1416
                 __(
1417 1417
                     'The %s view file could not be found or is not readable due to file permissions.',
@@ -1419,10 +1419,10 @@  discard block
 block discarded – undo
1419 1419
                 ),
1420 1420
                 $view
1421 1421
             );
1422
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1422
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1423 1423
             return false;
1424 1424
         }
1425
-        EE_Config::$_module_view_map[ $key ][ $route ][ absint($status) ] = $view;
1425
+        EE_Config::$_module_view_map[$key][$route][absint($status)] = $view;
1426 1426
         return true;
1427 1427
     }
1428 1428
 
@@ -1440,10 +1440,10 @@  discard block
 block discarded – undo
1440 1440
     public static function get_view($route = null, $status = 0, $key = 'ee')
1441 1441
     {
1442 1442
         do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1443
-        if (isset(EE_Config::$_module_view_map[ $key ][ $route ][ $status ])) {
1443
+        if (isset(EE_Config::$_module_view_map[$key][$route][$status])) {
1444 1444
             return apply_filters(
1445 1445
                 'FHEE__EE_Config__get_view',
1446
-                EE_Config::$_module_view_map[ $key ][ $route ][ $status ],
1446
+                EE_Config::$_module_view_map[$key][$route][$status],
1447 1447
                 $route,
1448 1448
                 $status
1449 1449
             );
@@ -1470,7 +1470,7 @@  discard block
 block discarded – undo
1470 1470
     public static function getLegacyShortcodesManager()
1471 1471
     {
1472 1472
 
1473
-        if (! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1473
+        if ( ! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1474 1474
             EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager(
1475 1475
                 EE_Registry::instance()
1476 1476
             );
@@ -1517,7 +1517,7 @@  discard block
 block discarded – undo
1517 1517
      */
1518 1518
     public function get_pretty($property)
1519 1519
     {
1520
-        if (! property_exists($this, $property)) {
1520
+        if ( ! property_exists($this, $property)) {
1521 1521
             throw new EE_Error(
1522 1522
                 sprintf(
1523 1523
                     __(
@@ -1745,11 +1745,11 @@  discard block
 block discarded – undo
1745 1745
      */
1746 1746
     public function reg_page_url()
1747 1747
     {
1748
-        if (! $this->reg_page_url) {
1748
+        if ( ! $this->reg_page_url) {
1749 1749
             $this->reg_page_url = add_query_arg(
1750 1750
                 array('uts' => time()),
1751 1751
                 get_permalink($this->reg_page_id)
1752
-            ) . '#checkout';
1752
+            ).'#checkout';
1753 1753
         }
1754 1754
         return $this->reg_page_url;
1755 1755
     }
@@ -1765,7 +1765,7 @@  discard block
 block discarded – undo
1765 1765
      */
1766 1766
     public function txn_page_url($query_args = array())
1767 1767
     {
1768
-        if (! $this->txn_page_url) {
1768
+        if ( ! $this->txn_page_url) {
1769 1769
             $this->txn_page_url = get_permalink($this->txn_page_id);
1770 1770
         }
1771 1771
         if ($query_args) {
@@ -1786,7 +1786,7 @@  discard block
 block discarded – undo
1786 1786
      */
1787 1787
     public function thank_you_page_url($query_args = array())
1788 1788
     {
1789
-        if (! $this->thank_you_page_url) {
1789
+        if ( ! $this->thank_you_page_url) {
1790 1790
             $this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1791 1791
         }
1792 1792
         if ($query_args) {
@@ -1805,7 +1805,7 @@  discard block
 block discarded – undo
1805 1805
      */
1806 1806
     public function cancel_page_url()
1807 1807
     {
1808
-        if (! $this->cancel_page_url) {
1808
+        if ( ! $this->cancel_page_url) {
1809 1809
             $this->cancel_page_url = get_permalink($this->cancel_page_id);
1810 1810
         }
1811 1811
         return $this->cancel_page_url;
@@ -1840,7 +1840,7 @@  discard block
 block discarded – undo
1840 1840
             return get_option('ee_ueip_optin', false);
1841 1841
         }
1842 1842
         // is this already cached for this request?  If so use it.
1843
-        if (! empty(EE_Core_Config::$ee_ueip_option)) {
1843
+        if ( ! empty(EE_Core_Config::$ee_ueip_option)) {
1844 1844
             return EE_Core_Config::$ee_ueip_option;
1845 1845
         }
1846 1846
         global $wpdb;
@@ -1848,13 +1848,13 @@  discard block
 block discarded – undo
1848 1848
         $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1849 1849
         $option = 'ee_ueip_optin';
1850 1850
         // set correct table for query
1851
-        $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1851
+        $table_name = $wpdb->get_blog_prefix($current_main_site_id).'options';
1852 1852
         // rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1853 1853
         // get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1854 1854
         // re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1855 1855
         // this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1856 1856
         // for the purpose of caching.
1857
-        $pre = apply_filters('pre_option_' . $option, false, $option);
1857
+        $pre = apply_filters('pre_option_'.$option, false, $option);
1858 1858
         if (false !== $pre) {
1859 1859
             EE_Core_Config::$ee_ueip_option = $pre;
1860 1860
             return EE_Core_Config::$ee_ueip_option;
@@ -1868,9 +1868,9 @@  discard block
 block discarded – undo
1868 1868
         if (is_object($row)) {
1869 1869
             $value = $row->option_value;
1870 1870
         } else { // option does not exist so use default.
1871
-            return apply_filters('default_option_' . $option, false, $option);
1871
+            return apply_filters('default_option_'.$option, false, $option);
1872 1872
         }
1873
-        EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1873
+        EE_Core_Config::$ee_ueip_option = apply_filters('option_'.$option, maybe_unserialize($value), $option);
1874 1874
         return EE_Core_Config::$ee_ueip_option;
1875 1875
     }
1876 1876
 
@@ -2148,37 +2148,37 @@  discard block
 block discarded – undo
2148 2148
         // but override if requested
2149 2149
         $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2150 2150
         // so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists
2151
-        if (! empty($CNT_ISO)
2151
+        if ( ! empty($CNT_ISO)
2152 2152
             && EE_Maintenance_Mode::instance()->models_can_query()
2153 2153
             && $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())
2154 2154
         ) {
2155 2155
             // retrieve the country settings from the db, just in case they have been customized
2156 2156
             $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2157 2157
             if ($country instanceof EE_Country) {
2158
-                $this->code = $country->currency_code();    // currency code: USD, CAD, EUR
2159
-                $this->name = $country->currency_name_single();    // Dollar
2160
-                $this->plural = $country->currency_name_plural();    // Dollars
2161
-                $this->sign = $country->currency_sign();            // currency sign: $
2158
+                $this->code = $country->currency_code(); // currency code: USD, CAD, EUR
2159
+                $this->name = $country->currency_name_single(); // Dollar
2160
+                $this->plural = $country->currency_name_plural(); // Dollars
2161
+                $this->sign = $country->currency_sign(); // currency sign: $
2162 2162
                 $this->sign_b4 = $country->currency_sign_before(
2163
-                );        // currency sign before or after: $TRUE  or  FALSE$
2164
-                $this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2163
+                ); // currency sign before or after: $TRUE  or  FALSE$
2164
+                $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00  3 = 0.000
2165 2165
                 $this->dec_mrk = $country->currency_decimal_mark(
2166
-                );    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2166
+                ); // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2167 2167
                 $this->thsnds = $country->currency_thousands_separator(
2168
-                );    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2168
+                ); // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2169 2169
             }
2170 2170
         }
2171 2171
         // fallback to hardcoded defaults, in case the above failed
2172 2172
         if (empty($this->code)) {
2173 2173
             // set default currency settings
2174
-            $this->code = 'USD';    // currency code: USD, CAD, EUR
2175
-            $this->name = __('Dollar', 'event_espresso');    // Dollar
2176
-            $this->plural = __('Dollars', 'event_espresso');    // Dollars
2177
-            $this->sign = '$';    // currency sign: $
2178
-            $this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2179
-            $this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2180
-            $this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2181
-            $this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2174
+            $this->code = 'USD'; // currency code: USD, CAD, EUR
2175
+            $this->name = __('Dollar', 'event_espresso'); // Dollar
2176
+            $this->plural = __('Dollars', 'event_espresso'); // Dollars
2177
+            $this->sign = '$'; // currency sign: $
2178
+            $this->sign_b4 = true; // currency sign before or after: $TRUE  or  FALSE$
2179
+            $this->dec_plc = 2; // decimal places: 2 = 0.00  3 = 0.000
2180
+            $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2181
+            $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2182 2182
         }
2183 2183
     }
2184 2184
 }
@@ -2530,7 +2530,7 @@  discard block
 block discarded – undo
2530 2530
     public function log_file_name($reset = false)
2531 2531
     {
2532 2532
         if (empty($this->log_file_name) || $reset) {
2533
-            $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2533
+            $this->log_file_name = sanitize_key('espresso_log_'.md5(uniqid('', true))).'.txt';
2534 2534
             EE_Config::instance()->update_espresso_config(false, false);
2535 2535
         }
2536 2536
         return $this->log_file_name;
@@ -2544,7 +2544,7 @@  discard block
 block discarded – undo
2544 2544
     public function debug_file_name($reset = false)
2545 2545
     {
2546 2546
         if (empty($this->debug_file_name) || $reset) {
2547
-            $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2547
+            $this->debug_file_name = sanitize_key('espresso_debug_'.md5(uniqid('', true))).'.txt';
2548 2548
             EE_Config::instance()->update_espresso_config(false, false);
2549 2549
         }
2550 2550
         return $this->debug_file_name;
@@ -2750,21 +2750,21 @@  discard block
 block discarded – undo
2750 2750
         $this->use_google_maps = true;
2751 2751
         $this->google_map_api_key = '';
2752 2752
         // for event details pages (reg page)
2753
-        $this->event_details_map_width = 585;            // ee_map_width_single
2754
-        $this->event_details_map_height = 362;            // ee_map_height_single
2755
-        $this->event_details_map_zoom = 14;            // ee_map_zoom_single
2756
-        $this->event_details_display_nav = true;            // ee_map_nav_display_single
2757
-        $this->event_details_nav_size = false;            // ee_map_nav_size_single
2758
-        $this->event_details_control_type = 'default';        // ee_map_type_control_single
2759
-        $this->event_details_map_align = 'center';            // ee_map_align_single
2753
+        $this->event_details_map_width = 585; // ee_map_width_single
2754
+        $this->event_details_map_height = 362; // ee_map_height_single
2755
+        $this->event_details_map_zoom = 14; // ee_map_zoom_single
2756
+        $this->event_details_display_nav = true; // ee_map_nav_display_single
2757
+        $this->event_details_nav_size = false; // ee_map_nav_size_single
2758
+        $this->event_details_control_type = 'default'; // ee_map_type_control_single
2759
+        $this->event_details_map_align = 'center'; // ee_map_align_single
2760 2760
         // for event list pages
2761
-        $this->event_list_map_width = 300;            // ee_map_width
2762
-        $this->event_list_map_height = 185;        // ee_map_height
2763
-        $this->event_list_map_zoom = 12;            // ee_map_zoom
2764
-        $this->event_list_display_nav = false;        // ee_map_nav_display
2765
-        $this->event_list_nav_size = true;            // ee_map_nav_size
2766
-        $this->event_list_control_type = 'dropdown';        // ee_map_type_control
2767
-        $this->event_list_map_align = 'center';            // ee_map_align
2761
+        $this->event_list_map_width = 300; // ee_map_width
2762
+        $this->event_list_map_height = 185; // ee_map_height
2763
+        $this->event_list_map_zoom = 12; // ee_map_zoom
2764
+        $this->event_list_display_nav = false; // ee_map_nav_display
2765
+        $this->event_list_nav_size = true; // ee_map_nav_size
2766
+        $this->event_list_control_type = 'dropdown'; // ee_map_type_control
2767
+        $this->event_list_map_align = 'center'; // ee_map_align
2768 2768
     }
2769 2769
 }
2770 2770
 
@@ -3060,7 +3060,7 @@  discard block
 block discarded – undo
3060 3060
      */
3061 3061
     public function max_input_vars_limit_check($input_count = 0)
3062 3062
     {
3063
-        if (! empty($this->php->max_input_vars)
3063
+        if ( ! empty($this->php->max_input_vars)
3064 3064
             && ($input_count >= $this->php->max_input_vars)
3065 3065
             && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9)
3066 3066
         ) {
Please login to merge, or discard this patch.
Indentation   +3039 added lines, -3039 removed lines patch added patch discarded remove patch
@@ -13,2412 +13,2412 @@  discard block
 block discarded – undo
13 13
 final class EE_Config implements ResettableInterface
14 14
 {
15 15
 
16
-    const OPTION_NAME = 'ee_config';
17
-
18
-    const LOG_NAME = 'ee_config_log';
19
-
20
-    const LOG_LENGTH = 100;
21
-
22
-    const ADDON_OPTION_NAMES = 'ee_config_option_names';
23
-
24
-
25
-    /**
26
-     *    instance of the EE_Config object
27
-     *
28
-     * @var    EE_Config $_instance
29
-     * @access    private
30
-     */
31
-    private static $_instance;
32
-
33
-    /**
34
-     * @var boolean $_logging_enabled
35
-     */
36
-    private static $_logging_enabled = false;
37
-
38
-    /**
39
-     * @var LegacyShortcodesManager $legacy_shortcodes_manager
40
-     */
41
-    private $legacy_shortcodes_manager;
42
-
43
-    /**
44
-     * An StdClass whose property names are addon slugs,
45
-     * and values are their config classes
46
-     *
47
-     * @var StdClass
48
-     */
49
-    public $addons;
50
-
51
-    /**
52
-     * @var EE_Admin_Config
53
-     */
54
-    public $admin;
55
-
56
-    /**
57
-     * @var EE_Core_Config
58
-     */
59
-    public $core;
60
-
61
-    /**
62
-     * @var EE_Currency_Config
63
-     */
64
-    public $currency;
65
-
66
-    /**
67
-     * @var EE_Organization_Config
68
-     */
69
-    public $organization;
70
-
71
-    /**
72
-     * @var EE_Registration_Config
73
-     */
74
-    public $registration;
75
-
76
-    /**
77
-     * @var EE_Template_Config
78
-     */
79
-    public $template_settings;
80
-
81
-    /**
82
-     * Holds EE environment values.
83
-     *
84
-     * @var EE_Environment_Config
85
-     */
86
-    public $environment;
87
-
88
-    /**
89
-     * settings pertaining to Google maps
90
-     *
91
-     * @var EE_Map_Config
92
-     */
93
-    public $map_settings;
94
-
95
-    /**
96
-     * settings pertaining to Taxes
97
-     *
98
-     * @var EE_Tax_Config
99
-     */
100
-    public $tax_settings;
101
-
102
-
103
-    /**
104
-     * Settings pertaining to global messages settings.
105
-     *
106
-     * @var EE_Messages_Config
107
-     */
108
-    public $messages;
109
-
110
-    /**
111
-     * @deprecated
112
-     * @var EE_Gateway_Config
113
-     */
114
-    public $gateway;
115
-
116
-    /**
117
-     * @var    array $_addon_option_names
118
-     * @access    private
119
-     */
120
-    private $_addon_option_names = array();
121
-
122
-    /**
123
-     * @var    array $_module_route_map
124
-     * @access    private
125
-     */
126
-    private static $_module_route_map = array();
127
-
128
-    /**
129
-     * @var    array $_module_forward_map
130
-     * @access    private
131
-     */
132
-    private static $_module_forward_map = array();
133
-
134
-    /**
135
-     * @var    array $_module_view_map
136
-     * @access    private
137
-     */
138
-    private static $_module_view_map = array();
139
-
140
-
141
-    /**
142
-     * @singleton method used to instantiate class object
143
-     * @access    public
144
-     * @return EE_Config instance
145
-     */
146
-    public static function instance()
147
-    {
148
-        // check if class object is instantiated, and instantiated properly
149
-        if (! self::$_instance instanceof EE_Config) {
150
-            self::$_instance = new self();
151
-        }
152
-        return self::$_instance;
153
-    }
154
-
155
-
156
-    /**
157
-     * Resets the config
158
-     *
159
-     * @param bool    $hard_reset    if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE
160
-     *                               (default) leaves the database alone, and merely resets the EE_Config object to
161
-     *                               reflect its state in the database
162
-     * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave
163
-     *                               $_instance as NULL. Useful in case you want to forget about the old instance on
164
-     *                               EE_Config, but might not be ready to instantiate EE_Config currently (eg if the
165
-     *                               site was put into maintenance mode)
166
-     * @return EE_Config
167
-     */
168
-    public static function reset($hard_reset = false, $reinstantiate = true)
169
-    {
170
-        if (self::$_instance instanceof EE_Config) {
171
-            if ($hard_reset) {
172
-                self::$_instance->legacy_shortcodes_manager = null;
173
-                self::$_instance->_addon_option_names = array();
174
-                self::$_instance->_initialize_config();
175
-                self::$_instance->update_espresso_config();
176
-            }
177
-            self::$_instance->update_addon_option_names();
178
-        }
179
-        self::$_instance = null;
180
-        // we don't need to reset the static properties imo because those should
181
-        // only change when a module is added or removed. Currently we don't
182
-        // support removing a module during a request when it previously existed
183
-        if ($reinstantiate) {
184
-            return self::instance();
185
-        } else {
186
-            return null;
187
-        }
188
-    }
189
-
190
-
191
-    /**
192
-     *    class constructor
193
-     *
194
-     * @access    private
195
-     */
196
-    private function __construct()
197
-    {
198
-        do_action('AHEE__EE_Config__construct__begin', $this);
199
-        EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false);
200
-        // setup empty config classes
201
-        $this->_initialize_config();
202
-        // load existing EE site settings
203
-        $this->_load_core_config();
204
-        // confirm everything loaded correctly and set filtered defaults if not
205
-        $this->_verify_config();
206
-        //  register shortcodes and modules
207
-        add_action(
208
-            'AHEE__EE_System__register_shortcodes_modules_and_widgets',
209
-            array($this, 'register_shortcodes_and_modules'),
210
-            999
211
-        );
212
-        //  initialize shortcodes and modules
213
-        add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules'));
214
-        // register widgets
215
-        add_action('widgets_init', array($this, 'widgets_init'), 10);
216
-        // shutdown
217
-        add_action('shutdown', array($this, 'shutdown'), 10);
218
-        // construct__end hook
219
-        do_action('AHEE__EE_Config__construct__end', $this);
220
-        // hardcoded hack
221
-        $this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014';
222
-    }
223
-
224
-
225
-    /**
226
-     * @return boolean
227
-     */
228
-    public static function logging_enabled()
229
-    {
230
-        return self::$_logging_enabled;
231
-    }
232
-
233
-
234
-    /**
235
-     * use to get the current theme if needed from static context
236
-     *
237
-     * @return string current theme set.
238
-     */
239
-    public static function get_current_theme()
240
-    {
241
-        return isset(self::$_instance->template_settings->current_espresso_theme)
242
-            ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014';
243
-    }
244
-
245
-
246
-    /**
247
-     *        _initialize_config
248
-     *
249
-     * @access private
250
-     * @return void
251
-     */
252
-    private function _initialize_config()
253
-    {
254
-        EE_Config::trim_log();
255
-        // set defaults
256
-        $this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array());
257
-        $this->addons = new stdClass();
258
-        // set _module_route_map
259
-        EE_Config::$_module_route_map = array();
260
-        // set _module_forward_map
261
-        EE_Config::$_module_forward_map = array();
262
-        // set _module_view_map
263
-        EE_Config::$_module_view_map = array();
264
-    }
265
-
266
-
267
-    /**
268
-     *        load core plugin configuration
269
-     *
270
-     * @access private
271
-     * @return void
272
-     */
273
-    private function _load_core_config()
274
-    {
275
-        // load_core_config__start hook
276
-        do_action('AHEE__EE_Config___load_core_config__start', $this);
277
-        $espresso_config = $this->get_espresso_config();
278
-        foreach ($espresso_config as $config => $settings) {
279
-            // load_core_config__start hook
280
-            $settings = apply_filters(
281
-                'FHEE__EE_Config___load_core_config__config_settings',
282
-                $settings,
283
-                $config,
284
-                $this
285
-            );
286
-            if (is_object($settings) && property_exists($this, $config)) {
287
-                $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
288
-                // call configs populate method to ensure any defaults are set for empty values.
289
-                if (method_exists($settings, 'populate')) {
290
-                    $this->{$config}->populate();
291
-                }
292
-                if (method_exists($settings, 'do_hooks')) {
293
-                    $this->{$config}->do_hooks();
294
-                }
295
-            }
296
-        }
297
-        if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) {
298
-            $this->update_espresso_config();
299
-        }
300
-        // load_core_config__end hook
301
-        do_action('AHEE__EE_Config___load_core_config__end', $this);
302
-    }
303
-
304
-
305
-    /**
306
-     *    _verify_config
307
-     *
308
-     * @access    protected
309
-     * @return    void
310
-     */
311
-    protected function _verify_config()
312
-    {
313
-        $this->core = $this->core instanceof EE_Core_Config
314
-            ? $this->core
315
-            : new EE_Core_Config();
316
-        $this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core);
317
-        $this->organization = $this->organization instanceof EE_Organization_Config
318
-            ? $this->organization
319
-            : new EE_Organization_Config();
320
-        $this->organization = apply_filters(
321
-            'FHEE__EE_Config___initialize_config__organization',
322
-            $this->organization
323
-        );
324
-        $this->currency = $this->currency instanceof EE_Currency_Config
325
-            ? $this->currency
326
-            : new EE_Currency_Config();
327
-        $this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency);
328
-        $this->registration = $this->registration instanceof EE_Registration_Config
329
-            ? $this->registration
330
-            : new EE_Registration_Config();
331
-        $this->registration = apply_filters(
332
-            'FHEE__EE_Config___initialize_config__registration',
333
-            $this->registration
334
-        );
335
-        $this->admin = $this->admin instanceof EE_Admin_Config
336
-            ? $this->admin
337
-            : new EE_Admin_Config();
338
-        $this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin);
339
-        $this->template_settings = $this->template_settings instanceof EE_Template_Config
340
-            ? $this->template_settings
341
-            : new EE_Template_Config();
342
-        $this->template_settings = apply_filters(
343
-            'FHEE__EE_Config___initialize_config__template_settings',
344
-            $this->template_settings
345
-        );
346
-        $this->map_settings = $this->map_settings instanceof EE_Map_Config
347
-            ? $this->map_settings
348
-            : new EE_Map_Config();
349
-        $this->map_settings = apply_filters(
350
-            'FHEE__EE_Config___initialize_config__map_settings',
351
-            $this->map_settings
352
-        );
353
-        $this->environment = $this->environment instanceof EE_Environment_Config
354
-            ? $this->environment
355
-            : new EE_Environment_Config();
356
-        $this->environment = apply_filters(
357
-            'FHEE__EE_Config___initialize_config__environment',
358
-            $this->environment
359
-        );
360
-        $this->tax_settings = $this->tax_settings instanceof EE_Tax_Config
361
-            ? $this->tax_settings
362
-            : new EE_Tax_Config();
363
-        $this->tax_settings = apply_filters(
364
-            'FHEE__EE_Config___initialize_config__tax_settings',
365
-            $this->tax_settings
366
-        );
367
-        $this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages);
368
-        $this->messages = $this->messages instanceof EE_Messages_Config
369
-            ? $this->messages
370
-            : new EE_Messages_Config();
371
-        $this->gateway = $this->gateway instanceof EE_Gateway_Config
372
-            ? $this->gateway
373
-            : new EE_Gateway_Config();
374
-        $this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway);
375
-        $this->legacy_shortcodes_manager = null;
376
-    }
377
-
378
-
379
-    /**
380
-     *    get_espresso_config
381
-     *
382
-     * @access    public
383
-     * @return    array of espresso config stuff
384
-     */
385
-    public function get_espresso_config()
386
-    {
387
-        // grab espresso configuration
388
-        return apply_filters(
389
-            'FHEE__EE_Config__get_espresso_config__CFG',
390
-            get_option(EE_Config::OPTION_NAME, array())
391
-        );
392
-    }
393
-
394
-
395
-    /**
396
-     *    double_check_config_comparison
397
-     *
398
-     * @access    public
399
-     * @param string $option
400
-     * @param        $old_value
401
-     * @param        $value
402
-     */
403
-    public function double_check_config_comparison($option = '', $old_value, $value)
404
-    {
405
-        // make sure we're checking the ee config
406
-        if ($option === EE_Config::OPTION_NAME) {
407
-            // run a loose comparison of the old value against the new value for type and properties,
408
-            // but NOT exact instance like WP update_option does (ie: NOT type safe comparison)
409
-            if ($value != $old_value) {
410
-                // if they are NOT the same, then remove the hook,
411
-                // which means the subsequent update results will be based solely on the update query results
412
-                // the reason we do this is because, as stated above,
413
-                // WP update_option performs an exact instance comparison (===) on any update values passed to it
414
-                // this happens PRIOR to serialization and any subsequent update.
415
-                // If values are found to match their previous old value,
416
-                // then WP bails before performing any update.
417
-                // Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version
418
-                // it just pulled from the db, with the one being passed to it (which will not match).
419
-                // HOWEVER, once the object is serialized and passed off to MySQL to update,
420
-                // MySQL MAY ALSO NOT perform the update because
421
-                // the string it sees in the db looks the same as the new one it has been passed!!!
422
-                // This results in the query returning an "affected rows" value of ZERO,
423
-                // which gets returned immediately by WP update_option and looks like an error.
424
-                remove_action('update_option', array($this, 'check_config_updated'));
425
-            }
426
-        }
427
-    }
428
-
429
-
430
-    /**
431
-     *    update_espresso_config
432
-     *
433
-     * @access   public
434
-     */
435
-    protected function _reset_espresso_addon_config()
436
-    {
437
-        $this->_addon_option_names = array();
438
-        foreach ($this->addons as $addon_name => $addon_config_obj) {
439
-            $addon_config_obj = maybe_unserialize($addon_config_obj);
440
-            if ($addon_config_obj instanceof EE_Config_Base) {
441
-                $this->update_config('addons', $addon_name, $addon_config_obj, false);
442
-            }
443
-            $this->addons->{$addon_name} = null;
444
-        }
445
-    }
446
-
447
-
448
-    /**
449
-     *    update_espresso_config
450
-     *
451
-     * @access   public
452
-     * @param   bool $add_success
453
-     * @param   bool $add_error
454
-     * @return   bool
455
-     */
456
-    public function update_espresso_config($add_success = false, $add_error = true)
457
-    {
458
-        // don't allow config updates during WP heartbeats
459
-        if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
460
-            return false;
461
-        }
462
-        // commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
463
-        // $clone = clone( self::$_instance );
464
-        // self::$_instance = NULL;
465
-        do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
466
-        $this->_reset_espresso_addon_config();
467
-        // hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
468
-        // but BEFORE the actual update occurs
469
-        add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
470
-        // don't want to persist legacy_shortcodes_manager, but don't want to lose it either
471
-        $legacy_shortcodes_manager = $this->legacy_shortcodes_manager;
472
-        $this->legacy_shortcodes_manager = null;
473
-        // now update "ee_config"
474
-        $saved = update_option(EE_Config::OPTION_NAME, $this);
475
-        $this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
476
-        EE_Config::log(EE_Config::OPTION_NAME);
477
-        // if not saved... check if the hook we just added still exists;
478
-        // if it does, it means one of two things:
479
-        // that update_option bailed at the($value === $old_value) conditional,
480
-        // or...
481
-        // the db update query returned 0 rows affected
482
-        // (probably because the data  value was the same from it's perspective)
483
-        // so the existence of the hook means that a negative result from update_option is NOT an error,
484
-        // but just means no update occurred, so don't display an error to the user.
485
-        // BUT... if update_option returns FALSE, AND the hook is missing,
486
-        // then it means that something truly went wrong
487
-        $saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
488
-        // remove our action since we don't want it in the system anymore
489
-        remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
490
-        do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
491
-        // self::$_instance = $clone;
492
-        // unset( $clone );
493
-        // if config remains the same or was updated successfully
494
-        if ($saved) {
495
-            if ($add_success) {
496
-                EE_Error::add_success(
497
-                    __('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
498
-                    __FILE__,
499
-                    __FUNCTION__,
500
-                    __LINE__
501
-                );
502
-            }
503
-            return true;
504
-        } else {
505
-            if ($add_error) {
506
-                EE_Error::add_error(
507
-                    __('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
508
-                    __FILE__,
509
-                    __FUNCTION__,
510
-                    __LINE__
511
-                );
512
-            }
513
-            return false;
514
-        }
515
-    }
516
-
517
-
518
-    /**
519
-     *    _verify_config_params
520
-     *
521
-     * @access    private
522
-     * @param    string         $section
523
-     * @param    string         $name
524
-     * @param    string         $config_class
525
-     * @param    EE_Config_Base $config_obj
526
-     * @param    array          $tests_to_run
527
-     * @param    bool           $display_errors
528
-     * @return    bool    TRUE on success, FALSE on fail
529
-     */
530
-    private function _verify_config_params(
531
-        $section = '',
532
-        $name = '',
533
-        $config_class = '',
534
-        $config_obj = null,
535
-        $tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
536
-        $display_errors = true
537
-    ) {
538
-        try {
539
-            foreach ($tests_to_run as $test) {
540
-                switch ($test) {
541
-                    // TEST #1 : check that section was set
542
-                    case 1:
543
-                        if (empty($section)) {
544
-                            if ($display_errors) {
545
-                                throw new EE_Error(
546
-                                    sprintf(
547
-                                        __(
548
-                                            'No configuration section has been provided while attempting to save "%s".',
549
-                                            'event_espresso'
550
-                                        ),
551
-                                        $config_class
552
-                                    )
553
-                                );
554
-                            }
555
-                            return false;
556
-                        }
557
-                        break;
558
-                    // TEST #2 : check that settings section exists
559
-                    case 2:
560
-                        if (! isset($this->{$section})) {
561
-                            if ($display_errors) {
562
-                                throw new EE_Error(
563
-                                    sprintf(
564
-                                        __('The "%s" configuration section does not exist.', 'event_espresso'),
565
-                                        $section
566
-                                    )
567
-                                );
568
-                            }
569
-                            return false;
570
-                        }
571
-                        break;
572
-                    // TEST #3 : check that section is the proper format
573
-                    case 3:
574
-                        if (! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
575
-                        ) {
576
-                            if ($display_errors) {
577
-                                throw new EE_Error(
578
-                                    sprintf(
579
-                                        __(
580
-                                            'The "%s" configuration settings have not been formatted correctly.',
581
-                                            'event_espresso'
582
-                                        ),
583
-                                        $section
584
-                                    )
585
-                                );
586
-                            }
587
-                            return false;
588
-                        }
589
-                        break;
590
-                    // TEST #4 : check that config section name has been set
591
-                    case 4:
592
-                        if (empty($name)) {
593
-                            if ($display_errors) {
594
-                                throw new EE_Error(
595
-                                    __(
596
-                                        'No name has been provided for the specific configuration section.',
597
-                                        'event_espresso'
598
-                                    )
599
-                                );
600
-                            }
601
-                            return false;
602
-                        }
603
-                        break;
604
-                    // TEST #5 : check that a config class name has been set
605
-                    case 5:
606
-                        if (empty($config_class)) {
607
-                            if ($display_errors) {
608
-                                throw new EE_Error(
609
-                                    __(
610
-                                        'No class name has been provided for the specific configuration section.',
611
-                                        'event_espresso'
612
-                                    )
613
-                                );
614
-                            }
615
-                            return false;
616
-                        }
617
-                        break;
618
-                    // TEST #6 : verify config class is accessible
619
-                    case 6:
620
-                        if (! class_exists($config_class)) {
621
-                            if ($display_errors) {
622
-                                throw new EE_Error(
623
-                                    sprintf(
624
-                                        __(
625
-                                            'The "%s" class does not exist. Please ensure that an autoloader has been set for it.',
626
-                                            'event_espresso'
627
-                                        ),
628
-                                        $config_class
629
-                                    )
630
-                                );
631
-                            }
632
-                            return false;
633
-                        }
634
-                        break;
635
-                    // TEST #7 : check that config has even been set
636
-                    case 7:
637
-                        if (! isset($this->{$section}->{$name})) {
638
-                            if ($display_errors) {
639
-                                throw new EE_Error(
640
-                                    sprintf(
641
-                                        __('No configuration has been set for "%1$s->%2$s".', 'event_espresso'),
642
-                                        $section,
643
-                                        $name
644
-                                    )
645
-                                );
646
-                            }
647
-                            return false;
648
-                        } else {
649
-                            // and make sure it's not serialized
650
-                            $this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name});
651
-                        }
652
-                        break;
653
-                    // TEST #8 : check that config is the requested type
654
-                    case 8:
655
-                        if (! $this->{$section}->{$name} instanceof $config_class) {
656
-                            if ($display_errors) {
657
-                                throw new EE_Error(
658
-                                    sprintf(
659
-                                        __(
660
-                                            'The configuration for "%1$s->%2$s" is not of the "%3$s" class.',
661
-                                            'event_espresso'
662
-                                        ),
663
-                                        $section,
664
-                                        $name,
665
-                                        $config_class
666
-                                    )
667
-                                );
668
-                            }
669
-                            return false;
670
-                        }
671
-                        break;
672
-                    // TEST #9 : verify config object
673
-                    case 9:
674
-                        if (! $config_obj instanceof EE_Config_Base) {
675
-                            if ($display_errors) {
676
-                                throw new EE_Error(
677
-                                    sprintf(
678
-                                        __('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'),
679
-                                        print_r($config_obj, true)
680
-                                    )
681
-                                );
682
-                            }
683
-                            return false;
684
-                        }
685
-                        break;
686
-                }
687
-            }
688
-        } catch (EE_Error $e) {
689
-            $e->get_error();
690
-        }
691
-        // you have successfully run the gauntlet
692
-        return true;
693
-    }
694
-
695
-
696
-    /**
697
-     *    _generate_config_option_name
698
-     *
699
-     * @access        protected
700
-     * @param        string $section
701
-     * @param        string $name
702
-     * @return        string
703
-     */
704
-    private function _generate_config_option_name($section = '', $name = '')
705
-    {
706
-        return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
707
-    }
708
-
709
-
710
-    /**
711
-     *    _set_config_class
712
-     * ensures that a config class is set, either from a passed config class or one generated from the config name
713
-     *
714
-     * @access    private
715
-     * @param    string $config_class
716
-     * @param    string $name
717
-     * @return    string
718
-     */
719
-    private function _set_config_class($config_class = '', $name = '')
720
-    {
721
-        return ! empty($config_class)
722
-            ? $config_class
723
-            : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
724
-    }
725
-
726
-
727
-    /**
728
-     *    set_config
729
-     *
730
-     * @access    protected
731
-     * @param    string         $section
732
-     * @param    string         $name
733
-     * @param    string         $config_class
734
-     * @param    EE_Config_Base $config_obj
735
-     * @return    EE_Config_Base
736
-     */
737
-    public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null)
738
-    {
739
-        // ensure config class is set to something
740
-        $config_class = $this->_set_config_class($config_class, $name);
741
-        // run tests 1-4, 6, and 7 to verify all config params are set and valid
742
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
743
-            return null;
744
-        }
745
-        $config_option_name = $this->_generate_config_option_name($section, $name);
746
-        // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
747
-        if (! isset($this->_addon_option_names[ $config_option_name ])) {
748
-            $this->_addon_option_names[ $config_option_name ] = $config_class;
749
-            $this->update_addon_option_names();
750
-        }
751
-        // verify the incoming config object but suppress errors
752
-        if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
753
-            $config_obj = new $config_class();
754
-        }
755
-        if (get_option($config_option_name)) {
756
-            EE_Config::log($config_option_name);
757
-            update_option($config_option_name, $config_obj);
758
-            $this->{$section}->{$name} = $config_obj;
759
-            return $this->{$section}->{$name};
760
-        } else {
761
-            // create a wp-option for this config
762
-            if (add_option($config_option_name, $config_obj, '', 'no')) {
763
-                $this->{$section}->{$name} = maybe_unserialize($config_obj);
764
-                return $this->{$section}->{$name};
765
-            } else {
766
-                EE_Error::add_error(
767
-                    sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class),
768
-                    __FILE__,
769
-                    __FUNCTION__,
770
-                    __LINE__
771
-                );
772
-                return null;
773
-            }
774
-        }
775
-    }
776
-
777
-
778
-    /**
779
-     *    update_config
780
-     * Important: the config object must ALREADY be set, otherwise this will produce an error.
781
-     *
782
-     * @access    public
783
-     * @param    string                $section
784
-     * @param    string                $name
785
-     * @param    EE_Config_Base|string $config_obj
786
-     * @param    bool                  $throw_errors
787
-     * @return    bool
788
-     */
789
-    public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true)
790
-    {
791
-        // don't allow config updates during WP heartbeats
792
-        if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
793
-            return false;
794
-        }
795
-        $config_obj = maybe_unserialize($config_obj);
796
-        // get class name of the incoming object
797
-        $config_class = get_class($config_obj);
798
-        // run tests 1-5 and 9 to verify config
799
-        if (! $this->_verify_config_params(
800
-            $section,
801
-            $name,
802
-            $config_class,
803
-            $config_obj,
804
-            array(1, 2, 3, 4, 7, 9)
805
-        )
806
-        ) {
807
-            return false;
808
-        }
809
-        $config_option_name = $this->_generate_config_option_name($section, $name);
810
-        // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
811
-        if (! isset($this->_addon_option_names[ $config_option_name ])) {
812
-            // save new config to db
813
-            if ($this->set_config($section, $name, $config_class, $config_obj)) {
814
-                return true;
815
-            }
816
-        } else {
817
-            // first check if the record already exists
818
-            $existing_config = get_option($config_option_name);
819
-            $config_obj = serialize($config_obj);
820
-            // just return if db record is already up to date (NOT type safe comparison)
821
-            if ($existing_config == $config_obj) {
822
-                $this->{$section}->{$name} = $config_obj;
823
-                return true;
824
-            } elseif (update_option($config_option_name, $config_obj)) {
825
-                EE_Config::log($config_option_name);
826
-                // update wp-option for this config class
827
-                $this->{$section}->{$name} = $config_obj;
828
-                return true;
829
-            } elseif ($throw_errors) {
830
-                EE_Error::add_error(
831
-                    sprintf(
832
-                        __(
833
-                            'The "%1$s" object stored at"%2$s" was not successfully updated in the database.',
834
-                            'event_espresso'
835
-                        ),
836
-                        $config_class,
837
-                        'EE_Config->' . $section . '->' . $name
838
-                    ),
839
-                    __FILE__,
840
-                    __FUNCTION__,
841
-                    __LINE__
842
-                );
843
-            }
844
-        }
845
-        return false;
846
-    }
847
-
848
-
849
-    /**
850
-     *    get_config
851
-     *
852
-     * @access    public
853
-     * @param    string $section
854
-     * @param    string $name
855
-     * @param    string $config_class
856
-     * @return    mixed EE_Config_Base | NULL
857
-     */
858
-    public function get_config($section = '', $name = '', $config_class = '')
859
-    {
860
-        // ensure config class is set to something
861
-        $config_class = $this->_set_config_class($config_class, $name);
862
-        // run tests 1-4, 6 and 7 to verify that all params have been set
863
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
864
-            return null;
865
-        }
866
-        // now test if the requested config object exists, but suppress errors
867
-        if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) {
868
-            // config already exists, so pass it back
869
-            return $this->{$section}->{$name};
870
-        }
871
-        // load config option from db if it exists
872
-        $config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
873
-        // verify the newly retrieved config object, but suppress errors
874
-        if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
875
-            // config is good, so set it and pass it back
876
-            $this->{$section}->{$name} = $config_obj;
877
-            return $this->{$section}->{$name};
878
-        }
879
-        // oops! $config_obj is not already set and does not exist in the db, so create a new one
880
-        $config_obj = $this->set_config($section, $name, $config_class);
881
-        // verify the newly created config object
882
-        if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
883
-            return $this->{$section}->{$name};
884
-        } else {
885
-            EE_Error::add_error(
886
-                sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
887
-                __FILE__,
888
-                __FUNCTION__,
889
-                __LINE__
890
-            );
891
-        }
892
-        return null;
893
-    }
894
-
895
-
896
-    /**
897
-     *    get_config_option
898
-     *
899
-     * @access    public
900
-     * @param    string $config_option_name
901
-     * @return    mixed EE_Config_Base | FALSE
902
-     */
903
-    public function get_config_option($config_option_name = '')
904
-    {
905
-        // retrieve the wp-option for this config class.
906
-        $config_option = maybe_unserialize(get_option($config_option_name, array()));
907
-        if (empty($config_option)) {
908
-            EE_Config::log($config_option_name . '-NOT-FOUND');
909
-        }
910
-        return $config_option;
911
-    }
912
-
913
-
914
-    /**
915
-     * log
916
-     *
917
-     * @param string $config_option_name
918
-     */
919
-    public static function log($config_option_name = '')
920
-    {
921
-        if (EE_Config::logging_enabled() && ! empty($config_option_name)) {
922
-            $config_log = get_option(EE_Config::LOG_NAME, array());
923
-            // copy incoming $_REQUEST and sanitize it so we can save it
924
-            $_request = $_REQUEST;
925
-            array_walk_recursive($_request, 'sanitize_text_field');
926
-            $config_log[ (string) microtime(true) ] = array(
927
-                'config_name' => $config_option_name,
928
-                'request'     => $_request,
929
-            );
930
-            update_option(EE_Config::LOG_NAME, $config_log);
931
-        }
932
-    }
933
-
934
-
935
-    /**
936
-     * trim_log
937
-     * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH
938
-     */
939
-    public static function trim_log()
940
-    {
941
-        if (! EE_Config::logging_enabled()) {
942
-            return;
943
-        }
944
-        $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
945
-        $log_length = count($config_log);
946
-        if ($log_length > EE_Config::LOG_LENGTH) {
947
-            ksort($config_log);
948
-            $config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true);
949
-            update_option(EE_Config::LOG_NAME, $config_log);
950
-        }
951
-    }
952
-
953
-
954
-    /**
955
-     *    get_page_for_posts
956
-     *    if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the
957
-     *    wp-option "page_for_posts", or "posts" if no page is selected
958
-     *
959
-     * @access    public
960
-     * @return    string
961
-     */
962
-    public static function get_page_for_posts()
963
-    {
964
-        $page_for_posts = get_option('page_for_posts');
965
-        if (! $page_for_posts) {
966
-            return 'posts';
967
-        }
968
-        /** @type WPDB $wpdb */
969
-        global $wpdb;
970
-        $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
971
-        return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
972
-    }
973
-
974
-
975
-    /**
976
-     *    register_shortcodes_and_modules.
977
-     *    At this point, it's too early to tell if we're maintenance mode or not.
978
-     *    In fact, this is where we give modules a chance to let core know they exist
979
-     *    so they can help trigger maintenance mode if it's needed
980
-     *
981
-     * @access    public
982
-     * @return    void
983
-     */
984
-    public function register_shortcodes_and_modules()
985
-    {
986
-        // allow modules to set hooks for the rest of the system
987
-        EE_Registry::instance()->modules = $this->_register_modules();
988
-    }
989
-
990
-
991
-    /**
992
-     *    initialize_shortcodes_and_modules
993
-     *    meaning they can start adding their hooks to get stuff done
994
-     *
995
-     * @access    public
996
-     * @return    void
997
-     */
998
-    public function initialize_shortcodes_and_modules()
999
-    {
1000
-        // allow modules to set hooks for the rest of the system
1001
-        $this->_initialize_modules();
1002
-    }
1003
-
1004
-
1005
-    /**
1006
-     *    widgets_init
1007
-     *
1008
-     * @access private
1009
-     * @return void
1010
-     */
1011
-    public function widgets_init()
1012
-    {
1013
-        // only init widgets on admin pages when not in complete maintenance, and
1014
-        // on frontend when not in any maintenance mode
1015
-        if (! EE_Maintenance_Mode::instance()->level()
1016
-            || (
1017
-                is_admin()
1018
-                && EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
1019
-            )
1020
-        ) {
1021
-            // grab list of installed widgets
1022
-            $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1023
-            // filter list of modules to register
1024
-            $widgets_to_register = apply_filters(
1025
-                'FHEE__EE_Config__register_widgets__widgets_to_register',
1026
-                $widgets_to_register
1027
-            );
1028
-            if (! empty($widgets_to_register)) {
1029
-                // cycle thru widget folders
1030
-                foreach ($widgets_to_register as $widget_path) {
1031
-                    // add to list of installed widget modules
1032
-                    EE_Config::register_ee_widget($widget_path);
1033
-                }
1034
-            }
1035
-            // filter list of installed modules
1036
-            EE_Registry::instance()->widgets = apply_filters(
1037
-                'FHEE__EE_Config__register_widgets__installed_widgets',
1038
-                EE_Registry::instance()->widgets
1039
-            );
1040
-        }
1041
-    }
1042
-
1043
-
1044
-    /**
1045
-     *    register_ee_widget - makes core aware of this widget
1046
-     *
1047
-     * @access    public
1048
-     * @param    string $widget_path - full path up to and including widget folder
1049
-     * @return    void
1050
-     */
1051
-    public static function register_ee_widget($widget_path = null)
1052
-    {
1053
-        do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
1054
-        $widget_ext = '.widget.php';
1055
-        // make all separators match
1056
-        $widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS);
1057
-        // does the file path INCLUDE the actual file name as part of the path ?
1058
-        if (strpos($widget_path, $widget_ext) !== false) {
1059
-            // grab and shortcode file name from directory name and break apart at dots
1060
-            $file_name = explode('.', basename($widget_path));
1061
-            // take first segment from file name pieces and remove class prefix if it exists
1062
-            $widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
1063
-            // sanitize shortcode directory name
1064
-            $widget = sanitize_key($widget);
1065
-            // now we need to rebuild the shortcode path
1066
-            $widget_path = explode(DS, $widget_path);
1067
-            // remove last segment
1068
-            array_pop($widget_path);
1069
-            // glue it back together
1070
-            $widget_path = implode(DS, $widget_path);
1071
-        } else {
1072
-            // grab and sanitize widget directory name
1073
-            $widget = sanitize_key(basename($widget_path));
1074
-        }
1075
-        // create classname from widget directory name
1076
-        $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1077
-        // add class prefix
1078
-        $widget_class = 'EEW_' . $widget;
1079
-        // does the widget exist ?
1080
-        if (! is_readable($widget_path . DS . $widget_class . $widget_ext)) {
1081
-            $msg = sprintf(
1082
-                __(
1083
-                    'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s',
1084
-                    'event_espresso'
1085
-                ),
1086
-                $widget_class,
1087
-                $widget_path . DS . $widget_class . $widget_ext
1088
-            );
1089
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1090
-            return;
1091
-        }
1092
-        // load the widget class file
1093
-        require_once($widget_path . DS . $widget_class . $widget_ext);
1094
-        // verify that class exists
1095
-        if (! class_exists($widget_class)) {
1096
-            $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1097
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1098
-            return;
1099
-        }
1100
-        register_widget($widget_class);
1101
-        // add to array of registered widgets
1102
-        EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext;
1103
-    }
1104
-
1105
-
1106
-    /**
1107
-     *        _register_modules
1108
-     *
1109
-     * @access private
1110
-     * @return array
1111
-     */
1112
-    private function _register_modules()
1113
-    {
1114
-        // grab list of installed modules
1115
-        $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1116
-        // filter list of modules to register
1117
-        $modules_to_register = apply_filters(
1118
-            'FHEE__EE_Config__register_modules__modules_to_register',
1119
-            $modules_to_register
1120
-        );
1121
-        if (! empty($modules_to_register)) {
1122
-            // loop through folders
1123
-            foreach ($modules_to_register as $module_path) {
1124
-                /**TEMPORARILY EXCLUDE gateways from modules for time being**/
1125
-                if ($module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1126
-                    && $module_path !== EE_MODULES . 'gateways'
1127
-                ) {
1128
-                    // add to list of installed modules
1129
-                    EE_Config::register_module($module_path);
1130
-                }
1131
-            }
1132
-        }
1133
-        // filter list of installed modules
1134
-        return apply_filters(
1135
-            'FHEE__EE_Config___register_modules__installed_modules',
1136
-            EE_Registry::instance()->modules
1137
-        );
1138
-    }
1139
-
1140
-
1141
-    /**
1142
-     *    register_module - makes core aware of this module
1143
-     *
1144
-     * @access    public
1145
-     * @param    string $module_path - full path up to and including module folder
1146
-     * @return    bool
1147
-     */
1148
-    public static function register_module($module_path = null)
1149
-    {
1150
-        do_action('AHEE__EE_Config__register_module__begin', $module_path);
1151
-        $module_ext = '.module.php';
1152
-        // make all separators match
1153
-        $module_path = str_replace(array('\\', '/'), DS, $module_path);
1154
-        // does the file path INCLUDE the actual file name as part of the path ?
1155
-        if (strpos($module_path, $module_ext) !== false) {
1156
-            // grab and shortcode file name from directory name and break apart at dots
1157
-            $module_file = explode('.', basename($module_path));
1158
-            // now we need to rebuild the shortcode path
1159
-            $module_path = explode(DS, $module_path);
1160
-            // remove last segment
1161
-            array_pop($module_path);
1162
-            // glue it back together
1163
-            $module_path = implode(DS, $module_path) . DS;
1164
-            // take first segment from file name pieces and sanitize it
1165
-            $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1166
-            // ensure class prefix is added
1167
-            $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1168
-        } else {
1169
-            // we need to generate the filename based off of the folder name
1170
-            // grab and sanitize module name
1171
-            $module = strtolower(basename($module_path));
1172
-            $module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1173
-            // like trailingslashit()
1174
-            $module_path = rtrim($module_path, DS) . DS;
1175
-            // create classname from module directory name
1176
-            $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1177
-            // add class prefix
1178
-            $module_class = 'EED_' . $module;
1179
-        }
1180
-        // does the module exist ?
1181
-        if (! is_readable($module_path . DS . $module_class . $module_ext)) {
1182
-            $msg = sprintf(
1183
-                __(
1184
-                    'The requested %s module file could not be found or is not readable due to file permissions.',
1185
-                    'event_espresso'
1186
-                ),
1187
-                $module
1188
-            );
1189
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1190
-            return false;
1191
-        }
1192
-        // load the module class file
1193
-        require_once($module_path . $module_class . $module_ext);
1194
-        // verify that class exists
1195
-        if (! class_exists($module_class)) {
1196
-            $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1197
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1198
-            return false;
1199
-        }
1200
-        // add to array of registered modules
1201
-        EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1202
-        do_action(
1203
-            'AHEE__EE_Config__register_module__complete',
1204
-            $module_class,
1205
-            EE_Registry::instance()->modules->{$module_class}
1206
-        );
1207
-        return true;
1208
-    }
1209
-
1210
-
1211
-    /**
1212
-     *    _initialize_modules
1213
-     *    allow modules to set hooks for the rest of the system
1214
-     *
1215
-     * @access private
1216
-     * @return void
1217
-     */
1218
-    private function _initialize_modules()
1219
-    {
1220
-        // cycle thru shortcode folders
1221
-        foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1222
-            // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1223
-            // which set hooks ?
1224
-            if (is_admin()) {
1225
-                // fire immediately
1226
-                call_user_func(array($module_class, 'set_hooks_admin'));
1227
-            } else {
1228
-                // delay until other systems are online
1229
-                add_action(
1230
-                    'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1231
-                    array($module_class, 'set_hooks')
1232
-                );
1233
-            }
1234
-        }
1235
-    }
1236
-
1237
-
1238
-    /**
1239
-     *    register_route - adds module method routes to route_map
1240
-     *
1241
-     * @access    public
1242
-     * @param    string $route       - "pretty" public alias for module method
1243
-     * @param    string $module      - module name (classname without EED_ prefix)
1244
-     * @param    string $method_name - the actual module method to be routed to
1245
-     * @param    string $key         - url param key indicating a route is being called
1246
-     * @return    bool
1247
-     */
1248
-    public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee')
1249
-    {
1250
-        do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1251
-        $module = str_replace('EED_', '', $module);
1252
-        $module_class = 'EED_' . $module;
1253
-        if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1254
-            $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1255
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1256
-            return false;
1257
-        }
1258
-        if (empty($route)) {
1259
-            $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1260
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1261
-            return false;
1262
-        }
1263
-        if (! method_exists('EED_' . $module, $method_name)) {
1264
-            $msg = sprintf(
1265
-                __('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1266
-                $route
1267
-            );
1268
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1269
-            return false;
1270
-        }
1271
-        EE_Config::$_module_route_map[ $key ][ $route ] = array('EED_' . $module, $method_name);
1272
-        return true;
1273
-    }
1274
-
1275
-
1276
-    /**
1277
-     *    get_route - get module method route
1278
-     *
1279
-     * @access    public
1280
-     * @param    string $route - "pretty" public alias for module method
1281
-     * @param    string $key   - url param key indicating a route is being called
1282
-     * @return    string
1283
-     */
1284
-    public static function get_route($route = null, $key = 'ee')
1285
-    {
1286
-        do_action('AHEE__EE_Config__get_route__begin', $route);
1287
-        $route = (string) apply_filters('FHEE__EE_Config__get_route', $route);
1288
-        if (isset(EE_Config::$_module_route_map[ $key ][ $route ])) {
1289
-            return EE_Config::$_module_route_map[ $key ][ $route ];
1290
-        }
1291
-        return null;
1292
-    }
1293
-
1294
-
1295
-    /**
1296
-     *    get_routes - get ALL module method routes
1297
-     *
1298
-     * @access    public
1299
-     * @return    array
1300
-     */
1301
-    public static function get_routes()
1302
-    {
1303
-        return EE_Config::$_module_route_map;
1304
-    }
1305
-
1306
-
1307
-    /**
1308
-     *    register_forward - allows modules to forward request to another module for further processing
1309
-     *
1310
-     * @access    public
1311
-     * @param    string       $route   - "pretty" public alias for module method
1312
-     * @param    integer      $status  - integer value corresponding  to status constant strings set in module parent
1313
-     *                                 class, allows different forwards to be served based on status
1314
-     * @param    array|string $forward - function name or array( class, method )
1315
-     * @param    string       $key     - url param key indicating a route is being called
1316
-     * @return    bool
1317
-     */
1318
-    public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1319
-    {
1320
-        do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1321
-        if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1322
-            $msg = sprintf(
1323
-                __('The module route %s for this forward has not been registered.', 'event_espresso'),
1324
-                $route
1325
-            );
1326
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1327
-            return false;
1328
-        }
1329
-        if (empty($forward)) {
1330
-            $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1331
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1332
-            return false;
1333
-        }
1334
-        if (is_array($forward)) {
1335
-            if (! isset($forward[1])) {
1336
-                $msg = sprintf(
1337
-                    __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1338
-                    $route
1339
-                );
1340
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1341
-                return false;
1342
-            }
1343
-            if (! method_exists($forward[0], $forward[1])) {
1344
-                $msg = sprintf(
1345
-                    __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1346
-                    $forward[1],
1347
-                    $route
1348
-                );
1349
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1350
-                return false;
1351
-            }
1352
-        } elseif (! function_exists($forward)) {
1353
-            $msg = sprintf(
1354
-                __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1355
-                $forward,
1356
-                $route
1357
-            );
1358
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1359
-            return false;
1360
-        }
1361
-        EE_Config::$_module_forward_map[ $key ][ $route ][ absint($status) ] = $forward;
1362
-        return true;
1363
-    }
1364
-
1365
-
1366
-    /**
1367
-     *    get_forward - get forwarding route
1368
-     *
1369
-     * @access    public
1370
-     * @param    string  $route  - "pretty" public alias for module method
1371
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1372
-     *                           allows different forwards to be served based on status
1373
-     * @param    string  $key    - url param key indicating a route is being called
1374
-     * @return    string
1375
-     */
1376
-    public static function get_forward($route = null, $status = 0, $key = 'ee')
1377
-    {
1378
-        do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1379
-        if (isset(EE_Config::$_module_forward_map[ $key ][ $route ][ $status ])) {
1380
-            return apply_filters(
1381
-                'FHEE__EE_Config__get_forward',
1382
-                EE_Config::$_module_forward_map[ $key ][ $route ][ $status ],
1383
-                $route,
1384
-                $status
1385
-            );
1386
-        }
1387
-        return null;
1388
-    }
1389
-
1390
-
1391
-    /**
1392
-     *    register_forward - allows modules to specify different view templates for different method routes and status
1393
-     *    results
1394
-     *
1395
-     * @access    public
1396
-     * @param    string  $route  - "pretty" public alias for module method
1397
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1398
-     *                           allows different views to be served based on status
1399
-     * @param    string  $view
1400
-     * @param    string  $key    - url param key indicating a route is being called
1401
-     * @return    bool
1402
-     */
1403
-    public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1404
-    {
1405
-        do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1406
-        if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1407
-            $msg = sprintf(
1408
-                __('The module route %s for this view has not been registered.', 'event_espresso'),
1409
-                $route
1410
-            );
1411
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1412
-            return false;
1413
-        }
1414
-        if (! is_readable($view)) {
1415
-            $msg = sprintf(
1416
-                __(
1417
-                    'The %s view file could not be found or is not readable due to file permissions.',
1418
-                    'event_espresso'
1419
-                ),
1420
-                $view
1421
-            );
1422
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1423
-            return false;
1424
-        }
1425
-        EE_Config::$_module_view_map[ $key ][ $route ][ absint($status) ] = $view;
1426
-        return true;
1427
-    }
1428
-
1429
-
1430
-    /**
1431
-     *    get_view - get view for route and status
1432
-     *
1433
-     * @access    public
1434
-     * @param    string  $route  - "pretty" public alias for module method
1435
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1436
-     *                           allows different views to be served based on status
1437
-     * @param    string  $key    - url param key indicating a route is being called
1438
-     * @return    string
1439
-     */
1440
-    public static function get_view($route = null, $status = 0, $key = 'ee')
1441
-    {
1442
-        do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1443
-        if (isset(EE_Config::$_module_view_map[ $key ][ $route ][ $status ])) {
1444
-            return apply_filters(
1445
-                'FHEE__EE_Config__get_view',
1446
-                EE_Config::$_module_view_map[ $key ][ $route ][ $status ],
1447
-                $route,
1448
-                $status
1449
-            );
1450
-        }
1451
-        return null;
1452
-    }
1453
-
1454
-
1455
-    public function update_addon_option_names()
1456
-    {
1457
-        update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names);
1458
-    }
1459
-
1460
-
1461
-    public function shutdown()
1462
-    {
1463
-        $this->update_addon_option_names();
1464
-    }
1465
-
1466
-
1467
-    /**
1468
-     * @return LegacyShortcodesManager
1469
-     */
1470
-    public static function getLegacyShortcodesManager()
1471
-    {
1472
-
1473
-        if (! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1474
-            EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager(
1475
-                EE_Registry::instance()
1476
-            );
1477
-        }
1478
-        return EE_Config::instance()->legacy_shortcodes_manager;
1479
-    }
1480
-
1481
-
1482
-    /**
1483
-     * register_shortcode - makes core aware of this shortcode
1484
-     *
1485
-     * @deprecated 4.9.26
1486
-     * @param    string $shortcode_path - full path up to and including shortcode folder
1487
-     * @return    bool
1488
-     */
1489
-    public static function register_shortcode($shortcode_path = null)
1490
-    {
1491
-        EE_Error::doing_it_wrong(
1492
-            __METHOD__,
1493
-            __(
1494
-                'Usage is deprecated. Use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::registerShortcode() as direct replacement, or better yet, please see the new \EventEspresso\core\services\shortcodes\ShortcodesManager class.',
1495
-                'event_espresso'
1496
-            ),
1497
-            '4.9.26'
1498
-        );
1499
-        return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path);
1500
-    }
1501
-}
1502
-
1503
-/**
1504
- * Base class used for config classes. These classes should generally not have
1505
- * magic functions in use, except we'll allow them to magically set and get stuff...
1506
- * basically, they should just be well-defined stdClasses
1507
- */
1508
-class EE_Config_Base
1509
-{
1510
-
1511
-    /**
1512
-     * Utility function for escaping the value of a property and returning.
1513
-     *
1514
-     * @param string $property property name (checks to see if exists).
1515
-     * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1516
-     * @throws \EE_Error
1517
-     */
1518
-    public function get_pretty($property)
1519
-    {
1520
-        if (! property_exists($this, $property)) {
1521
-            throw new EE_Error(
1522
-                sprintf(
1523
-                    __(
1524
-                        '%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.',
1525
-                        'event_espresso'
1526
-                    ),
1527
-                    get_class($this),
1528
-                    $property
1529
-                )
1530
-            );
1531
-        }
1532
-        // just handling escaping of strings for now.
1533
-        if (is_string($this->{$property})) {
1534
-            return stripslashes($this->{$property});
1535
-        }
1536
-        return $this->{$property};
1537
-    }
1538
-
1539
-
1540
-    public function populate()
1541
-    {
1542
-        // grab defaults via a new instance of this class.
1543
-        $class_name = get_class($this);
1544
-        $defaults = new $class_name;
1545
-        // loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1546
-        // default from our $defaults object.
1547
-        foreach (get_object_vars($defaults) as $property => $value) {
1548
-            if ($this->{$property} === null) {
1549
-                $this->{$property} = $value;
1550
-            }
1551
-        }
1552
-        // cleanup
1553
-        unset($defaults);
1554
-    }
1555
-
1556
-
1557
-    /**
1558
-     *        __isset
1559
-     *
1560
-     * @param $a
1561
-     * @return bool
1562
-     */
1563
-    public function __isset($a)
1564
-    {
1565
-        return false;
1566
-    }
1567
-
1568
-
1569
-    /**
1570
-     *        __unset
1571
-     *
1572
-     * @param $a
1573
-     * @return bool
1574
-     */
1575
-    public function __unset($a)
1576
-    {
1577
-        return false;
1578
-    }
1579
-
1580
-
1581
-    /**
1582
-     *        __clone
1583
-     */
1584
-    public function __clone()
1585
-    {
1586
-    }
1587
-
1588
-
1589
-    /**
1590
-     *        __wakeup
1591
-     */
1592
-    public function __wakeup()
1593
-    {
1594
-    }
1595
-
1596
-
1597
-    /**
1598
-     *        __destruct
1599
-     */
1600
-    public function __destruct()
1601
-    {
1602
-    }
1603
-}
1604
-
1605
-
1606
-/**
1607
- * Class for defining what's in the EE_Config relating to registration settings
1608
- */
1609
-class EE_Core_Config extends EE_Config_Base
1610
-{
1611
-
1612
-    public $current_blog_id;
1613
-
1614
-    public $ee_ueip_optin;
1615
-
1616
-    public $ee_ueip_has_notified;
1617
-
1618
-    /**
1619
-     * Not to be confused with the 4 critical page variables (See
1620
-     * get_critical_pages_array()), this is just an array of wp posts that have EE
1621
-     * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode
1622
-     * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array.
1623
-     *
1624
-     * @var array
1625
-     */
1626
-    public $post_shortcodes;
1627
-
1628
-    public $module_route_map;
1629
-
1630
-    public $module_forward_map;
1631
-
1632
-    public $module_view_map;
1633
-
1634
-    /**
1635
-     * The next 4 vars are the IDs of critical EE pages.
1636
-     *
1637
-     * @var int
1638
-     */
1639
-    public $reg_page_id;
1640
-
1641
-    public $txn_page_id;
1642
-
1643
-    public $thank_you_page_id;
1644
-
1645
-    public $cancel_page_id;
1646
-
1647
-    /**
1648
-     * The next 4 vars are the URLs of critical EE pages.
1649
-     *
1650
-     * @var int
1651
-     */
1652
-    public $reg_page_url;
1653
-
1654
-    public $txn_page_url;
1655
-
1656
-    public $thank_you_page_url;
1657
-
1658
-    public $cancel_page_url;
1659
-
1660
-    /**
1661
-     * The next vars relate to the custom slugs for EE CPT routes
1662
-     */
1663
-    public $event_cpt_slug;
1664
-
1665
-
1666
-    /**
1667
-     * This caches the _ee_ueip_option in case this config is reset in the same
1668
-     * request across blog switches in a multisite context.
1669
-     * Avoids extra queries to the db for this option.
1670
-     *
1671
-     * @var bool
1672
-     */
1673
-    public static $ee_ueip_option;
1674
-
1675
-
1676
-    /**
1677
-     *    class constructor
1678
-     *
1679
-     * @access    public
1680
-     */
1681
-    public function __construct()
1682
-    {
1683
-        // set default organization settings
1684
-        $this->current_blog_id = get_current_blog_id();
1685
-        $this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id;
1686
-        $this->ee_ueip_optin = $this->_get_main_ee_ueip_optin();
1687
-        $this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1688
-        $this->post_shortcodes = array();
1689
-        $this->module_route_map = array();
1690
-        $this->module_forward_map = array();
1691
-        $this->module_view_map = array();
1692
-        // critical EE page IDs
1693
-        $this->reg_page_id = 0;
1694
-        $this->txn_page_id = 0;
1695
-        $this->thank_you_page_id = 0;
1696
-        $this->cancel_page_id = 0;
1697
-        // critical EE page URLs
1698
-        $this->reg_page_url = '';
1699
-        $this->txn_page_url = '';
1700
-        $this->thank_you_page_url = '';
1701
-        $this->cancel_page_url = '';
1702
-        // cpt slugs
1703
-        $this->event_cpt_slug = __('events', 'event_espresso');
1704
-        // ueip constant check
1705
-        if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1706
-            $this->ee_ueip_optin = false;
1707
-            $this->ee_ueip_has_notified = true;
1708
-        }
1709
-    }
1710
-
1711
-
1712
-    /**
1713
-     * @return array
1714
-     */
1715
-    public function get_critical_pages_array()
1716
-    {
1717
-        return array(
1718
-            $this->reg_page_id,
1719
-            $this->txn_page_id,
1720
-            $this->thank_you_page_id,
1721
-            $this->cancel_page_id,
1722
-        );
1723
-    }
1724
-
1725
-
1726
-    /**
1727
-     * @return array
1728
-     */
1729
-    public function get_critical_pages_shortcodes_array()
1730
-    {
1731
-        return array(
1732
-            $this->reg_page_id       => 'ESPRESSO_CHECKOUT',
1733
-            $this->txn_page_id       => 'ESPRESSO_TXN_PAGE',
1734
-            $this->thank_you_page_id => 'ESPRESSO_THANK_YOU',
1735
-            $this->cancel_page_id    => 'ESPRESSO_CANCELLED',
1736
-        );
1737
-    }
1738
-
1739
-
1740
-    /**
1741
-     *  gets/returns URL for EE reg_page
1742
-     *
1743
-     * @access    public
1744
-     * @return    string
1745
-     */
1746
-    public function reg_page_url()
1747
-    {
1748
-        if (! $this->reg_page_url) {
1749
-            $this->reg_page_url = add_query_arg(
1750
-                array('uts' => time()),
1751
-                get_permalink($this->reg_page_id)
1752
-            ) . '#checkout';
1753
-        }
1754
-        return $this->reg_page_url;
1755
-    }
1756
-
1757
-
1758
-    /**
1759
-     *  gets/returns URL for EE txn_page
1760
-     *
1761
-     * @param array $query_args like what gets passed to
1762
-     *                          add_query_arg() as the first argument
1763
-     * @access    public
1764
-     * @return    string
1765
-     */
1766
-    public function txn_page_url($query_args = array())
1767
-    {
1768
-        if (! $this->txn_page_url) {
1769
-            $this->txn_page_url = get_permalink($this->txn_page_id);
1770
-        }
1771
-        if ($query_args) {
1772
-            return add_query_arg($query_args, $this->txn_page_url);
1773
-        } else {
1774
-            return $this->txn_page_url;
1775
-        }
1776
-    }
1777
-
1778
-
1779
-    /**
1780
-     *  gets/returns URL for EE thank_you_page
1781
-     *
1782
-     * @param array $query_args like what gets passed to
1783
-     *                          add_query_arg() as the first argument
1784
-     * @access    public
1785
-     * @return    string
1786
-     */
1787
-    public function thank_you_page_url($query_args = array())
1788
-    {
1789
-        if (! $this->thank_you_page_url) {
1790
-            $this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1791
-        }
1792
-        if ($query_args) {
1793
-            return add_query_arg($query_args, $this->thank_you_page_url);
1794
-        } else {
1795
-            return $this->thank_you_page_url;
1796
-        }
1797
-    }
1798
-
1799
-
1800
-    /**
1801
-     *  gets/returns URL for EE cancel_page
1802
-     *
1803
-     * @access    public
1804
-     * @return    string
1805
-     */
1806
-    public function cancel_page_url()
1807
-    {
1808
-        if (! $this->cancel_page_url) {
1809
-            $this->cancel_page_url = get_permalink($this->cancel_page_id);
1810
-        }
1811
-        return $this->cancel_page_url;
1812
-    }
1813
-
1814
-
1815
-    /**
1816
-     * Resets all critical page urls to their original state.  Used primarily by the __sleep() magic method currently.
1817
-     *
1818
-     * @since 4.7.5
1819
-     */
1820
-    protected function _reset_urls()
1821
-    {
1822
-        $this->reg_page_url = '';
1823
-        $this->txn_page_url = '';
1824
-        $this->cancel_page_url = '';
1825
-        $this->thank_you_page_url = '';
1826
-    }
1827
-
1828
-
1829
-    /**
1830
-     * Used to return what the optin value is set for the EE User Experience Program.
1831
-     * This accounts for multisite and this value being requested for a subsite.  In multisite, the value is set
1832
-     * on the main site only.
1833
-     *
1834
-     * @return mixed|void
1835
-     */
1836
-    protected function _get_main_ee_ueip_optin()
1837
-    {
1838
-        // if this is the main site then we can just bypass our direct query.
1839
-        if (is_main_site()) {
1840
-            return get_option('ee_ueip_optin', false);
1841
-        }
1842
-        // is this already cached for this request?  If so use it.
1843
-        if (! empty(EE_Core_Config::$ee_ueip_option)) {
1844
-            return EE_Core_Config::$ee_ueip_option;
1845
-        }
1846
-        global $wpdb;
1847
-        $current_network_main_site = is_multisite() ? get_current_site() : null;
1848
-        $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1849
-        $option = 'ee_ueip_optin';
1850
-        // set correct table for query
1851
-        $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1852
-        // rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1853
-        // get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1854
-        // re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1855
-        // this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1856
-        // for the purpose of caching.
1857
-        $pre = apply_filters('pre_option_' . $option, false, $option);
1858
-        if (false !== $pre) {
1859
-            EE_Core_Config::$ee_ueip_option = $pre;
1860
-            return EE_Core_Config::$ee_ueip_option;
1861
-        }
1862
-        $row = $wpdb->get_row(
1863
-            $wpdb->prepare(
1864
-                "SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1",
1865
-                $option
1866
-            )
1867
-        );
1868
-        if (is_object($row)) {
1869
-            $value = $row->option_value;
1870
-        } else { // option does not exist so use default.
1871
-            return apply_filters('default_option_' . $option, false, $option);
1872
-        }
1873
-        EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1874
-        return EE_Core_Config::$ee_ueip_option;
1875
-    }
1876
-
1877
-    /**
1878
-     * Utility function for escaping the value of a property and returning.
1879
-     *
1880
-     * @param string $property property name (checks to see if exists).
1881
-     * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1882
-     * @throws \EE_Error
1883
-     */
1884
-    public function get_pretty($property)
1885
-    {
1886
-        if ($property === 'ee_ueip_optin') {
1887
-            return $this->ee_ueip_optin ? 'yes' : 'no';
1888
-        }
1889
-        return parent::get_pretty($property);
1890
-    }
1891
-
1892
-
1893
-    /**
1894
-     * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values
1895
-     * on the object.
1896
-     *
1897
-     * @return array
1898
-     */
1899
-    public function __sleep()
1900
-    {
1901
-        // reset all url properties
1902
-        $this->_reset_urls();
1903
-        // return what to save to db
1904
-        return array_keys(get_object_vars($this));
1905
-    }
1906
-}
1907
-
1908
-
1909
-/**
1910
- * Config class for storing info on the Organization
1911
- */
1912
-class EE_Organization_Config extends EE_Config_Base
1913
-{
1914
-
1915
-    /**
1916
-     * @var string $name
1917
-     * eg EE4.1
1918
-     */
1919
-    public $name;
1920
-
1921
-    /**
1922
-     * @var string $address_1
1923
-     * eg 123 Onna Road
1924
-     */
1925
-    public $address_1;
1926
-
1927
-    /**
1928
-     * @var string $address_2
1929
-     * eg PO Box 123
1930
-     */
1931
-    public $address_2;
1932
-
1933
-    /**
1934
-     * @var string $city
1935
-     * eg Inna City
1936
-     */
1937
-    public $city;
1938
-
1939
-    /**
1940
-     * @var int $STA_ID
1941
-     * eg 4
1942
-     */
1943
-    public $STA_ID;
1944
-
1945
-    /**
1946
-     * @var string $CNT_ISO
1947
-     * eg US
1948
-     */
1949
-    public $CNT_ISO;
1950
-
1951
-    /**
1952
-     * @var string $zip
1953
-     * eg 12345  or V1A 2B3
1954
-     */
1955
-    public $zip;
1956
-
1957
-    /**
1958
-     * @var string $email
1959
-     * eg [email protected]
1960
-     */
1961
-    public $email;
1962
-
1963
-
1964
-    /**
1965
-     * @var string $phone
1966
-     * eg. 111-111-1111
1967
-     */
1968
-    public $phone;
1969
-
1970
-
1971
-    /**
1972
-     * @var string $vat
1973
-     * VAT/Tax Number
1974
-     */
1975
-    public $vat;
1976
-
1977
-    /**
1978
-     * @var string $logo_url
1979
-     * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg
1980
-     */
1981
-    public $logo_url;
1982
-
1983
-
1984
-    /**
1985
-     * The below are all various properties for holding links to organization social network profiles
1986
-     *
1987
-     * @var string
1988
-     */
1989
-    /**
1990
-     * facebook (facebook.com/profile.name)
1991
-     *
1992
-     * @var string
1993
-     */
1994
-    public $facebook;
1995
-
1996
-
1997
-    /**
1998
-     * twitter (twitter.com/twitter_handle)
1999
-     *
2000
-     * @var string
2001
-     */
2002
-    public $twitter;
2003
-
2004
-
2005
-    /**
2006
-     * linkedin (linkedin.com/in/profile_name)
2007
-     *
2008
-     * @var string
2009
-     */
2010
-    public $linkedin;
2011
-
2012
-
2013
-    /**
2014
-     * pinterest (www.pinterest.com/profile_name)
2015
-     *
2016
-     * @var string
2017
-     */
2018
-    public $pinterest;
2019
-
2020
-
2021
-    /**
2022
-     * google+ (google.com/+profileName)
2023
-     *
2024
-     * @var string
2025
-     */
2026
-    public $google;
2027
-
2028
-
2029
-    /**
2030
-     * instagram (instagram.com/handle)
2031
-     *
2032
-     * @var string
2033
-     */
2034
-    public $instagram;
2035
-
2036
-
2037
-    /**
2038
-     *    class constructor
2039
-     *
2040
-     * @access    public
2041
-     */
2042
-    public function __construct()
2043
-    {
2044
-        // set default organization settings
2045
-        // decode HTML entities from the WP blogname, because it's stored in the DB with HTML entities encoded
2046
-        $this->name = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES);
2047
-        $this->address_1 = '123 Onna Road';
2048
-        $this->address_2 = 'PO Box 123';
2049
-        $this->city = 'Inna City';
2050
-        $this->STA_ID = 4;
2051
-        $this->CNT_ISO = 'US';
2052
-        $this->zip = '12345';
2053
-        $this->email = get_bloginfo('admin_email');
2054
-        $this->phone = '';
2055
-        $this->vat = '123456789';
2056
-        $this->logo_url = '';
2057
-        $this->facebook = '';
2058
-        $this->twitter = '';
2059
-        $this->linkedin = '';
2060
-        $this->pinterest = '';
2061
-        $this->google = '';
2062
-        $this->instagram = '';
2063
-    }
2064
-}
2065
-
2066
-
2067
-/**
2068
- * Class for defining what's in the EE_Config relating to currency
2069
- */
2070
-class EE_Currency_Config extends EE_Config_Base
2071
-{
2072
-
2073
-    /**
2074
-     * @var string $code
2075
-     * eg 'US'
2076
-     */
2077
-    public $code;
2078
-
2079
-    /**
2080
-     * @var string $name
2081
-     * eg 'Dollar'
2082
-     */
2083
-    public $name;
2084
-
2085
-    /**
2086
-     * plural name
2087
-     *
2088
-     * @var string $plural
2089
-     * eg 'Dollars'
2090
-     */
2091
-    public $plural;
2092
-
2093
-    /**
2094
-     * currency sign
2095
-     *
2096
-     * @var string $sign
2097
-     * eg '$'
2098
-     */
2099
-    public $sign;
2100
-
2101
-    /**
2102
-     * Whether the currency sign should come before the number or not
2103
-     *
2104
-     * @var boolean $sign_b4
2105
-     */
2106
-    public $sign_b4;
2107
-
2108
-    /**
2109
-     * How many digits should come after the decimal place
2110
-     *
2111
-     * @var int $dec_plc
2112
-     */
2113
-    public $dec_plc;
2114
-
2115
-    /**
2116
-     * Symbol to use for decimal mark
2117
-     *
2118
-     * @var string $dec_mrk
2119
-     * eg '.'
2120
-     */
2121
-    public $dec_mrk;
2122
-
2123
-    /**
2124
-     * Symbol to use for thousands
2125
-     *
2126
-     * @var string $thsnds
2127
-     * eg ','
2128
-     */
2129
-    public $thsnds;
16
+	const OPTION_NAME = 'ee_config';
17
+
18
+	const LOG_NAME = 'ee_config_log';
19
+
20
+	const LOG_LENGTH = 100;
21
+
22
+	const ADDON_OPTION_NAMES = 'ee_config_option_names';
23
+
24
+
25
+	/**
26
+	 *    instance of the EE_Config object
27
+	 *
28
+	 * @var    EE_Config $_instance
29
+	 * @access    private
30
+	 */
31
+	private static $_instance;
32
+
33
+	/**
34
+	 * @var boolean $_logging_enabled
35
+	 */
36
+	private static $_logging_enabled = false;
37
+
38
+	/**
39
+	 * @var LegacyShortcodesManager $legacy_shortcodes_manager
40
+	 */
41
+	private $legacy_shortcodes_manager;
42
+
43
+	/**
44
+	 * An StdClass whose property names are addon slugs,
45
+	 * and values are their config classes
46
+	 *
47
+	 * @var StdClass
48
+	 */
49
+	public $addons;
50
+
51
+	/**
52
+	 * @var EE_Admin_Config
53
+	 */
54
+	public $admin;
55
+
56
+	/**
57
+	 * @var EE_Core_Config
58
+	 */
59
+	public $core;
60
+
61
+	/**
62
+	 * @var EE_Currency_Config
63
+	 */
64
+	public $currency;
65
+
66
+	/**
67
+	 * @var EE_Organization_Config
68
+	 */
69
+	public $organization;
70
+
71
+	/**
72
+	 * @var EE_Registration_Config
73
+	 */
74
+	public $registration;
75
+
76
+	/**
77
+	 * @var EE_Template_Config
78
+	 */
79
+	public $template_settings;
80
+
81
+	/**
82
+	 * Holds EE environment values.
83
+	 *
84
+	 * @var EE_Environment_Config
85
+	 */
86
+	public $environment;
87
+
88
+	/**
89
+	 * settings pertaining to Google maps
90
+	 *
91
+	 * @var EE_Map_Config
92
+	 */
93
+	public $map_settings;
94
+
95
+	/**
96
+	 * settings pertaining to Taxes
97
+	 *
98
+	 * @var EE_Tax_Config
99
+	 */
100
+	public $tax_settings;
101
+
102
+
103
+	/**
104
+	 * Settings pertaining to global messages settings.
105
+	 *
106
+	 * @var EE_Messages_Config
107
+	 */
108
+	public $messages;
109
+
110
+	/**
111
+	 * @deprecated
112
+	 * @var EE_Gateway_Config
113
+	 */
114
+	public $gateway;
115
+
116
+	/**
117
+	 * @var    array $_addon_option_names
118
+	 * @access    private
119
+	 */
120
+	private $_addon_option_names = array();
121
+
122
+	/**
123
+	 * @var    array $_module_route_map
124
+	 * @access    private
125
+	 */
126
+	private static $_module_route_map = array();
127
+
128
+	/**
129
+	 * @var    array $_module_forward_map
130
+	 * @access    private
131
+	 */
132
+	private static $_module_forward_map = array();
133
+
134
+	/**
135
+	 * @var    array $_module_view_map
136
+	 * @access    private
137
+	 */
138
+	private static $_module_view_map = array();
139
+
140
+
141
+	/**
142
+	 * @singleton method used to instantiate class object
143
+	 * @access    public
144
+	 * @return EE_Config instance
145
+	 */
146
+	public static function instance()
147
+	{
148
+		// check if class object is instantiated, and instantiated properly
149
+		if (! self::$_instance instanceof EE_Config) {
150
+			self::$_instance = new self();
151
+		}
152
+		return self::$_instance;
153
+	}
154
+
155
+
156
+	/**
157
+	 * Resets the config
158
+	 *
159
+	 * @param bool    $hard_reset    if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE
160
+	 *                               (default) leaves the database alone, and merely resets the EE_Config object to
161
+	 *                               reflect its state in the database
162
+	 * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave
163
+	 *                               $_instance as NULL. Useful in case you want to forget about the old instance on
164
+	 *                               EE_Config, but might not be ready to instantiate EE_Config currently (eg if the
165
+	 *                               site was put into maintenance mode)
166
+	 * @return EE_Config
167
+	 */
168
+	public static function reset($hard_reset = false, $reinstantiate = true)
169
+	{
170
+		if (self::$_instance instanceof EE_Config) {
171
+			if ($hard_reset) {
172
+				self::$_instance->legacy_shortcodes_manager = null;
173
+				self::$_instance->_addon_option_names = array();
174
+				self::$_instance->_initialize_config();
175
+				self::$_instance->update_espresso_config();
176
+			}
177
+			self::$_instance->update_addon_option_names();
178
+		}
179
+		self::$_instance = null;
180
+		// we don't need to reset the static properties imo because those should
181
+		// only change when a module is added or removed. Currently we don't
182
+		// support removing a module during a request when it previously existed
183
+		if ($reinstantiate) {
184
+			return self::instance();
185
+		} else {
186
+			return null;
187
+		}
188
+	}
189
+
190
+
191
+	/**
192
+	 *    class constructor
193
+	 *
194
+	 * @access    private
195
+	 */
196
+	private function __construct()
197
+	{
198
+		do_action('AHEE__EE_Config__construct__begin', $this);
199
+		EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false);
200
+		// setup empty config classes
201
+		$this->_initialize_config();
202
+		// load existing EE site settings
203
+		$this->_load_core_config();
204
+		// confirm everything loaded correctly and set filtered defaults if not
205
+		$this->_verify_config();
206
+		//  register shortcodes and modules
207
+		add_action(
208
+			'AHEE__EE_System__register_shortcodes_modules_and_widgets',
209
+			array($this, 'register_shortcodes_and_modules'),
210
+			999
211
+		);
212
+		//  initialize shortcodes and modules
213
+		add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules'));
214
+		// register widgets
215
+		add_action('widgets_init', array($this, 'widgets_init'), 10);
216
+		// shutdown
217
+		add_action('shutdown', array($this, 'shutdown'), 10);
218
+		// construct__end hook
219
+		do_action('AHEE__EE_Config__construct__end', $this);
220
+		// hardcoded hack
221
+		$this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014';
222
+	}
223
+
224
+
225
+	/**
226
+	 * @return boolean
227
+	 */
228
+	public static function logging_enabled()
229
+	{
230
+		return self::$_logging_enabled;
231
+	}
232
+
233
+
234
+	/**
235
+	 * use to get the current theme if needed from static context
236
+	 *
237
+	 * @return string current theme set.
238
+	 */
239
+	public static function get_current_theme()
240
+	{
241
+		return isset(self::$_instance->template_settings->current_espresso_theme)
242
+			? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014';
243
+	}
244
+
245
+
246
+	/**
247
+	 *        _initialize_config
248
+	 *
249
+	 * @access private
250
+	 * @return void
251
+	 */
252
+	private function _initialize_config()
253
+	{
254
+		EE_Config::trim_log();
255
+		// set defaults
256
+		$this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array());
257
+		$this->addons = new stdClass();
258
+		// set _module_route_map
259
+		EE_Config::$_module_route_map = array();
260
+		// set _module_forward_map
261
+		EE_Config::$_module_forward_map = array();
262
+		// set _module_view_map
263
+		EE_Config::$_module_view_map = array();
264
+	}
265
+
266
+
267
+	/**
268
+	 *        load core plugin configuration
269
+	 *
270
+	 * @access private
271
+	 * @return void
272
+	 */
273
+	private function _load_core_config()
274
+	{
275
+		// load_core_config__start hook
276
+		do_action('AHEE__EE_Config___load_core_config__start', $this);
277
+		$espresso_config = $this->get_espresso_config();
278
+		foreach ($espresso_config as $config => $settings) {
279
+			// load_core_config__start hook
280
+			$settings = apply_filters(
281
+				'FHEE__EE_Config___load_core_config__config_settings',
282
+				$settings,
283
+				$config,
284
+				$this
285
+			);
286
+			if (is_object($settings) && property_exists($this, $config)) {
287
+				$this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
288
+				// call configs populate method to ensure any defaults are set for empty values.
289
+				if (method_exists($settings, 'populate')) {
290
+					$this->{$config}->populate();
291
+				}
292
+				if (method_exists($settings, 'do_hooks')) {
293
+					$this->{$config}->do_hooks();
294
+				}
295
+			}
296
+		}
297
+		if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) {
298
+			$this->update_espresso_config();
299
+		}
300
+		// load_core_config__end hook
301
+		do_action('AHEE__EE_Config___load_core_config__end', $this);
302
+	}
303
+
304
+
305
+	/**
306
+	 *    _verify_config
307
+	 *
308
+	 * @access    protected
309
+	 * @return    void
310
+	 */
311
+	protected function _verify_config()
312
+	{
313
+		$this->core = $this->core instanceof EE_Core_Config
314
+			? $this->core
315
+			: new EE_Core_Config();
316
+		$this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core);
317
+		$this->organization = $this->organization instanceof EE_Organization_Config
318
+			? $this->organization
319
+			: new EE_Organization_Config();
320
+		$this->organization = apply_filters(
321
+			'FHEE__EE_Config___initialize_config__organization',
322
+			$this->organization
323
+		);
324
+		$this->currency = $this->currency instanceof EE_Currency_Config
325
+			? $this->currency
326
+			: new EE_Currency_Config();
327
+		$this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency);
328
+		$this->registration = $this->registration instanceof EE_Registration_Config
329
+			? $this->registration
330
+			: new EE_Registration_Config();
331
+		$this->registration = apply_filters(
332
+			'FHEE__EE_Config___initialize_config__registration',
333
+			$this->registration
334
+		);
335
+		$this->admin = $this->admin instanceof EE_Admin_Config
336
+			? $this->admin
337
+			: new EE_Admin_Config();
338
+		$this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin);
339
+		$this->template_settings = $this->template_settings instanceof EE_Template_Config
340
+			? $this->template_settings
341
+			: new EE_Template_Config();
342
+		$this->template_settings = apply_filters(
343
+			'FHEE__EE_Config___initialize_config__template_settings',
344
+			$this->template_settings
345
+		);
346
+		$this->map_settings = $this->map_settings instanceof EE_Map_Config
347
+			? $this->map_settings
348
+			: new EE_Map_Config();
349
+		$this->map_settings = apply_filters(
350
+			'FHEE__EE_Config___initialize_config__map_settings',
351
+			$this->map_settings
352
+		);
353
+		$this->environment = $this->environment instanceof EE_Environment_Config
354
+			? $this->environment
355
+			: new EE_Environment_Config();
356
+		$this->environment = apply_filters(
357
+			'FHEE__EE_Config___initialize_config__environment',
358
+			$this->environment
359
+		);
360
+		$this->tax_settings = $this->tax_settings instanceof EE_Tax_Config
361
+			? $this->tax_settings
362
+			: new EE_Tax_Config();
363
+		$this->tax_settings = apply_filters(
364
+			'FHEE__EE_Config___initialize_config__tax_settings',
365
+			$this->tax_settings
366
+		);
367
+		$this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages);
368
+		$this->messages = $this->messages instanceof EE_Messages_Config
369
+			? $this->messages
370
+			: new EE_Messages_Config();
371
+		$this->gateway = $this->gateway instanceof EE_Gateway_Config
372
+			? $this->gateway
373
+			: new EE_Gateway_Config();
374
+		$this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway);
375
+		$this->legacy_shortcodes_manager = null;
376
+	}
377
+
378
+
379
+	/**
380
+	 *    get_espresso_config
381
+	 *
382
+	 * @access    public
383
+	 * @return    array of espresso config stuff
384
+	 */
385
+	public function get_espresso_config()
386
+	{
387
+		// grab espresso configuration
388
+		return apply_filters(
389
+			'FHEE__EE_Config__get_espresso_config__CFG',
390
+			get_option(EE_Config::OPTION_NAME, array())
391
+		);
392
+	}
393
+
394
+
395
+	/**
396
+	 *    double_check_config_comparison
397
+	 *
398
+	 * @access    public
399
+	 * @param string $option
400
+	 * @param        $old_value
401
+	 * @param        $value
402
+	 */
403
+	public function double_check_config_comparison($option = '', $old_value, $value)
404
+	{
405
+		// make sure we're checking the ee config
406
+		if ($option === EE_Config::OPTION_NAME) {
407
+			// run a loose comparison of the old value against the new value for type and properties,
408
+			// but NOT exact instance like WP update_option does (ie: NOT type safe comparison)
409
+			if ($value != $old_value) {
410
+				// if they are NOT the same, then remove the hook,
411
+				// which means the subsequent update results will be based solely on the update query results
412
+				// the reason we do this is because, as stated above,
413
+				// WP update_option performs an exact instance comparison (===) on any update values passed to it
414
+				// this happens PRIOR to serialization and any subsequent update.
415
+				// If values are found to match their previous old value,
416
+				// then WP bails before performing any update.
417
+				// Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version
418
+				// it just pulled from the db, with the one being passed to it (which will not match).
419
+				// HOWEVER, once the object is serialized and passed off to MySQL to update,
420
+				// MySQL MAY ALSO NOT perform the update because
421
+				// the string it sees in the db looks the same as the new one it has been passed!!!
422
+				// This results in the query returning an "affected rows" value of ZERO,
423
+				// which gets returned immediately by WP update_option and looks like an error.
424
+				remove_action('update_option', array($this, 'check_config_updated'));
425
+			}
426
+		}
427
+	}
428
+
429
+
430
+	/**
431
+	 *    update_espresso_config
432
+	 *
433
+	 * @access   public
434
+	 */
435
+	protected function _reset_espresso_addon_config()
436
+	{
437
+		$this->_addon_option_names = array();
438
+		foreach ($this->addons as $addon_name => $addon_config_obj) {
439
+			$addon_config_obj = maybe_unserialize($addon_config_obj);
440
+			if ($addon_config_obj instanceof EE_Config_Base) {
441
+				$this->update_config('addons', $addon_name, $addon_config_obj, false);
442
+			}
443
+			$this->addons->{$addon_name} = null;
444
+		}
445
+	}
446
+
447
+
448
+	/**
449
+	 *    update_espresso_config
450
+	 *
451
+	 * @access   public
452
+	 * @param   bool $add_success
453
+	 * @param   bool $add_error
454
+	 * @return   bool
455
+	 */
456
+	public function update_espresso_config($add_success = false, $add_error = true)
457
+	{
458
+		// don't allow config updates during WP heartbeats
459
+		if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
460
+			return false;
461
+		}
462
+		// commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
463
+		// $clone = clone( self::$_instance );
464
+		// self::$_instance = NULL;
465
+		do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
466
+		$this->_reset_espresso_addon_config();
467
+		// hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
468
+		// but BEFORE the actual update occurs
469
+		add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
470
+		// don't want to persist legacy_shortcodes_manager, but don't want to lose it either
471
+		$legacy_shortcodes_manager = $this->legacy_shortcodes_manager;
472
+		$this->legacy_shortcodes_manager = null;
473
+		// now update "ee_config"
474
+		$saved = update_option(EE_Config::OPTION_NAME, $this);
475
+		$this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
476
+		EE_Config::log(EE_Config::OPTION_NAME);
477
+		// if not saved... check if the hook we just added still exists;
478
+		// if it does, it means one of two things:
479
+		// that update_option bailed at the($value === $old_value) conditional,
480
+		// or...
481
+		// the db update query returned 0 rows affected
482
+		// (probably because the data  value was the same from it's perspective)
483
+		// so the existence of the hook means that a negative result from update_option is NOT an error,
484
+		// but just means no update occurred, so don't display an error to the user.
485
+		// BUT... if update_option returns FALSE, AND the hook is missing,
486
+		// then it means that something truly went wrong
487
+		$saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
488
+		// remove our action since we don't want it in the system anymore
489
+		remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
490
+		do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
491
+		// self::$_instance = $clone;
492
+		// unset( $clone );
493
+		// if config remains the same or was updated successfully
494
+		if ($saved) {
495
+			if ($add_success) {
496
+				EE_Error::add_success(
497
+					__('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
498
+					__FILE__,
499
+					__FUNCTION__,
500
+					__LINE__
501
+				);
502
+			}
503
+			return true;
504
+		} else {
505
+			if ($add_error) {
506
+				EE_Error::add_error(
507
+					__('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
508
+					__FILE__,
509
+					__FUNCTION__,
510
+					__LINE__
511
+				);
512
+			}
513
+			return false;
514
+		}
515
+	}
516
+
517
+
518
+	/**
519
+	 *    _verify_config_params
520
+	 *
521
+	 * @access    private
522
+	 * @param    string         $section
523
+	 * @param    string         $name
524
+	 * @param    string         $config_class
525
+	 * @param    EE_Config_Base $config_obj
526
+	 * @param    array          $tests_to_run
527
+	 * @param    bool           $display_errors
528
+	 * @return    bool    TRUE on success, FALSE on fail
529
+	 */
530
+	private function _verify_config_params(
531
+		$section = '',
532
+		$name = '',
533
+		$config_class = '',
534
+		$config_obj = null,
535
+		$tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
536
+		$display_errors = true
537
+	) {
538
+		try {
539
+			foreach ($tests_to_run as $test) {
540
+				switch ($test) {
541
+					// TEST #1 : check that section was set
542
+					case 1:
543
+						if (empty($section)) {
544
+							if ($display_errors) {
545
+								throw new EE_Error(
546
+									sprintf(
547
+										__(
548
+											'No configuration section has been provided while attempting to save "%s".',
549
+											'event_espresso'
550
+										),
551
+										$config_class
552
+									)
553
+								);
554
+							}
555
+							return false;
556
+						}
557
+						break;
558
+					// TEST #2 : check that settings section exists
559
+					case 2:
560
+						if (! isset($this->{$section})) {
561
+							if ($display_errors) {
562
+								throw new EE_Error(
563
+									sprintf(
564
+										__('The "%s" configuration section does not exist.', 'event_espresso'),
565
+										$section
566
+									)
567
+								);
568
+							}
569
+							return false;
570
+						}
571
+						break;
572
+					// TEST #3 : check that section is the proper format
573
+					case 3:
574
+						if (! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
575
+						) {
576
+							if ($display_errors) {
577
+								throw new EE_Error(
578
+									sprintf(
579
+										__(
580
+											'The "%s" configuration settings have not been formatted correctly.',
581
+											'event_espresso'
582
+										),
583
+										$section
584
+									)
585
+								);
586
+							}
587
+							return false;
588
+						}
589
+						break;
590
+					// TEST #4 : check that config section name has been set
591
+					case 4:
592
+						if (empty($name)) {
593
+							if ($display_errors) {
594
+								throw new EE_Error(
595
+									__(
596
+										'No name has been provided for the specific configuration section.',
597
+										'event_espresso'
598
+									)
599
+								);
600
+							}
601
+							return false;
602
+						}
603
+						break;
604
+					// TEST #5 : check that a config class name has been set
605
+					case 5:
606
+						if (empty($config_class)) {
607
+							if ($display_errors) {
608
+								throw new EE_Error(
609
+									__(
610
+										'No class name has been provided for the specific configuration section.',
611
+										'event_espresso'
612
+									)
613
+								);
614
+							}
615
+							return false;
616
+						}
617
+						break;
618
+					// TEST #6 : verify config class is accessible
619
+					case 6:
620
+						if (! class_exists($config_class)) {
621
+							if ($display_errors) {
622
+								throw new EE_Error(
623
+									sprintf(
624
+										__(
625
+											'The "%s" class does not exist. Please ensure that an autoloader has been set for it.',
626
+											'event_espresso'
627
+										),
628
+										$config_class
629
+									)
630
+								);
631
+							}
632
+							return false;
633
+						}
634
+						break;
635
+					// TEST #7 : check that config has even been set
636
+					case 7:
637
+						if (! isset($this->{$section}->{$name})) {
638
+							if ($display_errors) {
639
+								throw new EE_Error(
640
+									sprintf(
641
+										__('No configuration has been set for "%1$s->%2$s".', 'event_espresso'),
642
+										$section,
643
+										$name
644
+									)
645
+								);
646
+							}
647
+							return false;
648
+						} else {
649
+							// and make sure it's not serialized
650
+							$this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name});
651
+						}
652
+						break;
653
+					// TEST #8 : check that config is the requested type
654
+					case 8:
655
+						if (! $this->{$section}->{$name} instanceof $config_class) {
656
+							if ($display_errors) {
657
+								throw new EE_Error(
658
+									sprintf(
659
+										__(
660
+											'The configuration for "%1$s->%2$s" is not of the "%3$s" class.',
661
+											'event_espresso'
662
+										),
663
+										$section,
664
+										$name,
665
+										$config_class
666
+									)
667
+								);
668
+							}
669
+							return false;
670
+						}
671
+						break;
672
+					// TEST #9 : verify config object
673
+					case 9:
674
+						if (! $config_obj instanceof EE_Config_Base) {
675
+							if ($display_errors) {
676
+								throw new EE_Error(
677
+									sprintf(
678
+										__('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'),
679
+										print_r($config_obj, true)
680
+									)
681
+								);
682
+							}
683
+							return false;
684
+						}
685
+						break;
686
+				}
687
+			}
688
+		} catch (EE_Error $e) {
689
+			$e->get_error();
690
+		}
691
+		// you have successfully run the gauntlet
692
+		return true;
693
+	}
694
+
695
+
696
+	/**
697
+	 *    _generate_config_option_name
698
+	 *
699
+	 * @access        protected
700
+	 * @param        string $section
701
+	 * @param        string $name
702
+	 * @return        string
703
+	 */
704
+	private function _generate_config_option_name($section = '', $name = '')
705
+	{
706
+		return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
707
+	}
708
+
709
+
710
+	/**
711
+	 *    _set_config_class
712
+	 * ensures that a config class is set, either from a passed config class or one generated from the config name
713
+	 *
714
+	 * @access    private
715
+	 * @param    string $config_class
716
+	 * @param    string $name
717
+	 * @return    string
718
+	 */
719
+	private function _set_config_class($config_class = '', $name = '')
720
+	{
721
+		return ! empty($config_class)
722
+			? $config_class
723
+			: str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
724
+	}
725
+
726
+
727
+	/**
728
+	 *    set_config
729
+	 *
730
+	 * @access    protected
731
+	 * @param    string         $section
732
+	 * @param    string         $name
733
+	 * @param    string         $config_class
734
+	 * @param    EE_Config_Base $config_obj
735
+	 * @return    EE_Config_Base
736
+	 */
737
+	public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null)
738
+	{
739
+		// ensure config class is set to something
740
+		$config_class = $this->_set_config_class($config_class, $name);
741
+		// run tests 1-4, 6, and 7 to verify all config params are set and valid
742
+		if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
743
+			return null;
744
+		}
745
+		$config_option_name = $this->_generate_config_option_name($section, $name);
746
+		// if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
747
+		if (! isset($this->_addon_option_names[ $config_option_name ])) {
748
+			$this->_addon_option_names[ $config_option_name ] = $config_class;
749
+			$this->update_addon_option_names();
750
+		}
751
+		// verify the incoming config object but suppress errors
752
+		if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
753
+			$config_obj = new $config_class();
754
+		}
755
+		if (get_option($config_option_name)) {
756
+			EE_Config::log($config_option_name);
757
+			update_option($config_option_name, $config_obj);
758
+			$this->{$section}->{$name} = $config_obj;
759
+			return $this->{$section}->{$name};
760
+		} else {
761
+			// create a wp-option for this config
762
+			if (add_option($config_option_name, $config_obj, '', 'no')) {
763
+				$this->{$section}->{$name} = maybe_unserialize($config_obj);
764
+				return $this->{$section}->{$name};
765
+			} else {
766
+				EE_Error::add_error(
767
+					sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class),
768
+					__FILE__,
769
+					__FUNCTION__,
770
+					__LINE__
771
+				);
772
+				return null;
773
+			}
774
+		}
775
+	}
776
+
777
+
778
+	/**
779
+	 *    update_config
780
+	 * Important: the config object must ALREADY be set, otherwise this will produce an error.
781
+	 *
782
+	 * @access    public
783
+	 * @param    string                $section
784
+	 * @param    string                $name
785
+	 * @param    EE_Config_Base|string $config_obj
786
+	 * @param    bool                  $throw_errors
787
+	 * @return    bool
788
+	 */
789
+	public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true)
790
+	{
791
+		// don't allow config updates during WP heartbeats
792
+		if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
793
+			return false;
794
+		}
795
+		$config_obj = maybe_unserialize($config_obj);
796
+		// get class name of the incoming object
797
+		$config_class = get_class($config_obj);
798
+		// run tests 1-5 and 9 to verify config
799
+		if (! $this->_verify_config_params(
800
+			$section,
801
+			$name,
802
+			$config_class,
803
+			$config_obj,
804
+			array(1, 2, 3, 4, 7, 9)
805
+		)
806
+		) {
807
+			return false;
808
+		}
809
+		$config_option_name = $this->_generate_config_option_name($section, $name);
810
+		// check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
811
+		if (! isset($this->_addon_option_names[ $config_option_name ])) {
812
+			// save new config to db
813
+			if ($this->set_config($section, $name, $config_class, $config_obj)) {
814
+				return true;
815
+			}
816
+		} else {
817
+			// first check if the record already exists
818
+			$existing_config = get_option($config_option_name);
819
+			$config_obj = serialize($config_obj);
820
+			// just return if db record is already up to date (NOT type safe comparison)
821
+			if ($existing_config == $config_obj) {
822
+				$this->{$section}->{$name} = $config_obj;
823
+				return true;
824
+			} elseif (update_option($config_option_name, $config_obj)) {
825
+				EE_Config::log($config_option_name);
826
+				// update wp-option for this config class
827
+				$this->{$section}->{$name} = $config_obj;
828
+				return true;
829
+			} elseif ($throw_errors) {
830
+				EE_Error::add_error(
831
+					sprintf(
832
+						__(
833
+							'The "%1$s" object stored at"%2$s" was not successfully updated in the database.',
834
+							'event_espresso'
835
+						),
836
+						$config_class,
837
+						'EE_Config->' . $section . '->' . $name
838
+					),
839
+					__FILE__,
840
+					__FUNCTION__,
841
+					__LINE__
842
+				);
843
+			}
844
+		}
845
+		return false;
846
+	}
847
+
848
+
849
+	/**
850
+	 *    get_config
851
+	 *
852
+	 * @access    public
853
+	 * @param    string $section
854
+	 * @param    string $name
855
+	 * @param    string $config_class
856
+	 * @return    mixed EE_Config_Base | NULL
857
+	 */
858
+	public function get_config($section = '', $name = '', $config_class = '')
859
+	{
860
+		// ensure config class is set to something
861
+		$config_class = $this->_set_config_class($config_class, $name);
862
+		// run tests 1-4, 6 and 7 to verify that all params have been set
863
+		if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
864
+			return null;
865
+		}
866
+		// now test if the requested config object exists, but suppress errors
867
+		if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) {
868
+			// config already exists, so pass it back
869
+			return $this->{$section}->{$name};
870
+		}
871
+		// load config option from db if it exists
872
+		$config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
873
+		// verify the newly retrieved config object, but suppress errors
874
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
875
+			// config is good, so set it and pass it back
876
+			$this->{$section}->{$name} = $config_obj;
877
+			return $this->{$section}->{$name};
878
+		}
879
+		// oops! $config_obj is not already set and does not exist in the db, so create a new one
880
+		$config_obj = $this->set_config($section, $name, $config_class);
881
+		// verify the newly created config object
882
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
883
+			return $this->{$section}->{$name};
884
+		} else {
885
+			EE_Error::add_error(
886
+				sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
887
+				__FILE__,
888
+				__FUNCTION__,
889
+				__LINE__
890
+			);
891
+		}
892
+		return null;
893
+	}
894
+
895
+
896
+	/**
897
+	 *    get_config_option
898
+	 *
899
+	 * @access    public
900
+	 * @param    string $config_option_name
901
+	 * @return    mixed EE_Config_Base | FALSE
902
+	 */
903
+	public function get_config_option($config_option_name = '')
904
+	{
905
+		// retrieve the wp-option for this config class.
906
+		$config_option = maybe_unserialize(get_option($config_option_name, array()));
907
+		if (empty($config_option)) {
908
+			EE_Config::log($config_option_name . '-NOT-FOUND');
909
+		}
910
+		return $config_option;
911
+	}
912
+
913
+
914
+	/**
915
+	 * log
916
+	 *
917
+	 * @param string $config_option_name
918
+	 */
919
+	public static function log($config_option_name = '')
920
+	{
921
+		if (EE_Config::logging_enabled() && ! empty($config_option_name)) {
922
+			$config_log = get_option(EE_Config::LOG_NAME, array());
923
+			// copy incoming $_REQUEST and sanitize it so we can save it
924
+			$_request = $_REQUEST;
925
+			array_walk_recursive($_request, 'sanitize_text_field');
926
+			$config_log[ (string) microtime(true) ] = array(
927
+				'config_name' => $config_option_name,
928
+				'request'     => $_request,
929
+			);
930
+			update_option(EE_Config::LOG_NAME, $config_log);
931
+		}
932
+	}
933
+
934
+
935
+	/**
936
+	 * trim_log
937
+	 * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH
938
+	 */
939
+	public static function trim_log()
940
+	{
941
+		if (! EE_Config::logging_enabled()) {
942
+			return;
943
+		}
944
+		$config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
945
+		$log_length = count($config_log);
946
+		if ($log_length > EE_Config::LOG_LENGTH) {
947
+			ksort($config_log);
948
+			$config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true);
949
+			update_option(EE_Config::LOG_NAME, $config_log);
950
+		}
951
+	}
952
+
953
+
954
+	/**
955
+	 *    get_page_for_posts
956
+	 *    if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the
957
+	 *    wp-option "page_for_posts", or "posts" if no page is selected
958
+	 *
959
+	 * @access    public
960
+	 * @return    string
961
+	 */
962
+	public static function get_page_for_posts()
963
+	{
964
+		$page_for_posts = get_option('page_for_posts');
965
+		if (! $page_for_posts) {
966
+			return 'posts';
967
+		}
968
+		/** @type WPDB $wpdb */
969
+		global $wpdb;
970
+		$SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
971
+		return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
972
+	}
973
+
974
+
975
+	/**
976
+	 *    register_shortcodes_and_modules.
977
+	 *    At this point, it's too early to tell if we're maintenance mode or not.
978
+	 *    In fact, this is where we give modules a chance to let core know they exist
979
+	 *    so they can help trigger maintenance mode if it's needed
980
+	 *
981
+	 * @access    public
982
+	 * @return    void
983
+	 */
984
+	public function register_shortcodes_and_modules()
985
+	{
986
+		// allow modules to set hooks for the rest of the system
987
+		EE_Registry::instance()->modules = $this->_register_modules();
988
+	}
989
+
990
+
991
+	/**
992
+	 *    initialize_shortcodes_and_modules
993
+	 *    meaning they can start adding their hooks to get stuff done
994
+	 *
995
+	 * @access    public
996
+	 * @return    void
997
+	 */
998
+	public function initialize_shortcodes_and_modules()
999
+	{
1000
+		// allow modules to set hooks for the rest of the system
1001
+		$this->_initialize_modules();
1002
+	}
1003
+
1004
+
1005
+	/**
1006
+	 *    widgets_init
1007
+	 *
1008
+	 * @access private
1009
+	 * @return void
1010
+	 */
1011
+	public function widgets_init()
1012
+	{
1013
+		// only init widgets on admin pages when not in complete maintenance, and
1014
+		// on frontend when not in any maintenance mode
1015
+		if (! EE_Maintenance_Mode::instance()->level()
1016
+			|| (
1017
+				is_admin()
1018
+				&& EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
1019
+			)
1020
+		) {
1021
+			// grab list of installed widgets
1022
+			$widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1023
+			// filter list of modules to register
1024
+			$widgets_to_register = apply_filters(
1025
+				'FHEE__EE_Config__register_widgets__widgets_to_register',
1026
+				$widgets_to_register
1027
+			);
1028
+			if (! empty($widgets_to_register)) {
1029
+				// cycle thru widget folders
1030
+				foreach ($widgets_to_register as $widget_path) {
1031
+					// add to list of installed widget modules
1032
+					EE_Config::register_ee_widget($widget_path);
1033
+				}
1034
+			}
1035
+			// filter list of installed modules
1036
+			EE_Registry::instance()->widgets = apply_filters(
1037
+				'FHEE__EE_Config__register_widgets__installed_widgets',
1038
+				EE_Registry::instance()->widgets
1039
+			);
1040
+		}
1041
+	}
1042
+
1043
+
1044
+	/**
1045
+	 *    register_ee_widget - makes core aware of this widget
1046
+	 *
1047
+	 * @access    public
1048
+	 * @param    string $widget_path - full path up to and including widget folder
1049
+	 * @return    void
1050
+	 */
1051
+	public static function register_ee_widget($widget_path = null)
1052
+	{
1053
+		do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
1054
+		$widget_ext = '.widget.php';
1055
+		// make all separators match
1056
+		$widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS);
1057
+		// does the file path INCLUDE the actual file name as part of the path ?
1058
+		if (strpos($widget_path, $widget_ext) !== false) {
1059
+			// grab and shortcode file name from directory name and break apart at dots
1060
+			$file_name = explode('.', basename($widget_path));
1061
+			// take first segment from file name pieces and remove class prefix if it exists
1062
+			$widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
1063
+			// sanitize shortcode directory name
1064
+			$widget = sanitize_key($widget);
1065
+			// now we need to rebuild the shortcode path
1066
+			$widget_path = explode(DS, $widget_path);
1067
+			// remove last segment
1068
+			array_pop($widget_path);
1069
+			// glue it back together
1070
+			$widget_path = implode(DS, $widget_path);
1071
+		} else {
1072
+			// grab and sanitize widget directory name
1073
+			$widget = sanitize_key(basename($widget_path));
1074
+		}
1075
+		// create classname from widget directory name
1076
+		$widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1077
+		// add class prefix
1078
+		$widget_class = 'EEW_' . $widget;
1079
+		// does the widget exist ?
1080
+		if (! is_readable($widget_path . DS . $widget_class . $widget_ext)) {
1081
+			$msg = sprintf(
1082
+				__(
1083
+					'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s',
1084
+					'event_espresso'
1085
+				),
1086
+				$widget_class,
1087
+				$widget_path . DS . $widget_class . $widget_ext
1088
+			);
1089
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1090
+			return;
1091
+		}
1092
+		// load the widget class file
1093
+		require_once($widget_path . DS . $widget_class . $widget_ext);
1094
+		// verify that class exists
1095
+		if (! class_exists($widget_class)) {
1096
+			$msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1097
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1098
+			return;
1099
+		}
1100
+		register_widget($widget_class);
1101
+		// add to array of registered widgets
1102
+		EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext;
1103
+	}
1104
+
1105
+
1106
+	/**
1107
+	 *        _register_modules
1108
+	 *
1109
+	 * @access private
1110
+	 * @return array
1111
+	 */
1112
+	private function _register_modules()
1113
+	{
1114
+		// grab list of installed modules
1115
+		$modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1116
+		// filter list of modules to register
1117
+		$modules_to_register = apply_filters(
1118
+			'FHEE__EE_Config__register_modules__modules_to_register',
1119
+			$modules_to_register
1120
+		);
1121
+		if (! empty($modules_to_register)) {
1122
+			// loop through folders
1123
+			foreach ($modules_to_register as $module_path) {
1124
+				/**TEMPORARILY EXCLUDE gateways from modules for time being**/
1125
+				if ($module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1126
+					&& $module_path !== EE_MODULES . 'gateways'
1127
+				) {
1128
+					// add to list of installed modules
1129
+					EE_Config::register_module($module_path);
1130
+				}
1131
+			}
1132
+		}
1133
+		// filter list of installed modules
1134
+		return apply_filters(
1135
+			'FHEE__EE_Config___register_modules__installed_modules',
1136
+			EE_Registry::instance()->modules
1137
+		);
1138
+	}
1139
+
1140
+
1141
+	/**
1142
+	 *    register_module - makes core aware of this module
1143
+	 *
1144
+	 * @access    public
1145
+	 * @param    string $module_path - full path up to and including module folder
1146
+	 * @return    bool
1147
+	 */
1148
+	public static function register_module($module_path = null)
1149
+	{
1150
+		do_action('AHEE__EE_Config__register_module__begin', $module_path);
1151
+		$module_ext = '.module.php';
1152
+		// make all separators match
1153
+		$module_path = str_replace(array('\\', '/'), DS, $module_path);
1154
+		// does the file path INCLUDE the actual file name as part of the path ?
1155
+		if (strpos($module_path, $module_ext) !== false) {
1156
+			// grab and shortcode file name from directory name and break apart at dots
1157
+			$module_file = explode('.', basename($module_path));
1158
+			// now we need to rebuild the shortcode path
1159
+			$module_path = explode(DS, $module_path);
1160
+			// remove last segment
1161
+			array_pop($module_path);
1162
+			// glue it back together
1163
+			$module_path = implode(DS, $module_path) . DS;
1164
+			// take first segment from file name pieces and sanitize it
1165
+			$module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1166
+			// ensure class prefix is added
1167
+			$module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1168
+		} else {
1169
+			// we need to generate the filename based off of the folder name
1170
+			// grab and sanitize module name
1171
+			$module = strtolower(basename($module_path));
1172
+			$module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1173
+			// like trailingslashit()
1174
+			$module_path = rtrim($module_path, DS) . DS;
1175
+			// create classname from module directory name
1176
+			$module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1177
+			// add class prefix
1178
+			$module_class = 'EED_' . $module;
1179
+		}
1180
+		// does the module exist ?
1181
+		if (! is_readable($module_path . DS . $module_class . $module_ext)) {
1182
+			$msg = sprintf(
1183
+				__(
1184
+					'The requested %s module file could not be found or is not readable due to file permissions.',
1185
+					'event_espresso'
1186
+				),
1187
+				$module
1188
+			);
1189
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1190
+			return false;
1191
+		}
1192
+		// load the module class file
1193
+		require_once($module_path . $module_class . $module_ext);
1194
+		// verify that class exists
1195
+		if (! class_exists($module_class)) {
1196
+			$msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1197
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1198
+			return false;
1199
+		}
1200
+		// add to array of registered modules
1201
+		EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1202
+		do_action(
1203
+			'AHEE__EE_Config__register_module__complete',
1204
+			$module_class,
1205
+			EE_Registry::instance()->modules->{$module_class}
1206
+		);
1207
+		return true;
1208
+	}
1209
+
1210
+
1211
+	/**
1212
+	 *    _initialize_modules
1213
+	 *    allow modules to set hooks for the rest of the system
1214
+	 *
1215
+	 * @access private
1216
+	 * @return void
1217
+	 */
1218
+	private function _initialize_modules()
1219
+	{
1220
+		// cycle thru shortcode folders
1221
+		foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1222
+			// fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1223
+			// which set hooks ?
1224
+			if (is_admin()) {
1225
+				// fire immediately
1226
+				call_user_func(array($module_class, 'set_hooks_admin'));
1227
+			} else {
1228
+				// delay until other systems are online
1229
+				add_action(
1230
+					'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1231
+					array($module_class, 'set_hooks')
1232
+				);
1233
+			}
1234
+		}
1235
+	}
1236
+
1237
+
1238
+	/**
1239
+	 *    register_route - adds module method routes to route_map
1240
+	 *
1241
+	 * @access    public
1242
+	 * @param    string $route       - "pretty" public alias for module method
1243
+	 * @param    string $module      - module name (classname without EED_ prefix)
1244
+	 * @param    string $method_name - the actual module method to be routed to
1245
+	 * @param    string $key         - url param key indicating a route is being called
1246
+	 * @return    bool
1247
+	 */
1248
+	public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee')
1249
+	{
1250
+		do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1251
+		$module = str_replace('EED_', '', $module);
1252
+		$module_class = 'EED_' . $module;
1253
+		if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1254
+			$msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1255
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1256
+			return false;
1257
+		}
1258
+		if (empty($route)) {
1259
+			$msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1260
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1261
+			return false;
1262
+		}
1263
+		if (! method_exists('EED_' . $module, $method_name)) {
1264
+			$msg = sprintf(
1265
+				__('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1266
+				$route
1267
+			);
1268
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1269
+			return false;
1270
+		}
1271
+		EE_Config::$_module_route_map[ $key ][ $route ] = array('EED_' . $module, $method_name);
1272
+		return true;
1273
+	}
1274
+
1275
+
1276
+	/**
1277
+	 *    get_route - get module method route
1278
+	 *
1279
+	 * @access    public
1280
+	 * @param    string $route - "pretty" public alias for module method
1281
+	 * @param    string $key   - url param key indicating a route is being called
1282
+	 * @return    string
1283
+	 */
1284
+	public static function get_route($route = null, $key = 'ee')
1285
+	{
1286
+		do_action('AHEE__EE_Config__get_route__begin', $route);
1287
+		$route = (string) apply_filters('FHEE__EE_Config__get_route', $route);
1288
+		if (isset(EE_Config::$_module_route_map[ $key ][ $route ])) {
1289
+			return EE_Config::$_module_route_map[ $key ][ $route ];
1290
+		}
1291
+		return null;
1292
+	}
1293
+
1294
+
1295
+	/**
1296
+	 *    get_routes - get ALL module method routes
1297
+	 *
1298
+	 * @access    public
1299
+	 * @return    array
1300
+	 */
1301
+	public static function get_routes()
1302
+	{
1303
+		return EE_Config::$_module_route_map;
1304
+	}
1305
+
1306
+
1307
+	/**
1308
+	 *    register_forward - allows modules to forward request to another module for further processing
1309
+	 *
1310
+	 * @access    public
1311
+	 * @param    string       $route   - "pretty" public alias for module method
1312
+	 * @param    integer      $status  - integer value corresponding  to status constant strings set in module parent
1313
+	 *                                 class, allows different forwards to be served based on status
1314
+	 * @param    array|string $forward - function name or array( class, method )
1315
+	 * @param    string       $key     - url param key indicating a route is being called
1316
+	 * @return    bool
1317
+	 */
1318
+	public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1319
+	{
1320
+		do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1321
+		if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1322
+			$msg = sprintf(
1323
+				__('The module route %s for this forward has not been registered.', 'event_espresso'),
1324
+				$route
1325
+			);
1326
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1327
+			return false;
1328
+		}
1329
+		if (empty($forward)) {
1330
+			$msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1331
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1332
+			return false;
1333
+		}
1334
+		if (is_array($forward)) {
1335
+			if (! isset($forward[1])) {
1336
+				$msg = sprintf(
1337
+					__('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1338
+					$route
1339
+				);
1340
+				EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1341
+				return false;
1342
+			}
1343
+			if (! method_exists($forward[0], $forward[1])) {
1344
+				$msg = sprintf(
1345
+					__('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1346
+					$forward[1],
1347
+					$route
1348
+				);
1349
+				EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1350
+				return false;
1351
+			}
1352
+		} elseif (! function_exists($forward)) {
1353
+			$msg = sprintf(
1354
+				__('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1355
+				$forward,
1356
+				$route
1357
+			);
1358
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1359
+			return false;
1360
+		}
1361
+		EE_Config::$_module_forward_map[ $key ][ $route ][ absint($status) ] = $forward;
1362
+		return true;
1363
+	}
1364
+
1365
+
1366
+	/**
1367
+	 *    get_forward - get forwarding route
1368
+	 *
1369
+	 * @access    public
1370
+	 * @param    string  $route  - "pretty" public alias for module method
1371
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1372
+	 *                           allows different forwards to be served based on status
1373
+	 * @param    string  $key    - url param key indicating a route is being called
1374
+	 * @return    string
1375
+	 */
1376
+	public static function get_forward($route = null, $status = 0, $key = 'ee')
1377
+	{
1378
+		do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1379
+		if (isset(EE_Config::$_module_forward_map[ $key ][ $route ][ $status ])) {
1380
+			return apply_filters(
1381
+				'FHEE__EE_Config__get_forward',
1382
+				EE_Config::$_module_forward_map[ $key ][ $route ][ $status ],
1383
+				$route,
1384
+				$status
1385
+			);
1386
+		}
1387
+		return null;
1388
+	}
1389
+
1390
+
1391
+	/**
1392
+	 *    register_forward - allows modules to specify different view templates for different method routes and status
1393
+	 *    results
1394
+	 *
1395
+	 * @access    public
1396
+	 * @param    string  $route  - "pretty" public alias for module method
1397
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1398
+	 *                           allows different views to be served based on status
1399
+	 * @param    string  $view
1400
+	 * @param    string  $key    - url param key indicating a route is being called
1401
+	 * @return    bool
1402
+	 */
1403
+	public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1404
+	{
1405
+		do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1406
+		if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1407
+			$msg = sprintf(
1408
+				__('The module route %s for this view has not been registered.', 'event_espresso'),
1409
+				$route
1410
+			);
1411
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1412
+			return false;
1413
+		}
1414
+		if (! is_readable($view)) {
1415
+			$msg = sprintf(
1416
+				__(
1417
+					'The %s view file could not be found or is not readable due to file permissions.',
1418
+					'event_espresso'
1419
+				),
1420
+				$view
1421
+			);
1422
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1423
+			return false;
1424
+		}
1425
+		EE_Config::$_module_view_map[ $key ][ $route ][ absint($status) ] = $view;
1426
+		return true;
1427
+	}
1428
+
1429
+
1430
+	/**
1431
+	 *    get_view - get view for route and status
1432
+	 *
1433
+	 * @access    public
1434
+	 * @param    string  $route  - "pretty" public alias for module method
1435
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1436
+	 *                           allows different views to be served based on status
1437
+	 * @param    string  $key    - url param key indicating a route is being called
1438
+	 * @return    string
1439
+	 */
1440
+	public static function get_view($route = null, $status = 0, $key = 'ee')
1441
+	{
1442
+		do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1443
+		if (isset(EE_Config::$_module_view_map[ $key ][ $route ][ $status ])) {
1444
+			return apply_filters(
1445
+				'FHEE__EE_Config__get_view',
1446
+				EE_Config::$_module_view_map[ $key ][ $route ][ $status ],
1447
+				$route,
1448
+				$status
1449
+			);
1450
+		}
1451
+		return null;
1452
+	}
1453
+
1454
+
1455
+	public function update_addon_option_names()
1456
+	{
1457
+		update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names);
1458
+	}
1459
+
1460
+
1461
+	public function shutdown()
1462
+	{
1463
+		$this->update_addon_option_names();
1464
+	}
1465
+
1466
+
1467
+	/**
1468
+	 * @return LegacyShortcodesManager
1469
+	 */
1470
+	public static function getLegacyShortcodesManager()
1471
+	{
1472
+
1473
+		if (! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1474
+			EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager(
1475
+				EE_Registry::instance()
1476
+			);
1477
+		}
1478
+		return EE_Config::instance()->legacy_shortcodes_manager;
1479
+	}
1480
+
1481
+
1482
+	/**
1483
+	 * register_shortcode - makes core aware of this shortcode
1484
+	 *
1485
+	 * @deprecated 4.9.26
1486
+	 * @param    string $shortcode_path - full path up to and including shortcode folder
1487
+	 * @return    bool
1488
+	 */
1489
+	public static function register_shortcode($shortcode_path = null)
1490
+	{
1491
+		EE_Error::doing_it_wrong(
1492
+			__METHOD__,
1493
+			__(
1494
+				'Usage is deprecated. Use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::registerShortcode() as direct replacement, or better yet, please see the new \EventEspresso\core\services\shortcodes\ShortcodesManager class.',
1495
+				'event_espresso'
1496
+			),
1497
+			'4.9.26'
1498
+		);
1499
+		return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path);
1500
+	}
1501
+}
2130 1502
 
1503
+/**
1504
+ * Base class used for config classes. These classes should generally not have
1505
+ * magic functions in use, except we'll allow them to magically set and get stuff...
1506
+ * basically, they should just be well-defined stdClasses
1507
+ */
1508
+class EE_Config_Base
1509
+{
2131 1510
 
2132
-    /**
2133
-     *    class constructor
2134
-     *
2135
-     * @access    public
2136
-     * @param string $CNT_ISO
2137
-     * @throws \EE_Error
2138
-     */
2139
-    public function __construct($CNT_ISO = '')
2140
-    {
2141
-        /** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */
2142
-        $table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
2143
-        // get country code from organization settings or use default
2144
-        $ORG_CNT = isset(EE_Registry::instance()->CFG->organization)
2145
-                   && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
2146
-            ? EE_Registry::instance()->CFG->organization->CNT_ISO
2147
-            : '';
2148
-        // but override if requested
2149
-        $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2150
-        // so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists
2151
-        if (! empty($CNT_ISO)
2152
-            && EE_Maintenance_Mode::instance()->models_can_query()
2153
-            && $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())
2154
-        ) {
2155
-            // retrieve the country settings from the db, just in case they have been customized
2156
-            $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2157
-            if ($country instanceof EE_Country) {
2158
-                $this->code = $country->currency_code();    // currency code: USD, CAD, EUR
2159
-                $this->name = $country->currency_name_single();    // Dollar
2160
-                $this->plural = $country->currency_name_plural();    // Dollars
2161
-                $this->sign = $country->currency_sign();            // currency sign: $
2162
-                $this->sign_b4 = $country->currency_sign_before(
2163
-                );        // currency sign before or after: $TRUE  or  FALSE$
2164
-                $this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2165
-                $this->dec_mrk = $country->currency_decimal_mark(
2166
-                );    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2167
-                $this->thsnds = $country->currency_thousands_separator(
2168
-                );    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2169
-            }
2170
-        }
2171
-        // fallback to hardcoded defaults, in case the above failed
2172
-        if (empty($this->code)) {
2173
-            // set default currency settings
2174
-            $this->code = 'USD';    // currency code: USD, CAD, EUR
2175
-            $this->name = __('Dollar', 'event_espresso');    // Dollar
2176
-            $this->plural = __('Dollars', 'event_espresso');    // Dollars
2177
-            $this->sign = '$';    // currency sign: $
2178
-            $this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2179
-            $this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2180
-            $this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2181
-            $this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2182
-        }
2183
-    }
1511
+	/**
1512
+	 * Utility function for escaping the value of a property and returning.
1513
+	 *
1514
+	 * @param string $property property name (checks to see if exists).
1515
+	 * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1516
+	 * @throws \EE_Error
1517
+	 */
1518
+	public function get_pretty($property)
1519
+	{
1520
+		if (! property_exists($this, $property)) {
1521
+			throw new EE_Error(
1522
+				sprintf(
1523
+					__(
1524
+						'%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.',
1525
+						'event_espresso'
1526
+					),
1527
+					get_class($this),
1528
+					$property
1529
+				)
1530
+			);
1531
+		}
1532
+		// just handling escaping of strings for now.
1533
+		if (is_string($this->{$property})) {
1534
+			return stripslashes($this->{$property});
1535
+		}
1536
+		return $this->{$property};
1537
+	}
1538
+
1539
+
1540
+	public function populate()
1541
+	{
1542
+		// grab defaults via a new instance of this class.
1543
+		$class_name = get_class($this);
1544
+		$defaults = new $class_name;
1545
+		// loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1546
+		// default from our $defaults object.
1547
+		foreach (get_object_vars($defaults) as $property => $value) {
1548
+			if ($this->{$property} === null) {
1549
+				$this->{$property} = $value;
1550
+			}
1551
+		}
1552
+		// cleanup
1553
+		unset($defaults);
1554
+	}
1555
+
1556
+
1557
+	/**
1558
+	 *        __isset
1559
+	 *
1560
+	 * @param $a
1561
+	 * @return bool
1562
+	 */
1563
+	public function __isset($a)
1564
+	{
1565
+		return false;
1566
+	}
1567
+
1568
+
1569
+	/**
1570
+	 *        __unset
1571
+	 *
1572
+	 * @param $a
1573
+	 * @return bool
1574
+	 */
1575
+	public function __unset($a)
1576
+	{
1577
+		return false;
1578
+	}
1579
+
1580
+
1581
+	/**
1582
+	 *        __clone
1583
+	 */
1584
+	public function __clone()
1585
+	{
1586
+	}
1587
+
1588
+
1589
+	/**
1590
+	 *        __wakeup
1591
+	 */
1592
+	public function __wakeup()
1593
+	{
1594
+	}
1595
+
1596
+
1597
+	/**
1598
+	 *        __destruct
1599
+	 */
1600
+	public function __destruct()
1601
+	{
1602
+	}
2184 1603
 }
2185 1604
 
2186 1605
 
2187 1606
 /**
2188 1607
  * Class for defining what's in the EE_Config relating to registration settings
2189 1608
  */
2190
-class EE_Registration_Config extends EE_Config_Base
1609
+class EE_Core_Config extends EE_Config_Base
2191 1610
 {
2192 1611
 
2193
-    /**
2194
-     * Default registration status
2195
-     *
2196
-     * @var string $default_STS_ID
2197
-     * eg 'RPP'
2198
-     */
2199
-    public $default_STS_ID;
2200
-
2201
-
2202
-    /**
2203
-     * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of
2204
-     * registrations)
2205
-     *
2206
-     * @var int
2207
-     */
2208
-    public $default_maximum_number_of_tickets;
2209
-
2210
-
2211
-    /**
2212
-     * level of validation to apply to email addresses
2213
-     *
2214
-     * @var string $email_validation_level
2215
-     * options: 'basic', 'wp_default', 'i18n', 'i18n_dns'
2216
-     */
2217
-    public $email_validation_level;
2218
-
2219
-    /**
2220
-     *    whether or not to show alternate payment options during the reg process if payment status is pending
2221
-     *
2222
-     * @var boolean $show_pending_payment_options
2223
-     */
2224
-    public $show_pending_payment_options;
2225
-
2226
-    /**
2227
-     * Whether to skip the registration confirmation page
2228
-     *
2229
-     * @var boolean $skip_reg_confirmation
2230
-     */
2231
-    public $skip_reg_confirmation;
2232
-
2233
-    /**
2234
-     * an array of SPCO reg steps where:
2235
-     *        the keys denotes the reg step order
2236
-     *        each element consists of an array with the following elements:
2237
-     *            "file_path" => the file path to the EE_SPCO_Reg_Step class
2238
-     *            "class_name" => the specific EE_SPCO_Reg_Step child class name
2239
-     *            "slug" => the URL param used to trigger the reg step
2240
-     *
2241
-     * @var array $reg_steps
2242
-     */
2243
-    public $reg_steps;
2244
-
2245
-    /**
2246
-     * Whether registration confirmation should be the last page of SPCO
2247
-     *
2248
-     * @var boolean $reg_confirmation_last
2249
-     */
2250
-    public $reg_confirmation_last;
2251
-
2252
-    /**
2253
-     * Whether or not to enable the EE Bot Trap
2254
-     *
2255
-     * @var boolean $use_bot_trap
2256
-     */
2257
-    public $use_bot_trap;
2258
-
2259
-    /**
2260
-     * Whether or not to encrypt some data sent by the EE Bot Trap
2261
-     *
2262
-     * @var boolean $use_encryption
2263
-     */
2264
-    public $use_encryption;
2265
-
2266
-    /**
2267
-     * Whether or not to use ReCaptcha
2268
-     *
2269
-     * @var boolean $use_captcha
2270
-     */
2271
-    public $use_captcha;
2272
-
2273
-    /**
2274
-     * ReCaptcha Theme
2275
-     *
2276
-     * @var string $recaptcha_theme
2277
-     *    options: 'dark', 'light', 'invisible'
2278
-     */
2279
-    public $recaptcha_theme;
2280
-
2281
-    /**
2282
-     * ReCaptcha Badge - determines the position of the reCAPTCHA badge if using Invisible ReCaptcha.
2283
-     *
2284
-     * @var string $recaptcha_badge
2285
-     *    options: 'bottomright', 'bottomleft', 'inline'
2286
-     */
2287
-    public $recaptcha_badge;
2288
-
2289
-    /**
2290
-     * ReCaptcha Type
2291
-     *
2292
-     * @var string $recaptcha_type
2293
-     *    options: 'audio', 'image'
2294
-     */
2295
-    public $recaptcha_type;
2296
-
2297
-    /**
2298
-     * ReCaptcha language
2299
-     *
2300
-     * @var string $recaptcha_language
2301
-     * eg 'en'
2302
-     */
2303
-    public $recaptcha_language;
2304
-
2305
-    /**
2306
-     * ReCaptcha public key
2307
-     *
2308
-     * @var string $recaptcha_publickey
2309
-     */
2310
-    public $recaptcha_publickey;
2311
-
2312
-    /**
2313
-     * ReCaptcha private key
2314
-     *
2315
-     * @var string $recaptcha_privatekey
2316
-     */
2317
-    public $recaptcha_privatekey;
2318
-
2319
-    /**
2320
-     * array of form names protected by ReCaptcha
2321
-     *
2322
-     * @var array $recaptcha_protected_forms
2323
-     */
2324
-    public $recaptcha_protected_forms;
2325
-
2326
-    /**
2327
-     * ReCaptcha width
2328
-     *
2329
-     * @var int $recaptcha_width
2330
-     * @deprecated
2331
-     */
2332
-    public $recaptcha_width;
2333
-
2334
-    /**
2335
-     * Whether or not invalid attempts to directly access the registration checkout page should be tracked.
2336
-     *
2337
-     * @var boolean $track_invalid_checkout_access
2338
-     */
2339
-    protected $track_invalid_checkout_access = true;
2340
-
1612
+	public $current_blog_id;
1613
+
1614
+	public $ee_ueip_optin;
1615
+
1616
+	public $ee_ueip_has_notified;
1617
+
1618
+	/**
1619
+	 * Not to be confused with the 4 critical page variables (See
1620
+	 * get_critical_pages_array()), this is just an array of wp posts that have EE
1621
+	 * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode
1622
+	 * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array.
1623
+	 *
1624
+	 * @var array
1625
+	 */
1626
+	public $post_shortcodes;
1627
+
1628
+	public $module_route_map;
1629
+
1630
+	public $module_forward_map;
1631
+
1632
+	public $module_view_map;
1633
+
1634
+	/**
1635
+	 * The next 4 vars are the IDs of critical EE pages.
1636
+	 *
1637
+	 * @var int
1638
+	 */
1639
+	public $reg_page_id;
1640
+
1641
+	public $txn_page_id;
1642
+
1643
+	public $thank_you_page_id;
1644
+
1645
+	public $cancel_page_id;
1646
+
1647
+	/**
1648
+	 * The next 4 vars are the URLs of critical EE pages.
1649
+	 *
1650
+	 * @var int
1651
+	 */
1652
+	public $reg_page_url;
1653
+
1654
+	public $txn_page_url;
1655
+
1656
+	public $thank_you_page_url;
1657
+
1658
+	public $cancel_page_url;
1659
+
1660
+	/**
1661
+	 * The next vars relate to the custom slugs for EE CPT routes
1662
+	 */
1663
+	public $event_cpt_slug;
1664
+
1665
+
1666
+	/**
1667
+	 * This caches the _ee_ueip_option in case this config is reset in the same
1668
+	 * request across blog switches in a multisite context.
1669
+	 * Avoids extra queries to the db for this option.
1670
+	 *
1671
+	 * @var bool
1672
+	 */
1673
+	public static $ee_ueip_option;
1674
+
1675
+
1676
+	/**
1677
+	 *    class constructor
1678
+	 *
1679
+	 * @access    public
1680
+	 */
1681
+	public function __construct()
1682
+	{
1683
+		// set default organization settings
1684
+		$this->current_blog_id = get_current_blog_id();
1685
+		$this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id;
1686
+		$this->ee_ueip_optin = $this->_get_main_ee_ueip_optin();
1687
+		$this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1688
+		$this->post_shortcodes = array();
1689
+		$this->module_route_map = array();
1690
+		$this->module_forward_map = array();
1691
+		$this->module_view_map = array();
1692
+		// critical EE page IDs
1693
+		$this->reg_page_id = 0;
1694
+		$this->txn_page_id = 0;
1695
+		$this->thank_you_page_id = 0;
1696
+		$this->cancel_page_id = 0;
1697
+		// critical EE page URLs
1698
+		$this->reg_page_url = '';
1699
+		$this->txn_page_url = '';
1700
+		$this->thank_you_page_url = '';
1701
+		$this->cancel_page_url = '';
1702
+		// cpt slugs
1703
+		$this->event_cpt_slug = __('events', 'event_espresso');
1704
+		// ueip constant check
1705
+		if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1706
+			$this->ee_ueip_optin = false;
1707
+			$this->ee_ueip_has_notified = true;
1708
+		}
1709
+	}
1710
+
1711
+
1712
+	/**
1713
+	 * @return array
1714
+	 */
1715
+	public function get_critical_pages_array()
1716
+	{
1717
+		return array(
1718
+			$this->reg_page_id,
1719
+			$this->txn_page_id,
1720
+			$this->thank_you_page_id,
1721
+			$this->cancel_page_id,
1722
+		);
1723
+	}
1724
+
1725
+
1726
+	/**
1727
+	 * @return array
1728
+	 */
1729
+	public function get_critical_pages_shortcodes_array()
1730
+	{
1731
+		return array(
1732
+			$this->reg_page_id       => 'ESPRESSO_CHECKOUT',
1733
+			$this->txn_page_id       => 'ESPRESSO_TXN_PAGE',
1734
+			$this->thank_you_page_id => 'ESPRESSO_THANK_YOU',
1735
+			$this->cancel_page_id    => 'ESPRESSO_CANCELLED',
1736
+		);
1737
+	}
1738
+
1739
+
1740
+	/**
1741
+	 *  gets/returns URL for EE reg_page
1742
+	 *
1743
+	 * @access    public
1744
+	 * @return    string
1745
+	 */
1746
+	public function reg_page_url()
1747
+	{
1748
+		if (! $this->reg_page_url) {
1749
+			$this->reg_page_url = add_query_arg(
1750
+				array('uts' => time()),
1751
+				get_permalink($this->reg_page_id)
1752
+			) . '#checkout';
1753
+		}
1754
+		return $this->reg_page_url;
1755
+	}
1756
+
1757
+
1758
+	/**
1759
+	 *  gets/returns URL for EE txn_page
1760
+	 *
1761
+	 * @param array $query_args like what gets passed to
1762
+	 *                          add_query_arg() as the first argument
1763
+	 * @access    public
1764
+	 * @return    string
1765
+	 */
1766
+	public function txn_page_url($query_args = array())
1767
+	{
1768
+		if (! $this->txn_page_url) {
1769
+			$this->txn_page_url = get_permalink($this->txn_page_id);
1770
+		}
1771
+		if ($query_args) {
1772
+			return add_query_arg($query_args, $this->txn_page_url);
1773
+		} else {
1774
+			return $this->txn_page_url;
1775
+		}
1776
+	}
1777
+
1778
+
1779
+	/**
1780
+	 *  gets/returns URL for EE thank_you_page
1781
+	 *
1782
+	 * @param array $query_args like what gets passed to
1783
+	 *                          add_query_arg() as the first argument
1784
+	 * @access    public
1785
+	 * @return    string
1786
+	 */
1787
+	public function thank_you_page_url($query_args = array())
1788
+	{
1789
+		if (! $this->thank_you_page_url) {
1790
+			$this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1791
+		}
1792
+		if ($query_args) {
1793
+			return add_query_arg($query_args, $this->thank_you_page_url);
1794
+		} else {
1795
+			return $this->thank_you_page_url;
1796
+		}
1797
+	}
1798
+
1799
+
1800
+	/**
1801
+	 *  gets/returns URL for EE cancel_page
1802
+	 *
1803
+	 * @access    public
1804
+	 * @return    string
1805
+	 */
1806
+	public function cancel_page_url()
1807
+	{
1808
+		if (! $this->cancel_page_url) {
1809
+			$this->cancel_page_url = get_permalink($this->cancel_page_id);
1810
+		}
1811
+		return $this->cancel_page_url;
1812
+	}
1813
+
1814
+
1815
+	/**
1816
+	 * Resets all critical page urls to their original state.  Used primarily by the __sleep() magic method currently.
1817
+	 *
1818
+	 * @since 4.7.5
1819
+	 */
1820
+	protected function _reset_urls()
1821
+	{
1822
+		$this->reg_page_url = '';
1823
+		$this->txn_page_url = '';
1824
+		$this->cancel_page_url = '';
1825
+		$this->thank_you_page_url = '';
1826
+	}
1827
+
1828
+
1829
+	/**
1830
+	 * Used to return what the optin value is set for the EE User Experience Program.
1831
+	 * This accounts for multisite and this value being requested for a subsite.  In multisite, the value is set
1832
+	 * on the main site only.
1833
+	 *
1834
+	 * @return mixed|void
1835
+	 */
1836
+	protected function _get_main_ee_ueip_optin()
1837
+	{
1838
+		// if this is the main site then we can just bypass our direct query.
1839
+		if (is_main_site()) {
1840
+			return get_option('ee_ueip_optin', false);
1841
+		}
1842
+		// is this already cached for this request?  If so use it.
1843
+		if (! empty(EE_Core_Config::$ee_ueip_option)) {
1844
+			return EE_Core_Config::$ee_ueip_option;
1845
+		}
1846
+		global $wpdb;
1847
+		$current_network_main_site = is_multisite() ? get_current_site() : null;
1848
+		$current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1849
+		$option = 'ee_ueip_optin';
1850
+		// set correct table for query
1851
+		$table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1852
+		// rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1853
+		// get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1854
+		// re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1855
+		// this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1856
+		// for the purpose of caching.
1857
+		$pre = apply_filters('pre_option_' . $option, false, $option);
1858
+		if (false !== $pre) {
1859
+			EE_Core_Config::$ee_ueip_option = $pre;
1860
+			return EE_Core_Config::$ee_ueip_option;
1861
+		}
1862
+		$row = $wpdb->get_row(
1863
+			$wpdb->prepare(
1864
+				"SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1",
1865
+				$option
1866
+			)
1867
+		);
1868
+		if (is_object($row)) {
1869
+			$value = $row->option_value;
1870
+		} else { // option does not exist so use default.
1871
+			return apply_filters('default_option_' . $option, false, $option);
1872
+		}
1873
+		EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1874
+		return EE_Core_Config::$ee_ueip_option;
1875
+	}
1876
+
1877
+	/**
1878
+	 * Utility function for escaping the value of a property and returning.
1879
+	 *
1880
+	 * @param string $property property name (checks to see if exists).
1881
+	 * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1882
+	 * @throws \EE_Error
1883
+	 */
1884
+	public function get_pretty($property)
1885
+	{
1886
+		if ($property === 'ee_ueip_optin') {
1887
+			return $this->ee_ueip_optin ? 'yes' : 'no';
1888
+		}
1889
+		return parent::get_pretty($property);
1890
+	}
1891
+
1892
+
1893
+	/**
1894
+	 * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values
1895
+	 * on the object.
1896
+	 *
1897
+	 * @return array
1898
+	 */
1899
+	public function __sleep()
1900
+	{
1901
+		// reset all url properties
1902
+		$this->_reset_urls();
1903
+		// return what to save to db
1904
+		return array_keys(get_object_vars($this));
1905
+	}
1906
+}
2341 1907
 
2342
-    /**
2343
-     *    class constructor
2344
-     *
2345
-     * @access    public
2346
-     */
2347
-    public function __construct()
2348
-    {
2349
-        // set default registration settings
2350
-        $this->default_STS_ID = EEM_Registration::status_id_pending_payment;
2351
-        $this->email_validation_level = 'wp_default';
2352
-        $this->show_pending_payment_options = true;
2353
-        $this->skip_reg_confirmation = true;
2354
-        $this->reg_steps = array();
2355
-        $this->reg_confirmation_last = false;
2356
-        $this->use_bot_trap = true;
2357
-        $this->use_encryption = true;
2358
-        $this->use_captcha = false;
2359
-        $this->recaptcha_theme = 'light';
2360
-        $this->recaptcha_badge = 'bottomleft';
2361
-        $this->recaptcha_type = 'image';
2362
-        $this->recaptcha_language = 'en';
2363
-        $this->recaptcha_publickey = null;
2364
-        $this->recaptcha_privatekey = null;
2365
-        $this->recaptcha_protected_forms = array();
2366
-        $this->recaptcha_width = 500;
2367
-        $this->default_maximum_number_of_tickets = 10;
2368
-    }
2369
-
2370
-
2371
-    /**
2372
-     * This is called by the config loader and hooks are initialized AFTER the config has been populated.
2373
-     *
2374
-     * @since 4.8.8.rc.019
2375
-     */
2376
-    public function do_hooks()
2377
-    {
2378
-        add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2379
-        add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event'));
2380
-    }
2381 1908
 
1909
+/**
1910
+ * Config class for storing info on the Organization
1911
+ */
1912
+class EE_Organization_Config extends EE_Config_Base
1913
+{
2382 1914
 
2383
-    /**
2384
-     * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the
2385
-     * EVT_default_registration_status field matches the config setting for default_STS_ID.
2386
-     */
2387
-    public function set_default_reg_status_on_EEM_Event()
2388
-    {
2389
-        EEM_Event::set_default_reg_status($this->default_STS_ID);
2390
-    }
1915
+	/**
1916
+	 * @var string $name
1917
+	 * eg EE4.1
1918
+	 */
1919
+	public $name;
1920
+
1921
+	/**
1922
+	 * @var string $address_1
1923
+	 * eg 123 Onna Road
1924
+	 */
1925
+	public $address_1;
1926
+
1927
+	/**
1928
+	 * @var string $address_2
1929
+	 * eg PO Box 123
1930
+	 */
1931
+	public $address_2;
1932
+
1933
+	/**
1934
+	 * @var string $city
1935
+	 * eg Inna City
1936
+	 */
1937
+	public $city;
1938
+
1939
+	/**
1940
+	 * @var int $STA_ID
1941
+	 * eg 4
1942
+	 */
1943
+	public $STA_ID;
1944
+
1945
+	/**
1946
+	 * @var string $CNT_ISO
1947
+	 * eg US
1948
+	 */
1949
+	public $CNT_ISO;
1950
+
1951
+	/**
1952
+	 * @var string $zip
1953
+	 * eg 12345  or V1A 2B3
1954
+	 */
1955
+	public $zip;
1956
+
1957
+	/**
1958
+	 * @var string $email
1959
+	 * eg [email protected]
1960
+	 */
1961
+	public $email;
1962
+
1963
+
1964
+	/**
1965
+	 * @var string $phone
1966
+	 * eg. 111-111-1111
1967
+	 */
1968
+	public $phone;
1969
+
1970
+
1971
+	/**
1972
+	 * @var string $vat
1973
+	 * VAT/Tax Number
1974
+	 */
1975
+	public $vat;
1976
+
1977
+	/**
1978
+	 * @var string $logo_url
1979
+	 * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg
1980
+	 */
1981
+	public $logo_url;
1982
+
1983
+
1984
+	/**
1985
+	 * The below are all various properties for holding links to organization social network profiles
1986
+	 *
1987
+	 * @var string
1988
+	 */
1989
+	/**
1990
+	 * facebook (facebook.com/profile.name)
1991
+	 *
1992
+	 * @var string
1993
+	 */
1994
+	public $facebook;
1995
+
1996
+
1997
+	/**
1998
+	 * twitter (twitter.com/twitter_handle)
1999
+	 *
2000
+	 * @var string
2001
+	 */
2002
+	public $twitter;
2003
+
2004
+
2005
+	/**
2006
+	 * linkedin (linkedin.com/in/profile_name)
2007
+	 *
2008
+	 * @var string
2009
+	 */
2010
+	public $linkedin;
2011
+
2012
+
2013
+	/**
2014
+	 * pinterest (www.pinterest.com/profile_name)
2015
+	 *
2016
+	 * @var string
2017
+	 */
2018
+	public $pinterest;
2019
+
2020
+
2021
+	/**
2022
+	 * google+ (google.com/+profileName)
2023
+	 *
2024
+	 * @var string
2025
+	 */
2026
+	public $google;
2027
+
2028
+
2029
+	/**
2030
+	 * instagram (instagram.com/handle)
2031
+	 *
2032
+	 * @var string
2033
+	 */
2034
+	public $instagram;
2035
+
2036
+
2037
+	/**
2038
+	 *    class constructor
2039
+	 *
2040
+	 * @access    public
2041
+	 */
2042
+	public function __construct()
2043
+	{
2044
+		// set default organization settings
2045
+		// decode HTML entities from the WP blogname, because it's stored in the DB with HTML entities encoded
2046
+		$this->name = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES);
2047
+		$this->address_1 = '123 Onna Road';
2048
+		$this->address_2 = 'PO Box 123';
2049
+		$this->city = 'Inna City';
2050
+		$this->STA_ID = 4;
2051
+		$this->CNT_ISO = 'US';
2052
+		$this->zip = '12345';
2053
+		$this->email = get_bloginfo('admin_email');
2054
+		$this->phone = '';
2055
+		$this->vat = '123456789';
2056
+		$this->logo_url = '';
2057
+		$this->facebook = '';
2058
+		$this->twitter = '';
2059
+		$this->linkedin = '';
2060
+		$this->pinterest = '';
2061
+		$this->google = '';
2062
+		$this->instagram = '';
2063
+	}
2064
+}
2391 2065
 
2392 2066
 
2393
-    /**
2394
-     * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field
2395
-     * for Events matches the config setting for default_maximum_number_of_tickets
2396
-     */
2397
-    public function set_default_max_ticket_on_EEM_Event()
2398
-    {
2399
-        EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets);
2400
-    }
2067
+/**
2068
+ * Class for defining what's in the EE_Config relating to currency
2069
+ */
2070
+class EE_Currency_Config extends EE_Config_Base
2071
+{
2401 2072
 
2073
+	/**
2074
+	 * @var string $code
2075
+	 * eg 'US'
2076
+	 */
2077
+	public $code;
2078
+
2079
+	/**
2080
+	 * @var string $name
2081
+	 * eg 'Dollar'
2082
+	 */
2083
+	public $name;
2084
+
2085
+	/**
2086
+	 * plural name
2087
+	 *
2088
+	 * @var string $plural
2089
+	 * eg 'Dollars'
2090
+	 */
2091
+	public $plural;
2092
+
2093
+	/**
2094
+	 * currency sign
2095
+	 *
2096
+	 * @var string $sign
2097
+	 * eg '$'
2098
+	 */
2099
+	public $sign;
2100
+
2101
+	/**
2102
+	 * Whether the currency sign should come before the number or not
2103
+	 *
2104
+	 * @var boolean $sign_b4
2105
+	 */
2106
+	public $sign_b4;
2107
+
2108
+	/**
2109
+	 * How many digits should come after the decimal place
2110
+	 *
2111
+	 * @var int $dec_plc
2112
+	 */
2113
+	public $dec_plc;
2114
+
2115
+	/**
2116
+	 * Symbol to use for decimal mark
2117
+	 *
2118
+	 * @var string $dec_mrk
2119
+	 * eg '.'
2120
+	 */
2121
+	public $dec_mrk;
2122
+
2123
+	/**
2124
+	 * Symbol to use for thousands
2125
+	 *
2126
+	 * @var string $thsnds
2127
+	 * eg ','
2128
+	 */
2129
+	public $thsnds;
2130
+
2131
+
2132
+	/**
2133
+	 *    class constructor
2134
+	 *
2135
+	 * @access    public
2136
+	 * @param string $CNT_ISO
2137
+	 * @throws \EE_Error
2138
+	 */
2139
+	public function __construct($CNT_ISO = '')
2140
+	{
2141
+		/** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */
2142
+		$table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
2143
+		// get country code from organization settings or use default
2144
+		$ORG_CNT = isset(EE_Registry::instance()->CFG->organization)
2145
+				   && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
2146
+			? EE_Registry::instance()->CFG->organization->CNT_ISO
2147
+			: '';
2148
+		// but override if requested
2149
+		$CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2150
+		// so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists
2151
+		if (! empty($CNT_ISO)
2152
+			&& EE_Maintenance_Mode::instance()->models_can_query()
2153
+			&& $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())
2154
+		) {
2155
+			// retrieve the country settings from the db, just in case they have been customized
2156
+			$country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2157
+			if ($country instanceof EE_Country) {
2158
+				$this->code = $country->currency_code();    // currency code: USD, CAD, EUR
2159
+				$this->name = $country->currency_name_single();    // Dollar
2160
+				$this->plural = $country->currency_name_plural();    // Dollars
2161
+				$this->sign = $country->currency_sign();            // currency sign: $
2162
+				$this->sign_b4 = $country->currency_sign_before(
2163
+				);        // currency sign before or after: $TRUE  or  FALSE$
2164
+				$this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2165
+				$this->dec_mrk = $country->currency_decimal_mark(
2166
+				);    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2167
+				$this->thsnds = $country->currency_thousands_separator(
2168
+				);    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2169
+			}
2170
+		}
2171
+		// fallback to hardcoded defaults, in case the above failed
2172
+		if (empty($this->code)) {
2173
+			// set default currency settings
2174
+			$this->code = 'USD';    // currency code: USD, CAD, EUR
2175
+			$this->name = __('Dollar', 'event_espresso');    // Dollar
2176
+			$this->plural = __('Dollars', 'event_espresso');    // Dollars
2177
+			$this->sign = '$';    // currency sign: $
2178
+			$this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2179
+			$this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2180
+			$this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2181
+			$this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2182
+		}
2183
+	}
2184
+}
2402 2185
 
2403
-    /**
2404
-     * @return boolean
2405
-     */
2406
-    public function track_invalid_checkout_access()
2407
-    {
2408
-        return $this->track_invalid_checkout_access;
2409
-    }
2410 2186
 
2187
+/**
2188
+ * Class for defining what's in the EE_Config relating to registration settings
2189
+ */
2190
+class EE_Registration_Config extends EE_Config_Base
2191
+{
2411 2192
 
2412
-    /**
2413
-     * @param boolean $track_invalid_checkout_access
2414
-     */
2415
-    public function set_track_invalid_checkout_access($track_invalid_checkout_access)
2416
-    {
2417
-        $this->track_invalid_checkout_access = filter_var(
2418
-            $track_invalid_checkout_access,
2419
-            FILTER_VALIDATE_BOOLEAN
2420
-        );
2421
-    }
2193
+	/**
2194
+	 * Default registration status
2195
+	 *
2196
+	 * @var string $default_STS_ID
2197
+	 * eg 'RPP'
2198
+	 */
2199
+	public $default_STS_ID;
2200
+
2201
+
2202
+	/**
2203
+	 * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of
2204
+	 * registrations)
2205
+	 *
2206
+	 * @var int
2207
+	 */
2208
+	public $default_maximum_number_of_tickets;
2209
+
2210
+
2211
+	/**
2212
+	 * level of validation to apply to email addresses
2213
+	 *
2214
+	 * @var string $email_validation_level
2215
+	 * options: 'basic', 'wp_default', 'i18n', 'i18n_dns'
2216
+	 */
2217
+	public $email_validation_level;
2218
+
2219
+	/**
2220
+	 *    whether or not to show alternate payment options during the reg process if payment status is pending
2221
+	 *
2222
+	 * @var boolean $show_pending_payment_options
2223
+	 */
2224
+	public $show_pending_payment_options;
2225
+
2226
+	/**
2227
+	 * Whether to skip the registration confirmation page
2228
+	 *
2229
+	 * @var boolean $skip_reg_confirmation
2230
+	 */
2231
+	public $skip_reg_confirmation;
2232
+
2233
+	/**
2234
+	 * an array of SPCO reg steps where:
2235
+	 *        the keys denotes the reg step order
2236
+	 *        each element consists of an array with the following elements:
2237
+	 *            "file_path" => the file path to the EE_SPCO_Reg_Step class
2238
+	 *            "class_name" => the specific EE_SPCO_Reg_Step child class name
2239
+	 *            "slug" => the URL param used to trigger the reg step
2240
+	 *
2241
+	 * @var array $reg_steps
2242
+	 */
2243
+	public $reg_steps;
2244
+
2245
+	/**
2246
+	 * Whether registration confirmation should be the last page of SPCO
2247
+	 *
2248
+	 * @var boolean $reg_confirmation_last
2249
+	 */
2250
+	public $reg_confirmation_last;
2251
+
2252
+	/**
2253
+	 * Whether or not to enable the EE Bot Trap
2254
+	 *
2255
+	 * @var boolean $use_bot_trap
2256
+	 */
2257
+	public $use_bot_trap;
2258
+
2259
+	/**
2260
+	 * Whether or not to encrypt some data sent by the EE Bot Trap
2261
+	 *
2262
+	 * @var boolean $use_encryption
2263
+	 */
2264
+	public $use_encryption;
2265
+
2266
+	/**
2267
+	 * Whether or not to use ReCaptcha
2268
+	 *
2269
+	 * @var boolean $use_captcha
2270
+	 */
2271
+	public $use_captcha;
2272
+
2273
+	/**
2274
+	 * ReCaptcha Theme
2275
+	 *
2276
+	 * @var string $recaptcha_theme
2277
+	 *    options: 'dark', 'light', 'invisible'
2278
+	 */
2279
+	public $recaptcha_theme;
2280
+
2281
+	/**
2282
+	 * ReCaptcha Badge - determines the position of the reCAPTCHA badge if using Invisible ReCaptcha.
2283
+	 *
2284
+	 * @var string $recaptcha_badge
2285
+	 *    options: 'bottomright', 'bottomleft', 'inline'
2286
+	 */
2287
+	public $recaptcha_badge;
2288
+
2289
+	/**
2290
+	 * ReCaptcha Type
2291
+	 *
2292
+	 * @var string $recaptcha_type
2293
+	 *    options: 'audio', 'image'
2294
+	 */
2295
+	public $recaptcha_type;
2296
+
2297
+	/**
2298
+	 * ReCaptcha language
2299
+	 *
2300
+	 * @var string $recaptcha_language
2301
+	 * eg 'en'
2302
+	 */
2303
+	public $recaptcha_language;
2304
+
2305
+	/**
2306
+	 * ReCaptcha public key
2307
+	 *
2308
+	 * @var string $recaptcha_publickey
2309
+	 */
2310
+	public $recaptcha_publickey;
2311
+
2312
+	/**
2313
+	 * ReCaptcha private key
2314
+	 *
2315
+	 * @var string $recaptcha_privatekey
2316
+	 */
2317
+	public $recaptcha_privatekey;
2318
+
2319
+	/**
2320
+	 * array of form names protected by ReCaptcha
2321
+	 *
2322
+	 * @var array $recaptcha_protected_forms
2323
+	 */
2324
+	public $recaptcha_protected_forms;
2325
+
2326
+	/**
2327
+	 * ReCaptcha width
2328
+	 *
2329
+	 * @var int $recaptcha_width
2330
+	 * @deprecated
2331
+	 */
2332
+	public $recaptcha_width;
2333
+
2334
+	/**
2335
+	 * Whether or not invalid attempts to directly access the registration checkout page should be tracked.
2336
+	 *
2337
+	 * @var boolean $track_invalid_checkout_access
2338
+	 */
2339
+	protected $track_invalid_checkout_access = true;
2340
+
2341
+
2342
+	/**
2343
+	 *    class constructor
2344
+	 *
2345
+	 * @access    public
2346
+	 */
2347
+	public function __construct()
2348
+	{
2349
+		// set default registration settings
2350
+		$this->default_STS_ID = EEM_Registration::status_id_pending_payment;
2351
+		$this->email_validation_level = 'wp_default';
2352
+		$this->show_pending_payment_options = true;
2353
+		$this->skip_reg_confirmation = true;
2354
+		$this->reg_steps = array();
2355
+		$this->reg_confirmation_last = false;
2356
+		$this->use_bot_trap = true;
2357
+		$this->use_encryption = true;
2358
+		$this->use_captcha = false;
2359
+		$this->recaptcha_theme = 'light';
2360
+		$this->recaptcha_badge = 'bottomleft';
2361
+		$this->recaptcha_type = 'image';
2362
+		$this->recaptcha_language = 'en';
2363
+		$this->recaptcha_publickey = null;
2364
+		$this->recaptcha_privatekey = null;
2365
+		$this->recaptcha_protected_forms = array();
2366
+		$this->recaptcha_width = 500;
2367
+		$this->default_maximum_number_of_tickets = 10;
2368
+	}
2369
+
2370
+
2371
+	/**
2372
+	 * This is called by the config loader and hooks are initialized AFTER the config has been populated.
2373
+	 *
2374
+	 * @since 4.8.8.rc.019
2375
+	 */
2376
+	public function do_hooks()
2377
+	{
2378
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2379
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event'));
2380
+	}
2381
+
2382
+
2383
+	/**
2384
+	 * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the
2385
+	 * EVT_default_registration_status field matches the config setting for default_STS_ID.
2386
+	 */
2387
+	public function set_default_reg_status_on_EEM_Event()
2388
+	{
2389
+		EEM_Event::set_default_reg_status($this->default_STS_ID);
2390
+	}
2391
+
2392
+
2393
+	/**
2394
+	 * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field
2395
+	 * for Events matches the config setting for default_maximum_number_of_tickets
2396
+	 */
2397
+	public function set_default_max_ticket_on_EEM_Event()
2398
+	{
2399
+		EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets);
2400
+	}
2401
+
2402
+
2403
+	/**
2404
+	 * @return boolean
2405
+	 */
2406
+	public function track_invalid_checkout_access()
2407
+	{
2408
+		return $this->track_invalid_checkout_access;
2409
+	}
2410
+
2411
+
2412
+	/**
2413
+	 * @param boolean $track_invalid_checkout_access
2414
+	 */
2415
+	public function set_track_invalid_checkout_access($track_invalid_checkout_access)
2416
+	{
2417
+		$this->track_invalid_checkout_access = filter_var(
2418
+			$track_invalid_checkout_access,
2419
+			FILTER_VALIDATE_BOOLEAN
2420
+		);
2421
+	}
2422 2422
 }
2423 2423
 
2424 2424
 
@@ -2428,175 +2428,175 @@  discard block
 block discarded – undo
2428 2428
 class EE_Admin_Config extends EE_Config_Base
2429 2429
 {
2430 2430
 
2431
-    /**
2432
-     * @var boolean $use_personnel_manager
2433
-     */
2434
-    public $use_personnel_manager;
2435
-
2436
-    /**
2437
-     * @var boolean $use_dashboard_widget
2438
-     */
2439
-    public $use_dashboard_widget;
2440
-
2441
-    /**
2442
-     * @var int $events_in_dashboard
2443
-     */
2444
-    public $events_in_dashboard;
2445
-
2446
-    /**
2447
-     * @var boolean $use_event_timezones
2448
-     */
2449
-    public $use_event_timezones;
2450
-
2451
-    /**
2452
-     * @var boolean $use_full_logging
2453
-     */
2454
-    public $use_full_logging;
2455
-
2456
-    /**
2457
-     * @var string $log_file_name
2458
-     */
2459
-    public $log_file_name;
2460
-
2461
-    /**
2462
-     * @var string $debug_file_name
2463
-     */
2464
-    public $debug_file_name;
2465
-
2466
-    /**
2467
-     * @var boolean $use_remote_logging
2468
-     */
2469
-    public $use_remote_logging;
2470
-
2471
-    /**
2472
-     * @var string $remote_logging_url
2473
-     */
2474
-    public $remote_logging_url;
2475
-
2476
-    /**
2477
-     * @var boolean $show_reg_footer
2478
-     */
2479
-    public $show_reg_footer;
2480
-
2481
-    /**
2482
-     * @var string $affiliate_id
2483
-     */
2484
-    public $affiliate_id;
2485
-
2486
-    /**
2487
-     * help tours on or off (global setting)
2488
-     *
2489
-     * @var boolean
2490
-     */
2491
-    public $help_tour_activation;
2492
-
2493
-    public $gateway_log_lifespan = '1 week';
2494
-
2495
-    /**
2496
-     * adds extra layer of encoding to session data to prevent serialization errors
2497
-     * but is incompatible with some server configuration errors
2498
-     * if you get "500 internal server errors" during registration, try turning this on
2499
-     * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off
2500
-     *
2501
-     * @var boolean $encode_session_data
2502
-     */
2503
-    private $encode_session_data = false;
2504
-
2505
-
2506
-    /**
2507
-     *    class constructor
2508
-     *
2509
-     * @access    public
2510
-     */
2511
-    public function __construct()
2512
-    {
2513
-        // set default general admin settings
2514
-        $this->use_personnel_manager = true;
2515
-        $this->use_dashboard_widget = true;
2516
-        $this->events_in_dashboard = 30;
2517
-        $this->use_event_timezones = false;
2518
-        $this->use_full_logging = false;
2519
-        $this->use_remote_logging = false;
2520
-        $this->remote_logging_url = null;
2521
-        $this->show_reg_footer = true;
2522
-        $this->affiliate_id = 'default';
2523
-        $this->help_tour_activation = true;
2524
-        $this->encode_session_data = false;
2525
-        $this->gateway_log_lifespan = '1 week';
2526
-    }
2527
-
2528
-
2529
-    /**
2530
-     * @param bool $reset
2531
-     * @return string
2532
-     */
2533
-    public function log_file_name($reset = false)
2534
-    {
2535
-        if (empty($this->log_file_name) || $reset) {
2536
-            $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2537
-            EE_Config::instance()->update_espresso_config(false, false);
2538
-        }
2539
-        return $this->log_file_name;
2540
-    }
2541
-
2542
-
2543
-    /**
2544
-     * @param bool $reset
2545
-     * @return string
2546
-     */
2547
-    public function debug_file_name($reset = false)
2548
-    {
2549
-        if (empty($this->debug_file_name) || $reset) {
2550
-            $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2551
-            EE_Config::instance()->update_espresso_config(false, false);
2552
-        }
2553
-        return $this->debug_file_name;
2554
-    }
2555
-
2556
-
2557
-    /**
2558
-     * @return string
2559
-     */
2560
-    public function affiliate_id()
2561
-    {
2562
-        return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default';
2563
-    }
2564
-
2565
-
2566
-    /**
2567
-     * @return boolean
2568
-     */
2569
-    public function encode_session_data()
2570
-    {
2571
-        return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN);
2572
-    }
2573
-
2574
-
2575
-    /**
2576
-     * @param boolean $encode_session_data
2577
-     */
2578
-    public function set_encode_session_data($encode_session_data)
2579
-    {
2580
-        $this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN);
2581
-    }
2582
-
2583
-
2584
-    /**
2585
-     * Gets the options to make availalbe for the gateway log lifespan
2586
-     * @return array
2587
-     */
2588
-    public function gatewayLogLifespanOptions()
2589
-    {
2590
-        return (array) apply_filters(
2591
-            'FHEE_EE_Admin_Config__gatewayLogLifespanOptions',
2592
-            array(
2593
-                '1 second' => esc_html__('Don\'t Log At All', 'event_espresso'),
2594
-                '1 day' => esc_html__('A Day', 'event_espresso'),
2595
-                '1 week' => esc_html__('A Week', 'event_espresso'),
2596
-                '5 weeks' => esc_html__('5 Weeks', 'event_espresso')
2597
-            )
2598
-        );
2599
-    }
2431
+	/**
2432
+	 * @var boolean $use_personnel_manager
2433
+	 */
2434
+	public $use_personnel_manager;
2435
+
2436
+	/**
2437
+	 * @var boolean $use_dashboard_widget
2438
+	 */
2439
+	public $use_dashboard_widget;
2440
+
2441
+	/**
2442
+	 * @var int $events_in_dashboard
2443
+	 */
2444
+	public $events_in_dashboard;
2445
+
2446
+	/**
2447
+	 * @var boolean $use_event_timezones
2448
+	 */
2449
+	public $use_event_timezones;
2450
+
2451
+	/**
2452
+	 * @var boolean $use_full_logging
2453
+	 */
2454
+	public $use_full_logging;
2455
+
2456
+	/**
2457
+	 * @var string $log_file_name
2458
+	 */
2459
+	public $log_file_name;
2460
+
2461
+	/**
2462
+	 * @var string $debug_file_name
2463
+	 */
2464
+	public $debug_file_name;
2465
+
2466
+	/**
2467
+	 * @var boolean $use_remote_logging
2468
+	 */
2469
+	public $use_remote_logging;
2470
+
2471
+	/**
2472
+	 * @var string $remote_logging_url
2473
+	 */
2474
+	public $remote_logging_url;
2475
+
2476
+	/**
2477
+	 * @var boolean $show_reg_footer
2478
+	 */
2479
+	public $show_reg_footer;
2480
+
2481
+	/**
2482
+	 * @var string $affiliate_id
2483
+	 */
2484
+	public $affiliate_id;
2485
+
2486
+	/**
2487
+	 * help tours on or off (global setting)
2488
+	 *
2489
+	 * @var boolean
2490
+	 */
2491
+	public $help_tour_activation;
2492
+
2493
+	public $gateway_log_lifespan = '1 week';
2494
+
2495
+	/**
2496
+	 * adds extra layer of encoding to session data to prevent serialization errors
2497
+	 * but is incompatible with some server configuration errors
2498
+	 * if you get "500 internal server errors" during registration, try turning this on
2499
+	 * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off
2500
+	 *
2501
+	 * @var boolean $encode_session_data
2502
+	 */
2503
+	private $encode_session_data = false;
2504
+
2505
+
2506
+	/**
2507
+	 *    class constructor
2508
+	 *
2509
+	 * @access    public
2510
+	 */
2511
+	public function __construct()
2512
+	{
2513
+		// set default general admin settings
2514
+		$this->use_personnel_manager = true;
2515
+		$this->use_dashboard_widget = true;
2516
+		$this->events_in_dashboard = 30;
2517
+		$this->use_event_timezones = false;
2518
+		$this->use_full_logging = false;
2519
+		$this->use_remote_logging = false;
2520
+		$this->remote_logging_url = null;
2521
+		$this->show_reg_footer = true;
2522
+		$this->affiliate_id = 'default';
2523
+		$this->help_tour_activation = true;
2524
+		$this->encode_session_data = false;
2525
+		$this->gateway_log_lifespan = '1 week';
2526
+	}
2527
+
2528
+
2529
+	/**
2530
+	 * @param bool $reset
2531
+	 * @return string
2532
+	 */
2533
+	public function log_file_name($reset = false)
2534
+	{
2535
+		if (empty($this->log_file_name) || $reset) {
2536
+			$this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2537
+			EE_Config::instance()->update_espresso_config(false, false);
2538
+		}
2539
+		return $this->log_file_name;
2540
+	}
2541
+
2542
+
2543
+	/**
2544
+	 * @param bool $reset
2545
+	 * @return string
2546
+	 */
2547
+	public function debug_file_name($reset = false)
2548
+	{
2549
+		if (empty($this->debug_file_name) || $reset) {
2550
+			$this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2551
+			EE_Config::instance()->update_espresso_config(false, false);
2552
+		}
2553
+		return $this->debug_file_name;
2554
+	}
2555
+
2556
+
2557
+	/**
2558
+	 * @return string
2559
+	 */
2560
+	public function affiliate_id()
2561
+	{
2562
+		return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default';
2563
+	}
2564
+
2565
+
2566
+	/**
2567
+	 * @return boolean
2568
+	 */
2569
+	public function encode_session_data()
2570
+	{
2571
+		return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN);
2572
+	}
2573
+
2574
+
2575
+	/**
2576
+	 * @param boolean $encode_session_data
2577
+	 */
2578
+	public function set_encode_session_data($encode_session_data)
2579
+	{
2580
+		$this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN);
2581
+	}
2582
+
2583
+
2584
+	/**
2585
+	 * Gets the options to make availalbe for the gateway log lifespan
2586
+	 * @return array
2587
+	 */
2588
+	public function gatewayLogLifespanOptions()
2589
+	{
2590
+		return (array) apply_filters(
2591
+			'FHEE_EE_Admin_Config__gatewayLogLifespanOptions',
2592
+			array(
2593
+				'1 second' => esc_html__('Don\'t Log At All', 'event_espresso'),
2594
+				'1 day' => esc_html__('A Day', 'event_espresso'),
2595
+				'1 week' => esc_html__('A Week', 'event_espresso'),
2596
+				'5 weeks' => esc_html__('5 Weeks', 'event_espresso')
2597
+			)
2598
+		);
2599
+	}
2600 2600
 }
2601 2601
 
2602 2602
 
@@ -2606,70 +2606,70 @@  discard block
 block discarded – undo
2606 2606
 class EE_Template_Config extends EE_Config_Base
2607 2607
 {
2608 2608
 
2609
-    /**
2610
-     * @var boolean $enable_default_style
2611
-     */
2612
-    public $enable_default_style;
2613
-
2614
-    /**
2615
-     * @var string $custom_style_sheet
2616
-     */
2617
-    public $custom_style_sheet;
2618
-
2619
-    /**
2620
-     * @var boolean $display_address_in_regform
2621
-     */
2622
-    public $display_address_in_regform;
2623
-
2624
-    /**
2625
-     * @var int $display_description_on_multi_reg_page
2626
-     */
2627
-    public $display_description_on_multi_reg_page;
2628
-
2629
-    /**
2630
-     * @var boolean $use_custom_templates
2631
-     */
2632
-    public $use_custom_templates;
2633
-
2634
-    /**
2635
-     * @var string $current_espresso_theme
2636
-     */
2637
-    public $current_espresso_theme;
2638
-
2639
-    /**
2640
-     * @var EE_Ticket_Selector_Config $EED_Ticket_Selector
2641
-     */
2642
-    public $EED_Ticket_Selector;
2643
-
2644
-    /**
2645
-     * @var EE_Event_Single_Config $EED_Event_Single
2646
-     */
2647
-    public $EED_Event_Single;
2648
-
2649
-    /**
2650
-     * @var EE_Events_Archive_Config $EED_Events_Archive
2651
-     */
2652
-    public $EED_Events_Archive;
2653
-
2654
-
2655
-    /**
2656
-     *    class constructor
2657
-     *
2658
-     * @access    public
2659
-     */
2660
-    public function __construct()
2661
-    {
2662
-        // set default template settings
2663
-        $this->enable_default_style = true;
2664
-        $this->custom_style_sheet = null;
2665
-        $this->display_address_in_regform = true;
2666
-        $this->display_description_on_multi_reg_page = false;
2667
-        $this->use_custom_templates = false;
2668
-        $this->current_espresso_theme = 'Espresso_Arabica_2014';
2669
-        $this->EED_Event_Single = null;
2670
-        $this->EED_Events_Archive = null;
2671
-        $this->EED_Ticket_Selector = null;
2672
-    }
2609
+	/**
2610
+	 * @var boolean $enable_default_style
2611
+	 */
2612
+	public $enable_default_style;
2613
+
2614
+	/**
2615
+	 * @var string $custom_style_sheet
2616
+	 */
2617
+	public $custom_style_sheet;
2618
+
2619
+	/**
2620
+	 * @var boolean $display_address_in_regform
2621
+	 */
2622
+	public $display_address_in_regform;
2623
+
2624
+	/**
2625
+	 * @var int $display_description_on_multi_reg_page
2626
+	 */
2627
+	public $display_description_on_multi_reg_page;
2628
+
2629
+	/**
2630
+	 * @var boolean $use_custom_templates
2631
+	 */
2632
+	public $use_custom_templates;
2633
+
2634
+	/**
2635
+	 * @var string $current_espresso_theme
2636
+	 */
2637
+	public $current_espresso_theme;
2638
+
2639
+	/**
2640
+	 * @var EE_Ticket_Selector_Config $EED_Ticket_Selector
2641
+	 */
2642
+	public $EED_Ticket_Selector;
2643
+
2644
+	/**
2645
+	 * @var EE_Event_Single_Config $EED_Event_Single
2646
+	 */
2647
+	public $EED_Event_Single;
2648
+
2649
+	/**
2650
+	 * @var EE_Events_Archive_Config $EED_Events_Archive
2651
+	 */
2652
+	public $EED_Events_Archive;
2653
+
2654
+
2655
+	/**
2656
+	 *    class constructor
2657
+	 *
2658
+	 * @access    public
2659
+	 */
2660
+	public function __construct()
2661
+	{
2662
+		// set default template settings
2663
+		$this->enable_default_style = true;
2664
+		$this->custom_style_sheet = null;
2665
+		$this->display_address_in_regform = true;
2666
+		$this->display_description_on_multi_reg_page = false;
2667
+		$this->use_custom_templates = false;
2668
+		$this->current_espresso_theme = 'Espresso_Arabica_2014';
2669
+		$this->EED_Event_Single = null;
2670
+		$this->EED_Events_Archive = null;
2671
+		$this->EED_Ticket_Selector = null;
2672
+	}
2673 2673
 }
2674 2674
 
2675 2675
 
@@ -2679,114 +2679,114 @@  discard block
 block discarded – undo
2679 2679
 class EE_Map_Config extends EE_Config_Base
2680 2680
 {
2681 2681
 
2682
-    /**
2683
-     * @var boolean $use_google_maps
2684
-     */
2685
-    public $use_google_maps;
2686
-
2687
-    /**
2688
-     * @var string $api_key
2689
-     */
2690
-    public $google_map_api_key;
2691
-
2692
-    /**
2693
-     * @var int $event_details_map_width
2694
-     */
2695
-    public $event_details_map_width;
2696
-
2697
-    /**
2698
-     * @var int $event_details_map_height
2699
-     */
2700
-    public $event_details_map_height;
2701
-
2702
-    /**
2703
-     * @var int $event_details_map_zoom
2704
-     */
2705
-    public $event_details_map_zoom;
2706
-
2707
-    /**
2708
-     * @var boolean $event_details_display_nav
2709
-     */
2710
-    public $event_details_display_nav;
2711
-
2712
-    /**
2713
-     * @var boolean $event_details_nav_size
2714
-     */
2715
-    public $event_details_nav_size;
2716
-
2717
-    /**
2718
-     * @var string $event_details_control_type
2719
-     */
2720
-    public $event_details_control_type;
2721
-
2722
-    /**
2723
-     * @var string $event_details_map_align
2724
-     */
2725
-    public $event_details_map_align;
2726
-
2727
-    /**
2728
-     * @var int $event_list_map_width
2729
-     */
2730
-    public $event_list_map_width;
2731
-
2732
-    /**
2733
-     * @var int $event_list_map_height
2734
-     */
2735
-    public $event_list_map_height;
2736
-
2737
-    /**
2738
-     * @var int $event_list_map_zoom
2739
-     */
2740
-    public $event_list_map_zoom;
2741
-
2742
-    /**
2743
-     * @var boolean $event_list_display_nav
2744
-     */
2745
-    public $event_list_display_nav;
2746
-
2747
-    /**
2748
-     * @var boolean $event_list_nav_size
2749
-     */
2750
-    public $event_list_nav_size;
2751
-
2752
-    /**
2753
-     * @var string $event_list_control_type
2754
-     */
2755
-    public $event_list_control_type;
2756
-
2757
-    /**
2758
-     * @var string $event_list_map_align
2759
-     */
2760
-    public $event_list_map_align;
2761
-
2762
-
2763
-    /**
2764
-     *    class constructor
2765
-     *
2766
-     * @access    public
2767
-     */
2768
-    public function __construct()
2769
-    {
2770
-        // set default map settings
2771
-        $this->use_google_maps = true;
2772
-        $this->google_map_api_key = '';
2773
-        // for event details pages (reg page)
2774
-        $this->event_details_map_width = 585;            // ee_map_width_single
2775
-        $this->event_details_map_height = 362;            // ee_map_height_single
2776
-        $this->event_details_map_zoom = 14;            // ee_map_zoom_single
2777
-        $this->event_details_display_nav = true;            // ee_map_nav_display_single
2778
-        $this->event_details_nav_size = false;            // ee_map_nav_size_single
2779
-        $this->event_details_control_type = 'default';        // ee_map_type_control_single
2780
-        $this->event_details_map_align = 'center';            // ee_map_align_single
2781
-        // for event list pages
2782
-        $this->event_list_map_width = 300;            // ee_map_width
2783
-        $this->event_list_map_height = 185;        // ee_map_height
2784
-        $this->event_list_map_zoom = 12;            // ee_map_zoom
2785
-        $this->event_list_display_nav = false;        // ee_map_nav_display
2786
-        $this->event_list_nav_size = true;            // ee_map_nav_size
2787
-        $this->event_list_control_type = 'dropdown';        // ee_map_type_control
2788
-        $this->event_list_map_align = 'center';            // ee_map_align
2789
-    }
2682
+	/**
2683
+	 * @var boolean $use_google_maps
2684
+	 */
2685
+	public $use_google_maps;
2686
+
2687
+	/**
2688
+	 * @var string $api_key
2689
+	 */
2690
+	public $google_map_api_key;
2691
+
2692
+	/**
2693
+	 * @var int $event_details_map_width
2694
+	 */
2695
+	public $event_details_map_width;
2696
+
2697
+	/**
2698
+	 * @var int $event_details_map_height
2699
+	 */
2700
+	public $event_details_map_height;
2701
+
2702
+	/**
2703
+	 * @var int $event_details_map_zoom
2704
+	 */
2705
+	public $event_details_map_zoom;
2706
+
2707
+	/**
2708
+	 * @var boolean $event_details_display_nav
2709
+	 */
2710
+	public $event_details_display_nav;
2711
+
2712
+	/**
2713
+	 * @var boolean $event_details_nav_size
2714
+	 */
2715
+	public $event_details_nav_size;
2716
+
2717
+	/**
2718
+	 * @var string $event_details_control_type
2719
+	 */
2720
+	public $event_details_control_type;
2721
+
2722
+	/**
2723
+	 * @var string $event_details_map_align
2724
+	 */
2725
+	public $event_details_map_align;
2726
+
2727
+	/**
2728
+	 * @var int $event_list_map_width
2729
+	 */
2730
+	public $event_list_map_width;
2731
+
2732
+	/**
2733
+	 * @var int $event_list_map_height
2734
+	 */
2735
+	public $event_list_map_height;
2736
+
2737
+	/**
2738
+	 * @var int $event_list_map_zoom
2739
+	 */
2740
+	public $event_list_map_zoom;
2741
+
2742
+	/**
2743
+	 * @var boolean $event_list_display_nav
2744
+	 */
2745
+	public $event_list_display_nav;
2746
+
2747
+	/**
2748
+	 * @var boolean $event_list_nav_size
2749
+	 */
2750
+	public $event_list_nav_size;
2751
+
2752
+	/**
2753
+	 * @var string $event_list_control_type
2754
+	 */
2755
+	public $event_list_control_type;
2756
+
2757
+	/**
2758
+	 * @var string $event_list_map_align
2759
+	 */
2760
+	public $event_list_map_align;
2761
+
2762
+
2763
+	/**
2764
+	 *    class constructor
2765
+	 *
2766
+	 * @access    public
2767
+	 */
2768
+	public function __construct()
2769
+	{
2770
+		// set default map settings
2771
+		$this->use_google_maps = true;
2772
+		$this->google_map_api_key = '';
2773
+		// for event details pages (reg page)
2774
+		$this->event_details_map_width = 585;            // ee_map_width_single
2775
+		$this->event_details_map_height = 362;            // ee_map_height_single
2776
+		$this->event_details_map_zoom = 14;            // ee_map_zoom_single
2777
+		$this->event_details_display_nav = true;            // ee_map_nav_display_single
2778
+		$this->event_details_nav_size = false;            // ee_map_nav_size_single
2779
+		$this->event_details_control_type = 'default';        // ee_map_type_control_single
2780
+		$this->event_details_map_align = 'center';            // ee_map_align_single
2781
+		// for event list pages
2782
+		$this->event_list_map_width = 300;            // ee_map_width
2783
+		$this->event_list_map_height = 185;        // ee_map_height
2784
+		$this->event_list_map_zoom = 12;            // ee_map_zoom
2785
+		$this->event_list_display_nav = false;        // ee_map_nav_display
2786
+		$this->event_list_nav_size = true;            // ee_map_nav_size
2787
+		$this->event_list_control_type = 'dropdown';        // ee_map_type_control
2788
+		$this->event_list_map_align = 'center';            // ee_map_align
2789
+	}
2790 2790
 }
2791 2791
 
2792 2792
 
@@ -2796,46 +2796,46 @@  discard block
 block discarded – undo
2796 2796
 class EE_Events_Archive_Config extends EE_Config_Base
2797 2797
 {
2798 2798
 
2799
-    public $display_status_banner;
2799
+	public $display_status_banner;
2800 2800
 
2801
-    public $display_description;
2801
+	public $display_description;
2802 2802
 
2803
-    public $display_ticket_selector;
2803
+	public $display_ticket_selector;
2804 2804
 
2805
-    public $display_datetimes;
2805
+	public $display_datetimes;
2806 2806
 
2807
-    public $display_venue;
2807
+	public $display_venue;
2808 2808
 
2809
-    public $display_expired_events;
2809
+	public $display_expired_events;
2810 2810
 
2811
-    public $use_sortable_display_order;
2811
+	public $use_sortable_display_order;
2812 2812
 
2813
-    public $display_order_tickets;
2813
+	public $display_order_tickets;
2814 2814
 
2815
-    public $display_order_datetimes;
2815
+	public $display_order_datetimes;
2816 2816
 
2817
-    public $display_order_event;
2817
+	public $display_order_event;
2818 2818
 
2819
-    public $display_order_venue;
2819
+	public $display_order_venue;
2820 2820
 
2821 2821
 
2822
-    /**
2823
-     *    class constructor
2824
-     */
2825
-    public function __construct()
2826
-    {
2827
-        $this->display_status_banner = 0;
2828
-        $this->display_description = 1;
2829
-        $this->display_ticket_selector = 0;
2830
-        $this->display_datetimes = 1;
2831
-        $this->display_venue = 0;
2832
-        $this->display_expired_events = 0;
2833
-        $this->use_sortable_display_order = false;
2834
-        $this->display_order_tickets = 100;
2835
-        $this->display_order_datetimes = 110;
2836
-        $this->display_order_event = 120;
2837
-        $this->display_order_venue = 130;
2838
-    }
2822
+	/**
2823
+	 *    class constructor
2824
+	 */
2825
+	public function __construct()
2826
+	{
2827
+		$this->display_status_banner = 0;
2828
+		$this->display_description = 1;
2829
+		$this->display_ticket_selector = 0;
2830
+		$this->display_datetimes = 1;
2831
+		$this->display_venue = 0;
2832
+		$this->display_expired_events = 0;
2833
+		$this->use_sortable_display_order = false;
2834
+		$this->display_order_tickets = 100;
2835
+		$this->display_order_datetimes = 110;
2836
+		$this->display_order_event = 120;
2837
+		$this->display_order_venue = 130;
2838
+	}
2839 2839
 }
2840 2840
 
2841 2841
 
@@ -2845,34 +2845,34 @@  discard block
 block discarded – undo
2845 2845
 class EE_Event_Single_Config extends EE_Config_Base
2846 2846
 {
2847 2847
 
2848
-    public $display_status_banner_single;
2848
+	public $display_status_banner_single;
2849 2849
 
2850
-    public $display_venue;
2850
+	public $display_venue;
2851 2851
 
2852
-    public $use_sortable_display_order;
2852
+	public $use_sortable_display_order;
2853 2853
 
2854
-    public $display_order_tickets;
2854
+	public $display_order_tickets;
2855 2855
 
2856
-    public $display_order_datetimes;
2856
+	public $display_order_datetimes;
2857 2857
 
2858
-    public $display_order_event;
2858
+	public $display_order_event;
2859 2859
 
2860
-    public $display_order_venue;
2860
+	public $display_order_venue;
2861 2861
 
2862 2862
 
2863
-    /**
2864
-     *    class constructor
2865
-     */
2866
-    public function __construct()
2867
-    {
2868
-        $this->display_status_banner_single = 0;
2869
-        $this->display_venue = 1;
2870
-        $this->use_sortable_display_order = false;
2871
-        $this->display_order_tickets = 100;
2872
-        $this->display_order_datetimes = 110;
2873
-        $this->display_order_event = 120;
2874
-        $this->display_order_venue = 130;
2875
-    }
2863
+	/**
2864
+	 *    class constructor
2865
+	 */
2866
+	public function __construct()
2867
+	{
2868
+		$this->display_status_banner_single = 0;
2869
+		$this->display_venue = 1;
2870
+		$this->use_sortable_display_order = false;
2871
+		$this->display_order_tickets = 100;
2872
+		$this->display_order_datetimes = 110;
2873
+		$this->display_order_event = 120;
2874
+		$this->display_order_venue = 130;
2875
+	}
2876 2876
 }
2877 2877
 
2878 2878
 
@@ -2882,146 +2882,146 @@  discard block
 block discarded – undo
2882 2882
 class EE_Ticket_Selector_Config extends EE_Config_Base
2883 2883
 {
2884 2884
 
2885
-    /**
2886
-     * constant to indicate that a datetime selector should NEVER be shown for ticket selectors
2887
-     */
2888
-    const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector';
2889
-
2890
-    /**
2891
-     * constant to indicate that a datetime selector should only be shown for ticket selectors
2892
-     * when the number of datetimes for the event matches the value set for $datetime_selector_threshold
2893
-     */
2894
-    const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector';
2895
-
2896
-    /**
2897
-     * @var boolean $show_ticket_sale_columns
2898
-     */
2899
-    public $show_ticket_sale_columns;
2900
-
2901
-    /**
2902
-     * @var boolean $show_ticket_details
2903
-     */
2904
-    public $show_ticket_details;
2905
-
2906
-    /**
2907
-     * @var boolean $show_expired_tickets
2908
-     */
2909
-    public $show_expired_tickets;
2910
-
2911
-    /**
2912
-     * whether or not to display a dropdown box populated with event datetimes
2913
-     * that toggles which tickets are displayed for a ticket selector.
2914
-     * uses one of the *_DATETIME_SELECTOR constants defined above
2915
-     *
2916
-     * @var string $show_datetime_selector
2917
-     */
2918
-    private $show_datetime_selector = 'no_datetime_selector';
2919
-
2920
-    /**
2921
-     * the number of datetimes an event has to have before conditionally displaying a datetime selector
2922
-     *
2923
-     * @var int $datetime_selector_threshold
2924
-     */
2925
-    private $datetime_selector_threshold = 3;
2926
-
2927
-
2928
-    /**
2929
-     *    class constructor
2930
-     */
2931
-    public function __construct()
2932
-    {
2933
-        $this->show_ticket_sale_columns = true;
2934
-        $this->show_ticket_details = true;
2935
-        $this->show_expired_tickets = true;
2936
-        $this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
2937
-        $this->datetime_selector_threshold = 3;
2938
-    }
2939
-
2940
-
2941
-    /**
2942
-     * returns true if a datetime selector should be displayed
2943
-     *
2944
-     * @param array $datetimes
2945
-     * @return bool
2946
-     */
2947
-    public function showDatetimeSelector(array $datetimes)
2948
-    {
2949
-        // if the settings are NOT: don't show OR below threshold, THEN active = true
2950
-        return ! (
2951
-            $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
2952
-            || (
2953
-                $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR
2954
-                && count($datetimes) < $this->getDatetimeSelectorThreshold()
2955
-            )
2956
-        );
2957
-    }
2958
-
2959
-
2960
-    /**
2961
-     * @return string
2962
-     */
2963
-    public function getShowDatetimeSelector()
2964
-    {
2965
-        return $this->show_datetime_selector;
2966
-    }
2967
-
2968
-
2969
-    /**
2970
-     * @param bool $keys_only
2971
-     * @return array
2972
-     */
2973
-    public function getShowDatetimeSelectorOptions($keys_only = true)
2974
-    {
2975
-        return $keys_only
2976
-            ? array(
2977
-                \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
2978
-                \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
2979
-            )
2980
-            : array(
2981
-                \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__(
2982
-                    'Do not show date & time filter',
2983
-                    'event_espresso'
2984
-                ),
2985
-                \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR  => esc_html__(
2986
-                    'Maybe show date & time filter',
2987
-                    'event_espresso'
2988
-                ),
2989
-            );
2990
-    }
2991
-
2992
-
2993
-    /**
2994
-     * @param string $show_datetime_selector
2995
-     */
2996
-    public function setShowDatetimeSelector($show_datetime_selector)
2997
-    {
2998
-        $this->show_datetime_selector = in_array(
2999
-            $show_datetime_selector,
3000
-            $this->getShowDatetimeSelectorOptions(),
3001
-            true
3002
-        )
3003
-            ? $show_datetime_selector
3004
-            : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3005
-    }
3006
-
3007
-
3008
-    /**
3009
-     * @return int
3010
-     */
3011
-    public function getDatetimeSelectorThreshold()
3012
-    {
3013
-        return $this->datetime_selector_threshold;
3014
-    }
3015
-
3016
-
3017
-    /**
3018
-     * @param int $datetime_selector_threshold
3019
-     */
3020
-    public function setDatetimeSelectorThreshold($datetime_selector_threshold)
3021
-    {
3022
-        $datetime_selector_threshold = absint($datetime_selector_threshold);
3023
-        $this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3;
3024
-    }
2885
+	/**
2886
+	 * constant to indicate that a datetime selector should NEVER be shown for ticket selectors
2887
+	 */
2888
+	const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector';
2889
+
2890
+	/**
2891
+	 * constant to indicate that a datetime selector should only be shown for ticket selectors
2892
+	 * when the number of datetimes for the event matches the value set for $datetime_selector_threshold
2893
+	 */
2894
+	const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector';
2895
+
2896
+	/**
2897
+	 * @var boolean $show_ticket_sale_columns
2898
+	 */
2899
+	public $show_ticket_sale_columns;
2900
+
2901
+	/**
2902
+	 * @var boolean $show_ticket_details
2903
+	 */
2904
+	public $show_ticket_details;
2905
+
2906
+	/**
2907
+	 * @var boolean $show_expired_tickets
2908
+	 */
2909
+	public $show_expired_tickets;
2910
+
2911
+	/**
2912
+	 * whether or not to display a dropdown box populated with event datetimes
2913
+	 * that toggles which tickets are displayed for a ticket selector.
2914
+	 * uses one of the *_DATETIME_SELECTOR constants defined above
2915
+	 *
2916
+	 * @var string $show_datetime_selector
2917
+	 */
2918
+	private $show_datetime_selector = 'no_datetime_selector';
2919
+
2920
+	/**
2921
+	 * the number of datetimes an event has to have before conditionally displaying a datetime selector
2922
+	 *
2923
+	 * @var int $datetime_selector_threshold
2924
+	 */
2925
+	private $datetime_selector_threshold = 3;
2926
+
2927
+
2928
+	/**
2929
+	 *    class constructor
2930
+	 */
2931
+	public function __construct()
2932
+	{
2933
+		$this->show_ticket_sale_columns = true;
2934
+		$this->show_ticket_details = true;
2935
+		$this->show_expired_tickets = true;
2936
+		$this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
2937
+		$this->datetime_selector_threshold = 3;
2938
+	}
2939
+
2940
+
2941
+	/**
2942
+	 * returns true if a datetime selector should be displayed
2943
+	 *
2944
+	 * @param array $datetimes
2945
+	 * @return bool
2946
+	 */
2947
+	public function showDatetimeSelector(array $datetimes)
2948
+	{
2949
+		// if the settings are NOT: don't show OR below threshold, THEN active = true
2950
+		return ! (
2951
+			$this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
2952
+			|| (
2953
+				$this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR
2954
+				&& count($datetimes) < $this->getDatetimeSelectorThreshold()
2955
+			)
2956
+		);
2957
+	}
2958
+
2959
+
2960
+	/**
2961
+	 * @return string
2962
+	 */
2963
+	public function getShowDatetimeSelector()
2964
+	{
2965
+		return $this->show_datetime_selector;
2966
+	}
2967
+
2968
+
2969
+	/**
2970
+	 * @param bool $keys_only
2971
+	 * @return array
2972
+	 */
2973
+	public function getShowDatetimeSelectorOptions($keys_only = true)
2974
+	{
2975
+		return $keys_only
2976
+			? array(
2977
+				\EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
2978
+				\EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
2979
+			)
2980
+			: array(
2981
+				\EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__(
2982
+					'Do not show date & time filter',
2983
+					'event_espresso'
2984
+				),
2985
+				\EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR  => esc_html__(
2986
+					'Maybe show date & time filter',
2987
+					'event_espresso'
2988
+				),
2989
+			);
2990
+	}
2991
+
2992
+
2993
+	/**
2994
+	 * @param string $show_datetime_selector
2995
+	 */
2996
+	public function setShowDatetimeSelector($show_datetime_selector)
2997
+	{
2998
+		$this->show_datetime_selector = in_array(
2999
+			$show_datetime_selector,
3000
+			$this->getShowDatetimeSelectorOptions(),
3001
+			true
3002
+		)
3003
+			? $show_datetime_selector
3004
+			: \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3005
+	}
3006
+
3007
+
3008
+	/**
3009
+	 * @return int
3010
+	 */
3011
+	public function getDatetimeSelectorThreshold()
3012
+	{
3013
+		return $this->datetime_selector_threshold;
3014
+	}
3015
+
3016
+
3017
+	/**
3018
+	 * @param int $datetime_selector_threshold
3019
+	 */
3020
+	public function setDatetimeSelectorThreshold($datetime_selector_threshold)
3021
+	{
3022
+		$datetime_selector_threshold = absint($datetime_selector_threshold);
3023
+		$this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3;
3024
+	}
3025 3025
 }
3026 3026
 
3027 3027
 
@@ -3035,81 +3035,81 @@  discard block
 block discarded – undo
3035 3035
 class EE_Environment_Config extends EE_Config_Base
3036 3036
 {
3037 3037
 
3038
-    /**
3039
-     * Hold any php environment variables that we want to track.
3040
-     *
3041
-     * @var stdClass;
3042
-     */
3043
-    public $php;
3044
-
3045
-
3046
-    /**
3047
-     *    constructor
3048
-     */
3049
-    public function __construct()
3050
-    {
3051
-        $this->php = new stdClass();
3052
-        $this->_set_php_values();
3053
-    }
3054
-
3055
-
3056
-    /**
3057
-     * This sets the php environment variables.
3058
-     *
3059
-     * @since 4.4.0
3060
-     * @return void
3061
-     */
3062
-    protected function _set_php_values()
3063
-    {
3064
-        $this->php->max_input_vars = ini_get('max_input_vars');
3065
-        $this->php->version = phpversion();
3066
-    }
3067
-
3068
-
3069
-    /**
3070
-     * helper method for determining whether input_count is
3071
-     * reaching the potential maximum the server can handle
3072
-     * according to max_input_vars
3073
-     *
3074
-     * @param int   $input_count the count of input vars.
3075
-     * @return array {
3076
-     *                           An array that represents whether available space and if no available space the error
3077
-     *                           message.
3078
-     * @type bool   $has_space   whether more inputs can be added.
3079
-     * @type string $msg         Any message to be displayed.
3080
-     *                           }
3081
-     */
3082
-    public function max_input_vars_limit_check($input_count = 0)
3083
-    {
3084
-        if (! empty($this->php->max_input_vars)
3085
-            && ($input_count >= $this->php->max_input_vars)
3086
-            && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9)
3087
-        ) {
3088
-            return sprintf(
3089
-                __(
3090
-                    'The maximum number of inputs on this page has been exceeded.  You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.',
3091
-                    'event_espresso'
3092
-                ),
3093
-                '<br>',
3094
-                $input_count,
3095
-                $this->php->max_input_vars
3096
-            );
3097
-        } else {
3098
-            return '';
3099
-        }
3100
-    }
3101
-
3102
-
3103
-    /**
3104
-     * The purpose of this method is just to force rechecking php values so if they've changed, they get updated.
3105
-     *
3106
-     * @since 4.4.1
3107
-     * @return void
3108
-     */
3109
-    public function recheck_values()
3110
-    {
3111
-        $this->_set_php_values();
3112
-    }
3038
+	/**
3039
+	 * Hold any php environment variables that we want to track.
3040
+	 *
3041
+	 * @var stdClass;
3042
+	 */
3043
+	public $php;
3044
+
3045
+
3046
+	/**
3047
+	 *    constructor
3048
+	 */
3049
+	public function __construct()
3050
+	{
3051
+		$this->php = new stdClass();
3052
+		$this->_set_php_values();
3053
+	}
3054
+
3055
+
3056
+	/**
3057
+	 * This sets the php environment variables.
3058
+	 *
3059
+	 * @since 4.4.0
3060
+	 * @return void
3061
+	 */
3062
+	protected function _set_php_values()
3063
+	{
3064
+		$this->php->max_input_vars = ini_get('max_input_vars');
3065
+		$this->php->version = phpversion();
3066
+	}
3067
+
3068
+
3069
+	/**
3070
+	 * helper method for determining whether input_count is
3071
+	 * reaching the potential maximum the server can handle
3072
+	 * according to max_input_vars
3073
+	 *
3074
+	 * @param int   $input_count the count of input vars.
3075
+	 * @return array {
3076
+	 *                           An array that represents whether available space and if no available space the error
3077
+	 *                           message.
3078
+	 * @type bool   $has_space   whether more inputs can be added.
3079
+	 * @type string $msg         Any message to be displayed.
3080
+	 *                           }
3081
+	 */
3082
+	public function max_input_vars_limit_check($input_count = 0)
3083
+	{
3084
+		if (! empty($this->php->max_input_vars)
3085
+			&& ($input_count >= $this->php->max_input_vars)
3086
+			&& (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9)
3087
+		) {
3088
+			return sprintf(
3089
+				__(
3090
+					'The maximum number of inputs on this page has been exceeded.  You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.',
3091
+					'event_espresso'
3092
+				),
3093
+				'<br>',
3094
+				$input_count,
3095
+				$this->php->max_input_vars
3096
+			);
3097
+		} else {
3098
+			return '';
3099
+		}
3100
+	}
3101
+
3102
+
3103
+	/**
3104
+	 * The purpose of this method is just to force rechecking php values so if they've changed, they get updated.
3105
+	 *
3106
+	 * @since 4.4.1
3107
+	 * @return void
3108
+	 */
3109
+	public function recheck_values()
3110
+	{
3111
+		$this->_set_php_values();
3112
+	}
3113 3113
 }
3114 3114
 
3115 3115
 
@@ -3123,21 +3123,21 @@  discard block
 block discarded – undo
3123 3123
 class EE_Tax_Config extends EE_Config_Base
3124 3124
 {
3125 3125
 
3126
-    /*
3126
+	/*
3127 3127
      * flag to indicate whether or not to display ticket prices with the taxes included
3128 3128
      *
3129 3129
      * @var boolean $prices_displayed_including_taxes
3130 3130
      */
3131
-    public $prices_displayed_including_taxes;
3131
+	public $prices_displayed_including_taxes;
3132 3132
 
3133 3133
 
3134
-    /**
3135
-     *    class constructor
3136
-     */
3137
-    public function __construct()
3138
-    {
3139
-        $this->prices_displayed_including_taxes = true;
3140
-    }
3134
+	/**
3135
+	 *    class constructor
3136
+	 */
3137
+	public function __construct()
3138
+	{
3139
+		$this->prices_displayed_including_taxes = true;
3140
+	}
3141 3141
 }
3142 3142
 
3143 3143
 
@@ -3152,18 +3152,18 @@  discard block
 block discarded – undo
3152 3152
 class EE_Messages_Config extends EE_Config_Base
3153 3153
 {
3154 3154
 
3155
-    /**
3156
-     * This is an integer representing the deletion threshold in months for when old messages will get deleted.
3157
-     * A value of 0 represents never deleting.  Default is 0.
3158
-     *
3159
-     * @var integer
3160
-     */
3161
-    public $delete_threshold;
3162
-
3163
-    public function __construct()
3164
-    {
3165
-        $this->delete_threshold = 0;
3166
-    }
3155
+	/**
3156
+	 * This is an integer representing the deletion threshold in months for when old messages will get deleted.
3157
+	 * A value of 0 represents never deleting.  Default is 0.
3158
+	 *
3159
+	 * @var integer
3160
+	 */
3161
+	public $delete_threshold;
3162
+
3163
+	public function __construct()
3164
+	{
3165
+		$this->delete_threshold = 0;
3166
+	}
3167 3167
 }
3168 3168
 
3169 3169
 
@@ -3175,31 +3175,31 @@  discard block
 block discarded – undo
3175 3175
 class EE_Gateway_Config extends EE_Config_Base
3176 3176
 {
3177 3177
 
3178
-    /**
3179
-     * Array with keys that are payment gateways slugs, and values are arrays
3180
-     * with any config info the gateway wants to store
3181
-     *
3182
-     * @var array
3183
-     */
3184
-    public $payment_settings;
3185
-
3186
-    /**
3187
-     * Where keys are gateway slugs, and values are booleans indicating whether or not
3188
-     * the gateway is stored in the uploads directory
3189
-     *
3190
-     * @var array
3191
-     */
3192
-    public $active_gateways;
3193
-
3194
-
3195
-    /**
3196
-     *    class constructor
3197
-     *
3198
-     * @deprecated
3199
-     */
3200
-    public function __construct()
3201
-    {
3202
-        $this->payment_settings = array();
3203
-        $this->active_gateways = array('Invoice' => false);
3204
-    }
3178
+	/**
3179
+	 * Array with keys that are payment gateways slugs, and values are arrays
3180
+	 * with any config info the gateway wants to store
3181
+	 *
3182
+	 * @var array
3183
+	 */
3184
+	public $payment_settings;
3185
+
3186
+	/**
3187
+	 * Where keys are gateway slugs, and values are booleans indicating whether or not
3188
+	 * the gateway is stored in the uploads directory
3189
+	 *
3190
+	 * @var array
3191
+	 */
3192
+	public $active_gateways;
3193
+
3194
+
3195
+	/**
3196
+	 *    class constructor
3197
+	 *
3198
+	 * @deprecated
3199
+	 */
3200
+	public function __construct()
3201
+	{
3202
+		$this->payment_settings = array();
3203
+		$this->active_gateways = array('Invoice' => false);
3204
+	}
3205 3205
 }
Please login to merge, or discard this patch.
admin_pages/registrations/EE_Attendee_Contact_List_Table.class.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
      * ATT_address column
304 304
      *
305 305
      * @param EE_Attendee $attendee
306
-     * @return mixed
306
+     * @return string
307 307
      * @throws EE_Error
308 308
      */
309 309
     public function column_ATT_address(EE_Attendee $attendee)
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
      * ATT_city column
317 317
      *
318 318
      * @param EE_Attendee $attendee
319
-     * @return mixed
319
+     * @return string
320 320
      * @throws EE_Error
321 321
      */
322 322
     public function column_ATT_city(EE_Attendee $attendee)
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
      * Phone Number column
370 370
      *
371 371
      * @param EE_Attendee $attendee
372
-     * @return mixed
372
+     * @return string
373 373
      * @throws EE_Error
374 374
      */
375 375
     public function column_ATT_phone(EE_Attendee $attendee)
Please login to merge, or discard this patch.
Indentation   +370 added lines, -370 removed lines patch added patch discarded remove patch
@@ -12,374 +12,374 @@
 block discarded – undo
12 12
  */
13 13
 class EE_Attendee_Contact_List_Table extends EE_Admin_List_Table
14 14
 {
15
-    /**
16
-     * Initial setup of data (called by parent).
17
-     */
18
-    protected function _setup_data()
19
-    {
20
-        $this->_data = $this->_view !== 'trash'
21
-            ? $this->_admin_page->get_attendees($this->_per_page)
22
-            : $this->_admin_page->get_attendees($this->_per_page, false, true);
23
-        $this->_all_data_count = $this->_view !== 'trash'
24
-            ? $this->_admin_page->get_attendees($this->_per_page, true)
25
-            : $this->_admin_page->get_attendees($this->_per_page, true, true);
26
-    }
27
-
28
-
29
-    /**
30
-     * Initial setup of properties.
31
-     */
32
-    protected function _set_properties()
33
-    {
34
-        $this->_wp_list_args = array(
35
-            'singular' => esc_html__('attendee', 'event_espresso'),
36
-            'plural'   => esc_html__('attendees', 'event_espresso'),
37
-            'ajax'     => true,
38
-            'screen'   => $this->_admin_page->get_current_screen()->id,
39
-        );
40
-
41
-        $this->_columns = array(
42
-            'cb'                 => '<input type="checkbox" />', // Render a checkbox instead of text
43
-            'ATT_ID'             => esc_html__('ID', 'event_espresso'),
44
-            'ATT_fname'          => esc_html__('First Name', 'event_espresso'),
45
-            'ATT_lname'          => esc_html__('Last Name', 'event_espresso'),
46
-            'ATT_email'          => esc_html__('Email Address', 'event_espresso'),
47
-            'Registration_Count' => esc_html__('# Registrations', 'event_espresso'),
48
-            'ATT_phone'          => esc_html__('Phone', 'event_espresso'),
49
-            'ATT_address'        => esc_html__('Address', 'event_espresso'),
50
-            'ATT_city'           => esc_html__('City', 'event_espresso'),
51
-            'STA_ID'             => esc_html__('State/Province', 'event_espresso'),
52
-            'CNT_ISO'            => esc_html__('Country', 'event_espresso'),
53
-        );
54
-
55
-        $this->_sortable_columns = array(
56
-            'ATT_ID'             => array('ATT_ID' => false),
57
-            'ATT_lname'          => array('ATT_lname' => true), // true means its already sorted
58
-            'ATT_fname'          => array('ATT_fname' => false),
59
-            'ATT_email'          => array('ATT_email' => false),
60
-            'Registration_Count' => array('Registration_Count' => false),
61
-            'ATT_city'           => array('ATT_city' => false),
62
-            'STA_ID'             => array('STA_ID' => false),
63
-            'CNT_ISO'            => array('CNT_ISO' => false),
64
-        );
65
-
66
-        $this->_hidden_columns = array(
67
-            'ATT_phone',
68
-            'ATT_address',
69
-            'ATT_city',
70
-            'STA_ID',
71
-            'CNT_ISO',
72
-        );
73
-    }
74
-
75
-
76
-    /**
77
-     * Initial setup of filters
78
-     *
79
-     * @return array
80
-     */
81
-    protected function _get_table_filters()
82
-    {
83
-        return array();
84
-    }
85
-
86
-
87
-    /**
88
-     * Initial setup of counts for views
89
-     *
90
-     * @throws InvalidArgumentException
91
-     * @throws InvalidDataTypeException
92
-     * @throws InvalidInterfaceException
93
-     */
94
-    protected function _add_view_counts()
95
-    {
96
-        $this->_views['in_use']['count'] = $this->_admin_page->get_attendees($this->_per_page, true);
97
-        if (EE_Registry::instance()->CAP->current_user_can(
98
-            'ee_delete_contacts',
99
-            'espresso_registrations_delete_registration'
100
-        )) {
101
-            $this->_views['trash']['count'] = $this->_admin_page->get_attendees($this->_per_page, true, true);
102
-        }
103
-    }
104
-
105
-
106
-    /**
107
-     * Get count of attendees.
108
-     *
109
-     * @return int
110
-     * @throws EE_Error
111
-     * @throws InvalidArgumentException
112
-     * @throws InvalidDataTypeException
113
-     * @throws InvalidInterfaceException
114
-     */
115
-    protected function _get_attendees_count()
116
-    {
117
-        return EEM_Attendee::instance()->count();
118
-    }
119
-
120
-
121
-    /**
122
-     * Checkbox column
123
-     *
124
-     * @param EE_Attendee $attendee Unable to typehint this method because overrides parent.
125
-     * @return string
126
-     * @throws EE_Error
127
-     */
128
-    public function column_cb($attendee)
129
-    {
130
-        if (! $attendee instanceof EE_Attendee) {
131
-            return '';
132
-        }
133
-        return sprintf(
134
-            '<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />',
135
-            $attendee->ID()
136
-        );
137
-    }
138
-
139
-
140
-    /**
141
-     * ATT_ID column
142
-     *
143
-     * @param EE_Attendee $attendee
144
-     * @return string
145
-     * @throws EE_Error
146
-     */
147
-    public function column_ATT_ID(EE_Attendee $attendee)
148
-    {
149
-        $content = $attendee->ID();
150
-        $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
151
-        $content .= '  <span class="show-on-mobile-view-only">' . $attendee_name . '</span>';
152
-        return $content;
153
-    }
154
-
155
-
156
-    /**
157
-     * ATT_lname column
158
-     *
159
-     * @param EE_Attendee $attendee
160
-     * @return string
161
-     * @throws InvalidArgumentException
162
-     * @throws InvalidDataTypeException
163
-     * @throws InvalidInterfaceException
164
-     * @throws EE_Error
165
-     */
166
-    public function column_ATT_lname(EE_Attendee $attendee)
167
-    {
168
-        // edit attendee link
169
-        $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
170
-            array(
171
-                'action' => 'edit_attendee',
172
-                'post'   => $attendee->ID(),
173
-            ),
174
-            REG_ADMIN_URL
175
-        );
176
-        $name_link = EE_Registry::instance()->CAP->current_user_can(
177
-            'ee_edit_contacts',
178
-            'espresso_registrations_edit_attendee'
179
-        )
180
-            ? '<a href="' . $edit_lnk_url . '" title="'
181
-              . esc_attr__('Edit Contact', 'event_espresso') . '">'
182
-              . $attendee->lname() . '</a>'
183
-            : $attendee->lname();
184
-        return $name_link;
185
-    }
186
-
187
-
188
-    /**
189
-     * ATT_fname column
190
-     *
191
-     * @param EE_Attendee $attendee
192
-     * @return string
193
-     * @throws InvalidArgumentException
194
-     * @throws InvalidDataTypeException
195
-     * @throws InvalidInterfaceException
196
-     * @throws EE_Error
197
-     */
198
-    public function column_ATT_fname(EE_Attendee $attendee)
199
-    {
200
-        // Build row actions
201
-        $actions = array();
202
-        // edit attendee link
203
-        if (EE_Registry::instance()->CAP->current_user_can(
204
-            'ee_edit_contacts',
205
-            'espresso_registrations_edit_attendee'
206
-        )) {
207
-            $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
208
-                array(
209
-                    'action' => 'edit_attendee',
210
-                    'post'   => $attendee->ID(),
211
-                ),
212
-                REG_ADMIN_URL
213
-            );
214
-            $actions['edit'] = '<a href="' . $edit_lnk_url . '" title="'
215
-                               . esc_attr__('Edit Contact', 'event_espresso') . '">'
216
-                               . esc_html__('Edit', 'event_espresso') . '</a>';
217
-        }
218
-
219
-        if ($this->_view === 'in_use') {
220
-            // trash attendee link
221
-            if (EE_Registry::instance()->CAP->current_user_can(
222
-                'ee_delete_contacts',
223
-                'espresso_registrations_trash_attendees'
224
-            )) {
225
-                $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
226
-                    array(
227
-                        'action' => 'trash_attendee',
228
-                        'ATT_ID' => $attendee->ID(),
229
-                    ),
230
-                    REG_ADMIN_URL
231
-                );
232
-                $actions['trash'] = '<a href="' . $trash_lnk_url . '" title="'
233
-                                    . esc_attr__('Move Contact to Trash', 'event_espresso')
234
-                                    . '">' . esc_html__('Trash', 'event_espresso') . '</a>';
235
-            }
236
-        } else {
237
-            if (EE_Registry::instance()->CAP->current_user_can(
238
-                'ee_delete_contacts',
239
-                'espresso_registrations_restore_attendees'
240
-            )) {
241
-                // restore attendee link
242
-                $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
243
-                    array(
244
-                        'action' => 'restore_attendees',
245
-                        'ATT_ID' => $attendee->ID(),
246
-                    ),
247
-                    REG_ADMIN_URL
248
-                );
249
-                $actions['restore'] = '<a href="' . $restore_lnk_url . '" title="'
250
-                                      . esc_attr__('Restore Contact', 'event_espresso') . '">'
251
-                                      . esc_html__('Restore', 'event_espresso') . '</a>';
252
-            }
253
-        }
254
-
255
-        $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
256
-            array(
257
-                'action' => 'edit_attendee',
258
-                'post'   => $attendee->ID(),
259
-            ),
260
-            REG_ADMIN_URL
261
-        );
262
-        $name_link = EE_Registry::instance()->CAP->current_user_can(
263
-            'ee_edit_contacts',
264
-            'espresso_registrations_edit_attendee'
265
-        )
266
-            ? '<a href="' . $edit_lnk_url . '" title="'
267
-              . esc_attr__('Edit Contact', 'event_espresso') . '">' . $attendee->fname() . '</a>'
268
-            : $attendee->fname();
269
-
270
-        // Return the name contents
271
-        return sprintf('%1$s %2$s', $name_link, $this->row_actions($actions));
272
-    }
273
-
274
-
275
-    /**
276
-     * Email Column
277
-     *
278
-     * @param EE_Attendee $attendee
279
-     * @return string
280
-     * @throws EE_Error
281
-     */
282
-    public function column_ATT_email(EE_Attendee $attendee)
283
-    {
284
-        return '<a href="mailto:' . $attendee->email() . '">' . $attendee->email() . '</a>';
285
-    }
286
-
287
-
288
-    /**
289
-     * Column displaying count of registrations attached to Attendee.
290
-     *
291
-     * @param EE_Attendee $attendee
292
-     * @return string
293
-     * @throws EE_Error
294
-     */
295
-    public function column_Registration_Count(EE_Attendee $attendee)
296
-    {
297
-        $link = EEH_URL::add_query_args_and_nonce(
298
-            array(
299
-                'action' => 'default',
300
-                'ATT_ID' => $attendee->ID(),
301
-            ),
302
-            REG_ADMIN_URL
303
-        );
304
-        return '<a href="' . $link . '">' . $attendee->getCustomSelect('Registration_Count') . '</a>';
305
-    }
306
-
307
-
308
-    /**
309
-     * ATT_address column
310
-     *
311
-     * @param EE_Attendee $attendee
312
-     * @return mixed
313
-     * @throws EE_Error
314
-     */
315
-    public function column_ATT_address(EE_Attendee $attendee)
316
-    {
317
-        return $attendee->address();
318
-    }
319
-
320
-
321
-    /**
322
-     * ATT_city column
323
-     *
324
-     * @param EE_Attendee $attendee
325
-     * @return mixed
326
-     * @throws EE_Error
327
-     */
328
-    public function column_ATT_city(EE_Attendee $attendee)
329
-    {
330
-        return $attendee->city();
331
-    }
332
-
333
-
334
-    /**
335
-     * State Column
336
-     *
337
-     * @param EE_Attendee $attendee
338
-     * @return string
339
-     * @throws EE_Error
340
-     * @throws InvalidArgumentException
341
-     * @throws InvalidDataTypeException
342
-     * @throws InvalidInterfaceException
343
-     */
344
-    public function column_STA_ID(EE_Attendee $attendee)
345
-    {
346
-        $states = EEM_State::instance()->get_all_states();
347
-        $state = isset($states[ $attendee->state_ID() ])
348
-            ? $states[ $attendee->state_ID() ]->get('STA_name')
349
-            : $attendee->state_ID();
350
-        return ! is_numeric($state) ? $state : '';
351
-    }
352
-
353
-
354
-    /**
355
-     * Country Column
356
-     *
357
-     * @param EE_Attendee $attendee
358
-     * @return string
359
-     * @throws EE_Error
360
-     * @throws InvalidArgumentException
361
-     * @throws InvalidDataTypeException
362
-     * @throws InvalidInterfaceException
363
-     */
364
-    public function column_CNT_ISO(EE_Attendee $attendee)
365
-    {
366
-        $countries = EEM_Country::instance()->get_all_countries();
367
-        $country = isset($countries[ $attendee->country_ID() ])
368
-            ? $countries[ $attendee->country_ID() ]->get('CNT_name')
369
-            : $attendee->country_ID();
370
-        return ! is_numeric($country) ? $country : '';
371
-    }
372
-
373
-
374
-    /**
375
-     * Phone Number column
376
-     *
377
-     * @param EE_Attendee $attendee
378
-     * @return mixed
379
-     * @throws EE_Error
380
-     */
381
-    public function column_ATT_phone(EE_Attendee $attendee)
382
-    {
383
-        return $attendee->phone();
384
-    }
15
+	/**
16
+	 * Initial setup of data (called by parent).
17
+	 */
18
+	protected function _setup_data()
19
+	{
20
+		$this->_data = $this->_view !== 'trash'
21
+			? $this->_admin_page->get_attendees($this->_per_page)
22
+			: $this->_admin_page->get_attendees($this->_per_page, false, true);
23
+		$this->_all_data_count = $this->_view !== 'trash'
24
+			? $this->_admin_page->get_attendees($this->_per_page, true)
25
+			: $this->_admin_page->get_attendees($this->_per_page, true, true);
26
+	}
27
+
28
+
29
+	/**
30
+	 * Initial setup of properties.
31
+	 */
32
+	protected function _set_properties()
33
+	{
34
+		$this->_wp_list_args = array(
35
+			'singular' => esc_html__('attendee', 'event_espresso'),
36
+			'plural'   => esc_html__('attendees', 'event_espresso'),
37
+			'ajax'     => true,
38
+			'screen'   => $this->_admin_page->get_current_screen()->id,
39
+		);
40
+
41
+		$this->_columns = array(
42
+			'cb'                 => '<input type="checkbox" />', // Render a checkbox instead of text
43
+			'ATT_ID'             => esc_html__('ID', 'event_espresso'),
44
+			'ATT_fname'          => esc_html__('First Name', 'event_espresso'),
45
+			'ATT_lname'          => esc_html__('Last Name', 'event_espresso'),
46
+			'ATT_email'          => esc_html__('Email Address', 'event_espresso'),
47
+			'Registration_Count' => esc_html__('# Registrations', 'event_espresso'),
48
+			'ATT_phone'          => esc_html__('Phone', 'event_espresso'),
49
+			'ATT_address'        => esc_html__('Address', 'event_espresso'),
50
+			'ATT_city'           => esc_html__('City', 'event_espresso'),
51
+			'STA_ID'             => esc_html__('State/Province', 'event_espresso'),
52
+			'CNT_ISO'            => esc_html__('Country', 'event_espresso'),
53
+		);
54
+
55
+		$this->_sortable_columns = array(
56
+			'ATT_ID'             => array('ATT_ID' => false),
57
+			'ATT_lname'          => array('ATT_lname' => true), // true means its already sorted
58
+			'ATT_fname'          => array('ATT_fname' => false),
59
+			'ATT_email'          => array('ATT_email' => false),
60
+			'Registration_Count' => array('Registration_Count' => false),
61
+			'ATT_city'           => array('ATT_city' => false),
62
+			'STA_ID'             => array('STA_ID' => false),
63
+			'CNT_ISO'            => array('CNT_ISO' => false),
64
+		);
65
+
66
+		$this->_hidden_columns = array(
67
+			'ATT_phone',
68
+			'ATT_address',
69
+			'ATT_city',
70
+			'STA_ID',
71
+			'CNT_ISO',
72
+		);
73
+	}
74
+
75
+
76
+	/**
77
+	 * Initial setup of filters
78
+	 *
79
+	 * @return array
80
+	 */
81
+	protected function _get_table_filters()
82
+	{
83
+		return array();
84
+	}
85
+
86
+
87
+	/**
88
+	 * Initial setup of counts for views
89
+	 *
90
+	 * @throws InvalidArgumentException
91
+	 * @throws InvalidDataTypeException
92
+	 * @throws InvalidInterfaceException
93
+	 */
94
+	protected function _add_view_counts()
95
+	{
96
+		$this->_views['in_use']['count'] = $this->_admin_page->get_attendees($this->_per_page, true);
97
+		if (EE_Registry::instance()->CAP->current_user_can(
98
+			'ee_delete_contacts',
99
+			'espresso_registrations_delete_registration'
100
+		)) {
101
+			$this->_views['trash']['count'] = $this->_admin_page->get_attendees($this->_per_page, true, true);
102
+		}
103
+	}
104
+
105
+
106
+	/**
107
+	 * Get count of attendees.
108
+	 *
109
+	 * @return int
110
+	 * @throws EE_Error
111
+	 * @throws InvalidArgumentException
112
+	 * @throws InvalidDataTypeException
113
+	 * @throws InvalidInterfaceException
114
+	 */
115
+	protected function _get_attendees_count()
116
+	{
117
+		return EEM_Attendee::instance()->count();
118
+	}
119
+
120
+
121
+	/**
122
+	 * Checkbox column
123
+	 *
124
+	 * @param EE_Attendee $attendee Unable to typehint this method because overrides parent.
125
+	 * @return string
126
+	 * @throws EE_Error
127
+	 */
128
+	public function column_cb($attendee)
129
+	{
130
+		if (! $attendee instanceof EE_Attendee) {
131
+			return '';
132
+		}
133
+		return sprintf(
134
+			'<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />',
135
+			$attendee->ID()
136
+		);
137
+	}
138
+
139
+
140
+	/**
141
+	 * ATT_ID column
142
+	 *
143
+	 * @param EE_Attendee $attendee
144
+	 * @return string
145
+	 * @throws EE_Error
146
+	 */
147
+	public function column_ATT_ID(EE_Attendee $attendee)
148
+	{
149
+		$content = $attendee->ID();
150
+		$attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
151
+		$content .= '  <span class="show-on-mobile-view-only">' . $attendee_name . '</span>';
152
+		return $content;
153
+	}
154
+
155
+
156
+	/**
157
+	 * ATT_lname column
158
+	 *
159
+	 * @param EE_Attendee $attendee
160
+	 * @return string
161
+	 * @throws InvalidArgumentException
162
+	 * @throws InvalidDataTypeException
163
+	 * @throws InvalidInterfaceException
164
+	 * @throws EE_Error
165
+	 */
166
+	public function column_ATT_lname(EE_Attendee $attendee)
167
+	{
168
+		// edit attendee link
169
+		$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
170
+			array(
171
+				'action' => 'edit_attendee',
172
+				'post'   => $attendee->ID(),
173
+			),
174
+			REG_ADMIN_URL
175
+		);
176
+		$name_link = EE_Registry::instance()->CAP->current_user_can(
177
+			'ee_edit_contacts',
178
+			'espresso_registrations_edit_attendee'
179
+		)
180
+			? '<a href="' . $edit_lnk_url . '" title="'
181
+			  . esc_attr__('Edit Contact', 'event_espresso') . '">'
182
+			  . $attendee->lname() . '</a>'
183
+			: $attendee->lname();
184
+		return $name_link;
185
+	}
186
+
187
+
188
+	/**
189
+	 * ATT_fname column
190
+	 *
191
+	 * @param EE_Attendee $attendee
192
+	 * @return string
193
+	 * @throws InvalidArgumentException
194
+	 * @throws InvalidDataTypeException
195
+	 * @throws InvalidInterfaceException
196
+	 * @throws EE_Error
197
+	 */
198
+	public function column_ATT_fname(EE_Attendee $attendee)
199
+	{
200
+		// Build row actions
201
+		$actions = array();
202
+		// edit attendee link
203
+		if (EE_Registry::instance()->CAP->current_user_can(
204
+			'ee_edit_contacts',
205
+			'espresso_registrations_edit_attendee'
206
+		)) {
207
+			$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
208
+				array(
209
+					'action' => 'edit_attendee',
210
+					'post'   => $attendee->ID(),
211
+				),
212
+				REG_ADMIN_URL
213
+			);
214
+			$actions['edit'] = '<a href="' . $edit_lnk_url . '" title="'
215
+							   . esc_attr__('Edit Contact', 'event_espresso') . '">'
216
+							   . esc_html__('Edit', 'event_espresso') . '</a>';
217
+		}
218
+
219
+		if ($this->_view === 'in_use') {
220
+			// trash attendee link
221
+			if (EE_Registry::instance()->CAP->current_user_can(
222
+				'ee_delete_contacts',
223
+				'espresso_registrations_trash_attendees'
224
+			)) {
225
+				$trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
226
+					array(
227
+						'action' => 'trash_attendee',
228
+						'ATT_ID' => $attendee->ID(),
229
+					),
230
+					REG_ADMIN_URL
231
+				);
232
+				$actions['trash'] = '<a href="' . $trash_lnk_url . '" title="'
233
+									. esc_attr__('Move Contact to Trash', 'event_espresso')
234
+									. '">' . esc_html__('Trash', 'event_espresso') . '</a>';
235
+			}
236
+		} else {
237
+			if (EE_Registry::instance()->CAP->current_user_can(
238
+				'ee_delete_contacts',
239
+				'espresso_registrations_restore_attendees'
240
+			)) {
241
+				// restore attendee link
242
+				$restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
243
+					array(
244
+						'action' => 'restore_attendees',
245
+						'ATT_ID' => $attendee->ID(),
246
+					),
247
+					REG_ADMIN_URL
248
+				);
249
+				$actions['restore'] = '<a href="' . $restore_lnk_url . '" title="'
250
+									  . esc_attr__('Restore Contact', 'event_espresso') . '">'
251
+									  . esc_html__('Restore', 'event_espresso') . '</a>';
252
+			}
253
+		}
254
+
255
+		$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
256
+			array(
257
+				'action' => 'edit_attendee',
258
+				'post'   => $attendee->ID(),
259
+			),
260
+			REG_ADMIN_URL
261
+		);
262
+		$name_link = EE_Registry::instance()->CAP->current_user_can(
263
+			'ee_edit_contacts',
264
+			'espresso_registrations_edit_attendee'
265
+		)
266
+			? '<a href="' . $edit_lnk_url . '" title="'
267
+			  . esc_attr__('Edit Contact', 'event_espresso') . '">' . $attendee->fname() . '</a>'
268
+			: $attendee->fname();
269
+
270
+		// Return the name contents
271
+		return sprintf('%1$s %2$s', $name_link, $this->row_actions($actions));
272
+	}
273
+
274
+
275
+	/**
276
+	 * Email Column
277
+	 *
278
+	 * @param EE_Attendee $attendee
279
+	 * @return string
280
+	 * @throws EE_Error
281
+	 */
282
+	public function column_ATT_email(EE_Attendee $attendee)
283
+	{
284
+		return '<a href="mailto:' . $attendee->email() . '">' . $attendee->email() . '</a>';
285
+	}
286
+
287
+
288
+	/**
289
+	 * Column displaying count of registrations attached to Attendee.
290
+	 *
291
+	 * @param EE_Attendee $attendee
292
+	 * @return string
293
+	 * @throws EE_Error
294
+	 */
295
+	public function column_Registration_Count(EE_Attendee $attendee)
296
+	{
297
+		$link = EEH_URL::add_query_args_and_nonce(
298
+			array(
299
+				'action' => 'default',
300
+				'ATT_ID' => $attendee->ID(),
301
+			),
302
+			REG_ADMIN_URL
303
+		);
304
+		return '<a href="' . $link . '">' . $attendee->getCustomSelect('Registration_Count') . '</a>';
305
+	}
306
+
307
+
308
+	/**
309
+	 * ATT_address column
310
+	 *
311
+	 * @param EE_Attendee $attendee
312
+	 * @return mixed
313
+	 * @throws EE_Error
314
+	 */
315
+	public function column_ATT_address(EE_Attendee $attendee)
316
+	{
317
+		return $attendee->address();
318
+	}
319
+
320
+
321
+	/**
322
+	 * ATT_city column
323
+	 *
324
+	 * @param EE_Attendee $attendee
325
+	 * @return mixed
326
+	 * @throws EE_Error
327
+	 */
328
+	public function column_ATT_city(EE_Attendee $attendee)
329
+	{
330
+		return $attendee->city();
331
+	}
332
+
333
+
334
+	/**
335
+	 * State Column
336
+	 *
337
+	 * @param EE_Attendee $attendee
338
+	 * @return string
339
+	 * @throws EE_Error
340
+	 * @throws InvalidArgumentException
341
+	 * @throws InvalidDataTypeException
342
+	 * @throws InvalidInterfaceException
343
+	 */
344
+	public function column_STA_ID(EE_Attendee $attendee)
345
+	{
346
+		$states = EEM_State::instance()->get_all_states();
347
+		$state = isset($states[ $attendee->state_ID() ])
348
+			? $states[ $attendee->state_ID() ]->get('STA_name')
349
+			: $attendee->state_ID();
350
+		return ! is_numeric($state) ? $state : '';
351
+	}
352
+
353
+
354
+	/**
355
+	 * Country Column
356
+	 *
357
+	 * @param EE_Attendee $attendee
358
+	 * @return string
359
+	 * @throws EE_Error
360
+	 * @throws InvalidArgumentException
361
+	 * @throws InvalidDataTypeException
362
+	 * @throws InvalidInterfaceException
363
+	 */
364
+	public function column_CNT_ISO(EE_Attendee $attendee)
365
+	{
366
+		$countries = EEM_Country::instance()->get_all_countries();
367
+		$country = isset($countries[ $attendee->country_ID() ])
368
+			? $countries[ $attendee->country_ID() ]->get('CNT_name')
369
+			: $attendee->country_ID();
370
+		return ! is_numeric($country) ? $country : '';
371
+	}
372
+
373
+
374
+	/**
375
+	 * Phone Number column
376
+	 *
377
+	 * @param EE_Attendee $attendee
378
+	 * @return mixed
379
+	 * @throws EE_Error
380
+	 */
381
+	public function column_ATT_phone(EE_Attendee $attendee)
382
+	{
383
+		return $attendee->phone();
384
+	}
385 385
 }
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
      */
128 128
     public function column_cb($attendee)
129 129
     {
130
-        if (! $attendee instanceof EE_Attendee) {
130
+        if ( ! $attendee instanceof EE_Attendee) {
131 131
             return '';
132 132
         }
133 133
         return sprintf(
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
     {
149 149
         $content = $attendee->ID();
150 150
         $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
151
-        $content .= '  <span class="show-on-mobile-view-only">' . $attendee_name . '</span>';
151
+        $content .= '  <span class="show-on-mobile-view-only">'.$attendee_name.'</span>';
152 152
         return $content;
153 153
     }
154 154
 
@@ -177,9 +177,9 @@  discard block
 block discarded – undo
177 177
             'ee_edit_contacts',
178 178
             'espresso_registrations_edit_attendee'
179 179
         )
180
-            ? '<a href="' . $edit_lnk_url . '" title="'
181
-              . esc_attr__('Edit Contact', 'event_espresso') . '">'
182
-              . $attendee->lname() . '</a>'
180
+            ? '<a href="'.$edit_lnk_url.'" title="'
181
+              . esc_attr__('Edit Contact', 'event_espresso').'">'
182
+              . $attendee->lname().'</a>'
183 183
             : $attendee->lname();
184 184
         return $name_link;
185 185
     }
@@ -211,9 +211,9 @@  discard block
 block discarded – undo
211 211
                 ),
212 212
                 REG_ADMIN_URL
213 213
             );
214
-            $actions['edit'] = '<a href="' . $edit_lnk_url . '" title="'
215
-                               . esc_attr__('Edit Contact', 'event_espresso') . '">'
216
-                               . esc_html__('Edit', 'event_espresso') . '</a>';
214
+            $actions['edit'] = '<a href="'.$edit_lnk_url.'" title="'
215
+                               . esc_attr__('Edit Contact', 'event_espresso').'">'
216
+                               . esc_html__('Edit', 'event_espresso').'</a>';
217 217
         }
218 218
 
219 219
         if ($this->_view === 'in_use') {
@@ -229,9 +229,9 @@  discard block
 block discarded – undo
229 229
                     ),
230 230
                     REG_ADMIN_URL
231 231
                 );
232
-                $actions['trash'] = '<a href="' . $trash_lnk_url . '" title="'
232
+                $actions['trash'] = '<a href="'.$trash_lnk_url.'" title="'
233 233
                                     . esc_attr__('Move Contact to Trash', 'event_espresso')
234
-                                    . '">' . esc_html__('Trash', 'event_espresso') . '</a>';
234
+                                    . '">'.esc_html__('Trash', 'event_espresso').'</a>';
235 235
             }
236 236
         } else {
237 237
             if (EE_Registry::instance()->CAP->current_user_can(
@@ -246,9 +246,9 @@  discard block
 block discarded – undo
246 246
                     ),
247 247
                     REG_ADMIN_URL
248 248
                 );
249
-                $actions['restore'] = '<a href="' . $restore_lnk_url . '" title="'
250
-                                      . esc_attr__('Restore Contact', 'event_espresso') . '">'
251
-                                      . esc_html__('Restore', 'event_espresso') . '</a>';
249
+                $actions['restore'] = '<a href="'.$restore_lnk_url.'" title="'
250
+                                      . esc_attr__('Restore Contact', 'event_espresso').'">'
251
+                                      . esc_html__('Restore', 'event_espresso').'</a>';
252 252
             }
253 253
         }
254 254
 
@@ -263,8 +263,8 @@  discard block
 block discarded – undo
263 263
             'ee_edit_contacts',
264 264
             'espresso_registrations_edit_attendee'
265 265
         )
266
-            ? '<a href="' . $edit_lnk_url . '" title="'
267
-              . esc_attr__('Edit Contact', 'event_espresso') . '">' . $attendee->fname() . '</a>'
266
+            ? '<a href="'.$edit_lnk_url.'" title="'
267
+              . esc_attr__('Edit Contact', 'event_espresso').'">'.$attendee->fname().'</a>'
268 268
             : $attendee->fname();
269 269
 
270 270
         // Return the name contents
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
      */
282 282
     public function column_ATT_email(EE_Attendee $attendee)
283 283
     {
284
-        return '<a href="mailto:' . $attendee->email() . '">' . $attendee->email() . '</a>';
284
+        return '<a href="mailto:'.$attendee->email().'">'.$attendee->email().'</a>';
285 285
     }
286 286
 
287 287
 
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
             ),
302 302
             REG_ADMIN_URL
303 303
         );
304
-        return '<a href="' . $link . '">' . $attendee->getCustomSelect('Registration_Count') . '</a>';
304
+        return '<a href="'.$link.'">'.$attendee->getCustomSelect('Registration_Count').'</a>';
305 305
     }
306 306
 
307 307
 
@@ -344,8 +344,8 @@  discard block
 block discarded – undo
344 344
     public function column_STA_ID(EE_Attendee $attendee)
345 345
     {
346 346
         $states = EEM_State::instance()->get_all_states();
347
-        $state = isset($states[ $attendee->state_ID() ])
348
-            ? $states[ $attendee->state_ID() ]->get('STA_name')
347
+        $state = isset($states[$attendee->state_ID()])
348
+            ? $states[$attendee->state_ID()]->get('STA_name')
349 349
             : $attendee->state_ID();
350 350
         return ! is_numeric($state) ? $state : '';
351 351
     }
@@ -364,8 +364,8 @@  discard block
 block discarded – undo
364 364
     public function column_CNT_ISO(EE_Attendee $attendee)
365 365
     {
366 366
         $countries = EEM_Country::instance()->get_all_countries();
367
-        $country = isset($countries[ $attendee->country_ID() ])
368
-            ? $countries[ $attendee->country_ID() ]->get('CNT_name')
367
+        $country = isset($countries[$attendee->country_ID()])
368
+            ? $countries[$attendee->country_ID()]->get('CNT_name')
369 369
             : $attendee->country_ID();
370 370
         return ! is_numeric($country) ? $country : '';
371 371
     }
Please login to merge, or discard this patch.
core/domain/services/factories/ModelFactory.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -25,17 +25,17 @@
 block discarded – undo
25 25
 class ModelFactory
26 26
 {
27 27
 
28
-    /**
29
-     * @param string $model_name
30
-     * @return bool|EEM_Base
31
-     * @throws EE_Error
32
-     * @throws InvalidDataTypeException
33
-     * @throws InvalidInterfaceException
34
-     * @throws InvalidArgumentException
35
-     * @throws ReflectionException
36
-     */
37
-    public static function getModel($model_name)
38
-    {
39
-        return EE_Registry::instance()->load_model($model_name);
40
-    }
28
+	/**
29
+	 * @param string $model_name
30
+	 * @return bool|EEM_Base
31
+	 * @throws EE_Error
32
+	 * @throws InvalidDataTypeException
33
+	 * @throws InvalidInterfaceException
34
+	 * @throws InvalidArgumentException
35
+	 * @throws ReflectionException
36
+	 */
37
+	public static function getModel($model_name)
38
+	{
39
+		return EE_Registry::instance()->load_model($model_name);
40
+	}
41 41
 }
Please login to merge, or discard this patch.
modules/ticket_selector/TicketDatetimeAvailabilityTracker.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -66,24 +66,24 @@  discard block
 block discarded – undo
66 66
     public function ticketDatetimeAvailability(EE_Ticket $ticket, $get_original_ticket_spaces = false)
67 67
     {
68 68
         // if the $_available_spaces array has not been set up yet...
69
-        if (! isset($this->available_spaces['tickets'][ $ticket->ID() ])) {
69
+        if ( ! isset($this->available_spaces['tickets'][$ticket->ID()])) {
70 70
             $this->setInitialTicketDatetimeAvailability($ticket);
71 71
         }
72 72
         $available_spaces = $ticket->qty() - $ticket->sold();
73
-        if (isset($this->available_spaces['tickets'][ $ticket->ID() ])) {
73
+        if (isset($this->available_spaces['tickets'][$ticket->ID()])) {
74 74
             // loop thru tickets, which will ALSO include individual ticket records AND a total
75
-            foreach ($this->available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces) {
75
+            foreach ($this->available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) {
76 76
                 // if we want the original datetime availability BEFORE we started subtracting tickets ?
77 77
                 if ($get_original_ticket_spaces) {
78 78
                     // then grab the available spaces from the "tickets" array
79 79
                     // and compare with the above to get the lowest number
80 80
                     $available_spaces = min(
81 81
                         $available_spaces,
82
-                        $this->available_spaces['tickets'][ $ticket->ID() ][ $DTD_ID ]
82
+                        $this->available_spaces['tickets'][$ticket->ID()][$DTD_ID]
83 83
                     );
84 84
                 } else {
85 85
                     // we want the updated ticket availability as stored in the "datetimes" array
86
-                    $available_spaces = min($available_spaces, $this->available_spaces['datetimes'][ $DTD_ID ]);
86
+                    $available_spaces = min($available_spaces, $this->available_spaces['datetimes'][$DTD_ID]);
87 87
                 }
88 88
             }
89 89
         }
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
                 'order_by' => array('DTT_EVT_start' => 'ASC'),
115 115
             )
116 116
         );
117
-        if (! empty($datetimes)) {
117
+        if ( ! empty($datetimes)) {
118 118
             // now loop thru all of the datetimes
119 119
             foreach ($datetimes as $datetime) {
120 120
                 if ($datetime instanceof EE_Datetime) {
@@ -122,17 +122,17 @@  discard block
 block discarded – undo
122 122
                     $spaces_remaining = $datetime->spaces_remaining();
123 123
                     // save the total available spaces ( the lesser of the ticket qty minus the number of tickets sold
124 124
                     // or the datetime spaces remaining) to this ticket using the datetime ID as the key
125
-                    $this->available_spaces['tickets'][ $ticket->ID() ][ $datetime->ID() ] = min(
125
+                    $this->available_spaces['tickets'][$ticket->ID()][$datetime->ID()] = min(
126 126
                         $ticket->qty() - $ticket->sold(),
127 127
                         $spaces_remaining
128 128
                     );
129 129
                     // if the remaining spaces for this datetime is already set,
130 130
                     // then compare that against the datetime spaces remaining, and take the lowest number,
131 131
                     // else just take the datetime spaces remaining, and assign to the datetimes array
132
-                    $this->available_spaces['datetimes'][ $datetime->ID() ] = isset(
133
-                        $this->available_spaces['datetimes'][ $datetime->ID() ]
132
+                    $this->available_spaces['datetimes'][$datetime->ID()] = isset(
133
+                        $this->available_spaces['datetimes'][$datetime->ID()]
134 134
                     )
135
-                        ? min($this->available_spaces['datetimes'][ $datetime->ID() ], $spaces_remaining)
135
+                        ? min($this->available_spaces['datetimes'][$datetime->ID()], $spaces_remaining)
136 136
                         : $spaces_remaining;
137 137
                 }
138 138
             }
@@ -148,11 +148,11 @@  discard block
 block discarded – undo
148 148
      */
149 149
     public function recalculateTicketDatetimeAvailability(EE_Ticket $ticket, $qty = 0)
150 150
     {
151
-        if (isset($this->available_spaces['tickets'][ $ticket->ID() ])) {
151
+        if (isset($this->available_spaces['tickets'][$ticket->ID()])) {
152 152
             // loop thru tickets, which will ALSO include individual ticket records AND a total
153
-            foreach ($this->available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces) {
153
+            foreach ($this->available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) {
154 154
                 // subtract the qty of selected tickets from each datetime's available spaces this ticket has access to,
155
-                $this->available_spaces['datetimes'][ $DTD_ID ] -= $qty;
155
+                $this->available_spaces['datetimes'][$DTD_ID] -= $qty;
156 156
             }
157 157
         }
158 158
     }
Please login to merge, or discard this patch.
Indentation   +211 added lines, -211 removed lines patch added patch discarded remove patch
@@ -22,215 +22,215 @@
 block discarded – undo
22 22
 class TicketDatetimeAvailabilityTracker
23 23
 {
24 24
 
25
-    /**
26
-     * array of datetimes and the spaces available for them
27
-     *
28
-     * @var array[][]
29
-     */
30
-    private $available_spaces = array();
31
-
32
-    /**
33
-     * @var EEM_Datetime $datetime_model
34
-     */
35
-    private $datetime_model;
36
-
37
-
38
-    /**
39
-     * TicketDatetimeAvailabilityTracker constructor.
40
-     *
41
-     * @param EEM_Datetime $datetime_model
42
-     */
43
-    public function __construct(EEM_Datetime $datetime_model)
44
-    {
45
-        $this->datetime_model = $datetime_model;
46
-    }
47
-
48
-
49
-    /**
50
-     * ticketDatetimeAvailability
51
-     * creates an array of tickets plus all of the datetimes available to each ticket
52
-     * and tracks the spaces remaining for each of those datetimes
53
-     *
54
-     * @param EE_Ticket $ticket - selected ticket
55
-     * @param bool      $get_original_ticket_spaces
56
-     * @return int
57
-     * @throws EE_Error
58
-     * @throws InvalidArgumentException
59
-     * @throws InvalidDataTypeException
60
-     * @throws InvalidInterfaceException
61
-     */
62
-    public function ticketDatetimeAvailability(EE_Ticket $ticket, $get_original_ticket_spaces = false)
63
-    {
64
-        // if the $_available_spaces array has not been set up yet...
65
-        if (! isset($this->available_spaces['tickets'][ $ticket->ID() ])) {
66
-            $this->setInitialTicketDatetimeAvailability($ticket);
67
-        }
68
-        $available_spaces = $ticket->qty() - $ticket->sold();
69
-        if (isset($this->available_spaces['tickets'][ $ticket->ID() ])) {
70
-            // loop thru tickets, which will ALSO include individual ticket records AND a total
71
-            foreach ($this->available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces) {
72
-                // if we want the original datetime availability BEFORE we started subtracting tickets ?
73
-                if ($get_original_ticket_spaces) {
74
-                    // then grab the available spaces from the "tickets" array
75
-                    // and compare with the above to get the lowest number
76
-                    $available_spaces = min(
77
-                        $available_spaces,
78
-                        $this->available_spaces['tickets'][ $ticket->ID() ][ $DTD_ID ]
79
-                    );
80
-                } else {
81
-                    // we want the updated ticket availability as stored in the "datetimes" array
82
-                    $available_spaces = min($available_spaces, $this->available_spaces['datetimes'][ $DTD_ID ]);
83
-                }
84
-            }
85
-        }
86
-        return $available_spaces;
87
-    }
88
-
89
-
90
-    /**
91
-     * @param EE_Ticket $ticket
92
-     * @return void
93
-     * @throws InvalidArgumentException
94
-     * @throws InvalidInterfaceException
95
-     * @throws InvalidDataTypeException
96
-     * @throws EE_Error
97
-     */
98
-    private function setInitialTicketDatetimeAvailability(EE_Ticket $ticket)
99
-    {
100
-        // first, get all of the datetimes that are available to this ticket
101
-        $datetimes = $ticket->get_many_related(
102
-            'Datetime',
103
-            array(
104
-                array(
105
-                    'DTT_EVT_end' => array(
106
-                        '>=',
107
-                        $this->datetime_model->current_time_for_query('DTT_EVT_end'),
108
-                    ),
109
-                ),
110
-                'order_by' => array('DTT_EVT_start' => 'ASC'),
111
-            )
112
-        );
113
-        if (! empty($datetimes)) {
114
-            // now loop thru all of the datetimes
115
-            foreach ($datetimes as $datetime) {
116
-                if ($datetime instanceof EE_Datetime) {
117
-                    // the number of spaces available for the datetime without considering individual ticket quantities
118
-                    $spaces_remaining = $datetime->spaces_remaining();
119
-                    // save the total available spaces ( the lesser of the ticket qty minus the number of tickets sold
120
-                    // or the datetime spaces remaining) to this ticket using the datetime ID as the key
121
-                    $this->available_spaces['tickets'][ $ticket->ID() ][ $datetime->ID() ] = min(
122
-                        $ticket->qty() - $ticket->sold(),
123
-                        $spaces_remaining
124
-                    );
125
-                    // if the remaining spaces for this datetime is already set,
126
-                    // then compare that against the datetime spaces remaining, and take the lowest number,
127
-                    // else just take the datetime spaces remaining, and assign to the datetimes array
128
-                    $this->available_spaces['datetimes'][ $datetime->ID() ] = isset(
129
-                        $this->available_spaces['datetimes'][ $datetime->ID() ]
130
-                    )
131
-                        ? min($this->available_spaces['datetimes'][ $datetime->ID() ], $spaces_remaining)
132
-                        : $spaces_remaining;
133
-                }
134
-            }
135
-        }
136
-    }
137
-
138
-
139
-    /**
140
-     * @param    EE_Ticket $ticket
141
-     * @param    int       $qty
142
-     * @return    void
143
-     * @throws EE_Error
144
-     */
145
-    public function recalculateTicketDatetimeAvailability(EE_Ticket $ticket, $qty = 0)
146
-    {
147
-        if (isset($this->available_spaces['tickets'][ $ticket->ID() ])) {
148
-            // loop thru tickets, which will ALSO include individual ticket records AND a total
149
-            foreach ($this->available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces) {
150
-                // subtract the qty of selected tickets from each datetime's available spaces this ticket has access to,
151
-                $this->available_spaces['datetimes'][ $DTD_ID ] -= $qty;
152
-            }
153
-        }
154
-    }
155
-
156
-
157
-    /**
158
-     * @param EE_Ticket $ticket
159
-     * @param           $qty
160
-     * @param int       $total_ticket_count
161
-     * @throws EE_Error
162
-     * @throws InvalidArgumentException
163
-     * @throws InvalidDataTypeException
164
-     * @throws InvalidInterfaceException
165
-     */
166
-    public function processAvailabilityError(EE_Ticket $ticket, $qty, $total_ticket_count = 1)
167
-    {
168
-        // tickets can not be purchased but let's find the exact number left
169
-        // for the last ticket selected PRIOR to subtracting tickets
170
-        $available_spaces = $this->ticketDatetimeAvailability($ticket, true);
171
-        // greedy greedy greedy eh?
172
-        if ($available_spaces > 0) {
173
-            if (apply_filters(
174
-                'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_display_availability_error',
175
-                true,
176
-                $ticket,
177
-                $qty,
178
-                $available_spaces
179
-            )) {
180
-                $this->availabilityError(
181
-                    $available_spaces,
182
-                    $total_ticket_count
183
-                );
184
-            }
185
-        } else {
186
-            EE_Error::add_error(
187
-                esc_html__(
188
-                    'We\'re sorry, but there are no available spaces left for this event at this particular date and time.',
189
-                    'event_espresso'
190
-                ),
191
-                __FILE__,
192
-                __FUNCTION__,
193
-                __LINE__
194
-            );
195
-        }
196
-    }
197
-
198
-
199
-    /**
200
-     * @param int $available_spaces
201
-     * @param int $total_ticket_count
202
-     */
203
-    private function availabilityError($available_spaces = 1, $total_ticket_count = 1)
204
-    {
205
-        // add error messaging - we're using the _n function that will generate
206
-        // the appropriate singular or plural message based on the number of $available_spaces
207
-        if ($total_ticket_count) {
208
-            $msg = sprintf(
209
-                esc_html(
210
-                    _n(
211
-                        'We\'re sorry, but there is only %1$s available space left for this event at this particular date and time. Please select a different number (or different combination) of tickets by cancelling the current selection and choosing again, or proceed to registration.',
212
-                        'We\'re sorry, but there are only %1$s available spaces left for this event at this particular date and time. Please select a different number (or different combination) of tickets by cancelling the current selection and choosing again, or proceed to registration.',
213
-                        $available_spaces,
214
-                        'event_espresso'
215
-                    )
216
-                ),
217
-                $available_spaces,
218
-                '<br />'
219
-            );
220
-        } else {
221
-            $msg = sprintf(
222
-                esc_html(
223
-                    _n(
224
-                        'We\'re sorry, but there is only %1$s available space left for this event at this particular date and time. Please select a different number (or different combination) of tickets.',
225
-                        'We\'re sorry, but there are only %1$s available spaces left for this event at this particular date and time. Please select a different number (or different combination) of tickets.',
226
-                        $available_spaces,
227
-                        'event_espresso'
228
-                    )
229
-                ),
230
-                $available_spaces,
231
-                '<br />'
232
-            );
233
-        }
234
-        EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
235
-    }
25
+	/**
26
+	 * array of datetimes and the spaces available for them
27
+	 *
28
+	 * @var array[][]
29
+	 */
30
+	private $available_spaces = array();
31
+
32
+	/**
33
+	 * @var EEM_Datetime $datetime_model
34
+	 */
35
+	private $datetime_model;
36
+
37
+
38
+	/**
39
+	 * TicketDatetimeAvailabilityTracker constructor.
40
+	 *
41
+	 * @param EEM_Datetime $datetime_model
42
+	 */
43
+	public function __construct(EEM_Datetime $datetime_model)
44
+	{
45
+		$this->datetime_model = $datetime_model;
46
+	}
47
+
48
+
49
+	/**
50
+	 * ticketDatetimeAvailability
51
+	 * creates an array of tickets plus all of the datetimes available to each ticket
52
+	 * and tracks the spaces remaining for each of those datetimes
53
+	 *
54
+	 * @param EE_Ticket $ticket - selected ticket
55
+	 * @param bool      $get_original_ticket_spaces
56
+	 * @return int
57
+	 * @throws EE_Error
58
+	 * @throws InvalidArgumentException
59
+	 * @throws InvalidDataTypeException
60
+	 * @throws InvalidInterfaceException
61
+	 */
62
+	public function ticketDatetimeAvailability(EE_Ticket $ticket, $get_original_ticket_spaces = false)
63
+	{
64
+		// if the $_available_spaces array has not been set up yet...
65
+		if (! isset($this->available_spaces['tickets'][ $ticket->ID() ])) {
66
+			$this->setInitialTicketDatetimeAvailability($ticket);
67
+		}
68
+		$available_spaces = $ticket->qty() - $ticket->sold();
69
+		if (isset($this->available_spaces['tickets'][ $ticket->ID() ])) {
70
+			// loop thru tickets, which will ALSO include individual ticket records AND a total
71
+			foreach ($this->available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces) {
72
+				// if we want the original datetime availability BEFORE we started subtracting tickets ?
73
+				if ($get_original_ticket_spaces) {
74
+					// then grab the available spaces from the "tickets" array
75
+					// and compare with the above to get the lowest number
76
+					$available_spaces = min(
77
+						$available_spaces,
78
+						$this->available_spaces['tickets'][ $ticket->ID() ][ $DTD_ID ]
79
+					);
80
+				} else {
81
+					// we want the updated ticket availability as stored in the "datetimes" array
82
+					$available_spaces = min($available_spaces, $this->available_spaces['datetimes'][ $DTD_ID ]);
83
+				}
84
+			}
85
+		}
86
+		return $available_spaces;
87
+	}
88
+
89
+
90
+	/**
91
+	 * @param EE_Ticket $ticket
92
+	 * @return void
93
+	 * @throws InvalidArgumentException
94
+	 * @throws InvalidInterfaceException
95
+	 * @throws InvalidDataTypeException
96
+	 * @throws EE_Error
97
+	 */
98
+	private function setInitialTicketDatetimeAvailability(EE_Ticket $ticket)
99
+	{
100
+		// first, get all of the datetimes that are available to this ticket
101
+		$datetimes = $ticket->get_many_related(
102
+			'Datetime',
103
+			array(
104
+				array(
105
+					'DTT_EVT_end' => array(
106
+						'>=',
107
+						$this->datetime_model->current_time_for_query('DTT_EVT_end'),
108
+					),
109
+				),
110
+				'order_by' => array('DTT_EVT_start' => 'ASC'),
111
+			)
112
+		);
113
+		if (! empty($datetimes)) {
114
+			// now loop thru all of the datetimes
115
+			foreach ($datetimes as $datetime) {
116
+				if ($datetime instanceof EE_Datetime) {
117
+					// the number of spaces available for the datetime without considering individual ticket quantities
118
+					$spaces_remaining = $datetime->spaces_remaining();
119
+					// save the total available spaces ( the lesser of the ticket qty minus the number of tickets sold
120
+					// or the datetime spaces remaining) to this ticket using the datetime ID as the key
121
+					$this->available_spaces['tickets'][ $ticket->ID() ][ $datetime->ID() ] = min(
122
+						$ticket->qty() - $ticket->sold(),
123
+						$spaces_remaining
124
+					);
125
+					// if the remaining spaces for this datetime is already set,
126
+					// then compare that against the datetime spaces remaining, and take the lowest number,
127
+					// else just take the datetime spaces remaining, and assign to the datetimes array
128
+					$this->available_spaces['datetimes'][ $datetime->ID() ] = isset(
129
+						$this->available_spaces['datetimes'][ $datetime->ID() ]
130
+					)
131
+						? min($this->available_spaces['datetimes'][ $datetime->ID() ], $spaces_remaining)
132
+						: $spaces_remaining;
133
+				}
134
+			}
135
+		}
136
+	}
137
+
138
+
139
+	/**
140
+	 * @param    EE_Ticket $ticket
141
+	 * @param    int       $qty
142
+	 * @return    void
143
+	 * @throws EE_Error
144
+	 */
145
+	public function recalculateTicketDatetimeAvailability(EE_Ticket $ticket, $qty = 0)
146
+	{
147
+		if (isset($this->available_spaces['tickets'][ $ticket->ID() ])) {
148
+			// loop thru tickets, which will ALSO include individual ticket records AND a total
149
+			foreach ($this->available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces) {
150
+				// subtract the qty of selected tickets from each datetime's available spaces this ticket has access to,
151
+				$this->available_spaces['datetimes'][ $DTD_ID ] -= $qty;
152
+			}
153
+		}
154
+	}
155
+
156
+
157
+	/**
158
+	 * @param EE_Ticket $ticket
159
+	 * @param           $qty
160
+	 * @param int       $total_ticket_count
161
+	 * @throws EE_Error
162
+	 * @throws InvalidArgumentException
163
+	 * @throws InvalidDataTypeException
164
+	 * @throws InvalidInterfaceException
165
+	 */
166
+	public function processAvailabilityError(EE_Ticket $ticket, $qty, $total_ticket_count = 1)
167
+	{
168
+		// tickets can not be purchased but let's find the exact number left
169
+		// for the last ticket selected PRIOR to subtracting tickets
170
+		$available_spaces = $this->ticketDatetimeAvailability($ticket, true);
171
+		// greedy greedy greedy eh?
172
+		if ($available_spaces > 0) {
173
+			if (apply_filters(
174
+				'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_display_availability_error',
175
+				true,
176
+				$ticket,
177
+				$qty,
178
+				$available_spaces
179
+			)) {
180
+				$this->availabilityError(
181
+					$available_spaces,
182
+					$total_ticket_count
183
+				);
184
+			}
185
+		} else {
186
+			EE_Error::add_error(
187
+				esc_html__(
188
+					'We\'re sorry, but there are no available spaces left for this event at this particular date and time.',
189
+					'event_espresso'
190
+				),
191
+				__FILE__,
192
+				__FUNCTION__,
193
+				__LINE__
194
+			);
195
+		}
196
+	}
197
+
198
+
199
+	/**
200
+	 * @param int $available_spaces
201
+	 * @param int $total_ticket_count
202
+	 */
203
+	private function availabilityError($available_spaces = 1, $total_ticket_count = 1)
204
+	{
205
+		// add error messaging - we're using the _n function that will generate
206
+		// the appropriate singular or plural message based on the number of $available_spaces
207
+		if ($total_ticket_count) {
208
+			$msg = sprintf(
209
+				esc_html(
210
+					_n(
211
+						'We\'re sorry, but there is only %1$s available space left for this event at this particular date and time. Please select a different number (or different combination) of tickets by cancelling the current selection and choosing again, or proceed to registration.',
212
+						'We\'re sorry, but there are only %1$s available spaces left for this event at this particular date and time. Please select a different number (or different combination) of tickets by cancelling the current selection and choosing again, or proceed to registration.',
213
+						$available_spaces,
214
+						'event_espresso'
215
+					)
216
+				),
217
+				$available_spaces,
218
+				'<br />'
219
+			);
220
+		} else {
221
+			$msg = sprintf(
222
+				esc_html(
223
+					_n(
224
+						'We\'re sorry, but there is only %1$s available space left for this event at this particular date and time. Please select a different number (or different combination) of tickets.',
225
+						'We\'re sorry, but there are only %1$s available spaces left for this event at this particular date and time. Please select a different number (or different combination) of tickets.',
226
+						$available_spaces,
227
+						'event_espresso'
228
+					)
229
+				),
230
+				$available_spaces,
231
+				'<br />'
232
+			);
233
+		}
234
+		EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
235
+	}
236 236
 }
Please login to merge, or discard this patch.
core/domain/entities/notifications/PersistentAdminNotice.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
      */
131 131
     private function setName($name)
132 132
     {
133
-        if (! is_string($name)) {
133
+        if ( ! is_string($name)) {
134 134
             throw new InvalidDataTypeException('$name', $name, 'string');
135 135
         }
136 136
         $this->name = sanitize_key($name);
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
      */
155 155
     private function setMessage($message)
156 156
     {
157
-        if (! is_string($message)) {
157
+        if ( ! is_string($message)) {
158 158
             throw new InvalidDataTypeException('$message', $message, 'string');
159 159
         }
160 160
         global $allowedtags;
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
      */
201 201
     private function setCapability($capability)
202 202
     {
203
-        if (! is_string($capability)) {
203
+        if ( ! is_string($capability)) {
204 204
             throw new InvalidDataTypeException('$capability', $capability, 'string');
205 205
         }
206 206
         $this->capability = ! empty($capability) ? $capability : 'manage_options';
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
      */
225 225
     private function setCapContext($cap_context)
226 226
     {
227
-        if (! is_string($cap_context)) {
227
+        if ( ! is_string($cap_context)) {
228 228
             throw new InvalidDataTypeException('$cap_context', $cap_context, 'string');
229 229
         }
230 230
         $this->cap_context = ! empty($cap_context) ? $cap_context : 'view persistent admin notice';
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
      */
259 259
     public function getCapCheck()
260 260
     {
261
-        if (! $this->cap_check instanceof CapCheckInterface) {
261
+        if ( ! $this->cap_check instanceof CapCheckInterface) {
262 262
             $this->setCapCheck(
263 263
                 new CapCheck(
264 264
                     $this->capability,
@@ -343,10 +343,10 @@  discard block
 block discarded – undo
343 343
      */
344 344
     public function confirmRegistered()
345 345
     {
346
-        if (! apply_filters('PersistentAdminNoticeManager__registerAndSaveNotices__complete', false)) {
346
+        if ( ! apply_filters('PersistentAdminNoticeManager__registerAndSaveNotices__complete', false)) {
347 347
             PersistentAdminNoticeManager::loadRegisterAndSaveNotices();
348 348
         }
349
-        if (! $this->registered && WP_DEBUG) {
349
+        if ( ! $this->registered && WP_DEBUG) {
350 350
             throw new DomainException(
351 351
                 sprintf(
352 352
                     esc_html__(
Please login to merge, or discard this patch.
Indentation   +311 added lines, -311 removed lines patch added patch discarded remove patch
@@ -24,315 +24,315 @@
 block discarded – undo
24 24
 class PersistentAdminNotice implements RequiresCapCheckInterface
25 25
 {
26 26
 
27
-    /**
28
-     * @var string $name
29
-     */
30
-    protected $name = '';
31
-
32
-    /**
33
-     * @var string $message
34
-     */
35
-    protected $message = '';
36
-
37
-    /**
38
-     * @var boolean $force_update
39
-     */
40
-    protected $force_update = false;
41
-
42
-    /**
43
-     * @var string $capability
44
-     */
45
-    protected $capability = 'manage_options';
46
-
47
-    /**
48
-     * @var string $cap_context
49
-     */
50
-    protected $cap_context = 'view persistent admin notice';
51
-
52
-    /**
53
-     * @var boolean $dismissed
54
-     */
55
-    protected $dismissed = false;
56
-
57
-    /**
58
-     * @var CapCheckInterface $cap_check
59
-     */
60
-    protected $cap_check;
61
-
62
-    /**
63
-     * if true, then this notice will be deleted from the database
64
-     *
65
-     * @var boolean $purge
66
-     */
67
-    protected $purge = false;
68
-
69
-    /**
70
-     * gets set to true if notice is successfully registered with the PersistentAdminNoticeManager
71
-     * if false, and WP_DEBUG is on, then an exception will be thrown in the admin footer
72
-     *
73
-     * @var boolean $registered
74
-     */
75
-    private $registered = false;
76
-
77
-
78
-    /**
79
-     * PersistentAdminNotice constructor
80
-     *
81
-     * @param string $name         [required] the name, or key of the Persistent Admin Notice to be stored
82
-     * @param string $message      [required] the message to be stored persistently until dismissed
83
-     * @param bool   $force_update enforce the reappearance of a persistent message
84
-     * @param string $capability   user capability required to view this notice
85
-     * @param string $cap_context  description for why the cap check is being performed
86
-     * @param bool   $dismissed    whether or not the user has already dismissed/viewed this notice
87
-     * @throws InvalidDataTypeException
88
-     */
89
-    public function __construct(
90
-        $name,
91
-        $message,
92
-        $force_update = false,
93
-        $capability = 'manage_options',
94
-        $cap_context = 'view persistent admin notice',
95
-        $dismissed = false
96
-    ) {
97
-        $this->setName($name);
98
-        $this->setMessage($message);
99
-        $this->setForceUpdate($force_update);
100
-        $this->setCapability($capability);
101
-        $this->setCapContext($cap_context);
102
-        $this->setDismissed($dismissed);
103
-        add_action(
104
-            'AHEE__EventEspresso_core_services_notifications_PersistentAdminNoticeManager__registerNotices',
105
-            array($this, 'registerPersistentAdminNotice')
106
-        );
107
-        add_action('shutdown', array($this, 'confirmRegistered'), 999);
108
-    }
109
-
110
-
111
-    /**
112
-     * @return string
113
-     */
114
-    public function getName()
115
-    {
116
-        return $this->name;
117
-    }
118
-
119
-
120
-    /**
121
-     * @param string $name
122
-     * @throws InvalidDataTypeException
123
-     */
124
-    private function setName($name)
125
-    {
126
-        if (! is_string($name)) {
127
-            throw new InvalidDataTypeException('$name', $name, 'string');
128
-        }
129
-        $this->name = sanitize_key($name);
130
-    }
131
-
132
-
133
-    /**
134
-     * @return string
135
-     */
136
-    public function getMessage()
137
-    {
138
-        return $this->message;
139
-    }
140
-
141
-
142
-    /**
143
-     * @param string $message
144
-     * @throws InvalidDataTypeException
145
-     */
146
-    private function setMessage($message)
147
-    {
148
-        if (! is_string($message)) {
149
-            throw new InvalidDataTypeException('$message', $message, 'string');
150
-        }
151
-        global $allowedtags;
152
-        $allowedtags['br'] = array();
153
-        $this->message = wp_kses($message, $allowedtags);
154
-    }
155
-
156
-
157
-    /**
158
-     * @return bool
159
-     */
160
-    public function getForceUpdate()
161
-    {
162
-        return $this->force_update;
163
-    }
164
-
165
-
166
-    /**
167
-     * @param bool $force_update
168
-     */
169
-    private function setForceUpdate($force_update)
170
-    {
171
-        $this->force_update = filter_var($force_update, FILTER_VALIDATE_BOOLEAN);
172
-    }
173
-
174
-
175
-    /**
176
-     * @return string
177
-     */
178
-    public function getCapability()
179
-    {
180
-        return $this->capability;
181
-    }
182
-
183
-
184
-    /**
185
-     * @param string $capability
186
-     * @throws InvalidDataTypeException
187
-     */
188
-    private function setCapability($capability)
189
-    {
190
-        if (! is_string($capability)) {
191
-            throw new InvalidDataTypeException('$capability', $capability, 'string');
192
-        }
193
-        $this->capability = ! empty($capability) ? $capability : 'manage_options';
194
-    }
195
-
196
-
197
-    /**
198
-     * @return string
199
-     */
200
-    public function getCapContext()
201
-    {
202
-        return $this->cap_context;
203
-    }
204
-
205
-
206
-    /**
207
-     * @param string $cap_context
208
-     * @throws InvalidDataTypeException
209
-     */
210
-    private function setCapContext($cap_context)
211
-    {
212
-        if (! is_string($cap_context)) {
213
-            throw new InvalidDataTypeException('$cap_context', $cap_context, 'string');
214
-        }
215
-        $this->cap_context = ! empty($cap_context) ? $cap_context : 'view persistent admin notice';
216
-    }
217
-
218
-
219
-    /**
220
-     * @return bool
221
-     */
222
-    public function getDismissed()
223
-    {
224
-        return $this->dismissed;
225
-    }
226
-
227
-
228
-    /**
229
-     * @param bool $dismissed
230
-     */
231
-    public function setDismissed($dismissed)
232
-    {
233
-        $this->dismissed = filter_var($dismissed, FILTER_VALIDATE_BOOLEAN);
234
-    }
235
-
236
-
237
-    /**
238
-     * @return CapCheckInterface
239
-     * @throws InvalidDataTypeException
240
-     */
241
-    public function getCapCheck()
242
-    {
243
-        if (! $this->cap_check instanceof CapCheckInterface) {
244
-            $this->setCapCheck(
245
-                new CapCheck(
246
-                    $this->capability,
247
-                    $this->cap_context
248
-                )
249
-            );
250
-        }
251
-        return $this->cap_check;
252
-    }
253
-
254
-
255
-    /**
256
-     * @param CapCheckInterface $cap_check
257
-     */
258
-    private function setCapCheck(CapCheckInterface $cap_check)
259
-    {
260
-        $this->cap_check = $cap_check;
261
-    }
262
-
263
-
264
-    /**
265
-     * @return bool
266
-     */
267
-    public function getPurge()
268
-    {
269
-        return $this->purge;
270
-    }
271
-
272
-
273
-    /**
274
-     * @param bool $purge
275
-     */
276
-    public function setPurge($purge)
277
-    {
278
-        $this->purge = filter_var($purge, FILTER_VALIDATE_BOOLEAN);
279
-    }
280
-
281
-
282
-    /**
283
-     * given a valid PersistentAdminNotice Collection,
284
-     * this notice will be added if it is not already found in the collection (using its name as the identifier)
285
-     * if an existing notice is found that has already been dismissed,
286
-     * but we are overriding with a forced update, then we will toggle its dismissed state,
287
-     * so that the notice is displayed again
288
-     *
289
-     * @param Collection $persistent_admin_notice_collection
290
-     * @throws InvalidEntityException
291
-     * @throws InvalidDataTypeException
292
-     */
293
-    public function registerPersistentAdminNotice(Collection $persistent_admin_notice_collection)
294
-    {
295
-        if ($this->registered) {
296
-            return;
297
-        }
298
-        // first check if this notice has already been added to the collection
299
-        if ($persistent_admin_notice_collection->has($this->name)) {
300
-            /** @var PersistentAdminNotice $existing */
301
-            $existing = $persistent_admin_notice_collection->get($this->name);
302
-            // we don't need to add it again (we can't actually)
303
-            // but if it has already been dismissed, and we are overriding with a forced update
304
-            if ($existing->getDismissed() && $this->getForceUpdate()) {
305
-                // then toggle the notice's dismissed state to true
306
-                // so that it gets displayed again
307
-                $existing->setDismissed(false);
308
-                // and make sure the message is set
309
-                $existing->setMessage($this->message);
310
-            }
311
-        } else {
312
-            $persistent_admin_notice_collection->add($this, $this->name);
313
-        }
314
-        $this->registered = true;
315
-    }
316
-
317
-
318
-    /**
319
-     * @throws Exception
320
-     */
321
-    public function confirmRegistered()
322
-    {
323
-        if (! apply_filters('PersistentAdminNoticeManager__registerAndSaveNotices__complete', false)) {
324
-            PersistentAdminNoticeManager::loadRegisterAndSaveNotices();
325
-        }
326
-        if (! $this->registered && WP_DEBUG) {
327
-            throw new DomainException(
328
-                sprintf(
329
-                    esc_html__(
330
-                        'The "%1$s" PersistentAdminNotice was not successfully registered. Please ensure that it is being created prior to either the "admin_notices" or "network_admin_notices" hooks being triggered.',
331
-                        'event_espresso'
332
-                    ),
333
-                    $this->name
334
-                )
335
-            );
336
-        }
337
-    }
27
+	/**
28
+	 * @var string $name
29
+	 */
30
+	protected $name = '';
31
+
32
+	/**
33
+	 * @var string $message
34
+	 */
35
+	protected $message = '';
36
+
37
+	/**
38
+	 * @var boolean $force_update
39
+	 */
40
+	protected $force_update = false;
41
+
42
+	/**
43
+	 * @var string $capability
44
+	 */
45
+	protected $capability = 'manage_options';
46
+
47
+	/**
48
+	 * @var string $cap_context
49
+	 */
50
+	protected $cap_context = 'view persistent admin notice';
51
+
52
+	/**
53
+	 * @var boolean $dismissed
54
+	 */
55
+	protected $dismissed = false;
56
+
57
+	/**
58
+	 * @var CapCheckInterface $cap_check
59
+	 */
60
+	protected $cap_check;
61
+
62
+	/**
63
+	 * if true, then this notice will be deleted from the database
64
+	 *
65
+	 * @var boolean $purge
66
+	 */
67
+	protected $purge = false;
68
+
69
+	/**
70
+	 * gets set to true if notice is successfully registered with the PersistentAdminNoticeManager
71
+	 * if false, and WP_DEBUG is on, then an exception will be thrown in the admin footer
72
+	 *
73
+	 * @var boolean $registered
74
+	 */
75
+	private $registered = false;
76
+
77
+
78
+	/**
79
+	 * PersistentAdminNotice constructor
80
+	 *
81
+	 * @param string $name         [required] the name, or key of the Persistent Admin Notice to be stored
82
+	 * @param string $message      [required] the message to be stored persistently until dismissed
83
+	 * @param bool   $force_update enforce the reappearance of a persistent message
84
+	 * @param string $capability   user capability required to view this notice
85
+	 * @param string $cap_context  description for why the cap check is being performed
86
+	 * @param bool   $dismissed    whether or not the user has already dismissed/viewed this notice
87
+	 * @throws InvalidDataTypeException
88
+	 */
89
+	public function __construct(
90
+		$name,
91
+		$message,
92
+		$force_update = false,
93
+		$capability = 'manage_options',
94
+		$cap_context = 'view persistent admin notice',
95
+		$dismissed = false
96
+	) {
97
+		$this->setName($name);
98
+		$this->setMessage($message);
99
+		$this->setForceUpdate($force_update);
100
+		$this->setCapability($capability);
101
+		$this->setCapContext($cap_context);
102
+		$this->setDismissed($dismissed);
103
+		add_action(
104
+			'AHEE__EventEspresso_core_services_notifications_PersistentAdminNoticeManager__registerNotices',
105
+			array($this, 'registerPersistentAdminNotice')
106
+		);
107
+		add_action('shutdown', array($this, 'confirmRegistered'), 999);
108
+	}
109
+
110
+
111
+	/**
112
+	 * @return string
113
+	 */
114
+	public function getName()
115
+	{
116
+		return $this->name;
117
+	}
118
+
119
+
120
+	/**
121
+	 * @param string $name
122
+	 * @throws InvalidDataTypeException
123
+	 */
124
+	private function setName($name)
125
+	{
126
+		if (! is_string($name)) {
127
+			throw new InvalidDataTypeException('$name', $name, 'string');
128
+		}
129
+		$this->name = sanitize_key($name);
130
+	}
131
+
132
+
133
+	/**
134
+	 * @return string
135
+	 */
136
+	public function getMessage()
137
+	{
138
+		return $this->message;
139
+	}
140
+
141
+
142
+	/**
143
+	 * @param string $message
144
+	 * @throws InvalidDataTypeException
145
+	 */
146
+	private function setMessage($message)
147
+	{
148
+		if (! is_string($message)) {
149
+			throw new InvalidDataTypeException('$message', $message, 'string');
150
+		}
151
+		global $allowedtags;
152
+		$allowedtags['br'] = array();
153
+		$this->message = wp_kses($message, $allowedtags);
154
+	}
155
+
156
+
157
+	/**
158
+	 * @return bool
159
+	 */
160
+	public function getForceUpdate()
161
+	{
162
+		return $this->force_update;
163
+	}
164
+
165
+
166
+	/**
167
+	 * @param bool $force_update
168
+	 */
169
+	private function setForceUpdate($force_update)
170
+	{
171
+		$this->force_update = filter_var($force_update, FILTER_VALIDATE_BOOLEAN);
172
+	}
173
+
174
+
175
+	/**
176
+	 * @return string
177
+	 */
178
+	public function getCapability()
179
+	{
180
+		return $this->capability;
181
+	}
182
+
183
+
184
+	/**
185
+	 * @param string $capability
186
+	 * @throws InvalidDataTypeException
187
+	 */
188
+	private function setCapability($capability)
189
+	{
190
+		if (! is_string($capability)) {
191
+			throw new InvalidDataTypeException('$capability', $capability, 'string');
192
+		}
193
+		$this->capability = ! empty($capability) ? $capability : 'manage_options';
194
+	}
195
+
196
+
197
+	/**
198
+	 * @return string
199
+	 */
200
+	public function getCapContext()
201
+	{
202
+		return $this->cap_context;
203
+	}
204
+
205
+
206
+	/**
207
+	 * @param string $cap_context
208
+	 * @throws InvalidDataTypeException
209
+	 */
210
+	private function setCapContext($cap_context)
211
+	{
212
+		if (! is_string($cap_context)) {
213
+			throw new InvalidDataTypeException('$cap_context', $cap_context, 'string');
214
+		}
215
+		$this->cap_context = ! empty($cap_context) ? $cap_context : 'view persistent admin notice';
216
+	}
217
+
218
+
219
+	/**
220
+	 * @return bool
221
+	 */
222
+	public function getDismissed()
223
+	{
224
+		return $this->dismissed;
225
+	}
226
+
227
+
228
+	/**
229
+	 * @param bool $dismissed
230
+	 */
231
+	public function setDismissed($dismissed)
232
+	{
233
+		$this->dismissed = filter_var($dismissed, FILTER_VALIDATE_BOOLEAN);
234
+	}
235
+
236
+
237
+	/**
238
+	 * @return CapCheckInterface
239
+	 * @throws InvalidDataTypeException
240
+	 */
241
+	public function getCapCheck()
242
+	{
243
+		if (! $this->cap_check instanceof CapCheckInterface) {
244
+			$this->setCapCheck(
245
+				new CapCheck(
246
+					$this->capability,
247
+					$this->cap_context
248
+				)
249
+			);
250
+		}
251
+		return $this->cap_check;
252
+	}
253
+
254
+
255
+	/**
256
+	 * @param CapCheckInterface $cap_check
257
+	 */
258
+	private function setCapCheck(CapCheckInterface $cap_check)
259
+	{
260
+		$this->cap_check = $cap_check;
261
+	}
262
+
263
+
264
+	/**
265
+	 * @return bool
266
+	 */
267
+	public function getPurge()
268
+	{
269
+		return $this->purge;
270
+	}
271
+
272
+
273
+	/**
274
+	 * @param bool $purge
275
+	 */
276
+	public function setPurge($purge)
277
+	{
278
+		$this->purge = filter_var($purge, FILTER_VALIDATE_BOOLEAN);
279
+	}
280
+
281
+
282
+	/**
283
+	 * given a valid PersistentAdminNotice Collection,
284
+	 * this notice will be added if it is not already found in the collection (using its name as the identifier)
285
+	 * if an existing notice is found that has already been dismissed,
286
+	 * but we are overriding with a forced update, then we will toggle its dismissed state,
287
+	 * so that the notice is displayed again
288
+	 *
289
+	 * @param Collection $persistent_admin_notice_collection
290
+	 * @throws InvalidEntityException
291
+	 * @throws InvalidDataTypeException
292
+	 */
293
+	public function registerPersistentAdminNotice(Collection $persistent_admin_notice_collection)
294
+	{
295
+		if ($this->registered) {
296
+			return;
297
+		}
298
+		// first check if this notice has already been added to the collection
299
+		if ($persistent_admin_notice_collection->has($this->name)) {
300
+			/** @var PersistentAdminNotice $existing */
301
+			$existing = $persistent_admin_notice_collection->get($this->name);
302
+			// we don't need to add it again (we can't actually)
303
+			// but if it has already been dismissed, and we are overriding with a forced update
304
+			if ($existing->getDismissed() && $this->getForceUpdate()) {
305
+				// then toggle the notice's dismissed state to true
306
+				// so that it gets displayed again
307
+				$existing->setDismissed(false);
308
+				// and make sure the message is set
309
+				$existing->setMessage($this->message);
310
+			}
311
+		} else {
312
+			$persistent_admin_notice_collection->add($this, $this->name);
313
+		}
314
+		$this->registered = true;
315
+	}
316
+
317
+
318
+	/**
319
+	 * @throws Exception
320
+	 */
321
+	public function confirmRegistered()
322
+	{
323
+		if (! apply_filters('PersistentAdminNoticeManager__registerAndSaveNotices__complete', false)) {
324
+			PersistentAdminNoticeManager::loadRegisterAndSaveNotices();
325
+		}
326
+		if (! $this->registered && WP_DEBUG) {
327
+			throw new DomainException(
328
+				sprintf(
329
+					esc_html__(
330
+						'The "%1$s" PersistentAdminNotice was not successfully registered. Please ensure that it is being created prior to either the "admin_notices" or "network_admin_notices" hooks being triggered.',
331
+						'event_espresso'
332
+					),
333
+					$this->name
334
+				)
335
+			);
336
+		}
337
+	}
338 338
 }
Please login to merge, or discard this patch.
acceptance_tests/Helpers/EventsAdmin.php 1 patch
Indentation   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -14,133 +14,133 @@
 block discarded – undo
14 14
 trait EventsAdmin
15 15
 {
16 16
 
17
-    /**
18
-     * @param string $additional_params
19
-     */
20
-    public function amOnDefaultEventsListTablePage($additional_params = '')
21
-    {
22
-        $this->actor()->amOnAdminPage(EventsPage::defaultEventsListTableUrl($additional_params));
23
-    }
24
-
25
-
26
-    /**
27
-     * Triggers the publishing of the Event.
28
-     */
29
-    public function publishEvent()
30
-    {
31
-        $this->actor()->scrollTo(EventsPage::EVENT_EDITOR_TITLE_FIELD_SELECTOR);
32
-        $this->actor()->wait(3);
33
-        $this->actor()->click(EventsPage::EVENT_EDITOR_PUBLISH_BUTTON_SELECTOR);
34
-        $this->actor()->waitForText('Event published.', 30);
35
-    }
36
-
37
-
38
-    /**
39
-     * Triggers saving the Event.
40
-     */
41
-    public function saveEvent()
42
-    {
43
-        $this->actor()->scrollTo(EventsPage::EVENT_EDITOR_TITLE_FIELD_SELECTOR);
44
-        $this->actor()->wait(2);
45
-        $this->actor()->click(EventsPage::EVENT_EDITOR_SAVE_BUTTON_SELECTOR);
46
-    }
47
-
48
-
49
-    /**
50
-     * Navigates the actor to the event list table page and will attempt to edit the event for the given title.
51
-     * First this will search using the given title and then attempt to edit from the results of the search.
52
-     *
53
-     * Assumes actor is already logged in.
54
-     * @param $event_title
55
-     */
56
-    public function amEditingTheEventWithTitle($event_title)
57
-    {
58
-        $this->amOnDefaultEventsListTablePage();
59
-        $this->actor()->fillField(EventsPage::EVENT_LIST_TABLE_SEARCH_INPUT_SELECTOR, $event_title);
60
-        $this->actor()->click(CoreAdmin::LIST_TABLE_SEARCH_SUBMIT_SELECTOR);
61
-        $this->actor()->waitForText($event_title, 15);
62
-        $this->actor()->click(EventsPage::eventListTableEventTitleEditLinkSelectorForTitle($event_title));
63
-    }
64
-
65
-
66
-    /**
67
-     * Navigates the user to the single event page (frontend view) for the given event title via clicking the "View"
68
-     * link for the event in the event list table.
69
-     * Assumes the actor is already logged in and on the Event list table page.
70
-     *
71
-     * @param string $event_title
72
-     */
73
-    public function amOnEventPageAfterClickingViewLinkInListTableForEvent($event_title)
74
-    {
75
-        $this->actor()->moveMouseOver(EventsPage::eventListTableEventTitleEditLinkSelectorForTitle($event_title));
76
-        $this->actor()->click(EventsPage::eventListTableEventTitleViewLinkSelectorForTitle($event_title));
77
-    }
78
-
79
-
80
-    /**
81
-     * Used to retrieve the event id for the event via the list table and for the given event.
82
-     * @param string $event_title
83
-     */
84
-    public function observeEventIdInListTableForEvent($event_title)
85
-    {
86
-        return $this->actor()->observeValueFromInputAt(EventsPage::eventListTableEventIdSelectorForTitle($event_title));
87
-    }
88
-
89
-
90
-    /**
91
-     * This performs the click action on the gear icon that triggers the advanced settings view state.
92
-     * Assumes the actor is already logged in and editing an event.
93
-     *
94
-     * @param int $row_number  What ticket row to toggle open/close.
95
-     */
96
-    public function toggleAdvancedSettingsViewForTicketRow($row_number = 1)
97
-    {
98
-        $this->actor()->click(EventsPage::eventEditorTicketAdvancedDetailsSelector($row_number));
99
-    }
100
-
101
-
102
-    /**
103
-     * Toggles the TKT_is_taxable checkbox for the ticket in the given row.
104
-     * Assumes the actor is already logged in and editing an event and that the advanced settings view state for that
105
-     * ticket is "open".
106
-     *
107
-     * @param int $row_number  What ticket row to toggle the checkbox for.
108
-     */
109
-    public function toggleTicketIsTaxableForTicketRow($row_number = 1)
110
-    {
111
-        $this->actor()->click(EventsPage::eventEditorTicketTaxableCheckboxSelector($row_number));
112
-    }
113
-
114
-
115
-    /**
116
-     * Use to change the default registration status for the event.
117
-     * Assumes the view is already on the event editor.
118
-     * @param $registration_status
119
-     */
120
-    public function changeDefaultRegistrationStatusTo($registration_status)
121
-    {
122
-        $this->actor()->selectOption(
123
-            EventsPage::EVENT_EDITOR_DEFAULT_REGISTRATION_STATUS_FIELD_SELECTOR,
124
-            $registration_status
125
-        );
126
-    }
127
-
128
-
129
-    /**
130
-     * Use this from the context of the event editor to select the given custom template for a given message type and
131
-     * messenger.
132
-     *
133
-     * @param string $message_type_label  The visible label for the message type (eg Registration Approved)
134
-     * @param string $messenger_slug      The slug for the messenger (eg 'email')
135
-     * @param string $custom_template_label The visible label in the select input for the custom template you want
136
-     *                                      selected.
137
-     */
138
-    public function selectCustomTemplateFor($message_type_label, $messenger_slug, $custom_template_label)
139
-    {
140
-        $this->actor()->click(EventsPage::eventEditorNotificationsMetaBoxMessengerTabSelector($messenger_slug));
141
-        $this->actor()->selectOption(
142
-            EventsPage::eventEditorNotificationsMetaBoxSelectSelectorForMessageType($message_type_label),
143
-            $custom_template_label
144
-        );
145
-    }
17
+	/**
18
+	 * @param string $additional_params
19
+	 */
20
+	public function amOnDefaultEventsListTablePage($additional_params = '')
21
+	{
22
+		$this->actor()->amOnAdminPage(EventsPage::defaultEventsListTableUrl($additional_params));
23
+	}
24
+
25
+
26
+	/**
27
+	 * Triggers the publishing of the Event.
28
+	 */
29
+	public function publishEvent()
30
+	{
31
+		$this->actor()->scrollTo(EventsPage::EVENT_EDITOR_TITLE_FIELD_SELECTOR);
32
+		$this->actor()->wait(3);
33
+		$this->actor()->click(EventsPage::EVENT_EDITOR_PUBLISH_BUTTON_SELECTOR);
34
+		$this->actor()->waitForText('Event published.', 30);
35
+	}
36
+
37
+
38
+	/**
39
+	 * Triggers saving the Event.
40
+	 */
41
+	public function saveEvent()
42
+	{
43
+		$this->actor()->scrollTo(EventsPage::EVENT_EDITOR_TITLE_FIELD_SELECTOR);
44
+		$this->actor()->wait(2);
45
+		$this->actor()->click(EventsPage::EVENT_EDITOR_SAVE_BUTTON_SELECTOR);
46
+	}
47
+
48
+
49
+	/**
50
+	 * Navigates the actor to the event list table page and will attempt to edit the event for the given title.
51
+	 * First this will search using the given title and then attempt to edit from the results of the search.
52
+	 *
53
+	 * Assumes actor is already logged in.
54
+	 * @param $event_title
55
+	 */
56
+	public function amEditingTheEventWithTitle($event_title)
57
+	{
58
+		$this->amOnDefaultEventsListTablePage();
59
+		$this->actor()->fillField(EventsPage::EVENT_LIST_TABLE_SEARCH_INPUT_SELECTOR, $event_title);
60
+		$this->actor()->click(CoreAdmin::LIST_TABLE_SEARCH_SUBMIT_SELECTOR);
61
+		$this->actor()->waitForText($event_title, 15);
62
+		$this->actor()->click(EventsPage::eventListTableEventTitleEditLinkSelectorForTitle($event_title));
63
+	}
64
+
65
+
66
+	/**
67
+	 * Navigates the user to the single event page (frontend view) for the given event title via clicking the "View"
68
+	 * link for the event in the event list table.
69
+	 * Assumes the actor is already logged in and on the Event list table page.
70
+	 *
71
+	 * @param string $event_title
72
+	 */
73
+	public function amOnEventPageAfterClickingViewLinkInListTableForEvent($event_title)
74
+	{
75
+		$this->actor()->moveMouseOver(EventsPage::eventListTableEventTitleEditLinkSelectorForTitle($event_title));
76
+		$this->actor()->click(EventsPage::eventListTableEventTitleViewLinkSelectorForTitle($event_title));
77
+	}
78
+
79
+
80
+	/**
81
+	 * Used to retrieve the event id for the event via the list table and for the given event.
82
+	 * @param string $event_title
83
+	 */
84
+	public function observeEventIdInListTableForEvent($event_title)
85
+	{
86
+		return $this->actor()->observeValueFromInputAt(EventsPage::eventListTableEventIdSelectorForTitle($event_title));
87
+	}
88
+
89
+
90
+	/**
91
+	 * This performs the click action on the gear icon that triggers the advanced settings view state.
92
+	 * Assumes the actor is already logged in and editing an event.
93
+	 *
94
+	 * @param int $row_number  What ticket row to toggle open/close.
95
+	 */
96
+	public function toggleAdvancedSettingsViewForTicketRow($row_number = 1)
97
+	{
98
+		$this->actor()->click(EventsPage::eventEditorTicketAdvancedDetailsSelector($row_number));
99
+	}
100
+
101
+
102
+	/**
103
+	 * Toggles the TKT_is_taxable checkbox for the ticket in the given row.
104
+	 * Assumes the actor is already logged in and editing an event and that the advanced settings view state for that
105
+	 * ticket is "open".
106
+	 *
107
+	 * @param int $row_number  What ticket row to toggle the checkbox for.
108
+	 */
109
+	public function toggleTicketIsTaxableForTicketRow($row_number = 1)
110
+	{
111
+		$this->actor()->click(EventsPage::eventEditorTicketTaxableCheckboxSelector($row_number));
112
+	}
113
+
114
+
115
+	/**
116
+	 * Use to change the default registration status for the event.
117
+	 * Assumes the view is already on the event editor.
118
+	 * @param $registration_status
119
+	 */
120
+	public function changeDefaultRegistrationStatusTo($registration_status)
121
+	{
122
+		$this->actor()->selectOption(
123
+			EventsPage::EVENT_EDITOR_DEFAULT_REGISTRATION_STATUS_FIELD_SELECTOR,
124
+			$registration_status
125
+		);
126
+	}
127
+
128
+
129
+	/**
130
+	 * Use this from the context of the event editor to select the given custom template for a given message type and
131
+	 * messenger.
132
+	 *
133
+	 * @param string $message_type_label  The visible label for the message type (eg Registration Approved)
134
+	 * @param string $messenger_slug      The slug for the messenger (eg 'email')
135
+	 * @param string $custom_template_label The visible label in the select input for the custom template you want
136
+	 *                                      selected.
137
+	 */
138
+	public function selectCustomTemplateFor($message_type_label, $messenger_slug, $custom_template_label)
139
+	{
140
+		$this->actor()->click(EventsPage::eventEditorNotificationsMetaBoxMessengerTabSelector($messenger_slug));
141
+		$this->actor()->selectOption(
142
+			EventsPage::eventEditorNotificationsMetaBoxSelectSelectorForMessageType($message_type_label),
143
+			$custom_template_label
144
+		);
145
+	}
146 146
 }
147 147
\ No newline at end of file
Please login to merge, or discard this patch.