Completed
Branch BUG/errant-code-example-for-mi... (ad738d)
by
unknown
24:53 queued 11:00
created
admin_pages/transactions/EE_Admin_Transactions_List_Table.class.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
      *
103 103
      * @abstract
104 104
      * @access protected
105
-     * @return array
105
+     * @return string[]
106 106
      */
107 107
     protected function _get_table_filters()
108 108
     {
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
      *    column_TXN_paid
266 266
      *
267 267
      * @param \EE_Transaction $transaction
268
-     * @return mixed|string
268
+     * @return string
269 269
      * @throws \EE_Error
270 270
      */
271 271
     public function column_TXN_paid(EE_Transaction $transaction)
Please login to merge, or discard this patch.
Indentation   +659 added lines, -659 removed lines patch added patch discarded remove patch
@@ -15,121 +15,121 @@  discard block
 block discarded – undo
15 15
 class EE_Admin_Transactions_List_Table extends EE_Admin_List_Table
16 16
 {
17 17
 
18
-    /**
19
-     * @var SessionLifespan $session_lifespan
20
-     */
21
-    private $session_lifespan;
22
-
23
-    private $_status;
24
-
25
-
26
-    /**
27
-     * @param \Transactions_Admin_Page $admin_page
28
-     * @param SessionLifespan          $lifespan
29
-     */
30
-    public function __construct(\Transactions_Admin_Page $admin_page, SessionLifespan $lifespan)
31
-    {
32
-        parent::__construct($admin_page);
33
-        $this->session_lifespan = $lifespan;
34
-        $this->_status = $this->_admin_page->get_transaction_status_array();
35
-    }
36
-
37
-
38
-    /**
39
-     *_setup_data
40
-     */
41
-    protected function _setup_data()
42
-    {
43
-        $this->_data = $this->_admin_page->get_transactions($this->_per_page);
44
-        $status = ! empty($this->_req_data['status']) ? $this->_req_data['status'] : 'all';
45
-        $this->_all_data_count = $this->_admin_page->get_transactions($this->_per_page, true, $status);
46
-    }
47
-
48
-
49
-    /**
50
-     *_set_properties
51
-     */
52
-    protected function _set_properties()
53
-    {
54
-        $this->_wp_list_args = array(
55
-            'singular' => __('transaction', 'event_espresso'),
56
-            'plural'   => __('transactions', 'event_espresso'),
57
-            'ajax'     => true,
58
-            'screen'   => $this->_admin_page->get_current_screen()->id,
59
-        );
60
-        $ID_column_name = __('ID', 'event_espresso');
61
-        $ID_column_name .= ' : <span class="show-on-mobile-view-only" style="float:none">';
62
-        $ID_column_name .= __('Transaction Date', 'event_espresso');
63
-        $ID_column_name .= '</span> ';
64
-        $this->_columns = array(
65
-            'TXN_ID'        => $ID_column_name,
66
-            'TXN_timestamp' => __('Transaction Date', 'event_espresso'),
67
-            'TXN_total'     => __('Total', 'event_espresso'),
68
-            'TXN_paid'      => __('Paid', 'event_espresso'),
69
-            'ATT_fname'     => __('Primary Registrant', 'event_espresso'),
70
-            'event_name'    => __('Event', 'event_espresso'),
71
-            'actions'       => __('Actions', 'event_espresso'),
72
-        );
73
-
74
-        $this->_sortable_columns = array(
75
-            'TXN_ID'        => array('TXN_ID' => false),
76
-            'event_name'    => array('event_name' => false),
77
-            'ATT_fname'     => array('ATT_fname' => false),
78
-            'TXN_timestamp' => array('TXN_timestamp' => true) // true means its already sorted
79
-        );
80
-
81
-        $this->_primary_column = 'TXN_ID';
82
-
83
-        $this->_hidden_columns = array();
84
-    }
85
-
86
-
87
-    /**
88
-     * This simply sets up the row class for the table rows.
89
-     * Allows for easier overriding of child methods for setting up sorting.
90
-     *
91
-     * @param  EE_Transaction $transaction the current item
92
-     * @return string
93
-     * @throws \EE_Error
94
-     */
95
-    protected function _get_row_class($transaction)
96
-    {
97
-        $class = parent::_get_row_class($transaction);
98
-        // add status class
99
-        $class .= ' ee-status-strip txn-status-' . $transaction->status_ID();
100
-        if ($this->_has_checkbox_column) {
101
-            $class .= ' has-checkbox-column';
102
-        }
103
-        return $class;
104
-    }
105
-
106
-
107
-    /**
108
-     * _get_table_filters
109
-     * We use this to assemble and return any filters that are associated with this table that help further refine what
110
-     * get's shown in the table.
111
-     *
112
-     * @abstract
113
-     * @access protected
114
-     * @return array
115
-     */
116
-    protected function _get_table_filters()
117
-    {
118
-        $filters = array();
119
-        $start_date = isset($this->_req_data['txn-filter-start-date'])
120
-            ? wp_strip_all_tags($this->_req_data['txn-filter-start-date'])
121
-            : date(
122
-                'm/d/Y',
123
-                strtotime('-10 year')
124
-            );
125
-        $end_date = isset($this->_req_data['txn-filter-end-date'])
126
-            ? wp_strip_all_tags($this->_req_data['txn-filter-end-date'])
127
-            : date(
128
-                'm/d/Y',
129
-                current_time('timestamp')
130
-            );
131
-        ob_start();
132
-        ?>
18
+	/**
19
+	 * @var SessionLifespan $session_lifespan
20
+	 */
21
+	private $session_lifespan;
22
+
23
+	private $_status;
24
+
25
+
26
+	/**
27
+	 * @param \Transactions_Admin_Page $admin_page
28
+	 * @param SessionLifespan          $lifespan
29
+	 */
30
+	public function __construct(\Transactions_Admin_Page $admin_page, SessionLifespan $lifespan)
31
+	{
32
+		parent::__construct($admin_page);
33
+		$this->session_lifespan = $lifespan;
34
+		$this->_status = $this->_admin_page->get_transaction_status_array();
35
+	}
36
+
37
+
38
+	/**
39
+	 *_setup_data
40
+	 */
41
+	protected function _setup_data()
42
+	{
43
+		$this->_data = $this->_admin_page->get_transactions($this->_per_page);
44
+		$status = ! empty($this->_req_data['status']) ? $this->_req_data['status'] : 'all';
45
+		$this->_all_data_count = $this->_admin_page->get_transactions($this->_per_page, true, $status);
46
+	}
47
+
48
+
49
+	/**
50
+	 *_set_properties
51
+	 */
52
+	protected function _set_properties()
53
+	{
54
+		$this->_wp_list_args = array(
55
+			'singular' => __('transaction', 'event_espresso'),
56
+			'plural'   => __('transactions', 'event_espresso'),
57
+			'ajax'     => true,
58
+			'screen'   => $this->_admin_page->get_current_screen()->id,
59
+		);
60
+		$ID_column_name = __('ID', 'event_espresso');
61
+		$ID_column_name .= ' : <span class="show-on-mobile-view-only" style="float:none">';
62
+		$ID_column_name .= __('Transaction Date', 'event_espresso');
63
+		$ID_column_name .= '</span> ';
64
+		$this->_columns = array(
65
+			'TXN_ID'        => $ID_column_name,
66
+			'TXN_timestamp' => __('Transaction Date', 'event_espresso'),
67
+			'TXN_total'     => __('Total', 'event_espresso'),
68
+			'TXN_paid'      => __('Paid', 'event_espresso'),
69
+			'ATT_fname'     => __('Primary Registrant', 'event_espresso'),
70
+			'event_name'    => __('Event', 'event_espresso'),
71
+			'actions'       => __('Actions', 'event_espresso'),
72
+		);
73
+
74
+		$this->_sortable_columns = array(
75
+			'TXN_ID'        => array('TXN_ID' => false),
76
+			'event_name'    => array('event_name' => false),
77
+			'ATT_fname'     => array('ATT_fname' => false),
78
+			'TXN_timestamp' => array('TXN_timestamp' => true) // true means its already sorted
79
+		);
80
+
81
+		$this->_primary_column = 'TXN_ID';
82
+
83
+		$this->_hidden_columns = array();
84
+	}
85
+
86
+
87
+	/**
88
+	 * This simply sets up the row class for the table rows.
89
+	 * Allows for easier overriding of child methods for setting up sorting.
90
+	 *
91
+	 * @param  EE_Transaction $transaction the current item
92
+	 * @return string
93
+	 * @throws \EE_Error
94
+	 */
95
+	protected function _get_row_class($transaction)
96
+	{
97
+		$class = parent::_get_row_class($transaction);
98
+		// add status class
99
+		$class .= ' ee-status-strip txn-status-' . $transaction->status_ID();
100
+		if ($this->_has_checkbox_column) {
101
+			$class .= ' has-checkbox-column';
102
+		}
103
+		return $class;
104
+	}
105
+
106
+
107
+	/**
108
+	 * _get_table_filters
109
+	 * We use this to assemble and return any filters that are associated with this table that help further refine what
110
+	 * get's shown in the table.
111
+	 *
112
+	 * @abstract
113
+	 * @access protected
114
+	 * @return array
115
+	 */
116
+	protected function _get_table_filters()
117
+	{
118
+		$filters = array();
119
+		$start_date = isset($this->_req_data['txn-filter-start-date'])
120
+			? wp_strip_all_tags($this->_req_data['txn-filter-start-date'])
121
+			: date(
122
+				'm/d/Y',
123
+				strtotime('-10 year')
124
+			);
125
+		$end_date = isset($this->_req_data['txn-filter-end-date'])
126
+			? wp_strip_all_tags($this->_req_data['txn-filter-end-date'])
127
+			: date(
128
+				'm/d/Y',
129
+				current_time('timestamp')
130
+			);
131
+		ob_start();
132
+		?>
133 133
         <label for="txn-filter-start-date">Display Transactions from </label>
134 134
         <input id="txn-filter-start-date" class="datepicker" type="text" value="<?php echo $start_date; ?>"
135 135
                name="txn-filter-start-date" size="15"/>
@@ -137,579 +137,579 @@  discard block
 block discarded – undo
137 137
         <input id="txn-filter-end-date" class="datepicker" type="text" value="<?php echo $end_date; ?>"
138 138
                name="txn-filter-end-date" size="15"/>
139 139
         <?php
140
-        $filters[] = ob_get_contents();
141
-        ob_end_clean();
142
-        return $filters;
143
-    }
144
-
145
-
146
-    /**
147
-     *_add_view_counts
148
-     */
149
-    protected function _add_view_counts()
150
-    {
151
-        $this->_views['all']['count'] = $this->_admin_page->get_transactions($this->_per_page, true, 'all');
152
-        $this->_views['abandoned']['count'] = $this->_admin_page->get_transactions($this->_per_page, true, 'abandoned');
153
-        $this->_views['failed']['count'] = $this->_admin_page->get_transactions($this->_per_page, true, 'failed');
154
-    }
155
-
156
-
157
-    /**
158
-     *    column TXN_ID
159
-     *
160
-     * @param \EE_Transaction $transaction
161
-     * @return string
162
-     * @throws \EE_Error
163
-     */
164
-    public function column_TXN_ID(EE_Transaction $transaction)
165
-    {
166
-        $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
167
-            array(
168
-                'action' => 'view_transaction',
169
-                'TXN_ID' => $transaction->ID(),
170
-            ),
171
-            TXN_ADMIN_URL
172
-        );
173
-        $content = '<a href="' . $view_lnk_url . '"'
174
-                   . ' title="' . esc_attr__('Go to Transaction Details', 'event_espresso') . '">'
175
-                   . $transaction->ID()
176
-                   . '</a>';
177
-
178
-        // txn timestamp
179
-        $content .= '  <span class="show-on-mobile-view-only">' . $this->_get_txn_timestamp($transaction) . '</span>';
180
-        return $content;
181
-    }
182
-
183
-
184
-    /**
185
-     * @param \EE_Transaction $transaction
186
-     * @return string
187
-     * @throws EE_Error
188
-     * @throws InvalidArgumentException
189
-     * @throws InvalidDataTypeException
190
-     * @throws InvalidInterfaceException
191
-     */
192
-    protected function _get_txn_timestamp(EE_Transaction $transaction)
193
-    {
194
-        // is TXN less than 2 hours old ?
195
-        if (($transaction->failed() || $transaction->is_abandoned())
196
-            && $this->session_lifespan->expiration() < $transaction->datetime(false, true)
197
-        ) {
198
-            $timestamp = esc_html__('TXN in progress...', 'event_espresso');
199
-        } else {
200
-            $timestamp = $transaction->get_i18n_datetime('TXN_timestamp');
201
-        }
202
-        return $timestamp;
203
-    }
204
-
205
-
206
-    /**
207
-     *    column_cb
208
-     *
209
-     * @param \EE_Transaction $transaction
210
-     * @return string
211
-     * @throws \EE_Error
212
-     */
213
-    public function column_cb($transaction)
214
-    {
215
-        return sprintf(
216
-            '<input type="checkbox" name="%1$s[]" value="%2$s" />',
217
-            $this->_wp_list_args['singular'],
218
-            $transaction->ID()
219
-        );
220
-    }
221
-
222
-
223
-    /**
224
-     *    column_TXN_timestamp
225
-     *
226
-     * @param \EE_Transaction $transaction
227
-     * @return string
228
-     * @throws \EE_Error
229
-     */
230
-    public function column_TXN_timestamp(EE_Transaction $transaction)
231
-    {
232
-        $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
233
-            array(
234
-                'action' => 'view_transaction',
235
-                'TXN_ID' => $transaction->ID(),
236
-            ),
237
-            TXN_ADMIN_URL
238
-        );
239
-        $txn_date = '<a href="' . $view_lnk_url . '"'
240
-                    . ' title="'
241
-                    . esc_attr__('View Transaction Details for TXN #', 'event_espresso') . $transaction->ID() . '">'
242
-                    . $this->_get_txn_timestamp($transaction)
243
-                    . '</a>';
244
-        // status
245
-        $txn_date .= '<br><span class="ee-status-text-small">'
246
-                    . EEH_Template::pretty_status(
247
-                        $transaction->status_ID(),
248
-                        false,
249
-                        'sentence'
250
-                    )
251
-                     . '</span>';
252
-        return $txn_date;
253
-    }
254
-
255
-
256
-    /**
257
-     *    column_TXN_total
258
-     *
259
-     * @param \EE_Transaction $transaction
260
-     * @return string
261
-     * @throws \EE_Error
262
-     */
263
-    public function column_TXN_total(EE_Transaction $transaction)
264
-    {
265
-        if ($transaction->get('TXN_total') > 0) {
266
-            return '<span class="txn-pad-rght">'
267
-                   . apply_filters(
268
-                       'FHEE__EE_Admin_Transactions_List_Table__column_TXN_total__TXN_total',
269
-                       $transaction->get_pretty('TXN_total'),
270
-                       $transaction
271
-                   )
272
-                   . '</span>';
273
-        } else {
274
-            return '<span class="txn-overview-free-event-spn">' . esc_html__('free', 'event_espresso') . '</span>';
275
-        }
276
-    }
277
-
278
-
279
-    /**
280
-     *    column_TXN_paid
281
-     *
282
-     * @param \EE_Transaction $transaction
283
-     * @return mixed|string
284
-     * @throws \EE_Error
285
-     */
286
-    public function column_TXN_paid(EE_Transaction $transaction)
287
-    {
288
-        $transaction_total = $transaction->get('TXN_total');
289
-        $transaction_paid = $transaction->get('TXN_paid');
290
-
291
-        if (\EEH_Money::compare_floats($transaction_total, 0, '>')) {
292
-            // monies owing
293
-            $span_class = 'txn-overview-part-payment-spn';
294
-            if (\EEH_Money::compare_floats($transaction_paid, $transaction_total, '>=')) {
295
-                // paid in full
296
-                $span_class = 'txn-overview-full-payment-spn';
297
-            } elseif (\EEH_Money::compare_floats($transaction_paid, 0, '==')) {
298
-                // no payments made
299
-                $span_class = 'txn-overview-no-payment-spn';
300
-            }
301
-        } else {
302
-            $span_class = 'txn-overview-free-event-spn';
303
-            $transaction_paid = 0;
304
-        }
305
-
306
-        $payment_method = $transaction->payment_method();
307
-        $payment_method_name = $payment_method instanceof EE_Payment_Method
308
-            ? $payment_method->admin_name()
309
-            : esc_html__('Unknown', 'event_espresso');
310
-        $transaction_paid_content = $transaction_paid !== 0 ? $transaction->get_pretty('TXN_paid') : $transaction_paid;
311
-
312
-        $content = '<span class="' . $span_class . ' txn-pad-rght">'
313
-                   . $transaction_paid_content
314
-                   . '</span>';
315
-        if ($transaction_paid > 0) {
316
-            $content .= '<br><span class="ee-status-text-small">'
317
-                        . sprintf(
318
-                            esc_html__('...via %s', 'event_espresso'),
319
-                            $payment_method_name
320
-                        )
321
-                        . '</span>';
322
-        }
323
-        return $content;
324
-    }
325
-
326
-
327
-    /**
328
-     *    column_ATT_fname
329
-     *
330
-     * @param \EE_Transaction $transaction
331
-     * @return string
332
-     * @throws EE_Error
333
-     * @throws InvalidArgumentException
334
-     * @throws InvalidDataTypeException
335
-     * @throws InvalidInterfaceException
336
-     */
337
-    public function column_ATT_fname(EE_Transaction $transaction)
338
-    {
339
-        $primary_reg = $transaction->primary_registration();
340
-        $attendee = $primary_reg->get_first_related('Attendee');
341
-        if ($attendee instanceof EE_Attendee) {
342
-            $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
343
-                array(
344
-                    'action'  => 'view_registration',
345
-                    '_REG_ID' => $primary_reg->ID(),
346
-                ),
347
-                REG_ADMIN_URL
348
-            );
349
-            $content = EE_Registry::instance()->CAP->current_user_can(
350
-                'ee_read_registration',
351
-                'espresso_registrations_view_registration',
352
-                $primary_reg->ID()
353
-            )
354
-                ? '<a href="' . $edit_lnk_url . '"'
355
-                  . ' title="' . esc_attr__('View Registration Details', 'event_espresso') . '">'
356
-                  . $attendee->full_name()
357
-                  . '</a>'
358
-                : $attendee->full_name();
359
-            $content .= '<br>' . $attendee->email();
360
-            return $content;
361
-        }
362
-        return $transaction->failed() || $transaction->is_abandoned()
363
-            ? esc_html__('no contact record.', 'event_espresso')
364
-            : esc_html__(
365
-                'No contact record, because the transaction was abandoned or the registration process failed.',
366
-                'event_espresso'
367
-            );
368
-    }
369
-
370
-
371
-    /**
372
-     *    column_ATT_email
373
-     *
374
-     * @param \EE_Transaction $transaction
375
-     * @return string
376
-     * @throws \EE_Error
377
-     */
378
-    public function column_ATT_email(EE_Transaction $transaction)
379
-    {
380
-        $attendee = $transaction->primary_registration()->get_first_related('Attendee');
381
-        if (! empty($attendee)) {
382
-            return '<a href="mailto:' . $attendee->get('ATT_email') . '">'
383
-                   . $attendee->get('ATT_email')
384
-                   . '</a>';
385
-        } else {
386
-            return $transaction->failed() || $transaction->is_abandoned()
387
-                ? esc_html__('no contact record.', 'event_espresso')
388
-                : esc_html__(
389
-                    'No contact record, because the transaction was abandoned or the registration process failed.',
390
-                    'event_espresso'
391
-                );
392
-        }
393
-    }
394
-
395
-
396
-    /**
397
-     *    column_event_name
398
-     *
399
-     * @param \EE_Transaction $transaction
400
-     * @return string
401
-     * @throws EE_Error
402
-     * @throws InvalidArgumentException
403
-     * @throws InvalidDataTypeException
404
-     * @throws InvalidInterfaceException
405
-     */
406
-    public function column_event_name(EE_Transaction $transaction)
407
-    {
408
-        $actions = array();
409
-        $event = $transaction->primary_registration()->get_first_related('Event');
410
-        if (! empty($event)) {
411
-            $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(
412
-                array('action' => 'edit', 'post' => $event->ID()),
413
-                EVENTS_ADMIN_URL
414
-            );
415
-            $event_name = $event->get('EVT_name');
416
-
417
-            // filter this view by transactions for this event
418
-            $txn_by_event_lnk = EE_Admin_Page::add_query_args_and_nonce(
419
-                array(
420
-                    'action' => 'default',
421
-                    'EVT_ID' => $event->ID(),
422
-                )
423
-            );
424
-            if (empty($this->_req_data['EVT_ID'])
425
-                && EE_Registry::instance()->CAP->current_user_can(
426
-                    'ee_edit_event',
427
-                    'espresso_events_edit',
428
-                    $event->ID()
429
-                )
430
-            ) {
431
-                $actions['filter_by_event'] = '<a href="' . $txn_by_event_lnk . '"'
432
-                                              . ' title="' . esc_attr__(
433
-                                                  'Filter transactions by this event',
434
-                                                  'event_espresso'
435
-                                              ) . '">'
436
-                                              . esc_html__('View Transactions for this event', 'event_espresso')
437
-                                              . '</a>';
438
-            }
439
-
440
-            return sprintf(
441
-                '%1$s %2$s',
442
-                EE_Registry::instance()->CAP->current_user_can(
443
-                    'ee_edit_event',
444
-                    'espresso_events_edit',
445
-                    $event->ID()
446
-                )
447
-                    ? '<a href="' . $edit_event_url . '"'
448
-                      . ' title="'
449
-                      . sprintf(
450
-                          esc_attr__('Edit Event: %s', 'event_espresso'),
451
-                          $event->get('EVT_name')
452
-                      )
453
-                      . '">'
454
-                      . wp_trim_words(
455
-                          $event_name,
456
-                          30,
457
-                          '...'
458
-                      )
459
-                      . '</a>'
460
-                    : wp_trim_words($event_name, 30, '...'),
461
-                $this->row_actions($actions)
462
-            );
463
-        } else {
464
-            return esc_html__(
465
-                'The event associated with this transaction via the primary registration cannot be retrieved.',
466
-                'event_espresso'
467
-            );
468
-        }
469
-    }
470
-
471
-
472
-    /**
473
-     *    column_actions
474
-     *
475
-     * @param \EE_Transaction $transaction
476
-     * @return string
477
-     * @throws \EE_Error
478
-     */
479
-    public function column_actions(EE_Transaction $transaction)
480
-    {
481
-        return $this->_action_string(
482
-            $this->get_transaction_details_link($transaction)
483
-            . $this->get_invoice_link($transaction)
484
-            . $this->get_receipt_link($transaction)
485
-            . $this->get_primary_registration_details_link($transaction)
486
-            . $this->get_send_payment_reminder_trigger_link($transaction)
487
-            . $this->get_payment_overview_link($transaction)
488
-            . $this->get_related_messages_link($transaction),
489
-            $transaction,
490
-            'ul',
491
-            'txn-overview-actions-ul'
492
-        );
493
-    }
494
-
495
-
496
-    /**
497
-     * Get the transaction details link.
498
-     *
499
-     * @param EE_Transaction $transaction
500
-     * @return string
501
-     * @throws EE_Error
502
-     */
503
-    protected function get_transaction_details_link(EE_Transaction $transaction)
504
-    {
505
-        $url = EE_Admin_Page::add_query_args_and_nonce(
506
-            array(
507
-                'action' => 'view_transaction',
508
-                'TXN_ID' => $transaction->ID(),
509
-            ),
510
-            TXN_ADMIN_URL
511
-        );
512
-        return '
140
+		$filters[] = ob_get_contents();
141
+		ob_end_clean();
142
+		return $filters;
143
+	}
144
+
145
+
146
+	/**
147
+	 *_add_view_counts
148
+	 */
149
+	protected function _add_view_counts()
150
+	{
151
+		$this->_views['all']['count'] = $this->_admin_page->get_transactions($this->_per_page, true, 'all');
152
+		$this->_views['abandoned']['count'] = $this->_admin_page->get_transactions($this->_per_page, true, 'abandoned');
153
+		$this->_views['failed']['count'] = $this->_admin_page->get_transactions($this->_per_page, true, 'failed');
154
+	}
155
+
156
+
157
+	/**
158
+	 *    column TXN_ID
159
+	 *
160
+	 * @param \EE_Transaction $transaction
161
+	 * @return string
162
+	 * @throws \EE_Error
163
+	 */
164
+	public function column_TXN_ID(EE_Transaction $transaction)
165
+	{
166
+		$view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
167
+			array(
168
+				'action' => 'view_transaction',
169
+				'TXN_ID' => $transaction->ID(),
170
+			),
171
+			TXN_ADMIN_URL
172
+		);
173
+		$content = '<a href="' . $view_lnk_url . '"'
174
+				   . ' title="' . esc_attr__('Go to Transaction Details', 'event_espresso') . '">'
175
+				   . $transaction->ID()
176
+				   . '</a>';
177
+
178
+		// txn timestamp
179
+		$content .= '  <span class="show-on-mobile-view-only">' . $this->_get_txn_timestamp($transaction) . '</span>';
180
+		return $content;
181
+	}
182
+
183
+
184
+	/**
185
+	 * @param \EE_Transaction $transaction
186
+	 * @return string
187
+	 * @throws EE_Error
188
+	 * @throws InvalidArgumentException
189
+	 * @throws InvalidDataTypeException
190
+	 * @throws InvalidInterfaceException
191
+	 */
192
+	protected function _get_txn_timestamp(EE_Transaction $transaction)
193
+	{
194
+		// is TXN less than 2 hours old ?
195
+		if (($transaction->failed() || $transaction->is_abandoned())
196
+			&& $this->session_lifespan->expiration() < $transaction->datetime(false, true)
197
+		) {
198
+			$timestamp = esc_html__('TXN in progress...', 'event_espresso');
199
+		} else {
200
+			$timestamp = $transaction->get_i18n_datetime('TXN_timestamp');
201
+		}
202
+		return $timestamp;
203
+	}
204
+
205
+
206
+	/**
207
+	 *    column_cb
208
+	 *
209
+	 * @param \EE_Transaction $transaction
210
+	 * @return string
211
+	 * @throws \EE_Error
212
+	 */
213
+	public function column_cb($transaction)
214
+	{
215
+		return sprintf(
216
+			'<input type="checkbox" name="%1$s[]" value="%2$s" />',
217
+			$this->_wp_list_args['singular'],
218
+			$transaction->ID()
219
+		);
220
+	}
221
+
222
+
223
+	/**
224
+	 *    column_TXN_timestamp
225
+	 *
226
+	 * @param \EE_Transaction $transaction
227
+	 * @return string
228
+	 * @throws \EE_Error
229
+	 */
230
+	public function column_TXN_timestamp(EE_Transaction $transaction)
231
+	{
232
+		$view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
233
+			array(
234
+				'action' => 'view_transaction',
235
+				'TXN_ID' => $transaction->ID(),
236
+			),
237
+			TXN_ADMIN_URL
238
+		);
239
+		$txn_date = '<a href="' . $view_lnk_url . '"'
240
+					. ' title="'
241
+					. esc_attr__('View Transaction Details for TXN #', 'event_espresso') . $transaction->ID() . '">'
242
+					. $this->_get_txn_timestamp($transaction)
243
+					. '</a>';
244
+		// status
245
+		$txn_date .= '<br><span class="ee-status-text-small">'
246
+					. EEH_Template::pretty_status(
247
+						$transaction->status_ID(),
248
+						false,
249
+						'sentence'
250
+					)
251
+					 . '</span>';
252
+		return $txn_date;
253
+	}
254
+
255
+
256
+	/**
257
+	 *    column_TXN_total
258
+	 *
259
+	 * @param \EE_Transaction $transaction
260
+	 * @return string
261
+	 * @throws \EE_Error
262
+	 */
263
+	public function column_TXN_total(EE_Transaction $transaction)
264
+	{
265
+		if ($transaction->get('TXN_total') > 0) {
266
+			return '<span class="txn-pad-rght">'
267
+				   . apply_filters(
268
+					   'FHEE__EE_Admin_Transactions_List_Table__column_TXN_total__TXN_total',
269
+					   $transaction->get_pretty('TXN_total'),
270
+					   $transaction
271
+				   )
272
+				   . '</span>';
273
+		} else {
274
+			return '<span class="txn-overview-free-event-spn">' . esc_html__('free', 'event_espresso') . '</span>';
275
+		}
276
+	}
277
+
278
+
279
+	/**
280
+	 *    column_TXN_paid
281
+	 *
282
+	 * @param \EE_Transaction $transaction
283
+	 * @return mixed|string
284
+	 * @throws \EE_Error
285
+	 */
286
+	public function column_TXN_paid(EE_Transaction $transaction)
287
+	{
288
+		$transaction_total = $transaction->get('TXN_total');
289
+		$transaction_paid = $transaction->get('TXN_paid');
290
+
291
+		if (\EEH_Money::compare_floats($transaction_total, 0, '>')) {
292
+			// monies owing
293
+			$span_class = 'txn-overview-part-payment-spn';
294
+			if (\EEH_Money::compare_floats($transaction_paid, $transaction_total, '>=')) {
295
+				// paid in full
296
+				$span_class = 'txn-overview-full-payment-spn';
297
+			} elseif (\EEH_Money::compare_floats($transaction_paid, 0, '==')) {
298
+				// no payments made
299
+				$span_class = 'txn-overview-no-payment-spn';
300
+			}
301
+		} else {
302
+			$span_class = 'txn-overview-free-event-spn';
303
+			$transaction_paid = 0;
304
+		}
305
+
306
+		$payment_method = $transaction->payment_method();
307
+		$payment_method_name = $payment_method instanceof EE_Payment_Method
308
+			? $payment_method->admin_name()
309
+			: esc_html__('Unknown', 'event_espresso');
310
+		$transaction_paid_content = $transaction_paid !== 0 ? $transaction->get_pretty('TXN_paid') : $transaction_paid;
311
+
312
+		$content = '<span class="' . $span_class . ' txn-pad-rght">'
313
+				   . $transaction_paid_content
314
+				   . '</span>';
315
+		if ($transaction_paid > 0) {
316
+			$content .= '<br><span class="ee-status-text-small">'
317
+						. sprintf(
318
+							esc_html__('...via %s', 'event_espresso'),
319
+							$payment_method_name
320
+						)
321
+						. '</span>';
322
+		}
323
+		return $content;
324
+	}
325
+
326
+
327
+	/**
328
+	 *    column_ATT_fname
329
+	 *
330
+	 * @param \EE_Transaction $transaction
331
+	 * @return string
332
+	 * @throws EE_Error
333
+	 * @throws InvalidArgumentException
334
+	 * @throws InvalidDataTypeException
335
+	 * @throws InvalidInterfaceException
336
+	 */
337
+	public function column_ATT_fname(EE_Transaction $transaction)
338
+	{
339
+		$primary_reg = $transaction->primary_registration();
340
+		$attendee = $primary_reg->get_first_related('Attendee');
341
+		if ($attendee instanceof EE_Attendee) {
342
+			$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
343
+				array(
344
+					'action'  => 'view_registration',
345
+					'_REG_ID' => $primary_reg->ID(),
346
+				),
347
+				REG_ADMIN_URL
348
+			);
349
+			$content = EE_Registry::instance()->CAP->current_user_can(
350
+				'ee_read_registration',
351
+				'espresso_registrations_view_registration',
352
+				$primary_reg->ID()
353
+			)
354
+				? '<a href="' . $edit_lnk_url . '"'
355
+				  . ' title="' . esc_attr__('View Registration Details', 'event_espresso') . '">'
356
+				  . $attendee->full_name()
357
+				  . '</a>'
358
+				: $attendee->full_name();
359
+			$content .= '<br>' . $attendee->email();
360
+			return $content;
361
+		}
362
+		return $transaction->failed() || $transaction->is_abandoned()
363
+			? esc_html__('no contact record.', 'event_espresso')
364
+			: esc_html__(
365
+				'No contact record, because the transaction was abandoned or the registration process failed.',
366
+				'event_espresso'
367
+			);
368
+	}
369
+
370
+
371
+	/**
372
+	 *    column_ATT_email
373
+	 *
374
+	 * @param \EE_Transaction $transaction
375
+	 * @return string
376
+	 * @throws \EE_Error
377
+	 */
378
+	public function column_ATT_email(EE_Transaction $transaction)
379
+	{
380
+		$attendee = $transaction->primary_registration()->get_first_related('Attendee');
381
+		if (! empty($attendee)) {
382
+			return '<a href="mailto:' . $attendee->get('ATT_email') . '">'
383
+				   . $attendee->get('ATT_email')
384
+				   . '</a>';
385
+		} else {
386
+			return $transaction->failed() || $transaction->is_abandoned()
387
+				? esc_html__('no contact record.', 'event_espresso')
388
+				: esc_html__(
389
+					'No contact record, because the transaction was abandoned or the registration process failed.',
390
+					'event_espresso'
391
+				);
392
+		}
393
+	}
394
+
395
+
396
+	/**
397
+	 *    column_event_name
398
+	 *
399
+	 * @param \EE_Transaction $transaction
400
+	 * @return string
401
+	 * @throws EE_Error
402
+	 * @throws InvalidArgumentException
403
+	 * @throws InvalidDataTypeException
404
+	 * @throws InvalidInterfaceException
405
+	 */
406
+	public function column_event_name(EE_Transaction $transaction)
407
+	{
408
+		$actions = array();
409
+		$event = $transaction->primary_registration()->get_first_related('Event');
410
+		if (! empty($event)) {
411
+			$edit_event_url = EE_Admin_Page::add_query_args_and_nonce(
412
+				array('action' => 'edit', 'post' => $event->ID()),
413
+				EVENTS_ADMIN_URL
414
+			);
415
+			$event_name = $event->get('EVT_name');
416
+
417
+			// filter this view by transactions for this event
418
+			$txn_by_event_lnk = EE_Admin_Page::add_query_args_and_nonce(
419
+				array(
420
+					'action' => 'default',
421
+					'EVT_ID' => $event->ID(),
422
+				)
423
+			);
424
+			if (empty($this->_req_data['EVT_ID'])
425
+				&& EE_Registry::instance()->CAP->current_user_can(
426
+					'ee_edit_event',
427
+					'espresso_events_edit',
428
+					$event->ID()
429
+				)
430
+			) {
431
+				$actions['filter_by_event'] = '<a href="' . $txn_by_event_lnk . '"'
432
+											  . ' title="' . esc_attr__(
433
+												  'Filter transactions by this event',
434
+												  'event_espresso'
435
+											  ) . '">'
436
+											  . esc_html__('View Transactions for this event', 'event_espresso')
437
+											  . '</a>';
438
+			}
439
+
440
+			return sprintf(
441
+				'%1$s %2$s',
442
+				EE_Registry::instance()->CAP->current_user_can(
443
+					'ee_edit_event',
444
+					'espresso_events_edit',
445
+					$event->ID()
446
+				)
447
+					? '<a href="' . $edit_event_url . '"'
448
+					  . ' title="'
449
+					  . sprintf(
450
+						  esc_attr__('Edit Event: %s', 'event_espresso'),
451
+						  $event->get('EVT_name')
452
+					  )
453
+					  . '">'
454
+					  . wp_trim_words(
455
+						  $event_name,
456
+						  30,
457
+						  '...'
458
+					  )
459
+					  . '</a>'
460
+					: wp_trim_words($event_name, 30, '...'),
461
+				$this->row_actions($actions)
462
+			);
463
+		} else {
464
+			return esc_html__(
465
+				'The event associated with this transaction via the primary registration cannot be retrieved.',
466
+				'event_espresso'
467
+			);
468
+		}
469
+	}
470
+
471
+
472
+	/**
473
+	 *    column_actions
474
+	 *
475
+	 * @param \EE_Transaction $transaction
476
+	 * @return string
477
+	 * @throws \EE_Error
478
+	 */
479
+	public function column_actions(EE_Transaction $transaction)
480
+	{
481
+		return $this->_action_string(
482
+			$this->get_transaction_details_link($transaction)
483
+			. $this->get_invoice_link($transaction)
484
+			. $this->get_receipt_link($transaction)
485
+			. $this->get_primary_registration_details_link($transaction)
486
+			. $this->get_send_payment_reminder_trigger_link($transaction)
487
+			. $this->get_payment_overview_link($transaction)
488
+			. $this->get_related_messages_link($transaction),
489
+			$transaction,
490
+			'ul',
491
+			'txn-overview-actions-ul'
492
+		);
493
+	}
494
+
495
+
496
+	/**
497
+	 * Get the transaction details link.
498
+	 *
499
+	 * @param EE_Transaction $transaction
500
+	 * @return string
501
+	 * @throws EE_Error
502
+	 */
503
+	protected function get_transaction_details_link(EE_Transaction $transaction)
504
+	{
505
+		$url = EE_Admin_Page::add_query_args_and_nonce(
506
+			array(
507
+				'action' => 'view_transaction',
508
+				'TXN_ID' => $transaction->ID(),
509
+			),
510
+			TXN_ADMIN_URL
511
+		);
512
+		return '
513 513
 			<li>
514 514
 				<a href="' . $url . '"'
515
-               . ' title="' . esc_attr__('View Transaction Details', 'event_espresso') . '" class="tiny-text">
515
+			   . ' title="' . esc_attr__('View Transaction Details', 'event_espresso') . '" class="tiny-text">
516 516
 					<span class="dashicons dashicons-cart"></span>
517 517
 				</a>
518 518
 			</li>';
519
-    }
520
-
521
-
522
-    /**
523
-     * Get the invoice link for the given registration.
524
-     *
525
-     * @param EE_Transaction $transaction
526
-     * @return string
527
-     * @throws EE_Error
528
-     */
529
-    protected function get_invoice_link(EE_Transaction $transaction)
530
-    {
531
-        $registration = $transaction->primary_registration();
532
-        if ($registration instanceof EE_Registration) {
533
-            $url = $registration->invoice_url();
534
-            // only show invoice link if message type is active.
535
-            if ($registration->attendee() instanceof EE_Attendee
536
-                && EEH_MSG_Template::is_mt_active('invoice')
537
-            ) {
538
-                return '
519
+	}
520
+
521
+
522
+	/**
523
+	 * Get the invoice link for the given registration.
524
+	 *
525
+	 * @param EE_Transaction $transaction
526
+	 * @return string
527
+	 * @throws EE_Error
528
+	 */
529
+	protected function get_invoice_link(EE_Transaction $transaction)
530
+	{
531
+		$registration = $transaction->primary_registration();
532
+		if ($registration instanceof EE_Registration) {
533
+			$url = $registration->invoice_url();
534
+			// only show invoice link if message type is active.
535
+			if ($registration->attendee() instanceof EE_Attendee
536
+				&& EEH_MSG_Template::is_mt_active('invoice')
537
+			) {
538
+				return '
539 539
                 <li>
540 540
                     <a title="' . esc_attr__('View Transaction Invoice', 'event_espresso') . '"'
541
-                       . ' target="_blank" href="' . $url . '" class="tiny-text">
541
+					   . ' target="_blank" href="' . $url . '" class="tiny-text">
542 542
                         <span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span>
543 543
                     </a>
544 544
                 </li>';
545
-            }
546
-        }
547
-        return '';
548
-    }
549
-
550
-
551
-    /**
552
-     * Get the receipt link for the transaction.
553
-     *
554
-     * @param EE_Transaction $transaction
555
-     * @return string
556
-     * @throws EE_Error
557
-     */
558
-    protected function get_receipt_link(EE_Transaction $transaction)
559
-    {
560
-        $registration = $transaction->primary_registration();
561
-        if ($registration instanceof EE_Registration) {
562
-            $url = $registration->receipt_url();
563
-            // only show receipt link if message type is active.
564
-            if ($registration->attendee() instanceof EE_Attendee
565
-                && EEH_MSG_Template::is_mt_active('receipt')) {
566
-                return '
545
+			}
546
+		}
547
+		return '';
548
+	}
549
+
550
+
551
+	/**
552
+	 * Get the receipt link for the transaction.
553
+	 *
554
+	 * @param EE_Transaction $transaction
555
+	 * @return string
556
+	 * @throws EE_Error
557
+	 */
558
+	protected function get_receipt_link(EE_Transaction $transaction)
559
+	{
560
+		$registration = $transaction->primary_registration();
561
+		if ($registration instanceof EE_Registration) {
562
+			$url = $registration->receipt_url();
563
+			// only show receipt link if message type is active.
564
+			if ($registration->attendee() instanceof EE_Attendee
565
+				&& EEH_MSG_Template::is_mt_active('receipt')) {
566
+				return '
567 567
 			<li>
568 568
 				<a title="' . esc_attr__('View Transaction Receipt', 'event_espresso') . '"'
569
-                       . ' target="_blank" href="' . $url . '" class="tiny-text">
569
+					   . ' target="_blank" href="' . $url . '" class="tiny-text">
570 570
 					<span class="dashicons dashicons-media-default ee-icon-size-18"></span>
571 571
 				</a>
572 572
 			</li>';
573
-            }
574
-        }
575
-        return '';
576
-    }
577
-
578
-
579
-    /**
580
-     * Get the link to view the details for the primary registration.
581
-     *
582
-     * @param EE_Transaction $transaction
583
-     * @return string
584
-     * @throws EE_Error
585
-     * @throws InvalidArgumentException
586
-     * @throws InvalidDataTypeException
587
-     * @throws InvalidInterfaceException
588
-     */
589
-    protected function get_primary_registration_details_link(EE_Transaction $transaction)
590
-    {
591
-        $registration = $transaction->primary_registration();
592
-        if ($registration instanceof EE_Registration) {
593
-            $url = EE_Admin_Page::add_query_args_and_nonce(
594
-                array(
595
-                    'action'  => 'view_registration',
596
-                    '_REG_ID' => $registration->ID(),
597
-                ),
598
-                REG_ADMIN_URL
599
-            );
600
-            return EE_Registry::instance()->CAP->current_user_can(
601
-                'ee_read_registration',
602
-                'espresso_registrations_view_registration',
603
-                $registration->ID()
604
-            )
605
-                ? '
573
+			}
574
+		}
575
+		return '';
576
+	}
577
+
578
+
579
+	/**
580
+	 * Get the link to view the details for the primary registration.
581
+	 *
582
+	 * @param EE_Transaction $transaction
583
+	 * @return string
584
+	 * @throws EE_Error
585
+	 * @throws InvalidArgumentException
586
+	 * @throws InvalidDataTypeException
587
+	 * @throws InvalidInterfaceException
588
+	 */
589
+	protected function get_primary_registration_details_link(EE_Transaction $transaction)
590
+	{
591
+		$registration = $transaction->primary_registration();
592
+		if ($registration instanceof EE_Registration) {
593
+			$url = EE_Admin_Page::add_query_args_and_nonce(
594
+				array(
595
+					'action'  => 'view_registration',
596
+					'_REG_ID' => $registration->ID(),
597
+				),
598
+				REG_ADMIN_URL
599
+			);
600
+			return EE_Registry::instance()->CAP->current_user_can(
601
+				'ee_read_registration',
602
+				'espresso_registrations_view_registration',
603
+				$registration->ID()
604
+			)
605
+				? '
606 606
 				<li>
607 607
 					<a href="' . $url . '"'
608
-                  . ' title="' . esc_attr__('View Registration Details', 'event_espresso') . '" class="tiny-text">
608
+				  . ' title="' . esc_attr__('View Registration Details', 'event_espresso') . '" class="tiny-text">
609 609
 						<span class="dashicons dashicons-clipboard"></span>
610 610
 					</a>
611 611
 				</li>'
612
-                : '';
613
-        }
614
-        return '';
615
-    }
616
-
617
-
618
-    /**
619
-     * Get send payment reminder trigger link
620
-     *
621
-     * @param EE_Transaction $transaction
622
-     * @return string
623
-     * @throws EE_Error
624
-     * @throws InvalidArgumentException
625
-     * @throws InvalidDataTypeException
626
-     * @throws InvalidInterfaceException
627
-     */
628
-    protected function get_send_payment_reminder_trigger_link(EE_Transaction $transaction)
629
-    {
630
-        $registration = $transaction->primary_registration();
631
-        if ($registration instanceof EE_Registration
632
-            && $registration->attendee() instanceof EE_Attendee
633
-            && EEH_MSG_Template::is_mt_active('payment_reminder')
634
-            && ! in_array(
635
-                $transaction->status_ID(),
636
-                array(EEM_Transaction::complete_status_code, EEM_Transaction::overpaid_status_code),
637
-                true
638
-            )
639
-            && EE_Registry::instance()->CAP->current_user_can(
640
-                'ee_send_message',
641
-                'espresso_transactions_send_payment_reminder'
642
-            )
643
-        ) {
644
-            $url = EE_Admin_Page::add_query_args_and_nonce(
645
-                array(
646
-                    'action' => 'send_payment_reminder',
647
-                    'TXN_ID' => $transaction->ID(),
648
-                ),
649
-                TXN_ADMIN_URL
650
-            );
651
-            return '
612
+				: '';
613
+		}
614
+		return '';
615
+	}
616
+
617
+
618
+	/**
619
+	 * Get send payment reminder trigger link
620
+	 *
621
+	 * @param EE_Transaction $transaction
622
+	 * @return string
623
+	 * @throws EE_Error
624
+	 * @throws InvalidArgumentException
625
+	 * @throws InvalidDataTypeException
626
+	 * @throws InvalidInterfaceException
627
+	 */
628
+	protected function get_send_payment_reminder_trigger_link(EE_Transaction $transaction)
629
+	{
630
+		$registration = $transaction->primary_registration();
631
+		if ($registration instanceof EE_Registration
632
+			&& $registration->attendee() instanceof EE_Attendee
633
+			&& EEH_MSG_Template::is_mt_active('payment_reminder')
634
+			&& ! in_array(
635
+				$transaction->status_ID(),
636
+				array(EEM_Transaction::complete_status_code, EEM_Transaction::overpaid_status_code),
637
+				true
638
+			)
639
+			&& EE_Registry::instance()->CAP->current_user_can(
640
+				'ee_send_message',
641
+				'espresso_transactions_send_payment_reminder'
642
+			)
643
+		) {
644
+			$url = EE_Admin_Page::add_query_args_and_nonce(
645
+				array(
646
+					'action' => 'send_payment_reminder',
647
+					'TXN_ID' => $transaction->ID(),
648
+				),
649
+				TXN_ADMIN_URL
650
+			);
651
+			return '
652 652
             <li>
653 653
                 <a href="' . $url . '"'
654
-                   . ' title="' . esc_attr__('Send Payment Reminder', 'event_espresso') . '" class="tiny-text">
654
+				   . ' title="' . esc_attr__('Send Payment Reminder', 'event_espresso') . '" class="tiny-text">
655 655
                     <span class="dashicons dashicons-email-alt"></span>
656 656
                 </a>
657 657
             </li>';
658
-        }
659
-        return '';
660
-    }
661
-
662
-
663
-    /**
664
-     * Get link to filtered view in the message activity list table of messages for this transaction.
665
-     *
666
-     * @param EE_Transaction $transaction
667
-     * @return string
668
-     * @throws EE_Error
669
-     * @throws InvalidArgumentException
670
-     * @throws InvalidDataTypeException
671
-     * @throws InvalidInterfaceException
672
-     */
673
-    protected function get_related_messages_link(EE_Transaction $transaction)
674
-    {
675
-        $url = EEH_MSG_Template::get_message_action_link(
676
-            'see_notifications_for',
677
-            null,
678
-            array('TXN_ID' => $transaction->ID())
679
-        );
680
-        return EE_Registry::instance()->CAP->current_user_can(
681
-            'ee_read_global_messages',
682
-            'view_filtered_messages'
683
-        )
684
-            ? '<li>' . $url . '</li>'
685
-            : '';
686
-    }
687
-
688
-
689
-    /**
690
-     * Return the link to make a payment on the frontend
691
-     *
692
-     * @param EE_Transaction $transaction
693
-     * @return string
694
-     * @throws EE_Error
695
-     */
696
-    protected function get_payment_overview_link(EE_Transaction $transaction)
697
-    {
698
-        $registration = $transaction->primary_registration();
699
-        if ($registration instanceof EE_Registration
700
-            && $transaction->status_ID() !== EEM_Transaction::complete_status_code
701
-            && $registration->owes_monies_and_can_pay()
702
-        ) {
703
-            return '
658
+		}
659
+		return '';
660
+	}
661
+
662
+
663
+	/**
664
+	 * Get link to filtered view in the message activity list table of messages for this transaction.
665
+	 *
666
+	 * @param EE_Transaction $transaction
667
+	 * @return string
668
+	 * @throws EE_Error
669
+	 * @throws InvalidArgumentException
670
+	 * @throws InvalidDataTypeException
671
+	 * @throws InvalidInterfaceException
672
+	 */
673
+	protected function get_related_messages_link(EE_Transaction $transaction)
674
+	{
675
+		$url = EEH_MSG_Template::get_message_action_link(
676
+			'see_notifications_for',
677
+			null,
678
+			array('TXN_ID' => $transaction->ID())
679
+		);
680
+		return EE_Registry::instance()->CAP->current_user_can(
681
+			'ee_read_global_messages',
682
+			'view_filtered_messages'
683
+		)
684
+			? '<li>' . $url . '</li>'
685
+			: '';
686
+	}
687
+
688
+
689
+	/**
690
+	 * Return the link to make a payment on the frontend
691
+	 *
692
+	 * @param EE_Transaction $transaction
693
+	 * @return string
694
+	 * @throws EE_Error
695
+	 */
696
+	protected function get_payment_overview_link(EE_Transaction $transaction)
697
+	{
698
+		$registration = $transaction->primary_registration();
699
+		if ($registration instanceof EE_Registration
700
+			&& $transaction->status_ID() !== EEM_Transaction::complete_status_code
701
+			&& $registration->owes_monies_and_can_pay()
702
+		) {
703
+			return '
704 704
             <li>
705 705
                 <a title="' . esc_attr__('Make Payment from the Frontend.', 'event_espresso') . '"'
706
-                   . ' target="_blank" href="' . $registration->payment_overview_url(true) . '"'
707
-                   . ' class="tiny-text">
706
+				   . ' target="_blank" href="' . $registration->payment_overview_url(true) . '"'
707
+				   . ' class="tiny-text">
708 708
                     <span class="dashicons dashicons-money ee-icon-size-18"></span>
709 709
                 </a>
710 710
             </li>
711 711
             ';
712
-        }
713
-        return '';
714
-    }
712
+		}
713
+		return '';
714
+	}
715 715
 }
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
     {
97 97
         $class = parent::_get_row_class($transaction);
98 98
         // add status class
99
-        $class .= ' ee-status-strip txn-status-' . $transaction->status_ID();
99
+        $class .= ' ee-status-strip txn-status-'.$transaction->status_ID();
100 100
         if ($this->_has_checkbox_column) {
101 101
             $class .= ' has-checkbox-column';
102 102
         }
@@ -170,13 +170,13 @@  discard block
 block discarded – undo
170 170
             ),
