Completed
Branch models-cleanup/more-ee-base-cl... (91a157)
by
unknown
53:04 queued 43:29
created
core/domain/entities/contexts/ContextInterface.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -18,14 +18,14 @@
 block discarded – undo
18 18
 interface ContextInterface
19 19
 {
20 20
 
21
-    /**
22
-     * @return string
23
-     */
24
-    public function slug();
21
+	/**
22
+	 * @return string
23
+	 */
24
+	public function slug();
25 25
 
26 26
 
27
-    /**
28
-     * @return string
29
-     */
30
-    public function description();
27
+	/**
28
+	 * @return string
29
+	 */
30
+	public function description();
31 31
 }
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   +2567 added lines, -2567 removed lines patch added patch discarded remove patch
@@ -13,2572 +13,2572 @@
 block discarded – undo
13 13
 class Transactions_Admin_Page extends EE_Admin_Page
14 14
 {
15 15
 
16
-    /**
17
-     * @var EE_Transaction
18
-     */
19
-    private $_transaction;
20
-
21
-    /**
22
-     * @var EE_Session
23
-     */
24
-    private $_session;
25
-
26
-    /**
27
-     * @var array $_txn_status
28
-     */
29
-    private static $_txn_status;
30
-
31
-    /**
32
-     * @var array $_pay_status
33
-     */
34
-    private static $_pay_status;
35
-
36
-    /**
37
-     * @var array $_existing_reg_payment_REG_IDs
38
-     */
39
-    protected $_existing_reg_payment_REG_IDs;
40
-
41
-
42
-    /**
43
-     *    _init_page_props
44
-     *
45
-     * @return void
46
-     */
47
-    protected function _init_page_props()
48
-    {
49
-        $this->page_slug = TXN_PG_SLUG;
50
-        $this->page_label = esc_html__('Transactions', 'event_espresso');
51
-        $this->_admin_base_url = TXN_ADMIN_URL;
52
-        $this->_admin_base_path = TXN_ADMIN;
53
-    }
54
-
55
-
56
-    /**
57
-     *    _ajax_hooks
58
-     *
59
-     * @return void
60
-     */
61
-    protected function _ajax_hooks()
62
-    {
63
-        add_action('wp_ajax_espresso_apply_payment', array($this, 'apply_payments_or_refunds'));
64
-        add_action('wp_ajax_espresso_apply_refund', array($this, 'apply_payments_or_refunds'));
65
-        add_action('wp_ajax_espresso_delete_payment', array($this, 'delete_payment'));
66
-    }
67
-
68
-
69
-    /**
70
-     *    _define_page_props
71
-     *
72
-     * @return void
73
-     */
74
-    protected function _define_page_props()
75
-    {
76
-        $this->_admin_page_title = $this->page_label;
77
-        $this->_labels = array(
78
-            'buttons' => array(
79
-                'add'    => esc_html__('Add New Transaction', 'event_espresso'),
80
-                'edit'   => esc_html__('Edit Transaction', 'event_espresso'),
81
-                'delete' => esc_html__('Delete Transaction', 'event_espresso'),
82
-            ),
83
-        );
84
-    }
85
-
86
-
87
-    /**
88
-     *        grab url requests and route them
89
-     *
90
-     * @access private
91
-     * @return void
92
-     * @throws EE_Error
93
-     * @throws InvalidArgumentException
94
-     * @throws InvalidDataTypeException
95
-     * @throws InvalidInterfaceException
96
-     */
97
-    public function _set_page_routes()
98
-    {
99
-
100
-        $this->_set_transaction_status_array();
101
-
102
-        $txn_id = ! empty($this->_req_data['TXN_ID'])
103
-                  && ! is_array($this->_req_data['TXN_ID'])
104
-            ? $this->_req_data['TXN_ID']
105
-            : 0;
106
-
107
-        $this->_page_routes = array(
108
-
109
-            'default' => array(
110
-                'func'       => '_transactions_overview_list_table',
111
-                'capability' => 'ee_read_transactions',
112
-            ),
113
-
114
-            'view_transaction' => array(
115
-                'func'       => '_transaction_details',
116
-                'capability' => 'ee_read_transaction',
117
-                'obj_id'     => $txn_id,
118
-            ),
119
-
120
-            'send_payment_reminder' => array(
121
-                'func'       => '_send_payment_reminder',
122
-                'noheader'   => true,
123
-                'capability' => 'ee_send_message',
124
-            ),
125
-
126
-            'espresso_apply_payment' => array(
127
-                'func'       => 'apply_payments_or_refunds',
128
-                'noheader'   => true,
129
-                'capability' => 'ee_edit_payments',
130
-            ),
131
-
132
-            'espresso_apply_refund' => array(
133
-                'func'       => 'apply_payments_or_refunds',
134
-                'noheader'   => true,
135
-                'capability' => 'ee_edit_payments',
136
-            ),
137
-
138
-            'espresso_delete_payment' => array(
139
-                'func'       => 'delete_payment',
140
-                'noheader'   => true,
141
-                'capability' => 'ee_delete_payments',
142
-            ),
143
-
144
-            'espresso_recalculate_line_items' => array(
145
-                'func'       => 'recalculateLineItems',
146
-                'noheader'   => true,
147
-                'capability' => 'ee_edit_payments',
148
-            ),
149
-
150
-        );
151
-    }
152
-
153
-
154
-    protected function _set_page_config()
155
-    {
156
-        $this->_page_config = array(
157
-            'default'          => array(
158
-                'nav'           => array(
159
-                    'label' => esc_html__('Overview', 'event_espresso'),
160
-                    'order' => 10,
161
-                ),
162
-                'list_table'    => 'EE_Admin_Transactions_List_Table',
163
-                'help_tabs'     => array(
164
-                    'transactions_overview_help_tab'                       => array(
165
-                        'title'    => esc_html__('Transactions Overview', 'event_espresso'),
166
-                        'filename' => 'transactions_overview',
167
-                    ),
168
-                    'transactions_overview_table_column_headings_help_tab' => array(
169
-                        'title'    => esc_html__('Transactions Table Column Headings', 'event_espresso'),
170
-                        'filename' => 'transactions_overview_table_column_headings',
171
-                    ),
172
-                    'transactions_overview_views_filters_help_tab'         => array(
173
-                        'title'    => esc_html__('Transaction Views & Filters & Search', 'event_espresso'),
174
-                        'filename' => 'transactions_overview_views_filters_search',
175
-                    ),
176
-                ),
177
-                'help_tour'     => array('Transactions_Overview_Help_Tour'),
178
-                /**
179
-                 * commented out because currently we are not displaying tips for transaction list table status but this
180
-                 * may change in a later iteration so want to keep the code for then.
181
-                 */
182
-                // 'qtips' => array( 'Transactions_List_Table_Tips' ),
183
-                'require_nonce' => false,
184
-            ),
185
-            'view_transaction' => array(
186
-                'nav'       => array(
187
-                    'label'      => esc_html__('View Transaction', 'event_espresso'),
188
-                    'order'      => 5,
189
-                    'url'        => isset($this->_req_data['TXN_ID'])
190
-                        ? add_query_arg(array('TXN_ID' => $this->_req_data['TXN_ID']), $this->_current_page_view_url)
191
-                        : $this->_admin_base_url,
192
-                    'persistent' => false,
193
-                ),
194
-                'help_tabs' => array(
195
-                    'transactions_view_transaction_help_tab'                                              => array(
196
-                        'title'    => esc_html__('View Transaction', 'event_espresso'),
197
-                        'filename' => 'transactions_view_transaction',
198
-                    ),
199
-                    'transactions_view_transaction_transaction_details_table_help_tab'                    => array(
200
-                        'title'    => esc_html__('Transaction Details Table', 'event_espresso'),
201
-                        'filename' => 'transactions_view_transaction_transaction_details_table',
202
-                    ),
203
-                    'transactions_view_transaction_attendees_registered_help_tab'                         => array(
204
-                        'title'    => esc_html__('Attendees Registered', 'event_espresso'),
205
-                        'filename' => 'transactions_view_transaction_attendees_registered',
206
-                    ),
207
-                    'transactions_view_transaction_views_primary_registrant_billing_information_help_tab' => array(
208
-                        'title'    => esc_html__('Primary Registrant & Billing Information', 'event_espresso'),
209
-                        'filename' => 'transactions_view_transaction_primary_registrant_billing_information',
210
-                    ),
211
-                ),
212
-                'qtips'     => array('Transaction_Details_Tips'),
213
-                'help_tour' => array('Transaction_Details_Help_Tour'),
214
-                'metaboxes' => array('_transaction_details_metaboxes'),
215
-
216
-                'require_nonce' => false,
217
-            ),
218
-        );
219
-    }
220
-
221
-
222
-    /**
223
-     * The below methods aren't used by this class currently
224
-     */
225
-    protected function _add_screen_options()
226
-    {
227
-        // noop
228
-    }
229
-
230
-
231
-    protected function _add_feature_pointers()
232
-    {
233
-        // noop
234
-    }
235
-
236
-
237
-    public function admin_init()
238
-    {
239
-        // IF a registration was JUST added via the admin...
240
-        if (
241
-            isset(
242
-                $this->_req_data['redirect_from'],
243
-                $this->_req_data['EVT_ID'],
244
-                $this->_req_data['event_name']
245
-            )
246
-        ) {
247
-            // then set a cookie so that we can block any attempts to use
248
-            // the back button as a way to enter another registration.
249
-            setcookie(
250
-                'ee_registration_added',
251
-                $this->_req_data['EVT_ID'],
252
-                time() + WEEK_IN_SECONDS,
253
-                '/'
254
-            );
255
-            // and update the global
256
-            $_COOKIE['ee_registration_added'] = $this->_req_data['EVT_ID'];
257
-        }
258
-        EE_Registry::$i18n_js_strings['invalid_server_response'] = esc_html__(
259
-            '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.',
260
-            'event_espresso'
261
-        );
262
-        EE_Registry::$i18n_js_strings['error_occurred'] = esc_html__(
263
-            'An error occurred! Please refresh the page and try again.',
264
-            'event_espresso'
265
-        );
266
-        EE_Registry::$i18n_js_strings['txn_status_array'] = self::$_txn_status;
267
-        EE_Registry::$i18n_js_strings['pay_status_array'] = self::$_pay_status;
268
-        EE_Registry::$i18n_js_strings['payments_total'] = esc_html__('Payments Total', 'event_espresso');
269
-        EE_Registry::$i18n_js_strings['transaction_overpaid'] = esc_html__(
270
-            'This transaction has been overpaid ! Payments Total',
271
-            'event_espresso'
272
-        );
273
-    }
274
-
275
-
276
-    public function admin_notices()
277
-    {
278
-        // noop
279
-    }
280
-
281
-
282
-    public function admin_footer_scripts()
283
-    {
284
-        // noop
285
-    }
286
-
287
-
288
-    /**
289
-     * _set_transaction_status_array
290
-     * sets list of transaction statuses
291
-     *
292
-     * @access private
293
-     * @return void
294
-     * @throws EE_Error
295
-     * @throws InvalidArgumentException
296
-     * @throws InvalidDataTypeException
297
-     * @throws InvalidInterfaceException
298
-     */
299
-    private function _set_transaction_status_array()
300
-    {
301
-        self::$_txn_status = EEM_Transaction::instance()->status_array(true);
302
-    }
303
-
304
-
305
-    /**
306
-     * get_transaction_status_array
307
-     * return the transaction status array for wp_list_table
308
-     *
309
-     * @access public
310
-     * @return array
311
-     */
312
-    public function get_transaction_status_array()
313
-    {
314
-        return self::$_txn_status;
315
-    }
316
-
317
-
318
-    /**
319
-     *    get list of payment statuses
320
-     *
321
-     * @access private
322
-     * @return void
323
-     * @throws EE_Error
324
-     * @throws InvalidArgumentException
325
-     * @throws InvalidDataTypeException
326
-     * @throws InvalidInterfaceException
327
-     */
328
-    private function _get_payment_status_array()
329
-    {
330
-        self::$_pay_status = EEM_Payment::instance()->status_array(true);
331
-        $this->_template_args['payment_status'] = self::$_pay_status;
332
-    }
333
-
334
-
335
-    /**
336
-     *    _add_screen_options_default
337
-     *
338
-     * @access protected
339
-     * @return void
340
-     * @throws InvalidArgumentException
341
-     * @throws InvalidDataTypeException
342
-     * @throws InvalidInterfaceException
343
-     */
344
-    protected function _add_screen_options_default()
345
-    {
346
-        $this->_per_page_screen_option();
347
-    }
348
-
349
-
350
-    /**
351
-     * load_scripts_styles
352
-     *
353
-     * @access public
354
-     * @return void
355
-     */
356
-    public function load_scripts_styles()
357
-    {
358
-        // enqueue style
359
-        wp_register_style(
360
-            'espresso_txn',
361
-            TXN_ASSETS_URL . 'espresso_transactions_admin.css',
362
-            array(),
363
-            EVENT_ESPRESSO_VERSION
364
-        );
365
-        wp_enqueue_style('espresso_txn');
366
-        // scripts
367
-        wp_register_script(
368
-            'espresso_txn',
369
-            TXN_ASSETS_URL . 'espresso_transactions_admin.js',
370
-            array(
371
-                'ee_admin_js',
372
-                'ee-datepicker',
373
-                'jquery-ui-datepicker',
374
-                'jquery-ui-draggable',
375
-                'ee-dialog',
376
-                'ee-accounting',
377
-                'ee-serialize-full-array',
378
-            ),
379
-            EVENT_ESPRESSO_VERSION,
380
-            true
381
-        );
382
-        wp_enqueue_script('espresso_txn');
383
-    }
384
-
385
-
386
-    /**
387
-     *    load_scripts_styles_view_transaction
388
-     *
389
-     * @access public
390
-     * @return void
391
-     */
392
-    public function load_scripts_styles_view_transaction()
393
-    {
394
-        // styles
395
-        wp_enqueue_style('espresso-ui-theme');
396
-    }
397
-
398
-
399
-    /**
400
-     *    load_scripts_styles_default
401
-     *
402
-     * @access public
403
-     * @return void
404
-     */
405
-    public function load_scripts_styles_default()
406
-    {
407
-        // styles
408
-        wp_enqueue_style('espresso-ui-theme');
409
-    }
410
-
411
-
412
-    /**
413
-     *    _set_list_table_views_default
414
-     *
415
-     * @access protected
416
-     * @return void
417
-     */
418
-    protected function _set_list_table_views_default()
419
-    {
420
-        $this->_views = array(
421
-            'all'        => array(
422
-                'slug'  => 'all',
423
-                'label' => esc_html__('View All Transactions', 'event_espresso'),
424
-                'count' => 0,
425
-            ),
426
-            'abandoned'  => array(
427
-                'slug'  => 'abandoned',
428
-                'label' => esc_html__('Abandoned Transactions', 'event_espresso'),
429
-                'count' => 0,
430
-            ),
431
-            'incomplete' => array(
432
-                'slug'  => 'incomplete',
433
-                'label' => esc_html__('Incomplete Transactions', 'event_espresso'),
434
-                'count' => 0,
435
-            ),
436
-        );
437
-        if (
16
+	/**
17
+	 * @var EE_Transaction
18
+	 */
19
+	private $_transaction;
20
+
21
+	/**
22
+	 * @var EE_Session
23
+	 */
24
+	private $_session;
25
+
26
+	/**
27
+	 * @var array $_txn_status
28
+	 */
29
+	private static $_txn_status;
30
+
31
+	/**
32
+	 * @var array $_pay_status
33
+	 */
34
+	private static $_pay_status;
35
+
36
+	/**
37
+	 * @var array $_existing_reg_payment_REG_IDs
38
+	 */
39
+	protected $_existing_reg_payment_REG_IDs;
40
+
41
+
42
+	/**
43
+	 *    _init_page_props
44
+	 *
45
+	 * @return void
46
+	 */
47
+	protected function _init_page_props()
48
+	{
49
+		$this->page_slug = TXN_PG_SLUG;
50
+		$this->page_label = esc_html__('Transactions', 'event_espresso');
51
+		$this->_admin_base_url = TXN_ADMIN_URL;
52
+		$this->_admin_base_path = TXN_ADMIN;
53
+	}
54
+
55
+
56
+	/**
57
+	 *    _ajax_hooks
58
+	 *
59
+	 * @return void
60
+	 */
61
+	protected function _ajax_hooks()
62
+	{
63
+		add_action('wp_ajax_espresso_apply_payment', array($this, 'apply_payments_or_refunds'));
64
+		add_action('wp_ajax_espresso_apply_refund', array($this, 'apply_payments_or_refunds'));
65
+		add_action('wp_ajax_espresso_delete_payment', array($this, 'delete_payment'));
66
+	}
67
+
68
+
69
+	/**
70
+	 *    _define_page_props
71
+	 *
72
+	 * @return void
73
+	 */
74
+	protected function _define_page_props()
75
+	{
76
+		$this->_admin_page_title = $this->page_label;
77
+		$this->_labels = array(
78
+			'buttons' => array(
79
+				'add'    => esc_html__('Add New Transaction', 'event_espresso'),
80
+				'edit'   => esc_html__('Edit Transaction', 'event_espresso'),
81
+				'delete' => esc_html__('Delete Transaction', 'event_espresso'),
82
+			),
83
+		);
84
+	}
85
+
86
+
87
+	/**
88
+	 *        grab url requests and route them
89
+	 *
90
+	 * @access private
91
+	 * @return void
92
+	 * @throws EE_Error
93
+	 * @throws InvalidArgumentException
94
+	 * @throws InvalidDataTypeException
95
+	 * @throws InvalidInterfaceException
96
+	 */
97
+	public function _set_page_routes()
98
+	{
99
+
100
+		$this->_set_transaction_status_array();
101
+
102
+		$txn_id = ! empty($this->_req_data['TXN_ID'])
103
+				  && ! is_array($this->_req_data['TXN_ID'])
104
+			? $this->_req_data['TXN_ID']
105
+			: 0;
106
+
107
+		$this->_page_routes = array(
108
+
109
+			'default' => array(
110
+				'func'       => '_transactions_overview_list_table',
111
+				'capability' => 'ee_read_transactions',
112
+			),
113
+
114
+			'view_transaction' => array(
115
+				'func'       => '_transaction_details',
116
+				'capability' => 'ee_read_transaction',
117
+				'obj_id'     => $txn_id,
118
+			),
119
+
120
+			'send_payment_reminder' => array(
121
+				'func'       => '_send_payment_reminder',
122
+				'noheader'   => true,
123
+				'capability' => 'ee_send_message',
124
+			),
125
+
126
+			'espresso_apply_payment' => array(
127
+				'func'       => 'apply_payments_or_refunds',
128
+				'noheader'   => true,
129
+				'capability' => 'ee_edit_payments',
130
+			),
131
+
132
+			'espresso_apply_refund' => array(
133
+				'func'       => 'apply_payments_or_refunds',
134
+				'noheader'   => true,
135
+				'capability' => 'ee_edit_payments',
136
+			),
137
+
138
+			'espresso_delete_payment' => array(
139
+				'func'       => 'delete_payment',
140
+				'noheader'   => true,
141
+				'capability' => 'ee_delete_payments',
142
+			),
143
+
144
+			'espresso_recalculate_line_items' => array(
145
+				'func'       => 'recalculateLineItems',
146
+				'noheader'   => true,
147
+				'capability' => 'ee_edit_payments',
148
+			),
149
+
150
+		);
151
+	}
152
+
153
+
154
+	protected function _set_page_config()
155
+	{
156
+		$this->_page_config = array(
157
+			'default'          => array(
158
+				'nav'           => array(
159
+					'label' => esc_html__('Overview', 'event_espresso'),
160
+					'order' => 10,
161
+				),
162
+				'list_table'    => 'EE_Admin_Transactions_List_Table',
163
+				'help_tabs'     => array(
164
+					'transactions_overview_help_tab'                       => array(
165
+						'title'    => esc_html__('Transactions Overview', 'event_espresso'),
166
+						'filename' => 'transactions_overview',
167
+					),
168
+					'transactions_overview_table_column_headings_help_tab' => array(
169
+						'title'    => esc_html__('Transactions Table Column Headings', 'event_espresso'),
170
+						'filename' => 'transactions_overview_table_column_headings',
171
+					),
172
+					'transactions_overview_views_filters_help_tab'         => array(
173
+						'title'    => esc_html__('Transaction Views & Filters & Search', 'event_espresso'),
174
+						'filename' => 'transactions_overview_views_filters_search',
175
+					),
176
+				),
177
+				'help_tour'     => array('Transactions_Overview_Help_Tour'),
178
+				/**
179
+				 * commented out because currently we are not displaying tips for transaction list table status but this
180
+				 * may change in a later iteration so want to keep the code for then.
181
+				 */
182
+				// 'qtips' => array( 'Transactions_List_Table_Tips' ),
183
+				'require_nonce' => false,
184
+			),
185
+			'view_transaction' => array(
186
+				'nav'       => array(
187
+					'label'      => esc_html__('View Transaction', 'event_espresso'),
188
+					'order'      => 5,
189
+					'url'        => isset($this->_req_data['TXN_ID'])
190
+						? add_query_arg(array('TXN_ID' => $this->_req_data['TXN_ID']), $this->_current_page_view_url)
191
+						: $this->_admin_base_url,
192
+					'persistent' => false,
193
+				),
194
+				'help_tabs' => array(
195
+					'transactions_view_transaction_help_tab'                                              => array(
196
+						'title'    => esc_html__('View Transaction', 'event_espresso'),
197
+						'filename' => 'transactions_view_transaction',
198
+					),
199
+					'transactions_view_transaction_transaction_details_table_help_tab'                    => array(
200
+						'title'    => esc_html__('Transaction Details Table', 'event_espresso'),
201
+						'filename' => 'transactions_view_transaction_transaction_details_table',
202
+					),
203
+					'transactions_view_transaction_attendees_registered_help_tab'                         => array(
204
+						'title'    => esc_html__('Attendees Registered', 'event_espresso'),
205
+						'filename' => 'transactions_view_transaction_attendees_registered',
206
+					),
207
+					'transactions_view_transaction_views_primary_registrant_billing_information_help_tab' => array(
208
+						'title'    => esc_html__('Primary Registrant & Billing Information', 'event_espresso'),
209
+						'filename' => 'transactions_view_transaction_primary_registrant_billing_information',
210
+					),
211
+				),
212
+				'qtips'     => array('Transaction_Details_Tips'),
213
+				'help_tour' => array('Transaction_Details_Help_Tour'),
214
+				'metaboxes' => array('_transaction_details_metaboxes'),
215
+
216
+				'require_nonce' => false,
217
+			),
218
+		);
219
+	}
220
+
221
+
222
+	/**
223
+	 * The below methods aren't used by this class currently
224
+	 */
225
+	protected function _add_screen_options()
226
+	{
227
+		// noop
228
+	}
229
+
230
+
231
+	protected function _add_feature_pointers()
232
+	{
233
+		// noop
234
+	}
235
+
236
+
237
+	public function admin_init()
238
+	{
239
+		// IF a registration was JUST added via the admin...
240
+		if (
241
+			isset(
242
+				$this->_req_data['redirect_from'],
243
+				$this->_req_data['EVT_ID'],
244
+				$this->_req_data['event_name']
245
+			)
246
+		) {
247
+			// then set a cookie so that we can block any attempts to use
248
+			// the back button as a way to enter another registration.
249
+			setcookie(
250
+				'ee_registration_added',
251
+				$this->_req_data['EVT_ID'],
252
+				time() + WEEK_IN_SECONDS,
253
+				'/'
254
+			);
255
+			// and update the global
256
+			$_COOKIE['ee_registration_added'] = $this->_req_data['EVT_ID'];
257
+		}
258
+		EE_Registry::$i18n_js_strings['invalid_server_response'] = esc_html__(
259
+			'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.',
260
+			'event_espresso'
261
+		);
262
+		EE_Registry::$i18n_js_strings['error_occurred'] = esc_html__(
263
+			'An error occurred! Please refresh the page and try again.',
264
+			'event_espresso'
265
+		);
266
+		EE_Registry::$i18n_js_strings['txn_status_array'] = self::$_txn_status;
267
+		EE_Registry::$i18n_js_strings['pay_status_array'] = self::$_pay_status;
268
+		EE_Registry::$i18n_js_strings['payments_total'] = esc_html__('Payments Total', 'event_espresso');
269
+		EE_Registry::$i18n_js_strings['transaction_overpaid'] = esc_html__(
270
+			'This transaction has been overpaid ! Payments Total',
271
+			'event_espresso'
272
+		);
273
+	}
274
+
275
+
276
+	public function admin_notices()
277
+	{
278
+		// noop
279
+	}
280
+
281
+
282
+	public function admin_footer_scripts()
283
+	{
284
+		// noop
285
+	}
286
+
287
+
288
+	/**
289
+	 * _set_transaction_status_array
290
+	 * sets list of transaction statuses
291
+	 *
292
+	 * @access private
293
+	 * @return void
294
+	 * @throws EE_Error
295
+	 * @throws InvalidArgumentException
296
+	 * @throws InvalidDataTypeException
297
+	 * @throws InvalidInterfaceException
298
+	 */
299
+	private function _set_transaction_status_array()
300
+	{
301
+		self::$_txn_status = EEM_Transaction::instance()->status_array(true);
302
+	}
303
+
304
+
305
+	/**
306
+	 * get_transaction_status_array
307
+	 * return the transaction status array for wp_list_table
308
+	 *
309
+	 * @access public
310
+	 * @return array
311
+	 */
312
+	public function get_transaction_status_array()
313
+	{
314
+		return self::$_txn_status;
315
+	}
316
+
317
+
318
+	/**
319
+	 *    get list of payment statuses
320
+	 *
321
+	 * @access private
322
+	 * @return void
323
+	 * @throws EE_Error
324
+	 * @throws InvalidArgumentException
325
+	 * @throws InvalidDataTypeException
326
+	 * @throws InvalidInterfaceException
327
+	 */
328
+	private function _get_payment_status_array()
329
+	{
330
+		self::$_pay_status = EEM_Payment::instance()->status_array(true);
331
+		$this->_template_args['payment_status'] = self::$_pay_status;
332
+	}
333
+
334
+
335
+	/**
336
+	 *    _add_screen_options_default
337
+	 *
338
+	 * @access protected
339
+	 * @return void
340
+	 * @throws InvalidArgumentException
341
+	 * @throws InvalidDataTypeException
342
+	 * @throws InvalidInterfaceException
343
+	 */
344
+	protected function _add_screen_options_default()
345
+	{
346
+		$this->_per_page_screen_option();
347
+	}
348
+
349
+
350
+	/**
351
+	 * load_scripts_styles
352
+	 *
353
+	 * @access public
354
+	 * @return void
355
+	 */
356
+	public function load_scripts_styles()
357
+	{
358
+		// enqueue style
359
+		wp_register_style(
360
+			'espresso_txn',
361
+			TXN_ASSETS_URL . 'espresso_transactions_admin.css',
362
+			array(),
363
+			EVENT_ESPRESSO_VERSION
364
+		);
365
+		wp_enqueue_style('espresso_txn');
366
+		// scripts
367
+		wp_register_script(
368
+			'espresso_txn',
369
+			TXN_ASSETS_URL . 'espresso_transactions_admin.js',
370
+			array(
371
+				'ee_admin_js',
372
+				'ee-datepicker',
373
+				'jquery-ui-datepicker',
374
+				'jquery-ui-draggable',
375
+				'ee-dialog',
376
+				'ee-accounting',
377
+				'ee-serialize-full-array',
378
+			),
379
+			EVENT_ESPRESSO_VERSION,
380
+			true
381
+		);
382
+		wp_enqueue_script('espresso_txn');
383
+	}
384
+
385
+
386
+	/**
387
+	 *    load_scripts_styles_view_transaction
388
+	 *
389
+	 * @access public
390
+	 * @return void
391
+	 */
392
+	public function load_scripts_styles_view_transaction()
393
+	{
394
+		// styles
395
+		wp_enqueue_style('espresso-ui-theme');
396
+	}
397
+
398
+
399
+	/**
400
+	 *    load_scripts_styles_default
401
+	 *
402
+	 * @access public
403
+	 * @return void
404
+	 */
405
+	public function load_scripts_styles_default()
406
+	{
407
+		// styles
408
+		wp_enqueue_style('espresso-ui-theme');
409
+	}
410
+
411
+
412
+	/**
413
+	 *    _set_list_table_views_default
414
+	 *
415
+	 * @access protected
416
+	 * @return void
417
+	 */
418
+	protected function _set_list_table_views_default()
419
+	{
420
+		$this->_views = array(
421
+			'all'        => array(
422
+				'slug'  => 'all',
423
+				'label' => esc_html__('View All Transactions', 'event_espresso'),
424
+				'count' => 0,
425
+			),
426
+			'abandoned'  => array(
427
+				'slug'  => 'abandoned',
428
+				'label' => esc_html__('Abandoned Transactions', 'event_espresso'),
429
+				'count' => 0,
430
+			),
431
+			'incomplete' => array(
432
+				'slug'  => 'incomplete',
433
+				'label' => esc_html__('Incomplete Transactions', 'event_espresso'),
434
+				'count' => 0,
435
+			),
436
+		);
437
+		if (
438 438
 /**
439
-         * Filters whether a link to the "Failed Transactions" list table
440
-         * appears on the Transactions Admin Page list table.
441
-         * List display can be turned back on via the following:
442
-         * add_filter(
443
-         *     'FHEE__Transactions_Admin_Page___set_list_table_views_default__display_failed_txns_list',
444
-         *     '__return_true'
445
-         * );
446
-         *
447
-         * @since 4.9.70.p
448
-         * @param boolean                 $display_failed_txns_list
449
-         * @param Transactions_Admin_Page $this
450
-         */
451
-            apply_filters(
452
-                'FHEE__Transactions_Admin_Page___set_list_table_views_default__display_failed_txns_list',
453
-                false,
454
-                $this
455
-            )
456
-        ) {
457
-            $this->_views['failed'] = array(
458
-                'slug'  => 'failed',
459
-                'label' => esc_html__('Failed Transactions', 'event_espresso'),
460
-                'count' => 0,
461
-            );
462
-        }
463
-    }
464
-
465
-
466
-    /**
467
-     * _set_transaction_object
468
-     * This sets the _transaction property for the transaction details screen
469
-     *
470
-     * @access private
471
-     * @return void
472
-     * @throws EE_Error
473
-     * @throws InvalidArgumentException
474
-     * @throws RuntimeException
475
-     * @throws InvalidDataTypeException
476
-     * @throws InvalidInterfaceException
477
-     * @throws ReflectionException
478
-     */
479
-    private function _set_transaction_object()
480
-    {
481
-        if ($this->_transaction instanceof EE_Transaction) {
482
-            return;
483
-        } //get out we've already set the object
484
-
485
-        $TXN_ID = ! empty($this->_req_data['TXN_ID'])
486
-            ? absint($this->_req_data['TXN_ID'])
487
-            : false;
488
-
489
-        // get transaction object
490
-        $this->_transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
491
-        $this->_session = $this->_transaction instanceof EE_Transaction
492
-            ? $this->_transaction->session_data()
493
-            : null;
494
-        if ($this->_transaction instanceof EE_Transaction) {
495
-            $this->_transaction->verify_abandoned_transaction_status();
496
-        }
497
-
498
-        if (! $this->_transaction instanceof EE_Transaction) {
499
-            $error_msg = sprintf(
500
-                esc_html__(
501
-                    'An error occurred and the details for the transaction with the ID # %d could not be retrieved.',
502
-                    'event_espresso'
503
-                ),
504
-                $TXN_ID
505
-            );
506
-            EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
507
-        }
508
-    }
509
-
510
-
511
-    /**
512
-     *    _transaction_legend_items
513
-     *
514
-     * @access protected
515
-     * @return array
516
-     * @throws EE_Error
517
-     * @throws InvalidArgumentException
518
-     * @throws ReflectionException
519
-     * @throws InvalidDataTypeException
520
-     * @throws InvalidInterfaceException
521
-     */
522
-    protected function _transaction_legend_items()
523
-    {
524
-        EE_Registry::instance()->load_helper('MSG_Template');
525
-        $items = array();
526
-
527
-        if (
528
-            EE_Registry::instance()->CAP->current_user_can(
529
-                'ee_read_global_messages',
530
-                'view_filtered_messages'
531
-            )
532
-        ) {
533
-            $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
534
-            if (
535
-                is_array($related_for_icon)
536
-                && isset($related_for_icon['css_class'], $related_for_icon['label'])
537
-            ) {
538
-                $items['view_related_messages'] = array(
539
-                    'class' => $related_for_icon['css_class'],
540
-                    'desc'  => $related_for_icon['label'],
541
-                );
542
-            }
543
-        }
544
-
545
-        $items = apply_filters(
546
-            'FHEE__Transactions_Admin_Page___transaction_legend_items__items',
547
-            array_merge(
548
-                $items,
549
-                array(
550
-                    'view_details'          => array(
551
-                        'class' => 'dashicons dashicons-cart',
552
-                        'desc'  => esc_html__('View Transaction Details', 'event_espresso'),
553
-                    ),
554
-                    'view_invoice'          => array(
555
-                        'class' => 'dashicons dashicons-media-spreadsheet',
556
-                        'desc'  => esc_html__('View Transaction Invoice', 'event_espresso'),
557
-                    ),
558
-                    'view_receipt'          => array(
559
-                        'class' => 'dashicons dashicons-media-default',
560
-                        'desc'  => esc_html__('View Transaction Receipt', 'event_espresso'),
561
-                    ),
562
-                    'view_registration'     => array(
563
-                        'class' => 'dashicons dashicons-clipboard',
564
-                        'desc'  => esc_html__('View Registration Details', 'event_espresso'),
565
-                    ),
566
-                    'payment_overview_link' => array(
567
-                        'class' => 'dashicons dashicons-money',
568
-                        'desc'  => esc_html__('Make Payment on Frontend', 'event_espresso'),
569
-                    ),
570
-                )
571
-            )
572
-        );
573
-
574
-        if (
575
-            EEH_MSG_Template::is_mt_active('payment_reminder')
576
-            && EE_Registry::instance()->CAP->current_user_can(
577
-                'ee_send_message',
578
-                'espresso_transactions_send_payment_reminder'
579
-            )
580
-        ) {
581
-            $items['send_payment_reminder'] = array(
582
-                'class' => 'dashicons dashicons-email-alt',
583
-                'desc'  => esc_html__('Send Payment Reminder', 'event_espresso'),
584
-            );
585
-        }
586
-        $more_items = apply_filters(
587
-            'FHEE__Transactions_Admin_Page___transaction_legend_items__more_items',
588
-            array(
589
-                'overpaid'   => array(
590
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::overpaid_status_code,
591
-                    'desc'  => EEH_Template::pretty_status(
592
-                        EEM_Transaction::overpaid_status_code,
593
-                        false,
594
-                        'sentence'
595
-                    ),
596
-                ),
597
-                'complete'   => array(
598
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::complete_status_code,
599
-                    'desc'  => EEH_Template::pretty_status(
600
-                        EEM_Transaction::complete_status_code,
601
-                        false,
602
-                        'sentence'
603
-                    ),
604
-                ),
605
-                'incomplete' => array(
606
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::incomplete_status_code,
607
-                    'desc'  => EEH_Template::pretty_status(
608
-                        EEM_Transaction::incomplete_status_code,
609
-                        false,
610
-                        'sentence'
611
-                    ),
612
-                ),
613
-                'abandoned'  => array(
614
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::abandoned_status_code,
615
-                    'desc'  => EEH_Template::pretty_status(
616
-                        EEM_Transaction::abandoned_status_code,
617
-                        false,
618
-                        'sentence'
619
-                    ),
620
-                ),
621
-                'failed'     => array(
622
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::failed_status_code,
623
-                    'desc'  => EEH_Template::pretty_status(
624
-                        EEM_Transaction::failed_status_code,
625
-                        false,
626
-                        'sentence'
627
-                    ),
628
-                ),
629
-            )
630
-        );
631
-
632
-        return array_merge($items, $more_items);
633
-    }
634
-
635
-
636
-    /**
637
-     *    _transactions_overview_list_table
638
-     *
639
-     * @access protected
640
-     * @return void
641
-     * @throws DomainException
642
-     * @throws EE_Error
643
-     * @throws InvalidArgumentException
644
-     * @throws InvalidDataTypeException
645
-     * @throws InvalidInterfaceException
646
-     * @throws ReflectionException
647
-     */
648
-    protected function _transactions_overview_list_table()
649
-    {
650
-        $this->_admin_page_title = esc_html__('Transactions', 'event_espresso');
651
-        $event = isset($this->_req_data['EVT_ID'])
652
-            ? EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID'])
653
-            : null;
654
-        $this->_template_args['admin_page_header'] = $event instanceof EE_Event
655
-            ? sprintf(
656
-                esc_html__(
657
-                    '%sViewing Transactions for the Event: %s%s',
658
-                    'event_espresso'
659
-                ),
660
-                '<h3>',
661
-                '<a href="'
662
-                . EE_Admin_Page::add_query_args_and_nonce(
663
-                    array('action' => 'edit', 'post' => $event->ID()),
664
-                    EVENTS_ADMIN_URL
665
-                )
666
-                . '" title="'
667
-                . esc_attr__(
668
-                    'Click to Edit event',
669
-                    'event_espresso'
670
-                )
671
-                . '">' . $event->name() . '</a>',
672
-                '</h3>'
673
-            )
674
-            : '';
675
-        $this->_template_args['after_list_table'] = $this->_display_legend($this->_transaction_legend_items());
676
-        $this->display_admin_list_table_page_with_no_sidebar();
677
-    }
678
-
679
-
680
-    /**
681
-     *    _transaction_details
682
-     * generates HTML for the View Transaction Details Admin page
683
-     *
684
-     * @access protected
685
-     * @return void
686
-     * @throws DomainException
687
-     * @throws EE_Error
688
-     * @throws InvalidArgumentException
689
-     * @throws InvalidDataTypeException
690
-     * @throws InvalidInterfaceException
691
-     * @throws RuntimeException
692
-     * @throws ReflectionException
693
-     */
694
-    protected function _transaction_details()
695
-    {
696
-        do_action('AHEE__Transactions_Admin_Page__transaction_details__start', $this->_transaction);
697
-
698
-        $this->_set_transaction_status_array();
699
-
700
-        $this->_template_args = array();
701
-        $this->_template_args['transactions_page'] = $this->_wp_page_slug;
702
-
703
-        $this->_set_transaction_object();
704
-
705
-        if (! $this->_transaction instanceof EE_Transaction) {
706
-            return;
707
-        }
708
-        $primary_registration = $this->_transaction->primary_registration();
709
-        $attendee = $primary_registration instanceof EE_Registration
710
-            ? $primary_registration->attendee()
711
-            : null;
712
-
713
-        $this->_template_args['txn_nmbr']['value'] = $this->_transaction->ID();
714
-        $this->_template_args['txn_nmbr']['label'] = esc_html__('Transaction Number', 'event_espresso');
715
-
716
-        $this->_template_args['txn_datetime']['value'] = $this->_transaction->get_i18n_datetime('TXN_timestamp');
717
-        $this->_template_args['txn_datetime']['label'] = esc_html__('Date', 'event_espresso');
718
-
719
-        $this->_template_args['txn_status']['value'] = self::$_txn_status[ $this->_transaction->status_ID() ];
720
-        $this->_template_args['txn_status']['label'] = esc_html__('Transaction Status', 'event_espresso');
721
-        $this->_template_args['txn_status']['class'] = 'status-' . $this->_transaction->status_ID();
722
-
723
-        $this->_template_args['grand_total'] = $this->_transaction->total();
724
-        $this->_template_args['total_paid'] = $this->_transaction->paid();
725
-
726
-        $amount_due = $this->_transaction->total() - $this->_transaction->paid();
727
-        $this->_template_args['amount_due'] = EEH_Template::format_currency(
728
-            $amount_due,
729
-            true
730
-        );
731
-        if (EE_Registry::instance()->CFG->currency->sign_b4) {
732
-            $this->_template_args['amount_due'] = EE_Registry::instance()->CFG->currency->sign
733
-                                                  . $this->_template_args['amount_due'];
734
-        } else {
735
-            $this->_template_args['amount_due'] .= EE_Registry::instance()->CFG->currency->sign;
736
-        }
737
-        $this->_template_args['amount_due_class'] = '';
738
-
739
-        if ($this->_transaction->paid() === $this->_transaction->total()) {
740
-            // paid in full
741
-            $this->_template_args['amount_due'] = false;
742
-        } elseif ($this->_transaction->paid() > $this->_transaction->total()) {
743
-            // overpaid
744
-            $this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn';
745
-        } elseif ($this->_transaction->total() > (float) 0) {
746
-            if ($this->_transaction->paid() > (float) 0) {
747
-                // monies owing
748
-                $this->_template_args['amount_due_class'] = 'txn-overview-part-payment-spn';
749
-            } elseif ($this->_transaction->paid() === (float) 0) {
750
-                // no payments made yet
751
-                $this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn';
752
-            }
753
-        } elseif ($this->_transaction->total() === (float) 0) {
754
-            // free event
755
-            $this->_template_args['amount_due'] = false;
756
-        }
757
-
758
-        $payment_method = $this->_transaction->payment_method();
759
-
760
-        $this->_template_args['method_of_payment_name'] = $payment_method instanceof EE_Payment_Method
761
-            ? $payment_method->admin_name()
762
-            : esc_html__('Unknown', 'event_espresso');
763
-
764
-        $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
765
-        // link back to overview
766
-        $this->_template_args['txn_overview_url'] = ! empty($_SERVER['HTTP_REFERER'])
767
-            ? $_SERVER['HTTP_REFERER']
768
-            : TXN_ADMIN_URL;
769
-
770
-
771
-        // next link
772
-        $next_txn = $this->_transaction->next(
773
-            null,
774
-            array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))),
775
-            'TXN_ID'
776
-        );
777
-        $this->_template_args['next_transaction'] = $next_txn
778
-            ? $this->_next_link(
779
-                EE_Admin_Page::add_query_args_and_nonce(
780
-                    array('action' => 'view_transaction', 'TXN_ID' => $next_txn['TXN_ID']),
781
-                    TXN_ADMIN_URL
782
-                ),
783
-                'dashicons dashicons-arrow-right ee-icon-size-22'
784
-            )
785
-            : '';
786
-        // previous link
787
-        $previous_txn = $this->_transaction->previous(
788
-            null,
789
-            array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))),
790
-            'TXN_ID'
791
-        );
792
-        $this->_template_args['previous_transaction'] = $previous_txn
793
-            ? $this->_previous_link(
794
-                EE_Admin_Page::add_query_args_and_nonce(
795
-                    array('action' => 'view_transaction', 'TXN_ID' => $previous_txn['TXN_ID']),
796
-                    TXN_ADMIN_URL
797
-                ),
798
-                'dashicons dashicons-arrow-left ee-icon-size-22'
799
-            )
800
-            : '';
801
-
802
-        // were we just redirected here after adding a new registration ???
803
-        if (
804
-            isset(
805
-                $this->_req_data['redirect_from'],
806
-                $this->_req_data['EVT_ID'],
807
-                $this->_req_data['event_name']
808
-            )
809
-        ) {
810
-            if (
811
-                EE_Registry::instance()->CAP->current_user_can(
812
-                    'ee_edit_registrations',
813
-                    'espresso_registrations_new_registration',
814
-                    $this->_req_data['EVT_ID']
815
-                )
816
-            ) {
817
-                $this->_admin_page_title .= '<a id="add-new-registration" class="add-new-h2 button-primary" href="';
818
-                $this->_admin_page_title .= EE_Admin_Page::add_query_args_and_nonce(
819
-                    array(
820
-                        'page'     => 'espresso_registrations',
821
-                        'action'   => 'new_registration',
822
-                        'return'   => 'default',
823
-                        'TXN_ID'   => $this->_transaction->ID(),
824
-                        'event_id' => $this->_req_data['EVT_ID'],
825
-                    ),
826
-                    REG_ADMIN_URL
827
-                );
828
-                $this->_admin_page_title .= '">';
829
-
830
-                $this->_admin_page_title .= sprintf(
831
-                    esc_html__('Add Another New Registration to Event: "%1$s" ?', 'event_espresso'),
832
-                    htmlentities(urldecode($this->_req_data['event_name']), ENT_QUOTES, 'UTF-8')
833
-                );
834
-                $this->_admin_page_title .= '</a>';
835
-            }
836
-            EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
837
-        }
838
-        // grab messages at the last second
839
-        $this->_template_args['notices'] = EE_Error::get_notices();
840
-        // path to template
841
-        $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_header.template.php';
842
-        $this->_template_args['admin_page_header'] = EEH_Template::display_template(
843
-            $template_path,
844
-            $this->_template_args,
845
-            true
846
-        );
847
-
848
-        // the details template wrapper
849
-        $this->display_admin_page_with_sidebar();
850
-    }
851
-
852
-
853
-    /**
854
-     *        _transaction_details_metaboxes
855
-     *
856
-     * @access protected
857
-     * @return void
858
-     * @throws EE_Error
859
-     * @throws InvalidArgumentException
860
-     * @throws InvalidDataTypeException
861
-     * @throws InvalidInterfaceException
862
-     * @throws RuntimeException
863
-     * @throws ReflectionException
864
-     */
865
-    protected function _transaction_details_metaboxes()
866
-    {
867
-
868
-        $this->_set_transaction_object();
869
-
870
-        if (! $this->_transaction instanceof EE_Transaction) {
871
-            return;
872
-        }
873
-        add_meta_box(
874
-            'edit-txn-details-mbox',
875
-            esc_html__('Transaction Details', 'event_espresso'),
876
-            array($this, 'txn_details_meta_box'),
877
-            $this->_wp_page_slug,
878
-            'normal',
879
-            'high'
880
-        );
881
-        add_meta_box(
882
-            'edit-txn-attendees-mbox',
883
-            esc_html__('Attendees Registered in this Transaction', 'event_espresso'),
884
-            array($this, 'txn_attendees_meta_box'),
885
-            $this->_wp_page_slug,
886
-            'normal',
887
-            'high',
888
-            array('TXN_ID' => $this->_transaction->ID())
889
-        );
890
-        add_meta_box(
891
-            'edit-txn-registrant-mbox',
892
-            esc_html__('Primary Contact', 'event_espresso'),
893
-            array($this, 'txn_registrant_side_meta_box'),
894
-            $this->_wp_page_slug,
895
-            'side',
896
-            'high'
897
-        );
898
-        add_meta_box(
899
-            'edit-txn-billing-info-mbox',
900
-            esc_html__('Billing Information', 'event_espresso'),
901
-            array($this, 'txn_billing_info_side_meta_box'),
902
-            $this->_wp_page_slug,
903
-            'side',
904
-            'high'
905
-        );
906
-    }
907
-
908
-
909
-    /**
910
-     * Callback for transaction actions metabox.
911
-     *
912
-     * @param EE_Transaction|null $transaction
913
-     * @return string
914
-     * @throws DomainException
915
-     * @throws EE_Error
916
-     * @throws InvalidArgumentException
917
-     * @throws InvalidDataTypeException
918
-     * @throws InvalidInterfaceException
919
-     * @throws ReflectionException
920
-     * @throws RuntimeException
921
-     */
922
-    public function getActionButtons(EE_Transaction $transaction = null)
923
-    {
924
-        $content = '';
925
-        $actions = array();
926
-        if (! $transaction instanceof EE_Transaction) {
927
-            return $content;
928
-        }
929
-        /** @var EE_Registration $primary_registration */
930
-        $primary_registration = $transaction->primary_registration();
931
-        $attendee = $primary_registration instanceof EE_Registration
932
-            ? $primary_registration->attendee()
933
-            : null;
934
-
935
-        if (
936
-            $attendee instanceof EE_Attendee
937
-            && EE_Registry::instance()->CAP->current_user_can(
938
-                'ee_send_message',
939
-                'espresso_transactions_send_payment_reminder'
940
-            )
941
-        ) {
942
-            $actions['payment_reminder'] =
943
-                EEH_MSG_Template::is_mt_active('payment_reminder')
944
-                && $this->_transaction->status_ID() !== EEM_Transaction::complete_status_code
945
-                && $this->_transaction->status_ID() !== EEM_Transaction::overpaid_status_code
946
-                    ? EEH_Template::get_button_or_link(
947
-                        EE_Admin_Page::add_query_args_and_nonce(
948
-                            array(
949
-                                'action'      => 'send_payment_reminder',
950
-                                'TXN_ID'      => $this->_transaction->ID(),
951
-                                'redirect_to' => 'view_transaction',
952
-                            ),
953
-                            TXN_ADMIN_URL
954
-                        ),
955
-                        esc_html__(' Send Payment Reminder', 'event_espresso'),
956
-                        'button secondary-button',
957
-                        'dashicons dashicons-email-alt'
958
-                    )
959
-                    : '';
960
-        }
961
-
962
-        if (
963
-            EE_Registry::instance()->CAP->current_user_can(
964
-                'ee_edit_payments',
965
-                'espresso_transactions_recalculate_line_items'
966
-            )
967
-        ) {
968
-            $actions['recalculate_line_items'] = EEH_Template::get_button_or_link(
969
-                EE_Admin_Page::add_query_args_and_nonce(
970
-                    array(
971
-                        'action'      => 'espresso_recalculate_line_items',
972
-                        'TXN_ID'      => $this->_transaction->ID(),
973
-                        'redirect_to' => 'view_transaction',
974
-                    ),
975
-                    TXN_ADMIN_URL
976
-                ),
977
-                esc_html__(' Recalculate Taxes and Total', 'event_espresso'),
978
-                'button secondary-button',
979
-                'dashicons dashicons-update'
980
-            );
981
-        }
982
-
983
-        if (
984
-            $primary_registration instanceof EE_Registration
985
-            && EEH_MSG_Template::is_mt_active('receipt')
986
-        ) {
987
-            $actions['receipt'] = EEH_Template::get_button_or_link(
988
-                $primary_registration->receipt_url(),
989
-                esc_html__('View Receipt', 'event_espresso'),
990
-                'button secondary-button',
991
-                'dashicons dashicons-media-default'
992
-            );
993
-        }
994
-
995
-        if (
996
-            $primary_registration instanceof EE_Registration
997
-            && EEH_MSG_Template::is_mt_active('invoice')
998
-        ) {
999
-            $actions['invoice'] = EEH_Template::get_button_or_link(
1000
-                $primary_registration->invoice_url(),
1001
-                esc_html__('View Invoice', 'event_espresso'),
1002
-                'button secondary-button',
1003
-                'dashicons dashicons-media-spreadsheet'
1004
-            );
1005
-        }
1006
-        $actions = array_filter(
1007
-            apply_filters('FHEE__Transactions_Admin_Page__getActionButtons__actions', $actions, $transaction)
1008
-        );
1009
-        if ($actions) {
1010
-            $content = '<ul>';
1011
-            $content .= '<li>' . implode('</li><li>', $actions) . '</li>';
1012
-            $content .= '</uL>';
1013
-        }
1014
-        return $content;
1015
-    }
1016
-
1017
-
1018
-    /**
1019
-     * txn_details_meta_box
1020
-     * generates HTML for the Transaction main meta box
1021
-     *
1022
-     * @return void
1023
-     * @throws DomainException
1024
-     * @throws EE_Error
1025
-     * @throws InvalidArgumentException
1026
-     * @throws InvalidDataTypeException
1027
-     * @throws InvalidInterfaceException
1028
-     * @throws RuntimeException
1029
-     * @throws ReflectionException
1030
-     */
1031
-    public function txn_details_meta_box()
1032
-    {
1033
-        $this->_set_transaction_object();
1034
-        $this->_template_args['TXN_ID'] = $this->_transaction->ID();
1035
-        $this->_template_args['attendee'] = $this->_transaction->primary_registration() instanceof EE_Registration
1036
-            ? $this->_transaction->primary_registration()->attendee()
1037
-            : null;
1038
-        $this->_template_args['can_edit_payments'] = EE_Registry::instance()->CAP->current_user_can(
1039
-            'ee_edit_payments',
1040
-            'apply_payment_or_refund_from_registration_details'
1041
-        );
1042
-        $this->_template_args['can_delete_payments'] = EE_Registry::instance()->CAP->current_user_can(
1043
-            'ee_delete_payments',
1044
-            'delete_payment_from_registration_details'
1045
-        );
1046
-
1047
-        // get line table
1048
-        EEH_Autoloader::register_line_item_display_autoloaders();
1049
-        $Line_Item_Display = new EE_Line_Item_Display(
1050
-            'admin_table',
1051
-            'EE_Admin_Table_Line_Item_Display_Strategy'
1052
-        );
1053
-        $this->_template_args['line_item_table'] = $Line_Item_Display->display_line_item(
1054
-            $this->_transaction->total_line_item()
1055
-        );
1056
-        $this->_template_args['REG_code'] = $this->_transaction->primary_registration()->reg_code();
1057
-
1058
-        // process taxes
1059
-        $taxes = $this->_transaction->line_items(array(array('LIN_type' => EEM_Line_Item::type_tax)));
1060
-        $this->_template_args['taxes'] = ! empty($taxes) ? $taxes : false;
1061
-
1062
-        $this->_template_args['grand_total'] = EEH_Template::format_currency(
1063
-            $this->_transaction->total(),
1064
-            false,
1065
-            false
1066
-        );
1067
-        $this->_template_args['grand_raw_total'] = $this->_transaction->total();
1068
-        $this->_template_args['TXN_status'] = $this->_transaction->status_ID();
1069
-
1070
-        // process payment details
1071
-        $payments = $this->_transaction->payments();
1072
-        if (! empty($payments)) {
1073
-            $this->_template_args['payments'] = $payments;
1074
-            $this->_template_args['existing_reg_payments'] = $this->_get_registration_payment_IDs($payments);
1075
-        } else {
1076
-            $this->_template_args['payments'] = false;
1077
-            $this->_template_args['existing_reg_payments'] = array();
1078
-        }
1079
-
1080
-        $this->_template_args['edit_payment_url'] = add_query_arg(array('action' => 'edit_payment'), TXN_ADMIN_URL);
1081
-        $this->_template_args['delete_payment_url'] = add_query_arg(
1082
-            array('action' => 'espresso_delete_payment'),
1083
-            TXN_ADMIN_URL
1084
-        );
1085
-
1086
-        if (isset($txn_details['invoice_number'])) {
1087
-            $this->_template_args['txn_details']['invoice_number']['value'] = $this->_template_args['REG_code'];
1088
-            $this->_template_args['txn_details']['invoice_number']['label'] = esc_html__(
1089
-                'Invoice Number',
1090
-                'event_espresso'
1091
-            );
1092
-        }
1093
-
1094
-        $this->_template_args['txn_details']['registration_session']['value'] = $this->_transaction
1095
-            ->primary_registration()
1096
-            ->session_ID();
1097
-        $this->_template_args['txn_details']['registration_session']['label'] = esc_html__(
1098
-            'Registration Session',
1099
-            'event_espresso'
1100
-        );
1101
-
1102
-        $this->_template_args['txn_details']['ip_address']['value'] = isset($this->_session['ip_address'])
1103
-            ? $this->_session['ip_address']
1104
-            : '';
1105
-        $this->_template_args['txn_details']['ip_address']['label'] = esc_html__(
1106
-            'Transaction placed from IP',
1107
-            'event_espresso'
1108
-        );
1109
-
1110
-        $this->_template_args['txn_details']['user_agent']['value'] = isset($this->_session['user_agent'])
1111
-            ? $this->_session['user_agent']
1112
-            : '';
1113
-        $this->_template_args['txn_details']['user_agent']['label'] = esc_html__(
1114
-            'Registrant User Agent',
1115
-            'event_espresso'
1116
-        );
1117
-
1118
-        $reg_steps = '<ul>';
1119
-        foreach ($this->_transaction->reg_steps() as $reg_step => $reg_step_status) {
1120
-            if ($reg_step_status === true) {
1121
-                $reg_steps .= '<li style="color:#70cc50">'
1122
-                              . sprintf(
1123
-                                  esc_html__('%1$s : Completed', 'event_espresso'),
1124
-                                  ucwords(str_replace('_', ' ', $reg_step))
1125
-                              )
1126
-                              . '</li>';
1127
-            } elseif (is_numeric($reg_step_status) && $reg_step_status !== false) {
1128
-                $reg_steps .= '<li style="color:#2EA2CC">'
1129
-                              . sprintf(
1130
-                                  esc_html__('%1$s : Initiated %2$s', 'event_espresso'),
1131
-                                  ucwords(str_replace('_', ' ', $reg_step)),
1132
-                                  date(
1133
-                                      get_option('date_format') . ' ' . get_option('time_format'),
1134
-                                      $reg_step_status + (get_option('gmt_offset') * HOUR_IN_SECONDS)
1135
-                                  )
1136
-                              )
1137
-                              . '</li>';
1138
-            } else {
1139
-                $reg_steps .= '<li style="color:#E76700">'
1140
-                              . sprintf(
1141
-                                  esc_html__('%1$s : Never Initiated', 'event_espresso'),
1142
-                                  ucwords(str_replace('_', ' ', $reg_step))
1143
-                              )
1144
-                              . '</li>';
1145
-            }
1146
-        }
1147
-        $reg_steps .= '</ul>';
1148
-        $this->_template_args['txn_details']['reg_steps']['value'] = $reg_steps;
1149
-        $this->_template_args['txn_details']['reg_steps']['label'] = esc_html__(
1150
-            'Registration Step Progress',
1151
-            'event_espresso'
1152
-        );
1153
-
1154
-
1155
-        $this->_get_registrations_to_apply_payment_to();
1156
-        $this->_get_payment_methods($payments);
1157
-        $this->_get_payment_status_array();
1158
-        $this->_get_reg_status_selection(); // sets up the template args for the reg status array for the transaction.
1159
-
1160
-        $this->_template_args['transaction_form_url'] = add_query_arg(
1161
-            array(
1162
-                'action'  => 'edit_transaction',
1163
-                'process' => 'transaction',
1164
-            ),
1165
-            TXN_ADMIN_URL
1166
-        );
1167
-        $this->_template_args['apply_payment_form_url'] = add_query_arg(
1168
-            array(
1169
-                'page'   => 'espresso_transactions',
1170
-                'action' => 'espresso_apply_payment',
1171
-            ),
1172
-            WP_AJAX_URL
1173
-        );
1174
-        $this->_template_args['delete_payment_form_url'] = add_query_arg(
1175
-            array(
1176
-                'page'   => 'espresso_transactions',
1177
-                'action' => 'espresso_delete_payment',
1178
-            ),
1179
-            WP_AJAX_URL
1180
-        );
1181
-
1182
-        $this->_template_args['action_buttons'] = $this->getActionButtons($this->_transaction);
1183
-
1184
-        // 'espresso_delete_payment_nonce'
1185
-
1186
-        $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_txn_details.template.php';
1187
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);
1188
-    }
1189
-
1190
-
1191
-    /**
1192
-     * _get_registration_payment_IDs
1193
-     *    generates an array of Payment IDs and their corresponding Registration IDs
1194
-     *
1195
-     * @access protected
1196
-     * @param EE_Payment[] $payments
1197
-     * @return array
1198
-     * @throws EE_Error
1199
-     * @throws InvalidArgumentException
1200
-     * @throws InvalidDataTypeException
1201
-     * @throws InvalidInterfaceException
1202
-     * @throws ReflectionException
1203
-     */
1204
-    protected function _get_registration_payment_IDs($payments = array())
1205
-    {
1206
-        $existing_reg_payments = array();
1207
-        // get all reg payments for these payments
1208
-        $reg_payments = EEM_Registration_Payment::instance()->get_all(
1209
-            array(
1210
-                array(
1211
-                    'PAY_ID' => array(
1212
-                        'IN',
1213
-                        array_keys($payments),
1214
-                    ),
1215
-                ),
1216
-            )
1217
-        );
1218
-        if (! empty($reg_payments)) {
1219
-            foreach ($payments as $payment) {
1220
-                if (! $payment instanceof EE_Payment) {
1221
-                    continue;
1222
-                } elseif (! isset($existing_reg_payments[ $payment->ID() ])) {
1223
-                    $existing_reg_payments[ $payment->ID() ] = array();
1224
-                }
1225
-                foreach ($reg_payments as $reg_payment) {
1226
-                    if (
1227
-                        $reg_payment instanceof EE_Registration_Payment
1228
-                        && $reg_payment->payment_ID() === $payment->ID()
1229
-                    ) {
1230
-                        $existing_reg_payments[ $payment->ID() ][] = $reg_payment->registration_ID();
1231
-                    }
1232
-                }
1233
-            }
1234
-        }
1235
-
1236
-        return $existing_reg_payments;
1237
-    }
1238
-
1239
-
1240
-    /**
1241
-     * _get_registrations_to_apply_payment_to
1242
-     *    generates HTML for displaying a series of checkboxes in the admin payment modal window
1243
-     * which allows the admin to only apply the payment to the specific registrations
1244
-     *
1245
-     * @access protected
1246
-     * @return void
1247
-     * @throws EE_Error
1248
-     * @throws InvalidArgumentException
1249
-     * @throws InvalidDataTypeException
1250
-     * @throws InvalidInterfaceException
1251
-     * @throws ReflectionException
1252
-     */
1253
-    protected function _get_registrations_to_apply_payment_to()
1254
-    {
1255
-        // we want any registration with an active status (ie: not deleted or cancelled)
1256
-        $query_params = array(
1257
-            array(
1258
-                'STS_ID' => array(
1259
-                    'IN',
1260
-                    array(
1261
-                        EEM_Registration::status_id_approved,
1262
-                        EEM_Registration::status_id_pending_payment,
1263
-                        EEM_Registration::status_id_not_approved,
1264
-                    ),
1265
-                ),
1266
-            ),
1267
-        );
1268
-        $registrations_to_apply_payment_to = EEH_HTML::br() . EEH_HTML::div(
1269
-            '',
1270
-            'txn-admin-apply-payment-to-registrations-dv',
1271
-            '',
1272
-            'clear: both; margin: 1.5em 0 0; display: none;'
1273
-        );
1274
-        $registrations_to_apply_payment_to .= EEH_HTML::br() . EEH_HTML::div('', '', 'admin-primary-mbox-tbl-wrap');
1275
-        $registrations_to_apply_payment_to .= EEH_HTML::table('', '', 'admin-primary-mbox-tbl');
1276
-        $registrations_to_apply_payment_to .= EEH_HTML::thead(
1277
-            EEH_HTML::tr(
1278
-                EEH_HTML::th(esc_html__('ID', 'event_espresso')) .
1279
-                EEH_HTML::th(esc_html__('Registrant', 'event_espresso')) .
1280
-                EEH_HTML::th(esc_html__('Ticket', 'event_espresso')) .
1281
-                EEH_HTML::th(esc_html__('Event', 'event_espresso')) .
1282
-                EEH_HTML::th(esc_html__('Paid', 'event_espresso'), '', 'txn-admin-payment-paid-td jst-cntr') .
1283
-                EEH_HTML::th(esc_html__('Owing', 'event_espresso'), '', 'txn-admin-payment-owing-td jst-cntr') .
1284
-                EEH_HTML::th(esc_html__('Apply', 'event_espresso'), '', 'jst-cntr')
1285
-            )
1286
-        );
1287
-        $registrations_to_apply_payment_to .= EEH_HTML::tbody();
1288
-        // get registrations for TXN
1289
-        $registrations = $this->_transaction->registrations($query_params);
1290
-        $existing_reg_payments = $this->_template_args['existing_reg_payments'];
1291
-        foreach ($registrations as $registration) {
1292
-            if ($registration instanceof EE_Registration) {
1293
-                $attendee_name = $registration->attendee() instanceof EE_Attendee
1294
-                    ? $registration->attendee()->full_name()
1295
-                    : esc_html__('Unknown Attendee', 'event_espresso');
1296
-                $owing = $registration->final_price() - $registration->paid();
1297
-                $taxable = $registration->ticket()->taxable()
1298
-                    ? ' <span class="smaller-text lt-grey-text"> ' . esc_html__('+ tax', 'event_espresso') . '</span>'
1299
-                    : '';
1300
-                $checked = empty($existing_reg_payments)
1301
-                           || in_array($registration->ID(), $existing_reg_payments, true)
1302
-                    ? ' checked="checked"'
1303
-                    : '';
1304
-                $disabled = $registration->final_price() > 0 ? '' : ' disabled';
1305
-                $registrations_to_apply_payment_to .= EEH_HTML::tr(
1306
-                    EEH_HTML::td($registration->ID()) .
1307
-                    EEH_HTML::td($attendee_name) .
1308
-                    EEH_HTML::td(
1309
-                        $registration->ticket()->name() . ' : ' . $registration->ticket()->pretty_price() . $taxable
1310
-                    ) .
1311
-                    EEH_HTML::td($registration->event_name()) .
1312
-                    EEH_HTML::td($registration->pretty_paid(), '', 'txn-admin-payment-paid-td jst-cntr') .
1313
-                    EEH_HTML::td(
1314
-                        EEH_Template::format_currency($owing),
1315
-                        '',
1316
-                        'txn-admin-payment-owing-td jst-cntr'
1317
-                    ) .
1318
-                    EEH_HTML::td(
1319
-                        '<input type="checkbox" value="' . $registration->ID()
1320
-                        . '" name="txn_admin_payment[registrations]"'
1321
-                        . $checked . $disabled . '>',
1322
-                        '',
1323
-                        'jst-cntr'
1324
-                    ),
1325
-                    'apply-payment-registration-row-' . $registration->ID()
1326
-                );
1327
-            }
1328
-        }
1329
-        $registrations_to_apply_payment_to .= EEH_HTML::tbodyx();
1330
-        $registrations_to_apply_payment_to .= EEH_HTML::tablex();
1331
-        $registrations_to_apply_payment_to .= EEH_HTML::divx();
1332
-        $registrations_to_apply_payment_to .= EEH_HTML::p(
1333
-            esc_html__(
1334
-                '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.',
1335
-                'event_espresso'
1336
-            ),
1337
-            '',
1338
-            'clear description'
1339
-        );
1340
-        $registrations_to_apply_payment_to .= EEH_HTML::divx();
1341
-        $this->_template_args['registrations_to_apply_payment_to'] = $registrations_to_apply_payment_to;
1342
-    }
1343
-
1344
-
1345
-    /**
1346
-     * _get_reg_status_selection
1347
-     *
1348
-     * @todo   this will need to be adjusted either once MER comes along OR we move default reg status to tickets
1349
-     *         instead of events.
1350
-     * @access protected
1351
-     * @return void
1352
-     * @throws EE_Error
1353
-     */
1354
-    protected function _get_reg_status_selection()
1355
-    {
1356
-        // first get all possible statuses
1357
-        $statuses = EEM_Registration::reg_status_array(array(), true);
1358
-        // let's add a "don't change" option.
1359
-        $status_array['NAN'] = esc_html__('Leave the Same', 'event_espresso');
1360
-        $status_array = array_merge($status_array, $statuses);
1361
-        $this->_template_args['status_change_select'] = EEH_Form_Fields::select_input(
1362
-            'txn_reg_status_change[reg_status]',
1363
-            $status_array,
1364
-            'NAN',
1365
-            'id="txn-admin-payment-reg-status-inp"',
1366
-            'txn-reg-status-change-reg-status'
1367
-        );
1368
-        $this->_template_args['delete_status_change_select'] = EEH_Form_Fields::select_input(
1369
-            'delete_txn_reg_status_change[reg_status]',
1370
-            $status_array,
1371
-            'NAN',
1372
-            'delete-txn-admin-payment-reg-status-inp',
1373
-            'delete-txn-reg-status-change-reg-status'
1374
-        );
1375
-    }
1376
-
1377
-
1378
-    /**
1379
-     *    _get_payment_methods
1380
-     * Gets all the payment methods available generally, or the ones that are already
1381
-     * selected on these payments (in case their payment methods are no longer active).
1382
-     * Has the side-effect of updating the template args' payment_methods item
1383
-     *
1384
-     * @access private
1385
-     * @param EE_Payment[] to show on this page
1386
-     * @return void
1387
-     * @throws EE_Error
1388
-     * @throws InvalidArgumentException
1389
-     * @throws InvalidDataTypeException
1390
-     * @throws InvalidInterfaceException
1391
-     * @throws ReflectionException
1392
-     */
1393
-    private function _get_payment_methods($payments = array())
1394
-    {
1395
-        $payment_methods_of_payments = array();
1396
-        foreach ($payments as $payment) {
1397
-            if ($payment instanceof EE_Payment) {
1398
-                $payment_methods_of_payments[] = $payment->ID();
1399
-            }
1400
-        }
1401
-        if ($payment_methods_of_payments) {
1402
-            $query_args = array(
1403
-                array(
1404
-                    'OR*payment_method_for_payment' => array(
1405
-                        'PMD_ID'    => array('IN', $payment_methods_of_payments),
1406
-                        'PMD_scope' => array('LIKE', '%' . EEM_Payment_Method::scope_admin . '%'),
1407
-                    ),
1408
-                ),
1409
-            );
1410
-        } else {
1411
-            $query_args = array(array('PMD_scope' => array('LIKE', '%' . EEM_Payment_Method::scope_admin . '%')));
1412
-        }
1413
-        $this->_template_args['payment_methods'] = EEM_Payment_Method::instance()->get_all($query_args);
1414
-    }
1415
-
1416
-
1417
-    /**
1418
-     * txn_attendees_meta_box
1419
-     *    generates HTML for the Attendees Transaction main meta box
1420
-     *
1421
-     * @access public
1422
-     * @param WP_Post $post
1423
-     * @param array   $metabox
1424
-     * @return void
1425
-     * @throws DomainException
1426
-     * @throws EE_Error
1427
-     * @throws InvalidArgumentException
1428
-     * @throws InvalidDataTypeException
1429
-     * @throws InvalidInterfaceException
1430
-     * @throws ReflectionException
1431
-     */
1432
-    public function txn_attendees_meta_box($post, $metabox = array('args' => array()))
1433
-    {
1434
-
1435
-        /** @noinspection NonSecureExtractUsageInspection */
1436
-        extract($metabox['args']);
1437
-        $this->_template_args['post'] = $post;
1438
-        $this->_template_args['event_attendees'] = array();
1439
-        // process items in cart
1440
-        $line_items = $this->_transaction->get_many_related(
1441
-            'Line_Item',
1442
-            array(array('LIN_type' => 'line-item'))
1443
-        );
1444
-        if (! empty($line_items)) {
1445
-            foreach ($line_items as $item) {
1446
-                if ($item instanceof EE_Line_Item) {
1447
-                    switch ($item->OBJ_type()) {
1448
-                        case 'Event':
1449
-                            break;
1450
-                        case 'Ticket':
1451
-                            $ticket = $item->ticket();
1452
-                            // right now we're only handling tickets here.
1453
-                            // Cause its expected that only tickets will have attendees right?
1454
-                            if (! $ticket instanceof EE_Ticket) {
1455
-                                break;
1456
-                            }
1457
-                            try {
1458
-                                $event_name = $ticket->get_event_name();
1459
-                            } catch (Exception $e) {
1460
-                                EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1461
-                                $event_name = esc_html__('Unknown Event', 'event_espresso');
1462
-                            }
1463
-                            $event_name .= ' - ' . $item->name();
1464
-                            $ticket_price = EEH_Template::format_currency($item->unit_price());
1465
-                            // now get all of the registrations for this transaction that use this ticket
1466
-                            $registrations = $ticket->registrations(
1467
-                                array(array('TXN_ID' => $this->_transaction->ID()))
1468
-                            );
1469
-                            foreach ($registrations as $registration) {
1470
-                                if (! $registration instanceof EE_Registration) {
1471
-                                    break;
1472
-                                }
1473
-                                $this->_template_args['event_attendees'][ $registration->ID() ]['STS_ID']
1474
-                                    = $registration->status_ID();
1475
-                                $this->_template_args['event_attendees'][ $registration->ID() ]['att_num']
1476
-                                    = $registration->count();
1477
-                                $this->_template_args['event_attendees'][ $registration->ID() ]['event_ticket_name']
1478
-                                    = $event_name;
1479
-                                $this->_template_args['event_attendees'][ $registration->ID() ]['ticket_price']
1480
-                                    = $ticket_price;
1481
-                                // attendee info
1482
-                                $attendee = $registration->get_first_related('Attendee');
1483
-                                if ($attendee instanceof EE_Attendee) {
1484
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['att_id']
1485
-                                        = $attendee->ID();
1486
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['attendee']
1487
-                                        = $attendee->full_name();
1488
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['email']
1489
-                                        = '<a href="mailto:' . $attendee->email() . '?subject=' . $event_name
1490
-                                          . esc_html__(
1491
-                                              ' Event',
1492
-                                              'event_espresso'
1493
-                                          )
1494
-                                          . '">' . $attendee->email() . '</a>';
1495
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['address']
1496
-                                        = EEH_Address::format($attendee, 'inline', false, false);
1497
-                                } else {
1498
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['att_id'] = '';
1499
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['attendee'] = '';
1500
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['email'] = '';
1501
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['address'] = '';
1502
-                                }
1503
-                            }
1504
-                            break;
1505
-                    }
1506
-                }
1507
-            }
1508
-
1509
-            $this->_template_args['transaction_form_url'] = add_query_arg(
1510
-                array(
1511
-                    'action'  => 'edit_transaction',
1512
-                    'process' => 'attendees',
1513
-                ),
1514
-                TXN_ADMIN_URL
1515
-            );
1516
-            echo EEH_Template::display_template(
1517
-                TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_attendees.template.php',
1518
-                $this->_template_args,
1519
-                true
1520
-            );
1521
-        } else {
1522
-            echo sprintf(
1523
-                esc_html__(
1524
-                    '%1$sFor some reason, there are no attendees registered for this transaction. Likely the registration was abandoned in process.%2$s',
1525
-                    'event_espresso'
1526
-                ),
1527
-                '<p class="important-notice">',
1528
-                '</p>'
1529
-            );
1530
-        }
1531
-    }
1532
-
1533
-
1534
-    /**
1535
-     * txn_registrant_side_meta_box
1536
-     * generates HTML for the Edit Transaction side meta box
1537
-     *
1538
-     * @access public
1539
-     * @return void
1540
-     * @throws DomainException
1541
-     * @throws EE_Error
1542
-     * @throws InvalidArgumentException
1543
-     * @throws InvalidDataTypeException
1544
-     * @throws InvalidInterfaceException
1545
-     * @throws ReflectionException
1546
-     */
1547
-    public function txn_registrant_side_meta_box()
1548
-    {
1549
-        $primary_att = $this->_transaction->primary_registration() instanceof EE_Registration
1550
-            ? $this->_transaction->primary_registration()->get_first_related('Attendee')
1551
-            : null;
1552
-        if (! $primary_att instanceof EE_Attendee) {
1553
-            $this->_template_args['no_attendee_message'] = esc_html__(
1554
-                'There is no attached contact for this transaction.  The transaction either failed due to an error or was abandoned.',
1555
-                'event_espresso'
1556
-            );
1557
-            $primary_att = EEM_Attendee::instance()->create_default_object();
1558
-        }
1559
-        $this->_template_args['ATT_ID'] = $primary_att->ID();
1560
-        $this->_template_args['prime_reg_fname'] = $primary_att->fname();
1561
-        $this->_template_args['prime_reg_lname'] = $primary_att->lname();
1562
-        $this->_template_args['prime_reg_email'] = $primary_att->email();
1563
-        $this->_template_args['prime_reg_phone'] = $primary_att->phone();
1564
-        $this->_template_args['edit_attendee_url'] = EE_Admin_Page::add_query_args_and_nonce(
1565
-            array(
1566
-                'action' => 'edit_attendee',
1567
-                'post'   => $primary_att->ID(),
1568
-            ),
1569
-            REG_ADMIN_URL
1570
-        );
1571
-        // get formatted address for registrant
1572
-        $this->_template_args['formatted_address'] = EEH_Address::format($primary_att);
1573
-        echo EEH_Template::display_template(
1574
-            TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_registrant.template.php',
1575
-            $this->_template_args,
1576
-            true
1577
-        );
1578
-    }
1579
-
1580
-
1581
-    /**
1582
-     * txn_billing_info_side_meta_box
1583
-     *    generates HTML for the Edit Transaction side meta box
1584
-     *
1585
-     * @access public
1586
-     * @return void
1587
-     * @throws DomainException
1588
-     * @throws EE_Error
1589
-     */
1590
-    public function txn_billing_info_side_meta_box()
1591
-    {
1592
-
1593
-        $this->_template_args['billing_form'] = $this->_transaction->billing_info();
1594
-        $this->_template_args['billing_form_url'] = add_query_arg(
1595
-            array('action' => 'edit_transaction', 'process' => 'billing'),
1596
-            TXN_ADMIN_URL
1597
-        );
1598
-
1599
-        $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_billing_info.template.php';
1600
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);
1601
-    }
1602
-
1603
-
1604
-    /**
1605
-     * apply_payments_or_refunds
1606
-     *    registers a payment or refund made towards a transaction
1607
-     *
1608
-     * @access public
1609
-     * @return void
1610
-     * @throws EE_Error
1611
-     * @throws InvalidArgumentException
1612
-     * @throws ReflectionException
1613
-     * @throws RuntimeException
1614
-     * @throws InvalidDataTypeException
1615
-     * @throws InvalidInterfaceException
1616
-     */
1617
-    public function apply_payments_or_refunds()
1618
-    {
1619
-        $json_response_data = array('return_data' => false);
1620
-        $valid_data = $this->_validate_payment_request_data();
1621
-        $has_access = EE_Registry::instance()->CAP->current_user_can(
1622
-            'ee_edit_payments',
1623
-            'apply_payment_or_refund_from_registration_details'
1624
-        );
1625
-        if (! empty($valid_data) && $has_access) {
1626
-            $PAY_ID = $valid_data['PAY_ID'];
1627
-            // save  the new payment
1628
-            $payment = $this->_create_payment_from_request_data($valid_data);
1629
-            // get the TXN for this payment
1630
-            $transaction = $payment->transaction();
1631
-            // verify transaction
1632
-            if ($transaction instanceof EE_Transaction) {
1633
-                // calculate_total_payments_and_update_status
1634
-                $this->_process_transaction_payments($transaction);
1635
-                $REG_IDs = $this->_get_REG_IDs_to_apply_payment_to($payment);
1636
-                $this->_remove_existing_registration_payments($payment, $PAY_ID);
1637
-                // apply payment to registrations (if applicable)
1638
-                if (! empty($REG_IDs)) {
1639
-                    $this->_update_registration_payments($transaction, $payment, $REG_IDs);
1640
-                    $this->_maybe_send_notifications();
1641
-                    // now process status changes for the same registrations
1642
-                    $this->_process_registration_status_change($transaction, $REG_IDs);
1643
-                }
1644
-                $this->_maybe_send_notifications($payment);
1645
-                // prepare to render page
1646
-                $json_response_data['return_data'] = $this->_build_payment_json_response($payment, $REG_IDs);
1647
-                do_action(
1648
-                    'AHEE__Transactions_Admin_Page__apply_payments_or_refund__after_recording',
1649
-                    $transaction,
1650
-                    $payment
1651
-                );
1652
-            } else {
1653
-                EE_Error::add_error(
1654
-                    esc_html__(
1655
-                        'A valid Transaction for this payment could not be retrieved.',
1656
-                        'event_espresso'
1657
-                    ),
1658
-                    __FILE__,
1659
-                    __FUNCTION__,
1660
-                    __LINE__
1661
-                );
1662
-            }
1663
-        } elseif ($has_access) {
1664
-            EE_Error::add_error(
1665
-                esc_html__(
1666
-                    'The payment form data could not be processed. Please try again.',
1667
-                    'event_espresso'
1668
-                ),
1669
-                __FILE__,
1670
-                __FUNCTION__,
1671
-                __LINE__
1672
-            );
1673
-        } else {
1674
-            EE_Error::add_error(
1675
-                esc_html__(
1676
-                    'You do not have access to apply payments or refunds to a registration.',
1677
-                    'event_espresso'
1678
-                ),
1679
-                __FILE__,
1680
-                __FUNCTION__,
1681
-                __LINE__
1682
-            );
1683
-        }
1684
-        $notices = EE_Error::get_notices(
1685
-            false,
1686
-            false,
1687
-            false
1688
-        );
1689
-        $this->_template_args = array(
1690
-            'data'    => $json_response_data,
1691
-            'error'   => $notices['errors'],
1692
-            'success' => $notices['success'],
1693
-        );
1694
-        $this->_return_json();
1695
-    }
1696
-
1697
-
1698
-    /**
1699
-     * _validate_payment_request_data
1700
-     *
1701
-     * @return array
1702
-     * @throws EE_Error
1703
-     * @throws InvalidArgumentException
1704
-     * @throws InvalidDataTypeException
1705
-     * @throws InvalidInterfaceException
1706
-     */
1707
-    protected function _validate_payment_request_data()
1708
-    {
1709
-        if (! isset($this->_req_data['txn_admin_payment'])) {
1710
-            return array();
1711
-        }
1712
-        $payment_form = $this->_generate_payment_form_section();
1713
-        try {
1714
-            if ($payment_form->was_submitted()) {
1715
-                $payment_form->receive_form_submission();
1716
-                if (! $payment_form->is_valid()) {
1717
-                    $submission_error_messages = array();
1718
-                    foreach ($payment_form->get_validation_errors_accumulated() as $validation_error) {
1719
-                        if ($validation_error instanceof EE_Validation_Error) {
1720
-                            $submission_error_messages[] = sprintf(
1721
-                                _x('%s : %s', 'Form Section Name : Form Validation Error', 'event_espresso'),
1722
-                                $validation_error->get_form_section()->html_label_text(),
1723
-                                $validation_error->getMessage()
1724
-                            );
1725
-                        }
1726
-                    }
1727
-                    EE_Error::add_error(
1728
-                        implode('<br />', $submission_error_messages),
1729
-                        __FILE__,
1730
-                        __FUNCTION__,
1731
-                        __LINE__
1732
-                    );
1733
-                    return array();
1734
-                }
1735
-            }
1736
-        } catch (EE_Error $e) {
1737
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1738
-            return array();
1739
-        }
1740
-
1741
-        return $payment_form->valid_data();
1742
-    }
1743
-
1744
-
1745
-    /**
1746
-     * _generate_payment_form_section
1747
-     *
1748
-     * @return EE_Form_Section_Proper
1749
-     * @throws EE_Error
1750
-     */
1751
-    protected function _generate_payment_form_section()
1752
-    {
1753
-        return new EE_Form_Section_Proper(
1754
-            array(
1755
-                'name'        => 'txn_admin_payment',
1756
-                'subsections' => array(
1757
-                    'PAY_ID'          => new EE_Text_Input(
1758
-                        array(
1759
-                            'default'               => 0,
1760
-                            'required'              => false,
1761
-                            'html_label_text'       => esc_html__('Payment ID', 'event_espresso'),
1762
-                            'validation_strategies' => array(new EE_Int_Normalization()),
1763
-                        )
1764
-                    ),
1765
-                    'TXN_ID'          => new EE_Text_Input(
1766
-                        array(
1767
-                            'default'               => 0,
1768
-                            'required'              => true,
1769
-                            'html_label_text'       => esc_html__('Transaction ID', 'event_espresso'),
1770
-                            'validation_strategies' => array(new EE_Int_Normalization()),
1771
-                        )
1772
-                    ),
1773
-                    'type'            => new EE_Text_Input(
1774
-                        array(
1775
-                            'default'               => 1,
1776
-                            'required'              => true,
1777
-                            'html_label_text'       => esc_html__('Payment or Refund', 'event_espresso'),
1778
-                            'validation_strategies' => array(new EE_Int_Normalization()),
1779
-                        )
1780
-                    ),
1781
-                    'amount'          => new EE_Text_Input(
1782
-                        array(
1783
-                            'default'               => 0,
1784
-                            'required'              => true,
1785
-                            'html_label_text'       => esc_html__('Payment amount', 'event_espresso'),
1786
-                            'validation_strategies' => array(new EE_Float_Normalization()),
1787
-                        )
1788
-                    ),
1789
-                    'status'          => new EE_Text_Input(
1790
-                        array(
1791
-                            'default'         => EEM_Payment::status_id_approved,
1792
-                            'required'        => true,
1793
-                            'html_label_text' => esc_html__('Payment status', 'event_espresso'),
1794
-                        )
1795
-                    ),
1796
-                    'PMD_ID'          => new EE_Text_Input(
1797
-                        array(
1798
-                            'default'               => 2,
1799
-                            'required'              => true,
1800
-                            'html_label_text'       => esc_html__('Payment Method', 'event_espresso'),
1801
-                            'validation_strategies' => array(new EE_Int_Normalization()),
1802
-                        )
1803
-                    ),
1804
-                    'date'            => new EE_Text_Input(
1805
-                        array(
1806
-                            'default'         => time(),
1807
-                            'required'        => true,
1808
-                            'html_label_text' => esc_html__('Payment date', 'event_espresso'),
1809
-                        )
1810
-                    ),
1811
-                    'txn_id_chq_nmbr' => new EE_Text_Input(
1812
-                        array(
1813
-                            'default'               => '',
1814
-                            'required'              => false,
1815
-                            'html_label_text'       => esc_html__('Transaction or Cheque Number', 'event_espresso'),
1816
-                            'validation_strategies' => array(
1817
-                                new EE_Max_Length_Validation_Strategy(
1818
-                                    esc_html__('Input too long', 'event_espresso'),
1819
-                                    100
1820
-                                ),
1821
-                            ),
1822
-                        )
1823
-                    ),
1824
-                    'po_number'       => new EE_Text_Input(
1825
-                        array(
1826
-                            'default'               => '',
1827
-                            'required'              => false,
1828
-                            'html_label_text'       => esc_html__('Purchase Order Number', 'event_espresso'),
1829
-                            'validation_strategies' => array(
1830
-                                new EE_Max_Length_Validation_Strategy(
1831
-                                    esc_html__('Input too long', 'event_espresso'),
1832
-                                    100
1833
-                                ),
1834
-                            ),
1835
-                        )
1836
-                    ),
1837
-                    'accounting'      => new EE_Text_Input(
1838
-                        array(
1839
-                            'default'               => '',
1840
-                            'required'              => false,
1841
-                            'html_label_text'       => esc_html__('Extra Field for Accounting', 'event_espresso'),
1842
-                            'validation_strategies' => array(
1843
-                                new EE_Max_Length_Validation_Strategy(
1844
-                                    esc_html__('Input too long', 'event_espresso'),
1845
-                                    100
1846
-                                ),
1847
-                            ),
1848
-                        )
1849
-                    ),
1850
-                ),
1851
-            )
1852
-        );
1853
-    }
1854
-
1855
-
1856
-    /**
1857
-     * _create_payment_from_request_data
1858
-     *
1859
-     * @param array $valid_data
1860
-     * @return EE_Payment
1861
-     * @throws EE_Error
1862
-     * @throws InvalidArgumentException
1863
-     * @throws InvalidDataTypeException
1864
-     * @throws InvalidInterfaceException
1865
-     * @throws ReflectionException
1866
-     */
1867
-    protected function _create_payment_from_request_data($valid_data)
1868
-    {
1869
-        $PAY_ID = $valid_data['PAY_ID'];
1870
-        // get payment amount
1871
-        $amount = $valid_data['amount'] ? abs($valid_data['amount']) : 0;
1872
-        // payments have a type value of 1 and refunds have a type value of -1
1873
-        // so multiplying amount by type will give a positive value for payments, and negative values for refunds
1874
-        $amount = $valid_data['type'] < 0 ? $amount * -1 : $amount;
1875
-        // for some reason the date string coming in has extra spaces between the date and time.  This fixes that.
1876
-        $date = $valid_data['date']
1877
-            ? preg_replace('/\s+/', ' ', $valid_data['date'])
1878
-            : date('Y-m-d g:i a', current_time('timestamp'));
1879
-        $payment = EE_Payment::new_instance(
1880
-            array(
1881
-                'TXN_ID'              => $valid_data['TXN_ID'],
1882
-                'STS_ID'              => $valid_data['status'],
1883
-                'PAY_timestamp'       => $date,
1884
-                'PAY_source'          => EEM_Payment_Method::scope_admin,
1885
-                'PMD_ID'              => $valid_data['PMD_ID'],
1886
-                'PAY_amount'          => $amount,
1887
-                'PAY_txn_id_chq_nmbr' => $valid_data['txn_id_chq_nmbr'],
1888
-                'PAY_po_number'       => $valid_data['po_number'],
1889
-                'PAY_extra_accntng'   => $valid_data['accounting'],
1890
-                'PAY_details'         => $valid_data,
1891
-                'PAY_ID'              => $PAY_ID,
1892
-            ),
1893
-            '',
1894
-            array('Y-m-d', 'g:i a')
1895
-        );
1896
-
1897
-        if (! $payment->save()) {
1898
-            EE_Error::add_error(
1899
-                sprintf(
1900
-                    esc_html__('Payment %1$d has not been successfully saved to the database.', 'event_espresso'),
1901
-                    $payment->ID()
1902
-                ),
1903
-                __FILE__,
1904
-                __FUNCTION__,
1905
-                __LINE__
1906
-            );
1907
-        }
1908
-
1909
-        return $payment;
1910
-    }
1911
-
1912
-
1913
-    /**
1914
-     * _process_transaction_payments
1915
-     *
1916
-     * @param \EE_Transaction $transaction
1917
-     * @return void
1918
-     * @throws EE_Error
1919
-     * @throws InvalidArgumentException
1920
-     * @throws ReflectionException
1921
-     * @throws InvalidDataTypeException
1922
-     * @throws InvalidInterfaceException
1923
-     */
1924
-    protected function _process_transaction_payments(EE_Transaction $transaction)
1925
-    {
1926
-        /** @type EE_Transaction_Payments $transaction_payments */
1927
-        $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
1928
-        // update the transaction with this payment
1929
-        if ($transaction_payments->calculate_total_payments_and_update_status($transaction)) {
1930
-            EE_Error::add_success(
1931
-                esc_html__(
1932
-                    'The payment has been processed successfully.',
1933
-                    'event_espresso'
1934
-                ),
1935
-                __FILE__,
1936
-                __FUNCTION__,
1937
-                __LINE__
1938
-            );
1939
-        } else {
1940
-            EE_Error::add_error(
1941
-                esc_html__(
1942
-                    'The payment was processed successfully but the amount paid for the transaction was not updated.',
1943
-                    'event_espresso'
1944
-                ),
1945
-                __FILE__,
1946
-                __FUNCTION__,
1947
-                __LINE__
1948
-            );
1949
-        }
1950
-    }
1951
-
1952
-
1953
-    /**
1954
-     * _get_REG_IDs_to_apply_payment_to
1955
-     * returns a list of registration IDs that the payment will apply to
1956
-     *
1957
-     * @param \EE_Payment $payment
1958
-     * @return array
1959
-     * @throws EE_Error
1960
-     * @throws InvalidArgumentException
1961
-     * @throws InvalidDataTypeException
1962
-     * @throws InvalidInterfaceException
1963
-     * @throws ReflectionException
1964
-     */
1965
-    protected function _get_REG_IDs_to_apply_payment_to(EE_Payment $payment)
1966
-    {
1967
-        $REG_IDs = array();
1968
-        // grab array of IDs for specific registrations to apply changes to
1969
-        if (isset($this->_req_data['txn_admin_payment']['registrations'])) {
1970
-            $REG_IDs = (array) $this->_req_data['txn_admin_payment']['registrations'];
1971
-        }
1972
-        // nothing specified ? then get all reg IDs
1973
-        if (empty($REG_IDs)) {
1974
-            $registrations = $payment->transaction()->registrations();
1975
-            $REG_IDs = ! empty($registrations)
1976
-                ? array_keys($registrations)
1977
-                : $this->_get_existing_reg_payment_REG_IDs($payment);
1978
-        }
1979
-
1980
-        // ensure that REG_IDs are integers and NOT strings
1981
-        return array_map('intval', $REG_IDs);
1982
-    }
1983
-
1984
-
1985
-    /**
1986
-     * @return array
1987
-     */
1988
-    public function existing_reg_payment_REG_IDs()
1989
-    {
1990
-        return $this->_existing_reg_payment_REG_IDs;
1991
-    }
1992
-
1993
-
1994
-    /**
1995
-     * @param array $existing_reg_payment_REG_IDs
1996
-     */
1997
-    public function set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs = null)
1998
-    {
1999
-        $this->_existing_reg_payment_REG_IDs = $existing_reg_payment_REG_IDs;
2000
-    }
2001
-
2002
-
2003
-    /**
2004
-     * _get_existing_reg_payment_REG_IDs
2005
-     * returns a list of registration IDs that the payment is currently related to
2006
-     * as recorded in the database
2007
-     *
2008
-     * @param \EE_Payment $payment
2009
-     * @return array
2010
-     * @throws EE_Error
2011
-     * @throws InvalidArgumentException
2012
-     * @throws InvalidDataTypeException
2013
-     * @throws InvalidInterfaceException
2014
-     * @throws ReflectionException
2015
-     */
2016
-    protected function _get_existing_reg_payment_REG_IDs(EE_Payment $payment)
2017
-    {
2018
-        if ($this->existing_reg_payment_REG_IDs() === null) {
2019
-            // let's get any existing reg payment records for this payment
2020
-            $existing_reg_payment_REG_IDs = $payment->get_many_related('Registration');
2021
-            // but we only want the REG IDs, so grab the array keys
2022
-            $existing_reg_payment_REG_IDs = ! empty($existing_reg_payment_REG_IDs)
2023
-                ? array_keys($existing_reg_payment_REG_IDs)
2024
-                : array();
2025
-            $this->set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs);
2026
-        }
2027
-
2028
-        return $this->existing_reg_payment_REG_IDs();
2029
-    }
2030
-
2031
-
2032
-    /**
2033
-     * _remove_existing_registration_payments
2034
-     * this calculates the difference between existing relations
2035
-     * to the supplied payment and the new list registration IDs,
2036
-     * removes any related registrations that no longer apply,
2037
-     * and then updates the registration paid fields
2038
-     *
2039
-     * @param \EE_Payment $payment
2040
-     * @param int         $PAY_ID
2041
-     * @return bool;
2042
-     * @throws EE_Error
2043
-     * @throws InvalidArgumentException
2044
-     * @throws ReflectionException
2045
-     * @throws InvalidDataTypeException
2046
-     * @throws InvalidInterfaceException
2047
-     */
2048
-    protected function _remove_existing_registration_payments(EE_Payment $payment, $PAY_ID = 0)
2049
-    {
2050
-        // newly created payments will have nothing recorded for $PAY_ID
2051
-        if (absint($PAY_ID) === 0) {
2052
-            return false;
2053
-        }
2054
-        $existing_reg_payment_REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment);
2055
-        if (empty($existing_reg_payment_REG_IDs)) {
2056
-            return false;
2057
-        }
2058
-        /** @type EE_Transaction_Payments $transaction_payments */
2059
-        $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
2060
-
2061
-        return $transaction_payments->delete_registration_payments_and_update_registrations(
2062
-            $payment,
2063
-            array(
2064
-                array(
2065
-                    'PAY_ID' => $payment->ID(),
2066
-                    'REG_ID' => array('IN', $existing_reg_payment_REG_IDs),
2067
-                ),
2068
-            )
2069
-        );
2070
-    }
2071
-
2072
-
2073
-    /**
2074
-     * _update_registration_payments
2075
-     * this applies the payments to the selected registrations
2076
-     * but only if they have not already been paid for
2077
-     *
2078
-     * @param  EE_Transaction $transaction
2079
-     * @param \EE_Payment     $payment
2080
-     * @param array           $REG_IDs
2081
-     * @return void
2082
-     * @throws EE_Error
2083
-     * @throws InvalidArgumentException
2084
-     * @throws ReflectionException
2085
-     * @throws RuntimeException
2086
-     * @throws InvalidDataTypeException
2087
-     * @throws InvalidInterfaceException
2088
-     */
2089
-    protected function _update_registration_payments(
2090
-        EE_Transaction $transaction,
2091
-        EE_Payment $payment,
2092
-        $REG_IDs = array()
2093
-    ) {
2094
-        // we can pass our own custom set of registrations to EE_Payment_Processor::process_registration_payments()
2095
-        // so let's do that using our set of REG_IDs from the form
2096
-        $registration_query_where_params = array(
2097
-            'REG_ID' => array('IN', $REG_IDs),
2098
-        );
2099
-        // but add in some conditions regarding payment,
2100
-        // so that we don't apply payments to registrations that are free or have already been paid for
2101
-        // but ONLY if the payment is NOT a refund ( ie: the payment amount is not negative )
2102
-        if (! $payment->is_a_refund()) {
2103
-            $registration_query_where_params['REG_final_price'] = array('!=', 0);
2104
-            $registration_query_where_params['REG_final_price*'] = array('!=', 'REG_paid', true);
2105
-        }
2106
-        $registrations = $transaction->registrations(array($registration_query_where_params));
2107
-        if (! empty($registrations)) {
2108
-            /** @type EE_Payment_Processor $payment_processor */
2109
-            $payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
2110
-            $payment_processor->process_registration_payments($transaction, $payment, $registrations);
2111
-        }
2112
-    }
2113
-
2114
-
2115
-    /**
2116
-     * _process_registration_status_change
2117
-     * This processes requested registration status changes for all the registrations
2118
-     * on a given transaction and (optionally) sends out notifications for the changes.
2119
-     *
2120
-     * @param  EE_Transaction $transaction
2121
-     * @param array           $REG_IDs
2122
-     * @return bool
2123
-     * @throws EE_Error
2124
-     * @throws InvalidArgumentException
2125
-     * @throws ReflectionException
2126
-     * @throws InvalidDataTypeException
2127
-     * @throws InvalidInterfaceException
2128
-     */
2129
-    protected function _process_registration_status_change(EE_Transaction $transaction, $REG_IDs = array())
2130
-    {
2131
-        // first if there is no change in status then we get out.
2132
-        if (
2133
-            ! isset($this->_req_data['txn_reg_status_change']['reg_status'])
2134
-            || $this->_req_data['txn_reg_status_change']['reg_status'] === 'NAN'
2135
-        ) {
2136
-            // no error message, no change requested, just nothing to do man.
2137
-            return false;
2138
-        }
2139
-        /** @type EE_Transaction_Processor $transaction_processor */
2140
-        $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
2141
-
2142
-        // made it here dude?  Oh WOW.  K, let's take care of changing the statuses
2143
-        return $transaction_processor->manually_update_registration_statuses(
2144
-            $transaction,
2145
-            sanitize_text_field($this->_req_data['txn_reg_status_change']['reg_status']),
2146
-            array(array('REG_ID' => array('IN', $REG_IDs)))
2147
-        );
2148
-    }
2149
-
2150
-
2151
-    /**
2152
-     * _build_payment_json_response
2153
-     *
2154
-     * @access public
2155
-     * @param \EE_Payment $payment
2156
-     * @param array       $REG_IDs
2157
-     * @param bool | null $delete_txn_reg_status_change
2158
-     * @return array
2159
-     * @throws EE_Error
2160
-     * @throws InvalidArgumentException
2161
-     * @throws InvalidDataTypeException
2162
-     * @throws InvalidInterfaceException
2163
-     * @throws ReflectionException
2164
-     */
2165
-    protected function _build_payment_json_response(
2166
-        EE_Payment $payment,
2167
-        $REG_IDs = array(),
2168
-        $delete_txn_reg_status_change = null
2169
-    ) {
2170
-        // was the payment deleted ?
2171
-        if (is_bool($delete_txn_reg_status_change)) {
2172
-            return array(
2173
-                'PAY_ID'                       => $payment->ID(),
2174
-                'amount'                       => $payment->amount(),
2175
-                'total_paid'                   => $payment->transaction()->paid(),
2176
-                'txn_status'                   => $payment->transaction()->status_ID(),
2177
-                'pay_status'                   => $payment->STS_ID(),
2178
-                'registrations'                => $this->_registration_payment_data_array($REG_IDs),
2179
-                'delete_txn_reg_status_change' => $delete_txn_reg_status_change,
2180
-            );
2181
-        } else {
2182
-            $this->_get_payment_status_array();
2183
-
2184
-            return array(
2185
-                'amount'           => $payment->amount(),
2186
-                'total_paid'       => $payment->transaction()->paid(),
2187
-                'txn_status'       => $payment->transaction()->status_ID(),
2188
-                'pay_status'       => $payment->STS_ID(),
2189
-                'PAY_ID'           => $payment->ID(),
2190
-                'STS_ID'           => $payment->STS_ID(),
2191
-                'status'           => self::$_pay_status[ $payment->STS_ID() ],
2192
-                'date'             => $payment->timestamp('Y-m-d', 'h:i a'),
2193
-                'method'           => strtoupper($payment->source()),
2194
-                'PM_ID'            => $payment->payment_method() ? $payment->payment_method()->ID() : 1,
2195
-                'gateway'          => $payment->payment_method()
2196
-                    ? $payment->payment_method()->admin_name()
2197
-                    : esc_html__('Unknown', 'event_espresso'),
2198
-                'gateway_response' => $payment->gateway_response(),
2199
-                'txn_id_chq_nmbr'  => $payment->txn_id_chq_nmbr(),
2200
-                'po_number'        => $payment->po_number(),
2201
-                'extra_accntng'    => $payment->extra_accntng(),
2202
-                'registrations'    => $this->_registration_payment_data_array($REG_IDs),
2203
-            );
2204
-        }
2205
-    }
2206
-
2207
-
2208
-    /**
2209
-     * delete_payment
2210
-     *    delete a payment or refund made towards a transaction
2211
-     *
2212
-     * @access public
2213
-     * @return void
2214
-     * @throws EE_Error
2215
-     * @throws InvalidArgumentException
2216
-     * @throws ReflectionException
2217
-     * @throws InvalidDataTypeException
2218
-     * @throws InvalidInterfaceException
2219
-     */
2220
-    public function delete_payment()
2221
-    {
2222
-        $json_response_data = array('return_data' => false);
2223
-        $PAY_ID = isset($this->_req_data['delete_txn_admin_payment']['PAY_ID'])
2224
-            ? absint($this->_req_data['delete_txn_admin_payment']['PAY_ID'])
2225
-            : 0;
2226
-        $can_delete = EE_Registry::instance()->CAP->current_user_can(
2227
-            'ee_delete_payments',
2228
-            'delete_payment_from_registration_details'
2229
-        );
2230
-        if ($PAY_ID && $can_delete) {
2231
-            $delete_txn_reg_status_change = isset($this->_req_data['delete_txn_reg_status_change'])
2232
-                ? $this->_req_data['delete_txn_reg_status_change']
2233
-                : false;
2234
-            $payment = EEM_Payment::instance()->get_one_by_ID($PAY_ID);
2235
-            if ($payment instanceof EE_Payment) {
2236
-                $REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment);
2237
-                /** @type EE_Transaction_Payments $transaction_payments */
2238
-                $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
2239
-                if ($transaction_payments->delete_payment_and_update_transaction($payment)) {
2240
-                    $json_response_data['return_data'] = $this->_build_payment_json_response(
2241
-                        $payment,
2242
-                        $REG_IDs,
2243
-                        $delete_txn_reg_status_change
2244
-                    );
2245
-                    if ($delete_txn_reg_status_change) {
2246
-                        $this->_req_data['txn_reg_status_change'] = $delete_txn_reg_status_change;
2247
-                        // MAKE sure we also add the delete_txn_req_status_change to the
2248
-                        // $_REQUEST global because that's how messages will be looking for it.
2249
-                        $_REQUEST['txn_reg_status_change'] = $delete_txn_reg_status_change;
2250
-                        $this->_maybe_send_notifications();
2251
-                        $this->_process_registration_status_change($payment->transaction(), $REG_IDs);
2252
-                    }
2253
-                }
2254
-            } else {
2255
-                EE_Error::add_error(
2256
-                    esc_html__('Valid Payment data could not be retrieved from the database.', 'event_espresso'),
2257
-                    __FILE__,
2258
-                    __FUNCTION__,
2259
-                    __LINE__
2260
-                );
2261
-            }
2262
-        } elseif ($can_delete) {
2263
-            EE_Error::add_error(
2264
-                esc_html__(
2265
-                    'A valid Payment ID was not received, therefore payment form data could not be loaded.',
2266
-                    'event_espresso'
2267
-                ),
2268
-                __FILE__,
2269
-                __FUNCTION__,
2270
-                __LINE__
2271
-            );
2272
-        } else {
2273
-            EE_Error::add_error(
2274
-                esc_html__(
2275
-                    'You do not have access to delete a payment.',
2276
-                    'event_espresso'
2277
-                ),
2278
-                __FILE__,
2279
-                __FUNCTION__,
2280
-                __LINE__
2281
-            );
2282
-        }
2283
-        $notices = EE_Error::get_notices(false, false, false);
2284
-        $this->_template_args = array(
2285
-            'data'      => $json_response_data,
2286
-            'success'   => $notices['success'],
2287
-            'error'     => $notices['errors'],
2288
-            'attention' => $notices['attention'],
2289
-        );
2290
-        $this->_return_json();
2291
-    }
2292
-
2293
-
2294
-    /**
2295
-     * _registration_payment_data_array
2296
-     * adds info for 'owing' and 'paid' for each registration to the json response
2297
-     *
2298
-     * @access protected
2299
-     * @param array $REG_IDs
2300
-     * @return array
2301
-     * @throws EE_Error
2302
-     * @throws InvalidArgumentException
2303
-     * @throws InvalidDataTypeException
2304
-     * @throws InvalidInterfaceException
2305
-     * @throws ReflectionException
2306
-     */
2307
-    protected function _registration_payment_data_array($REG_IDs)
2308
-    {
2309
-        $registration_payment_data = array();
2310
-        // if non empty reg_ids lets get an array of registrations and update the values for the apply_payment/refund rows.
2311
-        if (! empty($REG_IDs)) {
2312
-            $registrations = EEM_Registration::instance()->get_all(array(array('REG_ID' => array('IN', $REG_IDs))));
2313
-            foreach ($registrations as $registration) {
2314
-                if ($registration instanceof EE_Registration) {
2315
-                    $registration_payment_data[ $registration->ID() ] = array(
2316
-                        'paid'  => $registration->pretty_paid(),
2317
-                        'owing' => EEH_Template::format_currency($registration->final_price() - $registration->paid()),
2318
-                    );
2319
-                }
2320
-            }
2321
-        }
2322
-
2323
-        return $registration_payment_data;
2324
-    }
2325
-
2326
-
2327
-    /**
2328
-     * _maybe_send_notifications
2329
-     * determines whether or not the admin has indicated that notifications should be sent.
2330
-     * If so, will toggle a filter switch for delivering registration notices.
2331
-     * If passed an EE_Payment object, then it will trigger payment notifications instead.
2332
-     *
2333
-     * @access protected
2334
-     * @param \EE_Payment | null $payment
2335
-     */
2336
-    protected function _maybe_send_notifications($payment = null)
2337
-    {
2338
-        switch ($payment instanceof EE_Payment) {
2339
-            // payment notifications
2340
-            case true:
2341
-                if (
2342
-                    isset($this->_req_data['txn_payments']['send_notifications'])
2343
-                    && filter_var(
2344
-                        $this->_req_data['txn_payments']['send_notifications'],
2345
-                        FILTER_VALIDATE_BOOLEAN
2346
-                    )
2347
-                ) {
2348
-                    $this->_process_payment_notification($payment);
2349
-                }
2350
-                break;
2351
-            // registration notifications
2352
-            case false:
2353
-                if (
2354
-                    isset($this->_req_data['txn_reg_status_change']['send_notifications'])
2355
-                    && filter_var(
2356
-                        $this->_req_data['txn_reg_status_change']['send_notifications'],
2357
-                        FILTER_VALIDATE_BOOLEAN
2358
-                    )
2359
-                ) {
2360
-                    add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true');
2361
-                }
2362
-                break;
2363
-        }
2364
-    }
2365
-
2366
-
2367
-    /**
2368
-     * _send_payment_reminder
2369
-     *    generates HTML for the View Transaction Details Admin page
2370
-     *
2371
-     * @access protected
2372
-     * @return void
2373
-     * @throws EE_Error
2374
-     * @throws InvalidArgumentException
2375
-     * @throws InvalidDataTypeException
2376
-     * @throws InvalidInterfaceException
2377
-     */
2378
-    protected function _send_payment_reminder()
2379
-    {
2380
-        $TXN_ID = ! empty($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : false;
2381
-        $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
2382
-        $query_args = isset($this->_req_data['redirect_to']) ? array(
2383
-            'action' => $this->_req_data['redirect_to'],
2384
-            'TXN_ID' => $this->_req_data['TXN_ID'],
2385
-        ) : array();
2386
-        do_action(
2387
-            'AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder',
2388
-            $transaction
2389
-        );
2390
-        $this->_redirect_after_action(
2391
-            false,
2392
-            esc_html__('payment reminder', 'event_espresso'),
2393
-            esc_html__('sent', 'event_espresso'),
2394
-            $query_args,
2395
-            true
2396
-        );
2397
-    }
2398
-
2399
-
2400
-    /**
2401
-     *  get_transactions
2402
-     *    get transactions for given parameters (used by list table)
2403
-     *
2404
-     * @param  int     $perpage how many transactions displayed per page
2405
-     * @param  boolean $count   return the count or objects
2406
-     * @param string   $view
2407
-     * @return mixed int = count || array of transaction objects
2408
-     * @throws EE_Error
2409
-     * @throws InvalidArgumentException
2410
-     * @throws InvalidDataTypeException
2411
-     * @throws InvalidInterfaceException
2412
-     */
2413
-    public function get_transactions($perpage, $count = false, $view = '')
2414
-    {
2415
-
2416
-        $TXN = EEM_Transaction::instance();
2417
-
2418
-        $start_date = isset($this->_req_data['txn-filter-start-date'])
2419
-            ? wp_strip_all_tags($this->_req_data['txn-filter-start-date'])
2420
-            : date(
2421
-                'm/d/Y',
2422
-                strtotime('-10 year')
2423
-            );
2424
-        $end_date = isset($this->_req_data['txn-filter-end-date'])
2425
-            ? wp_strip_all_tags($this->_req_data['txn-filter-end-date'])
2426
-            : date('m/d/Y');
2427
-
2428
-        // make sure our timestamps start and end right at the boundaries for each day
2429
-        $start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00';
2430
-        $end_date = date('Y-m-d', strtotime($end_date)) . ' 23:59:59';
2431
-
2432
-
2433
-        // convert to timestamps
2434
-        $start_date = strtotime($start_date);
2435
-        $end_date = strtotime($end_date);
2436
-
2437
-        // makes sure start date is the lowest value and vice versa
2438
-        $start_date = min($start_date, $end_date);
2439
-        $end_date = max($start_date, $end_date);
2440
-
2441
-        // convert to correct format for query
2442
-        $start_date = EEM_Transaction::instance()->convert_datetime_for_query(
2443
-            'TXN_timestamp',
2444
-            date('Y-m-d H:i:s', $start_date),
2445
-            'Y-m-d H:i:s'
2446
-        );
2447
-        $end_date = EEM_Transaction::instance()->convert_datetime_for_query(
2448
-            'TXN_timestamp',
2449
-            date('Y-m-d H:i:s', $end_date),
2450
-            'Y-m-d H:i:s'
2451
-        );
2452
-
2453
-
2454
-        // set orderby
2455
-        $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
2456
-
2457
-        switch ($this->_req_data['orderby']) {
2458
-            case 'TXN_ID':
2459
-                $orderby = 'TXN_ID';
2460
-                break;
2461
-            case 'ATT_fname':
2462
-                $orderby = 'Registration.Attendee.ATT_fname';
2463
-                break;
2464
-            case 'event_name':
2465
-                $orderby = 'Registration.Event.EVT_name';
2466
-                break;
2467
-            default: // 'TXN_timestamp'
2468
-                $orderby = 'TXN_timestamp';
2469
-        }
2470
-
2471
-        $sort = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC';
2472
-        $current_page = ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1;
2473
-        $per_page = ! empty($perpage) ? $perpage : 10;
2474
-        $per_page = ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page;
2475
-
2476
-        $offset = ($current_page - 1) * $per_page;
2477
-        $limit = array($offset, $per_page);
2478
-
2479
-        $_where = array(
2480
-            'TXN_timestamp'          => array('BETWEEN', array($start_date, $end_date)),
2481
-            'Registration.REG_count' => 1,
2482
-        );
2483
-
2484
-        if (isset($this->_req_data['EVT_ID'])) {
2485
-            $_where['Registration.EVT_ID'] = $this->_req_data['EVT_ID'];
2486
-        }
2487
-
2488
-        if (isset($this->_req_data['s'])) {
2489
-            $search_string = '%' . $this->_req_data['s'] . '%';
2490
-            $_where['OR'] = array(
2491
-                'Registration.Event.EVT_name'         => array('LIKE', $search_string),
2492
-                'Registration.Event.EVT_desc'         => array('LIKE', $search_string),
2493
-                'Registration.Event.EVT_short_desc'   => array('LIKE', $search_string),
2494
-                'Registration.Attendee.ATT_full_name' => array('LIKE', $search_string),
2495
-                'Registration.Attendee.ATT_fname'     => array('LIKE', $search_string),
2496
-                'Registration.Attendee.ATT_lname'     => array('LIKE', $search_string),
2497
-                'Registration.Attendee.ATT_short_bio' => array('LIKE', $search_string),
2498
-                'Registration.Attendee.ATT_email'     => array('LIKE', $search_string),
2499
-                'Registration.Attendee.ATT_address'   => array('LIKE', $search_string),
2500
-                'Registration.Attendee.ATT_address2'  => array('LIKE', $search_string),
2501
-                'Registration.Attendee.ATT_city'      => array('LIKE', $search_string),
2502
-                'Registration.REG_final_price'        => array('LIKE', $search_string),
2503
-                'Registration.REG_code'               => array('LIKE', $search_string),
2504
-                'Registration.REG_count'              => array('LIKE', $search_string),
2505
-                'Registration.REG_group_size'         => array('LIKE', $search_string),
2506
-                'Registration.Ticket.TKT_name'        => array('LIKE', $search_string),
2507
-                'Registration.Ticket.TKT_description' => array('LIKE', $search_string),
2508
-                'Payment.PAY_source'                  => array('LIKE', $search_string),
2509
-                'Payment.Payment_Method.PMD_name'     => array('LIKE', $search_string),
2510
-                'TXN_session_data'                    => array('LIKE', $search_string),
2511
-                'Payment.PAY_txn_id_chq_nmbr'         => array('LIKE', $search_string),
2512
-            );
2513
-        }
2514
-
2515
-        // failed transactions
2516
-        $failed = (! empty($this->_req_data['status']) && $this->_req_data['status'] === 'failed' && ! $count)
2517
-                  || ($count && $view === 'failed');
2518
-        $abandoned = (! empty($this->_req_data['status']) && $this->_req_data['status'] === 'abandoned' && ! $count)
2519
-                     || ($count && $view === 'abandoned');
2520
-        $incomplete = (! empty($this->_req_data['status']) && $this->_req_data['status'] === 'incomplete' && ! $count)
2521
-                      || ($count && $view === 'incomplete');
2522
-
2523
-        if ($failed) {
2524
-            $_where['STS_ID'] = EEM_Transaction::failed_status_code;
2525
-        } elseif ($abandoned) {
2526
-            $_where['STS_ID'] = EEM_Transaction::abandoned_status_code;
2527
-        } elseif ($incomplete) {
2528
-            $_where['STS_ID'] = EEM_Transaction::incomplete_status_code;
2529
-        } else {
2530
-            $_where['STS_ID'] = array('!=', EEM_Transaction::failed_status_code);
2531
-            $_where['STS_ID*'] = array('!=', EEM_Transaction::abandoned_status_code);
2532
-        }
2533
-
2534
-        $query_params = apply_filters(
2535
-            'FHEE__Transactions_Admin_Page___get_transactions_query_params',
2536
-            array(
2537
-                $_where,
2538
-                'order_by'                 => array($orderby => $sort),
2539
-                'limit'                    => $limit,
2540
-                'default_where_conditions' => EEM_Base::default_where_conditions_this_only,
2541
-            ),
2542
-            $this->_req_data,
2543
-            $view,
2544
-            $count
2545
-        );
2546
-
2547
-        $transactions = $count
2548
-            ? $TXN->count(array($query_params[0]), 'TXN_ID', true)
2549
-            : $TXN->get_all($query_params);
2550
-
2551
-        return $transactions;
2552
-    }
2553
-
2554
-
2555
-    /**
2556
-     * @since 4.9.79.p
2557
-     * @throws EE_Error
2558
-     * @throws InvalidArgumentException
2559
-     * @throws InvalidDataTypeException
2560
-     * @throws InvalidInterfaceException
2561
-     * @throws ReflectionException
2562
-     * @throws RuntimeException
2563
-     */
2564
-    public function recalculateLineItems()
2565
-    {
2566
-        $TXN_ID = ! empty($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : false;
2567
-        /** @var EE_Transaction $transaction */
2568
-        $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
2569
-        $total_line_item = $transaction->total_line_item(false);
2570
-        $success = $transaction->recalculateLineItems();
2571
-        $this->_redirect_after_action(
2572
-            (bool) $success,
2573
-            esc_html__('Transaction taxes and totals', 'event_espresso'),
2574
-            esc_html__('recalculated', 'event_espresso'),
2575
-            isset($this->_req_data['redirect_to'])
2576
-                ? array(
2577
-                'action' => $this->_req_data['redirect_to'],
2578
-                'TXN_ID' => $this->_req_data['TXN_ID'],
2579
-            )
2580
-                : array(),
2581
-            true
2582
-        );
2583
-    }
439
+		 * Filters whether a link to the "Failed Transactions" list table
440
+		 * appears on the Transactions Admin Page list table.
441
+		 * List display can be turned back on via the following:
442
+		 * add_filter(
443
+		 *     'FHEE__Transactions_Admin_Page___set_list_table_views_default__display_failed_txns_list',
444
+		 *     '__return_true'
445
+		 * );
446
+		 *
447
+		 * @since 4.9.70.p
448
+		 * @param boolean                 $display_failed_txns_list
449
+		 * @param Transactions_Admin_Page $this
450
+		 */
451
+			apply_filters(
452
+				'FHEE__Transactions_Admin_Page___set_list_table_views_default__display_failed_txns_list',
453
+				false,
454
+				$this
455
+			)
456
+		) {
457
+			$this->_views['failed'] = array(
458
+				'slug'  => 'failed',
459
+				'label' => esc_html__('Failed Transactions', 'event_espresso'),
460
+				'count' => 0,
461
+			);
462
+		}
463
+	}
464
+
465
+
466
+	/**
467
+	 * _set_transaction_object
468
+	 * This sets the _transaction property for the transaction details screen
469
+	 *
470
+	 * @access private
471
+	 * @return void
472
+	 * @throws EE_Error
473
+	 * @throws InvalidArgumentException
474
+	 * @throws RuntimeException
475
+	 * @throws InvalidDataTypeException
476
+	 * @throws InvalidInterfaceException
477
+	 * @throws ReflectionException
478
+	 */
479
+	private function _set_transaction_object()
480
+	{
481
+		if ($this->_transaction instanceof EE_Transaction) {
482
+			return;
483
+		} //get out we've already set the object
484
+
485
+		$TXN_ID = ! empty($this->_req_data['TXN_ID'])
486
+			? absint($this->_req_data['TXN_ID'])
487
+			: false;
488
+
489
+		// get transaction object
490
+		$this->_transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
491
+		$this->_session = $this->_transaction instanceof EE_Transaction
492
+			? $this->_transaction->session_data()
493
+			: null;
494
+		if ($this->_transaction instanceof EE_Transaction) {
495
+			$this->_transaction->verify_abandoned_transaction_status();
496
+		}
497
+
498
+		if (! $this->_transaction instanceof EE_Transaction) {
499
+			$error_msg = sprintf(
500
+				esc_html__(
501
+					'An error occurred and the details for the transaction with the ID # %d could not be retrieved.',
502
+					'event_espresso'
503
+				),
504
+				$TXN_ID
505
+			);
506
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
507
+		}
508
+	}
509
+
510
+
511
+	/**
512
+	 *    _transaction_legend_items
513
+	 *
514
+	 * @access protected
515
+	 * @return array
516
+	 * @throws EE_Error
517
+	 * @throws InvalidArgumentException
518
+	 * @throws ReflectionException
519
+	 * @throws InvalidDataTypeException
520
+	 * @throws InvalidInterfaceException
521
+	 */
522
+	protected function _transaction_legend_items()
523
+	{
524
+		EE_Registry::instance()->load_helper('MSG_Template');
525
+		$items = array();
526
+
527
+		if (
528
+			EE_Registry::instance()->CAP->current_user_can(
529
+				'ee_read_global_messages',
530
+				'view_filtered_messages'
531
+			)
532
+		) {
533
+			$related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
534
+			if (
535
+				is_array($related_for_icon)
536
+				&& isset($related_for_icon['css_class'], $related_for_icon['label'])
537
+			) {
538
+				$items['view_related_messages'] = array(
539
+					'class' => $related_for_icon['css_class'],
540
+					'desc'  => $related_for_icon['label'],
541
+				);
542
+			}
543
+		}
544
+
545
+		$items = apply_filters(
546
+			'FHEE__Transactions_Admin_Page___transaction_legend_items__items',
547
+			array_merge(
548
+				$items,
549
+				array(
550
+					'view_details'          => array(
551
+						'class' => 'dashicons dashicons-cart',
552
+						'desc'  => esc_html__('View Transaction Details', 'event_espresso'),
553
+					),
554
+					'view_invoice'          => array(
555
+						'class' => 'dashicons dashicons-media-spreadsheet',
556
+						'desc'  => esc_html__('View Transaction Invoice', 'event_espresso'),
557
+					),
558
+					'view_receipt'          => array(
559
+						'class' => 'dashicons dashicons-media-default',
560
+						'desc'  => esc_html__('View Transaction Receipt', 'event_espresso'),
561
+					),
562
+					'view_registration'     => array(
563
+						'class' => 'dashicons dashicons-clipboard',
564
+						'desc'  => esc_html__('View Registration Details', 'event_espresso'),
565
+					),
566
+					'payment_overview_link' => array(
567
+						'class' => 'dashicons dashicons-money',
568
+						'desc'  => esc_html__('Make Payment on Frontend', 'event_espresso'),
569
+					),
570
+				)
571
+			)
572
+		);
573
+
574
+		if (
575
+			EEH_MSG_Template::is_mt_active('payment_reminder')
576
+			&& EE_Registry::instance()->CAP->current_user_can(
577
+				'ee_send_message',
578
+				'espresso_transactions_send_payment_reminder'
579
+			)
580
+		) {
581
+			$items['send_payment_reminder'] = array(
582
+				'class' => 'dashicons dashicons-email-alt',
583
+				'desc'  => esc_html__('Send Payment Reminder', 'event_espresso'),
584
+			);
585
+		}
586
+		$more_items = apply_filters(
587
+			'FHEE__Transactions_Admin_Page___transaction_legend_items__more_items',
588
+			array(
589
+				'overpaid'   => array(
590
+					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::overpaid_status_code,
591
+					'desc'  => EEH_Template::pretty_status(
592
+						EEM_Transaction::overpaid_status_code,
593
+						false,
594
+						'sentence'
595
+					),
596
+				),
597
+				'complete'   => array(
598
+					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::complete_status_code,
599
+					'desc'  => EEH_Template::pretty_status(
600
+						EEM_Transaction::complete_status_code,
601
+						false,
602
+						'sentence'
603
+					),
604
+				),
605
+				'incomplete' => array(
606
+					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::incomplete_status_code,
607
+					'desc'  => EEH_Template::pretty_status(
608
+						EEM_Transaction::incomplete_status_code,
609
+						false,
610
+						'sentence'
611
+					),
612
+				),
613
+				'abandoned'  => array(
614
+					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::abandoned_status_code,
615
+					'desc'  => EEH_Template::pretty_status(
616
+						EEM_Transaction::abandoned_status_code,
617
+						false,
618
+						'sentence'
619
+					),
620
+				),
621
+				'failed'     => array(
622
+					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::failed_status_code,
623
+					'desc'  => EEH_Template::pretty_status(
624
+						EEM_Transaction::failed_status_code,
625
+						false,
626
+						'sentence'
627
+					),
628
+				),
629
+			)
630
+		);
631
+
632
+		return array_merge($items, $more_items);
633
+	}
634
+
635
+
636
+	/**
637
+	 *    _transactions_overview_list_table
638
+	 *
639
+	 * @access protected
640
+	 * @return void
641
+	 * @throws DomainException
642
+	 * @throws EE_Error
643
+	 * @throws InvalidArgumentException
644
+	 * @throws InvalidDataTypeException
645
+	 * @throws InvalidInterfaceException
646
+	 * @throws ReflectionException
647
+	 */
648
+	protected function _transactions_overview_list_table()
649
+	{
650
+		$this->_admin_page_title = esc_html__('Transactions', 'event_espresso');
651
+		$event = isset($this->_req_data['EVT_ID'])
652
+			? EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID'])
653
+			: null;
654
+		$this->_template_args['admin_page_header'] = $event instanceof EE_Event
655
+			? sprintf(
656
+				esc_html__(
657
+					'%sViewing Transactions for the Event: %s%s',
658
+					'event_espresso'
659
+				),
660
+				'<h3>',
661
+				'<a href="'
662
+				. EE_Admin_Page::add_query_args_and_nonce(
663
+					array('action' => 'edit', 'post' => $event->ID()),
664
+					EVENTS_ADMIN_URL
665
+				)
666
+				. '" title="'
667
+				. esc_attr__(
668
+					'Click to Edit event',
669
+					'event_espresso'
670
+				)
671
+				. '">' . $event->name() . '</a>',
672
+				'</h3>'
673
+			)
674
+			: '';
675
+		$this->_template_args['after_list_table'] = $this->_display_legend($this->_transaction_legend_items());
676
+		$this->display_admin_list_table_page_with_no_sidebar();
677
+	}
678
+
679
+
680
+	/**
681
+	 *    _transaction_details
682
+	 * generates HTML for the View Transaction Details Admin page
683
+	 *
684
+	 * @access protected
685
+	 * @return void
686
+	 * @throws DomainException
687
+	 * @throws EE_Error
688
+	 * @throws InvalidArgumentException
689
+	 * @throws InvalidDataTypeException
690
+	 * @throws InvalidInterfaceException
691
+	 * @throws RuntimeException
692
+	 * @throws ReflectionException
693
+	 */
694
+	protected function _transaction_details()
695
+	{
696
+		do_action('AHEE__Transactions_Admin_Page__transaction_details__start', $this->_transaction);
697
+
698
+		$this->_set_transaction_status_array();
699
+
700
+		$this->_template_args = array();
701
+		$this->_template_args['transactions_page'] = $this->_wp_page_slug;
702
+
703
+		$this->_set_transaction_object();
704
+
705
+		if (! $this->_transaction instanceof EE_Transaction) {
706
+			return;
707
+		}
708
+		$primary_registration = $this->_transaction->primary_registration();
709
+		$attendee = $primary_registration instanceof EE_Registration
710
+			? $primary_registration->attendee()
711
+			: null;
712
+
713
+		$this->_template_args['txn_nmbr']['value'] = $this->_transaction->ID();
714
+		$this->_template_args['txn_nmbr']['label'] = esc_html__('Transaction Number', 'event_espresso');
715
+
716
+		$this->_template_args['txn_datetime']['value'] = $this->_transaction->get_i18n_datetime('TXN_timestamp');
717
+		$this->_template_args['txn_datetime']['label'] = esc_html__('Date', 'event_espresso');
718
+
719
+		$this->_template_args['txn_status']['value'] = self::$_txn_status[ $this->_transaction->status_ID() ];
720
+		$this->_template_args['txn_status']['label'] = esc_html__('Transaction Status', 'event_espresso');
721
+		$this->_template_args['txn_status']['class'] = 'status-' . $this->_transaction->status_ID();
722
+
723
+		$this->_template_args['grand_total'] = $this->_transaction->total();
724
+		$this->_template_args['total_paid'] = $this->_transaction->paid();
725
+
726
+		$amount_due = $this->_transaction->total() - $this->_transaction->paid();
727
+		$this->_template_args['amount_due'] = EEH_Template::format_currency(
728
+			$amount_due,
729
+			true
730
+		);
731
+		if (EE_Registry::instance()->CFG->currency->sign_b4) {
732
+			$this->_template_args['amount_due'] = EE_Registry::instance()->CFG->currency->sign
733
+												  . $this->_template_args['amount_due'];
734
+		} else {
735
+			$this->_template_args['amount_due'] .= EE_Registry::instance()->CFG->currency->sign;
736
+		}
737
+		$this->_template_args['amount_due_class'] = '';
738
+
739
+		if ($this->_transaction->paid() === $this->_transaction->total()) {
740
+			// paid in full
741
+			$this->_template_args['amount_due'] = false;
742
+		} elseif ($this->_transaction->paid() > $this->_transaction->total()) {
743
+			// overpaid
744
+			$this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn';
745
+		} elseif ($this->_transaction->total() > (float) 0) {
746
+			if ($this->_transaction->paid() > (float) 0) {
747
+				// monies owing
748
+				$this->_template_args['amount_due_class'] = 'txn-overview-part-payment-spn';
749
+			} elseif ($this->_transaction->paid() === (float) 0) {
750
+				// no payments made yet
751
+				$this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn';
752
+			}
753
+		} elseif ($this->_transaction->total() === (float) 0) {
754
+			// free event
755
+			$this->_template_args['amount_due'] = false;
756
+		}
757
+
758
+		$payment_method = $this->_transaction->payment_method();
759
+
760
+		$this->_template_args['method_of_payment_name'] = $payment_method instanceof EE_Payment_Method
761
+			? $payment_method->admin_name()
762
+			: esc_html__('Unknown', 'event_espresso');
763
+
764
+		$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
765
+		// link back to overview
766
+		$this->_template_args['txn_overview_url'] = ! empty($_SERVER['HTTP_REFERER'])
767
+			? $_SERVER['HTTP_REFERER']
768
+			: TXN_ADMIN_URL;
769
+
770
+
771
+		// next link
772
+		$next_txn = $this->_transaction->next(
773
+			null,
774
+			array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))),
775
+			'TXN_ID'
776
+		);
777
+		$this->_template_args['next_transaction'] = $next_txn
778
+			? $this->_next_link(
779
+				EE_Admin_Page::add_query_args_and_nonce(
780
+					array('action' => 'view_transaction', 'TXN_ID' => $next_txn['TXN_ID']),
781
+					TXN_ADMIN_URL
782
+				),
783
+				'dashicons dashicons-arrow-right ee-icon-size-22'
784
+			)
785
+			: '';
786
+		// previous link
787
+		$previous_txn = $this->_transaction->previous(
788
+			null,
789
+			array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))),
790
+			'TXN_ID'
791
+		);
792
+		$this->_template_args['previous_transaction'] = $previous_txn
793
+			? $this->_previous_link(
794
+				EE_Admin_Page::add_query_args_and_nonce(
795
+					array('action' => 'view_transaction', 'TXN_ID' => $previous_txn['TXN_ID']),
796
+					TXN_ADMIN_URL
797
+				),
798
+				'dashicons dashicons-arrow-left ee-icon-size-22'
799
+			)
800
+			: '';
801
+
802
+		// were we just redirected here after adding a new registration ???
803
+		if (
804
+			isset(
805
+				$this->_req_data['redirect_from'],
806
+				$this->_req_data['EVT_ID'],
807
+				$this->_req_data['event_name']
808
+			)
809
+		) {
810
+			if (
811
+				EE_Registry::instance()->CAP->current_user_can(
812
+					'ee_edit_registrations',
813
+					'espresso_registrations_new_registration',
814
+					$this->_req_data['EVT_ID']
815
+				)
816
+			) {
817
+				$this->_admin_page_title .= '<a id="add-new-registration" class="add-new-h2 button-primary" href="';
818
+				$this->_admin_page_title .= EE_Admin_Page::add_query_args_and_nonce(
819
+					array(
820
+						'page'     => 'espresso_registrations',
821
+						'action'   => 'new_registration',
822
+						'return'   => 'default',
823
+						'TXN_ID'   => $this->_transaction->ID(),
824
+						'event_id' => $this->_req_data['EVT_ID'],
825
+					),
826
+					REG_ADMIN_URL
827
+				);
828
+				$this->_admin_page_title .= '">';
829
+
830
+				$this->_admin_page_title .= sprintf(
831
+					esc_html__('Add Another New Registration to Event: "%1$s" ?', 'event_espresso'),
832
+					htmlentities(urldecode($this->_req_data['event_name']), ENT_QUOTES, 'UTF-8')
833
+				);
834
+				$this->_admin_page_title .= '</a>';
835
+			}
836
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
837
+		}
838
+		// grab messages at the last second
839
+		$this->_template_args['notices'] = EE_Error::get_notices();
840
+		// path to template
841
+		$template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_header.template.php';
842
+		$this->_template_args['admin_page_header'] = EEH_Template::display_template(
843
+			$template_path,
844
+			$this->_template_args,
845
+			true
846
+		);
847
+
848
+		// the details template wrapper
849
+		$this->display_admin_page_with_sidebar();
850
+	}
851
+
852
+
853
+	/**
854
+	 *        _transaction_details_metaboxes
855
+	 *
856
+	 * @access protected
857
+	 * @return void
858
+	 * @throws EE_Error
859
+	 * @throws InvalidArgumentException
860
+	 * @throws InvalidDataTypeException
861
+	 * @throws InvalidInterfaceException
862
+	 * @throws RuntimeException
863
+	 * @throws ReflectionException
864
+	 */
865
+	protected function _transaction_details_metaboxes()
866
+	{
867
+
868
+		$this->_set_transaction_object();
869
+
870
+		if (! $this->_transaction instanceof EE_Transaction) {
871
+			return;
872
+		}
873
+		add_meta_box(
874
+			'edit-txn-details-mbox',
875
+			esc_html__('Transaction Details', 'event_espresso'),
876
+			array($this, 'txn_details_meta_box'),
877
+			$this->_wp_page_slug,
878
+			'normal',
879
+			'high'
880
+		);
881
+		add_meta_box(
882
+			'edit-txn-attendees-mbox',
883
+			esc_html__('Attendees Registered in this Transaction', 'event_espresso'),
884
+			array($this, 'txn_attendees_meta_box'),
885
+			$this->_wp_page_slug,
886
+			'normal',
887
+			'high',
888
+			array('TXN_ID' => $this->_transaction->ID())
889
+		);
890
+		add_meta_box(
891
+			'edit-txn-registrant-mbox',
892
+			esc_html__('Primary Contact', 'event_espresso'),
893
+			array($this, 'txn_registrant_side_meta_box'),
894
+			$this->_wp_page_slug,
895
+			'side',
896
+			'high'
897
+		);
898
+		add_meta_box(
899
+			'edit-txn-billing-info-mbox',
900
+			esc_html__('Billing Information', 'event_espresso'),
901
+			array($this, 'txn_billing_info_side_meta_box'),
902
+			$this->_wp_page_slug,
903
+			'side',
904
+			'high'
905
+		);
906
+	}
907
+
908
+
909
+	/**
910
+	 * Callback for transaction actions metabox.
911
+	 *
912
+	 * @param EE_Transaction|null $transaction
913
+	 * @return string
914
+	 * @throws DomainException
915
+	 * @throws EE_Error
916
+	 * @throws InvalidArgumentException
917
+	 * @throws InvalidDataTypeException
918
+	 * @throws InvalidInterfaceException
919
+	 * @throws ReflectionException
920
+	 * @throws RuntimeException
921
+	 */
922
+	public function getActionButtons(EE_Transaction $transaction = null)
923
+	{
924
+		$content = '';
925
+		$actions = array();
926
+		if (! $transaction instanceof EE_Transaction) {
927
+			return $content;
928
+		}
929
+		/** @var EE_Registration $primary_registration */
930
+		$primary_registration = $transaction->primary_registration();
931
+		$attendee = $primary_registration instanceof EE_Registration
932
+			? $primary_registration->attendee()
933
+			: null;
934
+
935
+		if (
936
+			$attendee instanceof EE_Attendee
937
+			&& EE_Registry::instance()->CAP->current_user_can(
938
+				'ee_send_message',
939
+				'espresso_transactions_send_payment_reminder'
940
+			)
941
+		) {
942
+			$actions['payment_reminder'] =
943
+				EEH_MSG_Template::is_mt_active('payment_reminder')
944
+				&& $this->_transaction->status_ID() !== EEM_Transaction::complete_status_code
945
+				&& $this->_transaction->status_ID() !== EEM_Transaction::overpaid_status_code
946
+					? EEH_Template::get_button_or_link(
947
+						EE_Admin_Page::add_query_args_and_nonce(
948
+							array(
949
+								'action'      => 'send_payment_reminder',
950
+								'TXN_ID'      => $this->_transaction->ID(),
951
+								'redirect_to' => 'view_transaction',
952
+							),
953
+							TXN_ADMIN_URL
954
+						),
955
+						esc_html__(' Send Payment Reminder', 'event_espresso'),
956
+						'button secondary-button',
957
+						'dashicons dashicons-email-alt'
958
+					)
959
+					: '';
960
+		}
961
+
962
+		if (
963
+			EE_Registry::instance()->CAP->current_user_can(
964
+				'ee_edit_payments',
965
+				'espresso_transactions_recalculate_line_items'
966
+			)
967
+		) {
968
+			$actions['recalculate_line_items'] = EEH_Template::get_button_or_link(
969
+				EE_Admin_Page::add_query_args_and_nonce(
970
+					array(
971
+						'action'      => 'espresso_recalculate_line_items',
972
+						'TXN_ID'      => $this->_transaction->ID(),
973
+						'redirect_to' => 'view_transaction',
974
+					),
975
+					TXN_ADMIN_URL
976
+				),
977
+				esc_html__(' Recalculate Taxes and Total', 'event_espresso'),
978
+				'button secondary-button',
979
+				'dashicons dashicons-update'
980
+			);
981
+		}
982
+
983
+		if (
984
+			$primary_registration instanceof EE_Registration
985
+			&& EEH_MSG_Template::is_mt_active('receipt')
986
+		) {
987
+			$actions['receipt'] = EEH_Template::get_button_or_link(
988
+				$primary_registration->receipt_url(),
989
+				esc_html__('View Receipt', 'event_espresso'),
990
+				'button secondary-button',
991
+				'dashicons dashicons-media-default'
992
+			);
993
+		}
994
+
995
+		if (
996
+			$primary_registration instanceof EE_Registration
997
+			&& EEH_MSG_Template::is_mt_active('invoice')
998
+		) {
999
+			$actions['invoice'] = EEH_Template::get_button_or_link(
1000
+				$primary_registration->invoice_url(),
1001
+				esc_html__('View Invoice', 'event_espresso'),
1002
+				'button secondary-button',
1003
+				'dashicons dashicons-media-spreadsheet'
1004
+			);
1005
+		}
1006
+		$actions = array_filter(
1007
+			apply_filters('FHEE__Transactions_Admin_Page__getActionButtons__actions', $actions, $transaction)
1008
+		);
1009
+		if ($actions) {
1010
+			$content = '<ul>';
1011
+			$content .= '<li>' . implode('</li><li>', $actions) . '</li>';
1012
+			$content .= '</uL>';
1013
+		}
1014
+		return $content;
1015
+	}
1016
+
1017
+
1018
+	/**
1019
+	 * txn_details_meta_box
1020
+	 * generates HTML for the Transaction main meta box
1021
+	 *
1022
+	 * @return void
1023
+	 * @throws DomainException
1024
+	 * @throws EE_Error
1025
+	 * @throws InvalidArgumentException
1026
+	 * @throws InvalidDataTypeException
1027
+	 * @throws InvalidInterfaceException
1028
+	 * @throws RuntimeException
1029
+	 * @throws ReflectionException
1030
+	 */
1031
+	public function txn_details_meta_box()
1032
+	{
1033
+		$this->_set_transaction_object();
1034
+		$this->_template_args['TXN_ID'] = $this->_transaction->ID();
1035
+		$this->_template_args['attendee'] = $this->_transaction->primary_registration() instanceof EE_Registration
1036
+			? $this->_transaction->primary_registration()->attendee()
1037
+			: null;
1038
+		$this->_template_args['can_edit_payments'] = EE_Registry::instance()->CAP->current_user_can(
1039
+			'ee_edit_payments',
1040
+			'apply_payment_or_refund_from_registration_details'
1041
+		);
1042
+		$this->_template_args['can_delete_payments'] = EE_Registry::instance()->CAP->current_user_can(
1043
+			'ee_delete_payments',
1044
+			'delete_payment_from_registration_details'
1045
+		);
1046
+
1047
+		// get line table
1048
+		EEH_Autoloader::register_line_item_display_autoloaders();
1049
+		$Line_Item_Display = new EE_Line_Item_Display(
1050
+			'admin_table',
1051
+			'EE_Admin_Table_Line_Item_Display_Strategy'
1052
+		);
1053
+		$this->_template_args['line_item_table'] = $Line_Item_Display->display_line_item(
1054
+			$this->_transaction->total_line_item()
1055
+		);
1056
+		$this->_template_args['REG_code'] = $this->_transaction->primary_registration()->reg_code();
1057
+
1058
+		// process taxes
1059
+		$taxes = $this->_transaction->line_items(array(array('LIN_type' => EEM_Line_Item::type_tax)));
1060
+		$this->_template_args['taxes'] = ! empty($taxes) ? $taxes : false;
1061
+
1062
+		$this->_template_args['grand_total'] = EEH_Template::format_currency(
1063
+			$this->_transaction->total(),
1064
+			false,
1065
+			false
1066
+		);
1067
+		$this->_template_args['grand_raw_total'] = $this->_transaction->total();
1068
+		$this->_template_args['TXN_status'] = $this->_transaction->status_ID();
1069
+
1070
+		// process payment details
1071
+		$payments = $this->_transaction->payments();
1072
+		if (! empty($payments)) {
1073
+			$this->_template_args['payments'] = $payments;
1074
+			$this->_template_args['existing_reg_payments'] = $this->_get_registration_payment_IDs($payments);
1075
+		} else {
1076
+			$this->_template_args['payments'] = false;
1077
+			$this->_template_args['existing_reg_payments'] = array();
1078
+		}
1079
+
1080
+		$this->_template_args['edit_payment_url'] = add_query_arg(array('action' => 'edit_payment'), TXN_ADMIN_URL);
1081
+		$this->_template_args['delete_payment_url'] = add_query_arg(
1082
+			array('action' => 'espresso_delete_payment'),
1083
+			TXN_ADMIN_URL
1084
+		);
1085
+
1086
+		if (isset($txn_details['invoice_number'])) {
1087
+			$this->_template_args['txn_details']['invoice_number']['value'] = $this->_template_args['REG_code'];
1088
+			$this->_template_args['txn_details']['invoice_number']['label'] = esc_html__(
1089
+				'Invoice Number',
1090
+				'event_espresso'
1091
+			);
1092
+		}
1093
+
1094
+		$this->_template_args['txn_details']['registration_session']['value'] = $this->_transaction
1095
+			->primary_registration()
1096
+			->session_ID();
1097
+		$this->_template_args['txn_details']['registration_session']['label'] = esc_html__(
1098
+			'Registration Session',
1099
+			'event_espresso'
1100
+		);
1101
+
1102
+		$this->_template_args['txn_details']['ip_address']['value'] = isset($this->_session['ip_address'])
1103
+			? $this->_session['ip_address']
1104
+			: '';
1105
+		$this->_template_args['txn_details']['ip_address']['label'] = esc_html__(
1106
+			'Transaction placed from IP',
1107
+			'event_espresso'
1108
+		);
1109
+
1110
+		$this->_template_args['txn_details']['user_agent']['value'] = isset($this->_session['user_agent'])
1111
+			? $this->_session['user_agent']
1112
+			: '';
1113
+		$this->_template_args['txn_details']['user_agent']['label'] = esc_html__(
1114
+			'Registrant User Agent',
1115
+			'event_espresso'
1116
+		);
1117
+
1118
+		$reg_steps = '<ul>';
1119
+		foreach ($this->_transaction->reg_steps() as $reg_step => $reg_step_status) {
1120
+			if ($reg_step_status === true) {
1121
+				$reg_steps .= '<li style="color:#70cc50">'
1122
+							  . sprintf(
1123
+								  esc_html__('%1$s : Completed', 'event_espresso'),
1124
+								  ucwords(str_replace('_', ' ', $reg_step))
1125
+							  )
1126
+							  . '</li>';
1127
+			} elseif (is_numeric($reg_step_status) && $reg_step_status !== false) {
1128
+				$reg_steps .= '<li style="color:#2EA2CC">'
1129
+							  . sprintf(
1130
+								  esc_html__('%1$s : Initiated %2$s', 'event_espresso'),
1131
+								  ucwords(str_replace('_', ' ', $reg_step)),
1132
+								  date(
1133
+									  get_option('date_format') . ' ' . get_option('time_format'),
1134
+									  $reg_step_status + (get_option('gmt_offset') * HOUR_IN_SECONDS)
1135
+								  )
1136
+							  )
1137
+							  . '</li>';
1138
+			} else {
1139
+				$reg_steps .= '<li style="color:#E76700">'
1140
+							  . sprintf(
1141
+								  esc_html__('%1$s : Never Initiated', 'event_espresso'),
1142
+								  ucwords(str_replace('_', ' ', $reg_step))
1143
+							  )
1144
+							  . '</li>';
1145
+			}
1146
+		}
1147
+		$reg_steps .= '</ul>';
1148
+		$this->_template_args['txn_details']['reg_steps']['value'] = $reg_steps;
1149
+		$this->_template_args['txn_details']['reg_steps']['label'] = esc_html__(
1150
+			'Registration Step Progress',
1151
+			'event_espresso'
1152
+		);
1153
+
1154
+
1155
+		$this->_get_registrations_to_apply_payment_to();
1156
+		$this->_get_payment_methods($payments);
1157
+		$this->_get_payment_status_array();
1158
+		$this->_get_reg_status_selection(); // sets up the template args for the reg status array for the transaction.
1159
+
1160
+		$this->_template_args['transaction_form_url'] = add_query_arg(
1161
+			array(
1162
+				'action'  => 'edit_transaction',
1163
+				'process' => 'transaction',
1164
+			),
1165
+			TXN_ADMIN_URL
1166
+		);
1167
+		$this->_template_args['apply_payment_form_url'] = add_query_arg(
1168
+			array(
1169
+				'page'   => 'espresso_transactions',
1170
+				'action' => 'espresso_apply_payment',
1171
+			),
1172
+			WP_AJAX_URL
1173
+		);
1174
+		$this->_template_args['delete_payment_form_url'] = add_query_arg(
1175
+			array(
1176
+				'page'   => 'espresso_transactions',
1177
+				'action' => 'espresso_delete_payment',
1178
+			),
1179
+			WP_AJAX_URL
1180
+		);
1181
+
1182
+		$this->_template_args['action_buttons'] = $this->getActionButtons($this->_transaction);
1183
+
1184
+		// 'espresso_delete_payment_nonce'
1185
+
1186
+		$template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_txn_details.template.php';
1187
+		echo EEH_Template::display_template($template_path, $this->_template_args, true);
1188
+	}
1189
+
1190
+
1191
+	/**
1192
+	 * _get_registration_payment_IDs
1193
+	 *    generates an array of Payment IDs and their corresponding Registration IDs
1194
+	 *
1195
+	 * @access protected
1196
+	 * @param EE_Payment[] $payments
1197
+	 * @return array
1198
+	 * @throws EE_Error
1199
+	 * @throws InvalidArgumentException
1200
+	 * @throws InvalidDataTypeException
1201
+	 * @throws InvalidInterfaceException
1202
+	 * @throws ReflectionException
1203
+	 */
1204
+	protected function _get_registration_payment_IDs($payments = array())
1205
+	{
1206
+		$existing_reg_payments = array();
1207
+		// get all reg payments for these payments
1208
+		$reg_payments = EEM_Registration_Payment::instance()->get_all(
1209
+			array(
1210
+				array(
1211
+					'PAY_ID' => array(
1212
+						'IN',
1213
+						array_keys($payments),
1214
+					),
1215
+				),
1216
+			)
1217
+		);
1218
+		if (! empty($reg_payments)) {
1219
+			foreach ($payments as $payment) {
1220
+				if (! $payment instanceof EE_Payment) {
1221
+					continue;
1222
+				} elseif (! isset($existing_reg_payments[ $payment->ID() ])) {
1223
+					$existing_reg_payments[ $payment->ID() ] = array();
1224
+				}
1225
+				foreach ($reg_payments as $reg_payment) {
1226
+					if (
1227
+						$reg_payment instanceof EE_Registration_Payment
1228
+						&& $reg_payment->payment_ID() === $payment->ID()
1229
+					) {
1230
+						$existing_reg_payments[ $payment->ID() ][] = $reg_payment->registration_ID();
1231
+					}
1232
+				}
1233
+			}
1234
+		}
1235
+
1236
+		return $existing_reg_payments;
1237
+	}
1238
+
1239
+
1240
+	/**
1241
+	 * _get_registrations_to_apply_payment_to
1242
+	 *    generates HTML for displaying a series of checkboxes in the admin payment modal window
1243
+	 * which allows the admin to only apply the payment to the specific registrations
1244
+	 *
1245
+	 * @access protected
1246
+	 * @return void
1247
+	 * @throws EE_Error
1248
+	 * @throws InvalidArgumentException
1249
+	 * @throws InvalidDataTypeException
1250
+	 * @throws InvalidInterfaceException
1251
+	 * @throws ReflectionException
1252
+	 */
1253
+	protected function _get_registrations_to_apply_payment_to()
1254
+	{
1255
+		// we want any registration with an active status (ie: not deleted or cancelled)
1256
+		$query_params = array(
1257
+			array(
1258
+				'STS_ID' => array(
1259
+					'IN',
1260
+					array(
1261
+						EEM_Registration::status_id_approved,
1262
+						EEM_Registration::status_id_pending_payment,
1263
+						EEM_Registration::status_id_not_approved,
1264
+					),
1265
+				),
1266
+			),
1267
+		);
1268
+		$registrations_to_apply_payment_to = EEH_HTML::br() . EEH_HTML::div(
1269
+			'',
1270
+			'txn-admin-apply-payment-to-registrations-dv',
1271
+			'',
1272
+			'clear: both; margin: 1.5em 0 0; display: none;'
1273
+		);
1274
+		$registrations_to_apply_payment_to .= EEH_HTML::br() . EEH_HTML::div('', '', 'admin-primary-mbox-tbl-wrap');
1275
+		$registrations_to_apply_payment_to .= EEH_HTML::table('', '', 'admin-primary-mbox-tbl');
1276
+		$registrations_to_apply_payment_to .= EEH_HTML::thead(
1277
+			EEH_HTML::tr(
1278
+				EEH_HTML::th(esc_html__('ID', 'event_espresso')) .
1279
+				EEH_HTML::th(esc_html__('Registrant', 'event_espresso')) .
1280
+				EEH_HTML::th(esc_html__('Ticket', 'event_espresso')) .
1281
+				EEH_HTML::th(esc_html__('Event', 'event_espresso')) .
1282
+				EEH_HTML::th(esc_html__('Paid', 'event_espresso'), '', 'txn-admin-payment-paid-td jst-cntr') .
1283
+				EEH_HTML::th(esc_html__('Owing', 'event_espresso'), '', 'txn-admin-payment-owing-td jst-cntr') .
1284
+				EEH_HTML::th(esc_html__('Apply', 'event_espresso'), '', 'jst-cntr')
1285
+			)
1286
+		);
1287
+		$registrations_to_apply_payment_to .= EEH_HTML::tbody();
1288
+		// get registrations for TXN
1289
+		$registrations = $this->_transaction->registrations($query_params);
1290
+		$existing_reg_payments = $this->_template_args['existing_reg_payments'];
1291
+		foreach ($registrations as $registration) {
1292
+			if ($registration instanceof EE_Registration) {
1293
+				$attendee_name = $registration->attendee() instanceof EE_Attendee
1294
+					? $registration->attendee()->full_name()
1295
+					: esc_html__('Unknown Attendee', 'event_espresso');
1296
+				$owing = $registration->final_price() - $registration->paid();
1297
+				$taxable = $registration->ticket()->taxable()
1298
+					? ' <span class="smaller-text lt-grey-text"> ' . esc_html__('+ tax', 'event_espresso') . '</span>'
1299
+					: '';
1300
+				$checked = empty($existing_reg_payments)
1301
+						   || in_array($registration->ID(), $existing_reg_payments, true)
1302
+					? ' checked="checked"'
1303
+					: '';
1304
+				$disabled = $registration->final_price() > 0 ? '' : ' disabled';
1305
+				$registrations_to_apply_payment_to .= EEH_HTML::tr(
1306
+					EEH_HTML::td($registration->ID()) .
1307
+					EEH_HTML::td($attendee_name) .
1308
+					EEH_HTML::td(
1309
+						$registration->ticket()->name() . ' : ' . $registration->ticket()->pretty_price() . $taxable
1310
+					) .
1311
+					EEH_HTML::td($registration->event_name()) .
1312
+					EEH_HTML::td($registration->pretty_paid(), '', 'txn-admin-payment-paid-td jst-cntr') .
1313
+					EEH_HTML::td(
1314
+						EEH_Template::format_currency($owing),
1315
+						'',
1316
+						'txn-admin-payment-owing-td jst-cntr'
1317
+					) .
1318
+					EEH_HTML::td(
1319
+						'<input type="checkbox" value="' . $registration->ID()
1320
+						. '" name="txn_admin_payment[registrations]"'
1321
+						. $checked . $disabled . '>',
1322
+						'',
1323
+						'jst-cntr'
1324
+					),
1325
+					'apply-payment-registration-row-' . $registration->ID()
1326
+				);
1327
+			}
1328
+		}
1329
+		$registrations_to_apply_payment_to .= EEH_HTML::tbodyx();
1330
+		$registrations_to_apply_payment_to .= EEH_HTML::tablex();
1331
+		$registrations_to_apply_payment_to .= EEH_HTML::divx();
1332
+		$registrations_to_apply_payment_to .= EEH_HTML::p(
1333
+			esc_html__(
1334
+				'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.',
1335
+				'event_espresso'
1336
+			),
1337
+			'',
1338
+			'clear description'
1339
+		);
1340
+		$registrations_to_apply_payment_to .= EEH_HTML::divx();
1341
+		$this->_template_args['registrations_to_apply_payment_to'] = $registrations_to_apply_payment_to;
1342
+	}
1343
+
1344
+
1345
+	/**
1346
+	 * _get_reg_status_selection
1347
+	 *
1348
+	 * @todo   this will need to be adjusted either once MER comes along OR we move default reg status to tickets
1349
+	 *         instead of events.
1350
+	 * @access protected
1351
+	 * @return void
1352
+	 * @throws EE_Error
1353
+	 */
1354
+	protected function _get_reg_status_selection()
1355
+	{
1356
+		// first get all possible statuses
1357
+		$statuses = EEM_Registration::reg_status_array(array(), true);
1358
+		// let's add a "don't change" option.
1359
+		$status_array['NAN'] = esc_html__('Leave the Same', 'event_espresso');
1360
+		$status_array = array_merge($status_array, $statuses);
1361
+		$this->_template_args['status_change_select'] = EEH_Form_Fields::select_input(
1362
+			'txn_reg_status_change[reg_status]',
1363
+			$status_array,
1364
+			'NAN',
1365
+			'id="txn-admin-payment-reg-status-inp"',
1366
+			'txn-reg-status-change-reg-status'
1367
+		);
1368
+		$this->_template_args['delete_status_change_select'] = EEH_Form_Fields::select_input(
1369
+			'delete_txn_reg_status_change[reg_status]',
1370
+			$status_array,
1371
+			'NAN',
1372
+			'delete-txn-admin-payment-reg-status-inp',
1373
+			'delete-txn-reg-status-change-reg-status'
1374
+		);
1375
+	}
1376
+
1377
+
1378
+	/**
1379
+	 *    _get_payment_methods
1380
+	 * Gets all the payment methods available generally, or the ones that are already
1381
+	 * selected on these payments (in case their payment methods are no longer active).
1382
+	 * Has the side-effect of updating the template args' payment_methods item
1383
+	 *
1384
+	 * @access private
1385
+	 * @param EE_Payment[] to show on this page
1386
+	 * @return void
1387
+	 * @throws EE_Error
1388
+	 * @throws InvalidArgumentException
1389
+	 * @throws InvalidDataTypeException
1390
+	 * @throws InvalidInterfaceException
1391
+	 * @throws ReflectionException
1392
+	 */
1393
+	private function _get_payment_methods($payments = array())
1394
+	{
1395
+		$payment_methods_of_payments = array();
1396
+		foreach ($payments as $payment) {
1397
+			if ($payment instanceof EE_Payment) {
1398
+				$payment_methods_of_payments[] = $payment->ID();
1399
+			}
1400
+		}
1401
+		if ($payment_methods_of_payments) {
1402
+			$query_args = array(
1403
+				array(
1404
+					'OR*payment_method_for_payment' => array(
1405
+						'PMD_ID'    => array('IN', $payment_methods_of_payments),
1406
+						'PMD_scope' => array('LIKE', '%' . EEM_Payment_Method::scope_admin . '%'),
1407
+					),
1408
+				),
1409
+			);
1410
+		} else {
1411
+			$query_args = array(array('PMD_scope' => array('LIKE', '%' . EEM_Payment_Method::scope_admin . '%')));
1412
+		}
1413
+		$this->_template_args['payment_methods'] = EEM_Payment_Method::instance()->get_all($query_args);
1414
+	}
1415
+
1416
+
1417
+	/**
1418
+	 * txn_attendees_meta_box
1419
+	 *    generates HTML for the Attendees Transaction main meta box
1420
+	 *
1421
+	 * @access public
1422
+	 * @param WP_Post $post
1423
+	 * @param array   $metabox
1424
+	 * @return void
1425
+	 * @throws DomainException
1426
+	 * @throws EE_Error
1427
+	 * @throws InvalidArgumentException
1428
+	 * @throws InvalidDataTypeException
1429
+	 * @throws InvalidInterfaceException
1430
+	 * @throws ReflectionException
1431
+	 */
1432
+	public function txn_attendees_meta_box($post, $metabox = array('args' => array()))
1433
+	{
1434
+
1435
+		/** @noinspection NonSecureExtractUsageInspection */
1436
+		extract($metabox['args']);
1437
+		$this->_template_args['post'] = $post;
1438
+		$this->_template_args['event_attendees'] = array();
1439
+		// process items in cart
1440
+		$line_items = $this->_transaction->get_many_related(
1441
+			'Line_Item',
1442
+			array(array('LIN_type' => 'line-item'))
1443
+		);
1444
+		if (! empty($line_items)) {
1445
+			foreach ($line_items as $item) {
1446
+				if ($item instanceof EE_Line_Item) {
1447
+					switch ($item->OBJ_type()) {
1448
+						case 'Event':
1449
+							break;
1450
+						case 'Ticket':
1451
+							$ticket = $item->ticket();
1452
+							// right now we're only handling tickets here.
1453
+							// Cause its expected that only tickets will have attendees right?
1454
+							if (! $ticket instanceof EE_Ticket) {
1455
+								break;
1456
+							}
1457
+							try {
1458
+								$event_name = $ticket->get_event_name();
1459
+							} catch (Exception $e) {
1460
+								EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1461
+								$event_name = esc_html__('Unknown Event', 'event_espresso');
1462
+							}
1463
+							$event_name .= ' - ' . $item->name();
1464
+							$ticket_price = EEH_Template::format_currency($item->unit_price());
1465
+							// now get all of the registrations for this transaction that use this ticket
1466
+							$registrations = $ticket->registrations(
1467
+								array(array('TXN_ID' => $this->_transaction->ID()))
1468
+							);
1469
+							foreach ($registrations as $registration) {
1470
+								if (! $registration instanceof EE_Registration) {
1471
+									break;
1472
+								}
1473
+								$this->_template_args['event_attendees'][ $registration->ID() ]['STS_ID']
1474
+									= $registration->status_ID();
1475
+								$this->_template_args['event_attendees'][ $registration->ID() ]['att_num']
1476
+									= $registration->count();
1477
+								$this->_template_args['event_attendees'][ $registration->ID() ]['event_ticket_name']
1478
+									= $event_name;
1479
+								$this->_template_args['event_attendees'][ $registration->ID() ]['ticket_price']
1480
+									= $ticket_price;
1481
+								// attendee info
1482
+								$attendee = $registration->get_first_related('Attendee');
1483
+								if ($attendee instanceof EE_Attendee) {
1484
+									$this->_template_args['event_attendees'][ $registration->ID() ]['att_id']
1485
+										= $attendee->ID();
1486
+									$this->_template_args['event_attendees'][ $registration->ID() ]['attendee']
1487
+										= $attendee->full_name();
1488
+									$this->_template_args['event_attendees'][ $registration->ID() ]['email']
1489
+										= '<a href="mailto:' . $attendee->email() . '?subject=' . $event_name
1490
+										  . esc_html__(
1491
+											  ' Event',
1492
+											  'event_espresso'
1493
+										  )
1494
+										  . '">' . $attendee->email() . '</a>';
1495
+									$this->_template_args['event_attendees'][ $registration->ID() ]['address']
1496
+										= EEH_Address::format($attendee, 'inline', false, false);
1497
+								} else {
1498
+									$this->_template_args['event_attendees'][ $registration->ID() ]['att_id'] = '';
1499
+									$this->_template_args['event_attendees'][ $registration->ID() ]['attendee'] = '';
1500
+									$this->_template_args['event_attendees'][ $registration->ID() ]['email'] = '';
1501
+									$this->_template_args['event_attendees'][ $registration->ID() ]['address'] = '';
1502
+								}
1503
+							}
1504
+							break;
1505
+					}
1506
+				}
1507
+			}
1508
+
1509
+			$this->_template_args['transaction_form_url'] = add_query_arg(
1510
+				array(
1511
+					'action'  => 'edit_transaction',
1512
+					'process' => 'attendees',
1513
+				),
1514
+				TXN_ADMIN_URL
1515
+			);
1516
+			echo EEH_Template::display_template(
1517
+				TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_attendees.template.php',
1518
+				$this->_template_args,
1519
+				true
1520
+			);
1521
+		} else {
1522
+			echo sprintf(
1523
+				esc_html__(
1524
+					'%1$sFor some reason, there are no attendees registered for this transaction. Likely the registration was abandoned in process.%2$s',
1525
+					'event_espresso'
1526
+				),
1527
+				'<p class="important-notice">',
1528
+				'</p>'
1529
+			);
1530
+		}
1531
+	}
1532
+
1533
+
1534
+	/**
1535
+	 * txn_registrant_side_meta_box
1536
+	 * generates HTML for the Edit Transaction side meta box
1537
+	 *
1538
+	 * @access public
1539
+	 * @return void
1540
+	 * @throws DomainException
1541
+	 * @throws EE_Error
1542
+	 * @throws InvalidArgumentException
1543
+	 * @throws InvalidDataTypeException
1544
+	 * @throws InvalidInterfaceException
1545
+	 * @throws ReflectionException
1546
+	 */
1547
+	public function txn_registrant_side_meta_box()
1548
+	{
1549
+		$primary_att = $this->_transaction->primary_registration() instanceof EE_Registration
1550
+			? $this->_transaction->primary_registration()->get_first_related('Attendee')
1551
+			: null;
1552
+		if (! $primary_att instanceof EE_Attendee) {
1553
+			$this->_template_args['no_attendee_message'] = esc_html__(
1554
+				'There is no attached contact for this transaction.  The transaction either failed due to an error or was abandoned.',
1555
+				'event_espresso'
1556
+			);
1557
+			$primary_att = EEM_Attendee::instance()->create_default_object();
1558
+		}
1559
+		$this->_template_args['ATT_ID'] = $primary_att->ID();
1560
+		$this->_template_args['prime_reg_fname'] = $primary_att->fname();
1561
+		$this->_template_args['prime_reg_lname'] = $primary_att->lname();
1562
+		$this->_template_args['prime_reg_email'] = $primary_att->email();
1563
+		$this->_template_args['prime_reg_phone'] = $primary_att->phone();
1564
+		$this->_template_args['edit_attendee_url'] = EE_Admin_Page::add_query_args_and_nonce(
1565
+			array(
1566
+				'action' => 'edit_attendee',
1567
+				'post'   => $primary_att->ID(),
1568
+			),
1569
+			REG_ADMIN_URL
1570
+		);
1571
+		// get formatted address for registrant
1572
+		$this->_template_args['formatted_address'] = EEH_Address::format($primary_att);
1573
+		echo EEH_Template::display_template(
1574
+			TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_registrant.template.php',
1575
+			$this->_template_args,
1576
+			true
1577
+		);
1578
+	}
1579
+
1580
+
1581
+	/**
1582
+	 * txn_billing_info_side_meta_box
1583
+	 *    generates HTML for the Edit Transaction side meta box
1584
+	 *
1585
+	 * @access public
1586
+	 * @return void
1587
+	 * @throws DomainException
1588
+	 * @throws EE_Error
1589
+	 */
1590
+	public function txn_billing_info_side_meta_box()
1591
+	{
1592
+
1593
+		$this->_template_args['billing_form'] = $this->_transaction->billing_info();
1594
+		$this->_template_args['billing_form_url'] = add_query_arg(
1595
+			array('action' => 'edit_transaction', 'process' => 'billing'),
1596
+			TXN_ADMIN_URL
1597
+		);
1598
+
1599
+		$template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_billing_info.template.php';
1600
+		echo EEH_Template::display_template($template_path, $this->_template_args, true);
1601
+	}
1602
+
1603
+
1604
+	/**
1605
+	 * apply_payments_or_refunds
1606
+	 *    registers a payment or refund made towards a transaction
1607
+	 *
1608
+	 * @access public
1609
+	 * @return void
1610
+	 * @throws EE_Error
1611
+	 * @throws InvalidArgumentException
1612
+	 * @throws ReflectionException
1613
+	 * @throws RuntimeException
1614
+	 * @throws InvalidDataTypeException
1615
+	 * @throws InvalidInterfaceException
1616
+	 */
1617
+	public function apply_payments_or_refunds()
1618
+	{
1619
+		$json_response_data = array('return_data' => false);
1620
+		$valid_data = $this->_validate_payment_request_data();
1621
+		$has_access = EE_Registry::instance()->CAP->current_user_can(
1622
+			'ee_edit_payments',
1623
+			'apply_payment_or_refund_from_registration_details'
1624
+		);
1625
+		if (! empty($valid_data) && $has_access) {
1626
+			$PAY_ID = $valid_data['PAY_ID'];
1627
+			// save  the new payment
1628
+			$payment = $this->_create_payment_from_request_data($valid_data);
1629
+			// get the TXN for this payment
1630
+			$transaction = $payment->transaction();
1631
+			// verify transaction
1632
+			if ($transaction instanceof EE_Transaction) {
1633
+				// calculate_total_payments_and_update_status
1634
+				$this->_process_transaction_payments($transaction);
1635
+				$REG_IDs = $this->_get_REG_IDs_to_apply_payment_to($payment);
1636
+				$this->_remove_existing_registration_payments($payment, $PAY_ID);
1637
+				// apply payment to registrations (if applicable)
1638
+				if (! empty($REG_IDs)) {
1639
+					$this->_update_registration_payments($transaction, $payment, $REG_IDs);
1640
+					$this->_maybe_send_notifications();
1641
+					// now process status changes for the same registrations
1642
+					$this->_process_registration_status_change($transaction, $REG_IDs);
1643
+				}
1644
+				$this->_maybe_send_notifications($payment);
1645
+				// prepare to render page
1646
+				$json_response_data['return_data'] = $this->_build_payment_json_response($payment, $REG_IDs);
1647
+				do_action(
1648
+					'AHEE__Transactions_Admin_Page__apply_payments_or_refund__after_recording',
1649
+					$transaction,
1650
+					$payment
1651
+				);
1652
+			} else {
1653
+				EE_Error::add_error(
1654
+					esc_html__(
1655
+						'A valid Transaction for this payment could not be retrieved.',
1656
+						'event_espresso'
1657
+					),
1658
+					__FILE__,
1659
+					__FUNCTION__,
1660
+					__LINE__
1661
+				);
1662
+			}
1663
+		} elseif ($has_access) {
1664
+			EE_Error::add_error(
1665
+				esc_html__(
1666
+					'The payment form data could not be processed. Please try again.',
1667
+					'event_espresso'
1668
+				),
1669
+				__FILE__,
1670
+				__FUNCTION__,
1671
+				__LINE__
1672
+			);
1673
+		} else {
1674
+			EE_Error::add_error(
1675
+				esc_html__(
1676
+					'You do not have access to apply payments or refunds to a registration.',
1677
+					'event_espresso'
1678
+				),
1679
+				__FILE__,
1680
+				__FUNCTION__,
1681
+				__LINE__
1682
+			);
1683
+		}
1684
+		$notices = EE_Error::get_notices(
1685
+			false,
1686
+			false,
1687
+			false
1688
+		);
1689
+		$this->_template_args = array(
1690
+			'data'    => $json_response_data,
1691
+			'error'   => $notices['errors'],
1692
+			'success' => $notices['success'],
1693
+		);
1694
+		$this->_return_json();
1695
+	}
1696
+
1697
+
1698
+	/**
1699
+	 * _validate_payment_request_data
1700
+	 *
1701
+	 * @return array
1702
+	 * @throws EE_Error
1703
+	 * @throws InvalidArgumentException
1704
+	 * @throws InvalidDataTypeException
1705
+	 * @throws InvalidInterfaceException
1706
+	 */
1707
+	protected function _validate_payment_request_data()
1708
+	{
1709
+		if (! isset($this->_req_data['txn_admin_payment'])) {
1710
+			return array();
1711
+		}
1712
+		$payment_form = $this->_generate_payment_form_section();
1713
+		try {
1714
+			if ($payment_form->was_submitted()) {
1715
+				$payment_form->receive_form_submission();
1716
+				if (! $payment_form->is_valid()) {
1717
+					$submission_error_messages = array();
1718
+					foreach ($payment_form->get_validation_errors_accumulated() as $validation_error) {
1719
+						if ($validation_error instanceof EE_Validation_Error) {
1720
+							$submission_error_messages[] = sprintf(
1721
+								_x('%s : %s', 'Form Section Name : Form Validation Error', 'event_espresso'),
1722
+								$validation_error->get_form_section()->html_label_text(),
1723
+								$validation_error->getMessage()
1724
+							);
1725
+						}
1726
+					}
1727
+					EE_Error::add_error(
1728
+						implode('<br />', $submission_error_messages),
1729
+						__FILE__,
1730
+						__FUNCTION__,
1731
+						__LINE__
1732
+					);
1733
+					return array();
1734
+				}
1735
+			}
1736
+		} catch (EE_Error $e) {
1737
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1738
+			return array();
1739
+		}
1740
+
1741
+		return $payment_form->valid_data();
1742
+	}
1743
+
1744
+
1745
+	/**
1746
+	 * _generate_payment_form_section
1747
+	 *
1748
+	 * @return EE_Form_Section_Proper
1749
+	 * @throws EE_Error
1750
+	 */
1751
+	protected function _generate_payment_form_section()
1752
+	{
1753
+		return new EE_Form_Section_Proper(
1754
+			array(
1755
+				'name'        => 'txn_admin_payment',
1756
+				'subsections' => array(
1757
+					'PAY_ID'          => new EE_Text_Input(
1758
+						array(
1759
+							'default'               => 0,
1760
+							'required'              => false,
1761
+							'html_label_text'       => esc_html__('Payment ID', 'event_espresso'),
1762
+							'validation_strategies' => array(new EE_Int_Normalization()),
1763
+						)
1764
+					),
1765
+					'TXN_ID'          => new EE_Text_Input(
1766
+						array(
1767
+							'default'               => 0,
1768
+							'required'              => true,
1769
+							'html_label_text'       => esc_html__('Transaction ID', 'event_espresso'),
1770
+							'validation_strategies' => array(new EE_Int_Normalization()),
1771
+						)
1772
+					),
1773
+					'type'            => new EE_Text_Input(
1774
+						array(
1775
+							'default'               => 1,
1776
+							'required'              => true,
1777
+							'html_label_text'       => esc_html__('Payment or Refund', 'event_espresso'),
1778
+							'validation_strategies' => array(new EE_Int_Normalization()),
1779
+						)
1780
+					),
1781
+					'amount'          => new EE_Text_Input(
1782
+						array(
1783
+							'default'               => 0,
1784
+							'required'              => true,
1785
+							'html_label_text'       => esc_html__('Payment amount', 'event_espresso'),
1786
+							'validation_strategies' => array(new EE_Float_Normalization()),
1787
+						)
1788
+					),
1789
+					'status'          => new EE_Text_Input(
1790
+						array(
1791
+							'default'         => EEM_Payment::status_id_approved,
1792
+							'required'        => true,
1793
+							'html_label_text' => esc_html__('Payment status', 'event_espresso'),
1794
+						)
1795
+					),
1796
+					'PMD_ID'          => new EE_Text_Input(
1797
+						array(
1798
+							'default'               => 2,
1799
+							'required'              => true,
1800
+							'html_label_text'       => esc_html__('Payment Method', 'event_espresso'),
1801
+							'validation_strategies' => array(new EE_Int_Normalization()),
1802
+						)
1803
+					),
1804
+					'date'            => new EE_Text_Input(
1805
+						array(
1806
+							'default'         => time(),
1807
+							'required'        => true,
1808
+							'html_label_text' => esc_html__('Payment date', 'event_espresso'),
1809
+						)
1810
+					),
1811
+					'txn_id_chq_nmbr' => new EE_Text_Input(
1812
+						array(
1813
+							'default'               => '',
1814
+							'required'              => false,
1815
+							'html_label_text'       => esc_html__('Transaction or Cheque Number', 'event_espresso'),
1816
+							'validation_strategies' => array(
1817
+								new EE_Max_Length_Validation_Strategy(
1818
+									esc_html__('Input too long', 'event_espresso'),
1819
+									100
1820
+								),
1821
+							),
1822
+						)
1823
+					),
1824
+					'po_number'       => new EE_Text_Input(
1825
+						array(
1826
+							'default'               => '',
1827
+							'required'              => false,
1828
+							'html_label_text'       => esc_html__('Purchase Order Number', 'event_espresso'),
1829
+							'validation_strategies' => array(
1830
+								new EE_Max_Length_Validation_Strategy(
1831
+									esc_html__('Input too long', 'event_espresso'),
1832
+									100
1833
+								),
1834
+							),
1835
+						)
1836
+					),
1837
+					'accounting'      => new EE_Text_Input(
1838
+						array(
1839
+							'default'               => '',
1840
+							'required'              => false,
1841
+							'html_label_text'       => esc_html__('Extra Field for Accounting', 'event_espresso'),
1842
+							'validation_strategies' => array(
1843
+								new EE_Max_Length_Validation_Strategy(
1844
+									esc_html__('Input too long', 'event_espresso'),
1845
+									100
1846
+								),
1847
+							),
1848
+						)
1849
+					),
1850
+				),
1851
+			)
1852
+		);
1853
+	}
1854
+
1855
+
1856
+	/**
1857
+	 * _create_payment_from_request_data
1858
+	 *
1859
+	 * @param array $valid_data
1860
+	 * @return EE_Payment
1861
+	 * @throws EE_Error
1862
+	 * @throws InvalidArgumentException
1863
+	 * @throws InvalidDataTypeException
1864
+	 * @throws InvalidInterfaceException
1865
+	 * @throws ReflectionException
1866
+	 */
1867
+	protected function _create_payment_from_request_data($valid_data)
1868
+	{
1869
+		$PAY_ID = $valid_data['PAY_ID'];
1870
+		// get payment amount
1871
+		$amount = $valid_data['amount'] ? abs($valid_data['amount']) : 0;
1872
+		// payments have a type value of 1 and refunds have a type value of -1
1873
+		// so multiplying amount by type will give a positive value for payments, and negative values for refunds
1874
+		$amount = $valid_data['type'] < 0 ? $amount * -1 : $amount;
1875
+		// for some reason the date string coming in has extra spaces between the date and time.  This fixes that.
1876
+		$date = $valid_data['date']
1877
+			? preg_replace('/\s+/', ' ', $valid_data['date'])
1878
+			: date('Y-m-d g:i a', current_time('timestamp'));
1879
+		$payment = EE_Payment::new_instance(
1880
+			array(
1881
+				'TXN_ID'              => $valid_data['TXN_ID'],
1882
+				'STS_ID'              => $valid_data['status'],
1883
+				'PAY_timestamp'       => $date,
1884
+				'PAY_source'          => EEM_Payment_Method::scope_admin,
1885
+				'PMD_ID'              => $valid_data['PMD_ID'],
1886
+				'PAY_amount'          => $amount,
1887
+				'PAY_txn_id_chq_nmbr' => $valid_data['txn_id_chq_nmbr'],
1888
+				'PAY_po_number'       => $valid_data['po_number'],
1889
+				'PAY_extra_accntng'   => $valid_data['accounting'],
1890
+				'PAY_details'         => $valid_data,
1891
+				'PAY_ID'              => $PAY_ID,
1892
+			),
1893
+			'',
1894
+			array('Y-m-d', 'g:i a')
1895
+		);
1896
+
1897
+		if (! $payment->save()) {
1898
+			EE_Error::add_error(
1899
+				sprintf(
1900
+					esc_html__('Payment %1$d has not been successfully saved to the database.', 'event_espresso'),
1901
+					$payment->ID()
1902
+				),
1903
+				__FILE__,
1904
+				__FUNCTION__,
1905
+				__LINE__
1906
+			);
1907
+		}
1908
+
1909
+		return $payment;
1910
+	}
1911
+
1912
+
1913
+	/**
1914
+	 * _process_transaction_payments
1915
+	 *
1916
+	 * @param \EE_Transaction $transaction
1917
+	 * @return void
1918
+	 * @throws EE_Error
1919
+	 * @throws InvalidArgumentException
1920
+	 * @throws ReflectionException
1921
+	 * @throws InvalidDataTypeException
1922
+	 * @throws InvalidInterfaceException
1923
+	 */
1924
+	protected function _process_transaction_payments(EE_Transaction $transaction)
1925
+	{
1926
+		/** @type EE_Transaction_Payments $transaction_payments */
1927
+		$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
1928
+		// update the transaction with this payment
1929
+		if ($transaction_payments->calculate_total_payments_and_update_status($transaction)) {
1930
+			EE_Error::add_success(
1931
+				esc_html__(
1932
+					'The payment has been processed successfully.',
1933
+					'event_espresso'
1934
+				),
1935
+				__FILE__,
1936
+				__FUNCTION__,
1937
+				__LINE__
1938
+			);
1939
+		} else {
1940
+			EE_Error::add_error(
1941
+				esc_html__(
1942
+					'The payment was processed successfully but the amount paid for the transaction was not updated.',
1943
+					'event_espresso'
1944
+				),
1945
+				__FILE__,
1946
+				__FUNCTION__,
1947
+				__LINE__
1948
+			);
1949
+		}
1950
+	}
1951
+
1952
+
1953
+	/**
1954
+	 * _get_REG_IDs_to_apply_payment_to
1955
+	 * returns a list of registration IDs that the payment will apply to
1956
+	 *
1957
+	 * @param \EE_Payment $payment
1958
+	 * @return array
1959
+	 * @throws EE_Error
1960
+	 * @throws InvalidArgumentException
1961
+	 * @throws InvalidDataTypeException
1962
+	 * @throws InvalidInterfaceException
1963
+	 * @throws ReflectionException
1964
+	 */
1965
+	protected function _get_REG_IDs_to_apply_payment_to(EE_Payment $payment)
1966
+	{
1967
+		$REG_IDs = array();
1968
+		// grab array of IDs for specific registrations to apply changes to
1969
+		if (isset($this->_req_data['txn_admin_payment']['registrations'])) {
1970
+			$REG_IDs = (array) $this->_req_data['txn_admin_payment']['registrations'];
1971
+		}
1972
+		// nothing specified ? then get all reg IDs
1973
+		if (empty($REG_IDs)) {
1974
+			$registrations = $payment->transaction()->registrations();
1975
+			$REG_IDs = ! empty($registrations)
1976
+				? array_keys($registrations)
1977
+				: $this->_get_existing_reg_payment_REG_IDs($payment);
1978
+		}
1979
+
1980
+		// ensure that REG_IDs are integers and NOT strings
1981
+		return array_map('intval', $REG_IDs);
1982
+	}
1983
+
1984
+
1985
+	/**
1986
+	 * @return array
1987
+	 */
1988
+	public function existing_reg_payment_REG_IDs()
1989
+	{
1990
+		return $this->_existing_reg_payment_REG_IDs;
1991
+	}
1992
+
1993
+
1994
+	/**
1995
+	 * @param array $existing_reg_payment_REG_IDs
1996
+	 */
1997
+	public function set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs = null)
1998
+	{
1999
+		$this->_existing_reg_payment_REG_IDs = $existing_reg_payment_REG_IDs;
2000
+	}
2001
+
2002
+
2003
+	/**
2004
+	 * _get_existing_reg_payment_REG_IDs
2005
+	 * returns a list of registration IDs that the payment is currently related to
2006
+	 * as recorded in the database
2007
+	 *
2008
+	 * @param \EE_Payment $payment
2009
+	 * @return array
2010
+	 * @throws EE_Error
2011
+	 * @throws InvalidArgumentException
2012
+	 * @throws InvalidDataTypeException
2013
+	 * @throws InvalidInterfaceException
2014
+	 * @throws ReflectionException
2015
+	 */
2016
+	protected function _get_existing_reg_payment_REG_IDs(EE_Payment $payment)
2017
+	{
2018
+		if ($this->existing_reg_payment_REG_IDs() === null) {
2019
+			// let's get any existing reg payment records for this payment
2020
+			$existing_reg_payment_REG_IDs = $payment->get_many_related('Registration');
2021
+			// but we only want the REG IDs, so grab the array keys
2022
+			$existing_reg_payment_REG_IDs = ! empty($existing_reg_payment_REG_IDs)
2023
+				? array_keys($existing_reg_payment_REG_IDs)
2024
+				: array();
2025
+			$this->set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs);
2026
+		}
2027
+
2028
+		return $this->existing_reg_payment_REG_IDs();
2029
+	}
2030
+
2031
+
2032
+	/**
2033
+	 * _remove_existing_registration_payments
2034
+	 * this calculates the difference between existing relations
2035
+	 * to the supplied payment and the new list registration IDs,
2036
+	 * removes any related registrations that no longer apply,
2037
+	 * and then updates the registration paid fields
2038
+	 *
2039
+	 * @param \EE_Payment $payment
2040
+	 * @param int         $PAY_ID
2041
+	 * @return bool;
2042
+	 * @throws EE_Error
2043
+	 * @throws InvalidArgumentException
2044
+	 * @throws ReflectionException
2045
+	 * @throws InvalidDataTypeException
2046
+	 * @throws InvalidInterfaceException
2047
+	 */
2048
+	protected function _remove_existing_registration_payments(EE_Payment $payment, $PAY_ID = 0)
2049
+	{
2050
+		// newly created payments will have nothing recorded for $PAY_ID
2051
+		if (absint($PAY_ID) === 0) {
2052
+			return false;
2053
+		}
2054
+		$existing_reg_payment_REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment);
2055
+		if (empty($existing_reg_payment_REG_IDs)) {
2056
+			return false;
2057
+		}
2058
+		/** @type EE_Transaction_Payments $transaction_payments */
2059
+		$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
2060
+
2061
+		return $transaction_payments->delete_registration_payments_and_update_registrations(
2062
+			$payment,
2063
+			array(
2064
+				array(
2065
+					'PAY_ID' => $payment->ID(),
2066
+					'REG_ID' => array('IN', $existing_reg_payment_REG_IDs),
2067
+				),
2068
+			)
2069
+		);
2070
+	}
2071
+
2072
+
2073
+	/**
2074
+	 * _update_registration_payments
2075
+	 * this applies the payments to the selected registrations
2076
+	 * but only if they have not already been paid for
2077
+	 *
2078
+	 * @param  EE_Transaction $transaction
2079
+	 * @param \EE_Payment     $payment
2080
+	 * @param array           $REG_IDs
2081
+	 * @return void
2082
+	 * @throws EE_Error
2083
+	 * @throws InvalidArgumentException
2084
+	 * @throws ReflectionException
2085
+	 * @throws RuntimeException
2086
+	 * @throws InvalidDataTypeException
2087
+	 * @throws InvalidInterfaceException
2088
+	 */
2089
+	protected function _update_registration_payments(
2090
+		EE_Transaction $transaction,
2091
+		EE_Payment $payment,
2092
+		$REG_IDs = array()
2093
+	) {
2094
+		// we can pass our own custom set of registrations to EE_Payment_Processor::process_registration_payments()
2095
+		// so let's do that using our set of REG_IDs from the form
2096
+		$registration_query_where_params = array(
2097
+			'REG_ID' => array('IN', $REG_IDs),
2098
+		);
2099
+		// but add in some conditions regarding payment,
2100
+		// so that we don't apply payments to registrations that are free or have already been paid for
2101
+		// but ONLY if the payment is NOT a refund ( ie: the payment amount is not negative )
2102
+		if (! $payment->is_a_refund()) {
2103
+			$registration_query_where_params['REG_final_price'] = array('!=', 0);
2104
+			$registration_query_where_params['REG_final_price*'] = array('!=', 'REG_paid', true);
2105
+		}
2106
+		$registrations = $transaction->registrations(array($registration_query_where_params));
2107
+		if (! empty($registrations)) {
2108
+			/** @type EE_Payment_Processor $payment_processor */
2109
+			$payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
2110
+			$payment_processor->process_registration_payments($transaction, $payment, $registrations);
2111
+		}
2112
+	}
2113
+
2114
+
2115
+	/**
2116
+	 * _process_registration_status_change
2117
+	 * This processes requested registration status changes for all the registrations
2118
+	 * on a given transaction and (optionally) sends out notifications for the changes.
2119
+	 *
2120
+	 * @param  EE_Transaction $transaction
2121
+	 * @param array           $REG_IDs
2122
+	 * @return bool
2123
+	 * @throws EE_Error
2124
+	 * @throws InvalidArgumentException
2125
+	 * @throws ReflectionException
2126
+	 * @throws InvalidDataTypeException
2127
+	 * @throws InvalidInterfaceException
2128
+	 */
2129
+	protected function _process_registration_status_change(EE_Transaction $transaction, $REG_IDs = array())
2130
+	{
2131
+		// first if there is no change in status then we get out.
2132
+		if (
2133
+			! isset($this->_req_data['txn_reg_status_change']['reg_status'])
2134
+			|| $this->_req_data['txn_reg_status_change']['reg_status'] === 'NAN'
2135
+		) {
2136
+			// no error message, no change requested, just nothing to do man.
2137
+			return false;
2138
+		}
2139
+		/** @type EE_Transaction_Processor $transaction_processor */
2140
+		$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
2141
+
2142
+		// made it here dude?  Oh WOW.  K, let's take care of changing the statuses
2143
+		return $transaction_processor->manually_update_registration_statuses(
2144
+			$transaction,
2145
+			sanitize_text_field($this->_req_data['txn_reg_status_change']['reg_status']),
2146
+			array(array('REG_ID' => array('IN', $REG_IDs)))
2147
+		);
2148
+	}
2149
+
2150
+
2151
+	/**
2152
+	 * _build_payment_json_response
2153
+	 *
2154
+	 * @access public
2155
+	 * @param \EE_Payment $payment
2156
+	 * @param array       $REG_IDs
2157
+	 * @param bool | null $delete_txn_reg_status_change
2158
+	 * @return array
2159
+	 * @throws EE_Error
2160
+	 * @throws InvalidArgumentException
2161
+	 * @throws InvalidDataTypeException
2162
+	 * @throws InvalidInterfaceException
2163
+	 * @throws ReflectionException
2164
+	 */
2165
+	protected function _build_payment_json_response(
2166
+		EE_Payment $payment,
2167
+		$REG_IDs = array(),
2168
+		$delete_txn_reg_status_change = null
2169
+	) {
2170
+		// was the payment deleted ?
2171
+		if (is_bool($delete_txn_reg_status_change)) {
2172
+			return array(
2173
+				'PAY_ID'                       => $payment->ID(),
2174
+				'amount'                       => $payment->amount(),
2175
+				'total_paid'                   => $payment->transaction()->paid(),
2176
+				'txn_status'                   => $payment->transaction()->status_ID(),
2177
+				'pay_status'                   => $payment->STS_ID(),
2178
+				'registrations'                => $this->_registration_payment_data_array($REG_IDs),
2179
+				'delete_txn_reg_status_change' => $delete_txn_reg_status_change,
2180
+			);
2181
+		} else {
2182
+			$this->_get_payment_status_array();
2183
+
2184
+			return array(
2185
+				'amount'           => $payment->amount(),
2186
+				'total_paid'       => $payment->transaction()->paid(),
2187
+				'txn_status'       => $payment->transaction()->status_ID(),
2188
+				'pay_status'       => $payment->STS_ID(),
2189
+				'PAY_ID'           => $payment->ID(),
2190
+				'STS_ID'           => $payment->STS_ID(),
2191
+				'status'           => self::$_pay_status[ $payment->STS_ID() ],
2192
+				'date'             => $payment->timestamp('Y-m-d', 'h:i a'),
2193
+				'method'           => strtoupper($payment->source()),
2194
+				'PM_ID'            => $payment->payment_method() ? $payment->payment_method()->ID() : 1,
2195
+				'gateway'          => $payment->payment_method()
2196
+					? $payment->payment_method()->admin_name()
2197
+					: esc_html__('Unknown', 'event_espresso'),
2198
+				'gateway_response' => $payment->gateway_response(),
2199
+				'txn_id_chq_nmbr'  => $payment->txn_id_chq_nmbr(),
2200
+				'po_number'        => $payment->po_number(),
2201
+				'extra_accntng'    => $payment->extra_accntng(),
2202
+				'registrations'    => $this->_registration_payment_data_array($REG_IDs),
2203
+			);
2204
+		}
2205
+	}
2206
+
2207
+
2208
+	/**
2209
+	 * delete_payment
2210
+	 *    delete a payment or refund made towards a transaction
2211
+	 *
2212
+	 * @access public
2213
+	 * @return void
2214
+	 * @throws EE_Error
2215
+	 * @throws InvalidArgumentException
2216
+	 * @throws ReflectionException
2217
+	 * @throws InvalidDataTypeException
2218
+	 * @throws InvalidInterfaceException
2219
+	 */
2220
+	public function delete_payment()
2221
+	{
2222
+		$json_response_data = array('return_data' => false);
2223
+		$PAY_ID = isset($this->_req_data['delete_txn_admin_payment']['PAY_ID'])
2224
+			? absint($this->_req_data['delete_txn_admin_payment']['PAY_ID'])
2225
+			: 0;
2226
+		$can_delete = EE_Registry::instance()->CAP->current_user_can(
2227
+			'ee_delete_payments',
2228
+			'delete_payment_from_registration_details'
2229
+		);
2230
+		if ($PAY_ID && $can_delete) {
2231
+			$delete_txn_reg_status_change = isset($this->_req_data['delete_txn_reg_status_change'])
2232
+				? $this->_req_data['delete_txn_reg_status_change']
2233
+				: false;
2234
+			$payment = EEM_Payment::instance()->get_one_by_ID($PAY_ID);
2235
+			if ($payment instanceof EE_Payment) {
2236
+				$REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment);
2237
+				/** @type EE_Transaction_Payments $transaction_payments */
2238
+				$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
2239
+				if ($transaction_payments->delete_payment_and_update_transaction($payment)) {
2240
+					$json_response_data['return_data'] = $this->_build_payment_json_response(
2241
+						$payment,
2242
+						$REG_IDs,
2243
+						$delete_txn_reg_status_change
2244
+					);
2245
+					if ($delete_txn_reg_status_change) {
2246
+						$this->_req_data['txn_reg_status_change'] = $delete_txn_reg_status_change;
2247
+						// MAKE sure we also add the delete_txn_req_status_change to the
2248
+						// $_REQUEST global because that's how messages will be looking for it.
2249
+						$_REQUEST['txn_reg_status_change'] = $delete_txn_reg_status_change;
2250
+						$this->_maybe_send_notifications();
2251
+						$this->_process_registration_status_change($payment->transaction(), $REG_IDs);
2252
+					}
2253
+				}
2254
+			} else {
2255
+				EE_Error::add_error(
2256
+					esc_html__('Valid Payment data could not be retrieved from the database.', 'event_espresso'),
2257
+					__FILE__,
2258
+					__FUNCTION__,
2259
+					__LINE__
2260
+				);
2261
+			}
2262
+		} elseif ($can_delete) {
2263
+			EE_Error::add_error(
2264
+				esc_html__(
2265
+					'A valid Payment ID was not received, therefore payment form data could not be loaded.',
2266
+					'event_espresso'
2267
+				),
2268
+				__FILE__,
2269
+				__FUNCTION__,
2270
+				__LINE__
2271
+			);
2272
+		} else {
2273
+			EE_Error::add_error(
2274
+				esc_html__(
2275
+					'You do not have access to delete a payment.',
2276
+					'event_espresso'
2277
+				),
2278
+				__FILE__,
2279
+				__FUNCTION__,
2280
+				__LINE__
2281
+			);
2282
+		}
2283
+		$notices = EE_Error::get_notices(false, false, false);
2284
+		$this->_template_args = array(
2285
+			'data'      => $json_response_data,
2286
+			'success'   => $notices['success'],
2287
+			'error'     => $notices['errors'],
2288
+			'attention' => $notices['attention'],
2289
+		);
2290
+		$this->_return_json();
2291
+	}
2292
+
2293
+
2294
+	/**
2295
+	 * _registration_payment_data_array
2296
+	 * adds info for 'owing' and 'paid' for each registration to the json response
2297
+	 *
2298
+	 * @access protected
2299
+	 * @param array $REG_IDs
2300
+	 * @return array
2301
+	 * @throws EE_Error
2302
+	 * @throws InvalidArgumentException
2303
+	 * @throws InvalidDataTypeException
2304
+	 * @throws InvalidInterfaceException
2305
+	 * @throws ReflectionException
2306
+	 */
2307
+	protected function _registration_payment_data_array($REG_IDs)
2308
+	{
2309
+		$registration_payment_data = array();
2310
+		// if non empty reg_ids lets get an array of registrations and update the values for the apply_payment/refund rows.
2311
+		if (! empty($REG_IDs)) {
2312
+			$registrations = EEM_Registration::instance()->get_all(array(array('REG_ID' => array('IN', $REG_IDs))));
2313
+			foreach ($registrations as $registration) {
2314
+				if ($registration instanceof EE_Registration) {
2315
+					$registration_payment_data[ $registration->ID() ] = array(
2316
+						'paid'  => $registration->pretty_paid(),
2317
+						'owing' => EEH_Template::format_currency($registration->final_price() - $registration->paid()),
2318
+					);
2319
+				}
2320
+			}
2321
+		}
2322
+
2323
+		return $registration_payment_data;
2324
+	}
2325
+
2326
+
2327
+	/**
2328
+	 * _maybe_send_notifications
2329
+	 * determines whether or not the admin has indicated that notifications should be sent.
2330
+	 * If so, will toggle a filter switch for delivering registration notices.
2331
+	 * If passed an EE_Payment object, then it will trigger payment notifications instead.
2332
+	 *
2333
+	 * @access protected
2334
+	 * @param \EE_Payment | null $payment
2335
+	 */
2336
+	protected function _maybe_send_notifications($payment = null)
2337
+	{
2338
+		switch ($payment instanceof EE_Payment) {
2339
+			// payment notifications
2340
+			case true:
2341
+				if (
2342
+					isset($this->_req_data['txn_payments']['send_notifications'])
2343
+					&& filter_var(
2344
+						$this->_req_data['txn_payments']['send_notifications'],
2345
+						FILTER_VALIDATE_BOOLEAN
2346
+					)
2347
+				) {
2348
+					$this->_process_payment_notification($payment);
2349
+				}
2350
+				break;
2351
+			// registration notifications
2352
+			case false:
2353
+				if (
2354
+					isset($this->_req_data['txn_reg_status_change']['send_notifications'])
2355
+					&& filter_var(
2356
+						$this->_req_data['txn_reg_status_change']['send_notifications'],
2357
+						FILTER_VALIDATE_BOOLEAN
2358
+					)
2359
+				) {
2360
+					add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true');
2361
+				}
2362
+				break;
2363
+		}
2364
+	}
2365
+
2366
+
2367
+	/**
2368
+	 * _send_payment_reminder
2369
+	 *    generates HTML for the View Transaction Details Admin page
2370
+	 *
2371
+	 * @access protected
2372
+	 * @return void
2373
+	 * @throws EE_Error
2374
+	 * @throws InvalidArgumentException
2375
+	 * @throws InvalidDataTypeException
2376
+	 * @throws InvalidInterfaceException
2377
+	 */
2378
+	protected function _send_payment_reminder()
2379
+	{
2380
+		$TXN_ID = ! empty($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : false;
2381
+		$transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
2382
+		$query_args = isset($this->_req_data['redirect_to']) ? array(
2383
+			'action' => $this->_req_data['redirect_to'],
2384
+			'TXN_ID' => $this->_req_data['TXN_ID'],
2385
+		) : array();
2386
+		do_action(
2387
+			'AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder',
2388
+			$transaction
2389
+		);
2390
+		$this->_redirect_after_action(
2391
+			false,
2392
+			esc_html__('payment reminder', 'event_espresso'),
2393
+			esc_html__('sent', 'event_espresso'),
2394
+			$query_args,
2395
+			true
2396
+		);
2397
+	}
2398
+
2399
+
2400
+	/**
2401
+	 *  get_transactions
2402
+	 *    get transactions for given parameters (used by list table)
2403
+	 *
2404
+	 * @param  int     $perpage how many transactions displayed per page
2405
+	 * @param  boolean $count   return the count or objects
2406
+	 * @param string   $view
2407
+	 * @return mixed int = count || array of transaction objects
2408
+	 * @throws EE_Error
2409
+	 * @throws InvalidArgumentException
2410
+	 * @throws InvalidDataTypeException
2411
+	 * @throws InvalidInterfaceException
2412
+	 */
2413
+	public function get_transactions($perpage, $count = false, $view = '')
2414
+	{
2415
+
2416
+		$TXN = EEM_Transaction::instance();
2417
+
2418
+		$start_date = isset($this->_req_data['txn-filter-start-date'])
2419
+			? wp_strip_all_tags($this->_req_data['txn-filter-start-date'])
2420
+			: date(
2421
+				'm/d/Y',
2422
+				strtotime('-10 year')
2423
+			);
2424
+		$end_date = isset($this->_req_data['txn-filter-end-date'])
2425
+			? wp_strip_all_tags($this->_req_data['txn-filter-end-date'])
2426
+			: date('m/d/Y');
2427
+
2428
+		// make sure our timestamps start and end right at the boundaries for each day
2429
+		$start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00';
2430
+		$end_date = date('Y-m-d', strtotime($end_date)) . ' 23:59:59';
2431
+
2432
+
2433
+		// convert to timestamps
2434
+		$start_date = strtotime($start_date);
2435
+		$end_date = strtotime($end_date);
2436
+
2437
+		// makes sure start date is the lowest value and vice versa
2438
+		$start_date = min($start_date, $end_date);
2439
+		$end_date = max($start_date, $end_date);
2440
+
2441
+		// convert to correct format for query
2442
+		$start_date = EEM_Transaction::instance()->convert_datetime_for_query(
2443
+			'TXN_timestamp',
2444
+			date('Y-m-d H:i:s', $start_date),
2445
+			'Y-m-d H:i:s'
2446
+		);
2447
+		$end_date = EEM_Transaction::instance()->convert_datetime_for_query(
2448
+			'TXN_timestamp',
2449
+			date('Y-m-d H:i:s', $end_date),
2450
+			'Y-m-d H:i:s'
2451
+		);
2452
+
2453
+
2454
+		// set orderby
2455
+		$this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
2456
+
2457
+		switch ($this->_req_data['orderby']) {
2458
+			case 'TXN_ID':
2459
+				$orderby = 'TXN_ID';
2460
+				break;
2461
+			case 'ATT_fname':
2462
+				$orderby = 'Registration.Attendee.ATT_fname';
2463
+				break;
2464
+			case 'event_name':
2465
+				$orderby = 'Registration.Event.EVT_name';
2466
+				break;
2467
+			default: // 'TXN_timestamp'
2468
+				$orderby = 'TXN_timestamp';
2469
+		}
2470
+
2471
+		$sort = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC';
2472
+		$current_page = ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1;
2473
+		$per_page = ! empty($perpage) ? $perpage : 10;
2474
+		$per_page = ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page;
2475
+
2476
+		$offset = ($current_page - 1) * $per_page;
2477
+		$limit = array($offset, $per_page);
2478
+
2479
+		$_where = array(
2480
+			'TXN_timestamp'          => array('BETWEEN', array($start_date, $end_date)),
2481
+			'Registration.REG_count' => 1,
2482
+		);
2483
+
2484
+		if (isset($this->_req_data['EVT_ID'])) {
2485
+			$_where['Registration.EVT_ID'] = $this->_req_data['EVT_ID'];
2486
+		}
2487
+
2488
+		if (isset($this->_req_data['s'])) {
2489
+			$search_string = '%' . $this->_req_data['s'] . '%';
2490
+			$_where['OR'] = array(
2491
+				'Registration.Event.EVT_name'         => array('LIKE', $search_string),
2492
+				'Registration.Event.EVT_desc'         => array('LIKE', $search_string),
2493
+				'Registration.Event.EVT_short_desc'   => array('LIKE', $search_string),
2494
+				'Registration.Attendee.ATT_full_name' => array('LIKE', $search_string),
2495
+				'Registration.Attendee.ATT_fname'     => array('LIKE', $search_string),
2496
+				'Registration.Attendee.ATT_lname'     => array('LIKE', $search_string),
2497
+				'Registration.Attendee.ATT_short_bio' => array('LIKE', $search_string),
2498
+				'Registration.Attendee.ATT_email'     => array('LIKE', $search_string),
2499
+				'Registration.Attendee.ATT_address'   => array('LIKE', $search_string),
2500
+				'Registration.Attendee.ATT_address2'  => array('LIKE', $search_string),
2501
+				'Registration.Attendee.ATT_city'      => array('LIKE', $search_string),
2502
+				'Registration.REG_final_price'        => array('LIKE', $search_string),
2503
+				'Registration.REG_code'               => array('LIKE', $search_string),
2504
+				'Registration.REG_count'              => array('LIKE', $search_string),
2505
+				'Registration.REG_group_size'         => array('LIKE', $search_string),
2506
+				'Registration.Ticket.TKT_name'        => array('LIKE', $search_string),
2507
+				'Registration.Ticket.TKT_description' => array('LIKE', $search_string),
2508
+				'Payment.PAY_source'                  => array('LIKE', $search_string),
2509
+				'Payment.Payment_Method.PMD_name'     => array('LIKE', $search_string),
2510
+				'TXN_session_data'                    => array('LIKE', $search_string),
2511
+				'Payment.PAY_txn_id_chq_nmbr'         => array('LIKE', $search_string),
2512
+			);
2513
+		}
2514
+
2515
+		// failed transactions
2516
+		$failed = (! empty($this->_req_data['status']) && $this->_req_data['status'] === 'failed' && ! $count)
2517
+				  || ($count && $view === 'failed');
2518
+		$abandoned = (! empty($this->_req_data['status']) && $this->_req_data['status'] === 'abandoned' && ! $count)
2519
+					 || ($count && $view === 'abandoned');
2520
+		$incomplete = (! empty($this->_req_data['status']) && $this->_req_data['status'] === 'incomplete' && ! $count)
2521
+					  || ($count && $view === 'incomplete');
2522
+
2523
+		if ($failed) {
2524
+			$_where['STS_ID'] = EEM_Transaction::failed_status_code;
2525
+		} elseif ($abandoned) {
2526
+			$_where['STS_ID'] = EEM_Transaction::abandoned_status_code;
2527
+		} elseif ($incomplete) {
2528
+			$_where['STS_ID'] = EEM_Transaction::incomplete_status_code;
2529
+		} else {
2530
+			$_where['STS_ID'] = array('!=', EEM_Transaction::failed_status_code);
2531
+			$_where['STS_ID*'] = array('!=', EEM_Transaction::abandoned_status_code);
2532
+		}
2533
+
2534
+		$query_params = apply_filters(
2535
+			'FHEE__Transactions_Admin_Page___get_transactions_query_params',
2536
+			array(
2537
+				$_where,
2538
+				'order_by'                 => array($orderby => $sort),
2539
+				'limit'                    => $limit,
2540
+				'default_where_conditions' => EEM_Base::default_where_conditions_this_only,
2541
+			),
2542
+			$this->_req_data,
2543
+			$view,
2544
+			$count
2545
+		);
2546
+
2547
+		$transactions = $count
2548
+			? $TXN->count(array($query_params[0]), 'TXN_ID', true)
2549
+			: $TXN->get_all($query_params);
2550
+
2551
+		return $transactions;
2552
+	}
2553
+
2554
+
2555
+	/**
2556
+	 * @since 4.9.79.p
2557
+	 * @throws EE_Error
2558
+	 * @throws InvalidArgumentException
2559
+	 * @throws InvalidDataTypeException
2560
+	 * @throws InvalidInterfaceException
2561
+	 * @throws ReflectionException
2562
+	 * @throws RuntimeException
2563
+	 */
2564
+	public function recalculateLineItems()
2565
+	{
2566
+		$TXN_ID = ! empty($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : false;
2567
+		/** @var EE_Transaction $transaction */
2568
+		$transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
2569
+		$total_line_item = $transaction->total_line_item(false);
2570
+		$success = $transaction->recalculateLineItems();
2571
+		$this->_redirect_after_action(
2572
+			(bool) $success,
2573
+			esc_html__('Transaction taxes and totals', 'event_espresso'),
2574
+			esc_html__('recalculated', 'event_espresso'),
2575
+			isset($this->_req_data['redirect_to'])
2576
+				? array(
2577
+				'action' => $this->_req_data['redirect_to'],
2578
+				'TXN_ID' => $this->_req_data['TXN_ID'],
2579
+			)
2580
+				: array(),
2581
+			true
2582
+		);
2583
+	}
2584 2584
 }
Please login to merge, or discard this patch.
Spacing   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
         // enqueue style
359 359
         wp_register_style(
360 360
             'espresso_txn',
361
-            TXN_ASSETS_URL . 'espresso_transactions_admin.css',
361
+            TXN_ASSETS_URL.'espresso_transactions_admin.css',
362 362
             array(),
363 363
             EVENT_ESPRESSO_VERSION
364 364
         );
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
         // scripts
367 367
         wp_register_script(
368 368
             'espresso_txn',
369
-            TXN_ASSETS_URL . 'espresso_transactions_admin.js',
369
+            TXN_ASSETS_URL.'espresso_transactions_admin.js',
370 370
             array(
371 371
                 'ee_admin_js',
372 372
                 'ee-datepicker',
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
             $this->_transaction->verify_abandoned_transaction_status();
496 496
         }
497 497
 
498
-        if (! $this->_transaction instanceof EE_Transaction) {
498
+        if ( ! $this->_transaction instanceof EE_Transaction) {
499 499
             $error_msg = sprintf(
500 500
                 esc_html__(
501 501
                     'An error occurred and the details for the transaction with the ID # %d could not be retrieved.',
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
             'FHEE__Transactions_Admin_Page___transaction_legend_items__more_items',
588 588
             array(
589 589
                 'overpaid'   => array(
590
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::overpaid_status_code,
590
+                    'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::overpaid_status_code,
591 591
                     'desc'  => EEH_Template::pretty_status(
592 592
                         EEM_Transaction::overpaid_status_code,
593 593
                         false,
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
                     ),
596 596
                 ),
597 597
                 'complete'   => array(
598
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::complete_status_code,
598
+                    'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::complete_status_code,
599 599
                     'desc'  => EEH_Template::pretty_status(
600 600
                         EEM_Transaction::complete_status_code,
601 601
                         false,
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
                     ),
604 604
                 ),
605 605
                 'incomplete' => array(
606
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::incomplete_status_code,
606
+                    'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::incomplete_status_code,
607 607
                     'desc'  => EEH_Template::pretty_status(
608 608
                         EEM_Transaction::incomplete_status_code,
609 609
                         false,
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
                     ),
612 612
                 ),
613 613
                 'abandoned'  => array(
614
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::abandoned_status_code,
614
+                    'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::abandoned_status_code,
615 615
                     'desc'  => EEH_Template::pretty_status(
616 616
                         EEM_Transaction::abandoned_status_code,
617 617
                         false,
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
                     ),
620 620
                 ),
621 621
                 'failed'     => array(
622
-                    'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::failed_status_code,
622
+                    'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::failed_status_code,
623 623
                     'desc'  => EEH_Template::pretty_status(
624 624
                         EEM_Transaction::failed_status_code,
625 625
                         false,
@@ -668,7 +668,7 @@  discard block
 block discarded – undo
668 668
                     'Click to Edit event',
669 669
                     'event_espresso'
670 670
                 )
671
-                . '">' . $event->name() . '</a>',
671
+                . '">'.$event->name().'</a>',
672 672
                 '</h3>'
673 673
             )
674 674
             : '';
@@ -702,7 +702,7 @@  discard block
 block discarded – undo
702 702
 
703 703
         $this->_set_transaction_object();
704 704
 
705
-        if (! $this->_transaction instanceof EE_Transaction) {
705
+        if ( ! $this->_transaction instanceof EE_Transaction) {
706 706
             return;
707 707
         }
708 708
         $primary_registration = $this->_transaction->primary_registration();
@@ -716,9 +716,9 @@  discard block
 block discarded – undo
716 716
         $this->_template_args['txn_datetime']['value'] = $this->_transaction->get_i18n_datetime('TXN_timestamp');
717 717
         $this->_template_args['txn_datetime']['label'] = esc_html__('Date', 'event_espresso');
718 718
 
719
-        $this->_template_args['txn_status']['value'] = self::$_txn_status[ $this->_transaction->status_ID() ];
719
+        $this->_template_args['txn_status']['value'] = self::$_txn_status[$this->_transaction->status_ID()];
720 720
         $this->_template_args['txn_status']['label'] = esc_html__('Transaction Status', 'event_espresso');
721
-        $this->_template_args['txn_status']['class'] = 'status-' . $this->_transaction->status_ID();
721
+        $this->_template_args['txn_status']['class'] = 'status-'.$this->_transaction->status_ID();
722 722
 
723 723
         $this->_template_args['grand_total'] = $this->_transaction->total();
724 724
         $this->_template_args['total_paid'] = $this->_transaction->paid();
@@ -838,7 +838,7 @@  discard block
 block discarded – undo
838 838
         // grab messages at the last second
839 839
         $this->_template_args['notices'] = EE_Error::get_notices();
840 840
         // path to template
841
-        $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_header.template.php';
841
+        $template_path = TXN_TEMPLATE_PATH.'txn_admin_details_header.template.php';
842 842
         $this->_template_args['admin_page_header'] = EEH_Template::display_template(
843 843
             $template_path,
844 844
             $this->_template_args,
@@ -867,7 +867,7 @@  discard block
 block discarded – undo
867 867
 
868 868
         $this->_set_transaction_object();
869 869
 
870
-        if (! $this->_transaction instanceof EE_Transaction) {
870
+        if ( ! $this->_transaction instanceof EE_Transaction) {
871 871
             return;
872 872
         }
873 873
         add_meta_box(
@@ -923,7 +923,7 @@  discard block
 block discarded – undo
923 923
     {
924 924
         $content = '';
925 925
         $actions = array();
926
-        if (! $transaction instanceof EE_Transaction) {
926
+        if ( ! $transaction instanceof EE_Transaction) {
927 927
             return $content;
928 928
         }
929 929
         /** @var EE_Registration $primary_registration */
@@ -1008,7 +1008,7 @@  discard block
 block discarded – undo
1008 1008
         );
1009 1009
         if ($actions) {
1010 1010
             $content = '<ul>';
1011
-            $content .= '<li>' . implode('</li><li>', $actions) . '</li>';
1011
+            $content .= '<li>'.implode('</li><li>', $actions).'</li>';
1012 1012
             $content .= '</uL>';
1013 1013
         }
1014 1014
         return $content;
@@ -1069,7 +1069,7 @@  discard block
 block discarded – undo
1069 1069
 
1070 1070
         // process payment details
1071 1071
         $payments = $this->_transaction->payments();
1072
-        if (! empty($payments)) {
1072
+        if ( ! empty($payments)) {
1073 1073
             $this->_template_args['payments'] = $payments;
1074 1074
             $this->_template_args['existing_reg_payments'] = $this->_get_registration_payment_IDs($payments);
1075 1075
         } else {
@@ -1130,7 +1130,7 @@  discard block
 block discarded – undo
1130 1130
                                   esc_html__('%1$s : Initiated %2$s', 'event_espresso'),
1131 1131
                                   ucwords(str_replace('_', ' ', $reg_step)),
1132 1132
                                   date(
1133
-                                      get_option('date_format') . ' ' . get_option('time_format'),
1133
+                                      get_option('date_format').' '.get_option('time_format'),
1134 1134
                                       $reg_step_status + (get_option('gmt_offset') * HOUR_IN_SECONDS)
1135 1135
                                   )
1136 1136
                               )
@@ -1183,7 +1183,7 @@  discard block
 block discarded – undo
1183 1183
 
1184 1184
         // 'espresso_delete_payment_nonce'
1185 1185
 
1186
-        $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_txn_details.template.php';
1186
+        $template_path = TXN_TEMPLATE_PATH.'txn_admin_details_main_meta_box_txn_details.template.php';
1187 1187
         echo EEH_Template::display_template($template_path, $this->_template_args, true);
1188 1188
     }
1189 1189
 
@@ -1215,19 +1215,19 @@  discard block
 block discarded – undo
1215 1215
                 ),
1216 1216
             )
1217 1217
         );
1218
-        if (! empty($reg_payments)) {
1218
+        if ( ! empty($reg_payments)) {
1219 1219
             foreach ($payments as $payment) {
1220
-                if (! $payment instanceof EE_Payment) {
1220
+                if ( ! $payment instanceof EE_Payment) {
1221 1221
                     continue;
1222
-                } elseif (! isset($existing_reg_payments[ $payment->ID() ])) {
1223
-                    $existing_reg_payments[ $payment->ID() ] = array();
1222
+                } elseif ( ! isset($existing_reg_payments[$payment->ID()])) {
1223
+                    $existing_reg_payments[$payment->ID()] = array();
1224 1224
                 }
1225 1225
                 foreach ($reg_payments as $reg_payment) {
1226 1226
                     if (
1227 1227
                         $reg_payment instanceof EE_Registration_Payment
1228 1228
                         && $reg_payment->payment_ID() === $payment->ID()
1229 1229
                     ) {
1230
-                        $existing_reg_payments[ $payment->ID() ][] = $reg_payment->registration_ID();
1230
+                        $existing_reg_payments[$payment->ID()][] = $reg_payment->registration_ID();
1231 1231
                     }
1232 1232
                 }
1233 1233
             }
@@ -1265,22 +1265,22 @@  discard block
 block discarded – undo
1265 1265
                 ),
1266 1266
             ),
1267 1267
         );
1268
-        $registrations_to_apply_payment_to = EEH_HTML::br() . EEH_HTML::div(
1268
+        $registrations_to_apply_payment_to = EEH_HTML::br().EEH_HTML::div(
1269 1269
             '',
1270 1270
             'txn-admin-apply-payment-to-registrations-dv',
1271 1271
             '',
1272 1272
             'clear: both; margin: 1.5em 0 0; display: none;'
1273 1273
         );
1274
-        $registrations_to_apply_payment_to .= EEH_HTML::br() . EEH_HTML::div('', '', 'admin-primary-mbox-tbl-wrap');
1274
+        $registrations_to_apply_payment_to .= EEH_HTML::br().EEH_HTML::div('', '', 'admin-primary-mbox-tbl-wrap');
1275 1275
         $registrations_to_apply_payment_to .= EEH_HTML::table('', '', 'admin-primary-mbox-tbl');
1276 1276
         $registrations_to_apply_payment_to .= EEH_HTML::thead(
1277 1277
             EEH_HTML::tr(
1278
-                EEH_HTML::th(esc_html__('ID', 'event_espresso')) .
1279
-                EEH_HTML::th(esc_html__('Registrant', 'event_espresso')) .
1280
-                EEH_HTML::th(esc_html__('Ticket', 'event_espresso')) .
1281
-                EEH_HTML::th(esc_html__('Event', 'event_espresso')) .
1282
-                EEH_HTML::th(esc_html__('Paid', 'event_espresso'), '', 'txn-admin-payment-paid-td jst-cntr') .
1283
-                EEH_HTML::th(esc_html__('Owing', 'event_espresso'), '', 'txn-admin-payment-owing-td jst-cntr') .
1278
+                EEH_HTML::th(esc_html__('ID', 'event_espresso')).
1279
+                EEH_HTML::th(esc_html__('Registrant', 'event_espresso')).
1280
+                EEH_HTML::th(esc_html__('Ticket', 'event_espresso')).
1281
+                EEH_HTML::th(esc_html__('Event', 'event_espresso')).
1282
+                EEH_HTML::th(esc_html__('Paid', 'event_espresso'), '', 'txn-admin-payment-paid-td jst-cntr').
1283
+                EEH_HTML::th(esc_html__('Owing', 'event_espresso'), '', 'txn-admin-payment-owing-td jst-cntr').
1284 1284
                 EEH_HTML::th(esc_html__('Apply', 'event_espresso'), '', 'jst-cntr')
1285 1285
             )
1286 1286
         );
@@ -1295,7 +1295,7 @@  discard block
 block discarded – undo
1295 1295
                     : esc_html__('Unknown Attendee', 'event_espresso');
1296 1296
                 $owing = $registration->final_price() - $registration->paid();
1297 1297
                 $taxable = $registration->ticket()->taxable()
1298
-                    ? ' <span class="smaller-text lt-grey-text"> ' . esc_html__('+ tax', 'event_espresso') . '</span>'
1298
+                    ? ' <span class="smaller-text lt-grey-text"> '.esc_html__('+ tax', 'event_espresso').'</span>'
1299 1299
                     : '';
1300 1300
                 $checked = empty($existing_reg_payments)
1301 1301
                            || in_array($registration->ID(), $existing_reg_payments, true)
@@ -1303,26 +1303,26 @@  discard block
 block discarded – undo
1303 1303
                     : '';
1304 1304
                 $disabled = $registration->final_price() > 0 ? '' : ' disabled';
1305 1305
                 $registrations_to_apply_payment_to .= EEH_HTML::tr(
1306
-                    EEH_HTML::td($registration->ID()) .
1307
-                    EEH_HTML::td($attendee_name) .
1306
+                    EEH_HTML::td($registration->ID()).
1307
+                    EEH_HTML::td($attendee_name).
1308 1308
                     EEH_HTML::td(
1309
-                        $registration->ticket()->name() . ' : ' . $registration->ticket()->pretty_price() . $taxable
1310
-                    ) .
1311
-                    EEH_HTML::td($registration->event_name()) .
1312
-                    EEH_HTML::td($registration->pretty_paid(), '', 'txn-admin-payment-paid-td jst-cntr') .
1309
+                        $registration->ticket()->name().' : '.$registration->ticket()->pretty_price().$taxable
1310
+                    ).
1311
+                    EEH_HTML::td($registration->event_name()).
1312
+                    EEH_HTML::td($registration->pretty_paid(), '', 'txn-admin-payment-paid-td jst-cntr').
1313 1313
                     EEH_HTML::td(
1314 1314
                         EEH_Template::format_currency($owing),
1315 1315
                         '',
1316 1316
                         'txn-admin-payment-owing-td jst-cntr'
1317
-                    ) .
1317
+                    ).
1318 1318
                     EEH_HTML::td(
1319
-                        '<input type="checkbox" value="' . $registration->ID()
1319
+                        '<input type="checkbox" value="'.$registration->ID()
1320 1320
                         . '" name="txn_admin_payment[registrations]"'
1321
-                        . $checked . $disabled . '>',
1321
+                        . $checked.$disabled.'>',
1322 1322
                         '',
1323 1323
                         'jst-cntr'
1324 1324
                     ),
1325
-                    'apply-payment-registration-row-' . $registration->ID()
1325
+                    'apply-payment-registration-row-'.$registration->ID()
1326 1326
                 );
1327 1327
             }
1328 1328
         }
@@ -1403,12 +1403,12 @@  discard block
 block discarded – undo
1403 1403
                 array(
1404 1404
                     'OR*payment_method_for_payment' => array(
1405 1405
                         'PMD_ID'    => array('IN', $payment_methods_of_payments),
1406
-                        'PMD_scope' => array('LIKE', '%' . EEM_Payment_Method::scope_admin . '%'),
1406
+                        'PMD_scope' => array('LIKE', '%'.EEM_Payment_Method::scope_admin.'%'),
1407 1407
                     ),
1408 1408
                 ),
1409 1409
             );
1410 1410
         } else {
1411
-            $query_args = array(array('PMD_scope' => array('LIKE', '%' . EEM_Payment_Method::scope_admin . '%')));
1411
+            $query_args = array(array('PMD_scope' => array('LIKE', '%'.EEM_Payment_Method::scope_admin.'%')));
1412 1412
         }
1413 1413
         $this->_template_args['payment_methods'] = EEM_Payment_Method::instance()->get_all($query_args);
1414 1414
     }
@@ -1441,7 +1441,7 @@  discard block
 block discarded – undo
1441 1441
             'Line_Item',
1442 1442
             array(array('LIN_type' => 'line-item'))
1443 1443
         );
1444
-        if (! empty($line_items)) {
1444
+        if ( ! empty($line_items)) {
1445 1445
             foreach ($line_items as $item) {
1446 1446
                 if ($item instanceof EE_Line_Item) {
1447 1447
                     switch ($item->OBJ_type()) {
@@ -1451,7 +1451,7 @@  discard block
 block discarded – undo
1451 1451
                             $ticket = $item->ticket();
1452 1452
                             // right now we're only handling tickets here.
1453 1453
                             // Cause its expected that only tickets will have attendees right?
1454
-                            if (! $ticket instanceof EE_Ticket) {
1454
+                            if ( ! $ticket instanceof EE_Ticket) {
1455 1455
                                 break;
1456 1456
                             }
1457 1457
                             try {
@@ -1460,45 +1460,45 @@  discard block
 block discarded – undo
1460 1460
                                 EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1461 1461
                                 $event_name = esc_html__('Unknown Event', 'event_espresso');
1462 1462
                             }
1463
-                            $event_name .= ' - ' . $item->name();
1463
+                            $event_name .= ' - '.$item->name();
1464 1464
                             $ticket_price = EEH_Template::format_currency($item->unit_price());
1465 1465
                             // now get all of the registrations for this transaction that use this ticket
1466 1466
                             $registrations = $ticket->registrations(
1467 1467
                                 array(array('TXN_ID' => $this->_transaction->ID()))
1468 1468
                             );
1469 1469
                             foreach ($registrations as $registration) {
1470
-                                if (! $registration instanceof EE_Registration) {
1470
+                                if ( ! $registration instanceof EE_Registration) {
1471 1471
                                     break;
1472 1472
                                 }
1473
-                                $this->_template_args['event_attendees'][ $registration->ID() ]['STS_ID']
1473
+                                $this->_template_args['event_attendees'][$registration->ID()]['STS_ID']
1474 1474
                                     = $registration->status_ID();
1475
-                                $this->_template_args['event_attendees'][ $registration->ID() ]['att_num']
1475
+                                $this->_template_args['event_attendees'][$registration->ID()]['att_num']
1476 1476
                                     = $registration->count();
1477
-                                $this->_template_args['event_attendees'][ $registration->ID() ]['event_ticket_name']
1477
+                                $this->_template_args['event_attendees'][$registration->ID()]['event_ticket_name']
1478 1478
                                     = $event_name;
1479
-                                $this->_template_args['event_attendees'][ $registration->ID() ]['ticket_price']
1479
+                                $this->_template_args['event_attendees'][$registration->ID()]['ticket_price']
1480 1480
                                     = $ticket_price;
1481 1481
                                 // attendee info
1482 1482
                                 $attendee = $registration->get_first_related('Attendee');
1483 1483
                                 if ($attendee instanceof EE_Attendee) {
1484
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['att_id']
1484
+                                    $this->_template_args['event_attendees'][$registration->ID()]['att_id']
1485 1485
                                         = $attendee->ID();
1486
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['attendee']
1486
+                                    $this->_template_args['event_attendees'][$registration->ID()]['attendee']
1487 1487
                                         = $attendee->full_name();
1488
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['email']
1489
-                                        = '<a href="mailto:' . $attendee->email() . '?subject=' . $event_name
1488
+                                    $this->_template_args['event_attendees'][$registration->ID()]['email']
1489
+                                        = '<a href="mailto:'.$attendee->email().'?subject='.$event_name
1490 1490
                                           . esc_html__(
1491 1491
                                               ' Event',
1492 1492
                                               'event_espresso'
1493 1493
                                           )
1494
-                                          . '">' . $attendee->email() . '</a>';
1495
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['address']
1494
+                                          . '">'.$attendee->email().'</a>';
1495
+                                    $this->_template_args['event_attendees'][$registration->ID()]['address']
1496 1496
                                         = EEH_Address::format($attendee, 'inline', false, false);
1497 1497
                                 } else {
1498
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['att_id'] = '';
1499
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['attendee'] = '';
1500
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['email'] = '';
1501
-                                    $this->_template_args['event_attendees'][ $registration->ID() ]['address'] = '';
1498
+                                    $this->_template_args['event_attendees'][$registration->ID()]['att_id'] = '';
1499
+                                    $this->_template_args['event_attendees'][$registration->ID()]['attendee'] = '';
1500
+                                    $this->_template_args['event_attendees'][$registration->ID()]['email'] = '';
1501
+                                    $this->_template_args['event_attendees'][$registration->ID()]['address'] = '';
1502 1502
                                 }
1503 1503
                             }
1504 1504
                             break;
@@ -1514,7 +1514,7 @@  discard block
 block discarded – undo
1514 1514
                 TXN_ADMIN_URL
1515 1515
             );
1516 1516
             echo EEH_Template::display_template(
1517
-                TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_attendees.template.php',
1517
+                TXN_TEMPLATE_PATH.'txn_admin_details_main_meta_box_attendees.template.php',
1518 1518
                 $this->_template_args,
1519 1519
                 true
1520 1520
             );
@@ -1549,7 +1549,7 @@  discard block
 block discarded – undo
1549 1549
         $primary_att = $this->_transaction->primary_registration() instanceof EE_Registration
1550 1550
             ? $this->_transaction->primary_registration()->get_first_related('Attendee')
1551 1551
             : null;
1552
-        if (! $primary_att instanceof EE_Attendee) {
1552
+        if ( ! $primary_att instanceof EE_Attendee) {
1553 1553
             $this->_template_args['no_attendee_message'] = esc_html__(
1554 1554
                 'There is no attached contact for this transaction.  The transaction either failed due to an error or was abandoned.',
1555 1555
                 'event_espresso'
@@ -1571,7 +1571,7 @@  discard block
 block discarded – undo
1571 1571
         // get formatted address for registrant
1572 1572
         $this->_template_args['formatted_address'] = EEH_Address::format($primary_att);
1573 1573
         echo EEH_Template::display_template(
1574
-            TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_registrant.template.php',
1574
+            TXN_TEMPLATE_PATH.'txn_admin_details_side_meta_box_registrant.template.php',
1575 1575
             $this->_template_args,
1576 1576
             true
1577 1577
         );
@@ -1596,7 +1596,7 @@  discard block
 block discarded – undo
1596 1596
             TXN_ADMIN_URL
1597 1597
         );
1598 1598
 
1599
-        $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_billing_info.template.php';
1599
+        $template_path = TXN_TEMPLATE_PATH.'txn_admin_details_side_meta_box_billing_info.template.php';
1600 1600
         echo EEH_Template::display_template($template_path, $this->_template_args, true);
1601 1601
     }
1602 1602
 
@@ -1622,7 +1622,7 @@  discard block
 block discarded – undo
1622 1622
             'ee_edit_payments',
1623 1623
             'apply_payment_or_refund_from_registration_details'
1624 1624
         );
1625
-        if (! empty($valid_data) && $has_access) {
1625
+        if ( ! empty($valid_data) && $has_access) {
1626 1626
             $PAY_ID = $valid_data['PAY_ID'];
1627 1627
             // save  the new payment
1628 1628
             $payment = $this->_create_payment_from_request_data($valid_data);
@@ -1635,7 +1635,7 @@  discard block
 block discarded – undo
1635 1635
                 $REG_IDs = $this->_get_REG_IDs_to_apply_payment_to($payment);
1636 1636
                 $this->_remove_existing_registration_payments($payment, $PAY_ID);
1637 1637
                 // apply payment to registrations (if applicable)
1638
-                if (! empty($REG_IDs)) {
1638
+                if ( ! empty($REG_IDs)) {
1639 1639
                     $this->_update_registration_payments($transaction, $payment, $REG_IDs);
1640 1640
                     $this->_maybe_send_notifications();
1641 1641
                     // now process status changes for the same registrations
@@ -1706,14 +1706,14 @@  discard block
 block discarded – undo
1706 1706
      */
1707 1707
     protected function _validate_payment_request_data()
1708 1708
     {
1709
-        if (! isset($this->_req_data['txn_admin_payment'])) {
1709
+        if ( ! isset($this->_req_data['txn_admin_payment'])) {
1710 1710
             return array();
1711 1711
         }
1712 1712
         $payment_form = $this->_generate_payment_form_section();
1713 1713
         try {
1714 1714
             if ($payment_form->was_submitted()) {
1715 1715
                 $payment_form->receive_form_submission();
1716
-                if (! $payment_form->is_valid()) {
1716
+                if ( ! $payment_form->is_valid()) {
1717 1717
                     $submission_error_messages = array();
1718 1718
                     foreach ($payment_form->get_validation_errors_accumulated() as $validation_error) {
1719 1719
                         if ($validation_error instanceof EE_Validation_Error) {
@@ -1894,7 +1894,7 @@  discard block
 block discarded – undo
1894 1894
             array('Y-m-d', 'g:i a')
1895 1895
         );
1896 1896
 
1897
-        if (! $payment->save()) {
1897
+        if ( ! $payment->save()) {
1898 1898
             EE_Error::add_error(
1899 1899
                 sprintf(
1900 1900
                     esc_html__('Payment %1$d has not been successfully saved to the database.', 'event_espresso'),
@@ -2099,12 +2099,12 @@  discard block
 block discarded – undo
2099 2099
         // but add in some conditions regarding payment,
2100 2100
         // so that we don't apply payments to registrations that are free or have already been paid for
2101 2101
         // but ONLY if the payment is NOT a refund ( ie: the payment amount is not negative )
2102
-        if (! $payment->is_a_refund()) {
2102
+        if ( ! $payment->is_a_refund()) {
2103 2103
             $registration_query_where_params['REG_final_price'] = array('!=', 0);
2104 2104
             $registration_query_where_params['REG_final_price*'] = array('!=', 'REG_paid', true);
2105 2105
         }
2106 2106
         $registrations = $transaction->registrations(array($registration_query_where_params));
2107
-        if (! empty($registrations)) {
2107
+        if ( ! empty($registrations)) {
2108 2108
             /** @type EE_Payment_Processor $payment_processor */
2109 2109
             $payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
2110 2110
             $payment_processor->process_registration_payments($transaction, $payment, $registrations);
@@ -2188,7 +2188,7 @@  discard block
 block discarded – undo
2188 2188
                 'pay_status'       => $payment->STS_ID(),
2189 2189
                 'PAY_ID'           => $payment->ID(),
2190 2190
                 'STS_ID'           => $payment->STS_ID(),
2191
-                'status'           => self::$_pay_status[ $payment->STS_ID() ],
2191
+                'status'           => self::$_pay_status[$payment->STS_ID()],
2192 2192
                 'date'             => $payment->timestamp('Y-m-d', 'h:i a'),
2193 2193
                 'method'           => strtoupper($payment->source()),
2194 2194
                 'PM_ID'            => $payment->payment_method() ? $payment->payment_method()->ID() : 1,
@@ -2308,11 +2308,11 @@  discard block
 block discarded – undo
2308 2308
     {
2309 2309
         $registration_payment_data = array();
2310 2310
         // if non empty reg_ids lets get an array of registrations and update the values for the apply_payment/refund rows.
2311
-        if (! empty($REG_IDs)) {
2311
+        if ( ! empty($REG_IDs)) {
2312 2312
             $registrations = EEM_Registration::instance()->get_all(array(array('REG_ID' => array('IN', $REG_IDs))));
2313 2313
             foreach ($registrations as $registration) {
2314 2314
                 if ($registration instanceof EE_Registration) {
2315
-                    $registration_payment_data[ $registration->ID() ] = array(
2315
+                    $registration_payment_data[$registration->ID()] = array(
2316 2316
                         'paid'  => $registration->pretty_paid(),
2317 2317
                         'owing' => EEH_Template::format_currency($registration->final_price() - $registration->paid()),
2318 2318
                     );
@@ -2426,8 +2426,8 @@  discard block
 block discarded – undo
2426 2426
             : date('m/d/Y');
2427 2427
 
2428 2428
         // make sure our timestamps start and end right at the boundaries for each day
2429
-        $start_date = date('Y-m-d', strtotime($start_date)) . ' 00:00:00';
2430
-        $end_date = date('Y-m-d', strtotime($end_date)) . ' 23:59:59';
2429
+        $start_date = date('Y-m-d', strtotime($start_date)).' 00:00:00';
2430
+        $end_date = date('Y-m-d', strtotime($end_date)).' 23:59:59';
2431 2431
 
2432 2432
 
2433 2433
         // convert to timestamps
@@ -2486,7 +2486,7 @@  discard block
 block discarded – undo
2486 2486
         }
2487 2487
 
2488 2488
         if (isset($this->_req_data['s'])) {
2489
-            $search_string = '%' . $this->_req_data['s'] . '%';
2489
+            $search_string = '%'.$this->_req_data['s'].'%';
2490 2490
             $_where['OR'] = array(
2491 2491
                 'Registration.Event.EVT_name'         => array('LIKE', $search_string),
2492 2492
                 'Registration.Event.EVT_desc'         => array('LIKE', $search_string),
@@ -2513,11 +2513,11 @@  discard block
 block discarded – undo
2513 2513
         }
2514 2514
 
2515 2515
         // failed transactions
2516
-        $failed = (! empty($this->_req_data['status']) && $this->_req_data['status'] === 'failed' && ! $count)
2516
+        $failed = ( ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'failed' && ! $count)
2517 2517
                   || ($count && $view === 'failed');
2518
-        $abandoned = (! empty($this->_req_data['status']) && $this->_req_data['status'] === 'abandoned' && ! $count)
2518
+        $abandoned = ( ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'abandoned' && ! $count)
2519 2519
                      || ($count && $view === 'abandoned');
2520
-        $incomplete = (! empty($this->_req_data['status']) && $this->_req_data['status'] === 'incomplete' && ! $count)
2520
+        $incomplete = ( ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'incomplete' && ! $count)
2521 2521
                       || ($count && $view === 'incomplete');
2522 2522
 
2523 2523
         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.
Indentation   +3213 added lines, -3213 removed lines patch added patch discarded remove patch
@@ -14,2544 +14,2544 @@  discard block
 block discarded – undo
14 14
 final class EE_Config implements ResettableInterface
15 15
 {
16 16
 
17
-    const OPTION_NAME = 'ee_config';
18
-
19
-    const LOG_NAME = 'ee_config_log';
20
-
21
-    const LOG_LENGTH = 100;
22
-
23
-    const ADDON_OPTION_NAMES = 'ee_config_option_names';
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
-     * Settings pertaining to global messages settings.
104
-     *
105
-     * @var EE_Messages_Config
106
-     */
107
-    public $messages;
108
-
109
-    /**
110
-     * @deprecated
111
-     * @var EE_Gateway_Config
112
-     */
113
-    public $gateway;
114
-
115
-    /**
116
-     * @var    array $_addon_option_names
117
-     * @access    private
118
-     */
119
-    private $_addon_option_names = array();
120
-
121
-    /**
122
-     * @var    array $_module_route_map
123
-     * @access    private
124
-     */
125
-    private static $_module_route_map = array();
126
-
127
-    /**
128
-     * @var    array $_module_forward_map
129
-     * @access    private
130
-     */
131
-    private static $_module_forward_map = array();
132
-
133
-    /**
134
-     * @var    array $_module_view_map
135
-     * @access    private
136
-     */
137
-    private static $_module_view_map = array();
138
-
139
-
140
-    /**
141
-     * @singleton method used to instantiate class object
142
-     * @access    public
143
-     * @return EE_Config instance
144
-     */
145
-    public static function instance()
146
-    {
147
-        // check if class object is instantiated, and instantiated properly
148
-        if (! self::$_instance instanceof EE_Config) {
149
-            self::$_instance = new self();
150
-        }
151
-        return self::$_instance;
152
-    }
153
-
154
-
155
-    /**
156
-     * Resets the config
157
-     *
158
-     * @param bool    $hard_reset    if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE
159
-     *                               (default) leaves the database alone, and merely resets the EE_Config object to
160
-     *                               reflect its state in the database
161
-     * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave
162
-     *                               $_instance as NULL. Useful in case you want to forget about the old instance on
163
-     *                               EE_Config, but might not be ready to instantiate EE_Config currently (eg if the
164
-     *                               site was put into maintenance mode)
165
-     * @return EE_Config
166
-     */
167
-    public static function reset($hard_reset = false, $reinstantiate = true)
168
-    {
169
-        if (self::$_instance instanceof EE_Config) {
170
-            if ($hard_reset) {
171
-                self::$_instance->legacy_shortcodes_manager = null;
172
-                self::$_instance->_addon_option_names = array();
173
-                self::$_instance->_initialize_config();
174
-                self::$_instance->update_espresso_config();
175
-            }
176
-            self::$_instance->update_addon_option_names();
177
-        }
178
-        self::$_instance = null;
179
-        // we don't need to reset the static properties imo because those should
180
-        // only change when a module is added or removed. Currently we don't
181
-        // support removing a module during a request when it previously existed
182
-        if ($reinstantiate) {
183
-            return self::instance();
184
-        } else {
185
-            return null;
186
-        }
187
-    }
188
-
189
-
190
-    /**
191
-     *    class constructor
192
-     *
193
-     * @access    private
194
-     */
195
-    private function __construct()
196
-    {
197
-        do_action('AHEE__EE_Config__construct__begin', $this);
198
-        EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false);
199
-        // setup empty config classes
200
-        $this->_initialize_config();
201
-        // load existing EE site settings
202
-        $this->_load_core_config();
203
-        // confirm everything loaded correctly and set filtered defaults if not
204
-        $this->_verify_config();
205
-        //  register shortcodes and modules
206
-        add_action(
207
-            'AHEE__EE_System__register_shortcodes_modules_and_widgets',
208
-            array($this, 'register_shortcodes_and_modules'),
209
-            999
210
-        );
211
-        //  initialize shortcodes and modules
212
-        add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules'));
213
-        // register widgets
214
-        add_action('widgets_init', array($this, 'widgets_init'), 10);
215
-        // shutdown
216
-        add_action('shutdown', array($this, 'shutdown'), 10);
217
-        // construct__end hook
218
-        do_action('AHEE__EE_Config__construct__end', $this);
219
-        // hardcoded hack
220
-        $this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014';
221
-    }
222
-
223
-
224
-    /**
225
-     * @return boolean
226
-     */
227
-    public static function logging_enabled()
228
-    {
229
-        return self::$_logging_enabled;
230
-    }
231
-
232
-
233
-    /**
234
-     * use to get the current theme if needed from static context
235
-     *
236
-     * @return string current theme set.
237
-     */
238
-    public static function get_current_theme()
239
-    {
240
-        return isset(self::$_instance->template_settings->current_espresso_theme)
241
-            ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014';
242
-    }
243
-
244
-
245
-    /**
246
-     *        _initialize_config
247
-     *
248
-     * @access private
249
-     * @return void
250
-     */
251
-    private function _initialize_config()
252
-    {
253
-        EE_Config::trim_log();
254
-        // set defaults
255
-        $this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array());
256
-        $this->addons = new stdClass();
257
-        // set _module_route_map
258
-        EE_Config::$_module_route_map = array();
259
-        // set _module_forward_map
260
-        EE_Config::$_module_forward_map = array();
261
-        // set _module_view_map
262
-        EE_Config::$_module_view_map = array();
263
-    }
264
-
265
-
266
-    /**
267
-     *        load core plugin configuration
268
-     *
269
-     * @access private
270
-     * @return void
271
-     */
272
-    private function _load_core_config()
273
-    {
274
-        // load_core_config__start hook
275
-        do_action('AHEE__EE_Config___load_core_config__start', $this);
276
-        $espresso_config = $this->get_espresso_config();
277
-        foreach ($espresso_config as $config => $settings) {
278
-            // load_core_config__start hook
279
-            $settings = apply_filters(
280
-                'FHEE__EE_Config___load_core_config__config_settings',
281
-                $settings,
282
-                $config,
283
-                $this
284
-            );
285
-            if (is_object($settings) && property_exists($this, $config)) {
286
-                $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
287
-                // call configs populate method to ensure any defaults are set for empty values.
288
-                if (method_exists($settings, 'populate')) {
289
-                    $this->{$config}->populate();
290
-                }
291
-                if (method_exists($settings, 'do_hooks')) {
292
-                    $this->{$config}->do_hooks();
293
-                }
294
-            }
295
-        }
296
-        if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) {
297
-            $this->update_espresso_config();
298
-        }
299
-        // load_core_config__end hook
300
-        do_action('AHEE__EE_Config___load_core_config__end', $this);
301
-    }
302
-
303
-
304
-    /**
305
-     *    _verify_config
306
-     *
307
-     * @access    protected
308
-     * @return    void
309
-     */
310
-    protected function _verify_config()
311
-    {
312
-        $this->core = $this->core instanceof EE_Core_Config
313
-            ? $this->core
314
-            : new EE_Core_Config();
315
-        $this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core);
316
-        $this->organization = $this->organization instanceof EE_Organization_Config
317
-            ? $this->organization
318
-            : new EE_Organization_Config();
319
-        $this->organization = apply_filters(
320
-            'FHEE__EE_Config___initialize_config__organization',
321
-            $this->organization
322
-        );
323
-        $this->currency = $this->currency instanceof EE_Currency_Config
324
-            ? $this->currency
325
-            : new EE_Currency_Config();
326
-        $this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency);
327
-        $this->registration = $this->registration instanceof EE_Registration_Config
328
-            ? $this->registration
329
-            : new EE_Registration_Config();
330
-        $this->registration = apply_filters(
331
-            'FHEE__EE_Config___initialize_config__registration',
332
-            $this->registration
333
-        );
334
-        $this->admin = $this->admin instanceof EE_Admin_Config
335
-            ? $this->admin
336
-            : new EE_Admin_Config();
337
-        $this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin);
338
-        $this->template_settings = $this->template_settings instanceof EE_Template_Config
339
-            ? $this->template_settings
340
-            : new EE_Template_Config();
341
-        $this->template_settings = apply_filters(
342
-            'FHEE__EE_Config___initialize_config__template_settings',
343
-            $this->template_settings
344
-        );
345
-        $this->map_settings = $this->map_settings instanceof EE_Map_Config
346
-            ? $this->map_settings
347
-            : new EE_Map_Config();
348
-        $this->map_settings = apply_filters(
349
-            'FHEE__EE_Config___initialize_config__map_settings',
350
-            $this->map_settings
351
-        );
352
-        $this->environment = $this->environment instanceof EE_Environment_Config
353
-            ? $this->environment
354
-            : new EE_Environment_Config();
355
-        $this->environment = apply_filters(
356
-            'FHEE__EE_Config___initialize_config__environment',
357
-            $this->environment
358
-        );
359
-        $this->tax_settings = $this->tax_settings instanceof EE_Tax_Config
360
-            ? $this->tax_settings
361
-            : new EE_Tax_Config();
362
-        $this->tax_settings = apply_filters(
363
-            'FHEE__EE_Config___initialize_config__tax_settings',
364
-            $this->tax_settings
365
-        );
366
-        $this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages);
367
-        $this->messages = $this->messages instanceof EE_Messages_Config
368
-            ? $this->messages
369
-            : new EE_Messages_Config();
370
-        $this->gateway = $this->gateway instanceof EE_Gateway_Config
371
-            ? $this->gateway
372
-            : new EE_Gateway_Config();
373
-        $this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway);
374
-        $this->legacy_shortcodes_manager = null;
375
-    }
376
-
377
-
378
-    /**
379
-     *    get_espresso_config
380
-     *
381
-     * @access    public
382
-     * @return    array of espresso config stuff
383
-     */
384
-    public function get_espresso_config()
385
-    {
386
-        // grab espresso configuration
387
-        return apply_filters(
388
-            'FHEE__EE_Config__get_espresso_config__CFG',
389
-            get_option(EE_Config::OPTION_NAME, array())
390
-        );
391
-    }
392
-
393
-
394
-    /**
395
-     *    double_check_config_comparison
396
-     *
397
-     * @access    public
398
-     * @param string $option
399
-     * @param        $old_value
400
-     * @param        $value
401
-     */
402
-    public function double_check_config_comparison($option = '', $old_value, $value)
403
-    {
404
-        // make sure we're checking the ee config
405
-        if ($option === EE_Config::OPTION_NAME) {
406
-            // run a loose comparison of the old value against the new value for type and properties,
407
-            // but NOT exact instance like WP update_option does (ie: NOT type safe comparison)
408
-            if ($value != $old_value) {
409
-                // if they are NOT the same, then remove the hook,
410
-                // which means the subsequent update results will be based solely on the update query results
411
-                // the reason we do this is because, as stated above,
412
-                // WP update_option performs an exact instance comparison (===) on any update values passed to it
413
-                // this happens PRIOR to serialization and any subsequent update.
414
-                // If values are found to match their previous old value,
415
-                // then WP bails before performing any update.
416
-                // Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version
417
-                // it just pulled from the db, with the one being passed to it (which will not match).
418
-                // HOWEVER, once the object is serialized and passed off to MySQL to update,
419
-                // MySQL MAY ALSO NOT perform the update because
420
-                // the string it sees in the db looks the same as the new one it has been passed!!!
421
-                // This results in the query returning an "affected rows" value of ZERO,
422
-                // which gets returned immediately by WP update_option and looks like an error.
423
-                remove_action('update_option', array($this, 'check_config_updated'));
424
-            }
425
-        }
426
-    }
427
-
428
-
429
-    /**
430
-     *    update_espresso_config
431
-     *
432
-     * @access   public
433
-     */
434
-    protected function _reset_espresso_addon_config()
435
-    {
436
-        $this->_addon_option_names = array();
437
-        foreach ($this->addons as $addon_name => $addon_config_obj) {
438
-            $addon_config_obj = maybe_unserialize($addon_config_obj);
439
-            if ($addon_config_obj instanceof EE_Config_Base) {
440
-                $this->update_config('addons', $addon_name, $addon_config_obj, false);
441
-            }
442
-            $this->addons->{$addon_name} = null;
443
-        }
444
-    }
445
-
446
-
447
-    /**
448
-     *    update_espresso_config
449
-     *
450
-     * @access   public
451
-     * @param   bool $add_success
452
-     * @param   bool $add_error
453
-     * @return   bool
454
-     */
455
-    public function update_espresso_config($add_success = false, $add_error = true)
456
-    {
457
-        // don't allow config updates during WP heartbeats
458
-        if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
459
-            return false;
460
-        }
461
-        // commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
462
-        // $clone = clone( self::$_instance );
463
-        // self::$_instance = NULL;
464
-        do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
465
-        $this->_reset_espresso_addon_config();
466
-        // hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
467
-        // but BEFORE the actual update occurs
468
-        add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
469
-        // don't want to persist legacy_shortcodes_manager, but don't want to lose it either
470
-        $legacy_shortcodes_manager = $this->legacy_shortcodes_manager;
471
-        $this->legacy_shortcodes_manager = null;
472
-        // now update "ee_config"
473
-        $saved = update_option(EE_Config::OPTION_NAME, $this);
474
-        $this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
475
-        EE_Config::log(EE_Config::OPTION_NAME);
476
-        // if not saved... check if the hook we just added still exists;
477
-        // if it does, it means one of two things:
478
-        // that update_option bailed at the($value === $old_value) conditional,
479
-        // or...
480
-        // the db update query returned 0 rows affected
481
-        // (probably because the data  value was the same from it's perspective)
482
-        // so the existence of the hook means that a negative result from update_option is NOT an error,
483
-        // but just means no update occurred, so don't display an error to the user.
484
-        // BUT... if update_option returns FALSE, AND the hook is missing,
485
-        // then it means that something truly went wrong
486
-        $saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
487
-        // remove our action since we don't want it in the system anymore
488
-        remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
489
-        do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
490
-        // self::$_instance = $clone;
491
-        // unset( $clone );
492
-        // if config remains the same or was updated successfully
493
-        if ($saved) {
494
-            if ($add_success) {
495
-                EE_Error::add_success(
496
-                    __('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
497
-                    __FILE__,
498
-                    __FUNCTION__,
499
-                    __LINE__
500
-                );
501
-            }
502
-            return true;
503
-        } else {
504
-            if ($add_error) {
505
-                EE_Error::add_error(
506
-                    __('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
507
-                    __FILE__,
508
-                    __FUNCTION__,
509
-                    __LINE__
510
-                );
511
-            }
512
-            return false;
513
-        }
514
-    }
515
-
516
-
517
-    /**
518
-     *    _verify_config_params
519
-     *
520
-     * @access    private
521
-     * @param    string         $section
522
-     * @param    string         $name
523
-     * @param    string         $config_class
524
-     * @param    EE_Config_Base $config_obj
525
-     * @param    array          $tests_to_run
526
-     * @param    bool           $display_errors
527
-     * @return    bool    TRUE on success, FALSE on fail
528
-     */
529
-    private function _verify_config_params(
530
-        $section = '',
531
-        $name = '',
532
-        $config_class = '',
533
-        $config_obj = null,
534
-        $tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
535
-        $display_errors = true
536
-    ) {
537
-        try {
538
-            foreach ($tests_to_run as $test) {
539
-                switch ($test) {
540
-                    // TEST #1 : check that section was set
541
-                    case 1:
542
-                        if (empty($section)) {
543
-                            if ($display_errors) {
544
-                                throw new EE_Error(
545
-                                    sprintf(
546
-                                        __(
547
-                                            'No configuration section has been provided while attempting to save "%s".',
548
-                                            'event_espresso'
549
-                                        ),
550
-                                        $config_class
551
-                                    )
552
-                                );
553
-                            }
554
-                            return false;
555
-                        }
556
-                        break;
557
-                    // TEST #2 : check that settings section exists
558
-                    case 2:
559
-                        if (! isset($this->{$section})) {
560
-                            if ($display_errors) {
561
-                                throw new EE_Error(
562
-                                    sprintf(
563
-                                        __('The "%s" configuration section does not exist.', 'event_espresso'),
564
-                                        $section
565
-                                    )
566
-                                );
567
-                            }
568
-                            return false;
569
-                        }
570
-                        break;
571
-                    // TEST #3 : check that section is the proper format
572
-                    case 3:
573
-                        if (
574
-                            ! ($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 (
800
-            ! $this->_verify_config_params(
801
-                $section,
802
-                $name,
803
-                $config_class,
804
-                $config_obj,
805
-                array(1, 2, 3, 4, 7, 9)
806
-            )
807
-        ) {
808
-            return false;
809
-        }
810
-        $config_option_name = $this->_generate_config_option_name($section, $name);
811
-        // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
812
-        if (! isset($this->_addon_option_names[ $config_option_name ])) {
813
-            // save new config to db
814
-            if ($this->set_config($section, $name, $config_class, $config_obj)) {
815
-                return true;
816
-            }
817
-        } else {
818
-            // first check if the record already exists
819
-            $existing_config = get_option($config_option_name);
820
-            $config_obj = serialize($config_obj);
821
-            // just return if db record is already up to date (NOT type safe comparison)
822
-            if ($existing_config == $config_obj) {
823
-                $this->{$section}->{$name} = $config_obj;
824
-                return true;
825
-            } elseif (update_option($config_option_name, $config_obj)) {
826
-                EE_Config::log($config_option_name);
827
-                // update wp-option for this config class
828
-                $this->{$section}->{$name} = $config_obj;
829
-                return true;
830
-            } elseif ($throw_errors) {
831
-                EE_Error::add_error(
832
-                    sprintf(
833
-                        __(
834
-                            'The "%1$s" object stored at"%2$s" was not successfully updated in the database.',
835
-                            'event_espresso'
836
-                        ),
837
-                        $config_class,
838
-                        'EE_Config->' . $section . '->' . $name
839
-                    ),
840
-                    __FILE__,
841
-                    __FUNCTION__,
842
-                    __LINE__
843
-                );
844
-            }
845
-        }
846
-        return false;
847
-    }
848
-
849
-
850
-    /**
851
-     *    get_config
852
-     *
853
-     * @access    public
854
-     * @param    string $section
855
-     * @param    string $name
856
-     * @param    string $config_class
857
-     * @return    mixed EE_Config_Base | NULL
858
-     */
859
-    public function get_config($section = '', $name = '', $config_class = '')
860
-    {
861
-        // ensure config class is set to something
862
-        $config_class = $this->_set_config_class($config_class, $name);
863
-        // run tests 1-4, 6 and 7 to verify that all params have been set
864
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
865
-            return null;
866
-        }
867
-        // now test if the requested config object exists, but suppress errors
868
-        if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) {
869
-            // config already exists, so pass it back
870
-            return $this->{$section}->{$name};
871
-        }
872
-        // load config option from db if it exists
873
-        $config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
874
-        // verify the newly retrieved config object, but suppress errors
875
-        if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
876
-            // config is good, so set it and pass it back
877
-            $this->{$section}->{$name} = $config_obj;
878
-            return $this->{$section}->{$name};
879
-        }
880
-        // oops! $config_obj is not already set and does not exist in the db, so create a new one
881
-        $config_obj = $this->set_config($section, $name, $config_class);
882
-        // verify the newly created config object
883
-        if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
884
-            return $this->{$section}->{$name};
885
-        } else {
886
-            EE_Error::add_error(
887
-                sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
888
-                __FILE__,
889
-                __FUNCTION__,
890
-                __LINE__
891
-            );
892
-        }
893
-        return null;
894
-    }
895
-
896
-
897
-    /**
898
-     *    get_config_option
899
-     *
900
-     * @access    public
901
-     * @param    string $config_option_name
902
-     * @return    mixed EE_Config_Base | FALSE
903
-     */
904
-    public function get_config_option($config_option_name = '')
905
-    {
906
-        // retrieve the wp-option for this config class.
907
-        $config_option = maybe_unserialize(get_option($config_option_name, array()));
908
-        if (empty($config_option)) {
909
-            EE_Config::log($config_option_name . '-NOT-FOUND');
910
-        }
911
-        return $config_option;
912
-    }
913
-
914
-
915
-    /**
916
-     * log
917
-     *
918
-     * @param string $config_option_name
919
-     */
920
-    public static function log($config_option_name = '')
921
-    {
922
-        if (EE_Config::logging_enabled() && ! empty($config_option_name)) {
923
-            $config_log = get_option(EE_Config::LOG_NAME, array());
924
-            // copy incoming $_REQUEST and sanitize it so we can save it
925
-            $_request = $_REQUEST;
926
-            array_walk_recursive($_request, 'sanitize_text_field');
927
-            $config_log[ (string) microtime(true) ] = array(
928
-                'config_name' => $config_option_name,
929
-                'request'     => $_request,
930
-            );
931
-            update_option(EE_Config::LOG_NAME, $config_log);
932
-        }
933
-    }
934
-
935
-
936
-    /**
937
-     * trim_log
938
-     * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH
939
-     */
940
-    public static function trim_log()
941
-    {
942
-        if (! EE_Config::logging_enabled()) {
943
-            return;
944
-        }
945
-        $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
946
-        $log_length = count($config_log);
947
-        if ($log_length > EE_Config::LOG_LENGTH) {
948
-            ksort($config_log);
949
-            $config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true);
950
-            update_option(EE_Config::LOG_NAME, $config_log);
951
-        }
952
-    }
953
-
954
-
955
-    /**
956
-     *    get_page_for_posts
957
-     *    if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the
958
-     *    wp-option "page_for_posts", or "posts" if no page is selected
959
-     *
960
-     * @access    public
961
-     * @return    string
962
-     */
963
-    public static function get_page_for_posts()
964
-    {
965
-        $page_for_posts = get_option('page_for_posts');
966
-        if (! $page_for_posts) {
967
-            return 'posts';
968
-        }
969
-        /** @type WPDB $wpdb */
970
-        global $wpdb;
971
-        $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
972
-        return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
973
-    }
974
-
975
-
976
-    /**
977
-     *    register_shortcodes_and_modules.
978
-     *    At this point, it's too early to tell if we're maintenance mode or not.
979
-     *    In fact, this is where we give modules a chance to let core know they exist
980
-     *    so they can help trigger maintenance mode if it's needed
981
-     *
982
-     * @access    public
983
-     * @return    void
984
-     */
985
-    public function register_shortcodes_and_modules()
986
-    {
987
-        // allow modules to set hooks for the rest of the system
988
-        EE_Registry::instance()->modules = $this->_register_modules();
989
-    }
990
-
991
-
992
-    /**
993
-     *    initialize_shortcodes_and_modules
994
-     *    meaning they can start adding their hooks to get stuff done
995
-     *
996
-     * @access    public
997
-     * @return    void
998
-     */
999
-    public function initialize_shortcodes_and_modules()
1000
-    {
1001
-        // allow modules to set hooks for the rest of the system
1002
-        $this->_initialize_modules();
1003
-    }
1004
-
1005
-
1006
-    /**
1007
-     *    widgets_init
1008
-     *
1009
-     * @access private
1010
-     * @return void
1011
-     */
1012
-    public function widgets_init()
1013
-    {
1014
-        // only init widgets on admin pages when not in complete maintenance, and
1015
-        // on frontend when not in any maintenance mode
1016
-        if (
1017
-            ! EE_Maintenance_Mode::instance()->level()
1018
-            || (
1019
-                is_admin()
1020
-                && EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
1021
-            )
1022
-        ) {
1023
-            // grab list of installed widgets
1024
-            $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1025
-            // filter list of modules to register
1026
-            $widgets_to_register = apply_filters(
1027
-                'FHEE__EE_Config__register_widgets__widgets_to_register',
1028
-                $widgets_to_register
1029
-            );
1030
-            if (! empty($widgets_to_register)) {
1031
-                // cycle thru widget folders
1032
-                foreach ($widgets_to_register as $widget_path) {
1033
-                    // add to list of installed widget modules
1034
-                    EE_Config::register_ee_widget($widget_path);
1035
-                }
1036
-            }
1037
-            // filter list of installed modules
1038
-            EE_Registry::instance()->widgets = apply_filters(
1039
-                'FHEE__EE_Config__register_widgets__installed_widgets',
1040
-                EE_Registry::instance()->widgets
1041
-            );
1042
-        }
1043
-    }
1044
-
1045
-
1046
-    /**
1047
-     *    register_ee_widget - makes core aware of this widget
1048
-     *
1049
-     * @access    public
1050
-     * @param    string $widget_path - full path up to and including widget folder
1051
-     * @return    void
1052
-     */
1053
-    public static function register_ee_widget($widget_path = null)
1054
-    {
1055
-        do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
1056
-        $widget_ext = '.widget.php';
1057
-        // make all separators match
1058
-        $widget_path = rtrim(str_replace('\\', DS, $widget_path), DS);
1059
-        // does the file path INCLUDE the actual file name as part of the path ?
1060
-        if (strpos($widget_path, $widget_ext) !== false) {
1061
-            // grab and shortcode file name from directory name and break apart at dots
1062
-            $file_name = explode('.', basename($widget_path));
1063
-            // take first segment from file name pieces and remove class prefix if it exists
1064
-            $widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
1065
-            // sanitize shortcode directory name
1066
-            $widget = sanitize_key($widget);
1067
-            // now we need to rebuild the shortcode path
1068
-            $widget_path = explode('/', $widget_path);
1069
-            // remove last segment
1070
-            array_pop($widget_path);
1071
-            // glue it back together
1072
-            $widget_path = implode(DS, $widget_path);
1073
-        } else {
1074
-            // grab and sanitize widget directory name
1075
-            $widget = sanitize_key(basename($widget_path));
1076
-        }
1077
-        // create classname from widget directory name
1078
-        $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1079
-        // add class prefix
1080
-        $widget_class = 'EEW_' . $widget;
1081
-        // does the widget exist ?
1082
-        if (! is_readable($widget_path . '/' . $widget_class . $widget_ext)) {
1083
-            $msg = sprintf(
1084
-                __(
1085
-                    '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',
1086
-                    'event_espresso'
1087
-                ),
1088
-                $widget_class,
1089
-                $widget_path . '/' . $widget_class . $widget_ext
1090
-            );
1091
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1092
-            return;
1093
-        }
1094
-        // load the widget class file
1095
-        require_once($widget_path . '/' . $widget_class . $widget_ext);
1096
-        // verify that class exists
1097
-        if (! class_exists($widget_class)) {
1098
-            $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1099
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1100
-            return;
1101
-        }
1102
-        register_widget($widget_class);
1103
-        // add to array of registered widgets
1104
-        EE_Registry::instance()->widgets->{$widget_class} = $widget_path . '/' . $widget_class . $widget_ext;
1105
-    }
1106
-
1107
-
1108
-    /**
1109
-     *        _register_modules
1110
-     *
1111
-     * @access private
1112
-     * @return array
1113
-     */
1114
-    private function _register_modules()
1115
-    {
1116
-        // grab list of installed modules
1117
-        $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1118
-        // filter list of modules to register
1119
-        $modules_to_register = apply_filters(
1120
-            'FHEE__EE_Config__register_modules__modules_to_register',
1121
-            $modules_to_register
1122
-        );
1123
-        if (! empty($modules_to_register)) {
1124
-            // loop through folders
1125
-            foreach ($modules_to_register as $module_path) {
1126
-                /**TEMPORARILY EXCLUDE gateways from modules for time being**/
1127
-                if (
1128
-                    $module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1129
-                    && $module_path !== EE_MODULES . 'gateways'
1130
-                ) {
1131
-                    // add to list of installed modules
1132
-                    EE_Config::register_module($module_path);
1133
-                }
1134
-            }
1135
-        }
1136
-        // filter list of installed modules
1137
-        return apply_filters(
1138
-            'FHEE__EE_Config___register_modules__installed_modules',
1139
-            EE_Registry::instance()->modules
1140
-        );
1141
-    }
1142
-
1143
-
1144
-    /**
1145
-     *    register_module - makes core aware of this module
1146
-     *
1147
-     * @access    public
1148
-     * @param    string $module_path - full path up to and including module folder
1149
-     * @return    bool
1150
-     */
1151
-    public static function register_module($module_path = null)
1152
-    {
1153
-        do_action('AHEE__EE_Config__register_module__begin', $module_path);
1154
-        $module_ext = '.module.php';
1155
-        // make all separators match
1156
-        $module_path = str_replace(array('\\', '/'), '/', $module_path);
1157
-        // does the file path INCLUDE the actual file name as part of the path ?
1158
-        if (strpos($module_path, $module_ext) !== false) {
1159
-            // grab and shortcode file name from directory name and break apart at dots
1160
-            $module_file = explode('.', basename($module_path));
1161
-            // now we need to rebuild the shortcode path
1162
-            $module_path = explode('/', $module_path);
1163
-            // remove last segment
1164
-            array_pop($module_path);
1165
-            // glue it back together
1166
-            $module_path = implode('/', $module_path) . '/';
1167
-            // take first segment from file name pieces and sanitize it
1168
-            $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1169
-            // ensure class prefix is added
1170
-            $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1171
-        } else {
1172
-            // we need to generate the filename based off of the folder name
1173
-            // grab and sanitize module name
1174
-            $module = strtolower(basename($module_path));
1175
-            $module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1176
-            // like trailingslashit()
1177
-            $module_path = rtrim($module_path, '/') . '/';
1178
-            // create classname from module directory name
1179
-            $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1180
-            // add class prefix
1181
-            $module_class = 'EED_' . $module;
1182
-        }
1183
-        // does the module exist ?
1184
-        if (! is_readable($module_path . '/' . $module_class . $module_ext)) {
1185
-            $msg = sprintf(
1186
-                __(
1187
-                    'The requested %s module file could not be found or is not readable due to file permissions.',
1188
-                    'event_espresso'
1189
-                ),
1190
-                $module
1191
-            );
1192
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1193
-            return false;
1194
-        }
1195
-        // load the module class file
1196
-        require_once($module_path . $module_class . $module_ext);
1197
-        // verify that class exists
1198
-        if (! class_exists($module_class)) {
1199
-            $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1200
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1201
-            return false;
1202
-        }
1203
-        // add to array of registered modules
1204
-        EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1205
-        do_action(
1206
-            'AHEE__EE_Config__register_module__complete',
1207
-            $module_class,
1208
-            EE_Registry::instance()->modules->{$module_class}
1209
-        );
1210
-        return true;
1211
-    }
1212
-
1213
-
1214
-    /**
1215
-     *    _initialize_modules
1216
-     *    allow modules to set hooks for the rest of the system
1217
-     *
1218
-     * @access private
1219
-     * @return void
1220
-     */
1221
-    private function _initialize_modules()
1222
-    {
1223
-        // cycle thru shortcode folders
1224
-        foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1225
-            // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1226
-            // which set hooks ?
1227
-            if (is_admin()) {
1228
-                // fire immediately
1229
-                call_user_func(array($module_class, 'set_hooks_admin'));
1230
-            } else {
1231
-                // delay until other systems are online
1232
-                add_action(
1233
-                    'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1234
-                    array($module_class, 'set_hooks')
1235
-                );
1236
-            }
1237
-        }
1238
-    }
1239
-
1240
-
1241
-    /**
1242
-     *    register_route - adds module method routes to route_map
1243
-     *
1244
-     * @access    public
1245
-     * @param    string $route       - "pretty" public alias for module method
1246
-     * @param    string $module      - module name (classname without EED_ prefix)
1247
-     * @param    string $method_name - the actual module method to be routed to
1248
-     * @param    string $key         - url param key indicating a route is being called
1249
-     * @return    bool
1250
-     */
1251
-    public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee')
1252
-    {
1253
-        do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1254
-        $module = str_replace('EED_', '', $module);
1255
-        $module_class = 'EED_' . $module;
1256
-        if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1257
-            $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1258
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1259
-            return false;
1260
-        }
1261
-        if (empty($route)) {
1262
-            $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1263
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1264
-            return false;
1265
-        }
1266
-        if (! method_exists('EED_' . $module, $method_name)) {
1267
-            $msg = sprintf(
1268
-                __('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1269
-                $route
1270
-            );
1271
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1272
-            return false;
1273
-        }
1274
-        EE_Config::$_module_route_map[ (string) $key ][ (string) $route ] = array('EED_' . $module, $method_name);
1275
-        return true;
1276
-    }
1277
-
1278
-
1279
-    /**
1280
-     *    get_route - get module method route
1281
-     *
1282
-     * @access    public
1283
-     * @param    string $route - "pretty" public alias for module method
1284
-     * @param    string $key   - url param key indicating a route is being called
1285
-     * @return    string
1286
-     */
1287
-    public static function get_route($route = null, $key = 'ee')
1288
-    {
1289
-        do_action('AHEE__EE_Config__get_route__begin', $route);
1290
-        $route = (string) apply_filters('FHEE__EE_Config__get_route', $route);
1291
-        if (isset(EE_Config::$_module_route_map[ $key ][ $route ])) {
1292
-            return EE_Config::$_module_route_map[ $key ][ $route ];
1293
-        }
1294
-        return null;
1295
-    }
1296
-
1297
-
1298
-    /**
1299
-     *    get_routes - get ALL module method routes
1300
-     *
1301
-     * @access    public
1302
-     * @return    array
1303
-     */
1304
-    public static function get_routes()
1305
-    {
1306
-        return EE_Config::$_module_route_map;
1307
-    }
1308
-
1309
-
1310
-    /**
1311
-     *    register_forward - allows modules to forward request to another module for further processing
1312
-     *
1313
-     * @access    public
1314
-     * @param    string       $route   - "pretty" public alias for module method
1315
-     * @param    integer      $status  - integer value corresponding  to status constant strings set in module parent
1316
-     *                                 class, allows different forwards to be served based on status
1317
-     * @param    array|string $forward - function name or array( class, method )
1318
-     * @param    string       $key     - url param key indicating a route is being called
1319
-     * @return    bool
1320
-     */
1321
-    public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1322
-    {
1323
-        do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1324
-        if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1325
-            $msg = sprintf(
1326
-                __('The module route %s for this forward has not been registered.', 'event_espresso'),
1327
-                $route
1328
-            );
1329
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1330
-            return false;
1331
-        }
1332
-        if (empty($forward)) {
1333
-            $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1334
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1335
-            return false;
1336
-        }
1337
-        if (is_array($forward)) {
1338
-            if (! isset($forward[1])) {
1339
-                $msg = sprintf(
1340
-                    __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1341
-                    $route
1342
-                );
1343
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1344
-                return false;
1345
-            }
1346
-            if (! method_exists($forward[0], $forward[1])) {
1347
-                $msg = sprintf(
1348
-                    __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1349
-                    $forward[1],
1350
-                    $route
1351
-                );
1352
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1353
-                return false;
1354
-            }
1355
-        } elseif (! function_exists($forward)) {
1356
-            $msg = sprintf(
1357
-                __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1358
-                $forward,
1359
-                $route
1360
-            );
1361
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1362
-            return false;
1363
-        }
1364
-        EE_Config::$_module_forward_map[ $key ][ $route ][ absint($status) ] = $forward;
1365
-        return true;
1366
-    }
1367
-
1368
-
1369
-    /**
1370
-     *    get_forward - get forwarding route
1371
-     *
1372
-     * @access    public
1373
-     * @param    string  $route  - "pretty" public alias for module method
1374
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1375
-     *                           allows different forwards to be served based on status
1376
-     * @param    string  $key    - url param key indicating a route is being called
1377
-     * @return    string
1378
-     */
1379
-    public static function get_forward($route = null, $status = 0, $key = 'ee')
1380
-    {
1381
-        do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1382
-        if (isset(EE_Config::$_module_forward_map[ $key ][ $route ][ $status ])) {
1383
-            return apply_filters(
1384
-                'FHEE__EE_Config__get_forward',
1385
-                EE_Config::$_module_forward_map[ $key ][ $route ][ $status ],
1386
-                $route,
1387
-                $status
1388
-            );
1389
-        }
1390
-        return null;
1391
-    }
1392
-
1393
-
1394
-    /**
1395
-     *    register_forward - allows modules to specify different view templates for different method routes and status
1396
-     *    results
1397
-     *
1398
-     * @access    public
1399
-     * @param    string  $route  - "pretty" public alias for module method
1400
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1401
-     *                           allows different views to be served based on status
1402
-     * @param    string  $view
1403
-     * @param    string  $key    - url param key indicating a route is being called
1404
-     * @return    bool
1405
-     */
1406
-    public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1407
-    {
1408
-        do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1409
-        if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1410
-            $msg = sprintf(
1411
-                __('The module route %s for this view has not been registered.', 'event_espresso'),
1412
-                $route
1413
-            );
1414
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1415
-            return false;
1416
-        }
1417
-        if (! is_readable($view)) {
1418
-            $msg = sprintf(
1419
-                __(
1420
-                    'The %s view file could not be found or is not readable due to file permissions.',
1421
-                    'event_espresso'
1422
-                ),
1423
-                $view
1424
-            );
1425
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1426
-            return false;
1427
-        }
1428
-        EE_Config::$_module_view_map[ $key ][ $route ][ absint($status) ] = $view;
1429
-        return true;
1430
-    }
1431
-
1432
-
1433
-    /**
1434
-     *    get_view - get view for route and status
1435
-     *
1436
-     * @access    public
1437
-     * @param    string  $route  - "pretty" public alias for module method
1438
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1439
-     *                           allows different views to be served based on status
1440
-     * @param    string  $key    - url param key indicating a route is being called
1441
-     * @return    string
1442
-     */
1443
-    public static function get_view($route = null, $status = 0, $key = 'ee')
1444
-    {
1445
-        do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1446
-        if (isset(EE_Config::$_module_view_map[ $key ][ $route ][ $status ])) {
1447
-            return apply_filters(
1448
-                'FHEE__EE_Config__get_view',
1449
-                EE_Config::$_module_view_map[ $key ][ $route ][ $status ],
1450
-                $route,
1451
-                $status
1452
-            );
1453
-        }
1454
-        return null;
1455
-    }
1456
-
1457
-
1458
-    public function update_addon_option_names()
1459
-    {
1460
-        update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names);
1461
-    }
1462
-
1463
-
1464
-    public function shutdown()
1465
-    {
1466
-        $this->update_addon_option_names();
1467
-    }
1468
-
1469
-
1470
-    /**
1471
-     * @return LegacyShortcodesManager
1472
-     */
1473
-    public static function getLegacyShortcodesManager()
1474
-    {
1475
-
1476
-        if (! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1477
-            EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager(
1478
-                EE_Registry::instance()
1479
-            );
1480
-        }
1481
-        return EE_Config::instance()->legacy_shortcodes_manager;
1482
-    }
1483
-
1484
-
1485
-    /**
1486
-     * register_shortcode - makes core aware of this shortcode
1487
-     *
1488
-     * @deprecated 4.9.26
1489
-     * @param    string $shortcode_path - full path up to and including shortcode folder
1490
-     * @return    bool
1491
-     */
1492
-    public static function register_shortcode($shortcode_path = null)
1493
-    {
1494
-        EE_Error::doing_it_wrong(
1495
-            __METHOD__,
1496
-            __(
1497
-                '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.',
1498
-                'event_espresso'
1499
-            ),
1500
-            '4.9.26'
1501
-        );
1502
-        return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path);
1503
-    }
1504
-}
1505
-
1506
-/**
1507
- * Base class used for config classes. These classes should generally not have
1508
- * magic functions in use, except we'll allow them to magically set and get stuff...
1509
- * basically, they should just be well-defined stdClasses
1510
- */
1511
-class EE_Config_Base
1512
-{
1513
-
1514
-    /**
1515
-     * Utility function for escaping the value of a property and returning.
1516
-     *
1517
-     * @param string $property property name (checks to see if exists).
1518
-     * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1519
-     * @throws \EE_Error
1520
-     */
1521
-    public function get_pretty($property)
1522
-    {
1523
-        if (! property_exists($this, $property)) {
1524
-            throw new EE_Error(
1525
-                sprintf(
1526
-                    __(
1527
-                        '%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.',
1528
-                        'event_espresso'
1529
-                    ),
1530
-                    get_class($this),
1531
-                    $property
1532
-                )
1533
-            );
1534
-        }
1535
-        // just handling escaping of strings for now.
1536
-        if (is_string($this->{$property})) {
1537
-            return stripslashes($this->{$property});
1538
-        }
1539
-        return $this->{$property};
1540
-    }
1541
-
1542
-
1543
-    public function populate()
1544
-    {
1545
-        // grab defaults via a new instance of this class.
1546
-        $class_name = get_class($this);
1547
-        $defaults = new $class_name();
1548
-        // loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1549
-        // default from our $defaults object.
1550
-        foreach (get_object_vars($defaults) as $property => $value) {
1551
-            if ($this->{$property} === null) {
1552
-                $this->{$property} = $value;
1553
-            }
1554
-        }
1555
-        // cleanup
1556
-        unset($defaults);
1557
-    }
1558
-
1559
-
1560
-    /**
1561
-     *        __isset
1562
-     *
1563
-     * @param $a
1564
-     * @return bool
1565
-     */
1566
-    public function __isset($a)
1567
-    {
1568
-        return false;
1569
-    }
1570
-
1571
-
1572
-    /**
1573
-     *        __unset
1574
-     *
1575
-     * @param $a
1576
-     * @return bool
1577
-     */
1578
-    public function __unset($a)
1579
-    {
1580
-        return false;
1581
-    }
1582
-
1583
-
1584
-    /**
1585
-     *        __clone
1586
-     */
1587
-    public function __clone()
1588
-    {
1589
-    }
1590
-
1591
-
1592
-    /**
1593
-     *        __wakeup
1594
-     */
1595
-    public function __wakeup()
1596
-    {
1597
-    }
1598
-
1599
-
1600
-    /**
1601
-     *        __destruct
1602
-     */
1603
-    public function __destruct()
1604
-    {
1605
-    }
1606
-}
1607
-
1608
-/**
1609
- * Class for defining what's in the EE_Config relating to registration settings
1610
- */
1611
-class EE_Core_Config extends EE_Config_Base
1612
-{
1613
-
1614
-    const OPTION_NAME_UXIP = 'ee_ueip_optin';
1615
-
1616
-
1617
-    public $current_blog_id;
1618
-
1619
-    public $ee_ueip_optin;
1620
-
1621
-    public $ee_ueip_has_notified;
1622
-
1623
-    /**
1624
-     * Not to be confused with the 4 critical page variables (See
1625
-     * get_critical_pages_array()), this is just an array of wp posts that have EE
1626
-     * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode
1627
-     * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array.
1628
-     *
1629
-     * @var array
1630
-     */
1631
-    public $post_shortcodes;
1632
-
1633
-    public $module_route_map;
1634
-
1635
-    public $module_forward_map;
1636
-
1637
-    public $module_view_map;
1638
-
1639
-    /**
1640
-     * The next 4 vars are the IDs of critical EE pages.
1641
-     *
1642
-     * @var int
1643
-     */
1644
-    public $reg_page_id;
1645
-
1646
-    public $txn_page_id;
1647
-
1648
-    public $thank_you_page_id;
1649
-
1650
-    public $cancel_page_id;
1651
-
1652
-    /**
1653
-     * The next 4 vars are the URLs of critical EE pages.
1654
-     *
1655
-     * @var int
1656
-     */
1657
-    public $reg_page_url;
1658
-
1659
-    public $txn_page_url;
1660
-
1661
-    public $thank_you_page_url;
1662
-
1663
-    public $cancel_page_url;
1664
-
1665
-    /**
1666
-     * The next vars relate to the custom slugs for EE CPT routes
1667
-     */
1668
-    public $event_cpt_slug;
1669
-
1670
-    /**
1671
-     * This caches the _ee_ueip_option in case this config is reset in the same
1672
-     * request across blog switches in a multisite context.
1673
-     * Avoids extra queries to the db for this option.
1674
-     *
1675
-     * @var bool
1676
-     */
1677
-    public static $ee_ueip_option;
1678
-
1679
-
1680
-    /**
1681
-     *    class constructor
1682
-     *
1683
-     * @access    public
1684
-     */
1685
-    public function __construct()
1686
-    {
1687
-        // set default organization settings
1688
-        $this->current_blog_id = get_current_blog_id();
1689
-        $this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id;
1690
-        $this->ee_ueip_optin = $this->_get_main_ee_ueip_optin();
1691
-        $this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1692
-        $this->post_shortcodes = array();
1693
-        $this->module_route_map = array();
1694
-        $this->module_forward_map = array();
1695
-        $this->module_view_map = array();
1696
-        // critical EE page IDs
1697
-        $this->reg_page_id = 0;
1698
-        $this->txn_page_id = 0;
1699
-        $this->thank_you_page_id = 0;
1700
-        $this->cancel_page_id = 0;
1701
-        // critical EE page URLs
1702
-        $this->reg_page_url = '';
1703
-        $this->txn_page_url = '';
1704
-        $this->thank_you_page_url = '';
1705
-        $this->cancel_page_url = '';
1706
-        // cpt slugs
1707
-        $this->event_cpt_slug = __('events', 'event_espresso');
1708
-        // ueip constant check
1709
-        if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1710
-            $this->ee_ueip_optin = false;
1711
-            $this->ee_ueip_has_notified = true;
1712
-        }
1713
-    }
1714
-
1715
-
1716
-    /**
1717
-     * @return array
1718
-     */
1719
-    public function get_critical_pages_array()
1720
-    {
1721
-        return array(
1722
-            $this->reg_page_id,
1723
-            $this->txn_page_id,
1724
-            $this->thank_you_page_id,
1725
-            $this->cancel_page_id,
1726
-        );
1727
-    }
1728
-
1729
-
1730
-    /**
1731
-     * @return array
1732
-     */
1733
-    public function get_critical_pages_shortcodes_array()
1734
-    {
1735
-        return array(
1736
-            $this->reg_page_id       => 'ESPRESSO_CHECKOUT',
1737
-            $this->txn_page_id       => 'ESPRESSO_TXN_PAGE',
1738
-            $this->thank_you_page_id => 'ESPRESSO_THANK_YOU',
1739
-            $this->cancel_page_id    => 'ESPRESSO_CANCELLED',
1740
-        );
1741
-    }
1742
-
1743
-
1744
-    /**
1745
-     *  gets/returns URL for EE reg_page
1746
-     *
1747
-     * @access    public
1748
-     * @return    string
1749
-     */
1750
-    public function reg_page_url()
1751
-    {
1752
-        if (! $this->reg_page_url) {
1753
-            $this->reg_page_url = add_query_arg(
1754
-                array('uts' => time()),
1755
-                get_permalink($this->reg_page_id)
1756
-            ) . '#checkout';
1757
-        }
1758
-        return $this->reg_page_url;
1759
-    }
1760
-
1761
-
1762
-    /**
1763
-     *  gets/returns URL for EE txn_page
1764
-     *
1765
-     * @param array $query_args like what gets passed to
1766
-     *                          add_query_arg() as the first argument
1767
-     * @access    public
1768
-     * @return    string
1769
-     */
1770
-    public function txn_page_url($query_args = array())
1771
-    {
1772
-        if (! $this->txn_page_url) {
1773
-            $this->txn_page_url = get_permalink($this->txn_page_id);
1774
-        }
1775
-        if ($query_args) {
1776
-            return add_query_arg($query_args, $this->txn_page_url);
1777
-        } else {
1778
-            return $this->txn_page_url;
1779
-        }
1780
-    }
1781
-
1782
-
1783
-    /**
1784
-     *  gets/returns URL for EE thank_you_page
1785
-     *
1786
-     * @param array $query_args like what gets passed to
1787
-     *                          add_query_arg() as the first argument
1788
-     * @access    public
1789
-     * @return    string
1790
-     */
1791
-    public function thank_you_page_url($query_args = array())
1792
-    {
1793
-        if (! $this->thank_you_page_url) {
1794
-            $this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1795
-        }
1796
-        if ($query_args) {
1797
-            return add_query_arg($query_args, $this->thank_you_page_url);
1798
-        } else {
1799
-            return $this->thank_you_page_url;
1800
-        }
1801
-    }
1802
-
1803
-
1804
-    /**
1805
-     *  gets/returns URL for EE cancel_page
1806
-     *
1807
-     * @access    public
1808
-     * @return    string
1809
-     */
1810
-    public function cancel_page_url()
1811
-    {
1812
-        if (! $this->cancel_page_url) {
1813
-            $this->cancel_page_url = get_permalink($this->cancel_page_id);
1814
-        }
1815
-        return $this->cancel_page_url;
1816
-    }
1817
-
1818
-
1819
-    /**
1820
-     * Resets all critical page urls to their original state.  Used primarily by the __sleep() magic method currently.
1821
-     *
1822
-     * @since 4.7.5
1823
-     */
1824
-    protected function _reset_urls()
1825
-    {
1826
-        $this->reg_page_url = '';
1827
-        $this->txn_page_url = '';
1828
-        $this->cancel_page_url = '';
1829
-        $this->thank_you_page_url = '';
1830
-    }
1831
-
1832
-
1833
-    /**
1834
-     * Used to return what the optin value is set for the EE User Experience Program.
1835
-     * This accounts for multisite and this value being requested for a subsite.  In multisite, the value is set
1836
-     * on the main site only.
1837
-     *
1838
-     * @return bool
1839
-     */
1840
-    protected function _get_main_ee_ueip_optin()
1841
-    {
1842
-        // if this is the main site then we can just bypass our direct query.
1843
-        if (is_main_site()) {
1844
-            return get_option(self::OPTION_NAME_UXIP, false);
1845
-        }
1846
-        // is this already cached for this request?  If so use it.
1847
-        if (EE_Core_Config::$ee_ueip_option !== null) {
1848
-            return EE_Core_Config::$ee_ueip_option;
1849
-        }
1850
-        global $wpdb;
1851
-        $current_network_main_site = is_multisite() ? get_current_site() : null;
1852
-        $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1853
-        $option = self::OPTION_NAME_UXIP;
1854
-        // set correct table for query
1855
-        $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1856
-        // rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1857
-        // get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1858
-        // re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1859
-        // this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1860
-        // for the purpose of caching.
1861
-        $pre = apply_filters('pre_option_' . $option, false, $option);
1862
-        if (false !== $pre) {
1863
-            EE_Core_Config::$ee_ueip_option = $pre;
1864
-            return EE_Core_Config::$ee_ueip_option;
1865
-        }
1866
-        $row = $wpdb->get_row(
1867
-            $wpdb->prepare(
1868
-                "SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1",
1869
-                $option
1870
-            )
1871
-        );
1872
-        if (is_object($row)) {
1873
-            $value = $row->option_value;
1874
-        } else { // option does not exist so use default.
1875
-            EE_Core_Config::$ee_ueip_option =  apply_filters('default_option_' . $option, false, $option);
1876
-            return EE_Core_Config::$ee_ueip_option;
1877
-        }
1878
-        EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1879
-        return EE_Core_Config::$ee_ueip_option;
1880
-    }
1881
-
1882
-
1883
-    /**
1884
-     * Utility function for escaping the value of a property and returning.
1885
-     *
1886
-     * @param string $property property name (checks to see if exists).
1887
-     * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1888
-     * @throws \EE_Error
1889
-     */
1890
-    public function get_pretty($property)
1891
-    {
1892
-        if ($property === self::OPTION_NAME_UXIP) {
1893
-            return $this->ee_ueip_optin ? 'yes' : 'no';
1894
-        }
1895
-        return parent::get_pretty($property);
1896
-    }
1897
-
1898
-
1899
-    /**
1900
-     * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values
1901
-     * on the object.
1902
-     *
1903
-     * @return array
1904
-     */
1905
-    public function __sleep()
1906
-    {
1907
-        // reset all url properties
1908
-        $this->_reset_urls();
1909
-        // return what to save to db
1910
-        return array_keys(get_object_vars($this));
1911
-    }
1912
-}
1913
-
1914
-/**
1915
- * Config class for storing info on the Organization
1916
- */
1917
-class EE_Organization_Config extends EE_Config_Base
1918
-{
1919
-
1920
-    /**
1921
-     * @var string $name
1922
-     * eg EE4.1
1923
-     */
1924
-    public $name;
1925
-
1926
-    /**
1927
-     * @var string $address_1
1928
-     * eg 123 Onna Road
1929
-     */
1930
-    public $address_1 = '';
1931
-
1932
-    /**
1933
-     * @var string $address_2
1934
-     * eg PO Box 123
1935
-     */
1936
-    public $address_2 = '';
1937
-
1938
-    /**
1939
-     * @var string $city
1940
-     * eg Inna City
1941
-     */
1942
-    public $city = '';
1943
-
1944
-    /**
1945
-     * @var int $STA_ID
1946
-     * eg 4
1947
-     */
1948
-    public $STA_ID = 0;
1949
-
1950
-    /**
1951
-     * @var string $CNT_ISO
1952
-     * eg US
1953
-     */
1954
-    public $CNT_ISO = '';
1955
-
1956
-    /**
1957
-     * @var string $zip
1958
-     * eg 12345  or V1A 2B3
1959
-     */
1960
-    public $zip = '';
1961
-
1962
-    /**
1963
-     * @var string $email
1964
-     * eg [email protected]
1965
-     */
1966
-    public $email;
1967
-
1968
-    /**
1969
-     * @var string $phone
1970
-     * eg. 111-111-1111
1971
-     */
1972
-    public $phone = '';
1973
-
1974
-    /**
1975
-     * @var string $vat
1976
-     * VAT/Tax Number
1977
-     */
1978
-    public $vat = '';
1979
-
1980
-    /**
1981
-     * @var string $logo_url
1982
-     * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg
1983
-     */
1984
-    public $logo_url = '';
1985
-
1986
-    /**
1987
-     * The below are all various properties for holding links to organization social network profiles
1988
-     *
1989
-     * @var string
1990
-     */
1991
-    /**
1992
-     * facebook (facebook.com/profile.name)
1993
-     *
1994
-     * @var string
1995
-     */
1996
-    public $facebook = '';
1997
-
1998
-    /**
1999
-     * twitter (twitter.com/twitter_handle)
2000
-     *
2001
-     * @var string
2002
-     */
2003
-    public $twitter = '';
2004
-
2005
-    /**
2006
-     * linkedin (linkedin.com/in/profile_name)
2007
-     *
2008
-     * @var string
2009
-     */
2010
-    public $linkedin = '';
2011
-
2012
-    /**
2013
-     * pinterest (www.pinterest.com/profile_name)
2014
-     *
2015
-     * @var string
2016
-     */
2017
-    public $pinterest = '';
2018
-
2019
-    /**
2020
-     * google+ (google.com/+profileName)
2021
-     *
2022
-     * @var string
2023
-     */
2024
-    public $google = '';
2025
-
2026
-    /**
2027
-     * instagram (instagram.com/handle)
2028
-     *
2029
-     * @var string
2030
-     */
2031
-    public $instagram = '';
2032
-
2033
-
2034
-    /**
2035
-     *    class constructor
2036
-     *
2037
-     * @access    public
2038
-     */
2039
-    public function __construct()
2040
-    {
2041
-        // set default organization settings
2042
-        // decode HTML entities from the WP blogname, because it's stored in the DB with HTML entities encoded
2043
-        $this->name = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES);
2044
-        $this->email = get_bloginfo('admin_email');
2045
-    }
2046
-}
2047
-
2048
-/**
2049
- * Class for defining what's in the EE_Config relating to currency
2050
- */
2051
-class EE_Currency_Config extends EE_Config_Base
2052
-{
2053
-
2054
-    /**
2055
-     * @var string $code
2056
-     * eg 'US'
2057
-     */
2058
-    public $code;
2059
-
2060
-    /**
2061
-     * @var string $name
2062
-     * eg 'Dollar'
2063
-     */
2064
-    public $name;
2065
-
2066
-    /**
2067
-     * plural name
2068
-     *
2069
-     * @var string $plural
2070
-     * eg 'Dollars'
2071
-     */
2072
-    public $plural;
2073
-
2074
-    /**
2075
-     * currency sign
2076
-     *
2077
-     * @var string $sign
2078
-     * eg '$'
2079
-     */
2080
-    public $sign;
2081
-
2082
-    /**
2083
-     * Whether the currency sign should come before the number or not
2084
-     *
2085
-     * @var boolean $sign_b4
2086
-     */
2087
-    public $sign_b4;
2088
-
2089
-    /**
2090
-     * How many digits should come after the decimal place
2091
-     *
2092
-     * @var int $dec_plc
2093
-     */
2094
-    public $dec_plc;
2095
-
2096
-    /**
2097
-     * Symbol to use for decimal mark
2098
-     *
2099
-     * @var string $dec_mrk
2100
-     * eg '.'
2101
-     */
2102
-    public $dec_mrk;
2103
-
2104
-    /**
2105
-     * Symbol to use for thousands
2106
-     *
2107
-     * @var string $thsnds
2108
-     * eg ','
2109
-     */
2110
-    public $thsnds;
2111
-
2112
-
2113
-    /**
2114
-     *    class constructor
2115
-     *
2116
-     * @access    public
2117
-     * @param string $CNT_ISO
2118
-     * @throws \EE_Error
2119
-     */
2120
-    public function __construct($CNT_ISO = '')
2121
-    {
2122
-        /** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */
2123
-        $table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
2124
-        // get country code from organization settings or use default
2125
-        $ORG_CNT = isset(EE_Registry::instance()->CFG->organization)
2126
-                   && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
2127
-            ? EE_Registry::instance()->CFG->organization->CNT_ISO
2128
-            : '';
2129
-        // but override if requested
2130
-        $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2131
-        // 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
2132
-        if (
2133
-            ! empty($CNT_ISO)
2134
-            && EE_Maintenance_Mode::instance()->models_can_query()
2135
-            && $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())
2136
-        ) {
2137
-            // retrieve the country settings from the db, just in case they have been customized
2138
-            $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2139
-            if ($country instanceof EE_Country) {
2140
-                $this->code = $country->currency_code();    // currency code: USD, CAD, EUR
2141
-                $this->name = $country->currency_name_single();    // Dollar
2142
-                $this->plural = $country->currency_name_plural();    // Dollars
2143
-                $this->sign = $country->currency_sign();            // currency sign: $
2144
-                $this->sign_b4 = $country->currency_sign_before(
2145
-                );        // currency sign before or after: $TRUE  or  FALSE$
2146
-                $this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2147
-                $this->dec_mrk = $country->currency_decimal_mark(
2148
-                );    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2149
-                $this->thsnds = $country->currency_thousands_separator(
2150
-                );    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2151
-            }
2152
-        }
2153
-        // fallback to hardcoded defaults, in case the above failed
2154
-        if (empty($this->code)) {
2155
-            // set default currency settings
2156
-            $this->code = 'USD';    // currency code: USD, CAD, EUR
2157
-            $this->name = __('Dollar', 'event_espresso');    // Dollar
2158
-            $this->plural = __('Dollars', 'event_espresso');    // Dollars
2159
-            $this->sign = '$';    // currency sign: $
2160
-            $this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2161
-            $this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2162
-            $this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2163
-            $this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2164
-        }
2165
-    }
2166
-}
2167
-
2168
-/**
2169
- * Class for defining what's in the EE_Config relating to registration settings
2170
- */
2171
-class EE_Registration_Config extends EE_Config_Base
2172
-{
2173
-
2174
-    /**
2175
-     * Default registration status
2176
-     *
2177
-     * @var string $default_STS_ID
2178
-     * eg 'RPP'
2179
-     */
2180
-    public $default_STS_ID;
2181
-
2182
-    /**
2183
-     * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of
2184
-     * registrations)
2185
-     *
2186
-     * @var int
2187
-     */
2188
-    public $default_maximum_number_of_tickets;
2189
-
2190
-    /**
2191
-     * level of validation to apply to email addresses
2192
-     *
2193
-     * @var string $email_validation_level
2194
-     * options: 'basic', 'wp_default', 'i18n', 'i18n_dns'
2195
-     */
2196
-    public $email_validation_level;
2197
-
2198
-    /**
2199
-     *    whether or not to show alternate payment options during the reg process if payment status is pending
2200
-     *
2201
-     * @var boolean $show_pending_payment_options
2202
-     */
2203
-    public $show_pending_payment_options;
2204
-
2205
-    /**
2206
-     * Whether to skip the registration confirmation page
2207
-     *
2208
-     * @var boolean $skip_reg_confirmation
2209
-     */
2210
-    public $skip_reg_confirmation;
2211
-
2212
-    /**
2213
-     * an array of SPCO reg steps where:
2214
-     *        the keys denotes the reg step order
2215
-     *        each element consists of an array with the following elements:
2216
-     *            "file_path" => the file path to the EE_SPCO_Reg_Step class
2217
-     *            "class_name" => the specific EE_SPCO_Reg_Step child class name
2218
-     *            "slug" => the URL param used to trigger the reg step
2219
-     *
2220
-     * @var array $reg_steps
2221
-     */
2222
-    public $reg_steps;
2223
-
2224
-    /**
2225
-     * Whether registration confirmation should be the last page of SPCO
2226
-     *
2227
-     * @var boolean $reg_confirmation_last
2228
-     */
2229
-    public $reg_confirmation_last;
2230
-
2231
-    /**
2232
-     * Whether or not to enable the EE Bot Trap
2233
-     *
2234
-     * @var boolean $use_bot_trap
2235
-     */
2236
-    public $use_bot_trap;
2237
-
2238
-    /**
2239
-     * Whether or not to encrypt some data sent by the EE Bot Trap
2240
-     *
2241
-     * @var boolean $use_encryption
2242
-     */
2243
-    public $use_encryption;
2244
-
2245
-    /**
2246
-     * Whether or not to use ReCaptcha
2247
-     *
2248
-     * @var boolean $use_captcha
2249
-     */
2250
-    public $use_captcha;
2251
-
2252
-    /**
2253
-     * ReCaptcha Theme
2254
-     *
2255
-     * @var string $recaptcha_theme
2256
-     *    options: 'dark', 'light', 'invisible'
2257
-     */
2258
-    public $recaptcha_theme;
2259
-
2260
-    /**
2261
-     * ReCaptcha Badge - determines the position of the reCAPTCHA badge if using Invisible ReCaptcha.
2262
-     *
2263
-     * @var string $recaptcha_badge
2264
-     *    options: 'bottomright', 'bottomleft', 'inline'
2265
-     */
2266
-    public $recaptcha_badge;
17
+	const OPTION_NAME = 'ee_config';
18
+
19
+	const LOG_NAME = 'ee_config_log';
20
+
21
+	const LOG_LENGTH = 100;
22
+
23
+	const ADDON_OPTION_NAMES = 'ee_config_option_names';
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
+	 * Settings pertaining to global messages settings.
104
+	 *
105
+	 * @var EE_Messages_Config
106
+	 */
107
+	public $messages;
108
+
109
+	/**
110
+	 * @deprecated
111
+	 * @var EE_Gateway_Config
112
+	 */
113
+	public $gateway;
114
+
115
+	/**
116
+	 * @var    array $_addon_option_names
117
+	 * @access    private
118
+	 */
119
+	private $_addon_option_names = array();
120
+
121
+	/**
122
+	 * @var    array $_module_route_map
123
+	 * @access    private
124
+	 */
125
+	private static $_module_route_map = array();
126
+
127
+	/**
128
+	 * @var    array $_module_forward_map
129
+	 * @access    private
130
+	 */
131
+	private static $_module_forward_map = array();
132
+
133
+	/**
134
+	 * @var    array $_module_view_map
135
+	 * @access    private
136
+	 */
137
+	private static $_module_view_map = array();
138
+
139
+
140
+	/**
141
+	 * @singleton method used to instantiate class object
142
+	 * @access    public
143
+	 * @return EE_Config instance
144
+	 */
145
+	public static function instance()
146
+	{
147
+		// check if class object is instantiated, and instantiated properly
148
+		if (! self::$_instance instanceof EE_Config) {
149
+			self::$_instance = new self();
150
+		}
151
+		return self::$_instance;
152
+	}
153
+
154
+
155
+	/**
156
+	 * Resets the config
157
+	 *
158
+	 * @param bool    $hard_reset    if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE
159
+	 *                               (default) leaves the database alone, and merely resets the EE_Config object to
160
+	 *                               reflect its state in the database
161
+	 * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave
162
+	 *                               $_instance as NULL. Useful in case you want to forget about the old instance on
163
+	 *                               EE_Config, but might not be ready to instantiate EE_Config currently (eg if the
164
+	 *                               site was put into maintenance mode)
165
+	 * @return EE_Config
166
+	 */
167
+	public static function reset($hard_reset = false, $reinstantiate = true)
168
+	{
169
+		if (self::$_instance instanceof EE_Config) {
170
+			if ($hard_reset) {
171
+				self::$_instance->legacy_shortcodes_manager = null;
172
+				self::$_instance->_addon_option_names = array();
173
+				self::$_instance->_initialize_config();
174
+				self::$_instance->update_espresso_config();
175
+			}
176
+			self::$_instance->update_addon_option_names();
177
+		}
178
+		self::$_instance = null;
179
+		// we don't need to reset the static properties imo because those should
180
+		// only change when a module is added or removed. Currently we don't
181
+		// support removing a module during a request when it previously existed
182
+		if ($reinstantiate) {
183
+			return self::instance();
184
+		} else {
185
+			return null;
186
+		}
187
+	}
188
+
189
+
190
+	/**
191
+	 *    class constructor
192
+	 *
193
+	 * @access    private
194
+	 */
195
+	private function __construct()
196
+	{
197
+		do_action('AHEE__EE_Config__construct__begin', $this);
198
+		EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false);
199
+		// setup empty config classes
200
+		$this->_initialize_config();
201
+		// load existing EE site settings
202
+		$this->_load_core_config();
203
+		// confirm everything loaded correctly and set filtered defaults if not
204
+		$this->_verify_config();
205
+		//  register shortcodes and modules
206
+		add_action(
207
+			'AHEE__EE_System__register_shortcodes_modules_and_widgets',
208
+			array($this, 'register_shortcodes_and_modules'),
209
+			999
210
+		);
211
+		//  initialize shortcodes and modules
212
+		add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules'));
213
+		// register widgets
214
+		add_action('widgets_init', array($this, 'widgets_init'), 10);
215
+		// shutdown
216
+		add_action('shutdown', array($this, 'shutdown'), 10);
217
+		// construct__end hook
218
+		do_action('AHEE__EE_Config__construct__end', $this);
219
+		// hardcoded hack
220
+		$this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014';
221
+	}
222
+
223
+
224
+	/**
225
+	 * @return boolean
226
+	 */
227
+	public static function logging_enabled()
228
+	{
229
+		return self::$_logging_enabled;
230
+	}
231
+
232
+
233
+	/**
234
+	 * use to get the current theme if needed from static context
235
+	 *
236
+	 * @return string current theme set.
237
+	 */
238
+	public static function get_current_theme()
239
+	{
240
+		return isset(self::$_instance->template_settings->current_espresso_theme)
241
+			? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014';
242
+	}
243
+
244
+
245
+	/**
246
+	 *        _initialize_config
247
+	 *
248
+	 * @access private
249
+	 * @return void
250
+	 */
251
+	private function _initialize_config()
252
+	{
253
+		EE_Config::trim_log();
254
+		// set defaults
255
+		$this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array());
256
+		$this->addons = new stdClass();
257
+		// set _module_route_map
258
+		EE_Config::$_module_route_map = array();
259
+		// set _module_forward_map
260
+		EE_Config::$_module_forward_map = array();
261
+		// set _module_view_map
262
+		EE_Config::$_module_view_map = array();
263
+	}
264
+
265
+
266
+	/**
267
+	 *        load core plugin configuration
268
+	 *
269
+	 * @access private
270
+	 * @return void
271
+	 */
272
+	private function _load_core_config()
273
+	{
274
+		// load_core_config__start hook
275
+		do_action('AHEE__EE_Config___load_core_config__start', $this);
276
+		$espresso_config = $this->get_espresso_config();
277
+		foreach ($espresso_config as $config => $settings) {
278
+			// load_core_config__start hook
279
+			$settings = apply_filters(
280
+				'FHEE__EE_Config___load_core_config__config_settings',
281
+				$settings,
282
+				$config,
283
+				$this
284
+			);
285
+			if (is_object($settings) && property_exists($this, $config)) {
286
+				$this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
287
+				// call configs populate method to ensure any defaults are set for empty values.
288
+				if (method_exists($settings, 'populate')) {
289
+					$this->{$config}->populate();
290
+				}
291
+				if (method_exists($settings, 'do_hooks')) {
292
+					$this->{$config}->do_hooks();
293
+				}
294
+			}
295
+		}
296
+		if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) {
297
+			$this->update_espresso_config();
298
+		}
299
+		// load_core_config__end hook
300
+		do_action('AHEE__EE_Config___load_core_config__end', $this);
301
+	}
302
+
303
+
304
+	/**
305
+	 *    _verify_config
306
+	 *
307
+	 * @access    protected
308
+	 * @return    void
309
+	 */
310
+	protected function _verify_config()
311
+	{
312
+		$this->core = $this->core instanceof EE_Core_Config
313
+			? $this->core
314
+			: new EE_Core_Config();
315
+		$this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core);
316
+		$this->organization = $this->organization instanceof EE_Organization_Config
317
+			? $this->organization
318
+			: new EE_Organization_Config();
319
+		$this->organization = apply_filters(
320
+			'FHEE__EE_Config___initialize_config__organization',
321
+			$this->organization
322
+		);
323
+		$this->currency = $this->currency instanceof EE_Currency_Config
324
+			? $this->currency
325
+			: new EE_Currency_Config();
326
+		$this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency);
327
+		$this->registration = $this->registration instanceof EE_Registration_Config
328
+			? $this->registration
329
+			: new EE_Registration_Config();
330
+		$this->registration = apply_filters(
331
+			'FHEE__EE_Config___initialize_config__registration',
332
+			$this->registration
333
+		);
334
+		$this->admin = $this->admin instanceof EE_Admin_Config
335
+			? $this->admin
336
+			: new EE_Admin_Config();
337
+		$this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin);
338
+		$this->template_settings = $this->template_settings instanceof EE_Template_Config
339
+			? $this->template_settings
340
+			: new EE_Template_Config();
341
+		$this->template_settings = apply_filters(
342
+			'FHEE__EE_Config___initialize_config__template_settings',
343
+			$this->template_settings
344
+		);
345
+		$this->map_settings = $this->map_settings instanceof EE_Map_Config
346
+			? $this->map_settings
347
+			: new EE_Map_Config();
348
+		$this->map_settings = apply_filters(
349
+			'FHEE__EE_Config___initialize_config__map_settings',
350
+			$this->map_settings
351
+		);
352
+		$this->environment = $this->environment instanceof EE_Environment_Config
353
+			? $this->environment
354
+			: new EE_Environment_Config();
355
+		$this->environment = apply_filters(
356
+			'FHEE__EE_Config___initialize_config__environment',
357
+			$this->environment
358
+		);
359
+		$this->tax_settings = $this->tax_settings instanceof EE_Tax_Config
360
+			? $this->tax_settings
361
+			: new EE_Tax_Config();
362
+		$this->tax_settings = apply_filters(
363
+			'FHEE__EE_Config___initialize_config__tax_settings',
364
+			$this->tax_settings
365
+		);
366
+		$this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages);
367
+		$this->messages = $this->messages instanceof EE_Messages_Config
368
+			? $this->messages
369
+			: new EE_Messages_Config();
370
+		$this->gateway = $this->gateway instanceof EE_Gateway_Config
371
+			? $this->gateway
372
+			: new EE_Gateway_Config();
373
+		$this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway);
374
+		$this->legacy_shortcodes_manager = null;
375
+	}
376
+
377
+
378
+	/**
379
+	 *    get_espresso_config
380
+	 *
381
+	 * @access    public
382
+	 * @return    array of espresso config stuff
383
+	 */
384
+	public function get_espresso_config()
385
+	{
386
+		// grab espresso configuration
387
+		return apply_filters(
388
+			'FHEE__EE_Config__get_espresso_config__CFG',
389
+			get_option(EE_Config::OPTION_NAME, array())
390
+		);
391
+	}
392
+
393
+
394
+	/**
395
+	 *    double_check_config_comparison
396
+	 *
397
+	 * @access    public
398
+	 * @param string $option
399
+	 * @param        $old_value
400
+	 * @param        $value
401
+	 */
402
+	public function double_check_config_comparison($option = '', $old_value, $value)
403
+	{
404
+		// make sure we're checking the ee config
405
+		if ($option === EE_Config::OPTION_NAME) {
406
+			// run a loose comparison of the old value against the new value for type and properties,
407
+			// but NOT exact instance like WP update_option does (ie: NOT type safe comparison)
408
+			if ($value != $old_value) {
409
+				// if they are NOT the same, then remove the hook,
410
+				// which means the subsequent update results will be based solely on the update query results
411
+				// the reason we do this is because, as stated above,
412
+				// WP update_option performs an exact instance comparison (===) on any update values passed to it
413
+				// this happens PRIOR to serialization and any subsequent update.
414
+				// If values are found to match their previous old value,
415
+				// then WP bails before performing any update.
416
+				// Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version
417
+				// it just pulled from the db, with the one being passed to it (which will not match).
418
+				// HOWEVER, once the object is serialized and passed off to MySQL to update,
419
+				// MySQL MAY ALSO NOT perform the update because
420
+				// the string it sees in the db looks the same as the new one it has been passed!!!
421
+				// This results in the query returning an "affected rows" value of ZERO,
422
+				// which gets returned immediately by WP update_option and looks like an error.
423
+				remove_action('update_option', array($this, 'check_config_updated'));
424
+			}
425
+		}
426
+	}
427
+
428
+
429
+	/**
430
+	 *    update_espresso_config
431
+	 *
432
+	 * @access   public
433
+	 */
434
+	protected function _reset_espresso_addon_config()
435
+	{
436
+		$this->_addon_option_names = array();
437
+		foreach ($this->addons as $addon_name => $addon_config_obj) {
438
+			$addon_config_obj = maybe_unserialize($addon_config_obj);
439
+			if ($addon_config_obj instanceof EE_Config_Base) {
440
+				$this->update_config('addons', $addon_name, $addon_config_obj, false);
441
+			}
442
+			$this->addons->{$addon_name} = null;
443
+		}
444
+	}
445
+
446
+
447
+	/**
448
+	 *    update_espresso_config
449
+	 *
450
+	 * @access   public
451
+	 * @param   bool $add_success
452
+	 * @param   bool $add_error
453
+	 * @return   bool
454
+	 */
455
+	public function update_espresso_config($add_success = false, $add_error = true)
456
+	{
457
+		// don't allow config updates during WP heartbeats
458
+		if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
459
+			return false;
460
+		}
461
+		// commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
462
+		// $clone = clone( self::$_instance );
463
+		// self::$_instance = NULL;
464
+		do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
465
+		$this->_reset_espresso_addon_config();
466
+		// hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
467
+		// but BEFORE the actual update occurs
468
+		add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
469
+		// don't want to persist legacy_shortcodes_manager, but don't want to lose it either
470
+		$legacy_shortcodes_manager = $this->legacy_shortcodes_manager;
471
+		$this->legacy_shortcodes_manager = null;
472
+		// now update "ee_config"
473
+		$saved = update_option(EE_Config::OPTION_NAME, $this);
474
+		$this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
475
+		EE_Config::log(EE_Config::OPTION_NAME);
476
+		// if not saved... check if the hook we just added still exists;
477
+		// if it does, it means one of two things:
478
+		// that update_option bailed at the($value === $old_value) conditional,
479
+		// or...
480
+		// the db update query returned 0 rows affected
481
+		// (probably because the data  value was the same from it's perspective)
482
+		// so the existence of the hook means that a negative result from update_option is NOT an error,
483
+		// but just means no update occurred, so don't display an error to the user.
484
+		// BUT... if update_option returns FALSE, AND the hook is missing,
485
+		// then it means that something truly went wrong
486
+		$saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
487
+		// remove our action since we don't want it in the system anymore
488
+		remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
489
+		do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
490
+		// self::$_instance = $clone;
491
+		// unset( $clone );
492
+		// if config remains the same or was updated successfully
493
+		if ($saved) {
494
+			if ($add_success) {
495
+				EE_Error::add_success(
496
+					__('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
497
+					__FILE__,
498
+					__FUNCTION__,
499
+					__LINE__
500
+				);
501
+			}
502
+			return true;
503
+		} else {
504
+			if ($add_error) {
505
+				EE_Error::add_error(
506
+					__('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
507
+					__FILE__,
508
+					__FUNCTION__,
509
+					__LINE__
510
+				);
511
+			}
512
+			return false;
513
+		}
514
+	}
515
+
516
+
517
+	/**
518
+	 *    _verify_config_params
519
+	 *
520
+	 * @access    private
521
+	 * @param    string         $section
522
+	 * @param    string         $name
523
+	 * @param    string         $config_class
524
+	 * @param    EE_Config_Base $config_obj
525
+	 * @param    array          $tests_to_run
526
+	 * @param    bool           $display_errors
527
+	 * @return    bool    TRUE on success, FALSE on fail
528
+	 */
529
+	private function _verify_config_params(
530
+		$section = '',
531
+		$name = '',
532
+		$config_class = '',
533
+		$config_obj = null,
534
+		$tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
535
+		$display_errors = true
536
+	) {
537
+		try {
538
+			foreach ($tests_to_run as $test) {
539
+				switch ($test) {
540
+					// TEST #1 : check that section was set
541
+					case 1:
542
+						if (empty($section)) {
543
+							if ($display_errors) {
544
+								throw new EE_Error(
545
+									sprintf(
546
+										__(
547
+											'No configuration section has been provided while attempting to save "%s".',
548
+											'event_espresso'
549
+										),
550
+										$config_class
551
+									)
552
+								);
553
+							}
554
+							return false;
555
+						}
556
+						break;
557
+					// TEST #2 : check that settings section exists
558
+					case 2:
559
+						if (! isset($this->{$section})) {
560
+							if ($display_errors) {
561
+								throw new EE_Error(
562
+									sprintf(
563
+										__('The "%s" configuration section does not exist.', 'event_espresso'),
564
+										$section
565
+									)
566
+								);
567
+							}
568
+							return false;
569
+						}
570
+						break;
571
+					// TEST #3 : check that section is the proper format
572
+					case 3:
573
+						if (
574
+							! ($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 (
800
+			! $this->_verify_config_params(
801
+				$section,
802
+				$name,
803
+				$config_class,
804
+				$config_obj,
805
+				array(1, 2, 3, 4, 7, 9)
806
+			)
807
+		) {
808
+			return false;
809
+		}
810
+		$config_option_name = $this->_generate_config_option_name($section, $name);
811
+		// check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
812
+		if (! isset($this->_addon_option_names[ $config_option_name ])) {
813
+			// save new config to db
814
+			if ($this->set_config($section, $name, $config_class, $config_obj)) {
815
+				return true;
816
+			}
817
+		} else {
818
+			// first check if the record already exists
819
+			$existing_config = get_option($config_option_name);
820
+			$config_obj = serialize($config_obj);
821
+			// just return if db record is already up to date (NOT type safe comparison)
822
+			if ($existing_config == $config_obj) {
823
+				$this->{$section}->{$name} = $config_obj;
824
+				return true;
825
+			} elseif (update_option($config_option_name, $config_obj)) {
826
+				EE_Config::log($config_option_name);
827
+				// update wp-option for this config class
828
+				$this->{$section}->{$name} = $config_obj;
829
+				return true;
830
+			} elseif ($throw_errors) {
831
+				EE_Error::add_error(
832
+					sprintf(
833
+						__(
834
+							'The "%1$s" object stored at"%2$s" was not successfully updated in the database.',
835
+							'event_espresso'
836
+						),
837
+						$config_class,
838
+						'EE_Config->' . $section . '->' . $name
839
+					),
840
+					__FILE__,
841
+					__FUNCTION__,
842
+					__LINE__
843
+				);
844
+			}
845
+		}
846
+		return false;
847
+	}
848
+
849
+
850
+	/**
851
+	 *    get_config
852
+	 *
853
+	 * @access    public
854
+	 * @param    string $section
855
+	 * @param    string $name
856
+	 * @param    string $config_class
857
+	 * @return    mixed EE_Config_Base | NULL
858
+	 */
859
+	public function get_config($section = '', $name = '', $config_class = '')
860
+	{
861
+		// ensure config class is set to something
862
+		$config_class = $this->_set_config_class($config_class, $name);
863
+		// run tests 1-4, 6 and 7 to verify that all params have been set
864
+		if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
865
+			return null;
866
+		}
867
+		// now test if the requested config object exists, but suppress errors
868
+		if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) {
869
+			// config already exists, so pass it back
870
+			return $this->{$section}->{$name};
871
+		}
872
+		// load config option from db if it exists
873
+		$config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
874
+		// verify the newly retrieved config object, but suppress errors
875
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
876
+			// config is good, so set it and pass it back
877
+			$this->{$section}->{$name} = $config_obj;
878
+			return $this->{$section}->{$name};
879
+		}
880
+		// oops! $config_obj is not already set and does not exist in the db, so create a new one
881
+		$config_obj = $this->set_config($section, $name, $config_class);
882
+		// verify the newly created config object
883
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
884
+			return $this->{$section}->{$name};
885
+		} else {
886
+			EE_Error::add_error(
887
+				sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
888
+				__FILE__,
889
+				__FUNCTION__,
890
+				__LINE__
891
+			);
892
+		}
893
+		return null;
894
+	}
895
+
896
+
897
+	/**
898
+	 *    get_config_option
899
+	 *
900
+	 * @access    public
901
+	 * @param    string $config_option_name
902
+	 * @return    mixed EE_Config_Base | FALSE
903
+	 */
904
+	public function get_config_option($config_option_name = '')
905
+	{
906
+		// retrieve the wp-option for this config class.
907
+		$config_option = maybe_unserialize(get_option($config_option_name, array()));
908
+		if (empty($config_option)) {
909
+			EE_Config::log($config_option_name . '-NOT-FOUND');
910
+		}
911
+		return $config_option;
912
+	}
913
+
914
+
915
+	/**
916
+	 * log
917
+	 *
918
+	 * @param string $config_option_name
919
+	 */
920
+	public static function log($config_option_name = '')
921
+	{
922
+		if (EE_Config::logging_enabled() && ! empty($config_option_name)) {
923
+			$config_log = get_option(EE_Config::LOG_NAME, array());
924
+			// copy incoming $_REQUEST and sanitize it so we can save it
925
+			$_request = $_REQUEST;
926
+			array_walk_recursive($_request, 'sanitize_text_field');
927
+			$config_log[ (string) microtime(true) ] = array(
928
+				'config_name' => $config_option_name,
929
+				'request'     => $_request,
930
+			);
931
+			update_option(EE_Config::LOG_NAME, $config_log);
932
+		}
933
+	}
934
+
935
+
936
+	/**
937
+	 * trim_log
938
+	 * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH
939
+	 */
940
+	public static function trim_log()
941
+	{
942
+		if (! EE_Config::logging_enabled()) {
943
+			return;
944
+		}
945
+		$config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
946
+		$log_length = count($config_log);
947
+		if ($log_length > EE_Config::LOG_LENGTH) {
948
+			ksort($config_log);
949
+			$config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true);
950
+			update_option(EE_Config::LOG_NAME, $config_log);
951
+		}
952
+	}
953
+
954
+
955
+	/**
956
+	 *    get_page_for_posts
957
+	 *    if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the
958
+	 *    wp-option "page_for_posts", or "posts" if no page is selected
959
+	 *
960
+	 * @access    public
961
+	 * @return    string
962
+	 */
963
+	public static function get_page_for_posts()
964
+	{
965
+		$page_for_posts = get_option('page_for_posts');
966
+		if (! $page_for_posts) {
967
+			return 'posts';
968
+		}
969
+		/** @type WPDB $wpdb */
970
+		global $wpdb;
971
+		$SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
972
+		return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
973
+	}
974
+
975
+
976
+	/**
977
+	 *    register_shortcodes_and_modules.
978
+	 *    At this point, it's too early to tell if we're maintenance mode or not.
979
+	 *    In fact, this is where we give modules a chance to let core know they exist
980
+	 *    so they can help trigger maintenance mode if it's needed
981
+	 *
982
+	 * @access    public
983
+	 * @return    void
984
+	 */
985
+	public function register_shortcodes_and_modules()
986
+	{
987
+		// allow modules to set hooks for the rest of the system
988
+		EE_Registry::instance()->modules = $this->_register_modules();
989
+	}
990
+
991
+
992
+	/**
993
+	 *    initialize_shortcodes_and_modules
994
+	 *    meaning they can start adding their hooks to get stuff done
995
+	 *
996
+	 * @access    public
997
+	 * @return    void
998
+	 */
999
+	public function initialize_shortcodes_and_modules()
1000
+	{
1001
+		// allow modules to set hooks for the rest of the system
1002
+		$this->_initialize_modules();
1003
+	}
1004
+
1005
+
1006
+	/**
1007
+	 *    widgets_init
1008
+	 *
1009
+	 * @access private
1010
+	 * @return void
1011
+	 */
1012
+	public function widgets_init()
1013
+	{
1014
+		// only init widgets on admin pages when not in complete maintenance, and
1015
+		// on frontend when not in any maintenance mode
1016
+		if (
1017
+			! EE_Maintenance_Mode::instance()->level()
1018
+			|| (
1019
+				is_admin()
1020
+				&& EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
1021
+			)
1022
+		) {
1023
+			// grab list of installed widgets
1024
+			$widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1025
+			// filter list of modules to register
1026
+			$widgets_to_register = apply_filters(
1027
+				'FHEE__EE_Config__register_widgets__widgets_to_register',
1028
+				$widgets_to_register
1029
+			);
1030
+			if (! empty($widgets_to_register)) {
1031
+				// cycle thru widget folders
1032
+				foreach ($widgets_to_register as $widget_path) {
1033
+					// add to list of installed widget modules
1034
+					EE_Config::register_ee_widget($widget_path);
1035
+				}
1036
+			}
1037
+			// filter list of installed modules
1038
+			EE_Registry::instance()->widgets = apply_filters(
1039
+				'FHEE__EE_Config__register_widgets__installed_widgets',
1040
+				EE_Registry::instance()->widgets
1041
+			);
1042
+		}
1043
+	}
1044
+
1045
+
1046
+	/**
1047
+	 *    register_ee_widget - makes core aware of this widget
1048
+	 *
1049
+	 * @access    public
1050
+	 * @param    string $widget_path - full path up to and including widget folder
1051
+	 * @return    void
1052
+	 */
1053
+	public static function register_ee_widget($widget_path = null)
1054
+	{
1055
+		do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
1056
+		$widget_ext = '.widget.php';
1057
+		// make all separators match
1058
+		$widget_path = rtrim(str_replace('\\', DS, $widget_path), DS);
1059
+		// does the file path INCLUDE the actual file name as part of the path ?
1060
+		if (strpos($widget_path, $widget_ext) !== false) {
1061
+			// grab and shortcode file name from directory name and break apart at dots
1062
+			$file_name = explode('.', basename($widget_path));
1063
+			// take first segment from file name pieces and remove class prefix if it exists
1064
+			$widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
1065
+			// sanitize shortcode directory name
1066
+			$widget = sanitize_key($widget);
1067
+			// now we need to rebuild the shortcode path
1068
+			$widget_path = explode('/', $widget_path);
1069
+			// remove last segment
1070
+			array_pop($widget_path);
1071
+			// glue it back together
1072
+			$widget_path = implode(DS, $widget_path);
1073
+		} else {
1074
+			// grab and sanitize widget directory name
1075
+			$widget = sanitize_key(basename($widget_path));
1076
+		}
1077
+		// create classname from widget directory name
1078
+		$widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1079
+		// add class prefix
1080
+		$widget_class = 'EEW_' . $widget;
1081
+		// does the widget exist ?
1082
+		if (! is_readable($widget_path . '/' . $widget_class . $widget_ext)) {
1083
+			$msg = sprintf(
1084
+				__(
1085
+					'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',
1086
+					'event_espresso'
1087
+				),
1088
+				$widget_class,
1089
+				$widget_path . '/' . $widget_class . $widget_ext
1090
+			);
1091
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1092
+			return;
1093
+		}
1094
+		// load the widget class file
1095
+		require_once($widget_path . '/' . $widget_class . $widget_ext);
1096
+		// verify that class exists
1097
+		if (! class_exists($widget_class)) {
1098
+			$msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1099
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1100
+			return;
1101
+		}
1102
+		register_widget($widget_class);
1103
+		// add to array of registered widgets
1104
+		EE_Registry::instance()->widgets->{$widget_class} = $widget_path . '/' . $widget_class . $widget_ext;
1105
+	}
1106
+
1107
+
1108
+	/**
1109
+	 *        _register_modules
1110
+	 *
1111
+	 * @access private
1112
+	 * @return array
1113
+	 */
1114
+	private function _register_modules()
1115
+	{
1116
+		// grab list of installed modules
1117
+		$modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1118
+		// filter list of modules to register
1119
+		$modules_to_register = apply_filters(
1120
+			'FHEE__EE_Config__register_modules__modules_to_register',
1121
+			$modules_to_register
1122
+		);
1123
+		if (! empty($modules_to_register)) {
1124
+			// loop through folders
1125
+			foreach ($modules_to_register as $module_path) {
1126
+				/**TEMPORARILY EXCLUDE gateways from modules for time being**/
1127
+				if (
1128
+					$module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1129
+					&& $module_path !== EE_MODULES . 'gateways'
1130
+				) {
1131
+					// add to list of installed modules
1132
+					EE_Config::register_module($module_path);
1133
+				}
1134
+			}
1135
+		}
1136
+		// filter list of installed modules
1137
+		return apply_filters(
1138
+			'FHEE__EE_Config___register_modules__installed_modules',
1139
+			EE_Registry::instance()->modules
1140
+		);
1141
+	}
1142
+
1143
+
1144
+	/**
1145
+	 *    register_module - makes core aware of this module
1146
+	 *
1147
+	 * @access    public
1148
+	 * @param    string $module_path - full path up to and including module folder
1149
+	 * @return    bool
1150
+	 */
1151
+	public static function register_module($module_path = null)
1152
+	{
1153
+		do_action('AHEE__EE_Config__register_module__begin', $module_path);
1154
+		$module_ext = '.module.php';
1155
+		// make all separators match
1156
+		$module_path = str_replace(array('\\', '/'), '/', $module_path);
1157
+		// does the file path INCLUDE the actual file name as part of the path ?
1158
+		if (strpos($module_path, $module_ext) !== false) {
1159
+			// grab and shortcode file name from directory name and break apart at dots
1160
+			$module_file = explode('.', basename($module_path));
1161
+			// now we need to rebuild the shortcode path
1162
+			$module_path = explode('/', $module_path);
1163
+			// remove last segment
1164
+			array_pop($module_path);
1165
+			// glue it back together
1166
+			$module_path = implode('/', $module_path) . '/';
1167
+			// take first segment from file name pieces and sanitize it
1168
+			$module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1169
+			// ensure class prefix is added
1170
+			$module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1171
+		} else {
1172
+			// we need to generate the filename based off of the folder name
1173
+			// grab and sanitize module name
1174
+			$module = strtolower(basename($module_path));
1175
+			$module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1176
+			// like trailingslashit()
1177
+			$module_path = rtrim($module_path, '/') . '/';
1178
+			// create classname from module directory name
1179
+			$module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1180
+			// add class prefix
1181
+			$module_class = 'EED_' . $module;
1182
+		}
1183
+		// does the module exist ?
1184
+		if (! is_readable($module_path . '/' . $module_class . $module_ext)) {
1185
+			$msg = sprintf(
1186
+				__(
1187
+					'The requested %s module file could not be found or is not readable due to file permissions.',
1188
+					'event_espresso'
1189
+				),
1190
+				$module
1191
+			);
1192
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1193
+			return false;
1194
+		}
1195
+		// load the module class file
1196
+		require_once($module_path . $module_class . $module_ext);
1197
+		// verify that class exists
1198
+		if (! class_exists($module_class)) {
1199
+			$msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1200
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1201
+			return false;
1202
+		}
1203
+		// add to array of registered modules
1204
+		EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1205
+		do_action(
1206
+			'AHEE__EE_Config__register_module__complete',
1207
+			$module_class,
1208
+			EE_Registry::instance()->modules->{$module_class}
1209
+		);
1210
+		return true;
1211
+	}
1212
+
1213
+
1214
+	/**
1215
+	 *    _initialize_modules
1216
+	 *    allow modules to set hooks for the rest of the system
1217
+	 *
1218
+	 * @access private
1219
+	 * @return void
1220
+	 */
1221
+	private function _initialize_modules()
1222
+	{
1223
+		// cycle thru shortcode folders
1224
+		foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1225
+			// fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1226
+			// which set hooks ?
1227
+			if (is_admin()) {
1228
+				// fire immediately
1229
+				call_user_func(array($module_class, 'set_hooks_admin'));
1230
+			} else {
1231
+				// delay until other systems are online
1232
+				add_action(
1233
+					'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1234
+					array($module_class, 'set_hooks')
1235
+				);
1236
+			}
1237
+		}
1238
+	}
1239
+
1240
+
1241
+	/**
1242
+	 *    register_route - adds module method routes to route_map
1243
+	 *
1244
+	 * @access    public
1245
+	 * @param    string $route       - "pretty" public alias for module method
1246
+	 * @param    string $module      - module name (classname without EED_ prefix)
1247
+	 * @param    string $method_name - the actual module method to be routed to
1248
+	 * @param    string $key         - url param key indicating a route is being called
1249
+	 * @return    bool
1250
+	 */
1251
+	public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee')
1252
+	{
1253
+		do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1254
+		$module = str_replace('EED_', '', $module);
1255
+		$module_class = 'EED_' . $module;
1256
+		if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1257
+			$msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1258
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1259
+			return false;
1260
+		}
1261
+		if (empty($route)) {
1262
+			$msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1263
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1264
+			return false;
1265
+		}
1266
+		if (! method_exists('EED_' . $module, $method_name)) {
1267
+			$msg = sprintf(
1268
+				__('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1269
+				$route
1270
+			);
1271
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1272
+			return false;
1273
+		}
1274
+		EE_Config::$_module_route_map[ (string) $key ][ (string) $route ] = array('EED_' . $module, $method_name);
1275
+		return true;
1276
+	}
1277
+
1278
+
1279
+	/**
1280
+	 *    get_route - get module method route
1281
+	 *
1282
+	 * @access    public
1283
+	 * @param    string $route - "pretty" public alias for module method
1284
+	 * @param    string $key   - url param key indicating a route is being called
1285
+	 * @return    string
1286
+	 */
1287
+	public static function get_route($route = null, $key = 'ee')
1288
+	{
1289
+		do_action('AHEE__EE_Config__get_route__begin', $route);
1290
+		$route = (string) apply_filters('FHEE__EE_Config__get_route', $route);
1291
+		if (isset(EE_Config::$_module_route_map[ $key ][ $route ])) {
1292
+			return EE_Config::$_module_route_map[ $key ][ $route ];
1293
+		}
1294
+		return null;
1295
+	}
1296
+
1297
+
1298
+	/**
1299
+	 *    get_routes - get ALL module method routes
1300
+	 *
1301
+	 * @access    public
1302
+	 * @return    array
1303
+	 */
1304
+	public static function get_routes()
1305
+	{
1306
+		return EE_Config::$_module_route_map;
1307
+	}
1308
+
1309
+
1310
+	/**
1311
+	 *    register_forward - allows modules to forward request to another module for further processing
1312
+	 *
1313
+	 * @access    public
1314
+	 * @param    string       $route   - "pretty" public alias for module method
1315
+	 * @param    integer      $status  - integer value corresponding  to status constant strings set in module parent
1316
+	 *                                 class, allows different forwards to be served based on status
1317
+	 * @param    array|string $forward - function name or array( class, method )
1318
+	 * @param    string       $key     - url param key indicating a route is being called
1319
+	 * @return    bool
1320
+	 */
1321
+	public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1322
+	{
1323
+		do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1324
+		if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1325
+			$msg = sprintf(
1326
+				__('The module route %s for this forward has not been registered.', 'event_espresso'),
1327
+				$route
1328
+			);
1329
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1330
+			return false;
1331
+		}
1332
+		if (empty($forward)) {
1333
+			$msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1334
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1335
+			return false;
1336
+		}
1337
+		if (is_array($forward)) {
1338
+			if (! isset($forward[1])) {
1339
+				$msg = sprintf(
1340
+					__('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1341
+					$route
1342
+				);
1343
+				EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1344
+				return false;
1345
+			}
1346
+			if (! method_exists($forward[0], $forward[1])) {
1347
+				$msg = sprintf(
1348
+					__('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1349
+					$forward[1],
1350
+					$route
1351
+				);
1352
+				EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1353
+				return false;
1354
+			}
1355
+		} elseif (! function_exists($forward)) {
1356
+			$msg = sprintf(
1357
+				__('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1358
+				$forward,
1359
+				$route
1360
+			);
1361
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1362
+			return false;
1363
+		}
1364
+		EE_Config::$_module_forward_map[ $key ][ $route ][ absint($status) ] = $forward;
1365
+		return true;
1366
+	}
1367
+
1368
+
1369
+	/**
1370
+	 *    get_forward - get forwarding route
1371
+	 *
1372
+	 * @access    public
1373
+	 * @param    string  $route  - "pretty" public alias for module method
1374
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1375
+	 *                           allows different forwards to be served based on status
1376
+	 * @param    string  $key    - url param key indicating a route is being called
1377
+	 * @return    string
1378
+	 */
1379
+	public static function get_forward($route = null, $status = 0, $key = 'ee')
1380
+	{
1381
+		do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1382
+		if (isset(EE_Config::$_module_forward_map[ $key ][ $route ][ $status ])) {
1383
+			return apply_filters(
1384
+				'FHEE__EE_Config__get_forward',
1385
+				EE_Config::$_module_forward_map[ $key ][ $route ][ $status ],
1386
+				$route,
1387
+				$status
1388
+			);
1389
+		}
1390
+		return null;
1391
+	}
1392
+
1393
+
1394
+	/**
1395
+	 *    register_forward - allows modules to specify different view templates for different method routes and status
1396
+	 *    results
1397
+	 *
1398
+	 * @access    public
1399
+	 * @param    string  $route  - "pretty" public alias for module method
1400
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1401
+	 *                           allows different views to be served based on status
1402
+	 * @param    string  $view
1403
+	 * @param    string  $key    - url param key indicating a route is being called
1404
+	 * @return    bool
1405
+	 */
1406
+	public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1407
+	{
1408
+		do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1409
+		if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1410
+			$msg = sprintf(
1411
+				__('The module route %s for this view has not been registered.', 'event_espresso'),
1412
+				$route
1413
+			);
1414
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1415
+			return false;
1416
+		}
1417
+		if (! is_readable($view)) {
1418
+			$msg = sprintf(
1419
+				__(
1420
+					'The %s view file could not be found or is not readable due to file permissions.',
1421
+					'event_espresso'
1422
+				),
1423
+				$view
1424
+			);
1425
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1426
+			return false;
1427
+		}
1428
+		EE_Config::$_module_view_map[ $key ][ $route ][ absint($status) ] = $view;
1429
+		return true;
1430
+	}
1431
+
1432
+
1433
+	/**
1434
+	 *    get_view - get view for route and status
1435
+	 *
1436
+	 * @access    public
1437
+	 * @param    string  $route  - "pretty" public alias for module method
1438
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1439
+	 *                           allows different views to be served based on status
1440
+	 * @param    string  $key    - url param key indicating a route is being called
1441
+	 * @return    string
1442
+	 */
1443
+	public static function get_view($route = null, $status = 0, $key = 'ee')
1444
+	{
1445
+		do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1446
+		if (isset(EE_Config::$_module_view_map[ $key ][ $route ][ $status ])) {
1447
+			return apply_filters(
1448
+				'FHEE__EE_Config__get_view',
1449
+				EE_Config::$_module_view_map[ $key ][ $route ][ $status ],
1450
+				$route,
1451
+				$status
1452
+			);
1453
+		}
1454
+		return null;
1455
+	}
1456
+
1457
+
1458
+	public function update_addon_option_names()
1459
+	{
1460
+		update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names);
1461
+	}
1462
+
1463
+
1464
+	public function shutdown()
1465
+	{
1466
+		$this->update_addon_option_names();
1467
+	}
1468
+
1469
+
1470
+	/**
1471
+	 * @return LegacyShortcodesManager
1472
+	 */
1473
+	public static function getLegacyShortcodesManager()
1474
+	{
1475
+
1476
+		if (! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1477
+			EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager(
1478
+				EE_Registry::instance()
1479
+			);
1480
+		}
1481
+		return EE_Config::instance()->legacy_shortcodes_manager;
1482
+	}
1483
+
1484
+
1485
+	/**
1486
+	 * register_shortcode - makes core aware of this shortcode
1487
+	 *
1488
+	 * @deprecated 4.9.26
1489
+	 * @param    string $shortcode_path - full path up to and including shortcode folder
1490
+	 * @return    bool
1491
+	 */
1492
+	public static function register_shortcode($shortcode_path = null)
1493
+	{
1494
+		EE_Error::doing_it_wrong(
1495
+			__METHOD__,
1496
+			__(
1497
+				'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.',
1498
+				'event_espresso'
1499
+			),
1500
+			'4.9.26'
1501
+		);
1502
+		return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path);
1503
+	}
1504
+}
2267 1505
 
2268
-    /**
2269
-     * ReCaptcha Type
2270
-     *
2271
-     * @var string $recaptcha_type
2272
-     *    options: 'audio', 'image'
2273
-     */
2274
-    public $recaptcha_type;
1506
+/**
1507
+ * Base class used for config classes. These classes should generally not have
1508
+ * magic functions in use, except we'll allow them to magically set and get stuff...
1509
+ * basically, they should just be well-defined stdClasses
1510
+ */
1511
+class EE_Config_Base
1512
+{
2275 1513
 
2276
-    /**
2277
-     * ReCaptcha language
2278
-     *
2279
-     * @var string $recaptcha_language
2280
-     * eg 'en'
2281
-     */
2282
-    public $recaptcha_language;
1514
+	/**
1515
+	 * Utility function for escaping the value of a property and returning.
1516
+	 *
1517
+	 * @param string $property property name (checks to see if exists).
1518
+	 * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1519
+	 * @throws \EE_Error
1520
+	 */
1521
+	public function get_pretty($property)
1522
+	{
1523
+		if (! property_exists($this, $property)) {
1524
+			throw new EE_Error(
1525
+				sprintf(
1526
+					__(
1527
+						'%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.',
1528
+						'event_espresso'
1529
+					),
1530
+					get_class($this),
1531
+					$property
1532
+				)
1533
+			);
1534
+		}
1535
+		// just handling escaping of strings for now.
1536
+		if (is_string($this->{$property})) {
1537
+			return stripslashes($this->{$property});
1538
+		}
1539
+		return $this->{$property};
1540
+	}
1541
+
1542
+
1543
+	public function populate()
1544
+	{
1545
+		// grab defaults via a new instance of this class.
1546
+		$class_name = get_class($this);
1547
+		$defaults = new $class_name();
1548
+		// loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1549
+		// default from our $defaults object.
1550
+		foreach (get_object_vars($defaults) as $property => $value) {
1551
+			if ($this->{$property} === null) {
1552
+				$this->{$property} = $value;
1553
+			}
1554
+		}
1555
+		// cleanup
1556
+		unset($defaults);
1557
+	}
1558
+
1559
+
1560
+	/**
1561
+	 *        __isset
1562
+	 *
1563
+	 * @param $a
1564
+	 * @return bool
1565
+	 */
1566
+	public function __isset($a)
1567
+	{
1568
+		return false;
1569
+	}
1570
+
1571
+
1572
+	/**
1573
+	 *        __unset
1574
+	 *
1575
+	 * @param $a
1576
+	 * @return bool
1577
+	 */
1578
+	public function __unset($a)
1579
+	{
1580
+		return false;
1581
+	}
1582
+
1583
+
1584
+	/**
1585
+	 *        __clone
1586
+	 */
1587
+	public function __clone()
1588
+	{
1589
+	}
1590
+
1591
+
1592
+	/**
1593
+	 *        __wakeup
1594
+	 */
1595
+	public function __wakeup()
1596
+	{
1597
+	}
1598
+
1599
+
1600
+	/**
1601
+	 *        __destruct
1602
+	 */
1603
+	public function __destruct()
1604
+	{
1605
+	}
1606
+}
2283 1607
 
2284
-    /**
2285
-     * ReCaptcha public key
2286
-     *
2287
-     * @var string $recaptcha_publickey
2288
-     */
2289
-    public $recaptcha_publickey;
1608
+/**
1609
+ * Class for defining what's in the EE_Config relating to registration settings
1610
+ */
1611
+class EE_Core_Config extends EE_Config_Base
1612
+{
2290 1613
 
2291
-    /**
2292
-     * ReCaptcha private key
2293
-     *
2294
-     * @var string $recaptcha_privatekey
2295
-     */
2296
-    public $recaptcha_privatekey;
1614
+	const OPTION_NAME_UXIP = 'ee_ueip_optin';
1615
+
1616
+
1617
+	public $current_blog_id;
1618
+
1619
+	public $ee_ueip_optin;
1620
+
1621
+	public $ee_ueip_has_notified;
1622
+
1623
+	/**
1624
+	 * Not to be confused with the 4 critical page variables (See
1625
+	 * get_critical_pages_array()), this is just an array of wp posts that have EE
1626
+	 * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode
1627
+	 * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array.
1628
+	 *
1629
+	 * @var array
1630
+	 */
1631
+	public $post_shortcodes;
1632
+
1633
+	public $module_route_map;
1634
+
1635
+	public $module_forward_map;
1636
+
1637
+	public $module_view_map;
1638
+
1639
+	/**
1640
+	 * The next 4 vars are the IDs of critical EE pages.
1641
+	 *
1642
+	 * @var int
1643
+	 */
1644
+	public $reg_page_id;
1645
+
1646
+	public $txn_page_id;
1647
+
1648
+	public $thank_you_page_id;
1649
+
1650
+	public $cancel_page_id;
1651
+
1652
+	/**
1653
+	 * The next 4 vars are the URLs of critical EE pages.
1654
+	 *
1655
+	 * @var int
1656
+	 */
1657
+	public $reg_page_url;
1658
+
1659
+	public $txn_page_url;
1660
+
1661
+	public $thank_you_page_url;
1662
+
1663
+	public $cancel_page_url;
1664
+
1665
+	/**
1666
+	 * The next vars relate to the custom slugs for EE CPT routes
1667
+	 */
1668
+	public $event_cpt_slug;
1669
+
1670
+	/**
1671
+	 * This caches the _ee_ueip_option in case this config is reset in the same
1672
+	 * request across blog switches in a multisite context.
1673
+	 * Avoids extra queries to the db for this option.
1674
+	 *
1675
+	 * @var bool
1676
+	 */
1677
+	public static $ee_ueip_option;
1678
+
1679
+
1680
+	/**
1681
+	 *    class constructor
1682
+	 *
1683
+	 * @access    public
1684
+	 */
1685
+	public function __construct()
1686
+	{
1687
+		// set default organization settings
1688
+		$this->current_blog_id = get_current_blog_id();
1689
+		$this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id;
1690
+		$this->ee_ueip_optin = $this->_get_main_ee_ueip_optin();
1691
+		$this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1692
+		$this->post_shortcodes = array();
1693
+		$this->module_route_map = array();
1694
+		$this->module_forward_map = array();
1695
+		$this->module_view_map = array();
1696
+		// critical EE page IDs
1697
+		$this->reg_page_id = 0;
1698
+		$this->txn_page_id = 0;
1699
+		$this->thank_you_page_id = 0;
1700
+		$this->cancel_page_id = 0;
1701
+		// critical EE page URLs
1702
+		$this->reg_page_url = '';
1703
+		$this->txn_page_url = '';
1704
+		$this->thank_you_page_url = '';
1705
+		$this->cancel_page_url = '';
1706
+		// cpt slugs
1707
+		$this->event_cpt_slug = __('events', 'event_espresso');
1708
+		// ueip constant check
1709
+		if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1710
+			$this->ee_ueip_optin = false;
1711
+			$this->ee_ueip_has_notified = true;
1712
+		}
1713
+	}
1714
+
1715
+
1716
+	/**
1717
+	 * @return array
1718
+	 */
1719
+	public function get_critical_pages_array()
1720
+	{
1721
+		return array(
1722
+			$this->reg_page_id,
1723
+			$this->txn_page_id,
1724
+			$this->thank_you_page_id,
1725
+			$this->cancel_page_id,
1726
+		);
1727
+	}
1728
+
1729
+
1730
+	/**
1731
+	 * @return array
1732
+	 */
1733
+	public function get_critical_pages_shortcodes_array()
1734
+	{
1735
+		return array(
1736
+			$this->reg_page_id       => 'ESPRESSO_CHECKOUT',
1737
+			$this->txn_page_id       => 'ESPRESSO_TXN_PAGE',
1738
+			$this->thank_you_page_id => 'ESPRESSO_THANK_YOU',
1739
+			$this->cancel_page_id    => 'ESPRESSO_CANCELLED',
1740
+		);
1741
+	}
1742
+
1743
+
1744
+	/**
1745
+	 *  gets/returns URL for EE reg_page
1746
+	 *
1747
+	 * @access    public
1748
+	 * @return    string
1749
+	 */
1750
+	public function reg_page_url()
1751
+	{
1752
+		if (! $this->reg_page_url) {
1753
+			$this->reg_page_url = add_query_arg(
1754
+				array('uts' => time()),
1755
+				get_permalink($this->reg_page_id)
1756
+			) . '#checkout';
1757
+		}
1758
+		return $this->reg_page_url;
1759
+	}
1760
+
1761
+
1762
+	/**
1763
+	 *  gets/returns URL for EE txn_page
1764
+	 *
1765
+	 * @param array $query_args like what gets passed to
1766
+	 *                          add_query_arg() as the first argument
1767
+	 * @access    public
1768
+	 * @return    string
1769
+	 */
1770
+	public function txn_page_url($query_args = array())
1771
+	{
1772
+		if (! $this->txn_page_url) {
1773
+			$this->txn_page_url = get_permalink($this->txn_page_id);
1774
+		}
1775
+		if ($query_args) {
1776
+			return add_query_arg($query_args, $this->txn_page_url);
1777
+		} else {
1778
+			return $this->txn_page_url;
1779
+		}
1780
+	}
1781
+
1782
+
1783
+	/**
1784
+	 *  gets/returns URL for EE thank_you_page
1785
+	 *
1786
+	 * @param array $query_args like what gets passed to
1787
+	 *                          add_query_arg() as the first argument
1788
+	 * @access    public
1789
+	 * @return    string
1790
+	 */
1791
+	public function thank_you_page_url($query_args = array())
1792
+	{
1793
+		if (! $this->thank_you_page_url) {
1794
+			$this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1795
+		}
1796
+		if ($query_args) {
1797
+			return add_query_arg($query_args, $this->thank_you_page_url);
1798
+		} else {
1799
+			return $this->thank_you_page_url;
1800
+		}
1801
+	}
1802
+
1803
+
1804
+	/**
1805
+	 *  gets/returns URL for EE cancel_page
1806
+	 *
1807
+	 * @access    public
1808
+	 * @return    string
1809
+	 */
1810
+	public function cancel_page_url()
1811
+	{
1812
+		if (! $this->cancel_page_url) {
1813
+			$this->cancel_page_url = get_permalink($this->cancel_page_id);
1814
+		}
1815
+		return $this->cancel_page_url;
1816
+	}
1817
+
1818
+
1819
+	/**
1820
+	 * Resets all critical page urls to their original state.  Used primarily by the __sleep() magic method currently.
1821
+	 *
1822
+	 * @since 4.7.5
1823
+	 */
1824
+	protected function _reset_urls()
1825
+	{
1826
+		$this->reg_page_url = '';
1827
+		$this->txn_page_url = '';
1828
+		$this->cancel_page_url = '';
1829
+		$this->thank_you_page_url = '';
1830
+	}
1831
+
1832
+
1833
+	/**
1834
+	 * Used to return what the optin value is set for the EE User Experience Program.
1835
+	 * This accounts for multisite and this value being requested for a subsite.  In multisite, the value is set
1836
+	 * on the main site only.
1837
+	 *
1838
+	 * @return bool
1839
+	 */
1840
+	protected function _get_main_ee_ueip_optin()
1841
+	{
1842
+		// if this is the main site then we can just bypass our direct query.
1843
+		if (is_main_site()) {
1844
+			return get_option(self::OPTION_NAME_UXIP, false);
1845
+		}
1846
+		// is this already cached for this request?  If so use it.
1847
+		if (EE_Core_Config::$ee_ueip_option !== null) {
1848
+			return EE_Core_Config::$ee_ueip_option;
1849
+		}
1850
+		global $wpdb;
1851
+		$current_network_main_site = is_multisite() ? get_current_site() : null;
1852
+		$current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1853
+		$option = self::OPTION_NAME_UXIP;
1854
+		// set correct table for query
1855
+		$table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1856
+		// rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1857
+		// get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1858
+		// re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1859
+		// this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1860
+		// for the purpose of caching.
1861
+		$pre = apply_filters('pre_option_' . $option, false, $option);
1862
+		if (false !== $pre) {
1863
+			EE_Core_Config::$ee_ueip_option = $pre;
1864
+			return EE_Core_Config::$ee_ueip_option;
1865
+		}
1866
+		$row = $wpdb->get_row(
1867
+			$wpdb->prepare(
1868
+				"SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1",
1869
+				$option
1870
+			)
1871
+		);
1872
+		if (is_object($row)) {
1873
+			$value = $row->option_value;
1874
+		} else { // option does not exist so use default.
1875
+			EE_Core_Config::$ee_ueip_option =  apply_filters('default_option_' . $option, false, $option);
1876
+			return EE_Core_Config::$ee_ueip_option;
1877
+		}
1878
+		EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1879
+		return EE_Core_Config::$ee_ueip_option;
1880
+	}
1881
+
1882
+
1883
+	/**
1884
+	 * Utility function for escaping the value of a property and returning.
1885
+	 *
1886
+	 * @param string $property property name (checks to see if exists).
1887
+	 * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1888
+	 * @throws \EE_Error
1889
+	 */
1890
+	public function get_pretty($property)
1891
+	{
1892
+		if ($property === self::OPTION_NAME_UXIP) {
1893
+			return $this->ee_ueip_optin ? 'yes' : 'no';
1894
+		}
1895
+		return parent::get_pretty($property);
1896
+	}
1897
+
1898
+
1899
+	/**
1900
+	 * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values
1901
+	 * on the object.
1902
+	 *
1903
+	 * @return array
1904
+	 */
1905
+	public function __sleep()
1906
+	{
1907
+		// reset all url properties
1908
+		$this->_reset_urls();
1909
+		// return what to save to db
1910
+		return array_keys(get_object_vars($this));
1911
+	}
1912
+}
2297 1913
 
2298
-    /**
2299
-     * array of form names protected by ReCaptcha
2300
-     *
2301
-     * @var array $recaptcha_protected_forms
2302
-     */
2303
-    public $recaptcha_protected_forms;
1914
+/**
1915
+ * Config class for storing info on the Organization
1916
+ */
1917
+class EE_Organization_Config extends EE_Config_Base
1918
+{
2304 1919
 
2305
-    /**
2306
-     * ReCaptcha width
2307
-     *
2308
-     * @var int $recaptcha_width
2309
-     * @deprecated
2310
-     */
2311
-    public $recaptcha_width;
1920
+	/**
1921
+	 * @var string $name
1922
+	 * eg EE4.1
1923
+	 */
1924
+	public $name;
1925
+
1926
+	/**
1927
+	 * @var string $address_1
1928
+	 * eg 123 Onna Road
1929
+	 */
1930
+	public $address_1 = '';
1931
+
1932
+	/**
1933
+	 * @var string $address_2
1934
+	 * eg PO Box 123
1935
+	 */
1936
+	public $address_2 = '';
1937
+
1938
+	/**
1939
+	 * @var string $city
1940
+	 * eg Inna City
1941
+	 */
1942
+	public $city = '';
1943
+
1944
+	/**
1945
+	 * @var int $STA_ID
1946
+	 * eg 4
1947
+	 */
1948
+	public $STA_ID = 0;
1949
+
1950
+	/**
1951
+	 * @var string $CNT_ISO
1952
+	 * eg US
1953
+	 */
1954
+	public $CNT_ISO = '';
1955
+
1956
+	/**
1957
+	 * @var string $zip
1958
+	 * eg 12345  or V1A 2B3
1959
+	 */
1960
+	public $zip = '';
1961
+
1962
+	/**
1963
+	 * @var string $email
1964
+	 * eg [email protected]
1965
+	 */
1966
+	public $email;
1967
+
1968
+	/**
1969
+	 * @var string $phone
1970
+	 * eg. 111-111-1111
1971
+	 */
1972
+	public $phone = '';
1973
+
1974
+	/**
1975
+	 * @var string $vat
1976
+	 * VAT/Tax Number
1977
+	 */
1978
+	public $vat = '';
1979
+
1980
+	/**
1981
+	 * @var string $logo_url
1982
+	 * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg
1983
+	 */
1984
+	public $logo_url = '';
1985
+
1986
+	/**
1987
+	 * The below are all various properties for holding links to organization social network profiles
1988
+	 *
1989
+	 * @var string
1990
+	 */
1991
+	/**
1992
+	 * facebook (facebook.com/profile.name)
1993
+	 *
1994
+	 * @var string
1995
+	 */
1996
+	public $facebook = '';
1997
+
1998
+	/**
1999
+	 * twitter (twitter.com/twitter_handle)
2000
+	 *
2001
+	 * @var string
2002
+	 */
2003
+	public $twitter = '';
2004
+
2005
+	/**
2006
+	 * linkedin (linkedin.com/in/profile_name)
2007
+	 *
2008
+	 * @var string
2009
+	 */
2010
+	public $linkedin = '';
2011
+
2012
+	/**
2013
+	 * pinterest (www.pinterest.com/profile_name)
2014
+	 *
2015
+	 * @var string
2016
+	 */
2017
+	public $pinterest = '';
2018
+
2019
+	/**
2020
+	 * google+ (google.com/+profileName)
2021
+	 *
2022
+	 * @var string
2023
+	 */
2024
+	public $google = '';
2025
+
2026
+	/**
2027
+	 * instagram (instagram.com/handle)
2028
+	 *
2029
+	 * @var string
2030
+	 */
2031
+	public $instagram = '';
2032
+
2033
+
2034
+	/**
2035
+	 *    class constructor
2036
+	 *
2037
+	 * @access    public
2038
+	 */
2039
+	public function __construct()
2040
+	{
2041
+		// set default organization settings
2042
+		// decode HTML entities from the WP blogname, because it's stored in the DB with HTML entities encoded
2043
+		$this->name = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES);
2044
+		$this->email = get_bloginfo('admin_email');
2045
+	}
2046
+}
2312 2047
 
2313
-    /**
2314
-     * Whether or not invalid attempts to directly access the registration checkout page should be tracked.
2315
-     *
2316
-     * @var boolean $track_invalid_checkout_access
2317
-     */
2318
-    protected $track_invalid_checkout_access = true;
2048
+/**
2049
+ * Class for defining what's in the EE_Config relating to currency
2050
+ */
2051
+class EE_Currency_Config extends EE_Config_Base
2052
+{
2319 2053
 
2320
-    /**
2321
-     * Whether or not to show the privacy policy consent checkbox
2322
-     *
2323
-     * @var bool
2324
-     */
2325
-    public $consent_checkbox_enabled;
2054
+	/**
2055
+	 * @var string $code
2056
+	 * eg 'US'
2057
+	 */
2058
+	public $code;
2059
+
2060
+	/**
2061
+	 * @var string $name
2062
+	 * eg 'Dollar'
2063
+	 */
2064
+	public $name;
2065
+
2066
+	/**
2067
+	 * plural name
2068
+	 *
2069
+	 * @var string $plural
2070
+	 * eg 'Dollars'
2071
+	 */
2072
+	public $plural;
2073
+
2074
+	/**
2075
+	 * currency sign
2076
+	 *
2077
+	 * @var string $sign
2078
+	 * eg '$'
2079
+	 */
2080
+	public $sign;
2081
+
2082
+	/**
2083
+	 * Whether the currency sign should come before the number or not
2084
+	 *
2085
+	 * @var boolean $sign_b4
2086
+	 */
2087
+	public $sign_b4;
2088
+
2089
+	/**
2090
+	 * How many digits should come after the decimal place
2091
+	 *
2092
+	 * @var int $dec_plc
2093
+	 */
2094
+	public $dec_plc;
2095
+
2096
+	/**
2097
+	 * Symbol to use for decimal mark
2098
+	 *
2099
+	 * @var string $dec_mrk
2100
+	 * eg '.'
2101
+	 */
2102
+	public $dec_mrk;
2103
+
2104
+	/**
2105
+	 * Symbol to use for thousands
2106
+	 *
2107
+	 * @var string $thsnds
2108
+	 * eg ','
2109
+	 */
2110
+	public $thsnds;
2111
+
2112
+
2113
+	/**
2114
+	 *    class constructor
2115
+	 *
2116
+	 * @access    public
2117
+	 * @param string $CNT_ISO
2118
+	 * @throws \EE_Error
2119
+	 */
2120
+	public function __construct($CNT_ISO = '')
2121
+	{
2122
+		/** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */
2123
+		$table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
2124
+		// get country code from organization settings or use default
2125
+		$ORG_CNT = isset(EE_Registry::instance()->CFG->organization)
2126
+				   && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
2127
+			? EE_Registry::instance()->CFG->organization->CNT_ISO
2128
+			: '';
2129
+		// but override if requested
2130
+		$CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2131
+		// 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
2132
+		if (
2133
+			! empty($CNT_ISO)
2134
+			&& EE_Maintenance_Mode::instance()->models_can_query()
2135
+			&& $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())
2136
+		) {
2137
+			// retrieve the country settings from the db, just in case they have been customized
2138
+			$country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2139
+			if ($country instanceof EE_Country) {
2140
+				$this->code = $country->currency_code();    // currency code: USD, CAD, EUR
2141
+				$this->name = $country->currency_name_single();    // Dollar
2142
+				$this->plural = $country->currency_name_plural();    // Dollars
2143
+				$this->sign = $country->currency_sign();            // currency sign: $
2144
+				$this->sign_b4 = $country->currency_sign_before(
2145
+				);        // currency sign before or after: $TRUE  or  FALSE$
2146
+				$this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2147
+				$this->dec_mrk = $country->currency_decimal_mark(
2148
+				);    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2149
+				$this->thsnds = $country->currency_thousands_separator(
2150
+				);    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2151
+			}
2152
+		}
2153
+		// fallback to hardcoded defaults, in case the above failed
2154
+		if (empty($this->code)) {
2155
+			// set default currency settings
2156
+			$this->code = 'USD';    // currency code: USD, CAD, EUR
2157
+			$this->name = __('Dollar', 'event_espresso');    // Dollar
2158
+			$this->plural = __('Dollars', 'event_espresso');    // Dollars
2159
+			$this->sign = '$';    // currency sign: $
2160
+			$this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2161
+			$this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2162
+			$this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2163
+			$this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2164
+		}
2165
+	}
2166
+}
2326 2167
 
2327
-    /**
2328
-     * Label text to show on the checkbox
2329
-     *
2330
-     * @var string
2331
-     */
2332
-    public $consent_checkbox_label_text;
2168
+/**
2169
+ * Class for defining what's in the EE_Config relating to registration settings
2170
+ */
2171
+class EE_Registration_Config extends EE_Config_Base
2172
+{
2333 2173
 
2334
-    /*
2174
+	/**
2175
+	 * Default registration status
2176
+	 *
2177
+	 * @var string $default_STS_ID
2178
+	 * eg 'RPP'
2179
+	 */
2180
+	public $default_STS_ID;
2181
+
2182
+	/**
2183
+	 * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of
2184
+	 * registrations)
2185
+	 *
2186
+	 * @var int
2187
+	 */
2188
+	public $default_maximum_number_of_tickets;
2189
+
2190
+	/**
2191
+	 * level of validation to apply to email addresses
2192
+	 *
2193
+	 * @var string $email_validation_level
2194
+	 * options: 'basic', 'wp_default', 'i18n', 'i18n_dns'
2195
+	 */
2196
+	public $email_validation_level;
2197
+
2198
+	/**
2199
+	 *    whether or not to show alternate payment options during the reg process if payment status is pending
2200
+	 *
2201
+	 * @var boolean $show_pending_payment_options
2202
+	 */
2203
+	public $show_pending_payment_options;
2204
+
2205
+	/**
2206
+	 * Whether to skip the registration confirmation page
2207
+	 *
2208
+	 * @var boolean $skip_reg_confirmation
2209
+	 */
2210
+	public $skip_reg_confirmation;
2211
+
2212
+	/**
2213
+	 * an array of SPCO reg steps where:
2214
+	 *        the keys denotes the reg step order
2215
+	 *        each element consists of an array with the following elements:
2216
+	 *            "file_path" => the file path to the EE_SPCO_Reg_Step class
2217
+	 *            "class_name" => the specific EE_SPCO_Reg_Step child class name
2218
+	 *            "slug" => the URL param used to trigger the reg step
2219
+	 *
2220
+	 * @var array $reg_steps
2221
+	 */
2222
+	public $reg_steps;
2223
+
2224
+	/**
2225
+	 * Whether registration confirmation should be the last page of SPCO
2226
+	 *
2227
+	 * @var boolean $reg_confirmation_last
2228
+	 */
2229
+	public $reg_confirmation_last;
2230
+
2231
+	/**
2232
+	 * Whether or not to enable the EE Bot Trap
2233
+	 *
2234
+	 * @var boolean $use_bot_trap
2235
+	 */
2236
+	public $use_bot_trap;
2237
+
2238
+	/**
2239
+	 * Whether or not to encrypt some data sent by the EE Bot Trap
2240
+	 *
2241
+	 * @var boolean $use_encryption
2242
+	 */
2243
+	public $use_encryption;
2244
+
2245
+	/**
2246
+	 * Whether or not to use ReCaptcha
2247
+	 *
2248
+	 * @var boolean $use_captcha
2249
+	 */
2250
+	public $use_captcha;
2251
+
2252
+	/**
2253
+	 * ReCaptcha Theme
2254
+	 *
2255
+	 * @var string $recaptcha_theme
2256
+	 *    options: 'dark', 'light', 'invisible'
2257
+	 */
2258
+	public $recaptcha_theme;
2259
+
2260
+	/**
2261
+	 * ReCaptcha Badge - determines the position of the reCAPTCHA badge if using Invisible ReCaptcha.
2262
+	 *
2263
+	 * @var string $recaptcha_badge
2264
+	 *    options: 'bottomright', 'bottomleft', 'inline'
2265
+	 */
2266
+	public $recaptcha_badge;
2267
+
2268
+	/**
2269
+	 * ReCaptcha Type
2270
+	 *
2271
+	 * @var string $recaptcha_type
2272
+	 *    options: 'audio', 'image'
2273
+	 */
2274
+	public $recaptcha_type;
2275
+
2276
+	/**
2277
+	 * ReCaptcha language
2278
+	 *
2279
+	 * @var string $recaptcha_language
2280
+	 * eg 'en'
2281
+	 */
2282
+	public $recaptcha_language;
2283
+
2284
+	/**
2285
+	 * ReCaptcha public key
2286
+	 *
2287
+	 * @var string $recaptcha_publickey
2288
+	 */
2289
+	public $recaptcha_publickey;
2290
+
2291
+	/**
2292
+	 * ReCaptcha private key
2293
+	 *
2294
+	 * @var string $recaptcha_privatekey
2295
+	 */
2296
+	public $recaptcha_privatekey;
2297
+
2298
+	/**
2299
+	 * array of form names protected by ReCaptcha
2300
+	 *
2301
+	 * @var array $recaptcha_protected_forms
2302
+	 */
2303
+	public $recaptcha_protected_forms;
2304
+
2305
+	/**
2306
+	 * ReCaptcha width
2307
+	 *
2308
+	 * @var int $recaptcha_width
2309
+	 * @deprecated
2310
+	 */
2311
+	public $recaptcha_width;
2312
+
2313
+	/**
2314
+	 * Whether or not invalid attempts to directly access the registration checkout page should be tracked.
2315
+	 *
2316
+	 * @var boolean $track_invalid_checkout_access
2317
+	 */
2318
+	protected $track_invalid_checkout_access = true;
2319
+
2320
+	/**
2321
+	 * Whether or not to show the privacy policy consent checkbox
2322
+	 *
2323
+	 * @var bool
2324
+	 */
2325
+	public $consent_checkbox_enabled;
2326
+
2327
+	/**
2328
+	 * Label text to show on the checkbox
2329
+	 *
2330
+	 * @var string
2331
+	 */
2332
+	public $consent_checkbox_label_text;
2333
+
2334
+	/*
2335 2335
      * String describing how long to keep payment logs. Passed into DateTime constructor
2336 2336
      * @var string
2337 2337
      */
2338
-    public $gateway_log_lifespan = '1 week';
2339
-
2340
-    /**
2341
-     * Enable copy attendee info at form
2342
-     *
2343
-     * @var boolean $enable_copy_attendee
2344
-     */
2345
-    protected $copy_attendee_info = true;
2346
-
2347
-
2348
-    /**
2349
-     *    class constructor
2350
-     *
2351
-     * @access    public
2352
-     */
2353
-    public function __construct()
2354
-    {
2355
-        // set default registration settings
2356
-        $this->default_STS_ID = EEM_Registration::status_id_pending_payment;
2357
-        $this->email_validation_level = 'wp_default';
2358
-        $this->show_pending_payment_options = true;
2359
-        $this->skip_reg_confirmation = true;
2360
-        $this->reg_steps = array();
2361
-        $this->reg_confirmation_last = false;
2362
-        $this->use_bot_trap = true;
2363
-        $this->use_encryption = true;
2364
-        $this->use_captcha = false;
2365
-        $this->recaptcha_theme = 'light';
2366
-        $this->recaptcha_badge = 'bottomleft';
2367
-        $this->recaptcha_type = 'image';
2368
-        $this->recaptcha_language = 'en';
2369
-        $this->recaptcha_publickey = null;
2370
-        $this->recaptcha_privatekey = null;
2371
-        $this->recaptcha_protected_forms = array();
2372
-        $this->recaptcha_width = 500;
2373
-        $this->default_maximum_number_of_tickets = 10;
2374
-        $this->consent_checkbox_enabled = false;
2375
-        $this->consent_checkbox_label_text = '';
2376
-        $this->gateway_log_lifespan = '7 days';
2377
-        $this->copy_attendee_info = true;
2378
-    }
2379
-
2380
-
2381
-    /**
2382
-     * This is called by the config loader and hooks are initialized AFTER the config has been populated.
2383
-     *
2384
-     * @since 4.8.8.rc.019
2385
-     */
2386
-    public function do_hooks()
2387
-    {
2388
-        add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2389
-        add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event'));
2390
-        add_action('setup_theme', array($this, 'setDefaultCheckboxLabelText'));
2391
-    }
2392
-
2393
-
2394
-    /**
2395
-     * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the
2396
-     * EVT_default_registration_status field matches the config setting for default_STS_ID.
2397
-     */
2398
-    public function set_default_reg_status_on_EEM_Event()
2399
-    {
2400
-        EEM_Event::set_default_reg_status($this->default_STS_ID);
2401
-    }
2402
-
2403
-
2404
-    /**
2405
-     * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field
2406
-     * for Events matches the config setting for default_maximum_number_of_tickets
2407
-     */
2408
-    public function set_default_max_ticket_on_EEM_Event()
2409
-    {
2410
-        EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets);
2411
-    }
2412
-
2413
-
2414
-    /**
2415
-     * Sets the default consent checkbox text. This needs to be done a bit later than when EE_Registration_Config is
2416
-     * constructed because that happens before we can get the privacy policy page's permalink.
2417
-     *
2418
-     * @throws InvalidArgumentException
2419
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2420
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2421
-     */
2422
-    public function setDefaultCheckboxLabelText()
2423
-    {
2424
-        if (
2425
-            $this->getConsentCheckboxLabelText() === null
2426
-            || $this->getConsentCheckboxLabelText() === ''
2427
-        ) {
2428
-            $opening_a_tag = '';
2429
-            $closing_a_tag = '';
2430
-            if (function_exists('get_privacy_policy_url')) {
2431
-                $privacy_page_url = get_privacy_policy_url();
2432
-                if (! empty($privacy_page_url)) {
2433
-                    $opening_a_tag = '<a href="' . $privacy_page_url . '" target="_blank">';
2434
-                    $closing_a_tag = '</a>';
2435
-                }
2436
-            }
2437
-            $loader = LoaderFactory::getLoader();
2438
-            $org_config = $loader->getShared('EE_Organization_Config');
2439
-            /**
2440
-             * @var $org_config EE_Organization_Config
2441
-             */
2442
-
2443
-            $this->setConsentCheckboxLabelText(
2444
-                sprintf(
2445
-                    esc_html__(
2446
-                        'I consent to %1$s storing and using my personal information, according to their %2$sprivacy policy%3$s.',
2447
-                        'event_espresso'
2448
-                    ),
2449
-                    $org_config->name,
2450
-                    $opening_a_tag,
2451
-                    $closing_a_tag
2452
-                )
2453
-            );
2454
-        }
2455
-    }
2456
-
2457
-
2458
-    /**
2459
-     * @return boolean
2460
-     */
2461
-    public function track_invalid_checkout_access()
2462
-    {
2463
-        return $this->track_invalid_checkout_access;
2464
-    }
2465
-
2466
-
2467
-    /**
2468
-     * @param boolean $track_invalid_checkout_access
2469
-     */
2470
-    public function set_track_invalid_checkout_access($track_invalid_checkout_access)
2471
-    {
2472
-        $this->track_invalid_checkout_access = filter_var(
2473
-            $track_invalid_checkout_access,
2474
-            FILTER_VALIDATE_BOOLEAN
2475
-        );
2476
-    }
2477
-
2478
-    /**
2479
-     * @return boolean
2480
-     */
2481
-    public function copyAttendeeInfo()
2482
-    {
2483
-        return $this->copy_attendee_info;
2484
-    }
2485
-
2486
-
2487
-    /**
2488
-     * @param boolean $copy_attendee_info
2489
-     */
2490
-    public function setCopyAttendeeInfo($copy_attendee_info)
2491
-    {
2492
-        $this->copy_attendee_info = filter_var(
2493
-            $copy_attendee_info,
2494
-            FILTER_VALIDATE_BOOLEAN
2495
-        );
2496
-    }
2497
-
2498
-
2499
-    /**
2500
-     * Gets the options to make availalbe for the gateway log lifespan
2501
-     * @return array
2502
-     */
2503
-    public function gatewayLogLifespanOptions()
2504
-    {
2505
-        return (array) apply_filters(
2506
-            'FHEE_EE_Admin_Config__gatewayLogLifespanOptions',
2507
-            array(
2508
-                '1 second' => esc_html__('Don\'t Log At All', 'event_espresso'),
2509
-                '1 day' => esc_html__('1 Day', 'event_espresso'),
2510
-                '7 days' => esc_html__('7 Days', 'event_espresso'),
2511
-                '14 days' => esc_html__('14 Days', 'event_espresso'),
2512
-                '30 days' => esc_html__('30 Days', 'event_espresso')
2513
-            )
2514
-        );
2515
-    }
2516
-
2517
-
2518
-    /**
2519
-     * @return bool
2520
-     */
2521
-    public function isConsentCheckboxEnabled()
2522
-    {
2523
-        return $this->consent_checkbox_enabled;
2524
-    }
2525
-
2526
-
2527
-    /**
2528
-     * @param bool $consent_checkbox_enabled
2529
-     */
2530
-    public function setConsentCheckboxEnabled($consent_checkbox_enabled)
2531
-    {
2532
-        $this->consent_checkbox_enabled = filter_var(
2533
-            $consent_checkbox_enabled,
2534
-            FILTER_VALIDATE_BOOLEAN
2535
-        );
2536
-    }
2537
-
2538
-
2539
-    /**
2540
-     * @return string
2541
-     */
2542
-    public function getConsentCheckboxLabelText()
2543
-    {
2544
-        return $this->consent_checkbox_label_text;
2545
-    }
2546
-
2547
-
2548
-    /**
2549
-     * @param string $consent_checkbox_label_text
2550
-     */
2551
-    public function setConsentCheckboxLabelText($consent_checkbox_label_text)
2552
-    {
2553
-        $this->consent_checkbox_label_text = (string) $consent_checkbox_label_text;
2554
-    }
2338
+	public $gateway_log_lifespan = '1 week';
2339
+
2340
+	/**
2341
+	 * Enable copy attendee info at form
2342
+	 *
2343
+	 * @var boolean $enable_copy_attendee
2344
+	 */
2345
+	protected $copy_attendee_info = true;
2346
+
2347
+
2348
+	/**
2349
+	 *    class constructor
2350
+	 *
2351
+	 * @access    public
2352
+	 */
2353
+	public function __construct()
2354
+	{
2355
+		// set default registration settings
2356
+		$this->default_STS_ID = EEM_Registration::status_id_pending_payment;
2357
+		$this->email_validation_level = 'wp_default';
2358
+		$this->show_pending_payment_options = true;
2359
+		$this->skip_reg_confirmation = true;
2360
+		$this->reg_steps = array();
2361
+		$this->reg_confirmation_last = false;
2362
+		$this->use_bot_trap = true;
2363
+		$this->use_encryption = true;
2364
+		$this->use_captcha = false;
2365
+		$this->recaptcha_theme = 'light';
2366
+		$this->recaptcha_badge = 'bottomleft';
2367
+		$this->recaptcha_type = 'image';
2368
+		$this->recaptcha_language = 'en';
2369
+		$this->recaptcha_publickey = null;
2370
+		$this->recaptcha_privatekey = null;
2371
+		$this->recaptcha_protected_forms = array();
2372
+		$this->recaptcha_width = 500;
2373
+		$this->default_maximum_number_of_tickets = 10;
2374
+		$this->consent_checkbox_enabled = false;
2375
+		$this->consent_checkbox_label_text = '';
2376
+		$this->gateway_log_lifespan = '7 days';
2377
+		$this->copy_attendee_info = true;
2378
+	}
2379
+
2380
+
2381
+	/**
2382
+	 * This is called by the config loader and hooks are initialized AFTER the config has been populated.
2383
+	 *
2384
+	 * @since 4.8.8.rc.019
2385
+	 */
2386
+	public function do_hooks()
2387
+	{
2388
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2389
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event'));
2390
+		add_action('setup_theme', array($this, 'setDefaultCheckboxLabelText'));
2391
+	}
2392
+
2393
+
2394
+	/**
2395
+	 * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the
2396
+	 * EVT_default_registration_status field matches the config setting for default_STS_ID.
2397
+	 */
2398
+	public function set_default_reg_status_on_EEM_Event()
2399
+	{
2400
+		EEM_Event::set_default_reg_status($this->default_STS_ID);
2401
+	}
2402
+
2403
+
2404
+	/**
2405
+	 * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field
2406
+	 * for Events matches the config setting for default_maximum_number_of_tickets
2407
+	 */
2408
+	public function set_default_max_ticket_on_EEM_Event()
2409
+	{
2410
+		EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets);
2411
+	}
2412
+
2413
+
2414
+	/**
2415
+	 * Sets the default consent checkbox text. This needs to be done a bit later than when EE_Registration_Config is
2416
+	 * constructed because that happens before we can get the privacy policy page's permalink.
2417
+	 *
2418
+	 * @throws InvalidArgumentException
2419
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2420
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2421
+	 */
2422
+	public function setDefaultCheckboxLabelText()
2423
+	{
2424
+		if (
2425
+			$this->getConsentCheckboxLabelText() === null
2426
+			|| $this->getConsentCheckboxLabelText() === ''
2427
+		) {
2428
+			$opening_a_tag = '';
2429
+			$closing_a_tag = '';
2430
+			if (function_exists('get_privacy_policy_url')) {
2431
+				$privacy_page_url = get_privacy_policy_url();
2432
+				if (! empty($privacy_page_url)) {
2433
+					$opening_a_tag = '<a href="' . $privacy_page_url . '" target="_blank">';
2434
+					$closing_a_tag = '</a>';
2435
+				}
2436
+			}
2437
+			$loader = LoaderFactory::getLoader();
2438
+			$org_config = $loader->getShared('EE_Organization_Config');
2439
+			/**
2440
+			 * @var $org_config EE_Organization_Config
2441
+			 */
2442
+
2443
+			$this->setConsentCheckboxLabelText(
2444
+				sprintf(
2445
+					esc_html__(
2446
+						'I consent to %1$s storing and using my personal information, according to their %2$sprivacy policy%3$s.',
2447
+						'event_espresso'
2448
+					),
2449
+					$org_config->name,
2450
+					$opening_a_tag,
2451
+					$closing_a_tag
2452
+				)
2453
+			);
2454
+		}
2455
+	}
2456
+
2457
+
2458
+	/**
2459
+	 * @return boolean
2460
+	 */
2461
+	public function track_invalid_checkout_access()
2462
+	{
2463
+		return $this->track_invalid_checkout_access;
2464
+	}
2465
+
2466
+
2467
+	/**
2468
+	 * @param boolean $track_invalid_checkout_access
2469
+	 */
2470
+	public function set_track_invalid_checkout_access($track_invalid_checkout_access)
2471
+	{
2472
+		$this->track_invalid_checkout_access = filter_var(
2473
+			$track_invalid_checkout_access,
2474
+			FILTER_VALIDATE_BOOLEAN
2475
+		);
2476
+	}
2477
+
2478
+	/**
2479
+	 * @return boolean
2480
+	 */
2481
+	public function copyAttendeeInfo()
2482
+	{
2483
+		return $this->copy_attendee_info;
2484
+	}
2485
+
2486
+
2487
+	/**
2488
+	 * @param boolean $copy_attendee_info
2489
+	 */
2490
+	public function setCopyAttendeeInfo($copy_attendee_info)
2491
+	{
2492
+		$this->copy_attendee_info = filter_var(
2493
+			$copy_attendee_info,
2494
+			FILTER_VALIDATE_BOOLEAN
2495
+		);
2496
+	}
2497
+
2498
+
2499
+	/**
2500
+	 * Gets the options to make availalbe for the gateway log lifespan
2501
+	 * @return array
2502
+	 */
2503
+	public function gatewayLogLifespanOptions()
2504
+	{
2505
+		return (array) apply_filters(
2506
+			'FHEE_EE_Admin_Config__gatewayLogLifespanOptions',
2507
+			array(
2508
+				'1 second' => esc_html__('Don\'t Log At All', 'event_espresso'),
2509
+				'1 day' => esc_html__('1 Day', 'event_espresso'),
2510
+				'7 days' => esc_html__('7 Days', 'event_espresso'),
2511
+				'14 days' => esc_html__('14 Days', 'event_espresso'),
2512
+				'30 days' => esc_html__('30 Days', 'event_espresso')
2513
+			)
2514
+		);
2515
+	}
2516
+
2517
+
2518
+	/**
2519
+	 * @return bool
2520
+	 */
2521
+	public function isConsentCheckboxEnabled()
2522
+	{
2523
+		return $this->consent_checkbox_enabled;
2524
+	}
2525
+
2526
+
2527
+	/**
2528
+	 * @param bool $consent_checkbox_enabled
2529
+	 */
2530
+	public function setConsentCheckboxEnabled($consent_checkbox_enabled)
2531
+	{
2532
+		$this->consent_checkbox_enabled = filter_var(
2533
+			$consent_checkbox_enabled,
2534
+			FILTER_VALIDATE_BOOLEAN
2535
+		);
2536
+	}
2537
+
2538
+
2539
+	/**
2540
+	 * @return string
2541
+	 */
2542
+	public function getConsentCheckboxLabelText()
2543
+	{
2544
+		return $this->consent_checkbox_label_text;
2545
+	}
2546
+
2547
+
2548
+	/**
2549
+	 * @param string $consent_checkbox_label_text
2550
+	 */
2551
+	public function setConsentCheckboxLabelText($consent_checkbox_label_text)
2552
+	{
2553
+		$this->consent_checkbox_label_text = (string) $consent_checkbox_label_text;
2554
+	}
2555 2555
 }
2556 2556
 
2557 2557
 /**
@@ -2560,180 +2560,180 @@  discard block
 block discarded – undo
2560 2560
 class EE_Admin_Config extends EE_Config_Base
2561 2561
 {
2562 2562
 
2563
-    /**
2564
-     * @var boolean $useAdvancedEditor
2565
-     */
2566
-    private $useAdvancedEditor;
2567
-
2568
-    /**
2569
-     * @var boolean $use_personnel_manager
2570
-     */
2571
-    public $use_personnel_manager;
2572
-
2573
-    /**
2574
-     * @var boolean $use_dashboard_widget
2575
-     */
2576
-    public $use_dashboard_widget;
2577
-
2578
-    /**
2579
-     * @var int $events_in_dashboard
2580
-     */
2581
-    public $events_in_dashboard;
2582
-
2583
-    /**
2584
-     * @var boolean $use_event_timezones
2585
-     */
2586
-    public $use_event_timezones;
2587
-
2588
-    /**
2589
-     * @var string $log_file_name
2590
-     */
2591
-    public $log_file_name;
2592
-
2593
-    /**
2594
-     * @var string $debug_file_name
2595
-     */
2596
-    public $debug_file_name;
2597
-
2598
-    /**
2599
-     * @var boolean $use_remote_logging
2600
-     */
2601
-    public $use_remote_logging;
2602
-
2603
-    /**
2604
-     * @var string $remote_logging_url
2605
-     */
2606
-    public $remote_logging_url;
2607
-
2608
-    /**
2609
-     * @var boolean $show_reg_footer
2610
-     */
2611
-    public $show_reg_footer;
2612
-
2613
-    /**
2614
-     * @var string $affiliate_id
2615
-     */
2616
-    public $affiliate_id;
2617
-
2618
-    /**
2619
-     * help tours on or off (global setting)
2620
-     *
2621
-     * @var boolean
2622
-     */
2623
-    public $help_tour_activation;
2624
-
2625
-    /**
2626
-     * adds extra layer of encoding to session data to prevent serialization errors
2627
-     * but is incompatible with some server configuration errors
2628
-     * if you get "500 internal server errors" during registration, try turning this on
2629
-     * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off
2630
-     *
2631
-     * @var boolean $encode_session_data
2632
-     */
2633
-    private $encode_session_data = false;
2634
-
2635
-
2636
-    /**
2637
-     *    class constructor
2638
-     *
2639
-     * @access    public
2640
-     */
2641
-    public function __construct()
2642
-    {
2643
-        // set default general admin settings
2644
-        $this->useAdvancedEditor = true;
2645
-        $this->use_personnel_manager = true;
2646
-        $this->use_dashboard_widget = true;
2647
-        $this->events_in_dashboard = 30;
2648
-        $this->use_event_timezones = false;
2649
-        $this->use_remote_logging = false;
2650
-        $this->remote_logging_url = null;
2651
-        $this->show_reg_footer = apply_filters(
2652
-            'FHEE__EE_Admin_Config__show_reg_footer__default',
2653
-            false
2654
-        );
2655
-        $this->affiliate_id = 'default';
2656
-        $this->help_tour_activation = true;
2657
-        $this->encode_session_data = false;
2658
-    }
2659
-
2660
-
2661
-    /**
2662
-     * @param bool $reset
2663
-     * @return string
2664
-     */
2665
-    public function log_file_name($reset = false)
2666
-    {
2667
-        if (empty($this->log_file_name) || $reset) {
2668
-            $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2669
-            EE_Config::instance()->update_espresso_config(false, false);
2670
-        }
2671
-        return $this->log_file_name;
2672
-    }
2673
-
2674
-
2675
-    /**
2676
-     * @param bool $reset
2677
-     * @return string
2678
-     */
2679
-    public function debug_file_name($reset = false)
2680
-    {
2681
-        if (empty($this->debug_file_name) || $reset) {
2682
-            $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2683
-            EE_Config::instance()->update_espresso_config(false, false);
2684
-        }
2685
-        return $this->debug_file_name;
2686
-    }
2687
-
2688
-
2689
-    /**
2690
-     * @return string
2691
-     */
2692
-    public function affiliate_id()
2693
-    {
2694
-        return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default';
2695
-    }
2696
-
2697
-
2698
-    /**
2699
-     * @return boolean
2700
-     */
2701
-    public function encode_session_data()
2702
-    {
2703
-        return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN);
2704
-    }
2705
-
2706
-
2707
-    /**
2708
-     * @param boolean $encode_session_data
2709
-     */
2710
-    public function set_encode_session_data($encode_session_data)
2711
-    {
2712
-        $this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN);
2713
-    }
2714
-
2715
-    /**
2716
-     * @return boolean
2717
-     */
2718
-    public function useAdvancedEditor()
2719
-    {
2720
-        $domain = LoaderFactory::getLoader()->getShared('EventEspresso\core\domain\Domain');
2721
-        return $this->useAdvancedEditor && $domain->isCaffeinated();
2722
-    }
2723
-
2724
-    /**
2725
-     * @param boolean $use_advanced_editor
2726
-     */
2727
-    public function setUseAdvancedEditor($use_advanced_editor = true)
2728
-    {
2729
-        $this->useAdvancedEditor = filter_var(
2730
-            apply_filters(
2731
-                'FHEE__EE_Admin_Config__setUseAdvancedEditor__use_advanced_editor',
2732
-                $use_advanced_editor
2733
-            ),
2734
-            FILTER_VALIDATE_BOOLEAN
2735
-        );
2736
-    }
2563
+	/**
2564
+	 * @var boolean $useAdvancedEditor
2565
+	 */
2566
+	private $useAdvancedEditor;
2567
+
2568
+	/**
2569
+	 * @var boolean $use_personnel_manager
2570
+	 */
2571
+	public $use_personnel_manager;
2572
+
2573
+	/**
2574
+	 * @var boolean $use_dashboard_widget
2575
+	 */
2576
+	public $use_dashboard_widget;
2577
+
2578
+	/**
2579
+	 * @var int $events_in_dashboard
2580
+	 */
2581
+	public $events_in_dashboard;
2582
+
2583
+	/**
2584
+	 * @var boolean $use_event_timezones
2585
+	 */
2586
+	public $use_event_timezones;
2587
+
2588
+	/**
2589
+	 * @var string $log_file_name
2590
+	 */
2591
+	public $log_file_name;
2592
+
2593
+	/**
2594
+	 * @var string $debug_file_name
2595
+	 */
2596
+	public $debug_file_name;
2597
+
2598
+	/**
2599
+	 * @var boolean $use_remote_logging
2600
+	 */
2601
+	public $use_remote_logging;
2602
+
2603
+	/**
2604
+	 * @var string $remote_logging_url
2605
+	 */
2606
+	public $remote_logging_url;
2607
+
2608
+	/**
2609
+	 * @var boolean $show_reg_footer
2610
+	 */
2611
+	public $show_reg_footer;
2612
+
2613
+	/**
2614
+	 * @var string $affiliate_id
2615
+	 */
2616
+	public $affiliate_id;
2617
+
2618
+	/**
2619
+	 * help tours on or off (global setting)
2620
+	 *
2621
+	 * @var boolean
2622
+	 */
2623
+	public $help_tour_activation;
2624
+
2625
+	/**
2626
+	 * adds extra layer of encoding to session data to prevent serialization errors
2627
+	 * but is incompatible with some server configuration errors
2628
+	 * if you get "500 internal server errors" during registration, try turning this on
2629
+	 * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off
2630
+	 *
2631
+	 * @var boolean $encode_session_data
2632
+	 */
2633
+	private $encode_session_data = false;
2634
+
2635
+
2636
+	/**
2637
+	 *    class constructor
2638
+	 *
2639
+	 * @access    public
2640
+	 */
2641
+	public function __construct()
2642
+	{
2643
+		// set default general admin settings
2644
+		$this->useAdvancedEditor = true;
2645
+		$this->use_personnel_manager = true;
2646
+		$this->use_dashboard_widget = true;
2647
+		$this->events_in_dashboard = 30;
2648
+		$this->use_event_timezones = false;
2649
+		$this->use_remote_logging = false;
2650
+		$this->remote_logging_url = null;
2651
+		$this->show_reg_footer = apply_filters(
2652
+			'FHEE__EE_Admin_Config__show_reg_footer__default',
2653
+			false
2654
+		);
2655
+		$this->affiliate_id = 'default';
2656
+		$this->help_tour_activation = true;
2657
+		$this->encode_session_data = false;
2658
+	}
2659
+
2660
+
2661
+	/**
2662
+	 * @param bool $reset
2663
+	 * @return string
2664
+	 */
2665
+	public function log_file_name($reset = false)
2666
+	{
2667
+		if (empty($this->log_file_name) || $reset) {
2668
+			$this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2669
+			EE_Config::instance()->update_espresso_config(false, false);
2670
+		}
2671
+		return $this->log_file_name;
2672
+	}
2673
+
2674
+
2675
+	/**
2676
+	 * @param bool $reset
2677
+	 * @return string
2678
+	 */
2679
+	public function debug_file_name($reset = false)
2680
+	{
2681
+		if (empty($this->debug_file_name) || $reset) {
2682
+			$this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2683
+			EE_Config::instance()->update_espresso_config(false, false);
2684
+		}
2685
+		return $this->debug_file_name;
2686
+	}
2687
+
2688
+
2689
+	/**
2690
+	 * @return string
2691
+	 */
2692
+	public function affiliate_id()
2693
+	{
2694
+		return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default';
2695
+	}
2696
+
2697
+
2698
+	/**
2699
+	 * @return boolean
2700
+	 */
2701
+	public function encode_session_data()
2702
+	{
2703
+		return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN);
2704
+	}
2705
+
2706
+
2707
+	/**
2708
+	 * @param boolean $encode_session_data
2709
+	 */
2710
+	public function set_encode_session_data($encode_session_data)
2711
+	{
2712
+		$this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN);
2713
+	}
2714
+
2715
+	/**
2716
+	 * @return boolean
2717
+	 */
2718
+	public function useAdvancedEditor()
2719
+	{
2720
+		$domain = LoaderFactory::getLoader()->getShared('EventEspresso\core\domain\Domain');
2721
+		return $this->useAdvancedEditor && $domain->isCaffeinated();
2722
+	}
2723
+
2724
+	/**
2725
+	 * @param boolean $use_advanced_editor
2726
+	 */
2727
+	public function setUseAdvancedEditor($use_advanced_editor = true)
2728
+	{
2729
+		$this->useAdvancedEditor = filter_var(
2730
+			apply_filters(
2731
+				'FHEE__EE_Admin_Config__setUseAdvancedEditor__use_advanced_editor',
2732
+				$use_advanced_editor
2733
+			),
2734
+			FILTER_VALIDATE_BOOLEAN
2735
+		);
2736
+	}
2737 2737
 }
2738 2738
 
2739 2739
 /**
@@ -2742,70 +2742,70 @@  discard block
 block discarded – undo
2742 2742
 class EE_Template_Config extends EE_Config_Base
2743 2743
 {
2744 2744
 
2745
-    /**
2746
-     * @var boolean $enable_default_style
2747
-     */
2748
-    public $enable_default_style;
2749
-
2750
-    /**
2751
-     * @var string $custom_style_sheet
2752
-     */
2753
-    public $custom_style_sheet;
2754
-
2755
-    /**
2756
-     * @var boolean $display_address_in_regform
2757
-     */
2758
-    public $display_address_in_regform;
2759
-
2760
-    /**
2761
-     * @var int $display_description_on_multi_reg_page
2762
-     */
2763
-    public $display_description_on_multi_reg_page;
2764
-
2765
-    /**
2766
-     * @var boolean $use_custom_templates
2767
-     */
2768
-    public $use_custom_templates;
2769
-
2770
-    /**
2771
-     * @var string $current_espresso_theme
2772
-     */
2773
-    public $current_espresso_theme;
2774
-
2775
-    /**
2776
-     * @var EE_Ticket_Selector_Config $EED_Ticket_Selector
2777
-     */
2778
-    public $EED_Ticket_Selector;
2779
-
2780
-    /**
2781
-     * @var EE_Event_Single_Config $EED_Event_Single
2782
-     */
2783
-    public $EED_Event_Single;
2784
-
2785
-    /**
2786
-     * @var EE_Events_Archive_Config $EED_Events_Archive
2787
-     */
2788
-    public $EED_Events_Archive;
2789
-
2790
-
2791
-    /**
2792
-     *    class constructor
2793
-     *
2794
-     * @access    public
2795
-     */
2796
-    public function __construct()
2797
-    {
2798
-        // set default template settings
2799
-        $this->enable_default_style = true;
2800
-        $this->custom_style_sheet = null;
2801
-        $this->display_address_in_regform = true;
2802
-        $this->display_description_on_multi_reg_page = false;
2803
-        $this->use_custom_templates = false;
2804
-        $this->current_espresso_theme = 'Espresso_Arabica_2014';
2805
-        $this->EED_Event_Single = null;
2806
-        $this->EED_Events_Archive = null;
2807
-        $this->EED_Ticket_Selector = null;
2808
-    }
2745
+	/**
2746
+	 * @var boolean $enable_default_style
2747
+	 */
2748
+	public $enable_default_style;
2749
+
2750
+	/**
2751
+	 * @var string $custom_style_sheet
2752
+	 */
2753
+	public $custom_style_sheet;
2754
+
2755
+	/**
2756
+	 * @var boolean $display_address_in_regform
2757
+	 */
2758
+	public $display_address_in_regform;
2759
+
2760
+	/**
2761
+	 * @var int $display_description_on_multi_reg_page
2762
+	 */
2763
+	public $display_description_on_multi_reg_page;
2764
+
2765
+	/**
2766
+	 * @var boolean $use_custom_templates
2767
+	 */
2768
+	public $use_custom_templates;
2769
+
2770
+	/**
2771
+	 * @var string $current_espresso_theme
2772
+	 */
2773
+	public $current_espresso_theme;
2774
+
2775
+	/**
2776
+	 * @var EE_Ticket_Selector_Config $EED_Ticket_Selector
2777
+	 */
2778
+	public $EED_Ticket_Selector;
2779
+
2780
+	/**
2781
+	 * @var EE_Event_Single_Config $EED_Event_Single
2782
+	 */
2783
+	public $EED_Event_Single;
2784
+
2785
+	/**
2786
+	 * @var EE_Events_Archive_Config $EED_Events_Archive
2787
+	 */
2788
+	public $EED_Events_Archive;
2789
+
2790
+
2791
+	/**
2792
+	 *    class constructor
2793
+	 *
2794
+	 * @access    public
2795
+	 */
2796
+	public function __construct()
2797
+	{
2798
+		// set default template settings
2799
+		$this->enable_default_style = true;
2800
+		$this->custom_style_sheet = null;
2801
+		$this->display_address_in_regform = true;
2802
+		$this->display_description_on_multi_reg_page = false;
2803
+		$this->use_custom_templates = false;
2804
+		$this->current_espresso_theme = 'Espresso_Arabica_2014';
2805
+		$this->EED_Event_Single = null;
2806
+		$this->EED_Events_Archive = null;
2807
+		$this->EED_Ticket_Selector = null;
2808
+	}
2809 2809
 }
2810 2810
 
2811 2811
 /**
@@ -2814,114 +2814,114 @@  discard block
 block discarded – undo
2814 2814
 class EE_Map_Config extends EE_Config_Base
2815 2815
 {
2816 2816
 
2817
-    /**
2818
-     * @var boolean $use_google_maps
2819
-     */
2820
-    public $use_google_maps;
2821
-
2822
-    /**
2823
-     * @var string $api_key
2824
-     */
2825
-    public $google_map_api_key;
2826
-
2827
-    /**
2828
-     * @var int $event_details_map_width
2829
-     */
2830
-    public $event_details_map_width;
2831
-
2832
-    /**
2833
-     * @var int $event_details_map_height
2834
-     */
2835
-    public $event_details_map_height;
2836
-
2837
-    /**
2838
-     * @var int $event_details_map_zoom
2839
-     */
2840
-    public $event_details_map_zoom;
2841
-
2842
-    /**
2843
-     * @var boolean $event_details_display_nav
2844
-     */
2845
-    public $event_details_display_nav;
2846
-
2847
-    /**
2848
-     * @var boolean $event_details_nav_size
2849
-     */
2850
-    public $event_details_nav_size;
2851
-
2852
-    /**
2853
-     * @var string $event_details_control_type
2854
-     */
2855
-    public $event_details_control_type;
2856
-
2857
-    /**
2858
-     * @var string $event_details_map_align
2859
-     */
2860
-    public $event_details_map_align;
2861
-
2862
-    /**
2863
-     * @var int $event_list_map_width
2864
-     */
2865
-    public $event_list_map_width;
2866
-
2867
-    /**
2868
-     * @var int $event_list_map_height
2869
-     */
2870
-    public $event_list_map_height;
2871
-
2872
-    /**
2873
-     * @var int $event_list_map_zoom
2874
-     */
2875
-    public $event_list_map_zoom;
2876
-
2877
-    /**
2878
-     * @var boolean $event_list_display_nav
2879
-     */
2880
-    public $event_list_display_nav;
2881
-
2882
-    /**
2883
-     * @var boolean $event_list_nav_size
2884
-     */
2885
-    public $event_list_nav_size;
2886
-
2887
-    /**
2888
-     * @var string $event_list_control_type
2889
-     */
2890
-    public $event_list_control_type;
2891
-
2892
-    /**
2893
-     * @var string $event_list_map_align
2894
-     */
2895
-    public $event_list_map_align;
2896
-
2897
-
2898
-    /**
2899
-     *    class constructor
2900
-     *
2901
-     * @access    public
2902
-     */
2903
-    public function __construct()
2904
-    {
2905
-        // set default map settings
2906
-        $this->use_google_maps = true;
2907
-        $this->google_map_api_key = '';
2908
-        // for event details pages (reg page)
2909
-        $this->event_details_map_width = 585;            // ee_map_width_single
2910
-        $this->event_details_map_height = 362;            // ee_map_height_single
2911
-        $this->event_details_map_zoom = 14;            // ee_map_zoom_single
2912
-        $this->event_details_display_nav = true;            // ee_map_nav_display_single
2913
-        $this->event_details_nav_size = false;            // ee_map_nav_size_single
2914
-        $this->event_details_control_type = 'default';        // ee_map_type_control_single
2915
-        $this->event_details_map_align = 'center';            // ee_map_align_single
2916
-        // for event list pages
2917
-        $this->event_list_map_width = 300;            // ee_map_width
2918
-        $this->event_list_map_height = 185;        // ee_map_height
2919
-        $this->event_list_map_zoom = 12;            // ee_map_zoom
2920
-        $this->event_list_display_nav = false;        // ee_map_nav_display
2921
-        $this->event_list_nav_size = true;            // ee_map_nav_size
2922
-        $this->event_list_control_type = 'dropdown';        // ee_map_type_control
2923
-        $this->event_list_map_align = 'center';            // ee_map_align
2924
-    }
2817
+	/**
2818
+	 * @var boolean $use_google_maps
2819
+	 */
2820
+	public $use_google_maps;
2821
+
2822
+	/**
2823
+	 * @var string $api_key
2824
+	 */
2825
+	public $google_map_api_key;
2826
+
2827
+	/**
2828
+	 * @var int $event_details_map_width
2829
+	 */
2830
+	public $event_details_map_width;
2831
+
2832
+	/**
2833
+	 * @var int $event_details_map_height
2834
+	 */
2835
+	public $event_details_map_height;
2836
+
2837
+	/**
2838
+	 * @var int $event_details_map_zoom
2839
+	 */
2840
+	public $event_details_map_zoom;
2841
+
2842
+	/**
2843
+	 * @var boolean $event_details_display_nav
2844
+	 */
2845
+	public $event_details_display_nav;
2846
+
2847
+	/**
2848
+	 * @var boolean $event_details_nav_size
2849
+	 */
2850
+	public $event_details_nav_size;
2851
+
2852
+	/**
2853
+	 * @var string $event_details_control_type
2854
+	 */
2855
+	public $event_details_control_type;
2856
+
2857
+	/**
2858
+	 * @var string $event_details_map_align
2859
+	 */
2860
+	public $event_details_map_align;
2861
+
2862
+	/**
2863
+	 * @var int $event_list_map_width
2864
+	 */
2865
+	public $event_list_map_width;
2866
+
2867
+	/**
2868
+	 * @var int $event_list_map_height
2869
+	 */
2870
+	public $event_list_map_height;
2871
+
2872
+	/**
2873
+	 * @var int $event_list_map_zoom
2874
+	 */
2875
+	public $event_list_map_zoom;
2876
+
2877
+	/**
2878
+	 * @var boolean $event_list_display_nav
2879
+	 */
2880
+	public $event_list_display_nav;
2881
+
2882
+	/**
2883
+	 * @var boolean $event_list_nav_size
2884
+	 */
2885
+	public $event_list_nav_size;
2886
+
2887
+	/**
2888
+	 * @var string $event_list_control_type
2889
+	 */
2890
+	public $event_list_control_type;
2891
+
2892
+	/**
2893
+	 * @var string $event_list_map_align
2894
+	 */
2895
+	public $event_list_map_align;
2896
+
2897
+
2898
+	/**
2899
+	 *    class constructor
2900
+	 *
2901
+	 * @access    public
2902
+	 */
2903
+	public function __construct()
2904
+	{
2905
+		// set default map settings
2906
+		$this->use_google_maps = true;
2907
+		$this->google_map_api_key = '';
2908
+		// for event details pages (reg page)
2909
+		$this->event_details_map_width = 585;            // ee_map_width_single
2910
+		$this->event_details_map_height = 362;            // ee_map_height_single
2911
+		$this->event_details_map_zoom = 14;            // ee_map_zoom_single
2912
+		$this->event_details_display_nav = true;            // ee_map_nav_display_single
2913
+		$this->event_details_nav_size = false;            // ee_map_nav_size_single
2914
+		$this->event_details_control_type = 'default';        // ee_map_type_control_single
2915
+		$this->event_details_map_align = 'center';            // ee_map_align_single
2916
+		// for event list pages
2917
+		$this->event_list_map_width = 300;            // ee_map_width
2918
+		$this->event_list_map_height = 185;        // ee_map_height
2919
+		$this->event_list_map_zoom = 12;            // ee_map_zoom
2920
+		$this->event_list_display_nav = false;        // ee_map_nav_display
2921
+		$this->event_list_nav_size = true;            // ee_map_nav_size
2922
+		$this->event_list_control_type = 'dropdown';        // ee_map_type_control
2923
+		$this->event_list_map_align = 'center';            // ee_map_align
2924
+	}
2925 2925
 }
2926 2926
 
2927 2927
 /**
@@ -2930,46 +2930,46 @@  discard block
 block discarded – undo
2930 2930
 class EE_Events_Archive_Config extends EE_Config_Base
2931 2931
 {
2932 2932
 
2933
-    public $display_status_banner;
2933
+	public $display_status_banner;
2934 2934
 
2935
-    public $display_description;
2935
+	public $display_description;
2936 2936
 
2937
-    public $display_ticket_selector;
2937
+	public $display_ticket_selector;
2938 2938
 
2939
-    public $display_datetimes;
2939
+	public $display_datetimes;
2940 2940
 
2941
-    public $display_venue;
2941
+	public $display_venue;
2942 2942
 
2943
-    public $display_expired_events;
2943
+	public $display_expired_events;
2944 2944
 
2945
-    public $use_sortable_display_order;
2945
+	public $use_sortable_display_order;
2946 2946
 
2947
-    public $display_order_tickets;
2947
+	public $display_order_tickets;
2948 2948
 
2949
-    public $display_order_datetimes;
2949
+	public $display_order_datetimes;
2950 2950
 
2951
-    public $display_order_event;
2951
+	public $display_order_event;
2952 2952
 
2953
-    public $display_order_venue;
2953
+	public $display_order_venue;
2954 2954
 
2955 2955
 
2956
-    /**
2957
-     *    class constructor
2958
-     */
2959
-    public function __construct()
2960
-    {
2961
-        $this->display_status_banner = 0;
2962
-        $this->display_description = 1;
2963
-        $this->display_ticket_selector = 0;
2964
-        $this->display_datetimes = 1;
2965
-        $this->display_venue = 0;
2966
-        $this->display_expired_events = 0;
2967
-        $this->use_sortable_display_order = false;
2968
-        $this->display_order_tickets = 100;
2969
-        $this->display_order_datetimes = 110;
2970
-        $this->display_order_event = 120;
2971
-        $this->display_order_venue = 130;
2972
-    }
2956
+	/**
2957
+	 *    class constructor
2958
+	 */
2959
+	public function __construct()
2960
+	{
2961
+		$this->display_status_banner = 0;
2962
+		$this->display_description = 1;
2963
+		$this->display_ticket_selector = 0;
2964
+		$this->display_datetimes = 1;
2965
+		$this->display_venue = 0;
2966
+		$this->display_expired_events = 0;
2967
+		$this->use_sortable_display_order = false;
2968
+		$this->display_order_tickets = 100;
2969
+		$this->display_order_datetimes = 110;
2970
+		$this->display_order_event = 120;
2971
+		$this->display_order_venue = 130;
2972
+	}
2973 2973
 }
2974 2974
 
2975 2975
 /**
@@ -2978,34 +2978,34 @@  discard block
 block discarded – undo
2978 2978
 class EE_Event_Single_Config extends EE_Config_Base
2979 2979
 {
2980 2980
 
2981
-    public $display_status_banner_single;
2981
+	public $display_status_banner_single;
2982 2982
 
2983
-    public $display_venue;
2983
+	public $display_venue;
2984 2984
 
2985
-    public $use_sortable_display_order;
2985
+	public $use_sortable_display_order;
2986 2986
 
2987
-    public $display_order_tickets;
2987
+	public $display_order_tickets;
2988 2988
 
2989
-    public $display_order_datetimes;
2989
+	public $display_order_datetimes;
2990 2990
 
2991
-    public $display_order_event;
2991
+	public $display_order_event;
2992 2992
 
2993
-    public $display_order_venue;
2993
+	public $display_order_venue;
2994 2994
 
2995 2995
 
2996
-    /**
2997
-     *    class constructor
2998
-     */
2999
-    public function __construct()
3000
-    {
3001
-        $this->display_status_banner_single = 0;
3002
-        $this->display_venue = 1;
3003
-        $this->use_sortable_display_order = false;
3004
-        $this->display_order_tickets = 100;
3005
-        $this->display_order_datetimes = 110;
3006
-        $this->display_order_event = 120;
3007
-        $this->display_order_venue = 130;
3008
-    }
2996
+	/**
2997
+	 *    class constructor
2998
+	 */
2999
+	public function __construct()
3000
+	{
3001
+		$this->display_status_banner_single = 0;
3002
+		$this->display_venue = 1;
3003
+		$this->use_sortable_display_order = false;
3004
+		$this->display_order_tickets = 100;
3005
+		$this->display_order_datetimes = 110;
3006
+		$this->display_order_event = 120;
3007
+		$this->display_order_venue = 130;
3008
+	}
3009 3009
 }
3010 3010
 
3011 3011
 /**
@@ -3014,172 +3014,172 @@  discard block
 block discarded – undo
3014 3014
 class EE_Ticket_Selector_Config extends EE_Config_Base
3015 3015
 {
3016 3016
 
3017
-    /**
3018
-     * constant to indicate that a datetime selector should NEVER be shown for ticket selectors
3019
-     */
3020
-    const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector';
3021
-
3022
-    /**
3023
-     * constant to indicate that a datetime selector should only be shown for ticket selectors
3024
-     * when the number of datetimes for the event matches the value set for $datetime_selector_threshold
3025
-     */
3026
-    const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector';
3027
-
3028
-    /**
3029
-     * @var boolean $show_ticket_sale_columns
3030
-     */
3031
-    public $show_ticket_sale_columns;
3032
-
3033
-    /**
3034
-     * @var boolean $show_ticket_details
3035
-     */
3036
-    public $show_ticket_details;
3037
-
3038
-    /**
3039
-     * @var boolean $show_expired_tickets
3040
-     */
3041
-    public $show_expired_tickets;
3042
-
3043
-    /**
3044
-     * whether or not to display a dropdown box populated with event datetimes
3045
-     * that toggles which tickets are displayed for a ticket selector.
3046
-     * uses one of the *_DATETIME_SELECTOR constants defined above
3047
-     *
3048
-     * @var string $show_datetime_selector
3049
-     */
3050
-    private $show_datetime_selector = 'no_datetime_selector';
3051
-
3052
-    /**
3053
-     * the number of datetimes an event has to have before conditionally displaying a datetime selector
3054
-     *
3055
-     * @var int $datetime_selector_threshold
3056
-     */
3057
-    private $datetime_selector_threshold = 3;
3058
-
3059
-    /**
3060
-     * determines the maximum number of "checked" dates in the date and time filter
3061
-     *
3062
-     * @var int $datetime_selector_checked
3063
-     */
3064
-    private $datetime_selector_max_checked = 10;
3065
-
3066
-
3067
-    /**
3068
-     *    class constructor
3069
-     */
3070
-    public function __construct()
3071
-    {
3072
-        $this->show_ticket_sale_columns = true;
3073
-        $this->show_ticket_details = true;
3074
-        $this->show_expired_tickets = true;
3075
-        $this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3076
-        $this->datetime_selector_threshold = 3;
3077
-        $this->datetime_selector_max_checked = 10;
3078
-    }
3079
-
3080
-
3081
-    /**
3082
-     * returns true if a datetime selector should be displayed
3083
-     *
3084
-     * @param array $datetimes
3085
-     * @return bool
3086
-     */
3087
-    public function showDatetimeSelector(array $datetimes)
3088
-    {
3089
-        // if the settings are NOT: don't show OR below threshold, THEN active = true
3090
-        return ! (
3091
-            $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
3092
-            || (
3093
-                $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR
3094
-                && count($datetimes) < $this->getDatetimeSelectorThreshold()
3095
-            )
3096
-        );
3097
-    }
3098
-
3099
-
3100
-    /**
3101
-     * @return string
3102
-     */
3103
-    public function getShowDatetimeSelector()
3104
-    {
3105
-        return $this->show_datetime_selector;
3106
-    }
3107
-
3108
-
3109
-    /**
3110
-     * @param bool $keys_only
3111
-     * @return array
3112
-     */
3113
-    public function getShowDatetimeSelectorOptions($keys_only = true)
3114
-    {
3115
-        return $keys_only
3116
-            ? array(
3117
-                \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
3118
-                \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
3119
-            )
3120
-            : array(
3121
-                \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__(
3122
-                    'Do not show date & time filter',
3123
-                    'event_espresso'
3124
-                ),
3125
-                \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR  => esc_html__(
3126
-                    'Maybe show date & time filter',
3127
-                    'event_espresso'
3128
-                ),
3129
-            );
3130
-    }
3131
-
3132
-
3133
-    /**
3134
-     * @param string $show_datetime_selector
3135
-     */
3136
-    public function setShowDatetimeSelector($show_datetime_selector)
3137
-    {
3138
-        $this->show_datetime_selector = in_array(
3139
-            $show_datetime_selector,
3140
-            $this->getShowDatetimeSelectorOptions(),
3141
-            true
3142
-        )
3143
-            ? $show_datetime_selector
3144
-            : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3145
-    }
3146
-
3147
-
3148
-    /**
3149
-     * @return int
3150
-     */
3151
-    public function getDatetimeSelectorThreshold()
3152
-    {
3153
-        return $this->datetime_selector_threshold;
3154
-    }
3155
-
3156
-
3157
-    /**
3158
-     * @param int $datetime_selector_threshold
3159
-     */
3160
-    public function setDatetimeSelectorThreshold($datetime_selector_threshold)
3161
-    {
3162
-        $datetime_selector_threshold = absint($datetime_selector_threshold);
3163
-        $this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3;
3164
-    }
3165
-
3166
-
3167
-    /**
3168
-     * @return int
3169
-     */
3170
-    public function getDatetimeSelectorMaxChecked()
3171
-    {
3172
-        return $this->datetime_selector_max_checked;
3173
-    }
3174
-
3175
-
3176
-    /**
3177
-     * @param int $datetime_selector_max_checked
3178
-     */
3179
-    public function setDatetimeSelectorMaxChecked($datetime_selector_max_checked)
3180
-    {
3181
-        $this->datetime_selector_max_checked = absint($datetime_selector_max_checked);
3182
-    }
3017
+	/**
3018
+	 * constant to indicate that a datetime selector should NEVER be shown for ticket selectors
3019
+	 */
3020
+	const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector';
3021
+
3022
+	/**
3023
+	 * constant to indicate that a datetime selector should only be shown for ticket selectors
3024
+	 * when the number of datetimes for the event matches the value set for $datetime_selector_threshold
3025
+	 */
3026
+	const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector';
3027
+
3028
+	/**
3029
+	 * @var boolean $show_ticket_sale_columns
3030
+	 */
3031
+	public $show_ticket_sale_columns;
3032
+
3033
+	/**
3034
+	 * @var boolean $show_ticket_details
3035
+	 */
3036
+	public $show_ticket_details;
3037
+
3038
+	/**
3039
+	 * @var boolean $show_expired_tickets
3040
+	 */
3041
+	public $show_expired_tickets;
3042
+
3043
+	/**
3044
+	 * whether or not to display a dropdown box populated with event datetimes
3045
+	 * that toggles which tickets are displayed for a ticket selector.
3046
+	 * uses one of the *_DATETIME_SELECTOR constants defined above
3047
+	 *
3048
+	 * @var string $show_datetime_selector
3049
+	 */
3050
+	private $show_datetime_selector = 'no_datetime_selector';
3051
+
3052
+	/**
3053
+	 * the number of datetimes an event has to have before conditionally displaying a datetime selector
3054
+	 *
3055
+	 * @var int $datetime_selector_threshold
3056
+	 */
3057
+	private $datetime_selector_threshold = 3;
3058
+
3059
+	/**
3060
+	 * determines the maximum number of "checked" dates in the date and time filter
3061
+	 *
3062
+	 * @var int $datetime_selector_checked
3063
+	 */
3064
+	private $datetime_selector_max_checked = 10;
3065
+
3066
+
3067
+	/**
3068
+	 *    class constructor
3069
+	 */
3070
+	public function __construct()
3071
+	{
3072
+		$this->show_ticket_sale_columns = true;
3073
+		$this->show_ticket_details = true;
3074
+		$this->show_expired_tickets = true;
3075
+		$this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3076
+		$this->datetime_selector_threshold = 3;
3077
+		$this->datetime_selector_max_checked = 10;
3078
+	}
3079
+
3080
+
3081
+	/**
3082
+	 * returns true if a datetime selector should be displayed
3083
+	 *
3084
+	 * @param array $datetimes
3085
+	 * @return bool
3086
+	 */
3087
+	public function showDatetimeSelector(array $datetimes)
3088
+	{
3089
+		// if the settings are NOT: don't show OR below threshold, THEN active = true
3090
+		return ! (
3091
+			$this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
3092
+			|| (
3093
+				$this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR
3094
+				&& count($datetimes) < $this->getDatetimeSelectorThreshold()
3095
+			)
3096
+		);
3097
+	}
3098
+
3099
+
3100
+	/**
3101
+	 * @return string
3102
+	 */
3103
+	public function getShowDatetimeSelector()
3104
+	{
3105
+		return $this->show_datetime_selector;
3106
+	}
3107
+
3108
+
3109
+	/**
3110
+	 * @param bool $keys_only
3111
+	 * @return array
3112
+	 */
3113
+	public function getShowDatetimeSelectorOptions($keys_only = true)
3114
+	{
3115
+		return $keys_only
3116
+			? array(
3117
+				\EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
3118
+				\EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
3119
+			)
3120
+			: array(
3121
+				\EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__(
3122
+					'Do not show date & time filter',
3123
+					'event_espresso'
3124
+				),
3125
+				\EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR  => esc_html__(
3126
+					'Maybe show date & time filter',
3127
+					'event_espresso'
3128
+				),
3129
+			);
3130
+	}
3131
+
3132
+
3133
+	/**
3134
+	 * @param string $show_datetime_selector
3135
+	 */
3136
+	public function setShowDatetimeSelector($show_datetime_selector)
3137
+	{
3138
+		$this->show_datetime_selector = in_array(
3139
+			$show_datetime_selector,
3140
+			$this->getShowDatetimeSelectorOptions(),
3141
+			true
3142
+		)
3143
+			? $show_datetime_selector
3144
+			: \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3145
+	}
3146
+
3147
+
3148
+	/**
3149
+	 * @return int
3150
+	 */
3151
+	public function getDatetimeSelectorThreshold()
3152
+	{
3153
+		return $this->datetime_selector_threshold;
3154
+	}
3155
+
3156
+
3157
+	/**
3158
+	 * @param int $datetime_selector_threshold
3159
+	 */
3160
+	public function setDatetimeSelectorThreshold($datetime_selector_threshold)
3161
+	{
3162
+		$datetime_selector_threshold = absint($datetime_selector_threshold);
3163
+		$this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3;
3164
+	}
3165
+
3166
+
3167
+	/**
3168
+	 * @return int
3169
+	 */
3170
+	public function getDatetimeSelectorMaxChecked()
3171
+	{
3172
+		return $this->datetime_selector_max_checked;
3173
+	}
3174
+
3175
+
3176
+	/**
3177
+	 * @param int $datetime_selector_max_checked
3178
+	 */
3179
+	public function setDatetimeSelectorMaxChecked($datetime_selector_max_checked)
3180
+	{
3181
+		$this->datetime_selector_max_checked = absint($datetime_selector_max_checked);
3182
+	}
3183 3183
 }
3184 3184
 
3185 3185
 /**
@@ -3192,87 +3192,87 @@  discard block
 block discarded – undo
3192 3192
 class EE_Environment_Config extends EE_Config_Base
3193 3193
 {
3194 3194
 
3195
-    /**
3196
-     * Hold any php environment variables that we want to track.
3197
-     *
3198
-     * @var stdClass;
3199
-     */
3200
-    public $php;
3201
-
3202
-
3203
-    /**
3204
-     *    constructor
3205
-     */
3206
-    public function __construct()
3207
-    {
3208
-        $this->php = new stdClass();
3209
-        $this->_set_php_values();
3210
-    }
3211
-
3212
-
3213
-    /**
3214
-     * This sets the php environment variables.
3215
-     *
3216
-     * @since 4.4.0
3217
-     * @return void
3218
-     */
3219
-    protected function _set_php_values()
3220
-    {
3221
-        $this->php->max_input_vars = ini_get('max_input_vars');
3222
-        $this->php->version = phpversion();
3223
-    }
3224
-
3225
-
3226
-    /**
3227
-     * helper method for determining whether input_count is
3228
-     * reaching the potential maximum the server can handle
3229
-     * according to max_input_vars
3230
-     *
3231
-     * @param int   $input_count the count of input vars.
3232
-     * @return array {
3233
-     *                           An array that represents whether available space and if no available space the error
3234
-     *                           message.
3235
-     * @type bool   $has_space   whether more inputs can be added.
3236
-     * @type string $msg         Any message to be displayed.
3237
-     *                           }
3238
-     */
3239
-    public function max_input_vars_limit_check($input_count = 0)
3240
-    {
3241
-        if (
3242
-            ! empty($this->php->max_input_vars)
3243
-            && ($input_count >= $this->php->max_input_vars)
3244
-        ) {
3245
-            // check the server setting because the config value could be stale
3246
-            $max_input_vars = ini_get('max_input_vars');
3247
-            if ($input_count >= $max_input_vars) {
3248
-                return sprintf(
3249
-                    esc_html__(
3250
-                        'The maximum number of inputs on this page has been exceeded. You cannot make edits to this page because of your server\'s PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.%1$sPlease contact your web host and ask them to raise the "max_input_vars" limit.',
3251
-                        'event_espresso'
3252
-                    ),
3253
-                    '<br>',
3254
-                    $input_count,
3255
-                    $max_input_vars
3256
-                );
3257
-            } else {
3258
-                return '';
3259
-            }
3260
-        } else {
3261
-            return '';
3262
-        }
3263
-    }
3264
-
3265
-
3266
-    /**
3267
-     * The purpose of this method is just to force rechecking php values so if they've changed, they get updated.
3268
-     *
3269
-     * @since 4.4.1
3270
-     * @return void
3271
-     */
3272
-    public function recheck_values()
3273
-    {
3274
-        $this->_set_php_values();
3275
-    }
3195
+	/**
3196
+	 * Hold any php environment variables that we want to track.
3197
+	 *
3198
+	 * @var stdClass;
3199
+	 */
3200
+	public $php;
3201
+
3202
+
3203
+	/**
3204
+	 *    constructor
3205
+	 */
3206
+	public function __construct()
3207
+	{
3208
+		$this->php = new stdClass();
3209
+		$this->_set_php_values();
3210
+	}
3211
+
3212
+
3213
+	/**
3214
+	 * This sets the php environment variables.
3215
+	 *
3216
+	 * @since 4.4.0
3217
+	 * @return void
3218
+	 */
3219
+	protected function _set_php_values()
3220
+	{
3221
+		$this->php->max_input_vars = ini_get('max_input_vars');
3222
+		$this->php->version = phpversion();
3223
+	}
3224
+
3225
+
3226
+	/**
3227
+	 * helper method for determining whether input_count is
3228
+	 * reaching the potential maximum the server can handle
3229
+	 * according to max_input_vars
3230
+	 *
3231
+	 * @param int   $input_count the count of input vars.
3232
+	 * @return array {
3233
+	 *                           An array that represents whether available space and if no available space the error
3234
+	 *                           message.
3235
+	 * @type bool   $has_space   whether more inputs can be added.
3236
+	 * @type string $msg         Any message to be displayed.
3237
+	 *                           }
3238
+	 */
3239
+	public function max_input_vars_limit_check($input_count = 0)
3240
+	{
3241
+		if (
3242
+			! empty($this->php->max_input_vars)
3243
+			&& ($input_count >= $this->php->max_input_vars)
3244
+		) {
3245
+			// check the server setting because the config value could be stale
3246
+			$max_input_vars = ini_get('max_input_vars');
3247
+			if ($input_count >= $max_input_vars) {
3248
+				return sprintf(
3249
+					esc_html__(
3250
+						'The maximum number of inputs on this page has been exceeded. You cannot make edits to this page because of your server\'s PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.%1$sPlease contact your web host and ask them to raise the "max_input_vars" limit.',
3251
+						'event_espresso'
3252
+					),
3253
+					'<br>',
3254
+					$input_count,
3255
+					$max_input_vars
3256
+				);
3257
+			} else {
3258
+				return '';
3259
+			}
3260
+		} else {
3261
+			return '';
3262
+		}
3263
+	}
3264
+
3265
+
3266
+	/**
3267
+	 * The purpose of this method is just to force rechecking php values so if they've changed, they get updated.
3268
+	 *
3269
+	 * @since 4.4.1
3270
+	 * @return void
3271
+	 */
3272
+	public function recheck_values()
3273
+	{
3274
+		$this->_set_php_values();
3275
+	}
3276 3276
 }
3277 3277
 
3278 3278
 /**
@@ -3285,21 +3285,21 @@  discard block
 block discarded – undo
3285 3285
 class EE_Tax_Config extends EE_Config_Base
3286 3286
 {
3287 3287
 
3288
-    /*
3288
+	/*
3289 3289
      * flag to indicate whether or not to display ticket prices with the taxes included
3290 3290
      *
3291 3291
      * @var boolean $prices_displayed_including_taxes
3292 3292
      */
3293
-    public $prices_displayed_including_taxes;
3293
+	public $prices_displayed_including_taxes;
3294 3294
 
3295 3295
 
3296
-    /**
3297
-     *    class constructor
3298
-     */
3299
-    public function __construct()
3300
-    {
3301
-        $this->prices_displayed_including_taxes = true;
3302
-    }
3296
+	/**
3297
+	 *    class constructor
3298
+	 */
3299
+	public function __construct()
3300
+	{
3301
+		$this->prices_displayed_including_taxes = true;
3302
+	}
3303 3303
 }
3304 3304
 
3305 3305
 /**
@@ -3313,19 +3313,19 @@  discard block
 block discarded – undo
3313 3313
 class EE_Messages_Config extends EE_Config_Base
3314 3314
 {
3315 3315
 
3316
-    /**
3317
-     * This is an integer representing the deletion threshold in months for when old messages will get deleted.
3318
-     * A value of 0 represents never deleting.  Default is 0.
3319
-     *
3320
-     * @var integer
3321
-     */
3322
-    public $delete_threshold;
3316
+	/**
3317
+	 * This is an integer representing the deletion threshold in months for when old messages will get deleted.
3318
+	 * A value of 0 represents never deleting.  Default is 0.
3319
+	 *
3320
+	 * @var integer
3321
+	 */
3322
+	public $delete_threshold;
3323 3323
 
3324 3324
 
3325
-    public function __construct()
3326
-    {
3327
-        $this->delete_threshold = 0;
3328
-    }
3325
+	public function __construct()
3326
+	{
3327
+		$this->delete_threshold = 0;
3328
+	}
3329 3329
 }
3330 3330
 
3331 3331
 /**
@@ -3336,31 +3336,31 @@  discard block
 block discarded – undo
3336 3336
 class EE_Gateway_Config extends EE_Config_Base
3337 3337
 {
3338 3338
 
3339
-    /**
3340
-     * Array with keys that are payment gateways slugs, and values are arrays
3341
-     * with any config info the gateway wants to store
3342
-     *
3343
-     * @var array
3344
-     */
3345
-    public $payment_settings;
3346
-
3347
-    /**
3348
-     * Where keys are gateway slugs, and values are booleans indicating whether or not
3349
-     * the gateway is stored in the uploads directory
3350
-     *
3351
-     * @var array
3352
-     */
3353
-    public $active_gateways;
3354
-
3355
-
3356
-    /**
3357
-     *    class constructor
3358
-     *
3359
-     * @deprecated
3360
-     */
3361
-    public function __construct()
3362
-    {
3363
-        $this->payment_settings = array();
3364
-        $this->active_gateways = array('Invoice' => false);
3365
-    }
3339
+	/**
3340
+	 * Array with keys that are payment gateways slugs, and values are arrays
3341
+	 * with any config info the gateway wants to store
3342
+	 *
3343
+	 * @var array
3344
+	 */
3345
+	public $payment_settings;
3346
+
3347
+	/**
3348
+	 * Where keys are gateway slugs, and values are booleans indicating whether or not
3349
+	 * the gateway is stored in the uploads directory
3350
+	 *
3351
+	 * @var array
3352
+	 */
3353
+	public $active_gateways;
3354
+
3355
+
3356
+	/**
3357
+	 *    class constructor
3358
+	 *
3359
+	 * @deprecated
3360
+	 */
3361
+	public function __construct()
3362
+	{
3363
+		$this->payment_settings = array();
3364
+		$this->active_gateways = array('Invoice' => false);
3365
+	}
3366 3366
 }
Please login to merge, or discard this patch.
Spacing   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
     public static function instance()
146 146
     {
147 147
         // check if class object is instantiated, and instantiated properly
148
-        if (! self::$_instance instanceof EE_Config) {
148
+        if ( ! self::$_instance instanceof EE_Config) {
149 149
             self::$_instance = new self();
150 150
         }
151 151
         return self::$_instance;
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
                 $this
284 284
             );
285 285
             if (is_object($settings) && property_exists($this, $config)) {
286
-                $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
286
+                $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__'.$config, $settings);
287 287
                 // call configs populate method to ensure any defaults are set for empty values.
288 288
                 if (method_exists($settings, 'populate')) {
289 289
                     $this->{$config}->populate();
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
                         break;
557 557
                     // TEST #2 : check that settings section exists
558 558
                     case 2:
559
-                        if (! isset($this->{$section})) {
559
+                        if ( ! isset($this->{$section})) {
560 560
                             if ($display_errors) {
561 561
                                 throw new EE_Error(
562 562
                                     sprintf(
@@ -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)) {
@@ -809,7 +809,7 @@  discard block
 block discarded – undo
809 809
         }
810 810
         $config_option_name = $this->_generate_config_option_name($section, $name);
811 811
         // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
812
-        if (! isset($this->_addon_option_names[ $config_option_name ])) {
812
+        if ( ! isset($this->_addon_option_names[$config_option_name])) {
813 813
             // save new config to db
814 814
             if ($this->set_config($section, $name, $config_class, $config_obj)) {
815 815
                 return true;
@@ -835,7 +835,7 @@  discard block
 block discarded – undo
835 835
                             'event_espresso'
836 836
                         ),
837 837
                         $config_class,
838
-                        'EE_Config->' . $section . '->' . $name
838
+                        'EE_Config->'.$section.'->'.$name
839 839
                     ),
840 840
                     __FILE__,
841 841
                     __FUNCTION__,
@@ -861,7 +861,7 @@  discard block
 block discarded – undo
861 861
         // ensure config class is set to something
862 862
         $config_class = $this->_set_config_class($config_class, $name);
863 863
         // run tests 1-4, 6 and 7 to verify that all params have been set
864
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
864
+        if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
865 865
             return null;
866 866
         }
867 867
         // now test if the requested config object exists, but suppress errors
@@ -906,7 +906,7 @@  discard block
 block discarded – undo
906 906
         // retrieve the wp-option for this config class.
907 907
         $config_option = maybe_unserialize(get_option($config_option_name, array()));
908 908
         if (empty($config_option)) {
909
-            EE_Config::log($config_option_name . '-NOT-FOUND');
909
+            EE_Config::log($config_option_name.'-NOT-FOUND');
910 910
         }
911 911
         return $config_option;
912 912
     }
@@ -924,7 +924,7 @@  discard block
 block discarded – undo
924 924
             // copy incoming $_REQUEST and sanitize it so we can save it
925 925
             $_request = $_REQUEST;
926 926
             array_walk_recursive($_request, 'sanitize_text_field');
927
-            $config_log[ (string) microtime(true) ] = array(
927
+            $config_log[(string) microtime(true)] = array(
928 928
                 'config_name' => $config_option_name,
929 929
                 'request'     => $_request,
930 930
             );
@@ -939,7 +939,7 @@  discard block
 block discarded – undo
939 939
      */
940 940
     public static function trim_log()
941 941
     {
942
-        if (! EE_Config::logging_enabled()) {
942
+        if ( ! EE_Config::logging_enabled()) {
943 943
             return;
944 944
         }
945 945
         $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
@@ -963,7 +963,7 @@  discard block
 block discarded – undo
963 963
     public static function get_page_for_posts()
964 964
     {
965 965
         $page_for_posts = get_option('page_for_posts');
966
-        if (! $page_for_posts) {
966
+        if ( ! $page_for_posts) {
967 967
             return 'posts';
968 968
         }
969 969
         /** @type WPDB $wpdb */
@@ -1021,13 +1021,13 @@  discard block
 block discarded – undo
1021 1021
             )
1022 1022
         ) {
1023 1023
             // grab list of installed widgets
1024
-            $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1024
+            $widgets_to_register = glob(EE_WIDGETS.'*', GLOB_ONLYDIR);
1025 1025
             // filter list of modules to register
1026 1026
             $widgets_to_register = apply_filters(
1027 1027
                 'FHEE__EE_Config__register_widgets__widgets_to_register',
1028 1028
                 $widgets_to_register
1029 1029
             );
1030
-            if (! empty($widgets_to_register)) {
1030
+            if ( ! empty($widgets_to_register)) {
1031 1031
                 // cycle thru widget folders
1032 1032
                 foreach ($widgets_to_register as $widget_path) {
1033 1033
                     // add to list of installed widget modules
@@ -1077,31 +1077,31 @@  discard block
 block discarded – undo
1077 1077
         // create classname from widget directory name
1078 1078
         $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1079 1079
         // add class prefix
1080
-        $widget_class = 'EEW_' . $widget;
1080
+        $widget_class = 'EEW_'.$widget;
1081 1081
         // does the widget exist ?
1082
-        if (! is_readable($widget_path . '/' . $widget_class . $widget_ext)) {
1082
+        if ( ! is_readable($widget_path.'/'.$widget_class.$widget_ext)) {
1083 1083
             $msg = sprintf(
1084 1084
                 __(
1085 1085
                     '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',
1086 1086
                     'event_espresso'
1087 1087
                 ),
1088 1088
                 $widget_class,
1089
-                $widget_path . '/' . $widget_class . $widget_ext
1089
+                $widget_path.'/'.$widget_class.$widget_ext
1090 1090
             );
1091
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1091
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1092 1092
             return;
1093 1093
         }
1094 1094
         // load the widget class file
1095
-        require_once($widget_path . '/' . $widget_class . $widget_ext);
1095
+        require_once($widget_path.'/'.$widget_class.$widget_ext);
1096 1096
         // verify that class exists
1097
-        if (! class_exists($widget_class)) {
1097
+        if ( ! class_exists($widget_class)) {
1098 1098
             $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1099
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1099
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1100 1100
             return;
1101 1101
         }
1102 1102
         register_widget($widget_class);
1103 1103
         // add to array of registered widgets
1104
-        EE_Registry::instance()->widgets->{$widget_class} = $widget_path . '/' . $widget_class . $widget_ext;
1104
+        EE_Registry::instance()->widgets->{$widget_class} = $widget_path.'/'.$widget_class.$widget_ext;
1105 1105
     }
1106 1106
 
1107 1107
 
@@ -1114,19 +1114,19 @@  discard block
 block discarded – undo
1114 1114
     private function _register_modules()
1115 1115
     {
1116 1116
         // grab list of installed modules
1117
-        $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1117
+        $modules_to_register = glob(EE_MODULES.'*', GLOB_ONLYDIR);
1118 1118
         // filter list of modules to register
1119 1119
         $modules_to_register = apply_filters(
1120 1120
             'FHEE__EE_Config__register_modules__modules_to_register',
1121 1121
             $modules_to_register
1122 1122
         );
1123
-        if (! empty($modules_to_register)) {
1123
+        if ( ! empty($modules_to_register)) {
1124 1124
             // loop through folders
1125 1125
             foreach ($modules_to_register as $module_path) {
1126 1126
                 /**TEMPORARILY EXCLUDE gateways from modules for time being**/
1127 1127
                 if (
1128
-                    $module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1129
-                    && $module_path !== EE_MODULES . 'gateways'
1128
+                    $module_path !== EE_MODULES.'zzz-copy-this-module-template'
1129
+                    && $module_path !== EE_MODULES.'gateways'
1130 1130
                 ) {
1131 1131
                     // add to list of installed modules
1132 1132
                     EE_Config::register_module($module_path);
@@ -1163,25 +1163,25 @@  discard block
 block discarded – undo
1163 1163
             // remove last segment
1164 1164
             array_pop($module_path);
1165 1165
             // glue it back together
1166
-            $module_path = implode('/', $module_path) . '/';
1166
+            $module_path = implode('/', $module_path).'/';
1167 1167
             // take first segment from file name pieces and sanitize it
1168 1168
             $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1169 1169
             // ensure class prefix is added
1170
-            $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1170
+            $module_class = strpos($module, 'EED_') !== 0 ? 'EED_'.$module : $module;
1171 1171
         } else {
1172 1172
             // we need to generate the filename based off of the folder name
1173 1173
             // grab and sanitize module name
1174 1174
             $module = strtolower(basename($module_path));
1175 1175
             $module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1176 1176
             // like trailingslashit()
1177
-            $module_path = rtrim($module_path, '/') . '/';
1177
+            $module_path = rtrim($module_path, '/').'/';
1178 1178
             // create classname from module directory name
1179 1179
             $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1180 1180
             // add class prefix
1181
-            $module_class = 'EED_' . $module;
1181
+            $module_class = 'EED_'.$module;
1182 1182
         }
1183 1183
         // does the module exist ?
1184
-        if (! is_readable($module_path . '/' . $module_class . $module_ext)) {
1184
+        if ( ! is_readable($module_path.'/'.$module_class.$module_ext)) {
1185 1185
             $msg = sprintf(
1186 1186
                 __(
1187 1187
                     'The requested %s module file could not be found or is not readable due to file permissions.',
@@ -1189,19 +1189,19 @@  discard block
 block discarded – undo
1189 1189
                 ),
1190 1190
                 $module
1191 1191
             );
1192
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1192
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1193 1193
             return false;
1194 1194
         }
1195 1195
         // load the module class file
1196
-        require_once($module_path . $module_class . $module_ext);
1196
+        require_once($module_path.$module_class.$module_ext);
1197 1197
         // verify that class exists
1198
-        if (! class_exists($module_class)) {
1198
+        if ( ! class_exists($module_class)) {
1199 1199
             $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1200
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1200
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1201 1201
             return false;
1202 1202
         }
1203 1203
         // add to array of registered modules
1204
-        EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1204
+        EE_Registry::instance()->modules->{$module_class} = $module_path.$module_class.$module_ext;
1205 1205
         do_action(
1206 1206
             'AHEE__EE_Config__register_module__complete',
1207 1207
             $module_class,
@@ -1252,26 +1252,26 @@  discard block
 block discarded – undo
1252 1252
     {
1253 1253
         do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1254 1254
         $module = str_replace('EED_', '', $module);
1255
-        $module_class = 'EED_' . $module;
1256
-        if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1255
+        $module_class = 'EED_'.$module;
1256
+        if ( ! isset(EE_Registry::instance()->modules->{$module_class})) {
1257 1257
             $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1258
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1258
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1259 1259
             return false;
1260 1260
         }
1261 1261
         if (empty($route)) {
1262 1262
             $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1263
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1263
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1264 1264
             return false;
1265 1265
         }
1266
-        if (! method_exists('EED_' . $module, $method_name)) {
1266
+        if ( ! method_exists('EED_'.$module, $method_name)) {
1267 1267
             $msg = sprintf(
1268 1268
                 __('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1269 1269
                 $route
1270 1270
             );
1271
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1271
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1272 1272
             return false;
1273 1273
         }
1274
-        EE_Config::$_module_route_map[ (string) $key ][ (string) $route ] = array('EED_' . $module, $method_name);
1274
+        EE_Config::$_module_route_map[(string) $key][(string) $route] = array('EED_'.$module, $method_name);
1275 1275
         return true;
1276 1276
     }
1277 1277
 
@@ -1288,8 +1288,8 @@  discard block
 block discarded – undo
1288 1288
     {
1289 1289
         do_action('AHEE__EE_Config__get_route__begin', $route);
1290 1290
         $route = (string) apply_filters('FHEE__EE_Config__get_route', $route);
1291
-        if (isset(EE_Config::$_module_route_map[ $key ][ $route ])) {
1292
-            return EE_Config::$_module_route_map[ $key ][ $route ];
1291
+        if (isset(EE_Config::$_module_route_map[$key][$route])) {
1292
+            return EE_Config::$_module_route_map[$key][$route];
1293 1293
         }
1294 1294
         return null;
1295 1295
     }
@@ -1321,47 +1321,47 @@  discard block
 block discarded – undo
1321 1321
     public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1322 1322
     {
1323 1323
         do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1324
-        if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1324
+        if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1325 1325
             $msg = sprintf(
1326 1326
                 __('The module route %s for this forward has not been registered.', 'event_espresso'),
1327 1327
                 $route
1328 1328
             );
1329
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1329
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1330 1330
             return false;
1331 1331
         }
1332 1332
         if (empty($forward)) {
1333 1333
             $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1334
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1334
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1335 1335
             return false;
1336 1336
         }
1337 1337
         if (is_array($forward)) {
1338
-            if (! isset($forward[1])) {
1338
+            if ( ! isset($forward[1])) {
1339 1339
                 $msg = sprintf(
1340 1340
                     __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1341 1341
                     $route
1342 1342
                 );
1343
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1343
+                EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1344 1344
                 return false;
1345 1345
             }
1346
-            if (! method_exists($forward[0], $forward[1])) {
1346
+            if ( ! method_exists($forward[0], $forward[1])) {
1347 1347
                 $msg = sprintf(
1348 1348
                     __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1349 1349
                     $forward[1],
1350 1350
                     $route
1351 1351
                 );
1352
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1352
+                EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1353 1353
                 return false;
1354 1354
             }
1355
-        } elseif (! function_exists($forward)) {
1355
+        } elseif ( ! function_exists($forward)) {
1356 1356
             $msg = sprintf(
1357 1357
                 __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1358 1358
                 $forward,
1359 1359
                 $route
1360 1360
             );
1361
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1361
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1362 1362
             return false;
1363 1363
         }
1364
-        EE_Config::$_module_forward_map[ $key ][ $route ][ absint($status) ] = $forward;
1364
+        EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward;
1365 1365
         return true;
1366 1366
     }
1367 1367
 
@@ -1379,10 +1379,10 @@  discard block
 block discarded – undo
1379 1379
     public static function get_forward($route = null, $status = 0, $key = 'ee')
1380 1380
     {
1381 1381
         do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1382
-        if (isset(EE_Config::$_module_forward_map[ $key ][ $route ][ $status ])) {
1382
+        if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) {
1383 1383
             return apply_filters(
1384 1384
                 'FHEE__EE_Config__get_forward',
1385
-                EE_Config::$_module_forward_map[ $key ][ $route ][ $status ],
1385
+                EE_Config::$_module_forward_map[$key][$route][$status],
1386 1386
                 $route,
1387 1387
                 $status
1388 1388
             );
@@ -1406,15 +1406,15 @@  discard block
 block discarded – undo
1406 1406
     public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1407 1407
     {
1408 1408
         do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1409
-        if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1409
+        if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1410 1410
             $msg = sprintf(
1411 1411
                 __('The module route %s for this view has not been registered.', 'event_espresso'),
1412 1412
                 $route
1413 1413
             );
1414
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1414
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1415 1415
             return false;
1416 1416
         }
1417
-        if (! is_readable($view)) {
1417
+        if ( ! is_readable($view)) {
1418 1418
             $msg = sprintf(
1419 1419
                 __(
1420 1420
                     'The %s view file could not be found or is not readable due to file permissions.',
@@ -1422,10 +1422,10 @@  discard block
 block discarded – undo
1422 1422
                 ),
1423 1423
                 $view
1424 1424
             );
1425
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1425
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1426 1426
             return false;
1427 1427
         }
1428
-        EE_Config::$_module_view_map[ $key ][ $route ][ absint($status) ] = $view;
1428
+        EE_Config::$_module_view_map[$key][$route][absint($status)] = $view;
1429 1429
         return true;
1430 1430
     }
1431 1431
 
@@ -1443,10 +1443,10 @@  discard block
 block discarded – undo
1443 1443
     public static function get_view($route = null, $status = 0, $key = 'ee')
1444 1444
     {
1445 1445
         do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1446
-        if (isset(EE_Config::$_module_view_map[ $key ][ $route ][ $status ])) {
1446
+        if (isset(EE_Config::$_module_view_map[$key][$route][$status])) {
1447 1447
             return apply_filters(
1448 1448
                 'FHEE__EE_Config__get_view',
1449
-                EE_Config::$_module_view_map[ $key ][ $route ][ $status ],
1449
+                EE_Config::$_module_view_map[$key][$route][$status],
1450 1450
                 $route,
1451 1451
                 $status
1452 1452
             );
@@ -1473,7 +1473,7 @@  discard block
 block discarded – undo
1473 1473
     public static function getLegacyShortcodesManager()
1474 1474
     {
1475 1475
 
1476
-        if (! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1476
+        if ( ! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1477 1477
             EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager(
1478 1478
                 EE_Registry::instance()
1479 1479
             );
@@ -1520,7 +1520,7 @@  discard block
 block discarded – undo
1520 1520
      */
1521 1521
     public function get_pretty($property)
1522 1522
     {
1523
-        if (! property_exists($this, $property)) {
1523
+        if ( ! property_exists($this, $property)) {
1524 1524
             throw new EE_Error(
1525 1525
                 sprintf(
1526 1526
                     __(
@@ -1749,11 +1749,11 @@  discard block
 block discarded – undo
1749 1749
      */
1750 1750
     public function reg_page_url()
1751 1751
     {
1752
-        if (! $this->reg_page_url) {
1752
+        if ( ! $this->reg_page_url) {
1753 1753
             $this->reg_page_url = add_query_arg(
1754 1754
                 array('uts' => time()),
1755 1755
                 get_permalink($this->reg_page_id)
1756
-            ) . '#checkout';
1756
+            ).'#checkout';
1757 1757
         }
1758 1758
         return $this->reg_page_url;
1759 1759
     }
@@ -1769,7 +1769,7 @@  discard block
 block discarded – undo
1769 1769
      */
1770 1770
     public function txn_page_url($query_args = array())
1771 1771
     {
1772
-        if (! $this->txn_page_url) {
1772
+        if ( ! $this->txn_page_url) {
1773 1773
             $this->txn_page_url = get_permalink($this->txn_page_id);
1774 1774
         }
1775 1775
         if ($query_args) {
@@ -1790,7 +1790,7 @@  discard block
 block discarded – undo
1790 1790
      */
1791 1791
     public function thank_you_page_url($query_args = array())
1792 1792
     {
1793
-        if (! $this->thank_you_page_url) {
1793
+        if ( ! $this->thank_you_page_url) {
1794 1794
             $this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1795 1795
         }
1796 1796
         if ($query_args) {
@@ -1809,7 +1809,7 @@  discard block
 block discarded – undo
1809 1809
      */
1810 1810
     public function cancel_page_url()
1811 1811
     {
1812
-        if (! $this->cancel_page_url) {
1812
+        if ( ! $this->cancel_page_url) {
1813 1813
             $this->cancel_page_url = get_permalink($this->cancel_page_id);
1814 1814
         }
1815 1815
         return $this->cancel_page_url;
@@ -1852,13 +1852,13 @@  discard block
 block discarded – undo
1852 1852
         $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1853 1853
         $option = self::OPTION_NAME_UXIP;
1854 1854
         // set correct table for query
1855
-        $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1855
+        $table_name = $wpdb->get_blog_prefix($current_main_site_id).'options';
1856 1856
         // rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1857 1857
         // get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1858 1858
         // re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1859 1859
         // this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1860 1860
         // for the purpose of caching.
1861
-        $pre = apply_filters('pre_option_' . $option, false, $option);
1861
+        $pre = apply_filters('pre_option_'.$option, false, $option);
1862 1862
         if (false !== $pre) {
1863 1863
             EE_Core_Config::$ee_ueip_option = $pre;
1864 1864
             return EE_Core_Config::$ee_ueip_option;
@@ -1872,10 +1872,10 @@  discard block
 block discarded – undo
1872 1872
         if (is_object($row)) {
1873 1873
             $value = $row->option_value;
1874 1874
         } else { // option does not exist so use default.
1875
-            EE_Core_Config::$ee_ueip_option =  apply_filters('default_option_' . $option, false, $option);
1875
+            EE_Core_Config::$ee_ueip_option = apply_filters('default_option_'.$option, false, $option);
1876 1876
             return EE_Core_Config::$ee_ueip_option;
1877 1877
         }
1878
-        EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1878
+        EE_Core_Config::$ee_ueip_option = apply_filters('option_'.$option, maybe_unserialize($value), $option);
1879 1879
         return EE_Core_Config::$ee_ueip_option;
1880 1880
     }
1881 1881
 
@@ -2137,30 +2137,30 @@  discard block
 block discarded – undo
2137 2137
             // retrieve the country settings from the db, just in case they have been customized
2138 2138
             $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2139 2139
             if ($country instanceof EE_Country) {
2140
-                $this->code = $country->currency_code();    // currency code: USD, CAD, EUR
2141
-                $this->name = $country->currency_name_single();    // Dollar
2142
-                $this->plural = $country->currency_name_plural();    // Dollars
2143
-                $this->sign = $country->currency_sign();            // currency sign: $
2140
+                $this->code = $country->currency_code(); // currency code: USD, CAD, EUR
2141
+                $this->name = $country->currency_name_single(); // Dollar
2142
+                $this->plural = $country->currency_name_plural(); // Dollars
2143
+                $this->sign = $country->currency_sign(); // currency sign: $
2144 2144
                 $this->sign_b4 = $country->currency_sign_before(
2145
-                );        // currency sign before or after: $TRUE  or  FALSE$
2146
-                $this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2145
+                ); // currency sign before or after: $TRUE  or  FALSE$
2146
+                $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00  3 = 0.000
2147 2147
                 $this->dec_mrk = $country->currency_decimal_mark(
2148
-                );    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2148
+                ); // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2149 2149
                 $this->thsnds = $country->currency_thousands_separator(
2150
-                );    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2150
+                ); // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2151 2151
             }
2152 2152
         }
2153 2153
         // fallback to hardcoded defaults, in case the above failed
2154 2154
         if (empty($this->code)) {
2155 2155
             // set default currency settings
2156
-            $this->code = 'USD';    // currency code: USD, CAD, EUR
2157
-            $this->name = __('Dollar', 'event_espresso');    // Dollar
2158
-            $this->plural = __('Dollars', 'event_espresso');    // Dollars
2159
-            $this->sign = '$';    // currency sign: $
2160
-            $this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2161
-            $this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2162
-            $this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2163
-            $this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2156
+            $this->code = 'USD'; // currency code: USD, CAD, EUR
2157
+            $this->name = __('Dollar', 'event_espresso'); // Dollar
2158
+            $this->plural = __('Dollars', 'event_espresso'); // Dollars
2159
+            $this->sign = '$'; // currency sign: $
2160
+            $this->sign_b4 = true; // currency sign before or after: $TRUE  or  FALSE$
2161
+            $this->dec_plc = 2; // decimal places: 2 = 0.00  3 = 0.000
2162
+            $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2163
+            $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2164 2164
         }
2165 2165
     }
2166 2166
 }
@@ -2429,8 +2429,8 @@  discard block
 block discarded – undo
2429 2429
             $closing_a_tag = '';
2430 2430
             if (function_exists('get_privacy_policy_url')) {
2431 2431
                 $privacy_page_url = get_privacy_policy_url();
2432
-                if (! empty($privacy_page_url)) {
2433
-                    $opening_a_tag = '<a href="' . $privacy_page_url . '" target="_blank">';
2432
+                if ( ! empty($privacy_page_url)) {
2433
+                    $opening_a_tag = '<a href="'.$privacy_page_url.'" target="_blank">';
2434 2434
                     $closing_a_tag = '</a>';
2435 2435
                 }
2436 2436
             }
@@ -2665,7 +2665,7 @@  discard block
 block discarded – undo
2665 2665
     public function log_file_name($reset = false)
2666 2666
     {
2667 2667
         if (empty($this->log_file_name) || $reset) {
2668
-            $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2668
+            $this->log_file_name = sanitize_key('espresso_log_'.md5(uniqid('', true))).'.txt';
2669 2669
             EE_Config::instance()->update_espresso_config(false, false);
2670 2670
         }
2671 2671
         return $this->log_file_name;
@@ -2679,7 +2679,7 @@  discard block
 block discarded – undo
2679 2679
     public function debug_file_name($reset = false)
2680 2680
     {
2681 2681
         if (empty($this->debug_file_name) || $reset) {
2682
-            $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2682
+            $this->debug_file_name = sanitize_key('espresso_debug_'.md5(uniqid('', true))).'.txt';
2683 2683
             EE_Config::instance()->update_espresso_config(false, false);
2684 2684
         }
2685 2685
         return $this->debug_file_name;
@@ -2906,21 +2906,21 @@  discard block
 block discarded – undo
2906 2906
         $this->use_google_maps = true;
2907 2907
         $this->google_map_api_key = '';
2908 2908
         // for event details pages (reg page)
2909
-        $this->event_details_map_width = 585;            // ee_map_width_single
2910
-        $this->event_details_map_height = 362;            // ee_map_height_single
2911
-        $this->event_details_map_zoom = 14;            // ee_map_zoom_single
2912
-        $this->event_details_display_nav = true;            // ee_map_nav_display_single
2913
-        $this->event_details_nav_size = false;            // ee_map_nav_size_single
2914
-        $this->event_details_control_type = 'default';        // ee_map_type_control_single
2915
-        $this->event_details_map_align = 'center';            // ee_map_align_single
2909
+        $this->event_details_map_width = 585; // ee_map_width_single
2910
+        $this->event_details_map_height = 362; // ee_map_height_single
2911
+        $this->event_details_map_zoom = 14; // ee_map_zoom_single
2912
+        $this->event_details_display_nav = true; // ee_map_nav_display_single
2913
+        $this->event_details_nav_size = false; // ee_map_nav_size_single
2914
+        $this->event_details_control_type = 'default'; // ee_map_type_control_single
2915
+        $this->event_details_map_align = 'center'; // ee_map_align_single
2916 2916
         // for event list pages
2917
-        $this->event_list_map_width = 300;            // ee_map_width
2918
-        $this->event_list_map_height = 185;        // ee_map_height
2919
-        $this->event_list_map_zoom = 12;            // ee_map_zoom
2920
-        $this->event_list_display_nav = false;        // ee_map_nav_display
2921
-        $this->event_list_nav_size = true;            // ee_map_nav_size
2922
-        $this->event_list_control_type = 'dropdown';        // ee_map_type_control
2923
-        $this->event_list_map_align = 'center';            // ee_map_align
2917
+        $this->event_list_map_width = 300; // ee_map_width
2918
+        $this->event_list_map_height = 185; // ee_map_height
2919
+        $this->event_list_map_zoom = 12; // ee_map_zoom
2920
+        $this->event_list_display_nav = false; // ee_map_nav_display
2921
+        $this->event_list_nav_size = true; // ee_map_nav_size
2922
+        $this->event_list_control_type = 'dropdown'; // ee_map_type_control
2923
+        $this->event_list_map_align = 'center'; // ee_map_align
2924 2924
     }
2925 2925
 }
2926 2926
 
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   +378 added lines, -378 removed lines patch added patch discarded remove patch
@@ -12,382 +12,382 @@
 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 (
98
-            EE_Registry::instance()->CAP->current_user_can(
99
-                'ee_delete_contacts',
100
-                'espresso_registrations_delete_registration'
101
-            )
102
-        ) {
103
-            $this->_views['trash']['count'] = $this->_admin_page->get_attendees($this->_per_page, true, true);
104
-        }
105
-    }
106
-
107
-
108
-    /**
109
-     * Get count of attendees.
110
-     *
111
-     * @return int
112
-     * @throws EE_Error
113
-     * @throws InvalidArgumentException
114
-     * @throws InvalidDataTypeException
115
-     * @throws InvalidInterfaceException
116
-     */
117
-    protected function _get_attendees_count()
118
-    {
119
-        return EEM_Attendee::instance()->count();
120
-    }
121
-
122
-
123
-    /**
124
-     * Checkbox column
125
-     *
126
-     * @param EE_Attendee $attendee Unable to typehint this method because overrides parent.
127
-     * @return string
128
-     * @throws EE_Error
129
-     */
130
-    public function column_cb($attendee)
131
-    {
132
-        if (! $attendee instanceof EE_Attendee) {
133
-            return '';
134
-        }
135
-        return sprintf(
136
-            '<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />',
137
-            $attendee->ID()
138
-        );
139
-    }
140
-
141
-
142
-    /**
143
-     * ATT_ID column
144
-     *
145
-     * @param EE_Attendee $attendee
146
-     * @return string
147
-     * @throws EE_Error
148
-     */
149
-    public function column_ATT_ID(EE_Attendee $attendee)
150
-    {
151
-        $content = $attendee->ID();
152
-        $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
153
-        $content .= '  <span class="show-on-mobile-view-only">' . $attendee_name . '</span>';
154
-        return $content;
155
-    }
156
-
157
-
158
-    /**
159
-     * ATT_lname column
160
-     *
161
-     * @param EE_Attendee $attendee
162
-     * @return string
163
-     * @throws InvalidArgumentException
164
-     * @throws InvalidDataTypeException
165
-     * @throws InvalidInterfaceException
166
-     * @throws EE_Error
167
-     */
168
-    public function column_ATT_lname(EE_Attendee $attendee)
169
-    {
170
-        // edit attendee link
171
-        $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
172
-            array(
173
-                'action' => 'edit_attendee',
174
-                'post'   => $attendee->ID(),
175
-            ),
176
-            REG_ADMIN_URL
177
-        );
178
-        $name_link = EE_Registry::instance()->CAP->current_user_can(
179
-            'ee_edit_contacts',
180
-            'espresso_registrations_edit_attendee'
181
-        )
182
-            ? '<a href="' . $edit_lnk_url . '" title="'
183
-              . esc_attr__('Edit Contact', 'event_espresso') . '">'
184
-              . $attendee->lname() . '</a>'
185
-            : $attendee->lname();
186
-        return $name_link;
187
-    }
188
-
189
-
190
-    /**
191
-     * ATT_fname column
192
-     *
193
-     * @param EE_Attendee $attendee
194
-     * @return string
195
-     * @throws InvalidArgumentException
196
-     * @throws InvalidDataTypeException
197
-     * @throws InvalidInterfaceException
198
-     * @throws EE_Error
199
-     */
200
-    public function column_ATT_fname(EE_Attendee $attendee)
201
-    {
202
-        // Build row actions
203
-        $actions = array();
204
-        // edit attendee link
205
-        if (
206
-            EE_Registry::instance()->CAP->current_user_can(
207
-                'ee_edit_contacts',
208
-                'espresso_registrations_edit_attendee'
209
-            )
210
-        ) {
211
-            $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
212
-                array(
213
-                    'action' => 'edit_attendee',
214
-                    'post'   => $attendee->ID(),
215
-                ),
216
-                REG_ADMIN_URL
217
-            );
218
-            $actions['edit'] = '<a href="' . $edit_lnk_url . '" title="'
219
-                               . esc_attr__('Edit Contact', 'event_espresso') . '">'
220
-                               . esc_html__('Edit', 'event_espresso') . '</a>';
221
-        }
222
-
223
-        if ($this->_view === 'in_use') {
224
-            // trash attendee link
225
-            if (
226
-                EE_Registry::instance()->CAP->current_user_can(
227
-                    'ee_delete_contacts',
228
-                    'espresso_registrations_trash_attendees'
229
-                )
230
-            ) {
231
-                $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
232
-                    array(
233
-                        'action' => 'trash_attendee',
234
-                        'ATT_ID' => $attendee->ID(),
235
-                    ),
236
-                    REG_ADMIN_URL
237
-                );
238
-                $actions['trash'] = '<a href="' . $trash_lnk_url . '" title="'
239
-                                    . esc_attr__('Move Contact to Trash', 'event_espresso')
240
-                                    . '">' . esc_html__('Trash', 'event_espresso') . '</a>';
241
-            }
242
-        } else {
243
-            if (
244
-                EE_Registry::instance()->CAP->current_user_can(
245
-                    'ee_delete_contacts',
246
-                    'espresso_registrations_restore_attendees'
247
-                )
248
-            ) {
249
-                // restore attendee link
250
-                $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
251
-                    array(
252
-                        'action' => 'restore_attendees',
253
-                        'ATT_ID' => $attendee->ID(),
254
-                    ),
255
-                    REG_ADMIN_URL
256
-                );
257
-                $actions['restore'] = '<a href="' . $restore_lnk_url . '" title="'
258
-                                      . esc_attr__('Restore Contact', 'event_espresso') . '">'
259
-                                      . esc_html__('Restore', 'event_espresso') . '</a>';
260
-            }
261
-        }
262
-
263
-        $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
264
-            array(
265
-                'action' => 'edit_attendee',
266
-                'post'   => $attendee->ID(),
267
-            ),
268
-            REG_ADMIN_URL
269
-        );
270
-        $name_link = EE_Registry::instance()->CAP->current_user_can(
271
-            'ee_edit_contacts',
272
-            'espresso_registrations_edit_attendee'
273
-        )
274
-            ? '<a href="' . $edit_lnk_url . '" title="'
275
-              . esc_attr__('Edit Contact', 'event_espresso') . '">' . $attendee->fname() . '</a>'
276
-            : $attendee->fname();
277
-
278
-        // Return the name contents
279
-        return sprintf('%1$s %2$s', $name_link, $this->row_actions($actions));
280
-    }
281
-
282
-
283
-    /**
284
-     * Email Column
285
-     *
286
-     * @param EE_Attendee $attendee
287
-     * @return string
288
-     * @throws EE_Error
289
-     */
290
-    public function column_ATT_email(EE_Attendee $attendee)
291
-    {
292
-        return '<a href="mailto:' . $attendee->email() . '">' . $attendee->email() . '</a>';
293
-    }
294
-
295
-
296
-    /**
297
-     * Column displaying count of registrations attached to Attendee.
298
-     *
299
-     * @param EE_Attendee $attendee
300
-     * @return string
301
-     * @throws EE_Error
302
-     */
303
-    public function column_Registration_Count(EE_Attendee $attendee)
304
-    {
305
-        $link = EEH_URL::add_query_args_and_nonce(
306
-            array(
307
-                'action' => 'default',
308
-                'ATT_ID' => $attendee->ID(),
309
-            ),
310
-            REG_ADMIN_URL
311
-        );
312
-        return '<a href="' . $link . '">' . $attendee->getCustomSelect('Registration_Count') . '</a>';
313
-    }
314
-
315
-
316
-    /**
317
-     * ATT_address column
318
-     *
319
-     * @param EE_Attendee $attendee
320
-     * @return mixed
321
-     * @throws EE_Error
322
-     */
323
-    public function column_ATT_address(EE_Attendee $attendee)
324
-    {
325
-        return $attendee->address();
326
-    }
327
-
328
-
329
-    /**
330
-     * ATT_city column
331
-     *
332
-     * @param EE_Attendee $attendee
333
-     * @return mixed
334
-     * @throws EE_Error
335
-     */
336
-    public function column_ATT_city(EE_Attendee $attendee)
337
-    {
338
-        return $attendee->city();
339
-    }
340
-
341
-
342
-    /**
343
-     * State Column
344
-     *
345
-     * @param EE_Attendee $attendee
346
-     * @return string
347
-     * @throws EE_Error
348
-     * @throws InvalidArgumentException
349
-     * @throws InvalidDataTypeException
350
-     * @throws InvalidInterfaceException
351
-     */
352
-    public function column_STA_ID(EE_Attendee $attendee)
353
-    {
354
-        $states = EEM_State::instance()->get_all_states();
355
-        $state = isset($states[ $attendee->state_ID() ])
356
-            ? $states[ $attendee->state_ID() ]->get('STA_name')
357
-            : $attendee->state_ID();
358
-        return ! is_numeric($state) ? $state : '';
359
-    }
360
-
361
-
362
-    /**
363
-     * Country Column
364
-     *
365
-     * @param EE_Attendee $attendee
366
-     * @return string
367
-     * @throws EE_Error
368
-     * @throws InvalidArgumentException
369
-     * @throws InvalidDataTypeException
370
-     * @throws InvalidInterfaceException
371
-     */
372
-    public function column_CNT_ISO(EE_Attendee $attendee)
373
-    {
374
-        $countries = EEM_Country::instance()->get_all_countries();
375
-        $country = isset($countries[ $attendee->country_ID() ])
376
-            ? $countries[ $attendee->country_ID() ]->get('CNT_name')
377
-            : $attendee->country_ID();
378
-        return ! is_numeric($country) ? $country : '';
379
-    }
380
-
381
-
382
-    /**
383
-     * Phone Number column
384
-     *
385
-     * @param EE_Attendee $attendee
386
-     * @return mixed
387
-     * @throws EE_Error
388
-     */
389
-    public function column_ATT_phone(EE_Attendee $attendee)
390
-    {
391
-        return $attendee->phone();
392
-    }
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 (
98
+			EE_Registry::instance()->CAP->current_user_can(
99
+				'ee_delete_contacts',
100
+				'espresso_registrations_delete_registration'
101
+			)
102
+		) {
103
+			$this->_views['trash']['count'] = $this->_admin_page->get_attendees($this->_per_page, true, true);
104
+		}
105
+	}
106
+
107
+
108
+	/**
109
+	 * Get count of attendees.
110
+	 *
111
+	 * @return int
112
+	 * @throws EE_Error
113
+	 * @throws InvalidArgumentException
114
+	 * @throws InvalidDataTypeException
115
+	 * @throws InvalidInterfaceException
116
+	 */
117
+	protected function _get_attendees_count()
118
+	{
119
+		return EEM_Attendee::instance()->count();
120
+	}
121
+
122
+
123
+	/**
124
+	 * Checkbox column
125
+	 *
126
+	 * @param EE_Attendee $attendee Unable to typehint this method because overrides parent.
127
+	 * @return string
128
+	 * @throws EE_Error
129
+	 */
130
+	public function column_cb($attendee)
131
+	{
132
+		if (! $attendee instanceof EE_Attendee) {
133
+			return '';
134
+		}
135
+		return sprintf(
136
+			'<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />',
137
+			$attendee->ID()
138
+		);
139
+	}
140
+
141
+
142
+	/**
143
+	 * ATT_ID column
144
+	 *
145
+	 * @param EE_Attendee $attendee
146
+	 * @return string
147
+	 * @throws EE_Error
148
+	 */
149
+	public function column_ATT_ID(EE_Attendee $attendee)
150
+	{
151
+		$content = $attendee->ID();
152
+		$attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
153
+		$content .= '  <span class="show-on-mobile-view-only">' . $attendee_name . '</span>';
154
+		return $content;
155
+	}
156
+
157
+
158
+	/**
159
+	 * ATT_lname column
160
+	 *
161
+	 * @param EE_Attendee $attendee
162
+	 * @return string
163
+	 * @throws InvalidArgumentException
164
+	 * @throws InvalidDataTypeException
165
+	 * @throws InvalidInterfaceException
166
+	 * @throws EE_Error
167
+	 */
168
+	public function column_ATT_lname(EE_Attendee $attendee)
169
+	{
170
+		// edit attendee link
171
+		$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
172
+			array(
173
+				'action' => 'edit_attendee',
174
+				'post'   => $attendee->ID(),
175
+			),
176
+			REG_ADMIN_URL
177
+		);
178
+		$name_link = EE_Registry::instance()->CAP->current_user_can(
179
+			'ee_edit_contacts',
180
+			'espresso_registrations_edit_attendee'
181
+		)
182
+			? '<a href="' . $edit_lnk_url . '" title="'
183
+			  . esc_attr__('Edit Contact', 'event_espresso') . '">'
184
+			  . $attendee->lname() . '</a>'
185
+			: $attendee->lname();
186
+		return $name_link;
187
+	}
188
+
189
+
190
+	/**
191
+	 * ATT_fname column
192
+	 *
193
+	 * @param EE_Attendee $attendee
194
+	 * @return string
195
+	 * @throws InvalidArgumentException
196
+	 * @throws InvalidDataTypeException
197
+	 * @throws InvalidInterfaceException
198
+	 * @throws EE_Error
199
+	 */
200
+	public function column_ATT_fname(EE_Attendee $attendee)
201
+	{
202
+		// Build row actions
203
+		$actions = array();
204
+		// edit attendee link
205
+		if (
206
+			EE_Registry::instance()->CAP->current_user_can(
207
+				'ee_edit_contacts',
208
+				'espresso_registrations_edit_attendee'
209
+			)
210
+		) {
211
+			$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
212
+				array(
213
+					'action' => 'edit_attendee',
214
+					'post'   => $attendee->ID(),
215
+				),
216
+				REG_ADMIN_URL
217
+			);
218
+			$actions['edit'] = '<a href="' . $edit_lnk_url . '" title="'
219
+							   . esc_attr__('Edit Contact', 'event_espresso') . '">'
220
+							   . esc_html__('Edit', 'event_espresso') . '</a>';
221
+		}
222
+
223
+		if ($this->_view === 'in_use') {
224
+			// trash attendee link
225
+			if (
226
+				EE_Registry::instance()->CAP->current_user_can(
227
+					'ee_delete_contacts',
228
+					'espresso_registrations_trash_attendees'
229
+				)
230
+			) {
231
+				$trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
232
+					array(
233
+						'action' => 'trash_attendee',
234
+						'ATT_ID' => $attendee->ID(),
235
+					),
236
+					REG_ADMIN_URL
237
+				);
238
+				$actions['trash'] = '<a href="' . $trash_lnk_url . '" title="'
239
+									. esc_attr__('Move Contact to Trash', 'event_espresso')
240
+									. '">' . esc_html__('Trash', 'event_espresso') . '</a>';
241
+			}
242
+		} else {
243
+			if (
244
+				EE_Registry::instance()->CAP->current_user_can(
245
+					'ee_delete_contacts',
246
+					'espresso_registrations_restore_attendees'
247
+				)
248
+			) {
249
+				// restore attendee link
250
+				$restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
251
+					array(
252
+						'action' => 'restore_attendees',
253
+						'ATT_ID' => $attendee->ID(),
254
+					),
255
+					REG_ADMIN_URL
256
+				);
257
+				$actions['restore'] = '<a href="' . $restore_lnk_url . '" title="'
258
+									  . esc_attr__('Restore Contact', 'event_espresso') . '">'
259
+									  . esc_html__('Restore', 'event_espresso') . '</a>';
260
+			}
261
+		}
262
+
263
+		$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
264
+			array(
265
+				'action' => 'edit_attendee',
266
+				'post'   => $attendee->ID(),
267
+			),
268
+			REG_ADMIN_URL
269
+		);
270
+		$name_link = EE_Registry::instance()->CAP->current_user_can(
271
+			'ee_edit_contacts',
272
+			'espresso_registrations_edit_attendee'
273
+		)
274
+			? '<a href="' . $edit_lnk_url . '" title="'
275
+			  . esc_attr__('Edit Contact', 'event_espresso') . '">' . $attendee->fname() . '</a>'
276
+			: $attendee->fname();
277
+
278
+		// Return the name contents
279
+		return sprintf('%1$s %2$s', $name_link, $this->row_actions($actions));
280
+	}
281
+
282
+
283
+	/**
284
+	 * Email Column
285
+	 *
286
+	 * @param EE_Attendee $attendee
287
+	 * @return string
288
+	 * @throws EE_Error
289
+	 */
290
+	public function column_ATT_email(EE_Attendee $attendee)
291
+	{
292
+		return '<a href="mailto:' . $attendee->email() . '">' . $attendee->email() . '</a>';
293
+	}
294
+
295
+
296
+	/**
297
+	 * Column displaying count of registrations attached to Attendee.
298
+	 *
299
+	 * @param EE_Attendee $attendee
300
+	 * @return string
301
+	 * @throws EE_Error
302
+	 */
303
+	public function column_Registration_Count(EE_Attendee $attendee)
304
+	{
305
+		$link = EEH_URL::add_query_args_and_nonce(
306
+			array(
307
+				'action' => 'default',
308
+				'ATT_ID' => $attendee->ID(),
309
+			),
310
+			REG_ADMIN_URL
311
+		);
312
+		return '<a href="' . $link . '">' . $attendee->getCustomSelect('Registration_Count') . '</a>';
313
+	}
314
+
315
+
316
+	/**
317
+	 * ATT_address column
318
+	 *
319
+	 * @param EE_Attendee $attendee
320
+	 * @return mixed
321
+	 * @throws EE_Error
322
+	 */
323
+	public function column_ATT_address(EE_Attendee $attendee)
324
+	{
325
+		return $attendee->address();
326
+	}
327
+
328
+
329
+	/**
330
+	 * ATT_city column
331
+	 *
332
+	 * @param EE_Attendee $attendee
333
+	 * @return mixed
334
+	 * @throws EE_Error
335
+	 */
336
+	public function column_ATT_city(EE_Attendee $attendee)
337
+	{
338
+		return $attendee->city();
339
+	}
340
+
341
+
342
+	/**
343
+	 * State Column
344
+	 *
345
+	 * @param EE_Attendee $attendee
346
+	 * @return string
347
+	 * @throws EE_Error
348
+	 * @throws InvalidArgumentException
349
+	 * @throws InvalidDataTypeException
350
+	 * @throws InvalidInterfaceException
351
+	 */
352
+	public function column_STA_ID(EE_Attendee $attendee)
353
+	{
354
+		$states = EEM_State::instance()->get_all_states();
355
+		$state = isset($states[ $attendee->state_ID() ])
356
+			? $states[ $attendee->state_ID() ]->get('STA_name')
357
+			: $attendee->state_ID();
358
+		return ! is_numeric($state) ? $state : '';
359
+	}
360
+
361
+
362
+	/**
363
+	 * Country Column
364
+	 *
365
+	 * @param EE_Attendee $attendee
366
+	 * @return string
367
+	 * @throws EE_Error
368
+	 * @throws InvalidArgumentException
369
+	 * @throws InvalidDataTypeException
370
+	 * @throws InvalidInterfaceException
371
+	 */
372
+	public function column_CNT_ISO(EE_Attendee $attendee)
373
+	{
374
+		$countries = EEM_Country::instance()->get_all_countries();
375
+		$country = isset($countries[ $attendee->country_ID() ])
376
+			? $countries[ $attendee->country_ID() ]->get('CNT_name')
377
+			: $attendee->country_ID();
378
+		return ! is_numeric($country) ? $country : '';
379
+	}
380
+
381
+
382
+	/**
383
+	 * Phone Number column
384
+	 *
385
+	 * @param EE_Attendee $attendee
386
+	 * @return mixed
387
+	 * @throws EE_Error
388
+	 */
389
+	public function column_ATT_phone(EE_Attendee $attendee)
390
+	{
391
+		return $attendee->phone();
392
+	}
393 393
 }
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
      */
130 130
     public function column_cb($attendee)
131 131
     {
132
-        if (! $attendee instanceof EE_Attendee) {
132
+        if ( ! $attendee instanceof EE_Attendee) {
133 133
             return '';
134 134
         }
135 135
         return sprintf(
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
     {
151 151
         $content = $attendee->ID();
152 152
         $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
153
-        $content .= '  <span class="show-on-mobile-view-only">' . $attendee_name . '</span>';
153
+        $content .= '  <span class="show-on-mobile-view-only">'.$attendee_name.'</span>';
154 154
         return $content;
155 155
     }
156 156
 
@@ -179,9 +179,9 @@  discard block
 block discarded – undo
179 179
             'ee_edit_contacts',
180 180
             'espresso_registrations_edit_attendee'
181 181
         )
182
-            ? '<a href="' . $edit_lnk_url . '" title="'
183
-              . esc_attr__('Edit Contact', 'event_espresso') . '">'
184
-              . $attendee->lname() . '</a>'
182
+            ? '<a href="'.$edit_lnk_url.'" title="'
183
+              . esc_attr__('Edit Contact', 'event_espresso').'">'
184
+              . $attendee->lname().'</a>'
185 185
             : $attendee->lname();
186 186
         return $name_link;
187 187
     }
@@ -215,9 +215,9 @@  discard block
 block discarded – undo
215 215
                 ),
216 216
                 REG_ADMIN_URL
217 217
             );
218
-            $actions['edit'] = '<a href="' . $edit_lnk_url . '" title="'
219
-                               . esc_attr__('Edit Contact', 'event_espresso') . '">'
220
-                               . esc_html__('Edit', 'event_espresso') . '</a>';
218
+            $actions['edit'] = '<a href="'.$edit_lnk_url.'" title="'
219
+                               . esc_attr__('Edit Contact', 'event_espresso').'">'
220
+                               . esc_html__('Edit', 'event_espresso').'</a>';
221 221
         }
222 222
 
223 223
         if ($this->_view === 'in_use') {
@@ -235,9 +235,9 @@  discard block
 block discarded – undo
235 235
                     ),
236 236
                     REG_ADMIN_URL
237 237
                 );
238
-                $actions['trash'] = '<a href="' . $trash_lnk_url . '" title="'
238
+                $actions['trash'] = '<a href="'.$trash_lnk_url.'" title="'
239 239
                                     . esc_attr__('Move Contact to Trash', 'event_espresso')
240
-                                    . '">' . esc_html__('Trash', 'event_espresso') . '</a>';
240
+                                    . '">'.esc_html__('Trash', 'event_espresso').'</a>';
241 241
             }
242 242
         } else {
243 243
             if (
@@ -254,9 +254,9 @@  discard block
 block discarded – undo
254 254
                     ),
255 255
                     REG_ADMIN_URL
256 256
                 );
257
-                $actions['restore'] = '<a href="' . $restore_lnk_url . '" title="'
258
-                                      . esc_attr__('Restore Contact', 'event_espresso') . '">'
259
-                                      . esc_html__('Restore', 'event_espresso') . '</a>';
257
+                $actions['restore'] = '<a href="'.$restore_lnk_url.'" title="'
258
+                                      . esc_attr__('Restore Contact', 'event_espresso').'">'
259
+                                      . esc_html__('Restore', 'event_espresso').'</a>';
260 260
             }
261 261
         }
262 262
 
@@ -271,8 +271,8 @@  discard block
 block discarded – undo
271 271
             'ee_edit_contacts',
272 272
             'espresso_registrations_edit_attendee'
273 273
         )
274
-            ? '<a href="' . $edit_lnk_url . '" title="'
275
-              . esc_attr__('Edit Contact', 'event_espresso') . '">' . $attendee->fname() . '</a>'
274
+            ? '<a href="'.$edit_lnk_url.'" title="'
275
+              . esc_attr__('Edit Contact', 'event_espresso').'">'.$attendee->fname().'</a>'
276 276
             : $attendee->fname();
277 277
 
278 278
         // Return the name contents
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
      */
290 290
     public function column_ATT_email(EE_Attendee $attendee)
291 291
     {
292
-        return '<a href="mailto:' . $attendee->email() . '">' . $attendee->email() . '</a>';
292
+        return '<a href="mailto:'.$attendee->email().'">'.$attendee->email().'</a>';
293 293
     }
294 294
 
295 295
 
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
             ),
310 310
             REG_ADMIN_URL
311 311
         );
312
-        return '<a href="' . $link . '">' . $attendee->getCustomSelect('Registration_Count') . '</a>';
312
+        return '<a href="'.$link.'">'.$attendee->getCustomSelect('Registration_Count').'</a>';
313 313
     }
314 314
 
315 315
 
@@ -352,8 +352,8 @@  discard block
 block discarded – undo
352 352
     public function column_STA_ID(EE_Attendee $attendee)
353 353
     {
354 354
         $states = EEM_State::instance()->get_all_states();
355
-        $state = isset($states[ $attendee->state_ID() ])
356
-            ? $states[ $attendee->state_ID() ]->get('STA_name')
355
+        $state = isset($states[$attendee->state_ID()])
356
+            ? $states[$attendee->state_ID()]->get('STA_name')
357 357
             : $attendee->state_ID();
358 358
         return ! is_numeric($state) ? $state : '';
359 359
     }
@@ -372,8 +372,8 @@  discard block
 block discarded – undo
372 372
     public function column_CNT_ISO(EE_Attendee $attendee)
373 373
     {
374 374
         $countries = EEM_Country::instance()->get_all_countries();
375
-        $country = isset($countries[ $attendee->country_ID() ])
376
-            ? $countries[ $attendee->country_ID() ]->get('CNT_name')
375
+        $country = isset($countries[$attendee->country_ID()])
376
+            ? $countries[$attendee->country_ID()]->get('CNT_name')
377 377
             : $attendee->country_ID();
378 378
         return ! is_numeric($country) ? $country : '';
379 379
     }
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   +213 added lines, -213 removed lines patch added patch discarded remove patch
@@ -22,217 +22,217 @@
 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 (
174
-                apply_filters(
175
-                    'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_display_availability_error',
176
-                    true,
177
-                    $ticket,
178
-                    $qty,
179
-                    $available_spaces
180
-                )
181
-            ) {
182
-                $this->availabilityError(
183
-                    $available_spaces,
184
-                    $total_ticket_count
185
-                );
186
-            }
187
-        } else {
188
-            EE_Error::add_error(
189
-                esc_html__(
190
-                    'We\'re sorry, but there are no available spaces left for this event at this particular date and time.',
191
-                    'event_espresso'
192
-                ),
193
-                __FILE__,
194
-                __FUNCTION__,
195
-                __LINE__
196
-            );
197
-        }
198
-    }
199
-
200
-
201
-    /**
202
-     * @param int $available_spaces
203
-     * @param int $total_ticket_count
204
-     */
205
-    private function availabilityError($available_spaces = 1, $total_ticket_count = 1)
206
-    {
207
-        // add error messaging - we're using the _n function that will generate
208
-        // the appropriate singular or plural message based on the number of $available_spaces
209
-        if ($total_ticket_count) {
210
-            $msg = sprintf(
211
-                esc_html(
212
-                    _n(
213
-                        '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.',
214
-                        '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.',
215
-                        $available_spaces,
216
-                        'event_espresso'
217
-                    )
218
-                ),
219
-                $available_spaces,
220
-                '<br />'
221
-            );
222
-        } else {
223
-            $msg = sprintf(
224
-                esc_html(
225
-                    _n(
226
-                        '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.',
227
-                        '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.',
228
-                        $available_spaces,
229
-                        'event_espresso'
230
-                    )
231
-                ),
232
-                $available_spaces,
233
-                '<br />'
234
-            );
235
-        }
236
-        EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
237
-    }
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 (
174
+				apply_filters(
175
+					'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_display_availability_error',
176
+					true,
177
+					$ticket,
178
+					$qty,
179
+					$available_spaces
180
+				)
181
+			) {
182
+				$this->availabilityError(
183
+					$available_spaces,
184
+					$total_ticket_count
185
+				);
186
+			}
187
+		} else {
188
+			EE_Error::add_error(
189
+				esc_html__(
190
+					'We\'re sorry, but there are no available spaces left for this event at this particular date and time.',
191
+					'event_espresso'
192
+				),
193
+				__FILE__,
194
+				__FUNCTION__,
195
+				__LINE__
196
+			);
197
+		}
198
+	}
199
+
200
+
201
+	/**
202
+	 * @param int $available_spaces
203
+	 * @param int $total_ticket_count
204
+	 */
205
+	private function availabilityError($available_spaces = 1, $total_ticket_count = 1)
206
+	{
207
+		// add error messaging - we're using the _n function that will generate
208
+		// the appropriate singular or plural message based on the number of $available_spaces
209
+		if ($total_ticket_count) {
210
+			$msg = sprintf(
211
+				esc_html(
212
+					_n(
213
+						'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.',
214
+						'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.',
215
+						$available_spaces,
216
+						'event_espresso'
217
+					)
218
+				),
219
+				$available_spaces,
220
+				'<br />'
221
+			);
222
+		} else {
223
+			$msg = sprintf(
224
+				esc_html(
225
+					_n(
226
+						'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.',
227
+						'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.',
228
+						$available_spaces,
229
+						'event_espresso'
230
+					)
231
+				),
232
+				$available_spaces,
233
+				'<br />'
234
+			);
235
+		}
236
+		EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
237
+	}
238 238
 }
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   +312 added lines, -312 removed lines patch added patch discarded remove patch
@@ -25,316 +25,316 @@
 block discarded – undo
25 25
 class PersistentAdminNotice implements RequiresCapCheckInterface
26 26
 {
27 27
 
28
-    /**
29
-     * @var string $name
30
-     */
31
-    protected $name = '';
32
-
33
-    /**
34
-     * @var string $message
35
-     */
36
-    protected $message = '';
37
-
38
-    /**
39
-     * @var boolean $force_update
40
-     */
41
-    protected $force_update = false;
42
-
43
-    /**
44
-     * @var string $capability
45
-     */
46
-    protected $capability = 'manage_options';
47
-
48
-    /**
49
-     * @var string $cap_context
50
-     */
51
-    protected $cap_context = 'view persistent admin notice';
52
-
53
-    /**
54
-     * @var boolean $dismissed
55
-     */
56
-    protected $dismissed = false;
57
-
58
-    /**
59
-     * @var CapCheckInterface $cap_check
60
-     */
61
-    protected $cap_check;
62
-
63
-    /**
64
-     * if true, then this notice will be deleted from the database
65
-     *
66
-     * @var boolean $purge
67
-     */
68
-    protected $purge = false;
69
-
70
-    /**
71
-     * gets set to true if notice is successfully registered with the PersistentAdminNoticeManager
72
-     * if false, and WP_DEBUG is on, then an exception will be thrown in the admin footer
73
-     *
74
-     * @var boolean $registered
75
-     */
76
-    private $registered = false;
77
-
78
-
79
-    /**
80
-     * PersistentAdminNotice constructor
81
-     *
82
-     * @param string $name         [required] the name, or key of the Persistent Admin Notice to be stored
83
-     * @param string $message      [required] the message to be stored persistently until dismissed
84
-     * @param bool   $force_update enforce the reappearance of a persistent message
85
-     * @param string $capability   user capability required to view this notice
86
-     * @param string $cap_context  description for why the cap check is being performed
87
-     * @param bool   $dismissed    whether or not the user has already dismissed/viewed this notice
88
-     * @throws InvalidDataTypeException
89
-     */
90
-    public function __construct(
91
-        $name,
92
-        $message,
93
-        $force_update = false,
94
-        $capability = 'manage_options',
95
-        $cap_context = 'view persistent admin notice',
96
-        $dismissed = false
97
-    ) {
98
-        $this->setName($name);
99
-        $this->setMessage($message);
100
-        $this->setForceUpdate($force_update);
101
-        $this->setCapability($capability);
102
-        $this->setCapContext($cap_context);
103
-        $this->setDismissed($dismissed);
104
-        add_action(
105
-            'AHEE__EventEspresso_core_services_notifications_PersistentAdminNoticeManager__registerNotices',
106
-            array($this, 'registerPersistentAdminNotice')
107
-        );
108
-        add_action('shutdown', array($this, 'confirmRegistered'), 999);
109
-    }
110
-
111
-
112
-    /**
113
-     * @return string
114
-     */
115
-    public function getName()
116
-    {
117
-        return $this->name;
118
-    }
119
-
120
-
121
-    /**
122
-     * @param string $name
123
-     * @throws InvalidDataTypeException
124
-     */
125
-    private function setName($name)
126
-    {
127
-        if (! is_string($name)) {
128
-            throw new InvalidDataTypeException('$name', $name, 'string');
129
-        }
130
-        $this->name = sanitize_key($name);
131
-    }
132
-
133
-
134
-    /**
135
-     * @return string
136
-     */
137
-    public function getMessage()
138
-    {
139
-        return $this->message;
140
-    }
141
-
142
-
143
-    /**
144
-     * @param string $message
145
-     * @throws InvalidDataTypeException
146
-     */
147
-    private function setMessage($message)
148
-    {
149
-        if (! is_string($message)) {
150
-            throw new InvalidDataTypeException('$message', $message, 'string');
151
-        }
152
-        global $allowedtags;
153
-        $allowedtags['br'] = array();
154
-        $this->message = wp_kses($message, $allowedtags);
155
-    }
156
-
157
-
158
-    /**
159
-     * @return bool
160
-     */
161
-    public function getForceUpdate()
162
-    {
163
-        return $this->force_update;
164
-    }
165
-
166
-
167
-    /**
168
-     * @param bool $force_update
169
-     */
170
-    private function setForceUpdate($force_update)
171
-    {
172
-        $this->force_update = filter_var($force_update, FILTER_VALIDATE_BOOLEAN);
173
-    }
174
-
175
-
176
-    /**
177
-     * @return string
178
-     */
179
-    public function getCapability()
180
-    {
181
-        return $this->capability;
182
-    }
183
-
184
-
185
-    /**
186
-     * @param string $capability
187
-     * @throws InvalidDataTypeException
188
-     */
189
-    private function setCapability($capability)
190
-    {
191
-        if (! is_string($capability)) {
192
-            throw new InvalidDataTypeException('$capability', $capability, 'string');
193
-        }
194
-        $this->capability = ! empty($capability) ? $capability : 'manage_options';
195
-    }
196
-
197
-
198
-    /**
199
-     * @return string
200
-     */
201
-    public function getCapContext()
202
-    {
203
-        return $this->cap_context;
204
-    }
205
-
206
-
207
-    /**
208
-     * @param string $cap_context
209
-     * @throws InvalidDataTypeException
210
-     */
211
-    private function setCapContext($cap_context)
212
-    {
213
-        if (! is_string($cap_context)) {
214
-            throw new InvalidDataTypeException('$cap_context', $cap_context, 'string');
215
-        }
216
-        $this->cap_context = ! empty($cap_context) ? $cap_context : 'view persistent admin notice';
217
-    }
218
-
219
-
220
-    /**
221
-     * @return bool
222
-     */
223
-    public function getDismissed()
224
-    {
225
-        return $this->dismissed;
226
-    }
227
-
228
-
229
-    /**
230
-     * @param bool $dismissed
231
-     */
232
-    public function setDismissed($dismissed)
233
-    {
234
-        $this->dismissed = filter_var($dismissed, FILTER_VALIDATE_BOOLEAN);
235
-    }
236
-
237
-
238
-    /**
239
-     * @return CapCheckInterface
240
-     * @throws InvalidDataTypeException
241
-     */
242
-    public function getCapCheck()
243
-    {
244
-        if (! $this->cap_check instanceof CapCheckInterface) {
245
-            $this->setCapCheck(
246
-                new CapCheck(
247
-                    $this->capability,
248
-                    $this->cap_context
249
-                )
250
-            );
251
-        }
252
-        return $this->cap_check;
253
-    }
254
-
255
-
256
-    /**
257
-     * @param CapCheckInterface $cap_check
258
-     */
259
-    private function setCapCheck(CapCheckInterface $cap_check)
260
-    {
261
-        $this->cap_check = $cap_check;
262
-    }
263
-
264
-
265
-    /**
266
-     * @return bool
267
-     */
268
-    public function getPurge()
269
-    {
270
-        return $this->purge;
271
-    }
272
-
273
-
274
-    /**
275
-     * @param bool $purge
276
-     */
277
-    public function setPurge($purge)
278
-    {
279
-        $this->purge = filter_var($purge, FILTER_VALIDATE_BOOLEAN);
280
-    }
281
-
282
-
283
-    /**
284
-     * given a valid PersistentAdminNotice Collection,
285
-     * this notice will be added if it is not already found in the collection (using its name as the identifier)
286
-     * if an existing notice is found that has already been dismissed,
287
-     * but we are overriding with a forced update, then we will toggle its dismissed state,
288
-     * so that the notice is displayed again
289
-     *
290
-     * @param Collection $persistent_admin_notice_collection
291
-     * @throws InvalidEntityException
292
-     * @throws InvalidDataTypeException
293
-     * @throws DuplicateCollectionIdentifierException
294
-     */
295
-    public function registerPersistentAdminNotice(Collection $persistent_admin_notice_collection)
296
-    {
297
-        if ($this->registered) {
298
-            return;
299
-        }
300
-        // first check if this notice has already been added to the collection
301
-        if ($persistent_admin_notice_collection->has($this->name)) {
302
-            /** @var PersistentAdminNotice $existing */
303
-            $existing = $persistent_admin_notice_collection->get($this->name);
304
-            // we don't need to add it again (we can't actually)
305
-            // but if it has already been dismissed, and we are overriding with a forced update
306
-            if ($existing->getDismissed() && $this->getForceUpdate()) {
307
-                // then toggle the notice's dismissed state to true
308
-                // so that it gets displayed again
309
-                $existing->setDismissed(false);
310
-                // and make sure the message is set
311
-                $existing->setMessage($this->message);
312
-            }
313
-        } else {
314
-            $persistent_admin_notice_collection->add($this, $this->name);
315
-        }
316
-        $this->registered = true;
317
-    }
318
-
319
-
320
-    /**
321
-     * @throws Exception
322
-     */
323
-    public function confirmRegistered()
324
-    {
325
-        if (! apply_filters('PersistentAdminNoticeManager__registerAndSaveNotices__complete', false)) {
326
-            PersistentAdminNoticeManager::loadRegisterAndSaveNotices();
327
-        }
328
-        if (! $this->registered && WP_DEBUG) {
329
-            throw new DomainException(
330
-                sprintf(
331
-                    esc_html__(
332
-                        '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.',
333
-                        'event_espresso'
334
-                    ),
335
-                    $this->name
336
-                )
337
-            );
338
-        }
339
-    }
28
+	/**
29
+	 * @var string $name
30
+	 */
31
+	protected $name = '';
32
+
33
+	/**
34
+	 * @var string $message
35
+	 */
36
+	protected $message = '';
37
+
38
+	/**
39
+	 * @var boolean $force_update
40
+	 */
41
+	protected $force_update = false;
42
+
43
+	/**
44
+	 * @var string $capability
45
+	 */
46
+	protected $capability = 'manage_options';
47
+
48
+	/**
49
+	 * @var string $cap_context
50
+	 */
51
+	protected $cap_context = 'view persistent admin notice';
52
+
53
+	/**
54
+	 * @var boolean $dismissed
55
+	 */
56
+	protected $dismissed = false;
57
+
58
+	/**
59
+	 * @var CapCheckInterface $cap_check
60
+	 */
61
+	protected $cap_check;
62
+
63
+	/**
64
+	 * if true, then this notice will be deleted from the database
65
+	 *
66
+	 * @var boolean $purge
67
+	 */
68
+	protected $purge = false;
69
+
70
+	/**
71
+	 * gets set to true if notice is successfully registered with the PersistentAdminNoticeManager
72
+	 * if false, and WP_DEBUG is on, then an exception will be thrown in the admin footer
73
+	 *
74
+	 * @var boolean $registered
75
+	 */
76
+	private $registered = false;
77
+
78
+
79
+	/**
80
+	 * PersistentAdminNotice constructor
81
+	 *
82
+	 * @param string $name         [required] the name, or key of the Persistent Admin Notice to be stored
83
+	 * @param string $message      [required] the message to be stored persistently until dismissed
84
+	 * @param bool   $force_update enforce the reappearance of a persistent message
85
+	 * @param string $capability   user capability required to view this notice
86
+	 * @param string $cap_context  description for why the cap check is being performed
87
+	 * @param bool   $dismissed    whether or not the user has already dismissed/viewed this notice
88
+	 * @throws InvalidDataTypeException
89
+	 */
90
+	public function __construct(
91
+		$name,
92
+		$message,
93
+		$force_update = false,
94
+		$capability = 'manage_options',
95
+		$cap_context = 'view persistent admin notice',
96
+		$dismissed = false
97
+	) {
98
+		$this->setName($name);
99
+		$this->setMessage($message);
100
+		$this->setForceUpdate($force_update);
101
+		$this->setCapability($capability);
102
+		$this->setCapContext($cap_context);
103
+		$this->setDismissed($dismissed);
104
+		add_action(
105
+			'AHEE__EventEspresso_core_services_notifications_PersistentAdminNoticeManager__registerNotices',
106
+			array($this, 'registerPersistentAdminNotice')
107
+		);
108
+		add_action('shutdown', array($this, 'confirmRegistered'), 999);
109
+	}
110
+
111
+
112
+	/**
113
+	 * @return string
114
+	 */
115
+	public function getName()
116
+	{
117
+		return $this->name;
118
+	}
119
+
120
+
121
+	/**
122
+	 * @param string $name
123
+	 * @throws InvalidDataTypeException
124
+	 */
125
+	private function setName($name)
126
+	{
127
+		if (! is_string($name)) {
128
+			throw new InvalidDataTypeException('$name', $name, 'string');
129
+		}
130
+		$this->name = sanitize_key($name);
131
+	}
132
+
133
+
134
+	/**
135
+	 * @return string
136
+	 */
137
+	public function getMessage()
138
+	{
139
+		return $this->message;
140
+	}
141
+
142
+
143
+	/**
144
+	 * @param string $message
145
+	 * @throws InvalidDataTypeException
146
+	 */
147
+	private function setMessage($message)
148
+	{
149
+		if (! is_string($message)) {
150
+			throw new InvalidDataTypeException('$message', $message, 'string');
151
+		}
152
+		global $allowedtags;
153
+		$allowedtags['br'] = array();
154
+		$this->message = wp_kses($message, $allowedtags);
155
+	}
156
+
157
+
158
+	/**
159
+	 * @return bool
160
+	 */
161
+	public function getForceUpdate()
162
+	{
163
+		return $this->force_update;
164
+	}
165
+
166
+
167
+	/**
168
+	 * @param bool $force_update
169
+	 */
170
+	private function setForceUpdate($force_update)
171
+	{
172
+		$this->force_update = filter_var($force_update, FILTER_VALIDATE_BOOLEAN);
173
+	}
174
+
175
+
176
+	/**
177
+	 * @return string
178
+	 */
179
+	public function getCapability()
180
+	{
181
+		return $this->capability;
182
+	}
183
+
184
+
185
+	/**
186
+	 * @param string $capability
187
+	 * @throws InvalidDataTypeException
188
+	 */
189
+	private function setCapability($capability)
190
+	{
191
+		if (! is_string($capability)) {
192
+			throw new InvalidDataTypeException('$capability', $capability, 'string');
193
+		}
194
+		$this->capability = ! empty($capability) ? $capability : 'manage_options';
195
+	}
196
+
197
+
198
+	/**
199
+	 * @return string
200
+	 */
201
+	public function getCapContext()
202
+	{
203
+		return $this->cap_context;
204
+	}
205
+
206
+
207
+	/**
208
+	 * @param string $cap_context
209
+	 * @throws InvalidDataTypeException
210
+	 */
211
+	private function setCapContext($cap_context)
212
+	{
213
+		if (! is_string($cap_context)) {
214
+			throw new InvalidDataTypeException('$cap_context', $cap_context, 'string');
215
+		}
216
+		$this->cap_context = ! empty($cap_context) ? $cap_context : 'view persistent admin notice';
217
+	}
218
+
219
+
220
+	/**
221
+	 * @return bool
222
+	 */
223
+	public function getDismissed()
224
+	{
225
+		return $this->dismissed;
226
+	}
227
+
228
+
229
+	/**
230
+	 * @param bool $dismissed
231
+	 */
232
+	public function setDismissed($dismissed)
233
+	{
234
+		$this->dismissed = filter_var($dismissed, FILTER_VALIDATE_BOOLEAN);
235
+	}
236
+
237
+
238
+	/**
239
+	 * @return CapCheckInterface
240
+	 * @throws InvalidDataTypeException
241
+	 */
242
+	public function getCapCheck()
243
+	{
244
+		if (! $this->cap_check instanceof CapCheckInterface) {
245
+			$this->setCapCheck(
246
+				new CapCheck(
247
+					$this->capability,
248
+					$this->cap_context
249
+				)
250
+			);
251
+		}
252
+		return $this->cap_check;
253
+	}
254
+
255
+
256
+	/**
257
+	 * @param CapCheckInterface $cap_check
258
+	 */
259
+	private function setCapCheck(CapCheckInterface $cap_check)
260
+	{
261
+		$this->cap_check = $cap_check;
262
+	}
263
+
264
+
265
+	/**
266
+	 * @return bool
267
+	 */
268
+	public function getPurge()
269
+	{
270
+		return $this->purge;
271
+	}
272
+
273
+
274
+	/**
275
+	 * @param bool $purge
276
+	 */
277
+	public function setPurge($purge)
278
+	{
279
+		$this->purge = filter_var($purge, FILTER_VALIDATE_BOOLEAN);
280
+	}
281
+
282
+
283
+	/**
284
+	 * given a valid PersistentAdminNotice Collection,
285
+	 * this notice will be added if it is not already found in the collection (using its name as the identifier)
286
+	 * if an existing notice is found that has already been dismissed,
287
+	 * but we are overriding with a forced update, then we will toggle its dismissed state,
288
+	 * so that the notice is displayed again
289
+	 *
290
+	 * @param Collection $persistent_admin_notice_collection
291
+	 * @throws InvalidEntityException
292
+	 * @throws InvalidDataTypeException
293
+	 * @throws DuplicateCollectionIdentifierException
294
+	 */
295
+	public function registerPersistentAdminNotice(Collection $persistent_admin_notice_collection)
296
+	{
297
+		if ($this->registered) {
298
+			return;
299
+		}
300
+		// first check if this notice has already been added to the collection
301
+		if ($persistent_admin_notice_collection->has($this->name)) {
302
+			/** @var PersistentAdminNotice $existing */
303
+			$existing = $persistent_admin_notice_collection->get($this->name);
304
+			// we don't need to add it again (we can't actually)
305
+			// but if it has already been dismissed, and we are overriding with a forced update
306
+			if ($existing->getDismissed() && $this->getForceUpdate()) {
307
+				// then toggle the notice's dismissed state to true
308
+				// so that it gets displayed again
309
+				$existing->setDismissed(false);
310
+				// and make sure the message is set
311
+				$existing->setMessage($this->message);
312
+			}
313
+		} else {
314
+			$persistent_admin_notice_collection->add($this, $this->name);
315
+		}
316
+		$this->registered = true;
317
+	}
318
+
319
+
320
+	/**
321
+	 * @throws Exception
322
+	 */
323
+	public function confirmRegistered()
324
+	{
325
+		if (! apply_filters('PersistentAdminNoticeManager__registerAndSaveNotices__complete', false)) {
326
+			PersistentAdminNoticeManager::loadRegisterAndSaveNotices();
327
+		}
328
+		if (! $this->registered && WP_DEBUG) {
329
+			throw new DomainException(
330
+				sprintf(
331
+					esc_html__(
332
+						'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.',
333
+						'event_espresso'
334
+					),
335
+					$this->name
336
+				)
337
+			);
338
+		}
339
+	}
340 340
 }
Please login to merge, or discard this patch.
admin_pages/payments/Payment_Log_Admin_List_Table.class.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -101,7 +101,7 @@
 block discarded – undo
101 101
     /**
102 102
      * _get_table_filters
103 103
      *
104
-     * @return array
104
+     * @return string[]
105 105
      */
106 106
     protected function _get_table_filters()
107 107
     {
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@
 block discarded – undo
56 56
              . __(
57 57
                  'Download Results',
58 58
                  'event_espresso'
59
-             ) . "'>";
59
+             )."'>";
60 60
     }
61 61
 
62 62
 
Please login to merge, or discard this patch.
Indentation   +227 added lines, -227 removed lines patch added patch discarded remove patch
@@ -13,111 +13,111 @@  discard block
 block discarded – undo
13 13
 class Payment_Log_Admin_List_Table extends EE_Admin_List_Table
14 14
 {
15 15
 
16
-    /**
17
-     * @param \EE_Admin_Page $admin_page
18
-     * @return Payment_Log_Admin_List_Table
19
-     */
20
-    public function __construct($admin_page)
21
-    {
22
-        parent::__construct($admin_page);
23
-    }
24
-
25
-
26
-    /**
27
-     * _setup_data
28
-     *
29
-     * @return void
30
-     */
31
-    protected function _setup_data()
32
-    {
33
-        $this->_data = $this->_admin_page->get_payment_logs($this->_per_page, $this->_current_page);
34
-        // if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'trash') {
35
-        //     $this->_data = $this->_admin_page->get_trashed_questions($this->_per_page, $this->_current_page, false);
36
-        // } else {
37
-        //     $this->_data = $this->_admin_page->get_questions($this->_per_page, $this->_current_page, false);
38
-        // }
39
-        $this->_all_data_count = $this->_admin_page->get_payment_logs($this->_per_page, $this->_current_page, true);
40
-        add_action(
41
-            'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons',
42
-            array($this, 'add_download_logs_checkbox')
43
-        );
44
-    }
45
-
46
-
47
-    /**
48
-     * add_download_logs_checkbox
49
-     * adds a checkbox to the bottom of the list table, instead of at the top with the rest of the filters
50
-     *
51
-     * @return void
52
-     */
53
-    public function add_download_logs_checkbox()
54
-    {
55
-        echo "<input type='submit' class='button-primary' id='download_results' name='download_results' value='"
56
-             . __(
57
-                 'Download Results',
58
-                 'event_espresso'
59
-             ) . "'>";
60
-    }
61
-
62
-
63
-    /**
64
-     * _set_properties
65
-     *
66
-     * @return void
67
-     */
68
-    protected function _set_properties()
69
-    {
70
-        $this->_wp_list_args = array(
71
-            'singular' => __('payment log', 'event_espresso'),
72
-            'plural'   => __('payment logs', 'event_espresso'),
73
-            'ajax'     => true, // for now,
74
-            'screen'   => $this->_admin_page->get_current_screen()->id,
75
-        );
76
-        $this->_columns = array(
77
-            'cb'       => '<input type="checkbox" />',
78
-            'id'       => __('ID', 'event_espresso'),
79
-            'LOG_time' => __('Time', 'event_espresso'),
80
-            'PMD_ID'   => __('Payment Method', 'event_espresso'),
81
-            'TXN_ID'   => __('Transaction ID', 'event_espresso'),
82
-        );
83
-        $this->_sortable_columns = array(
84
-            'LOG_time' => array('LOG_time' => true),
85
-        );
86
-        $this->_hidden_columns = array();
87
-    }
88
-
89
-
90
-    /**
91
-     * _get_table_filters
92
-     *
93
-     * @return array
94
-     */
95
-    protected function _get_table_filters()
96
-    {
97
-        $filters = array();
98
-        // todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as methods.
99
-        $payment_methods = EEM_Payment_Method::instance()->get_all();
100
-        $payment_method_names = array(
101
-            array('id' => 'all', 'text' => __("All", 'event_espresso')),
102
-            array('id' => '0', 'text' => __("Unknown Payment Method", 'event_espresso')),
103
-        );
104
-        foreach ($payment_methods as $payment_method) {
105
-            $payment_method_names[] = array('id' => $payment_method->ID(), 'text' => $payment_method->admin_name());
106
-        }
107
-        $filters[] = EEH_Form_Fields::select_input(
108
-            '_payment_method',
109
-            $payment_method_names,
110
-            isset($this->_req_data['_payment_method'])
111
-                ? $this->_req_data['_payment_method'] : 'all'
112
-        );
113
-        $start_date = isset($this->_req_data['payment-filter-start-date']) ? wp_strip_all_tags(
114
-            $this->_req_data['payment-filter-start-date']
115
-        ) : date('m/d/Y', strtotime('-6 months'));
116
-        $end_date = isset($this->_req_data['payment-filter-end-date']) ? wp_strip_all_tags(
117
-            $this->_req_data['payment-filter-end-date']
118
-        ) : date('m/d/Y');
119
-        ob_start();
120
-        ?>
16
+	/**
17
+	 * @param \EE_Admin_Page $admin_page
18
+	 * @return Payment_Log_Admin_List_Table
19
+	 */
20
+	public function __construct($admin_page)
21
+	{
22
+		parent::__construct($admin_page);
23
+	}
24
+
25
+
26
+	/**
27
+	 * _setup_data
28
+	 *
29
+	 * @return void
30
+	 */
31
+	protected function _setup_data()
32
+	{
33
+		$this->_data = $this->_admin_page->get_payment_logs($this->_per_page, $this->_current_page);
34
+		// if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'trash') {
35
+		//     $this->_data = $this->_admin_page->get_trashed_questions($this->_per_page, $this->_current_page, false);
36
+		// } else {
37
+		//     $this->_data = $this->_admin_page->get_questions($this->_per_page, $this->_current_page, false);
38
+		// }
39
+		$this->_all_data_count = $this->_admin_page->get_payment_logs($this->_per_page, $this->_current_page, true);
40
+		add_action(
41
+			'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons',
42
+			array($this, 'add_download_logs_checkbox')
43
+		);
44
+	}
45
+
46
+
47
+	/**
48
+	 * add_download_logs_checkbox
49
+	 * adds a checkbox to the bottom of the list table, instead of at the top with the rest of the filters
50
+	 *
51
+	 * @return void
52
+	 */
53
+	public function add_download_logs_checkbox()
54
+	{
55
+		echo "<input type='submit' class='button-primary' id='download_results' name='download_results' value='"
56
+			 . __(
57
+				 'Download Results',
58
+				 'event_espresso'
59
+			 ) . "'>";
60
+	}
61
+
62
+
63
+	/**
64
+	 * _set_properties
65
+	 *
66
+	 * @return void
67
+	 */
68
+	protected function _set_properties()
69
+	{
70
+		$this->_wp_list_args = array(
71
+			'singular' => __('payment log', 'event_espresso'),
72
+			'plural'   => __('payment logs', 'event_espresso'),
73
+			'ajax'     => true, // for now,
74
+			'screen'   => $this->_admin_page->get_current_screen()->id,
75
+		);
76
+		$this->_columns = array(
77
+			'cb'       => '<input type="checkbox" />',
78
+			'id'       => __('ID', 'event_espresso'),
79
+			'LOG_time' => __('Time', 'event_espresso'),
80
+			'PMD_ID'   => __('Payment Method', 'event_espresso'),
81
+			'TXN_ID'   => __('Transaction ID', 'event_espresso'),
82
+		);
83
+		$this->_sortable_columns = array(
84
+			'LOG_time' => array('LOG_time' => true),
85
+		);
86
+		$this->_hidden_columns = array();
87
+	}
88
+
89
+
90
+	/**
91
+	 * _get_table_filters
92
+	 *
93
+	 * @return array
94
+	 */
95
+	protected function _get_table_filters()
96
+	{
97
+		$filters = array();
98
+		// todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as methods.
99
+		$payment_methods = EEM_Payment_Method::instance()->get_all();
100
+		$payment_method_names = array(
101
+			array('id' => 'all', 'text' => __("All", 'event_espresso')),
102
+			array('id' => '0', 'text' => __("Unknown Payment Method", 'event_espresso')),
103
+		);
104
+		foreach ($payment_methods as $payment_method) {
105
+			$payment_method_names[] = array('id' => $payment_method->ID(), 'text' => $payment_method->admin_name());
106
+		}
107
+		$filters[] = EEH_Form_Fields::select_input(
108
+			'_payment_method',
109
+			$payment_method_names,
110
+			isset($this->_req_data['_payment_method'])
111
+				? $this->_req_data['_payment_method'] : 'all'
112
+		);
113
+		$start_date = isset($this->_req_data['payment-filter-start-date']) ? wp_strip_all_tags(
114
+			$this->_req_data['payment-filter-start-date']
115
+		) : date('m/d/Y', strtotime('-6 months'));
116
+		$end_date = isset($this->_req_data['payment-filter-end-date']) ? wp_strip_all_tags(
117
+			$this->_req_data['payment-filter-end-date']
118
+		) : date('m/d/Y');
119
+		ob_start();
120
+		?>
121 121
         <label for="txn-filter-start-date"><?php _e('Display Transactions from ', 'event_espresso'); ?></label>
122 122
         <input id="payment-filter-start-date" class="datepicker" type="text" value="<?php echo $start_date; ?>"
123 123
                name="payment-filter-start-date" size="15"/>
@@ -125,126 +125,126 @@  discard block
 block discarded – undo
125 125
         <input id="payment-filter-end-date" class="datepicker" type="text" value="<?php echo $end_date; ?>"
126 126
                name="payment-filter-end-date" size="15"/>
127 127
         <?php
128
-        $filters[] = ob_get_clean();
129
-        return $filters;
130
-    }
131
-
132
-
133
-    /**
134
-     * _add_view_counts
135
-     *
136
-     * @return void
137
-     */
138
-    protected function _add_view_counts()
139
-    {
140
-        $this->_views['all']['count'] = $this->_admin_page->get_payment_logs(
141
-            $this->_per_page,
142
-            $this->_current_page,
143
-            true
144
-        );
145
-    }
146
-
147
-
148
-    /**
149
-     * column_cb
150
-     *
151
-     * @param \EE_Change_Log $item
152
-     * @return string
153
-     */
154
-    public function column_cb($item)
155
-    {
156
-        return sprintf('<input type="checkbox" class="option_id" name="checkbox[%1$d]" value="%1$d" />', $item->ID());
157
-    }
158
-
159
-
160
-    /**
161
-     * column_id
162
-     *
163
-     * @param \EE_Change_Log $item
164
-     * @return string
165
-     */
166
-    public function column_id(EE_Change_Log $item)
167
-    {
168
-        $details_query_args = array(
169
-            'action' => 'payment_log_details',
170
-            'ID'     => $item->ID(),
171
-        );
172
-        $url = EE_Admin_Page::add_query_args_and_nonce($details_query_args, EE_PAYMENTS_ADMIN_URL);
173
-        return "<a href='$url'>{$item->ID()}</a>";
174
-    }
175
-
176
-
177
-    /**
178
-     * column_LOG_time
179
-     *
180
-     * @param \EE_Change_Log $item
181
-     * @return string
182
-     */
183
-    public function column_LOG_time(EE_Change_Log $item)
184
-    {
185
-        return $item->get_datetime('LOG_time');
186
-    }
187
-
188
-
189
-    /**
190
-     * column_PMD_ID
191
-     *
192
-     * @param \EE_Change_Log $item
193
-     * @return string
194
-     */
195
-    public function column_PMD_ID(EE_Change_Log $item)
196
-    {
197
-        if ($item->object() instanceof EE_Payment_Method) {
198
-            return $item->object()->admin_name();
199
-        } elseif ($item->object() instanceof EE_Payment && $item->object()->payment_method()) {
200
-            return $item->object()->payment_method()->admin_name();
201
-        } elseif ($item->object() instanceof EE_Transaction) {
202
-            return esc_html__('Unknown', 'event_espresso');
203
-        } else {
204
-            return esc_html__("No longer exists", 'event_espresso');
205
-        }
206
-    }
207
-
208
-
209
-    /**
210
-     * column_TXN_ID
211
-     *
212
-     * @param \EE_Change_Log $item
213
-     * @return string
214
-     */
215
-    public function column_TXN_ID(EE_Change_Log $item)
216
-    {
217
-        if ($item->object() instanceof EE_Payment) {
218
-            $transaction_id = $item->object()->TXN_ID();
219
-        } elseif ($item->object() instanceof EE_Transaction) {
220
-            $transaction_id = $item->object()->ID();
221
-        } else {
222
-            $transaction_id = null;
223
-        }
224
-        if (
225
-            $transaction_id
226
-            && EE_Registry::instance()->CAP->current_user_can(
227
-                'ee_read_transaction',
228
-                'espresso_transactions_view_transaction',
229
-                $transaction_id
230
-            )
231
-        ) {
232
-            $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
233
-                array('action' => 'view_transaction', 'TXN_ID' => $transaction_id),
234
-                TXN_ADMIN_URL
235
-            );
236
-            return '<a href="'
237
-                   . $view_txn_lnk_url
238
-                   . '"  title="'
239
-                   . sprintf(
240
-                       esc_attr__('click to view transaction #%s', 'event_espresso'),
241
-                       $transaction_id
242
-                   )
243
-                   . '">'
244
-                   . sprintf(esc_html__('view txn %s', 'event_espresso'), $transaction_id)
245
-                   . '</a>';
246
-        }
247
-        // No transaction id or use can not view the transaction.
248
-        return __("Unable to find transaction", 'event_espresso');
249
-    }
128
+		$filters[] = ob_get_clean();
129
+		return $filters;
130
+	}
131
+
132
+
133
+	/**
134
+	 * _add_view_counts
135
+	 *
136
+	 * @return void
137
+	 */
138
+	protected function _add_view_counts()
139
+	{
140
+		$this->_views['all']['count'] = $this->_admin_page->get_payment_logs(
141
+			$this->_per_page,
142
+			$this->_current_page,
143
+			true
144
+		);
145
+	}
146
+
147
+
148
+	/**
149
+	 * column_cb
150
+	 *
151
+	 * @param \EE_Change_Log $item
152
+	 * @return string
153
+	 */
154
+	public function column_cb($item)
155
+	{
156
+		return sprintf('<input type="checkbox" class="option_id" name="checkbox[%1$d]" value="%1$d" />', $item->ID());
157
+	}
158
+
159
+
160
+	/**
161
+	 * column_id
162
+	 *
163
+	 * @param \EE_Change_Log $item
164
+	 * @return string
165
+	 */
166
+	public function column_id(EE_Change_Log $item)
167
+	{
168
+		$details_query_args = array(
169
+			'action' => 'payment_log_details',
170
+			'ID'     => $item->ID(),
171
+		);
172
+		$url = EE_Admin_Page::add_query_args_and_nonce($details_query_args, EE_PAYMENTS_ADMIN_URL);
173
+		return "<a href='$url'>{$item->ID()}</a>";
174
+	}
175
+
176
+
177
+	/**
178
+	 * column_LOG_time
179
+	 *
180
+	 * @param \EE_Change_Log $item
181
+	 * @return string
182
+	 */
183
+	public function column_LOG_time(EE_Change_Log $item)
184
+	{
185
+		return $item->get_datetime('LOG_time');
186
+	}
187
+
188
+
189
+	/**
190
+	 * column_PMD_ID
191
+	 *
192
+	 * @param \EE_Change_Log $item
193
+	 * @return string
194
+	 */
195
+	public function column_PMD_ID(EE_Change_Log $item)
196
+	{
197
+		if ($item->object() instanceof EE_Payment_Method) {
198
+			return $item->object()->admin_name();
199
+		} elseif ($item->object() instanceof EE_Payment && $item->object()->payment_method()) {
200
+			return $item->object()->payment_method()->admin_name();
201
+		} elseif ($item->object() instanceof EE_Transaction) {
202
+			return esc_html__('Unknown', 'event_espresso');
203
+		} else {
204
+			return esc_html__("No longer exists", 'event_espresso');
205
+		}
206
+	}
207
+
208
+
209
+	/**
210
+	 * column_TXN_ID
211
+	 *
212
+	 * @param \EE_Change_Log $item
213
+	 * @return string
214
+	 */
215
+	public function column_TXN_ID(EE_Change_Log $item)
216
+	{
217
+		if ($item->object() instanceof EE_Payment) {
218
+			$transaction_id = $item->object()->TXN_ID();
219
+		} elseif ($item->object() instanceof EE_Transaction) {
220
+			$transaction_id = $item->object()->ID();
221
+		} else {
222
+			$transaction_id = null;
223
+		}
224
+		if (
225
+			$transaction_id
226
+			&& EE_Registry::instance()->CAP->current_user_can(
227
+				'ee_read_transaction',
228
+				'espresso_transactions_view_transaction',
229
+				$transaction_id
230
+			)
231
+		) {
232
+			$view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
233
+				array('action' => 'view_transaction', 'TXN_ID' => $transaction_id),
234
+				TXN_ADMIN_URL
235
+			);
236
+			return '<a href="'
237
+				   . $view_txn_lnk_url
238
+				   . '"  title="'
239
+				   . sprintf(
240
+					   esc_attr__('click to view transaction #%s', 'event_espresso'),
241
+					   $transaction_id
242
+				   )
243
+				   . '">'
244
+				   . sprintf(esc_html__('view txn %s', 'event_espresso'), $transaction_id)
245
+				   . '</a>';
246
+		}
247
+		// No transaction id or use can not view the transaction.
248
+		return __("Unable to find transaction", 'event_espresso');
249
+	}
250 250
 }
Please login to merge, or discard this patch.