171 171
             TXN_ADMIN_URL
172 172
         );
173
-        $content = '<a href="' . $view_lnk_url . '"'
174
-                   . ' title="' . esc_attr__('Go to Transaction Details', 'event_espresso') . '">'
173
+        $content = '<a href="'.$view_lnk_url.'"'
174
+                   . ' title="'.esc_attr__('Go to Transaction Details', 'event_espresso').'">'
175 175
                    . $transaction->ID()
176 176
                    . '</a>';
177 177
 
178 178
         // txn timestamp
179
-        $content .= '  <span class="show-on-mobile-view-only">' . $this->_get_txn_timestamp($transaction) . '</span>';
179
+        $content .= '  <span class="show-on-mobile-view-only">'.$this->_get_txn_timestamp($transaction).'</span>';
180 180
         return $content;
181 181
     }
182 182
 
@@ -236,9 +236,9 @@  discard block
 block discarded – undo
236 236
             ),
237 237
             TXN_ADMIN_URL
238 238
         );
239
-        $txn_date = '<a href="' . $view_lnk_url . '"'
239
+        $txn_date = '<a href="'.$view_lnk_url.'"'
240 240
                     . ' title="'
241
-                    . esc_attr__('View Transaction Details for TXN #', 'event_espresso') . $transaction->ID() . '">'
241
+                    . esc_attr__('View Transaction Details for TXN #', 'event_espresso').$transaction->ID().'">'
242 242
                     . $this->_get_txn_timestamp($transaction)
243 243
                     . '</a>';
244 244
         // status
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
                    )
272 272
                    . '</span>';
273 273
         } else {
274
-            return '<span class="txn-overview-free-event-spn">' . esc_html__('free', 'event_espresso') . '</span>';
274
+            return '<span class="txn-overview-free-event-spn">'.esc_html__('free', 'event_espresso').'</span>';
275 275
         }
276 276
     }
277 277
 
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
             : esc_html__('Unknown', 'event_espresso');
310 310
         $transaction_paid_content = $transaction_paid !== 0 ? $transaction->get_pretty('TXN_paid') : $transaction_paid;
311 311
 
312
-        $content = '<span class="' . $span_class . ' txn-pad-rght">'
312
+        $content = '<span class="'.$span_class.' txn-pad-rght">'
313 313
                    . $transaction_paid_content
314 314
                    . '</span>';
315 315
         if ($transaction_paid > 0) {
@@ -351,12 +351,12 @@  discard block
 block discarded – undo
351 351
                 'espresso_registrations_view_registration',
352 352
                 $primary_reg->ID()
353 353
             )
354
-                ? '<a href="' . $edit_lnk_url . '"'
355
-                  . ' title="' . esc_attr__('View Registration Details', 'event_espresso') . '">'
354
+                ? '<a href="'.$edit_lnk_url.'"'
355
+                  . ' title="'.esc_attr__('View Registration Details', 'event_espresso').'">'
356 356
                   . $attendee->full_name()
357 357
                   . '</a>'
358 358
                 : $attendee->full_name();
359
-            $content .= '<br>' . $attendee->email();
359
+            $content .= '<br>'.$attendee->email();
360 360
             return $content;
361 361
         }
362 362
         return $transaction->failed() || $transaction->is_abandoned()
@@ -378,8 +378,8 @@  discard block
 block discarded – undo
378 378
     public function column_ATT_email(EE_Transaction $transaction)
379 379
     {
380 380
         $attendee = $transaction->primary_registration()->get_first_related('Attendee');
381
-        if (! empty($attendee)) {
382
-            return '<a href="mailto:' . $attendee->get('ATT_email') . '">'
381
+        if ( ! empty($attendee)) {
382
+            return '<a href="mailto:'.$attendee->get('ATT_email').'">'
383 383
                    . $attendee->get('ATT_email')
384 384
                    . '</a>';
385 385
         } else {
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
     {
408 408
         $actions = array();
409 409
         $event = $transaction->primary_registration()->get_first_related('Event');
410
-        if (! empty($event)) {
410
+        if ( ! empty($event)) {
411 411
             $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(
412 412
                 array('action' => 'edit', 'post' => $event->ID()),
413 413
                 EVENTS_ADMIN_URL
@@ -428,11 +428,11 @@  discard block
 block discarded – undo
428 428
                     $event->ID()
429 429
                 )
430 430
             ) {
431
-                $actions['filter_by_event'] = '<a href="' . $txn_by_event_lnk . '"'
432
-                                              . ' title="' . esc_attr__(
431
+                $actions['filter_by_event'] = '<a href="'.$txn_by_event_lnk.'"'
432
+                                              . ' title="'.esc_attr__(
433 433
                                                   'Filter transactions by this event',
434 434
                                                   'event_espresso'
435
-                                              ) . '">'
435
+                                              ).'">'
436 436
                                               . esc_html__('View Transactions for this event', 'event_espresso')
437 437
                                               . '</a>';
438 438
             }
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
                     'espresso_events_edit',
445 445
                     $event->ID()
446 446
                 )
447
-                    ? '<a href="' . $edit_event_url . '"'
447
+                    ? '<a href="'.$edit_event_url.'"'
448 448
                       . ' title="'
449 449
                       . sprintf(
450 450
                           esc_attr__('Edit Event: %s', 'event_espresso'),
@@ -511,8 +511,8 @@  discard block
 block discarded – undo
511 511
         );
512 512
         return '
513 513
 			<li>
514
-				<a href="' . $url . '"'
515
-               . ' title="' . esc_attr__('View Transaction Details', 'event_espresso') . '" class="tiny-text">
514
+				<a href="' . $url.'"'
515
+               . ' title="'.esc_attr__('View Transaction Details', 'event_espresso').'" class="tiny-text">
516 516
 					<span class="dashicons dashicons-cart"></span>
517 517
 				</a>
518 518
 			</li>';
@@ -537,8 +537,8 @@  discard block
 block discarded – undo
537 537
             ) {
538 538
                 return '
539 539
                 <li>
540
-                    <a title="' . esc_attr__('View Transaction Invoice', 'event_espresso') . '"'
541
-                       . ' target="_blank" href="' . $url . '" class="tiny-text">
540
+                    <a title="' . esc_attr__('View Transaction Invoice', 'event_espresso').'"'
541
+                       . ' target="_blank" href="'.$url.'" class="tiny-text">
542 542
                         <span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span>
543 543
                     </a>
544 544
                 </li>';
@@ -565,8 +565,8 @@  discard block
 block discarded – undo
565 565
                 && EEH_MSG_Template::is_mt_active('receipt')) {
566 566
                 return '
567 567
 			<li>
568
-				<a title="' . esc_attr__('View Transaction Receipt', 'event_espresso') . '"'
569
-                       . ' target="_blank" href="' . $url . '" class="tiny-text">
568
+				<a title="' . esc_attr__('View Transaction Receipt', 'event_espresso').'"'
569
+                       . ' target="_blank" href="'.$url.'" class="tiny-text">
570 570
 					<span class="dashicons dashicons-media-default ee-icon-size-18"></span>
571 571
 				</a>
572 572
 			</li>';
@@ -604,8 +604,8 @@  discard block
 block discarded – undo
604 604
             )
605 605
                 ? '
606 606
 				<li>
607
-					<a href="' . $url . '"'
608
-                  . ' title="' . esc_attr__('View Registration Details', 'event_espresso') . '" class="tiny-text">
607
+					<a href="' . $url.'"'
608
+                  . ' title="'.esc_attr__('View Registration Details', 'event_espresso').'" class="tiny-text">
609 609
 						<span class="dashicons dashicons-clipboard"></span>
610 610
 					</a>
611 611
 				</li>'
@@ -650,8 +650,8 @@  discard block
 block discarded – undo
650 650
             );
651 651
             return '
652 652
             <li>
653
-                <a href="' . $url . '"'
654
-                   . ' title="' . esc_attr__('Send Payment Reminder', 'event_espresso') . '" class="tiny-text">
653
+                <a href="' . $url.'"'
654
+                   . ' title="'.esc_attr__('Send Payment Reminder', 'event_espresso').'" class="tiny-text">
655 655
                     <span class="dashicons dashicons-email-alt"></span>
656 656
                 </a>
657 657
             </li>';
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
             'ee_read_global_messages',
682 682
             'view_filtered_messages'
683 683
         )
684
-            ? '<li>' . $url . '</li>'
684
+            ? '<li>'.$url.'</li>'
685 685
             : '';
686 686
     }
687 687
 
@@ -702,8 +702,8 @@  discard block
 block discarded – undo
702 702
         ) {
703 703
             return '
704 704
             <li>
705
-                <a title="' . esc_attr__('Make Payment from the Frontend.', 'event_espresso') . '"'
706
-                   . ' target="_blank" href="' . $registration->payment_overview_url(true) . '"'
705
+                <a title="' . esc_attr__('Make Payment from the Frontend.', 'event_espresso').'"'
706
+                   . ' target="_blank" href="'.$registration->payment_overview_url(true).'"'
707 707
                    . ' class="tiny-text">
708 708
                     <span class="dashicons dashicons-money ee-icon-size-18"></span>
709 709
                 </a>
Please login to merge, or discard this patch.
acceptance_tests/Helpers/CountrySettingsAdmin.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 namespace EventEspresso\Codeception\helpers;
3 3
 
4
-use Page\CoreAdmin;
5 4
 use Page\CountrySettingsAdmin as CountrySettings;
6 5
 
7 6
 trait CountrySettingsAdmin
Please login to merge, or discard this patch.
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -6,59 +6,59 @@
 block discarded – undo
6 6
 
7 7
 trait CountrySettingsAdmin
8 8
 {
9
-    /**
10
-     * Instructs the actor to browse to the country settings page.
11
-     * Assumes the actor is already logged in.
12
-     * @param string $additional_params
13
-     */
14
-    public function amOnCountrySettingsAdminPage($additional_params = '')
15
-    {
16
-        $this->actor()->amOnAdminPage(CountrySettings::url($additional_params));
17
-    }
9
+	/**
10
+	 * Instructs the actor to browse to the country settings page.
11
+	 * Assumes the actor is already logged in.
12
+	 * @param string $additional_params
13
+	 */
14
+	public function amOnCountrySettingsAdminPage($additional_params = '')
15
+	{
16
+		$this->actor()->amOnAdminPage(CountrySettings::url($additional_params));
17
+	}
18 18
 
19 19
 
20
-    /**
21
-     * Instructs the actor to select the given decimal places radio option.
22
-     * Assumes the actor is already on the country settings page.
23
-     * @param string $decimal_places
24
-     * @param string $country_code
25
-     */
26
-    public function setCurrencyDecimalPlacesTo($decimal_places = '2', $country_code = 'US')
27
-    {
28
-        $this->actor()->click(CountrySettings::currencyDecimalPlacesRadioField($decimal_places, $country_code));
29
-    }
20
+	/**
21
+	 * Instructs the actor to select the given decimal places radio option.
22
+	 * Assumes the actor is already on the country settings page.
23
+	 * @param string $decimal_places
24
+	 * @param string $country_code
25
+	 */
26
+	public function setCurrencyDecimalPlacesTo($decimal_places = '2', $country_code = 'US')
27
+	{
28
+		$this->actor()->click(CountrySettings::currencyDecimalPlacesRadioField($decimal_places, $country_code));
29
+	}
30 30
 
31 31
 
32
-    /**
33
-     * Instructs the actor to select the given decimal mark radio option.
34
-     * Assumes the actor is already on the country settings page.
35
-     * @param string $decimal_mark
36
-     */
37
-    public function setCurrencyDecimalMarkTo($decimal_mark = '.')
38
-    {
39
-        $this->actor()->click(CountrySettings::currencyDecimalMarkRadioField($decimal_mark));
40
-    }
32
+	/**
33
+	 * Instructs the actor to select the given decimal mark radio option.
34
+	 * Assumes the actor is already on the country settings page.
35
+	 * @param string $decimal_mark
36
+	 */
37
+	public function setCurrencyDecimalMarkTo($decimal_mark = '.')
38
+	{
39
+		$this->actor()->click(CountrySettings::currencyDecimalMarkRadioField($decimal_mark));
40
+	}
41 41
 
42 42
 
43
-    /**
44
-     * Instructs the actor to select the given thousands separator radio option.
45
-     * Assumes the actor is already on the country settings page.
46
-     * @param string $thousands_seperator
47
-     */
48
-    public function setCurrencyThousandsSeparatorTo($thousands_seperator = ',')
49
-    {
50
-        $this->actor()->click(CountrySettings::currencyThousandsSeparatorField($thousands_seperator));
51
-    }
43
+	/**
44
+	 * Instructs the actor to select the given thousands separator radio option.
45
+	 * Assumes the actor is already on the country settings page.
46
+	 * @param string $thousands_seperator
47
+	 */
48
+	public function setCurrencyThousandsSeparatorTo($thousands_seperator = ',')
49
+	{
50
+		$this->actor()->click(CountrySettings::currencyThousandsSeparatorField($thousands_seperator));
51
+	}
52 52
 
53 53
 
54
-    /**
55
-     * Clicks the country settings submit button.
56
-     * Assumes the actor is on the country settings admin page.
57
-     */
58
-    public function saveCountrySettings()
59
-    {
60
-        $this->actor()->click(CountrySettings::COUNTRY_SETTINGS_SAVE_BUTTON);
61
-        //no indicator on the page when stuff has been updated so just give a bit of time for it to finish.
62
-        $this->actor()->wait(10);
63
-    }
54
+	/**
55
+	 * Clicks the country settings submit button.
56
+	 * Assumes the actor is on the country settings admin page.
57
+	 */
58
+	public function saveCountrySettings()
59
+	{
60
+		$this->actor()->click(CountrySettings::COUNTRY_SETTINGS_SAVE_BUTTON);
61
+		//no indicator on the page when stuff has been updated so just give a bit of time for it to finish.
62
+		$this->actor()->wait(10);
63
+	}
64 64
 }
65 65
\ No newline at end of file
Please login to merge, or discard this patch.
acceptance_tests/Page/CountrySettingsAdmin.php 1 patch
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -14,51 +14,51 @@
 block discarded – undo
14 14
 {
15 15
 
16 16
 
17
-    const COUNTRY_SETTINGS_SAVE_BUTTON = '#country_settings_save_2';
17
+	const COUNTRY_SETTINGS_SAVE_BUTTON = '#country_settings_save_2';
18 18
 
19 19
 
20 20
 
21
-    /**
22
-     * Return the url for the country settings admin page.
23
-     * @param string $additional_params
24
-     * @return string
25
-     */
26
-    public static function url($additional_params = '')
27
-    {
28
-        return self::adminUrl('espresso_general_settings', 'country_settings', $additional_params);
29
-    }
21
+	/**
22
+	 * Return the url for the country settings admin page.
23
+	 * @param string $additional_params
24
+	 * @return string
25
+	 */
26
+	public static function url($additional_params = '')
27
+	{
28
+		return self::adminUrl('espresso_general_settings', 'country_settings', $additional_params);
29
+	}
30 30
 
31 31
 
32
-    /**
33
-     * Return the decimal places (precision) radio field locator for selection.
34
-     * @param int    $decimal_place_value
35
-     * @param string $country_code
36
-     * @return string
37
-     */
38
-    public static function currencyDecimalPlacesRadioField($decimal_place_value = 2, $country_code = 'US')
39
-    {
40
-        return "//input[@id='CNT_cur_dec_plc-$country_code-$decimal_place_value']";
41
-    }
32
+	/**
33
+	 * Return the decimal places (precision) radio field locator for selection.
34
+	 * @param int    $decimal_place_value
35
+	 * @param string $country_code
36
+	 * @return string
37
+	 */
38
+	public static function currencyDecimalPlacesRadioField($decimal_place_value = 2, $country_code = 'US')
39
+	{
40
+		return "//input[@id='CNT_cur_dec_plc-$country_code-$decimal_place_value']";
41
+	}
42 42
 
43 43
 
44
-    /**
45
-     * Return the currency decimal mark field locator for selection.
46
-     * @param string $decimal_mark
47
-     * @return string
48
-     */
49
-    public static function currencyDecimalMarkRadioField($decimal_mark = '.')
50
-    {
51
-        return "//input[@class='CNT_cur_dec_mrk' and @value='$decimal_mark']";
52
-    }
44
+	/**
45
+	 * Return the currency decimal mark field locator for selection.
46
+	 * @param string $decimal_mark
47
+	 * @return string
48
+	 */
49
+	public static function currencyDecimalMarkRadioField($decimal_mark = '.')
50
+	{
51
+		return "//input[@class='CNT_cur_dec_mrk' and @value='$decimal_mark']";
52
+	}
53 53
 
54 54
 
55
-    /**
56
-     * Return the currency thousands separator field locator for selection.
57
-     * @param string $thousands_separator
58
-     * @return string
59
-     */
60
-    public static function currencyThousandsSeparatorField($thousands_separator = ',')
61
-    {
62
-        return "//input[@class='CNT_cur_thsnds' and @value='$thousands_separator']";
63
-    }
55
+	/**
56
+	 * Return the currency thousands separator field locator for selection.
57
+	 * @param string $thousands_separator
58
+	 * @return string
59
+	 */
60
+	public static function currencyThousandsSeparatorField($thousands_separator = ',')
61
+	{
62
+		return "//input[@class='CNT_cur_thsnds' and @value='$thousands_separator']";
63
+	}
64 64
 }
65 65
\ No newline at end of file
Please login to merge, or discard this patch.
admin_pages/general_settings/General_Settings_Admin_Page.core.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -748,7 +748,7 @@  discard block
 block discarded – undo
748 748
      *
749 749
      * @access    public
750 750
      * @param    string $CNT_ISO
751
-     * @return mixed string | array
751
+     * @return string|null string | array
752 752
      * @throws DomainException
753 753
      */
754 754
     public function display_country_settings($CNT_ISO = '')
@@ -1064,7 +1064,7 @@  discard block
 block discarded – undo
1064 1064
      *        delete_state
1065 1065
      *
1066 1066
      * @access    public
1067
-     * @return        boolean
1067
+     * @return        false|null
1068 1068
      */
1069 1069
     public function delete_state()
1070 1070
     {
Please login to merge, or discard this patch.
Indentation   +1389 added lines, -1389 removed lines patch added patch discarded remove patch
@@ -16,1404 +16,1404 @@
 block discarded – undo
16 16
 {
17 17
 
18 18
 
19
-    /**
20
-     * _question_group
21
-     * holds the specific question group object for the question group details screen
22
-     *
23
-     * @var object
24
-     */
25
-    protected $_question_group;
26
-
27
-
28
-    /**
29
-     * Initialize basic properties.
30
-     */
31
-    protected function _init_page_props()
32
-    {
33
-        $this->page_slug = GEN_SET_PG_SLUG;
34
-        $this->page_label = GEN_SET_LABEL;
35
-        $this->_admin_base_url = GEN_SET_ADMIN_URL;
36
-        $this->_admin_base_path = GEN_SET_ADMIN;
37
-    }
38
-
39
-
40
-    /**
41
-     * Set ajax hooks
42
-     */
43
-    protected function _ajax_hooks()
44
-    {
45
-        add_action('wp_ajax_espresso_display_country_settings', array($this, 'display_country_settings'));
46
-        add_action('wp_ajax_espresso_display_country_states', array($this, 'display_country_states'));
47
-        add_action('wp_ajax_espresso_delete_state', array($this, 'delete_state'), 10, 3);
48
-        add_action('wp_ajax_espresso_add_new_state', array($this, 'add_new_state'));
49
-    }
50
-
51
-
52
-    /**
53
-     * More page properties initialization.
54
-     */
55
-    protected function _define_page_props()
56
-    {
57
-        $this->_admin_page_title = GEN_SET_LABEL;
58
-        $this->_labels = array(
59
-            'publishbox' => __('Update Settings', 'event_espresso'),
60
-        );
61
-    }
62
-
63
-
64
-    /**
65
-     * Set page routes property.
66
-     */
67
-    protected function _set_page_routes()
68
-    {
69
-        $this->_page_routes = array(
70
-
71
-            'critical_pages'                => array(
72
-                'func'       => '_espresso_page_settings',
73
-                'capability' => 'manage_options',
74
-            ),
75
-            'update_espresso_page_settings' => array(
76
-                'func'       => '_update_espresso_page_settings',
77
-                'capability' => 'manage_options',
78
-                'noheader'   => true,
79
-            ),
80
-            'default'                       => array(
81
-                'func'       => '_your_organization_settings',
82
-                'capability' => 'manage_options',
83
-            ),
84
-
85
-            'update_your_organization_settings' => array(
86
-                'func'       => '_update_your_organization_settings',
87
-                'capability' => 'manage_options',
88
-                'noheader'   => true,
89
-            ),
90
-
91
-            'admin_option_settings' => array(
92
-                'func'       => '_admin_option_settings',
93
-                'capability' => 'manage_options',
94
-            ),
95
-
96
-            'update_admin_option_settings' => array(
97
-                'func'       => '_update_admin_option_settings',
98
-                'capability' => 'manage_options',
99
-                'noheader'   => true,
100
-            ),
101
-
102
-            'country_settings' => array(
103
-                'func'       => '_country_settings',
104
-                'capability' => 'manage_options',
105
-            ),
106
-
107
-            'update_country_settings' => array(
108
-                'func'       => '_update_country_settings',
109
-                'capability' => 'manage_options',
110
-                'noheader'   => true,
111
-            ),
112
-
113
-            'display_country_settings' => array(
114
-                'func'       => 'display_country_settings',
115
-                'capability' => 'manage_options',
116
-                'noheader'   => true,
117
-            ),
118
-
119
-            'add_new_state' => array(
120
-                'func'       => 'add_new_state',
121
-                'capability' => 'manage_options',
122
-                'noheader'   => true,
123
-            ),
124
-
125
-            'delete_state' => array(
126
-                'func'       => 'delete_state',
127
-                'capability' => 'manage_options',
128
-                'noheader'   => true,
129
-            ),
130
-        );
131
-    }
132
-
133
-
134
-    /**
135
-     * Set page configuration property
136
-     */
137
-    protected function _set_page_config()
138
-    {
139
-        $this->_page_config = array(
140
-            'critical_pages'        => array(
141
-                'nav'           => array(
142
-                    'label' => __('Critical Pages', 'event_espresso'),
143
-                    'order' => 50,
144
-                ),
145
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
146
-                'help_tabs'     => array(
147
-                    'general_settings_critical_pages_help_tab' => array(
148
-                        'title'    => __('Critical Pages', 'event_espresso'),
149
-                        'filename' => 'general_settings_critical_pages',
150
-                    ),
151
-                ),
152
-                'help_tour'     => array('Critical_Pages_Help_Tour'),
153
-                'require_nonce' => false,
154
-            ),
155
-            'default'               => array(
156
-                'nav'           => array(
157
-                    'label' => __('Your Organization', 'event_espresso'),
158
-                    'order' => 20,
159
-                ),
160
-                'help_tabs'     => array(
161
-                    'general_settings_your_organization_help_tab' => array(
162
-                        'title'    => __('Your Organization', 'event_espresso'),
163
-                        'filename' => 'general_settings_your_organization',
164
-                    ),
165
-                ),
166
-                'help_tour'     => array('Your_Organization_Help_Tour'),
167
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
168
-                'require_nonce' => false,
169
-            ),
170
-            'admin_option_settings' => array(
171
-                'nav'           => array(
172
-                    'label' => __('Admin Options', 'event_espresso'),
173
-                    'order' => 60,
174
-                ),
175
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
176
-                'help_tabs'     => array(
177
-                    'general_settings_admin_options_help_tab' => array(
178
-                        'title'    => __('Admin Options', 'event_espresso'),
179
-                        'filename' => 'general_settings_admin_options',
180
-                    ),
181
-                ),
182
-                'help_tour'     => array('Admin_Options_Help_Tour'),
183
-                'require_nonce' => false,
184
-            ),
185
-            'country_settings'      => array(
186
-                'nav'           => array(
187
-                    'label' => __('Countries', 'event_espresso'),
188
-                    'order' => 70,
189
-                ),
190
-                'help_tabs'     => array(
191
-                    'general_settings_countries_help_tab' => array(
192
-                        'title'    => __('Countries', 'event_espresso'),
193
-                        'filename' => 'general_settings_countries',
194
-                    ),
195
-                ),
196
-                'help_tour'     => array('Countries_Help_Tour'),
197
-                'require_nonce' => false,
198
-            ),
199
-        );
200
-    }
201
-
202
-
203
-    protected function _add_screen_options()
204
-    {
205
-    }
206
-
207
-    protected function _add_feature_pointers()
208
-    {
209
-    }
210
-
211
-
212
-    /**
213
-     * Enqueue global scripts and styles for all routes in the General Settings Admin Pages.
214
-     */
215
-    public function load_scripts_styles()
216
-    {
217
-        // styles
218
-        wp_enqueue_style('espresso-ui-theme');
219
-        // scripts
220
-        wp_enqueue_script('ee_admin_js');
221
-    }
222
-
223
-
224
-    /**
225
-     * Execute logic running on `admin_init`
226
-     */
227
-    public function admin_init()
228
-    {
229
-        EE_Registry::$i18n_js_strings['invalid_server_response'] = __(
230
-            '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.',
231
-            'event_espresso'
232
-        );
233
-        EE_Registry::$i18n_js_strings['error_occurred'] = __(
234
-            'An error occurred! Please refresh the page and try again.',
235
-            'event_espresso'
236
-        );
237
-        EE_Registry::$i18n_js_strings['confirm_delete_state'] = __(
238
-            'Are you sure you want to delete this State / Province?',
239
-            'event_espresso'
240
-        );
241
-        $protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
242
-        EE_Registry::$i18n_js_strings['ajax_url'] = admin_url(
243
-            'admin-ajax.php?page=espresso_general_settings',
244
-            $protocol
245
-        );
246
-    }
247
-
248
-    public function admin_notices()
249
-    {
250
-    }
251
-
252
-    public function admin_footer_scripts()
253
-    {
254
-    }
255
-
256
-
257
-    /**
258
-     * Enqueue scripts and styles for the default route.
259
-     */
260
-    public function load_scripts_styles_default()
261
-    {
262
-        // styles
263
-        wp_enqueue_style('thickbox');
264
-        // scripts
265
-        wp_enqueue_script('media-upload');
266
-        wp_enqueue_script('thickbox');
267
-        wp_register_script(
268
-            'organization_settings',
269
-            GEN_SET_ASSETS_URL . 'your_organization_settings.js',
270
-            array('jquery', 'media-upload', 'thickbox'),
271
-            EVENT_ESPRESSO_VERSION,
272
-            true
273
-        );
274
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION);
275
-        wp_enqueue_script('organization_settings');
276
-        wp_enqueue_style('organization-css');
277
-        $confirm_image_delete = array(
278
-            'text' => __(
279
-                'Do you really want to delete this image? Please remember to save your settings to complete the removal.',
280
-                'event_espresso'
281
-            ),
282
-        );
283
-        wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete);
284
-    }
285
-
286
-
287
-    /**
288
-     * Enqueue scripts and styles for the country settings route.
289
-     */
290
-    public function load_scripts_styles_country_settings()
291
-    {
292
-        // scripts
293
-        wp_register_script(
294
-            'gen_settings_countries',
295
-            GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
296
-            array('ee_admin_js'),
297
-            EVENT_ESPRESSO_VERSION,
298
-            true
299
-        );
300
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION);
301
-        wp_enqueue_script('gen_settings_countries');
302
-        wp_enqueue_style('organization-css');
303
-    }
304
-
305
-
306
-    /*************        Espresso Pages        *************/
307
-    /**
308
-     * _espresso_page_settings
309
-     *
310
-     * @throws \EE_Error
311
-     */
312
-    protected function _espresso_page_settings()
313
-    {
314
-        // Check to make sure all of the main pages are setup properly,
315
-        // if not create the default pages and display an admin notice
316
-        EEH_Activation::verify_default_pages_exist();
317
-        $this->_transient_garbage_collection();
318
-        $this->_template_args['values'] = $this->_yes_no_values;
319
-        $this->_template_args['reg_page_id'] = isset(EE_Registry::instance()->CFG->core->reg_page_id)
320
-            ? EE_Registry::instance()->CFG->core->reg_page_id
321
-            : null;
322
-        $this->_template_args['reg_page_obj'] = isset(EE_Registry::instance()->CFG->core->reg_page_id)
323
-            ? get_page(EE_Registry::instance()->CFG->core->reg_page_id)
324
-            : false;
325
-        $this->_template_args['txn_page_id'] = isset(EE_Registry::instance()->CFG->core->txn_page_id)
326
-            ? EE_Registry::instance()->CFG->core->txn_page_id
327
-            : null;
328
-        $this->_template_args['txn_page_obj'] = isset(EE_Registry::instance()->CFG->core->txn_page_id)
329
-            ? get_page(EE_Registry::instance()->CFG->core->txn_page_id)
330
-            : false;
331
-        $this->_template_args['thank_you_page_id'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id)
332
-            ? EE_Registry::instance()->CFG->core->thank_you_page_id
333
-            : null;
334
-        $this->_template_args['thank_you_page_obj'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id)
335
-            ? get_page(EE_Registry::instance()->CFG->core->thank_you_page_id)
336
-            : false;
337
-        $this->_template_args['cancel_page_id'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id)
338
-            ? EE_Registry::instance()->CFG->core->cancel_page_id
339
-            : null;
340
-        $this->_template_args['cancel_page_obj'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id)
341
-            ? get_page(EE_Registry::instance()->CFG->core->cancel_page_id)
342
-            : false;
343
-        $this->_set_add_edit_form_tags('update_espresso_page_settings');
344
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
345
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
346
-            GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
347
-            $this->_template_args,
348
-            true
349
-        );
350
-        $this->display_admin_page_with_sidebar();
351
-    }
352
-
353
-
354
-    /**
355
-     * Handler for updating espresso page settings.
356
-     */
357
-    protected function _update_espresso_page_settings()
358
-    {
359
-        // capture incoming request data && set page IDs
360
-        EE_Registry::instance()->CFG->core->reg_page_id = isset($this->_req_data['reg_page_id'])
361
-            ? absint($this->_req_data['reg_page_id'])
362
-            : EE_Registry::instance()->CFG->core->reg_page_id;
363
-        EE_Registry::instance()->CFG->core->txn_page_id = isset($this->_req_data['txn_page_id'])
364
-            ? absint($this->_req_data['txn_page_id'])
365
-            : EE_Registry::instance()->CFG->core->txn_page_id;
366
-        EE_Registry::instance()->CFG->core->thank_you_page_id = isset($this->_req_data['thank_you_page_id'])
367
-            ? absint($this->_req_data['thank_you_page_id'])
368
-            : EE_Registry::instance()->CFG->core->thank_you_page_id;
369
-        EE_Registry::instance()->CFG->core->cancel_page_id = isset($this->_req_data['cancel_page_id'])
370
-            ? absint($this->_req_data['cancel_page_id'])
371
-            : EE_Registry::instance()->CFG->core->cancel_page_id;
372
-
373
-        EE_Registry::instance()->CFG->core = apply_filters(
374
-            'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core',
375
-            EE_Registry::instance()->CFG->core,
376
-            $this->_req_data
377
-        );
378
-        $what = __('Critical Pages & Shortcodes', 'event_espresso');
379
-        $this->_redirect_after_action(
380
-            $this->_update_espresso_configuration(
381
-                $what,
382
-                EE_Registry::instance()->CFG->core,
383
-                __FILE__,
384
-                __FUNCTION__,
385
-                __LINE__
386
-            ),
387
-            $what,
388
-            '',
389
-            array(
390
-                'action' => 'critical_pages',
391
-            ),
392
-            true
393
-        );
394
-    }
395
-
396
-
397
-    /*************        Your Organization        *************/
398
-
399
-
400
-    /**
401
-     * Output for the Your Organization settings route.
402
-     *
403
-     * @throws DomainException
404
-     * @throws EE_Error
405
-     */
406
-    protected function _your_organization_settings()
407
-    {
408
-
409
-        $this->_template_args['site_license_key'] = isset(
410
-            EE_Registry::instance()->NET_CFG->core->site_license_key
411
-        )
412
-            ? EE_Registry::instance()->NET_CFG->core->get_pretty('site_license_key')
413
-            : '';
414
-        $this->_template_args['organization_name'] = isset(EE_Registry::instance()->CFG->organization->name)
415
-            ? EE_Registry::instance()->CFG->organization->get_pretty('name')
416
-            : '';
417
-        $this->_template_args['organization_address_1'] = isset(EE_Registry::instance()->CFG->organization->address_1)
418
-            ? EE_Registry::instance()->CFG->organization->get_pretty('address_1')
419
-            : '';
420
-        $this->_template_args['organization_address_2'] = isset(EE_Registry::instance()->CFG->organization->address_2)
421
-            ? EE_Registry::instance()->CFG->organization->get_pretty('address_2')
422
-            : '';
423
-        $this->_template_args['organization_city'] = isset(EE_Registry::instance()->CFG->organization->city)
424
-            ? EE_Registry::instance()->CFG->organization->get_pretty('city')
425
-            : '';
426
-        $this->_template_args['organization_zip'] = isset(EE_Registry::instance()->CFG->organization->zip)
427
-            ? EE_Registry::instance()->CFG->organization->get_pretty('zip')
428
-            : '';
429
-        $this->_template_args['organization_email'] = isset(EE_Registry::instance()->CFG->organization->email)
430
-            ? EE_Registry::instance()->CFG->organization->get_pretty('email')
431
-            : '';
432
-        $this->_template_args['organization_phone'] = isset(EE_Registry::instance()->CFG->organization->phone)
433
-            ? EE_Registry::instance()->CFG->organization->get_pretty('phone')
434
-            : '';
435
-        $this->_template_args['organization_vat'] = isset(EE_Registry::instance()->CFG->organization->vat)
436
-            ? EE_Registry::instance()->CFG->organization->get_pretty('vat')
437
-            : '';
438
-        $this->_template_args['currency_sign'] = isset(EE_Registry::instance()->CFG->currency->sign)
439
-            ? EE_Registry::instance()->CFG->currency->get_pretty('sign')
440
-            : '$';
441
-        $this->_template_args['organization_logo_url'] = isset(EE_Registry::instance()->CFG->organization->logo_url)
442
-            ? EE_Registry::instance()->CFG->organization->get_pretty('logo_url')
443
-            : false;
444
-        $this->_template_args['organization_facebook'] = isset(EE_Registry::instance()->CFG->organization->facebook)
445
-            ? EE_Registry::instance()->CFG->organization->get_pretty('facebook')
446
-            : '';
447
-        $this->_template_args['organization_twitter'] = isset(EE_Registry::instance()->CFG->organization->twitter)
448
-            ? EE_Registry::instance()->CFG->organization->get_pretty('twitter')
449
-            : '';
450
-        $this->_template_args['organization_linkedin'] = isset(EE_Registry::instance()->CFG->organization->linkedin)
451
-            ? EE_Registry::instance()->CFG->organization->get_pretty('linkedin')
452
-            : '';
453
-        $this->_template_args['organization_pinterest'] = isset(EE_Registry::instance()->CFG->organization->pinterest)
454
-            ? EE_Registry::instance()->CFG->organization->get_pretty('pinterest')
455
-            : '';
456
-        $this->_template_args['organization_google'] = isset(EE_Registry::instance()->CFG->organization->google)
457
-            ? EE_Registry::instance()->CFG->organization->get_pretty('google')
458
-            : '';
459
-        $this->_template_args['organization_instagram'] = isset(EE_Registry::instance()->CFG->organization->instagram)
460
-            ? EE_Registry::instance()->CFG->organization->get_pretty('instagram')
461
-            : '';
462
-        // UXIP settings
463
-        $this->_template_args['ee_ueip_optin'] = isset(EE_Registry::instance()->CFG->core->ee_ueip_optin)
464
-            ? EE_Registry::instance()->CFG->core->get_pretty('ee_ueip_optin')
465
-            : 'yes';
466
-
467
-        $STA_ID = isset(EE_Registry::instance()->CFG->organization->STA_ID)
468
-            ? EE_Registry::instance()->CFG->organization->STA_ID
469
-            : 4;
470
-        $this->_template_args['states'] = new EE_Question_Form_Input(
471
-            EE_Question::new_instance(
472
-                array(
473
-                    'QST_ID'           => 0,
474
-                    'QST_display_text' => __('State/Province', 'event_espresso'),
475
-                    'QST_system'       => 'admin-state',
476
-                )
477
-            ),
478
-            EE_Answer::new_instance(
479
-                array(
480
-                    'ANS_ID'    => 0,
481
-                    'ANS_value' => $STA_ID,
482
-                )
483
-            ),
484
-            array(
485
-                'input_id'       => 'organization_state',
486
-                'input_name'     => 'organization_state',
487
-                'input_prefix'   => '',
488
-                'append_qstn_id' => false,
489
-            )
490
-        );
491
-
492
-        $CNT_ISO = isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
493
-            ? EE_Registry::instance()->CFG->organization->CNT_ISO
494
-            : 'US';
495
-        $this->_template_args['countries'] = new EE_Question_Form_Input(
496
-            EE_Question::new_instance(
497
-                array(
498
-                    'QST_ID'           => 0,
499
-                    'QST_display_text' => __('Country', 'event_espresso'),
500
-                    'QST_system'       => 'admin-country',
501
-                )
502
-            ),
503
-            EE_Answer::new_instance(
504
-                array(
505
-                    'ANS_ID'    => 0,
506
-                    'ANS_value' => $CNT_ISO,
507
-                )
508
-            ),
509
-            array(
510
-                'input_id'       => 'organization_country',
511
-                'input_name'     => 'organization_country',
512
-                'input_prefix'   => '',
513
-                'append_qstn_id' => false,
514
-            )
515
-        );
516
-
517
-        add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
518
-        add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
519
-
520
-        // PUE verification stuff
521
-        $ver_option_key = 'puvererr_' . basename(EE_PLUGIN_BASENAME);
522
-        $verify_fail = get_option($ver_option_key);
523
-        $this->_template_args['site_license_key_verified'] = $verify_fail
524
-                                                             || ! empty($verify_fail)
525
-                                                             || (empty($this->_template_args['site_license_key'])
526
-                                                                 && empty($verify_fail)
527
-                                                             )
528
-            ? '<span class="dashicons dashicons-admin-network ee-icon-color-ee-red ee-icon-size-20"></span>'
529
-            : '<span class="dashicons dashicons-admin-network ee-icon-color-ee-green ee-icon-size-20"></span>';
530
-
531
-        $this->_set_add_edit_form_tags('update_your_organization_settings');
532
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
533
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
534
-            GEN_SET_TEMPLATE_PATH . 'your_organization_settings.template.php',
535
-            $this->_template_args,
536
-            true
537
-        );
538
-
539
-        $this->display_admin_page_with_sidebar();
540
-    }
541
-
542
-
543
-    /**
544
-     * Handler for updating organziation settings.
545
-     */
546
-    protected function _update_your_organization_settings()
547
-    {
548
-        if (is_main_site()) {
549
-            EE_Registry::instance()->NET_CFG->core->site_license_key = isset($this->_req_data['site_license_key'])
550
-                ? sanitize_text_field($this->_req_data['site_license_key'])
551
-                : EE_Registry::instance()->NET_CFG->core->site_license_key;
552
-        }
553
-        EE_Registry::instance()->CFG->organization->name = isset($this->_req_data['organization_name'])
554
-            ? sanitize_text_field($this->_req_data['organization_name'])
555
-            : EE_Registry::instance()->CFG->organization->name;
556
-        EE_Registry::instance()->CFG->organization->address_1 = isset($this->_req_data['organization_address_1'])
557
-            ? sanitize_text_field($this->_req_data['organization_address_1'])
558
-            : EE_Registry::instance()->CFG->organization->address_1;
559
-        EE_Registry::instance()->CFG->organization->address_2 = isset($this->_req_data['organization_address_2'])
560
-            ? sanitize_text_field($this->_req_data['organization_address_2'])
561
-            : EE_Registry::instance()->CFG->organization->address_2;
562
-        EE_Registry::instance()->CFG->organization->city = isset($this->_req_data['organization_city'])
563
-            ? sanitize_text_field($this->_req_data['organization_city'])
564
-            : EE_Registry::instance()->CFG->organization->city;
565
-        EE_Registry::instance()->CFG->organization->STA_ID = isset($this->_req_data['organization_state'])
566
-            ? absint($this->_req_data['organization_state'])
567
-            : EE_Registry::instance()->CFG->organization->STA_ID;
568
-        EE_Registry::instance()->CFG->organization->CNT_ISO = isset($this->_req_data['organization_country'])
569
-            ? sanitize_text_field($this->_req_data['organization_country'])
570
-            : EE_Registry::instance()->CFG->organization->CNT_ISO;
571
-        EE_Registry::instance()->CFG->organization->zip = isset($this->_req_data['organization_zip'])
572
-            ? sanitize_text_field($this->_req_data['organization_zip'])
573
-            : EE_Registry::instance()->CFG->organization->zip;
574
-        EE_Registry::instance()->CFG->organization->email = isset($this->_req_data['organization_email'])
575
-            ? sanitize_email($this->_req_data['organization_email'])
576
-            : EE_Registry::instance()->CFG->organization->email;
577
-        EE_Registry::instance()->CFG->organization->vat = isset($this->_req_data['organization_vat'])
578
-            ? sanitize_text_field($this->_req_data['organization_vat'])
579
-            : EE_Registry::instance()->CFG->organization->vat;
580
-        EE_Registry::instance()->CFG->organization->phone = isset($this->_req_data['organization_phone'])
581
-            ? sanitize_text_field($this->_req_data['organization_phone'])
582
-            : EE_Registry::instance()->CFG->organization->phone;
583
-        EE_Registry::instance()->CFG->organization->logo_url = isset($this->_req_data['organization_logo_url'])
584
-            ? esc_url_raw($this->_req_data['organization_logo_url'])
585
-            : EE_Registry::instance()->CFG->organization->logo_url;
586
-        EE_Registry::instance()->CFG->organization->facebook = isset($this->_req_data['organization_facebook'])
587
-            ? esc_url_raw($this->_req_data['organization_facebook'])
588
-            : EE_Registry::instance()->CFG->organization->facebook;
589
-        EE_Registry::instance()->CFG->organization->twitter = isset($this->_req_data['organization_twitter'])
590
-            ? esc_url_raw($this->_req_data['organization_twitter'])
591
-            : EE_Registry::instance()->CFG->organization->twitter;
592
-        EE_Registry::instance()->CFG->organization->linkedin = isset($this->_req_data['organization_linkedin'])
593
-            ? esc_url_raw($this->_req_data['organization_linkedin'])
594
-            : EE_Registry::instance()->CFG->organization->linkedin;
595
-        EE_Registry::instance()->CFG->organization->pinterest = isset($this->_req_data['organization_pinterest'])
596
-            ? esc_url_raw($this->_req_data['organization_pinterest'])
597
-            : EE_Registry::instance()->CFG->organization->pinterest;
598
-        EE_Registry::instance()->CFG->organization->google = isset($this->_req_data['organization_google'])
599
-            ? esc_url_raw($this->_req_data['organization_google'])
600
-            : EE_Registry::instance()->CFG->organization->google;
601
-        EE_Registry::instance()->CFG->organization->instagram = isset($this->_req_data['organization_instagram'])
602
-            ? esc_url_raw($this->_req_data['organization_instagram'])
603
-            : EE_Registry::instance()->CFG->organization->instagram;
604
-        EE_Registry::instance()->CFG->core->ee_ueip_optin = isset($this->_req_data['ueip_optin'])
605
-                                                            && ! empty($this->_req_data['ueip_optin'])
606
-            ? filter_var($this->_req_data['ueip_optin'], FILTER_VALIDATE_BOOLEAN)
607
-            : EE_Registry::instance()->CFG->core->ee_ueip_optin;
608
-
609
-        EE_Registry::instance()->CFG->currency = new EE_Currency_Config(
610
-            EE_Registry::instance()->CFG->organization->CNT_ISO
611
-        );
612
-
613
-        EE_Registry::instance()->CFG = apply_filters(
614
-            'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG',
615
-            EE_Registry::instance()->CFG
616
-        );
617
-
618
-        $what = 'Your Organization Settings';
619
-        $success = $this->_update_espresso_configuration(
620
-            $what,
621
-            EE_Registry::instance()->CFG,
622
-            __FILE__,
623
-            __FUNCTION__,
624
-            __LINE__
625
-        );
626
-
627
-        $this->_redirect_after_action($success, $what, 'updated', array('action' => 'default'));
628
-    }
629
-
630
-
631
-
632
-    /*************        Admin Options        *************/
633
-
634
-
635
-    /**
636
-     * _admin_option_settings
637
-     *
638
-     * @throws \EE_Error
639
-     * @throws \LogicException
640
-     */
641
-    protected function _admin_option_settings()
642
-    {
643
-        $this->_template_args['admin_page_content'] = '';
644
-        try {
645
-            $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
646
-            // still need this for the old school form in Extend_General_Settings_Admin_Page
647
-            $this->_template_args['values'] = $this->_yes_no_values;
648
-            // also need to account for the do_action that was in the old template
649
-            $admin_options_settings_form->setTemplateArgs($this->_template_args);
650
-            $this->_template_args['admin_page_content'] = $admin_options_settings_form->display();
651
-        } catch (Exception $e) {
652
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
653
-        }
654
-        $this->_set_add_edit_form_tags('update_admin_option_settings');
655
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
656
-        $this->display_admin_page_with_sidebar();
657
-    }
658
-
659
-
660
-    /**
661
-     * _update_admin_option_settings
662
-     *
663
-     * @throws \EE_Error
664
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
665
-     * @throws \EventEspresso\core\exceptions\InvalidFormSubmissionException
666
-     * @throws \InvalidArgumentException
667
-     * @throws \LogicException
668
-     */
669
-    protected function _update_admin_option_settings()
670
-    {
671
-        try {
672
-            $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
673
-            $admin_options_settings_form->process($this->_req_data[ $admin_options_settings_form->slug() ]);
674
-            EE_Registry::instance()->CFG->admin = apply_filters(
675
-                'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
676
-                EE_Registry::instance()->CFG->admin
677
-            );
678
-        } catch (Exception $e) {
679
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
680
-        }
681
-        $this->_redirect_after_action(
682
-            apply_filters(
683
-                'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success',
684
-                $this->_update_espresso_configuration(
685
-                    'Admin Options',
686
-                    EE_Registry::instance()->CFG->admin,
687
-                    __FILE__,
688
-                    __FUNCTION__,
689
-                    __LINE__
690
-                )
691
-            ),
692
-            'Admin Options',
693
-            'updated',
694
-            array('action' => 'admin_option_settings')
695
-        );
696
-    }
697
-
698
-
699
-    /*************        Countries        *************/
700
-
701
-
702
-    /**
703
-     * Output Country Settings view.
704
-     *
705
-     * @throws DomainException
706
-     * @throws EE_Error
707
-     */
708
-    protected function _country_settings()
709
-    {
710
-        $CNT_ISO = isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
711
-            ? EE_Registry::instance()->CFG->organization->CNT_ISO
712
-            : 'US';
713
-        $CNT_ISO = isset($this->_req_data['country'])
714
-            ? strtoupper(sanitize_text_field($this->_req_data['country']))
715
-            : $CNT_ISO;
716
-
717
-        // load field generator helper
718
-
719
-        $this->_template_args['values'] = $this->_yes_no_values;
720
-
721
-        $this->_template_args['countries'] = new EE_Question_Form_Input(
722
-            EE_Question::new_instance(
723
-                array(
724
-                    'QST_ID'           => 0,
725
-                    'QST_display_text' => __('Select Country', 'event_espresso'),
726
-                    'QST_system'       => 'admin-country',
727
-                )
728
-            ),
729
-            EE_Answer::new_instance(
730
-                array(
731
-                    'ANS_ID'    => 0,
732
-                    'ANS_value' => $CNT_ISO,
733
-                )
734
-            ),
735
-            array(
736
-                'input_id'       => 'country',
737
-                'input_name'     => 'country',
738
-                'input_prefix'   => '',
739
-                'append_qstn_id' => false,
740
-            )
741
-        );
742
-
743
-        add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
744
-        add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
745
-        $this->_template_args['country_details_settings'] = $this->display_country_settings();
746
-        $this->_template_args['country_states_settings'] = $this->display_country_states();
747
-
748
-        $this->_set_add_edit_form_tags('update_country_settings');
749
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
750
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
751
-            GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
752
-            $this->_template_args,
753
-            true
754
-        );
755
-        $this->display_admin_page_with_no_sidebar();
756
-    }
757
-
758
-
759
-    /**
760
-     *        display_country_settings
761
-     *
762
-     * @access    public
763
-     * @param    string $CNT_ISO
764
-     * @return mixed string | array
765
-     * @throws DomainException
766
-     */
767
-    public function display_country_settings($CNT_ISO = '')
768
-    {
769
-
770
-        $CNT_ISO = isset($this->_req_data['country'])
771
-            ? strtoupper(sanitize_text_field($this->_req_data['country']))
772
-            : $CNT_ISO;
773
-        if (! $CNT_ISO) {
774
-            return '';
775
-        }
776
-
777
-        // for ajax
778
-        remove_all_filters('FHEE__EEH_Form_Fields__label_html');
779
-        remove_all_filters('FHEE__EEH_Form_Fields__input_html');
780
-        add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
781
-        add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
782
-        $country = EEM_Country::instance()->get_one_by_ID($CNT_ISO);
783
-
784
-        $country_input_types = array(
785
-            'CNT_active'      => array(
786
-                'type'             => 'RADIO_BTN',
787
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
788
-                'class'            => '',
789
-                'options'          => $this->_yes_no_values,
790
-                'use_desc_4_label' => true,
791
-            ),
792
-            'CNT_ISO'         => array(
793
-                'type'       => 'TEXT',
794
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
795
-                'class'      => 'small-text',
796
-            ),
797
-            'CNT_ISO3'        => array(
798
-                'type'       => 'TEXT',
799
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
800
-                'class'      => 'small-text',
801
-            ),
802
-            'RGN_ID'          => array(
803
-                'type'       => 'TEXT',
804
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
805
-                'class'      => 'small-text',
806
-            ),
807
-            'CNT_name'        => array(
808
-                'type'       => 'TEXT',
809
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
810
-                'class'      => 'regular-text',
811
-            ),
812
-            'CNT_cur_code'    => array(
813
-                'type'       => 'TEXT',
814
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
815
-                'class'      => 'small-text',
816
-            ),
817
-            'CNT_cur_single'  => array(
818
-                'type'       => 'TEXT',
819
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
820
-                'class'      => 'medium-text',
821
-            ),
822
-            'CNT_cur_plural'  => array(
823
-                'type'       => 'TEXT',
824
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
825
-                'class'      => 'medium-text',
826
-            ),
827
-            'CNT_cur_sign'    => array(
828
-                'type'         => 'TEXT',
829
-                'input_name'   => 'cntry[' . $CNT_ISO . ']',
830
-                'class'        => 'small-text',
831
-                'htmlentities' => false,
832
-            ),
833
-            'CNT_cur_sign_b4' => array(
834
-                'type'             => 'RADIO_BTN',
835
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
836
-                'class'            => '',
837
-                'options'          => $this->_yes_no_values,
838
-                'use_desc_4_label' => true,
839
-            ),
840
-            'CNT_cur_dec_plc' => array(
841
-                'type'       => 'RADIO_BTN',
842
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
843
-                'class'      => '',
844
-                'options'    => array(
845
-                    array('id' => 0, 'text' => ''),
846
-                    array('id' => 1, 'text' => ''),
847
-                    array('id' => 2, 'text' => ''),
848
-                    array('id' => 3, 'text' => ''),
849
-                ),
850
-            ),
851
-            'CNT_cur_dec_mrk' => array(
852
-                'type'             => 'RADIO_BTN',
853
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
854
-                'class'            => '',
855
-                'options'          => array(
856
-                    array(
857
-                        'id'   => ',',
858
-                        'text' => __(', (comma)', 'event_espresso'),
859
-                    ),
860
-                    array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')),
861
-                ),
862
-                'use_desc_4_label' => true,
863
-            ),
864
-            'CNT_cur_thsnds'  => array(
865
-                'type'             => 'RADIO_BTN',
866
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
867
-                'class'            => '',
868
-                'options'          => array(
869
-                    array(
870
-                        'id'   => ',',
871
-                        'text' => __(', (comma)', 'event_espresso'),
872
-                    ),
873
-                    array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')),
874
-                ),
875
-                'use_desc_4_label' => true,
876
-            ),
877
-            'CNT_tel_code'    => array(
878
-                'type'       => 'TEXT',
879
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
880
-                'class'      => 'small-text',
881
-            ),
882
-            'CNT_is_EU'       => array(
883
-                'type'             => 'RADIO_BTN',
884
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
885
-                'class'            => '',
886
-                'options'          => $this->_yes_no_values,
887
-                'use_desc_4_label' => true,
888
-            ),
889
-        );
890
-        $this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object(
891
-            $country,
892
-            $country_input_types
893
-        );
894
-        $country_details_settings = EEH_Template::display_template(
895
-            GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
896
-            $this->_template_args,
897
-            true
898
-        );
899
-
900
-        if (defined('DOING_AJAX')) {
901
-            $notices = EE_Error::get_notices(false, false, false);
902
-            echo wp_json_encode(
903
-                array(
904
-                    'return_data' => $country_details_settings,
905
-                    'success'     => $notices['success'],
906
-                    'errors'      => $notices['errors'],
907
-                )
908
-            );
909
-            die();
910
-        } else {
911
-            return $country_details_settings;
912
-        }
913
-    }
914
-
915
-
916
-    /**
917
-     *        display_country_states
918
-     *
919
-     * @access    public
920
-     * @param    string $CNT_ISO
921
-     * @return string
922
-     * @throws DomainException
923
-     */
924
-    public function display_country_states($CNT_ISO = '')
925
-    {
926
-
927
-        $CNT_ISO = isset($this->_req_data['country']) ? sanitize_text_field($this->_req_data['country']) : $CNT_ISO;
928
-
929
-        if (! $CNT_ISO) {
930
-            return '';
931
-        }
932
-        // for ajax
933
-        remove_all_filters('FHEE__EEH_Form_Fields__label_html');
934
-        remove_all_filters('FHEE__EEH_Form_Fields__input_html');
935
-        add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'state_form_field_label_wrap'), 10, 2);
936
-        add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'state_form_field_input__wrap'), 10, 2);
937
-        $states = EEM_State::instance()->get_all_states_for_these_countries(array($CNT_ISO => $CNT_ISO));
938
-
939
-        if ($states) {
940
-            foreach ($states as $STA_ID => $state) {
941
-                if ($state instanceof EE_State) {
942
-                    // STA_abbrev    STA_name    STA_active
943
-                    $state_input_types = array(
944
-                        'STA_abbrev' => array(
945
-                            'type'       => 'TEXT',
946
-                            'input_name' => 'states[' . $STA_ID . ']',
947
-                            'class'      => 'mid-text',
948
-                        ),
949
-                        'STA_name'   => array(
950
-                            'type'       => 'TEXT',
951
-                            'input_name' => 'states[' . $STA_ID . ']',
952
-                            'class'      => 'regular-text',
953
-                        ),
954
-                        'STA_active' => array(
955
-                            'type'             => 'RADIO_BTN',
956
-                            'input_name'       => 'states[' . $STA_ID . ']',
957
-                            'options'          => $this->_yes_no_values,
958
-                            'use_desc_4_label' => true,
959
-                        ),
960
-                    );
961
-                    $this->_template_args['states'][ $STA_ID ]['inputs'] =
962
-                        EE_Question_Form_Input::generate_question_form_inputs_for_object(
963
-                            $state,
964
-                            $state_input_types
965
-                        );
966
-                    $query_args = array(
967
-                        'action'     => 'delete_state',
968
-                        'STA_ID'     => $STA_ID,
969
-                        'CNT_ISO'    => $CNT_ISO,
970
-                        'STA_abbrev' => $state->abbrev(),
971
-                    );
972
-                    $this->_template_args['states'][ $STA_ID ]['delete_state_url'] =
973
-                        EE_Admin_Page::add_query_args_and_nonce(
974
-                            $query_args,
975
-                            GEN_SET_ADMIN_URL
976
-                        );
977
-                }
978
-            }
979
-        } else {
980
-            $this->_template_args['states'] = false;
981
-        }
982
-
983
-        $this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(
984
-            array('action' => 'add_new_state'),
985
-            GEN_SET_ADMIN_URL
986
-        );
987
-
988
-        $state_details_settings = EEH_Template::display_template(
989
-            GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
990
-            $this->_template_args,
991
-            true
992
-        );
993
-
994
-        if (defined('DOING_AJAX')) {
995
-            $notices = EE_Error::get_notices(false, false, false);
996
-            echo wp_json_encode(
997
-                array(
998
-                    'return_data' => $state_details_settings,
999
-                    'success'     => $notices['success'],
1000
-                    'errors'      => $notices['errors'],
1001
-                )
1002
-            );
1003
-            die();
1004
-        } else {
1005
-            return $state_details_settings;
1006
-        }
1007
-    }
1008
-
1009
-
1010
-    /**
1011
-     *        add_new_state
1012
-     *
1013
-     * @access    public
1014
-     * @return void
1015
-     * @throws EE_Error
1016
-     */
1017
-    public function add_new_state()
1018
-    {
1019
-
1020
-        $success = true;
1021
-
1022
-        $CNT_ISO = isset($this->_req_data['CNT_ISO'])
1023
-            ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO']))
1024
-            : false;
1025
-        if (! $CNT_ISO) {
1026
-            EE_Error::add_error(
1027
-                __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1028
-                __FILE__,
1029
-                __FUNCTION__,
1030
-                __LINE__
1031
-            );
1032
-            $success = false;
1033
-        }
1034
-        $STA_abbrev = isset($this->_req_data['STA_abbrev'])
1035
-            ? sanitize_text_field($this->_req_data['STA_abbrev'])
1036
-            : false;
1037
-        if (! $STA_abbrev) {
1038
-            EE_Error::add_error(
1039
-                __('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
1040
-                __FILE__,
1041
-                __FUNCTION__,
1042
-                __LINE__
1043
-            );
1044
-            $success = false;
1045
-        }
1046
-        $STA_name = isset($this->_req_data['STA_name'])
1047
-            ? sanitize_text_field($this->_req_data['STA_name'])
1048
-            : false;
1049
-        if (! $STA_name) {
1050
-            EE_Error::add_error(
1051
-                __('No State name or an invalid State name was received.', 'event_espresso'),
1052
-                __FILE__,
1053
-                __FUNCTION__,
1054
-                __LINE__
1055
-            );
1056
-            $success = false;
1057
-        }
1058
-
1059
-        if ($success) {
1060
-            $cols_n_values = array(
1061
-                'CNT_ISO'    => $CNT_ISO,
1062
-                'STA_abbrev' => $STA_abbrev,
1063
-                'STA_name'   => $STA_name,
1064
-                'STA_active' => true,
1065
-            );
1066
-            $success = EEM_State::instance()->insert($cols_n_values);
1067
-            EE_Error::add_success(__('The State was added successfully.', 'event_espresso'));
1068
-        }
1069
-
1070
-        if (defined('DOING_AJAX')) {
1071
-            $notices = EE_Error::get_notices(false, false, false);
1072
-            echo wp_json_encode(array_merge($notices, array('return_data' => $CNT_ISO)));
1073
-            die();
1074
-        } else {
1075
-            $this->_redirect_after_action($success, 'State', 'added', array('action' => 'country_settings'));
1076
-        }
1077
-    }
1078
-
1079
-
1080
-    /**
1081
-     *        delete_state
1082
-     *
1083
-     * @access    public
1084
-     * @return        boolean
1085
-     */
1086
-    public function delete_state()
1087
-    {
1088
-        $CNT_ISO = isset($this->_req_data['CNT_ISO'])
1089
-            ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO']))
1090
-            : false;
1091
-        $STA_ID = isset($this->_req_data['STA_ID'])
1092
-            ? sanitize_text_field($this->_req_data['STA_ID'])
1093
-            : false;
1094
-        $STA_abbrev = isset($this->_req_data['STA_abbrev'])
1095
-            ? sanitize_text_field($this->_req_data['STA_abbrev'])
1096
-            : false;
1097
-        if (! $STA_ID) {
1098
-            EE_Error::add_error(
1099
-                __('No State ID or an invalid State ID was received.', 'event_espresso'),
1100
-                __FILE__,
1101
-                __FUNCTION__,
1102
-                __LINE__
1103
-            );
1104
-            return false;
1105
-        }
1106
-
1107
-        $success = EEM_State::instance()->delete_by_ID($STA_ID);
1108
-        if ($success !== false) {
1109
-            do_action(
1110
-                'AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
1111
-                $CNT_ISO,
1112
-                $STA_ID,
1113
-                array('STA_abbrev' => $STA_abbrev)
1114
-            );
1115
-            EE_Error::add_success(__('The State was deleted successfully.', 'event_espresso'));
1116
-        }
1117
-        if (defined('DOING_AJAX')) {
1118
-            $notices = EE_Error::get_notices(false, false);
1119
-            $notices['return_data'] = true;
1120
-            echo wp_json_encode($notices);
1121
-            die();
1122
-        } else {
1123
-            $this->_redirect_after_action(
1124
-                $success,
1125
-                'State',
1126
-                'deleted',
1127
-                array('action' => 'country_settings')
1128
-            );
1129
-        }
1130
-    }
1131
-
1132
-
1133
-    /**
1134
-     *        _update_country_settings
1135
-     *
1136
-     * @access    protected
1137
-     * @return void
1138
-     * @throws EE_Error
1139
-     */
1140
-    protected function _update_country_settings()
1141
-    {
1142
-        // grab the country ISO code
1143
-        $CNT_ISO = isset($this->_req_data['country'])
1144
-            ? strtoupper(sanitize_text_field($this->_req_data['country']))
1145
-            : false;
1146
-        if (! $CNT_ISO) {
1147
-            EE_Error::add_error(
1148
-                __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1149
-                __FILE__,
1150
-                __FUNCTION__,
1151
-                __LINE__
1152
-            );
1153
-
1154
-            return;
1155
-        }
1156
-        $cols_n_values = array();
1157
-        $cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3'])
1158
-            ? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3']))
1159
-            : false;
1160
-        $cols_n_values['RGN_ID'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID'])
1161
-            ? absint($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID'])
1162
-            : null;
1163
-        $cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name'])
1164
-            ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name'])
1165
-            : null;
1166
-        $cols_n_values['CNT_cur_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code'])
1167
-            ? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code']))
1168
-            : 'USD';
1169
-        $cols_n_values['CNT_cur_single'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single'])
1170
-            ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single'])
1171
-            : 'dollar';
1172
-        $cols_n_values['CNT_cur_plural'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural'])
1173
-            ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural'])
1174
-            : 'dollars';
1175
-        $cols_n_values['CNT_cur_sign'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign'])
1176
-            ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign'])
1177
-            : '$';
1178
-        $cols_n_values['CNT_cur_sign_b4'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4'])
1179
-            ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4'])
1180
-            : true;
1181
-        $cols_n_values['CNT_cur_dec_plc'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc'])
1182
-            ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc'])
1183
-            : 2;
1184
-        $cols_n_values['CNT_cur_dec_mrk'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk'])
1185
-            ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk'])
1186
-            : '.';
1187
-        $cols_n_values['CNT_cur_thsnds'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds'])
1188
-            ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds'])
1189
-            : ',';
1190
-        $cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code'])
1191
-            ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code'])
1192
-            : null;
1193
-        $cols_n_values['CNT_is_EU'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU'])
1194
-            ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU'])
1195
-            : false;
1196
-        $cols_n_values['CNT_active'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active'])
1197
-            ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active'])
1198
-            : false;
1199
-        // allow filtering of country data
1200
-        $cols_n_values = apply_filters(
1201
-            'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values',
1202
-            $cols_n_values
1203
-        );
1204
-
1205
-        // where values
1206
-        $where_cols_n_values = array(array('CNT_ISO' => $CNT_ISO));
1207
-        // run the update
1208
-        $success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values);
1209
-
1210
-        if (isset($this->_req_data['states']) && is_array($this->_req_data['states']) && $success !== false) {
1211
-            // allow filtering of states data
1212
-            $states = apply_filters(
1213
-                'FHEE__General_Settings_Admin_Page___update_country_settings__states',
1214
-                $this->_req_data['states']
1215
-            );
1216
-
1217
-            // loop thru state data ( looks like : states[75][STA_name] )
1218
-            foreach ($states as $STA_ID => $state) {
1219
-                $cols_n_values = array(
1220
-                    'CNT_ISO'    => $CNT_ISO,
1221
-                    'STA_abbrev' => sanitize_text_field($state['STA_abbrev']),
1222
-                    'STA_name'   => sanitize_text_field($state['STA_name']),
1223
-                    'STA_active' => (bool) absint($state['STA_active']),
1224
-                );
1225
-                // where values
1226
-                $where_cols_n_values = array(array('STA_ID' => $STA_ID));
1227
-                // run the update
1228
-                $success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values);
1229
-                if ($success !== false) {
1230
-                    do_action(
1231
-                        'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
1232
-                        $CNT_ISO,
1233
-                        $STA_ID,
1234
-                        $cols_n_values
1235
-                    );
1236
-                }
1237
-            }
1238
-        }
1239
-        // check if country being edited matches org option country, and if so, then  update EE_Config with new settings
1240
-        if (isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
1241
-            && $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO
1242
-        ) {
1243
-            EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO);
1244
-            EE_Registry::instance()->CFG->update_espresso_config();
1245
-        }
1246
-
1247
-        if ($success !== false) {
1248
-            EE_Error::add_success(
1249
-                esc_html__('Country Settings updated successfully.', 'event_espresso')
1250
-            );
1251
-        }
1252
-        $this->_redirect_after_action(
1253
-            $success,
1254
-            '',
1255
-            '',
1256
-            array('action' => 'country_settings', 'country' => $CNT_ISO),
1257
-            true
1258
-        );
1259
-    }
1260
-
1261
-
1262
-    /**
1263
-     *        form_form_field_label_wrap
1264
-     *
1265
-     * @access        public
1266
-     * @param        string $label
1267
-     * @return        string
1268
-     */
1269
-    public function country_form_field_label_wrap($label, $required_text)
1270
-    {
1271
-        return '
19
+	/**
20
+	 * _question_group
21
+	 * holds the specific question group object for the question group details screen
22
+	 *
23
+	 * @var object
24
+	 */
25
+	protected $_question_group;
26
+
27
+
28
+	/**
29
+	 * Initialize basic properties.
30
+	 */
31
+	protected function _init_page_props()
32
+	{
33
+		$this->page_slug = GEN_SET_PG_SLUG;
34
+		$this->page_label = GEN_SET_LABEL;
35
+		$this->_admin_base_url = GEN_SET_ADMIN_URL;
36
+		$this->_admin_base_path = GEN_SET_ADMIN;
37
+	}
38
+
39
+
40
+	/**
41
+	 * Set ajax hooks
42
+	 */
43
+	protected function _ajax_hooks()
44
+	{
45
+		add_action('wp_ajax_espresso_display_country_settings', array($this, 'display_country_settings'));
46
+		add_action('wp_ajax_espresso_display_country_states', array($this, 'display_country_states'));
47
+		add_action('wp_ajax_espresso_delete_state', array($this, 'delete_state'), 10, 3);
48
+		add_action('wp_ajax_espresso_add_new_state', array($this, 'add_new_state'));
49
+	}
50
+
51
+
52
+	/**
53
+	 * More page properties initialization.
54
+	 */
55
+	protected function _define_page_props()
56
+	{
57
+		$this->_admin_page_title = GEN_SET_LABEL;
58
+		$this->_labels = array(
59
+			'publishbox' => __('Update Settings', 'event_espresso'),
60
+		);
61
+	}
62
+
63
+
64
+	/**
65
+	 * Set page routes property.
66
+	 */
67
+	protected function _set_page_routes()
68
+	{
69
+		$this->_page_routes = array(
70
+
71
+			'critical_pages'                => array(
72
+				'func'       => '_espresso_page_settings',
73
+				'capability' => 'manage_options',
74
+			),
75
+			'update_espresso_page_settings' => array(
76
+				'func'       => '_update_espresso_page_settings',
77
+				'capability' => 'manage_options',
78
+				'noheader'   => true,
79
+			),
80
+			'default'                       => array(
81
+				'func'       => '_your_organization_settings',
82
+				'capability' => 'manage_options',
83
+			),
84
+
85
+			'update_your_organization_settings' => array(
86
+				'func'       => '_update_your_organization_settings',
87
+				'capability' => 'manage_options',
88
+				'noheader'   => true,
89
+			),
90
+
91
+			'admin_option_settings' => array(
92
+				'func'       => '_admin_option_settings',
93
+				'capability' => 'manage_options',
94
+			),
95
+
96
+			'update_admin_option_settings' => array(
97
+				'func'       => '_update_admin_option_settings',
98
+				'capability' => 'manage_options',
99
+				'noheader'   => true,
100
+			),
101
+
102
+			'country_settings' => array(
103
+				'func'       => '_country_settings',
104
+				'capability' => 'manage_options',
105
+			),
106
+
107
+			'update_country_settings' => array(
108
+				'func'       => '_update_country_settings',
109
+				'capability' => 'manage_options',
110
+				'noheader'   => true,
111
+			),
112
+
113
+			'display_country_settings' => array(
114
+				'func'       => 'display_country_settings',
115
+				'capability' => 'manage_options',
116
+				'noheader'   => true,
117
+			),
118
+
119
+			'add_new_state' => array(
120
+				'func'       => 'add_new_state',
121
+				'capability' => 'manage_options',
122
+				'noheader'   => true,
123
+			),
124
+
125
+			'delete_state' => array(
126
+				'func'       => 'delete_state',
127
+				'capability' => 'manage_options',
128
+				'noheader'   => true,
129
+			),
130
+		);
131
+	}
132
+
133
+
134
+	/**
135
+	 * Set page configuration property
136
+	 */
137
+	protected function _set_page_config()
138
+	{
139
+		$this->_page_config = array(
140
+			'critical_pages'        => array(
141
+				'nav'           => array(
142
+					'label' => __('Critical Pages', 'event_espresso'),
143
+					'order' => 50,
144
+				),
145
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
146
+				'help_tabs'     => array(
147
+					'general_settings_critical_pages_help_tab' => array(
148
+						'title'    => __('Critical Pages', 'event_espresso'),
149
+						'filename' => 'general_settings_critical_pages',
150
+					),
151
+				),
152
+				'help_tour'     => array('Critical_Pages_Help_Tour'),
153
+				'require_nonce' => false,
154
+			),
155
+			'default'               => array(
156
+				'nav'           => array(
157
+					'label' => __('Your Organization', 'event_espresso'),
158
+					'order' => 20,
159
+				),
160
+				'help_tabs'     => array(
161
+					'general_settings_your_organization_help_tab' => array(
162
+						'title'    => __('Your Organization', 'event_espresso'),
163
+						'filename' => 'general_settings_your_organization',
164
+					),
165
+				),
166
+				'help_tour'     => array('Your_Organization_Help_Tour'),
167
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
168
+				'require_nonce' => false,
169
+			),
170
+			'admin_option_settings' => array(
171
+				'nav'           => array(
172
+					'label' => __('Admin Options', 'event_espresso'),
173
+					'order' => 60,
174
+				),
175
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
176
+				'help_tabs'     => array(
177
+					'general_settings_admin_options_help_tab' => array(
178
+						'title'    => __('Admin Options', 'event_espresso'),
179
+						'filename' => 'general_settings_admin_options',
180
+					),
181
+				),
182
+				'help_tour'     => array('Admin_Options_Help_Tour'),
183
+				'require_nonce' => false,
184
+			),
185
+			'country_settings'      => array(
186
+				'nav'           => array(
187
+					'label' => __('Countries', 'event_espresso'),
188
+					'order' => 70,
189
+				),
190
+				'help_tabs'     => array(
191
+					'general_settings_countries_help_tab' => array(
192
+						'title'    => __('Countries', 'event_espresso'),
193
+						'filename' => 'general_settings_countries',
194
+					),
195
+				),
196
+				'help_tour'     => array('Countries_Help_Tour'),
197
+				'require_nonce' => false,
198
+			),
199
+		);
200
+	}
201
+
202
+
203
+	protected function _add_screen_options()
204
+	{
205
+	}
206
+
207
+	protected function _add_feature_pointers()
208
+	{
209
+	}
210
+
211
+
212
+	/**
213
+	 * Enqueue global scripts and styles for all routes in the General Settings Admin Pages.
214
+	 */
215
+	public function load_scripts_styles()
216
+	{
217
+		// styles
218
+		wp_enqueue_style('espresso-ui-theme');
219
+		// scripts
220
+		wp_enqueue_script('ee_admin_js');
221
+	}
222
+
223
+
224
+	/**
225
+	 * Execute logic running on `admin_init`
226
+	 */
227
+	public function admin_init()
228
+	{
229
+		EE_Registry::$i18n_js_strings['invalid_server_response'] = __(
230
+			'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.',
231
+			'event_espresso'
232
+		);
233
+		EE_Registry::$i18n_js_strings['error_occurred'] = __(
234
+			'An error occurred! Please refresh the page and try again.',
235
+			'event_espresso'
236
+		);
237
+		EE_Registry::$i18n_js_strings['confirm_delete_state'] = __(
238
+			'Are you sure you want to delete this State / Province?',
239
+			'event_espresso'
240
+		);
241
+		$protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
242
+		EE_Registry::$i18n_js_strings['ajax_url'] = admin_url(
243
+			'admin-ajax.php?page=espresso_general_settings',
244
+			$protocol
245
+		);
246
+	}
247
+
248
+	public function admin_notices()
249
+	{
250
+	}
251
+
252
+	public function admin_footer_scripts()
253
+	{
254
+	}
255
+
256
+
257
+	/**
258
+	 * Enqueue scripts and styles for the default route.
259
+	 */
260
+	public function load_scripts_styles_default()
261
+	{
262
+		// styles
263
+		wp_enqueue_style('thickbox');
264
+		// scripts
265
+		wp_enqueue_script('media-upload');
266
+		wp_enqueue_script('thickbox');
267
+		wp_register_script(
268
+			'organization_settings',
269
+			GEN_SET_ASSETS_URL . 'your_organization_settings.js',
270
+			array('jquery', 'media-upload', 'thickbox'),
271
+			EVENT_ESPRESSO_VERSION,
272
+			true
273
+		);
274
+		wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION);
275
+		wp_enqueue_script('organization_settings');
276
+		wp_enqueue_style('organization-css');
277
+		$confirm_image_delete = array(
278
+			'text' => __(
279
+				'Do you really want to delete this image? Please remember to save your settings to complete the removal.',
280
+				'event_espresso'
281
+			),
282
+		);
283
+		wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete);
284
+	}
285
+
286
+
287
+	/**
288
+	 * Enqueue scripts and styles for the country settings route.
289
+	 */
290
+	public function load_scripts_styles_country_settings()
291
+	{
292
+		// scripts
293
+		wp_register_script(
294
+			'gen_settings_countries',
295
+			GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
296
+			array('ee_admin_js'),
297
+			EVENT_ESPRESSO_VERSION,
298
+			true
299
+		);
300
+		wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION);
301
+		wp_enqueue_script('gen_settings_countries');
302
+		wp_enqueue_style('organization-css');
303
+	}
304
+
305
+
306
+	/*************        Espresso Pages        *************/
307
+	/**
308
+	 * _espresso_page_settings
309
+	 *
310
+	 * @throws \EE_Error
311
+	 */
312
+	protected function _espresso_page_settings()
313
+	{
314
+		// Check to make sure all of the main pages are setup properly,
315
+		// if not create the default pages and display an admin notice
316
+		EEH_Activation::verify_default_pages_exist();
317
+		$this->_transient_garbage_collection();
318
+		$this->_template_args['values'] = $this->_yes_no_values;
319
+		$this->_template_args['reg_page_id'] = isset(EE_Registry::instance()->CFG->core->reg_page_id)
320
+			? EE_Registry::instance()->CFG->core->reg_page_id
321
+			: null;
322
+		$this->_template_args['reg_page_obj'] = isset(EE_Registry::instance()->CFG->core->reg_page_id)
323
+			? get_page(EE_Registry::instance()->CFG->core->reg_page_id)
324
+			: false;
325
+		$this->_template_args['txn_page_id'] = isset(EE_Registry::instance()->CFG->core->txn_page_id)
326
+			? EE_Registry::instance()->CFG->core->txn_page_id
327
+			: null;
328
+		$this->_template_args['txn_page_obj'] = isset(EE_Registry::instance()->CFG->core->txn_page_id)
329
+			? get_page(EE_Registry::instance()->CFG->core->txn_page_id)
330
+			: false;
331
+		$this->_template_args['thank_you_page_id'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id)
332
+			? EE_Registry::instance()->CFG->core->thank_you_page_id
333
+			: null;
334
+		$this->_template_args['thank_you_page_obj'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id)
335
+			? get_page(EE_Registry::instance()->CFG->core->thank_you_page_id)
336
+			: false;
337
+		$this->_template_args['cancel_page_id'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id)
338
+			? EE_Registry::instance()->CFG->core->cancel_page_id
339
+			: null;
340
+		$this->_template_args['cancel_page_obj'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id)
341
+			? get_page(EE_Registry::instance()->CFG->core->cancel_page_id)
342
+			: false;
343
+		$this->_set_add_edit_form_tags('update_espresso_page_settings');
344
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
345
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
346
+			GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
347
+			$this->_template_args,
348
+			true
349
+		);
350
+		$this->display_admin_page_with_sidebar();
351
+	}
352
+
353
+
354
+	/**
355
+	 * Handler for updating espresso page settings.
356
+	 */
357
+	protected function _update_espresso_page_settings()
358
+	{
359
+		// capture incoming request data && set page IDs
360
+		EE_Registry::instance()->CFG->core->reg_page_id = isset($this->_req_data['reg_page_id'])
361
+			? absint($this->_req_data['reg_page_id'])
362
+			: EE_Registry::instance()->CFG->core->reg_page_id;
363
+		EE_Registry::instance()->CFG->core->txn_page_id = isset($this->_req_data['txn_page_id'])
364
+			? absint($this->_req_data['txn_page_id'])
365
+			: EE_Registry::instance()->CFG->core->txn_page_id;
366
+		EE_Registry::instance()->CFG->core->thank_you_page_id = isset($this->_req_data['thank_you_page_id'])
367
+			? absint($this->_req_data['thank_you_page_id'])
368
+			: EE_Registry::instance()->CFG->core->thank_you_page_id;
369
+		EE_Registry::instance()->CFG->core->cancel_page_id = isset($this->_req_data['cancel_page_id'])
370
+			? absint($this->_req_data['cancel_page_id'])
371
+			: EE_Registry::instance()->CFG->core->cancel_page_id;
372
+
373
+		EE_Registry::instance()->CFG->core = apply_filters(
374
+			'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core',
375
+			EE_Registry::instance()->CFG->core,
376
+			$this->_req_data
377
+		);
378
+		$what = __('Critical Pages & Shortcodes', 'event_espresso');
379
+		$this->_redirect_after_action(
380
+			$this->_update_espresso_configuration(
381
+				$what,
382
+				EE_Registry::instance()->CFG->core,
383
+				__FILE__,
384
+				__FUNCTION__,
385
+				__LINE__
386
+			),
387
+			$what,
388
+			'',
389
+			array(
390
+				'action' => 'critical_pages',
391
+			),
392
+			true
393
+		);
394
+	}
395
+
396
+
397
+	/*************        Your Organization        *************/
398
+
399
+
400
+	/**
401
+	 * Output for the Your Organization settings route.
402
+	 *
403
+	 * @throws DomainException
404
+	 * @throws EE_Error
405
+	 */
406
+	protected function _your_organization_settings()
407
+	{
408
+
409
+		$this->_template_args['site_license_key'] = isset(
410
+			EE_Registry::instance()->NET_CFG->core->site_license_key
411
+		)
412
+			? EE_Registry::instance()->NET_CFG->core->get_pretty('site_license_key')
413
+			: '';
414
+		$this->_template_args['organization_name'] = isset(EE_Registry::instance()->CFG->organization->name)
415
+			? EE_Registry::instance()->CFG->organization->get_pretty('name')
416
+			: '';
417
+		$this->_template_args['organization_address_1'] = isset(EE_Registry::instance()->CFG->organization->address_1)
418
+			? EE_Registry::instance()->CFG->organization->get_pretty('address_1')
419
+			: '';
420
+		$this->_template_args['organization_address_2'] = isset(EE_Registry::instance()->CFG->organization->address_2)
421
+			? EE_Registry::instance()->CFG->organization->get_pretty('address_2')
422
+			: '';
423
+		$this->_template_args['organization_city'] = isset(EE_Registry::instance()->CFG->organization->city)
424
+			? EE_Registry::instance()->CFG->organization->get_pretty('city')
425
+			: '';
426
+		$this->_template_args['organization_zip'] = isset(EE_Registry::instance()->CFG->organization->zip)
427
+			? EE_Registry::instance()->CFG->organization->get_pretty('zip')
428
+			: '';
429
+		$this->_template_args['organization_email'] = isset(EE_Registry::instance()->CFG->organization->email)
430
+			? EE_Registry::instance()->CFG->organization->get_pretty('email')
431
+			: '';
432
+		$this->_template_args['organization_phone'] = isset(EE_Registry::instance()->CFG->organization->phone)
433
+			? EE_Registry::instance()->CFG->organization->get_pretty('phone')
434
+			: '';
435
+		$this->_template_args['organization_vat'] = isset(EE_Registry::instance()->CFG->organization->vat)
436
+			? EE_Registry::instance()->CFG->organization->get_pretty('vat')
437
+			: '';
438
+		$this->_template_args['currency_sign'] = isset(EE_Registry::instance()->CFG->currency->sign)
439
+			? EE_Registry::instance()->CFG->currency->get_pretty('sign')
440
+			: '$';
441
+		$this->_template_args['organization_logo_url'] = isset(EE_Registry::instance()->CFG->organization->logo_url)
442
+			? EE_Registry::instance()->CFG->organization->get_pretty('logo_url')
443
+			: false;
444
+		$this->_template_args['organization_facebook'] = isset(EE_Registry::instance()->CFG->organization->facebook)
445
+			? EE_Registry::instance()->CFG->organization->get_pretty('facebook')
446
+			: '';
447
+		$this->_template_args['organization_twitter'] = isset(EE_Registry::instance()->CFG->organization->twitter)
448
+			? EE_Registry::instance()->CFG->organization->get_pretty('twitter')
449
+			: '';
450
+		$this->_template_args['organization_linkedin'] = isset(EE_Registry::instance()->CFG->organization->linkedin)
451
+			? EE_Registry::instance()->CFG->organization->get_pretty('linkedin')
452
+			: '';
453
+		$this->_template_args['organization_pinterest'] = isset(EE_Registry::instance()->CFG->organization->pinterest)
454
+			? EE_Registry::instance()->CFG->organization->get_pretty('pinterest')
455
+			: '';
456
+		$this->_template_args['organization_google'] = isset(EE_Registry::instance()->CFG->organization->google)
457
+			? EE_Registry::instance()->CFG->organization->get_pretty('google')
458
+			: '';
459
+		$this->_template_args['organization_instagram'] = isset(EE_Registry::instance()->CFG->organization->instagram)
460
+			? EE_Registry::instance()->CFG->organization->get_pretty('instagram')
461
+			: '';
462
+		// UXIP settings
463
+		$this->_template_args['ee_ueip_optin'] = isset(EE_Registry::instance()->CFG->core->ee_ueip_optin)
464
+			? EE_Registry::instance()->CFG->core->get_pretty('ee_ueip_optin')
465
+			: 'yes';
466
+
467
+		$STA_ID = isset(EE_Registry::instance()->CFG->organization->STA_ID)
468
+			? EE_Registry::instance()->CFG->organization->STA_ID
469
+			: 4;
470
+		$this->_template_args['states'] = new EE_Question_Form_Input(
471
+			EE_Question::new_instance(
472
+				array(
473
+					'QST_ID'           => 0,
474
+					'QST_display_text' => __('State/Province', 'event_espresso'),
475
+					'QST_system'       => 'admin-state',
476
+				)
477
+			),
478
+			EE_Answer::new_instance(
479
+				array(
480
+					'ANS_ID'    => 0,
481
+					'ANS_value' => $STA_ID,
482
+				)
483
+			),
484
+			array(
485
+				'input_id'       => 'organization_state',
486
+				'input_name'     => 'organization_state',
487
+				'input_prefix'   => '',
488
+				'append_qstn_id' => false,
489
+			)
490
+		);
491
+
492
+		$CNT_ISO = isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
493
+			? EE_Registry::instance()->CFG->organization->CNT_ISO
494
+			: 'US';
495
+		$this->_template_args['countries'] = new EE_Question_Form_Input(
496
+			EE_Question::new_instance(
497
+				array(
498
+					'QST_ID'           => 0,
499
+					'QST_display_text' => __('Country', 'event_espresso'),
500
+					'QST_system'       => 'admin-country',
501
+				)
502
+			),
503
+			EE_Answer::new_instance(
504
+				array(
505
+					'ANS_ID'    => 0,
506
+					'ANS_value' => $CNT_ISO,
507
+				)
508
+			),
509
+			array(
510
+				'input_id'       => 'organization_country',
511
+				'input_name'     => 'organization_country',
512
+				'input_prefix'   => '',
513
+				'append_qstn_id' => false,
514
+			)
515
+		);
516
+
517
+		add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
518
+		add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
519
+
520
+		// PUE verification stuff
521
+		$ver_option_key = 'puvererr_' . basename(EE_PLUGIN_BASENAME);
522
+		$verify_fail = get_option($ver_option_key);
523
+		$this->_template_args['site_license_key_verified'] = $verify_fail
524
+															 || ! empty($verify_fail)
525
+															 || (empty($this->_template_args['site_license_key'])
526
+																 && empty($verify_fail)
527
+															 )
528
+			? '<span class="dashicons dashicons-admin-network ee-icon-color-ee-red ee-icon-size-20"></span>'
529
+			: '<span class="dashicons dashicons-admin-network ee-icon-color-ee-green ee-icon-size-20"></span>';
530
+
531
+		$this->_set_add_edit_form_tags('update_your_organization_settings');
532
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
533
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
534
+			GEN_SET_TEMPLATE_PATH . 'your_organization_settings.template.php',
535
+			$this->_template_args,
536
+			true
537
+		);
538
+
539
+		$this->display_admin_page_with_sidebar();
540
+	}
541
+
542
+
543
+	/**
544
+	 * Handler for updating organziation settings.
545
+	 */
546
+	protected function _update_your_organization_settings()
547
+	{
548
+		if (is_main_site()) {
549
+			EE_Registry::instance()->NET_CFG->core->site_license_key = isset($this->_req_data['site_license_key'])
550
+				? sanitize_text_field($this->_req_data['site_license_key'])
551
+				: EE_Registry::instance()->NET_CFG->core->site_license_key;
552
+		}
553
+		EE_Registry::instance()->CFG->organization->name = isset($this->_req_data['organization_name'])
554
+			? sanitize_text_field($this->_req_data['organization_name'])
555
+			: EE_Registry::instance()->CFG->organization->name;
556
+		EE_Registry::instance()->CFG->organization->address_1 = isset($this->_req_data['organization_address_1'])
557
+			? sanitize_text_field($this->_req_data['organization_address_1'])
558
+			: EE_Registry::instance()->CFG->organization->address_1;
559
+		EE_Registry::instance()->CFG->organization->address_2 = isset($this->_req_data['organization_address_2'])
560
+			? sanitize_text_field($this->_req_data['organization_address_2'])
561
+			: EE_Registry::instance()->CFG->organization->address_2;
562
+		EE_Registry::instance()->CFG->organization->city = isset($this->_req_data['organization_city'])
563
+			? sanitize_text_field($this->_req_data['organization_city'])
564
+			: EE_Registry::instance()->CFG->organization->city;
565
+		EE_Registry::instance()->CFG->organization->STA_ID = isset($this->_req_data['organization_state'])
566
+			? absint($this->_req_data['organization_state'])
567
+			: EE_Registry::instance()->CFG->organization->STA_ID;
568
+		EE_Registry::instance()->CFG->organization->CNT_ISO = isset($this->_req_data['organization_country'])
569
+			? sanitize_text_field($this->_req_data['organization_country'])
570
+			: EE_Registry::instance()->CFG->organization->CNT_ISO;
571
+		EE_Registry::instance()->CFG->organization->zip = isset($this->_req_data['organization_zip'])
572
+			? sanitize_text_field($this->_req_data['organization_zip'])
573
+			: EE_Registry::instance()->CFG->organization->zip;
574
+		EE_Registry::instance()->CFG->organization->email = isset($this->_req_data['organization_email'])
575
+			? sanitize_email($this->_req_data['organization_email'])
576
+			: EE_Registry::instance()->CFG->organization->email;
577
+		EE_Registry::instance()->CFG->organization->vat = isset($this->_req_data['organization_vat'])
578
+			? sanitize_text_field($this->_req_data['organization_vat'])
579
+			: EE_Registry::instance()->CFG->organization->vat;
580
+		EE_Registry::instance()->CFG->organization->phone = isset($this->_req_data['organization_phone'])
581
+			? sanitize_text_field($this->_req_data['organization_phone'])
582
+			: EE_Registry::instance()->CFG->organization->phone;
583
+		EE_Registry::instance()->CFG->organization->logo_url = isset($this->_req_data['organization_logo_url'])
584
+			? esc_url_raw($this->_req_data['organization_logo_url'])
585
+			: EE_Registry::instance()->CFG->organization->logo_url;
586
+		EE_Registry::instance()->CFG->organization->facebook = isset($this->_req_data['organization_facebook'])
587
+			? esc_url_raw($this->_req_data['organization_facebook'])
588
+			: EE_Registry::instance()->CFG->organization->facebook;
589
+		EE_Registry::instance()->CFG->organization->twitter = isset($this->_req_data['organization_twitter'])
590
+			? esc_url_raw($this->_req_data['organization_twitter'])
591
+			: EE_Registry::instance()->CFG->organization->twitter;
592
+		EE_Registry::instance()->CFG->organization->linkedin = isset($this->_req_data['organization_linkedin'])
593
+			? esc_url_raw($this->_req_data['organization_linkedin'])
594
+			: EE_Registry::instance()->CFG->organization->linkedin;
595
+		EE_Registry::instance()->CFG->organization->pinterest = isset($this->_req_data['organization_pinterest'])
596
+			? esc_url_raw($this->_req_data['organization_pinterest'])
597
+			: EE_Registry::instance()->CFG->organization->pinterest;
598
+		EE_Registry::instance()->CFG->organization->google = isset($this->_req_data['organization_google'])
599
+			? esc_url_raw($this->_req_data['organization_google'])
600
+			: EE_Registry::instance()->CFG->organization->google;
601
+		EE_Registry::instance()->CFG->organization->instagram = isset($this->_req_data['organization_instagram'])
602
+			? esc_url_raw($this->_req_data['organization_instagram'])
603
+			: EE_Registry::instance()->CFG->organization->instagram;
604
+		EE_Registry::instance()->CFG->core->ee_ueip_optin = isset($this->_req_data['ueip_optin'])
605
+															&& ! empty($this->_req_data['ueip_optin'])
606
+			? filter_var($this->_req_data['ueip_optin'], FILTER_VALIDATE_BOOLEAN)
607
+			: EE_Registry::instance()->CFG->core->ee_ueip_optin;
608
+
609
+		EE_Registry::instance()->CFG->currency = new EE_Currency_Config(
610
+			EE_Registry::instance()->CFG->organization->CNT_ISO
611
+		);
612
+
613
+		EE_Registry::instance()->CFG = apply_filters(
614
+			'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG',
615
+			EE_Registry::instance()->CFG
616
+		);
617
+
618
+		$what = 'Your Organization Settings';
619
+		$success = $this->_update_espresso_configuration(
620
+			$what,
621
+			EE_Registry::instance()->CFG,
622
+			__FILE__,
623
+			__FUNCTION__,
624
+			__LINE__
625
+		);
626
+
627
+		$this->_redirect_after_action($success, $what, 'updated', array('action' => 'default'));
628
+	}
629
+
630
+
631
+
632
+	/*************        Admin Options        *************/
633
+
634
+
635
+	/**
636
+	 * _admin_option_settings
637
+	 *
638
+	 * @throws \EE_Error
639
+	 * @throws \LogicException
640
+	 */
641
+	protected function _admin_option_settings()
642
+	{
643
+		$this->_template_args['admin_page_content'] = '';
644
+		try {
645
+			$admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
646
+			// still need this for the old school form in Extend_General_Settings_Admin_Page
647
+			$this->_template_args['values'] = $this->_yes_no_values;
648
+			// also need to account for the do_action that was in the old template
649
+			$admin_options_settings_form->setTemplateArgs($this->_template_args);
650
+			$this->_template_args['admin_page_content'] = $admin_options_settings_form->display();
651
+		} catch (Exception $e) {
652
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
653
+		}
654
+		$this->_set_add_edit_form_tags('update_admin_option_settings');
655
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
656
+		$this->display_admin_page_with_sidebar();
657
+	}
658
+
659
+
660
+	/**
661
+	 * _update_admin_option_settings
662
+	 *
663
+	 * @throws \EE_Error
664
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
665
+	 * @throws \EventEspresso\core\exceptions\InvalidFormSubmissionException
666
+	 * @throws \InvalidArgumentException
667
+	 * @throws \LogicException
668
+	 */
669
+	protected function _update_admin_option_settings()
670
+	{
671
+		try {
672
+			$admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
673
+			$admin_options_settings_form->process($this->_req_data[ $admin_options_settings_form->slug() ]);
674
+			EE_Registry::instance()->CFG->admin = apply_filters(
675
+				'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
676
+				EE_Registry::instance()->CFG->admin
677
+			);
678
+		} catch (Exception $e) {
679
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
680
+		}
681
+		$this->_redirect_after_action(
682
+			apply_filters(
683
+				'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success',
684
+				$this->_update_espresso_configuration(
685
+					'Admin Options',
686
+					EE_Registry::instance()->CFG->admin,
687
+					__FILE__,
688
+					__FUNCTION__,
689
+					__LINE__
690
+				)
691
+			),
692
+			'Admin Options',
693
+			'updated',
694
+			array('action' => 'admin_option_settings')
695
+		);
696
+	}
697
+
698
+
699
+	/*************        Countries        *************/
700
+
701
+
702
+	/**
703
+	 * Output Country Settings view.
704
+	 *
705
+	 * @throws DomainException
706
+	 * @throws EE_Error
707
+	 */
708
+	protected function _country_settings()
709
+	{
710
+		$CNT_ISO = isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
711
+			? EE_Registry::instance()->CFG->organization->CNT_ISO
712
+			: 'US';
713
+		$CNT_ISO = isset($this->_req_data['country'])
714
+			? strtoupper(sanitize_text_field($this->_req_data['country']))
715
+			: $CNT_ISO;
716
+
717
+		// load field generator helper
718
+
719
+		$this->_template_args['values'] = $this->_yes_no_values;
720
+
721
+		$this->_template_args['countries'] = new EE_Question_Form_Input(
722
+			EE_Question::new_instance(
723
+				array(
724
+					'QST_ID'           => 0,
725
+					'QST_display_text' => __('Select Country', 'event_espresso'),
726
+					'QST_system'       => 'admin-country',
727
+				)
728
+			),
729
+			EE_Answer::new_instance(
730
+				array(
731
+					'ANS_ID'    => 0,
732
+					'ANS_value' => $CNT_ISO,
733
+				)
734
+			),
735
+			array(
736
+				'input_id'       => 'country',
737
+				'input_name'     => 'country',
738
+				'input_prefix'   => '',
739
+				'append_qstn_id' => false,
740
+			)
741
+		);
742
+
743
+		add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
744
+		add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
745
+		$this->_template_args['country_details_settings'] = $this->display_country_settings();
746
+		$this->_template_args['country_states_settings'] = $this->display_country_states();
747
+
748
+		$this->_set_add_edit_form_tags('update_country_settings');
749
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
750
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
751
+			GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
752
+			$this->_template_args,
753
+			true
754
+		);
755
+		$this->display_admin_page_with_no_sidebar();
756
+	}
757
+
758
+
759
+	/**
760
+	 *        display_country_settings
761
+	 *
762
+	 * @access    public
763
+	 * @param    string $CNT_ISO
764
+	 * @return mixed string | array
765
+	 * @throws DomainException
766
+	 */
767
+	public function display_country_settings($CNT_ISO = '')
768
+	{
769
+
770
+		$CNT_ISO = isset($this->_req_data['country'])
771
+			? strtoupper(sanitize_text_field($this->_req_data['country']))
772
+			: $CNT_ISO;
773
+		if (! $CNT_ISO) {
774
+			return '';
775
+		}
776
+
777
+		// for ajax
778
+		remove_all_filters('FHEE__EEH_Form_Fields__label_html');
779
+		remove_all_filters('FHEE__EEH_Form_Fields__input_html');
780
+		add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
781
+		add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
782
+		$country = EEM_Country::instance()->get_one_by_ID($CNT_ISO);
783
+
784
+		$country_input_types = array(
785
+			'CNT_active'      => array(
786
+				'type'             => 'RADIO_BTN',
787
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
788
+				'class'            => '',
789
+				'options'          => $this->_yes_no_values,
790
+				'use_desc_4_label' => true,
791
+			),
792
+			'CNT_ISO'         => array(
793
+				'type'       => 'TEXT',
794
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
795
+				'class'      => 'small-text',
796
+			),
797
+			'CNT_ISO3'        => array(
798
+				'type'       => 'TEXT',
799
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
800
+				'class'      => 'small-text',
801
+			),
802
+			'RGN_ID'          => array(
803
+				'type'       => 'TEXT',
804
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
805
+				'class'      => 'small-text',
806
+			),
807
+			'CNT_name'        => array(
808
+				'type'       => 'TEXT',
809
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
810
+				'class'      => 'regular-text',
811
+			),
812
+			'CNT_cur_code'    => array(
813
+				'type'       => 'TEXT',
814
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
815
+				'class'      => 'small-text',
816
+			),
817
+			'CNT_cur_single'  => array(
818
+				'type'       => 'TEXT',
819
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
820
+				'class'      => 'medium-text',
821
+			),
822
+			'CNT_cur_plural'  => array(
823
+				'type'       => 'TEXT',
824
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
825
+				'class'      => 'medium-text',
826
+			),
827
+			'CNT_cur_sign'    => array(
828
+				'type'         => 'TEXT',
829
+				'input_name'   => 'cntry[' . $CNT_ISO . ']',
830
+				'class'        => 'small-text',
831
+				'htmlentities' => false,
832
+			),
833
+			'CNT_cur_sign_b4' => array(
834
+				'type'             => 'RADIO_BTN',
835
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
836
+				'class'            => '',
837
+				'options'          => $this->_yes_no_values,
838
+				'use_desc_4_label' => true,
839
+			),
840
+			'CNT_cur_dec_plc' => array(
841
+				'type'       => 'RADIO_BTN',
842
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
843
+				'class'      => '',
844
+				'options'    => array(
845
+					array('id' => 0, 'text' => ''),
846
+					array('id' => 1, 'text' => ''),
847
+					array('id' => 2, 'text' => ''),
848
+					array('id' => 3, 'text' => ''),
849
+				),
850
+			),
851
+			'CNT_cur_dec_mrk' => array(
852
+				'type'             => 'RADIO_BTN',
853
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
854
+				'class'            => '',
855
+				'options'          => array(
856
+					array(
857
+						'id'   => ',',
858
+						'text' => __(', (comma)', 'event_espresso'),
859
+					),
860
+					array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')),
861
+				),
862
+				'use_desc_4_label' => true,
863
+			),
864
+			'CNT_cur_thsnds'  => array(
865
+				'type'             => 'RADIO_BTN',
866
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
867
+				'class'            => '',
868
+				'options'          => array(
869
+					array(
870
+						'id'   => ',',
871
+						'text' => __(', (comma)', 'event_espresso'),
872
+					),
873
+					array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')),
874
+				),
875
+				'use_desc_4_label' => true,
876
+			),
877
+			'CNT_tel_code'    => array(
878
+				'type'       => 'TEXT',
879
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
880
+				'class'      => 'small-text',
881
+			),
882
+			'CNT_is_EU'       => array(
883
+				'type'             => 'RADIO_BTN',
884
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
885
+				'class'            => '',
886
+				'options'          => $this->_yes_no_values,
887
+				'use_desc_4_label' => true,
888
+			),
889
+		);
890
+		$this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object(
891
+			$country,
892
+			$country_input_types
893
+		);
894
+		$country_details_settings = EEH_Template::display_template(
895
+			GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
896
+			$this->_template_args,
897
+			true
898
+		);
899
+
900
+		if (defined('DOING_AJAX')) {
901
+			$notices = EE_Error::get_notices(false, false, false);
902
+			echo wp_json_encode(
903
+				array(
904
+					'return_data' => $country_details_settings,
905
+					'success'     => $notices['success'],
906
+					'errors'      => $notices['errors'],
907
+				)
908
+			);
909
+			die();
910
+		} else {
911
+			return $country_details_settings;
912
+		}
913
+	}
914
+
915
+
916
+	/**
917
+	 *        display_country_states
918
+	 *
919
+	 * @access    public
920
+	 * @param    string $CNT_ISO
921
+	 * @return string
922
+	 * @throws DomainException
923
+	 */
924
+	public function display_country_states($CNT_ISO = '')
925
+	{
926
+
927
+		$CNT_ISO = isset($this->_req_data['country']) ? sanitize_text_field($this->_req_data['country']) : $CNT_ISO;
928
+
929
+		if (! $CNT_ISO) {
930
+			return '';
931
+		}
932
+		// for ajax
933
+		remove_all_filters('FHEE__EEH_Form_Fields__label_html');
934
+		remove_all_filters('FHEE__EEH_Form_Fields__input_html');
935
+		add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'state_form_field_label_wrap'), 10, 2);
936
+		add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'state_form_field_input__wrap'), 10, 2);
937
+		$states = EEM_State::instance()->get_all_states_for_these_countries(array($CNT_ISO => $CNT_ISO));
938
+
939
+		if ($states) {
940
+			foreach ($states as $STA_ID => $state) {
941
+				if ($state instanceof EE_State) {
942
+					// STA_abbrev    STA_name    STA_active
943
+					$state_input_types = array(
944
+						'STA_abbrev' => array(
945
+							'type'       => 'TEXT',
946
+							'input_name' => 'states[' . $STA_ID . ']',
947
+							'class'      => 'mid-text',
948
+						),
949
+						'STA_name'   => array(
950
+							'type'       => 'TEXT',
951
+							'input_name' => 'states[' . $STA_ID . ']',
952
+							'class'      => 'regular-text',
953
+						),
954
+						'STA_active' => array(
955
+							'type'             => 'RADIO_BTN',
956
+							'input_name'       => 'states[' . $STA_ID . ']',
957
+							'options'          => $this->_yes_no_values,
958
+							'use_desc_4_label' => true,
959
+						),
960
+					);
961
+					$this->_template_args['states'][ $STA_ID ]['inputs'] =
962
+						EE_Question_Form_Input::generate_question_form_inputs_for_object(
963
+							$state,
964
+							$state_input_types
965
+						);
966
+					$query_args = array(
967
+						'action'     => 'delete_state',
968
+						'STA_ID'     => $STA_ID,
969
+						'CNT_ISO'    => $CNT_ISO,
970
+						'STA_abbrev' => $state->abbrev(),
971
+					);
972
+					$this->_template_args['states'][ $STA_ID ]['delete_state_url'] =
973
+						EE_Admin_Page::add_query_args_and_nonce(
974
+							$query_args,
975
+							GEN_SET_ADMIN_URL
976
+						);
977
+				}
978
+			}
979
+		} else {
980
+			$this->_template_args['states'] = false;
981
+		}
982
+
983
+		$this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(
984
+			array('action' => 'add_new_state'),
985
+			GEN_SET_ADMIN_URL
986
+		);
987
+
988
+		$state_details_settings = EEH_Template::display_template(
989
+			GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
990
+			$this->_template_args,
991
+			true
992
+		);
993
+
994
+		if (defined('DOING_AJAX')) {
995
+			$notices = EE_Error::get_notices(false, false, false);
996
+			echo wp_json_encode(
997
+				array(
998
+					'return_data' => $state_details_settings,
999
+					'success'     => $notices['success'],
1000
+					'errors'      => $notices['errors'],
1001
+				)
1002
+			);
1003
+			die();
1004
+		} else {
1005
+			return $state_details_settings;
1006
+		}
1007
+	}
1008
+
1009
+
1010
+	/**
1011
+	 *        add_new_state
1012
+	 *
1013
+	 * @access    public
1014
+	 * @return void
1015
+	 * @throws EE_Error
1016
+	 */
1017
+	public function add_new_state()
1018
+	{
1019
+
1020
+		$success = true;
1021
+
1022
+		$CNT_ISO = isset($this->_req_data['CNT_ISO'])
1023
+			? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO']))
1024
+			: false;
1025
+		if (! $CNT_ISO) {
1026
+			EE_Error::add_error(
1027
+				__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1028
+				__FILE__,
1029
+				__FUNCTION__,
1030
+				__LINE__
1031
+			);
1032
+			$success = false;
1033
+		}
1034
+		$STA_abbrev = isset($this->_req_data['STA_abbrev'])
1035
+			? sanitize_text_field($this->_req_data['STA_abbrev'])
1036
+			: false;
1037
+		if (! $STA_abbrev) {
1038
+			EE_Error::add_error(
1039
+				__('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
1040
+				__FILE__,
1041
+				__FUNCTION__,
1042
+				__LINE__
1043
+			);
1044
+			$success = false;
1045
+		}
1046
+		$STA_name = isset($this->_req_data['STA_name'])
1047
+			? sanitize_text_field($this->_req_data['STA_name'])
1048
+			: false;
1049
+		if (! $STA_name) {
1050
+			EE_Error::add_error(
1051
+				__('No State name or an invalid State name was received.', 'event_espresso'),
1052
+				__FILE__,
1053
+				__FUNCTION__,
1054
+				__LINE__
1055
+			);
1056
+			$success = false;
1057
+		}
1058
+
1059
+		if ($success) {
1060
+			$cols_n_values = array(
1061
+				'CNT_ISO'    => $CNT_ISO,
1062
+				'STA_abbrev' => $STA_abbrev,
1063
+				'STA_name'   => $STA_name,
1064
+				'STA_active' => true,
1065
+			);
1066
+			$success = EEM_State::instance()->insert($cols_n_values);
1067
+			EE_Error::add_success(__('The State was added successfully.', 'event_espresso'));
1068
+		}
1069
+
1070
+		if (defined('DOING_AJAX')) {
1071
+			$notices = EE_Error::get_notices(false, false, false);
1072
+			echo wp_json_encode(array_merge($notices, array('return_data' => $CNT_ISO)));
1073
+			die();
1074
+		} else {
1075
+			$this->_redirect_after_action($success, 'State', 'added', array('action' => 'country_settings'));
1076
+		}
1077
+	}
1078
+
1079
+
1080
+	/**
1081
+	 *        delete_state
1082
+	 *
1083
+	 * @access    public
1084
+	 * @return        boolean
1085
+	 */
1086
+	public function delete_state()
1087
+	{
1088
+		$CNT_ISO = isset($this->_req_data['CNT_ISO'])
1089
+			? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO']))
1090
+			: false;
1091
+		$STA_ID = isset($this->_req_data['STA_ID'])
1092
+			? sanitize_text_field($this->_req_data['STA_ID'])
1093
+			: false;
1094
+		$STA_abbrev = isset($this->_req_data['STA_abbrev'])
1095
+			? sanitize_text_field($this->_req_data['STA_abbrev'])
1096
+			: false;
1097
+		if (! $STA_ID) {
1098
+			EE_Error::add_error(
1099
+				__('No State ID or an invalid State ID was received.', 'event_espresso'),
1100
+				__FILE__,
1101
+				__FUNCTION__,
1102
+				__LINE__
1103
+			);
1104
+			return false;
1105
+		}
1106
+
1107
+		$success = EEM_State::instance()->delete_by_ID($STA_ID);
1108
+		if ($success !== false) {
1109
+			do_action(
1110
+				'AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
1111
+				$CNT_ISO,
1112
+				$STA_ID,
1113
+				array('STA_abbrev' => $STA_abbrev)
1114
+			);
1115
+			EE_Error::add_success(__('The State was deleted successfully.', 'event_espresso'));
1116
+		}
1117
+		if (defined('DOING_AJAX')) {
1118
+			$notices = EE_Error::get_notices(false, false);
1119
+			$notices['return_data'] = true;
1120
+			echo wp_json_encode($notices);
1121
+			die();
1122
+		} else {
1123
+			$this->_redirect_after_action(
1124
+				$success,
1125
+				'State',
1126
+				'deleted',
1127
+				array('action' => 'country_settings')
1128
+			);
1129
+		}
1130
+	}
1131
+
1132
+
1133
+	/**
1134
+	 *        _update_country_settings
1135
+	 *
1136
+	 * @access    protected
1137
+	 * @return void
1138
+	 * @throws EE_Error
1139
+	 */
1140
+	protected function _update_country_settings()
1141
+	{
1142
+		// grab the country ISO code
1143
+		$CNT_ISO = isset($this->_req_data['country'])
1144
+			? strtoupper(sanitize_text_field($this->_req_data['country']))
1145
+			: false;
1146
+		if (! $CNT_ISO) {
1147
+			EE_Error::add_error(
1148
+				__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1149
+				__FILE__,
1150
+				__FUNCTION__,
1151
+				__LINE__
1152
+			);
1153
+
1154
+			return;
1155
+		}
1156
+		$cols_n_values = array();
1157
+		$cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3'])
1158
+			? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3']))
1159
+			: false;
1160
+		$cols_n_values['RGN_ID'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID'])
1161
+			? absint($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID'])
1162
+			: null;
1163
+		$cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name'])
1164
+			? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name'])
1165
+			: null;
1166
+		$cols_n_values['CNT_cur_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code'])
1167
+			? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code']))
1168
+			: 'USD';
1169
+		$cols_n_values['CNT_cur_single'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single'])
1170
+			? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single'])
1171
+			: 'dollar';
1172
+		$cols_n_values['CNT_cur_plural'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural'])
1173
+			? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural'])
1174
+			: 'dollars';
1175
+		$cols_n_values['CNT_cur_sign'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign'])
1176
+			? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign'])
1177
+			: '$';
1178
+		$cols_n_values['CNT_cur_sign_b4'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4'])
1179
+			? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4'])
1180
+			: true;
1181
+		$cols_n_values['CNT_cur_dec_plc'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc'])
1182
+			? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc'])
1183
+			: 2;
1184
+		$cols_n_values['CNT_cur_dec_mrk'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk'])
1185
+			? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk'])
1186
+			: '.';
1187
+		$cols_n_values['CNT_cur_thsnds'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds'])
1188
+			? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds'])
1189
+			: ',';
1190
+		$cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code'])
1191
+			? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code'])
1192
+			: null;
1193
+		$cols_n_values['CNT_is_EU'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU'])
1194
+			? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU'])
1195
+			: false;
1196
+		$cols_n_values['CNT_active'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active'])
1197
+			? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active'])
1198
+			: false;
1199
+		// allow filtering of country data
1200
+		$cols_n_values = apply_filters(
1201
+			'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values',
1202
+			$cols_n_values
1203
+		);
1204
+
1205
+		// where values
1206
+		$where_cols_n_values = array(array('CNT_ISO' => $CNT_ISO));
1207
+		// run the update
1208
+		$success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values);
1209
+
1210
+		if (isset($this->_req_data['states']) && is_array($this->_req_data['states']) && $success !== false) {
1211
+			// allow filtering of states data
1212
+			$states = apply_filters(
1213
+				'FHEE__General_Settings_Admin_Page___update_country_settings__states',
1214
+				$this->_req_data['states']
1215
+			);
1216
+
1217
+			// loop thru state data ( looks like : states[75][STA_name] )
1218
+			foreach ($states as $STA_ID => $state) {
1219
+				$cols_n_values = array(
1220
+					'CNT_ISO'    => $CNT_ISO,
1221
+					'STA_abbrev' => sanitize_text_field($state['STA_abbrev']),
1222
+					'STA_name'   => sanitize_text_field($state['STA_name']),
1223
+					'STA_active' => (bool) absint($state['STA_active']),
1224
+				);
1225
+				// where values
1226
+				$where_cols_n_values = array(array('STA_ID' => $STA_ID));
1227
+				// run the update
1228
+				$success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values);
1229
+				if ($success !== false) {
1230
+					do_action(
1231
+						'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
1232
+						$CNT_ISO,
1233
+						$STA_ID,
1234
+						$cols_n_values
1235
+					);
1236
+				}
1237
+			}
1238
+		}
1239
+		// check if country being edited matches org option country, and if so, then  update EE_Config with new settings
1240
+		if (isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
1241
+			&& $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO
1242
+		) {
1243
+			EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO);
1244
+			EE_Registry::instance()->CFG->update_espresso_config();
1245
+		}
1246
+
1247
+		if ($success !== false) {
1248
+			EE_Error::add_success(
1249
+				esc_html__('Country Settings updated successfully.', 'event_espresso')
1250
+			);
1251
+		}
1252
+		$this->_redirect_after_action(
1253
+			$success,
1254
+			'',
1255
+			'',
1256
+			array('action' => 'country_settings', 'country' => $CNT_ISO),
1257
+			true
1258
+		);
1259
+	}
1260
+
1261
+
1262
+	/**
1263
+	 *        form_form_field_label_wrap
1264
+	 *
1265
+	 * @access        public
1266
+	 * @param        string $label
1267
+	 * @return        string
1268
+	 */
1269
+	public function country_form_field_label_wrap($label, $required_text)
1270
+	{
1271
+		return '
1272 1272
 			<tr>
1273 1273
 				<th>
1274 1274
 					' . $label . '
1275 1275
 				</th>';
1276
-    }
1277
-
1278
-
1279
-    /**
1280
-     *        form_form_field_input__wrap
1281
-     *
1282
-     * @access        public
1283
-     * @param        string $label
1284
-     * @return        string
1285
-     */
1286
-    public function country_form_field_input__wrap($input, $label)
1287
-    {
1288
-        return '
1276
+	}
1277
+
1278
+
1279
+	/**
1280
+	 *        form_form_field_input__wrap
1281
+	 *
1282
+	 * @access        public
1283
+	 * @param        string $label
1284
+	 * @return        string
1285
+	 */
1286
+	public function country_form_field_input__wrap($input, $label)
1287
+	{
1288
+		return '
1289 1289
 				<td class="general-settings-country-input-td">
1290 1290
 					' . $input . '
1291 1291
 				</td>
1292 1292
 			</tr>';
1293
-    }
1294
-
1295
-
1296
-    /**
1297
-     *        form_form_field_label_wrap
1298
-     *
1299
-     * @access        public
1300
-     * @param        string $label
1301
-     * @param        string $required_text
1302
-     * @return        string
1303
-     */
1304
-    public function state_form_field_label_wrap($label, $required_text)
1305
-    {
1306
-        return $required_text;
1307
-    }
1308
-
1309
-
1310
-    /**
1311
-     *        form_form_field_input__wrap
1312
-     *
1313
-     * @access        public
1314
-     * @param        string $label
1315
-     * @return        string
1316
-     */
1317
-    public function state_form_field_input__wrap($input, $label)
1318
-    {
1319
-        return '
1293
+	}
1294
+
1295
+
1296
+	/**
1297
+	 *        form_form_field_label_wrap
1298
+	 *
1299
+	 * @access        public
1300
+	 * @param        string $label
1301
+	 * @param        string $required_text
1302
+	 * @return        string
1303
+	 */
1304
+	public function state_form_field_label_wrap($label, $required_text)
1305
+	{
1306
+		return $required_text;
1307
+	}
1308
+
1309
+
1310
+	/**
1311
+	 *        form_form_field_input__wrap
1312
+	 *
1313
+	 * @access        public
1314
+	 * @param        string $label
1315
+	 * @return        string
1316
+	 */
1317
+	public function state_form_field_input__wrap($input, $label)
1318
+	{
1319
+		return '
1320 1320
 				<td class="general-settings-country-state-input-td">
1321 1321
 					' . $input . '
1322 1322
 				</td>';
1323
-    }
1324
-
1325
-
1326
-    /***********/
1327
-
1328
-
1329
-    /**
1330
-     * displays edit and view links for critical EE pages
1331
-     *
1332
-     * @access public
1333
-     * @param int $ee_page_id
1334
-     * @return string
1335
-     */
1336
-    public static function edit_view_links($ee_page_id)
1337
-    {
1338
-        $links = '<a href="'
1339
-                 . add_query_arg(
1340
-                     array('post' => $ee_page_id, 'action' => 'edit'),
1341
-                     admin_url('post.php')
1342
-                 )
1343
-                 . '" >'
1344
-                 . __('Edit', 'event_espresso')
1345
-                 . '</a>';
1346
-        $links .= ' &nbsp;|&nbsp; ';
1347
-        $links .= '<a href="' . get_permalink($ee_page_id) . '" >' . __('View', 'event_espresso') . '</a>';
1348
-
1349
-        return $links;
1350
-    }
1351
-
1352
-
1353
-    /**
1354
-     * displays page and shortcode status for critical EE pages
1355
-     *
1356
-     * @param WP page object $ee_page
1357
-     * @return string
1358
-     */
1359
-    public static function page_and_shortcode_status($ee_page, $shortcode)
1360
-    {
1361
-
1362
-        // page status
1363
-        if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') {
1364
-            $pg_colour = 'green';
1365
-            $pg_status = sprintf(__('Page%sStatus%sOK', 'event_espresso'), '&nbsp;', '&nbsp;');
1366
-        } else {
1367
-            $pg_colour = 'red';
1368
-            $pg_status = sprintf(__('Page%sVisibility%sProblem', 'event_espresso'), '&nbsp;', '&nbsp;');
1369
-        }
1370
-
1371
-        // shortcode status
1372
-        if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) {
1373
-            $sc_colour = 'green';
1374
-            $sc_status = sprintf(__('Shortcode%sOK', 'event_espresso'), '&nbsp;');
1375
-        } else {
1376
-            $sc_colour = 'red';
1377
-            $sc_status = sprintf(__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1378
-        }
1379
-
1380
-        return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>'
1381
-               . $pg_status
1382
-               . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>';
1383
-    }
1384
-
1385
-
1386
-    /**
1387
-     * generates a dropdown of all parent pages - copied from WP core
1388
-     *
1389
-     * @param int $default
1390
-     * @param int $parent
1391
-     * @param int $level
1392
-     */
1393
-    public static function page_settings_dropdown($default = 0, $parent = 0, $level = 0)
1394
-    {
1395
-        global $wpdb;
1396
-        $items = $wpdb->get_results(
1397
-            $wpdb->prepare(
1398
-                "SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status != 'trash' ORDER BY menu_order",
1399
-                $parent
1400
-            )
1401
-        );
1402
-
1403
-        if ($items) {
1404
-            foreach ($items as $item) {
1405
-                $pad = str_repeat('&nbsp;', $level * 3);
1406
-                if ($item->ID == $default) {
1407
-                    $current = ' selected="selected"';
1408
-                } else {
1409
-                    $current = '';
1410
-                }
1411
-
1412
-                echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad "
1413
-                     . esc_html($item->post_title)
1414
-                     . "</option>";
1415
-                parent_dropdown($default, $item->ID, $level + 1);
1416
-            }
1417
-        }
1418
-    }
1323
+	}
1324
+
1325
+
1326
+	/***********/
1327
+
1328
+
1329
+	/**
1330
+	 * displays edit and view links for critical EE pages
1331
+	 *
1332
+	 * @access public
1333
+	 * @param int $ee_page_id
1334
+	 * @return string
1335
+	 */
1336
+	public static function edit_view_links($ee_page_id)
1337
+	{
1338
+		$links = '<a href="'
1339
+				 . add_query_arg(
1340
+					 array('post' => $ee_page_id, 'action' => 'edit'),
1341
+					 admin_url('post.php')
1342
+				 )
1343
+				 . '" >'
1344
+				 . __('Edit', 'event_espresso')
1345
+				 . '</a>';
1346
+		$links .= ' &nbsp;|&nbsp; ';
1347
+		$links .= '<a href="' . get_permalink($ee_page_id) . '" >' . __('View', 'event_espresso') . '</a>';
1348
+
1349
+		return $links;
1350
+	}
1351
+
1352
+
1353
+	/**
1354
+	 * displays page and shortcode status for critical EE pages
1355
+	 *
1356
+	 * @param WP page object $ee_page
1357
+	 * @return string
1358
+	 */
1359
+	public static function page_and_shortcode_status($ee_page, $shortcode)
1360
+	{
1361
+
1362
+		// page status
1363
+		if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') {
1364
+			$pg_colour = 'green';
1365
+			$pg_status = sprintf(__('Page%sStatus%sOK', 'event_espresso'), '&nbsp;', '&nbsp;');
1366
+		} else {
1367
+			$pg_colour = 'red';
1368
+			$pg_status = sprintf(__('Page%sVisibility%sProblem', 'event_espresso'), '&nbsp;', '&nbsp;');
1369
+		}
1370
+
1371
+		// shortcode status
1372
+		if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) {
1373
+			$sc_colour = 'green';
1374
+			$sc_status = sprintf(__('Shortcode%sOK', 'event_espresso'), '&nbsp;');
1375
+		} else {
1376
+			$sc_colour = 'red';
1377
+			$sc_status = sprintf(__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1378
+		}
1379
+
1380
+		return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>'
1381
+			   . $pg_status
1382
+			   . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>';
1383
+	}
1384
+
1385
+
1386
+	/**
1387
+	 * generates a dropdown of all parent pages - copied from WP core
1388
+	 *
1389
+	 * @param int $default
1390
+	 * @param int $parent
1391
+	 * @param int $level
1392
+	 */
1393
+	public static function page_settings_dropdown($default = 0, $parent = 0, $level = 0)
1394
+	{
1395
+		global $wpdb;
1396
+		$items = $wpdb->get_results(
1397
+			$wpdb->prepare(
1398
+				"SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status != 'trash' ORDER BY menu_order",
1399
+				$parent
1400
+			)
1401
+		);
1402
+
1403
+		if ($items) {
1404
+			foreach ($items as $item) {
1405
+				$pad = str_repeat('&nbsp;', $level * 3);
1406
+				if ($item->ID == $default) {
1407
+					$current = ' selected="selected"';
1408
+				} else {
1409
+					$current = '';
1410
+				}
1411
+
1412
+				echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad "
1413
+					 . esc_html($item->post_title)
1414
+					 . "</option>";
1415
+				parent_dropdown($default, $item->ID, $level + 1);
1416
+			}
1417
+		}
1418
+	}
1419 1419
 }
Please login to merge, or discard this patch.
Spacing   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -266,12 +266,12 @@  discard block
 block discarded – undo
266 266
         wp_enqueue_script('thickbox');
267 267
         wp_register_script(
268 268
             'organization_settings',
269
-            GEN_SET_ASSETS_URL . 'your_organization_settings.js',
269
+            GEN_SET_ASSETS_URL.'your_organization_settings.js',
270 270
             array('jquery', 'media-upload', 'thickbox'),
271 271
             EVENT_ESPRESSO_VERSION,
272 272
             true
273 273
         );
274
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION);
274
+        wp_register_style('organization-css', GEN_SET_ASSETS_URL.'organization.css', array(), EVENT_ESPRESSO_VERSION);
275 275
         wp_enqueue_script('organization_settings');
276 276
         wp_enqueue_style('organization-css');
277 277
         $confirm_image_delete = array(
@@ -292,12 +292,12 @@  discard block
 block discarded – undo
292 292
         // scripts
293 293
         wp_register_script(
294 294
             'gen_settings_countries',
295
-            GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
295
+            GEN_SET_ASSETS_URL.'gen_settings_countries.js',
296 296
             array('ee_admin_js'),
297 297
             EVENT_ESPRESSO_VERSION,
298 298
             true
299 299
         );
300
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION);
300
+        wp_register_style('organization-css', GEN_SET_ASSETS_URL.'organization.css', array(), EVENT_ESPRESSO_VERSION);
301 301
         wp_enqueue_script('gen_settings_countries');
302 302
         wp_enqueue_style('organization-css');
303 303
     }
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
         $this->_set_add_edit_form_tags('update_espresso_page_settings');
344 344
         $this->_set_publish_post_box_vars(null, false, false, null, false);
345 345
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
346
-            GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
346
+            GEN_SET_TEMPLATE_PATH.'espresso_page_settings.template.php',
347 347
             $this->_template_args,
348 348
             true
349 349
         );
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
         add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
519 519
 
520 520
         // PUE verification stuff
521
-        $ver_option_key = 'puvererr_' . basename(EE_PLUGIN_BASENAME);
521
+        $ver_option_key = 'puvererr_'.basename(EE_PLUGIN_BASENAME);
522 522
         $verify_fail = get_option($ver_option_key);
523 523
         $this->_template_args['site_license_key_verified'] = $verify_fail
524 524
                                                              || ! empty($verify_fail)
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
         $this->_set_add_edit_form_tags('update_your_organization_settings');
532 532
         $this->_set_publish_post_box_vars(null, false, false, null, false);
533 533
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
534
-            GEN_SET_TEMPLATE_PATH . 'your_organization_settings.template.php',
534
+            GEN_SET_TEMPLATE_PATH.'your_organization_settings.template.php',
535 535
             $this->_template_args,
536 536
             true
537 537
         );
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
     {
671 671
         try {
672 672
             $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
673
-            $admin_options_settings_form->process($this->_req_data[ $admin_options_settings_form->slug() ]);
673
+            $admin_options_settings_form->process($this->_req_data[$admin_options_settings_form->slug()]);
674 674
             EE_Registry::instance()->CFG->admin = apply_filters(
675 675
                 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
676 676
                 EE_Registry::instance()->CFG->admin
@@ -748,7 +748,7 @@  discard block
 block discarded – undo
748 748
         $this->_set_add_edit_form_tags('update_country_settings');
749 749
         $this->_set_publish_post_box_vars(null, false, false, null, false);
750 750
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
751
-            GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
751
+            GEN_SET_TEMPLATE_PATH.'countries_settings.template.php',
752 752
             $this->_template_args,
753 753
             true
754 754
         );
@@ -770,7 +770,7 @@  discard block
 block discarded – undo
770 770
         $CNT_ISO = isset($this->_req_data['country'])
771 771
             ? strtoupper(sanitize_text_field($this->_req_data['country']))
772 772
             : $CNT_ISO;
773
-        if (! $CNT_ISO) {
773
+        if ( ! $CNT_ISO) {
774 774
             return '';
775 775
         }
776 776
 
@@ -784,62 +784,62 @@  discard block
 block discarded – undo
784 784
         $country_input_types = array(
785 785
             'CNT_active'      => array(
786 786
                 'type'             => 'RADIO_BTN',
787
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
787
+                'input_name'       => 'cntry['.$CNT_ISO.']',
788 788
                 'class'            => '',
789 789
                 'options'          => $this->_yes_no_values,
790 790
                 'use_desc_4_label' => true,
791 791
             ),
792 792
             'CNT_ISO'         => array(
793 793
                 'type'       => 'TEXT',
794
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
794
+                'input_name' => 'cntry['.$CNT_ISO.']',
795 795
                 'class'      => 'small-text',
796 796
             ),
797 797
             'CNT_ISO3'        => array(
798 798
                 'type'       => 'TEXT',
799
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
799
+                'input_name' => 'cntry['.$CNT_ISO.']',
800 800
                 'class'      => 'small-text',
801 801
             ),
802 802
             'RGN_ID'          => array(
803 803
                 'type'       => 'TEXT',
804
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
804
+                'input_name' => 'cntry['.$CNT_ISO.']',
805 805
                 'class'      => 'small-text',
806 806
             ),
807 807
             'CNT_name'        => array(
808 808
                 'type'       => 'TEXT',
809
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
809
+                'input_name' => 'cntry['.$CNT_ISO.']',
810 810
                 'class'      => 'regular-text',
811 811
             ),
812 812
             'CNT_cur_code'    => array(
813 813
                 'type'       => 'TEXT',
814
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
814
+                'input_name' => 'cntry['.$CNT_ISO.']',
815 815
                 'class'      => 'small-text',
816 816
             ),
817 817
             'CNT_cur_single'  => array(
818 818
                 'type'       => 'TEXT',
819
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
819
+                'input_name' => 'cntry['.$CNT_ISO.']',
820 820
                 'class'      => 'medium-text',
821 821
             ),
822 822
             'CNT_cur_plural'  => array(
823 823
                 'type'       => 'TEXT',
824
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
824
+                'input_name' => 'cntry['.$CNT_ISO.']',
825 825
                 'class'      => 'medium-text',
826 826
             ),
827 827
             'CNT_cur_sign'    => array(
828 828
                 'type'         => 'TEXT',
829
-                'input_name'   => 'cntry[' . $CNT_ISO . ']',
829
+                'input_name'   => 'cntry['.$CNT_ISO.']',
830 830
                 'class'        => 'small-text',
831 831
                 'htmlentities' => false,
832 832
             ),
833 833
             'CNT_cur_sign_b4' => array(
834 834
                 'type'             => 'RADIO_BTN',
835
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
835
+                'input_name'       => 'cntry['.$CNT_ISO.']',
836 836
                 'class'            => '',
837 837
                 'options'          => $this->_yes_no_values,
838 838
                 'use_desc_4_label' => true,
839 839
             ),
840 840
             'CNT_cur_dec_plc' => array(
841 841
                 'type'       => 'RADIO_BTN',
842
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
842
+                'input_name' => 'cntry['.$CNT_ISO.']',
843 843
                 'class'      => '',
844 844
                 'options'    => array(
845 845
                     array('id' => 0, 'text' => ''),
@@ -850,7 +850,7 @@  discard block
 block discarded – undo
850 850
             ),
851 851
             'CNT_cur_dec_mrk' => array(
852 852
                 'type'             => 'RADIO_BTN',
853
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
853
+                'input_name'       => 'cntry['.$CNT_ISO.']',
854 854
                 'class'            => '',
855 855
                 'options'          => array(
856 856
                     array(
@@ -863,7 +863,7 @@  discard block
 block discarded – undo
863 863
             ),
864 864
             'CNT_cur_thsnds'  => array(
865 865
                 'type'             => 'RADIO_BTN',
866
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
866
+                'input_name'       => 'cntry['.$CNT_ISO.']',
867 867
                 'class'            => '',
868 868
                 'options'          => array(
869 869
                     array(
@@ -876,12 +876,12 @@  discard block
 block discarded – undo
876 876
             ),
877 877
             'CNT_tel_code'    => array(
878 878
                 'type'       => 'TEXT',
879
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
879
+                'input_name' => 'cntry['.$CNT_ISO.']',
880 880
                 'class'      => 'small-text',
881 881
             ),
882 882
             'CNT_is_EU'       => array(
883 883
                 'type'             => 'RADIO_BTN',
884
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
884
+                'input_name'       => 'cntry['.$CNT_ISO.']',
885 885
                 'class'            => '',
886 886
                 'options'          => $this->_yes_no_values,
887 887
                 'use_desc_4_label' => true,
@@ -892,7 +892,7 @@  discard block
 block discarded – undo
892 892
             $country_input_types
893 893
         );
894 894
         $country_details_settings = EEH_Template::display_template(
895
-            GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
895
+            GEN_SET_TEMPLATE_PATH.'country_details_settings.template.php',
896 896
             $this->_template_args,
897 897
             true
898 898
         );
@@ -926,7 +926,7 @@  discard block
 block discarded – undo
926 926
 
927 927
         $CNT_ISO = isset($this->_req_data['country']) ? sanitize_text_field($this->_req_data['country']) : $CNT_ISO;
928 928
 
929
-        if (! $CNT_ISO) {
929
+        if ( ! $CNT_ISO) {
930 930
             return '';
931 931
         }
932 932
         // for ajax
@@ -943,22 +943,22 @@  discard block
 block discarded – undo
943 943
                     $state_input_types = array(
944 944
                         'STA_abbrev' => array(
945 945
                             'type'       => 'TEXT',
946
-                            'input_name' => 'states[' . $STA_ID . ']',
946
+                            'input_name' => 'states['.$STA_ID.']',
947 947
                             'class'      => 'mid-text',
948 948
                         ),
949 949
                         'STA_name'   => array(
950 950
                             'type'       => 'TEXT',
951
-                            'input_name' => 'states[' . $STA_ID . ']',
951
+                            'input_name' => 'states['.$STA_ID.']',
952 952
                             'class'      => 'regular-text',
953 953
                         ),
954 954
                         'STA_active' => array(
955 955
                             'type'             => 'RADIO_BTN',
956
-                            'input_name'       => 'states[' . $STA_ID . ']',
956
+                            'input_name'       => 'states['.$STA_ID.']',
957 957
                             'options'          => $this->_yes_no_values,
958 958
                             'use_desc_4_label' => true,
959 959
                         ),
960 960
                     );
961
-                    $this->_template_args['states'][ $STA_ID ]['inputs'] =
961
+                    $this->_template_args['states'][$STA_ID]['inputs'] =
962 962
                         EE_Question_Form_Input::generate_question_form_inputs_for_object(
963 963
                             $state,
964 964
                             $state_input_types
@@ -969,7 +969,7 @@  discard block
 block discarded – undo
969 969
                         'CNT_ISO'    => $CNT_ISO,
970 970
                         'STA_abbrev' => $state->abbrev(),
971 971
                     );
972
-                    $this->_template_args['states'][ $STA_ID ]['delete_state_url'] =
972
+                    $this->_template_args['states'][$STA_ID]['delete_state_url'] =
973 973
                         EE_Admin_Page::add_query_args_and_nonce(
974 974
                             $query_args,
975 975
                             GEN_SET_ADMIN_URL
@@ -986,7 +986,7 @@  discard block
 block discarded – undo
986 986
         );
987 987
 
988 988
         $state_details_settings = EEH_Template::display_template(
989
-            GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
989
+            GEN_SET_TEMPLATE_PATH.'state_details_settings.template.php',
990 990
             $this->_template_args,
991 991
             true
992 992
         );
@@ -1022,7 +1022,7 @@  discard block
 block discarded – undo
1022 1022
         $CNT_ISO = isset($this->_req_data['CNT_ISO'])
1023 1023
             ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO']))
1024 1024
             : false;
1025
-        if (! $CNT_ISO) {
1025
+        if ( ! $CNT_ISO) {
1026 1026
             EE_Error::add_error(
1027 1027
                 __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1028 1028
                 __FILE__,
@@ -1034,7 +1034,7 @@  discard block
 block discarded – undo
1034 1034
         $STA_abbrev = isset($this->_req_data['STA_abbrev'])
1035 1035
             ? sanitize_text_field($this->_req_data['STA_abbrev'])
1036 1036
             : false;
1037
-        if (! $STA_abbrev) {
1037
+        if ( ! $STA_abbrev) {
1038 1038
             EE_Error::add_error(
1039 1039
                 __('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
1040 1040
                 __FILE__,
@@ -1046,7 +1046,7 @@  discard block
 block discarded – undo
1046 1046
         $STA_name = isset($this->_req_data['STA_name'])
1047 1047
             ? sanitize_text_field($this->_req_data['STA_name'])
1048 1048
             : false;
1049
-        if (! $STA_name) {
1049
+        if ( ! $STA_name) {
1050 1050
             EE_Error::add_error(
1051 1051
                 __('No State name or an invalid State name was received.', 'event_espresso'),
1052 1052
                 __FILE__,
@@ -1094,7 +1094,7 @@  discard block
 block discarded – undo
1094 1094
         $STA_abbrev = isset($this->_req_data['STA_abbrev'])
1095 1095
             ? sanitize_text_field($this->_req_data['STA_abbrev'])
1096 1096
             : false;
1097
-        if (! $STA_ID) {
1097
+        if ( ! $STA_ID) {
1098 1098
             EE_Error::add_error(
1099 1099
                 __('No State ID or an invalid State ID was received.', 'event_espresso'),
1100 1100
                 __FILE__,
@@ -1143,7 +1143,7 @@  discard block
 block discarded – undo
1143 1143
         $CNT_ISO = isset($this->_req_data['country'])
1144 1144
             ? strtoupper(sanitize_text_field($this->_req_data['country']))
1145 1145
             : false;
1146
-        if (! $CNT_ISO) {
1146
+        if ( ! $CNT_ISO) {
1147 1147
             EE_Error::add_error(
1148 1148
                 __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1149 1149
                 __FILE__,
@@ -1154,47 +1154,47 @@  discard block
 block discarded – undo
1154 1154
             return;
1155 1155
         }
1156 1156
         $cols_n_values = array();
1157
-        $cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3'])
1158
-            ? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3']))
1157
+        $cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3'])
1158
+            ? strtoupper(sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3']))
1159 1159
             : false;
1160
-        $cols_n_values['RGN_ID'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID'])
1161
-            ? absint($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID'])
1160
+        $cols_n_values['RGN_ID'] = isset($this->_req_data['cntry'][$CNT_ISO]['RGN_ID'])
1161
+            ? absint($this->_req_data['cntry'][$CNT_ISO]['RGN_ID'])
1162 1162
             : null;
1163
-        $cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name'])
1164
-            ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name'])
1163
+        $cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_name'])
1164
+            ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_name'])
1165 1165
             : null;
1166
-        $cols_n_values['CNT_cur_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code'])
1167
-            ? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code']))
1166
+        $cols_n_values['CNT_cur_code'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code'])
1167
+            ? strtoupper(sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code']))
1168 1168
             : 'USD';
1169
-        $cols_n_values['CNT_cur_single'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single'])
1170
-            ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single'])
1169
+        $cols_n_values['CNT_cur_single'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single'])
1170
+            ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single'])
1171 1171
             : 'dollar';
1172
-        $cols_n_values['CNT_cur_plural'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural'])
1173
-            ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural'])
1172
+        $cols_n_values['CNT_cur_plural'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural'])
1173
+            ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural'])
1174 1174
             : 'dollars';
1175
-        $cols_n_values['CNT_cur_sign'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign'])
1176
-            ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign'])
1175
+        $cols_n_values['CNT_cur_sign'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign'])
1176
+            ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign'])
1177 1177
             : '$';
1178
-        $cols_n_values['CNT_cur_sign_b4'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4'])
1179
-            ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4'])
1178
+        $cols_n_values['CNT_cur_sign_b4'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4'])
1179
+            ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4'])
1180 1180
             : true;
1181
-        $cols_n_values['CNT_cur_dec_plc'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc'])
1182
-            ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc'])
1181
+        $cols_n_values['CNT_cur_dec_plc'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc'])
1182
+            ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc'])
1183 1183
             : 2;
1184
-        $cols_n_values['CNT_cur_dec_mrk'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk'])
1185
-            ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk'])
1184
+        $cols_n_values['CNT_cur_dec_mrk'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk'])
1185
+            ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk'])
1186 1186
             : '.';
1187
-        $cols_n_values['CNT_cur_thsnds'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds'])
1188
-            ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds'])
1187
+        $cols_n_values['CNT_cur_thsnds'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds'])
1188
+            ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds'])
1189 1189
             : ',';
1190
-        $cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code'])
1191
-            ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code'])
1190
+        $cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code'])
1191
+            ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code'])
1192 1192
             : null;
1193
-        $cols_n_values['CNT_is_EU'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU'])
1194
-            ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU'])
1193
+        $cols_n_values['CNT_is_EU'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU'])
1194
+            ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU'])
1195 1195
             : false;
1196
-        $cols_n_values['CNT_active'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active'])
1197
-            ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active'])
1196
+        $cols_n_values['CNT_active'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_active'])
1197
+            ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_active'])
1198 1198
             : false;
1199 1199
         // allow filtering of country data
1200 1200
         $cols_n_values = apply_filters(
@@ -1271,7 +1271,7 @@  discard block
 block discarded – undo
1271 1271
         return '
1272 1272
 			<tr>
1273 1273
 				<th>
1274
-					' . $label . '
1274
+					' . $label.'
1275 1275
 				</th>';
1276 1276
     }
1277 1277
 
@@ -1287,7 +1287,7 @@  discard block
 block discarded – undo
1287 1287
     {
1288 1288
         return '
1289 1289
 				<td class="general-settings-country-input-td">
1290
-					' . $input . '
1290
+					' . $input.'
1291 1291
 				</td>
1292 1292
 			</tr>';
1293 1293
     }
@@ -1318,7 +1318,7 @@  discard block
 block discarded – undo
1318 1318
     {
1319 1319
         return '
1320 1320
 				<td class="general-settings-country-state-input-td">
1321
-					' . $input . '
1321
+					' . $input.'
1322 1322
 				</td>';
1323 1323
     }
1324 1324
 
@@ -1344,7 +1344,7 @@  discard block
 block discarded – undo
1344 1344
                  . __('Edit', 'event_espresso')
1345 1345
                  . '</a>';
1346 1346
         $links .= ' &nbsp;|&nbsp; ';
1347
-        $links .= '<a href="' . get_permalink($ee_page_id) . '" >' . __('View', 'event_espresso') . '</a>';
1347
+        $links .= '<a href="'.get_permalink($ee_page_id).'" >'.__('View', 'event_espresso').'</a>';
1348 1348
 
1349 1349
         return $links;
1350 1350
     }
@@ -1377,9 +1377,9 @@  discard block
 block discarded – undo
1377 1377
             $sc_status = sprintf(__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1378 1378
         }
1379 1379
 
1380
-        return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>'
1380
+        return '<span style="color:'.$pg_colour.'; margin-right:2em;"><strong>'
1381 1381
                . $pg_status
1382
-               . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>';
1382
+               . '</strong></span><span style="color:'.$sc_colour.'"><strong>'.$sc_status.'</strong></span>';
1383 1383
     }
1384 1384
 
1385 1385
 
Please login to merge, or discard this patch.
core/db_models/fields/EE_Email_Field.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -16,38 +16,38 @@
 block discarded – undo
16 16
 {
17 17
 
18 18
 
19
-    /**
20
-     * @param string $table_column
21
-     * @param string $nice_name
22
-     * @param bool   $nullable
23
-     * @param null   $default_value
24
-     * @throws InvalidArgumentException
25
-     */
26
-    public function __construct($table_column, $nice_name, $nullable, $default_value = null)
27
-    {
28
-        parent::__construct($table_column, $nice_name, $nullable, $default_value);
29
-        $this->setSchemaFormat('email');
30
-    }
19
+	/**
20
+	 * @param string $table_column
21
+	 * @param string $nice_name
22
+	 * @param bool   $nullable
23
+	 * @param null   $default_value
24
+	 * @throws InvalidArgumentException
25
+	 */
26
+	public function __construct($table_column, $nice_name, $nullable, $default_value = null)
27
+	{
28
+		parent::__construct($table_column, $nice_name, $nullable, $default_value);
29
+		$this->setSchemaFormat('email');
30
+	}
31 31
 
32 32
 
33 33
 
34
-    /**
35
-     * In form inputs, we should have called htmlentities and addslashes() on form inputs,
36
-     * so we need to undo that on setting of these fields
37
-     *
38
-     * @param string $email_address
39
-     * @return string
40
-     * @throws InvalidArgumentException
41
-     * @throws InvalidInterfaceException
42
-     * @throws InvalidDataTypeException
43
-     */
44
-    public function prepare_for_set($email_address)
45
-    {
46
-        try {
47
-            $email_address = EmailAddressFactory::create($email_address);
48
-            return $email_address->get();
49
-        } catch (EmailValidationException $e) {
50
-            return '';
51
-        }
52
-    }
34
+	/**
35
+	 * In form inputs, we should have called htmlentities and addslashes() on form inputs,
36
+	 * so we need to undo that on setting of these fields
37
+	 *
38
+	 * @param string $email_address
39
+	 * @return string
40
+	 * @throws InvalidArgumentException
41
+	 * @throws InvalidInterfaceException
42
+	 * @throws InvalidDataTypeException
43
+	 */
44
+	public function prepare_for_set($email_address)
45
+	{
46
+		try {
47
+			$email_address = EmailAddressFactory::create($email_address);
48
+			return $email_address->get();
49
+		} catch (EmailValidationException $e) {
50
+			return '';
51
+		}
52
+	}
53 53
 }
Please login to merge, or discard this patch.
core/domain/services/factories/FactoryInterface.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@
 block discarded – undo
15 15
 interface FactoryInterface
16 16
 {
17 17
 
18
-    /**
19
-     * @param mixed $arguments
20
-     * @return mixed
21
-     */
22
-    public static function create($arguments);
18
+	/**
19
+	 * @param mixed $arguments
20
+	 * @return mixed
21
+	 */
22
+	public static function create($arguments);
23 23
 
24 24
 
25 25
 }
Please login to merge, or discard this patch.
core/domain/services/validation/email/strategies/InternationalDNS.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
             $email_address,
35 35
             $this->getAtIndex($email_address)
36 36
         );
37
-        if (! checkdnsrr($domain, 'MX')) {
37
+        if ( ! checkdnsrr($domain, 'MX')) {
38 38
             // domain not found in MX records
39 39
             throw new EmailValidationException(
40 40
                 __(
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
                 )
46 46
             );
47 47
         }
48
-        if (! checkdnsrr($domain, 'A')) {
48
+        if ( ! checkdnsrr($domain, 'A')) {
49 49
             // domain not found in A records
50 50
             throw new EmailValidationException(
51 51
                 __(
Please login to merge, or discard this patch.
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -15,43 +15,43 @@
 block discarded – undo
15 15
 class InternationalDNS extends International
16 16
 {
17 17
 
18
-    /**
19
-     * Validates the email in teh same way as the parent, but also
20
-     * verifies the domain exists.
21
-     *
22
-     * @param string $email_address
23
-     * @return bool
24
-     * @throws EmailValidationException
25
-     */
26
-    public function validate($email_address)
27
-    {
28
-        parent::validate($email_address);
29
-        $domain = $this->getDomainPartOfEmail(
30
-            $email_address,
31
-            $this->getAtIndex($email_address)
32
-        );
33
-        if (! checkdnsrr($domain, 'MX')) {
34
-            // domain not found in MX records
35
-            throw new EmailValidationException(
36
-                __(
37
-                // @codingStandardsIgnoreStart
38
-                    'Although the email address provided is formatted correctly, a valid "MX record" could not be located for that address and domain. Please enter a valid email address.',
39
-                    // @codingStandardsIgnoreEnd
40
-                    'event_espresso'
41
-                )
42
-            );
43
-        }
44
-        if (! checkdnsrr($domain, 'A')) {
45
-            // domain not found in A records
46
-            throw new EmailValidationException(
47
-                __(
48
-                // @codingStandardsIgnoreStart
49
-                    'Although the email address provided is formatted correctly, a valid "A record" could not be located for that address and domain. Please enter a valid email address.',
50
-                    // @codingStandardsIgnoreEnd
51
-                    'event_espresso'
52
-                )
53
-            );
54
-        }
55
-        return true;
56
-    }
18
+	/**
19
+	 * Validates the email in teh same way as the parent, but also
20
+	 * verifies the domain exists.
21
+	 *
22
+	 * @param string $email_address
23
+	 * @return bool
24
+	 * @throws EmailValidationException
25
+	 */
26
+	public function validate($email_address)
27
+	{
28
+		parent::validate($email_address);
29
+		$domain = $this->getDomainPartOfEmail(
30
+			$email_address,
31
+			$this->getAtIndex($email_address)
32
+		);
33
+		if (! checkdnsrr($domain, 'MX')) {
34
+			// domain not found in MX records
35
+			throw new EmailValidationException(
36
+				__(
37
+				// @codingStandardsIgnoreStart
38
+					'Although the email address provided is formatted correctly, a valid "MX record" could not be located for that address and domain. Please enter a valid email address.',
39
+					// @codingStandardsIgnoreEnd
40
+					'event_espresso'
41
+				)
42
+			);
43
+		}
44
+		if (! checkdnsrr($domain, 'A')) {
45
+			// domain not found in A records
46
+			throw new EmailValidationException(
47
+				__(
48
+				// @codingStandardsIgnoreStart
49
+					'Although the email address provided is formatted correctly, a valid "A record" could not be located for that address and domain. Please enter a valid email address.',
50
+					// @codingStandardsIgnoreEnd
51
+					'event_espresso'
52
+				)
53
+			);
54
+		}
55
+		return true;
56
+	}
57 57
 }
Please login to merge, or discard this patch.
core/domain/services/validation/email/EmailValidatorInterface.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 EmailValidatorInterface
19 19
 {
20 20
 
21
-    /**
22
-     * Validates the supplied email address. If it is invalid, throws EmailValidationException
23
-     *
24
-     * @param string $email_address
25
-     * @return boolean
26
-     * @throws EmailValidationException
27
-     */
28
-    public function validate($email_address);
21
+	/**
22
+	 * Validates the supplied email address. If it is invalid, throws EmailValidationException
23
+	 *
24
+	 * @param string $email_address
25
+	 * @return boolean
26
+	 * @throws EmailValidationException
27
+	 */
28
+	public function validate($email_address);
29 29
 
30 30
 
31 31
 }
Please login to merge, or discard this patch.
strategies/validation/EE_Email_Validation_Strategy.strategy.php 2 patches
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -18,72 +18,72 @@
 block discarded – undo
18 18
 {
19 19
 
20 20
 
21
-    /**
22
-     * @param string               $validation_error_message
23
-     */
24
-    public function __construct($validation_error_message = '')
25
-    {
26
-        if (! $validation_error_message) {
27
-            $validation_error_message = esc_html__('Please enter a valid email address.', 'event_espresso');
28
-        }
29
-        parent::__construct($validation_error_message);
30
-    }
21
+	/**
22
+	 * @param string               $validation_error_message
23
+	 */
24
+	public function __construct($validation_error_message = '')
25
+	{
26
+		if (! $validation_error_message) {
27
+			$validation_error_message = esc_html__('Please enter a valid email address.', 'event_espresso');
28
+		}
29
+		parent::__construct($validation_error_message);
30
+	}
31 31
 
32 32
 
33 33
 
34
-    /**
35
-     * just checks the field isn't blank
36
-     *
37
-     * @param $normalized_value
38
-     * @return bool
39
-     * @throws InvalidArgumentException
40
-     * @throws InvalidInterfaceException
41
-     * @throws InvalidDataTypeException
42
-     * @throws EE_Validation_Error
43
-     */
44
-    public function validate($normalized_value)
45
-    {
46
-        if ($normalized_value && ! $this->_validate_email($normalized_value)) {
47
-            throw new EE_Validation_Error($this->get_validation_error_message(), 'required');
48
-        }
49
-        return true;
50
-    }
34
+	/**
35
+	 * just checks the field isn't blank
36
+	 *
37
+	 * @param $normalized_value
38
+	 * @return bool
39
+	 * @throws InvalidArgumentException
40
+	 * @throws InvalidInterfaceException
41
+	 * @throws InvalidDataTypeException
42
+	 * @throws EE_Validation_Error
43
+	 */
44
+	public function validate($normalized_value)
45
+	{
46
+		if ($normalized_value && ! $this->_validate_email($normalized_value)) {
47
+			throw new EE_Validation_Error($this->get_validation_error_message(), 'required');
48
+		}
49
+		return true;
50
+	}
51 51
 
52 52
 
53 53
 
54
-    /**
55
-     * @return array
56
-     */
57
-    public function get_jquery_validation_rule_array()
58
-    {
59
-        return array('email' => true, 'messages' => array('email' => $this->get_validation_error_message()));
60
-    }
54
+	/**
55
+	 * @return array
56
+	 */
57
+	public function get_jquery_validation_rule_array()
58
+	{
59
+		return array('email' => true, 'messages' => array('email' => $this->get_validation_error_message()));
60
+	}
61 61
 
62 62
 
63 63
 
64
-    /**
65
-     * Validate an email address.
66
-     * Provide email address (raw input)
67
-     *
68
-     * @param $email
69
-     * @return bool of whether the email is valid or not
70
-     * @throws InvalidArgumentException
71
-     * @throws InvalidInterfaceException
72
-     * @throws InvalidDataTypeException
73
-     * @throws EE_Validation_Error
74
-     */
75
-    private function _validate_email($email)
76
-    {
77
-        try {
78
-            EmailAddressFactory::create($email);
79
-        } catch (EmailValidationException $e) {
80
-            throw new EE_Validation_Error(
81
-                $e->getMessage(),
82
-                'invalid_email',
83
-                $this->_input,
84
-                $e
85
-            );
86
-        }
87
-        return true;
88
-    }
64
+	/**
65
+	 * Validate an email address.
66
+	 * Provide email address (raw input)
67
+	 *
68
+	 * @param $email
69
+	 * @return bool of whether the email is valid or not
70
+	 * @throws InvalidArgumentException
71
+	 * @throws InvalidInterfaceException
72
+	 * @throws InvalidDataTypeException
73
+	 * @throws EE_Validation_Error
74
+	 */
75
+	private function _validate_email($email)
76
+	{
77
+		try {
78
+			EmailAddressFactory::create($email);
79
+		} catch (EmailValidationException $e) {
80
+			throw new EE_Validation_Error(
81
+				$e->getMessage(),
82
+				'invalid_email',
83
+				$this->_input,
84
+				$e
85
+			);
86
+		}
87
+		return true;
88
+	}
89 89
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
      */
24 24
     public function __construct($validation_error_message = '')
25 25
     {
26
-        if (! $validation_error_message) {
26
+        if ( ! $validation_error_message) {
27 27
             $validation_error_message = esc_html__('Please enter a valid email address.', 'event_espresso');
28 28
         }
29 29
         parent::__construct($validation_error_message);
Please login to merge, or discard this patch.