Completed
Branch BUG-11108-ticket-reserved-coun... (144d27)
by
unknown
14:21 queued 17s
created
admin/extend/registrations/EE_Registration_CheckIn_List_Table.class.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 
31 31
 
32 32
 
33
-	public function __construct( $admin_page ) {
33
+	public function __construct($admin_page) {
34 34
 		parent::__construct($admin_page);
35 35
 	}
36 36
 
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
 
39 39
 
40 40
 	protected function _setup_data() {
41
-		$this->_data = $this->_get_checkins( $this->_per_page );
42
-		$this->_all_data_count = $this->_get_checkins(  $this->_per_page, TRUE );
41
+		$this->_data = $this->_get_checkins($this->_per_page);
42
+		$this->_all_data_count = $this->_get_checkins($this->_per_page, TRUE);
43 43
 	}
44 44
 
45 45
 
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 			);
61 61
 
62 62
 		$this->_sortable_columns = array(
63
-			'CHK_timestamp' => array( 'CHK_timestamp' => TRUE )
63
+			'CHK_timestamp' => array('CHK_timestamp' => TRUE)
64 64
 			);
65 65
 
66 66
 		$this->_primary_column = 'CHK_in';
@@ -84,24 +84,24 @@  discard block
 block discarded – undo
84 84
 	}
85 85
 
86 86
 
87
-	function column_cb($item ) {
88
-		return sprintf( '<input type="checkbox" name="checkbox[%1$s]" />', $item->ID() );
87
+	function column_cb($item) {
88
+		return sprintf('<input type="checkbox" name="checkbox[%1$s]" />', $item->ID());
89 89
 	}
90 90
 
91 91
 
92
-	public function column_CHK_in( EE_Checkin $item ) {
92
+	public function column_CHK_in(EE_Checkin $item) {
93 93
         $checkin_status_dashicon = CheckinStatusDashicon::fromCheckin($item);
94
-        return '<span class="' . $checkin_status_dashicon->cssClasses() . '"></span><span class="show-on-mobile-view-only">' . $item->get_datetime('CHK_timestamp') . '</span>';
94
+        return '<span class="'.$checkin_status_dashicon->cssClasses().'"></span><span class="show-on-mobile-view-only">'.$item->get_datetime('CHK_timestamp').'</span>';
95 95
 	}
96 96
 
97 97
 
98 98
 
99
-	function column_CHK_timestamp( EE_Checkin $item ) {
99
+	function column_CHK_timestamp(EE_Checkin $item) {
100 100
 		$actions = array();
101
-		$delete_url = EE_Admin_Page::add_query_args_and_nonce( array('action' => 'delete_checkin_row', 'DTT_ID' => $this->_req_data['DTT_ID'], '_REG_ID' => $this->_req_data['_REG_ID'], 'CHK_ID' => $item->ID() ) );
102
-		$actions['delete_checkin'] = EE_Registry::instance()->CAP->current_user_can( 'ee_delete_checkins', 'espresso_registrations_delete_checkin_row' ) ? '<a href="' . $delete_url . '" title="' . esc_attr__('Click here to delete this check-in record', 'event_espresso') . '">' . __('Delete', 'event_espresso') . '</a>' : '';
101
+		$delete_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'delete_checkin_row', 'DTT_ID' => $this->_req_data['DTT_ID'], '_REG_ID' => $this->_req_data['_REG_ID'], 'CHK_ID' => $item->ID()));
102
+		$actions['delete_checkin'] = EE_Registry::instance()->CAP->current_user_can('ee_delete_checkins', 'espresso_registrations_delete_checkin_row') ? '<a href="'.$delete_url.'" title="'.esc_attr__('Click here to delete this check-in record', 'event_espresso').'">'.__('Delete', 'event_espresso').'</a>' : '';
103 103
 
104
-		return sprintf( '%1$s %2$s', $item->get_datetime('CHK_timestamp'), $this->row_actions($actions) );
104
+		return sprintf('%1$s %2$s', $item->get_datetime('CHK_timestamp'), $this->row_actions($actions));
105 105
 	}
106 106
 
107 107
 
@@ -116,30 +116,30 @@  discard block
 block discarded – undo
116 116
 	 * @param bool    $count        Whether to return a count or not
117 117
 	 * @return EE_Checkin[]|int
118 118
 	 */
119
-	protected function _get_checkins( $per_page = 10, $count = FALSE ) {
120
-		$REG_ID = isset( $this->_req_data['_REG_ID'] ) ? $this->_req_data['_REG_ID'] : FALSE;
121
-		$DTT_ID = isset( $this->_req_data['DTT_ID'] ) ? $this->_req_data['DTT_ID'] : FALSE;
119
+	protected function _get_checkins($per_page = 10, $count = FALSE) {
120
+		$REG_ID = isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : FALSE;
121
+		$DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : FALSE;
122 122
 
123 123
 		//if user does not have the capability for the checkins for this registration then get out!
124
-		if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_checkin', 'espresso_registrations_registration_checkins', $REG_ID ) ) {
124
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_checkin', 'espresso_registrations_registration_checkins', $REG_ID)) {
125 125
 			return $count ? 0 : array();
126 126
 		}
127 127
 
128 128
 		//if no reg id then get out cause need a reg id
129
-		if ( empty( $REG_ID ) || empty( $DTT_ID ) )
130
-			throw new EE_Error(__('This route cannot be viewed unless registration and datetime IDs are included in the request (via REG_ID and DTT_ID parameters)', 'event_espresso') );
129
+		if (empty($REG_ID) || empty($DTT_ID))
130
+			throw new EE_Error(__('This route cannot be viewed unless registration and datetime IDs are included in the request (via REG_ID and DTT_ID parameters)', 'event_espresso'));
131 131
 
132 132
 		//set orderby
133 133
 		$orderby = 'CHK_timestamp'; //note that with this table we're only providing the option to orderby the timestamp value.
134 134
 
135
-		$order = !empty( $this->_req_data['order'] ) ? $this->_req_data['order'] : 'ASC';
135
+		$order = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC';
136 136
 
137
-		$current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1;
138
-		$per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page;
137
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1;
138
+		$per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page;
139 139
 		$limit = NULL;
140
-		if ( !$count ) {
141
-			$offset = ($current_page-1)*$per_page;
142
-			$limit = array( $offset, $per_page );
140
+		if ( ! $count) {
141
+			$offset = ($current_page - 1) * $per_page;
142
+			$limit = array($offset, $per_page);
143 143
 		}
144 144
 
145 145
 		$_where = array(
@@ -147,13 +147,13 @@  discard block
 block discarded – undo
147 147
 			'DTT_ID' => $DTT_ID
148 148
 			);
149 149
 
150
-		$query_params = array( $_where, 'order_by' => array( $orderby => $order ), 'limit' => $limit );
150
+		$query_params = array($_where, 'order_by' => array($orderby => $order), 'limit' => $limit);
151 151
 
152 152
 		//if no per_page value then we just want to return a count of all Check-ins
153
-		if ( $count )
154
-			return EEM_Checkin::instance()->count( array( $_where ) );
153
+		if ($count)
154
+			return EEM_Checkin::instance()->count(array($_where));
155 155
 
156
-		return $count ? EEM_Checkin::instance()->count( array( $_where ) ) : EEM_Checkin::instance()->get_all($query_params);
156
+		return $count ? EEM_Checkin::instance()->count(array($_where)) : EEM_Checkin::instance()->get_all($query_params);
157 157
 	}
158 158
 
159 159
 } //end class EE_Registration_CheckIn_List_Table
Please login to merge, or discard this patch.
admin_pages/transactions/EE_Admin_Transactions_List_Table.class.php 2 patches
Indentation   +626 added lines, -626 removed lines patch added patch discarded remove patch
@@ -16,114 +16,114 @@  discard block
 block discarded – undo
16 16
 class EE_Admin_Transactions_List_Table extends EE_Admin_List_Table
17 17
 {
18 18
 
19
-    private $_status;
20
-
21
-
22
-    /**
23
-     * @param \Transactions_Admin_Page $admin_page
24
-     */
25
-    public function __construct(\Transactions_Admin_Page $admin_page)
26
-    {
27
-        parent::__construct($admin_page);
28
-        $this->_status = $this->_admin_page->get_transaction_status_array();
29
-    }
30
-
31
-
32
-    /**
33
-     *_setup_data
34
-     */
35
-    protected function _setup_data()
36
-    {
37
-        $this->_data           = $this->_admin_page->get_transactions($this->_per_page);
38
-        $status                = ! empty($this->_req_data['status']) ? $this->_req_data['status'] : 'all';
39
-        $this->_all_data_count = $this->_admin_page->get_transactions($this->_per_page, true, $status);
40
-    }
41
-
42
-
43
-    /**
44
-     *_set_properties
45
-     */
46
-    protected function _set_properties()
47
-    {
48
-        $this->_wp_list_args = array(
49
-            'singular' => __('transaction', 'event_espresso'),
50
-            'plural'   => __('transactions', 'event_espresso'),
51
-            'ajax'     => true,
52
-            'screen'   => $this->_admin_page->get_current_screen()->id,
53
-        );
54
-        $ID_column_name      = __('ID', 'event_espresso');
55
-        $ID_column_name      .= ' : <span class="show-on-mobile-view-only" style="float:none">';
56
-        $ID_column_name      .= __('Transaction Date', 'event_espresso');
57
-        $ID_column_name      .= '</span> ';
58
-        $this->_columns      = array(
59
-            'TXN_ID'        => $ID_column_name,
60
-            'TXN_timestamp' => __('Transaction Date', 'event_espresso'),
61
-            'TXN_total'     => __('Total', 'event_espresso'),
62
-            'TXN_paid'      => __('Paid', 'event_espresso'),
63
-            'ATT_fname'     => __('Primary Registrant', 'event_espresso'),
64
-            'event_name'    => __('Event', 'event_espresso'),
65
-            'actions'       => __('Actions', 'event_espresso'),
66
-        );
67
-
68
-        $this->_sortable_columns = array(
69
-            'TXN_ID'        => array('TXN_ID' => false),
70
-            'event_name'    => array('event_name' => false),
71
-            'ATT_fname'     => array('ATT_fname' => false),
72
-            'TXN_timestamp' => array('TXN_timestamp' => true) //true means its already sorted
73
-        );
74
-
75
-        $this->_primary_column = 'TXN_ID';
76
-
77
-        $this->_hidden_columns = array();
78
-    }
79
-
80
-
81
-    /**
82
-     * This simply sets up the row class for the table rows.
83
-     * Allows for easier overriding of child methods for setting up sorting.
84
-     *
85
-     * @param  EE_Transaction $transaction the current item
86
-     * @return string
87
-     * @throws \EE_Error
88
-     */
89
-    protected function _get_row_class($transaction)
90
-    {
91
-        $class = parent::_get_row_class($transaction);
92
-        //add status class
93
-        $class .= ' ee-status-strip txn-status-' . $transaction->status_ID();
94
-        if ($this->_has_checkbox_column) {
95
-            $class .= ' has-checkbox-column';
96
-        }
97
-        return $class;
98
-    }
99
-
100
-
101
-    /**
102
-     * _get_table_filters
103
-     * We use this to assemble and return any filters that are associated with this table that help further refine what
104
-     * get's shown in the table.
105
-     *
106
-     * @abstract
107
-     * @access protected
108
-     * @return array
109
-     */
110
-    protected function _get_table_filters()
111
-    {
112
-        $filters    = array();
113
-        $start_date = isset($this->_req_data['txn-filter-start-date'])
114
-            ? wp_strip_all_tags($this->_req_data['txn-filter-start-date'])
115
-            : date(
116
-                'm/d/Y',
117
-                strtotime('-10 year')
118
-            );
119
-        $end_date   = isset($this->_req_data['txn-filter-end-date'])
120
-            ? wp_strip_all_tags($this->_req_data['txn-filter-end-date'])
121
-            : date(
122
-                'm/d/Y',
123
-                current_time('timestamp')
124
-            );
125
-        ob_start();
126
-        ?>
19
+	private $_status;
20
+
21
+
22
+	/**
23
+	 * @param \Transactions_Admin_Page $admin_page
24
+	 */
25
+	public function __construct(\Transactions_Admin_Page $admin_page)
26
+	{
27
+		parent::__construct($admin_page);
28
+		$this->_status = $this->_admin_page->get_transaction_status_array();
29
+	}
30
+
31
+
32
+	/**
33
+	 *_setup_data
34
+	 */
35
+	protected function _setup_data()
36
+	{
37
+		$this->_data           = $this->_admin_page->get_transactions($this->_per_page);
38
+		$status                = ! empty($this->_req_data['status']) ? $this->_req_data['status'] : 'all';
39
+		$this->_all_data_count = $this->_admin_page->get_transactions($this->_per_page, true, $status);
40
+	}
41
+
42
+
43
+	/**
44
+	 *_set_properties
45
+	 */
46
+	protected function _set_properties()
47
+	{
48
+		$this->_wp_list_args = array(
49
+			'singular' => __('transaction', 'event_espresso'),
50
+			'plural'   => __('transactions', 'event_espresso'),
51
+			'ajax'     => true,
52
+			'screen'   => $this->_admin_page->get_current_screen()->id,
53
+		);
54
+		$ID_column_name      = __('ID', 'event_espresso');
55
+		$ID_column_name      .= ' : <span class="show-on-mobile-view-only" style="float:none">';
56
+		$ID_column_name      .= __('Transaction Date', 'event_espresso');
57
+		$ID_column_name      .= '</span> ';
58
+		$this->_columns      = array(
59
+			'TXN_ID'        => $ID_column_name,
60
+			'TXN_timestamp' => __('Transaction Date', 'event_espresso'),
61
+			'TXN_total'     => __('Total', 'event_espresso'),
62
+			'TXN_paid'      => __('Paid', 'event_espresso'),
63
+			'ATT_fname'     => __('Primary Registrant', 'event_espresso'),
64
+			'event_name'    => __('Event', 'event_espresso'),
65
+			'actions'       => __('Actions', 'event_espresso'),
66
+		);
67
+
68
+		$this->_sortable_columns = array(
69
+			'TXN_ID'        => array('TXN_ID' => false),
70
+			'event_name'    => array('event_name' => false),
71
+			'ATT_fname'     => array('ATT_fname' => false),
72
+			'TXN_timestamp' => array('TXN_timestamp' => true) //true means its already sorted
73
+		);
74
+
75
+		$this->_primary_column = 'TXN_ID';
76
+
77
+		$this->_hidden_columns = array();
78
+	}
79
+
80
+
81
+	/**
82
+	 * This simply sets up the row class for the table rows.
83
+	 * Allows for easier overriding of child methods for setting up sorting.
84
+	 *
85
+	 * @param  EE_Transaction $transaction the current item
86
+	 * @return string
87
+	 * @throws \EE_Error
88
+	 */
89
+	protected function _get_row_class($transaction)
90
+	{
91
+		$class = parent::_get_row_class($transaction);
92
+		//add status class
93
+		$class .= ' ee-status-strip txn-status-' . $transaction->status_ID();
94
+		if ($this->_has_checkbox_column) {
95
+			$class .= ' has-checkbox-column';
96
+		}
97
+		return $class;
98
+	}
99
+
100
+
101
+	/**
102
+	 * _get_table_filters
103
+	 * We use this to assemble and return any filters that are associated with this table that help further refine what
104
+	 * get's shown in the table.
105
+	 *
106
+	 * @abstract
107
+	 * @access protected
108
+	 * @return array
109
+	 */
110
+	protected function _get_table_filters()
111
+	{
112
+		$filters    = array();
113
+		$start_date = isset($this->_req_data['txn-filter-start-date'])
114
+			? wp_strip_all_tags($this->_req_data['txn-filter-start-date'])
115
+			: date(
116
+				'm/d/Y',
117
+				strtotime('-10 year')
118
+			);
119
+		$end_date   = isset($this->_req_data['txn-filter-end-date'])
120
+			? wp_strip_all_tags($this->_req_data['txn-filter-end-date'])
121
+			: date(
122
+				'm/d/Y',
123
+				current_time('timestamp')
124
+			);
125
+		ob_start();
126
+		?>
127 127
         <label for="txn-filter-start-date">Display Transactions from </label>
128 128
         <input id="txn-filter-start-date" class="datepicker" type="text" value="<?php echo $start_date; ?>"
129 129
                name="txn-filter-start-date" size="15"/>
@@ -131,554 +131,554 @@  discard block
 block discarded – undo
131 131
         <input id="txn-filter-end-date" class="datepicker" type="text" value="<?php echo $end_date; ?>"
132 132
                name="txn-filter-end-date" size="15"/>
133 133
         <?php
134
-        $filters[] = ob_get_contents();
135
-        ob_end_clean();
136
-        return $filters;
137
-    }
138
-
139
-
140
-    /**
141
-     *_add_view_counts
142
-     */
143
-    protected function _add_view_counts()
144
-    {
145
-        $this->_views['all']['count']       = $this->_admin_page->get_transactions($this->_per_page, true, 'all');
146
-        $this->_views['abandoned']['count'] = $this->_admin_page->get_transactions($this->_per_page, true, 'abandoned');
147
-        $this->_views['failed']['count']    = $this->_admin_page->get_transactions($this->_per_page, true, 'failed');
148
-    }
149
-
150
-
151
-    /**
152
-     *    column TXN_ID
153
-     *
154
-     * @param \EE_Transaction $transaction
155
-     * @return string
156
-     * @throws \EE_Error
157
-     */
158
-    public function column_TXN_ID(EE_Transaction $transaction)
159
-    {
160
-        $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
161
-            'action' => 'view_transaction',
162
-            'TXN_ID' => $transaction->ID(),
163
-        ), TXN_ADMIN_URL);
164
-        $content      = '<a href="' . $view_lnk_url . '"'
165
-                        . ' title="' . esc_attr__('Go to Transaction Details', 'event_espresso') . '">'
166
-                        . $transaction->ID()
167
-                        . '</a>';
168
-
169
-        //txn timestamp
170
-        $content .= '  <span class="show-on-mobile-view-only">' . $this->_get_txn_timestamp($transaction) . '</span>';
171
-        return $content;
172
-    }
173
-
174
-
175
-    /**
176
-     * @param \EE_Transaction $transaction
177
-     * @return string
178
-     * @throws EE_Error
179
-     * @throws InvalidArgumentException
180
-     * @throws InvalidDataTypeException
181
-     * @throws InvalidInterfaceException
182
-     */
183
-    protected function _get_txn_timestamp(EE_Transaction $transaction)
184
-    {
185
-        //txn timestamp
186
-        // is TXN less than 2 hours old ?
187
-        if (($transaction->failed() || $transaction->is_abandoned())
188
-            && (
189
-                (time() - EE_Registry::instance()->SSN->lifespan()) < $transaction->datetime(false, true)
190
-            )
191
-        ) {
192
-            $timestamp = esc_html__('TXN in progress...', 'event_espresso');
193
-        } else {
194
-            $timestamp = $transaction->get_i18n_datetime('TXN_timestamp');
195
-        }
196
-        return $timestamp;
197
-    }
198
-
199
-
200
-    /**
201
-     *    column_cb
202
-     *
203
-     * @param \EE_Transaction $transaction
204
-     * @return string
205
-     * @throws \EE_Error
206
-     */
207
-    public function column_cb($transaction)
208
-    {
209
-        return sprintf(
210
-            '<input type="checkbox" name="%1$s[]" value="%2$s" />',
211
-            $this->_wp_list_args['singular'],
212
-            $transaction->ID()
213
-        );
214
-    }
215
-
216
-
217
-    /**
218
-     *    column_TXN_timestamp
219
-     *
220
-     * @param \EE_Transaction $transaction
221
-     * @return string
222
-     * @throws \EE_Error
223
-     */
224
-    public function column_TXN_timestamp(EE_Transaction $transaction)
225
-    {
226
-        $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
227
-            'action' => 'view_transaction',
228
-            'TXN_ID' => $transaction->ID(),
229
-        ), TXN_ADMIN_URL);
230
-        $txn_date     = '<a href="' . $view_lnk_url . '"'
231
-                        . ' title="'
232
-                        . esc_attr__('View Transaction Details for TXN #', 'event_espresso') . $transaction->ID() . '">'
233
-                        . $this->_get_txn_timestamp($transaction)
234
-                        . '</a>';
235
-        //status
236
-        $txn_date .= '<br><span class="ee-status-text-small">'
237
-                     . EEH_Template::pretty_status(
238
-                         $transaction->status_ID(),
239
-                         false,
240
-                         'sentence'
241
-                     )
242
-                     . '</span>';
243
-        return $txn_date;
244
-    }
245
-
246
-
247
-    /**
248
-     *    column_TXN_total
249
-     *
250
-     * @param \EE_Transaction $transaction
251
-     * @return string
252
-     * @throws \EE_Error
253
-     */
254
-    public function column_TXN_total(EE_Transaction $transaction)
255
-    {
256
-        if ($transaction->get('TXN_total') > 0) {
257
-            return '<span class="txn-pad-rght">'
258
-                   . apply_filters(
259
-                       'FHEE__EE_Admin_Transactions_List_Table__column_TXN_total__TXN_total',
260
-                       $transaction->get_pretty('TXN_total'),
261
-                       $transaction
262
-                   )
263
-                   . '</span>';
264
-        } else {
265
-            return '<span class="txn-overview-free-event-spn">' . esc_html__('free', 'event_espresso') . '</span>';
266
-        }
267
-    }
268
-
269
-
270
-    /**
271
-     *    column_TXN_paid
272
-     *
273
-     * @param \EE_Transaction $transaction
274
-     * @return mixed|string
275
-     * @throws \EE_Error
276
-     */
277
-    public function column_TXN_paid(EE_Transaction $transaction)
278
-    {
279
-        $transaction_total = $transaction->get('TXN_total');
280
-        $transaction_paid  = $transaction->get('TXN_paid');
281
-
282
-        if (\EEH_Money::compare_floats($transaction_total, 0, '>')) {
283
-            // monies owing
284
-            $span_class = 'txn-overview-part-payment-spn';
285
-            if (\EEH_Money::compare_floats($transaction_paid, $transaction_total, '>=')) {
286
-                // paid in full
287
-                $span_class = 'txn-overview-full-payment-spn';
288
-            } elseif (\EEH_Money::compare_floats($transaction_paid, 0, '==')) {
289
-                // no payments made
290
-                $span_class = 'txn-overview-no-payment-spn';
291
-            }
292
-        } else {
293
-            $span_class       = 'txn-overview-free-event-spn';
294
-            $transaction_paid = 0;
295
-        }
296
-
297
-        $payment_method      = $transaction->payment_method();
298
-        $payment_method_name = $payment_method instanceof EE_Payment_Method
299
-            ? $payment_method->admin_name()
300
-            : esc_html__('Unknown', 'event_espresso');
301
-        $transaction_paid_content = $transaction_paid !== 0 ? $transaction->get_pretty('TXN_paid') : $transaction_paid;
302
-
303
-        $content = '<span class="' . $span_class . ' txn-pad-rght">'
304
-                   . $transaction_paid_content
305
-                   . '</span>';
306
-        if ($transaction_paid > 0) {
307
-            $content .= '<br><span class="ee-status-text-small">'
308
-                        . sprintf(
309
-                            esc_html__('...via %s', 'event_espresso'),
310
-                            $payment_method_name
311
-                        )
312
-                        . '</span>';
313
-        }
314
-        return $content;
315
-    }
316
-
317
-
318
-    /**
319
-     *    column_ATT_fname
320
-     *
321
-     * @param \EE_Transaction $transaction
322
-     * @return string
323
-     * @throws EE_Error
324
-     * @throws InvalidArgumentException
325
-     * @throws InvalidDataTypeException
326
-     * @throws InvalidInterfaceException
327
-     */
328
-    public function column_ATT_fname(EE_Transaction $transaction)
329
-    {
330
-        $primary_reg = $transaction->primary_registration();
331
-        $attendee    = $primary_reg->get_first_related('Attendee');
332
-        if ($attendee instanceof EE_Attendee) {
333
-            $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
334
-                'action'  => 'view_registration',
335
-                '_REG_ID' => $primary_reg->ID(),
336
-            ), REG_ADMIN_URL);
337
-            $content      = EE_Registry::instance()->CAP->current_user_can(
338
-                'ee_read_registration',
339
-                'espresso_registrations_view_registration',
340
-                $primary_reg->ID()
341
-            )
342
-                ? '<a href="' . $edit_lnk_url . '"'
343
-                    . ' title="' . esc_attr__('View Registration Details', 'event_espresso') . '">'
344
-                    . $attendee->full_name()
345
-                    . '</a>'
346
-                : $attendee->full_name();
347
-            $content      .= '<br>' . $attendee->email();
348
-            return $content;
349
-        }
350
-        return $transaction->failed() || $transaction->is_abandoned()
351
-            ? esc_html__('no contact record.', 'event_espresso')
352
-            : esc_html__(
353
-                'No contact record, because the transaction was abandoned or the registration process failed.',
354
-                'event_espresso'
355
-            );
356
-    }
357
-
358
-
359
-    /**
360
-     *    column_ATT_email
361
-     *
362
-     * @param \EE_Transaction $transaction
363
-     * @return string
364
-     * @throws \EE_Error
365
-     */
366
-    public function column_ATT_email(EE_Transaction $transaction)
367
-    {
368
-        $attendee = $transaction->primary_registration()->get_first_related('Attendee');
369
-        if (! empty($attendee)) {
370
-            return '<a href="mailto:' . $attendee->get('ATT_email') . '">'
371
-                   . $attendee->get('ATT_email')
372
-                   . '</a>';
373
-        } else {
374
-            return $transaction->failed() || $transaction->is_abandoned()
375
-                ? esc_html__('no contact record.', 'event_espresso')
376
-                : esc_html__(
377
-                    'No contact record, because the transaction was abandoned or the registration process failed.',
378
-                    'event_espresso'
379
-                );
380
-        }
381
-    }
382
-
383
-
384
-    /**
385
-     *    column_event_name
386
-     *
387
-     * @param \EE_Transaction $transaction
388
-     * @return string
389
-     * @throws EE_Error
390
-     * @throws InvalidArgumentException
391
-     * @throws InvalidDataTypeException
392
-     * @throws InvalidInterfaceException
393
-     */
394
-    public function column_event_name(EE_Transaction $transaction)
395
-    {
396
-        $actions = array();
397
-        $event   = $transaction->primary_registration()->get_first_related('Event');
398
-        if (! empty($event)) {
399
-            $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(
400
-                array('action' => 'edit', 'post' => $event->ID()),
401
-                EVENTS_ADMIN_URL
402
-            );
403
-            $event_name     = $event->get('EVT_name');
404
-
405
-            //filter this view by transactions for this event
406
-            $txn_by_event_lnk = EE_Admin_Page::add_query_args_and_nonce(array(
407
-                'action' => 'default',
408
-                'EVT_ID' => $event->ID(),
409
-            ));
410
-            if (empty($this->_req_data['EVT_ID'])
411
-                && EE_Registry::instance()->CAP->current_user_can(
412
-                    'ee_edit_event',
413
-                    'espresso_events_edit',
414
-                    $event->ID()
415
-                )
416
-            ) {
417
-                $actions['filter_by_event'] = '<a href="' . $txn_by_event_lnk . '"'
418
-                        . ' title="' . esc_attr__('Filter transactions by this event', 'event_espresso') . '">'
419
-                        . esc_html__('View Transactions for this event', 'event_espresso')
420
-                        . '</a>';
421
-            }
422
-
423
-            return sprintf(
424
-                '%1$s %2$s',
425
-                EE_Registry::instance()->CAP->current_user_can(
426
-                    'ee_edit_event',
427
-                    'espresso_events_edit',
428
-                    $event->ID()
429
-                )
430
-                    ? '<a href="' . $edit_event_url . '"'
431
-                        . ' title="'
432
-                        . sprintf(
433
-                            esc_attr__('Edit Event: %s', 'event_espresso'),
434
-                            $event->get('EVT_name')
435
-                        )
436
-                        . '">'
437
-                        . wp_trim_words(
438
-                            $event_name,
439
-                            30,
440
-                            '...'
441
-                        )
442
-                        . '</a>'
443
-                        : wp_trim_words($event_name, 30, '...'),
444
-                $this->row_actions($actions)
445
-            );
446
-        } else {
447
-            return esc_html__(
448
-                'The event associated with this transaction via the primary registration cannot be retrieved.',
449
-                'event_espresso'
450
-            );
451
-        }
452
-    }
453
-
454
-
455
-    /**
456
-     *    column_actions
457
-     *
458
-     * @param \EE_Transaction $transaction
459
-     * @return string
460
-     * @throws \EE_Error
461
-     */
462
-    public function column_actions(EE_Transaction $transaction)
463
-    {
464
-        return $this->_action_string(
465
-            $this->get_transaction_details_link($transaction)
466
-            . $this->get_invoice_link($transaction)
467
-            . $this->get_receipt_link($transaction)
468
-            . $this->get_primary_registration_details_link($transaction)
469
-            . $this->get_send_payment_reminder_trigger_link($transaction)
470
-            . $this->get_payment_overview_link($transaction)
471
-            . $this->get_related_messages_link($transaction),
472
-            $transaction,
473
-            'ul',
474
-            'txn-overview-actions-ul'
475
-        );
476
-    }
477
-
478
-
479
-    /**
480
-     * Get the transaction details link.
481
-     * @param EE_Transaction $transaction
482
-     * @return string
483
-     * @throws EE_Error
484
-     */
485
-    protected function get_transaction_details_link(EE_Transaction $transaction)
486
-    {
487
-        $url          = EE_Admin_Page::add_query_args_and_nonce(array(
488
-            'action' => 'view_transaction',
489
-            'TXN_ID' => $transaction->ID(),
490
-        ), TXN_ADMIN_URL);
491
-        return '
134
+		$filters[] = ob_get_contents();
135
+		ob_end_clean();
136
+		return $filters;
137
+	}
138
+
139
+
140
+	/**
141
+	 *_add_view_counts
142
+	 */
143
+	protected function _add_view_counts()
144
+	{
145
+		$this->_views['all']['count']       = $this->_admin_page->get_transactions($this->_per_page, true, 'all');
146
+		$this->_views['abandoned']['count'] = $this->_admin_page->get_transactions($this->_per_page, true, 'abandoned');
147
+		$this->_views['failed']['count']    = $this->_admin_page->get_transactions($this->_per_page, true, 'failed');
148
+	}
149
+
150
+
151
+	/**
152
+	 *    column TXN_ID
153
+	 *
154
+	 * @param \EE_Transaction $transaction
155
+	 * @return string
156
+	 * @throws \EE_Error
157
+	 */
158
+	public function column_TXN_ID(EE_Transaction $transaction)
159
+	{
160
+		$view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
161
+			'action' => 'view_transaction',
162
+			'TXN_ID' => $transaction->ID(),
163
+		), TXN_ADMIN_URL);
164
+		$content      = '<a href="' . $view_lnk_url . '"'
165
+						. ' title="' . esc_attr__('Go to Transaction Details', 'event_espresso') . '">'
166
+						. $transaction->ID()
167
+						. '</a>';
168
+
169
+		//txn timestamp
170
+		$content .= '  <span class="show-on-mobile-view-only">' . $this->_get_txn_timestamp($transaction) . '</span>';
171
+		return $content;
172
+	}
173
+
174
+
175
+	/**
176
+	 * @param \EE_Transaction $transaction
177
+	 * @return string
178
+	 * @throws EE_Error
179
+	 * @throws InvalidArgumentException
180
+	 * @throws InvalidDataTypeException
181
+	 * @throws InvalidInterfaceException
182
+	 */
183
+	protected function _get_txn_timestamp(EE_Transaction $transaction)
184
+	{
185
+		//txn timestamp
186
+		// is TXN less than 2 hours old ?
187
+		if (($transaction->failed() || $transaction->is_abandoned())
188
+			&& (
189
+				(time() - EE_Registry::instance()->SSN->lifespan()) < $transaction->datetime(false, true)
190
+			)
191
+		) {
192
+			$timestamp = esc_html__('TXN in progress...', 'event_espresso');
193
+		} else {
194
+			$timestamp = $transaction->get_i18n_datetime('TXN_timestamp');
195
+		}
196
+		return $timestamp;
197
+	}
198
+
199
+
200
+	/**
201
+	 *    column_cb
202
+	 *
203
+	 * @param \EE_Transaction $transaction
204
+	 * @return string
205
+	 * @throws \EE_Error
206
+	 */
207
+	public function column_cb($transaction)
208
+	{
209
+		return sprintf(
210
+			'<input type="checkbox" name="%1$s[]" value="%2$s" />',
211
+			$this->_wp_list_args['singular'],
212
+			$transaction->ID()
213
+		);
214
+	}
215
+
216
+
217
+	/**
218
+	 *    column_TXN_timestamp
219
+	 *
220
+	 * @param \EE_Transaction $transaction
221
+	 * @return string
222
+	 * @throws \EE_Error
223
+	 */
224
+	public function column_TXN_timestamp(EE_Transaction $transaction)
225
+	{
226
+		$view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
227
+			'action' => 'view_transaction',
228
+			'TXN_ID' => $transaction->ID(),
229
+		), TXN_ADMIN_URL);
230
+		$txn_date     = '<a href="' . $view_lnk_url . '"'
231
+						. ' title="'
232
+						. esc_attr__('View Transaction Details for TXN #', 'event_espresso') . $transaction->ID() . '">'
233
+						. $this->_get_txn_timestamp($transaction)
234
+						. '</a>';
235
+		//status
236
+		$txn_date .= '<br><span class="ee-status-text-small">'
237
+					 . EEH_Template::pretty_status(
238
+						 $transaction->status_ID(),
239
+						 false,
240
+						 'sentence'
241
+					 )
242
+					 . '</span>';
243
+		return $txn_date;
244
+	}
245
+
246
+
247
+	/**
248
+	 *    column_TXN_total
249
+	 *
250
+	 * @param \EE_Transaction $transaction
251
+	 * @return string
252
+	 * @throws \EE_Error
253
+	 */
254
+	public function column_TXN_total(EE_Transaction $transaction)
255
+	{
256
+		if ($transaction->get('TXN_total') > 0) {
257
+			return '<span class="txn-pad-rght">'
258
+				   . apply_filters(
259
+					   'FHEE__EE_Admin_Transactions_List_Table__column_TXN_total__TXN_total',
260
+					   $transaction->get_pretty('TXN_total'),
261
+					   $transaction
262
+				   )
263
+				   . '</span>';
264
+		} else {
265
+			return '<span class="txn-overview-free-event-spn">' . esc_html__('free', 'event_espresso') . '</span>';
266
+		}
267
+	}
268
+
269
+
270
+	/**
271
+	 *    column_TXN_paid
272
+	 *
273
+	 * @param \EE_Transaction $transaction
274
+	 * @return mixed|string
275
+	 * @throws \EE_Error
276
+	 */
277
+	public function column_TXN_paid(EE_Transaction $transaction)
278
+	{
279
+		$transaction_total = $transaction->get('TXN_total');
280
+		$transaction_paid  = $transaction->get('TXN_paid');
281
+
282
+		if (\EEH_Money::compare_floats($transaction_total, 0, '>')) {
283
+			// monies owing
284
+			$span_class = 'txn-overview-part-payment-spn';
285
+			if (\EEH_Money::compare_floats($transaction_paid, $transaction_total, '>=')) {
286
+				// paid in full
287
+				$span_class = 'txn-overview-full-payment-spn';
288
+			} elseif (\EEH_Money::compare_floats($transaction_paid, 0, '==')) {
289
+				// no payments made
290
+				$span_class = 'txn-overview-no-payment-spn';
291
+			}
292
+		} else {
293
+			$span_class       = 'txn-overview-free-event-spn';
294
+			$transaction_paid = 0;
295
+		}
296
+
297
+		$payment_method      = $transaction->payment_method();
298
+		$payment_method_name = $payment_method instanceof EE_Payment_Method
299
+			? $payment_method->admin_name()
300
+			: esc_html__('Unknown', 'event_espresso');
301
+		$transaction_paid_content = $transaction_paid !== 0 ? $transaction->get_pretty('TXN_paid') : $transaction_paid;
302
+
303
+		$content = '<span class="' . $span_class . ' txn-pad-rght">'
304
+				   . $transaction_paid_content
305
+				   . '</span>';
306
+		if ($transaction_paid > 0) {
307
+			$content .= '<br><span class="ee-status-text-small">'
308
+						. sprintf(
309
+							esc_html__('...via %s', 'event_espresso'),
310
+							$payment_method_name
311
+						)
312
+						. '</span>';
313
+		}
314
+		return $content;
315
+	}
316
+
317
+
318
+	/**
319
+	 *    column_ATT_fname
320
+	 *
321
+	 * @param \EE_Transaction $transaction
322
+	 * @return string
323
+	 * @throws EE_Error
324
+	 * @throws InvalidArgumentException
325
+	 * @throws InvalidDataTypeException
326
+	 * @throws InvalidInterfaceException
327
+	 */
328
+	public function column_ATT_fname(EE_Transaction $transaction)
329
+	{
330
+		$primary_reg = $transaction->primary_registration();
331
+		$attendee    = $primary_reg->get_first_related('Attendee');
332
+		if ($attendee instanceof EE_Attendee) {
333
+			$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array(
334
+				'action'  => 'view_registration',
335
+				'_REG_ID' => $primary_reg->ID(),
336
+			), REG_ADMIN_URL);
337
+			$content      = EE_Registry::instance()->CAP->current_user_can(
338
+				'ee_read_registration',
339
+				'espresso_registrations_view_registration',
340
+				$primary_reg->ID()
341
+			)
342
+				? '<a href="' . $edit_lnk_url . '"'
343
+					. ' title="' . esc_attr__('View Registration Details', 'event_espresso') . '">'
344
+					. $attendee->full_name()
345
+					. '</a>'
346
+				: $attendee->full_name();
347
+			$content      .= '<br>' . $attendee->email();
348
+			return $content;
349
+		}
350
+		return $transaction->failed() || $transaction->is_abandoned()
351
+			? esc_html__('no contact record.', 'event_espresso')
352
+			: esc_html__(
353
+				'No contact record, because the transaction was abandoned or the registration process failed.',
354
+				'event_espresso'
355
+			);
356
+	}
357
+
358
+
359
+	/**
360
+	 *    column_ATT_email
361
+	 *
362
+	 * @param \EE_Transaction $transaction
363
+	 * @return string
364
+	 * @throws \EE_Error
365
+	 */
366
+	public function column_ATT_email(EE_Transaction $transaction)
367
+	{
368
+		$attendee = $transaction->primary_registration()->get_first_related('Attendee');
369
+		if (! empty($attendee)) {
370
+			return '<a href="mailto:' . $attendee->get('ATT_email') . '">'
371
+				   . $attendee->get('ATT_email')
372
+				   . '</a>';
373
+		} else {
374
+			return $transaction->failed() || $transaction->is_abandoned()
375
+				? esc_html__('no contact record.', 'event_espresso')
376
+				: esc_html__(
377
+					'No contact record, because the transaction was abandoned or the registration process failed.',
378
+					'event_espresso'
379
+				);
380
+		}
381
+	}
382
+
383
+
384
+	/**
385
+	 *    column_event_name
386
+	 *
387
+	 * @param \EE_Transaction $transaction
388
+	 * @return string
389
+	 * @throws EE_Error
390
+	 * @throws InvalidArgumentException
391
+	 * @throws InvalidDataTypeException
392
+	 * @throws InvalidInterfaceException
393
+	 */
394
+	public function column_event_name(EE_Transaction $transaction)
395
+	{
396
+		$actions = array();
397
+		$event   = $transaction->primary_registration()->get_first_related('Event');
398
+		if (! empty($event)) {
399
+			$edit_event_url = EE_Admin_Page::add_query_args_and_nonce(
400
+				array('action' => 'edit', 'post' => $event->ID()),
401
+				EVENTS_ADMIN_URL
402
+			);
403
+			$event_name     = $event->get('EVT_name');
404
+
405
+			//filter this view by transactions for this event
406
+			$txn_by_event_lnk = EE_Admin_Page::add_query_args_and_nonce(array(
407
+				'action' => 'default',
408
+				'EVT_ID' => $event->ID(),
409
+			));
410
+			if (empty($this->_req_data['EVT_ID'])
411
+				&& EE_Registry::instance()->CAP->current_user_can(
412
+					'ee_edit_event',
413
+					'espresso_events_edit',
414
+					$event->ID()
415
+				)
416
+			) {
417
+				$actions['filter_by_event'] = '<a href="' . $txn_by_event_lnk . '"'
418
+						. ' title="' . esc_attr__('Filter transactions by this event', 'event_espresso') . '">'
419
+						. esc_html__('View Transactions for this event', 'event_espresso')
420
+						. '</a>';
421
+			}
422
+
423
+			return sprintf(
424
+				'%1$s %2$s',
425
+				EE_Registry::instance()->CAP->current_user_can(
426
+					'ee_edit_event',
427
+					'espresso_events_edit',
428
+					$event->ID()
429
+				)
430
+					? '<a href="' . $edit_event_url . '"'
431
+						. ' title="'
432
+						. sprintf(
433
+							esc_attr__('Edit Event: %s', 'event_espresso'),
434
+							$event->get('EVT_name')
435
+						)
436
+						. '">'
437
+						. wp_trim_words(
438
+							$event_name,
439
+							30,
440
+							'...'
441
+						)
442
+						. '</a>'
443
+						: wp_trim_words($event_name, 30, '...'),
444
+				$this->row_actions($actions)
445
+			);
446
+		} else {
447
+			return esc_html__(
448
+				'The event associated with this transaction via the primary registration cannot be retrieved.',
449
+				'event_espresso'
450
+			);
451
+		}
452
+	}
453
+
454
+
455
+	/**
456
+	 *    column_actions
457
+	 *
458
+	 * @param \EE_Transaction $transaction
459
+	 * @return string
460
+	 * @throws \EE_Error
461
+	 */
462
+	public function column_actions(EE_Transaction $transaction)
463
+	{
464
+		return $this->_action_string(
465
+			$this->get_transaction_details_link($transaction)
466
+			. $this->get_invoice_link($transaction)
467
+			. $this->get_receipt_link($transaction)
468
+			. $this->get_primary_registration_details_link($transaction)
469
+			. $this->get_send_payment_reminder_trigger_link($transaction)
470
+			. $this->get_payment_overview_link($transaction)
471
+			. $this->get_related_messages_link($transaction),
472
+			$transaction,
473
+			'ul',
474
+			'txn-overview-actions-ul'
475
+		);
476
+	}
477
+
478
+
479
+	/**
480
+	 * Get the transaction details link.
481
+	 * @param EE_Transaction $transaction
482
+	 * @return string
483
+	 * @throws EE_Error
484
+	 */
485
+	protected function get_transaction_details_link(EE_Transaction $transaction)
486
+	{
487
+		$url          = EE_Admin_Page::add_query_args_and_nonce(array(
488
+			'action' => 'view_transaction',
489
+			'TXN_ID' => $transaction->ID(),
490
+		), TXN_ADMIN_URL);
491
+		return '
492 492
 			<li>
493 493
 				<a href="' . $url . '"'
494
-                    . ' title="' . esc_attr__('View Transaction Details', 'event_espresso') . '" class="tiny-text">
494
+					. ' title="' . esc_attr__('View Transaction Details', 'event_espresso') . '" class="tiny-text">
495 495
 					<span class="dashicons dashicons-cart"></span>
496 496
 				</a>
497 497
 			</li>';
498
-    }
499
-
500
-
501
-    /**
502
-     * Get the invoice link for the given registration.
503
-     * @param EE_Transaction $transaction
504
-     * @return string
505
-     * @throws EE_Error
506
-     */
507
-    protected function get_invoice_link(EE_Transaction $transaction)
508
-    {
509
-        $registration = $transaction->primary_registration();
510
-        if ($registration instanceof EE_Registration) {
511
-            $url = $registration->invoice_url();
512
-            //only show invoice link if message type is active.
513
-            if ($registration->attendee() instanceof EE_Attendee
514
-                && EEH_MSG_Template::is_mt_active('invoice')
515
-            ) {
516
-                return '
498
+	}
499
+
500
+
501
+	/**
502
+	 * Get the invoice link for the given registration.
503
+	 * @param EE_Transaction $transaction
504
+	 * @return string
505
+	 * @throws EE_Error
506
+	 */
507
+	protected function get_invoice_link(EE_Transaction $transaction)
508
+	{
509
+		$registration = $transaction->primary_registration();
510
+		if ($registration instanceof EE_Registration) {
511
+			$url = $registration->invoice_url();
512
+			//only show invoice link if message type is active.
513
+			if ($registration->attendee() instanceof EE_Attendee
514
+				&& EEH_MSG_Template::is_mt_active('invoice')
515
+			) {
516
+				return '
517 517
                 <li>
518 518
                     <a title="' . esc_attr__('View Transaction Invoice', 'event_espresso') . '"'
519
-                       . ' target="_blank" href="' . $url . '" class="tiny-text">
519
+					   . ' target="_blank" href="' . $url . '" class="tiny-text">
520 520
                         <span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span>
521 521
                     </a>
522 522
                 </li>';
523
-            }
524
-        }
525
-        return '';
526
-    }
527
-
528
-
529
-    /**
530
-     * Get the receipt link for the transaction.
531
-     * @param EE_Transaction $transaction
532
-     * @return string
533
-     * @throws EE_Error
534
-     */
535
-    protected function get_receipt_link(EE_Transaction $transaction)
536
-    {
537
-        $registration = $transaction->primary_registration();
538
-        if ($registration instanceof EE_Registration) {
539
-            $url = $registration->receipt_url();
540
-            //only show receipt link if message type is active.
541
-            if ($registration->attendee() instanceof EE_Attendee
542
-                && EEH_MSG_Template::is_mt_active('receipt')) {
543
-                return '
523
+			}
524
+		}
525
+		return '';
526
+	}
527
+
528
+
529
+	/**
530
+	 * Get the receipt link for the transaction.
531
+	 * @param EE_Transaction $transaction
532
+	 * @return string
533
+	 * @throws EE_Error
534
+	 */
535
+	protected function get_receipt_link(EE_Transaction $transaction)
536
+	{
537
+		$registration = $transaction->primary_registration();
538
+		if ($registration instanceof EE_Registration) {
539
+			$url = $registration->receipt_url();
540
+			//only show receipt link if message type is active.
541
+			if ($registration->attendee() instanceof EE_Attendee
542
+				&& EEH_MSG_Template::is_mt_active('receipt')) {
543
+				return '
544 544
 			<li>
545 545
 				<a title="' . esc_attr__('View Transaction Receipt', 'event_espresso') . '"'
546
-                                  . ' target="_blank" href="' . $url . '" class="tiny-text">
546
+								  . ' target="_blank" href="' . $url . '" class="tiny-text">
547 547
 					<span class="dashicons dashicons-media-default ee-icon-size-18"></span>
548 548
 				</a>
549 549
 			</li>';
550
-            }
551
-        }
552
-        return '';
553
-    }
554
-
555
-
556
-    /**
557
-     * Get the link to view the details for the primary registration.
558
-     *
559
-     * @param EE_Transaction $transaction
560
-     * @return string
561
-     * @throws EE_Error
562
-     * @throws InvalidArgumentException
563
-     * @throws InvalidDataTypeException
564
-     * @throws InvalidInterfaceException
565
-     */
566
-    protected function get_primary_registration_details_link(EE_Transaction $transaction)
567
-    {
568
-        $registration = $transaction->primary_registration();
569
-        if ($registration instanceof EE_Registration) {
570
-            $url      = EE_Admin_Page::add_query_args_and_nonce(array(
571
-                'action'  => 'view_registration',
572
-                '_REG_ID' => $registration->ID(),
573
-            ), REG_ADMIN_URL);
574
-            return EE_Registry::instance()->CAP->current_user_can(
575
-                'ee_read_registration',
576
-                'espresso_registrations_view_registration',
577
-                $registration->ID()
578
-            )
579
-                ? '
550
+			}
551
+		}
552
+		return '';
553
+	}
554
+
555
+
556
+	/**
557
+	 * Get the link to view the details for the primary registration.
558
+	 *
559
+	 * @param EE_Transaction $transaction
560
+	 * @return string
561
+	 * @throws EE_Error
562
+	 * @throws InvalidArgumentException
563
+	 * @throws InvalidDataTypeException
564
+	 * @throws InvalidInterfaceException
565
+	 */
566
+	protected function get_primary_registration_details_link(EE_Transaction $transaction)
567
+	{
568
+		$registration = $transaction->primary_registration();
569
+		if ($registration instanceof EE_Registration) {
570
+			$url      = EE_Admin_Page::add_query_args_and_nonce(array(
571
+				'action'  => 'view_registration',
572
+				'_REG_ID' => $registration->ID(),
573
+			), REG_ADMIN_URL);
574
+			return EE_Registry::instance()->CAP->current_user_can(
575
+				'ee_read_registration',
576
+				'espresso_registrations_view_registration',
577
+				$registration->ID()
578
+			)
579
+				? '
580 580
 				<li>
581 581
 					<a href="' . $url . '"'
582
-                  . ' title="' . esc_attr__('View Registration Details', 'event_espresso') . '" class="tiny-text">
582
+				  . ' title="' . esc_attr__('View Registration Details', 'event_espresso') . '" class="tiny-text">
583 583
 						<span class="dashicons dashicons-clipboard"></span>
584 584
 					</a>
585 585
 				</li>'
586
-                : '';
587
-        }
588
-        return '';
589
-    }
590
-
591
-
592
-    /**
593
-     * Get send payment reminder trigger link
594
-     * @param EE_Transaction $transaction
595
-     * @return string
596
-     * @throws EE_Error
597
-     * @throws InvalidArgumentException
598
-     * @throws InvalidDataTypeException
599
-     * @throws InvalidInterfaceException
600
-     */
601
-    protected function get_send_payment_reminder_trigger_link(EE_Transaction $transaction)
602
-    {
603
-        $registration = $transaction->primary_registration();
604
-        if ($registration instanceof EE_Registration
605
-            && $registration->attendee() instanceof EE_Attendee
606
-            && EEH_MSG_Template::is_mt_active('payment_reminder')
607
-            && ! in_array(
608
-                $transaction->status_ID(),
609
-                array(EEM_Transaction::complete_status_code, EEM_Transaction::overpaid_status_code),
610
-                true
611
-            )
612
-            && EE_Registry::instance()->CAP->current_user_can(
613
-                'ee_send_message',
614
-                'espresso_transactions_send_payment_reminder'
615
-            )
616
-        ) {
617
-            $url = EE_Admin_Page::add_query_args_and_nonce(array(
618
-                'action' => 'send_payment_reminder',
619
-                'TXN_ID' => $transaction->ID(),
620
-            ), TXN_ADMIN_URL);
621
-            return  '
586
+				: '';
587
+		}
588
+		return '';
589
+	}
590
+
591
+
592
+	/**
593
+	 * Get send payment reminder trigger link
594
+	 * @param EE_Transaction $transaction
595
+	 * @return string
596
+	 * @throws EE_Error
597
+	 * @throws InvalidArgumentException
598
+	 * @throws InvalidDataTypeException
599
+	 * @throws InvalidInterfaceException
600
+	 */
601
+	protected function get_send_payment_reminder_trigger_link(EE_Transaction $transaction)
602
+	{
603
+		$registration = $transaction->primary_registration();
604
+		if ($registration instanceof EE_Registration
605
+			&& $registration->attendee() instanceof EE_Attendee
606
+			&& EEH_MSG_Template::is_mt_active('payment_reminder')
607
+			&& ! in_array(
608
+				$transaction->status_ID(),
609
+				array(EEM_Transaction::complete_status_code, EEM_Transaction::overpaid_status_code),
610
+				true
611
+			)
612
+			&& EE_Registry::instance()->CAP->current_user_can(
613
+				'ee_send_message',
614
+				'espresso_transactions_send_payment_reminder'
615
+			)
616
+		) {
617
+			$url = EE_Admin_Page::add_query_args_and_nonce(array(
618
+				'action' => 'send_payment_reminder',
619
+				'TXN_ID' => $transaction->ID(),
620
+			), TXN_ADMIN_URL);
621
+			return  '
622 622
             <li>
623 623
                 <a href="' . $url . '"'
624
-                  . ' title="' . esc_attr__('Send Payment Reminder', 'event_espresso') . '" class="tiny-text">
624
+				  . ' title="' . esc_attr__('Send Payment Reminder', 'event_espresso') . '" class="tiny-text">
625 625
                     <span class="dashicons dashicons-email-alt"></span>
626 626
                 </a>
627 627
             </li>';
628
-        }
629
-        return '';
630
-    }
631
-
632
-
633
-    /**
634
-     * Get link to filtered view in the message activity list table of messages for this transaction.
635
-     * @param EE_Transaction $transaction
636
-     * @return string
637
-     * @throws EE_Error
638
-     * @throws InvalidArgumentException
639
-     * @throws InvalidDataTypeException
640
-     * @throws InvalidInterfaceException
641
-     */
642
-    protected function get_related_messages_link(EE_Transaction $transaction)
643
-    {
644
-        $url = EEH_MSG_Template::get_message_action_link(
645
-            'see_notifications_for',
646
-            null,
647
-            array('TXN_ID' => $transaction->ID())
648
-        );
649
-        return EE_Registry::instance()->CAP->current_user_can(
650
-            'ee_read_global_messages',
651
-            'view_filtered_messages'
652
-        )
653
-            ? '<li>' . $url . '</li>'
654
-            : '';
655
-    }
656
-
657
-
658
-    /**
659
-     * Return the link to make a payment on the frontend
660
-     * @param EE_Transaction $transaction
661
-     * @return string
662
-     * @throws EE_Error
663
-     */
664
-    protected function get_payment_overview_link(EE_Transaction $transaction)
665
-    {
666
-        $registration = $transaction->primary_registration();
667
-        if ($registration instanceof EE_Registration
668
-            && $transaction->status_ID() !== EEM_Transaction::complete_status_code
669
-            && $registration->owes_monies_and_can_pay()
670
-        ) {
671
-            return '
628
+		}
629
+		return '';
630
+	}
631
+
632
+
633
+	/**
634
+	 * Get link to filtered view in the message activity list table of messages for this transaction.
635
+	 * @param EE_Transaction $transaction
636
+	 * @return string
637
+	 * @throws EE_Error
638
+	 * @throws InvalidArgumentException
639
+	 * @throws InvalidDataTypeException
640
+	 * @throws InvalidInterfaceException
641
+	 */
642
+	protected function get_related_messages_link(EE_Transaction $transaction)
643
+	{
644
+		$url = EEH_MSG_Template::get_message_action_link(
645
+			'see_notifications_for',
646
+			null,
647
+			array('TXN_ID' => $transaction->ID())
648
+		);
649
+		return EE_Registry::instance()->CAP->current_user_can(
650
+			'ee_read_global_messages',
651
+			'view_filtered_messages'
652
+		)
653
+			? '<li>' . $url . '</li>'
654
+			: '';
655
+	}
656
+
657
+
658
+	/**
659
+	 * Return the link to make a payment on the frontend
660
+	 * @param EE_Transaction $transaction
661
+	 * @return string
662
+	 * @throws EE_Error
663
+	 */
664
+	protected function get_payment_overview_link(EE_Transaction $transaction)
665
+	{
666
+		$registration = $transaction->primary_registration();
667
+		if ($registration instanceof EE_Registration
668
+			&& $transaction->status_ID() !== EEM_Transaction::complete_status_code
669
+			&& $registration->owes_monies_and_can_pay()
670
+		) {
671
+			return '
672 672
             <li>
673 673
                 <a title="' . esc_attr__('Make Payment from the Frontend.', 'event_espresso') . '"'
674
-                    . ' target="_blank" href="' . $registration->payment_overview_url(true) . '"'
675
-                    . ' class="tiny-text">
674
+					. ' target="_blank" href="' . $registration->payment_overview_url(true) . '"'
675
+					. ' class="tiny-text">
676 676
                     <span class="dashicons dashicons-money ee-icon-size-18"></span>
677 677
                 </a>
678 678
             </li>
679 679
             ';
680 680
 
681
-        }
682
-        return '';
683
-    }
681
+		}
682
+		return '';
683
+	}
684 684
 }
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -51,11 +51,11 @@  discard block
 block discarded – undo
51 51
             'ajax'     => true,
52 52
             'screen'   => $this->_admin_page->get_current_screen()->id,
53 53
         );
54
-        $ID_column_name      = __('ID', 'event_espresso');
54
+        $ID_column_name = __('ID', 'event_espresso');
55 55
         $ID_column_name      .= ' : <span class="show-on-mobile-view-only" style="float:none">';
56 56
         $ID_column_name      .= __('Transaction Date', 'event_espresso');
57 57
         $ID_column_name      .= '</span> ';
58
-        $this->_columns      = array(
58
+        $this->_columns = array(
59 59
             'TXN_ID'        => $ID_column_name,
60 60
             'TXN_timestamp' => __('Transaction Date', 'event_espresso'),
61 61
             'TXN_total'     => __('Total', 'event_espresso'),
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
     {
91 91
         $class = parent::_get_row_class($transaction);
92 92
         //add status class
93
-        $class .= ' ee-status-strip txn-status-' . $transaction->status_ID();
93
+        $class .= ' ee-status-strip txn-status-'.$transaction->status_ID();
94 94
         if ($this->_has_checkbox_column) {
95 95
             $class .= ' has-checkbox-column';
96 96
         }
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
                 'm/d/Y',
117 117
                 strtotime('-10 year')
118 118
             );
119
-        $end_date   = isset($this->_req_data['txn-filter-end-date'])
119
+        $end_date = isset($this->_req_data['txn-filter-end-date'])
120 120
             ? wp_strip_all_tags($this->_req_data['txn-filter-end-date'])
121 121
             : date(
122 122
                 'm/d/Y',
@@ -161,13 +161,13 @@  discard block
 block discarded – undo
161 161
             'action' => 'view_transaction',
162 162
             'TXN_ID' => $transaction->ID(),
163 163
         ), TXN_ADMIN_URL);
164
-        $content      = '<a href="' . $view_lnk_url . '"'
165
-                        . ' title="' . esc_attr__('Go to Transaction Details', 'event_espresso') . '">'
164
+        $content = '<a href="'.$view_lnk_url.'"'
165
+                        . ' title="'.esc_attr__('Go to Transaction Details', 'event_espresso').'">'
166 166
                         . $transaction->ID()
167 167
                         . '</a>';
168 168
 
169 169
         //txn timestamp
170
-        $content .= '  <span class="show-on-mobile-view-only">' . $this->_get_txn_timestamp($transaction) . '</span>';
170
+        $content .= '  <span class="show-on-mobile-view-only">'.$this->_get_txn_timestamp($transaction).'</span>';
171 171
         return $content;
172 172
     }
173 173
 
@@ -227,9 +227,9 @@  discard block
 block discarded – undo
227 227
             'action' => 'view_transaction',
228 228
             'TXN_ID' => $transaction->ID(),
229 229
         ), TXN_ADMIN_URL);
230
-        $txn_date     = '<a href="' . $view_lnk_url . '"'
230
+        $txn_date = '<a href="'.$view_lnk_url.'"'
231 231
                         . ' title="'
232
-                        . esc_attr__('View Transaction Details for TXN #', 'event_espresso') . $transaction->ID() . '">'
232
+                        . esc_attr__('View Transaction Details for TXN #', 'event_espresso').$transaction->ID().'">'
233 233
                         . $this->_get_txn_timestamp($transaction)
234 234
                         . '</a>';
235 235
         //status
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
                    )
263 263
                    . '</span>';
264 264
         } else {
265
-            return '<span class="txn-overview-free-event-spn">' . esc_html__('free', 'event_espresso') . '</span>';
265
+            return '<span class="txn-overview-free-event-spn">'.esc_html__('free', 'event_espresso').'</span>';
266 266
         }
267 267
     }
268 268
 
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
             : esc_html__('Unknown', 'event_espresso');
301 301
         $transaction_paid_content = $transaction_paid !== 0 ? $transaction->get_pretty('TXN_paid') : $transaction_paid;
302 302
 
303
-        $content = '<span class="' . $span_class . ' txn-pad-rght">'
303
+        $content = '<span class="'.$span_class.' txn-pad-rght">'
304 304
                    . $transaction_paid_content
305 305
                    . '</span>';
306 306
         if ($transaction_paid > 0) {
@@ -334,17 +334,17 @@  discard block
 block discarded – undo
334 334
                 'action'  => 'view_registration',
335 335
                 '_REG_ID' => $primary_reg->ID(),
336 336
             ), REG_ADMIN_URL);
337
-            $content      = EE_Registry::instance()->CAP->current_user_can(
337
+            $content = EE_Registry::instance()->CAP->current_user_can(
338 338
                 'ee_read_registration',
339 339
                 'espresso_registrations_view_registration',
340 340
                 $primary_reg->ID()
341 341
             )
342
-                ? '<a href="' . $edit_lnk_url . '"'
343
-                    . ' title="' . esc_attr__('View Registration Details', 'event_espresso') . '">'
342
+                ? '<a href="'.$edit_lnk_url.'"'
343
+                    . ' title="'.esc_attr__('View Registration Details', 'event_espresso').'">'
344 344
                     . $attendee->full_name()
345 345
                     . '</a>'
346 346
                 : $attendee->full_name();
347
-            $content      .= '<br>' . $attendee->email();
347
+            $content .= '<br>'.$attendee->email();
348 348
             return $content;
349 349
         }
350 350
         return $transaction->failed() || $transaction->is_abandoned()
@@ -366,8 +366,8 @@  discard block
 block discarded – undo
366 366
     public function column_ATT_email(EE_Transaction $transaction)
367 367
     {
368 368
         $attendee = $transaction->primary_registration()->get_first_related('Attendee');
369
-        if (! empty($attendee)) {
370
-            return '<a href="mailto:' . $attendee->get('ATT_email') . '">'
369
+        if ( ! empty($attendee)) {
370
+            return '<a href="mailto:'.$attendee->get('ATT_email').'">'
371 371
                    . $attendee->get('ATT_email')
372 372
                    . '</a>';
373 373
         } else {
@@ -395,12 +395,12 @@  discard block
 block discarded – undo
395 395
     {
396 396
         $actions = array();
397 397
         $event   = $transaction->primary_registration()->get_first_related('Event');
398
-        if (! empty($event)) {
398
+        if ( ! empty($event)) {
399 399
             $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(
400 400
                 array('action' => 'edit', 'post' => $event->ID()),
401 401
                 EVENTS_ADMIN_URL
402 402
             );
403
-            $event_name     = $event->get('EVT_name');
403
+            $event_name = $event->get('EVT_name');
404 404
 
405 405
             //filter this view by transactions for this event
406 406
             $txn_by_event_lnk = EE_Admin_Page::add_query_args_and_nonce(array(
@@ -414,8 +414,8 @@  discard block
 block discarded – undo
414 414
                     $event->ID()
415 415
                 )
416 416
             ) {
417
-                $actions['filter_by_event'] = '<a href="' . $txn_by_event_lnk . '"'
418
-                        . ' title="' . esc_attr__('Filter transactions by this event', 'event_espresso') . '">'
417
+                $actions['filter_by_event'] = '<a href="'.$txn_by_event_lnk.'"'
418
+                        . ' title="'.esc_attr__('Filter transactions by this event', 'event_espresso').'">'
419 419
                         . esc_html__('View Transactions for this event', 'event_espresso')
420 420
                         . '</a>';
421 421
             }
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
                     'espresso_events_edit',
428 428
                     $event->ID()
429 429
                 )
430
-                    ? '<a href="' . $edit_event_url . '"'
430
+                    ? '<a href="'.$edit_event_url.'"'
431 431
                         . ' title="'
432 432
                         . sprintf(
433 433
                             esc_attr__('Edit Event: %s', 'event_espresso'),
@@ -484,14 +484,14 @@  discard block
 block discarded – undo
484 484
      */
485 485
     protected function get_transaction_details_link(EE_Transaction $transaction)
486 486
     {
487
-        $url          = EE_Admin_Page::add_query_args_and_nonce(array(
487
+        $url = EE_Admin_Page::add_query_args_and_nonce(array(
488 488
             'action' => 'view_transaction',
489 489
             'TXN_ID' => $transaction->ID(),
490 490
         ), TXN_ADMIN_URL);
491 491
         return '
492 492
 			<li>
493
-				<a href="' . $url . '"'
494
-                    . ' title="' . esc_attr__('View Transaction Details', 'event_espresso') . '" class="tiny-text">
493
+				<a href="' . $url.'"'
494
+                    . ' title="'.esc_attr__('View Transaction Details', 'event_espresso').'" class="tiny-text">
495 495
 					<span class="dashicons dashicons-cart"></span>
496 496
 				</a>
497 497
 			</li>';
@@ -515,8 +515,8 @@  discard block
 block discarded – undo
515 515
             ) {
516 516
                 return '
517 517
                 <li>
518
-                    <a title="' . esc_attr__('View Transaction Invoice', 'event_espresso') . '"'
519
-                       . ' target="_blank" href="' . $url . '" class="tiny-text">
518
+                    <a title="' . esc_attr__('View Transaction Invoice', 'event_espresso').'"'
519
+                       . ' target="_blank" href="'.$url.'" class="tiny-text">
520 520
                         <span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span>
521 521
                     </a>
522 522
                 </li>';
@@ -542,8 +542,8 @@  discard block
 block discarded – undo
542 542
                 && EEH_MSG_Template::is_mt_active('receipt')) {
543 543
                 return '
544 544
 			<li>
545
-				<a title="' . esc_attr__('View Transaction Receipt', 'event_espresso') . '"'
546
-                                  . ' target="_blank" href="' . $url . '" class="tiny-text">
545
+				<a title="' . esc_attr__('View Transaction Receipt', 'event_espresso').'"'
546
+                                  . ' target="_blank" href="'.$url.'" class="tiny-text">
547 547
 					<span class="dashicons dashicons-media-default ee-icon-size-18"></span>
548 548
 				</a>
549 549
 			</li>';
@@ -578,8 +578,8 @@  discard block
 block discarded – undo
578 578
             )
579 579
                 ? '
580 580
 				<li>
581
-					<a href="' . $url . '"'
582
-                  . ' title="' . esc_attr__('View Registration Details', 'event_espresso') . '" class="tiny-text">
581
+					<a href="' . $url.'"'
582
+                  . ' title="'.esc_attr__('View Registration Details', 'event_espresso').'" class="tiny-text">
583 583
 						<span class="dashicons dashicons-clipboard"></span>
584 584
 					</a>
585 585
 				</li>'
@@ -620,8 +620,8 @@  discard block
 block discarded – undo
620 620
             ), TXN_ADMIN_URL);
621 621
             return  '
622 622
             <li>
623
-                <a href="' . $url . '"'
624
-                  . ' title="' . esc_attr__('Send Payment Reminder', 'event_espresso') . '" class="tiny-text">
623
+                <a href="' . $url.'"'
624
+                  . ' title="'.esc_attr__('Send Payment Reminder', 'event_espresso').'" class="tiny-text">
625 625
                     <span class="dashicons dashicons-email-alt"></span>
626 626
                 </a>
627 627
             </li>';
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
             'ee_read_global_messages',
651 651
             'view_filtered_messages'
652 652
         )
653
-            ? '<li>' . $url . '</li>'
653
+            ? '<li>'.$url.'</li>'
654 654
             : '';
655 655
     }
656 656
 
@@ -670,8 +670,8 @@  discard block
 block discarded – undo
670 670
         ) {
671 671
             return '
672 672
             <li>
673
-                <a title="' . esc_attr__('Make Payment from the Frontend.', 'event_espresso') . '"'
674
-                    . ' target="_blank" href="' . $registration->payment_overview_url(true) . '"'
673
+                <a title="' . esc_attr__('Make Payment from the Frontend.', 'event_espresso').'"'
674
+                    . ' target="_blank" href="'.$registration->payment_overview_url(true).'"'
675 675
                     . ' class="tiny-text">
676 676
                     <span class="dashicons dashicons-money ee-icon-size-18"></span>
677 677
                 </a>
Please login to merge, or discard this patch.
admin/extend/registrations/Extend_Registrations_Admin_Page.core.php 2 patches
Indentation   +1193 added lines, -1193 removed lines patch added patch discarded remove patch
@@ -18,1252 +18,1252 @@
 block discarded – undo
18 18
 {
19 19
 
20 20
 
21
-    /**
22
-     * This is used to hold the reports template data which is setup early in the request.
23
-     *
24
-     * @type array
25
-     */
26
-    protected $_reports_template_data = array();
21
+	/**
22
+	 * This is used to hold the reports template data which is setup early in the request.
23
+	 *
24
+	 * @type array
25
+	 */
26
+	protected $_reports_template_data = array();
27 27
 
28 28
 
29 29
 
30
-    /**
31
-     * Extend_Registrations_Admin_Page constructor.
32
-     *
33
-     * @param bool $routing
34
-     */
35
-    public function __construct($routing = true)
36
-    {
37
-        parent::__construct($routing);
38
-        if (! defined('REG_CAF_TEMPLATE_PATH')) {
39
-            define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/');
40
-            define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/');
41
-            define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/');
42
-        }
43
-    }
30
+	/**
31
+	 * Extend_Registrations_Admin_Page constructor.
32
+	 *
33
+	 * @param bool $routing
34
+	 */
35
+	public function __construct($routing = true)
36
+	{
37
+		parent::__construct($routing);
38
+		if (! defined('REG_CAF_TEMPLATE_PATH')) {
39
+			define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/');
40
+			define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/');
41
+			define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/');
42
+		}
43
+	}
44 44
 
45 45
 
46
-    /**
47
-     * Extending page configuration.
48
-     */
49
-    protected function _extend_page_config()
50
-    {
51
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations';
52
-        $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
53
-            ? $this->_req_data['_REG_ID']
54
-            : 0;
55
-        $new_page_routes = array(
56
-            'reports'                  => array(
57
-                'func'       => '_registration_reports',
58
-                'capability' => 'ee_read_registrations',
59
-            ),
60
-            'registration_checkins'    => array(
61
-                'func'       => '_registration_checkin_list_table',
62
-                'capability' => 'ee_read_checkins',
63
-            ),
64
-            'newsletter_selected_send' => array(
65
-                'func'       => '_newsletter_selected_send',
66
-                'noheader'   => true,
67
-                'capability' => 'ee_send_message',
68
-            ),
69
-            'delete_checkin_rows'      => array(
70
-                'func'       => '_delete_checkin_rows',
71
-                'noheader'   => true,
72
-                'capability' => 'ee_delete_checkins',
73
-            ),
74
-            'delete_checkin_row'       => array(
75
-                'func'       => '_delete_checkin_row',
76
-                'noheader'   => true,
77
-                'capability' => 'ee_delete_checkin',
78
-                'obj_id'     => $reg_id,
79
-            ),
80
-            'toggle_checkin_status'    => array(
81
-                'func'       => '_toggle_checkin_status',
82
-                'noheader'   => true,
83
-                'capability' => 'ee_edit_checkin',
84
-                'obj_id'     => $reg_id,
85
-            ),
86
-            'toggle_checkin_status_bulk' => array(
87
-                'func' => '_toggle_checkin_status',
88
-                'noheader' => true,
89
-                'capability' => 'ee_edit_checkins'
90
-            ),
91
-            'event_registrations'      => array(
92
-                'func'       => '_event_registrations_list_table',
93
-                'capability' => 'ee_read_checkins',
94
-            ),
95
-            'registrations_checkin_report' => array(
96
-                'func'       => '_registrations_checkin_report',
97
-                'noheader'   => true,
98
-                'capability' => 'ee_read_registrations',
99
-            ),
100
-        );
101
-        $this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
102
-        $new_page_config = array(
103
-            'reports'               => array(
104
-                'nav'           => array(
105
-                    'label' => esc_html__('Reports', 'event_espresso'),
106
-                    'order' => 30,
107
-                ),
108
-                'help_tabs'     => array(
109
-                    'registrations_reports_help_tab' => array(
110
-                        'title'    => esc_html__('Registration Reports', 'event_espresso'),
111
-                        'filename' => 'registrations_reports',
112
-                    ),
113
-                ),
114
-                /*'help_tour' => array( 'Registration_Reports_Help_Tour' ),*/
115
-                'require_nonce' => false,
116
-            ),
117
-            'event_registrations'   => array(
118
-                'nav'           => array(
119
-                    'label'      => esc_html__('Event Check-In', 'event_espresso'),
120
-                    'order'      => 10,
121
-                    'persistent' => true,
122
-                ),
123
-                'help_tabs'     => array(
124
-                    'registrations_event_checkin_help_tab'                       => array(
125
-                        'title'    => esc_html__('Registrations Event Check-In', 'event_espresso'),
126
-                        'filename' => 'registrations_event_checkin',
127
-                    ),
128
-                    'registrations_event_checkin_table_column_headings_help_tab' => array(
129
-                        'title'    => esc_html__('Event Check-In Table Column Headings', 'event_espresso'),
130
-                        'filename' => 'registrations_event_checkin_table_column_headings',
131
-                    ),
132
-                    'registrations_event_checkin_filters_help_tab'               => array(
133
-                        'title'    => esc_html__('Event Check-In Filters', 'event_espresso'),
134
-                        'filename' => 'registrations_event_checkin_filters',
135
-                    ),
136
-                    'registrations_event_checkin_views_help_tab'                 => array(
137
-                        'title'    => esc_html__('Event Check-In Views', 'event_espresso'),
138
-                        'filename' => 'registrations_event_checkin_views',
139
-                    ),
140
-                    'registrations_event_checkin_other_help_tab'                 => array(
141
-                        'title'    => esc_html__('Event Check-In Other', 'event_espresso'),
142
-                        'filename' => 'registrations_event_checkin_other',
143
-                    ),
144
-                ),
145
-                'help_tour'     => array('Event_Checkin_Help_Tour'),
146
-                'qtips'         => array('Registration_List_Table_Tips'),
147
-                'list_table'    => 'EE_Event_Registrations_List_Table',
148
-                'metaboxes'     => array(),
149
-                'require_nonce' => false,
150
-            ),
151
-            'registration_checkins' => array(
152
-                'nav'           => array(
153
-                    'label'      => esc_html__('Check-In Records', 'event_espresso'),
154
-                    'order'      => 15,
155
-                    'persistent' => false,
156
-                ),
157
-                'list_table'    => 'EE_Registration_CheckIn_List_Table',
158
-                //'help_tour' => array( 'Checkin_Toggle_View_Help_Tour' ),
159
-                'metaboxes'     => array(),
160
-                'require_nonce' => false,
161
-            ),
162
-        );
163
-        $this->_page_config = array_merge($this->_page_config, $new_page_config);
164
-        $this->_page_config['contact_list']['list_table'] = 'Extend_EE_Attendee_Contact_List_Table';
165
-        $this->_page_config['default']['list_table'] = 'Extend_EE_Registrations_List_Table';
166
-    }
46
+	/**
47
+	 * Extending page configuration.
48
+	 */
49
+	protected function _extend_page_config()
50
+	{
51
+		$this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations';
52
+		$reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
53
+			? $this->_req_data['_REG_ID']
54
+			: 0;
55
+		$new_page_routes = array(
56
+			'reports'                  => array(
57
+				'func'       => '_registration_reports',
58
+				'capability' => 'ee_read_registrations',
59
+			),
60
+			'registration_checkins'    => array(
61
+				'func'       => '_registration_checkin_list_table',
62
+				'capability' => 'ee_read_checkins',
63
+			),
64
+			'newsletter_selected_send' => array(
65
+				'func'       => '_newsletter_selected_send',
66
+				'noheader'   => true,
67
+				'capability' => 'ee_send_message',
68
+			),
69
+			'delete_checkin_rows'      => array(
70
+				'func'       => '_delete_checkin_rows',
71
+				'noheader'   => true,
72
+				'capability' => 'ee_delete_checkins',
73
+			),
74
+			'delete_checkin_row'       => array(
75
+				'func'       => '_delete_checkin_row',
76
+				'noheader'   => true,
77
+				'capability' => 'ee_delete_checkin',
78
+				'obj_id'     => $reg_id,
79
+			),
80
+			'toggle_checkin_status'    => array(
81
+				'func'       => '_toggle_checkin_status',
82
+				'noheader'   => true,
83
+				'capability' => 'ee_edit_checkin',
84
+				'obj_id'     => $reg_id,
85
+			),
86
+			'toggle_checkin_status_bulk' => array(
87
+				'func' => '_toggle_checkin_status',
88
+				'noheader' => true,
89
+				'capability' => 'ee_edit_checkins'
90
+			),
91
+			'event_registrations'      => array(
92
+				'func'       => '_event_registrations_list_table',
93
+				'capability' => 'ee_read_checkins',
94
+			),
95
+			'registrations_checkin_report' => array(
96
+				'func'       => '_registrations_checkin_report',
97
+				'noheader'   => true,
98
+				'capability' => 'ee_read_registrations',
99
+			),
100
+		);
101
+		$this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
102
+		$new_page_config = array(
103
+			'reports'               => array(
104
+				'nav'           => array(
105
+					'label' => esc_html__('Reports', 'event_espresso'),
106
+					'order' => 30,
107
+				),
108
+				'help_tabs'     => array(
109
+					'registrations_reports_help_tab' => array(
110
+						'title'    => esc_html__('Registration Reports', 'event_espresso'),
111
+						'filename' => 'registrations_reports',
112
+					),
113
+				),
114
+				/*'help_tour' => array( 'Registration_Reports_Help_Tour' ),*/
115
+				'require_nonce' => false,
116
+			),
117
+			'event_registrations'   => array(
118
+				'nav'           => array(
119
+					'label'      => esc_html__('Event Check-In', 'event_espresso'),
120
+					'order'      => 10,
121
+					'persistent' => true,
122
+				),
123
+				'help_tabs'     => array(
124
+					'registrations_event_checkin_help_tab'                       => array(
125
+						'title'    => esc_html__('Registrations Event Check-In', 'event_espresso'),
126
+						'filename' => 'registrations_event_checkin',
127
+					),
128
+					'registrations_event_checkin_table_column_headings_help_tab' => array(
129
+						'title'    => esc_html__('Event Check-In Table Column Headings', 'event_espresso'),
130
+						'filename' => 'registrations_event_checkin_table_column_headings',
131
+					),
132
+					'registrations_event_checkin_filters_help_tab'               => array(
133
+						'title'    => esc_html__('Event Check-In Filters', 'event_espresso'),
134
+						'filename' => 'registrations_event_checkin_filters',
135
+					),
136
+					'registrations_event_checkin_views_help_tab'                 => array(
137
+						'title'    => esc_html__('Event Check-In Views', 'event_espresso'),
138
+						'filename' => 'registrations_event_checkin_views',
139
+					),
140
+					'registrations_event_checkin_other_help_tab'                 => array(
141
+						'title'    => esc_html__('Event Check-In Other', 'event_espresso'),
142
+						'filename' => 'registrations_event_checkin_other',
143
+					),
144
+				),
145
+				'help_tour'     => array('Event_Checkin_Help_Tour'),
146
+				'qtips'         => array('Registration_List_Table_Tips'),
147
+				'list_table'    => 'EE_Event_Registrations_List_Table',
148
+				'metaboxes'     => array(),
149
+				'require_nonce' => false,
150
+			),
151
+			'registration_checkins' => array(
152
+				'nav'           => array(
153
+					'label'      => esc_html__('Check-In Records', 'event_espresso'),
154
+					'order'      => 15,
155
+					'persistent' => false,
156
+				),
157
+				'list_table'    => 'EE_Registration_CheckIn_List_Table',
158
+				//'help_tour' => array( 'Checkin_Toggle_View_Help_Tour' ),
159
+				'metaboxes'     => array(),
160
+				'require_nonce' => false,
161
+			),
162
+		);
163
+		$this->_page_config = array_merge($this->_page_config, $new_page_config);
164
+		$this->_page_config['contact_list']['list_table'] = 'Extend_EE_Attendee_Contact_List_Table';
165
+		$this->_page_config['default']['list_table'] = 'Extend_EE_Registrations_List_Table';
166
+	}
167 167
 
168 168
 
169
-    /**
170
-     * Ajax hooks for all routes in this page.
171
-     */
172
-    protected function _ajax_hooks()
173
-    {
174
-        parent::_ajax_hooks();
175
-        add_action('wp_ajax_get_newsletter_form_content', array($this, 'get_newsletter_form_content'));
176
-    }
169
+	/**
170
+	 * Ajax hooks for all routes in this page.
171
+	 */
172
+	protected function _ajax_hooks()
173
+	{
174
+		parent::_ajax_hooks();
175
+		add_action('wp_ajax_get_newsletter_form_content', array($this, 'get_newsletter_form_content'));
176
+	}
177 177
 
178 178
 
179
-    /**
180
-     * Global scripts for all routes in this page.
181
-     */
182
-    public function load_scripts_styles()
183
-    {
184
-        parent::load_scripts_styles();
185
-        //if newsletter message type is active then let's add filter and load js for it.
186
-        if (EEH_MSG_Template::is_mt_active('newsletter')) {
187
-            //enqueue newsletter js
188
-            wp_enqueue_script(
189
-                'ee-newsletter-trigger',
190
-                REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js',
191
-                array('ee-dialog'),
192
-                EVENT_ESPRESSO_VERSION,
193
-                true
194
-            );
195
-            wp_enqueue_style(
196
-                'ee-newsletter-trigger-css',
197
-                REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css',
198
-                array(),
199
-                EVENT_ESPRESSO_VERSION
200
-            );
201
-            //hook in buttons for newsletter message type trigger.
202
-            add_action(
203
-                'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons',
204
-                array($this, 'add_newsletter_action_buttons'),
205
-                10
206
-            );
207
-        }
208
-    }
179
+	/**
180
+	 * Global scripts for all routes in this page.
181
+	 */
182
+	public function load_scripts_styles()
183
+	{
184
+		parent::load_scripts_styles();
185
+		//if newsletter message type is active then let's add filter and load js for it.
186
+		if (EEH_MSG_Template::is_mt_active('newsletter')) {
187
+			//enqueue newsletter js
188
+			wp_enqueue_script(
189
+				'ee-newsletter-trigger',
190
+				REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js',
191
+				array('ee-dialog'),
192
+				EVENT_ESPRESSO_VERSION,
193
+				true
194
+			);
195
+			wp_enqueue_style(
196
+				'ee-newsletter-trigger-css',
197
+				REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css',
198
+				array(),
199
+				EVENT_ESPRESSO_VERSION
200
+			);
201
+			//hook in buttons for newsletter message type trigger.
202
+			add_action(
203
+				'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons',
204
+				array($this, 'add_newsletter_action_buttons'),
205
+				10
206
+			);
207
+		}
208
+	}
209 209
 
210 210
 
211
-    /**
212
-     * Scripts and styles for just the reports route.
213
-     */
214
-    public function load_scripts_styles_reports()
215
-    {
216
-        wp_register_script(
217
-            'ee-reg-reports-js',
218
-            REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js',
219
-            array('google-charts'),
220
-            EVENT_ESPRESSO_VERSION,
221
-            true
222
-        );
223
-        wp_enqueue_script('ee-reg-reports-js');
224
-        $this->_registration_reports_js_setup();
225
-    }
211
+	/**
212
+	 * Scripts and styles for just the reports route.
213
+	 */
214
+	public function load_scripts_styles_reports()
215
+	{
216
+		wp_register_script(
217
+			'ee-reg-reports-js',
218
+			REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js',
219
+			array('google-charts'),
220
+			EVENT_ESPRESSO_VERSION,
221
+			true
222
+		);
223
+		wp_enqueue_script('ee-reg-reports-js');
224
+		$this->_registration_reports_js_setup();
225
+	}
226 226
 
227 227
 
228
-    /**
229
-     * Register screen options for event_registrations route.
230
-     */
231
-    protected function _add_screen_options_event_registrations()
232
-    {
233
-        $this->_per_page_screen_option();
234
-    }
228
+	/**
229
+	 * Register screen options for event_registrations route.
230
+	 */
231
+	protected function _add_screen_options_event_registrations()
232
+	{
233
+		$this->_per_page_screen_option();
234
+	}
235 235
 
236 236
 
237
-    /**
238
-     * Register screen options for registration_checkins route
239
-     */
240
-    protected function _add_screen_options_registration_checkins()
241
-    {
242
-        $page_title = $this->_admin_page_title;
243
-        $this->_admin_page_title = esc_html__('Check-In Records', 'event_espresso');
244
-        $this->_per_page_screen_option();
245
-        $this->_admin_page_title = $page_title;
246
-    }
237
+	/**
238
+	 * Register screen options for registration_checkins route
239
+	 */
240
+	protected function _add_screen_options_registration_checkins()
241
+	{
242
+		$page_title = $this->_admin_page_title;
243
+		$this->_admin_page_title = esc_html__('Check-In Records', 'event_espresso');
244
+		$this->_per_page_screen_option();
245
+		$this->_admin_page_title = $page_title;
246
+	}
247 247
 
248 248
 
249
-    /**
250
-     * Set views property for event_registrations route.
251
-     */
252
-    protected function _set_list_table_views_event_registrations()
253
-    {
254
-        $this->_views = array(
255
-            'all' => array(
256
-                'slug'        => 'all',
257
-                'label'       => esc_html__('All', 'event_espresso'),
258
-                'count'       => 0,
259
-                'bulk_action' => ! isset($this->_req_data['event_id'])
260
-                    ? array()
261
-                    : array(
262
-                        'toggle_checkin_status_bulk' => esc_html__('Toggle Check-In', 'event_espresso'),
263
-                    ),
264
-            ),
265
-        );
266
-    }
249
+	/**
250
+	 * Set views property for event_registrations route.
251
+	 */
252
+	protected function _set_list_table_views_event_registrations()
253
+	{
254
+		$this->_views = array(
255
+			'all' => array(
256
+				'slug'        => 'all',
257
+				'label'       => esc_html__('All', 'event_espresso'),
258
+				'count'       => 0,
259
+				'bulk_action' => ! isset($this->_req_data['event_id'])
260
+					? array()
261
+					: array(
262
+						'toggle_checkin_status_bulk' => esc_html__('Toggle Check-In', 'event_espresso'),
263
+					),
264
+			),
265
+		);
266
+	}
267 267
 
268 268
 
269
-    /**
270
-     * Set views property for registration_checkins route.
271
-     */
272
-    protected function _set_list_table_views_registration_checkins()
273
-    {
274
-        $this->_views = array(
275
-            'all' => array(
276
-                'slug'        => 'all',
277
-                'label'       => esc_html__('All', 'event_espresso'),
278
-                'count'       => 0,
279
-                'bulk_action' => array('delete_checkin_rows' => esc_html__('Delete Check-In Rows', 'event_espresso')),
280
-            ),
281
-        );
282
-    }
269
+	/**
270
+	 * Set views property for registration_checkins route.
271
+	 */
272
+	protected function _set_list_table_views_registration_checkins()
273
+	{
274
+		$this->_views = array(
275
+			'all' => array(
276
+				'slug'        => 'all',
277
+				'label'       => esc_html__('All', 'event_espresso'),
278
+				'count'       => 0,
279
+				'bulk_action' => array('delete_checkin_rows' => esc_html__('Delete Check-In Rows', 'event_espresso')),
280
+			),
281
+		);
282
+	}
283 283
 
284 284
 
285
-    /**
286
-     * callback for ajax action.
287
-     *
288
-     * @since 4.3.0
289
-     * @return void (JSON)
290
-     * @throws EE_Error
291
-     * @throws InvalidArgumentException
292
-     * @throws InvalidDataTypeException
293
-     * @throws InvalidInterfaceException
294
-     */
295
-    public function get_newsletter_form_content()
296
-    {
297
-        //do a nonce check cause we're not coming in from an normal route here.
298
-        $nonce = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field(
299
-            $this->_req_data['get_newsletter_form_content_nonce']
300
-        ) : '';
301
-        $nonce_ref = 'get_newsletter_form_content_nonce';
302
-        $this->_verify_nonce($nonce, $nonce_ref);
303
-        //let's get the mtp for the incoming MTP_ ID
304
-        if (! isset($this->_req_data['GRP_ID'])) {
305
-            EE_Error::add_error(
306
-                esc_html__(
307
-                    'There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).',
308
-                    'event_espresso'
309
-                ),
310
-                __FILE__,
311
-                __FUNCTION__,
312
-                __LINE__
313
-            );
314
-            $this->_template_args['success'] = false;
315
-            $this->_template_args['error'] = true;
316
-            $this->_return_json();
317
-        }
318
-        $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']);
319
-        if (! $MTPG instanceof EE_Message_Template_Group) {
320
-            EE_Error::add_error(
321
-                sprintf(
322
-                    esc_html__(
323
-                        'The GRP_ID given (%d) does not appear to have a corresponding row in the database.',
324
-                        'event_espresso'
325
-                    ),
326
-                    $this->_req_data['GRP_ID']
327
-                ),
328
-                __FILE__,
329
-                __FUNCTION__,
330
-                __LINE__
331
-            );
332
-            $this->_template_args['success'] = false;
333
-            $this->_template_args['error'] = true;
334
-            $this->_return_json();
335
-        }
336
-        $MTPs = $MTPG->context_templates();
337
-        $MTPs = $MTPs['attendee'];
338
-        $template_fields = array();
339
-        /** @var EE_Message_Template $MTP */
340
-        foreach ($MTPs as $MTP) {
341
-            $field = $MTP->get('MTP_template_field');
342
-            if ($field === 'content') {
343
-                $content = $MTP->get('MTP_content');
344
-                if (! empty($content['newsletter_content'])) {
345
-                    $template_fields['newsletter_content'] = $content['newsletter_content'];
346
-                }
347
-                continue;
348
-            }
349
-            $template_fields[$MTP->get('MTP_template_field')] = $MTP->get('MTP_content');
350
-        }
351
-        $this->_template_args['success'] = true;
352
-        $this->_template_args['error'] = false;
353
-        $this->_template_args['data'] = array(
354
-            'batch_message_from'    => isset($template_fields['from'])
355
-                ? $template_fields['from']
356
-                : '',
357
-            'batch_message_subject' => isset($template_fields['subject'])
358
-                ? $template_fields['subject']
359
-                : '',
360
-            'batch_message_content' => isset($template_fields['newsletter_content'])
361
-                ? $template_fields['newsletter_content']
362
-                : '',
363
-        );
364
-        $this->_return_json();
365
-    }
285
+	/**
286
+	 * callback for ajax action.
287
+	 *
288
+	 * @since 4.3.0
289
+	 * @return void (JSON)
290
+	 * @throws EE_Error
291
+	 * @throws InvalidArgumentException
292
+	 * @throws InvalidDataTypeException
293
+	 * @throws InvalidInterfaceException
294
+	 */
295
+	public function get_newsletter_form_content()
296
+	{
297
+		//do a nonce check cause we're not coming in from an normal route here.
298
+		$nonce = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field(
299
+			$this->_req_data['get_newsletter_form_content_nonce']
300
+		) : '';
301
+		$nonce_ref = 'get_newsletter_form_content_nonce';
302
+		$this->_verify_nonce($nonce, $nonce_ref);
303
+		//let's get the mtp for the incoming MTP_ ID
304
+		if (! isset($this->_req_data['GRP_ID'])) {
305
+			EE_Error::add_error(
306
+				esc_html__(
307
+					'There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).',
308
+					'event_espresso'
309
+				),
310
+				__FILE__,
311
+				__FUNCTION__,
312
+				__LINE__
313
+			);
314
+			$this->_template_args['success'] = false;
315
+			$this->_template_args['error'] = true;
316
+			$this->_return_json();
317
+		}
318
+		$MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']);
319
+		if (! $MTPG instanceof EE_Message_Template_Group) {
320
+			EE_Error::add_error(
321
+				sprintf(
322
+					esc_html__(
323
+						'The GRP_ID given (%d) does not appear to have a corresponding row in the database.',
324
+						'event_espresso'
325
+					),
326
+					$this->_req_data['GRP_ID']
327
+				),
328
+				__FILE__,
329
+				__FUNCTION__,
330
+				__LINE__
331
+			);
332
+			$this->_template_args['success'] = false;
333
+			$this->_template_args['error'] = true;
334
+			$this->_return_json();
335
+		}
336
+		$MTPs = $MTPG->context_templates();
337
+		$MTPs = $MTPs['attendee'];
338
+		$template_fields = array();
339
+		/** @var EE_Message_Template $MTP */
340
+		foreach ($MTPs as $MTP) {
341
+			$field = $MTP->get('MTP_template_field');
342
+			if ($field === 'content') {
343
+				$content = $MTP->get('MTP_content');
344
+				if (! empty($content['newsletter_content'])) {
345
+					$template_fields['newsletter_content'] = $content['newsletter_content'];
346
+				}
347
+				continue;
348
+			}
349
+			$template_fields[$MTP->get('MTP_template_field')] = $MTP->get('MTP_content');
350
+		}
351
+		$this->_template_args['success'] = true;
352
+		$this->_template_args['error'] = false;
353
+		$this->_template_args['data'] = array(
354
+			'batch_message_from'    => isset($template_fields['from'])
355
+				? $template_fields['from']
356
+				: '',
357
+			'batch_message_subject' => isset($template_fields['subject'])
358
+				? $template_fields['subject']
359
+				: '',
360
+			'batch_message_content' => isset($template_fields['newsletter_content'])
361
+				? $template_fields['newsletter_content']
362
+				: '',
363
+		);
364
+		$this->_return_json();
365
+	}
366 366
 
367 367
 
368
-    /**
369
-     * callback for AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons action
370
-     *
371
-     * @since 4.3.0
372
-     * @param EE_Admin_List_Table $list_table
373
-     * @return void
374
-     * @throws InvalidArgumentException
375
-     * @throws InvalidDataTypeException
376
-     * @throws InvalidInterfaceException
377
-     */
378
-    public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table)
379
-    {
380
-        if (! EE_Registry::instance()->CAP->current_user_can(
381
-            'ee_send_message',
382
-            'espresso_registrations_newsletter_selected_send'
383
-        )
384
-        ) {
385
-            return;
386
-        }
387
-        $routes_to_add_to = array(
388
-            'contact_list',
389
-            'event_registrations',
390
-            'default',
391
-        );
392
-        if ($this->_current_page === 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) {
393
-            if (($this->_req_action === 'event_registrations' && empty($this->_req_data['event_id']))
394
-                || (isset($this->_req_data['status']) && $this->_req_data['status'] === 'trash')
395
-            ) {
396
-                echo '';
397
-            } else {
398
-                $button_text = sprintf(
399
-                    esc_html__('Send Batch Message (%s selected)', 'event_espresso'),
400
-                    '<span class="send-selected-newsletter-count">0</span>'
401
-                );
402
-                echo '<button id="selected-batch-send-trigger" class="button secondary-button">'
403
-                     . '<span class="dashicons dashicons-email "></span>'
404
-                     . $button_text
405
-                     . '</button>';
406
-                add_action('admin_footer', array($this, 'newsletter_send_form_skeleton'));
407
-            }
408
-        }
409
-    }
368
+	/**
369
+	 * callback for AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons action
370
+	 *
371
+	 * @since 4.3.0
372
+	 * @param EE_Admin_List_Table $list_table
373
+	 * @return void
374
+	 * @throws InvalidArgumentException
375
+	 * @throws InvalidDataTypeException
376
+	 * @throws InvalidInterfaceException
377
+	 */
378
+	public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table)
379
+	{
380
+		if (! EE_Registry::instance()->CAP->current_user_can(
381
+			'ee_send_message',
382
+			'espresso_registrations_newsletter_selected_send'
383
+		)
384
+		) {
385
+			return;
386
+		}
387
+		$routes_to_add_to = array(
388
+			'contact_list',
389
+			'event_registrations',
390
+			'default',
391
+		);
392
+		if ($this->_current_page === 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) {
393
+			if (($this->_req_action === 'event_registrations' && empty($this->_req_data['event_id']))
394
+				|| (isset($this->_req_data['status']) && $this->_req_data['status'] === 'trash')
395
+			) {
396
+				echo '';
397
+			} else {
398
+				$button_text = sprintf(
399
+					esc_html__('Send Batch Message (%s selected)', 'event_espresso'),
400
+					'<span class="send-selected-newsletter-count">0</span>'
401
+				);
402
+				echo '<button id="selected-batch-send-trigger" class="button secondary-button">'
403
+					 . '<span class="dashicons dashicons-email "></span>'
404
+					 . $button_text
405
+					 . '</button>';
406
+				add_action('admin_footer', array($this, 'newsletter_send_form_skeleton'));
407
+			}
408
+		}
409
+	}
410 410
 
411 411
 
412
-    /**
413
-     * @throws DomainException
414
-     * @throws EE_Error
415
-     * @throws InvalidArgumentException
416
-     * @throws InvalidDataTypeException
417
-     * @throws InvalidInterfaceException
418
-     */
419
-    public function newsletter_send_form_skeleton()
420
-    {
421
-        $list_table = $this->_list_table_object;
422
-        $codes = array();
423
-        //need to templates for the newsletter message type for the template selector.
424
-        $values[] = array('text' => esc_html__('Select Template to Use', 'event_espresso'), 'id' => 0);
425
-        $mtps = EEM_Message_Template_Group::instance()->get_all(
426
-            array(array('MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email'))
427
-        );
428
-        foreach ($mtps as $mtp) {
429
-            $name = $mtp->name();
430
-            $values[] = array(
431
-                'text' => empty($name) ? esc_html__('Global', 'event_espresso') : $name,
432
-                'id'   => $mtp->ID(),
433
-            );
434
-        }
435
-        //need to get a list of shortcodes that are available for the newsletter message type.
436
-        $shortcodes = EEH_MSG_Template::get_shortcodes(
437
-            'newsletter',
438
-            'email',
439
-            array(),
440
-            'attendee',
441
-            false
442
-        );
443
-        foreach ($shortcodes as $field => $shortcode_array) {
444
-            $available_shortcodes = array();
445
-            foreach ($shortcode_array as $shortcode => $shortcode_details) {
446
-                $field_id = $field === '[NEWSLETTER_CONTENT]'
447
-                    ? 'content'
448
-                    : $field;
449
-                $field_id = 'batch-message-' . strtolower($field_id);
450
-                $available_shortcodes[] = '<span class="js-shortcode-selection" data-value="'
451
-                                          . $shortcode
452
-                                          . '" data-linked-input-id="' . $field_id . '">'
453
-                                          . $shortcode
454
-                                          . '</span>';
455
-            }
456
-            $codes[$field] = implode(', ', $available_shortcodes);
457
-        }
458
-        $shortcodes = $codes;
459
-        $form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php';
460
-        $form_template_args = array(
461
-            'form_action'       => admin_url('admin.php?page=espresso_registrations'),
462
-            'form_route'        => 'newsletter_selected_send',
463
-            'form_nonce_name'   => 'newsletter_selected_send_nonce',
464
-            'form_nonce'        => wp_create_nonce('newsletter_selected_send_nonce'),
465
-            'redirect_back_to'  => $this->_req_action,
466
-            'ajax_nonce'        => wp_create_nonce('get_newsletter_form_content_nonce'),
467
-            'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values),
468
-            'shortcodes'        => $shortcodes,
469
-            'id_type'           => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration',
470
-        );
471
-        EEH_Template::display_template($form_template, $form_template_args);
472
-    }
412
+	/**
413
+	 * @throws DomainException
414
+	 * @throws EE_Error
415
+	 * @throws InvalidArgumentException
416
+	 * @throws InvalidDataTypeException
417
+	 * @throws InvalidInterfaceException
418
+	 */
419
+	public function newsletter_send_form_skeleton()
420
+	{
421
+		$list_table = $this->_list_table_object;
422
+		$codes = array();
423
+		//need to templates for the newsletter message type for the template selector.
424
+		$values[] = array('text' => esc_html__('Select Template to Use', 'event_espresso'), 'id' => 0);
425
+		$mtps = EEM_Message_Template_Group::instance()->get_all(
426
+			array(array('MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email'))
427
+		);
428
+		foreach ($mtps as $mtp) {
429
+			$name = $mtp->name();
430
+			$values[] = array(
431
+				'text' => empty($name) ? esc_html__('Global', 'event_espresso') : $name,
432
+				'id'   => $mtp->ID(),
433
+			);
434
+		}
435
+		//need to get a list of shortcodes that are available for the newsletter message type.
436
+		$shortcodes = EEH_MSG_Template::get_shortcodes(
437
+			'newsletter',
438
+			'email',
439
+			array(),
440
+			'attendee',
441
+			false
442
+		);
443
+		foreach ($shortcodes as $field => $shortcode_array) {
444
+			$available_shortcodes = array();
445
+			foreach ($shortcode_array as $shortcode => $shortcode_details) {
446
+				$field_id = $field === '[NEWSLETTER_CONTENT]'
447
+					? 'content'
448
+					: $field;
449
+				$field_id = 'batch-message-' . strtolower($field_id);
450
+				$available_shortcodes[] = '<span class="js-shortcode-selection" data-value="'
451
+										  . $shortcode
452
+										  . '" data-linked-input-id="' . $field_id . '">'
453
+										  . $shortcode
454
+										  . '</span>';
455
+			}
456
+			$codes[$field] = implode(', ', $available_shortcodes);
457
+		}
458
+		$shortcodes = $codes;
459
+		$form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php';
460
+		$form_template_args = array(
461
+			'form_action'       => admin_url('admin.php?page=espresso_registrations'),
462
+			'form_route'        => 'newsletter_selected_send',
463
+			'form_nonce_name'   => 'newsletter_selected_send_nonce',
464
+			'form_nonce'        => wp_create_nonce('newsletter_selected_send_nonce'),
465
+			'redirect_back_to'  => $this->_req_action,
466
+			'ajax_nonce'        => wp_create_nonce('get_newsletter_form_content_nonce'),
467
+			'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values),
468
+			'shortcodes'        => $shortcodes,
469
+			'id_type'           => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration',
470
+		);
471
+		EEH_Template::display_template($form_template, $form_template_args);
472
+	}
473 473
 
474 474
 
475
-    /**
476
-     * Handles sending selected registrations/contacts a newsletter.
477
-     *
478
-     * @since  4.3.0
479
-     * @return void
480
-     * @throws EE_Error
481
-     * @throws InvalidArgumentException
482
-     * @throws InvalidDataTypeException
483
-     * @throws InvalidInterfaceException
484
-     */
485
-    protected function _newsletter_selected_send()
486
-    {
487
-        $success = true;
488
-        //first we need to make sure we have a GRP_ID so we know what template we're sending and updating!
489
-        if (empty($this->_req_data['newsletter_mtp_selected'])) {
490
-            EE_Error::add_error(
491
-                esc_html__(
492
-                    'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.',
493
-                    'event_espresso'
494
-                ),
495
-                __FILE__,
496
-                __FUNCTION__,
497
-                __LINE__
498
-            );
499
-            $success = false;
500
-        }
501
-        if ($success) {
502
-            //update Message template in case there are any changes
503
-            $Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID(
504
-                $this->_req_data['newsletter_mtp_selected']
505
-            );
506
-            $Message_Templates = $Message_Template_Group instanceof EE_Message_Template_Group
507
-                ? $Message_Template_Group->context_templates()
508
-                : array();
509
-            if (empty($Message_Templates)) {
510
-                EE_Error::add_error(
511
-                    esc_html__(
512
-                        'Unable to retrieve message template fields from the db. Messages not sent.',
513
-                        'event_espresso'
514
-                    ),
515
-                    __FILE__,
516
-                    __FUNCTION__,
517
-                    __LINE__
518
-                );
519
-            }
520
-            //let's just update the specific fields
521
-            foreach ($Message_Templates['attendee'] as $Message_Template) {
522
-                if ($Message_Template instanceof EE_Message_Template) {
523
-                    $field = $Message_Template->get('MTP_template_field');
524
-                    $content = $Message_Template->get('MTP_content');
525
-                    $new_content = $content;
526
-                    switch ($field) {
527
-                        case 'from':
528
-                            $new_content = ! empty($this->_req_data['batch_message']['from'])
529
-                                ? $this->_req_data['batch_message']['from']
530
-                                : $content;
531
-                            break;
532
-                        case 'subject':
533
-                            $new_content = ! empty($this->_req_data['batch_message']['subject'])
534
-                                ? $this->_req_data['batch_message']['subject']
535
-                                : $content;
536
-                            break;
537
-                        case 'content':
538
-                            $new_content = $content;
539
-                            $new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content'])
540
-                                ? $this->_req_data['batch_message']['content']
541
-                                : $content['newsletter_content'];
542
-                            break;
543
-                        default:
544
-                            //continue the foreach loop, we don't want to set $new_content nor save.
545
-                            continue 2;
546
-                    }
547
-                    $Message_Template->set('MTP_content', $new_content);
548
-                    $Message_Template->save();
549
-                }
550
-            }
551
-            //great fields are updated!  now let's make sure we just have contact objects (EE_Attendee).
552
-            $id_type = ! empty($this->_req_data['batch_message']['id_type'])
553
-                ? $this->_req_data['batch_message']['id_type']
554
-                : 'registration';
555
-            //id_type will affect how we assemble the ids.
556
-            $ids = ! empty($this->_req_data['batch_message']['ids'])
557
-                ? json_decode(stripslashes($this->_req_data['batch_message']['ids']))
558
-                : array();
559
-            $registrations_used_for_contact_data = array();
560
-            //using switch because eventually we'll have other contexts that will be used for generating messages.
561
-            switch ($id_type) {
562
-                case 'registration':
563
-                    $registrations_used_for_contact_data = EEM_Registration::instance()->get_all(
564
-                        array(
565
-                            array(
566
-                                'REG_ID' => array('IN', $ids),
567
-                            ),
568
-                        )
569
-                    );
570
-                    break;
571
-                case 'contact':
572
-                    $registrations_used_for_contact_data = EEM_Registration::instance()
573
-                        ->get_latest_registration_for_each_of_given_contacts($ids);
574
-                    break;
575
-            }
576
-            do_action_ref_array(
577
-                'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations',
578
-                array(
579
-                    $registrations_used_for_contact_data,
580
-                    $Message_Template_Group->ID()
581
-                )
582
-            );
583
-            //kept for backward compat, internally we no longer use this action.
584
-            //@deprecated 4.8.36.rc.002
585
-            $contacts = $id_type === 'registration'
586
-                ? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids)
587
-                : EEM_Attendee::instance()->get_all(array(array('ATT_ID' => array('in', $ids))));
588
-            do_action_ref_array(
589
-                'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send',
590
-                array(
591
-                    $contacts,
592
-                    $Message_Template_Group->ID()
593
-                )
594
-            );
595
-        }
596
-        $query_args = array(
597
-            'action' => ! empty($this->_req_data['redirect_back_to'])
598
-                ? $this->_req_data['redirect_back_to']
599
-                : 'default',
600
-        );
601
-        $this->_redirect_after_action(false, '', '', $query_args, true);
602
-    }
475
+	/**
476
+	 * Handles sending selected registrations/contacts a newsletter.
477
+	 *
478
+	 * @since  4.3.0
479
+	 * @return void
480
+	 * @throws EE_Error
481
+	 * @throws InvalidArgumentException
482
+	 * @throws InvalidDataTypeException
483
+	 * @throws InvalidInterfaceException
484
+	 */
485
+	protected function _newsletter_selected_send()
486
+	{
487
+		$success = true;
488
+		//first we need to make sure we have a GRP_ID so we know what template we're sending and updating!
489
+		if (empty($this->_req_data['newsletter_mtp_selected'])) {
490
+			EE_Error::add_error(
491
+				esc_html__(
492
+					'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.',
493
+					'event_espresso'
494
+				),
495
+				__FILE__,
496
+				__FUNCTION__,
497
+				__LINE__
498
+			);
499
+			$success = false;
500
+		}
501
+		if ($success) {
502
+			//update Message template in case there are any changes
503
+			$Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID(
504
+				$this->_req_data['newsletter_mtp_selected']
505
+			);
506
+			$Message_Templates = $Message_Template_Group instanceof EE_Message_Template_Group
507
+				? $Message_Template_Group->context_templates()
508
+				: array();
509
+			if (empty($Message_Templates)) {
510
+				EE_Error::add_error(
511
+					esc_html__(
512
+						'Unable to retrieve message template fields from the db. Messages not sent.',
513
+						'event_espresso'
514
+					),
515
+					__FILE__,
516
+					__FUNCTION__,
517
+					__LINE__
518
+				);
519
+			}
520
+			//let's just update the specific fields
521
+			foreach ($Message_Templates['attendee'] as $Message_Template) {
522
+				if ($Message_Template instanceof EE_Message_Template) {
523
+					$field = $Message_Template->get('MTP_template_field');
524
+					$content = $Message_Template->get('MTP_content');
525
+					$new_content = $content;
526
+					switch ($field) {
527
+						case 'from':
528
+							$new_content = ! empty($this->_req_data['batch_message']['from'])
529
+								? $this->_req_data['batch_message']['from']
530
+								: $content;
531
+							break;
532
+						case 'subject':
533
+							$new_content = ! empty($this->_req_data['batch_message']['subject'])
534
+								? $this->_req_data['batch_message']['subject']
535
+								: $content;
536
+							break;
537
+						case 'content':
538
+							$new_content = $content;
539
+							$new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content'])
540
+								? $this->_req_data['batch_message']['content']
541
+								: $content['newsletter_content'];
542
+							break;
543
+						default:
544
+							//continue the foreach loop, we don't want to set $new_content nor save.
545
+							continue 2;
546
+					}
547
+					$Message_Template->set('MTP_content', $new_content);
548
+					$Message_Template->save();
549
+				}
550
+			}
551
+			//great fields are updated!  now let's make sure we just have contact objects (EE_Attendee).
552
+			$id_type = ! empty($this->_req_data['batch_message']['id_type'])
553
+				? $this->_req_data['batch_message']['id_type']
554
+				: 'registration';
555
+			//id_type will affect how we assemble the ids.
556
+			$ids = ! empty($this->_req_data['batch_message']['ids'])
557
+				? json_decode(stripslashes($this->_req_data['batch_message']['ids']))
558
+				: array();
559
+			$registrations_used_for_contact_data = array();
560
+			//using switch because eventually we'll have other contexts that will be used for generating messages.
561
+			switch ($id_type) {
562
+				case 'registration':
563
+					$registrations_used_for_contact_data = EEM_Registration::instance()->get_all(
564
+						array(
565
+							array(
566
+								'REG_ID' => array('IN', $ids),
567
+							),
568
+						)
569
+					);
570
+					break;
571
+				case 'contact':
572
+					$registrations_used_for_contact_data = EEM_Registration::instance()
573
+						->get_latest_registration_for_each_of_given_contacts($ids);
574
+					break;
575
+			}
576
+			do_action_ref_array(
577
+				'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations',
578
+				array(
579
+					$registrations_used_for_contact_data,
580
+					$Message_Template_Group->ID()
581
+				)
582
+			);
583
+			//kept for backward compat, internally we no longer use this action.
584
+			//@deprecated 4.8.36.rc.002
585
+			$contacts = $id_type === 'registration'
586
+				? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids)
587
+				: EEM_Attendee::instance()->get_all(array(array('ATT_ID' => array('in', $ids))));
588
+			do_action_ref_array(
589
+				'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send',
590
+				array(
591
+					$contacts,
592
+					$Message_Template_Group->ID()
593
+				)
594
+			);
595
+		}
596
+		$query_args = array(
597
+			'action' => ! empty($this->_req_data['redirect_back_to'])
598
+				? $this->_req_data['redirect_back_to']
599
+				: 'default',
600
+		);
601
+		$this->_redirect_after_action(false, '', '', $query_args, true);
602
+	}
603 603
 
604 604
 
605 605
 
606
-    /**
607
-     * This is called when javascript is being enqueued to setup the various data needed for the reports js.
608
-     * Also $this->{$_reports_template_data} property is set for later usage by the _registration_reports method.
609
-     */
610
-    protected function _registration_reports_js_setup()
611
-    {
612
-        $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_day_report();
613
-        $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_event_report();
614
-    }
606
+	/**
607
+	 * This is called when javascript is being enqueued to setup the various data needed for the reports js.
608
+	 * Also $this->{$_reports_template_data} property is set for later usage by the _registration_reports method.
609
+	 */
610
+	protected function _registration_reports_js_setup()
611
+	{
612
+		$this->_reports_template_data['admin_reports'][] = $this->_registrations_per_day_report();
613
+		$this->_reports_template_data['admin_reports'][] = $this->_registrations_per_event_report();
614
+	}
615 615
 
616 616
 
617
-    /**
618
-     *        generates Business Reports regarding Registrations
619
-     *
620
-     * @access protected
621
-     * @return void
622
-     * @throws DomainException
623
-     */
624
-    protected function _registration_reports()
625
-    {
626
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php';
627
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
628
-            $template_path,
629
-            $this->_reports_template_data,
630
-            true
631
-        );
632
-        // the final template wrapper
633
-        $this->display_admin_page_with_no_sidebar();
634
-    }
617
+	/**
618
+	 *        generates Business Reports regarding Registrations
619
+	 *
620
+	 * @access protected
621
+	 * @return void
622
+	 * @throws DomainException
623
+	 */
624
+	protected function _registration_reports()
625
+	{
626
+		$template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php';
627
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
628
+			$template_path,
629
+			$this->_reports_template_data,
630
+			true
631
+		);
632
+		// the final template wrapper
633
+		$this->display_admin_page_with_no_sidebar();
634
+	}
635 635
 
636 636
 
637
-    /**
638
-     * Generates Business Report showing total registrations per day.
639
-     *
640
-     * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
641
-     * @return string
642
-     * @throws EE_Error
643
-     * @throws InvalidArgumentException
644
-     * @throws InvalidDataTypeException
645
-     * @throws InvalidInterfaceException
646
-     */
647
-    private function _registrations_per_day_report($period = '-1 month')
648
-    {
649
-        $report_ID = 'reg-admin-registrations-per-day-report-dv';
650
-        $results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period);
651
-        $results = (array)$results;
652
-        $regs = array();
653
-        $subtitle = '';
654
-        if ($results) {
655
-            $column_titles = array();
656
-            $tracker = 0;
657
-            foreach ($results as $result) {
658
-                $report_column_values = array();
659
-                foreach ($result as $property_name => $property_value) {
660
-                    $property_value = $property_name === 'Registration_REG_date' ? $property_value
661
-                        : (int)$property_value;
662
-                    $report_column_values[] = $property_value;
663
-                    if ($tracker === 0) {
664
-                        if ($property_name === 'Registration_REG_date') {
665
-                            $column_titles[] = esc_html__('Date (only days with registrations are shown)', 'event_espresso');
666
-                        } else {
667
-                            $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence');
668
-                        }
669
-                    }
670
-                }
671
-                $tracker++;
672
-                $regs[] = $report_column_values;
673
-            }
674
-            //make sure the column_titles is pushed to the beginning of the array
675
-            array_unshift($regs, $column_titles);
676
-            //setup the date range.
677
-            $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
678
-            $beginning_date = new DateTime("now " . $period, $DateTimeZone);
679
-            $ending_date = new DateTime("now", $DateTimeZone);
680
-            $subtitle = sprintf(
681
-                _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'),
682
-                $beginning_date->format('Y-m-d'),
683
-                $ending_date->format('Y-m-d')
684
-            );
685
-        }
686
-        $report_title = esc_html__('Total Registrations per Day', 'event_espresso');
687
-        $report_params = array(
688
-            'title'     => $report_title,
689
-            'subtitle'  => $subtitle,
690
-            'id'        => $report_ID,
691
-            'regs'      => $regs,
692
-            'noResults' => empty($regs),
693
-            'noRegsMsg' => sprintf(
694
-                esc_html__(
695
-                    '%sThere are currently no registration records in the last month for this report.%s',
696
-                    'event_espresso'
697
-                ),
698
-                '<h2>' . $report_title . '</h2><p>',
699
-                '</p>'
700
-            ),
701
-        );
702
-        wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params);
703
-        return $report_ID;
704
-    }
637
+	/**
638
+	 * Generates Business Report showing total registrations per day.
639
+	 *
640
+	 * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
641
+	 * @return string
642
+	 * @throws EE_Error
643
+	 * @throws InvalidArgumentException
644
+	 * @throws InvalidDataTypeException
645
+	 * @throws InvalidInterfaceException
646
+	 */
647
+	private function _registrations_per_day_report($period = '-1 month')
648
+	{
649
+		$report_ID = 'reg-admin-registrations-per-day-report-dv';
650
+		$results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period);
651
+		$results = (array)$results;
652
+		$regs = array();
653
+		$subtitle = '';
654
+		if ($results) {
655
+			$column_titles = array();
656
+			$tracker = 0;
657
+			foreach ($results as $result) {
658
+				$report_column_values = array();
659
+				foreach ($result as $property_name => $property_value) {
660
+					$property_value = $property_name === 'Registration_REG_date' ? $property_value
661
+						: (int)$property_value;
662
+					$report_column_values[] = $property_value;
663
+					if ($tracker === 0) {
664
+						if ($property_name === 'Registration_REG_date') {
665
+							$column_titles[] = esc_html__('Date (only days with registrations are shown)', 'event_espresso');
666
+						} else {
667
+							$column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence');
668
+						}
669
+					}
670
+				}
671
+				$tracker++;
672
+				$regs[] = $report_column_values;
673
+			}
674
+			//make sure the column_titles is pushed to the beginning of the array
675
+			array_unshift($regs, $column_titles);
676
+			//setup the date range.
677
+			$DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
678
+			$beginning_date = new DateTime("now " . $period, $DateTimeZone);
679
+			$ending_date = new DateTime("now", $DateTimeZone);
680
+			$subtitle = sprintf(
681
+				_x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'),
682
+				$beginning_date->format('Y-m-d'),
683
+				$ending_date->format('Y-m-d')
684
+			);
685
+		}
686
+		$report_title = esc_html__('Total Registrations per Day', 'event_espresso');
687
+		$report_params = array(
688
+			'title'     => $report_title,
689
+			'subtitle'  => $subtitle,
690
+			'id'        => $report_ID,
691
+			'regs'      => $regs,
692
+			'noResults' => empty($regs),
693
+			'noRegsMsg' => sprintf(
694
+				esc_html__(
695
+					'%sThere are currently no registration records in the last month for this report.%s',
696
+					'event_espresso'
697
+				),
698
+				'<h2>' . $report_title . '</h2><p>',
699
+				'</p>'
700
+			),
701
+		);
702
+		wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params);
703
+		return $report_ID;
704
+	}
705 705
 
706 706
 
707
-    /**
708
-     * Generates Business Report showing total registrations per event.
709
-     *
710
-     * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
711
-     * @return string
712
-     * @throws EE_Error
713
-     * @throws InvalidArgumentException
714
-     * @throws InvalidDataTypeException
715
-     * @throws InvalidInterfaceException
716
-     */
717
-    private function _registrations_per_event_report($period = '-1 month')
718
-    {
719
-        $report_ID = 'reg-admin-registrations-per-event-report-dv';
720
-        $results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period);
721
-        $results = (array)$results;
722
-        $regs = array();
723
-        $subtitle = '';
724
-        if ($results) {
725
-            $column_titles = array();
726
-            $tracker = 0;
727
-            foreach ($results as $result) {
728
-                $report_column_values = array();
729
-                foreach ($result as $property_name => $property_value) {
730
-                    $property_value = $property_name === 'Registration_Event' ? wp_trim_words(
731
-                        $property_value,
732
-                        4,
733
-                        '...'
734
-                    ) : (int)$property_value;
735
-                    $report_column_values[] = $property_value;
736
-                    if ($tracker === 0) {
737
-                        if ($property_name === 'Registration_Event') {
738
-                            $column_titles[] = esc_html__('Event', 'event_espresso');
739
-                        } else {
740
-                            $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence');
741
-                        }
742
-                    }
743
-                }
744
-                $tracker++;
745
-                $regs[] = $report_column_values;
746
-            }
747
-            //make sure the column_titles is pushed to the beginning of the array
748
-            array_unshift($regs, $column_titles);
749
-            //setup the date range.
750
-            $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
751
-            $beginning_date = new DateTime("now " . $period, $DateTimeZone);
752
-            $ending_date = new DateTime("now", $DateTimeZone);
753
-            $subtitle = sprintf(
754
-                _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'),
755
-                $beginning_date->format('Y-m-d'),
756
-                $ending_date->format('Y-m-d')
757
-            );
758
-        }
759
-        $report_title = esc_html__('Total Registrations per Event', 'event_espresso');
760
-        $report_params = array(
761
-            'title'     => $report_title,
762
-            'subtitle'  => $subtitle,
763
-            'id'        => $report_ID,
764
-            'regs'      => $regs,
765
-            'noResults' => empty($regs),
766
-            'noRegsMsg' => sprintf(
767
-                esc_html__(
768
-                    '%sThere are currently no registration records in the last month for this report.%s',
769
-                    'event_espresso'
770
-                ),
771
-                '<h2>' . $report_title . '</h2><p>',
772
-                '</p>'
773
-            ),
774
-        );
775
-        wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params);
776
-        return $report_ID;
777
-    }
707
+	/**
708
+	 * Generates Business Report showing total registrations per event.
709
+	 *
710
+	 * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
711
+	 * @return string
712
+	 * @throws EE_Error
713
+	 * @throws InvalidArgumentException
714
+	 * @throws InvalidDataTypeException
715
+	 * @throws InvalidInterfaceException
716
+	 */
717
+	private function _registrations_per_event_report($period = '-1 month')
718
+	{
719
+		$report_ID = 'reg-admin-registrations-per-event-report-dv';
720
+		$results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period);
721
+		$results = (array)$results;
722
+		$regs = array();
723
+		$subtitle = '';
724
+		if ($results) {
725
+			$column_titles = array();
726
+			$tracker = 0;
727
+			foreach ($results as $result) {
728
+				$report_column_values = array();
729
+				foreach ($result as $property_name => $property_value) {
730
+					$property_value = $property_name === 'Registration_Event' ? wp_trim_words(
731
+						$property_value,
732
+						4,
733
+						'...'
734
+					) : (int)$property_value;
735
+					$report_column_values[] = $property_value;
736
+					if ($tracker === 0) {
737
+						if ($property_name === 'Registration_Event') {
738
+							$column_titles[] = esc_html__('Event', 'event_espresso');
739
+						} else {
740
+							$column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence');
741
+						}
742
+					}
743
+				}
744
+				$tracker++;
745
+				$regs[] = $report_column_values;
746
+			}
747
+			//make sure the column_titles is pushed to the beginning of the array
748
+			array_unshift($regs, $column_titles);
749
+			//setup the date range.
750
+			$DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
751
+			$beginning_date = new DateTime("now " . $period, $DateTimeZone);
752
+			$ending_date = new DateTime("now", $DateTimeZone);
753
+			$subtitle = sprintf(
754
+				_x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'),
755
+				$beginning_date->format('Y-m-d'),
756
+				$ending_date->format('Y-m-d')
757
+			);
758
+		}
759
+		$report_title = esc_html__('Total Registrations per Event', 'event_espresso');
760
+		$report_params = array(
761
+			'title'     => $report_title,
762
+			'subtitle'  => $subtitle,
763
+			'id'        => $report_ID,
764
+			'regs'      => $regs,
765
+			'noResults' => empty($regs),
766
+			'noRegsMsg' => sprintf(
767
+				esc_html__(
768
+					'%sThere are currently no registration records in the last month for this report.%s',
769
+					'event_espresso'
770
+				),
771
+				'<h2>' . $report_title . '</h2><p>',
772
+				'</p>'
773
+			),
774
+		);
775
+		wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params);
776
+		return $report_ID;
777
+	}
778 778
 
779 779
 
780
-    /**
781
-     * generates HTML for the Registration Check-in list table (showing all Check-ins for a specific registration)
782
-     *
783
-     * @access protected
784
-     * @return void
785
-     * @throws EE_Error
786
-     * @throws InvalidArgumentException
787
-     * @throws InvalidDataTypeException
788
-     * @throws InvalidInterfaceException
789
-     * @throws \EventEspresso\core\exceptions\EntityNotFoundException
790
-     */
791
-    protected function _registration_checkin_list_table()
792
-    {
793
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
794
-        $reg_id = isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : null;
795
-        /** @var EE_Registration $registration */
796
-        $registration = EEM_Registration::instance()->get_one_by_ID($reg_id);
797
-        $attendee = $registration->attendee();
798
-        $this->_admin_page_title .= $this->get_action_link_or_button(
799
-            'new_registration',
800
-            'add-registrant',
801
-            array('event_id' => $registration->event_ID()),
802
-            'add-new-h2'
803
-        );
804
-        $checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in);
805
-        $checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out);
806
-        $legend_items = array(
807
-            'checkin'  => array(
808
-                'class' => $checked_in->cssClasses(),
809
-                'desc'  => $checked_in->legendLabel(),
810
-            ),
811
-            'checkout' => array(
812
-                'class' => $checked_out->cssClasses(),
813
-                'desc'  => $checked_out->legendLabel(),
814
-            ),
815
-        );
816
-        $this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
817
-        $dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null;
818
-        /** @var EE_Datetime $datetime */
819
-        $datetime = EEM_Datetime::instance()->get_one_by_ID($dtt_id);
820
-        $datetime_label = '';
821
-        if ($datetime instanceof EE_Datetime) {
822
-            $datetime_label = $datetime->get_dtt_display_name(true);
823
-            $datetime_label .= ! empty($datetime_label)
824
-                ? ' (' . $datetime->get_dtt_display_name() . ')'
825
-                : $datetime->get_dtt_display_name();
826
-        }
827
-        $datetime_link = ! empty($dtt_id) && $registration instanceof EE_Registration
828
-            ? EE_Admin_Page::add_query_args_and_nonce(
829
-                array(
830
-                    'action'   => 'event_registrations',
831
-                    'event_id' => $registration->event_ID(),
832
-                    'DTT_ID'   => $dtt_id,
833
-                ),
834
-                $this->_admin_base_url
835
-            )
836
-            : '';
837
-        $datetime_link = ! empty($datetime_link)
838
-            ? '<a href="' . $datetime_link . '">'
839
-              . '<span id="checkin-dtt">'
840
-              . $datetime_label
841
-              . '</span></a>'
842
-            : $datetime_label;
843
-        $attendee_name = $attendee instanceof EE_Attendee
844
-            ? $attendee->full_name()
845
-            : '';
846
-        $attendee_link = $attendee instanceof EE_Attendee
847
-            ? $attendee->get_admin_details_link()
848
-            : '';
849
-        $attendee_link = ! empty($attendee_link)
850
-            ? '<a href="' . $attendee->get_admin_details_link() . '"'
851
-              . ' title="' . esc_html__('Click for attendee details', 'event_espresso') . '">'
852
-              . '<span id="checkin-attendee-name">'
853
-              . $attendee_name
854
-              . '</span></a>'
855
-            : '';
856
-        $event_link = $registration->event() instanceof EE_Event
857
-            ? $registration->event()->get_admin_details_link()
858
-            : '';
859
-        $event_link = ! empty($event_link)
860
-            ? '<a href="' . $event_link . '"'
861
-              . ' title="' . esc_html__('Click here to edit event.', 'event_espresso') . '">'
862
-              . '<span id="checkin-event-name">'
863
-              . $registration->event_name()
864
-              . '</span>'
865
-              . '</a>'
866
-            : '';
867
-        $this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id)
868
-            ? '<h2>' . sprintf(
869
-                esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'),
870
-                $attendee_link,
871
-                $datetime_link,
872
-                $event_link
873
-            ) . '</h2>'
874
-            : '';
875
-        $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id)
876
-            ? '<input type="hidden" name="_REG_ID" value="' . $reg_id . '">' : '';
877
-        $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id)
878
-            ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : '';
879
-        $this->display_admin_list_table_page_with_no_sidebar();
880
-    }
780
+	/**
781
+	 * generates HTML for the Registration Check-in list table (showing all Check-ins for a specific registration)
782
+	 *
783
+	 * @access protected
784
+	 * @return void
785
+	 * @throws EE_Error
786
+	 * @throws InvalidArgumentException
787
+	 * @throws InvalidDataTypeException
788
+	 * @throws InvalidInterfaceException
789
+	 * @throws \EventEspresso\core\exceptions\EntityNotFoundException
790
+	 */
791
+	protected function _registration_checkin_list_table()
792
+	{
793
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
794
+		$reg_id = isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : null;
795
+		/** @var EE_Registration $registration */
796
+		$registration = EEM_Registration::instance()->get_one_by_ID($reg_id);
797
+		$attendee = $registration->attendee();
798
+		$this->_admin_page_title .= $this->get_action_link_or_button(
799
+			'new_registration',
800
+			'add-registrant',
801
+			array('event_id' => $registration->event_ID()),
802
+			'add-new-h2'
803
+		);
804
+		$checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in);
805
+		$checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out);
806
+		$legend_items = array(
807
+			'checkin'  => array(
808
+				'class' => $checked_in->cssClasses(),
809
+				'desc'  => $checked_in->legendLabel(),
810
+			),
811
+			'checkout' => array(
812
+				'class' => $checked_out->cssClasses(),
813
+				'desc'  => $checked_out->legendLabel(),
814
+			),
815
+		);
816
+		$this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
817
+		$dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null;
818
+		/** @var EE_Datetime $datetime */
819
+		$datetime = EEM_Datetime::instance()->get_one_by_ID($dtt_id);
820
+		$datetime_label = '';
821
+		if ($datetime instanceof EE_Datetime) {
822
+			$datetime_label = $datetime->get_dtt_display_name(true);
823
+			$datetime_label .= ! empty($datetime_label)
824
+				? ' (' . $datetime->get_dtt_display_name() . ')'
825
+				: $datetime->get_dtt_display_name();
826
+		}
827
+		$datetime_link = ! empty($dtt_id) && $registration instanceof EE_Registration
828
+			? EE_Admin_Page::add_query_args_and_nonce(
829
+				array(
830
+					'action'   => 'event_registrations',
831
+					'event_id' => $registration->event_ID(),
832
+					'DTT_ID'   => $dtt_id,
833
+				),
834
+				$this->_admin_base_url
835
+			)
836
+			: '';
837
+		$datetime_link = ! empty($datetime_link)
838
+			? '<a href="' . $datetime_link . '">'
839
+			  . '<span id="checkin-dtt">'
840
+			  . $datetime_label
841
+			  . '</span></a>'
842
+			: $datetime_label;
843
+		$attendee_name = $attendee instanceof EE_Attendee
844
+			? $attendee->full_name()
845
+			: '';
846
+		$attendee_link = $attendee instanceof EE_Attendee
847
+			? $attendee->get_admin_details_link()
848
+			: '';
849
+		$attendee_link = ! empty($attendee_link)
850
+			? '<a href="' . $attendee->get_admin_details_link() . '"'
851
+			  . ' title="' . esc_html__('Click for attendee details', 'event_espresso') . '">'
852
+			  . '<span id="checkin-attendee-name">'
853
+			  . $attendee_name
854
+			  . '</span></a>'
855
+			: '';
856
+		$event_link = $registration->event() instanceof EE_Event
857
+			? $registration->event()->get_admin_details_link()
858
+			: '';
859
+		$event_link = ! empty($event_link)
860
+			? '<a href="' . $event_link . '"'
861
+			  . ' title="' . esc_html__('Click here to edit event.', 'event_espresso') . '">'
862
+			  . '<span id="checkin-event-name">'
863
+			  . $registration->event_name()
864
+			  . '</span>'
865
+			  . '</a>'
866
+			: '';
867
+		$this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id)
868
+			? '<h2>' . sprintf(
869
+				esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'),
870
+				$attendee_link,
871
+				$datetime_link,
872
+				$event_link
873
+			) . '</h2>'
874
+			: '';
875
+		$this->_template_args['list_table_hidden_fields'] = ! empty($reg_id)
876
+			? '<input type="hidden" name="_REG_ID" value="' . $reg_id . '">' : '';
877
+		$this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id)
878
+			? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : '';
879
+		$this->display_admin_list_table_page_with_no_sidebar();
880
+	}
881 881
 
882 882
 
883
-    /**
884
-     * toggle the Check-in status for the given registration (coming from ajax)
885
-     *
886
-     * @return void (JSON)
887
-     * @throws EE_Error
888
-     * @throws InvalidArgumentException
889
-     * @throws InvalidDataTypeException
890
-     * @throws InvalidInterfaceException
891
-     */
892
-    public function toggle_checkin_status()
893
-    {
894
-        //first make sure we have the necessary data
895
-        if ( ! isset($this->_req_data['_regid'])) {
896
-            EE_Error::add_error(
897
-                esc_html__(
898
-                    'There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax',
899
-                    'event_espresso'
900
-                ),
901
-                __FILE__,
902
-                __FUNCTION__,
903
-                __LINE__
904
-            );
905
-            $this->_template_args['success'] = false;
906
-            $this->_template_args['error'] = true;
907
-            $this->_return_json();
908
-        };
909
-        //do a nonce check cause we're not coming in from an normal route here.
910
-        $nonce = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce'])
911
-            : '';
912
-        $nonce_ref = 'checkin_nonce';
913
-        $this->_verify_nonce($nonce, $nonce_ref);
914
-        //beautiful! Made it this far so let's get the status.
915
-        $new_status = new CheckinStatusDashicon($this->_toggle_checkin_status());
916
-        //setup new class to return via ajax
917
-        $this->_template_args['admin_page_content'] = 'clickable trigger-checkin ' . $new_status->cssClasses();
918
-        $this->_template_args['success'] = true;
919
-        $this->_return_json();
920
-    }
883
+	/**
884
+	 * toggle the Check-in status for the given registration (coming from ajax)
885
+	 *
886
+	 * @return void (JSON)
887
+	 * @throws EE_Error
888
+	 * @throws InvalidArgumentException
889
+	 * @throws InvalidDataTypeException
890
+	 * @throws InvalidInterfaceException
891
+	 */
892
+	public function toggle_checkin_status()
893
+	{
894
+		//first make sure we have the necessary data
895
+		if ( ! isset($this->_req_data['_regid'])) {
896
+			EE_Error::add_error(
897
+				esc_html__(
898
+					'There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax',
899
+					'event_espresso'
900
+				),
901
+				__FILE__,
902
+				__FUNCTION__,
903
+				__LINE__
904
+			);
905
+			$this->_template_args['success'] = false;
906
+			$this->_template_args['error'] = true;
907
+			$this->_return_json();
908
+		};
909
+		//do a nonce check cause we're not coming in from an normal route here.
910
+		$nonce = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce'])
911
+			: '';
912
+		$nonce_ref = 'checkin_nonce';
913
+		$this->_verify_nonce($nonce, $nonce_ref);
914
+		//beautiful! Made it this far so let's get the status.
915
+		$new_status = new CheckinStatusDashicon($this->_toggle_checkin_status());
916
+		//setup new class to return via ajax
917
+		$this->_template_args['admin_page_content'] = 'clickable trigger-checkin ' . $new_status->cssClasses();
918
+		$this->_template_args['success'] = true;
919
+		$this->_return_json();
920
+	}
921 921
 
922 922
 
923
-    /**
924
-     * handles toggling the checkin status for the registration,
925
-     *
926
-     * @access protected
927
-     * @return int|void
928
-     * @throws EE_Error
929
-     * @throws InvalidArgumentException
930
-     * @throws InvalidDataTypeException
931
-     * @throws InvalidInterfaceException
932
-     */
933
-    protected function _toggle_checkin_status()
934
-    {
935
-        //first let's get the query args out of the way for the redirect
936
-        $query_args = array(
937
-            'action'   => 'event_registrations',
938
-            'event_id' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null,
939
-            'DTT_ID'   => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null,
940
-        );
941
-        $new_status = false;
942
-        // bulk action check in toggle
943
-        if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
944
-            // cycle thru checkboxes
945
-            while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) {
946
-                $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null;
947
-                $new_status = $this->_toggle_checkin($REG_ID, $DTT_ID);
948
-            }
949
-        } elseif (isset($this->_req_data['_regid'])) {
950
-            //coming from ajax request
951
-            $DTT_ID = isset($this->_req_data['dttid']) ? $this->_req_data['dttid'] : null;
952
-            $query_args['DTT_ID'] = $DTT_ID;
953
-            $new_status = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID);
954
-        } else {
955
-            EE_Error::add_error(
956
-                esc_html__('Missing some required data to toggle the Check-in', 'event_espresso'),
957
-                __FILE__,
958
-                __FUNCTION__,
959
-                __LINE__
960
-            );
961
-        }
962
-        if (defined('DOING_AJAX')) {
963
-            return $new_status;
964
-        }
965
-        $this->_redirect_after_action(false, '', '', $query_args, true);
966
-    }
923
+	/**
924
+	 * handles toggling the checkin status for the registration,
925
+	 *
926
+	 * @access protected
927
+	 * @return int|void
928
+	 * @throws EE_Error
929
+	 * @throws InvalidArgumentException
930
+	 * @throws InvalidDataTypeException
931
+	 * @throws InvalidInterfaceException
932
+	 */
933
+	protected function _toggle_checkin_status()
934
+	{
935
+		//first let's get the query args out of the way for the redirect
936
+		$query_args = array(
937
+			'action'   => 'event_registrations',
938
+			'event_id' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null,
939
+			'DTT_ID'   => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null,
940
+		);
941
+		$new_status = false;
942
+		// bulk action check in toggle
943
+		if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
944
+			// cycle thru checkboxes
945
+			while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) {
946
+				$DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null;
947
+				$new_status = $this->_toggle_checkin($REG_ID, $DTT_ID);
948
+			}
949
+		} elseif (isset($this->_req_data['_regid'])) {
950
+			//coming from ajax request
951
+			$DTT_ID = isset($this->_req_data['dttid']) ? $this->_req_data['dttid'] : null;
952
+			$query_args['DTT_ID'] = $DTT_ID;
953
+			$new_status = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID);
954
+		} else {
955
+			EE_Error::add_error(
956
+				esc_html__('Missing some required data to toggle the Check-in', 'event_espresso'),
957
+				__FILE__,
958
+				__FUNCTION__,
959
+				__LINE__
960
+			);
961
+		}
962
+		if (defined('DOING_AJAX')) {
963
+			return $new_status;
964
+		}
965
+		$this->_redirect_after_action(false, '', '', $query_args, true);
966
+	}
967 967
 
968 968
 
969
-    /**
970
-     * This is toggles a single Check-in for the given registration and datetime.
971
-     *
972
-     * @param  int $REG_ID The registration we're toggling
973
-     * @param  int $DTT_ID The datetime we're toggling
974
-     * @return int The new status toggled to.
975
-     * @throws EE_Error
976
-     * @throws InvalidArgumentException
977
-     * @throws InvalidDataTypeException
978
-     * @throws InvalidInterfaceException
979
-     */
980
-    private function _toggle_checkin($REG_ID, $DTT_ID)
981
-    {
982
-        /** @var EE_Registration $REG */
983
-        $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID);
984
-        $new_status = $REG->toggle_checkin_status($DTT_ID);
985
-        if ($new_status !== false) {
986
-            EE_Error::add_success($REG->get_checkin_msg($DTT_ID));
987
-        } else {
988
-            EE_Error::add_error($REG->get_checkin_msg($DTT_ID, true), __FILE__, __FUNCTION__, __LINE__);
989
-            $new_status = false;
990
-        }
991
-        return $new_status;
992
-    }
969
+	/**
970
+	 * This is toggles a single Check-in for the given registration and datetime.
971
+	 *
972
+	 * @param  int $REG_ID The registration we're toggling
973
+	 * @param  int $DTT_ID The datetime we're toggling
974
+	 * @return int The new status toggled to.
975
+	 * @throws EE_Error
976
+	 * @throws InvalidArgumentException
977
+	 * @throws InvalidDataTypeException
978
+	 * @throws InvalidInterfaceException
979
+	 */
980
+	private function _toggle_checkin($REG_ID, $DTT_ID)
981
+	{
982
+		/** @var EE_Registration $REG */
983
+		$REG = EEM_Registration::instance()->get_one_by_ID($REG_ID);
984
+		$new_status = $REG->toggle_checkin_status($DTT_ID);
985
+		if ($new_status !== false) {
986
+			EE_Error::add_success($REG->get_checkin_msg($DTT_ID));
987
+		} else {
988
+			EE_Error::add_error($REG->get_checkin_msg($DTT_ID, true), __FILE__, __FUNCTION__, __LINE__);
989
+			$new_status = false;
990
+		}
991
+		return $new_status;
992
+	}
993 993
 
994 994
 
995
-    /**
996
-     * Takes care of deleting multiple EE_Checkin table rows
997
-     *
998
-     * @access protected
999
-     * @return void
1000
-     * @throws EE_Error
1001
-     * @throws InvalidArgumentException
1002
-     * @throws InvalidDataTypeException
1003
-     * @throws InvalidInterfaceException
1004
-     */
1005
-    protected function _delete_checkin_rows()
1006
-    {
1007
-        $query_args = array(
1008
-            'action' => 'registration_checkins',
1009
-            'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
1010
-            '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0,
1011
-        );
1012
-        $errors = 0;
1013
-        if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1014
-            while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) {
1015
-                if ( ! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) {
1016
-                    $errors++;
1017
-                }
1018
-            }
1019
-        } else {
1020
-            EE_Error::add_error(
1021
-                esc_html__(
1022
-                    'So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!',
1023
-                    'event_espresso'
1024
-                ),
1025
-                __FILE__,
1026
-                __FUNCTION__,
1027
-                __LINE__
1028
-            );
1029
-            $this->_redirect_after_action(false, '', '', $query_args, true);
1030
-        }
1031
-        if ($errors > 0) {
1032
-            EE_Error::add_error(
1033
-                sprintf(__('There were %d records that did not delete successfully', 'event_espresso'), $errors),
1034
-                __FILE__,
1035
-                __FUNCTION__,
1036
-                __LINE__
1037
-            );
1038
-        } else {
1039
-            EE_Error::add_success(__('Records were successfully deleted', 'event_espresso'));
1040
-        }
1041
-        $this->_redirect_after_action(false, '', '', $query_args, true);
1042
-    }
995
+	/**
996
+	 * Takes care of deleting multiple EE_Checkin table rows
997
+	 *
998
+	 * @access protected
999
+	 * @return void
1000
+	 * @throws EE_Error
1001
+	 * @throws InvalidArgumentException
1002
+	 * @throws InvalidDataTypeException
1003
+	 * @throws InvalidInterfaceException
1004
+	 */
1005
+	protected function _delete_checkin_rows()
1006
+	{
1007
+		$query_args = array(
1008
+			'action' => 'registration_checkins',
1009
+			'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
1010
+			'_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0,
1011
+		);
1012
+		$errors = 0;
1013
+		if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1014
+			while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) {
1015
+				if ( ! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) {
1016
+					$errors++;
1017
+				}
1018
+			}
1019
+		} else {
1020
+			EE_Error::add_error(
1021
+				esc_html__(
1022
+					'So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!',
1023
+					'event_espresso'
1024
+				),
1025
+				__FILE__,
1026
+				__FUNCTION__,
1027
+				__LINE__
1028
+			);
1029
+			$this->_redirect_after_action(false, '', '', $query_args, true);
1030
+		}
1031
+		if ($errors > 0) {
1032
+			EE_Error::add_error(
1033
+				sprintf(__('There were %d records that did not delete successfully', 'event_espresso'), $errors),
1034
+				__FILE__,
1035
+				__FUNCTION__,
1036
+				__LINE__
1037
+			);
1038
+		} else {
1039
+			EE_Error::add_success(__('Records were successfully deleted', 'event_espresso'));
1040
+		}
1041
+		$this->_redirect_after_action(false, '', '', $query_args, true);
1042
+	}
1043 1043
 
1044 1044
 
1045
-    /**
1046
-     * Deletes a single EE_Checkin row
1047
-     *
1048
-     * @return void
1049
-     * @throws EE_Error
1050
-     * @throws InvalidArgumentException
1051
-     * @throws InvalidDataTypeException
1052
-     * @throws InvalidInterfaceException
1053
-     */
1054
-    protected function _delete_checkin_row()
1055
-    {
1056
-        $query_args = array(
1057
-            'action' => 'registration_checkins',
1058
-            'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
1059
-            '_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0,
1060
-        );
1061
-        if ( ! empty($this->_req_data['CHK_ID'])) {
1062
-            if ( ! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) {
1063
-                EE_Error::add_error(
1064
-                    esc_html__('Something went wrong and this check-in record was not deleted', 'event_espresso'),
1065
-                    __FILE__,
1066
-                    __FUNCTION__,
1067
-                    __LINE__
1068
-                );
1069
-            } else {
1070
-                EE_Error::add_success(__('Check-In record successfully deleted', 'event_espresso'));
1071
-            }
1072
-        } else {
1073
-            EE_Error::add_error(
1074
-                esc_html__(
1075
-                    'In order to delete a Check-in record, there must be a Check-In ID available. There is not. It is not your fault, there is just a gremlin living in the code',
1076
-                    'event_espresso'
1077
-                ),
1078
-                __FILE__,
1079
-                __FUNCTION__,
1080
-                __LINE__
1081
-            );
1082
-        }
1083
-        $this->_redirect_after_action(false, '', '', $query_args, true);
1084
-    }
1045
+	/**
1046
+	 * Deletes a single EE_Checkin row
1047
+	 *
1048
+	 * @return void
1049
+	 * @throws EE_Error
1050
+	 * @throws InvalidArgumentException
1051
+	 * @throws InvalidDataTypeException
1052
+	 * @throws InvalidInterfaceException
1053
+	 */
1054
+	protected function _delete_checkin_row()
1055
+	{
1056
+		$query_args = array(
1057
+			'action' => 'registration_checkins',
1058
+			'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
1059
+			'_REG_ID' => isset($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0,
1060
+		);
1061
+		if ( ! empty($this->_req_data['CHK_ID'])) {
1062
+			if ( ! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) {
1063
+				EE_Error::add_error(
1064
+					esc_html__('Something went wrong and this check-in record was not deleted', 'event_espresso'),
1065
+					__FILE__,
1066
+					__FUNCTION__,
1067
+					__LINE__
1068
+				);
1069
+			} else {
1070
+				EE_Error::add_success(__('Check-In record successfully deleted', 'event_espresso'));
1071
+			}
1072
+		} else {
1073
+			EE_Error::add_error(
1074
+				esc_html__(
1075
+					'In order to delete a Check-in record, there must be a Check-In ID available. There is not. It is not your fault, there is just a gremlin living in the code',
1076
+					'event_espresso'
1077
+				),
1078
+				__FILE__,
1079
+				__FUNCTION__,
1080
+				__LINE__
1081
+			);
1082
+		}
1083
+		$this->_redirect_after_action(false, '', '', $query_args, true);
1084
+	}
1085 1085
 
1086 1086
 
1087
-    /**
1088
-     *        generates HTML for the Event Registrations List Table
1089
-     *
1090
-     * @access protected
1091
-     * @return void
1092
-     * @throws EE_Error
1093
-     * @throws InvalidArgumentException
1094
-     * @throws InvalidDataTypeException
1095
-     * @throws InvalidInterfaceException
1096
-     */
1097
-    protected function _event_registrations_list_table()
1098
-    {
1099
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1100
-        $this->_admin_page_title .= isset($this->_req_data['event_id'])
1101
-            ? $this->get_action_link_or_button(
1102
-                'new_registration',
1103
-                'add-registrant',
1104
-                array('event_id' => $this->_req_data['event_id']),
1105
-                'add-new-h2',
1106
-                '',
1107
-                false
1108
-            )
1109
-            : '';
1110
-        $checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in);
1111
-        $checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out);
1112
-        $checked_never = new CheckinStatusDashicon(EE_Checkin::status_checked_never);
1113
-        $legend_items = array(
1114
-            'star-icon'        => array(
1115
-                'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8',
1116
-                'desc'  => esc_html__('This Registrant is the Primary Registrant', 'event_espresso'),
1117
-            ),
1118
-            'checkin'          => array(
1119
-                'class' => $checked_in->cssClasses(),
1120
-                'desc'  => $checked_in->legendLabel(),
1121
-            ),
1122
-            'checkout'         => array(
1123
-                'class' => $checked_out->cssClasses(),
1124
-                'desc'  => $checked_out->legendLabel(),
1125
-            ),
1126
-            'nocheckinrecord'  => array(
1127
-                'class' => $checked_never->cssClasses(),
1128
-                'desc'  => $checked_never->legendLabel(),
1129
-            ),
1130
-            'approved_status'  => array(
1131
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
1132
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'),
1133
-            ),
1134
-            'cancelled_status' => array(
1135
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1136
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'),
1137
-            ),
1138
-            'declined_status'  => array(
1139
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
1140
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'),
1141
-            ),
1142
-            'not_approved'     => array(
1143
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
1144
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'),
1145
-            ),
1146
-            'pending_status'   => array(
1147
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
1148
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'),
1149
-            ),
1150
-            'wait_list'        => array(
1151
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
1152
-                'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'),
1153
-            ),
1154
-        );
1155
-        $this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
1156
-        $event_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null;
1157
-        $this->_template_args['before_list_table'] = ! empty($event_id)
1158
-            ? '<h2>' . sprintf(
1159
-                esc_html__('Viewing Registrations for Event: %s', 'event_espresso'),
1160
-                EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name')
1161
-            ) . '</h2>'
1162
-            : '';
1163
-        //need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on
1164
-        // the event.
1165
-        /** @var EE_Event $event */
1166
-        $event = EEM_Event::instance()->get_one_by_ID($event_id);
1167
-        $DTT_ID = ! empty($this->_req_data['DTT_ID']) ? absint($this->_req_data['DTT_ID']) : 0;
1168
-        $datetime = null;
1169
-        if ($event instanceof EE_Event) {
1170
-            $datetimes_on_event = $event->datetimes();
1171
-            if (count($datetimes_on_event) === 1) {
1172
-                $datetime = reset($datetimes_on_event);
1173
-            }
1174
-        }
1175
-        $datetime = $datetime instanceof EE_Datetime ? $datetime : EEM_Datetime::instance()->get_one_by_ID($DTT_ID);
1176
-        if ($datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '') {
1177
-            $this->_template_args['before_list_table'] = substr($this->_template_args['before_list_table'], 0, -5);
1178
-            $this->_template_args['before_list_table'] .= ' &nbsp;<span class="drk-grey-text">';
1179
-            $this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar"></span>';
1180
-            $this->_template_args['before_list_table'] .= $datetime->name();
1181
-            $this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )';
1182
-            $this->_template_args['before_list_table'] .= '</span></h2>';
1183
-        }
1184
-        //if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status
1185
-        // column represents
1186
-        if (! $datetime instanceof EE_Datetime) {
1187
-            $this->_template_args['before_list_table'] .= '<br><p class="description">'
1188
-                . esc_html__(
1189
-                    'In this view, the check-in status represents the latest check-in record for the registration in that row.',
1190
-                    'event_espresso'
1191
-                )
1192
-                . '</p>';
1193
-        }
1194
-        $this->display_admin_list_table_page_with_no_sidebar();
1195
-    }
1087
+	/**
1088
+	 *        generates HTML for the Event Registrations List Table
1089
+	 *
1090
+	 * @access protected
1091
+	 * @return void
1092
+	 * @throws EE_Error
1093
+	 * @throws InvalidArgumentException
1094
+	 * @throws InvalidDataTypeException
1095
+	 * @throws InvalidInterfaceException
1096
+	 */
1097
+	protected function _event_registrations_list_table()
1098
+	{
1099
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1100
+		$this->_admin_page_title .= isset($this->_req_data['event_id'])
1101
+			? $this->get_action_link_or_button(
1102
+				'new_registration',
1103
+				'add-registrant',
1104
+				array('event_id' => $this->_req_data['event_id']),
1105
+				'add-new-h2',
1106
+				'',
1107
+				false
1108
+			)
1109
+			: '';
1110
+		$checked_in = new CheckinStatusDashicon(EE_Checkin::status_checked_in);
1111
+		$checked_out = new CheckinStatusDashicon(EE_Checkin::status_checked_out);
1112
+		$checked_never = new CheckinStatusDashicon(EE_Checkin::status_checked_never);
1113
+		$legend_items = array(
1114
+			'star-icon'        => array(
1115
+				'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8',
1116
+				'desc'  => esc_html__('This Registrant is the Primary Registrant', 'event_espresso'),
1117
+			),
1118
+			'checkin'          => array(
1119
+				'class' => $checked_in->cssClasses(),
1120
+				'desc'  => $checked_in->legendLabel(),
1121
+			),
1122
+			'checkout'         => array(
1123
+				'class' => $checked_out->cssClasses(),
1124
+				'desc'  => $checked_out->legendLabel(),
1125
+			),
1126
+			'nocheckinrecord'  => array(
1127
+				'class' => $checked_never->cssClasses(),
1128
+				'desc'  => $checked_never->legendLabel(),
1129
+			),
1130
+			'approved_status'  => array(
1131
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
1132
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'),
1133
+			),
1134
+			'cancelled_status' => array(
1135
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1136
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'),
1137
+			),
1138
+			'declined_status'  => array(
1139
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
1140
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'),
1141
+			),
1142
+			'not_approved'     => array(
1143
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
1144
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'),
1145
+			),
1146
+			'pending_status'   => array(
1147
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
1148
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'),
1149
+			),
1150
+			'wait_list'        => array(
1151
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
1152
+				'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'),
1153
+			),
1154
+		);
1155
+		$this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
1156
+		$event_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null;
1157
+		$this->_template_args['before_list_table'] = ! empty($event_id)
1158
+			? '<h2>' . sprintf(
1159
+				esc_html__('Viewing Registrations for Event: %s', 'event_espresso'),
1160
+				EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name')
1161
+			) . '</h2>'
1162
+			: '';
1163
+		//need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on
1164
+		// the event.
1165
+		/** @var EE_Event $event */
1166
+		$event = EEM_Event::instance()->get_one_by_ID($event_id);
1167
+		$DTT_ID = ! empty($this->_req_data['DTT_ID']) ? absint($this->_req_data['DTT_ID']) : 0;
1168
+		$datetime = null;
1169
+		if ($event instanceof EE_Event) {
1170
+			$datetimes_on_event = $event->datetimes();
1171
+			if (count($datetimes_on_event) === 1) {
1172
+				$datetime = reset($datetimes_on_event);
1173
+			}
1174
+		}
1175
+		$datetime = $datetime instanceof EE_Datetime ? $datetime : EEM_Datetime::instance()->get_one_by_ID($DTT_ID);
1176
+		if ($datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '') {
1177
+			$this->_template_args['before_list_table'] = substr($this->_template_args['before_list_table'], 0, -5);
1178
+			$this->_template_args['before_list_table'] .= ' &nbsp;<span class="drk-grey-text">';
1179
+			$this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar"></span>';
1180
+			$this->_template_args['before_list_table'] .= $datetime->name();
1181
+			$this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )';
1182
+			$this->_template_args['before_list_table'] .= '</span></h2>';
1183
+		}
1184
+		//if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status
1185
+		// column represents
1186
+		if (! $datetime instanceof EE_Datetime) {
1187
+			$this->_template_args['before_list_table'] .= '<br><p class="description">'
1188
+				. esc_html__(
1189
+					'In this view, the check-in status represents the latest check-in record for the registration in that row.',
1190
+					'event_espresso'
1191
+				)
1192
+				. '</p>';
1193
+		}
1194
+		$this->display_admin_list_table_page_with_no_sidebar();
1195
+	}
1196 1196
 
1197
-    /**
1198
-     * Download the registrations check-in report (same as the normal registration report, but with different where
1199
-     * conditions)
1200
-     *
1201
-     * @return void ends the request by a redirect or download
1202
-     */
1203
-    public function _registrations_checkin_report()
1204
-    {
1205
-        $this->_registrations_report_base('_get_checkin_query_params_from_request');
1206
-    }
1197
+	/**
1198
+	 * Download the registrations check-in report (same as the normal registration report, but with different where
1199
+	 * conditions)
1200
+	 *
1201
+	 * @return void ends the request by a redirect or download
1202
+	 */
1203
+	public function _registrations_checkin_report()
1204
+	{
1205
+		$this->_registrations_report_base('_get_checkin_query_params_from_request');
1206
+	}
1207 1207
 
1208
-    /**
1209
-     * Gets the query params from the request, plus adds a where condition for the registration status,
1210
-     * because on the checkin page we only ever want to see approved and pending-approval registrations
1211
-     *
1212
-     * @param array $request
1213
-     * @param int   $per_page
1214
-     * @param bool  $count
1215
-     * @return array
1216
-     * @throws EE_Error
1217
-     */
1218
-    protected function _get_checkin_query_params_from_request(
1219
-        $request,
1220
-        $per_page = 10,
1221
-        $count = false
1222
-    ) {
1223
-        $query_params = $this->_get_registration_query_parameters($request, $per_page, $count);
1224
-        //unlike the regular registrations list table,
1225
-        $status_ids_array = apply_filters(
1226
-            'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array',
1227
-            array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved)
1228
-        );
1229
-        $query_params[0]['STS_ID'] = array('IN', $status_ids_array);
1230
-        return $query_params;
1231
-    }
1208
+	/**
1209
+	 * Gets the query params from the request, plus adds a where condition for the registration status,
1210
+	 * because on the checkin page we only ever want to see approved and pending-approval registrations
1211
+	 *
1212
+	 * @param array $request
1213
+	 * @param int   $per_page
1214
+	 * @param bool  $count
1215
+	 * @return array
1216
+	 * @throws EE_Error
1217
+	 */
1218
+	protected function _get_checkin_query_params_from_request(
1219
+		$request,
1220
+		$per_page = 10,
1221
+		$count = false
1222
+	) {
1223
+		$query_params = $this->_get_registration_query_parameters($request, $per_page, $count);
1224
+		//unlike the regular registrations list table,
1225
+		$status_ids_array = apply_filters(
1226
+			'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array',
1227
+			array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved)
1228
+		);
1229
+		$query_params[0]['STS_ID'] = array('IN', $status_ids_array);
1230
+		return $query_params;
1231
+	}
1232 1232
 
1233 1233
 
1234
-    /**
1235
-     * Gets registrations for an event
1236
-     *
1237
-     * @param int    $per_page
1238
-     * @param bool   $count whether to return count or data.
1239
-     * @param bool   $trash
1240
-     * @param string $orderby
1241
-     * @return EE_Registration[]|int
1242
-     * @throws EE_Error
1243
-     * @throws InvalidArgumentException
1244
-     * @throws InvalidDataTypeException
1245
-     * @throws InvalidInterfaceException
1246
-     */
1247
-    public function get_event_attendees($per_page = 10, $count = false, $trash = false, $orderby = 'ATT_fname')
1248
-    {
1249
-        //normalize some request params that get setup by the parent `get_registrations` method.
1250
-        $request = $this->_req_data;
1251
-        $request['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : $orderby;
1252
-        $request['order'] =  ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC';
1253
-        if ($trash) {
1254
-            $request['status'] = 'trash';
1255
-        }
1256
-        $query_params = $this->_get_checkin_query_params_from_request($request, $per_page, $count);
1257
-        /**
1258
-         * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1259
-         * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1260
-         * @see EEM_Base::get_all()
1261
-         */
1262
-        $query_params['group_by'] = '';
1234
+	/**
1235
+	 * Gets registrations for an event
1236
+	 *
1237
+	 * @param int    $per_page
1238
+	 * @param bool   $count whether to return count or data.
1239
+	 * @param bool   $trash
1240
+	 * @param string $orderby
1241
+	 * @return EE_Registration[]|int
1242
+	 * @throws EE_Error
1243
+	 * @throws InvalidArgumentException
1244
+	 * @throws InvalidDataTypeException
1245
+	 * @throws InvalidInterfaceException
1246
+	 */
1247
+	public function get_event_attendees($per_page = 10, $count = false, $trash = false, $orderby = 'ATT_fname')
1248
+	{
1249
+		//normalize some request params that get setup by the parent `get_registrations` method.
1250
+		$request = $this->_req_data;
1251
+		$request['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : $orderby;
1252
+		$request['order'] =  ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC';
1253
+		if ($trash) {
1254
+			$request['status'] = 'trash';
1255
+		}
1256
+		$query_params = $this->_get_checkin_query_params_from_request($request, $per_page, $count);
1257
+		/**
1258
+		 * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1259
+		 * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1260
+		 * @see EEM_Base::get_all()
1261
+		 */
1262
+		$query_params['group_by'] = '';
1263 1263
 
1264
-        return $count
1265
-            ? EEM_Registration::instance()->count($query_params)
1266
-            /** @type EE_Registration[] */
1267
-            : EEM_Registration::instance()->get_all($query_params);
1268
-    }
1264
+		return $count
1265
+			? EEM_Registration::instance()->count($query_params)
1266
+			/** @type EE_Registration[] */
1267
+			: EEM_Registration::instance()->get_all($query_params);
1268
+	}
1269 1269
 }
Please login to merge, or discard this patch.
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -35,10 +35,10 @@  discard block
 block discarded – undo
35 35
     public function __construct($routing = true)
36 36
     {
37 37
         parent::__construct($routing);
38
-        if (! defined('REG_CAF_TEMPLATE_PATH')) {
39
-            define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/');
40
-            define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/');
41
-            define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/');
38
+        if ( ! defined('REG_CAF_TEMPLATE_PATH')) {
39
+            define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'registrations/templates/');
40
+            define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND.'registrations/assets/');
41
+            define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registrations/assets/');
42 42
         }
43 43
     }
44 44
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      */
49 49
     protected function _extend_page_config()
50 50
     {
51
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations';
51
+        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'registrations';
52 52
         $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
53 53
             ? $this->_req_data['_REG_ID']
54 54
             : 0;
@@ -187,14 +187,14 @@  discard block
 block discarded – undo
187 187
             //enqueue newsletter js
188 188
             wp_enqueue_script(
189 189
                 'ee-newsletter-trigger',
190
-                REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js',
190
+                REG_CAF_ASSETS_URL.'ee-newsletter-trigger.js',
191 191
                 array('ee-dialog'),
192 192
                 EVENT_ESPRESSO_VERSION,
193 193
                 true
194 194
             );
195 195
             wp_enqueue_style(
196 196
                 'ee-newsletter-trigger-css',
197
-                REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css',
197
+                REG_CAF_ASSETS_URL.'ee-newsletter-trigger.css',
198 198
                 array(),
199 199
                 EVENT_ESPRESSO_VERSION
200 200
             );
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
     {
216 216
         wp_register_script(
217 217
             'ee-reg-reports-js',
218
-            REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js',
218
+            REG_CAF_ASSETS_URL.'ee-registration-admin-reports.js',
219 219
             array('google-charts'),
220 220
             EVENT_ESPRESSO_VERSION,
221 221
             true
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
         $nonce_ref = 'get_newsletter_form_content_nonce';
302 302
         $this->_verify_nonce($nonce, $nonce_ref);
303 303
         //let's get the mtp for the incoming MTP_ ID
304
-        if (! isset($this->_req_data['GRP_ID'])) {
304
+        if ( ! isset($this->_req_data['GRP_ID'])) {
305 305
             EE_Error::add_error(
306 306
                 esc_html__(
307 307
                     'There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).',
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
             $this->_return_json();
317 317
         }
318 318
         $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']);
319
-        if (! $MTPG instanceof EE_Message_Template_Group) {
319
+        if ( ! $MTPG instanceof EE_Message_Template_Group) {
320 320
             EE_Error::add_error(
321 321
                 sprintf(
322 322
                     esc_html__(
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
             $field = $MTP->get('MTP_template_field');
342 342
             if ($field === 'content') {
343 343
                 $content = $MTP->get('MTP_content');
344
-                if (! empty($content['newsletter_content'])) {
344
+                if ( ! empty($content['newsletter_content'])) {
345 345
                     $template_fields['newsletter_content'] = $content['newsletter_content'];
346 346
                 }
347 347
                 continue;
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
      */
378 378
     public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table)
379 379
     {
380
-        if (! EE_Registry::instance()->CAP->current_user_can(
380
+        if ( ! EE_Registry::instance()->CAP->current_user_can(
381 381
             'ee_send_message',
382 382
             'espresso_registrations_newsletter_selected_send'
383 383
         )
@@ -446,17 +446,17 @@  discard block
 block discarded – undo
446 446
                 $field_id = $field === '[NEWSLETTER_CONTENT]'
447 447
                     ? 'content'
448 448
                     : $field;
449
-                $field_id = 'batch-message-' . strtolower($field_id);
449
+                $field_id = 'batch-message-'.strtolower($field_id);
450 450
                 $available_shortcodes[] = '<span class="js-shortcode-selection" data-value="'
451 451
                                           . $shortcode
452
-                                          . '" data-linked-input-id="' . $field_id . '">'
452
+                                          . '" data-linked-input-id="'.$field_id.'">'
453 453
                                           . $shortcode
454 454
                                           . '</span>';
455 455
             }
456 456
             $codes[$field] = implode(', ', $available_shortcodes);
457 457
         }
458 458
         $shortcodes = $codes;
459
-        $form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php';
459
+        $form_template = REG_CAF_TEMPLATE_PATH.'newsletter-send-form.template.php';
460 460
         $form_template_args = array(
461 461
             'form_action'       => admin_url('admin.php?page=espresso_registrations'),
462 462
             'form_route'        => 'newsletter_selected_send',
@@ -623,7 +623,7 @@  discard block
 block discarded – undo
623 623
      */
624 624
     protected function _registration_reports()
625 625
     {
626
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php';
626
+        $template_path = EE_ADMIN_TEMPLATE.'admin_reports.template.php';
627 627
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
628 628
             $template_path,
629 629
             $this->_reports_template_data,
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
     {
649 649
         $report_ID = 'reg-admin-registrations-per-day-report-dv';
650 650
         $results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period);
651
-        $results = (array)$results;
651
+        $results = (array) $results;
652 652
         $regs = array();
653 653
         $subtitle = '';
654 654
         if ($results) {
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
                 $report_column_values = array();
659 659
                 foreach ($result as $property_name => $property_value) {
660 660
                     $property_value = $property_name === 'Registration_REG_date' ? $property_value
661
-                        : (int)$property_value;
661
+                        : (int) $property_value;
662 662
                     $report_column_values[] = $property_value;
663 663
                     if ($tracker === 0) {
664 664
                         if ($property_name === 'Registration_REG_date') {
@@ -675,7 +675,7 @@  discard block
 block discarded – undo
675 675
             array_unshift($regs, $column_titles);
676 676
             //setup the date range.
677 677
             $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
678
-            $beginning_date = new DateTime("now " . $period, $DateTimeZone);
678
+            $beginning_date = new DateTime("now ".$period, $DateTimeZone);
679 679
             $ending_date = new DateTime("now", $DateTimeZone);
680 680
             $subtitle = sprintf(
681 681
                 _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'),
@@ -695,7 +695,7 @@  discard block
 block discarded – undo
695 695
                     '%sThere are currently no registration records in the last month for this report.%s',
696 696
                     'event_espresso'
697 697
                 ),
698
-                '<h2>' . $report_title . '</h2><p>',
698
+                '<h2>'.$report_title.'</h2><p>',
699 699
                 '</p>'
700 700
             ),
701 701
         );
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
     {
719 719
         $report_ID = 'reg-admin-registrations-per-event-report-dv';
720 720
         $results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period);
721
-        $results = (array)$results;
721
+        $results = (array) $results;
722 722
         $regs = array();
723 723
         $subtitle = '';
724 724
         if ($results) {
@@ -731,7 +731,7 @@  discard block
 block discarded – undo
731 731
                         $property_value,
732 732
                         4,
733 733
                         '...'
734
-                    ) : (int)$property_value;
734
+                    ) : (int) $property_value;
735 735
                     $report_column_values[] = $property_value;
736 736
                     if ($tracker === 0) {
737 737
                         if ($property_name === 'Registration_Event') {
@@ -748,7 +748,7 @@  discard block
 block discarded – undo
748 748
             array_unshift($regs, $column_titles);
749 749
             //setup the date range.
750 750
             $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
751
-            $beginning_date = new DateTime("now " . $period, $DateTimeZone);
751
+            $beginning_date = new DateTime("now ".$period, $DateTimeZone);
752 752
             $ending_date = new DateTime("now", $DateTimeZone);
753 753
             $subtitle = sprintf(
754 754
                 _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'),
@@ -768,7 +768,7 @@  discard block
 block discarded – undo
768 768
                     '%sThere are currently no registration records in the last month for this report.%s',
769 769
                     'event_espresso'
770 770
                 ),
771
-                '<h2>' . $report_title . '</h2><p>',
771
+                '<h2>'.$report_title.'</h2><p>',
772 772
                 '</p>'
773 773
             ),
774 774
         );
@@ -821,7 +821,7 @@  discard block
 block discarded – undo
821 821
         if ($datetime instanceof EE_Datetime) {
822 822
             $datetime_label = $datetime->get_dtt_display_name(true);
823 823
             $datetime_label .= ! empty($datetime_label)
824
-                ? ' (' . $datetime->get_dtt_display_name() . ')'
824
+                ? ' ('.$datetime->get_dtt_display_name().')'
825 825
                 : $datetime->get_dtt_display_name();
826 826
         }
827 827
         $datetime_link = ! empty($dtt_id) && $registration instanceof EE_Registration
@@ -835,7 +835,7 @@  discard block
 block discarded – undo
835 835
             )
836 836
             : '';
837 837
         $datetime_link = ! empty($datetime_link)
838
-            ? '<a href="' . $datetime_link . '">'
838
+            ? '<a href="'.$datetime_link.'">'
839 839
               . '<span id="checkin-dtt">'
840 840
               . $datetime_label
841 841
               . '</span></a>'
@@ -847,8 +847,8 @@  discard block
 block discarded – undo
847 847
             ? $attendee->get_admin_details_link()
848 848
             : '';
849 849
         $attendee_link = ! empty($attendee_link)
850
-            ? '<a href="' . $attendee->get_admin_details_link() . '"'
851
-              . ' title="' . esc_html__('Click for attendee details', 'event_espresso') . '">'
850
+            ? '<a href="'.$attendee->get_admin_details_link().'"'
851
+              . ' title="'.esc_html__('Click for attendee details', 'event_espresso').'">'
852 852
               . '<span id="checkin-attendee-name">'
853 853
               . $attendee_name
854 854
               . '</span></a>'
@@ -857,25 +857,25 @@  discard block
 block discarded – undo
857 857
             ? $registration->event()->get_admin_details_link()
858 858
             : '';
859 859
         $event_link = ! empty($event_link)
860
-            ? '<a href="' . $event_link . '"'
861
-              . ' title="' . esc_html__('Click here to edit event.', 'event_espresso') . '">'
860
+            ? '<a href="'.$event_link.'"'
861
+              . ' title="'.esc_html__('Click here to edit event.', 'event_espresso').'">'
862 862
               . '<span id="checkin-event-name">'
863 863
               . $registration->event_name()
864 864
               . '</span>'
865 865
               . '</a>'
866 866
             : '';
867 867
         $this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id)
868
-            ? '<h2>' . sprintf(
868
+            ? '<h2>'.sprintf(
869 869
                 esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'),
870 870
                 $attendee_link,
871 871
                 $datetime_link,
872 872
                 $event_link
873
-            ) . '</h2>'
873
+            ).'</h2>'
874 874
             : '';
875 875
         $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id)
876
-            ? '<input type="hidden" name="_REG_ID" value="' . $reg_id . '">' : '';
876
+            ? '<input type="hidden" name="_REG_ID" value="'.$reg_id.'">' : '';
877 877
         $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id)
878
-            ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : '';
878
+            ? '<input type="hidden" name="DTT_ID" value="'.$dtt_id.'">' : '';
879 879
         $this->display_admin_list_table_page_with_no_sidebar();
880 880
     }
881 881
 
@@ -914,7 +914,7 @@  discard block
 block discarded – undo
914 914
         //beautiful! Made it this far so let's get the status.
915 915
         $new_status = new CheckinStatusDashicon($this->_toggle_checkin_status());
916 916
         //setup new class to return via ajax
917
-        $this->_template_args['admin_page_content'] = 'clickable trigger-checkin ' . $new_status->cssClasses();
917
+        $this->_template_args['admin_page_content'] = 'clickable trigger-checkin '.$new_status->cssClasses();
918 918
         $this->_template_args['success'] = true;
919 919
         $this->_return_json();
920 920
     }
@@ -1128,37 +1128,37 @@  discard block
 block discarded – undo
1128 1128
                 'desc'  => $checked_never->legendLabel(),
1129 1129
             ),
1130 1130
             'approved_status'  => array(
1131
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
1131
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_approved,
1132 1132
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'),
1133 1133
             ),
1134 1134
             'cancelled_status' => array(
1135
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1135
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_cancelled,
1136 1136
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'),
1137 1137
             ),
1138 1138
             'declined_status'  => array(
1139
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
1139
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_declined,
1140 1140
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'),
1141 1141
             ),
1142 1142
             'not_approved'     => array(
1143
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
1143
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_not_approved,
1144 1144
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'),
1145 1145
             ),
1146 1146
             'pending_status'   => array(
1147
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
1147
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_pending_payment,
1148 1148
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'),
1149 1149
             ),
1150 1150
             'wait_list'        => array(
1151
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
1151
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_wait_list,
1152 1152
                 'desc'  => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'),
1153 1153
             ),
1154 1154
         );
1155 1155
         $this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
1156 1156
         $event_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null;
1157 1157
         $this->_template_args['before_list_table'] = ! empty($event_id)
1158
-            ? '<h2>' . sprintf(
1158
+            ? '<h2>'.sprintf(
1159 1159
                 esc_html__('Viewing Registrations for Event: %s', 'event_espresso'),
1160 1160
                 EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name')
1161
-            ) . '</h2>'
1161
+            ).'</h2>'
1162 1162
             : '';
1163 1163
         //need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on
1164 1164
         // the event.
@@ -1178,12 +1178,12 @@  discard block
 block discarded – undo
1178 1178
             $this->_template_args['before_list_table'] .= ' &nbsp;<span class="drk-grey-text">';
1179 1179
             $this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar"></span>';
1180 1180
             $this->_template_args['before_list_table'] .= $datetime->name();
1181
-            $this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )';
1181
+            $this->_template_args['before_list_table'] .= ' ( '.$datetime->date_and_time_range().' )';
1182 1182
             $this->_template_args['before_list_table'] .= '</span></h2>';
1183 1183
         }
1184 1184
         //if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status
1185 1185
         // column represents
1186
-        if (! $datetime instanceof EE_Datetime) {
1186
+        if ( ! $datetime instanceof EE_Datetime) {
1187 1187
             $this->_template_args['before_list_table'] .= '<br><p class="description">'
1188 1188
                 . esc_html__(
1189 1189
                     'In this view, the check-in status represents the latest check-in record for the registration in that row.',
@@ -1249,7 +1249,7 @@  discard block
 block discarded – undo
1249 1249
         //normalize some request params that get setup by the parent `get_registrations` method.
1250 1250
         $request = $this->_req_data;
1251 1251
         $request['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : $orderby;
1252
-        $request['order'] =  ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC';
1252
+        $request['order'] = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC';
1253 1253
         if ($trash) {
1254 1254
             $request['status'] = 'trash';
1255 1255
         }
Please login to merge, or discard this patch.
core/db_classes/EE_Registration.class.php 1 patch
Indentation   +1999 added lines, -1999 removed lines patch added patch discarded remove patch
@@ -18,2005 +18,2005 @@
 block discarded – undo
18 18
 {
19 19
 
20 20
 
21
-    /**
22
-     * Used to reference when a registration has never been checked in.
23
-     *
24
-     * @deprecated use \EE_Checkin::status_checked_never instead
25
-     * @type int
26
-     */
27
-    const checkin_status_never = 2;
28
-
29
-    /**
30
-     * Used to reference when a registration has been checked in.
31
-     *
32
-     * @deprecated use \EE_Checkin::status_checked_in instead
33
-     * @type int
34
-     */
35
-    const checkin_status_in = 1;
36
-
37
-
38
-    /**
39
-     * Used to reference when a registration has been checked out.
40
-     *
41
-     * @deprecated use \EE_Checkin::status_checked_out instead
42
-     * @type int
43
-     */
44
-    const checkin_status_out = 0;
45
-
46
-
47
-    /**
48
-     * extra meta key for tracking reg status os trashed registrations
49
-     *
50
-     * @type string
51
-     */
52
-    const PRE_TRASH_REG_STATUS_KEY = 'pre_trash_registration_status';
53
-
54
-
55
-    /**
56
-     * extra meta key for tracking if registration has reserved ticket
57
-     *
58
-     * @type string
59
-     */
60
-    const HAS_RESERVED_TICKET_KEY = 'has_reserved_ticket';
61
-
62
-
63
-    /**
64
-     * @param array  $props_n_values          incoming values
65
-     * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
66
-     *                                        used.)
67
-     * @param array  $date_formats            incoming date_formats in an array where the first value is the
68
-     *                                        date_format and the second value is the time format
69
-     * @return EE_Registration
70
-     * @throws EE_Error
71
-     */
72
-    public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
73
-    {
74
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
75
-        return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
76
-    }
77
-
78
-
79
-    /**
80
-     * @param array  $props_n_values  incoming values from the database
81
-     * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
82
-     *                                the website will be used.
83
-     * @return EE_Registration
84
-     */
85
-    public static function new_instance_from_db($props_n_values = array(), $timezone = null)
86
-    {
87
-        return new self($props_n_values, true, $timezone);
88
-    }
89
-
90
-
91
-    /**
92
-     *        Set Event ID
93
-     *
94
-     * @param        int $EVT_ID Event ID
95
-     * @throws EE_Error
96
-     * @throws RuntimeException
97
-     */
98
-    public function set_event($EVT_ID = 0)
99
-    {
100
-        $this->set('EVT_ID', $EVT_ID);
101
-    }
102
-
103
-
104
-    /**
105
-     * Overrides parent set() method so that all calls to set( 'REG_code', $REG_code ) OR set( 'STS_ID', $STS_ID ) can
106
-     * be routed to internal methods
107
-     *
108
-     * @param string $field_name
109
-     * @param mixed  $field_value
110
-     * @param bool   $use_default
111
-     * @throws EE_Error
112
-     * @throws EntityNotFoundException
113
-     * @throws InvalidArgumentException
114
-     * @throws InvalidDataTypeException
115
-     * @throws InvalidInterfaceException
116
-     * @throws ReflectionException
117
-     * @throws RuntimeException
118
-     */
119
-    public function set($field_name, $field_value, $use_default = false)
120
-    {
121
-        switch ($field_name) {
122
-            case 'REG_code':
123
-                if (! empty($field_value) && $this->reg_code() === null) {
124
-                    $this->set_reg_code($field_value, $use_default);
125
-                }
126
-                break;
127
-            case 'STS_ID':
128
-                $this->set_status($field_value, $use_default);
129
-                break;
130
-            default:
131
-                parent::set($field_name, $field_value, $use_default);
132
-        }
133
-    }
134
-
135
-
136
-    /**
137
-     * Set Status ID
138
-     * updates the registration status and ALSO...
139
-     * calls reserve_registration_space() if the reg status changes TO approved from any other reg status
140
-     * calls release_registration_space() if the reg status changes FROM approved to any other reg status
141
-     *
142
-     * @param string       $new_STS_ID
143
-     * @param boolean      $use_default
144
-     * @param ContextInterface|null $context
145
-     * @return bool
146
-     * @throws EE_Error
147
-     * @throws EntityNotFoundException
148
-     * @throws InvalidArgumentException
149
-     * @throws ReflectionException
150
-     * @throws RuntimeException
151
-     * @throws InvalidDataTypeException
152
-     * @throws InvalidInterfaceException
153
-     */
154
-    public function set_status($new_STS_ID = null, $use_default = false, ContextInterface $context = null)
155
-    {
156
-        // get current REG_Status
157
-        $old_STS_ID = $this->status_ID();
158
-        // if status has changed
159
-        if ($old_STS_ID !== $new_STS_ID // and that status has actually changed
160
-            && ! empty($old_STS_ID) // and that old status is actually set
161
-            && ! empty($new_STS_ID) // as well as the new status
162
-            && $this->ID() // ensure registration is in the db
163
-        ) {
164
-            // TO approved
165
-            if ($new_STS_ID === EEM_Registration::status_id_approved) {
166
-                // reserve a space by incrementing ticket and datetime sold values
167
-                $this->_reserve_registration_space();
168
-                do_action('AHEE__EE_Registration__set_status__to_approved', $this, $old_STS_ID, $new_STS_ID, $context);
169
-                // OR FROM  approved
170
-            } elseif ($old_STS_ID === EEM_Registration::status_id_approved) {
171
-                // release a space by decrementing ticket and datetime sold values
172
-                $this->_release_registration_space();
173
-                do_action(
174
-                    'AHEE__EE_Registration__set_status__from_approved',
175
-                    $this,
176
-                    $old_STS_ID,
177
-                    $new_STS_ID,
178
-                    $context
179
-                );
180
-            }
181
-            // update status
182
-            parent::set('STS_ID', $new_STS_ID, $use_default);
183
-            $this->_update_if_canceled_or_declined($new_STS_ID, $old_STS_ID, $context);
184
-            if($this->statusChangeUpdatesTransaction($context)) {
185
-                $this->updateTransactionAfterStatusChange();
186
-            }
187
-            do_action('AHEE__EE_Registration__set_status__after_update', $this, $old_STS_ID, $new_STS_ID, $context);
188
-            return true;
189
-        }
190
-        //even though the old value matches the new value, it's still good to
191
-        //allow the parent set method to have a say
192
-        parent::set('STS_ID', $new_STS_ID, $use_default);
193
-        return true;
194
-    }
195
-
196
-
197
-    /**
198
-     * update REGs and TXN when cancelled or declined registrations involved
199
-     *
200
-     * @param string       $new_STS_ID
201
-     * @param string       $old_STS_ID
202
-     * @param ContextInterface|null $context
203
-     * @throws EE_Error
204
-     * @throws InvalidArgumentException
205
-     * @throws InvalidDataTypeException
206
-     * @throws InvalidInterfaceException
207
-     * @throws ReflectionException
208
-     */
209
-    private function _update_if_canceled_or_declined($new_STS_ID, $old_STS_ID, ContextInterface $context = null)
210
-    {
211
-        // these reg statuses should not be considered in any calculations involving monies owing
212
-        $closed_reg_statuses = EEM_Registration::closed_reg_statuses();
213
-        // true if registration has been cancelled or declined
214
-        $this->updateIfCanceled(
215
-            $closed_reg_statuses,
216
-            $new_STS_ID,
217
-            $old_STS_ID,
218
-            $context
219
-        );
220
-        $this->updateIfDeclined(
221
-            $closed_reg_statuses,
222
-            $new_STS_ID,
223
-            $old_STS_ID,
224
-            $context
225
-        );
226
-    }
227
-
228
-
229
-    /**
230
-     * update REGs and TXN when cancelled or declined registrations involved
231
-     *
232
-     * @param array        $closed_reg_statuses
233
-     * @param string       $new_STS_ID
234
-     * @param string       $old_STS_ID
235
-     * @param ContextInterface|null $context
236
-     * @throws EE_Error
237
-     * @throws InvalidArgumentException
238
-     * @throws InvalidDataTypeException
239
-     * @throws InvalidInterfaceException
240
-     * @throws ReflectionException
241
-     */
242
-    private function updateIfCanceled(array $closed_reg_statuses, $new_STS_ID, $old_STS_ID, ContextInterface $context = null)
243
-    {
244
-        // true if registration has been cancelled or declined
245
-        if (in_array($new_STS_ID, $closed_reg_statuses, true)
246
-            && ! in_array($old_STS_ID, $closed_reg_statuses, true)
247
-        ) {
248
-            /** @type EE_Registration_Processor $registration_processor */
249
-            $registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
250
-            /** @type EE_Transaction_Processor $transaction_processor */
251
-            $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
252
-            // cancelled or declined registration
253
-            $registration_processor->update_registration_after_being_canceled_or_declined(
254
-                $this,
255
-                $closed_reg_statuses
256
-            );
257
-            $transaction_processor->update_transaction_after_canceled_or_declined_registration(
258
-                $this,
259
-                $closed_reg_statuses,
260
-                false
261
-            );
262
-            do_action(
263
-                'AHEE__EE_Registration__set_status__canceled_or_declined',
264
-                $this,
265
-                $old_STS_ID,
266
-                $new_STS_ID,
267
-                $context
268
-            );
269
-            return;
270
-        }
271
-    }
272
-
273
-
274
-    /**
275
-     * update REGs and TXN when cancelled or declined registrations involved
276
-     *
277
-     * @param array        $closed_reg_statuses
278
-     * @param string       $new_STS_ID
279
-     * @param string       $old_STS_ID
280
-     * @param ContextInterface|null $context
281
-     * @throws EE_Error
282
-     * @throws InvalidArgumentException
283
-     * @throws InvalidDataTypeException
284
-     * @throws InvalidInterfaceException
285
-     * @throws ReflectionException
286
-     */
287
-    private function updateIfDeclined(array $closed_reg_statuses, $new_STS_ID, $old_STS_ID, ContextInterface $context = null)
288
-    {
289
-        // true if reinstating cancelled or declined registration
290
-        if (in_array($old_STS_ID, $closed_reg_statuses, true)
291
-            && ! in_array($new_STS_ID, $closed_reg_statuses, true)
292
-        ) {
293
-            /** @type EE_Registration_Processor $registration_processor */
294
-            $registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
295
-            /** @type EE_Transaction_Processor $transaction_processor */
296
-            $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
297
-            // reinstating cancelled or declined registration
298
-            $registration_processor->update_canceled_or_declined_registration_after_being_reinstated(
299
-                $this,
300
-                $closed_reg_statuses
301
-            );
302
-            $transaction_processor->update_transaction_after_reinstating_canceled_registration(
303
-                $this,
304
-                $closed_reg_statuses,
305
-                false
306
-            );
307
-            do_action(
308
-                'AHEE__EE_Registration__set_status__after_reinstated',
309
-                $this,
310
-                $old_STS_ID,
311
-                $new_STS_ID,
312
-                $context
313
-            );
314
-        }
315
-    }
316
-
317
-
318
-    /**
319
-     * @param ContextInterface|null $context
320
-     * @return bool
321
-     */
322
-    private function statusChangeUpdatesTransaction(ContextInterface $context = null)
323
-    {
324
-        $contexts_that_do_not_update_transaction = (array) apply_filters(
325
-            'AHEE__EE_Registration__statusChangeUpdatesTransaction__contexts_that_do_not_update_transaction',
326
-            array('spco_reg_step_attendee_information_process_registrations'),
327
-            $context,
328
-            $this
329
-        );
330
-        return ! (
331
-            $context instanceof ContextInterface
332
-            && in_array($context->slug(), $contexts_that_do_not_update_transaction, true)
333
-        );
334
-    }
335
-
336
-
337
-    /**
338
-     * @throws EE_Error
339
-     * @throws EntityNotFoundException
340
-     * @throws InvalidArgumentException
341
-     * @throws InvalidDataTypeException
342
-     * @throws InvalidInterfaceException
343
-     * @throws ReflectionException
344
-     * @throws RuntimeException
345
-     */
346
-    private function updateTransactionAfterStatusChange()
347
-    {
348
-        /** @type EE_Transaction_Payments $transaction_payments */
349
-        $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
350
-        $transaction_payments->recalculate_transaction_total($this->transaction(), false);
351
-        $this->transaction()->update_status_based_on_total_paid(true);
352
-    }
353
-
354
-
355
-    /**
356
-     *        get Status ID
357
-     */
358
-    public function status_ID()
359
-    {
360
-        return $this->get('STS_ID');
361
-    }
362
-
363
-
364
-    /**
365
-     * increments this registration's related ticket sold and corresponding datetime sold values
366
-     *
367
-     * @return void
368
-     * @throws EE_Error
369
-     * @throws EntityNotFoundException
370
-     */
371
-    private function _reserve_registration_space()
372
-    {
373
-        // reserved ticket and datetime counts will be decremented as sold counts are incremented
374
-        // so stop tracking that this reg has a ticket reserved
375
-        $this->release_reserved_ticket();
376
-        $ticket = $this->ticket();
377
-        $ticket->increase_sold();
378
-        $ticket->save();
379
-        // possibly set event status to sold out
380
-        $this->event()->perform_sold_out_status_check();
381
-    }
382
-
383
-
384
-    /**
385
-     * Gets the ticket this registration is for
386
-     *
387
-     * @param boolean $include_archived whether to include archived tickets or not.
388
-     *
389
-     * @return EE_Ticket|EE_Base_Class
390
-     * @throws EE_Error
391
-     */
392
-    public function ticket($include_archived = true)
393
-    {
394
-        $query_params = array();
395
-        if ($include_archived) {
396
-            $query_params['default_where_conditions'] = 'none';
397
-        }
398
-        return $this->get_first_related('Ticket', $query_params);
399
-    }
400
-
401
-
402
-    /**
403
-     * Gets the event this registration is for
404
-     *
405
-     * @return EE_Event
406
-     * @throws EE_Error
407
-     * @throws EntityNotFoundException
408
-     */
409
-    public function event()
410
-    {
411
-        $event = $this->get_first_related('Event');
412
-        if (! $event instanceof \EE_Event) {
413
-            throw new EntityNotFoundException('Event ID', $this->event_ID());
414
-        }
415
-        return $event;
416
-    }
417
-
418
-
419
-    /**
420
-     * Gets the "author" of the registration.  Note that for the purposes of registrations, the author will correspond
421
-     * with the author of the event this registration is for.
422
-     *
423
-     * @since 4.5.0
424
-     * @return int
425
-     * @throws EE_Error
426
-     * @throws EntityNotFoundException
427
-     */
428
-    public function wp_user()
429
-    {
430
-        $event = $this->event();
431
-        if ($event instanceof EE_Event) {
432
-            return $event->wp_user();
433
-        }
434
-        return 0;
435
-    }
436
-
437
-
438
-    /**
439
-     * decrements (subtracts) this registration's related ticket sold and corresponding datetime sold values
440
-     *
441
-     * @return void
442
-     * @throws EE_Error
443
-     */
444
-    private function _release_registration_space()
445
-    {
446
-        $ticket = $this->ticket();
447
-        $ticket->decrease_sold();
448
-        $ticket->save();
449
-    }
450
-
451
-
452
-    /**
453
-     * tracks this registration's ticket reservation in extra meta
454
-     * and can increment related ticket reserved and corresponding datetime reserved values
455
-     *
456
-     * @param bool $update_ticket if true, will increment ticket and datetime reserved count
457
-     *
458
-     * @return void
459
-     * @throws EE_Error
460
-     */
461
-    public function reserve_ticket($update_ticket = false)
462
-    {
463
-        if ($this->get_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true, false) === false) {
464
-            // PLZ NOTE: although checking $update_ticket first would be more efficient,
465
-            // we NEED to ALWAYS call update_extra_meta(), which is why that is done first
466
-            if ($this->update_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true, false) && $update_ticket) {
467
-                $ticket = $this->ticket();
468
-                $ticket->increase_reserved();
469
-                $ticket->save();
470
-            }
471
-        }
472
-    }
473
-
474
-
475
-    /**
476
-     * stops tracking this registration's ticket reservation in extra meta
477
-     * decrements (subtracts) related ticket reserved and corresponding datetime reserved values
478
-     *
479
-     * @param bool $update_ticket if true, will decrement ticket and datetime reserved count
480
-     *
481
-     * @return void
482
-     * @throws EE_Error
483
-     */
484
-    public function release_reserved_ticket($update_ticket = false)
485
-    {
486
-        if ($this->get_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true, false) !== false) {
487
-            // PLZ NOTE: although checking $update_ticket first would be more efficient,
488
-            // we NEED to ALWAYS call delete_extra_meta(), which is why that is done first
489
-            if ($this->delete_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY) && $update_ticket) {
490
-                $ticket = $this->ticket();
491
-                $ticket->decrease_reserved();
492
-                $ticket->save();
493
-            }
494
-        }
495
-    }
496
-
497
-
498
-    /**
499
-     * Set Attendee ID
500
-     *
501
-     * @param        int $ATT_ID Attendee ID
502
-     * @throws EE_Error
503
-     * @throws RuntimeException
504
-     */
505
-    public function set_attendee_id($ATT_ID = 0)
506
-    {
507
-        $this->set('ATT_ID', $ATT_ID);
508
-    }
509
-
510
-
511
-    /**
512
-     *        Set Transaction ID
513
-     *
514
-     * @param        int $TXN_ID Transaction ID
515
-     * @throws EE_Error
516
-     * @throws RuntimeException
517
-     */
518
-    public function set_transaction_id($TXN_ID = 0)
519
-    {
520
-        $this->set('TXN_ID', $TXN_ID);
521
-    }
522
-
523
-
524
-    /**
525
-     *        Set Session
526
-     *
527
-     * @param    string $REG_session PHP Session ID
528
-     * @throws EE_Error
529
-     * @throws RuntimeException
530
-     */
531
-    public function set_session($REG_session = '')
532
-    {
533
-        $this->set('REG_session', $REG_session);
534
-    }
535
-
536
-
537
-    /**
538
-     *        Set Registration URL Link
539
-     *
540
-     * @param    string $REG_url_link Registration URL Link
541
-     * @throws EE_Error
542
-     * @throws RuntimeException
543
-     */
544
-    public function set_reg_url_link($REG_url_link = '')
545
-    {
546
-        $this->set('REG_url_link', $REG_url_link);
547
-    }
548
-
549
-
550
-    /**
551
-     *        Set Attendee Counter
552
-     *
553
-     * @param        int $REG_count Primary Attendee
554
-     * @throws EE_Error
555
-     * @throws RuntimeException
556
-     */
557
-    public function set_count($REG_count = 1)
558
-    {
559
-        $this->set('REG_count', $REG_count);
560
-    }
561
-
562
-
563
-    /**
564
-     *        Set Group Size
565
-     *
566
-     * @param        boolean $REG_group_size Group Registration
567
-     * @throws EE_Error
568
-     * @throws RuntimeException
569
-     */
570
-    public function set_group_size($REG_group_size = false)
571
-    {
572
-        $this->set('REG_group_size', $REG_group_size);
573
-    }
574
-
575
-
576
-    /**
577
-     *    is_not_approved -  convenience method that returns TRUE if REG status ID ==
578
-     *    EEM_Registration::status_id_not_approved
579
-     *
580
-     * @return        boolean
581
-     */
582
-    public function is_not_approved()
583
-    {
584
-        return $this->status_ID() == EEM_Registration::status_id_not_approved ? true : false;
585
-    }
586
-
587
-
588
-    /**
589
-     *    is_pending_payment -  convenience method that returns TRUE if REG status ID ==
590
-     *    EEM_Registration::status_id_pending_payment
591
-     *
592
-     * @return        boolean
593
-     */
594
-    public function is_pending_payment()
595
-    {
596
-        return $this->status_ID() == EEM_Registration::status_id_pending_payment ? true : false;
597
-    }
598
-
599
-
600
-    /**
601
-     *    is_approved -  convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_approved
602
-     *
603
-     * @return        boolean
604
-     */
605
-    public function is_approved()
606
-    {
607
-        return $this->status_ID() == EEM_Registration::status_id_approved ? true : false;
608
-    }
609
-
610
-
611
-    /**
612
-     *    is_cancelled -  convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_cancelled
613
-     *
614
-     * @return        boolean
615
-     */
616
-    public function is_cancelled()
617
-    {
618
-        return $this->status_ID() == EEM_Registration::status_id_cancelled ? true : false;
619
-    }
620
-
621
-
622
-    /**
623
-     *    is_declined -  convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_declined
624
-     *
625
-     * @return        boolean
626
-     */
627
-    public function is_declined()
628
-    {
629
-        return $this->status_ID() == EEM_Registration::status_id_declined ? true : false;
630
-    }
631
-
632
-
633
-    /**
634
-     *    is_incomplete -  convenience method that returns TRUE if REG status ID ==
635
-     *    EEM_Registration::status_id_incomplete
636
-     *
637
-     * @return        boolean
638
-     */
639
-    public function is_incomplete()
640
-    {
641
-        return $this->status_ID() == EEM_Registration::status_id_incomplete ? true : false;
642
-    }
643
-
644
-
645
-    /**
646
-     *        Set Registration Date
647
-     *
648
-     * @param        mixed ( int or string ) $REG_date Registration Date - Unix timestamp or string representation of
649
-     *                                                 Date
650
-     * @throws EE_Error
651
-     * @throws RuntimeException
652
-     */
653
-    public function set_reg_date($REG_date = false)
654
-    {
655
-        $this->set('REG_date', $REG_date);
656
-    }
657
-
658
-
659
-    /**
660
-     *    Set final price owing for this registration after all ticket/price modifications
661
-     *
662
-     * @access    public
663
-     * @param    float $REG_final_price
664
-     * @throws EE_Error
665
-     * @throws RuntimeException
666
-     */
667
-    public function set_final_price($REG_final_price = 0.00)
668
-    {
669
-        $this->set('REG_final_price', $REG_final_price);
670
-    }
671
-
672
-
673
-    /**
674
-     *    Set amount paid towards this registration's final price
675
-     *
676
-     * @access    public
677
-     * @param    float $REG_paid
678
-     * @throws EE_Error
679
-     * @throws RuntimeException
680
-     */
681
-    public function set_paid($REG_paid = 0.00)
682
-    {
683
-        $this->set('REG_paid', $REG_paid);
684
-    }
685
-
686
-
687
-    /**
688
-     *        Attendee Is Going
689
-     *
690
-     * @param        boolean $REG_att_is_going Attendee Is Going
691
-     * @throws EE_Error
692
-     * @throws RuntimeException
693
-     */
694
-    public function set_att_is_going($REG_att_is_going = false)
695
-    {
696
-        $this->set('REG_att_is_going', $REG_att_is_going);
697
-    }
698
-
699
-
700
-    /**
701
-     * Gets the related attendee
702
-     *
703
-     * @return EE_Attendee
704
-     * @throws EE_Error
705
-     */
706
-    public function attendee()
707
-    {
708
-        return $this->get_first_related('Attendee');
709
-    }
710
-
711
-
712
-    /**
713
-     *        get Event ID
714
-     */
715
-    public function event_ID()
716
-    {
717
-        return $this->get('EVT_ID');
718
-    }
719
-
720
-
721
-    /**
722
-     *        get Event ID
723
-     */
724
-    public function event_name()
725
-    {
726
-        $event = $this->event_obj();
727
-        if ($event) {
728
-            return $event->name();
729
-        } else {
730
-            return null;
731
-        }
732
-    }
733
-
734
-
735
-    /**
736
-     * Fetches the event this registration is for
737
-     *
738
-     * @return EE_Event
739
-     * @throws EE_Error
740
-     */
741
-    public function event_obj()
742
-    {
743
-        return $this->get_first_related('Event');
744
-    }
745
-
746
-
747
-    /**
748
-     *        get Attendee ID
749
-     */
750
-    public function attendee_ID()
751
-    {
752
-        return $this->get('ATT_ID');
753
-    }
754
-
755
-
756
-    /**
757
-     *        get PHP Session ID
758
-     */
759
-    public function session_ID()
760
-    {
761
-        return $this->get('REG_session');
762
-    }
763
-
764
-
765
-    /**
766
-     * Gets the string which represents the URL trigger for the receipt template in the message template system.
767
-     *
768
-     * @param string $messenger 'pdf' or 'html'.  Default 'html'.
769
-     * @return string
770
-     */
771
-    public function receipt_url($messenger = 'html')
772
-    {
773
-
774
-        /**
775
-         * The below will be deprecated one version after this.  We check first if there is a custom receipt template
776
-         * already in use on old system.  If there is then we just return the standard url for it.
777
-         *
778
-         * @since 4.5.0
779
-         */
780
-        $template_relative_path = 'modules/gateways/Invoice/lib/templates/receipt_body.template.php';
781
-        $has_custom             = EEH_Template::locate_template(
782
-            $template_relative_path,
783
-            array(),
784
-            true,
785
-            true,
786
-            true
787
-        );
788
-
789
-        if ($has_custom) {
790
-            return add_query_arg(array('receipt' => 'true'), $this->invoice_url('launch'));
791
-        }
792
-        return apply_filters('FHEE__EE_Registration__receipt_url__receipt_url', '', $this, $messenger, 'receipt');
793
-    }
794
-
795
-
796
-    /**
797
-     * Gets the string which represents the URL trigger for the invoice template in the message template system.
798
-     *
799
-     * @param string $messenger 'pdf' or 'html'.  Default 'html'.
800
-     * @return string
801
-     * @throws EE_Error
802
-     */
803
-    public function invoice_url($messenger = 'html')
804
-    {
805
-        /**
806
-         * The below will be deprecated one version after this.  We check first if there is a custom invoice template
807
-         * already in use on old system.  If there is then we just return the standard url for it.
808
-         *
809
-         * @since 4.5.0
810
-         */
811
-        $template_relative_path = 'modules/gateways/Invoice/lib/templates/invoice_body.template.php';
812
-        $has_custom             = EEH_Template::locate_template(
813
-            $template_relative_path,
814
-            array(),
815
-            true,
816
-            true,
817
-            true
818
-        );
819
-
820
-        if ($has_custom) {
821
-            if ($messenger == 'html') {
822
-                return $this->invoice_url('launch');
823
-            }
824
-            $route = $messenger == 'download' || $messenger == 'pdf' ? 'download_invoice' : 'launch_invoice';
825
-
826
-            $query_args = array('ee' => $route, 'id' => $this->reg_url_link());
827
-            if ($messenger == 'html') {
828
-                $query_args['html'] = true;
829
-            }
830
-            return add_query_arg($query_args, get_permalink(EE_Registry::instance()->CFG->core->thank_you_page_id));
831
-        }
832
-        return apply_filters('FHEE__EE_Registration__invoice_url__invoice_url', '', $this, $messenger, 'invoice');
833
-    }
834
-
835
-
836
-    /**
837
-     * get Registration URL Link
838
-     *
839
-     * @access public
840
-     * @return string
841
-     * @throws EE_Error
842
-     */
843
-    public function reg_url_link()
844
-    {
845
-        return (string) $this->get('REG_url_link');
846
-    }
847
-
848
-
849
-    /**
850
-     * Echoes out invoice_url()
851
-     *
852
-     * @param string $type 'download','launch', or 'html' (default is 'launch')
853
-     * @return void
854
-     * @throws EE_Error
855
-     */
856
-    public function e_invoice_url($type = 'launch')
857
-    {
858
-        echo $this->invoice_url($type);
859
-    }
860
-
861
-
862
-    /**
863
-     * Echoes out payment_overview_url
864
-     */
865
-    public function e_payment_overview_url()
866
-    {
867
-        echo $this->payment_overview_url();
868
-    }
869
-
870
-
871
-    /**
872
-     * Gets the URL for the checkout payment options reg step
873
-     * with this registration's REG_url_link added as a query parameter
874
-     *
875
-     * @param bool $clear_session Set to true when you want to clear the session on revisiting the
876
-     *                            payment overview url.
877
-     * @return string
878
-     * @throws InvalidInterfaceException
879
-     * @throws InvalidDataTypeException
880
-     * @throws EE_Error
881
-     * @throws InvalidArgumentException
882
-     */
883
-    public function payment_overview_url($clear_session = false)
884
-    {
885
-        return add_query_arg(
886
-            (array) apply_filters(
887
-                'FHEE__EE_Registration__payment_overview_url__query_args',
888
-                array(
889
-                    'e_reg_url_link' => $this->reg_url_link(),
890
-                    'step'           => 'payment_options',
891
-                    'revisit'        => true,
892
-                    'clear_session'  => (bool) $clear_session,
893
-                ),
894
-                $this
895
-            ),
896
-            EE_Registry::instance()->CFG->core->reg_page_url()
897
-        );
898
-    }
899
-
900
-
901
-    /**
902
-     * Gets the URL for the checkout attendee information reg step
903
-     * with this registration's REG_url_link added as a query parameter
904
-     *
905
-     * @return string
906
-     * @throws InvalidInterfaceException
907
-     * @throws InvalidDataTypeException
908
-     * @throws EE_Error
909
-     * @throws InvalidArgumentException
910
-     */
911
-    public function edit_attendee_information_url()
912
-    {
913
-        return add_query_arg(
914
-            (array) apply_filters(
915
-                'FHEE__EE_Registration__edit_attendee_information_url__query_args',
916
-                array(
917
-                    'e_reg_url_link' => $this->reg_url_link(),
918
-                    'step'           => 'attendee_information',
919
-                    'revisit'        => true,
920
-                ),
921
-                $this
922
-            ),
923
-            EE_Registry::instance()->CFG->core->reg_page_url()
924
-        );
925
-    }
926
-
927
-
928
-    /**
929
-     * Simply generates and returns the appropriate admin_url link to edit this registration
930
-     *
931
-     * @return string
932
-     * @throws EE_Error
933
-     */
934
-    public function get_admin_edit_url()
935
-    {
936
-        return EEH_URL::add_query_args_and_nonce(array(
937
-            'page'    => 'espresso_registrations',
938
-            'action'  => 'view_registration',
939
-            '_REG_ID' => $this->ID(),
940
-        ), admin_url('admin.php'));
941
-    }
942
-
943
-
944
-    /**
945
-     *    is_primary_registrant?
946
-     */
947
-    public function is_primary_registrant()
948
-    {
949
-        return $this->get('REG_count') == 1 ? true : false;
950
-    }
951
-
952
-
953
-    /**
954
-     * This returns the primary registration object for this registration group (which may be this object).
955
-     *
956
-     * @return EE_Registration
957
-     * @throws EE_Error
958
-     */
959
-    public function get_primary_registration()
960
-    {
961
-        if ($this->is_primary_registrant()) {
962
-            return $this;
963
-        }
964
-
965
-        //k reg_count !== 1 so let's get the EE_Registration object matching this txn_id and reg_count == 1
966
-        /** @var EE_Registration $primary_registrant */
967
-        $primary_registrant = EEM_Registration::instance()->get_one(array(
968
-            array(
969
-                'TXN_ID'    => $this->transaction_ID(),
970
-                'REG_count' => 1,
971
-            ),
972
-        ));
973
-        return $primary_registrant;
974
-    }
975
-
976
-
977
-    /**
978
-     *        get  Attendee Number
979
-     *
980
-     * @access        public
981
-     */
982
-    public function count()
983
-    {
984
-        return $this->get('REG_count');
985
-    }
986
-
987
-
988
-    /**
989
-     *        get Group Size
990
-     */
991
-    public function group_size()
992
-    {
993
-        return $this->get('REG_group_size');
994
-    }
995
-
996
-
997
-    /**
998
-     *        get Registration Date
999
-     */
1000
-    public function date()
1001
-    {
1002
-        return $this->get('REG_date');
1003
-    }
1004
-
1005
-
1006
-    /**
1007
-     * gets a pretty date
1008
-     *
1009
-     * @param string $date_format
1010
-     * @param string $time_format
1011
-     * @return string
1012
-     * @throws EE_Error
1013
-     */
1014
-    public function pretty_date($date_format = null, $time_format = null)
1015
-    {
1016
-        return $this->get_datetime('REG_date', $date_format, $time_format);
1017
-    }
1018
-
1019
-
1020
-    /**
1021
-     * final_price
1022
-     * the registration's share of the transaction total, so that the
1023
-     * sum of all the transaction's REG_final_prices equal the transaction's total
1024
-     *
1025
-     * @return float
1026
-     * @throws EE_Error
1027
-     */
1028
-    public function final_price()
1029
-    {
1030
-        return $this->get('REG_final_price');
1031
-    }
1032
-
1033
-
1034
-    /**
1035
-     * pretty_final_price
1036
-     *  final price as formatted string, with correct decimal places and currency symbol
1037
-     *
1038
-     * @return string
1039
-     * @throws EE_Error
1040
-     */
1041
-    public function pretty_final_price()
1042
-    {
1043
-        return $this->get_pretty('REG_final_price');
1044
-    }
1045
-
1046
-
1047
-    /**
1048
-     * get paid (yeah)
1049
-     *
1050
-     * @return float
1051
-     * @throws EE_Error
1052
-     */
1053
-    public function paid()
1054
-    {
1055
-        return $this->get('REG_paid');
1056
-    }
1057
-
1058
-
1059
-    /**
1060
-     * pretty_paid
1061
-     *
1062
-     * @return float
1063
-     * @throws EE_Error
1064
-     */
1065
-    public function pretty_paid()
1066
-    {
1067
-        return $this->get_pretty('REG_paid');
1068
-    }
1069
-
1070
-
1071
-    /**
1072
-     * owes_monies_and_can_pay
1073
-     * whether or not this registration has monies owing and it's' status allows payment
1074
-     *
1075
-     * @param array $requires_payment
1076
-     * @return bool
1077
-     * @throws EE_Error
1078
-     */
1079
-    public function owes_monies_and_can_pay($requires_payment = array())
1080
-    {
1081
-        // these reg statuses require payment (if event is not free)
1082
-        $requires_payment = ! empty($requires_payment)
1083
-            ? $requires_payment
1084
-            : EEM_Registration::reg_statuses_that_allow_payment();
1085
-        if (in_array($this->status_ID(), $requires_payment) &&
1086
-            $this->final_price() != 0 &&
1087
-            $this->final_price() != $this->paid()
1088
-        ) {
1089
-            return true;
1090
-        } else {
1091
-            return false;
1092
-        }
1093
-    }
1094
-
1095
-
1096
-    /**
1097
-     * Prints out the return value of $this->pretty_status()
1098
-     *
1099
-     * @param bool $show_icons
1100
-     * @return void
1101
-     * @throws EE_Error
1102
-     */
1103
-    public function e_pretty_status($show_icons = false)
1104
-    {
1105
-        echo $this->pretty_status($show_icons);
1106
-    }
1107
-
1108
-
1109
-    /**
1110
-     * Returns a nice version of the status for displaying to customers
1111
-     *
1112
-     * @param bool $show_icons
1113
-     * @return string
1114
-     * @throws EE_Error
1115
-     */
1116
-    public function pretty_status($show_icons = false)
1117
-    {
1118
-        $status = EEM_Status::instance()->localized_status(
1119
-            array($this->status_ID() => esc_html__('unknown', 'event_espresso')),
1120
-            false,
1121
-            'sentence'
1122
-        );
1123
-        $icon   = '';
1124
-        switch ($this->status_ID()) {
1125
-            case EEM_Registration::status_id_approved:
1126
-                $icon = $show_icons
1127
-                    ? '<span class="dashicons dashicons-star-filled ee-icon-size-16 green-text"></span>'
1128
-                    : '';
1129
-                break;
1130
-            case EEM_Registration::status_id_pending_payment:
1131
-                $icon = $show_icons
1132
-                    ? '<span class="dashicons dashicons-star-half ee-icon-size-16 orange-text"></span>'
1133
-                    : '';
1134
-                break;
1135
-            case EEM_Registration::status_id_not_approved:
1136
-                $icon = $show_icons
1137
-                    ? '<span class="dashicons dashicons-marker ee-icon-size-16 orange-text"></span>'
1138
-                    : '';
1139
-                break;
1140
-            case EEM_Registration::status_id_cancelled:
1141
-                $icon = $show_icons
1142
-                    ? '<span class="dashicons dashicons-no ee-icon-size-16 lt-grey-text"></span>'
1143
-                    : '';
1144
-                break;
1145
-            case EEM_Registration::status_id_incomplete:
1146
-                $icon = $show_icons
1147
-                    ? '<span class="dashicons dashicons-no ee-icon-size-16 lt-orange-text"></span>'
1148
-                    : '';
1149
-                break;
1150
-            case EEM_Registration::status_id_declined:
1151
-                $icon = $show_icons
1152
-                    ? '<span class="dashicons dashicons-no ee-icon-size-16 red-text"></span>'
1153
-                    : '';
1154
-                break;
1155
-            case EEM_Registration::status_id_wait_list:
1156
-                $icon = $show_icons
1157
-                    ? '<span class="dashicons dashicons-clipboard ee-icon-size-16 purple-text"></span>'
1158
-                    : '';
1159
-                break;
1160
-        }
1161
-        return $icon . $status[$this->status_ID()];
1162
-    }
1163
-
1164
-
1165
-    /**
1166
-     *        get Attendee Is Going
1167
-     */
1168
-    public function att_is_going()
1169
-    {
1170
-        return $this->get('REG_att_is_going');
1171
-    }
1172
-
1173
-
1174
-    /**
1175
-     * Gets related answers
1176
-     *
1177
-     * @param array $query_params like EEM_Base::get_all
1178
-     * @return EE_Answer[]
1179
-     * @throws EE_Error
1180
-     */
1181
-    public function answers($query_params = null)
1182
-    {
1183
-        return $this->get_many_related('Answer', $query_params);
1184
-    }
1185
-
1186
-
1187
-    /**
1188
-     * Gets the registration's answer value to the specified question
1189
-     * (either the question's ID or a question object)
1190
-     *
1191
-     * @param EE_Question|int $question
1192
-     * @param bool            $pretty_value
1193
-     * @return array|string if pretty_value= true, the result will always be a string
1194
-     * (because the answer might be an array of answer values, so passing pretty_value=true
1195
-     * will convert it into some kind of string)
1196
-     * @throws EE_Error
1197
-     */
1198
-    public function answer_value_to_question($question, $pretty_value = true)
1199
-    {
1200
-        $question_id = EEM_Question::instance()->ensure_is_ID($question);
1201
-        return EEM_Answer::instance()->get_answer_value_to_question($this, $question_id, $pretty_value);
1202
-    }
1203
-
1204
-
1205
-    /**
1206
-     * question_groups
1207
-     * returns an array of EE_Question_Group objects for this registration
1208
-     *
1209
-     * @return EE_Question_Group[]
1210
-     * @throws EE_Error
1211
-     * @throws EntityNotFoundException
1212
-     */
1213
-    public function question_groups()
1214
-    {
1215
-        $question_groups = array();
1216
-        if ($this->event() instanceof EE_Event) {
1217
-            $question_groups = $this->event()->question_groups(
1218
-                array(
1219
-                    array(
1220
-                        'Event_Question_Group.EQG_primary' => $this->count() == 1 ? true : false,
1221
-                    ),
1222
-                    'order_by' => array('QSG_order' => 'ASC'),
1223
-                )
1224
-            );
1225
-        }
1226
-        return $question_groups;
1227
-    }
1228
-
1229
-
1230
-    /**
1231
-     * count_question_groups
1232
-     * returns a count of the number of EE_Question_Group objects for this registration
1233
-     *
1234
-     * @return int
1235
-     * @throws EE_Error
1236
-     * @throws EntityNotFoundException
1237
-     */
1238
-    public function count_question_groups()
1239
-    {
1240
-        $qg_count = 0;
1241
-        if ($this->event() instanceof EE_Event) {
1242
-            $qg_count = $this->event()->count_related(
1243
-                'Question_Group',
1244
-                array(
1245
-                    array(
1246
-                        'Event_Question_Group.EQG_primary' => $this->count() == 1 ? true : false,
1247
-                    ),
1248
-                )
1249
-            );
1250
-        }
1251
-        return $qg_count;
1252
-    }
1253
-
1254
-
1255
-    /**
1256
-     * Returns the registration date in the 'standard' string format
1257
-     * (function may be improved in the future to allow for different formats and timezones)
1258
-     *
1259
-     * @return string
1260
-     * @throws EE_Error
1261
-     */
1262
-    public function reg_date()
1263
-    {
1264
-        return $this->get_datetime('REG_date');
1265
-    }
1266
-
1267
-
1268
-    /**
1269
-     * Gets the datetime-ticket for this registration (ie, it can be used to isolate
1270
-     * the ticket this registration purchased, or the datetime they have registered
1271
-     * to attend)
1272
-     *
1273
-     * @return EE_Datetime_Ticket
1274
-     * @throws EE_Error
1275
-     */
1276
-    public function datetime_ticket()
1277
-    {
1278
-        return $this->get_first_related('Datetime_Ticket');
1279
-    }
1280
-
1281
-
1282
-    /**
1283
-     * Sets the registration's datetime_ticket.
1284
-     *
1285
-     * @param EE_Datetime_Ticket $datetime_ticket
1286
-     * @return EE_Datetime_Ticket
1287
-     * @throws EE_Error
1288
-     */
1289
-    public function set_datetime_ticket($datetime_ticket)
1290
-    {
1291
-        return $this->_add_relation_to($datetime_ticket, 'Datetime_Ticket');
1292
-    }
1293
-
1294
-    /**
1295
-     * Gets deleted
1296
-     *
1297
-     * @return bool
1298
-     * @throws EE_Error
1299
-     */
1300
-    public function deleted()
1301
-    {
1302
-        return $this->get('REG_deleted');
1303
-    }
1304
-
1305
-    /**
1306
-     * Sets deleted
1307
-     *
1308
-     * @param boolean $deleted
1309
-     * @return bool
1310
-     * @throws EE_Error
1311
-     * @throws RuntimeException
1312
-     */
1313
-    public function set_deleted($deleted)
1314
-    {
1315
-        if ($deleted) {
1316
-            $this->delete();
1317
-        } else {
1318
-            $this->restore();
1319
-        }
1320
-    }
1321
-
1322
-
1323
-    /**
1324
-     * Get the status object of this object
1325
-     *
1326
-     * @return EE_Status
1327
-     * @throws EE_Error
1328
-     */
1329
-    public function status_obj()
1330
-    {
1331
-        return $this->get_first_related('Status');
1332
-    }
1333
-
1334
-
1335
-    /**
1336
-     * Returns the number of times this registration has checked into any of the datetimes
1337
-     * its available for
1338
-     *
1339
-     * @return int
1340
-     * @throws EE_Error
1341
-     */
1342
-    public function count_checkins()
1343
-    {
1344
-        return $this->get_model()->count_related($this, 'Checkin');
1345
-    }
1346
-
1347
-
1348
-    /**
1349
-     * Returns the number of current Check-ins this registration is checked into for any of the datetimes the
1350
-     * registration is for.  Note, this is ONLY checked in (does not include checkedout)
1351
-     *
1352
-     * @return int
1353
-     * @throws EE_Error
1354
-     */
1355
-    public function count_checkins_not_checkedout()
1356
-    {
1357
-        return $this->get_model()->count_related($this, 'Checkin', array(array('CHK_in' => 1)));
1358
-    }
1359
-
1360
-
1361
-    /**
1362
-     * The purpose of this method is simply to check whether this registration can checkin to the given datetime.
1363
-     *
1364
-     * @param int | EE_Datetime $DTT_OR_ID      The datetime the registration is being checked against
1365
-     * @param bool              $check_approved This is used to indicate whether the caller wants can_checkin to also
1366
-     *                                          consider registration status as well as datetime access.
1367
-     * @return bool
1368
-     * @throws EE_Error
1369
-     */
1370
-    public function can_checkin($DTT_OR_ID, $check_approved = true)
1371
-    {
1372
-        $DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID);
1373
-
1374
-        //first check registration status
1375
-        if (($check_approved && ! $this->is_approved()) || ! $DTT_ID) {
1376
-            return false;
1377
-        }
1378
-        //is there a datetime ticket that matches this dtt_ID?
1379
-        if (! (EEM_Datetime_Ticket::instance()->exists(array(
1380
-            array(
1381
-                'TKT_ID' => $this->get('TKT_ID'),
1382
-                'DTT_ID' => $DTT_ID,
1383
-            ),
1384
-        )))
1385
-        ) {
1386
-            return false;
1387
-        }
1388
-
1389
-        //final check is against TKT_uses
1390
-        return $this->verify_can_checkin_against_TKT_uses($DTT_ID);
1391
-    }
1392
-
1393
-
1394
-    /**
1395
-     * This method verifies whether the user can checkin for the given datetime considering the max uses value set on
1396
-     * the ticket. To do this,  a query is done to get the count of the datetime records already checked into.  If the
1397
-     * datetime given does not have a check-in record and checking in for that datetime will exceed the allowed uses,
1398
-     * then return false.  Otherwise return true.
1399
-     *
1400
-     * @param int | EE_Datetime $DTT_OR_ID The datetime the registration is being checked against
1401
-     * @return bool true means can checkin.  false means cannot checkin.
1402
-     * @throws EE_Error
1403
-     */
1404
-    public function verify_can_checkin_against_TKT_uses($DTT_OR_ID)
1405
-    {
1406
-        $DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID);
1407
-
1408
-        if (! $DTT_ID) {
1409
-            return false;
1410
-        }
1411
-
1412
-        $max_uses = $this->ticket() instanceof EE_Ticket ? $this->ticket()->uses() : EE_INF;
1413
-
1414
-        // if max uses is not set or equals infinity then return true cause its not a factor for whether user can
1415
-        // check-in or not.
1416
-        if (! $max_uses || $max_uses === EE_INF) {
1417
-            return true;
1418
-        }
1419
-
1420
-        //does this datetime have a checkin record?  If so, then the dtt count has already been verified so we can just
1421
-        //go ahead and toggle.
1422
-        if (EEM_Checkin::instance()->exists(array(array('REG_ID' => $this->ID(), 'DTT_ID' => $DTT_ID)))) {
1423
-            return true;
1424
-        }
1425
-
1426
-        //made it here so the last check is whether the number of checkins per unique datetime on this registration
1427
-        //disallows further check-ins.
1428
-        $count_unique_dtt_checkins = EEM_Checkin::instance()->count(array(
1429
-            array(
1430
-                'REG_ID' => $this->ID(),
1431
-                'CHK_in' => true,
1432
-            ),
1433
-        ), 'DTT_ID', true);
1434
-        // checkins have already reached their max number of uses
1435
-        // so registrant can NOT checkin
1436
-        if ($count_unique_dtt_checkins >= $max_uses) {
1437
-            EE_Error::add_error(
1438
-                esc_html__(
1439
-                    'Check-in denied because number of datetime uses for the ticket has been reached or exceeded.',
1440
-                    'event_espresso'
1441
-                ),
1442
-                __FILE__,
1443
-                __FUNCTION__,
1444
-                __LINE__
1445
-            );
1446
-            return false;
1447
-        }
1448
-        return true;
1449
-    }
1450
-
1451
-
1452
-    /**
1453
-     * toggle Check-in status for this registration
1454
-     * Check-ins are toggled in the following order:
1455
-     * never checked in -> checked in
1456
-     * checked in -> checked out
1457
-     * checked out -> checked in
1458
-     *
1459
-     * @param  int $DTT_ID  include specific datetime to toggle Check-in for.
1460
-     *                      If not included or null, then it is assumed latest datetime is being toggled.
1461
-     * @param bool $verify  If true then can_checkin() is used to verify whether the person
1462
-     *                      can be checked in or not.  Otherwise this forces change in checkin status.
1463
-     * @return bool|int     the chk_in status toggled to OR false if nothing got changed.
1464
-     * @throws EE_Error
1465
-     */
1466
-    public function toggle_checkin_status($DTT_ID = null, $verify = false)
1467
-    {
1468
-        if (empty($DTT_ID)) {
1469
-            $datetime = $this->get_latest_related_datetime();
1470
-            $DTT_ID   = $datetime instanceof EE_Datetime ? $datetime->ID() : 0;
1471
-            // verify the registration can checkin for the given DTT_ID
1472
-        } elseif (! $this->can_checkin($DTT_ID, $verify)) {
1473
-            EE_Error::add_error(
1474
-                sprintf(
1475
-                    esc_html__(
1476
-                        'The given registration (ID:%1$d) can not be checked in to the given DTT_ID (%2$d), because the registration does not have access',
1477
-                        'event_espresso'
1478
-                    ),
1479
-                    $this->ID(),
1480
-                    $DTT_ID
1481
-                ),
1482
-                __FILE__,
1483
-                __FUNCTION__,
1484
-                __LINE__
1485
-            );
1486
-            return false;
1487
-        }
1488
-        $status_paths = array(
1489
-            EE_Checkin::status_checked_never => EE_Checkin::status_checked_in,
1490
-            EE_Checkin::status_checked_in    => EE_Checkin::status_checked_out,
1491
-            EE_Checkin::status_checked_out   => EE_Checkin::status_checked_in,
1492
-        );
1493
-        //start by getting the current status so we know what status we'll be changing to.
1494
-        $cur_status = $this->check_in_status_for_datetime($DTT_ID, null);
1495
-        $status_to  = $status_paths[$cur_status];
1496
-        // database only records true for checked IN or false for checked OUT
1497
-        // no record ( null ) means checked in NEVER, but we obviously don't save that
1498
-        $new_status = $status_to === EE_Checkin::status_checked_in ? true : false;
1499
-        // add relation - note Check-ins are always creating new rows
1500
-        // because we are keeping track of Check-ins over time.
1501
-        // Eventually we'll probably want to show a list table
1502
-        // for the individual Check-ins so that they can be managed.
1503
-        $checkin = EE_Checkin::new_instance(array(
1504
-            'REG_ID' => $this->ID(),
1505
-            'DTT_ID' => $DTT_ID,
1506
-            'CHK_in' => $new_status,
1507
-        ));
1508
-        // if the record could not be saved then return false
1509
-        if ($checkin->save() === 0) {
1510
-            if (WP_DEBUG) {
1511
-                global $wpdb;
1512
-                $error = sprintf(
1513
-                    esc_html__(
1514
-                        'Registration check in update failed because of the following database error: %1$s%2$s',
1515
-                        'event_espresso'
1516
-                    ),
1517
-                    '<br />',
1518
-                    $wpdb->last_error
1519
-                );
1520
-            } else {
1521
-                $error = esc_html__(
1522
-                    'Registration check in update failed because of an unknown database error',
1523
-                    'event_espresso'
1524
-                );
1525
-            }
1526
-            EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__);
1527
-            return false;
1528
-        }
1529
-        return $status_to;
1530
-    }
1531
-
1532
-
1533
-    /**
1534
-     * Returns the latest datetime related to this registration (via the ticket attached to the registration).
1535
-     * "Latest" is defined by the `DTT_EVT_start` column.
1536
-     *
1537
-     * @return EE_Datetime|null
1538
-     * @throws EE_Error
1539
-     */
1540
-    public function get_latest_related_datetime()
1541
-    {
1542
-        return EEM_Datetime::instance()->get_one(
1543
-            array(
1544
-                array(
1545
-                    'Ticket.Registration.REG_ID' => $this->ID(),
1546
-                ),
1547
-                'order_by' => array('DTT_EVT_start' => 'DESC'),
1548
-            )
1549
-        );
1550
-    }
1551
-
1552
-
1553
-    /**
1554
-     * Returns the earliest datetime related to this registration (via the ticket attached to the registration).
1555
-     * "Earliest" is defined by the `DTT_EVT_start` column.
1556
-     *
1557
-     * @throws EE_Error
1558
-     */
1559
-    public function get_earliest_related_datetime()
1560
-    {
1561
-        return EEM_Datetime::instance()->get_one(
1562
-            array(
1563
-                array(
1564
-                    'Ticket.Registration.REG_ID' => $this->ID(),
1565
-                ),
1566
-                'order_by' => array('DTT_EVT_start' => 'ASC'),
1567
-            )
1568
-        );
1569
-    }
1570
-
1571
-
1572
-    /**
1573
-     * This method simply returns the check-in status for this registration and the given datetime.
1574
-     * If neither the datetime nor the checkin values are provided as arguments,
1575
-     * then this will return the LATEST check-in status for the registration across all datetimes it belongs to.
1576
-     *
1577
-     * @param  int       $DTT_ID  The ID of the datetime we're checking against
1578
-     *                            (if empty we'll get the primary datetime for
1579
-     *                            this registration (via event) and use it's ID);
1580
-     * @param EE_Checkin $checkin If present, we use the given checkin object rather than the dtt_id.
1581
-     *
1582
-     * @return int                Integer representing Check-in status.
1583
-     * @throws EE_Error
1584
-     */
1585
-    public function check_in_status_for_datetime($DTT_ID = 0, $checkin = null)
1586
-    {
1587
-        $checkin_query_params = array(
1588
-            'order_by' => array('CHK_timestamp' => 'DESC'),
1589
-        );
1590
-
1591
-        if ($DTT_ID > 0) {
1592
-            $checkin_query_params[0] = array('DTT_ID' => $DTT_ID);
1593
-        }
1594
-
1595
-        //get checkin object (if exists)
1596
-        $checkin = $checkin instanceof EE_Checkin
1597
-            ? $checkin
1598
-            : $this->get_first_related('Checkin', $checkin_query_params);
1599
-        if ($checkin instanceof EE_Checkin) {
1600
-            if ($checkin->get('CHK_in')) {
1601
-                return EE_Checkin::status_checked_in; //checked in
1602
-            }
1603
-            return EE_Checkin::status_checked_out; //had checked in but is now checked out.
1604
-        }
1605
-        return EE_Checkin::status_checked_never; //never been checked in
1606
-    }
1607
-
1608
-
1609
-    /**
1610
-     * This method returns a localized message for the toggled Check-in message.
1611
-     *
1612
-     * @param  int $DTT_ID include specific datetime to get the correct Check-in message.  If not included or null,
1613
-     *                     then it is assumed Check-in for primary datetime was toggled.
1614
-     * @param bool $error  This just flags that you want an error message returned. This is put in so that the error
1615
-     *                     message can be customized with the attendee name.
1616
-     * @return string internationalized message
1617
-     * @throws EE_Error
1618
-     */
1619
-    public function get_checkin_msg($DTT_ID, $error = false)
1620
-    {
1621
-        //let's get the attendee first so we can include the name of the attendee
1622
-        $attendee = $this->get_first_related('Attendee');
1623
-        if ($attendee instanceof EE_Attendee) {
1624
-            if ($error) {
1625
-                return sprintf(__("%s's check-in status was not changed.", "event_espresso"), $attendee->full_name());
1626
-            }
1627
-            $cur_status = $this->check_in_status_for_datetime($DTT_ID);
1628
-            //what is the status message going to be?
1629
-            switch ($cur_status) {
1630
-                case EE_Checkin::status_checked_never:
1631
-                    return sprintf(__("%s has been removed from Check-in records", "event_espresso"),
1632
-                        $attendee->full_name());
1633
-                    break;
1634
-                case EE_Checkin::status_checked_in:
1635
-                    return sprintf(__('%s has been checked in', 'event_espresso'), $attendee->full_name());
1636
-                    break;
1637
-                case EE_Checkin::status_checked_out:
1638
-                    return sprintf(__('%s has been checked out', 'event_espresso'), $attendee->full_name());
1639
-                    break;
1640
-            }
1641
-        }
1642
-        return esc_html__("The check-in status could not be determined.", "event_espresso");
1643
-    }
1644
-
1645
-
1646
-    /**
1647
-     * Returns the related EE_Transaction to this registration
1648
-     *
1649
-     * @return EE_Transaction
1650
-     * @throws EE_Error
1651
-     * @throws EntityNotFoundException
1652
-     */
1653
-    public function transaction()
1654
-    {
1655
-        $transaction = $this->get_first_related('Transaction');
1656
-        if (! $transaction instanceof \EE_Transaction) {
1657
-            throw new EntityNotFoundException('Transaction ID', $this->transaction_ID());
1658
-        }
1659
-        return $transaction;
1660
-    }
1661
-
1662
-
1663
-    /**
1664
-     *        get Registration Code
1665
-     */
1666
-    public function reg_code()
1667
-    {
1668
-        return $this->get('REG_code');
1669
-    }
1670
-
1671
-
1672
-    /**
1673
-     *        get Transaction ID
1674
-     */
1675
-    public function transaction_ID()
1676
-    {
1677
-        return $this->get('TXN_ID');
1678
-    }
1679
-
1680
-
1681
-    /**
1682
-     * @return int
1683
-     * @throws EE_Error
1684
-     */
1685
-    public function ticket_ID()
1686
-    {
1687
-        return $this->get('TKT_ID');
1688
-    }
1689
-
1690
-
1691
-    /**
1692
-     *        Set Registration Code
1693
-     *
1694
-     * @access    public
1695
-     * @param    string  $REG_code Registration Code
1696
-     * @param    boolean $use_default
1697
-     * @throws EE_Error
1698
-     */
1699
-    public function set_reg_code($REG_code, $use_default = false)
1700
-    {
1701
-        if (empty($REG_code)) {
1702
-            EE_Error::add_error(
1703
-                esc_html__('REG_code can not be empty.', 'event_espresso'),
1704
-                __FILE__,
1705
-                __FUNCTION__,
1706
-                __LINE__
1707
-            );
1708
-            return;
1709
-        }
1710
-        if (! $this->reg_code()) {
1711
-            parent::set('REG_code', $REG_code, $use_default);
1712
-        } else {
1713
-            EE_Error::doing_it_wrong(
1714
-                __CLASS__ . '::' . __FUNCTION__,
1715
-                esc_html__('Can not change a registration REG_code once it has been set.', 'event_espresso'),
1716
-                '4.6.0'
1717
-            );
1718
-        }
1719
-    }
1720
-
1721
-
1722
-    /**
1723
-     * Returns all other registrations in the same group as this registrant who have the same ticket option.
1724
-     * Note, if you want to just get all registrations in the same transaction (group), use:
1725
-     *    $registration->transaction()->registrations();
1726
-     *
1727
-     * @since 4.5.0
1728
-     * @return EE_Registration[] or empty array if this isn't a group registration.
1729
-     * @throws EE_Error
1730
-     */
1731
-    public function get_all_other_registrations_in_group()
1732
-    {
1733
-        if ($this->group_size() < 2) {
1734
-            return array();
1735
-        }
1736
-
1737
-        $query[0] = array(
1738
-            'TXN_ID' => $this->transaction_ID(),
1739
-            'REG_ID' => array('!=', $this->ID()),
1740
-            'TKT_ID' => $this->ticket_ID(),
1741
-        );
1742
-        /** @var EE_Registration[] $registrations */
1743
-        $registrations = $this->get_model()->get_all($query);
1744
-        return $registrations;
1745
-    }
1746
-
1747
-    /**
1748
-     * Return the link to the admin details for the object.
1749
-     *
1750
-     * @return string
1751
-     * @throws EE_Error
1752
-     */
1753
-    public function get_admin_details_link()
1754
-    {
1755
-        EE_Registry::instance()->load_helper('URL');
1756
-        return EEH_URL::add_query_args_and_nonce(
1757
-            array(
1758
-                'page'    => 'espresso_registrations',
1759
-                'action'  => 'view_registration',
1760
-                '_REG_ID' => $this->ID(),
1761
-            ),
1762
-            admin_url('admin.php')
1763
-        );
1764
-    }
1765
-
1766
-    /**
1767
-     * Returns the link to the editor for the object.  Sometimes this is the same as the details.
1768
-     *
1769
-     * @return string
1770
-     * @throws EE_Error
1771
-     */
1772
-    public function get_admin_edit_link()
1773
-    {
1774
-        return $this->get_admin_details_link();
1775
-    }
1776
-
1777
-    /**
1778
-     * Returns the link to a settings page for the object.
1779
-     *
1780
-     * @return string
1781
-     * @throws EE_Error
1782
-     */
1783
-    public function get_admin_settings_link()
1784
-    {
1785
-        return $this->get_admin_details_link();
1786
-    }
1787
-
1788
-    /**
1789
-     * Returns the link to the "overview" for the object (typically the "list table" view).
1790
-     *
1791
-     * @return string
1792
-     */
1793
-    public function get_admin_overview_link()
1794
-    {
1795
-        EE_Registry::instance()->load_helper('URL');
1796
-        return EEH_URL::add_query_args_and_nonce(
1797
-            array(
1798
-                'page' => 'espresso_registrations',
1799
-            ),
1800
-            admin_url('admin.php')
1801
-        );
1802
-    }
1803
-
1804
-
1805
-    /**
1806
-     * @param array $query_params
1807
-     *
1808
-     * @return \EE_Registration[]
1809
-     * @throws EE_Error
1810
-     */
1811
-    public function payments($query_params = array())
1812
-    {
1813
-        return $this->get_many_related('Payment', $query_params);
1814
-    }
1815
-
1816
-
1817
-    /**
1818
-     * @param array $query_params
1819
-     *
1820
-     * @return \EE_Registration_Payment[]
1821
-     * @throws EE_Error
1822
-     */
1823
-    public function registration_payments($query_params = array())
1824
-    {
1825
-        return $this->get_many_related('Registration_Payment', $query_params);
1826
-    }
1827
-
1828
-
1829
-    /**
1830
-     * This grabs the payment method corresponding to the last payment made for the amount owing on the registration.
1831
-     * Note: if there are no payments on the registration there will be no payment method returned.
1832
-     *
1833
-     * @return EE_Payment_Method|null
1834
-     */
1835
-    public function payment_method()
1836
-    {
1837
-        return EEM_Payment_Method::instance()->get_last_used_for_registration($this);
1838
-    }
1839
-
1840
-
1841
-    /**
1842
-     * @return \EE_Line_Item
1843
-     * @throws EntityNotFoundException
1844
-     * @throws EE_Error
1845
-     */
1846
-    public function ticket_line_item()
1847
-    {
1848
-        $ticket            = $this->ticket();
1849
-        $transaction       = $this->transaction();
1850
-        $line_item         = null;
1851
-        $ticket_line_items = \EEH_Line_Item::get_line_items_by_object_type_and_IDs(
1852
-            $transaction->total_line_item(),
1853
-            'Ticket',
1854
-            array($ticket->ID())
1855
-        );
1856
-        foreach ($ticket_line_items as $ticket_line_item) {
1857
-            if (
1858
-                $ticket_line_item instanceof \EE_Line_Item
1859
-                && $ticket_line_item->OBJ_type() === 'Ticket'
1860
-                && $ticket_line_item->OBJ_ID() === $ticket->ID()
1861
-            ) {
1862
-                $line_item = $ticket_line_item;
1863
-                break;
1864
-            }
1865
-        }
1866
-        if (! ($line_item instanceof \EE_Line_Item && $line_item->OBJ_type() === 'Ticket')) {
1867
-            throw new EntityNotFoundException('Line Item Ticket ID', $ticket->ID());
1868
-        }
1869
-        return $line_item;
1870
-    }
1871
-
1872
-
1873
-    /**
1874
-     * Soft Deletes this model object.
1875
-     *
1876
-     * @return boolean | int
1877
-     * @throws RuntimeException
1878
-     * @throws EE_Error
1879
-     */
1880
-    public function delete()
1881
-    {
1882
-        if ($this->update_extra_meta(EE_Registration::PRE_TRASH_REG_STATUS_KEY, $this->status_ID()) === true) {
1883
-            $this->set_status(EEM_Registration::status_id_cancelled);
1884
-        }
1885
-        return parent::delete();
1886
-    }
1887
-
1888
-
1889
-    /**
1890
-     * Restores whatever the previous status was on a registration before it was trashed (if possible)
1891
-     *
1892
-     * @throws EE_Error
1893
-     * @throws RuntimeException
1894
-     */
1895
-    public function restore()
1896
-    {
1897
-        $previous_status = $this->get_extra_meta(
1898
-            EE_Registration::PRE_TRASH_REG_STATUS_KEY,
1899
-            true,
1900
-            EEM_Registration::status_id_cancelled
1901
-        );
1902
-        if ($previous_status) {
1903
-            $this->delete_extra_meta(EE_Registration::PRE_TRASH_REG_STATUS_KEY);
1904
-            $this->set_status($previous_status);
1905
-        }
1906
-        return parent::restore();
1907
-    }
1908
-
1909
-
1910
-    /**
1911
-     * possibly toggle Registration status based on comparison of REG_paid vs REG_final_price
1912
-     *
1913
-     * @param  boolean $trigger_set_status_logic EE_Registration::set_status() can trigger additional logic
1914
-     *                                           depending on whether the reg status changes to or from "Approved"
1915
-     * @return boolean whether the Registration status was updated
1916
-     * @throws EE_Error
1917
-     * @throws RuntimeException
1918
-     */
1919
-    public function updateStatusBasedOnTotalPaid($trigger_set_status_logic = true)
1920
-    {
1921
-        $paid = $this->paid();
1922
-        $price = $this->final_price();
1923
-        switch(true) {
1924
-            // overpaid or paid
1925
-            case EEH_Money::compare_floats($paid, $price, '>'):
1926
-            case EEH_Money::compare_floats($paid, $price):
1927
-                $new_status = EEM_Registration::status_id_approved;
1928
-                break;
1929
-            //  underpaid
1930
-            case EEH_Money::compare_floats($paid, $price, '<'):
1931
-                $new_status = EEM_Registration::status_id_pending_payment;
1932
-                break;
1933
-            // uhhh Houston...
1934
-            default:
1935
-                throw new RuntimeException(
1936
-                    esc_html__('The total paid calculation for this registration is inaccurate.', 'event_espresso')
1937
-                );
1938
-        }
1939
-        if ($new_status !== $this->status_ID()) {
1940
-            if ($trigger_set_status_logic) {
1941
-                return $this->set_status($new_status);
1942
-            }
1943
-            parent::set('STS_ID', $new_status);
1944
-            return true;
1945
-        }
1946
-        return false;
1947
-    }
1948
-
1949
-
1950
-    /*************************** DEPRECATED ***************************/
1951
-
1952
-
1953
-    /**
1954
-     * @deprecated
1955
-     * @since     4.7.0
1956
-     * @access    public
1957
-     */
1958
-    public function price_paid()
1959
-    {
1960
-        EE_Error::doing_it_wrong('EE_Registration::price_paid()',
1961
-            esc_html__('This method is deprecated, please use EE_Registration::final_price() instead.', 'event_espresso'),
1962
-            '4.7.0');
1963
-        return $this->final_price();
1964
-    }
1965
-
1966
-
1967
-    /**
1968
-     * @deprecated
1969
-     * @since     4.7.0
1970
-     * @access    public
1971
-     * @param    float $REG_final_price
1972
-     * @throws EE_Error
1973
-     * @throws RuntimeException
1974
-     */
1975
-    public function set_price_paid($REG_final_price = 0.00)
1976
-    {
1977
-        EE_Error::doing_it_wrong('EE_Registration::set_price_paid()',
1978
-            esc_html__('This method is deprecated, please use EE_Registration::set_final_price() instead.', 'event_espresso'),
1979
-            '4.7.0');
1980
-        $this->set_final_price($REG_final_price);
1981
-    }
1982
-
1983
-
1984
-    /**
1985
-     * @deprecated
1986
-     * @since 4.7.0
1987
-     * @return string
1988
-     * @throws EE_Error
1989
-     */
1990
-    public function pretty_price_paid()
1991
-    {
1992
-        EE_Error::doing_it_wrong('EE_Registration::pretty_price_paid()',
1993
-            esc_html__('This method is deprecated, please use EE_Registration::pretty_final_price() instead.',
1994
-                'event_espresso'), '4.7.0');
1995
-        return $this->pretty_final_price();
1996
-    }
1997
-
1998
-
1999
-    /**
2000
-     * Gets the primary datetime related to this registration via the related Event to this registration
2001
-     *
2002
-     * @deprecated 4.9.17
2003
-     * @return EE_Datetime
2004
-     * @throws EE_Error
2005
-     * @throws EntityNotFoundException
2006
-     */
2007
-    public function get_related_primary_datetime()
2008
-    {
2009
-        EE_Error::doing_it_wrong(
2010
-            __METHOD__,
2011
-            esc_html__(
2012
-                'Use EE_Registration::get_latest_related_datetime() or EE_Registration::get_earliest_related_datetime()',
2013
-                'event_espresso'
2014
-            ),
2015
-            '4.9.17',
2016
-            '5.0.0'
2017
-        );
2018
-        return $this->event()->primary_datetime();
2019
-    }
21
+	/**
22
+	 * Used to reference when a registration has never been checked in.
23
+	 *
24
+	 * @deprecated use \EE_Checkin::status_checked_never instead
25
+	 * @type int
26
+	 */
27
+	const checkin_status_never = 2;
28
+
29
+	/**
30
+	 * Used to reference when a registration has been checked in.
31
+	 *
32
+	 * @deprecated use \EE_Checkin::status_checked_in instead
33
+	 * @type int
34
+	 */
35
+	const checkin_status_in = 1;
36
+
37
+
38
+	/**
39
+	 * Used to reference when a registration has been checked out.
40
+	 *
41
+	 * @deprecated use \EE_Checkin::status_checked_out instead
42
+	 * @type int
43
+	 */
44
+	const checkin_status_out = 0;
45
+
46
+
47
+	/**
48
+	 * extra meta key for tracking reg status os trashed registrations
49
+	 *
50
+	 * @type string
51
+	 */
52
+	const PRE_TRASH_REG_STATUS_KEY = 'pre_trash_registration_status';
53
+
54
+
55
+	/**
56
+	 * extra meta key for tracking if registration has reserved ticket
57
+	 *
58
+	 * @type string
59
+	 */
60
+	const HAS_RESERVED_TICKET_KEY = 'has_reserved_ticket';
61
+
62
+
63
+	/**
64
+	 * @param array  $props_n_values          incoming values
65
+	 * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
66
+	 *                                        used.)
67
+	 * @param array  $date_formats            incoming date_formats in an array where the first value is the
68
+	 *                                        date_format and the second value is the time format
69
+	 * @return EE_Registration
70
+	 * @throws EE_Error
71
+	 */
72
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
73
+	{
74
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
75
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
76
+	}
77
+
78
+
79
+	/**
80
+	 * @param array  $props_n_values  incoming values from the database
81
+	 * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
82
+	 *                                the website will be used.
83
+	 * @return EE_Registration
84
+	 */
85
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null)
86
+	{
87
+		return new self($props_n_values, true, $timezone);
88
+	}
89
+
90
+
91
+	/**
92
+	 *        Set Event ID
93
+	 *
94
+	 * @param        int $EVT_ID Event ID
95
+	 * @throws EE_Error
96
+	 * @throws RuntimeException
97
+	 */
98
+	public function set_event($EVT_ID = 0)
99
+	{
100
+		$this->set('EVT_ID', $EVT_ID);
101
+	}
102
+
103
+
104
+	/**
105
+	 * Overrides parent set() method so that all calls to set( 'REG_code', $REG_code ) OR set( 'STS_ID', $STS_ID ) can
106
+	 * be routed to internal methods
107
+	 *
108
+	 * @param string $field_name
109
+	 * @param mixed  $field_value
110
+	 * @param bool   $use_default
111
+	 * @throws EE_Error
112
+	 * @throws EntityNotFoundException
113
+	 * @throws InvalidArgumentException
114
+	 * @throws InvalidDataTypeException
115
+	 * @throws InvalidInterfaceException
116
+	 * @throws ReflectionException
117
+	 * @throws RuntimeException
118
+	 */
119
+	public function set($field_name, $field_value, $use_default = false)
120
+	{
121
+		switch ($field_name) {
122
+			case 'REG_code':
123
+				if (! empty($field_value) && $this->reg_code() === null) {
124
+					$this->set_reg_code($field_value, $use_default);
125
+				}
126
+				break;
127
+			case 'STS_ID':
128
+				$this->set_status($field_value, $use_default);
129
+				break;
130
+			default:
131
+				parent::set($field_name, $field_value, $use_default);
132
+		}
133
+	}
134
+
135
+
136
+	/**
137
+	 * Set Status ID
138
+	 * updates the registration status and ALSO...
139
+	 * calls reserve_registration_space() if the reg status changes TO approved from any other reg status
140
+	 * calls release_registration_space() if the reg status changes FROM approved to any other reg status
141
+	 *
142
+	 * @param string       $new_STS_ID
143
+	 * @param boolean      $use_default
144
+	 * @param ContextInterface|null $context
145
+	 * @return bool
146
+	 * @throws EE_Error
147
+	 * @throws EntityNotFoundException
148
+	 * @throws InvalidArgumentException
149
+	 * @throws ReflectionException
150
+	 * @throws RuntimeException
151
+	 * @throws InvalidDataTypeException
152
+	 * @throws InvalidInterfaceException
153
+	 */
154
+	public function set_status($new_STS_ID = null, $use_default = false, ContextInterface $context = null)
155
+	{
156
+		// get current REG_Status
157
+		$old_STS_ID = $this->status_ID();
158
+		// if status has changed
159
+		if ($old_STS_ID !== $new_STS_ID // and that status has actually changed
160
+			&& ! empty($old_STS_ID) // and that old status is actually set
161
+			&& ! empty($new_STS_ID) // as well as the new status
162
+			&& $this->ID() // ensure registration is in the db
163
+		) {
164
+			// TO approved
165
+			if ($new_STS_ID === EEM_Registration::status_id_approved) {
166
+				// reserve a space by incrementing ticket and datetime sold values
167
+				$this->_reserve_registration_space();
168
+				do_action('AHEE__EE_Registration__set_status__to_approved', $this, $old_STS_ID, $new_STS_ID, $context);
169
+				// OR FROM  approved
170
+			} elseif ($old_STS_ID === EEM_Registration::status_id_approved) {
171
+				// release a space by decrementing ticket and datetime sold values
172
+				$this->_release_registration_space();
173
+				do_action(
174
+					'AHEE__EE_Registration__set_status__from_approved',
175
+					$this,
176
+					$old_STS_ID,
177
+					$new_STS_ID,
178
+					$context
179
+				);
180
+			}
181
+			// update status
182
+			parent::set('STS_ID', $new_STS_ID, $use_default);
183
+			$this->_update_if_canceled_or_declined($new_STS_ID, $old_STS_ID, $context);
184
+			if($this->statusChangeUpdatesTransaction($context)) {
185
+				$this->updateTransactionAfterStatusChange();
186
+			}
187
+			do_action('AHEE__EE_Registration__set_status__after_update', $this, $old_STS_ID, $new_STS_ID, $context);
188
+			return true;
189
+		}
190
+		//even though the old value matches the new value, it's still good to
191
+		//allow the parent set method to have a say
192
+		parent::set('STS_ID', $new_STS_ID, $use_default);
193
+		return true;
194
+	}
195
+
196
+
197
+	/**
198
+	 * update REGs and TXN when cancelled or declined registrations involved
199
+	 *
200
+	 * @param string       $new_STS_ID
201
+	 * @param string       $old_STS_ID
202
+	 * @param ContextInterface|null $context
203
+	 * @throws EE_Error
204
+	 * @throws InvalidArgumentException
205
+	 * @throws InvalidDataTypeException
206
+	 * @throws InvalidInterfaceException
207
+	 * @throws ReflectionException
208
+	 */
209
+	private function _update_if_canceled_or_declined($new_STS_ID, $old_STS_ID, ContextInterface $context = null)
210
+	{
211
+		// these reg statuses should not be considered in any calculations involving monies owing
212
+		$closed_reg_statuses = EEM_Registration::closed_reg_statuses();
213
+		// true if registration has been cancelled or declined
214
+		$this->updateIfCanceled(
215
+			$closed_reg_statuses,
216
+			$new_STS_ID,
217
+			$old_STS_ID,
218
+			$context
219
+		);
220
+		$this->updateIfDeclined(
221
+			$closed_reg_statuses,
222
+			$new_STS_ID,
223
+			$old_STS_ID,
224
+			$context
225
+		);
226
+	}
227
+
228
+
229
+	/**
230
+	 * update REGs and TXN when cancelled or declined registrations involved
231
+	 *
232
+	 * @param array        $closed_reg_statuses
233
+	 * @param string       $new_STS_ID
234
+	 * @param string       $old_STS_ID
235
+	 * @param ContextInterface|null $context
236
+	 * @throws EE_Error
237
+	 * @throws InvalidArgumentException
238
+	 * @throws InvalidDataTypeException
239
+	 * @throws InvalidInterfaceException
240
+	 * @throws ReflectionException
241
+	 */
242
+	private function updateIfCanceled(array $closed_reg_statuses, $new_STS_ID, $old_STS_ID, ContextInterface $context = null)
243
+	{
244
+		// true if registration has been cancelled or declined
245
+		if (in_array($new_STS_ID, $closed_reg_statuses, true)
246
+			&& ! in_array($old_STS_ID, $closed_reg_statuses, true)
247
+		) {
248
+			/** @type EE_Registration_Processor $registration_processor */
249
+			$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
250
+			/** @type EE_Transaction_Processor $transaction_processor */
251
+			$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
252
+			// cancelled or declined registration
253
+			$registration_processor->update_registration_after_being_canceled_or_declined(
254
+				$this,
255
+				$closed_reg_statuses
256
+			);
257
+			$transaction_processor->update_transaction_after_canceled_or_declined_registration(
258
+				$this,
259
+				$closed_reg_statuses,
260
+				false
261
+			);
262
+			do_action(
263
+				'AHEE__EE_Registration__set_status__canceled_or_declined',
264
+				$this,
265
+				$old_STS_ID,
266
+				$new_STS_ID,
267
+				$context
268
+			);
269
+			return;
270
+		}
271
+	}
272
+
273
+
274
+	/**
275
+	 * update REGs and TXN when cancelled or declined registrations involved
276
+	 *
277
+	 * @param array        $closed_reg_statuses
278
+	 * @param string       $new_STS_ID
279
+	 * @param string       $old_STS_ID
280
+	 * @param ContextInterface|null $context
281
+	 * @throws EE_Error
282
+	 * @throws InvalidArgumentException
283
+	 * @throws InvalidDataTypeException
284
+	 * @throws InvalidInterfaceException
285
+	 * @throws ReflectionException
286
+	 */
287
+	private function updateIfDeclined(array $closed_reg_statuses, $new_STS_ID, $old_STS_ID, ContextInterface $context = null)
288
+	{
289
+		// true if reinstating cancelled or declined registration
290
+		if (in_array($old_STS_ID, $closed_reg_statuses, true)
291
+			&& ! in_array($new_STS_ID, $closed_reg_statuses, true)
292
+		) {
293
+			/** @type EE_Registration_Processor $registration_processor */
294
+			$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
295
+			/** @type EE_Transaction_Processor $transaction_processor */
296
+			$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
297
+			// reinstating cancelled or declined registration
298
+			$registration_processor->update_canceled_or_declined_registration_after_being_reinstated(
299
+				$this,
300
+				$closed_reg_statuses
301
+			);
302
+			$transaction_processor->update_transaction_after_reinstating_canceled_registration(
303
+				$this,
304
+				$closed_reg_statuses,
305
+				false
306
+			);
307
+			do_action(
308
+				'AHEE__EE_Registration__set_status__after_reinstated',
309
+				$this,
310
+				$old_STS_ID,
311
+				$new_STS_ID,
312
+				$context
313
+			);
314
+		}
315
+	}
316
+
317
+
318
+	/**
319
+	 * @param ContextInterface|null $context
320
+	 * @return bool
321
+	 */
322
+	private function statusChangeUpdatesTransaction(ContextInterface $context = null)
323
+	{
324
+		$contexts_that_do_not_update_transaction = (array) apply_filters(
325
+			'AHEE__EE_Registration__statusChangeUpdatesTransaction__contexts_that_do_not_update_transaction',
326
+			array('spco_reg_step_attendee_information_process_registrations'),
327
+			$context,
328
+			$this
329
+		);
330
+		return ! (
331
+			$context instanceof ContextInterface
332
+			&& in_array($context->slug(), $contexts_that_do_not_update_transaction, true)
333
+		);
334
+	}
335
+
336
+
337
+	/**
338
+	 * @throws EE_Error
339
+	 * @throws EntityNotFoundException
340
+	 * @throws InvalidArgumentException
341
+	 * @throws InvalidDataTypeException
342
+	 * @throws InvalidInterfaceException
343
+	 * @throws ReflectionException
344
+	 * @throws RuntimeException
345
+	 */
346
+	private function updateTransactionAfterStatusChange()
347
+	{
348
+		/** @type EE_Transaction_Payments $transaction_payments */
349
+		$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
350
+		$transaction_payments->recalculate_transaction_total($this->transaction(), false);
351
+		$this->transaction()->update_status_based_on_total_paid(true);
352
+	}
353
+
354
+
355
+	/**
356
+	 *        get Status ID
357
+	 */
358
+	public function status_ID()
359
+	{
360
+		return $this->get('STS_ID');
361
+	}
362
+
363
+
364
+	/**
365
+	 * increments this registration's related ticket sold and corresponding datetime sold values
366
+	 *
367
+	 * @return void
368
+	 * @throws EE_Error
369
+	 * @throws EntityNotFoundException
370
+	 */
371
+	private function _reserve_registration_space()
372
+	{
373
+		// reserved ticket and datetime counts will be decremented as sold counts are incremented
374
+		// so stop tracking that this reg has a ticket reserved
375
+		$this->release_reserved_ticket();
376
+		$ticket = $this->ticket();
377
+		$ticket->increase_sold();
378
+		$ticket->save();
379
+		// possibly set event status to sold out
380
+		$this->event()->perform_sold_out_status_check();
381
+	}
382
+
383
+
384
+	/**
385
+	 * Gets the ticket this registration is for
386
+	 *
387
+	 * @param boolean $include_archived whether to include archived tickets or not.
388
+	 *
389
+	 * @return EE_Ticket|EE_Base_Class
390
+	 * @throws EE_Error
391
+	 */
392
+	public function ticket($include_archived = true)
393
+	{
394
+		$query_params = array();
395
+		if ($include_archived) {
396
+			$query_params['default_where_conditions'] = 'none';
397
+		}
398
+		return $this->get_first_related('Ticket', $query_params);
399
+	}
400
+
401
+
402
+	/**
403
+	 * Gets the event this registration is for
404
+	 *
405
+	 * @return EE_Event
406
+	 * @throws EE_Error
407
+	 * @throws EntityNotFoundException
408
+	 */
409
+	public function event()
410
+	{
411
+		$event = $this->get_first_related('Event');
412
+		if (! $event instanceof \EE_Event) {
413
+			throw new EntityNotFoundException('Event ID', $this->event_ID());
414
+		}
415
+		return $event;
416
+	}
417
+
418
+
419
+	/**
420
+	 * Gets the "author" of the registration.  Note that for the purposes of registrations, the author will correspond
421
+	 * with the author of the event this registration is for.
422
+	 *
423
+	 * @since 4.5.0
424
+	 * @return int
425
+	 * @throws EE_Error
426
+	 * @throws EntityNotFoundException
427
+	 */
428
+	public function wp_user()
429
+	{
430
+		$event = $this->event();
431
+		if ($event instanceof EE_Event) {
432
+			return $event->wp_user();
433
+		}
434
+		return 0;
435
+	}
436
+
437
+
438
+	/**
439
+	 * decrements (subtracts) this registration's related ticket sold and corresponding datetime sold values
440
+	 *
441
+	 * @return void
442
+	 * @throws EE_Error
443
+	 */
444
+	private function _release_registration_space()
445
+	{
446
+		$ticket = $this->ticket();
447
+		$ticket->decrease_sold();
448
+		$ticket->save();
449
+	}
450
+
451
+
452
+	/**
453
+	 * tracks this registration's ticket reservation in extra meta
454
+	 * and can increment related ticket reserved and corresponding datetime reserved values
455
+	 *
456
+	 * @param bool $update_ticket if true, will increment ticket and datetime reserved count
457
+	 *
458
+	 * @return void
459
+	 * @throws EE_Error
460
+	 */
461
+	public function reserve_ticket($update_ticket = false)
462
+	{
463
+		if ($this->get_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true, false) === false) {
464
+			// PLZ NOTE: although checking $update_ticket first would be more efficient,
465
+			// we NEED to ALWAYS call update_extra_meta(), which is why that is done first
466
+			if ($this->update_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true, false) && $update_ticket) {
467
+				$ticket = $this->ticket();
468
+				$ticket->increase_reserved();
469
+				$ticket->save();
470
+			}
471
+		}
472
+	}
473
+
474
+
475
+	/**
476
+	 * stops tracking this registration's ticket reservation in extra meta
477
+	 * decrements (subtracts) related ticket reserved and corresponding datetime reserved values
478
+	 *
479
+	 * @param bool $update_ticket if true, will decrement ticket and datetime reserved count
480
+	 *
481
+	 * @return void
482
+	 * @throws EE_Error
483
+	 */
484
+	public function release_reserved_ticket($update_ticket = false)
485
+	{
486
+		if ($this->get_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true, false) !== false) {
487
+			// PLZ NOTE: although checking $update_ticket first would be more efficient,
488
+			// we NEED to ALWAYS call delete_extra_meta(), which is why that is done first
489
+			if ($this->delete_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY) && $update_ticket) {
490
+				$ticket = $this->ticket();
491
+				$ticket->decrease_reserved();
492
+				$ticket->save();
493
+			}
494
+		}
495
+	}
496
+
497
+
498
+	/**
499
+	 * Set Attendee ID
500
+	 *
501
+	 * @param        int $ATT_ID Attendee ID
502
+	 * @throws EE_Error
503
+	 * @throws RuntimeException
504
+	 */
505
+	public function set_attendee_id($ATT_ID = 0)
506
+	{
507
+		$this->set('ATT_ID', $ATT_ID);
508
+	}
509
+
510
+
511
+	/**
512
+	 *        Set Transaction ID
513
+	 *
514
+	 * @param        int $TXN_ID Transaction ID
515
+	 * @throws EE_Error
516
+	 * @throws RuntimeException
517
+	 */
518
+	public function set_transaction_id($TXN_ID = 0)
519
+	{
520
+		$this->set('TXN_ID', $TXN_ID);
521
+	}
522
+
523
+
524
+	/**
525
+	 *        Set Session
526
+	 *
527
+	 * @param    string $REG_session PHP Session ID
528
+	 * @throws EE_Error
529
+	 * @throws RuntimeException
530
+	 */
531
+	public function set_session($REG_session = '')
532
+	{
533
+		$this->set('REG_session', $REG_session);
534
+	}
535
+
536
+
537
+	/**
538
+	 *        Set Registration URL Link
539
+	 *
540
+	 * @param    string $REG_url_link Registration URL Link
541
+	 * @throws EE_Error
542
+	 * @throws RuntimeException
543
+	 */
544
+	public function set_reg_url_link($REG_url_link = '')
545
+	{
546
+		$this->set('REG_url_link', $REG_url_link);
547
+	}
548
+
549
+
550
+	/**
551
+	 *        Set Attendee Counter
552
+	 *
553
+	 * @param        int $REG_count Primary Attendee
554
+	 * @throws EE_Error
555
+	 * @throws RuntimeException
556
+	 */
557
+	public function set_count($REG_count = 1)
558
+	{
559
+		$this->set('REG_count', $REG_count);
560
+	}
561
+
562
+
563
+	/**
564
+	 *        Set Group Size
565
+	 *
566
+	 * @param        boolean $REG_group_size Group Registration
567
+	 * @throws EE_Error
568
+	 * @throws RuntimeException
569
+	 */
570
+	public function set_group_size($REG_group_size = false)
571
+	{
572
+		$this->set('REG_group_size', $REG_group_size);
573
+	}
574
+
575
+
576
+	/**
577
+	 *    is_not_approved -  convenience method that returns TRUE if REG status ID ==
578
+	 *    EEM_Registration::status_id_not_approved
579
+	 *
580
+	 * @return        boolean
581
+	 */
582
+	public function is_not_approved()
583
+	{
584
+		return $this->status_ID() == EEM_Registration::status_id_not_approved ? true : false;
585
+	}
586
+
587
+
588
+	/**
589
+	 *    is_pending_payment -  convenience method that returns TRUE if REG status ID ==
590
+	 *    EEM_Registration::status_id_pending_payment
591
+	 *
592
+	 * @return        boolean
593
+	 */
594
+	public function is_pending_payment()
595
+	{
596
+		return $this->status_ID() == EEM_Registration::status_id_pending_payment ? true : false;
597
+	}
598
+
599
+
600
+	/**
601
+	 *    is_approved -  convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_approved
602
+	 *
603
+	 * @return        boolean
604
+	 */
605
+	public function is_approved()
606
+	{
607
+		return $this->status_ID() == EEM_Registration::status_id_approved ? true : false;
608
+	}
609
+
610
+
611
+	/**
612
+	 *    is_cancelled -  convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_cancelled
613
+	 *
614
+	 * @return        boolean
615
+	 */
616
+	public function is_cancelled()
617
+	{
618
+		return $this->status_ID() == EEM_Registration::status_id_cancelled ? true : false;
619
+	}
620
+
621
+
622
+	/**
623
+	 *    is_declined -  convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_declined
624
+	 *
625
+	 * @return        boolean
626
+	 */
627
+	public function is_declined()
628
+	{
629
+		return $this->status_ID() == EEM_Registration::status_id_declined ? true : false;
630
+	}
631
+
632
+
633
+	/**
634
+	 *    is_incomplete -  convenience method that returns TRUE if REG status ID ==
635
+	 *    EEM_Registration::status_id_incomplete
636
+	 *
637
+	 * @return        boolean
638
+	 */
639
+	public function is_incomplete()
640
+	{
641
+		return $this->status_ID() == EEM_Registration::status_id_incomplete ? true : false;
642
+	}
643
+
644
+
645
+	/**
646
+	 *        Set Registration Date
647
+	 *
648
+	 * @param        mixed ( int or string ) $REG_date Registration Date - Unix timestamp or string representation of
649
+	 *                                                 Date
650
+	 * @throws EE_Error
651
+	 * @throws RuntimeException
652
+	 */
653
+	public function set_reg_date($REG_date = false)
654
+	{
655
+		$this->set('REG_date', $REG_date);
656
+	}
657
+
658
+
659
+	/**
660
+	 *    Set final price owing for this registration after all ticket/price modifications
661
+	 *
662
+	 * @access    public
663
+	 * @param    float $REG_final_price
664
+	 * @throws EE_Error
665
+	 * @throws RuntimeException
666
+	 */
667
+	public function set_final_price($REG_final_price = 0.00)
668
+	{
669
+		$this->set('REG_final_price', $REG_final_price);
670
+	}
671
+
672
+
673
+	/**
674
+	 *    Set amount paid towards this registration's final price
675
+	 *
676
+	 * @access    public
677
+	 * @param    float $REG_paid
678
+	 * @throws EE_Error
679
+	 * @throws RuntimeException
680
+	 */
681
+	public function set_paid($REG_paid = 0.00)
682
+	{
683
+		$this->set('REG_paid', $REG_paid);
684
+	}
685
+
686
+
687
+	/**
688
+	 *        Attendee Is Going
689
+	 *
690
+	 * @param        boolean $REG_att_is_going Attendee Is Going
691
+	 * @throws EE_Error
692
+	 * @throws RuntimeException
693
+	 */
694
+	public function set_att_is_going($REG_att_is_going = false)
695
+	{
696
+		$this->set('REG_att_is_going', $REG_att_is_going);
697
+	}
698
+
699
+
700
+	/**
701
+	 * Gets the related attendee
702
+	 *
703
+	 * @return EE_Attendee
704
+	 * @throws EE_Error
705
+	 */
706
+	public function attendee()
707
+	{
708
+		return $this->get_first_related('Attendee');
709
+	}
710
+
711
+
712
+	/**
713
+	 *        get Event ID
714
+	 */
715
+	public function event_ID()
716
+	{
717
+		return $this->get('EVT_ID');
718
+	}
719
+
720
+
721
+	/**
722
+	 *        get Event ID
723
+	 */
724
+	public function event_name()
725
+	{
726
+		$event = $this->event_obj();
727
+		if ($event) {
728
+			return $event->name();
729
+		} else {
730
+			return null;
731
+		}
732
+	}
733
+
734
+
735
+	/**
736
+	 * Fetches the event this registration is for
737
+	 *
738
+	 * @return EE_Event
739
+	 * @throws EE_Error
740
+	 */
741
+	public function event_obj()
742
+	{
743
+		return $this->get_first_related('Event');
744
+	}
745
+
746
+
747
+	/**
748
+	 *        get Attendee ID
749
+	 */
750
+	public function attendee_ID()
751
+	{
752
+		return $this->get('ATT_ID');
753
+	}
754
+
755
+
756
+	/**
757
+	 *        get PHP Session ID
758
+	 */
759
+	public function session_ID()
760
+	{
761
+		return $this->get('REG_session');
762
+	}
763
+
764
+
765
+	/**
766
+	 * Gets the string which represents the URL trigger for the receipt template in the message template system.
767
+	 *
768
+	 * @param string $messenger 'pdf' or 'html'.  Default 'html'.
769
+	 * @return string
770
+	 */
771
+	public function receipt_url($messenger = 'html')
772
+	{
773
+
774
+		/**
775
+		 * The below will be deprecated one version after this.  We check first if there is a custom receipt template
776
+		 * already in use on old system.  If there is then we just return the standard url for it.
777
+		 *
778
+		 * @since 4.5.0
779
+		 */
780
+		$template_relative_path = 'modules/gateways/Invoice/lib/templates/receipt_body.template.php';
781
+		$has_custom             = EEH_Template::locate_template(
782
+			$template_relative_path,
783
+			array(),
784
+			true,
785
+			true,
786
+			true
787
+		);
788
+
789
+		if ($has_custom) {
790
+			return add_query_arg(array('receipt' => 'true'), $this->invoice_url('launch'));
791
+		}
792
+		return apply_filters('FHEE__EE_Registration__receipt_url__receipt_url', '', $this, $messenger, 'receipt');
793
+	}
794
+
795
+
796
+	/**
797
+	 * Gets the string which represents the URL trigger for the invoice template in the message template system.
798
+	 *
799
+	 * @param string $messenger 'pdf' or 'html'.  Default 'html'.
800
+	 * @return string
801
+	 * @throws EE_Error
802
+	 */
803
+	public function invoice_url($messenger = 'html')
804
+	{
805
+		/**
806
+		 * The below will be deprecated one version after this.  We check first if there is a custom invoice template
807
+		 * already in use on old system.  If there is then we just return the standard url for it.
808
+		 *
809
+		 * @since 4.5.0
810
+		 */
811
+		$template_relative_path = 'modules/gateways/Invoice/lib/templates/invoice_body.template.php';
812
+		$has_custom             = EEH_Template::locate_template(
813
+			$template_relative_path,
814
+			array(),
815
+			true,
816
+			true,
817
+			true
818
+		);
819
+
820
+		if ($has_custom) {
821
+			if ($messenger == 'html') {
822
+				return $this->invoice_url('launch');
823
+			}
824
+			$route = $messenger == 'download' || $messenger == 'pdf' ? 'download_invoice' : 'launch_invoice';
825
+
826
+			$query_args = array('ee' => $route, 'id' => $this->reg_url_link());
827
+			if ($messenger == 'html') {
828
+				$query_args['html'] = true;
829
+			}
830
+			return add_query_arg($query_args, get_permalink(EE_Registry::instance()->CFG->core->thank_you_page_id));
831
+		}
832
+		return apply_filters('FHEE__EE_Registration__invoice_url__invoice_url', '', $this, $messenger, 'invoice');
833
+	}
834
+
835
+
836
+	/**
837
+	 * get Registration URL Link
838
+	 *
839
+	 * @access public
840
+	 * @return string
841
+	 * @throws EE_Error
842
+	 */
843
+	public function reg_url_link()
844
+	{
845
+		return (string) $this->get('REG_url_link');
846
+	}
847
+
848
+
849
+	/**
850
+	 * Echoes out invoice_url()
851
+	 *
852
+	 * @param string $type 'download','launch', or 'html' (default is 'launch')
853
+	 * @return void
854
+	 * @throws EE_Error
855
+	 */
856
+	public function e_invoice_url($type = 'launch')
857
+	{
858
+		echo $this->invoice_url($type);
859
+	}
860
+
861
+
862
+	/**
863
+	 * Echoes out payment_overview_url
864
+	 */
865
+	public function e_payment_overview_url()
866
+	{
867
+		echo $this->payment_overview_url();
868
+	}
869
+
870
+
871
+	/**
872
+	 * Gets the URL for the checkout payment options reg step
873
+	 * with this registration's REG_url_link added as a query parameter
874
+	 *
875
+	 * @param bool $clear_session Set to true when you want to clear the session on revisiting the
876
+	 *                            payment overview url.
877
+	 * @return string
878
+	 * @throws InvalidInterfaceException
879
+	 * @throws InvalidDataTypeException
880
+	 * @throws EE_Error
881
+	 * @throws InvalidArgumentException
882
+	 */
883
+	public function payment_overview_url($clear_session = false)
884
+	{
885
+		return add_query_arg(
886
+			(array) apply_filters(
887
+				'FHEE__EE_Registration__payment_overview_url__query_args',
888
+				array(
889
+					'e_reg_url_link' => $this->reg_url_link(),
890
+					'step'           => 'payment_options',
891
+					'revisit'        => true,
892
+					'clear_session'  => (bool) $clear_session,
893
+				),
894
+				$this
895
+			),
896
+			EE_Registry::instance()->CFG->core->reg_page_url()
897
+		);
898
+	}
899
+
900
+
901
+	/**
902
+	 * Gets the URL for the checkout attendee information reg step
903
+	 * with this registration's REG_url_link added as a query parameter
904
+	 *
905
+	 * @return string
906
+	 * @throws InvalidInterfaceException
907
+	 * @throws InvalidDataTypeException
908
+	 * @throws EE_Error
909
+	 * @throws InvalidArgumentException
910
+	 */
911
+	public function edit_attendee_information_url()
912
+	{
913
+		return add_query_arg(
914
+			(array) apply_filters(
915
+				'FHEE__EE_Registration__edit_attendee_information_url__query_args',
916
+				array(
917
+					'e_reg_url_link' => $this->reg_url_link(),
918
+					'step'           => 'attendee_information',
919
+					'revisit'        => true,
920
+				),
921
+				$this
922
+			),
923
+			EE_Registry::instance()->CFG->core->reg_page_url()
924
+		);
925
+	}
926
+
927
+
928
+	/**
929
+	 * Simply generates and returns the appropriate admin_url link to edit this registration
930
+	 *
931
+	 * @return string
932
+	 * @throws EE_Error
933
+	 */
934
+	public function get_admin_edit_url()
935
+	{
936
+		return EEH_URL::add_query_args_and_nonce(array(
937
+			'page'    => 'espresso_registrations',
938
+			'action'  => 'view_registration',
939
+			'_REG_ID' => $this->ID(),
940
+		), admin_url('admin.php'));
941
+	}
942
+
943
+
944
+	/**
945
+	 *    is_primary_registrant?
946
+	 */
947
+	public function is_primary_registrant()
948
+	{
949
+		return $this->get('REG_count') == 1 ? true : false;
950
+	}
951
+
952
+
953
+	/**
954
+	 * This returns the primary registration object for this registration group (which may be this object).
955
+	 *
956
+	 * @return EE_Registration
957
+	 * @throws EE_Error
958
+	 */
959
+	public function get_primary_registration()
960
+	{
961
+		if ($this->is_primary_registrant()) {
962
+			return $this;
963
+		}
964
+
965
+		//k reg_count !== 1 so let's get the EE_Registration object matching this txn_id and reg_count == 1
966
+		/** @var EE_Registration $primary_registrant */
967
+		$primary_registrant = EEM_Registration::instance()->get_one(array(
968
+			array(
969
+				'TXN_ID'    => $this->transaction_ID(),
970
+				'REG_count' => 1,
971
+			),
972
+		));
973
+		return $primary_registrant;
974
+	}
975
+
976
+
977
+	/**
978
+	 *        get  Attendee Number
979
+	 *
980
+	 * @access        public
981
+	 */
982
+	public function count()
983
+	{
984
+		return $this->get('REG_count');
985
+	}
986
+
987
+
988
+	/**
989
+	 *        get Group Size
990
+	 */
991
+	public function group_size()
992
+	{
993
+		return $this->get('REG_group_size');
994
+	}
995
+
996
+
997
+	/**
998
+	 *        get Registration Date
999
+	 */
1000
+	public function date()
1001
+	{
1002
+		return $this->get('REG_date');
1003
+	}
1004
+
1005
+
1006
+	/**
1007
+	 * gets a pretty date
1008
+	 *
1009
+	 * @param string $date_format
1010
+	 * @param string $time_format
1011
+	 * @return string
1012
+	 * @throws EE_Error
1013
+	 */
1014
+	public function pretty_date($date_format = null, $time_format = null)
1015
+	{
1016
+		return $this->get_datetime('REG_date', $date_format, $time_format);
1017
+	}
1018
+
1019
+
1020
+	/**
1021
+	 * final_price
1022
+	 * the registration's share of the transaction total, so that the
1023
+	 * sum of all the transaction's REG_final_prices equal the transaction's total
1024
+	 *
1025
+	 * @return float
1026
+	 * @throws EE_Error
1027
+	 */
1028
+	public function final_price()
1029
+	{
1030
+		return $this->get('REG_final_price');
1031
+	}
1032
+
1033
+
1034
+	/**
1035
+	 * pretty_final_price
1036
+	 *  final price as formatted string, with correct decimal places and currency symbol
1037
+	 *
1038
+	 * @return string
1039
+	 * @throws EE_Error
1040
+	 */
1041
+	public function pretty_final_price()
1042
+	{
1043
+		return $this->get_pretty('REG_final_price');
1044
+	}
1045
+
1046
+
1047
+	/**
1048
+	 * get paid (yeah)
1049
+	 *
1050
+	 * @return float
1051
+	 * @throws EE_Error
1052
+	 */
1053
+	public function paid()
1054
+	{
1055
+		return $this->get('REG_paid');
1056
+	}
1057
+
1058
+
1059
+	/**
1060
+	 * pretty_paid
1061
+	 *
1062
+	 * @return float
1063
+	 * @throws EE_Error
1064
+	 */
1065
+	public function pretty_paid()
1066
+	{
1067
+		return $this->get_pretty('REG_paid');
1068
+	}
1069
+
1070
+
1071
+	/**
1072
+	 * owes_monies_and_can_pay
1073
+	 * whether or not this registration has monies owing and it's' status allows payment
1074
+	 *
1075
+	 * @param array $requires_payment
1076
+	 * @return bool
1077
+	 * @throws EE_Error
1078
+	 */
1079
+	public function owes_monies_and_can_pay($requires_payment = array())
1080
+	{
1081
+		// these reg statuses require payment (if event is not free)
1082
+		$requires_payment = ! empty($requires_payment)
1083
+			? $requires_payment
1084
+			: EEM_Registration::reg_statuses_that_allow_payment();
1085
+		if (in_array($this->status_ID(), $requires_payment) &&
1086
+			$this->final_price() != 0 &&
1087
+			$this->final_price() != $this->paid()
1088
+		) {
1089
+			return true;
1090
+		} else {
1091
+			return false;
1092
+		}
1093
+	}
1094
+
1095
+
1096
+	/**
1097
+	 * Prints out the return value of $this->pretty_status()
1098
+	 *
1099
+	 * @param bool $show_icons
1100
+	 * @return void
1101
+	 * @throws EE_Error
1102
+	 */
1103
+	public function e_pretty_status($show_icons = false)
1104
+	{
1105
+		echo $this->pretty_status($show_icons);
1106
+	}
1107
+
1108
+
1109
+	/**
1110
+	 * Returns a nice version of the status for displaying to customers
1111
+	 *
1112
+	 * @param bool $show_icons
1113
+	 * @return string
1114
+	 * @throws EE_Error
1115
+	 */
1116
+	public function pretty_status($show_icons = false)
1117
+	{
1118
+		$status = EEM_Status::instance()->localized_status(
1119
+			array($this->status_ID() => esc_html__('unknown', 'event_espresso')),
1120
+			false,
1121
+			'sentence'
1122
+		);
1123
+		$icon   = '';
1124
+		switch ($this->status_ID()) {
1125
+			case EEM_Registration::status_id_approved:
1126
+				$icon = $show_icons
1127
+					? '<span class="dashicons dashicons-star-filled ee-icon-size-16 green-text"></span>'
1128
+					: '';
1129
+				break;
1130
+			case EEM_Registration::status_id_pending_payment:
1131
+				$icon = $show_icons
1132
+					? '<span class="dashicons dashicons-star-half ee-icon-size-16 orange-text"></span>'
1133
+					: '';
1134
+				break;
1135
+			case EEM_Registration::status_id_not_approved:
1136
+				$icon = $show_icons
1137
+					? '<span class="dashicons dashicons-marker ee-icon-size-16 orange-text"></span>'
1138
+					: '';
1139
+				break;
1140
+			case EEM_Registration::status_id_cancelled:
1141
+				$icon = $show_icons
1142
+					? '<span class="dashicons dashicons-no ee-icon-size-16 lt-grey-text"></span>'
1143
+					: '';
1144
+				break;
1145
+			case EEM_Registration::status_id_incomplete:
1146
+				$icon = $show_icons
1147
+					? '<span class="dashicons dashicons-no ee-icon-size-16 lt-orange-text"></span>'
1148
+					: '';
1149
+				break;
1150
+			case EEM_Registration::status_id_declined:
1151
+				$icon = $show_icons
1152
+					? '<span class="dashicons dashicons-no ee-icon-size-16 red-text"></span>'
1153
+					: '';
1154
+				break;
1155
+			case EEM_Registration::status_id_wait_list:
1156
+				$icon = $show_icons
1157
+					? '<span class="dashicons dashicons-clipboard ee-icon-size-16 purple-text"></span>'
1158
+					: '';
1159
+				break;
1160
+		}
1161
+		return $icon . $status[$this->status_ID()];
1162
+	}
1163
+
1164
+
1165
+	/**
1166
+	 *        get Attendee Is Going
1167
+	 */
1168
+	public function att_is_going()
1169
+	{
1170
+		return $this->get('REG_att_is_going');
1171
+	}
1172
+
1173
+
1174
+	/**
1175
+	 * Gets related answers
1176
+	 *
1177
+	 * @param array $query_params like EEM_Base::get_all
1178
+	 * @return EE_Answer[]
1179
+	 * @throws EE_Error
1180
+	 */
1181
+	public function answers($query_params = null)
1182
+	{
1183
+		return $this->get_many_related('Answer', $query_params);
1184
+	}
1185
+
1186
+
1187
+	/**
1188
+	 * Gets the registration's answer value to the specified question
1189
+	 * (either the question's ID or a question object)
1190
+	 *
1191
+	 * @param EE_Question|int $question
1192
+	 * @param bool            $pretty_value
1193
+	 * @return array|string if pretty_value= true, the result will always be a string
1194
+	 * (because the answer might be an array of answer values, so passing pretty_value=true
1195
+	 * will convert it into some kind of string)
1196
+	 * @throws EE_Error
1197
+	 */
1198
+	public function answer_value_to_question($question, $pretty_value = true)
1199
+	{
1200
+		$question_id = EEM_Question::instance()->ensure_is_ID($question);
1201
+		return EEM_Answer::instance()->get_answer_value_to_question($this, $question_id, $pretty_value);
1202
+	}
1203
+
1204
+
1205
+	/**
1206
+	 * question_groups
1207
+	 * returns an array of EE_Question_Group objects for this registration
1208
+	 *
1209
+	 * @return EE_Question_Group[]
1210
+	 * @throws EE_Error
1211
+	 * @throws EntityNotFoundException
1212
+	 */
1213
+	public function question_groups()
1214
+	{
1215
+		$question_groups = array();
1216
+		if ($this->event() instanceof EE_Event) {
1217
+			$question_groups = $this->event()->question_groups(
1218
+				array(
1219
+					array(
1220
+						'Event_Question_Group.EQG_primary' => $this->count() == 1 ? true : false,
1221
+					),
1222
+					'order_by' => array('QSG_order' => 'ASC'),
1223
+				)
1224
+			);
1225
+		}
1226
+		return $question_groups;
1227
+	}
1228
+
1229
+
1230
+	/**
1231
+	 * count_question_groups
1232
+	 * returns a count of the number of EE_Question_Group objects for this registration
1233
+	 *
1234
+	 * @return int
1235
+	 * @throws EE_Error
1236
+	 * @throws EntityNotFoundException
1237
+	 */
1238
+	public function count_question_groups()
1239
+	{
1240
+		$qg_count = 0;
1241
+		if ($this->event() instanceof EE_Event) {
1242
+			$qg_count = $this->event()->count_related(
1243
+				'Question_Group',
1244
+				array(
1245
+					array(
1246
+						'Event_Question_Group.EQG_primary' => $this->count() == 1 ? true : false,
1247
+					),
1248
+				)
1249
+			);
1250
+		}
1251
+		return $qg_count;
1252
+	}
1253
+
1254
+
1255
+	/**
1256
+	 * Returns the registration date in the 'standard' string format
1257
+	 * (function may be improved in the future to allow for different formats and timezones)
1258
+	 *
1259
+	 * @return string
1260
+	 * @throws EE_Error
1261
+	 */
1262
+	public function reg_date()
1263
+	{
1264
+		return $this->get_datetime('REG_date');
1265
+	}
1266
+
1267
+
1268
+	/**
1269
+	 * Gets the datetime-ticket for this registration (ie, it can be used to isolate
1270
+	 * the ticket this registration purchased, or the datetime they have registered
1271
+	 * to attend)
1272
+	 *
1273
+	 * @return EE_Datetime_Ticket
1274
+	 * @throws EE_Error
1275
+	 */
1276
+	public function datetime_ticket()
1277
+	{
1278
+		return $this->get_first_related('Datetime_Ticket');
1279
+	}
1280
+
1281
+
1282
+	/**
1283
+	 * Sets the registration's datetime_ticket.
1284
+	 *
1285
+	 * @param EE_Datetime_Ticket $datetime_ticket
1286
+	 * @return EE_Datetime_Ticket
1287
+	 * @throws EE_Error
1288
+	 */
1289
+	public function set_datetime_ticket($datetime_ticket)
1290
+	{
1291
+		return $this->_add_relation_to($datetime_ticket, 'Datetime_Ticket');
1292
+	}
1293
+
1294
+	/**
1295
+	 * Gets deleted
1296
+	 *
1297
+	 * @return bool
1298
+	 * @throws EE_Error
1299
+	 */
1300
+	public function deleted()
1301
+	{
1302
+		return $this->get('REG_deleted');
1303
+	}
1304
+
1305
+	/**
1306
+	 * Sets deleted
1307
+	 *
1308
+	 * @param boolean $deleted
1309
+	 * @return bool
1310
+	 * @throws EE_Error
1311
+	 * @throws RuntimeException
1312
+	 */
1313
+	public function set_deleted($deleted)
1314
+	{
1315
+		if ($deleted) {
1316
+			$this->delete();
1317
+		} else {
1318
+			$this->restore();
1319
+		}
1320
+	}
1321
+
1322
+
1323
+	/**
1324
+	 * Get the status object of this object
1325
+	 *
1326
+	 * @return EE_Status
1327
+	 * @throws EE_Error
1328
+	 */
1329
+	public function status_obj()
1330
+	{
1331
+		return $this->get_first_related('Status');
1332
+	}
1333
+
1334
+
1335
+	/**
1336
+	 * Returns the number of times this registration has checked into any of the datetimes
1337
+	 * its available for
1338
+	 *
1339
+	 * @return int
1340
+	 * @throws EE_Error
1341
+	 */
1342
+	public function count_checkins()
1343
+	{
1344
+		return $this->get_model()->count_related($this, 'Checkin');
1345
+	}
1346
+
1347
+
1348
+	/**
1349
+	 * Returns the number of current Check-ins this registration is checked into for any of the datetimes the
1350
+	 * registration is for.  Note, this is ONLY checked in (does not include checkedout)
1351
+	 *
1352
+	 * @return int
1353
+	 * @throws EE_Error
1354
+	 */
1355
+	public function count_checkins_not_checkedout()
1356
+	{
1357
+		return $this->get_model()->count_related($this, 'Checkin', array(array('CHK_in' => 1)));
1358
+	}
1359
+
1360
+
1361
+	/**
1362
+	 * The purpose of this method is simply to check whether this registration can checkin to the given datetime.
1363
+	 *
1364
+	 * @param int | EE_Datetime $DTT_OR_ID      The datetime the registration is being checked against
1365
+	 * @param bool              $check_approved This is used to indicate whether the caller wants can_checkin to also
1366
+	 *                                          consider registration status as well as datetime access.
1367
+	 * @return bool
1368
+	 * @throws EE_Error
1369
+	 */
1370
+	public function can_checkin($DTT_OR_ID, $check_approved = true)
1371
+	{
1372
+		$DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID);
1373
+
1374
+		//first check registration status
1375
+		if (($check_approved && ! $this->is_approved()) || ! $DTT_ID) {
1376
+			return false;
1377
+		}
1378
+		//is there a datetime ticket that matches this dtt_ID?
1379
+		if (! (EEM_Datetime_Ticket::instance()->exists(array(
1380
+			array(
1381
+				'TKT_ID' => $this->get('TKT_ID'),
1382
+				'DTT_ID' => $DTT_ID,
1383
+			),
1384
+		)))
1385
+		) {
1386
+			return false;
1387
+		}
1388
+
1389
+		//final check is against TKT_uses
1390
+		return $this->verify_can_checkin_against_TKT_uses($DTT_ID);
1391
+	}
1392
+
1393
+
1394
+	/**
1395
+	 * This method verifies whether the user can checkin for the given datetime considering the max uses value set on
1396
+	 * the ticket. To do this,  a query is done to get the count of the datetime records already checked into.  If the
1397
+	 * datetime given does not have a check-in record and checking in for that datetime will exceed the allowed uses,
1398
+	 * then return false.  Otherwise return true.
1399
+	 *
1400
+	 * @param int | EE_Datetime $DTT_OR_ID The datetime the registration is being checked against
1401
+	 * @return bool true means can checkin.  false means cannot checkin.
1402
+	 * @throws EE_Error
1403
+	 */
1404
+	public function verify_can_checkin_against_TKT_uses($DTT_OR_ID)
1405
+	{
1406
+		$DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID);
1407
+
1408
+		if (! $DTT_ID) {
1409
+			return false;
1410
+		}
1411
+
1412
+		$max_uses = $this->ticket() instanceof EE_Ticket ? $this->ticket()->uses() : EE_INF;
1413
+
1414
+		// if max uses is not set or equals infinity then return true cause its not a factor for whether user can
1415
+		// check-in or not.
1416
+		if (! $max_uses || $max_uses === EE_INF) {
1417
+			return true;
1418
+		}
1419
+
1420
+		//does this datetime have a checkin record?  If so, then the dtt count has already been verified so we can just
1421
+		//go ahead and toggle.
1422
+		if (EEM_Checkin::instance()->exists(array(array('REG_ID' => $this->ID(), 'DTT_ID' => $DTT_ID)))) {
1423
+			return true;
1424
+		}
1425
+
1426
+		//made it here so the last check is whether the number of checkins per unique datetime on this registration
1427
+		//disallows further check-ins.
1428
+		$count_unique_dtt_checkins = EEM_Checkin::instance()->count(array(
1429
+			array(
1430
+				'REG_ID' => $this->ID(),
1431
+				'CHK_in' => true,
1432
+			),
1433
+		), 'DTT_ID', true);
1434
+		// checkins have already reached their max number of uses
1435
+		// so registrant can NOT checkin
1436
+		if ($count_unique_dtt_checkins >= $max_uses) {
1437
+			EE_Error::add_error(
1438
+				esc_html__(
1439
+					'Check-in denied because number of datetime uses for the ticket has been reached or exceeded.',
1440
+					'event_espresso'
1441
+				),
1442
+				__FILE__,
1443
+				__FUNCTION__,
1444
+				__LINE__
1445
+			);
1446
+			return false;
1447
+		}
1448
+		return true;
1449
+	}
1450
+
1451
+
1452
+	/**
1453
+	 * toggle Check-in status for this registration
1454
+	 * Check-ins are toggled in the following order:
1455
+	 * never checked in -> checked in
1456
+	 * checked in -> checked out
1457
+	 * checked out -> checked in
1458
+	 *
1459
+	 * @param  int $DTT_ID  include specific datetime to toggle Check-in for.
1460
+	 *                      If not included or null, then it is assumed latest datetime is being toggled.
1461
+	 * @param bool $verify  If true then can_checkin() is used to verify whether the person
1462
+	 *                      can be checked in or not.  Otherwise this forces change in checkin status.
1463
+	 * @return bool|int     the chk_in status toggled to OR false if nothing got changed.
1464
+	 * @throws EE_Error
1465
+	 */
1466
+	public function toggle_checkin_status($DTT_ID = null, $verify = false)
1467
+	{
1468
+		if (empty($DTT_ID)) {
1469
+			$datetime = $this->get_latest_related_datetime();
1470
+			$DTT_ID   = $datetime instanceof EE_Datetime ? $datetime->ID() : 0;
1471
+			// verify the registration can checkin for the given DTT_ID
1472
+		} elseif (! $this->can_checkin($DTT_ID, $verify)) {
1473
+			EE_Error::add_error(
1474
+				sprintf(
1475
+					esc_html__(
1476
+						'The given registration (ID:%1$d) can not be checked in to the given DTT_ID (%2$d), because the registration does not have access',
1477
+						'event_espresso'
1478
+					),
1479
+					$this->ID(),
1480
+					$DTT_ID
1481
+				),
1482
+				__FILE__,
1483
+				__FUNCTION__,
1484
+				__LINE__
1485
+			);
1486
+			return false;
1487
+		}
1488
+		$status_paths = array(
1489
+			EE_Checkin::status_checked_never => EE_Checkin::status_checked_in,
1490
+			EE_Checkin::status_checked_in    => EE_Checkin::status_checked_out,
1491
+			EE_Checkin::status_checked_out   => EE_Checkin::status_checked_in,
1492
+		);
1493
+		//start by getting the current status so we know what status we'll be changing to.
1494
+		$cur_status = $this->check_in_status_for_datetime($DTT_ID, null);
1495
+		$status_to  = $status_paths[$cur_status];
1496
+		// database only records true for checked IN or false for checked OUT
1497
+		// no record ( null ) means checked in NEVER, but we obviously don't save that
1498
+		$new_status = $status_to === EE_Checkin::status_checked_in ? true : false;
1499
+		// add relation - note Check-ins are always creating new rows
1500
+		// because we are keeping track of Check-ins over time.
1501
+		// Eventually we'll probably want to show a list table
1502
+		// for the individual Check-ins so that they can be managed.
1503
+		$checkin = EE_Checkin::new_instance(array(
1504
+			'REG_ID' => $this->ID(),
1505
+			'DTT_ID' => $DTT_ID,
1506
+			'CHK_in' => $new_status,
1507
+		));
1508
+		// if the record could not be saved then return false
1509
+		if ($checkin->save() === 0) {
1510
+			if (WP_DEBUG) {
1511
+				global $wpdb;
1512
+				$error = sprintf(
1513
+					esc_html__(
1514
+						'Registration check in update failed because of the following database error: %1$s%2$s',
1515
+						'event_espresso'
1516
+					),
1517
+					'<br />',
1518
+					$wpdb->last_error
1519
+				);
1520
+			} else {
1521
+				$error = esc_html__(
1522
+					'Registration check in update failed because of an unknown database error',
1523
+					'event_espresso'
1524
+				);
1525
+			}
1526
+			EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__);
1527
+			return false;
1528
+		}
1529
+		return $status_to;
1530
+	}
1531
+
1532
+
1533
+	/**
1534
+	 * Returns the latest datetime related to this registration (via the ticket attached to the registration).
1535
+	 * "Latest" is defined by the `DTT_EVT_start` column.
1536
+	 *
1537
+	 * @return EE_Datetime|null
1538
+	 * @throws EE_Error
1539
+	 */
1540
+	public function get_latest_related_datetime()
1541
+	{
1542
+		return EEM_Datetime::instance()->get_one(
1543
+			array(
1544
+				array(
1545
+					'Ticket.Registration.REG_ID' => $this->ID(),
1546
+				),
1547
+				'order_by' => array('DTT_EVT_start' => 'DESC'),
1548
+			)
1549
+		);
1550
+	}
1551
+
1552
+
1553
+	/**
1554
+	 * Returns the earliest datetime related to this registration (via the ticket attached to the registration).
1555
+	 * "Earliest" is defined by the `DTT_EVT_start` column.
1556
+	 *
1557
+	 * @throws EE_Error
1558
+	 */
1559
+	public function get_earliest_related_datetime()
1560
+	{
1561
+		return EEM_Datetime::instance()->get_one(
1562
+			array(
1563
+				array(
1564
+					'Ticket.Registration.REG_ID' => $this->ID(),
1565
+				),
1566
+				'order_by' => array('DTT_EVT_start' => 'ASC'),
1567
+			)
1568
+		);
1569
+	}
1570
+
1571
+
1572
+	/**
1573
+	 * This method simply returns the check-in status for this registration and the given datetime.
1574
+	 * If neither the datetime nor the checkin values are provided as arguments,
1575
+	 * then this will return the LATEST check-in status for the registration across all datetimes it belongs to.
1576
+	 *
1577
+	 * @param  int       $DTT_ID  The ID of the datetime we're checking against
1578
+	 *                            (if empty we'll get the primary datetime for
1579
+	 *                            this registration (via event) and use it's ID);
1580
+	 * @param EE_Checkin $checkin If present, we use the given checkin object rather than the dtt_id.
1581
+	 *
1582
+	 * @return int                Integer representing Check-in status.
1583
+	 * @throws EE_Error
1584
+	 */
1585
+	public function check_in_status_for_datetime($DTT_ID = 0, $checkin = null)
1586
+	{
1587
+		$checkin_query_params = array(
1588
+			'order_by' => array('CHK_timestamp' => 'DESC'),
1589
+		);
1590
+
1591
+		if ($DTT_ID > 0) {
1592
+			$checkin_query_params[0] = array('DTT_ID' => $DTT_ID);
1593
+		}
1594
+
1595
+		//get checkin object (if exists)
1596
+		$checkin = $checkin instanceof EE_Checkin
1597
+			? $checkin
1598
+			: $this->get_first_related('Checkin', $checkin_query_params);
1599
+		if ($checkin instanceof EE_Checkin) {
1600
+			if ($checkin->get('CHK_in')) {
1601
+				return EE_Checkin::status_checked_in; //checked in
1602
+			}
1603
+			return EE_Checkin::status_checked_out; //had checked in but is now checked out.
1604
+		}
1605
+		return EE_Checkin::status_checked_never; //never been checked in
1606
+	}
1607
+
1608
+
1609
+	/**
1610
+	 * This method returns a localized message for the toggled Check-in message.
1611
+	 *
1612
+	 * @param  int $DTT_ID include specific datetime to get the correct Check-in message.  If not included or null,
1613
+	 *                     then it is assumed Check-in for primary datetime was toggled.
1614
+	 * @param bool $error  This just flags that you want an error message returned. This is put in so that the error
1615
+	 *                     message can be customized with the attendee name.
1616
+	 * @return string internationalized message
1617
+	 * @throws EE_Error
1618
+	 */
1619
+	public function get_checkin_msg($DTT_ID, $error = false)
1620
+	{
1621
+		//let's get the attendee first so we can include the name of the attendee
1622
+		$attendee = $this->get_first_related('Attendee');
1623
+		if ($attendee instanceof EE_Attendee) {
1624
+			if ($error) {
1625
+				return sprintf(__("%s's check-in status was not changed.", "event_espresso"), $attendee->full_name());
1626
+			}
1627
+			$cur_status = $this->check_in_status_for_datetime($DTT_ID);
1628
+			//what is the status message going to be?
1629
+			switch ($cur_status) {
1630
+				case EE_Checkin::status_checked_never:
1631
+					return sprintf(__("%s has been removed from Check-in records", "event_espresso"),
1632
+						$attendee->full_name());
1633
+					break;
1634
+				case EE_Checkin::status_checked_in:
1635
+					return sprintf(__('%s has been checked in', 'event_espresso'), $attendee->full_name());
1636
+					break;
1637
+				case EE_Checkin::status_checked_out:
1638
+					return sprintf(__('%s has been checked out', 'event_espresso'), $attendee->full_name());
1639
+					break;
1640
+			}
1641
+		}
1642
+		return esc_html__("The check-in status could not be determined.", "event_espresso");
1643
+	}
1644
+
1645
+
1646
+	/**
1647
+	 * Returns the related EE_Transaction to this registration
1648
+	 *
1649
+	 * @return EE_Transaction
1650
+	 * @throws EE_Error
1651
+	 * @throws EntityNotFoundException
1652
+	 */
1653
+	public function transaction()
1654
+	{
1655
+		$transaction = $this->get_first_related('Transaction');
1656
+		if (! $transaction instanceof \EE_Transaction) {
1657
+			throw new EntityNotFoundException('Transaction ID', $this->transaction_ID());
1658
+		}
1659
+		return $transaction;
1660
+	}
1661
+
1662
+
1663
+	/**
1664
+	 *        get Registration Code
1665
+	 */
1666
+	public function reg_code()
1667
+	{
1668
+		return $this->get('REG_code');
1669
+	}
1670
+
1671
+
1672
+	/**
1673
+	 *        get Transaction ID
1674
+	 */
1675
+	public function transaction_ID()
1676
+	{
1677
+		return $this->get('TXN_ID');
1678
+	}
1679
+
1680
+
1681
+	/**
1682
+	 * @return int
1683
+	 * @throws EE_Error
1684
+	 */
1685
+	public function ticket_ID()
1686
+	{
1687
+		return $this->get('TKT_ID');
1688
+	}
1689
+
1690
+
1691
+	/**
1692
+	 *        Set Registration Code
1693
+	 *
1694
+	 * @access    public
1695
+	 * @param    string  $REG_code Registration Code
1696
+	 * @param    boolean $use_default
1697
+	 * @throws EE_Error
1698
+	 */
1699
+	public function set_reg_code($REG_code, $use_default = false)
1700
+	{
1701
+		if (empty($REG_code)) {
1702
+			EE_Error::add_error(
1703
+				esc_html__('REG_code can not be empty.', 'event_espresso'),
1704
+				__FILE__,
1705
+				__FUNCTION__,
1706
+				__LINE__
1707
+			);
1708
+			return;
1709
+		}
1710
+		if (! $this->reg_code()) {
1711
+			parent::set('REG_code', $REG_code, $use_default);
1712
+		} else {
1713
+			EE_Error::doing_it_wrong(
1714
+				__CLASS__ . '::' . __FUNCTION__,
1715
+				esc_html__('Can not change a registration REG_code once it has been set.', 'event_espresso'),
1716
+				'4.6.0'
1717
+			);
1718
+		}
1719
+	}
1720
+
1721
+
1722
+	/**
1723
+	 * Returns all other registrations in the same group as this registrant who have the same ticket option.
1724
+	 * Note, if you want to just get all registrations in the same transaction (group), use:
1725
+	 *    $registration->transaction()->registrations();
1726
+	 *
1727
+	 * @since 4.5.0
1728
+	 * @return EE_Registration[] or empty array if this isn't a group registration.
1729
+	 * @throws EE_Error
1730
+	 */
1731
+	public function get_all_other_registrations_in_group()
1732
+	{
1733
+		if ($this->group_size() < 2) {
1734
+			return array();
1735
+		}
1736
+
1737
+		$query[0] = array(
1738
+			'TXN_ID' => $this->transaction_ID(),
1739
+			'REG_ID' => array('!=', $this->ID()),
1740
+			'TKT_ID' => $this->ticket_ID(),
1741
+		);
1742
+		/** @var EE_Registration[] $registrations */
1743
+		$registrations = $this->get_model()->get_all($query);
1744
+		return $registrations;
1745
+	}
1746
+
1747
+	/**
1748
+	 * Return the link to the admin details for the object.
1749
+	 *
1750
+	 * @return string
1751
+	 * @throws EE_Error
1752
+	 */
1753
+	public function get_admin_details_link()
1754
+	{
1755
+		EE_Registry::instance()->load_helper('URL');
1756
+		return EEH_URL::add_query_args_and_nonce(
1757
+			array(
1758
+				'page'    => 'espresso_registrations',
1759
+				'action'  => 'view_registration',
1760
+				'_REG_ID' => $this->ID(),
1761
+			),
1762
+			admin_url('admin.php')
1763
+		);
1764
+	}
1765
+
1766
+	/**
1767
+	 * Returns the link to the editor for the object.  Sometimes this is the same as the details.
1768
+	 *
1769
+	 * @return string
1770
+	 * @throws EE_Error
1771
+	 */
1772
+	public function get_admin_edit_link()
1773
+	{
1774
+		return $this->get_admin_details_link();
1775
+	}
1776
+
1777
+	/**
1778
+	 * Returns the link to a settings page for the object.
1779
+	 *
1780
+	 * @return string
1781
+	 * @throws EE_Error
1782
+	 */
1783
+	public function get_admin_settings_link()
1784
+	{
1785
+		return $this->get_admin_details_link();
1786
+	}
1787
+
1788
+	/**
1789
+	 * Returns the link to the "overview" for the object (typically the "list table" view).
1790
+	 *
1791
+	 * @return string
1792
+	 */
1793
+	public function get_admin_overview_link()
1794
+	{
1795
+		EE_Registry::instance()->load_helper('URL');
1796
+		return EEH_URL::add_query_args_and_nonce(
1797
+			array(
1798
+				'page' => 'espresso_registrations',
1799
+			),
1800
+			admin_url('admin.php')
1801
+		);
1802
+	}
1803
+
1804
+
1805
+	/**
1806
+	 * @param array $query_params
1807
+	 *
1808
+	 * @return \EE_Registration[]
1809
+	 * @throws EE_Error
1810
+	 */
1811
+	public function payments($query_params = array())
1812
+	{
1813
+		return $this->get_many_related('Payment', $query_params);
1814
+	}
1815
+
1816
+
1817
+	/**
1818
+	 * @param array $query_params
1819
+	 *
1820
+	 * @return \EE_Registration_Payment[]
1821
+	 * @throws EE_Error
1822
+	 */
1823
+	public function registration_payments($query_params = array())
1824
+	{
1825
+		return $this->get_many_related('Registration_Payment', $query_params);
1826
+	}
1827
+
1828
+
1829
+	/**
1830
+	 * This grabs the payment method corresponding to the last payment made for the amount owing on the registration.
1831
+	 * Note: if there are no payments on the registration there will be no payment method returned.
1832
+	 *
1833
+	 * @return EE_Payment_Method|null
1834
+	 */
1835
+	public function payment_method()
1836
+	{
1837
+		return EEM_Payment_Method::instance()->get_last_used_for_registration($this);
1838
+	}
1839
+
1840
+
1841
+	/**
1842
+	 * @return \EE_Line_Item
1843
+	 * @throws EntityNotFoundException
1844
+	 * @throws EE_Error
1845
+	 */
1846
+	public function ticket_line_item()
1847
+	{
1848
+		$ticket            = $this->ticket();
1849
+		$transaction       = $this->transaction();
1850
+		$line_item         = null;
1851
+		$ticket_line_items = \EEH_Line_Item::get_line_items_by_object_type_and_IDs(
1852
+			$transaction->total_line_item(),
1853
+			'Ticket',
1854
+			array($ticket->ID())
1855
+		);
1856
+		foreach ($ticket_line_items as $ticket_line_item) {
1857
+			if (
1858
+				$ticket_line_item instanceof \EE_Line_Item
1859
+				&& $ticket_line_item->OBJ_type() === 'Ticket'
1860
+				&& $ticket_line_item->OBJ_ID() === $ticket->ID()
1861
+			) {
1862
+				$line_item = $ticket_line_item;
1863
+				break;
1864
+			}
1865
+		}
1866
+		if (! ($line_item instanceof \EE_Line_Item && $line_item->OBJ_type() === 'Ticket')) {
1867
+			throw new EntityNotFoundException('Line Item Ticket ID', $ticket->ID());
1868
+		}
1869
+		return $line_item;
1870
+	}
1871
+
1872
+
1873
+	/**
1874
+	 * Soft Deletes this model object.
1875
+	 *
1876
+	 * @return boolean | int
1877
+	 * @throws RuntimeException
1878
+	 * @throws EE_Error
1879
+	 */
1880
+	public function delete()
1881
+	{
1882
+		if ($this->update_extra_meta(EE_Registration::PRE_TRASH_REG_STATUS_KEY, $this->status_ID()) === true) {
1883
+			$this->set_status(EEM_Registration::status_id_cancelled);
1884
+		}
1885
+		return parent::delete();
1886
+	}
1887
+
1888
+
1889
+	/**
1890
+	 * Restores whatever the previous status was on a registration before it was trashed (if possible)
1891
+	 *
1892
+	 * @throws EE_Error
1893
+	 * @throws RuntimeException
1894
+	 */
1895
+	public function restore()
1896
+	{
1897
+		$previous_status = $this->get_extra_meta(
1898
+			EE_Registration::PRE_TRASH_REG_STATUS_KEY,
1899
+			true,
1900
+			EEM_Registration::status_id_cancelled
1901
+		);
1902
+		if ($previous_status) {
1903
+			$this->delete_extra_meta(EE_Registration::PRE_TRASH_REG_STATUS_KEY);
1904
+			$this->set_status($previous_status);
1905
+		}
1906
+		return parent::restore();
1907
+	}
1908
+
1909
+
1910
+	/**
1911
+	 * possibly toggle Registration status based on comparison of REG_paid vs REG_final_price
1912
+	 *
1913
+	 * @param  boolean $trigger_set_status_logic EE_Registration::set_status() can trigger additional logic
1914
+	 *                                           depending on whether the reg status changes to or from "Approved"
1915
+	 * @return boolean whether the Registration status was updated
1916
+	 * @throws EE_Error
1917
+	 * @throws RuntimeException
1918
+	 */
1919
+	public function updateStatusBasedOnTotalPaid($trigger_set_status_logic = true)
1920
+	{
1921
+		$paid = $this->paid();
1922
+		$price = $this->final_price();
1923
+		switch(true) {
1924
+			// overpaid or paid
1925
+			case EEH_Money::compare_floats($paid, $price, '>'):
1926
+			case EEH_Money::compare_floats($paid, $price):
1927
+				$new_status = EEM_Registration::status_id_approved;
1928
+				break;
1929
+			//  underpaid
1930
+			case EEH_Money::compare_floats($paid, $price, '<'):
1931
+				$new_status = EEM_Registration::status_id_pending_payment;
1932
+				break;
1933
+			// uhhh Houston...
1934
+			default:
1935
+				throw new RuntimeException(
1936
+					esc_html__('The total paid calculation for this registration is inaccurate.', 'event_espresso')
1937
+				);
1938
+		}
1939
+		if ($new_status !== $this->status_ID()) {
1940
+			if ($trigger_set_status_logic) {
1941
+				return $this->set_status($new_status);
1942
+			}
1943
+			parent::set('STS_ID', $new_status);
1944
+			return true;
1945
+		}
1946
+		return false;
1947
+	}
1948
+
1949
+
1950
+	/*************************** DEPRECATED ***************************/
1951
+
1952
+
1953
+	/**
1954
+	 * @deprecated
1955
+	 * @since     4.7.0
1956
+	 * @access    public
1957
+	 */
1958
+	public function price_paid()
1959
+	{
1960
+		EE_Error::doing_it_wrong('EE_Registration::price_paid()',
1961
+			esc_html__('This method is deprecated, please use EE_Registration::final_price() instead.', 'event_espresso'),
1962
+			'4.7.0');
1963
+		return $this->final_price();
1964
+	}
1965
+
1966
+
1967
+	/**
1968
+	 * @deprecated
1969
+	 * @since     4.7.0
1970
+	 * @access    public
1971
+	 * @param    float $REG_final_price
1972
+	 * @throws EE_Error
1973
+	 * @throws RuntimeException
1974
+	 */
1975
+	public function set_price_paid($REG_final_price = 0.00)
1976
+	{
1977
+		EE_Error::doing_it_wrong('EE_Registration::set_price_paid()',
1978
+			esc_html__('This method is deprecated, please use EE_Registration::set_final_price() instead.', 'event_espresso'),
1979
+			'4.7.0');
1980
+		$this->set_final_price($REG_final_price);
1981
+	}
1982
+
1983
+
1984
+	/**
1985
+	 * @deprecated
1986
+	 * @since 4.7.0
1987
+	 * @return string
1988
+	 * @throws EE_Error
1989
+	 */
1990
+	public function pretty_price_paid()
1991
+	{
1992
+		EE_Error::doing_it_wrong('EE_Registration::pretty_price_paid()',
1993
+			esc_html__('This method is deprecated, please use EE_Registration::pretty_final_price() instead.',
1994
+				'event_espresso'), '4.7.0');
1995
+		return $this->pretty_final_price();
1996
+	}
1997
+
1998
+
1999
+	/**
2000
+	 * Gets the primary datetime related to this registration via the related Event to this registration
2001
+	 *
2002
+	 * @deprecated 4.9.17
2003
+	 * @return EE_Datetime
2004
+	 * @throws EE_Error
2005
+	 * @throws EntityNotFoundException
2006
+	 */
2007
+	public function get_related_primary_datetime()
2008
+	{
2009
+		EE_Error::doing_it_wrong(
2010
+			__METHOD__,
2011
+			esc_html__(
2012
+				'Use EE_Registration::get_latest_related_datetime() or EE_Registration::get_earliest_related_datetime()',
2013
+				'event_espresso'
2014
+			),
2015
+			'4.9.17',
2016
+			'5.0.0'
2017
+		);
2018
+		return $this->event()->primary_datetime();
2019
+	}
2020 2020
 
2021 2021
 
2022 2022
 }
Please login to merge, or discard this patch.
core/helpers/EEH_Array.helper.php 2 patches
Indentation   +196 added lines, -196 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if (! defined('EVENT_ESPRESSO_VERSION')) {
3
-    exit('NO direct script access allowed');
3
+	exit('NO direct script access allowed');
4 4
 }
5 5
 
6 6
 require_once(EE_HELPERS . 'EEH_Base.helper.php');
@@ -18,201 +18,201 @@  discard block
 block discarded – undo
18 18
 {
19 19
 
20 20
 
21
-    /**
22
-     * This method basically works the same as the PHP core function array_diff except it allows you to compare arrays
23
-     * of EE_Base_Class objects NOTE: This will ONLY work on an array of EE_Base_Class objects
24
-     *
25
-     * @uses array_udiff core php function for setting up our own array comparison
26
-     * @uses self::_compare_objects as the custom method for array_udiff
27
-     * @param  array $array1 an array of objects
28
-     * @param  array $array2 an array of objects
29
-     * @return array         an array of objects found in array 1 that aren't found in array 2.
30
-     */
31
-    public static function object_array_diff($array1, $array2)
32
-    {
33
-        return array_udiff($array1, $array2, array('self', '_compare_objects'));
34
-    }
35
-
36
-    /**
37
-     * Given that $arr is an array, determines if it's associative or numerically AND sequentially indexed
38
-     *
39
-     * @param array $array
40
-     * @return boolean
41
-     */
42
-    public static function is_associative_array(array $array)
43
-    {
44
-        return array_keys($array) !== range(0, count($array) - 1);
45
-    }
46
-
47
-    /**
48
-     * Gets an item from the array and leave the array intact. Use in place of end()
49
-     * when you don't want to change the array
50
-     *
51
-     * @param array $arr
52
-     * @return mixed what ever is in the array
53
-     */
54
-    public static function get_one_item_from_array($arr)
55
-    {
56
-        $item = end($arr);
57
-        reset($arr);
58
-        return $item;
59
-    }
60
-
61
-    /**
62
-     * Detects if this is a multi-dimensional array (meaning that the top-level
63
-     * values are themselves array. Eg array(array(...),...)
64
-     *
65
-     * @param mixed $arr
66
-     * @return boolean
67
-     */
68
-    public static function is_multi_dimensional_array($arr)
69
-    {
70
-        if (is_array($arr)) {
71
-            $first_item = reset($arr);
72
-            if (is_array($first_item)) {
73
-                return true;//yep, there's at least 2 levels to this array
74
-            } else {
75
-                return false;//nope, only 1 level
76
-            }
77
-        } else {
78
-            return false;//its not an array at all!
79
-        }
80
-    }
81
-
82
-    /**
83
-     * Shorthand for isset( $arr[ $index ] ) ? $arr[ $index ] : $default
84
-     *
85
-     * @param array $arr
86
-     * @param mixed $index
87
-     * @param mixed $default
88
-     * @return mixed
89
-     */
90
-    public static function is_set($arr, $index, $default)
91
-    {
92
-        return isset($arr[$index]) ? $arr[$index] : $default;
93
-    }
94
-
95
-    /**
96
-     * Exactly like `maybe_unserialize`, but also accounts for a WP bug: http://core.trac.wordpress.org/ticket/26118
97
-     *
98
-     * @param mixed $value usually a string, but could be an array or object
99
-     * @return mixed the UN-serialized data
100
-     */
101
-    public static function maybe_unserialize($value)
102
-    {
103
-        $data = maybe_unserialize($value);
104
-        //it's possible that this still has serialized data if its the session.  WP has a bug, http://core.trac.wordpress.org/ticket/26118 that doesnt' unserialize this automatically.
105
-        $token = 'C';
106
-        $data = is_string($data) ? trim($data) : $data;
107
-        if (is_string($data) && strlen($data) > 1 && $data[0] == $token && preg_match("/^{$token}:[0-9]+:/s", $data)) {
108
-            return unserialize($data);
109
-        } else {
110
-            return $data;
111
-        }
112
-    }
113
-
114
-
115
-    /**
116
-     * insert_into_array
117
-     *
118
-     * @param array        $target_array the array to insert new data into
119
-     * @param array        $array_to_insert the new data to be inserted
120
-     * @param int | string $offset a known key within $target_array where new data will be inserted
121
-     * @param bool         $add_before whether to add new data before or after the offset key
122
-     * @param bool         $preserve_keys whether or not to reset numerically indexed arrays
123
-     * @return array
124
-     */
125
-    public static function insert_into_array(
126
-        $target_array = array(),
127
-        $array_to_insert = array(),
128
-        $offset = null,
129
-        $add_before = true,
130
-        $preserve_keys = true
131
-    ) {
132
-        // ensure incoming arrays are actually arrays
133
-        $target_array = (array)$target_array;
134
-        $array_to_insert = (array)$array_to_insert;
135
-        // if no offset key was supplied
136
-        if (empty($offset)) {
137
-            // use start or end of $target_array based on whether we are adding before or not
138
-            $offset = $add_before ? 0 : count($target_array);
139
-        }
140
-        // if offset key is a string, then find the corresponding numeric location for that element
141
-        $offset = is_int($offset) ? $offset : array_search($offset, array_keys($target_array));
142
-        // add one to the offset if adding after
143
-        $offset = $add_before ? $offset : $offset + 1;
144
-        // but ensure offset does not exceed the length of the array
145
-        $offset = $offset > count($target_array) ? count($target_array) : $offset;
146
-        // reindex array ???
147
-        if ($preserve_keys) {
148
-            // take a slice of the target array from the beginning till the offset,
149
-            // then add the new data
150
-            // then add another slice that starts at the offset and goes till the end
151
-            return array_slice($target_array, 0, $offset, true) + $array_to_insert + array_slice($target_array, $offset,
152
-                    null, true);
153
-        } else {
154
-            // since we don't want to preserve keys, we can use array_splice
155
-            array_splice($target_array, $offset, 0, $array_to_insert);
156
-            return $target_array;
157
-        }
158
-    }
159
-
160
-
161
-    /**
162
-     * array_merge() is slow and should never be used while looping over data
163
-     * if you don't need to preserve keys from all arrays, then using a foreach loop is much faster
164
-     * so really this acts more like array_replace( $array1, $array2 )
165
-     * or a union with the arrays flipped ( $array2 + $array1 )
166
-     * this saves a few lines of code and improves readability
167
-     *
168
-     * @param array $array1
169
-     * @param array $array2
170
-     * @return array
171
-     */
172
-    public static function merge_arrays_and_overwrite_keys(array $array1, array $array2)
173
-    {
174
-        foreach ($array2 as $key => $value) {
175
-            $array1[$key] = $value;
176
-        }
177
-        return $array1;
178
-    }
179
-
180
-
181
-    /**
182
-     * given a flat array like $array = array('A', 'B', 'C')
183
-     * will convert into a multidimensional array like $array[A][B][C]
184
-     * if $final_value is provided and is anything other than null,
185
-     * then that will be set as the value for the innermost array key
186
-     * like so: $array[A][B][C] = $final_value
187
-     *
188
-     * @param array $flat_array
189
-     * @param mixed $final_value
190
-     * @return array
191
-     */
192
-    public static function convert_array_values_to_keys(array $flat_array, $final_value = null)
193
-    {
194
-        $multidimensional = array();
195
-        $reference = &$multidimensional;
196
-        foreach ($flat_array as $key) {
197
-            $reference[$key] = array();
198
-            $reference = &$reference[$key];
199
-        }
200
-        if ($final_value !== null) {
201
-            $reference = $final_value;
202
-        }
203
-        return $multidimensional;
204
-    }
205
-
206
-
207
-    /**
208
-     * @see http://stackoverflow.com/questions/173400/how-to-check-if-php-array-is-associative-or-sequential
209
-     * @param array $array
210
-     * @return bool
211
-     */
212
-    public static function is_array_numerically_and_sequentially_indexed(array $array)
213
-    {
214
-        return ! empty($array) ? array_keys($array) === range(0, count($array) - 1) : true;
215
-    }
21
+	/**
22
+	 * This method basically works the same as the PHP core function array_diff except it allows you to compare arrays
23
+	 * of EE_Base_Class objects NOTE: This will ONLY work on an array of EE_Base_Class objects
24
+	 *
25
+	 * @uses array_udiff core php function for setting up our own array comparison
26
+	 * @uses self::_compare_objects as the custom method for array_udiff
27
+	 * @param  array $array1 an array of objects
28
+	 * @param  array $array2 an array of objects
29
+	 * @return array         an array of objects found in array 1 that aren't found in array 2.
30
+	 */
31
+	public static function object_array_diff($array1, $array2)
32
+	{
33
+		return array_udiff($array1, $array2, array('self', '_compare_objects'));
34
+	}
35
+
36
+	/**
37
+	 * Given that $arr is an array, determines if it's associative or numerically AND sequentially indexed
38
+	 *
39
+	 * @param array $array
40
+	 * @return boolean
41
+	 */
42
+	public static function is_associative_array(array $array)
43
+	{
44
+		return array_keys($array) !== range(0, count($array) - 1);
45
+	}
46
+
47
+	/**
48
+	 * Gets an item from the array and leave the array intact. Use in place of end()
49
+	 * when you don't want to change the array
50
+	 *
51
+	 * @param array $arr
52
+	 * @return mixed what ever is in the array
53
+	 */
54
+	public static function get_one_item_from_array($arr)
55
+	{
56
+		$item = end($arr);
57
+		reset($arr);
58
+		return $item;
59
+	}
60
+
61
+	/**
62
+	 * Detects if this is a multi-dimensional array (meaning that the top-level
63
+	 * values are themselves array. Eg array(array(...),...)
64
+	 *
65
+	 * @param mixed $arr
66
+	 * @return boolean
67
+	 */
68
+	public static function is_multi_dimensional_array($arr)
69
+	{
70
+		if (is_array($arr)) {
71
+			$first_item = reset($arr);
72
+			if (is_array($first_item)) {
73
+				return true;//yep, there's at least 2 levels to this array
74
+			} else {
75
+				return false;//nope, only 1 level
76
+			}
77
+		} else {
78
+			return false;//its not an array at all!
79
+		}
80
+	}
81
+
82
+	/**
83
+	 * Shorthand for isset( $arr[ $index ] ) ? $arr[ $index ] : $default
84
+	 *
85
+	 * @param array $arr
86
+	 * @param mixed $index
87
+	 * @param mixed $default
88
+	 * @return mixed
89
+	 */
90
+	public static function is_set($arr, $index, $default)
91
+	{
92
+		return isset($arr[$index]) ? $arr[$index] : $default;
93
+	}
94
+
95
+	/**
96
+	 * Exactly like `maybe_unserialize`, but also accounts for a WP bug: http://core.trac.wordpress.org/ticket/26118
97
+	 *
98
+	 * @param mixed $value usually a string, but could be an array or object
99
+	 * @return mixed the UN-serialized data
100
+	 */
101
+	public static function maybe_unserialize($value)
102
+	{
103
+		$data = maybe_unserialize($value);
104
+		//it's possible that this still has serialized data if its the session.  WP has a bug, http://core.trac.wordpress.org/ticket/26118 that doesnt' unserialize this automatically.
105
+		$token = 'C';
106
+		$data = is_string($data) ? trim($data) : $data;
107
+		if (is_string($data) && strlen($data) > 1 && $data[0] == $token && preg_match("/^{$token}:[0-9]+:/s", $data)) {
108
+			return unserialize($data);
109
+		} else {
110
+			return $data;
111
+		}
112
+	}
113
+
114
+
115
+	/**
116
+	 * insert_into_array
117
+	 *
118
+	 * @param array        $target_array the array to insert new data into
119
+	 * @param array        $array_to_insert the new data to be inserted
120
+	 * @param int | string $offset a known key within $target_array where new data will be inserted
121
+	 * @param bool         $add_before whether to add new data before or after the offset key
122
+	 * @param bool         $preserve_keys whether or not to reset numerically indexed arrays
123
+	 * @return array
124
+	 */
125
+	public static function insert_into_array(
126
+		$target_array = array(),
127
+		$array_to_insert = array(),
128
+		$offset = null,
129
+		$add_before = true,
130
+		$preserve_keys = true
131
+	) {
132
+		// ensure incoming arrays are actually arrays
133
+		$target_array = (array)$target_array;
134
+		$array_to_insert = (array)$array_to_insert;
135
+		// if no offset key was supplied
136
+		if (empty($offset)) {
137
+			// use start or end of $target_array based on whether we are adding before or not
138
+			$offset = $add_before ? 0 : count($target_array);
139
+		}
140
+		// if offset key is a string, then find the corresponding numeric location for that element
141
+		$offset = is_int($offset) ? $offset : array_search($offset, array_keys($target_array));
142
+		// add one to the offset if adding after
143
+		$offset = $add_before ? $offset : $offset + 1;
144
+		// but ensure offset does not exceed the length of the array
145
+		$offset = $offset > count($target_array) ? count($target_array) : $offset;
146
+		// reindex array ???
147
+		if ($preserve_keys) {
148
+			// take a slice of the target array from the beginning till the offset,
149
+			// then add the new data
150
+			// then add another slice that starts at the offset and goes till the end
151
+			return array_slice($target_array, 0, $offset, true) + $array_to_insert + array_slice($target_array, $offset,
152
+					null, true);
153
+		} else {
154
+			// since we don't want to preserve keys, we can use array_splice
155
+			array_splice($target_array, $offset, 0, $array_to_insert);
156
+			return $target_array;
157
+		}
158
+	}
159
+
160
+
161
+	/**
162
+	 * array_merge() is slow and should never be used while looping over data
163
+	 * if you don't need to preserve keys from all arrays, then using a foreach loop is much faster
164
+	 * so really this acts more like array_replace( $array1, $array2 )
165
+	 * or a union with the arrays flipped ( $array2 + $array1 )
166
+	 * this saves a few lines of code and improves readability
167
+	 *
168
+	 * @param array $array1
169
+	 * @param array $array2
170
+	 * @return array
171
+	 */
172
+	public static function merge_arrays_and_overwrite_keys(array $array1, array $array2)
173
+	{
174
+		foreach ($array2 as $key => $value) {
175
+			$array1[$key] = $value;
176
+		}
177
+		return $array1;
178
+	}
179
+
180
+
181
+	/**
182
+	 * given a flat array like $array = array('A', 'B', 'C')
183
+	 * will convert into a multidimensional array like $array[A][B][C]
184
+	 * if $final_value is provided and is anything other than null,
185
+	 * then that will be set as the value for the innermost array key
186
+	 * like so: $array[A][B][C] = $final_value
187
+	 *
188
+	 * @param array $flat_array
189
+	 * @param mixed $final_value
190
+	 * @return array
191
+	 */
192
+	public static function convert_array_values_to_keys(array $flat_array, $final_value = null)
193
+	{
194
+		$multidimensional = array();
195
+		$reference = &$multidimensional;
196
+		foreach ($flat_array as $key) {
197
+			$reference[$key] = array();
198
+			$reference = &$reference[$key];
199
+		}
200
+		if ($final_value !== null) {
201
+			$reference = $final_value;
202
+		}
203
+		return $multidimensional;
204
+	}
205
+
206
+
207
+	/**
208
+	 * @see http://stackoverflow.com/questions/173400/how-to-check-if-php-array-is-associative-or-sequential
209
+	 * @param array $array
210
+	 * @return bool
211
+	 */
212
+	public static function is_array_numerically_and_sequentially_indexed(array $array)
213
+	{
214
+		return ! empty($array) ? array_keys($array) === range(0, count($array) - 1) : true;
215
+	}
216 216
 
217 217
 
218 218
 } //end EEH_Template class
219 219
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (! defined('EVENT_ESPRESSO_VERSION')) {
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3 3
     exit('NO direct script access allowed');
4 4
 }
5 5
 
6
-require_once(EE_HELPERS . 'EEH_Base.helper.php');
6
+require_once(EE_HELPERS.'EEH_Base.helper.php');
7 7
 
8 8
 /**
9 9
  * EE_Array
@@ -70,12 +70,12 @@  discard block
 block discarded – undo
70 70
         if (is_array($arr)) {
71 71
             $first_item = reset($arr);
72 72
             if (is_array($first_item)) {
73
-                return true;//yep, there's at least 2 levels to this array
73
+                return true; //yep, there's at least 2 levels to this array
74 74
             } else {
75
-                return false;//nope, only 1 level
75
+                return false; //nope, only 1 level
76 76
             }
77 77
         } else {
78
-            return false;//its not an array at all!
78
+            return false; //its not an array at all!
79 79
         }
80 80
     }
81 81
 
@@ -130,8 +130,8 @@  discard block
 block discarded – undo
130 130
         $preserve_keys = true
131 131
     ) {
132 132
         // ensure incoming arrays are actually arrays
133
-        $target_array = (array)$target_array;
134
-        $array_to_insert = (array)$array_to_insert;
133
+        $target_array = (array) $target_array;
134
+        $array_to_insert = (array) $array_to_insert;
135 135
         // if no offset key was supplied
136 136
         if (empty($offset)) {
137 137
             // use start or end of $target_array based on whether we are adding before or not
Please login to merge, or discard this patch.
core/EE_Error.core.php 2 patches
Indentation   +1030 added lines, -1030 removed lines patch added patch discarded remove patch
@@ -11,8 +11,8 @@  discard block
 block discarded – undo
11 11
 // if you're a dev and want to receive all errors via email
12 12
 // add this to your wp-config.php: define( 'EE_ERROR_EMAILS', TRUE );
13 13
 if (defined('WP_DEBUG') && WP_DEBUG === true && defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS === true) {
14
-    set_error_handler(array('EE_Error', 'error_handler'));
15
-    register_shutdown_function(array('EE_Error', 'fatal_error_handler'));
14
+	set_error_handler(array('EE_Error', 'error_handler'));
15
+	register_shutdown_function(array('EE_Error', 'fatal_error_handler'));
16 16
 }
17 17
 
18 18
 
@@ -27,256 +27,256 @@  discard block
 block discarded – undo
27 27
 class EE_Error extends Exception
28 28
 {
29 29
 
30
-    const OPTIONS_KEY_NOTICES = 'ee_notices';
31
-
32
-
33
-    /**
34
-     * name of the file to log exceptions to
35
-     *
36
-     * @var string
37
-     */
38
-    private static $_exception_log_file = 'espresso_error_log.txt';
39
-
40
-    /**
41
-     *    stores details for all exception
42
-     *
43
-     * @var array
44
-     */
45
-    private static $_all_exceptions = array();
46
-
47
-    /**
48
-     *    tracks number of errors
49
-     *
50
-     * @var int
51
-     */
52
-    private static $_error_count = 0;
53
-
54
-    /**
55
-     * @var array $_espresso_notices
56
-     */
57
-    private static $_espresso_notices = array('success' => false, 'errors' => false, 'attention' => false);
58
-
59
-
60
-
61
-    /**
62
-     * @override default exception handling
63
-     * @param string         $message
64
-     * @param int            $code
65
-     * @param Exception|null $previous
66
-     */
67
-    public function __construct($message, $code = 0, Exception $previous = null)
68
-    {
69
-        if (version_compare(PHP_VERSION, '5.3.0', '<')) {
70
-            parent::__construct($message, $code);
71
-        } else {
72
-            parent::__construct($message, $code, $previous);
73
-        }
74
-    }
75
-
76
-
77
-
78
-    /**
79
-     *    error_handler
80
-     *
81
-     * @param $code
82
-     * @param $message
83
-     * @param $file
84
-     * @param $line
85
-     * @return void
86
-     */
87
-    public static function error_handler($code, $message, $file, $line)
88
-    {
89
-        $type = EE_Error::error_type($code);
90
-        $site = site_url();
91
-        switch ($site) {
92
-            case 'http://ee4.eventespresso.com/' :
93
-            case 'http://ee4decaf.eventespresso.com/' :
94
-            case 'http://ee4hf.eventespresso.com/' :
95
-            case 'http://ee4a.eventespresso.com/' :
96
-            case 'http://ee4ad.eventespresso.com/' :
97
-            case 'http://ee4b.eventespresso.com/' :
98
-            case 'http://ee4bd.eventespresso.com/' :
99
-            case 'http://ee4d.eventespresso.com/' :
100
-            case 'http://ee4dd.eventespresso.com/' :
101
-                $to = '[email protected]';
102
-                break;
103
-            default :
104
-                $to = get_option('admin_email');
105
-        }
106
-        $subject = $type . ' ' . $message . ' in ' . EVENT_ESPRESSO_VERSION . ' on ' . site_url();
107
-        $msg = EE_Error::_format_error($type, $message, $file, $line);
108
-        if (function_exists('wp_mail')) {
109
-            add_filter('wp_mail_content_type', array('EE_Error', 'set_content_type'));
110
-            wp_mail($to, $subject, $msg);
111
-        }
112
-        echo '<div id="message" class="espresso-notices error"><p>';
113
-        echo $type . ': ' . $message . '<br />' . $file . ' line ' . $line;
114
-        echo '<br /></p></div>';
115
-    }
116
-
117
-
118
-
119
-    /**
120
-     * error_type
121
-     * http://www.php.net/manual/en/errorfunc.constants.php#109430
122
-     *
123
-     * @param $code
124
-     * @return string
125
-     */
126
-    public static function error_type($code)
127
-    {
128
-        switch ($code) {
129
-            case E_ERROR: // 1 //
130
-                return 'E_ERROR';
131
-            case E_WARNING: // 2 //
132
-                return 'E_WARNING';
133
-            case E_PARSE: // 4 //
134
-                return 'E_PARSE';
135
-            case E_NOTICE: // 8 //
136
-                return 'E_NOTICE';
137
-            case E_CORE_ERROR: // 16 //
138
-                return 'E_CORE_ERROR';
139
-            case E_CORE_WARNING: // 32 //
140
-                return 'E_CORE_WARNING';
141
-            case E_COMPILE_ERROR: // 64 //
142
-                return 'E_COMPILE_ERROR';
143
-            case E_COMPILE_WARNING: // 128 //
144
-                return 'E_COMPILE_WARNING';
145
-            case E_USER_ERROR: // 256 //
146
-                return 'E_USER_ERROR';
147
-            case E_USER_WARNING: // 512 //
148
-                return 'E_USER_WARNING';
149
-            case E_USER_NOTICE: // 1024 //
150
-                return 'E_USER_NOTICE';
151
-            case E_STRICT: // 2048 //
152
-                return 'E_STRICT';
153
-            case E_RECOVERABLE_ERROR: // 4096 //
154
-                return 'E_RECOVERABLE_ERROR';
155
-            case E_DEPRECATED: // 8192 //
156
-                return 'E_DEPRECATED';
157
-            case E_USER_DEPRECATED: // 16384 //
158
-                return 'E_USER_DEPRECATED';
159
-            case E_ALL: // 16384 //
160
-                return 'E_ALL';
161
-        }
162
-        return '';
163
-    }
164
-
165
-
166
-
167
-    /**
168
-     *    fatal_error_handler
169
-     *
170
-     * @return void
171
-     */
172
-    public static function fatal_error_handler()
173
-    {
174
-        $last_error = error_get_last();
175
-        if ($last_error['type'] === E_ERROR) {
176
-            EE_Error::error_handler(E_ERROR, $last_error['message'], $last_error['file'], $last_error['line']);
177
-        }
178
-    }
179
-
180
-
181
-
182
-    /**
183
-     * _format_error
184
-     *
185
-     * @param $code
186
-     * @param $message
187
-     * @param $file
188
-     * @param $line
189
-     * @return string
190
-     */
191
-    private static function _format_error($code, $message, $file, $line)
192
-    {
193
-        $html = "<table cellpadding='5'><thead bgcolor='#f8f8f8'><th>Item</th><th align='left'>Details</th></thead><tbody>";
194
-        $html .= "<tr valign='top'><td><b>Code</b></td><td>$code</td></tr>";
195
-        $html .= "<tr valign='top'><td><b>Error</b></td><td>$message</td></tr>";
196
-        $html .= "<tr valign='top'><td><b>File</b></td><td>$file</td></tr>";
197
-        $html .= "<tr valign='top'><td><b>Line</b></td><td>$line</td></tr>";
198
-        $html .= '</tbody></table>';
199
-        return $html;
200
-    }
201
-
202
-
203
-
204
-    /**
205
-     * set_content_type
206
-     *
207
-     * @param $content_type
208
-     * @return string
209
-     */
210
-    public static function set_content_type($content_type)
211
-    {
212
-        return 'text/html';
213
-    }
214
-
215
-
216
-
217
-    /**
218
-     * @return void
219
-     * @throws EE_Error
220
-     * @throws ReflectionException
221
-     */
222
-    public function get_error()
223
-    {
224
-        if (apply_filters('FHEE__EE_Error__get_error__show_normal_exceptions', false)) {
225
-            throw $this;
226
-        }
227
-        // get separate user and developer messages if they exist
228
-        $msg = explode('||', $this->getMessage());
229
-        $user_msg = $msg[0];
230
-        $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0];
231
-        $msg = WP_DEBUG ? $dev_msg : $user_msg;
232
-        // add details to _all_exceptions array
233
-        $x_time = time();
234
-        self::$_all_exceptions[$x_time]['name'] = get_class($this);
235
-        self::$_all_exceptions[$x_time]['file'] = $this->getFile();
236
-        self::$_all_exceptions[$x_time]['line'] = $this->getLine();
237
-        self::$_all_exceptions[$x_time]['msg'] = $msg;
238
-        self::$_all_exceptions[$x_time]['code'] = $this->getCode();
239
-        self::$_all_exceptions[$x_time]['trace'] = $this->getTrace();
240
-        self::$_all_exceptions[$x_time]['string'] = $this->getTraceAsString();
241
-        self::$_error_count++;
242
-        //add_action( 'shutdown', array( $this, 'display_errors' ));
243
-        $this->display_errors();
244
-    }
245
-
246
-
247
-
248
-    /**
249
-     * @param bool   $check_stored
250
-     * @param string $type_to_check
251
-     * @return bool
252
-     */
253
-    public static function has_error($check_stored = false, $type_to_check = 'errors')
254
-    {
255
-        $has_error = isset(self::$_espresso_notices[$type_to_check])
256
-                     && ! empty(self::$_espresso_notices[$type_to_check])
257
-            ? true
258
-            : false;
259
-        if ($check_stored && ! $has_error) {
260
-            $notices = (array)get_option(EE_Error::OPTIONS_KEY_NOTICES, array());
261
-            foreach ($notices as $type => $notice) {
262
-                if ($type === $type_to_check && $notice) {
263
-                    return true;
264
-                }
265
-            }
266
-        }
267
-        return $has_error;
268
-    }
269
-
270
-
271
-
272
-    /**
273
-     * @echo string
274
-     * @throws \ReflectionException
275
-     */
276
-    public function display_errors()
277
-    {
278
-        $trace_details = '';
279
-        $output = '
30
+	const OPTIONS_KEY_NOTICES = 'ee_notices';
31
+
32
+
33
+	/**
34
+	 * name of the file to log exceptions to
35
+	 *
36
+	 * @var string
37
+	 */
38
+	private static $_exception_log_file = 'espresso_error_log.txt';
39
+
40
+	/**
41
+	 *    stores details for all exception
42
+	 *
43
+	 * @var array
44
+	 */
45
+	private static $_all_exceptions = array();
46
+
47
+	/**
48
+	 *    tracks number of errors
49
+	 *
50
+	 * @var int
51
+	 */
52
+	private static $_error_count = 0;
53
+
54
+	/**
55
+	 * @var array $_espresso_notices
56
+	 */
57
+	private static $_espresso_notices = array('success' => false, 'errors' => false, 'attention' => false);
58
+
59
+
60
+
61
+	/**
62
+	 * @override default exception handling
63
+	 * @param string         $message
64
+	 * @param int            $code
65
+	 * @param Exception|null $previous
66
+	 */
67
+	public function __construct($message, $code = 0, Exception $previous = null)
68
+	{
69
+		if (version_compare(PHP_VERSION, '5.3.0', '<')) {
70
+			parent::__construct($message, $code);
71
+		} else {
72
+			parent::__construct($message, $code, $previous);
73
+		}
74
+	}
75
+
76
+
77
+
78
+	/**
79
+	 *    error_handler
80
+	 *
81
+	 * @param $code
82
+	 * @param $message
83
+	 * @param $file
84
+	 * @param $line
85
+	 * @return void
86
+	 */
87
+	public static function error_handler($code, $message, $file, $line)
88
+	{
89
+		$type = EE_Error::error_type($code);
90
+		$site = site_url();
91
+		switch ($site) {
92
+			case 'http://ee4.eventespresso.com/' :
93
+			case 'http://ee4decaf.eventespresso.com/' :
94
+			case 'http://ee4hf.eventespresso.com/' :
95
+			case 'http://ee4a.eventespresso.com/' :
96
+			case 'http://ee4ad.eventespresso.com/' :
97
+			case 'http://ee4b.eventespresso.com/' :
98
+			case 'http://ee4bd.eventespresso.com/' :
99
+			case 'http://ee4d.eventespresso.com/' :
100
+			case 'http://ee4dd.eventespresso.com/' :
101
+				$to = '[email protected]';
102
+				break;
103
+			default :
104
+				$to = get_option('admin_email');
105
+		}
106
+		$subject = $type . ' ' . $message . ' in ' . EVENT_ESPRESSO_VERSION . ' on ' . site_url();
107
+		$msg = EE_Error::_format_error($type, $message, $file, $line);
108
+		if (function_exists('wp_mail')) {
109
+			add_filter('wp_mail_content_type', array('EE_Error', 'set_content_type'));
110
+			wp_mail($to, $subject, $msg);
111
+		}
112
+		echo '<div id="message" class="espresso-notices error"><p>';
113
+		echo $type . ': ' . $message . '<br />' . $file . ' line ' . $line;
114
+		echo '<br /></p></div>';
115
+	}
116
+
117
+
118
+
119
+	/**
120
+	 * error_type
121
+	 * http://www.php.net/manual/en/errorfunc.constants.php#109430
122
+	 *
123
+	 * @param $code
124
+	 * @return string
125
+	 */
126
+	public static function error_type($code)
127
+	{
128
+		switch ($code) {
129
+			case E_ERROR: // 1 //
130
+				return 'E_ERROR';
131
+			case E_WARNING: // 2 //
132
+				return 'E_WARNING';
133
+			case E_PARSE: // 4 //
134
+				return 'E_PARSE';
135
+			case E_NOTICE: // 8 //
136
+				return 'E_NOTICE';
137
+			case E_CORE_ERROR: // 16 //
138
+				return 'E_CORE_ERROR';
139
+			case E_CORE_WARNING: // 32 //
140
+				return 'E_CORE_WARNING';
141
+			case E_COMPILE_ERROR: // 64 //
142
+				return 'E_COMPILE_ERROR';
143
+			case E_COMPILE_WARNING: // 128 //
144
+				return 'E_COMPILE_WARNING';
145
+			case E_USER_ERROR: // 256 //
146
+				return 'E_USER_ERROR';
147
+			case E_USER_WARNING: // 512 //
148
+				return 'E_USER_WARNING';
149
+			case E_USER_NOTICE: // 1024 //
150
+				return 'E_USER_NOTICE';
151
+			case E_STRICT: // 2048 //
152
+				return 'E_STRICT';
153
+			case E_RECOVERABLE_ERROR: // 4096 //
154
+				return 'E_RECOVERABLE_ERROR';
155
+			case E_DEPRECATED: // 8192 //
156
+				return 'E_DEPRECATED';
157
+			case E_USER_DEPRECATED: // 16384 //
158
+				return 'E_USER_DEPRECATED';
159
+			case E_ALL: // 16384 //
160
+				return 'E_ALL';
161
+		}
162
+		return '';
163
+	}
164
+
165
+
166
+
167
+	/**
168
+	 *    fatal_error_handler
169
+	 *
170
+	 * @return void
171
+	 */
172
+	public static function fatal_error_handler()
173
+	{
174
+		$last_error = error_get_last();
175
+		if ($last_error['type'] === E_ERROR) {
176
+			EE_Error::error_handler(E_ERROR, $last_error['message'], $last_error['file'], $last_error['line']);
177
+		}
178
+	}
179
+
180
+
181
+
182
+	/**
183
+	 * _format_error
184
+	 *
185
+	 * @param $code
186
+	 * @param $message
187
+	 * @param $file
188
+	 * @param $line
189
+	 * @return string
190
+	 */
191
+	private static function _format_error($code, $message, $file, $line)
192
+	{
193
+		$html = "<table cellpadding='5'><thead bgcolor='#f8f8f8'><th>Item</th><th align='left'>Details</th></thead><tbody>";
194
+		$html .= "<tr valign='top'><td><b>Code</b></td><td>$code</td></tr>";
195
+		$html .= "<tr valign='top'><td><b>Error</b></td><td>$message</td></tr>";
196
+		$html .= "<tr valign='top'><td><b>File</b></td><td>$file</td></tr>";
197
+		$html .= "<tr valign='top'><td><b>Line</b></td><td>$line</td></tr>";
198
+		$html .= '</tbody></table>';
199
+		return $html;
200
+	}
201
+
202
+
203
+
204
+	/**
205
+	 * set_content_type
206
+	 *
207
+	 * @param $content_type
208
+	 * @return string
209
+	 */
210
+	public static function set_content_type($content_type)
211
+	{
212
+		return 'text/html';
213
+	}
214
+
215
+
216
+
217
+	/**
218
+	 * @return void
219
+	 * @throws EE_Error
220
+	 * @throws ReflectionException
221
+	 */
222
+	public function get_error()
223
+	{
224
+		if (apply_filters('FHEE__EE_Error__get_error__show_normal_exceptions', false)) {
225
+			throw $this;
226
+		}
227
+		// get separate user and developer messages if they exist
228
+		$msg = explode('||', $this->getMessage());
229
+		$user_msg = $msg[0];
230
+		$dev_msg = isset($msg[1]) ? $msg[1] : $msg[0];
231
+		$msg = WP_DEBUG ? $dev_msg : $user_msg;
232
+		// add details to _all_exceptions array
233
+		$x_time = time();
234
+		self::$_all_exceptions[$x_time]['name'] = get_class($this);
235
+		self::$_all_exceptions[$x_time]['file'] = $this->getFile();
236
+		self::$_all_exceptions[$x_time]['line'] = $this->getLine();
237
+		self::$_all_exceptions[$x_time]['msg'] = $msg;
238
+		self::$_all_exceptions[$x_time]['code'] = $this->getCode();
239
+		self::$_all_exceptions[$x_time]['trace'] = $this->getTrace();
240
+		self::$_all_exceptions[$x_time]['string'] = $this->getTraceAsString();
241
+		self::$_error_count++;
242
+		//add_action( 'shutdown', array( $this, 'display_errors' ));
243
+		$this->display_errors();
244
+	}
245
+
246
+
247
+
248
+	/**
249
+	 * @param bool   $check_stored
250
+	 * @param string $type_to_check
251
+	 * @return bool
252
+	 */
253
+	public static function has_error($check_stored = false, $type_to_check = 'errors')
254
+	{
255
+		$has_error = isset(self::$_espresso_notices[$type_to_check])
256
+					 && ! empty(self::$_espresso_notices[$type_to_check])
257
+			? true
258
+			: false;
259
+		if ($check_stored && ! $has_error) {
260
+			$notices = (array)get_option(EE_Error::OPTIONS_KEY_NOTICES, array());
261
+			foreach ($notices as $type => $notice) {
262
+				if ($type === $type_to_check && $notice) {
263
+					return true;
264
+				}
265
+			}
266
+		}
267
+		return $has_error;
268
+	}
269
+
270
+
271
+
272
+	/**
273
+	 * @echo string
274
+	 * @throws \ReflectionException
275
+	 */
276
+	public function display_errors()
277
+	{
278
+		$trace_details = '';
279
+		$output = '
280 280
 <style type="text/css">
281 281
 	#ee-error-message {
282 282
 		max-width:90% !important;
@@ -332,21 +332,21 @@  discard block
 block discarded – undo
332 332
 	}
333 333
 </style>
334 334
 <div id="ee-error-message" class="error">';
335
-        if (! WP_DEBUG) {
336
-            $output .= '
335
+		if (! WP_DEBUG) {
336
+			$output .= '
337 337
 	<p>';
338
-        }
339
-        // cycle thru errors
340
-        foreach (self::$_all_exceptions as $time => $ex) {
341
-            $error_code = '';
342
-            // process trace info
343
-            if (empty($ex['trace'])) {
344
-                $trace_details .= __(
345
-                    'Sorry, but no trace information was available for this exception.',
346
-                    'event_espresso'
347
-                );
348
-            } else {
349
-                $trace_details .= '
338
+		}
339
+		// cycle thru errors
340
+		foreach (self::$_all_exceptions as $time => $ex) {
341
+			$error_code = '';
342
+			// process trace info
343
+			if (empty($ex['trace'])) {
344
+				$trace_details .= __(
345
+					'Sorry, but no trace information was available for this exception.',
346
+					'event_espresso'
347
+				);
348
+			} else {
349
+				$trace_details .= '
350 350
 			<div id="ee-trace-details">
351 351
 			<table width="100%" border="0" cellpadding="5" cellspacing="0">
352 352
 				<tr>
@@ -356,43 +356,43 @@  discard block
 block discarded – undo
356 356
 					<th scope="col" align="left">Class</th>
357 357
 					<th scope="col" align="left">Method( arguments )</th>
358 358
 				</tr>';
359
-                $last_on_stack = count($ex['trace']) - 1;
360
-                // reverse array so that stack is in proper chronological order
361
-                $sorted_trace = array_reverse($ex['trace']);
362
-                foreach ($sorted_trace as $nmbr => $trace) {
363
-                    $file = isset($trace['file']) ? $trace['file'] : '';
364
-                    $class = isset($trace['class']) ? $trace['class'] : '';
365
-                    $type = isset($trace['type']) ? $trace['type'] : '';
366
-                    $function = isset($trace['function']) ? $trace['function'] : '';
367
-                    $args = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : '';
368
-                    $line = isset($trace['line']) ? $trace['line'] : '';
369
-                    $zebra = ($nmbr % 2) ? ' odd' : '';
370
-                    if (empty($file) && ! empty($class)) {
371
-                        $a = new ReflectionClass($class);
372
-                        $file = $a->getFileName();
373
-                        if (empty($line) && ! empty($function)) {
374
-                            try {
375
-                                //if $function is a closure, this throws an exception
376
-                                $b = new ReflectionMethod($class, $function);
377
-                                $line = $b->getStartLine();
378
-                            } catch (Exception $closure_exception) {
379
-                                $line = 'unknown';
380
-                            }
381
-                        }
382
-                    }
383
-                    if ($nmbr === $last_on_stack) {
384
-                        $file = $ex['file'] !== '' ? $ex['file'] : $file;
385
-                        $line = $ex['line'] !== '' ? $ex['line'] : $line;
386
-                        $error_code = self::generate_error_code($file, $trace['function'], $line);
387
-                    }
388
-                    $nmbr_dsply = ! empty($nmbr) ? $nmbr : '&nbsp;';
389
-                    $line_dsply = ! empty($line) ? $line : '&nbsp;';
390
-                    $file_dsply = ! empty($file) ? $file : '&nbsp;';
391
-                    $class_dsply = ! empty($class) ? $class : '&nbsp;';
392
-                    $type_dsply = ! empty($type) ? $type : '&nbsp;';
393
-                    $function_dsply = ! empty($function) ? $function : '&nbsp;';
394
-                    $args_dsply = ! empty($args) ? '( ' . $args . ' )' : '';
395
-                    $trace_details .= '
359
+				$last_on_stack = count($ex['trace']) - 1;
360
+				// reverse array so that stack is in proper chronological order
361
+				$sorted_trace = array_reverse($ex['trace']);
362
+				foreach ($sorted_trace as $nmbr => $trace) {
363
+					$file = isset($trace['file']) ? $trace['file'] : '';
364
+					$class = isset($trace['class']) ? $trace['class'] : '';
365
+					$type = isset($trace['type']) ? $trace['type'] : '';
366
+					$function = isset($trace['function']) ? $trace['function'] : '';
367
+					$args = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : '';
368
+					$line = isset($trace['line']) ? $trace['line'] : '';
369
+					$zebra = ($nmbr % 2) ? ' odd' : '';
370
+					if (empty($file) && ! empty($class)) {
371
+						$a = new ReflectionClass($class);
372
+						$file = $a->getFileName();
373
+						if (empty($line) && ! empty($function)) {
374
+							try {
375
+								//if $function is a closure, this throws an exception
376
+								$b = new ReflectionMethod($class, $function);
377
+								$line = $b->getStartLine();
378
+							} catch (Exception $closure_exception) {
379
+								$line = 'unknown';
380
+							}
381
+						}
382
+					}
383
+					if ($nmbr === $last_on_stack) {
384
+						$file = $ex['file'] !== '' ? $ex['file'] : $file;
385
+						$line = $ex['line'] !== '' ? $ex['line'] : $line;
386
+						$error_code = self::generate_error_code($file, $trace['function'], $line);
387
+					}
388
+					$nmbr_dsply = ! empty($nmbr) ? $nmbr : '&nbsp;';
389
+					$line_dsply = ! empty($line) ? $line : '&nbsp;';
390
+					$file_dsply = ! empty($file) ? $file : '&nbsp;';
391
+					$class_dsply = ! empty($class) ? $class : '&nbsp;';
392
+					$type_dsply = ! empty($type) ? $type : '&nbsp;';
393
+					$function_dsply = ! empty($function) ? $function : '&nbsp;';
394
+					$args_dsply = ! empty($args) ? '( ' . $args . ' )' : '';
395
+					$trace_details .= '
396 396
 					<tr>
397 397
 						<td align="right" class="' . $zebra . '">' . $nmbr_dsply . '</td>
398 398
 						<td align="right" class="' . $zebra . '">' . $line_dsply . '</td>
@@ -400,523 +400,523 @@  discard block
 block discarded – undo
400 400
 						<td align="left" class="' . $zebra . '">' . $class_dsply . '</td>
401 401
 						<td align="left" class="' . $zebra . '">' . $type_dsply . $function_dsply . $args_dsply . '</td>
402 402
 					</tr>';
403
-                }
404
-                $trace_details .= '
403
+				}
404
+				$trace_details .= '
405 405
 			 </table>
406 406
 			</div>';
407
-            }
408
-            $ex['code'] = $ex['code'] ? $ex['code'] : $error_code;
409
-            // add generic non-identifying messages for non-privileged users
410
-            if (! WP_DEBUG) {
411
-                $output .= '<span class="ee-error-user-msg-spn">'
412
-                           . trim($ex['msg'])
413
-                           . '</span> &nbsp; <sup>'
414
-                           . $ex['code']
415
-                           . '</sup><br />';
416
-            } else {
417
-                // or helpful developer messages if debugging is on
418
-                $output .= '
407
+			}
408
+			$ex['code'] = $ex['code'] ? $ex['code'] : $error_code;
409
+			// add generic non-identifying messages for non-privileged users
410
+			if (! WP_DEBUG) {
411
+				$output .= '<span class="ee-error-user-msg-spn">'
412
+						   . trim($ex['msg'])
413
+						   . '</span> &nbsp; <sup>'
414
+						   . $ex['code']
415
+						   . '</sup><br />';
416
+			} else {
417
+				// or helpful developer messages if debugging is on
418
+				$output .= '
419 419
 		<div class="ee-error-dev-msg-dv">
420 420
 			<p class="ee-error-dev-msg-pg">
421 421
 				<strong class="ee-error-dev-msg-str">An '
422
-                           . $ex['name']
423
-                           . ' exception was thrown!</strong>  &nbsp; <span>code: '
424
-                           . $ex['code']
425
-                           . '</span><br />
422
+						   . $ex['name']
423
+						   . ' exception was thrown!</strong>  &nbsp; <span>code: '
424
+						   . $ex['code']
425
+						   . '</span><br />
426 426
 				<span class="big-text">"'
427
-                           . trim($ex['msg'])
428
-                           . '"</span><br/>
427
+						   . trim($ex['msg'])
428
+						   . '"</span><br/>
429 429
 				<a id="display-ee-error-trace-'
430
-                           . self::$_error_count
431
-                           . $time
432
-                           . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-'
433
-                           . self::$_error_count
434
-                           . $time
435
-                           . '">
430
+						   . self::$_error_count
431
+						   . $time
432
+						   . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-'
433
+						   . self::$_error_count
434
+						   . $time
435
+						   . '">
436 436
 					'
437
-                           . __('click to view backtrace and class/method details', 'event_espresso')
438
-                           . '
437
+						   . __('click to view backtrace and class/method details', 'event_espresso')
438
+						   . '
439 439
 				</a><br />
440 440
 				<span class="small-text lt-grey-text">'
441
-                           . $ex['file']
442
-                           . ' &nbsp; ( line no: '
443
-                           . $ex['line']
444
-                           . ' )</span>
441
+						   . $ex['file']
442
+						   . ' &nbsp; ( line no: '
443
+						   . $ex['line']
444
+						   . ' )</span>
445 445
 			</p>
446 446
 			<div id="ee-error-trace-'
447
-                           . self::$_error_count
448
-                           . $time
449
-                           . '-dv" class="ee-error-trace-dv" style="display: none;">
447
+						   . self::$_error_count
448
+						   . $time
449
+						   . '-dv" class="ee-error-trace-dv" style="display: none;">
450 450
 				'
451
-                           . $trace_details;
452
-                if (! empty($class)) {
453
-                    $output .= '
451
+						   . $trace_details;
452
+				if (! empty($class)) {
453
+					$output .= '
454 454
 				<div style="padding:3px; margin:0 0 1em; border:1px solid #666; background:#fff; border-radius:3px;">
455 455
 					<div style="padding:1em 2em; border:1px solid #666; background:#f9f9f9;">
456 456
 						<h3>Class Details</h3>';
457
-                    $a = new ReflectionClass($class);
458
-                    $output .= '
457
+					$a = new ReflectionClass($class);
458
+					$output .= '
459 459
 						<pre>' . $a . '</pre>
460 460
 					</div>
461 461
 				</div>';
462
-                }
463
-                $output .= '
462
+				}
463
+				$output .= '
464 464
 			</div>
465 465
 		</div>
466 466
 		<br />';
467
-            }
468
-            $this->write_to_error_log($time, $ex);
469
-        }
470
-        // remove last linebreak
471
-        $output = substr($output, 0, -6);
472
-        if (! WP_DEBUG) {
473
-            $output .= '
467
+			}
468
+			$this->write_to_error_log($time, $ex);
469
+		}
470
+		// remove last linebreak
471
+		$output = substr($output, 0, -6);
472
+		if (! WP_DEBUG) {
473
+			$output .= '
474 474
 	</p>';
475
-        }
476
-        $output .= '
475
+		}
476
+		$output .= '
477 477
 </div>';
478
-        $output .= self::_print_scripts(true);
479
-        if (defined('DOING_AJAX')) {
480
-            echo wp_json_encode(array('error' => $output));
481
-            exit();
482
-        }
483
-        echo $output;
484
-        die();
485
-    }
486
-
487
-
488
-
489
-    /**
490
-     *    generate string from exception trace args
491
-     *
492
-     * @param array $arguments
493
-     * @param bool  $array
494
-     * @return string
495
-     */
496
-    private function _convert_args_to_string($arguments = array(), $array = false)
497
-    {
498
-        $arg_string = '';
499
-        if (! empty($arguments)) {
500
-            $args = array();
501
-            foreach ($arguments as $arg) {
502
-                if (! empty($arg)) {
503
-                    if (is_string($arg)) {
504
-                        $args[] = " '" . $arg . "'";
505
-                    } elseif (is_array($arg)) {
506
-                        $args[] = 'ARRAY(' . $this->_convert_args_to_string($arg, true);
507
-                    } elseif ($arg === null) {
508
-                        $args[] = ' NULL';
509
-                    } elseif (is_bool($arg)) {
510
-                        $args[] = ($arg) ? ' TRUE' : ' FALSE';
511
-                    } elseif (is_object($arg)) {
512
-                        $args[] = ' OBJECT ' . get_class($arg);
513
-                    } elseif (is_resource($arg)) {
514
-                        $args[] = get_resource_type($arg);
515
-                    } else {
516
-                        $args[] = $arg;
517
-                    }
518
-                }
519
-            }
520
-            $arg_string = implode(', ', $args);
521
-        }
522
-        if ($array) {
523
-            $arg_string .= ' )';
524
-        }
525
-        return $arg_string;
526
-    }
527
-
528
-
529
-
530
-    /**
531
-     *    add error message
532
-     *
533
-     * @param        string $msg  the message to display to users or developers - adding a double pipe || (OR) creates
534
-     *                            separate messages for user || dev
535
-     * @param        string $file the file that the error occurred in - just use __FILE__
536
-     * @param        string $func the function/method that the error occurred in - just use __FUNCTION__
537
-     * @param        string $line the line number where the error occurred - just use __LINE__
538
-     * @return        void
539
-     */
540
-    public static function add_error($msg = null, $file = null, $func = null, $line = null)
541
-    {
542
-        self::_add_notice('errors', $msg, $file, $func, $line);
543
-        self::$_error_count++;
544
-    }
545
-
546
-
547
-
548
-    /**
549
-     * If WP_DEBUG is active, throws an exception. If WP_DEBUG is off, just
550
-     * adds an error
551
-     *
552
-     * @param string $msg
553
-     * @param string $file
554
-     * @param string $func
555
-     * @param string $line
556
-     * @throws EE_Error
557
-     */
558
-    public static function throw_exception_if_debugging($msg = null, $file = null, $func = null, $line = null)
559
-    {
560
-        if (WP_DEBUG) {
561
-            throw new EE_Error($msg);
562
-        }
563
-        EE_Error::add_error($msg, $file, $func, $line);
564
-    }
565
-
566
-
567
-
568
-    /**
569
-     *    add success message
570
-     *
571
-     * @param        string $msg  the message to display to users or developers - adding a double pipe || (OR) creates
572
-     *                            separate messages for user || dev
573
-     * @param        string $file the file that the error occurred in - just use __FILE__
574
-     * @param        string $func the function/method that the error occurred in - just use __FUNCTION__
575
-     * @param        string $line the line number where the error occurred - just use __LINE__
576
-     * @return        void
577
-     */
578
-    public static function add_success($msg = null, $file = null, $func = null, $line = null)
579
-    {
580
-        self::_add_notice('success', $msg, $file, $func, $line);
581
-    }
582
-
583
-
584
-
585
-    /**
586
-     *    add attention message
587
-     *
588
-     * @param        string $msg  the message to display to users or developers - adding a double pipe || (OR) creates
589
-     *                            separate messages for user || dev
590
-     * @param        string $file the file that the error occurred in - just use __FILE__
591
-     * @param        string $func the function/method that the error occurred in - just use __FUNCTION__
592
-     * @param        string $line the line number where the error occurred - just use __LINE__
593
-     * @return        void
594
-     */
595
-    public static function add_attention($msg = null, $file = null, $func = null, $line = null)
596
-    {
597
-        self::_add_notice('attention', $msg, $file, $func, $line);
598
-    }
599
-
600
-
601
-
602
-    /**
603
-     * @param string $type whether the message is for a success or error notification
604
-     * @param string $msg the message to display to users or developers
605
-     *                    - adding a double pipe || (OR) creates separate messages for user || dev
606
-     * @param string $file the file that the error occurred in - just use __FILE__
607
-     * @param string $func the function/method that the error occurred in - just use __FUNCTION__
608
-     * @param string $line the line number where the error occurred - just use __LINE__
609
-     * @return void
610
-     */
611
-    private static function _add_notice($type = 'success', $msg = '', $file = '', $func = '', $line = '')
612
-    {
613
-        if (empty($msg)) {
614
-            EE_Error::doing_it_wrong(
615
-                'EE_Error::add_' . $type . '()',
616
-                sprintf(
617
-                    __('Notifications are not much use without a message! Please add a message to the EE_Error::add_%s() call made in %s on line %d',
618
-                        'event_espresso'),
619
-                    $type,
620
-                    $file,
621
-                    $line
622
-                ),
623
-                EVENT_ESPRESSO_VERSION
624
-            );
625
-        }
626
-        if ($type === 'errors' && (empty($file) || empty($func) || empty($line))) {
627
-            EE_Error::doing_it_wrong(
628
-                'EE_Error::add_error()',
629
-                __('You need to provide the file name, function name, and line number that the error occurred on in order to better assist with debugging.',
630
-                    'event_espresso'),
631
-                EVENT_ESPRESSO_VERSION
632
-            );
633
-        }
634
-        // get separate user and developer messages if they exist
635
-        $msg      = explode('||', $msg);
636
-        $user_msg = $msg[0];
637
-        $dev_msg  = isset($msg[1]) ? $msg[1] : $msg[0];
638
-        /**
639
-         * Do an action so other code can be triggered when a notice is created
640
-         *
641
-         * @param string $type     can be 'errors', 'attention', or 'success'
642
-         * @param string $user_msg message displayed to user when WP_DEBUG is off
643
-         * @param string $user_msg message displayed to user when WP_DEBUG is on
644
-         * @param string $file     file where error was generated
645
-         * @param string $func     function where error was generated
646
-         * @param string $line     line where error was generated
647
-         */
648
-        do_action('AHEE__EE_Error___add_notice', $type, $user_msg, $dev_msg, $file, $func, $line);
649
-        $msg = WP_DEBUG ? $dev_msg : $user_msg;
650
-        // add notice if message exists
651
-        if (! empty($msg)) {
652
-            // get error code
653
-            $notice_code = EE_Error::generate_error_code($file, $func, $line);
654
-            if (WP_DEBUG && $type === 'errors') {
655
-                $msg .= '<br/><span class="tiny-text">' . $notice_code . '</span>';
656
-            }
657
-            // add notice. Index by code if it's not blank
658
-            if ($notice_code) {
659
-                self::$_espresso_notices[$type][$notice_code] = $msg;
660
-            } else {
661
-                self::$_espresso_notices[$type][] = $msg;
662
-            }
663
-            add_action('wp_footer', array('EE_Error', 'enqueue_error_scripts'), 1);
664
-        }
665
-    }
666
-
667
-
668
-    /**
669
-     * in some case it may be necessary to overwrite the existing success messages
670
-     *
671
-     * @return        void
672
-     */
673
-    public static function overwrite_success()
674
-    {
675
-        self::$_espresso_notices['success'] = false;
676
-    }
677
-
678
-
679
-
680
-    /**
681
-     * in some case it may be necessary to overwrite the existing attention messages
682
-     *
683
-     * @return void
684
-     */
685
-    public static function overwrite_attention()
686
-    {
687
-        self::$_espresso_notices['attention'] = false;
688
-    }
689
-
690
-
691
-
692
-    /**
693
-     * in some case it may be necessary to overwrite the existing error messages
694
-     *
695
-     * @return void
696
-     */
697
-    public static function overwrite_errors()
698
-    {
699
-        self::$_espresso_notices['errors'] = false;
700
-    }
701
-
702
-
703
-
704
-    /**
705
-     * @return void
706
-     */
707
-    public static function reset_notices()
708
-    {
709
-        self::$_espresso_notices['success']   = false;
710
-        self::$_espresso_notices['attention'] = false;
711
-        self::$_espresso_notices['errors']    = false;
712
-    }
713
-
714
-
715
-
716
-    /**
717
-     * @return int
718
-     */
719
-    public static function has_notices()
720
-    {
721
-        $has_notices = 0;
722
-        // check for success messages
723
-        $has_notices = self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success'])
724
-            ? 3
725
-            : $has_notices;
726
-        // check for attention messages
727
-        $has_notices = self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention'])
728
-            ? 2
729
-            : $has_notices;
730
-        // check for error messages
731
-        $has_notices = self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors'])
732
-            ? 1
733
-            : $has_notices;
734
-        return $has_notices;
735
-    }
736
-
737
-
738
-    /**
739
-     * This simply returns non formatted error notices as they were sent into the EE_Error object.
740
-     *
741
-     * @since 4.9.0
742
-     * @return array
743
-     */
744
-    public static function get_vanilla_notices()
745
-    {
746
-        return array(
747
-            'success'   => isset(self::$_espresso_notices['success'])
748
-                ? self::$_espresso_notices['success']
749
-                : array(),
750
-            'attention' => isset(self::$_espresso_notices['attention'])
751
-                ? self::$_espresso_notices['attention']
752
-                : array(),
753
-            'errors'    => isset(self::$_espresso_notices['errors'])
754
-                ? self::$_espresso_notices['errors']
755
-                : array(),
756
-        );
757
-    }
758
-
759
-
760
-
761
-    /**
762
-     * compile all error or success messages into one string
763
-     *
764
-     * @see EE_Error::get_raw_notices if you want the raw notices without any preparations made to them
765
-     * @param boolean $format_output     whether or not to format the messages for display in the WP admin
766
-     * @param boolean $save_to_transient whether or not to save notices to the db for retrieval on next request
767
-     *                                          - ONLY do this just before redirecting
768
-     * @param boolean $remove_empty      whether or not to unset empty messages
769
-     * @return array
770
-     */
771
-    public static function get_notices($format_output = true, $save_to_transient = false, $remove_empty = true)
772
-    {
773
-        // do_action('AHEE_log', __FILE__, __FUNCTION__, '');
774
-        $success_messages   = '';
775
-        $attention_messages = '';
776
-        $error_messages     = '';
777
-        $print_scripts      = false;
778
-        // EEH_Debug_Tools::printr( self::$_espresso_notices, 'espresso_notices  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
779
-        // either save notices to the db
780
-        if ($save_to_transient || isset($_REQUEST['activate-selected'])) {
781
-            $existing_notices  = get_option(EE_Error::OPTIONS_KEY_NOTICES, array());
782
-            $existing_notices = is_array($existing_notices) ? $existing_notices : array();
783
-            self::$_espresso_notices = array_merge(
784
-                $existing_notices,
785
-                self::$_espresso_notices
786
-            );
787
-            update_option(EE_Error::OPTIONS_KEY_NOTICES, self::$_espresso_notices);
788
-            return array();
789
-        }
790
-        // grab any notices that have been previously saved
791
-        if ($notices = get_option(EE_Error::OPTIONS_KEY_NOTICES, array())) {
792
-            foreach ($notices as $type => $notice) {
793
-                if (is_array($notice) && ! empty($notice)) {
794
-                    // make sure that existing notice type is an array
795
-                    self::$_espresso_notices[$type] = is_array(self::$_espresso_notices[$type])
796
-                                                      && ! empty(self::$_espresso_notices[$type])
797
-                        ? self::$_espresso_notices[$type]
798
-                        : array();
799
-                    // merge stored notices with any newly created ones
800
-                    self::$_espresso_notices[$type] = array_merge(self::$_espresso_notices[$type], $notice);
801
-                    $print_scripts                  = true;
802
-                }
803
-            }
804
-            // now clear any stored notices
805
-            update_option(EE_Error::OPTIONS_KEY_NOTICES, array());
806
-        }
807
-        // check for success messages
808
-        if (self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success'])) {
809
-            // combine messages
810
-            $success_messages .= implode(self::$_espresso_notices['success'], '<br />');
811
-            $print_scripts    = true;
812
-        }
813
-        // check for attention messages
814
-        if (self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention'])) {
815
-            // combine messages
816
-            $attention_messages .= implode(self::$_espresso_notices['attention'], '<br />');
817
-            $print_scripts      = true;
818
-        }
819
-        // check for error messages
820
-        if (self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors'])) {
821
-            $error_messages .= count(self::$_espresso_notices['errors']) > 1
822
-                ? __('The following errors have occurred:<br />', 'event_espresso')
823
-                : __('An error has occurred:<br />', 'event_espresso');
824
-            // combine messages
825
-            $error_messages .= implode(self::$_espresso_notices['errors'], '<br />');
826
-            $print_scripts  = true;
827
-        }
828
-        if ($format_output) {
829
-
830
-            $notices = '<div id="espresso-notices">';
831
-            $close = is_admin() ? ''
832
-                : '<a class="close-espresso-notice hide-if-no-js"><span class="dashicons dashicons-no"></span></a>';
833
-            if ($success_messages !== '') {
834
-                $css_id    = is_admin() ? 'message' : 'espresso-notices-success';
835
-                $css_class = is_admin() ? 'updated fade' : 'success fade-away';
836
-                //showMessage( $success_messages );
837
-                $notices .= '<div id="'
838
-                            . $css_id
839
-                            . '" class="espresso-notices '
840
-                            . $css_class
841
-                            . '" style="display:none;"><p>'
842
-                            . $success_messages
843
-                            . '</p>'
844
-                            . $close
845
-                            . '</div>';
846
-            }
847
-            if ($attention_messages !== '') {
848
-                $css_id    = is_admin() ? 'message' : 'espresso-notices-attention';
849
-                $css_class = is_admin() ? 'updated ee-notices-attention' : 'attention fade-away';
850
-                //showMessage( $error_messages, TRUE );
851
-                $notices .= '<div id="'
852
-                            . $css_id
853
-                            . '" class="espresso-notices '
854
-                            . $css_class
855
-                            . '" style="display:none;"><p>'
856
-                            . $attention_messages
857
-                            . '</p>'
858
-                            . $close
859
-                            . '</div>';
860
-            }
861
-            if ($error_messages !== '') {
862
-                $css_id    = is_admin() ? 'message' : 'espresso-notices-error';
863
-                $css_class = is_admin() ? 'error' : 'error fade-away';
864
-                //showMessage( $error_messages, TRUE );
865
-                $notices .= '<div id="'
866
-                            . $css_id
867
-                            . '" class="espresso-notices '
868
-                            . $css_class
869
-                            . '" style="display:none;"><p>'
870
-                            . $error_messages
871
-                            . '</p>'
872
-                            . $close
873
-                            . '</div>';
874
-            }
875
-            $notices .= '</div>';
876
-        } else {
877
-
878
-            $notices = array(
879
-                'success'   => $success_messages,
880
-                'attention' => $attention_messages,
881
-                'errors'    => $error_messages,
882
-            );
883
-            if ($remove_empty) {
884
-                // remove empty notices
885
-                foreach ($notices as $type => $notice) {
886
-                    if (empty($notice)) {
887
-                        unset($notices[$type]);
888
-                    }
889
-                }
890
-            }
891
-        }
892
-        if ($print_scripts) {
893
-            self::_print_scripts();
894
-        }
895
-        return $notices;
896
-    }
897
-
898
-
899
-
900
-    /**
901
-     * _print_scripts
902
-     *
903
-     * @param    bool $force_print
904
-     * @return    string
905
-     */
906
-    private static function _print_scripts($force_print = false)
907
-    {
908
-        if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) {
909
-            if (wp_script_is('ee_error_js', 'enqueued')) {
910
-                return '';
911
-            }
912
-            if (wp_script_is('ee_error_js', 'registered')) {
913
-                wp_enqueue_style('espresso_default');
914
-                wp_enqueue_style('espresso_custom_css');
915
-                wp_enqueue_script('ee_error_js');
916
-                wp_localize_script('ee_error_js', 'ee_settings', array('wp_debug' => WP_DEBUG));
917
-            }
918
-        } else {
919
-            return '
478
+		$output .= self::_print_scripts(true);
479
+		if (defined('DOING_AJAX')) {
480
+			echo wp_json_encode(array('error' => $output));
481
+			exit();
482
+		}
483
+		echo $output;
484
+		die();
485
+	}
486
+
487
+
488
+
489
+	/**
490
+	 *    generate string from exception trace args
491
+	 *
492
+	 * @param array $arguments
493
+	 * @param bool  $array
494
+	 * @return string
495
+	 */
496
+	private function _convert_args_to_string($arguments = array(), $array = false)
497
+	{
498
+		$arg_string = '';
499
+		if (! empty($arguments)) {
500
+			$args = array();
501
+			foreach ($arguments as $arg) {
502
+				if (! empty($arg)) {
503
+					if (is_string($arg)) {
504
+						$args[] = " '" . $arg . "'";
505
+					} elseif (is_array($arg)) {
506
+						$args[] = 'ARRAY(' . $this->_convert_args_to_string($arg, true);
507
+					} elseif ($arg === null) {
508
+						$args[] = ' NULL';
509
+					} elseif (is_bool($arg)) {
510
+						$args[] = ($arg) ? ' TRUE' : ' FALSE';
511
+					} elseif (is_object($arg)) {
512
+						$args[] = ' OBJECT ' . get_class($arg);
513
+					} elseif (is_resource($arg)) {
514
+						$args[] = get_resource_type($arg);
515
+					} else {
516
+						$args[] = $arg;
517
+					}
518
+				}
519
+			}
520
+			$arg_string = implode(', ', $args);
521
+		}
522
+		if ($array) {
523
+			$arg_string .= ' )';
524
+		}
525
+		return $arg_string;
526
+	}
527
+
528
+
529
+
530
+	/**
531
+	 *    add error message
532
+	 *
533
+	 * @param        string $msg  the message to display to users or developers - adding a double pipe || (OR) creates
534
+	 *                            separate messages for user || dev
535
+	 * @param        string $file the file that the error occurred in - just use __FILE__
536
+	 * @param        string $func the function/method that the error occurred in - just use __FUNCTION__
537
+	 * @param        string $line the line number where the error occurred - just use __LINE__
538
+	 * @return        void
539
+	 */
540
+	public static function add_error($msg = null, $file = null, $func = null, $line = null)
541
+	{
542
+		self::_add_notice('errors', $msg, $file, $func, $line);
543
+		self::$_error_count++;
544
+	}
545
+
546
+
547
+
548
+	/**
549
+	 * If WP_DEBUG is active, throws an exception. If WP_DEBUG is off, just
550
+	 * adds an error
551
+	 *
552
+	 * @param string $msg
553
+	 * @param string $file
554
+	 * @param string $func
555
+	 * @param string $line
556
+	 * @throws EE_Error
557
+	 */
558
+	public static function throw_exception_if_debugging($msg = null, $file = null, $func = null, $line = null)
559
+	{
560
+		if (WP_DEBUG) {
561
+			throw new EE_Error($msg);
562
+		}
563
+		EE_Error::add_error($msg, $file, $func, $line);
564
+	}
565
+
566
+
567
+
568
+	/**
569
+	 *    add success message
570
+	 *
571
+	 * @param        string $msg  the message to display to users or developers - adding a double pipe || (OR) creates
572
+	 *                            separate messages for user || dev
573
+	 * @param        string $file the file that the error occurred in - just use __FILE__
574
+	 * @param        string $func the function/method that the error occurred in - just use __FUNCTION__
575
+	 * @param        string $line the line number where the error occurred - just use __LINE__
576
+	 * @return        void
577
+	 */
578
+	public static function add_success($msg = null, $file = null, $func = null, $line = null)
579
+	{
580
+		self::_add_notice('success', $msg, $file, $func, $line);
581
+	}
582
+
583
+
584
+
585
+	/**
586
+	 *    add attention message
587
+	 *
588
+	 * @param        string $msg  the message to display to users or developers - adding a double pipe || (OR) creates
589
+	 *                            separate messages for user || dev
590
+	 * @param        string $file the file that the error occurred in - just use __FILE__
591
+	 * @param        string $func the function/method that the error occurred in - just use __FUNCTION__
592
+	 * @param        string $line the line number where the error occurred - just use __LINE__
593
+	 * @return        void
594
+	 */
595
+	public static function add_attention($msg = null, $file = null, $func = null, $line = null)
596
+	{
597
+		self::_add_notice('attention', $msg, $file, $func, $line);
598
+	}
599
+
600
+
601
+
602
+	/**
603
+	 * @param string $type whether the message is for a success or error notification
604
+	 * @param string $msg the message to display to users or developers
605
+	 *                    - adding a double pipe || (OR) creates separate messages for user || dev
606
+	 * @param string $file the file that the error occurred in - just use __FILE__
607
+	 * @param string $func the function/method that the error occurred in - just use __FUNCTION__
608
+	 * @param string $line the line number where the error occurred - just use __LINE__
609
+	 * @return void
610
+	 */
611
+	private static function _add_notice($type = 'success', $msg = '', $file = '', $func = '', $line = '')
612
+	{
613
+		if (empty($msg)) {
614
+			EE_Error::doing_it_wrong(
615
+				'EE_Error::add_' . $type . '()',
616
+				sprintf(
617
+					__('Notifications are not much use without a message! Please add a message to the EE_Error::add_%s() call made in %s on line %d',
618
+						'event_espresso'),
619
+					$type,
620
+					$file,
621
+					$line
622
+				),
623
+				EVENT_ESPRESSO_VERSION
624
+			);
625
+		}
626
+		if ($type === 'errors' && (empty($file) || empty($func) || empty($line))) {
627
+			EE_Error::doing_it_wrong(
628
+				'EE_Error::add_error()',
629
+				__('You need to provide the file name, function name, and line number that the error occurred on in order to better assist with debugging.',
630
+					'event_espresso'),
631
+				EVENT_ESPRESSO_VERSION
632
+			);
633
+		}
634
+		// get separate user and developer messages if they exist
635
+		$msg      = explode('||', $msg);
636
+		$user_msg = $msg[0];
637
+		$dev_msg  = isset($msg[1]) ? $msg[1] : $msg[0];
638
+		/**
639
+		 * Do an action so other code can be triggered when a notice is created
640
+		 *
641
+		 * @param string $type     can be 'errors', 'attention', or 'success'
642
+		 * @param string $user_msg message displayed to user when WP_DEBUG is off
643
+		 * @param string $user_msg message displayed to user when WP_DEBUG is on
644
+		 * @param string $file     file where error was generated
645
+		 * @param string $func     function where error was generated
646
+		 * @param string $line     line where error was generated
647
+		 */
648
+		do_action('AHEE__EE_Error___add_notice', $type, $user_msg, $dev_msg, $file, $func, $line);
649
+		$msg = WP_DEBUG ? $dev_msg : $user_msg;
650
+		// add notice if message exists
651
+		if (! empty($msg)) {
652
+			// get error code
653
+			$notice_code = EE_Error::generate_error_code($file, $func, $line);
654
+			if (WP_DEBUG && $type === 'errors') {
655
+				$msg .= '<br/><span class="tiny-text">' . $notice_code . '</span>';
656
+			}
657
+			// add notice. Index by code if it's not blank
658
+			if ($notice_code) {
659
+				self::$_espresso_notices[$type][$notice_code] = $msg;
660
+			} else {
661
+				self::$_espresso_notices[$type][] = $msg;
662
+			}
663
+			add_action('wp_footer', array('EE_Error', 'enqueue_error_scripts'), 1);
664
+		}
665
+	}
666
+
667
+
668
+	/**
669
+	 * in some case it may be necessary to overwrite the existing success messages
670
+	 *
671
+	 * @return        void
672
+	 */
673
+	public static function overwrite_success()
674
+	{
675
+		self::$_espresso_notices['success'] = false;
676
+	}
677
+
678
+
679
+
680
+	/**
681
+	 * in some case it may be necessary to overwrite the existing attention messages
682
+	 *
683
+	 * @return void
684
+	 */
685
+	public static function overwrite_attention()
686
+	{
687
+		self::$_espresso_notices['attention'] = false;
688
+	}
689
+
690
+
691
+
692
+	/**
693
+	 * in some case it may be necessary to overwrite the existing error messages
694
+	 *
695
+	 * @return void
696
+	 */
697
+	public static function overwrite_errors()
698
+	{
699
+		self::$_espresso_notices['errors'] = false;
700
+	}
701
+
702
+
703
+
704
+	/**
705
+	 * @return void
706
+	 */
707
+	public static function reset_notices()
708
+	{
709
+		self::$_espresso_notices['success']   = false;
710
+		self::$_espresso_notices['attention'] = false;
711
+		self::$_espresso_notices['errors']    = false;
712
+	}
713
+
714
+
715
+
716
+	/**
717
+	 * @return int
718
+	 */
719
+	public static function has_notices()
720
+	{
721
+		$has_notices = 0;
722
+		// check for success messages
723
+		$has_notices = self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success'])
724
+			? 3
725
+			: $has_notices;
726
+		// check for attention messages
727
+		$has_notices = self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention'])
728
+			? 2
729
+			: $has_notices;
730
+		// check for error messages
731
+		$has_notices = self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors'])
732
+			? 1
733
+			: $has_notices;
734
+		return $has_notices;
735
+	}
736
+
737
+
738
+	/**
739
+	 * This simply returns non formatted error notices as they were sent into the EE_Error object.
740
+	 *
741
+	 * @since 4.9.0
742
+	 * @return array
743
+	 */
744
+	public static function get_vanilla_notices()
745
+	{
746
+		return array(
747
+			'success'   => isset(self::$_espresso_notices['success'])
748
+				? self::$_espresso_notices['success']
749
+				: array(),
750
+			'attention' => isset(self::$_espresso_notices['attention'])
751
+				? self::$_espresso_notices['attention']
752
+				: array(),
753
+			'errors'    => isset(self::$_espresso_notices['errors'])
754
+				? self::$_espresso_notices['errors']
755
+				: array(),
756
+		);
757
+	}
758
+
759
+
760
+
761
+	/**
762
+	 * compile all error or success messages into one string
763
+	 *
764
+	 * @see EE_Error::get_raw_notices if you want the raw notices without any preparations made to them
765
+	 * @param boolean $format_output     whether or not to format the messages for display in the WP admin
766
+	 * @param boolean $save_to_transient whether or not to save notices to the db for retrieval on next request
767
+	 *                                          - ONLY do this just before redirecting
768
+	 * @param boolean $remove_empty      whether or not to unset empty messages
769
+	 * @return array
770
+	 */
771
+	public static function get_notices($format_output = true, $save_to_transient = false, $remove_empty = true)
772
+	{
773
+		// do_action('AHEE_log', __FILE__, __FUNCTION__, '');
774
+		$success_messages   = '';
775
+		$attention_messages = '';
776
+		$error_messages     = '';
777
+		$print_scripts      = false;
778
+		// EEH_Debug_Tools::printr( self::$_espresso_notices, 'espresso_notices  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
779
+		// either save notices to the db
780
+		if ($save_to_transient || isset($_REQUEST['activate-selected'])) {
781
+			$existing_notices  = get_option(EE_Error::OPTIONS_KEY_NOTICES, array());
782
+			$existing_notices = is_array($existing_notices) ? $existing_notices : array();
783
+			self::$_espresso_notices = array_merge(
784
+				$existing_notices,
785
+				self::$_espresso_notices
786
+			);
787
+			update_option(EE_Error::OPTIONS_KEY_NOTICES, self::$_espresso_notices);
788
+			return array();
789
+		}
790
+		// grab any notices that have been previously saved
791
+		if ($notices = get_option(EE_Error::OPTIONS_KEY_NOTICES, array())) {
792
+			foreach ($notices as $type => $notice) {
793
+				if (is_array($notice) && ! empty($notice)) {
794
+					// make sure that existing notice type is an array
795
+					self::$_espresso_notices[$type] = is_array(self::$_espresso_notices[$type])
796
+													  && ! empty(self::$_espresso_notices[$type])
797
+						? self::$_espresso_notices[$type]
798
+						: array();
799
+					// merge stored notices with any newly created ones
800
+					self::$_espresso_notices[$type] = array_merge(self::$_espresso_notices[$type], $notice);
801
+					$print_scripts                  = true;
802
+				}
803
+			}
804
+			// now clear any stored notices
805
+			update_option(EE_Error::OPTIONS_KEY_NOTICES, array());
806
+		}
807
+		// check for success messages
808
+		if (self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success'])) {
809
+			// combine messages
810
+			$success_messages .= implode(self::$_espresso_notices['success'], '<br />');
811
+			$print_scripts    = true;
812
+		}
813
+		// check for attention messages
814
+		if (self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention'])) {
815
+			// combine messages
816
+			$attention_messages .= implode(self::$_espresso_notices['attention'], '<br />');
817
+			$print_scripts      = true;
818
+		}
819
+		// check for error messages
820
+		if (self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors'])) {
821
+			$error_messages .= count(self::$_espresso_notices['errors']) > 1
822
+				? __('The following errors have occurred:<br />', 'event_espresso')
823
+				: __('An error has occurred:<br />', 'event_espresso');
824
+			// combine messages
825
+			$error_messages .= implode(self::$_espresso_notices['errors'], '<br />');
826
+			$print_scripts  = true;
827
+		}
828
+		if ($format_output) {
829
+
830
+			$notices = '<div id="espresso-notices">';
831
+			$close = is_admin() ? ''
832
+				: '<a class="close-espresso-notice hide-if-no-js"><span class="dashicons dashicons-no"></span></a>';
833
+			if ($success_messages !== '') {
834
+				$css_id    = is_admin() ? 'message' : 'espresso-notices-success';
835
+				$css_class = is_admin() ? 'updated fade' : 'success fade-away';
836
+				//showMessage( $success_messages );
837
+				$notices .= '<div id="'
838
+							. $css_id
839
+							. '" class="espresso-notices '
840
+							. $css_class
841
+							. '" style="display:none;"><p>'
842
+							. $success_messages
843
+							. '</p>'
844
+							. $close
845
+							. '</div>';
846
+			}
847
+			if ($attention_messages !== '') {
848
+				$css_id    = is_admin() ? 'message' : 'espresso-notices-attention';
849
+				$css_class = is_admin() ? 'updated ee-notices-attention' : 'attention fade-away';
850
+				//showMessage( $error_messages, TRUE );
851
+				$notices .= '<div id="'
852
+							. $css_id
853
+							. '" class="espresso-notices '
854
+							. $css_class
855
+							. '" style="display:none;"><p>'
856
+							. $attention_messages
857
+							. '</p>'
858
+							. $close
859
+							. '</div>';
860
+			}
861
+			if ($error_messages !== '') {
862
+				$css_id    = is_admin() ? 'message' : 'espresso-notices-error';
863
+				$css_class = is_admin() ? 'error' : 'error fade-away';
864
+				//showMessage( $error_messages, TRUE );
865
+				$notices .= '<div id="'
866
+							. $css_id
867
+							. '" class="espresso-notices '
868
+							. $css_class
869
+							. '" style="display:none;"><p>'
870
+							. $error_messages
871
+							. '</p>'
872
+							. $close
873
+							. '</div>';
874
+			}
875
+			$notices .= '</div>';
876
+		} else {
877
+
878
+			$notices = array(
879
+				'success'   => $success_messages,
880
+				'attention' => $attention_messages,
881
+				'errors'    => $error_messages,
882
+			);
883
+			if ($remove_empty) {
884
+				// remove empty notices
885
+				foreach ($notices as $type => $notice) {
886
+					if (empty($notice)) {
887
+						unset($notices[$type]);
888
+					}
889
+				}
890
+			}
891
+		}
892
+		if ($print_scripts) {
893
+			self::_print_scripts();
894
+		}
895
+		return $notices;
896
+	}
897
+
898
+
899
+
900
+	/**
901
+	 * _print_scripts
902
+	 *
903
+	 * @param    bool $force_print
904
+	 * @return    string
905
+	 */
906
+	private static function _print_scripts($force_print = false)
907
+	{
908
+		if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) {
909
+			if (wp_script_is('ee_error_js', 'enqueued')) {
910
+				return '';
911
+			}
912
+			if (wp_script_is('ee_error_js', 'registered')) {
913
+				wp_enqueue_style('espresso_default');
914
+				wp_enqueue_style('espresso_custom_css');
915
+				wp_enqueue_script('ee_error_js');
916
+				wp_localize_script('ee_error_js', 'ee_settings', array('wp_debug' => WP_DEBUG));
917
+			}
918
+		} else {
919
+			return '
920 920
 <script>
921 921
 /* <![CDATA[ */
922 922
 var ee_settings = {"wp_debug":"' . WP_DEBUG . '"};
@@ -926,223 +926,223 @@  discard block
 block discarded – undo
926 926
 <script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script>
927 927
 <script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script>
928 928
 ';
929
-        }
930
-        return '';
931
-    }
932
-
933
-
934
-
935
-    /**
936
-     * @return void
937
-     */
938
-    public static function enqueue_error_scripts()
939
-    {
940
-        self::_print_scripts();
941
-    }
942
-
943
-
944
-
945
-    /**
946
-     * create error code from filepath, function name,
947
-     * and line number where exception or error was thrown
948
-     *
949
-     * @param string $file
950
-     * @param string $func
951
-     * @param string $line
952
-     * @return string
953
-     */
954
-    public static function generate_error_code($file = '', $func = '', $line = '')
955
-    {
956
-        $file       = explode('.', basename($file));
957
-        $error_code = ! empty($file[0]) ? $file[0] : '';
958
-        $error_code .= ! empty($func) ? ' - ' . $func : '';
959
-        $error_code .= ! empty($line) ? ' - ' . $line : '';
960
-        return $error_code;
961
-    }
962
-
963
-
964
-
965
-    /**
966
-     * write exception details to log file
967
-     * Since 4.9.53.rc.006 this writes to the standard PHP log file, not EE's custom log file
968
-     *
969
-     * @param int   $time
970
-     * @param array $ex
971
-     * @param bool  $clear
972
-     * @return void
973
-     */
974
-    public function write_to_error_log($time = 0, $ex = array(), $clear = false)
975
-    {
976
-        if (empty($ex)) {
977
-            return;
978
-        }
979
-        if (! $time) {
980
-            $time = time();
981
-        }
982
-        $exception_log = '----------------------------------------------------------------------------------------'
983
-                         . PHP_EOL;
984
-        $exception_log .= '[' . date('Y-m-d H:i:s', $time) . ']  Exception Details' . PHP_EOL;
985
-        $exception_log .= 'Message: ' . $ex['msg'] . PHP_EOL;
986
-        $exception_log .= 'Code: ' . $ex['code'] . PHP_EOL;
987
-        $exception_log .= 'File: ' . $ex['file'] . PHP_EOL;
988
-        $exception_log .= 'Line No: ' . $ex['line'] . PHP_EOL;
989
-        $exception_log .= 'Stack trace: ' . PHP_EOL;
990
-        $exception_log .= $ex['string'] . PHP_EOL;
991
-        $exception_log .= '----------------------------------------------------------------------------------------'
992
-                          . PHP_EOL;
993
-        try {
994
-            error_log($exception_log);
995
-        } catch (EE_Error $e) {
996
-            EE_Error::add_error(sprintf(__('Event Espresso error logging could not be setup because: %s',
997
-                'event_espresso'), $e->getMessage()));
998
-        }
999
-    }
1000
-
1001
-
1002
-
1003
-    /**
1004
-     * This is just a wrapper for the EEH_Debug_Tools::instance()->doing_it_wrong() method.
1005
-     * doing_it_wrong() is used in those cases where a normal PHP error won't get thrown,
1006
-     * but the code execution is done in a manner that could lead to unexpected results
1007
-     * (i.e. running to early, or too late in WP or EE loading process).
1008
-     * A good test for knowing whether to use this method is:
1009
-     * 1. Is there going to be a PHP error if something isn't setup/used correctly?
1010
-     * Yes -> use EE_Error::add_error() or throw new EE_Error()
1011
-     * 2. If this is loaded before something else, it won't break anything,
1012
-     * but just wont' do what its supposed to do? Yes -> use EE_Error::doing_it_wrong()
1013
-     *
1014
-     * @uses   constant WP_DEBUG test if wp_debug is on or not
1015
-     * @param string $function      The function that was called
1016
-     * @param string $message       A message explaining what has been done incorrectly
1017
-     * @param string $version       The version of Event Espresso where the error was added
1018
-     * @param string $applies_when  a version string for when you want the doing_it_wrong notice to begin appearing
1019
-     *                              for a deprecated function. This allows deprecation to occur during one version,
1020
-     *                              but not have any notices appear until a later version. This allows developers
1021
-     *                              extra time to update their code before notices appear.
1022
-     * @param int    $error_type
1023
-     */
1024
-    public static function doing_it_wrong(
1025
-        $function,
1026
-        $message,
1027
-        $version,
1028
-        $applies_when = '',
1029
-        $error_type = null
1030
-    ) {
1031
-        if (defined('WP_DEBUG') && WP_DEBUG) {
1032
-            EEH_Debug_Tools::instance()->doing_it_wrong($function, $message, $version, $applies_when, $error_type);
1033
-        }
1034
-    }
1035
-
1036
-
1037
-
1038
-    /**
1039
-     * Like get_notices, but returns an array of all the notices of the given type.
1040
-     *
1041
-     * @return array {
1042
-     *  @type array $success   all the success messages
1043
-     *  @type array $errors    all the error messages
1044
-     *  @type array $attention all the attention messages
1045
-     * }
1046
-     */
1047
-    public static function get_raw_notices()
1048
-    {
1049
-        return self::$_espresso_notices;
1050
-    }
1051
-
1052
-
1053
-
1054
-    /**
1055
-     * @deprecated 4.9.27
1056
-     * @param string $pan_name     the name, or key of the Persistent Admin Notice to be stored
1057
-     * @param string $pan_message  the message to be stored persistently until dismissed
1058
-     * @param bool   $force_update allows one to enforce the reappearance of a persistent message.
1059
-     * @return void
1060
-     * @throws InvalidDataTypeException
1061
-     */
1062
-    public static function add_persistent_admin_notice($pan_name = '', $pan_message, $force_update = false)
1063
-    {
1064
-        new PersistentAdminNotice(
1065
-            $pan_name,
1066
-            $pan_message,
1067
-            $force_update
1068
-        );
1069
-        EE_Error::doing_it_wrong(
1070
-            __METHOD__,
1071
-            sprintf(
1072
-                __('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
1073
-                '\EventEspresso\core\domain\entities\notifications\PersistentAdminNotice'
1074
-            ),
1075
-            '4.9.27'
1076
-        );
1077
-    }
1078
-
1079
-
1080
-
1081
-    /**
1082
-     * @deprecated 4.9.27
1083
-     * @param string $pan_name the name, or key of the Persistent Admin Notice to be dismissed
1084
-     * @param bool   $purge
1085
-     * @param bool   $return
1086
-     * @throws DomainException
1087
-     * @throws InvalidInterfaceException
1088
-     * @throws InvalidDataTypeException
1089
-     * @throws ServiceNotFoundException
1090
-     * @throws InvalidArgumentException
1091
-     */
1092
-    public static function dismiss_persistent_admin_notice($pan_name = '', $purge = false, $return = false)
1093
-    {
1094
-        /** @var PersistentAdminNoticeManager $persistent_admin_notice_manager */
1095
-        $persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared(
1096
-            'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
1097
-        );
1098
-        $persistent_admin_notice_manager->dismissNotice($pan_name, $purge, $return);
1099
-        EE_Error::doing_it_wrong(
1100
-            __METHOD__,
1101
-            sprintf(
1102
-                __('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
1103
-                '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
1104
-            ),
1105
-            '4.9.27'
1106
-        );
1107
-    }
1108
-
1109
-
1110
-
1111
-    /**
1112
-     * @deprecated 4.9.27
1113
-     * @param  string $pan_name    the name, or key of the Persistent Admin Notice to be stored
1114
-     * @param  string $pan_message the message to be stored persistently until dismissed
1115
-     * @param  string $return_url  URL to go back to after nag notice is dismissed
1116
-     */
1117
-    public static function display_persistent_admin_notices($pan_name = '', $pan_message = '', $return_url = '')
1118
-    {
1119
-        EE_Error::doing_it_wrong(
1120
-            __METHOD__,
1121
-            sprintf(
1122
-                __('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
1123
-                '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
1124
-            ),
1125
-            '4.9.27'
1126
-        );
1127
-    }
1128
-
1129
-
1130
-
1131
-    /**
1132
-     * @deprecated 4.9.27
1133
-     * @param string $return_url
1134
-     */
1135
-    public static function get_persistent_admin_notices($return_url = '')
1136
-    {
1137
-        EE_Error::doing_it_wrong(
1138
-            __METHOD__,
1139
-            sprintf(
1140
-                __('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
1141
-                '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
1142
-            ),
1143
-            '4.9.27'
1144
-        );
1145
-    }
929
+		}
930
+		return '';
931
+	}
932
+
933
+
934
+
935
+	/**
936
+	 * @return void
937
+	 */
938
+	public static function enqueue_error_scripts()
939
+	{
940
+		self::_print_scripts();
941
+	}
942
+
943
+
944
+
945
+	/**
946
+	 * create error code from filepath, function name,
947
+	 * and line number where exception or error was thrown
948
+	 *
949
+	 * @param string $file
950
+	 * @param string $func
951
+	 * @param string $line
952
+	 * @return string
953
+	 */
954
+	public static function generate_error_code($file = '', $func = '', $line = '')
955
+	{
956
+		$file       = explode('.', basename($file));
957
+		$error_code = ! empty($file[0]) ? $file[0] : '';
958
+		$error_code .= ! empty($func) ? ' - ' . $func : '';
959
+		$error_code .= ! empty($line) ? ' - ' . $line : '';
960
+		return $error_code;
961
+	}
962
+
963
+
964
+
965
+	/**
966
+	 * write exception details to log file
967
+	 * Since 4.9.53.rc.006 this writes to the standard PHP log file, not EE's custom log file
968
+	 *
969
+	 * @param int   $time
970
+	 * @param array $ex
971
+	 * @param bool  $clear
972
+	 * @return void
973
+	 */
974
+	public function write_to_error_log($time = 0, $ex = array(), $clear = false)
975
+	{
976
+		if (empty($ex)) {
977
+			return;
978
+		}
979
+		if (! $time) {
980
+			$time = time();
981
+		}
982
+		$exception_log = '----------------------------------------------------------------------------------------'
983
+						 . PHP_EOL;
984
+		$exception_log .= '[' . date('Y-m-d H:i:s', $time) . ']  Exception Details' . PHP_EOL;
985
+		$exception_log .= 'Message: ' . $ex['msg'] . PHP_EOL;
986
+		$exception_log .= 'Code: ' . $ex['code'] . PHP_EOL;
987
+		$exception_log .= 'File: ' . $ex['file'] . PHP_EOL;
988
+		$exception_log .= 'Line No: ' . $ex['line'] . PHP_EOL;
989
+		$exception_log .= 'Stack trace: ' . PHP_EOL;
990
+		$exception_log .= $ex['string'] . PHP_EOL;
991
+		$exception_log .= '----------------------------------------------------------------------------------------'
992
+						  . PHP_EOL;
993
+		try {
994
+			error_log($exception_log);
995
+		} catch (EE_Error $e) {
996
+			EE_Error::add_error(sprintf(__('Event Espresso error logging could not be setup because: %s',
997
+				'event_espresso'), $e->getMessage()));
998
+		}
999
+	}
1000
+
1001
+
1002
+
1003
+	/**
1004
+	 * This is just a wrapper for the EEH_Debug_Tools::instance()->doing_it_wrong() method.
1005
+	 * doing_it_wrong() is used in those cases where a normal PHP error won't get thrown,
1006
+	 * but the code execution is done in a manner that could lead to unexpected results
1007
+	 * (i.e. running to early, or too late in WP or EE loading process).
1008
+	 * A good test for knowing whether to use this method is:
1009
+	 * 1. Is there going to be a PHP error if something isn't setup/used correctly?
1010
+	 * Yes -> use EE_Error::add_error() or throw new EE_Error()
1011
+	 * 2. If this is loaded before something else, it won't break anything,
1012
+	 * but just wont' do what its supposed to do? Yes -> use EE_Error::doing_it_wrong()
1013
+	 *
1014
+	 * @uses   constant WP_DEBUG test if wp_debug is on or not
1015
+	 * @param string $function      The function that was called
1016
+	 * @param string $message       A message explaining what has been done incorrectly
1017
+	 * @param string $version       The version of Event Espresso where the error was added
1018
+	 * @param string $applies_when  a version string for when you want the doing_it_wrong notice to begin appearing
1019
+	 *                              for a deprecated function. This allows deprecation to occur during one version,
1020
+	 *                              but not have any notices appear until a later version. This allows developers
1021
+	 *                              extra time to update their code before notices appear.
1022
+	 * @param int    $error_type
1023
+	 */
1024
+	public static function doing_it_wrong(
1025
+		$function,
1026
+		$message,
1027
+		$version,
1028
+		$applies_when = '',
1029
+		$error_type = null
1030
+	) {
1031
+		if (defined('WP_DEBUG') && WP_DEBUG) {
1032
+			EEH_Debug_Tools::instance()->doing_it_wrong($function, $message, $version, $applies_when, $error_type);
1033
+		}
1034
+	}
1035
+
1036
+
1037
+
1038
+	/**
1039
+	 * Like get_notices, but returns an array of all the notices of the given type.
1040
+	 *
1041
+	 * @return array {
1042
+	 *  @type array $success   all the success messages
1043
+	 *  @type array $errors    all the error messages
1044
+	 *  @type array $attention all the attention messages
1045
+	 * }
1046
+	 */
1047
+	public static function get_raw_notices()
1048
+	{
1049
+		return self::$_espresso_notices;
1050
+	}
1051
+
1052
+
1053
+
1054
+	/**
1055
+	 * @deprecated 4.9.27
1056
+	 * @param string $pan_name     the name, or key of the Persistent Admin Notice to be stored
1057
+	 * @param string $pan_message  the message to be stored persistently until dismissed
1058
+	 * @param bool   $force_update allows one to enforce the reappearance of a persistent message.
1059
+	 * @return void
1060
+	 * @throws InvalidDataTypeException
1061
+	 */
1062
+	public static function add_persistent_admin_notice($pan_name = '', $pan_message, $force_update = false)
1063
+	{
1064
+		new PersistentAdminNotice(
1065
+			$pan_name,
1066
+			$pan_message,
1067
+			$force_update
1068
+		);
1069
+		EE_Error::doing_it_wrong(
1070
+			__METHOD__,
1071
+			sprintf(
1072
+				__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
1073
+				'\EventEspresso\core\domain\entities\notifications\PersistentAdminNotice'
1074
+			),
1075
+			'4.9.27'
1076
+		);
1077
+	}
1078
+
1079
+
1080
+
1081
+	/**
1082
+	 * @deprecated 4.9.27
1083
+	 * @param string $pan_name the name, or key of the Persistent Admin Notice to be dismissed
1084
+	 * @param bool   $purge
1085
+	 * @param bool   $return
1086
+	 * @throws DomainException
1087
+	 * @throws InvalidInterfaceException
1088
+	 * @throws InvalidDataTypeException
1089
+	 * @throws ServiceNotFoundException
1090
+	 * @throws InvalidArgumentException
1091
+	 */
1092
+	public static function dismiss_persistent_admin_notice($pan_name = '', $purge = false, $return = false)
1093
+	{
1094
+		/** @var PersistentAdminNoticeManager $persistent_admin_notice_manager */
1095
+		$persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared(
1096
+			'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
1097
+		);
1098
+		$persistent_admin_notice_manager->dismissNotice($pan_name, $purge, $return);
1099
+		EE_Error::doing_it_wrong(
1100
+			__METHOD__,
1101
+			sprintf(
1102
+				__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
1103
+				'\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
1104
+			),
1105
+			'4.9.27'
1106
+		);
1107
+	}
1108
+
1109
+
1110
+
1111
+	/**
1112
+	 * @deprecated 4.9.27
1113
+	 * @param  string $pan_name    the name, or key of the Persistent Admin Notice to be stored
1114
+	 * @param  string $pan_message the message to be stored persistently until dismissed
1115
+	 * @param  string $return_url  URL to go back to after nag notice is dismissed
1116
+	 */
1117
+	public static function display_persistent_admin_notices($pan_name = '', $pan_message = '', $return_url = '')
1118
+	{
1119
+		EE_Error::doing_it_wrong(
1120
+			__METHOD__,
1121
+			sprintf(
1122
+				__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
1123
+				'\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
1124
+			),
1125
+			'4.9.27'
1126
+		);
1127
+	}
1128
+
1129
+
1130
+
1131
+	/**
1132
+	 * @deprecated 4.9.27
1133
+	 * @param string $return_url
1134
+	 */
1135
+	public static function get_persistent_admin_notices($return_url = '')
1136
+	{
1137
+		EE_Error::doing_it_wrong(
1138
+			__METHOD__,
1139
+			sprintf(
1140
+				__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
1141
+				'\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
1142
+			),
1143
+			'4.9.27'
1144
+		);
1145
+	}
1146 1146
 
1147 1147
 
1148 1148
 
@@ -1157,27 +1157,27 @@  discard block
 block discarded – undo
1157 1157
  */
1158 1158
 function espresso_error_enqueue_scripts()
1159 1159
 {
1160
-    // js for error handling
1161
-    wp_register_script(
1162
-        'espresso_core',
1163
-        EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
1164
-        array('jquery'),
1165
-        EVENT_ESPRESSO_VERSION,
1166
-        false
1167
-    );
1168
-    wp_register_script(
1169
-        'ee_error_js',
1170
-        EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js',
1171
-        array('espresso_core'),
1172
-        EVENT_ESPRESSO_VERSION,
1173
-        false
1174
-    );
1160
+	// js for error handling
1161
+	wp_register_script(
1162
+		'espresso_core',
1163
+		EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
1164
+		array('jquery'),
1165
+		EVENT_ESPRESSO_VERSION,
1166
+		false
1167
+	);
1168
+	wp_register_script(
1169
+		'ee_error_js',
1170
+		EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js',
1171
+		array('espresso_core'),
1172
+		EVENT_ESPRESSO_VERSION,
1173
+		false
1174
+	);
1175 1175
 }
1176 1176
 
1177 1177
 if (is_admin()) {
1178
-    add_action('admin_enqueue_scripts', 'espresso_error_enqueue_scripts', 2);
1178
+	add_action('admin_enqueue_scripts', 'espresso_error_enqueue_scripts', 2);
1179 1179
 } else {
1180
-    add_action('wp_enqueue_scripts', 'espresso_error_enqueue_scripts', 2);
1180
+	add_action('wp_enqueue_scripts', 'espresso_error_enqueue_scripts', 2);
1181 1181
 }
1182 1182
 
1183 1183
 
Please login to merge, or discard this patch.
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -103,14 +103,14 @@  discard block
 block discarded – undo
103 103
             default :
104 104
                 $to = get_option('admin_email');
105 105
         }
106
-        $subject = $type . ' ' . $message . ' in ' . EVENT_ESPRESSO_VERSION . ' on ' . site_url();
106
+        $subject = $type.' '.$message.' in '.EVENT_ESPRESSO_VERSION.' on '.site_url();
107 107
         $msg = EE_Error::_format_error($type, $message, $file, $line);
108 108
         if (function_exists('wp_mail')) {
109 109
             add_filter('wp_mail_content_type', array('EE_Error', 'set_content_type'));
110 110
             wp_mail($to, $subject, $msg);
111 111
         }
112 112
         echo '<div id="message" class="espresso-notices error"><p>';
113
-        echo $type . ': ' . $message . '<br />' . $file . ' line ' . $line;
113
+        echo $type.': '.$message.'<br />'.$file.' line '.$line;
114 114
         echo '<br /></p></div>';
115 115
     }
116 116
 
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
             ? true
258 258
             : false;
259 259
         if ($check_stored && ! $has_error) {
260
-            $notices = (array)get_option(EE_Error::OPTIONS_KEY_NOTICES, array());
260
+            $notices = (array) get_option(EE_Error::OPTIONS_KEY_NOTICES, array());
261 261
             foreach ($notices as $type => $notice) {
262 262
                 if ($type === $type_to_check && $notice) {
263 263
                     return true;
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 	}
333 333
 </style>
334 334
 <div id="ee-error-message" class="error">';
335
-        if (! WP_DEBUG) {
335
+        if ( ! WP_DEBUG) {
336 336
             $output .= '
337 337
 	<p>';
338 338
         }
@@ -391,14 +391,14 @@  discard block
 block discarded – undo
391 391
                     $class_dsply = ! empty($class) ? $class : '&nbsp;';
392 392
                     $type_dsply = ! empty($type) ? $type : '&nbsp;';
393 393
                     $function_dsply = ! empty($function) ? $function : '&nbsp;';
394
-                    $args_dsply = ! empty($args) ? '( ' . $args . ' )' : '';
394
+                    $args_dsply = ! empty($args) ? '( '.$args.' )' : '';
395 395
                     $trace_details .= '
396 396
 					<tr>
397
-						<td align="right" class="' . $zebra . '">' . $nmbr_dsply . '</td>
398
-						<td align="right" class="' . $zebra . '">' . $line_dsply . '</td>
399
-						<td align="left" class="' . $zebra . '">' . $file_dsply . '</td>
400
-						<td align="left" class="' . $zebra . '">' . $class_dsply . '</td>
401
-						<td align="left" class="' . $zebra . '">' . $type_dsply . $function_dsply . $args_dsply . '</td>
397
+						<td align="right" class="' . $zebra.'">'.$nmbr_dsply.'</td>
398
+						<td align="right" class="' . $zebra.'">'.$line_dsply.'</td>
399
+						<td align="left" class="' . $zebra.'">'.$file_dsply.'</td>
400
+						<td align="left" class="' . $zebra.'">'.$class_dsply.'</td>
401
+						<td align="left" class="' . $zebra.'">'.$type_dsply.$function_dsply.$args_dsply.'</td>
402 402
 					</tr>';
403 403
                 }
404 404
                 $trace_details .= '
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
             }
408 408
             $ex['code'] = $ex['code'] ? $ex['code'] : $error_code;
409 409
             // add generic non-identifying messages for non-privileged users
410
-            if (! WP_DEBUG) {
410
+            if ( ! WP_DEBUG) {
411 411
                 $output .= '<span class="ee-error-user-msg-spn">'
412 412
                            . trim($ex['msg'])
413 413
                            . '</span> &nbsp; <sup>'
@@ -449,14 +449,14 @@  discard block
 block discarded – undo
449 449
                            . '-dv" class="ee-error-trace-dv" style="display: none;">
450 450
 				'
451 451
                            . $trace_details;
452
-                if (! empty($class)) {
452
+                if ( ! empty($class)) {
453 453
                     $output .= '
454 454
 				<div style="padding:3px; margin:0 0 1em; border:1px solid #666; background:#fff; border-radius:3px;">
455 455
 					<div style="padding:1em 2em; border:1px solid #666; background:#f9f9f9;">
456 456
 						<h3>Class Details</h3>';
457 457
                     $a = new ReflectionClass($class);
458 458
                     $output .= '
459
-						<pre>' . $a . '</pre>
459
+						<pre>' . $a.'</pre>
460 460
 					</div>
461 461
 				</div>';
462 462
                 }
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
         }
470 470
         // remove last linebreak
471 471
         $output = substr($output, 0, -6);
472
-        if (! WP_DEBUG) {
472
+        if ( ! WP_DEBUG) {
473 473
             $output .= '
474 474
 	</p>';
475 475
         }
@@ -496,20 +496,20 @@  discard block
 block discarded – undo
496 496
     private function _convert_args_to_string($arguments = array(), $array = false)
497 497
     {
498 498
         $arg_string = '';
499
-        if (! empty($arguments)) {
499
+        if ( ! empty($arguments)) {
500 500
             $args = array();
501 501
             foreach ($arguments as $arg) {
502
-                if (! empty($arg)) {
502
+                if ( ! empty($arg)) {
503 503
                     if (is_string($arg)) {
504
-                        $args[] = " '" . $arg . "'";
504
+                        $args[] = " '".$arg."'";
505 505
                     } elseif (is_array($arg)) {
506
-                        $args[] = 'ARRAY(' . $this->_convert_args_to_string($arg, true);
506
+                        $args[] = 'ARRAY('.$this->_convert_args_to_string($arg, true);
507 507
                     } elseif ($arg === null) {
508 508
                         $args[] = ' NULL';
509 509
                     } elseif (is_bool($arg)) {
510 510
                         $args[] = ($arg) ? ' TRUE' : ' FALSE';
511 511
                     } elseif (is_object($arg)) {
512
-                        $args[] = ' OBJECT ' . get_class($arg);
512
+                        $args[] = ' OBJECT '.get_class($arg);
513 513
                     } elseif (is_resource($arg)) {
514 514
                         $args[] = get_resource_type($arg);
515 515
                     } else {
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
     {
613 613
         if (empty($msg)) {
614 614
             EE_Error::doing_it_wrong(
615
-                'EE_Error::add_' . $type . '()',
615
+                'EE_Error::add_'.$type.'()',
616 616
                 sprintf(
617 617
                     __('Notifications are not much use without a message! Please add a message to the EE_Error::add_%s() call made in %s on line %d',
618 618
                         'event_espresso'),
@@ -648,11 +648,11 @@  discard block
 block discarded – undo
648 648
         do_action('AHEE__EE_Error___add_notice', $type, $user_msg, $dev_msg, $file, $func, $line);
649 649
         $msg = WP_DEBUG ? $dev_msg : $user_msg;
650 650
         // add notice if message exists
651
-        if (! empty($msg)) {
651
+        if ( ! empty($msg)) {
652 652
             // get error code
653 653
             $notice_code = EE_Error::generate_error_code($file, $func, $line);
654 654
             if (WP_DEBUG && $type === 'errors') {
655
-                $msg .= '<br/><span class="tiny-text">' . $notice_code . '</span>';
655
+                $msg .= '<br/><span class="tiny-text">'.$notice_code.'</span>';
656 656
             }
657 657
             // add notice. Index by code if it's not blank
658 658
             if ($notice_code) {
@@ -778,7 +778,7 @@  discard block
 block discarded – undo
778 778
         // EEH_Debug_Tools::printr( self::$_espresso_notices, 'espresso_notices  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
779 779
         // either save notices to the db
780 780
         if ($save_to_transient || isset($_REQUEST['activate-selected'])) {
781
-            $existing_notices  = get_option(EE_Error::OPTIONS_KEY_NOTICES, array());
781
+            $existing_notices = get_option(EE_Error::OPTIONS_KEY_NOTICES, array());
782 782
             $existing_notices = is_array($existing_notices) ? $existing_notices : array();
783 783
             self::$_espresso_notices = array_merge(
784 784
                 $existing_notices,
@@ -808,13 +808,13 @@  discard block
 block discarded – undo
808 808
         if (self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success'])) {
809 809
             // combine messages
810 810
             $success_messages .= implode(self::$_espresso_notices['success'], '<br />');
811
-            $print_scripts    = true;
811
+            $print_scripts = true;
812 812
         }
813 813
         // check for attention messages
814 814
         if (self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention'])) {
815 815
             // combine messages
816 816
             $attention_messages .= implode(self::$_espresso_notices['attention'], '<br />');
817
-            $print_scripts      = true;
817
+            $print_scripts = true;
818 818
         }
819 819
         // check for error messages
820 820
         if (self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors'])) {
@@ -823,7 +823,7 @@  discard block
 block discarded – undo
823 823
                 : __('An error has occurred:<br />', 'event_espresso');
824 824
             // combine messages
825 825
             $error_messages .= implode(self::$_espresso_notices['errors'], '<br />');
826
-            $print_scripts  = true;
826
+            $print_scripts = true;
827 827
         }
828 828
         if ($format_output) {
829 829
 
@@ -905,7 +905,7 @@  discard block
 block discarded – undo
905 905
      */
906 906
     private static function _print_scripts($force_print = false)
907 907
     {
908
-        if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) {
908
+        if ( ! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) {
909 909
             if (wp_script_is('ee_error_js', 'enqueued')) {
910 910
                 return '';
911 911
             }
@@ -919,12 +919,12 @@  discard block
 block discarded – undo
919 919
             return '
920 920
 <script>
921 921
 /* <![CDATA[ */
922
-var ee_settings = {"wp_debug":"' . WP_DEBUG . '"};
922
+var ee_settings = {"wp_debug":"' . WP_DEBUG.'"};
923 923
 /* ]]> */
924 924
 </script>
925
-<script src="' . includes_url() . 'js/jquery/jquery.js" type="text/javascript"></script>
926
-<script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script>
927
-<script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script>
925
+<script src="' . includes_url().'js/jquery/jquery.js" type="text/javascript"></script>
926
+<script src="' . EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js'.'?ver='.espresso_version().'" type="text/javascript"></script>
927
+<script src="' . EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js'.'?ver='.espresso_version().'" type="text/javascript"></script>
928 928
 ';
929 929
         }
930 930
         return '';
@@ -955,8 +955,8 @@  discard block
 block discarded – undo
955 955
     {
956 956
         $file       = explode('.', basename($file));
957 957
         $error_code = ! empty($file[0]) ? $file[0] : '';
958
-        $error_code .= ! empty($func) ? ' - ' . $func : '';
959
-        $error_code .= ! empty($line) ? ' - ' . $line : '';
958
+        $error_code .= ! empty($func) ? ' - '.$func : '';
959
+        $error_code .= ! empty($line) ? ' - '.$line : '';
960 960
         return $error_code;
961 961
     }
962 962
 
@@ -976,18 +976,18 @@  discard block
 block discarded – undo
976 976
         if (empty($ex)) {
977 977
             return;
978 978
         }
979
-        if (! $time) {
979
+        if ( ! $time) {
980 980
             $time = time();
981 981
         }
982 982
         $exception_log = '----------------------------------------------------------------------------------------'
983 983
                          . PHP_EOL;
984
-        $exception_log .= '[' . date('Y-m-d H:i:s', $time) . ']  Exception Details' . PHP_EOL;
985
-        $exception_log .= 'Message: ' . $ex['msg'] . PHP_EOL;
986
-        $exception_log .= 'Code: ' . $ex['code'] . PHP_EOL;
987
-        $exception_log .= 'File: ' . $ex['file'] . PHP_EOL;
988
-        $exception_log .= 'Line No: ' . $ex['line'] . PHP_EOL;
989
-        $exception_log .= 'Stack trace: ' . PHP_EOL;
990
-        $exception_log .= $ex['string'] . PHP_EOL;
984
+        $exception_log .= '['.date('Y-m-d H:i:s', $time).']  Exception Details'.PHP_EOL;
985
+        $exception_log .= 'Message: '.$ex['msg'].PHP_EOL;
986
+        $exception_log .= 'Code: '.$ex['code'].PHP_EOL;
987
+        $exception_log .= 'File: '.$ex['file'].PHP_EOL;
988
+        $exception_log .= 'Line No: '.$ex['line'].PHP_EOL;
989
+        $exception_log .= 'Stack trace: '.PHP_EOL;
990
+        $exception_log .= $ex['string'].PHP_EOL;
991 991
         $exception_log .= '----------------------------------------------------------------------------------------'
992 992
                           . PHP_EOL;
993 993
         try {
@@ -1160,14 +1160,14 @@  discard block
 block discarded – undo
1160 1160
     // js for error handling
1161 1161
     wp_register_script(
1162 1162
         'espresso_core',
1163
-        EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
1163
+        EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js',
1164 1164
         array('jquery'),
1165 1165
         EVENT_ESPRESSO_VERSION,
1166 1166
         false
1167 1167
     );
1168 1168
     wp_register_script(
1169 1169
         'ee_error_js',
1170
-        EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js',
1170
+        EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js',
1171 1171
         array('espresso_core'),
1172 1172
         EVENT_ESPRESSO_VERSION,
1173 1173
         false
Please login to merge, or discard this patch.
modules/ticket_selector/ProcessTicketSelector.php 3 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
     /**
42 42
      * cancelTicketSelections
43 43
      *
44
-     * @return        string
44
+     * @return        false|null
45 45
      * @throws EE_Error
46 46
      * @throws InvalidArgumentException
47 47
      * @throws InvalidInterfaceException
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
     /**
114 114
      * process_ticket_selections
115 115
      *
116
-     * @return array|bool
116
+     * @return boolean|null
117 117
      * @throws \ReflectionException
118 118
      * @throws InvalidArgumentException
119 119
      * @throws InvalidInterfaceException
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
      * validate_post_data
288 288
      *
289 289
      * @param int $id
290
-     * @return array|FALSE
290
+     * @return string
291 291
      * @throws \ReflectionException
292 292
      * @throws InvalidArgumentException
293 293
      * @throws InvalidInterfaceException
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
      *
411 411
      * @param EE_Ticket $ticket
412 412
      * @param int        $qty
413
-     * @return TRUE on success, FALSE on fail
413
+     * @return boolean on success, FALSE on fail
414 414
      * @throws InvalidArgumentException
415 415
      * @throws InvalidInterfaceException
416 416
      * @throws InvalidDataTypeException
Please login to merge, or discard this patch.
Indentation   +569 added lines, -569 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 use InvalidArgumentException;
14 14
 
15 15
 if (! defined('EVENT_ESPRESSO_VERSION')) {
16
-    exit('No direct script access allowed');
16
+	exit('No direct script access allowed');
17 17
 }
18 18
 
19 19
 
@@ -30,592 +30,592 @@  discard block
 block discarded – undo
30 30
 class ProcessTicketSelector
31 31
 {
32 32
 
33
-    /**
34
-     * array of datetimes and the spaces available for them
35
-     *
36
-     * @var array[][]
37
-     */
38
-    private static $_available_spaces = array();
33
+	/**
34
+	 * array of datetimes and the spaces available for them
35
+	 *
36
+	 * @var array[][]
37
+	 */
38
+	private static $_available_spaces = array();
39 39
 
40 40
 
41
-    /**
42
-     * cancelTicketSelections
43
-     *
44
-     * @return        string
45
-     * @throws EE_Error
46
-     * @throws InvalidArgumentException
47
-     * @throws InvalidInterfaceException
48
-     * @throws InvalidDataTypeException
49
-     */
50
-    public function cancelTicketSelections()
51
-    {
52
-        // check nonce
53
-        if (! $this->processTicketSelectorNonce('cancel_ticket_selections')) {
54
-            return false;
55
-        }
56
-        EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
57
-        if (EE_Registry::instance()->REQ->is_set('event_id')) {
58
-            wp_safe_redirect(
59
-                EEH_Event_View::event_link_url(
60
-                    EE_Registry::instance()->REQ->get('event_id')
61
-                )
62
-            );
63
-        } else {
64
-            wp_safe_redirect(
65
-                site_url('/' . EE_Registry::instance()->CFG->core->event_cpt_slug . '/')
66
-            );
67
-        }
68
-        exit();
69
-    }
41
+	/**
42
+	 * cancelTicketSelections
43
+	 *
44
+	 * @return        string
45
+	 * @throws EE_Error
46
+	 * @throws InvalidArgumentException
47
+	 * @throws InvalidInterfaceException
48
+	 * @throws InvalidDataTypeException
49
+	 */
50
+	public function cancelTicketSelections()
51
+	{
52
+		// check nonce
53
+		if (! $this->processTicketSelectorNonce('cancel_ticket_selections')) {
54
+			return false;
55
+		}
56
+		EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
57
+		if (EE_Registry::instance()->REQ->is_set('event_id')) {
58
+			wp_safe_redirect(
59
+				EEH_Event_View::event_link_url(
60
+					EE_Registry::instance()->REQ->get('event_id')
61
+				)
62
+			);
63
+		} else {
64
+			wp_safe_redirect(
65
+				site_url('/' . EE_Registry::instance()->CFG->core->event_cpt_slug . '/')
66
+			);
67
+		}
68
+		exit();
69
+	}
70 70
 
71 71
 
72
-    /**
73
-     * processTicketSelectorNonce
74
-     *
75
-     * @param  string $nonce_name
76
-     * @param string  $id
77
-     * @return bool
78
-     * @throws InvalidArgumentException
79
-     * @throws InvalidInterfaceException
80
-     * @throws InvalidDataTypeException
81
-     */
82
-    private function processTicketSelectorNonce($nonce_name, $id = '')
83
-    {
84
-        $nonce_name_with_id = ! empty($id) ? "{$nonce_name}_nonce_{$id}" : "{$nonce_name}_nonce";
85
-        if (
86
-            ! is_admin()
87
-            && (
88
-                ! EE_Registry::instance()->REQ->is_set($nonce_name_with_id)
89
-                || ! wp_verify_nonce(
90
-                    EE_Registry::instance()->REQ->get($nonce_name_with_id),
91
-                    $nonce_name
92
-                )
93
-            )
94
-        ) {
95
-            EE_Error::add_error(
96
-                sprintf(
97
-                    __(
98
-                        'We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.',
99
-                        'event_espresso'
100
-                    ),
101
-                    '<br/>'
102
-                ),
103
-                __FILE__,
104
-                __FUNCTION__,
105
-                __LINE__
106
-            );
107
-            return false;
108
-        }
109
-        return true;
110
-    }
72
+	/**
73
+	 * processTicketSelectorNonce
74
+	 *
75
+	 * @param  string $nonce_name
76
+	 * @param string  $id
77
+	 * @return bool
78
+	 * @throws InvalidArgumentException
79
+	 * @throws InvalidInterfaceException
80
+	 * @throws InvalidDataTypeException
81
+	 */
82
+	private function processTicketSelectorNonce($nonce_name, $id = '')
83
+	{
84
+		$nonce_name_with_id = ! empty($id) ? "{$nonce_name}_nonce_{$id}" : "{$nonce_name}_nonce";
85
+		if (
86
+			! is_admin()
87
+			&& (
88
+				! EE_Registry::instance()->REQ->is_set($nonce_name_with_id)
89
+				|| ! wp_verify_nonce(
90
+					EE_Registry::instance()->REQ->get($nonce_name_with_id),
91
+					$nonce_name
92
+				)
93
+			)
94
+		) {
95
+			EE_Error::add_error(
96
+				sprintf(
97
+					__(
98
+						'We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.',
99
+						'event_espresso'
100
+					),
101
+					'<br/>'
102
+				),
103
+				__FILE__,
104
+				__FUNCTION__,
105
+				__LINE__
106
+			);
107
+			return false;
108
+		}
109
+		return true;
110
+	}
111 111
 
112 112
 
113
-    /**
114
-     * process_ticket_selections
115
-     *
116
-     * @return array|bool
117
-     * @throws \ReflectionException
118
-     * @throws InvalidArgumentException
119
-     * @throws InvalidInterfaceException
120
-     * @throws InvalidDataTypeException
121
-     * @throws EE_Error
122
-     */
123
-    public function processTicketSelections()
124
-    {
125
-        do_action('EED_Ticket_Selector__process_ticket_selections__before');
126
-        // do we have an event id?
127
-        if (! EE_Registry::instance()->REQ->is_set('tkt-slctr-event-id')) {
128
-            // $_POST['tkt-slctr-event-id'] was not set ?!?!?!?
129
-            EE_Error::add_error(
130
-                sprintf(
131
-                    __(
132
-                        'An event id was not provided or was not received.%sPlease click the back button on your browser and try again.',
133
-                        'event_espresso'
134
-                    ),
135
-                    '<br/>'
136
-                ),
137
-                __FILE__,
138
-                __FUNCTION__,
139
-                __LINE__
140
-            );
141
-        }
142
-        //if event id is valid
143
-        $id = absint(EE_Registry::instance()->REQ->get('tkt-slctr-event-id'));
144
-        //		d( \EE_Registry::instance()->REQ );
145
-        self::$_available_spaces = array(
146
-            'tickets'   => array(),
147
-            'datetimes' => array(),
148
-        );
149
-        //we should really only have 1 registration in the works now (ie, no MER) so clear any previous items in the cart.
150
-        // When MER happens this will probably need to be tweaked, possibly wrapped in a conditional checking for some constant defined in MER etc.
151
-        EE_Registry::instance()->load_core('Session');
152
-        // unless otherwise requested, clear the session
153
-        if (apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', true)) {
154
-            EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
155
-        }
156
-        //d( \EE_Registry::instance()->SSN );
157
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
158
-        // validate/sanitize data
159
-        $valid = $this->validatePostData($id);
160
-        //EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ );
161
-        //EEH_Debug_Tools::printr( $valid, '$valid', __FILE__, __LINE__ );
162
-        //EEH_Debug_Tools::printr( $valid[ 'total_tickets' ], 'total_tickets', __FILE__, __LINE__ );
163
-        //EEH_Debug_Tools::printr( $valid[ 'max_atndz' ], 'max_atndz', __FILE__, __LINE__ );
164
-        //check total tickets ordered vs max number of attendees that can register
165
-        if ($valid['total_tickets'] > $valid['max_atndz']) {
166
-            // ordering too many tickets !!!
167
-            $total_tickets_string = _n(
168
-                'You have attempted to purchase %s ticket.',
169
-                'You have attempted to purchase %s tickets.',
170
-                $valid['total_tickets'],
171
-                'event_espresso'
172
-            );
173
-            $limit_error_1        = sprintf($total_tickets_string, $valid['total_tickets']);
174
-            // dev only message
175
-            $max_atndz_string = _n(
176
-                'The registration limit for this event is %s ticket per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.',
177
-                'The registration limit for this event is %s tickets per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.',
178
-                $valid['max_atndz'],
179
-                'event_espresso'
180
-            );
181
-            $limit_error_2    = sprintf($max_atndz_string, $valid['max_atndz'], $valid['max_atndz']);
182
-            EE_Error::add_error($limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__);
183
-        } else {
184
-            // all data appears to be valid
185
-            $tckts_slctd   = false;
186
-            $tickets_added = 0;
187
-            $valid         = apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__valid_post_data',
188
-                $valid);
189
-            if ($valid['total_tickets'] > 0) {
190
-                // load cart
191
-                EE_Registry::instance()->load_core('Cart');
192
-                // cycle thru the number of data rows sent from the event listing
193
-                for ($x = 0; $x < $valid['rows']; $x++) {
194
-                    // does this row actually contain a ticket quantity?
195
-                    if (isset($valid['qty'][ $x ]) && $valid['qty'][ $x ] > 0) {
196
-                        // YES we have a ticket quantity
197
-                        $tckts_slctd = true;
198
-                        //						d( $valid['ticket_obj'][$x] );
199
-                        if ($valid['ticket_obj'][ $x ] instanceof EE_Ticket) {
200
-                            // then add ticket to cart
201
-                            $tickets_added += $this->addTicketToCart(
202
-                                $valid['ticket_obj'][ $x ],
203
-                                $valid['qty'][ $x ]
204
-                            );
205
-                            if (EE_Error::has_error()) {
206
-                                break;
207
-                            }
208
-                        } else {
209
-                            // nothing added to cart retrieved
210
-                            EE_Error::add_error(
211
-                                sprintf(
212
-                                    __(
213
-                                        'A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.',
214
-                                        'event_espresso'
215
-                                    ),
216
-                                    '<br/>'
217
-                                ),
218
-                                __FILE__, __FUNCTION__, __LINE__
219
-                            );
220
-                        }
221
-                    }
222
-                }
223
-            }
224
-            do_action(
225
-                'AHEE__EE_Ticket_Selector__process_ticket_selections__after_tickets_added_to_cart',
226
-                EE_Registry::instance()->CART,
227
-                $this
228
-            );
229
-            //d( \EE_Registry::instance()->CART );
230
-            //die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE
231
-            if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tckts_slctd)) {
232
-                if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__success', $tickets_added)) {
233
-                    do_action(
234
-                        'FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout',
235
-                        EE_Registry::instance()->CART,
236
-                        $this
237
-                    );
238
-                    EE_Registry::instance()->CART->recalculate_all_cart_totals();
239
-                    EE_Registry::instance()->CART->save_cart(false);
240
-                    // exit('KILL REDIRECT AFTER CART UPDATE'); // <<<<<<<<  OR HERE TO KILL REDIRECT AFTER CART UPDATE
241
-                    // just return TRUE for registrations being made from admin
242
-                    if (is_admin()) {
243
-                        return true;
244
-                    }
245
-                    EE_Error::get_notices(false, true);
246
-                    wp_safe_redirect(
247
-                        apply_filters(
248
-                            'FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url',
249
-                            EE_Registry::instance()->CFG->core->reg_page_url()
250
-                        )
251
-                    );
252
-                    exit();
253
-                } else {
254
-                    if (! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) {
255
-                        // nothing added to cart
256
-                        EE_Error::add_attention(__('No tickets were added for the event', 'event_espresso'),
257
-                            __FILE__, __FUNCTION__, __LINE__);
258
-                    }
259
-                }
260
-            } else {
261
-                // no ticket quantities were selected
262
-                EE_Error::add_error(__('You need to select a ticket quantity before you can proceed.',
263
-                    'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
264
-            }
265
-        }
266
-        //die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL BEFORE REDIRECT
267
-        // at this point, just return if registration is being made from admin
268
-        if (is_admin()) {
269
-            return false;
270
-        }
271
-        if ($valid['return_url']) {
272
-            EE_Error::get_notices(false, true);
273
-            wp_safe_redirect($valid['return_url']);
274
-            exit();
275
-        } elseif (isset($event_to_add['id'])) {
276
-            EE_Error::get_notices(false, true);
277
-            wp_safe_redirect(get_permalink($event_to_add['id']));
278
-            exit();
279
-        } else {
280
-            echo EE_Error::get_notices();
281
-        }
282
-        return false;
283
-    }
113
+	/**
114
+	 * process_ticket_selections
115
+	 *
116
+	 * @return array|bool
117
+	 * @throws \ReflectionException
118
+	 * @throws InvalidArgumentException
119
+	 * @throws InvalidInterfaceException
120
+	 * @throws InvalidDataTypeException
121
+	 * @throws EE_Error
122
+	 */
123
+	public function processTicketSelections()
124
+	{
125
+		do_action('EED_Ticket_Selector__process_ticket_selections__before');
126
+		// do we have an event id?
127
+		if (! EE_Registry::instance()->REQ->is_set('tkt-slctr-event-id')) {
128
+			// $_POST['tkt-slctr-event-id'] was not set ?!?!?!?
129
+			EE_Error::add_error(
130
+				sprintf(
131
+					__(
132
+						'An event id was not provided or was not received.%sPlease click the back button on your browser and try again.',
133
+						'event_espresso'
134
+					),
135
+					'<br/>'
136
+				),
137
+				__FILE__,
138
+				__FUNCTION__,
139
+				__LINE__
140
+			);
141
+		}
142
+		//if event id is valid
143
+		$id = absint(EE_Registry::instance()->REQ->get('tkt-slctr-event-id'));
144
+		//		d( \EE_Registry::instance()->REQ );
145
+		self::$_available_spaces = array(
146
+			'tickets'   => array(),
147
+			'datetimes' => array(),
148
+		);
149
+		//we should really only have 1 registration in the works now (ie, no MER) so clear any previous items in the cart.
150
+		// When MER happens this will probably need to be tweaked, possibly wrapped in a conditional checking for some constant defined in MER etc.
151
+		EE_Registry::instance()->load_core('Session');
152
+		// unless otherwise requested, clear the session
153
+		if (apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', true)) {
154
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
155
+		}
156
+		//d( \EE_Registry::instance()->SSN );
157
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
158
+		// validate/sanitize data
159
+		$valid = $this->validatePostData($id);
160
+		//EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ );
161
+		//EEH_Debug_Tools::printr( $valid, '$valid', __FILE__, __LINE__ );
162
+		//EEH_Debug_Tools::printr( $valid[ 'total_tickets' ], 'total_tickets', __FILE__, __LINE__ );
163
+		//EEH_Debug_Tools::printr( $valid[ 'max_atndz' ], 'max_atndz', __FILE__, __LINE__ );
164
+		//check total tickets ordered vs max number of attendees that can register
165
+		if ($valid['total_tickets'] > $valid['max_atndz']) {
166
+			// ordering too many tickets !!!
167
+			$total_tickets_string = _n(
168
+				'You have attempted to purchase %s ticket.',
169
+				'You have attempted to purchase %s tickets.',
170
+				$valid['total_tickets'],
171
+				'event_espresso'
172
+			);
173
+			$limit_error_1        = sprintf($total_tickets_string, $valid['total_tickets']);
174
+			// dev only message
175
+			$max_atndz_string = _n(
176
+				'The registration limit for this event is %s ticket per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.',
177
+				'The registration limit for this event is %s tickets per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.',
178
+				$valid['max_atndz'],
179
+				'event_espresso'
180
+			);
181
+			$limit_error_2    = sprintf($max_atndz_string, $valid['max_atndz'], $valid['max_atndz']);
182
+			EE_Error::add_error($limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__);
183
+		} else {
184
+			// all data appears to be valid
185
+			$tckts_slctd   = false;
186
+			$tickets_added = 0;
187
+			$valid         = apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__valid_post_data',
188
+				$valid);
189
+			if ($valid['total_tickets'] > 0) {
190
+				// load cart
191
+				EE_Registry::instance()->load_core('Cart');
192
+				// cycle thru the number of data rows sent from the event listing
193
+				for ($x = 0; $x < $valid['rows']; $x++) {
194
+					// does this row actually contain a ticket quantity?
195
+					if (isset($valid['qty'][ $x ]) && $valid['qty'][ $x ] > 0) {
196
+						// YES we have a ticket quantity
197
+						$tckts_slctd = true;
198
+						//						d( $valid['ticket_obj'][$x] );
199
+						if ($valid['ticket_obj'][ $x ] instanceof EE_Ticket) {
200
+							// then add ticket to cart
201
+							$tickets_added += $this->addTicketToCart(
202
+								$valid['ticket_obj'][ $x ],
203
+								$valid['qty'][ $x ]
204
+							);
205
+							if (EE_Error::has_error()) {
206
+								break;
207
+							}
208
+						} else {
209
+							// nothing added to cart retrieved
210
+							EE_Error::add_error(
211
+								sprintf(
212
+									__(
213
+										'A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.',
214
+										'event_espresso'
215
+									),
216
+									'<br/>'
217
+								),
218
+								__FILE__, __FUNCTION__, __LINE__
219
+							);
220
+						}
221
+					}
222
+				}
223
+			}
224
+			do_action(
225
+				'AHEE__EE_Ticket_Selector__process_ticket_selections__after_tickets_added_to_cart',
226
+				EE_Registry::instance()->CART,
227
+				$this
228
+			);
229
+			//d( \EE_Registry::instance()->CART );
230
+			//die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE
231
+			if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tckts_slctd)) {
232
+				if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__success', $tickets_added)) {
233
+					do_action(
234
+						'FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout',
235
+						EE_Registry::instance()->CART,
236
+						$this
237
+					);
238
+					EE_Registry::instance()->CART->recalculate_all_cart_totals();
239
+					EE_Registry::instance()->CART->save_cart(false);
240
+					// exit('KILL REDIRECT AFTER CART UPDATE'); // <<<<<<<<  OR HERE TO KILL REDIRECT AFTER CART UPDATE
241
+					// just return TRUE for registrations being made from admin
242
+					if (is_admin()) {
243
+						return true;
244
+					}
245
+					EE_Error::get_notices(false, true);
246
+					wp_safe_redirect(
247
+						apply_filters(
248
+							'FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url',
249
+							EE_Registry::instance()->CFG->core->reg_page_url()
250
+						)
251
+					);
252
+					exit();
253
+				} else {
254
+					if (! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) {
255
+						// nothing added to cart
256
+						EE_Error::add_attention(__('No tickets were added for the event', 'event_espresso'),
257
+							__FILE__, __FUNCTION__, __LINE__);
258
+					}
259
+				}
260
+			} else {
261
+				// no ticket quantities were selected
262
+				EE_Error::add_error(__('You need to select a ticket quantity before you can proceed.',
263
+					'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
264
+			}
265
+		}
266
+		//die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL BEFORE REDIRECT
267
+		// at this point, just return if registration is being made from admin
268
+		if (is_admin()) {
269
+			return false;
270
+		}
271
+		if ($valid['return_url']) {
272
+			EE_Error::get_notices(false, true);
273
+			wp_safe_redirect($valid['return_url']);
274
+			exit();
275
+		} elseif (isset($event_to_add['id'])) {
276
+			EE_Error::get_notices(false, true);
277
+			wp_safe_redirect(get_permalink($event_to_add['id']));
278
+			exit();
279
+		} else {
280
+			echo EE_Error::get_notices();
281
+		}
282
+		return false;
283
+	}
284 284
 
285 285
 
286
-    /**
287
-     * validate_post_data
288
-     *
289
-     * @param int $id
290
-     * @return array|FALSE
291
-     * @throws \ReflectionException
292
-     * @throws InvalidArgumentException
293
-     * @throws InvalidInterfaceException
294
-     * @throws InvalidDataTypeException
295
-     * @throws EE_Error
296
-     */
297
-    private function validatePostData($id = 0)
298
-    {
299
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
300
-        if (! $id) {
301
-            EE_Error::add_error(
302
-                __('The event id provided was not valid.', 'event_espresso'),
303
-                __FILE__,
304
-                __FUNCTION__,
305
-                __LINE__
306
-            );
307
-            return false;
308
-        }
309
-        // start with an empty array()
310
-        $valid_data = array();
311
-        // grab valid id
312
-        $valid_data['id'] = $id;
313
-        // array of other form names
314
-        $inputs_to_clean = array(
315
-            'event_id'   => 'tkt-slctr-event-id',
316
-            'max_atndz'  => 'tkt-slctr-max-atndz-',
317
-            'rows'       => 'tkt-slctr-rows-',
318
-            'qty'        => 'tkt-slctr-qty-',
319
-            'ticket_id'  => 'tkt-slctr-ticket-id-',
320
-            'return_url' => 'tkt-slctr-return-url-',
321
-        );
322
-        // let's track the total number of tickets ordered.'
323
-        $valid_data['total_tickets'] = 0;
324
-        // cycle through $inputs_to_clean array
325
-        foreach ($inputs_to_clean as $what => $input_to_clean) {
326
-            // check for POST data
327
-            if (EE_Registry::instance()->REQ->is_set($input_to_clean . $id)) {
328
-                // grab value
329
-                $input_value = EE_Registry::instance()->REQ->get($input_to_clean . $id);
330
-                switch ($what) {
331
-                    // integers
332
-                    case 'event_id':
333
-                        $valid_data[ $what ] = absint($input_value);
334
-                        // get event via the event id we put in the form
335
-                        $valid_data['event'] = EE_Registry::instance()
336
-                                                           ->load_model('Event')
337
-                                                           ->get_one_by_ID($valid_data['event_id']);
338
-                        break;
339
-                    case 'rows':
340
-                    case 'max_atndz':
341
-                        $valid_data[ $what ] = absint($input_value);
342
-                        break;
343
-                    // arrays of integers
344
-                    case 'qty':
345
-                        /** @var array $row_qty */
346
-                        $row_qty = $input_value;
347
-                        // if qty is coming from a radio button input, then we need to assemble an array of rows
348
-                        if (! is_array($row_qty)) {
349
-                            // get number of rows
350
-                            $rows = EE_Registry::instance()->REQ->is_set('tkt-slctr-rows-' . $id)
351
-                                ? absint(EE_Registry::instance()->REQ->get('tkt-slctr-rows-' . $id))
352
-                                : 1;
353
-                            // explode ints by the dash
354
-                            $row_qty = explode('-', $row_qty);
355
-                            $row     = isset($row_qty[0]) ? absint($row_qty[0]) : 1;
356
-                            $qty     = isset($row_qty[1]) ? absint($row_qty[1]) : 0;
357
-                            $row_qty = array($row => $qty);
358
-                            for ($x = 1; $x <= $rows; $x++) {
359
-                                if (! isset($row_qty[ $x ])) {
360
-                                    $row_qty[ $x ] = 0;
361
-                                }
362
-                            }
363
-                        }
364
-                        ksort($row_qty);
365
-                        // cycle thru values
366
-                        foreach ($row_qty as $qty) {
367
-                            $qty = absint($qty);
368
-                            // sanitize as integers
369
-                            $valid_data[ $what ][]       = $qty;
370
-                            $valid_data['total_tickets'] += $qty;
371
-                        }
372
-                        break;
373
-                    // array of integers
374
-                    case 'ticket_id':
375
-                        $value_array = array();
376
-                        // cycle thru values
377
-                        foreach ((array) $input_value as $key => $value) {
378
-                            // allow only numbers, letters,  spaces, commas and dashes
379
-                            $value_array[ $key ] = wp_strip_all_tags($value);
380
-                            // get ticket via the ticket id we put in the form
381
-                            $ticket_obj                       = EE_Registry::instance()
382
-                                                                            ->load_model('Ticket')
383
-                                                                            ->get_one_by_ID($value);
384
-                            $valid_data['ticket_obj'][ $key ] = $ticket_obj;
385
-                        }
386
-                        $valid_data[ $what ] = $value_array;
387
-                        break;
388
-                    case 'return_url' :
389
-                        // grab and sanitize return-url
390
-                        $input_value = esc_url_raw($input_value);
391
-                        // was the request coming from an iframe ? if so, then:
392
-                        if (strpos($input_value, 'event_list=iframe')) {
393
-                            // get anchor fragment
394
-                            $input_value = explode('#', $input_value);
395
-                            $input_value = end($input_value);
396
-                            // use event list url instead, but append anchor
397
-                            $input_value = EEH_Event_View::event_archive_url() . '#' . $input_value;
398
-                        }
399
-                        $valid_data[ $what ] = $input_value;
400
-                        break;
401
-                }    // end switch $what
402
-            }
403
-        }    // end foreach $inputs_to_clean
404
-        return $valid_data;
405
-    }
286
+	/**
287
+	 * validate_post_data
288
+	 *
289
+	 * @param int $id
290
+	 * @return array|FALSE
291
+	 * @throws \ReflectionException
292
+	 * @throws InvalidArgumentException
293
+	 * @throws InvalidInterfaceException
294
+	 * @throws InvalidDataTypeException
295
+	 * @throws EE_Error
296
+	 */
297
+	private function validatePostData($id = 0)
298
+	{
299
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
300
+		if (! $id) {
301
+			EE_Error::add_error(
302
+				__('The event id provided was not valid.', 'event_espresso'),
303
+				__FILE__,
304
+				__FUNCTION__,
305
+				__LINE__
306
+			);
307
+			return false;
308
+		}
309
+		// start with an empty array()
310
+		$valid_data = array();
311
+		// grab valid id
312
+		$valid_data['id'] = $id;
313
+		// array of other form names
314
+		$inputs_to_clean = array(
315
+			'event_id'   => 'tkt-slctr-event-id',
316
+			'max_atndz'  => 'tkt-slctr-max-atndz-',
317
+			'rows'       => 'tkt-slctr-rows-',
318
+			'qty'        => 'tkt-slctr-qty-',
319
+			'ticket_id'  => 'tkt-slctr-ticket-id-',
320
+			'return_url' => 'tkt-slctr-return-url-',
321
+		);
322
+		// let's track the total number of tickets ordered.'
323
+		$valid_data['total_tickets'] = 0;
324
+		// cycle through $inputs_to_clean array
325
+		foreach ($inputs_to_clean as $what => $input_to_clean) {
326
+			// check for POST data
327
+			if (EE_Registry::instance()->REQ->is_set($input_to_clean . $id)) {
328
+				// grab value
329
+				$input_value = EE_Registry::instance()->REQ->get($input_to_clean . $id);
330
+				switch ($what) {
331
+					// integers
332
+					case 'event_id':
333
+						$valid_data[ $what ] = absint($input_value);
334
+						// get event via the event id we put in the form
335
+						$valid_data['event'] = EE_Registry::instance()
336
+														   ->load_model('Event')
337
+														   ->get_one_by_ID($valid_data['event_id']);
338
+						break;
339
+					case 'rows':
340
+					case 'max_atndz':
341
+						$valid_data[ $what ] = absint($input_value);
342
+						break;
343
+					// arrays of integers
344
+					case 'qty':
345
+						/** @var array $row_qty */
346
+						$row_qty = $input_value;
347
+						// if qty is coming from a radio button input, then we need to assemble an array of rows
348
+						if (! is_array($row_qty)) {
349
+							// get number of rows
350
+							$rows = EE_Registry::instance()->REQ->is_set('tkt-slctr-rows-' . $id)
351
+								? absint(EE_Registry::instance()->REQ->get('tkt-slctr-rows-' . $id))
352
+								: 1;
353
+							// explode ints by the dash
354
+							$row_qty = explode('-', $row_qty);
355
+							$row     = isset($row_qty[0]) ? absint($row_qty[0]) : 1;
356
+							$qty     = isset($row_qty[1]) ? absint($row_qty[1]) : 0;
357
+							$row_qty = array($row => $qty);
358
+							for ($x = 1; $x <= $rows; $x++) {
359
+								if (! isset($row_qty[ $x ])) {
360
+									$row_qty[ $x ] = 0;
361
+								}
362
+							}
363
+						}
364
+						ksort($row_qty);
365
+						// cycle thru values
366
+						foreach ($row_qty as $qty) {
367
+							$qty = absint($qty);
368
+							// sanitize as integers
369
+							$valid_data[ $what ][]       = $qty;
370
+							$valid_data['total_tickets'] += $qty;
371
+						}
372
+						break;
373
+					// array of integers
374
+					case 'ticket_id':
375
+						$value_array = array();
376
+						// cycle thru values
377
+						foreach ((array) $input_value as $key => $value) {
378
+							// allow only numbers, letters,  spaces, commas and dashes
379
+							$value_array[ $key ] = wp_strip_all_tags($value);
380
+							// get ticket via the ticket id we put in the form
381
+							$ticket_obj                       = EE_Registry::instance()
382
+																			->load_model('Ticket')
383
+																			->get_one_by_ID($value);
384
+							$valid_data['ticket_obj'][ $key ] = $ticket_obj;
385
+						}
386
+						$valid_data[ $what ] = $value_array;
387
+						break;
388
+					case 'return_url' :
389
+						// grab and sanitize return-url
390
+						$input_value = esc_url_raw($input_value);
391
+						// was the request coming from an iframe ? if so, then:
392
+						if (strpos($input_value, 'event_list=iframe')) {
393
+							// get anchor fragment
394
+							$input_value = explode('#', $input_value);
395
+							$input_value = end($input_value);
396
+							// use event list url instead, but append anchor
397
+							$input_value = EEH_Event_View::event_archive_url() . '#' . $input_value;
398
+						}
399
+						$valid_data[ $what ] = $input_value;
400
+						break;
401
+				}    // end switch $what
402
+			}
403
+		}    // end foreach $inputs_to_clean
404
+		return $valid_data;
405
+	}
406 406
 
407 407
 
408
-    /**
409
-     * adds a ticket to the cart
410
-     *
411
-     * @param EE_Ticket $ticket
412
-     * @param int        $qty
413
-     * @return TRUE on success, FALSE on fail
414
-     * @throws InvalidArgumentException
415
-     * @throws InvalidInterfaceException
416
-     * @throws InvalidDataTypeException
417
-     * @throws EE_Error
418
-     */
419
-    private function addTicketToCart(EE_Ticket $ticket = null, $qty = 1)
420
-    {
421
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
422
-        // get the number of spaces left for this datetime ticket
423
-        $available_spaces = $this->ticketDatetimeAvailability($ticket);
424
-        // compare available spaces against the number of tickets being purchased
425
-        if ($available_spaces >= $qty) {
426
-            // allow addons to prevent a ticket from being added to cart
427
-            if (
428
-            ! apply_filters(
429
-                'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart',
430
-                true,
431
-                $ticket,
432
-                $qty,
433
-                $available_spaces
434
-            )
435
-            ) {
436
-                return false;
437
-            }
438
-            $qty = absint(apply_filters('FHEE__EE_Ticket_Selector___add_ticket_to_cart__ticket_qty', $qty, $ticket));
439
-            // add event to cart
440
-            if (EE_Registry::instance()->CART->add_ticket_to_cart($ticket, $qty)) {
441
-                $this->recalculateTicketDatetimeAvailability($ticket, $qty);
442
-                return true;
443
-            }
444
-            return false;
445
-        }
446
-        // tickets can not be purchased but let's find the exact number left
447
-        // for the last ticket selected PRIOR to subtracting tickets
448
-        $available_spaces = $this->ticketDatetimeAvailability($ticket, true);
449
-        // greedy greedy greedy eh?
450
-        if ($available_spaces > 0) {
451
-            if (
452
-            apply_filters(
453
-                'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_display_availability_error',
454
-                true,
455
-                $ticket,
456
-                $qty,
457
-                $available_spaces
458
-            )
459
-            ) {
460
-                $this->displayAvailabilityError($available_spaces);
461
-            }
462
-        } else {
463
-            EE_Error::add_error(
464
-                __(
465
-                    'We\'re sorry, but there are no available spaces left for this event at this particular date and time.',
466
-                    'event_espresso'
467
-                ),
468
-                __FILE__, __FUNCTION__, __LINE__
469
-            );
470
-        }
471
-        return false;
472
-    }
408
+	/**
409
+	 * adds a ticket to the cart
410
+	 *
411
+	 * @param EE_Ticket $ticket
412
+	 * @param int        $qty
413
+	 * @return TRUE on success, FALSE on fail
414
+	 * @throws InvalidArgumentException
415
+	 * @throws InvalidInterfaceException
416
+	 * @throws InvalidDataTypeException
417
+	 * @throws EE_Error
418
+	 */
419
+	private function addTicketToCart(EE_Ticket $ticket = null, $qty = 1)
420
+	{
421
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
422
+		// get the number of spaces left for this datetime ticket
423
+		$available_spaces = $this->ticketDatetimeAvailability($ticket);
424
+		// compare available spaces against the number of tickets being purchased
425
+		if ($available_spaces >= $qty) {
426
+			// allow addons to prevent a ticket from being added to cart
427
+			if (
428
+			! apply_filters(
429
+				'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart',
430
+				true,
431
+				$ticket,
432
+				$qty,
433
+				$available_spaces
434
+			)
435
+			) {
436
+				return false;
437
+			}
438
+			$qty = absint(apply_filters('FHEE__EE_Ticket_Selector___add_ticket_to_cart__ticket_qty', $qty, $ticket));
439
+			// add event to cart
440
+			if (EE_Registry::instance()->CART->add_ticket_to_cart($ticket, $qty)) {
441
+				$this->recalculateTicketDatetimeAvailability($ticket, $qty);
442
+				return true;
443
+			}
444
+			return false;
445
+		}
446
+		// tickets can not be purchased but let's find the exact number left
447
+		// for the last ticket selected PRIOR to subtracting tickets
448
+		$available_spaces = $this->ticketDatetimeAvailability($ticket, true);
449
+		// greedy greedy greedy eh?
450
+		if ($available_spaces > 0) {
451
+			if (
452
+			apply_filters(
453
+				'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_display_availability_error',
454
+				true,
455
+				$ticket,
456
+				$qty,
457
+				$available_spaces
458
+			)
459
+			) {
460
+				$this->displayAvailabilityError($available_spaces);
461
+			}
462
+		} else {
463
+			EE_Error::add_error(
464
+				__(
465
+					'We\'re sorry, but there are no available spaces left for this event at this particular date and time.',
466
+					'event_espresso'
467
+				),
468
+				__FILE__, __FUNCTION__, __LINE__
469
+			);
470
+		}
471
+		return false;
472
+	}
473 473
 
474 474
 
475
-    /**
476
-     * @param int $available_spaces
477
-     * @throws InvalidArgumentException
478
-     * @throws InvalidInterfaceException
479
-     * @throws InvalidDataTypeException
480
-     * @throws EE_Error
481
-     */
482
-    private function displayAvailabilityError($available_spaces = 1)
483
-    {
484
-        // add error messaging - we're using the _n function that will generate
485
-        // the appropriate singular or plural message based on the number of $available_spaces
486
-        if (EE_Registry::instance()->CART->all_ticket_quantity_count()) {
487
-            $msg = sprintf(
488
-                _n(
489
-                    'We\'re sorry, but there is only %1$s available space left for this event at this particular date and time. Please select a different number (or different combination) of tickets by cancelling the current selection and choosing again, or proceed to registration.',
490
-                    'We\'re sorry, but there are only %1$s available spaces left for this event at this particular date and time. Please select a different number (or different combination) of tickets by cancelling the current selection and choosing again, or proceed to registration.',
491
-                    $available_spaces,
492
-                    'event_espresso'
493
-                ),
494
-                $available_spaces,
495
-                '<br />'
496
-            );
497
-        } else {
498
-            $msg = sprintf(
499
-                _n(
500
-                    'We\'re sorry, but there is only %1$s available space left for this event at this particular date and time. Please select a different number (or different combination) of tickets.',
501
-                    'We\'re sorry, but there are only %1$s available spaces left for this event at this particular date and time. Please select a different number (or different combination) of tickets.',
502
-                    $available_spaces,
503
-                    'event_espresso'
504
-                ),
505
-                $available_spaces,
506
-                '<br />'
507
-            );
508
-        }
509
-        EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
510
-    }
475
+	/**
476
+	 * @param int $available_spaces
477
+	 * @throws InvalidArgumentException
478
+	 * @throws InvalidInterfaceException
479
+	 * @throws InvalidDataTypeException
480
+	 * @throws EE_Error
481
+	 */
482
+	private function displayAvailabilityError($available_spaces = 1)
483
+	{
484
+		// add error messaging - we're using the _n function that will generate
485
+		// the appropriate singular or plural message based on the number of $available_spaces
486
+		if (EE_Registry::instance()->CART->all_ticket_quantity_count()) {
487
+			$msg = sprintf(
488
+				_n(
489
+					'We\'re sorry, but there is only %1$s available space left for this event at this particular date and time. Please select a different number (or different combination) of tickets by cancelling the current selection and choosing again, or proceed to registration.',
490
+					'We\'re sorry, but there are only %1$s available spaces left for this event at this particular date and time. Please select a different number (or different combination) of tickets by cancelling the current selection and choosing again, or proceed to registration.',
491
+					$available_spaces,
492
+					'event_espresso'
493
+				),
494
+				$available_spaces,
495
+				'<br />'
496
+			);
497
+		} else {
498
+			$msg = sprintf(
499
+				_n(
500
+					'We\'re sorry, but there is only %1$s available space left for this event at this particular date and time. Please select a different number (or different combination) of tickets.',
501
+					'We\'re sorry, but there are only %1$s available spaces left for this event at this particular date and time. Please select a different number (or different combination) of tickets.',
502
+					$available_spaces,
503
+					'event_espresso'
504
+				),
505
+				$available_spaces,
506
+				'<br />'
507
+			);
508
+		}
509
+		EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
510
+	}
511 511
 
512 512
 
513
-    /**
514
-     * ticketDatetimeAvailability
515
-     * creates an array of tickets plus all of the datetimes available to each ticket
516
-     * and tracks the spaces remaining for each of those datetimes
517
-     *
518
-     * @param EE_Ticket $ticket - selected ticket
519
-     * @param bool      $get_original_ticket_spaces
520
-     * @return int
521
-     * @throws InvalidArgumentException
522
-     * @throws InvalidInterfaceException
523
-     * @throws InvalidDataTypeException
524
-     * @throws EE_Error
525
-     */
526
-    private function ticketDatetimeAvailability(EE_Ticket $ticket, $get_original_ticket_spaces = false)
527
-    {
528
-        // if the $_available_spaces array has not been set up yet...
529
-        if (! isset(self::$_available_spaces['tickets'][ $ticket->ID() ])) {
530
-            $this->setInitialTicketDatetimeAvailability($ticket);
531
-        }
532
-        $available_spaces = $ticket->qty() - $ticket->sold();
533
-        if (isset(self::$_available_spaces['tickets'][ $ticket->ID() ])) {
534
-            // loop thru tickets, which will ALSO include individual ticket records AND a total
535
-            foreach (self::$_available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces) {
536
-                // if we want the original datetime availability BEFORE we started subtracting tickets ?
537
-                if ($get_original_ticket_spaces) {
538
-                    // then grab the available spaces from the "tickets" array
539
-                    // and compare with the above to get the lowest number
540
-                    $available_spaces = min(
541
-                        $available_spaces,
542
-                        self::$_available_spaces['tickets'][ $ticket->ID() ][ $DTD_ID ]
543
-                    );
544
-                } else {
545
-                    // we want the updated ticket availability as stored in the "datetimes" array
546
-                    $available_spaces = min($available_spaces, self::$_available_spaces['datetimes'][ $DTD_ID ]);
547
-                }
548
-            }
549
-        }
550
-        return $available_spaces;
551
-    }
513
+	/**
514
+	 * ticketDatetimeAvailability
515
+	 * creates an array of tickets plus all of the datetimes available to each ticket
516
+	 * and tracks the spaces remaining for each of those datetimes
517
+	 *
518
+	 * @param EE_Ticket $ticket - selected ticket
519
+	 * @param bool      $get_original_ticket_spaces
520
+	 * @return int
521
+	 * @throws InvalidArgumentException
522
+	 * @throws InvalidInterfaceException
523
+	 * @throws InvalidDataTypeException
524
+	 * @throws EE_Error
525
+	 */
526
+	private function ticketDatetimeAvailability(EE_Ticket $ticket, $get_original_ticket_spaces = false)
527
+	{
528
+		// if the $_available_spaces array has not been set up yet...
529
+		if (! isset(self::$_available_spaces['tickets'][ $ticket->ID() ])) {
530
+			$this->setInitialTicketDatetimeAvailability($ticket);
531
+		}
532
+		$available_spaces = $ticket->qty() - $ticket->sold();
533
+		if (isset(self::$_available_spaces['tickets'][ $ticket->ID() ])) {
534
+			// loop thru tickets, which will ALSO include individual ticket records AND a total
535
+			foreach (self::$_available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces) {
536
+				// if we want the original datetime availability BEFORE we started subtracting tickets ?
537
+				if ($get_original_ticket_spaces) {
538
+					// then grab the available spaces from the "tickets" array
539
+					// and compare with the above to get the lowest number
540
+					$available_spaces = min(
541
+						$available_spaces,
542
+						self::$_available_spaces['tickets'][ $ticket->ID() ][ $DTD_ID ]
543
+					);
544
+				} else {
545
+					// we want the updated ticket availability as stored in the "datetimes" array
546
+					$available_spaces = min($available_spaces, self::$_available_spaces['datetimes'][ $DTD_ID ]);
547
+				}
548
+			}
549
+		}
550
+		return $available_spaces;
551
+	}
552 552
 
553 553
 
554
-    /**
555
-     * @param EE_Ticket $ticket
556
-     * @return void
557
-     * @throws InvalidArgumentException
558
-     * @throws InvalidInterfaceException
559
-     * @throws InvalidDataTypeException
560
-     * @throws EE_Error
561
-     */
562
-    private function setInitialTicketDatetimeAvailability(EE_Ticket $ticket)
563
-    {
564
-        // first, get all of the datetimes that are available to this ticket
565
-        $datetimes = $ticket->get_many_related(
566
-            'Datetime',
567
-            array(
568
-                array(
569
-                    'DTT_EVT_end' => array(
570
-                        '>=',
571
-                        EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
572
-                    ),
573
-                ),
574
-                'order_by' => array('DTT_EVT_start' => 'ASC'),
575
-            )
576
-        );
577
-        if (! empty($datetimes)) {
578
-            // now loop thru all of the datetimes
579
-            foreach ($datetimes as $datetime) {
580
-                if ($datetime instanceof EE_Datetime) {
581
-                    // the number of spaces available for the datetime without considering individual ticket quantities
582
-                    $spaces_remaining = $datetime->spaces_remaining();
583
-                    // save the total available spaces ( the lesser of the ticket qty minus the number of tickets sold
584
-                    // or the datetime spaces remaining) to this ticket using the datetime ID as the key
585
-                    self::$_available_spaces['tickets'][ $ticket->ID() ][ $datetime->ID() ] = min(
586
-                        $ticket->qty() - $ticket->sold(),
587
-                        $spaces_remaining
588
-                    );
589
-                    // if the remaining spaces for this datetime is already set,
590
-                    // then compare that against the datetime spaces remaining, and take the lowest number,
591
-                    // else just take the datetime spaces remaining, and assign to the datetimes array
592
-                    self::$_available_spaces['datetimes'][ $datetime->ID() ] = isset(
593
-                        self::$_available_spaces['datetimes'][ $datetime->ID() ]
594
-                    )
595
-                        ? min(self::$_available_spaces['datetimes'][ $datetime->ID() ], $spaces_remaining)
596
-                        : $spaces_remaining;
597
-                }
598
-            }
599
-        }
600
-    }
554
+	/**
555
+	 * @param EE_Ticket $ticket
556
+	 * @return void
557
+	 * @throws InvalidArgumentException
558
+	 * @throws InvalidInterfaceException
559
+	 * @throws InvalidDataTypeException
560
+	 * @throws EE_Error
561
+	 */
562
+	private function setInitialTicketDatetimeAvailability(EE_Ticket $ticket)
563
+	{
564
+		// first, get all of the datetimes that are available to this ticket
565
+		$datetimes = $ticket->get_many_related(
566
+			'Datetime',
567
+			array(
568
+				array(
569
+					'DTT_EVT_end' => array(
570
+						'>=',
571
+						EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
572
+					),
573
+				),
574
+				'order_by' => array('DTT_EVT_start' => 'ASC'),
575
+			)
576
+		);
577
+		if (! empty($datetimes)) {
578
+			// now loop thru all of the datetimes
579
+			foreach ($datetimes as $datetime) {
580
+				if ($datetime instanceof EE_Datetime) {
581
+					// the number of spaces available for the datetime without considering individual ticket quantities
582
+					$spaces_remaining = $datetime->spaces_remaining();
583
+					// save the total available spaces ( the lesser of the ticket qty minus the number of tickets sold
584
+					// or the datetime spaces remaining) to this ticket using the datetime ID as the key
585
+					self::$_available_spaces['tickets'][ $ticket->ID() ][ $datetime->ID() ] = min(
586
+						$ticket->qty() - $ticket->sold(),
587
+						$spaces_remaining
588
+					);
589
+					// if the remaining spaces for this datetime is already set,
590
+					// then compare that against the datetime spaces remaining, and take the lowest number,
591
+					// else just take the datetime spaces remaining, and assign to the datetimes array
592
+					self::$_available_spaces['datetimes'][ $datetime->ID() ] = isset(
593
+						self::$_available_spaces['datetimes'][ $datetime->ID() ]
594
+					)
595
+						? min(self::$_available_spaces['datetimes'][ $datetime->ID() ], $spaces_remaining)
596
+						: $spaces_remaining;
597
+				}
598
+			}
599
+		}
600
+	}
601 601
 
602 602
 
603
-    /**
604
-     * @param    EE_Ticket $ticket
605
-     * @param    int        $qty
606
-     * @return    void
607
-     * @throws EE_Error
608
-     */
609
-    private function recalculateTicketDatetimeAvailability(EE_Ticket $ticket, $qty = 0)
610
-    {
611
-        if (isset(self::$_available_spaces['tickets'][ $ticket->ID() ])) {
612
-            // loop thru tickets, which will ALSO include individual ticket records AND a total
613
-            foreach (self::$_available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces) {
614
-                // subtract the qty of selected tickets from each datetime's available spaces this ticket has access to,
615
-                self::$_available_spaces['datetimes'][ $DTD_ID ] -= $qty;
616
-            }
617
-        }
618
-    }
603
+	/**
604
+	 * @param    EE_Ticket $ticket
605
+	 * @param    int        $qty
606
+	 * @return    void
607
+	 * @throws EE_Error
608
+	 */
609
+	private function recalculateTicketDatetimeAvailability(EE_Ticket $ticket, $qty = 0)
610
+	{
611
+		if (isset(self::$_available_spaces['tickets'][ $ticket->ID() ])) {
612
+			// loop thru tickets, which will ALSO include individual ticket records AND a total
613
+			foreach (self::$_available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces) {
614
+				// subtract the qty of selected tickets from each datetime's available spaces this ticket has access to,
615
+				self::$_available_spaces['datetimes'][ $DTD_ID ] -= $qty;
616
+			}
617
+		}
618
+	}
619 619
 }
620 620
 // End of file ProcessTicketSelector.php
621 621
 // Location: /ProcessTicketSelector.php
Please login to merge, or discard this patch.
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 use EventEspresso\core\exceptions\InvalidInterfaceException;
13 13
 use InvalidArgumentException;
14 14
 
15
-if (! defined('EVENT_ESPRESSO_VERSION')) {
15
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
16 16
     exit('No direct script access allowed');
17 17
 }
18 18
 
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
     public function cancelTicketSelections()
51 51
     {
52 52
         // check nonce
53
-        if (! $this->processTicketSelectorNonce('cancel_ticket_selections')) {
53
+        if ( ! $this->processTicketSelectorNonce('cancel_ticket_selections')) {
54 54
             return false;
55 55
         }
56 56
         EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
             );
63 63
         } else {
64 64
             wp_safe_redirect(
65
-                site_url('/' . EE_Registry::instance()->CFG->core->event_cpt_slug . '/')
65
+                site_url('/'.EE_Registry::instance()->CFG->core->event_cpt_slug.'/')
66 66
             );
67 67
         }
68 68
         exit();
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
     {
125 125
         do_action('EED_Ticket_Selector__process_ticket_selections__before');
126 126
         // do we have an event id?
127
-        if (! EE_Registry::instance()->REQ->is_set('tkt-slctr-event-id')) {
127
+        if ( ! EE_Registry::instance()->REQ->is_set('tkt-slctr-event-id')) {
128 128
             // $_POST['tkt-slctr-event-id'] was not set ?!?!?!?
129 129
             EE_Error::add_error(
130 130
                 sprintf(
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
                 $valid['total_tickets'],
171 171
                 'event_espresso'
172 172
             );
173
-            $limit_error_1        = sprintf($total_tickets_string, $valid['total_tickets']);
173
+            $limit_error_1 = sprintf($total_tickets_string, $valid['total_tickets']);
174 174
             // dev only message
175 175
             $max_atndz_string = _n(
176 176
                 'The registration limit for this event is %s ticket per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.',
@@ -178,8 +178,8 @@  discard block
 block discarded – undo
178 178
                 $valid['max_atndz'],
179 179
                 'event_espresso'
180 180
             );
181
-            $limit_error_2    = sprintf($max_atndz_string, $valid['max_atndz'], $valid['max_atndz']);
182
-            EE_Error::add_error($limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__);
181
+            $limit_error_2 = sprintf($max_atndz_string, $valid['max_atndz'], $valid['max_atndz']);
182
+            EE_Error::add_error($limit_error_1.'<br/>'.$limit_error_2, __FILE__, __FUNCTION__, __LINE__);
183 183
         } else {
184 184
             // all data appears to be valid
185 185
             $tckts_slctd   = false;
@@ -192,15 +192,15 @@  discard block
 block discarded – undo
192 192
                 // cycle thru the number of data rows sent from the event listing
193 193
                 for ($x = 0; $x < $valid['rows']; $x++) {
194 194
                     // does this row actually contain a ticket quantity?
195
-                    if (isset($valid['qty'][ $x ]) && $valid['qty'][ $x ] > 0) {
195
+                    if (isset($valid['qty'][$x]) && $valid['qty'][$x] > 0) {
196 196
                         // YES we have a ticket quantity
197 197
                         $tckts_slctd = true;
198 198
                         //						d( $valid['ticket_obj'][$x] );
199
-                        if ($valid['ticket_obj'][ $x ] instanceof EE_Ticket) {
199
+                        if ($valid['ticket_obj'][$x] instanceof EE_Ticket) {
200 200
                             // then add ticket to cart
201 201
                             $tickets_added += $this->addTicketToCart(
202
-                                $valid['ticket_obj'][ $x ],
203
-                                $valid['qty'][ $x ]
202
+                                $valid['ticket_obj'][$x],
203
+                                $valid['qty'][$x]
204 204
                             );
205 205
                             if (EE_Error::has_error()) {
206 206
                                 break;
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
                     );
252 252
                     exit();
253 253
                 } else {
254
-                    if (! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) {
254
+                    if ( ! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) {
255 255
                         // nothing added to cart
256 256
                         EE_Error::add_attention(__('No tickets were added for the event', 'event_espresso'),
257 257
                             __FILE__, __FUNCTION__, __LINE__);
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
     private function validatePostData($id = 0)
298 298
     {
299 299
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
300
-        if (! $id) {
300
+        if ( ! $id) {
301 301
             EE_Error::add_error(
302 302
                 __('The event id provided was not valid.', 'event_espresso'),
303 303
                 __FILE__,
@@ -324,13 +324,13 @@  discard block
 block discarded – undo
324 324
         // cycle through $inputs_to_clean array
325 325
         foreach ($inputs_to_clean as $what => $input_to_clean) {
326 326
             // check for POST data
327
-            if (EE_Registry::instance()->REQ->is_set($input_to_clean . $id)) {
327
+            if (EE_Registry::instance()->REQ->is_set($input_to_clean.$id)) {
328 328
                 // grab value
329
-                $input_value = EE_Registry::instance()->REQ->get($input_to_clean . $id);
329
+                $input_value = EE_Registry::instance()->REQ->get($input_to_clean.$id);
330 330
                 switch ($what) {
331 331
                     // integers
332 332
                     case 'event_id':
333
-                        $valid_data[ $what ] = absint($input_value);
333
+                        $valid_data[$what] = absint($input_value);
334 334
                         // get event via the event id we put in the form
335 335
                         $valid_data['event'] = EE_Registry::instance()
336 336
                                                            ->load_model('Event')
@@ -338,17 +338,17 @@  discard block
 block discarded – undo
338 338
                         break;
339 339
                     case 'rows':
340 340
                     case 'max_atndz':
341
-                        $valid_data[ $what ] = absint($input_value);
341
+                        $valid_data[$what] = absint($input_value);
342 342
                         break;
343 343
                     // arrays of integers
344 344
                     case 'qty':
345 345
                         /** @var array $row_qty */
346 346
                         $row_qty = $input_value;
347 347
                         // if qty is coming from a radio button input, then we need to assemble an array of rows
348
-                        if (! is_array($row_qty)) {
348
+                        if ( ! is_array($row_qty)) {
349 349
                             // get number of rows
350
-                            $rows = EE_Registry::instance()->REQ->is_set('tkt-slctr-rows-' . $id)
351
-                                ? absint(EE_Registry::instance()->REQ->get('tkt-slctr-rows-' . $id))
350
+                            $rows = EE_Registry::instance()->REQ->is_set('tkt-slctr-rows-'.$id)
351
+                                ? absint(EE_Registry::instance()->REQ->get('tkt-slctr-rows-'.$id))
352 352
                                 : 1;
353 353
                             // explode ints by the dash
354 354
                             $row_qty = explode('-', $row_qty);
@@ -356,8 +356,8 @@  discard block
 block discarded – undo
356 356
                             $qty     = isset($row_qty[1]) ? absint($row_qty[1]) : 0;
357 357
                             $row_qty = array($row => $qty);
358 358
                             for ($x = 1; $x <= $rows; $x++) {
359
-                                if (! isset($row_qty[ $x ])) {
360
-                                    $row_qty[ $x ] = 0;
359
+                                if ( ! isset($row_qty[$x])) {
360
+                                    $row_qty[$x] = 0;
361 361
                                 }
362 362
                             }
363 363
                         }
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
                         foreach ($row_qty as $qty) {
367 367
                             $qty = absint($qty);
368 368
                             // sanitize as integers
369
-                            $valid_data[ $what ][]       = $qty;
369
+                            $valid_data[$what][] = $qty;
370 370
                             $valid_data['total_tickets'] += $qty;
371 371
                         }
372 372
                         break;
@@ -376,14 +376,14 @@  discard block
 block discarded – undo
376 376
                         // cycle thru values
377 377
                         foreach ((array) $input_value as $key => $value) {
378 378
                             // allow only numbers, letters,  spaces, commas and dashes
379
-                            $value_array[ $key ] = wp_strip_all_tags($value);
379
+                            $value_array[$key] = wp_strip_all_tags($value);
380 380
                             // get ticket via the ticket id we put in the form
381 381
                             $ticket_obj                       = EE_Registry::instance()
382 382
                                                                             ->load_model('Ticket')
383 383
                                                                             ->get_one_by_ID($value);
384
-                            $valid_data['ticket_obj'][ $key ] = $ticket_obj;
384
+                            $valid_data['ticket_obj'][$key] = $ticket_obj;
385 385
                         }
386
-                        $valid_data[ $what ] = $value_array;
386
+                        $valid_data[$what] = $value_array;
387 387
                         break;
388 388
                     case 'return_url' :
389 389
                         // grab and sanitize return-url
@@ -394,9 +394,9 @@  discard block
 block discarded – undo
394 394
                             $input_value = explode('#', $input_value);
395 395
                             $input_value = end($input_value);
396 396
                             // use event list url instead, but append anchor
397
-                            $input_value = EEH_Event_View::event_archive_url() . '#' . $input_value;
397
+                            $input_value = EEH_Event_View::event_archive_url().'#'.$input_value;
398 398
                         }
399
-                        $valid_data[ $what ] = $input_value;
399
+                        $valid_data[$what] = $input_value;
400 400
                         break;
401 401
                 }    // end switch $what
402 402
             }
@@ -526,24 +526,24 @@  discard block
 block discarded – undo
526 526
     private function ticketDatetimeAvailability(EE_Ticket $ticket, $get_original_ticket_spaces = false)
527 527
     {
528 528
         // if the $_available_spaces array has not been set up yet...
529
-        if (! isset(self::$_available_spaces['tickets'][ $ticket->ID() ])) {
529
+        if ( ! isset(self::$_available_spaces['tickets'][$ticket->ID()])) {
530 530
             $this->setInitialTicketDatetimeAvailability($ticket);
531 531
         }
532 532
         $available_spaces = $ticket->qty() - $ticket->sold();
533
-        if (isset(self::$_available_spaces['tickets'][ $ticket->ID() ])) {
533
+        if (isset(self::$_available_spaces['tickets'][$ticket->ID()])) {
534 534
             // loop thru tickets, which will ALSO include individual ticket records AND a total
535
-            foreach (self::$_available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces) {
535
+            foreach (self::$_available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) {
536 536
                 // if we want the original datetime availability BEFORE we started subtracting tickets ?
537 537
                 if ($get_original_ticket_spaces) {
538 538
                     // then grab the available spaces from the "tickets" array
539 539
                     // and compare with the above to get the lowest number
540 540
                     $available_spaces = min(
541 541
                         $available_spaces,
542
-                        self::$_available_spaces['tickets'][ $ticket->ID() ][ $DTD_ID ]
542
+                        self::$_available_spaces['tickets'][$ticket->ID()][$DTD_ID]
543 543
                     );
544 544
                 } else {
545 545
                     // we want the updated ticket availability as stored in the "datetimes" array
546
-                    $available_spaces = min($available_spaces, self::$_available_spaces['datetimes'][ $DTD_ID ]);
546
+                    $available_spaces = min($available_spaces, self::$_available_spaces['datetimes'][$DTD_ID]);
547 547
                 }
548 548
             }
549 549
         }
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
                 'order_by' => array('DTT_EVT_start' => 'ASC'),
575 575
             )
576 576
         );
577
-        if (! empty($datetimes)) {
577
+        if ( ! empty($datetimes)) {
578 578
             // now loop thru all of the datetimes
579 579
             foreach ($datetimes as $datetime) {
580 580
                 if ($datetime instanceof EE_Datetime) {
@@ -582,17 +582,17 @@  discard block
 block discarded – undo
582 582
                     $spaces_remaining = $datetime->spaces_remaining();
583 583
                     // save the total available spaces ( the lesser of the ticket qty minus the number of tickets sold
584 584
                     // or the datetime spaces remaining) to this ticket using the datetime ID as the key
585
-                    self::$_available_spaces['tickets'][ $ticket->ID() ][ $datetime->ID() ] = min(
585
+                    self::$_available_spaces['tickets'][$ticket->ID()][$datetime->ID()] = min(
586 586
                         $ticket->qty() - $ticket->sold(),
587 587
                         $spaces_remaining
588 588
                     );
589 589
                     // if the remaining spaces for this datetime is already set,
590 590
                     // then compare that against the datetime spaces remaining, and take the lowest number,
591 591
                     // else just take the datetime spaces remaining, and assign to the datetimes array
592
-                    self::$_available_spaces['datetimes'][ $datetime->ID() ] = isset(
593
-                        self::$_available_spaces['datetimes'][ $datetime->ID() ]
592
+                    self::$_available_spaces['datetimes'][$datetime->ID()] = isset(
593
+                        self::$_available_spaces['datetimes'][$datetime->ID()]
594 594
                     )
595
-                        ? min(self::$_available_spaces['datetimes'][ $datetime->ID() ], $spaces_remaining)
595
+                        ? min(self::$_available_spaces['datetimes'][$datetime->ID()], $spaces_remaining)
596 596
                         : $spaces_remaining;
597 597
                 }
598 598
             }
@@ -608,11 +608,11 @@  discard block
 block discarded – undo
608 608
      */
609 609
     private function recalculateTicketDatetimeAvailability(EE_Ticket $ticket, $qty = 0)
610 610
     {
611
-        if (isset(self::$_available_spaces['tickets'][ $ticket->ID() ])) {
611
+        if (isset(self::$_available_spaces['tickets'][$ticket->ID()])) {
612 612
             // loop thru tickets, which will ALSO include individual ticket records AND a total
613
-            foreach (self::$_available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces) {
613
+            foreach (self::$_available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) {
614 614
                 // subtract the qty of selected tickets from each datetime's available spaces this ticket has access to,
615
-                self::$_available_spaces['datetimes'][ $DTD_ID ] -= $qty;
615
+                self::$_available_spaces['datetimes'][$DTD_ID] -= $qty;
616 616
             }
617 617
         }
618 618
     }
Please login to merge, or discard this patch.
core/EE_Config.core.php 2 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
      * @param    string         $name
534 534
      * @param    string         $config_class
535 535
      * @param    EE_Config_Base $config_obj
536
-     * @param    array          $tests_to_run
536
+     * @param    integer[]          $tests_to_run
537 537
      * @param    bool           $display_errors
538 538
      * @return    bool    TRUE on success, FALSE on fail
539 539
      */
@@ -797,7 +797,7 @@  discard block
 block discarded – undo
797 797
      * @access    public
798 798
      * @param    string                $section
799 799
      * @param    string                $name
800
-     * @param    EE_Config_Base|string $config_obj
800
+     * @param    EE_Config_Base $config_obj
801 801
      * @param    bool                  $throw_errors
802 802
      * @return    bool
803 803
      */
@@ -1764,7 +1764,7 @@  discard block
 block discarded – undo
1764 1764
 
1765 1765
 
1766 1766
     /**
1767
-     * @return array
1767
+     * @return integer[]
1768 1768
      */
1769 1769
     public function get_critical_pages_array()
1770 1770
     {
@@ -1779,7 +1779,7 @@  discard block
 block discarded – undo
1779 1779
 
1780 1780
 
1781 1781
     /**
1782
-     * @return array
1782
+     * @return string[]
1783 1783
      */
1784 1784
     public function get_critical_pages_shortcodes_array()
1785 1785
     {
@@ -3122,7 +3122,7 @@  discard block
 block discarded – undo
3122 3122
      * according to max_input_vars
3123 3123
      *
3124 3124
      * @param int   $input_count the count of input vars.
3125
-     * @return array {
3125
+     * @return string {
3126 3126
      *                           An array that represents whether available space and if no available space the error
3127 3127
      *                           message.
3128 3128
      * @type bool   $has_space   whether more inputs can be added.
Please login to merge, or discard this patch.
Indentation   +3060 added lines, -3060 removed lines patch added patch discarded remove patch
@@ -17,2442 +17,2442 @@  discard block
 block discarded – undo
17 17
 final class EE_Config implements ResettableInterface
18 18
 {
19 19
 
20
-    const OPTION_NAME        = 'ee_config';
20
+	const OPTION_NAME        = 'ee_config';
21
+
22
+	const LOG_NAME           = 'ee_config_log';
23
+
24
+	const LOG_LENGTH         = 100;
25
+
26
+	const ADDON_OPTION_NAMES = 'ee_config_option_names';
27
+
28
+
29
+	/**
30
+	 *    instance of the EE_Config object
31
+	 *
32
+	 * @var    EE_Config $_instance
33
+	 * @access    private
34
+	 */
35
+	private static $_instance;
36
+
37
+	/**
38
+	 * @var boolean $_logging_enabled
39
+	 */
40
+	private static $_logging_enabled = false;
41
+
42
+	/**
43
+	 * @var LegacyShortcodesManager $legacy_shortcodes_manager
44
+	 */
45
+	private $legacy_shortcodes_manager;
46
+
47
+	/**
48
+	 * An StdClass whose property names are addon slugs,
49
+	 * and values are their config classes
50
+	 *
51
+	 * @var StdClass
52
+	 */
53
+	public $addons;
54
+
55
+	/**
56
+	 * @var EE_Admin_Config
57
+	 */
58
+	public $admin;
59
+
60
+	/**
61
+	 * @var EE_Core_Config
62
+	 */
63
+	public $core;
64
+
65
+	/**
66
+	 * @var EE_Currency_Config
67
+	 */
68
+	public $currency;
69
+
70
+	/**
71
+	 * @var EE_Organization_Config
72
+	 */
73
+	public $organization;
74
+
75
+	/**
76
+	 * @var EE_Registration_Config
77
+	 */
78
+	public $registration;
79
+
80
+	/**
81
+	 * @var EE_Template_Config
82
+	 */
83
+	public $template_settings;
84
+
85
+	/**
86
+	 * Holds EE environment values.
87
+	 *
88
+	 * @var EE_Environment_Config
89
+	 */
90
+	public $environment;
91
+
92
+	/**
93
+	 * settings pertaining to Google maps
94
+	 *
95
+	 * @var EE_Map_Config
96
+	 */
97
+	public $map_settings;
98
+
99
+	/**
100
+	 * settings pertaining to Taxes
101
+	 *
102
+	 * @var EE_Tax_Config
103
+	 */
104
+	public $tax_settings;
105
+
106
+
107
+	/**
108
+	 * Settings pertaining to global messages settings.
109
+	 *
110
+	 * @var EE_Messages_Config
111
+	 */
112
+	public $messages;
113
+
114
+	/**
115
+	 * @deprecated
116
+	 * @var EE_Gateway_Config
117
+	 */
118
+	public $gateway;
119
+
120
+	/**
121
+	 * @var    array $_addon_option_names
122
+	 * @access    private
123
+	 */
124
+	private $_addon_option_names = array();
125
+
126
+	/**
127
+	 * @var    array $_module_route_map
128
+	 * @access    private
129
+	 */
130
+	private static $_module_route_map = array();
131
+
132
+	/**
133
+	 * @var    array $_module_forward_map
134
+	 * @access    private
135
+	 */
136
+	private static $_module_forward_map = array();
137
+
138
+	/**
139
+	 * @var    array $_module_view_map
140
+	 * @access    private
141
+	 */
142
+	private static $_module_view_map = array();
143
+
144
+
145
+
146
+	/**
147
+	 * @singleton method used to instantiate class object
148
+	 * @access    public
149
+	 * @return EE_Config instance
150
+	 */
151
+	public static function instance()
152
+	{
153
+		// check if class object is instantiated, and instantiated properly
154
+		if (! self::$_instance instanceof EE_Config) {
155
+			self::$_instance = new self();
156
+		}
157
+		return self::$_instance;
158
+	}
159
+
160
+
161
+
162
+	/**
163
+	 * Resets the config
164
+	 *
165
+	 * @param bool    $hard_reset    if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE
166
+	 *                               (default) leaves the database alone, and merely resets the EE_Config object to
167
+	 *                               reflect its state in the database
168
+	 * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave
169
+	 *                               $_instance as NULL. Useful in case you want to forget about the old instance on
170
+	 *                               EE_Config, but might not be ready to instantiate EE_Config currently (eg if the
171
+	 *                               site was put into maintenance mode)
172
+	 * @return EE_Config
173
+	 */
174
+	public static function reset($hard_reset = false, $reinstantiate = true)
175
+	{
176
+		if (self::$_instance instanceof EE_Config) {
177
+			if ($hard_reset) {
178
+				self::$_instance->legacy_shortcodes_manager = null;
179
+				self::$_instance->_addon_option_names = array();
180
+				self::$_instance->_initialize_config();
181
+				self::$_instance->update_espresso_config();
182
+			}
183
+			self::$_instance->update_addon_option_names();
184
+		}
185
+		self::$_instance = null;
186
+		//we don't need to reset the static properties imo because those should
187
+		//only change when a module is added or removed. Currently we don't
188
+		//support removing a module during a request when it previously existed
189
+		if ($reinstantiate) {
190
+			return self::instance();
191
+		} else {
192
+			return null;
193
+		}
194
+	}
195
+
196
+
197
+
198
+	/**
199
+	 *    class constructor
200
+	 *
201
+	 * @access    private
202
+	 */
203
+	private function __construct()
204
+	{
205
+		do_action('AHEE__EE_Config__construct__begin', $this);
206
+		EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false);
207
+		// setup empty config classes
208
+		$this->_initialize_config();
209
+		// load existing EE site settings
210
+		$this->_load_core_config();
211
+		// confirm everything loaded correctly and set filtered defaults if not
212
+		$this->_verify_config();
213
+		//  register shortcodes and modules
214
+		add_action(
215
+			'AHEE__EE_System__register_shortcodes_modules_and_widgets',
216
+			array($this, 'register_shortcodes_and_modules'),
217
+			999
218
+		);
219
+		//  initialize shortcodes and modules
220
+		add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules'));
221
+		// register widgets
222
+		add_action('widgets_init', array($this, 'widgets_init'), 10);
223
+		// shutdown
224
+		add_action('shutdown', array($this, 'shutdown'), 10);
225
+		// construct__end hook
226
+		do_action('AHEE__EE_Config__construct__end', $this);
227
+		// hardcoded hack
228
+		$this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014';
229
+	}
230
+
231
+
232
+
233
+	/**
234
+	 * @return boolean
235
+	 */
236
+	public static function logging_enabled()
237
+	{
238
+		return self::$_logging_enabled;
239
+	}
240
+
241
+
242
+
243
+	/**
244
+	 * use to get the current theme if needed from static context
245
+	 *
246
+	 * @return string current theme set.
247
+	 */
248
+	public static function get_current_theme()
249
+	{
250
+		return isset(self::$_instance->template_settings->current_espresso_theme)
251
+			? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014';
252
+	}
253
+
254
+
255
+
256
+	/**
257
+	 *        _initialize_config
258
+	 *
259
+	 * @access private
260
+	 * @return void
261
+	 */
262
+	private function _initialize_config()
263
+	{
264
+		EE_Config::trim_log();
265
+		//set defaults
266
+		$this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array());
267
+		$this->addons = new stdClass();
268
+		// set _module_route_map
269
+		EE_Config::$_module_route_map = array();
270
+		// set _module_forward_map
271
+		EE_Config::$_module_forward_map = array();
272
+		// set _module_view_map
273
+		EE_Config::$_module_view_map = array();
274
+	}
275
+
276
+
277
+
278
+	/**
279
+	 *        load core plugin configuration
280
+	 *
281
+	 * @access private
282
+	 * @return void
283
+	 */
284
+	private function _load_core_config()
285
+	{
286
+		// load_core_config__start hook
287
+		do_action('AHEE__EE_Config___load_core_config__start', $this);
288
+		$espresso_config = $this->get_espresso_config();
289
+		foreach ($espresso_config as $config => $settings) {
290
+			// load_core_config__start hook
291
+			$settings = apply_filters(
292
+				'FHEE__EE_Config___load_core_config__config_settings',
293
+				$settings,
294
+				$config,
295
+				$this
296
+			);
297
+			if (is_object($settings) && property_exists($this, $config)) {
298
+				$this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
299
+				//call configs populate method to ensure any defaults are set for empty values.
300
+				if (method_exists($settings, 'populate')) {
301
+					$this->{$config}->populate();
302
+				}
303
+				if (method_exists($settings, 'do_hooks')) {
304
+					$this->{$config}->do_hooks();
305
+				}
306
+			}
307
+		}
308
+		if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) {
309
+			$this->update_espresso_config();
310
+		}
311
+		// load_core_config__end hook
312
+		do_action('AHEE__EE_Config___load_core_config__end', $this);
313
+	}
314
+
315
+
316
+
317
+	/**
318
+	 *    _verify_config
319
+	 *
320
+	 * @access    protected
321
+	 * @return    void
322
+	 */
323
+	protected function _verify_config()
324
+	{
325
+		$this->core = $this->core instanceof EE_Core_Config
326
+			? $this->core
327
+			: new EE_Core_Config();
328
+		$this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core);
329
+		$this->organization = $this->organization instanceof EE_Organization_Config
330
+			? $this->organization
331
+			: new EE_Organization_Config();
332
+		$this->organization = apply_filters(
333
+			'FHEE__EE_Config___initialize_config__organization',
334
+			$this->organization
335
+		);
336
+		$this->currency = $this->currency instanceof EE_Currency_Config
337
+			? $this->currency
338
+			: new EE_Currency_Config();
339
+		$this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency);
340
+		$this->registration = $this->registration instanceof EE_Registration_Config
341
+			? $this->registration
342
+			: new EE_Registration_Config();
343
+		$this->registration = apply_filters(
344
+			'FHEE__EE_Config___initialize_config__registration',
345
+			$this->registration
346
+		);
347
+		$this->admin = $this->admin instanceof EE_Admin_Config
348
+			? $this->admin
349
+			: new EE_Admin_Config();
350
+		$this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin);
351
+		$this->template_settings = $this->template_settings instanceof EE_Template_Config
352
+			? $this->template_settings
353
+			: new EE_Template_Config();
354
+		$this->template_settings = apply_filters(
355
+			'FHEE__EE_Config___initialize_config__template_settings',
356
+			$this->template_settings
357
+		);
358
+		$this->map_settings = $this->map_settings instanceof EE_Map_Config
359
+			? $this->map_settings
360
+			: new EE_Map_Config();
361
+		$this->map_settings = apply_filters('FHEE__EE_Config___initialize_config__map_settings',
362
+			$this->map_settings);
363
+		$this->environment = $this->environment instanceof EE_Environment_Config
364
+			? $this->environment
365
+			: new EE_Environment_Config();
366
+		$this->environment = apply_filters('FHEE__EE_Config___initialize_config__environment',
367
+			$this->environment);
368
+		$this->tax_settings = $this->tax_settings instanceof EE_Tax_Config
369
+			? $this->tax_settings
370
+			: new EE_Tax_Config();
371
+		$this->tax_settings = apply_filters('FHEE__EE_Config___initialize_config__tax_settings',
372
+			$this->tax_settings);
373
+		$this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages);
374
+		$this->messages = $this->messages instanceof EE_Messages_Config
375
+			? $this->messages
376
+			: new EE_Messages_Config();
377
+		$this->gateway = $this->gateway instanceof EE_Gateway_Config
378
+			? $this->gateway
379
+			: new EE_Gateway_Config();
380
+		$this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway);
381
+		$this->legacy_shortcodes_manager = null;
382
+	}
383
+
384
+
385
+	/**
386
+	 *    get_espresso_config
387
+	 *
388
+	 * @access    public
389
+	 * @return    array of espresso config stuff
390
+	 */
391
+	public function get_espresso_config()
392
+	{
393
+		// grab espresso configuration
394
+		return apply_filters(
395
+			'FHEE__EE_Config__get_espresso_config__CFG',
396
+			get_option(EE_Config::OPTION_NAME, array())
397
+		);
398
+	}
399
+
400
+
401
+
402
+	/**
403
+	 *    double_check_config_comparison
404
+	 *
405
+	 * @access    public
406
+	 * @param string $option
407
+	 * @param        $old_value
408
+	 * @param        $value
409
+	 */
410
+	public function double_check_config_comparison($option = '', $old_value, $value)
411
+	{
412
+		// make sure we're checking the ee config
413
+		if ($option === EE_Config::OPTION_NAME) {
414
+			// run a loose comparison of the old value against the new value for type and properties,
415
+			// but NOT exact instance like WP update_option does (ie: NOT type safe comparison)
416
+			if ($value != $old_value) {
417
+				// if they are NOT the same, then remove the hook,
418
+				// which means the subsequent update results will be based solely on the update query results
419
+				// the reason we do this is because, as stated above,
420
+				// WP update_option performs an exact instance comparison (===) on any update values passed to it
421
+				// this happens PRIOR to serialization and any subsequent update.
422
+				// If values are found to match their previous old value,
423
+				// then WP bails before performing any update.
424
+				// Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version
425
+				// it just pulled from the db, with the one being passed to it (which will not match).
426
+				// HOWEVER, once the object is serialized and passed off to MySQL to update,
427
+				// MySQL MAY ALSO NOT perform the update because
428
+				// the string it sees in the db looks the same as the new one it has been passed!!!
429
+				// This results in the query returning an "affected rows" value of ZERO,
430
+				// which gets returned immediately by WP update_option and looks like an error.
431
+				remove_action('update_option', array($this, 'check_config_updated'));
432
+			}
433
+		}
434
+	}
435
+
436
+
437
+
438
+	/**
439
+	 *    update_espresso_config
440
+	 *
441
+	 * @access   public
442
+	 */
443
+	protected function _reset_espresso_addon_config()
444
+	{
445
+		$this->_addon_option_names = array();
446
+		foreach ($this->addons as $addon_name => $addon_config_obj) {
447
+			$addon_config_obj = maybe_unserialize($addon_config_obj);
448
+			if ($addon_config_obj instanceof EE_Config_Base) {
449
+				$this->update_config('addons', $addon_name, $addon_config_obj, false);
450
+			}
451
+			$this->addons->{$addon_name} = null;
452
+		}
453
+	}
454
+
455
+
456
+
457
+	/**
458
+	 *    update_espresso_config
459
+	 *
460
+	 * @access   public
461
+	 * @param   bool $add_success
462
+	 * @param   bool $add_error
463
+	 * @return   bool
464
+	 */
465
+	public function update_espresso_config($add_success = false, $add_error = true)
466
+	{
467
+		// don't allow config updates during WP heartbeats
468
+		if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
469
+			return false;
470
+		}
471
+		// commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
472
+		//$clone = clone( self::$_instance );
473
+		//self::$_instance = NULL;
474
+		do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
475
+		$this->_reset_espresso_addon_config();
476
+		// hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
477
+		// but BEFORE the actual update occurs
478
+		add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
479
+		// don't want to persist legacy_shortcodes_manager, but don't want to lose it either
480
+		$legacy_shortcodes_manager = $this->legacy_shortcodes_manager;
481
+		$this->legacy_shortcodes_manager = null;
482
+		// now update "ee_config"
483
+		$saved = update_option(EE_Config::OPTION_NAME, $this);
484
+		$this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
485
+		EE_Config::log(EE_Config::OPTION_NAME);
486
+		// if not saved... check if the hook we just added still exists;
487
+		// if it does, it means one of two things:
488
+		// 		that update_option bailed at the ( $value === $old_value ) conditional,
489
+		//		 or...
490
+		// 		the db update query returned 0 rows affected
491
+		// 		(probably because the data  value was the same from it's perspective)
492
+		// so the existence of the hook means that a negative result from update_option is NOT an error,
493
+		// but just means no update occurred, so don't display an error to the user.
494
+		// BUT... if update_option returns FALSE, AND the hook is missing,
495
+		// then it means that something truly went wrong
496
+		$saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
497
+		// remove our action since we don't want it in the system anymore
498
+		remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
499
+		do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
500
+		//self::$_instance = $clone;
501
+		//unset( $clone );
502
+		// if config remains the same or was updated successfully
503
+		if ($saved) {
504
+			if ($add_success) {
505
+				EE_Error::add_success(
506
+					__('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
507
+					__FILE__,
508
+					__FUNCTION__,
509
+					__LINE__
510
+				);
511
+			}
512
+			return true;
513
+		} else {
514
+			if ($add_error) {
515
+				EE_Error::add_error(
516
+					__('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
517
+					__FILE__,
518
+					__FUNCTION__,
519
+					__LINE__
520
+				);
521
+			}
522
+			return false;
523
+		}
524
+	}
525
+
526
+
527
+
528
+	/**
529
+	 *    _verify_config_params
530
+	 *
531
+	 * @access    private
532
+	 * @param    string         $section
533
+	 * @param    string         $name
534
+	 * @param    string         $config_class
535
+	 * @param    EE_Config_Base $config_obj
536
+	 * @param    array          $tests_to_run
537
+	 * @param    bool           $display_errors
538
+	 * @return    bool    TRUE on success, FALSE on fail
539
+	 */
540
+	private function _verify_config_params(
541
+		$section = '',
542
+		$name = '',
543
+		$config_class = '',
544
+		$config_obj = null,
545
+		$tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
546
+		$display_errors = true
547
+	) {
548
+		try {
549
+			foreach ($tests_to_run as $test) {
550
+				switch ($test) {
551
+					// TEST #1 : check that section was set
552
+					case 1 :
553
+						if (empty($section)) {
554
+							if ($display_errors) {
555
+								throw new EE_Error(
556
+									sprintf(
557
+										__(
558
+											'No configuration section has been provided while attempting to save "%s".',
559
+											'event_espresso'
560
+										),
561
+										$config_class
562
+									)
563
+								);
564
+							}
565
+							return false;
566
+						}
567
+						break;
568
+					// TEST #2 : check that settings section exists
569
+					case 2 :
570
+						if (! isset($this->{$section})) {
571
+							if ($display_errors) {
572
+								throw new EE_Error(
573
+									sprintf(
574
+										__('The "%s" configuration section does not exist.', 'event_espresso'),
575
+										$section
576
+									)
577
+								);
578
+							}
579
+							return false;
580
+						}
581
+						break;
582
+					// TEST #3 : check that section is the proper format
583
+					case 3 :
584
+						if (
585
+						! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
586
+						) {
587
+							if ($display_errors) {
588
+								throw new EE_Error(
589
+									sprintf(
590
+										__(
591
+											'The "%s" configuration settings have not been formatted correctly.',
592
+											'event_espresso'
593
+										),
594
+										$section
595
+									)
596
+								);
597
+							}
598
+							return false;
599
+						}
600
+						break;
601
+					// TEST #4 : check that config section name has been set
602
+					case 4 :
603
+						if (empty($name)) {
604
+							if ($display_errors) {
605
+								throw new EE_Error(
606
+									__(
607
+										'No name has been provided for the specific configuration section.',
608
+										'event_espresso'
609
+									)
610
+								);
611
+							}
612
+							return false;
613
+						}
614
+						break;
615
+					// TEST #5 : check that a config class name has been set
616
+					case 5 :
617
+						if (empty($config_class)) {
618
+							if ($display_errors) {
619
+								throw new EE_Error(
620
+									__(
621
+										'No class name has been provided for the specific configuration section.',
622
+										'event_espresso'
623
+									)
624
+								);
625
+							}
626
+							return false;
627
+						}
628
+						break;
629
+					// TEST #6 : verify config class is accessible
630
+					case 6 :
631
+						if (! class_exists($config_class)) {
632
+							if ($display_errors) {
633
+								throw new EE_Error(
634
+									sprintf(
635
+										__(
636
+											'The "%s" class does not exist. Please ensure that an autoloader has been set for it.',
637
+											'event_espresso'
638
+										),
639
+										$config_class
640
+									)
641
+								);
642
+							}
643
+							return false;
644
+						}
645
+						break;
646
+					// TEST #7 : check that config has even been set
647
+					case 7 :
648
+						if (! isset($this->{$section}->{$name})) {
649
+							if ($display_errors) {
650
+								throw new EE_Error(
651
+									sprintf(
652
+										__('No configuration has been set for "%1$s->%2$s".', 'event_espresso'),
653
+										$section,
654
+										$name
655
+									)
656
+								);
657
+							}
658
+							return false;
659
+						} else {
660
+							// and make sure it's not serialized
661
+							$this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name});
662
+						}
663
+						break;
664
+					// TEST #8 : check that config is the requested type
665
+					case 8 :
666
+						if (! $this->{$section}->{$name} instanceof $config_class) {
667
+							if ($display_errors) {
668
+								throw new EE_Error(
669
+									sprintf(
670
+										__(
671
+											'The configuration for "%1$s->%2$s" is not of the "%3$s" class.',
672
+											'event_espresso'
673
+										),
674
+										$section,
675
+										$name,
676
+										$config_class
677
+									)
678
+								);
679
+							}
680
+							return false;
681
+						}
682
+						break;
683
+					// TEST #9 : verify config object
684
+					case 9 :
685
+						if (! $config_obj instanceof EE_Config_Base) {
686
+							if ($display_errors) {
687
+								throw new EE_Error(
688
+									sprintf(
689
+										__('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'),
690
+										print_r($config_obj, true)
691
+									)
692
+								);
693
+							}
694
+							return false;
695
+						}
696
+						break;
697
+				}
698
+			}
699
+		} catch (EE_Error $e) {
700
+			$e->get_error();
701
+		}
702
+		// you have successfully run the gauntlet
703
+		return true;
704
+	}
705
+
706
+
707
+
708
+	/**
709
+	 *    _generate_config_option_name
710
+	 *
711
+	 * @access        protected
712
+	 * @param        string $section
713
+	 * @param        string $name
714
+	 * @return        string
715
+	 */
716
+	private function _generate_config_option_name($section = '', $name = '')
717
+	{
718
+		return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
719
+	}
720
+
721
+
722
+
723
+	/**
724
+	 *    _set_config_class
725
+	 * ensures that a config class is set, either from a passed config class or one generated from the config name
726
+	 *
727
+	 * @access    private
728
+	 * @param    string $config_class
729
+	 * @param    string $name
730
+	 * @return    string
731
+	 */
732
+	private function _set_config_class($config_class = '', $name = '')
733
+	{
734
+		return ! empty($config_class)
735
+			? $config_class
736
+			: str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
737
+	}
738
+
739
+
740
+
741
+	/**
742
+	 *    set_config
743
+	 *
744
+	 * @access    protected
745
+	 * @param    string         $section
746
+	 * @param    string         $name
747
+	 * @param    string         $config_class
748
+	 * @param    EE_Config_Base $config_obj
749
+	 * @return    EE_Config_Base
750
+	 */
751
+	public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null)
752
+	{
753
+		// ensure config class is set to something
754
+		$config_class = $this->_set_config_class($config_class, $name);
755
+		// run tests 1-4, 6, and 7 to verify all config params are set and valid
756
+		if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
757
+			return null;
758
+		}
759
+		$config_option_name = $this->_generate_config_option_name($section, $name);
760
+		// if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
761
+		if (! isset($this->_addon_option_names[$config_option_name])) {
762
+			$this->_addon_option_names[$config_option_name] = $config_class;
763
+			$this->update_addon_option_names();
764
+		}
765
+		// verify the incoming config object but suppress errors
766
+		if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
767
+			$config_obj = new $config_class();
768
+		}
769
+		if (get_option($config_option_name)) {
770
+			EE_Config::log($config_option_name);
771
+			update_option($config_option_name, $config_obj);
772
+			$this->{$section}->{$name} = $config_obj;
773
+			return $this->{$section}->{$name};
774
+		} else {
775
+			// create a wp-option for this config
776
+			if (add_option($config_option_name, $config_obj, '', 'no')) {
777
+				$this->{$section}->{$name} = maybe_unserialize($config_obj);
778
+				return $this->{$section}->{$name};
779
+			} else {
780
+				EE_Error::add_error(
781
+					sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class),
782
+					__FILE__,
783
+					__FUNCTION__,
784
+					__LINE__
785
+				);
786
+				return null;
787
+			}
788
+		}
789
+	}
790
+
791
+
792
+
793
+	/**
794
+	 *    update_config
795
+	 * Important: the config object must ALREADY be set, otherwise this will produce an error.
796
+	 *
797
+	 * @access    public
798
+	 * @param    string                $section
799
+	 * @param    string                $name
800
+	 * @param    EE_Config_Base|string $config_obj
801
+	 * @param    bool                  $throw_errors
802
+	 * @return    bool
803
+	 */
804
+	public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true)
805
+	{
806
+		// don't allow config updates during WP heartbeats
807
+		if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
808
+			return false;
809
+		}
810
+		$config_obj = maybe_unserialize($config_obj);
811
+		// get class name of the incoming object
812
+		$config_class = get_class($config_obj);
813
+		// run tests 1-5 and 9 to verify config
814
+		if (! $this->_verify_config_params(
815
+			$section,
816
+			$name,
817
+			$config_class,
818
+			$config_obj,
819
+			array(1, 2, 3, 4, 7, 9)
820
+		)
821
+		) {
822
+			return false;
823
+		}
824
+		$config_option_name = $this->_generate_config_option_name($section, $name);
825
+		// check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
826
+		if (! isset($this->_addon_option_names[$config_option_name])) {
827
+			// save new config to db
828
+			if ($this->set_config($section, $name, $config_class, $config_obj)) {
829
+				return true;
830
+			}
831
+		} else {
832
+			// first check if the record already exists
833
+			$existing_config = get_option($config_option_name);
834
+			$config_obj = serialize($config_obj);
835
+			// just return if db record is already up to date (NOT type safe comparison)
836
+			if ($existing_config == $config_obj) {
837
+				$this->{$section}->{$name} = $config_obj;
838
+				return true;
839
+			} else if (update_option($config_option_name, $config_obj)) {
840
+				EE_Config::log($config_option_name);
841
+				// update wp-option for this config class
842
+				$this->{$section}->{$name} = $config_obj;
843
+				return true;
844
+			} elseif ($throw_errors) {
845
+				EE_Error::add_error(
846
+					sprintf(
847
+						__(
848
+							'The "%1$s" object stored at"%2$s" was not successfully updated in the database.',
849
+							'event_espresso'
850
+						),
851
+						$config_class,
852
+						'EE_Config->' . $section . '->' . $name
853
+					),
854
+					__FILE__,
855
+					__FUNCTION__,
856
+					__LINE__
857
+				);
858
+			}
859
+		}
860
+		return false;
861
+	}
862
+
863
+
864
+
865
+	/**
866
+	 *    get_config
867
+	 *
868
+	 * @access    public
869
+	 * @param    string $section
870
+	 * @param    string $name
871
+	 * @param    string $config_class
872
+	 * @return    mixed EE_Config_Base | NULL
873
+	 */
874
+	public function get_config($section = '', $name = '', $config_class = '')
875
+	{
876
+		// ensure config class is set to something
877
+		$config_class = $this->_set_config_class($config_class, $name);
878
+		// run tests 1-4, 6 and 7 to verify that all params have been set
879
+		if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
880
+			return null;
881
+		}
882
+		// now test if the requested config object exists, but suppress errors
883
+		if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) {
884
+			// config already exists, so pass it back
885
+			return $this->{$section}->{$name};
886
+		}
887
+		// load config option from db if it exists
888
+		$config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
889
+		// verify the newly retrieved config object, but suppress errors
890
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
891
+			// config is good, so set it and pass it back
892
+			$this->{$section}->{$name} = $config_obj;
893
+			return $this->{$section}->{$name};
894
+		}
895
+		// oops! $config_obj is not already set and does not exist in the db, so create a new one
896
+		$config_obj = $this->set_config($section, $name, $config_class);
897
+		// verify the newly created config object
898
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
899
+			return $this->{$section}->{$name};
900
+		} else {
901
+			EE_Error::add_error(
902
+				sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
903
+				__FILE__,
904
+				__FUNCTION__,
905
+				__LINE__
906
+			);
907
+		}
908
+		return null;
909
+	}
910
+
911
+
912
+
913
+	/**
914
+	 *    get_config_option
915
+	 *
916
+	 * @access    public
917
+	 * @param    string $config_option_name
918
+	 * @return    mixed EE_Config_Base | FALSE
919
+	 */
920
+	public function get_config_option($config_option_name = '')
921
+	{
922
+		// retrieve the wp-option for this config class.
923
+		$config_option = maybe_unserialize(get_option($config_option_name, array()));
924
+		if (empty($config_option)) {
925
+			EE_Config::log($config_option_name . '-NOT-FOUND');
926
+		}
927
+		return $config_option;
928
+	}
929
+
930
+
931
+
932
+	/**
933
+	 * log
934
+	 *
935
+	 * @param string $config_option_name
936
+	 */
937
+	public static function log($config_option_name = '')
938
+	{
939
+		if (EE_Config::logging_enabled() && ! empty($config_option_name)) {
940
+			$config_log = get_option(EE_Config::LOG_NAME, array());
941
+			//copy incoming $_REQUEST and sanitize it so we can save it
942
+			$_request = $_REQUEST;
943
+			array_walk_recursive($_request, 'sanitize_text_field');
944
+			$config_log[(string)microtime(true)] = array(
945
+				'config_name' => $config_option_name,
946
+				'request'     => $_request,
947
+			);
948
+			update_option(EE_Config::LOG_NAME, $config_log);
949
+		}
950
+	}
951
+
952
+
953
+
954
+	/**
955
+	 * trim_log
956
+	 * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH
957
+	 */
958
+	public static function trim_log()
959
+	{
960
+		if (! EE_Config::logging_enabled()) {
961
+			return;
962
+		}
963
+		$config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
964
+		$log_length = count($config_log);
965
+		if ($log_length > EE_Config::LOG_LENGTH) {
966
+			ksort($config_log);
967
+			$config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true);
968
+			update_option(EE_Config::LOG_NAME, $config_log);
969
+		}
970
+	}
971
+
972
+
973
+
974
+	/**
975
+	 *    get_page_for_posts
976
+	 *    if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the
977
+	 *    wp-option "page_for_posts", or "posts" if no page is selected
978
+	 *
979
+	 * @access    public
980
+	 * @return    string
981
+	 */
982
+	public static function get_page_for_posts()
983
+	{
984
+		$page_for_posts = get_option('page_for_posts');
985
+		if (! $page_for_posts) {
986
+			return 'posts';
987
+		}
988
+		/** @type WPDB $wpdb */
989
+		global $wpdb;
990
+		$SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
991
+		return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
992
+	}
993
+
994
+
995
+
996
+	/**
997
+	 *    register_shortcodes_and_modules.
998
+	 *    At this point, it's too early to tell if we're maintenance mode or not.
999
+	 *    In fact, this is where we give modules a chance to let core know they exist
1000
+	 *    so they can help trigger maintenance mode if it's needed
1001
+	 *
1002
+	 * @access    public
1003
+	 * @return    void
1004
+	 */
1005
+	public function register_shortcodes_and_modules()
1006
+	{
1007
+		// allow modules to set hooks for the rest of the system
1008
+		EE_Registry::instance()->modules = $this->_register_modules();
1009
+	}
1010
+
1011
+
1012
+
1013
+	/**
1014
+	 *    initialize_shortcodes_and_modules
1015
+	 *    meaning they can start adding their hooks to get stuff done
1016
+	 *
1017
+	 * @access    public
1018
+	 * @return    void
1019
+	 */
1020
+	public function initialize_shortcodes_and_modules()
1021
+	{
1022
+		// allow modules to set hooks for the rest of the system
1023
+		$this->_initialize_modules();
1024
+	}
1025
+
1026
+
1027
+
1028
+	/**
1029
+	 *    widgets_init
1030
+	 *
1031
+	 * @access private
1032
+	 * @return void
1033
+	 */
1034
+	public function widgets_init()
1035
+	{
1036
+		//only init widgets on admin pages when not in complete maintenance, and
1037
+		//on frontend when not in any maintenance mode
1038
+		if (
1039
+			! EE_Maintenance_Mode::instance()->level()
1040
+			|| (
1041
+				is_admin()
1042
+				&& EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
1043
+			)
1044
+		) {
1045
+			// grab list of installed widgets
1046
+			$widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1047
+			// filter list of modules to register
1048
+			$widgets_to_register = apply_filters(
1049
+				'FHEE__EE_Config__register_widgets__widgets_to_register',
1050
+				$widgets_to_register
1051
+			);
1052
+			if (! empty($widgets_to_register)) {
1053
+				// cycle thru widget folders
1054
+				foreach ($widgets_to_register as $widget_path) {
1055
+					// add to list of installed widget modules
1056
+					EE_Config::register_ee_widget($widget_path);
1057
+				}
1058
+			}
1059
+			// filter list of installed modules
1060
+			EE_Registry::instance()->widgets = apply_filters(
1061
+				'FHEE__EE_Config__register_widgets__installed_widgets',
1062
+				EE_Registry::instance()->widgets
1063
+			);
1064
+		}
1065
+	}
1066
+
1067
+
1068
+
1069
+	/**
1070
+	 *    register_ee_widget - makes core aware of this widget
1071
+	 *
1072
+	 * @access    public
1073
+	 * @param    string $widget_path - full path up to and including widget folder
1074
+	 * @return    void
1075
+	 */
1076
+	public static function register_ee_widget($widget_path = null)
1077
+	{
1078
+		do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
1079
+		$widget_ext = '.widget.php';
1080
+		// make all separators match
1081
+		$widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS);
1082
+		// does the file path INCLUDE the actual file name as part of the path ?
1083
+		if (strpos($widget_path, $widget_ext) !== false) {
1084
+			// grab and shortcode file name from directory name and break apart at dots
1085
+			$file_name = explode('.', basename($widget_path));
1086
+			// take first segment from file name pieces and remove class prefix if it exists
1087
+			$widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
1088
+			// sanitize shortcode directory name
1089
+			$widget = sanitize_key($widget);
1090
+			// now we need to rebuild the shortcode path
1091
+			$widget_path = explode(DS, $widget_path);
1092
+			// remove last segment
1093
+			array_pop($widget_path);
1094
+			// glue it back together
1095
+			$widget_path = implode(DS, $widget_path);
1096
+		} else {
1097
+			// grab and sanitize widget directory name
1098
+			$widget = sanitize_key(basename($widget_path));
1099
+		}
1100
+		// create classname from widget directory name
1101
+		$widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1102
+		// add class prefix
1103
+		$widget_class = 'EEW_' . $widget;
1104
+		// does the widget exist ?
1105
+		if (! is_readable($widget_path . DS . $widget_class . $widget_ext)) {
1106
+			$msg = sprintf(
1107
+				__(
1108
+					'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s',
1109
+					'event_espresso'
1110
+				),
1111
+				$widget_class,
1112
+				$widget_path . DS . $widget_class . $widget_ext
1113
+			);
1114
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1115
+			return;
1116
+		}
1117
+		// load the widget class file
1118
+		require_once($widget_path . DS . $widget_class . $widget_ext);
1119
+		// verify that class exists
1120
+		if (! class_exists($widget_class)) {
1121
+			$msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1122
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1123
+			return;
1124
+		}
1125
+		register_widget($widget_class);
1126
+		// add to array of registered widgets
1127
+		EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext;
1128
+	}
1129
+
1130
+
1131
+
1132
+	/**
1133
+	 *        _register_modules
1134
+	 *
1135
+	 * @access private
1136
+	 * @return array
1137
+	 */
1138
+	private function _register_modules()
1139
+	{
1140
+		// grab list of installed modules
1141
+		$modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1142
+		// filter list of modules to register
1143
+		$modules_to_register = apply_filters(
1144
+			'FHEE__EE_Config__register_modules__modules_to_register',
1145
+			$modules_to_register
1146
+		);
1147
+		if (! empty($modules_to_register)) {
1148
+			// loop through folders
1149
+			foreach ($modules_to_register as $module_path) {
1150
+				/**TEMPORARILY EXCLUDE gateways from modules for time being**/
1151
+				if (
1152
+					$module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1153
+					&& $module_path !== EE_MODULES . 'gateways'
1154
+				) {
1155
+					// add to list of installed modules
1156
+					EE_Config::register_module($module_path);
1157
+				}
1158
+			}
1159
+		}
1160
+		// filter list of installed modules
1161
+		return apply_filters(
1162
+			'FHEE__EE_Config___register_modules__installed_modules',
1163
+			EE_Registry::instance()->modules
1164
+		);
1165
+	}
1166
+
1167
+
1168
+
1169
+	/**
1170
+	 *    register_module - makes core aware of this module
1171
+	 *
1172
+	 * @access    public
1173
+	 * @param    string $module_path - full path up to and including module folder
1174
+	 * @return    bool
1175
+	 */
1176
+	public static function register_module($module_path = null)
1177
+	{
1178
+		do_action('AHEE__EE_Config__register_module__begin', $module_path);
1179
+		$module_ext = '.module.php';
1180
+		// make all separators match
1181
+		$module_path = str_replace(array('\\', '/'), DS, $module_path);
1182
+		// does the file path INCLUDE the actual file name as part of the path ?
1183
+		if (strpos($module_path, $module_ext) !== false) {
1184
+			// grab and shortcode file name from directory name and break apart at dots
1185
+			$module_file = explode('.', basename($module_path));
1186
+			// now we need to rebuild the shortcode path
1187
+			$module_path = explode(DS, $module_path);
1188
+			// remove last segment
1189
+			array_pop($module_path);
1190
+			// glue it back together
1191
+			$module_path = implode(DS, $module_path) . DS;
1192
+			// take first segment from file name pieces and sanitize it
1193
+			$module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1194
+			// ensure class prefix is added
1195
+			$module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1196
+		} else {
1197
+			// we need to generate the filename based off of the folder name
1198
+			// grab and sanitize module name
1199
+			$module = strtolower(basename($module_path));
1200
+			$module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1201
+			// like trailingslashit()
1202
+			$module_path = rtrim($module_path, DS) . DS;
1203
+			// create classname from module directory name
1204
+			$module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1205
+			// add class prefix
1206
+			$module_class = 'EED_' . $module;
1207
+		}
1208
+		// does the module exist ?
1209
+		if (! is_readable($module_path . DS . $module_class . $module_ext)) {
1210
+			$msg = sprintf(
1211
+				__(
1212
+					'The requested %s module file could not be found or is not readable due to file permissions.',
1213
+					'event_espresso'
1214
+				),
1215
+				$module
1216
+			);
1217
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1218
+			return false;
1219
+		}
1220
+		// load the module class file
1221
+		require_once($module_path . $module_class . $module_ext);
1222
+		// verify that class exists
1223
+		if (! class_exists($module_class)) {
1224
+			$msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1225
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1226
+			return false;
1227
+		}
1228
+		// add to array of registered modules
1229
+		EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1230
+		do_action(
1231
+			'AHEE__EE_Config__register_module__complete',
1232
+			$module_class,
1233
+			EE_Registry::instance()->modules->{$module_class}
1234
+		);
1235
+		return true;
1236
+	}
1237
+
1238
+
1239
+
1240
+	/**
1241
+	 *    _initialize_modules
1242
+	 *    allow modules to set hooks for the rest of the system
1243
+	 *
1244
+	 * @access private
1245
+	 * @return void
1246
+	 */
1247
+	private function _initialize_modules()
1248
+	{
1249
+		// cycle thru shortcode folders
1250
+		foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1251
+			// fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1252
+			// which set hooks ?
1253
+			if (is_admin()) {
1254
+				// fire immediately
1255
+				call_user_func(array($module_class, 'set_hooks_admin'));
1256
+			} else {
1257
+				// delay until other systems are online
1258
+				add_action(
1259
+					'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1260
+					array($module_class, 'set_hooks')
1261
+				);
1262
+			}
1263
+		}
1264
+	}
1265
+
1266
+
1267
+
1268
+	/**
1269
+	 *    register_route - adds module method routes to route_map
1270
+	 *
1271
+	 * @access    public
1272
+	 * @param    string $route       - "pretty" public alias for module method
1273
+	 * @param    string $module      - module name (classname without EED_ prefix)
1274
+	 * @param    string $method_name - the actual module method to be routed to
1275
+	 * @param    string $key         - url param key indicating a route is being called
1276
+	 * @return    bool
1277
+	 */
1278
+	public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee')
1279
+	{
1280
+		do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1281
+		$module = str_replace('EED_', '', $module);
1282
+		$module_class = 'EED_' . $module;
1283
+		if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1284
+			$msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1285
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1286
+			return false;
1287
+		}
1288
+		if (empty($route)) {
1289
+			$msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1290
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1291
+			return false;
1292
+		}
1293
+		if (! method_exists('EED_' . $module, $method_name)) {
1294
+			$msg = sprintf(
1295
+				__('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1296
+				$route
1297
+			);
1298
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1299
+			return false;
1300
+		}
1301
+		EE_Config::$_module_route_map[$key][$route] = array('EED_' . $module, $method_name);
1302
+		return true;
1303
+	}
1304
+
1305
+
1306
+
1307
+	/**
1308
+	 *    get_route - get module method route
1309
+	 *
1310
+	 * @access    public
1311
+	 * @param    string $route - "pretty" public alias for module method
1312
+	 * @param    string $key   - url param key indicating a route is being called
1313
+	 * @return    string
1314
+	 */
1315
+	public static function get_route($route = null, $key = 'ee')
1316
+	{
1317
+		do_action('AHEE__EE_Config__get_route__begin', $route);
1318
+		$route = (string)apply_filters('FHEE__EE_Config__get_route', $route);
1319
+		if (isset(EE_Config::$_module_route_map[$key][$route])) {
1320
+			return EE_Config::$_module_route_map[$key][$route];
1321
+		}
1322
+		return null;
1323
+	}
1324
+
1325
+
1326
+
1327
+	/**
1328
+	 *    get_routes - get ALL module method routes
1329
+	 *
1330
+	 * @access    public
1331
+	 * @return    array
1332
+	 */
1333
+	public static function get_routes()
1334
+	{
1335
+		return EE_Config::$_module_route_map;
1336
+	}
1337
+
1338
+
1339
+
1340
+	/**
1341
+	 *    register_forward - allows modules to forward request to another module for further processing
1342
+	 *
1343
+	 * @access    public
1344
+	 * @param    string       $route   - "pretty" public alias for module method
1345
+	 * @param    integer      $status  - integer value corresponding  to status constant strings set in module parent
1346
+	 *                                 class, allows different forwards to be served based on status
1347
+	 * @param    array|string $forward - function name or array( class, method )
1348
+	 * @param    string       $key     - url param key indicating a route is being called
1349
+	 * @return    bool
1350
+	 */
1351
+	public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1352
+	{
1353
+		do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1354
+		if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1355
+			$msg = sprintf(
1356
+				__('The module route %s for this forward has not been registered.', 'event_espresso'),
1357
+				$route
1358
+			);
1359
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1360
+			return false;
1361
+		}
1362
+		if (empty($forward)) {
1363
+			$msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1364
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1365
+			return false;
1366
+		}
1367
+		if (is_array($forward)) {
1368
+			if (! isset($forward[1])) {
1369
+				$msg = sprintf(
1370
+					__('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1371
+					$route
1372
+				);
1373
+				EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1374
+				return false;
1375
+			}
1376
+			if (! method_exists($forward[0], $forward[1])) {
1377
+				$msg = sprintf(
1378
+					__('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1379
+					$forward[1],
1380
+					$route
1381
+				);
1382
+				EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1383
+				return false;
1384
+			}
1385
+		} else if (! function_exists($forward)) {
1386
+			$msg = sprintf(
1387
+				__('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1388
+				$forward,
1389
+				$route
1390
+			);
1391
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1392
+			return false;
1393
+		}
1394
+		EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward;
1395
+		return true;
1396
+	}
1397
+
1398
+
1399
+
1400
+	/**
1401
+	 *    get_forward - get forwarding route
1402
+	 *
1403
+	 * @access    public
1404
+	 * @param    string  $route  - "pretty" public alias for module method
1405
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1406
+	 *                           allows different forwards to be served based on status
1407
+	 * @param    string  $key    - url param key indicating a route is being called
1408
+	 * @return    string
1409
+	 */
1410
+	public static function get_forward($route = null, $status = 0, $key = 'ee')
1411
+	{
1412
+		do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1413
+		if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) {
1414
+			return apply_filters(
1415
+				'FHEE__EE_Config__get_forward',
1416
+				EE_Config::$_module_forward_map[$key][$route][$status],
1417
+				$route,
1418
+				$status
1419
+			);
1420
+		}
1421
+		return null;
1422
+	}
1423
+
1424
+
1425
+
1426
+	/**
1427
+	 *    register_forward - allows modules to specify different view templates for different method routes and status
1428
+	 *    results
1429
+	 *
1430
+	 * @access    public
1431
+	 * @param    string  $route  - "pretty" public alias for module method
1432
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1433
+	 *                           allows different views to be served based on status
1434
+	 * @param    string  $view
1435
+	 * @param    string  $key    - url param key indicating a route is being called
1436
+	 * @return    bool
1437
+	 */
1438
+	public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1439
+	{
1440
+		do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1441
+		if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1442
+			$msg = sprintf(
1443
+				__('The module route %s for this view has not been registered.', 'event_espresso'),
1444
+				$route
1445
+			);
1446
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1447
+			return false;
1448
+		}
1449
+		if (! is_readable($view)) {
1450
+			$msg = sprintf(
1451
+				__(
1452
+					'The %s view file could not be found or is not readable due to file permissions.',
1453
+					'event_espresso'
1454
+				),
1455
+				$view
1456
+			);
1457
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1458
+			return false;
1459
+		}
1460
+		EE_Config::$_module_view_map[$key][$route][absint($status)] = $view;
1461
+		return true;
1462
+	}
1463
+
1464
+
1465
+
1466
+	/**
1467
+	 *    get_view - get view for route and status
1468
+	 *
1469
+	 * @access    public
1470
+	 * @param    string  $route  - "pretty" public alias for module method
1471
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1472
+	 *                           allows different views to be served based on status
1473
+	 * @param    string  $key    - url param key indicating a route is being called
1474
+	 * @return    string
1475
+	 */
1476
+	public static function get_view($route = null, $status = 0, $key = 'ee')
1477
+	{
1478
+		do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1479
+		if (isset(EE_Config::$_module_view_map[$key][$route][$status])) {
1480
+			return apply_filters(
1481
+				'FHEE__EE_Config__get_view',
1482
+				EE_Config::$_module_view_map[$key][$route][$status],
1483
+				$route,
1484
+				$status
1485
+			);
1486
+		}
1487
+		return null;
1488
+	}
1489
+
1490
+
1491
+
1492
+	public function update_addon_option_names()
1493
+	{
1494
+		update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names);
1495
+	}
1496
+
1497
+
1498
+
1499
+	public function shutdown()
1500
+	{
1501
+		$this->update_addon_option_names();
1502
+	}
1503
+
1504
+
1505
+
1506
+	/**
1507
+	 * @return LegacyShortcodesManager
1508
+	 */
1509
+	public static function getLegacyShortcodesManager()
1510
+	{
1511
+
1512
+		if ( ! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1513
+			EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager(
1514
+				EE_Registry::instance()
1515
+			);
1516
+		}
1517
+		return EE_Config::instance()->legacy_shortcodes_manager;
1518
+	}
1519
+
1520
+
1521
+
1522
+	/**
1523
+	 * register_shortcode - makes core aware of this shortcode
1524
+	 *
1525
+	 * @deprecated 4.9.26
1526
+	 * @param    string $shortcode_path - full path up to and including shortcode folder
1527
+	 * @return    bool
1528
+	 */
1529
+	public static function register_shortcode($shortcode_path = null)
1530
+	{
1531
+		EE_Error::doing_it_wrong(
1532
+			__METHOD__,
1533
+			__(
1534
+				'Usage is deprecated. Use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::registerShortcode() as direct replacement, or better yet, please see the new \EventEspresso\core\services\shortcodes\ShortcodesManager class.',
1535
+				'event_espresso'
1536
+			),
1537
+			'4.9.26'
1538
+		);
1539
+		return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path);
1540
+	}
21 1541
 
22
-    const LOG_NAME           = 'ee_config_log';
23 1542
 
24
-    const LOG_LENGTH         = 100;
25 1543
 
26
-    const ADDON_OPTION_NAMES = 'ee_config_option_names';
27
-
28
-
29
-    /**
30
-     *    instance of the EE_Config object
31
-     *
32
-     * @var    EE_Config $_instance
33
-     * @access    private
34
-     */
35
-    private static $_instance;
36
-
37
-    /**
38
-     * @var boolean $_logging_enabled
39
-     */
40
-    private static $_logging_enabled = false;
41
-
42
-    /**
43
-     * @var LegacyShortcodesManager $legacy_shortcodes_manager
44
-     */
45
-    private $legacy_shortcodes_manager;
46
-
47
-    /**
48
-     * An StdClass whose property names are addon slugs,
49
-     * and values are their config classes
50
-     *
51
-     * @var StdClass
52
-     */
53
-    public $addons;
54
-
55
-    /**
56
-     * @var EE_Admin_Config
57
-     */
58
-    public $admin;
59
-
60
-    /**
61
-     * @var EE_Core_Config
62
-     */
63
-    public $core;
64
-
65
-    /**
66
-     * @var EE_Currency_Config
67
-     */
68
-    public $currency;
69
-
70
-    /**
71
-     * @var EE_Organization_Config
72
-     */
73
-    public $organization;
74
-
75
-    /**
76
-     * @var EE_Registration_Config
77
-     */
78
-    public $registration;
79
-
80
-    /**
81
-     * @var EE_Template_Config
82
-     */
83
-    public $template_settings;
84
-
85
-    /**
86
-     * Holds EE environment values.
87
-     *
88
-     * @var EE_Environment_Config
89
-     */
90
-    public $environment;
91
-
92
-    /**
93
-     * settings pertaining to Google maps
94
-     *
95
-     * @var EE_Map_Config
96
-     */
97
-    public $map_settings;
98
-
99
-    /**
100
-     * settings pertaining to Taxes
101
-     *
102
-     * @var EE_Tax_Config
103
-     */
104
-    public $tax_settings;
105
-
106
-
107
-    /**
108
-     * Settings pertaining to global messages settings.
109
-     *
110
-     * @var EE_Messages_Config
111
-     */
112
-    public $messages;
113
-
114
-    /**
115
-     * @deprecated
116
-     * @var EE_Gateway_Config
117
-     */
118
-    public $gateway;
119
-
120
-    /**
121
-     * @var    array $_addon_option_names
122
-     * @access    private
123
-     */
124
-    private $_addon_option_names = array();
125
-
126
-    /**
127
-     * @var    array $_module_route_map
128
-     * @access    private
129
-     */
130
-    private static $_module_route_map = array();
131
-
132
-    /**
133
-     * @var    array $_module_forward_map
134
-     * @access    private
135
-     */
136
-    private static $_module_forward_map = array();
137
-
138
-    /**
139
-     * @var    array $_module_view_map
140
-     * @access    private
141
-     */
142
-    private static $_module_view_map = array();
143
-
144
-
145
-
146
-    /**
147
-     * @singleton method used to instantiate class object
148
-     * @access    public
149
-     * @return EE_Config instance
150
-     */
151
-    public static function instance()
152
-    {
153
-        // check if class object is instantiated, and instantiated properly
154
-        if (! self::$_instance instanceof EE_Config) {
155
-            self::$_instance = new self();
156
-        }
157
-        return self::$_instance;
158
-    }
159
-
160
-
161
-
162
-    /**
163
-     * Resets the config
164
-     *
165
-     * @param bool    $hard_reset    if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE
166
-     *                               (default) leaves the database alone, and merely resets the EE_Config object to
167
-     *                               reflect its state in the database
168
-     * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave
169
-     *                               $_instance as NULL. Useful in case you want to forget about the old instance on
170
-     *                               EE_Config, but might not be ready to instantiate EE_Config currently (eg if the
171
-     *                               site was put into maintenance mode)
172
-     * @return EE_Config
173
-     */
174
-    public static function reset($hard_reset = false, $reinstantiate = true)
175
-    {
176
-        if (self::$_instance instanceof EE_Config) {
177
-            if ($hard_reset) {
178
-                self::$_instance->legacy_shortcodes_manager = null;
179
-                self::$_instance->_addon_option_names = array();
180
-                self::$_instance->_initialize_config();
181
-                self::$_instance->update_espresso_config();
182
-            }
183
-            self::$_instance->update_addon_option_names();
184
-        }
185
-        self::$_instance = null;
186
-        //we don't need to reset the static properties imo because those should
187
-        //only change when a module is added or removed. Currently we don't
188
-        //support removing a module during a request when it previously existed
189
-        if ($reinstantiate) {
190
-            return self::instance();
191
-        } else {
192
-            return null;
193
-        }
194
-    }
195
-
196
-
197
-
198
-    /**
199
-     *    class constructor
200
-     *
201
-     * @access    private
202
-     */
203
-    private function __construct()
204
-    {
205
-        do_action('AHEE__EE_Config__construct__begin', $this);
206
-        EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false);
207
-        // setup empty config classes
208
-        $this->_initialize_config();
209
-        // load existing EE site settings
210
-        $this->_load_core_config();
211
-        // confirm everything loaded correctly and set filtered defaults if not
212
-        $this->_verify_config();
213
-        //  register shortcodes and modules
214
-        add_action(
215
-            'AHEE__EE_System__register_shortcodes_modules_and_widgets',
216
-            array($this, 'register_shortcodes_and_modules'),
217
-            999
218
-        );
219
-        //  initialize shortcodes and modules
220
-        add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules'));
221
-        // register widgets
222
-        add_action('widgets_init', array($this, 'widgets_init'), 10);
223
-        // shutdown
224
-        add_action('shutdown', array($this, 'shutdown'), 10);
225
-        // construct__end hook
226
-        do_action('AHEE__EE_Config__construct__end', $this);
227
-        // hardcoded hack
228
-        $this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014';
229
-    }
230
-
231
-
232
-
233
-    /**
234
-     * @return boolean
235
-     */
236
-    public static function logging_enabled()
237
-    {
238
-        return self::$_logging_enabled;
239
-    }
240
-
241
-
242
-
243
-    /**
244
-     * use to get the current theme if needed from static context
245
-     *
246
-     * @return string current theme set.
247
-     */
248
-    public static function get_current_theme()
249
-    {
250
-        return isset(self::$_instance->template_settings->current_espresso_theme)
251
-            ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014';
252
-    }
253
-
254
-
255
-
256
-    /**
257
-     *        _initialize_config
258
-     *
259
-     * @access private
260
-     * @return void
261
-     */
262
-    private function _initialize_config()
263
-    {
264
-        EE_Config::trim_log();
265
-        //set defaults
266
-        $this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array());
267
-        $this->addons = new stdClass();
268
-        // set _module_route_map
269
-        EE_Config::$_module_route_map = array();
270
-        // set _module_forward_map
271
-        EE_Config::$_module_forward_map = array();
272
-        // set _module_view_map
273
-        EE_Config::$_module_view_map = array();
274
-    }
275
-
276
-
277
-
278
-    /**
279
-     *        load core plugin configuration
280
-     *
281
-     * @access private
282
-     * @return void
283
-     */
284
-    private function _load_core_config()
285
-    {
286
-        // load_core_config__start hook
287
-        do_action('AHEE__EE_Config___load_core_config__start', $this);
288
-        $espresso_config = $this->get_espresso_config();
289
-        foreach ($espresso_config as $config => $settings) {
290
-            // load_core_config__start hook
291
-            $settings = apply_filters(
292
-                'FHEE__EE_Config___load_core_config__config_settings',
293
-                $settings,
294
-                $config,
295
-                $this
296
-            );
297
-            if (is_object($settings) && property_exists($this, $config)) {
298
-                $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
299
-                //call configs populate method to ensure any defaults are set for empty values.
300
-                if (method_exists($settings, 'populate')) {
301
-                    $this->{$config}->populate();
302
-                }
303
-                if (method_exists($settings, 'do_hooks')) {
304
-                    $this->{$config}->do_hooks();
305
-                }
306
-            }
307
-        }
308
-        if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) {
309
-            $this->update_espresso_config();
310
-        }
311
-        // load_core_config__end hook
312
-        do_action('AHEE__EE_Config___load_core_config__end', $this);
313
-    }
314
-
315
-
316
-
317
-    /**
318
-     *    _verify_config
319
-     *
320
-     * @access    protected
321
-     * @return    void
322
-     */
323
-    protected function _verify_config()
324
-    {
325
-        $this->core = $this->core instanceof EE_Core_Config
326
-            ? $this->core
327
-            : new EE_Core_Config();
328
-        $this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core);
329
-        $this->organization = $this->organization instanceof EE_Organization_Config
330
-            ? $this->organization
331
-            : new EE_Organization_Config();
332
-        $this->organization = apply_filters(
333
-            'FHEE__EE_Config___initialize_config__organization',
334
-            $this->organization
335
-        );
336
-        $this->currency = $this->currency instanceof EE_Currency_Config
337
-            ? $this->currency
338
-            : new EE_Currency_Config();
339
-        $this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency);
340
-        $this->registration = $this->registration instanceof EE_Registration_Config
341
-            ? $this->registration
342
-            : new EE_Registration_Config();
343
-        $this->registration = apply_filters(
344
-            'FHEE__EE_Config___initialize_config__registration',
345
-            $this->registration
346
-        );
347
-        $this->admin = $this->admin instanceof EE_Admin_Config
348
-            ? $this->admin
349
-            : new EE_Admin_Config();
350
-        $this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin);
351
-        $this->template_settings = $this->template_settings instanceof EE_Template_Config
352
-            ? $this->template_settings
353
-            : new EE_Template_Config();
354
-        $this->template_settings = apply_filters(
355
-            'FHEE__EE_Config___initialize_config__template_settings',
356
-            $this->template_settings
357
-        );
358
-        $this->map_settings = $this->map_settings instanceof EE_Map_Config
359
-            ? $this->map_settings
360
-            : new EE_Map_Config();
361
-        $this->map_settings = apply_filters('FHEE__EE_Config___initialize_config__map_settings',
362
-            $this->map_settings);
363
-        $this->environment = $this->environment instanceof EE_Environment_Config
364
-            ? $this->environment
365
-            : new EE_Environment_Config();
366
-        $this->environment = apply_filters('FHEE__EE_Config___initialize_config__environment',
367
-            $this->environment);
368
-        $this->tax_settings = $this->tax_settings instanceof EE_Tax_Config
369
-            ? $this->tax_settings
370
-            : new EE_Tax_Config();
371
-        $this->tax_settings = apply_filters('FHEE__EE_Config___initialize_config__tax_settings',
372
-            $this->tax_settings);
373
-        $this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages);
374
-        $this->messages = $this->messages instanceof EE_Messages_Config
375
-            ? $this->messages
376
-            : new EE_Messages_Config();
377
-        $this->gateway = $this->gateway instanceof EE_Gateway_Config
378
-            ? $this->gateway
379
-            : new EE_Gateway_Config();
380
-        $this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway);
381
-        $this->legacy_shortcodes_manager = null;
382
-    }
383
-
384
-
385
-    /**
386
-     *    get_espresso_config
387
-     *
388
-     * @access    public
389
-     * @return    array of espresso config stuff
390
-     */
391
-    public function get_espresso_config()
392
-    {
393
-        // grab espresso configuration
394
-        return apply_filters(
395
-            'FHEE__EE_Config__get_espresso_config__CFG',
396
-            get_option(EE_Config::OPTION_NAME, array())
397
-        );
398
-    }
399
-
400
-
401
-
402
-    /**
403
-     *    double_check_config_comparison
404
-     *
405
-     * @access    public
406
-     * @param string $option
407
-     * @param        $old_value
408
-     * @param        $value
409
-     */
410
-    public function double_check_config_comparison($option = '', $old_value, $value)
411
-    {
412
-        // make sure we're checking the ee config
413
-        if ($option === EE_Config::OPTION_NAME) {
414
-            // run a loose comparison of the old value against the new value for type and properties,
415
-            // but NOT exact instance like WP update_option does (ie: NOT type safe comparison)
416
-            if ($value != $old_value) {
417
-                // if they are NOT the same, then remove the hook,
418
-                // which means the subsequent update results will be based solely on the update query results
419
-                // the reason we do this is because, as stated above,
420
-                // WP update_option performs an exact instance comparison (===) on any update values passed to it
421
-                // this happens PRIOR to serialization and any subsequent update.
422
-                // If values are found to match their previous old value,
423
-                // then WP bails before performing any update.
424
-                // Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version
425
-                // it just pulled from the db, with the one being passed to it (which will not match).
426
-                // HOWEVER, once the object is serialized and passed off to MySQL to update,
427
-                // MySQL MAY ALSO NOT perform the update because
428
-                // the string it sees in the db looks the same as the new one it has been passed!!!
429
-                // This results in the query returning an "affected rows" value of ZERO,
430
-                // which gets returned immediately by WP update_option and looks like an error.
431
-                remove_action('update_option', array($this, 'check_config_updated'));
432
-            }
433
-        }
434
-    }
435
-
436
-
437
-
438
-    /**
439
-     *    update_espresso_config
440
-     *
441
-     * @access   public
442
-     */
443
-    protected function _reset_espresso_addon_config()
444
-    {
445
-        $this->_addon_option_names = array();
446
-        foreach ($this->addons as $addon_name => $addon_config_obj) {
447
-            $addon_config_obj = maybe_unserialize($addon_config_obj);
448
-            if ($addon_config_obj instanceof EE_Config_Base) {
449
-                $this->update_config('addons', $addon_name, $addon_config_obj, false);
450
-            }
451
-            $this->addons->{$addon_name} = null;
452
-        }
453
-    }
454
-
455
-
456
-
457
-    /**
458
-     *    update_espresso_config
459
-     *
460
-     * @access   public
461
-     * @param   bool $add_success
462
-     * @param   bool $add_error
463
-     * @return   bool
464
-     */
465
-    public function update_espresso_config($add_success = false, $add_error = true)
466
-    {
467
-        // don't allow config updates during WP heartbeats
468
-        if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
469
-            return false;
470
-        }
471
-        // commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
472
-        //$clone = clone( self::$_instance );
473
-        //self::$_instance = NULL;
474
-        do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
475
-        $this->_reset_espresso_addon_config();
476
-        // hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
477
-        // but BEFORE the actual update occurs
478
-        add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
479
-        // don't want to persist legacy_shortcodes_manager, but don't want to lose it either
480
-        $legacy_shortcodes_manager = $this->legacy_shortcodes_manager;
481
-        $this->legacy_shortcodes_manager = null;
482
-        // now update "ee_config"
483
-        $saved = update_option(EE_Config::OPTION_NAME, $this);
484
-        $this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
485
-        EE_Config::log(EE_Config::OPTION_NAME);
486
-        // if not saved... check if the hook we just added still exists;
487
-        // if it does, it means one of two things:
488
-        // 		that update_option bailed at the ( $value === $old_value ) conditional,
489
-        //		 or...
490
-        // 		the db update query returned 0 rows affected
491
-        // 		(probably because the data  value was the same from it's perspective)
492
-        // so the existence of the hook means that a negative result from update_option is NOT an error,
493
-        // but just means no update occurred, so don't display an error to the user.
494
-        // BUT... if update_option returns FALSE, AND the hook is missing,
495
-        // then it means that something truly went wrong
496
-        $saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
497
-        // remove our action since we don't want it in the system anymore
498
-        remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
499
-        do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
500
-        //self::$_instance = $clone;
501
-        //unset( $clone );
502
-        // if config remains the same or was updated successfully
503
-        if ($saved) {
504
-            if ($add_success) {
505
-                EE_Error::add_success(
506
-                    __('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
507
-                    __FILE__,
508
-                    __FUNCTION__,
509
-                    __LINE__
510
-                );
511
-            }
512
-            return true;
513
-        } else {
514
-            if ($add_error) {
515
-                EE_Error::add_error(
516
-                    __('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
517
-                    __FILE__,
518
-                    __FUNCTION__,
519
-                    __LINE__
520
-                );
521
-            }
522
-            return false;
523
-        }
524
-    }
525
-
526
-
527
-
528
-    /**
529
-     *    _verify_config_params
530
-     *
531
-     * @access    private
532
-     * @param    string         $section
533
-     * @param    string         $name
534
-     * @param    string         $config_class
535
-     * @param    EE_Config_Base $config_obj
536
-     * @param    array          $tests_to_run
537
-     * @param    bool           $display_errors
538
-     * @return    bool    TRUE on success, FALSE on fail
539
-     */
540
-    private function _verify_config_params(
541
-        $section = '',
542
-        $name = '',
543
-        $config_class = '',
544
-        $config_obj = null,
545
-        $tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
546
-        $display_errors = true
547
-    ) {
548
-        try {
549
-            foreach ($tests_to_run as $test) {
550
-                switch ($test) {
551
-                    // TEST #1 : check that section was set
552
-                    case 1 :
553
-                        if (empty($section)) {
554
-                            if ($display_errors) {
555
-                                throw new EE_Error(
556
-                                    sprintf(
557
-                                        __(
558
-                                            'No configuration section has been provided while attempting to save "%s".',
559
-                                            'event_espresso'
560
-                                        ),
561
-                                        $config_class
562
-                                    )
563
-                                );
564
-                            }
565
-                            return false;
566
-                        }
567
-                        break;
568
-                    // TEST #2 : check that settings section exists
569
-                    case 2 :
570
-                        if (! isset($this->{$section})) {
571
-                            if ($display_errors) {
572
-                                throw new EE_Error(
573
-                                    sprintf(
574
-                                        __('The "%s" configuration section does not exist.', 'event_espresso'),
575
-                                        $section
576
-                                    )
577
-                                );
578
-                            }
579
-                            return false;
580
-                        }
581
-                        break;
582
-                    // TEST #3 : check that section is the proper format
583
-                    case 3 :
584
-                        if (
585
-                        ! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
586
-                        ) {
587
-                            if ($display_errors) {
588
-                                throw new EE_Error(
589
-                                    sprintf(
590
-                                        __(
591
-                                            'The "%s" configuration settings have not been formatted correctly.',
592
-                                            'event_espresso'
593
-                                        ),
594
-                                        $section
595
-                                    )
596
-                                );
597
-                            }
598
-                            return false;
599
-                        }
600
-                        break;
601
-                    // TEST #4 : check that config section name has been set
602
-                    case 4 :
603
-                        if (empty($name)) {
604
-                            if ($display_errors) {
605
-                                throw new EE_Error(
606
-                                    __(
607
-                                        'No name has been provided for the specific configuration section.',
608
-                                        'event_espresso'
609
-                                    )
610
-                                );
611
-                            }
612
-                            return false;
613
-                        }
614
-                        break;
615
-                    // TEST #5 : check that a config class name has been set
616
-                    case 5 :
617
-                        if (empty($config_class)) {
618
-                            if ($display_errors) {
619
-                                throw new EE_Error(
620
-                                    __(
621
-                                        'No class name has been provided for the specific configuration section.',
622
-                                        'event_espresso'
623
-                                    )
624
-                                );
625
-                            }
626
-                            return false;
627
-                        }
628
-                        break;
629
-                    // TEST #6 : verify config class is accessible
630
-                    case 6 :
631
-                        if (! class_exists($config_class)) {
632
-                            if ($display_errors) {
633
-                                throw new EE_Error(
634
-                                    sprintf(
635
-                                        __(
636
-                                            'The "%s" class does not exist. Please ensure that an autoloader has been set for it.',
637
-                                            'event_espresso'
638
-                                        ),
639
-                                        $config_class
640
-                                    )
641
-                                );
642
-                            }
643
-                            return false;
644
-                        }
645
-                        break;
646
-                    // TEST #7 : check that config has even been set
647
-                    case 7 :
648
-                        if (! isset($this->{$section}->{$name})) {
649
-                            if ($display_errors) {
650
-                                throw new EE_Error(
651
-                                    sprintf(
652
-                                        __('No configuration has been set for "%1$s->%2$s".', 'event_espresso'),
653
-                                        $section,
654
-                                        $name
655
-                                    )
656
-                                );
657
-                            }
658
-                            return false;
659
-                        } else {
660
-                            // and make sure it's not serialized
661
-                            $this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name});
662
-                        }
663
-                        break;
664
-                    // TEST #8 : check that config is the requested type
665
-                    case 8 :
666
-                        if (! $this->{$section}->{$name} instanceof $config_class) {
667
-                            if ($display_errors) {
668
-                                throw new EE_Error(
669
-                                    sprintf(
670
-                                        __(
671
-                                            'The configuration for "%1$s->%2$s" is not of the "%3$s" class.',
672
-                                            'event_espresso'
673
-                                        ),
674
-                                        $section,
675
-                                        $name,
676
-                                        $config_class
677
-                                    )
678
-                                );
679
-                            }
680
-                            return false;
681
-                        }
682
-                        break;
683
-                    // TEST #9 : verify config object
684
-                    case 9 :
685
-                        if (! $config_obj instanceof EE_Config_Base) {
686
-                            if ($display_errors) {
687
-                                throw new EE_Error(
688
-                                    sprintf(
689
-                                        __('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'),
690
-                                        print_r($config_obj, true)
691
-                                    )
692
-                                );
693
-                            }
694
-                            return false;
695
-                        }
696
-                        break;
697
-                }
698
-            }
699
-        } catch (EE_Error $e) {
700
-            $e->get_error();
701
-        }
702
-        // you have successfully run the gauntlet
703
-        return true;
704
-    }
705
-
706
-
707
-
708
-    /**
709
-     *    _generate_config_option_name
710
-     *
711
-     * @access        protected
712
-     * @param        string $section
713
-     * @param        string $name
714
-     * @return        string
715
-     */
716
-    private function _generate_config_option_name($section = '', $name = '')
717
-    {
718
-        return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
719
-    }
720
-
721
-
722
-
723
-    /**
724
-     *    _set_config_class
725
-     * ensures that a config class is set, either from a passed config class or one generated from the config name
726
-     *
727
-     * @access    private
728
-     * @param    string $config_class
729
-     * @param    string $name
730
-     * @return    string
731
-     */
732
-    private function _set_config_class($config_class = '', $name = '')
733
-    {
734
-        return ! empty($config_class)
735
-            ? $config_class
736
-            : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
737
-    }
738
-
739
-
740
-
741
-    /**
742
-     *    set_config
743
-     *
744
-     * @access    protected
745
-     * @param    string         $section
746
-     * @param    string         $name
747
-     * @param    string         $config_class
748
-     * @param    EE_Config_Base $config_obj
749
-     * @return    EE_Config_Base
750
-     */
751
-    public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null)
752
-    {
753
-        // ensure config class is set to something
754
-        $config_class = $this->_set_config_class($config_class, $name);
755
-        // run tests 1-4, 6, and 7 to verify all config params are set and valid
756
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
757
-            return null;
758
-        }
759
-        $config_option_name = $this->_generate_config_option_name($section, $name);
760
-        // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
761
-        if (! isset($this->_addon_option_names[$config_option_name])) {
762
-            $this->_addon_option_names[$config_option_name] = $config_class;
763
-            $this->update_addon_option_names();
764
-        }
765
-        // verify the incoming config object but suppress errors
766
-        if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
767
-            $config_obj = new $config_class();
768
-        }
769
-        if (get_option($config_option_name)) {
770
-            EE_Config::log($config_option_name);
771
-            update_option($config_option_name, $config_obj);
772
-            $this->{$section}->{$name} = $config_obj;
773
-            return $this->{$section}->{$name};
774
-        } else {
775
-            // create a wp-option for this config
776
-            if (add_option($config_option_name, $config_obj, '', 'no')) {
777
-                $this->{$section}->{$name} = maybe_unserialize($config_obj);
778
-                return $this->{$section}->{$name};
779
-            } else {
780
-                EE_Error::add_error(
781
-                    sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class),
782
-                    __FILE__,
783
-                    __FUNCTION__,
784
-                    __LINE__
785
-                );
786
-                return null;
787
-            }
788
-        }
789
-    }
790
-
791
-
792
-
793
-    /**
794
-     *    update_config
795
-     * Important: the config object must ALREADY be set, otherwise this will produce an error.
796
-     *
797
-     * @access    public
798
-     * @param    string                $section
799
-     * @param    string                $name
800
-     * @param    EE_Config_Base|string $config_obj
801
-     * @param    bool                  $throw_errors
802
-     * @return    bool
803
-     */
804
-    public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true)
805
-    {
806
-        // don't allow config updates during WP heartbeats
807
-        if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
808
-            return false;
809
-        }
810
-        $config_obj = maybe_unserialize($config_obj);
811
-        // get class name of the incoming object
812
-        $config_class = get_class($config_obj);
813
-        // run tests 1-5 and 9 to verify config
814
-        if (! $this->_verify_config_params(
815
-            $section,
816
-            $name,
817
-            $config_class,
818
-            $config_obj,
819
-            array(1, 2, 3, 4, 7, 9)
820
-        )
821
-        ) {
822
-            return false;
823
-        }
824
-        $config_option_name = $this->_generate_config_option_name($section, $name);
825
-        // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
826
-        if (! isset($this->_addon_option_names[$config_option_name])) {
827
-            // save new config to db
828
-            if ($this->set_config($section, $name, $config_class, $config_obj)) {
829
-                return true;
830
-            }
831
-        } else {
832
-            // first check if the record already exists
833
-            $existing_config = get_option($config_option_name);
834
-            $config_obj = serialize($config_obj);
835
-            // just return if db record is already up to date (NOT type safe comparison)
836
-            if ($existing_config == $config_obj) {
837
-                $this->{$section}->{$name} = $config_obj;
838
-                return true;
839
-            } else if (update_option($config_option_name, $config_obj)) {
840
-                EE_Config::log($config_option_name);
841
-                // update wp-option for this config class
842
-                $this->{$section}->{$name} = $config_obj;
843
-                return true;
844
-            } elseif ($throw_errors) {
845
-                EE_Error::add_error(
846
-                    sprintf(
847
-                        __(
848
-                            'The "%1$s" object stored at"%2$s" was not successfully updated in the database.',
849
-                            'event_espresso'
850
-                        ),
851
-                        $config_class,
852
-                        'EE_Config->' . $section . '->' . $name
853
-                    ),
854
-                    __FILE__,
855
-                    __FUNCTION__,
856
-                    __LINE__
857
-                );
858
-            }
859
-        }
860
-        return false;
861
-    }
862
-
863
-
864
-
865
-    /**
866
-     *    get_config
867
-     *
868
-     * @access    public
869
-     * @param    string $section
870
-     * @param    string $name
871
-     * @param    string $config_class
872
-     * @return    mixed EE_Config_Base | NULL
873
-     */
874
-    public function get_config($section = '', $name = '', $config_class = '')
875
-    {
876
-        // ensure config class is set to something
877
-        $config_class = $this->_set_config_class($config_class, $name);
878
-        // run tests 1-4, 6 and 7 to verify that all params have been set
879
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
880
-            return null;
881
-        }
882
-        // now test if the requested config object exists, but suppress errors
883
-        if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) {
884
-            // config already exists, so pass it back
885
-            return $this->{$section}->{$name};
886
-        }
887
-        // load config option from db if it exists
888
-        $config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
889
-        // verify the newly retrieved config object, but suppress errors
890
-        if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
891
-            // config is good, so set it and pass it back
892
-            $this->{$section}->{$name} = $config_obj;
893
-            return $this->{$section}->{$name};
894
-        }
895
-        // oops! $config_obj is not already set and does not exist in the db, so create a new one
896
-        $config_obj = $this->set_config($section, $name, $config_class);
897
-        // verify the newly created config object
898
-        if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
899
-            return $this->{$section}->{$name};
900
-        } else {
901
-            EE_Error::add_error(
902
-                sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
903
-                __FILE__,
904
-                __FUNCTION__,
905
-                __LINE__
906
-            );
907
-        }
908
-        return null;
909
-    }
910
-
911
-
912
-
913
-    /**
914
-     *    get_config_option
915
-     *
916
-     * @access    public
917
-     * @param    string $config_option_name
918
-     * @return    mixed EE_Config_Base | FALSE
919
-     */
920
-    public function get_config_option($config_option_name = '')
921
-    {
922
-        // retrieve the wp-option for this config class.
923
-        $config_option = maybe_unserialize(get_option($config_option_name, array()));
924
-        if (empty($config_option)) {
925
-            EE_Config::log($config_option_name . '-NOT-FOUND');
926
-        }
927
-        return $config_option;
928
-    }
929
-
930
-
931
-
932
-    /**
933
-     * log
934
-     *
935
-     * @param string $config_option_name
936
-     */
937
-    public static function log($config_option_name = '')
938
-    {
939
-        if (EE_Config::logging_enabled() && ! empty($config_option_name)) {
940
-            $config_log = get_option(EE_Config::LOG_NAME, array());
941
-            //copy incoming $_REQUEST and sanitize it so we can save it
942
-            $_request = $_REQUEST;
943
-            array_walk_recursive($_request, 'sanitize_text_field');
944
-            $config_log[(string)microtime(true)] = array(
945
-                'config_name' => $config_option_name,
946
-                'request'     => $_request,
947
-            );
948
-            update_option(EE_Config::LOG_NAME, $config_log);
949
-        }
950
-    }
951
-
952
-
953
-
954
-    /**
955
-     * trim_log
956
-     * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH
957
-     */
958
-    public static function trim_log()
959
-    {
960
-        if (! EE_Config::logging_enabled()) {
961
-            return;
962
-        }
963
-        $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
964
-        $log_length = count($config_log);
965
-        if ($log_length > EE_Config::LOG_LENGTH) {
966
-            ksort($config_log);
967
-            $config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true);
968
-            update_option(EE_Config::LOG_NAME, $config_log);
969
-        }
970
-    }
971
-
972
-
973
-
974
-    /**
975
-     *    get_page_for_posts
976
-     *    if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the
977
-     *    wp-option "page_for_posts", or "posts" if no page is selected
978
-     *
979
-     * @access    public
980
-     * @return    string
981
-     */
982
-    public static function get_page_for_posts()
983
-    {
984
-        $page_for_posts = get_option('page_for_posts');
985
-        if (! $page_for_posts) {
986
-            return 'posts';
987
-        }
988
-        /** @type WPDB $wpdb */
989
-        global $wpdb;
990
-        $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
991
-        return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
992
-    }
993
-
994
-
995
-
996
-    /**
997
-     *    register_shortcodes_and_modules.
998
-     *    At this point, it's too early to tell if we're maintenance mode or not.
999
-     *    In fact, this is where we give modules a chance to let core know they exist
1000
-     *    so they can help trigger maintenance mode if it's needed
1001
-     *
1002
-     * @access    public
1003
-     * @return    void
1004
-     */
1005
-    public function register_shortcodes_and_modules()
1006
-    {
1007
-        // allow modules to set hooks for the rest of the system
1008
-        EE_Registry::instance()->modules = $this->_register_modules();
1009
-    }
1010
-
1011
-
1012
-
1013
-    /**
1014
-     *    initialize_shortcodes_and_modules
1015
-     *    meaning they can start adding their hooks to get stuff done
1016
-     *
1017
-     * @access    public
1018
-     * @return    void
1019
-     */
1020
-    public function initialize_shortcodes_and_modules()
1021
-    {
1022
-        // allow modules to set hooks for the rest of the system
1023
-        $this->_initialize_modules();
1024
-    }
1025
-
1026
-
1027
-
1028
-    /**
1029
-     *    widgets_init
1030
-     *
1031
-     * @access private
1032
-     * @return void
1033
-     */
1034
-    public function widgets_init()
1035
-    {
1036
-        //only init widgets on admin pages when not in complete maintenance, and
1037
-        //on frontend when not in any maintenance mode
1038
-        if (
1039
-            ! EE_Maintenance_Mode::instance()->level()
1040
-            || (
1041
-                is_admin()
1042
-                && EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
1043
-            )
1044
-        ) {
1045
-            // grab list of installed widgets
1046
-            $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1047
-            // filter list of modules to register
1048
-            $widgets_to_register = apply_filters(
1049
-                'FHEE__EE_Config__register_widgets__widgets_to_register',
1050
-                $widgets_to_register
1051
-            );
1052
-            if (! empty($widgets_to_register)) {
1053
-                // cycle thru widget folders
1054
-                foreach ($widgets_to_register as $widget_path) {
1055
-                    // add to list of installed widget modules
1056
-                    EE_Config::register_ee_widget($widget_path);
1057
-                }
1058
-            }
1059
-            // filter list of installed modules
1060
-            EE_Registry::instance()->widgets = apply_filters(
1061
-                'FHEE__EE_Config__register_widgets__installed_widgets',
1062
-                EE_Registry::instance()->widgets
1063
-            );
1064
-        }
1065
-    }
1066
-
1067
-
1068
-
1069
-    /**
1070
-     *    register_ee_widget - makes core aware of this widget
1071
-     *
1072
-     * @access    public
1073
-     * @param    string $widget_path - full path up to and including widget folder
1074
-     * @return    void
1075
-     */
1076
-    public static function register_ee_widget($widget_path = null)
1077
-    {
1078
-        do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
1079
-        $widget_ext = '.widget.php';
1080
-        // make all separators match
1081
-        $widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS);
1082
-        // does the file path INCLUDE the actual file name as part of the path ?
1083
-        if (strpos($widget_path, $widget_ext) !== false) {
1084
-            // grab and shortcode file name from directory name and break apart at dots
1085
-            $file_name = explode('.', basename($widget_path));
1086
-            // take first segment from file name pieces and remove class prefix if it exists
1087
-            $widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
1088
-            // sanitize shortcode directory name
1089
-            $widget = sanitize_key($widget);
1090
-            // now we need to rebuild the shortcode path
1091
-            $widget_path = explode(DS, $widget_path);
1092
-            // remove last segment
1093
-            array_pop($widget_path);
1094
-            // glue it back together
1095
-            $widget_path = implode(DS, $widget_path);
1096
-        } else {
1097
-            // grab and sanitize widget directory name
1098
-            $widget = sanitize_key(basename($widget_path));
1099
-        }
1100
-        // create classname from widget directory name
1101
-        $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1102
-        // add class prefix
1103
-        $widget_class = 'EEW_' . $widget;
1104
-        // does the widget exist ?
1105
-        if (! is_readable($widget_path . DS . $widget_class . $widget_ext)) {
1106
-            $msg = sprintf(
1107
-                __(
1108
-                    'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s',
1109
-                    'event_espresso'
1110
-                ),
1111
-                $widget_class,
1112
-                $widget_path . DS . $widget_class . $widget_ext
1113
-            );
1114
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1115
-            return;
1116
-        }
1117
-        // load the widget class file
1118
-        require_once($widget_path . DS . $widget_class . $widget_ext);
1119
-        // verify that class exists
1120
-        if (! class_exists($widget_class)) {
1121
-            $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1122
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1123
-            return;
1124
-        }
1125
-        register_widget($widget_class);
1126
-        // add to array of registered widgets
1127
-        EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext;
1128
-    }
1129
-
1130
-
1131
-
1132
-    /**
1133
-     *        _register_modules
1134
-     *
1135
-     * @access private
1136
-     * @return array
1137
-     */
1138
-    private function _register_modules()
1139
-    {
1140
-        // grab list of installed modules
1141
-        $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1142
-        // filter list of modules to register
1143
-        $modules_to_register = apply_filters(
1144
-            'FHEE__EE_Config__register_modules__modules_to_register',
1145
-            $modules_to_register
1146
-        );
1147
-        if (! empty($modules_to_register)) {
1148
-            // loop through folders
1149
-            foreach ($modules_to_register as $module_path) {
1150
-                /**TEMPORARILY EXCLUDE gateways from modules for time being**/
1151
-                if (
1152
-                    $module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1153
-                    && $module_path !== EE_MODULES . 'gateways'
1154
-                ) {
1155
-                    // add to list of installed modules
1156
-                    EE_Config::register_module($module_path);
1157
-                }
1158
-            }
1159
-        }
1160
-        // filter list of installed modules
1161
-        return apply_filters(
1162
-            'FHEE__EE_Config___register_modules__installed_modules',
1163
-            EE_Registry::instance()->modules
1164
-        );
1165
-    }
1166
-
1167
-
1168
-
1169
-    /**
1170
-     *    register_module - makes core aware of this module
1171
-     *
1172
-     * @access    public
1173
-     * @param    string $module_path - full path up to and including module folder
1174
-     * @return    bool
1175
-     */
1176
-    public static function register_module($module_path = null)
1177
-    {
1178
-        do_action('AHEE__EE_Config__register_module__begin', $module_path);
1179
-        $module_ext = '.module.php';
1180
-        // make all separators match
1181
-        $module_path = str_replace(array('\\', '/'), DS, $module_path);
1182
-        // does the file path INCLUDE the actual file name as part of the path ?
1183
-        if (strpos($module_path, $module_ext) !== false) {
1184
-            // grab and shortcode file name from directory name and break apart at dots
1185
-            $module_file = explode('.', basename($module_path));
1186
-            // now we need to rebuild the shortcode path
1187
-            $module_path = explode(DS, $module_path);
1188
-            // remove last segment
1189
-            array_pop($module_path);
1190
-            // glue it back together
1191
-            $module_path = implode(DS, $module_path) . DS;
1192
-            // take first segment from file name pieces and sanitize it
1193
-            $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1194
-            // ensure class prefix is added
1195
-            $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1196
-        } else {
1197
-            // we need to generate the filename based off of the folder name
1198
-            // grab and sanitize module name
1199
-            $module = strtolower(basename($module_path));
1200
-            $module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1201
-            // like trailingslashit()
1202
-            $module_path = rtrim($module_path, DS) . DS;
1203
-            // create classname from module directory name
1204
-            $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1205
-            // add class prefix
1206
-            $module_class = 'EED_' . $module;
1207
-        }
1208
-        // does the module exist ?
1209
-        if (! is_readable($module_path . DS . $module_class . $module_ext)) {
1210
-            $msg = sprintf(
1211
-                __(
1212
-                    'The requested %s module file could not be found or is not readable due to file permissions.',
1213
-                    'event_espresso'
1214
-                ),
1215
-                $module
1216
-            );
1217
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1218
-            return false;
1219
-        }
1220
-        // load the module class file
1221
-        require_once($module_path . $module_class . $module_ext);
1222
-        // verify that class exists
1223
-        if (! class_exists($module_class)) {
1224
-            $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1225
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1226
-            return false;
1227
-        }
1228
-        // add to array of registered modules
1229
-        EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1230
-        do_action(
1231
-            'AHEE__EE_Config__register_module__complete',
1232
-            $module_class,
1233
-            EE_Registry::instance()->modules->{$module_class}
1234
-        );
1235
-        return true;
1236
-    }
1237
-
1238
-
1239
-
1240
-    /**
1241
-     *    _initialize_modules
1242
-     *    allow modules to set hooks for the rest of the system
1243
-     *
1244
-     * @access private
1245
-     * @return void
1246
-     */
1247
-    private function _initialize_modules()
1248
-    {
1249
-        // cycle thru shortcode folders
1250
-        foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1251
-            // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1252
-            // which set hooks ?
1253
-            if (is_admin()) {
1254
-                // fire immediately
1255
-                call_user_func(array($module_class, 'set_hooks_admin'));
1256
-            } else {
1257
-                // delay until other systems are online
1258
-                add_action(
1259
-                    'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1260
-                    array($module_class, 'set_hooks')
1261
-                );
1262
-            }
1263
-        }
1264
-    }
1265
-
1266
-
1267
-
1268
-    /**
1269
-     *    register_route - adds module method routes to route_map
1270
-     *
1271
-     * @access    public
1272
-     * @param    string $route       - "pretty" public alias for module method
1273
-     * @param    string $module      - module name (classname without EED_ prefix)
1274
-     * @param    string $method_name - the actual module method to be routed to
1275
-     * @param    string $key         - url param key indicating a route is being called
1276
-     * @return    bool
1277
-     */
1278
-    public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee')
1279
-    {
1280
-        do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1281
-        $module = str_replace('EED_', '', $module);
1282
-        $module_class = 'EED_' . $module;
1283
-        if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1284
-            $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1285
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1286
-            return false;
1287
-        }
1288
-        if (empty($route)) {
1289
-            $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1290
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1291
-            return false;
1292
-        }
1293
-        if (! method_exists('EED_' . $module, $method_name)) {
1294
-            $msg = sprintf(
1295
-                __('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1296
-                $route
1297
-            );
1298
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1299
-            return false;
1300
-        }
1301
-        EE_Config::$_module_route_map[$key][$route] = array('EED_' . $module, $method_name);
1302
-        return true;
1303
-    }
1304
-
1305
-
1306
-
1307
-    /**
1308
-     *    get_route - get module method route
1309
-     *
1310
-     * @access    public
1311
-     * @param    string $route - "pretty" public alias for module method
1312
-     * @param    string $key   - url param key indicating a route is being called
1313
-     * @return    string
1314
-     */
1315
-    public static function get_route($route = null, $key = 'ee')
1316
-    {
1317
-        do_action('AHEE__EE_Config__get_route__begin', $route);
1318
-        $route = (string)apply_filters('FHEE__EE_Config__get_route', $route);
1319
-        if (isset(EE_Config::$_module_route_map[$key][$route])) {
1320
-            return EE_Config::$_module_route_map[$key][$route];
1321
-        }
1322
-        return null;
1323
-    }
1324
-
1325
-
1326
-
1327
-    /**
1328
-     *    get_routes - get ALL module method routes
1329
-     *
1330
-     * @access    public
1331
-     * @return    array
1332
-     */
1333
-    public static function get_routes()
1334
-    {
1335
-        return EE_Config::$_module_route_map;
1336
-    }
1337
-
1338
-
1339
-
1340
-    /**
1341
-     *    register_forward - allows modules to forward request to another module for further processing
1342
-     *
1343
-     * @access    public
1344
-     * @param    string       $route   - "pretty" public alias for module method
1345
-     * @param    integer      $status  - integer value corresponding  to status constant strings set in module parent
1346
-     *                                 class, allows different forwards to be served based on status
1347
-     * @param    array|string $forward - function name or array( class, method )
1348
-     * @param    string       $key     - url param key indicating a route is being called
1349
-     * @return    bool
1350
-     */
1351
-    public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1352
-    {
1353
-        do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1354
-        if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1355
-            $msg = sprintf(
1356
-                __('The module route %s for this forward has not been registered.', 'event_espresso'),
1357
-                $route
1358
-            );
1359
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1360
-            return false;
1361
-        }
1362
-        if (empty($forward)) {
1363
-            $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1364
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1365
-            return false;
1366
-        }
1367
-        if (is_array($forward)) {
1368
-            if (! isset($forward[1])) {
1369
-                $msg = sprintf(
1370
-                    __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1371
-                    $route
1372
-                );
1373
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1374
-                return false;
1375
-            }
1376
-            if (! method_exists($forward[0], $forward[1])) {
1377
-                $msg = sprintf(
1378
-                    __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1379
-                    $forward[1],
1380
-                    $route
1381
-                );
1382
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1383
-                return false;
1384
-            }
1385
-        } else if (! function_exists($forward)) {
1386
-            $msg = sprintf(
1387
-                __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1388
-                $forward,
1389
-                $route
1390
-            );
1391
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1392
-            return false;
1393
-        }
1394
-        EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward;
1395
-        return true;
1396
-    }
1397
-
1398
-
1399
-
1400
-    /**
1401
-     *    get_forward - get forwarding route
1402
-     *
1403
-     * @access    public
1404
-     * @param    string  $route  - "pretty" public alias for module method
1405
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1406
-     *                           allows different forwards to be served based on status
1407
-     * @param    string  $key    - url param key indicating a route is being called
1408
-     * @return    string
1409
-     */
1410
-    public static function get_forward($route = null, $status = 0, $key = 'ee')
1411
-    {
1412
-        do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1413
-        if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) {
1414
-            return apply_filters(
1415
-                'FHEE__EE_Config__get_forward',
1416
-                EE_Config::$_module_forward_map[$key][$route][$status],
1417
-                $route,
1418
-                $status
1419
-            );
1420
-        }
1421
-        return null;
1422
-    }
1423
-
1424
-
1425
-
1426
-    /**
1427
-     *    register_forward - allows modules to specify different view templates for different method routes and status
1428
-     *    results
1429
-     *
1430
-     * @access    public
1431
-     * @param    string  $route  - "pretty" public alias for module method
1432
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1433
-     *                           allows different views to be served based on status
1434
-     * @param    string  $view
1435
-     * @param    string  $key    - url param key indicating a route is being called
1436
-     * @return    bool
1437
-     */
1438
-    public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1439
-    {
1440
-        do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1441
-        if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1442
-            $msg = sprintf(
1443
-                __('The module route %s for this view has not been registered.', 'event_espresso'),
1444
-                $route
1445
-            );
1446
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1447
-            return false;
1448
-        }
1449
-        if (! is_readable($view)) {
1450
-            $msg = sprintf(
1451
-                __(
1452
-                    'The %s view file could not be found or is not readable due to file permissions.',
1453
-                    'event_espresso'
1454
-                ),
1455
-                $view
1456
-            );
1457
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1458
-            return false;
1459
-        }
1460
-        EE_Config::$_module_view_map[$key][$route][absint($status)] = $view;
1461
-        return true;
1462
-    }
1463
-
1464
-
1465
-
1466
-    /**
1467
-     *    get_view - get view for route and status
1468
-     *
1469
-     * @access    public
1470
-     * @param    string  $route  - "pretty" public alias for module method
1471
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1472
-     *                           allows different views to be served based on status
1473
-     * @param    string  $key    - url param key indicating a route is being called
1474
-     * @return    string
1475
-     */
1476
-    public static function get_view($route = null, $status = 0, $key = 'ee')
1477
-    {
1478
-        do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1479
-        if (isset(EE_Config::$_module_view_map[$key][$route][$status])) {
1480
-            return apply_filters(
1481
-                'FHEE__EE_Config__get_view',
1482
-                EE_Config::$_module_view_map[$key][$route][$status],
1483
-                $route,
1484
-                $status
1485
-            );
1486
-        }
1487
-        return null;
1488
-    }
1489
-
1490
-
1491
-
1492
-    public function update_addon_option_names()
1493
-    {
1494
-        update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names);
1495
-    }
1496
-
1497
-
1498
-
1499
-    public function shutdown()
1500
-    {
1501
-        $this->update_addon_option_names();
1502
-    }
1503
-
1504
-
1505
-
1506
-    /**
1507
-     * @return LegacyShortcodesManager
1508
-     */
1509
-    public static function getLegacyShortcodesManager()
1510
-    {
1511
-
1512
-        if ( ! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1513
-            EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager(
1514
-                EE_Registry::instance()
1515
-            );
1516
-        }
1517
-        return EE_Config::instance()->legacy_shortcodes_manager;
1518
-    }
1519
-
1520
-
1521
-
1522
-    /**
1523
-     * register_shortcode - makes core aware of this shortcode
1524
-     *
1525
-     * @deprecated 4.9.26
1526
-     * @param    string $shortcode_path - full path up to and including shortcode folder
1527
-     * @return    bool
1528
-     */
1529
-    public static function register_shortcode($shortcode_path = null)
1530
-    {
1531
-        EE_Error::doing_it_wrong(
1532
-            __METHOD__,
1533
-            __(
1534
-                'Usage is deprecated. Use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::registerShortcode() as direct replacement, or better yet, please see the new \EventEspresso\core\services\shortcodes\ShortcodesManager class.',
1535
-                'event_espresso'
1536
-            ),
1537
-            '4.9.26'
1538
-        );
1539
-        return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path);
1540
-    }
1541
-
1542
-
1543
-
1544
-}
1545
-
1546
-
1547
-
1548
-/**
1549
- * Base class used for config classes. These classes should generally not have
1550
- * magic functions in use, except we'll allow them to magically set and get stuff...
1551
- * basically, they should just be well-defined stdClasses
1552
- */
1553
-class EE_Config_Base
1554
-{
1555
-
1556
-    /**
1557
-     * Utility function for escaping the value of a property and returning.
1558
-     *
1559
-     * @param string $property property name (checks to see if exists).
1560
-     * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1561
-     * @throws \EE_Error
1562
-     */
1563
-    public function get_pretty($property)
1564
-    {
1565
-        if (! property_exists($this, $property)) {
1566
-            throw new EE_Error(
1567
-                sprintf(
1568
-                    __(
1569
-                        '%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.',
1570
-                        'event_espresso'
1571
-                    ),
1572
-                    get_class($this),
1573
-                    $property
1574
-                )
1575
-            );
1576
-        }
1577
-        //just handling escaping of strings for now.
1578
-        if (is_string($this->{$property})) {
1579
-            return stripslashes($this->{$property});
1580
-        }
1581
-        return $this->{$property};
1582
-    }
1583
-
1584
-
1585
-
1586
-    public function populate()
1587
-    {
1588
-        //grab defaults via a new instance of this class.
1589
-        $class_name = get_class($this);
1590
-        $defaults = new $class_name;
1591
-        //loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1592
-        //default from our $defaults object.
1593
-        foreach (get_object_vars($defaults) as $property => $value) {
1594
-            if ($this->{$property} === null) {
1595
-                $this->{$property} = $value;
1596
-            }
1597
-        }
1598
-        //cleanup
1599
-        unset($defaults);
1600
-    }
1601
-
1602
-
1603
-
1604
-    /**
1605
-     *        __isset
1606
-     *
1607
-     * @param $a
1608
-     * @return bool
1609
-     */
1610
-    public function __isset($a)
1611
-    {
1612
-        return false;
1613
-    }
1614
-
1615
-
1616
-
1617
-    /**
1618
-     *        __unset
1619
-     *
1620
-     * @param $a
1621
-     * @return bool
1622
-     */
1623
-    public function __unset($a)
1624
-    {
1625
-        return false;
1626
-    }
1627
-
1628
-
1629
-
1630
-    /**
1631
-     *        __clone
1632
-     */
1633
-    public function __clone()
1634
-    {
1635
-    }
1636
-
1637
-
1638
-
1639
-    /**
1640
-     *        __wakeup
1641
-     */
1642
-    public function __wakeup()
1643
-    {
1644
-    }
1645
-
1646
-
1647
-
1648
-    /**
1649
-     *        __destruct
1650
-     */
1651
-    public function __destruct()
1652
-    {
1653
-    }
1654
-}
1655
-
1656
-
1657
-
1658
-/**
1659
- * Class for defining what's in the EE_Config relating to registration settings
1660
- */
1661
-class EE_Core_Config extends EE_Config_Base
1662
-{
1663
-
1664
-    public $current_blog_id;
1665
-
1666
-    public $ee_ueip_optin;
1667
-
1668
-    public $ee_ueip_has_notified;
1669
-
1670
-    /**
1671
-     * Not to be confused with the 4 critical page variables (See
1672
-     * get_critical_pages_array()), this is just an array of wp posts that have EE
1673
-     * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode
1674
-     * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array.
1675
-     *
1676
-     * @var array
1677
-     */
1678
-    public $post_shortcodes;
1679
-
1680
-    public $module_route_map;
1681
-
1682
-    public $module_forward_map;
1683
-
1684
-    public $module_view_map;
1685
-
1686
-    /**
1687
-     * The next 4 vars are the IDs of critical EE pages.
1688
-     *
1689
-     * @var int
1690
-     */
1691
-    public $reg_page_id;
1692
-
1693
-    public $txn_page_id;
1694
-
1695
-    public $thank_you_page_id;
1696
-
1697
-    public $cancel_page_id;
1698
-
1699
-    /**
1700
-     * The next 4 vars are the URLs of critical EE pages.
1701
-     *
1702
-     * @var int
1703
-     */
1704
-    public $reg_page_url;
1705
-
1706
-    public $txn_page_url;
1707
-
1708
-    public $thank_you_page_url;
1709
-
1710
-    public $cancel_page_url;
1711
-
1712
-    /**
1713
-     * The next vars relate to the custom slugs for EE CPT routes
1714
-     */
1715
-    public $event_cpt_slug;
1716
-
1717
-
1718
-    /**
1719
-     * This caches the _ee_ueip_option in case this config is reset in the same
1720
-     * request across blog switches in a multisite context.
1721
-     * Avoids extra queries to the db for this option.
1722
-     *
1723
-     * @var bool
1724
-     */
1725
-    public static $ee_ueip_option;
1726
-
1727
-
1728
-
1729
-    /**
1730
-     *    class constructor
1731
-     *
1732
-     * @access    public
1733
-     */
1734
-    public function __construct()
1735
-    {
1736
-        // set default organization settings
1737
-        $this->current_blog_id = get_current_blog_id();
1738
-        $this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id;
1739
-        $this->ee_ueip_optin = $this->_get_main_ee_ueip_optin();
1740
-        $this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1741
-        $this->post_shortcodes = array();
1742
-        $this->module_route_map = array();
1743
-        $this->module_forward_map = array();
1744
-        $this->module_view_map = array();
1745
-        // critical EE page IDs
1746
-        $this->reg_page_id = 0;
1747
-        $this->txn_page_id = 0;
1748
-        $this->thank_you_page_id = 0;
1749
-        $this->cancel_page_id = 0;
1750
-        // critical EE page URLs
1751
-        $this->reg_page_url = '';
1752
-        $this->txn_page_url = '';
1753
-        $this->thank_you_page_url = '';
1754
-        $this->cancel_page_url = '';
1755
-        //cpt slugs
1756
-        $this->event_cpt_slug = __('events', 'event_espresso');
1757
-        //ueip constant check
1758
-        if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1759
-            $this->ee_ueip_optin = false;
1760
-            $this->ee_ueip_has_notified = true;
1761
-        }
1762
-    }
1763
-
1764
-
1765
-
1766
-    /**
1767
-     * @return array
1768
-     */
1769
-    public function get_critical_pages_array()
1770
-    {
1771
-        return array(
1772
-            $this->reg_page_id,
1773
-            $this->txn_page_id,
1774
-            $this->thank_you_page_id,
1775
-            $this->cancel_page_id,
1776
-        );
1777
-    }
1778
-
1779
-
1780
-
1781
-    /**
1782
-     * @return array
1783
-     */
1784
-    public function get_critical_pages_shortcodes_array()
1785
-    {
1786
-        return array(
1787
-            $this->reg_page_id       => 'ESPRESSO_CHECKOUT',
1788
-            $this->txn_page_id       => 'ESPRESSO_TXN_PAGE',
1789
-            $this->thank_you_page_id => 'ESPRESSO_THANK_YOU',
1790
-            $this->cancel_page_id    => 'ESPRESSO_CANCELLED',
1791
-        );
1792
-    }
1793
-
1794
-
1795
-
1796
-    /**
1797
-     *  gets/returns URL for EE reg_page
1798
-     *
1799
-     * @access    public
1800
-     * @return    string
1801
-     */
1802
-    public function reg_page_url()
1803
-    {
1804
-        if (! $this->reg_page_url) {
1805
-            $this->reg_page_url = add_query_arg(
1806
-                                      array('uts' => time()),
1807
-                                      get_permalink($this->reg_page_id)
1808
-                                  ) . '#checkout';
1809
-        }
1810
-        return $this->reg_page_url;
1811
-    }
1812
-
1813
-
1814
-
1815
-    /**
1816
-     *  gets/returns URL for EE txn_page
1817
-     *
1818
-     * @param array $query_args like what gets passed to
1819
-     *                          add_query_arg() as the first argument
1820
-     * @access    public
1821
-     * @return    string
1822
-     */
1823
-    public function txn_page_url($query_args = array())
1824
-    {
1825
-        if (! $this->txn_page_url) {
1826
-            $this->txn_page_url = get_permalink($this->txn_page_id);
1827
-        }
1828
-        if ($query_args) {
1829
-            return add_query_arg($query_args, $this->txn_page_url);
1830
-        } else {
1831
-            return $this->txn_page_url;
1832
-        }
1833
-    }
1834
-
1835
-
1836
-
1837
-    /**
1838
-     *  gets/returns URL for EE thank_you_page
1839
-     *
1840
-     * @param array $query_args like what gets passed to
1841
-     *                          add_query_arg() as the first argument
1842
-     * @access    public
1843
-     * @return    string
1844
-     */
1845
-    public function thank_you_page_url($query_args = array())
1846
-    {
1847
-        if (! $this->thank_you_page_url) {
1848
-            $this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1849
-        }
1850
-        if ($query_args) {
1851
-            return add_query_arg($query_args, $this->thank_you_page_url);
1852
-        } else {
1853
-            return $this->thank_you_page_url;
1854
-        }
1855
-    }
1856
-
1857
-
1858
-
1859
-    /**
1860
-     *  gets/returns URL for EE cancel_page
1861
-     *
1862
-     * @access    public
1863
-     * @return    string
1864
-     */
1865
-    public function cancel_page_url()
1866
-    {
1867
-        if (! $this->cancel_page_url) {
1868
-            $this->cancel_page_url = get_permalink($this->cancel_page_id);
1869
-        }
1870
-        return $this->cancel_page_url;
1871
-    }
1872
-
1873
-
1874
-
1875
-    /**
1876
-     * Resets all critical page urls to their original state.  Used primarily by the __sleep() magic method currently.
1877
-     *
1878
-     * @since 4.7.5
1879
-     */
1880
-    protected function _reset_urls()
1881
-    {
1882
-        $this->reg_page_url = '';
1883
-        $this->txn_page_url = '';
1884
-        $this->cancel_page_url = '';
1885
-        $this->thank_you_page_url = '';
1886
-    }
1887
-
1888
-
1889
-
1890
-    /**
1891
-     * Used to return what the optin value is set for the EE User Experience Program.
1892
-     * This accounts for multisite and this value being requested for a subsite.  In multisite, the value is set
1893
-     * on the main site only.
1894
-     *
1895
-     * @return mixed|void
1896
-     */
1897
-    protected function _get_main_ee_ueip_optin()
1898
-    {
1899
-        //if this is the main site then we can just bypass our direct query.
1900
-        if (is_main_site()) {
1901
-            return get_option('ee_ueip_optin', false);
1902
-        }
1903
-        //is this already cached for this request?  If so use it.
1904
-        if ( ! empty(EE_Core_Config::$ee_ueip_option)) {
1905
-            return EE_Core_Config::$ee_ueip_option;
1906
-        }
1907
-        global $wpdb;
1908
-        $current_network_main_site = is_multisite() ? get_current_site() : null;
1909
-        $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1910
-        $option = 'ee_ueip_optin';
1911
-        //set correct table for query
1912
-        $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1913
-        //rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1914
-        //get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1915
-        //re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1916
-        //this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1917
-        //for the purpose of caching.
1918
-        $pre = apply_filters('pre_option_' . $option, false, $option);
1919
-        if (false !== $pre) {
1920
-            EE_Core_Config::$ee_ueip_option = $pre;
1921
-            return EE_Core_Config::$ee_ueip_option;
1922
-        }
1923
-        $row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1",
1924
-            $option));
1925
-        if (is_object($row)) {
1926
-            $value = $row->option_value;
1927
-        } else { //option does not exist so use default.
1928
-            return apply_filters('default_option_' . $option, false, $option);
1929
-        }
1930
-        EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1931
-        return EE_Core_Config::$ee_ueip_option;
1932
-    }
1933
-
1934
-
1935
-
1936
-    /**
1937
-     * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values
1938
-     * on the object.
1939
-     *
1940
-     * @return array
1941
-     */
1942
-    public function __sleep()
1943
-    {
1944
-        //reset all url properties
1945
-        $this->_reset_urls();
1946
-        //return what to save to db
1947
-        return array_keys(get_object_vars($this));
1948
-    }
1949
-
1950
-}
1951
-
1952
-
1953
-
1954
-/**
1955
- * Config class for storing info on the Organization
1956
- */
1957
-class EE_Organization_Config extends EE_Config_Base
1958
-{
1959
-
1960
-    /**
1961
-     * @var string $name
1962
-     * eg EE4.1
1963
-     */
1964
-    public $name;
1965
-
1966
-    /**
1967
-     * @var string $address_1
1968
-     * eg 123 Onna Road
1969
-     */
1970
-    public $address_1;
1971
-
1972
-    /**
1973
-     * @var string $address_2
1974
-     * eg PO Box 123
1975
-     */
1976
-    public $address_2;
1977
-
1978
-    /**
1979
-     * @var string $city
1980
-     * eg Inna City
1981
-     */
1982
-    public $city;
1983
-
1984
-    /**
1985
-     * @var int $STA_ID
1986
-     * eg 4
1987
-     */
1988
-    public $STA_ID;
1989
-
1990
-    /**
1991
-     * @var string $CNT_ISO
1992
-     * eg US
1993
-     */
1994
-    public $CNT_ISO;
1995
-
1996
-    /**
1997
-     * @var string $zip
1998
-     * eg 12345  or V1A 2B3
1999
-     */
2000
-    public $zip;
2001
-
2002
-    /**
2003
-     * @var string $email
2004
-     * eg [email protected]
2005
-     */
2006
-    public $email;
2007
-
2008
-
2009
-    /**
2010
-     * @var string $phone
2011
-     * eg. 111-111-1111
2012
-     */
2013
-    public $phone;
2014
-
2015
-
2016
-    /**
2017
-     * @var string $vat
2018
-     * VAT/Tax Number
2019
-     */
2020
-    public $vat;
2021
-
2022
-    /**
2023
-     * @var string $logo_url
2024
-     * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg
2025
-     */
2026
-    public $logo_url;
2027
-
2028
-
2029
-    /**
2030
-     * The below are all various properties for holding links to organization social network profiles
2031
-     *
2032
-     * @var string
2033
-     */
2034
-    /**
2035
-     * facebook (facebook.com/profile.name)
2036
-     *
2037
-     * @var string
2038
-     */
2039
-    public $facebook;
2040
-
2041
-
2042
-    /**
2043
-     * twitter (twitter.com/twitter_handle)
2044
-     *
2045
-     * @var string
2046
-     */
2047
-    public $twitter;
2048
-
2049
-
2050
-    /**
2051
-     * linkedin (linkedin.com/in/profile_name)
2052
-     *
2053
-     * @var string
2054
-     */
2055
-    public $linkedin;
2056
-
2057
-
2058
-    /**
2059
-     * pinterest (www.pinterest.com/profile_name)
2060
-     *
2061
-     * @var string
2062
-     */
2063
-    public $pinterest;
2064
-
2065
-
2066
-    /**
2067
-     * google+ (google.com/+profileName)
2068
-     *
2069
-     * @var string
2070
-     */
2071
-    public $google;
2072
-
2073
-
2074
-    /**
2075
-     * instagram (instagram.com/handle)
2076
-     *
2077
-     * @var string
2078
-     */
2079
-    public $instagram;
2080
-
2081
-
2082
-
2083
-    /**
2084
-     *    class constructor
2085
-     *
2086
-     * @access    public
2087
-     */
2088
-    public function __construct()
2089
-    {
2090
-        // set default organization settings
2091
-        $this->name = get_bloginfo('name');
2092
-        $this->address_1 = '123 Onna Road';
2093
-        $this->address_2 = 'PO Box 123';
2094
-        $this->city = 'Inna City';
2095
-        $this->STA_ID = 4;
2096
-        $this->CNT_ISO = 'US';
2097
-        $this->zip = '12345';
2098
-        $this->email = get_bloginfo('admin_email');
2099
-        $this->phone = '';
2100
-        $this->vat = '123456789';
2101
-        $this->logo_url = '';
2102
-        $this->facebook = '';
2103
-        $this->twitter = '';
2104
-        $this->linkedin = '';
2105
-        $this->pinterest = '';
2106
-        $this->google = '';
2107
-        $this->instagram = '';
2108
-    }
2109
-
2110
-}
2111
-
2112
-
2113
-
2114
-/**
2115
- * Class for defining what's in the EE_Config relating to currency
2116
- */
2117
-class EE_Currency_Config extends EE_Config_Base
2118
-{
2119
-
2120
-    /**
2121
-     * @var string $code
2122
-     * eg 'US'
2123
-     */
2124
-    public $code;
2125
-
2126
-    /**
2127
-     * @var string $name
2128
-     * eg 'Dollar'
2129
-     */
2130
-    public $name;
2131
-
2132
-    /**
2133
-     * plural name
2134
-     *
2135
-     * @var string $plural
2136
-     * eg 'Dollars'
2137
-     */
2138
-    public $plural;
2139
-
2140
-    /**
2141
-     * currency sign
2142
-     *
2143
-     * @var string $sign
2144
-     * eg '$'
2145
-     */
2146
-    public $sign;
2147
-
2148
-    /**
2149
-     * Whether the currency sign should come before the number or not
2150
-     *
2151
-     * @var boolean $sign_b4
2152
-     */
2153
-    public $sign_b4;
2154
-
2155
-    /**
2156
-     * How many digits should come after the decimal place
2157
-     *
2158
-     * @var int $dec_plc
2159
-     */
2160
-    public $dec_plc;
2161
-
2162
-    /**
2163
-     * Symbol to use for decimal mark
2164
-     *
2165
-     * @var string $dec_mrk
2166
-     * eg '.'
2167
-     */
2168
-    public $dec_mrk;
2169
-
2170
-    /**
2171
-     * Symbol to use for thousands
2172
-     *
2173
-     * @var string $thsnds
2174
-     * eg ','
2175
-     */
2176
-    public $thsnds;
2177
-
2178
-
2179
-
2180
-    /**
2181
-     *    class constructor
2182
-     *
2183
-     * @access    public
2184
-     * @param string $CNT_ISO
2185
-     * @throws \EE_Error
2186
-     */
2187
-    public function __construct($CNT_ISO = '')
2188
-    {
2189
-        /** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */
2190
-        $table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
2191
-        // get country code from organization settings or use default
2192
-        $ORG_CNT = isset(EE_Registry::instance()->CFG->organization)
2193
-                   && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
2194
-            ? EE_Registry::instance()->CFG->organization->CNT_ISO
2195
-            : '';
2196
-        // but override if requested
2197
-        $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2198
-        // so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists
2199
-        if (
2200
-            ! empty($CNT_ISO)
2201
-            && EE_Maintenance_Mode::instance()->models_can_query()
2202
-            && $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())
2203
-        ) {
2204
-            // retrieve the country settings from the db, just in case they have been customized
2205
-            $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2206
-            if ($country instanceof EE_Country) {
2207
-                $this->code = $country->currency_code();    // currency code: USD, CAD, EUR
2208
-                $this->name = $country->currency_name_single();    // Dollar
2209
-                $this->plural = $country->currency_name_plural();    // Dollars
2210
-                $this->sign = $country->currency_sign();            // currency sign: $
2211
-                $this->sign_b4 = $country->currency_sign_before();        // currency sign before or after: $TRUE  or  FALSE$
2212
-                $this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2213
-                $this->dec_mrk = $country->currency_decimal_mark();    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2214
-                $this->thsnds = $country->currency_thousands_separator();    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2215
-            }
2216
-        }
2217
-        // fallback to hardcoded defaults, in case the above failed
2218
-        if (empty($this->code)) {
2219
-            // set default currency settings
2220
-            $this->code = 'USD';    // currency code: USD, CAD, EUR
2221
-            $this->name = __('Dollar', 'event_espresso');    // Dollar
2222
-            $this->plural = __('Dollars', 'event_espresso');    // Dollars
2223
-            $this->sign = '$';    // currency sign: $
2224
-            $this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2225
-            $this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2226
-            $this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2227
-            $this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2228
-        }
2229
-    }
2230
-}
2231
-
2232
-
2233
-
2234
-/**
2235
- * Class for defining what's in the EE_Config relating to registration settings
2236
- */
2237
-class EE_Registration_Config extends EE_Config_Base
2238
-{
2239
-
2240
-    /**
2241
-     * Default registration status
2242
-     *
2243
-     * @var string $default_STS_ID
2244
-     * eg 'RPP'
2245
-     */
2246
-    public $default_STS_ID;
2247
-
2248
-
2249
-    /**
2250
-     * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of
2251
-     * registrations)
2252
-     * @var int
2253
-     */
2254
-    public $default_maximum_number_of_tickets;
2255
-
2256
-
2257
-    /**
2258
-     * level of validation to apply to email addresses
2259
-     *
2260
-     * @var string $email_validation_level
2261
-     * options: 'basic', 'wp_default', 'i18n', 'i18n_dns'
2262
-     */
2263
-    public $email_validation_level;
2264
-
2265
-    /**
2266
-     *    whether or not to show alternate payment options during the reg process if payment status is pending
2267
-     *
2268
-     * @var boolean $show_pending_payment_options
2269
-     */
2270
-    public $show_pending_payment_options;
2271
-
2272
-    /**
2273
-     * Whether to skip the registration confirmation page
2274
-     *
2275
-     * @var boolean $skip_reg_confirmation
2276
-     */
2277
-    public $skip_reg_confirmation;
2278
-
2279
-    /**
2280
-     * an array of SPCO reg steps where:
2281
-     *        the keys denotes the reg step order
2282
-     *        each element consists of an array with the following elements:
2283
-     *            "file_path" => the file path to the EE_SPCO_Reg_Step class
2284
-     *            "class_name" => the specific EE_SPCO_Reg_Step child class name
2285
-     *            "slug" => the URL param used to trigger the reg step
2286
-     *
2287
-     * @var array $reg_steps
2288
-     */
2289
-    public $reg_steps;
2290
-
2291
-    /**
2292
-     * Whether registration confirmation should be the last page of SPCO
2293
-     *
2294
-     * @var boolean $reg_confirmation_last
2295
-     */
2296
-    public $reg_confirmation_last;
2297
-
2298
-    /**
2299
-     * Whether or not to enable the EE Bot Trap
2300
-     *
2301
-     * @var boolean $use_bot_trap
2302
-     */
2303
-    public $use_bot_trap;
2304
-
2305
-    /**
2306
-     * Whether or not to encrypt some data sent by the EE Bot Trap
2307
-     *
2308
-     * @var boolean $use_encryption
2309
-     */
2310
-    public $use_encryption;
1544
+}
2311 1545
 
2312
-    /**
2313
-     * Whether or not to use ReCaptcha
2314
-     *
2315
-     * @var boolean $use_captcha
2316
-     */
2317
-    public $use_captcha;
2318 1546
 
2319
-    /**
2320
-     * ReCaptcha Theme
2321
-     *
2322
-     * @var string $recaptcha_theme
2323
-     *    options: 'dark    ', 'light'
2324
-     */
2325
-    public $recaptcha_theme;
2326 1547
 
2327
-    /**
2328
-     * ReCaptcha Type
2329
-     *
2330
-     * @var string $recaptcha_type
2331
-     *    options: 'audio', 'image'
2332
-     */
2333
-    public $recaptcha_type;
1548
+/**
1549
+ * Base class used for config classes. These classes should generally not have
1550
+ * magic functions in use, except we'll allow them to magically set and get stuff...
1551
+ * basically, they should just be well-defined stdClasses
1552
+ */
1553
+class EE_Config_Base
1554
+{
2334 1555
 
2335
-    /**
2336
-     * ReCaptcha language
2337
-     *
2338
-     * @var string $recaptcha_language
2339
-     * eg 'en'
2340
-     */
2341
-    public $recaptcha_language;
1556
+	/**
1557
+	 * Utility function for escaping the value of a property and returning.
1558
+	 *
1559
+	 * @param string $property property name (checks to see if exists).
1560
+	 * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1561
+	 * @throws \EE_Error
1562
+	 */
1563
+	public function get_pretty($property)
1564
+	{
1565
+		if (! property_exists($this, $property)) {
1566
+			throw new EE_Error(
1567
+				sprintf(
1568
+					__(
1569
+						'%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.',
1570
+						'event_espresso'
1571
+					),
1572
+					get_class($this),
1573
+					$property
1574
+				)
1575
+			);
1576
+		}
1577
+		//just handling escaping of strings for now.
1578
+		if (is_string($this->{$property})) {
1579
+			return stripslashes($this->{$property});
1580
+		}
1581
+		return $this->{$property};
1582
+	}
1583
+
1584
+
1585
+
1586
+	public function populate()
1587
+	{
1588
+		//grab defaults via a new instance of this class.
1589
+		$class_name = get_class($this);
1590
+		$defaults = new $class_name;
1591
+		//loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1592
+		//default from our $defaults object.
1593
+		foreach (get_object_vars($defaults) as $property => $value) {
1594
+			if ($this->{$property} === null) {
1595
+				$this->{$property} = $value;
1596
+			}
1597
+		}
1598
+		//cleanup
1599
+		unset($defaults);
1600
+	}
1601
+
1602
+
1603
+
1604
+	/**
1605
+	 *        __isset
1606
+	 *
1607
+	 * @param $a
1608
+	 * @return bool
1609
+	 */
1610
+	public function __isset($a)
1611
+	{
1612
+		return false;
1613
+	}
1614
+
1615
+
1616
+
1617
+	/**
1618
+	 *        __unset
1619
+	 *
1620
+	 * @param $a
1621
+	 * @return bool
1622
+	 */
1623
+	public function __unset($a)
1624
+	{
1625
+		return false;
1626
+	}
1627
+
1628
+
1629
+
1630
+	/**
1631
+	 *        __clone
1632
+	 */
1633
+	public function __clone()
1634
+	{
1635
+	}
1636
+
1637
+
1638
+
1639
+	/**
1640
+	 *        __wakeup
1641
+	 */
1642
+	public function __wakeup()
1643
+	{
1644
+	}
1645
+
1646
+
1647
+
1648
+	/**
1649
+	 *        __destruct
1650
+	 */
1651
+	public function __destruct()
1652
+	{
1653
+	}
1654
+}
2342 1655
 
2343
-    /**
2344
-     * ReCaptcha public key
2345
-     *
2346
-     * @var string $recaptcha_publickey
2347
-     */
2348
-    public $recaptcha_publickey;
2349 1656
 
2350
-    /**
2351
-     * ReCaptcha private key
2352
-     *
2353
-     * @var string $recaptcha_privatekey
2354
-     */
2355
-    public $recaptcha_privatekey;
2356 1657
 
2357
-    /**
2358
-     * ReCaptcha width
2359
-     *
2360
-     * @var int $recaptcha_width
2361
-     * @deprecated
2362
-     */
2363
-    public $recaptcha_width;
1658
+/**
1659
+ * Class for defining what's in the EE_Config relating to registration settings
1660
+ */
1661
+class EE_Core_Config extends EE_Config_Base
1662
+{
2364 1663
 
2365
-    /**
2366
-     * Whether or not invalid attempts to directly access the registration checkout page should be tracked.
2367
-     *
2368
-     * @var boolean $track_invalid_checkout_access
2369
-     */
2370
-    protected $track_invalid_checkout_access = true;
1664
+	public $current_blog_id;
1665
+
1666
+	public $ee_ueip_optin;
1667
+
1668
+	public $ee_ueip_has_notified;
1669
+
1670
+	/**
1671
+	 * Not to be confused with the 4 critical page variables (See
1672
+	 * get_critical_pages_array()), this is just an array of wp posts that have EE
1673
+	 * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode
1674
+	 * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array.
1675
+	 *
1676
+	 * @var array
1677
+	 */
1678
+	public $post_shortcodes;
1679
+
1680
+	public $module_route_map;
1681
+
1682
+	public $module_forward_map;
1683
+
1684
+	public $module_view_map;
1685
+
1686
+	/**
1687
+	 * The next 4 vars are the IDs of critical EE pages.
1688
+	 *
1689
+	 * @var int
1690
+	 */
1691
+	public $reg_page_id;
1692
+
1693
+	public $txn_page_id;
1694
+
1695
+	public $thank_you_page_id;
1696
+
1697
+	public $cancel_page_id;
1698
+
1699
+	/**
1700
+	 * The next 4 vars are the URLs of critical EE pages.
1701
+	 *
1702
+	 * @var int
1703
+	 */
1704
+	public $reg_page_url;
1705
+
1706
+	public $txn_page_url;
1707
+
1708
+	public $thank_you_page_url;
1709
+
1710
+	public $cancel_page_url;
1711
+
1712
+	/**
1713
+	 * The next vars relate to the custom slugs for EE CPT routes
1714
+	 */
1715
+	public $event_cpt_slug;
1716
+
1717
+
1718
+	/**
1719
+	 * This caches the _ee_ueip_option in case this config is reset in the same
1720
+	 * request across blog switches in a multisite context.
1721
+	 * Avoids extra queries to the db for this option.
1722
+	 *
1723
+	 * @var bool
1724
+	 */
1725
+	public static $ee_ueip_option;
1726
+
1727
+
1728
+
1729
+	/**
1730
+	 *    class constructor
1731
+	 *
1732
+	 * @access    public
1733
+	 */
1734
+	public function __construct()
1735
+	{
1736
+		// set default organization settings
1737
+		$this->current_blog_id = get_current_blog_id();
1738
+		$this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id;
1739
+		$this->ee_ueip_optin = $this->_get_main_ee_ueip_optin();
1740
+		$this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1741
+		$this->post_shortcodes = array();
1742
+		$this->module_route_map = array();
1743
+		$this->module_forward_map = array();
1744
+		$this->module_view_map = array();
1745
+		// critical EE page IDs
1746
+		$this->reg_page_id = 0;
1747
+		$this->txn_page_id = 0;
1748
+		$this->thank_you_page_id = 0;
1749
+		$this->cancel_page_id = 0;
1750
+		// critical EE page URLs
1751
+		$this->reg_page_url = '';
1752
+		$this->txn_page_url = '';
1753
+		$this->thank_you_page_url = '';
1754
+		$this->cancel_page_url = '';
1755
+		//cpt slugs
1756
+		$this->event_cpt_slug = __('events', 'event_espresso');
1757
+		//ueip constant check
1758
+		if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1759
+			$this->ee_ueip_optin = false;
1760
+			$this->ee_ueip_has_notified = true;
1761
+		}
1762
+	}
1763
+
1764
+
1765
+
1766
+	/**
1767
+	 * @return array
1768
+	 */
1769
+	public function get_critical_pages_array()
1770
+	{
1771
+		return array(
1772
+			$this->reg_page_id,
1773
+			$this->txn_page_id,
1774
+			$this->thank_you_page_id,
1775
+			$this->cancel_page_id,
1776
+		);
1777
+	}
1778
+
1779
+
1780
+
1781
+	/**
1782
+	 * @return array
1783
+	 */
1784
+	public function get_critical_pages_shortcodes_array()
1785
+	{
1786
+		return array(
1787
+			$this->reg_page_id       => 'ESPRESSO_CHECKOUT',
1788
+			$this->txn_page_id       => 'ESPRESSO_TXN_PAGE',
1789
+			$this->thank_you_page_id => 'ESPRESSO_THANK_YOU',
1790
+			$this->cancel_page_id    => 'ESPRESSO_CANCELLED',
1791
+		);
1792
+	}
1793
+
1794
+
1795
+
1796
+	/**
1797
+	 *  gets/returns URL for EE reg_page
1798
+	 *
1799
+	 * @access    public
1800
+	 * @return    string
1801
+	 */
1802
+	public function reg_page_url()
1803
+	{
1804
+		if (! $this->reg_page_url) {
1805
+			$this->reg_page_url = add_query_arg(
1806
+									  array('uts' => time()),
1807
+									  get_permalink($this->reg_page_id)
1808
+								  ) . '#checkout';
1809
+		}
1810
+		return $this->reg_page_url;
1811
+	}
1812
+
1813
+
1814
+
1815
+	/**
1816
+	 *  gets/returns URL for EE txn_page
1817
+	 *
1818
+	 * @param array $query_args like what gets passed to
1819
+	 *                          add_query_arg() as the first argument
1820
+	 * @access    public
1821
+	 * @return    string
1822
+	 */
1823
+	public function txn_page_url($query_args = array())
1824
+	{
1825
+		if (! $this->txn_page_url) {
1826
+			$this->txn_page_url = get_permalink($this->txn_page_id);
1827
+		}
1828
+		if ($query_args) {
1829
+			return add_query_arg($query_args, $this->txn_page_url);
1830
+		} else {
1831
+			return $this->txn_page_url;
1832
+		}
1833
+	}
1834
+
1835
+
1836
+
1837
+	/**
1838
+	 *  gets/returns URL for EE thank_you_page
1839
+	 *
1840
+	 * @param array $query_args like what gets passed to
1841
+	 *                          add_query_arg() as the first argument
1842
+	 * @access    public
1843
+	 * @return    string
1844
+	 */
1845
+	public function thank_you_page_url($query_args = array())
1846
+	{
1847
+		if (! $this->thank_you_page_url) {
1848
+			$this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1849
+		}
1850
+		if ($query_args) {
1851
+			return add_query_arg($query_args, $this->thank_you_page_url);
1852
+		} else {
1853
+			return $this->thank_you_page_url;
1854
+		}
1855
+	}
1856
+
1857
+
1858
+
1859
+	/**
1860
+	 *  gets/returns URL for EE cancel_page
1861
+	 *
1862
+	 * @access    public
1863
+	 * @return    string
1864
+	 */
1865
+	public function cancel_page_url()
1866
+	{
1867
+		if (! $this->cancel_page_url) {
1868
+			$this->cancel_page_url = get_permalink($this->cancel_page_id);
1869
+		}
1870
+		return $this->cancel_page_url;
1871
+	}
1872
+
1873
+
1874
+
1875
+	/**
1876
+	 * Resets all critical page urls to their original state.  Used primarily by the __sleep() magic method currently.
1877
+	 *
1878
+	 * @since 4.7.5
1879
+	 */
1880
+	protected function _reset_urls()
1881
+	{
1882
+		$this->reg_page_url = '';
1883
+		$this->txn_page_url = '';
1884
+		$this->cancel_page_url = '';
1885
+		$this->thank_you_page_url = '';
1886
+	}
1887
+
1888
+
1889
+
1890
+	/**
1891
+	 * Used to return what the optin value is set for the EE User Experience Program.
1892
+	 * This accounts for multisite and this value being requested for a subsite.  In multisite, the value is set
1893
+	 * on the main site only.
1894
+	 *
1895
+	 * @return mixed|void
1896
+	 */
1897
+	protected function _get_main_ee_ueip_optin()
1898
+	{
1899
+		//if this is the main site then we can just bypass our direct query.
1900
+		if (is_main_site()) {
1901
+			return get_option('ee_ueip_optin', false);
1902
+		}
1903
+		//is this already cached for this request?  If so use it.
1904
+		if ( ! empty(EE_Core_Config::$ee_ueip_option)) {
1905
+			return EE_Core_Config::$ee_ueip_option;
1906
+		}
1907
+		global $wpdb;
1908
+		$current_network_main_site = is_multisite() ? get_current_site() : null;
1909
+		$current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1910
+		$option = 'ee_ueip_optin';
1911
+		//set correct table for query
1912
+		$table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1913
+		//rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1914
+		//get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1915
+		//re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1916
+		//this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1917
+		//for the purpose of caching.
1918
+		$pre = apply_filters('pre_option_' . $option, false, $option);
1919
+		if (false !== $pre) {
1920
+			EE_Core_Config::$ee_ueip_option = $pre;
1921
+			return EE_Core_Config::$ee_ueip_option;
1922
+		}
1923
+		$row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1",
1924
+			$option));
1925
+		if (is_object($row)) {
1926
+			$value = $row->option_value;
1927
+		} else { //option does not exist so use default.
1928
+			return apply_filters('default_option_' . $option, false, $option);
1929
+		}
1930
+		EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1931
+		return EE_Core_Config::$ee_ueip_option;
1932
+	}
1933
+
1934
+
1935
+
1936
+	/**
1937
+	 * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values
1938
+	 * on the object.
1939
+	 *
1940
+	 * @return array
1941
+	 */
1942
+	public function __sleep()
1943
+	{
1944
+		//reset all url properties
1945
+		$this->_reset_urls();
1946
+		//return what to save to db
1947
+		return array_keys(get_object_vars($this));
1948
+	}
2371 1949
 
1950
+}
2372 1951
 
2373 1952
 
2374
-    /**
2375
-     *    class constructor
2376
-     *
2377
-     * @access    public
2378
-     */
2379
-    public function __construct()
2380
-    {
2381
-        // set default registration settings
2382
-        $this->default_STS_ID = EEM_Registration::status_id_pending_payment;
2383
-        $this->email_validation_level = 'wp_default';
2384
-        $this->show_pending_payment_options = true;
2385
-        $this->skip_reg_confirmation = false;
2386
-        $this->reg_steps = array();
2387
-        $this->reg_confirmation_last = false;
2388
-        $this->use_bot_trap = true;
2389
-        $this->use_encryption = true;
2390
-        $this->use_captcha = false;
2391
-        $this->recaptcha_theme = 'light';
2392
-        $this->recaptcha_type = 'image';
2393
-        $this->recaptcha_language = 'en';
2394
-        $this->recaptcha_publickey = null;
2395
-        $this->recaptcha_privatekey = null;
2396
-        $this->recaptcha_width = 500;
2397
-        $this->default_maximum_number_of_tickets = 10;
2398
-    }
2399
-
2400
-
2401
-
2402
-    /**
2403
-     * This is called by the config loader and hooks are initialized AFTER the config has been populated.
2404
-     *
2405
-     * @since 4.8.8.rc.019
2406
-     */
2407
-    public function do_hooks()
2408
-    {
2409
-        add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2410
-        add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event'));
2411
-    }
2412 1953
 
1954
+/**
1955
+ * Config class for storing info on the Organization
1956
+ */
1957
+class EE_Organization_Config extends EE_Config_Base
1958
+{
2413 1959
 
1960
+	/**
1961
+	 * @var string $name
1962
+	 * eg EE4.1
1963
+	 */
1964
+	public $name;
1965
+
1966
+	/**
1967
+	 * @var string $address_1
1968
+	 * eg 123 Onna Road
1969
+	 */
1970
+	public $address_1;
1971
+
1972
+	/**
1973
+	 * @var string $address_2
1974
+	 * eg PO Box 123
1975
+	 */
1976
+	public $address_2;
1977
+
1978
+	/**
1979
+	 * @var string $city
1980
+	 * eg Inna City
1981
+	 */
1982
+	public $city;
1983
+
1984
+	/**
1985
+	 * @var int $STA_ID
1986
+	 * eg 4
1987
+	 */
1988
+	public $STA_ID;
1989
+
1990
+	/**
1991
+	 * @var string $CNT_ISO
1992
+	 * eg US
1993
+	 */
1994
+	public $CNT_ISO;
1995
+
1996
+	/**
1997
+	 * @var string $zip
1998
+	 * eg 12345  or V1A 2B3
1999
+	 */
2000
+	public $zip;
2001
+
2002
+	/**
2003
+	 * @var string $email
2004
+	 * eg [email protected]
2005
+	 */
2006
+	public $email;
2007
+
2008
+
2009
+	/**
2010
+	 * @var string $phone
2011
+	 * eg. 111-111-1111
2012
+	 */
2013
+	public $phone;
2014
+
2015
+
2016
+	/**
2017
+	 * @var string $vat
2018
+	 * VAT/Tax Number
2019
+	 */
2020
+	public $vat;
2021
+
2022
+	/**
2023
+	 * @var string $logo_url
2024
+	 * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg
2025
+	 */
2026
+	public $logo_url;
2027
+
2028
+
2029
+	/**
2030
+	 * The below are all various properties for holding links to organization social network profiles
2031
+	 *
2032
+	 * @var string
2033
+	 */
2034
+	/**
2035
+	 * facebook (facebook.com/profile.name)
2036
+	 *
2037
+	 * @var string
2038
+	 */
2039
+	public $facebook;
2040
+
2041
+
2042
+	/**
2043
+	 * twitter (twitter.com/twitter_handle)
2044
+	 *
2045
+	 * @var string
2046
+	 */
2047
+	public $twitter;
2048
+
2049
+
2050
+	/**
2051
+	 * linkedin (linkedin.com/in/profile_name)
2052
+	 *
2053
+	 * @var string
2054
+	 */
2055
+	public $linkedin;
2056
+
2057
+
2058
+	/**
2059
+	 * pinterest (www.pinterest.com/profile_name)
2060
+	 *
2061
+	 * @var string
2062
+	 */
2063
+	public $pinterest;
2064
+
2065
+
2066
+	/**
2067
+	 * google+ (google.com/+profileName)
2068
+	 *
2069
+	 * @var string
2070
+	 */
2071
+	public $google;
2072
+
2073
+
2074
+	/**
2075
+	 * instagram (instagram.com/handle)
2076
+	 *
2077
+	 * @var string
2078
+	 */
2079
+	public $instagram;
2080
+
2081
+
2082
+
2083
+	/**
2084
+	 *    class constructor
2085
+	 *
2086
+	 * @access    public
2087
+	 */
2088
+	public function __construct()
2089
+	{
2090
+		// set default organization settings
2091
+		$this->name = get_bloginfo('name');
2092
+		$this->address_1 = '123 Onna Road';
2093
+		$this->address_2 = 'PO Box 123';
2094
+		$this->city = 'Inna City';
2095
+		$this->STA_ID = 4;
2096
+		$this->CNT_ISO = 'US';
2097
+		$this->zip = '12345';
2098
+		$this->email = get_bloginfo('admin_email');
2099
+		$this->phone = '';
2100
+		$this->vat = '123456789';
2101
+		$this->logo_url = '';
2102
+		$this->facebook = '';
2103
+		$this->twitter = '';
2104
+		$this->linkedin = '';
2105
+		$this->pinterest = '';
2106
+		$this->google = '';
2107
+		$this->instagram = '';
2108
+	}
2414 2109
 
2415
-    /**
2416
-     * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_default_registration_status
2417
-     * field matches the config setting for default_STS_ID.
2418
-     */
2419
-    public function set_default_reg_status_on_EEM_Event()
2420
-    {
2421
-        EEM_Event::set_default_reg_status($this->default_STS_ID);
2422
-    }
2110
+}
2423 2111
 
2424 2112
 
2425
-    /**
2426
-     * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field
2427
-     * for Events matches the config setting for default_maximum_number_of_tickets
2428
-     */
2429
-    public function set_default_max_ticket_on_EEM_Event()
2430
-    {
2431
-        EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets);
2432
-    }
2433 2113
 
2114
+/**
2115
+ * Class for defining what's in the EE_Config relating to currency
2116
+ */
2117
+class EE_Currency_Config extends EE_Config_Base
2118
+{
2434 2119
 
2120
+	/**
2121
+	 * @var string $code
2122
+	 * eg 'US'
2123
+	 */
2124
+	public $code;
2125
+
2126
+	/**
2127
+	 * @var string $name
2128
+	 * eg 'Dollar'
2129
+	 */
2130
+	public $name;
2131
+
2132
+	/**
2133
+	 * plural name
2134
+	 *
2135
+	 * @var string $plural
2136
+	 * eg 'Dollars'
2137
+	 */
2138
+	public $plural;
2139
+
2140
+	/**
2141
+	 * currency sign
2142
+	 *
2143
+	 * @var string $sign
2144
+	 * eg '$'
2145
+	 */
2146
+	public $sign;
2147
+
2148
+	/**
2149
+	 * Whether the currency sign should come before the number or not
2150
+	 *
2151
+	 * @var boolean $sign_b4
2152
+	 */
2153
+	public $sign_b4;
2154
+
2155
+	/**
2156
+	 * How many digits should come after the decimal place
2157
+	 *
2158
+	 * @var int $dec_plc
2159
+	 */
2160
+	public $dec_plc;
2161
+
2162
+	/**
2163
+	 * Symbol to use for decimal mark
2164
+	 *
2165
+	 * @var string $dec_mrk
2166
+	 * eg '.'
2167
+	 */
2168
+	public $dec_mrk;
2169
+
2170
+	/**
2171
+	 * Symbol to use for thousands
2172
+	 *
2173
+	 * @var string $thsnds
2174
+	 * eg ','
2175
+	 */
2176
+	public $thsnds;
2177
+
2178
+
2179
+
2180
+	/**
2181
+	 *    class constructor
2182
+	 *
2183
+	 * @access    public
2184
+	 * @param string $CNT_ISO
2185
+	 * @throws \EE_Error
2186
+	 */
2187
+	public function __construct($CNT_ISO = '')
2188
+	{
2189
+		/** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */
2190
+		$table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
2191
+		// get country code from organization settings or use default
2192
+		$ORG_CNT = isset(EE_Registry::instance()->CFG->organization)
2193
+				   && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
2194
+			? EE_Registry::instance()->CFG->organization->CNT_ISO
2195
+			: '';
2196
+		// but override if requested
2197
+		$CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2198
+		// so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists
2199
+		if (
2200
+			! empty($CNT_ISO)
2201
+			&& EE_Maintenance_Mode::instance()->models_can_query()
2202
+			&& $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())
2203
+		) {
2204
+			// retrieve the country settings from the db, just in case they have been customized
2205
+			$country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2206
+			if ($country instanceof EE_Country) {
2207
+				$this->code = $country->currency_code();    // currency code: USD, CAD, EUR
2208
+				$this->name = $country->currency_name_single();    // Dollar
2209
+				$this->plural = $country->currency_name_plural();    // Dollars
2210
+				$this->sign = $country->currency_sign();            // currency sign: $
2211
+				$this->sign_b4 = $country->currency_sign_before();        // currency sign before or after: $TRUE  or  FALSE$
2212
+				$this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2213
+				$this->dec_mrk = $country->currency_decimal_mark();    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2214
+				$this->thsnds = $country->currency_thousands_separator();    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2215
+			}
2216
+		}
2217
+		// fallback to hardcoded defaults, in case the above failed
2218
+		if (empty($this->code)) {
2219
+			// set default currency settings
2220
+			$this->code = 'USD';    // currency code: USD, CAD, EUR
2221
+			$this->name = __('Dollar', 'event_espresso');    // Dollar
2222
+			$this->plural = __('Dollars', 'event_espresso');    // Dollars
2223
+			$this->sign = '$';    // currency sign: $
2224
+			$this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2225
+			$this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2226
+			$this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2227
+			$this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2228
+		}
2229
+	}
2230
+}
2435 2231
 
2436
-    /**
2437
-     * @return boolean
2438
-     */
2439
-    public function track_invalid_checkout_access()
2440
-    {
2441
-        return $this->track_invalid_checkout_access;
2442
-    }
2443 2232
 
2444 2233
 
2234
+/**
2235
+ * Class for defining what's in the EE_Config relating to registration settings
2236
+ */
2237
+class EE_Registration_Config extends EE_Config_Base
2238
+{
2445 2239
 
2446
-    /**
2447
-     * @param boolean $track_invalid_checkout_access
2448
-     */
2449
-    public function set_track_invalid_checkout_access($track_invalid_checkout_access)
2450
-    {
2451
-        $this->track_invalid_checkout_access = filter_var(
2452
-            $track_invalid_checkout_access,
2453
-            FILTER_VALIDATE_BOOLEAN
2454
-        );
2455
-    }
2240
+	/**
2241
+	 * Default registration status
2242
+	 *
2243
+	 * @var string $default_STS_ID
2244
+	 * eg 'RPP'
2245
+	 */
2246
+	public $default_STS_ID;
2247
+
2248
+
2249
+	/**
2250
+	 * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of
2251
+	 * registrations)
2252
+	 * @var int
2253
+	 */
2254
+	public $default_maximum_number_of_tickets;
2255
+
2256
+
2257
+	/**
2258
+	 * level of validation to apply to email addresses
2259
+	 *
2260
+	 * @var string $email_validation_level
2261
+	 * options: 'basic', 'wp_default', 'i18n', 'i18n_dns'
2262
+	 */
2263
+	public $email_validation_level;
2264
+
2265
+	/**
2266
+	 *    whether or not to show alternate payment options during the reg process if payment status is pending
2267
+	 *
2268
+	 * @var boolean $show_pending_payment_options
2269
+	 */
2270
+	public $show_pending_payment_options;
2271
+
2272
+	/**
2273
+	 * Whether to skip the registration confirmation page
2274
+	 *
2275
+	 * @var boolean $skip_reg_confirmation
2276
+	 */
2277
+	public $skip_reg_confirmation;
2278
+
2279
+	/**
2280
+	 * an array of SPCO reg steps where:
2281
+	 *        the keys denotes the reg step order
2282
+	 *        each element consists of an array with the following elements:
2283
+	 *            "file_path" => the file path to the EE_SPCO_Reg_Step class
2284
+	 *            "class_name" => the specific EE_SPCO_Reg_Step child class name
2285
+	 *            "slug" => the URL param used to trigger the reg step
2286
+	 *
2287
+	 * @var array $reg_steps
2288
+	 */
2289
+	public $reg_steps;
2290
+
2291
+	/**
2292
+	 * Whether registration confirmation should be the last page of SPCO
2293
+	 *
2294
+	 * @var boolean $reg_confirmation_last
2295
+	 */
2296
+	public $reg_confirmation_last;
2297
+
2298
+	/**
2299
+	 * Whether or not to enable the EE Bot Trap
2300
+	 *
2301
+	 * @var boolean $use_bot_trap
2302
+	 */
2303
+	public $use_bot_trap;
2304
+
2305
+	/**
2306
+	 * Whether or not to encrypt some data sent by the EE Bot Trap
2307
+	 *
2308
+	 * @var boolean $use_encryption
2309
+	 */
2310
+	public $use_encryption;
2311
+
2312
+	/**
2313
+	 * Whether or not to use ReCaptcha
2314
+	 *
2315
+	 * @var boolean $use_captcha
2316
+	 */
2317
+	public $use_captcha;
2318
+
2319
+	/**
2320
+	 * ReCaptcha Theme
2321
+	 *
2322
+	 * @var string $recaptcha_theme
2323
+	 *    options: 'dark    ', 'light'
2324
+	 */
2325
+	public $recaptcha_theme;
2326
+
2327
+	/**
2328
+	 * ReCaptcha Type
2329
+	 *
2330
+	 * @var string $recaptcha_type
2331
+	 *    options: 'audio', 'image'
2332
+	 */
2333
+	public $recaptcha_type;
2334
+
2335
+	/**
2336
+	 * ReCaptcha language
2337
+	 *
2338
+	 * @var string $recaptcha_language
2339
+	 * eg 'en'
2340
+	 */
2341
+	public $recaptcha_language;
2342
+
2343
+	/**
2344
+	 * ReCaptcha public key
2345
+	 *
2346
+	 * @var string $recaptcha_publickey
2347
+	 */
2348
+	public $recaptcha_publickey;
2349
+
2350
+	/**
2351
+	 * ReCaptcha private key
2352
+	 *
2353
+	 * @var string $recaptcha_privatekey
2354
+	 */
2355
+	public $recaptcha_privatekey;
2356
+
2357
+	/**
2358
+	 * ReCaptcha width
2359
+	 *
2360
+	 * @var int $recaptcha_width
2361
+	 * @deprecated
2362
+	 */
2363
+	public $recaptcha_width;
2364
+
2365
+	/**
2366
+	 * Whether or not invalid attempts to directly access the registration checkout page should be tracked.
2367
+	 *
2368
+	 * @var boolean $track_invalid_checkout_access
2369
+	 */
2370
+	protected $track_invalid_checkout_access = true;
2371
+
2372
+
2373
+
2374
+	/**
2375
+	 *    class constructor
2376
+	 *
2377
+	 * @access    public
2378
+	 */
2379
+	public function __construct()
2380
+	{
2381
+		// set default registration settings
2382
+		$this->default_STS_ID = EEM_Registration::status_id_pending_payment;
2383
+		$this->email_validation_level = 'wp_default';
2384
+		$this->show_pending_payment_options = true;
2385
+		$this->skip_reg_confirmation = false;
2386
+		$this->reg_steps = array();
2387
+		$this->reg_confirmation_last = false;
2388
+		$this->use_bot_trap = true;
2389
+		$this->use_encryption = true;
2390
+		$this->use_captcha = false;
2391
+		$this->recaptcha_theme = 'light';
2392
+		$this->recaptcha_type = 'image';
2393
+		$this->recaptcha_language = 'en';
2394
+		$this->recaptcha_publickey = null;
2395
+		$this->recaptcha_privatekey = null;
2396
+		$this->recaptcha_width = 500;
2397
+		$this->default_maximum_number_of_tickets = 10;
2398
+	}
2399
+
2400
+
2401
+
2402
+	/**
2403
+	 * This is called by the config loader and hooks are initialized AFTER the config has been populated.
2404
+	 *
2405
+	 * @since 4.8.8.rc.019
2406
+	 */
2407
+	public function do_hooks()
2408
+	{
2409
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2410
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event'));
2411
+	}
2412
+
2413
+
2414
+
2415
+	/**
2416
+	 * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_default_registration_status
2417
+	 * field matches the config setting for default_STS_ID.
2418
+	 */
2419
+	public function set_default_reg_status_on_EEM_Event()
2420
+	{
2421
+		EEM_Event::set_default_reg_status($this->default_STS_ID);
2422
+	}
2423
+
2424
+
2425
+	/**
2426
+	 * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field
2427
+	 * for Events matches the config setting for default_maximum_number_of_tickets
2428
+	 */
2429
+	public function set_default_max_ticket_on_EEM_Event()
2430
+	{
2431
+		EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets);
2432
+	}
2433
+
2434
+
2435
+
2436
+	/**
2437
+	 * @return boolean
2438
+	 */
2439
+	public function track_invalid_checkout_access()
2440
+	{
2441
+		return $this->track_invalid_checkout_access;
2442
+	}
2443
+
2444
+
2445
+
2446
+	/**
2447
+	 * @param boolean $track_invalid_checkout_access
2448
+	 */
2449
+	public function set_track_invalid_checkout_access($track_invalid_checkout_access)
2450
+	{
2451
+		$this->track_invalid_checkout_access = filter_var(
2452
+			$track_invalid_checkout_access,
2453
+			FILTER_VALIDATE_BOOLEAN
2454
+		);
2455
+	}
2456 2456
 
2457 2457
 
2458 2458
 
@@ -2466,160 +2466,160 @@  discard block
 block discarded – undo
2466 2466
 class EE_Admin_Config extends EE_Config_Base
2467 2467
 {
2468 2468
 
2469
-    /**
2470
-     * @var boolean $use_personnel_manager
2471
-     */
2472
-    public $use_personnel_manager;
2473
-
2474
-    /**
2475
-     * @var boolean $use_dashboard_widget
2476
-     */
2477
-    public $use_dashboard_widget;
2478
-
2479
-    /**
2480
-     * @var int $events_in_dashboard
2481
-     */
2482
-    public $events_in_dashboard;
2483
-
2484
-    /**
2485
-     * @var boolean $use_event_timezones
2486
-     */
2487
-    public $use_event_timezones;
2488
-
2489
-    /**
2490
-     * @var boolean $use_full_logging
2491
-     */
2492
-    public $use_full_logging;
2493
-
2494
-    /**
2495
-     * @var string $log_file_name
2496
-     */
2497
-    public $log_file_name;
2498
-
2499
-    /**
2500
-     * @var string $debug_file_name
2501
-     */
2502
-    public $debug_file_name;
2503
-
2504
-    /**
2505
-     * @var boolean $use_remote_logging
2506
-     */
2507
-    public $use_remote_logging;
2508
-
2509
-    /**
2510
-     * @var string $remote_logging_url
2511
-     */
2512
-    public $remote_logging_url;
2513
-
2514
-    /**
2515
-     * @var boolean $show_reg_footer
2516
-     */
2517
-    public $show_reg_footer;
2518
-
2519
-    /**
2520
-     * @var string $affiliate_id
2521
-     */
2522
-    public $affiliate_id;
2523
-
2524
-    /**
2525
-     * help tours on or off (global setting)
2526
-     *
2527
-     * @var boolean
2528
-     */
2529
-    public $help_tour_activation;
2530
-
2531
-    /**
2532
-     * adds extra layer of encoding to session data to prevent serialization errors
2533
-     * but is incompatible with some server configuration errors
2534
-     * if you get "500 internal server errors" during registration, try turning this on
2535
-     * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off
2536
-     *
2537
-     * @var boolean $encode_session_data
2538
-     */
2539
-    private $encode_session_data = false;
2540
-
2541
-
2542
-
2543
-    /**
2544
-     *    class constructor
2545
-     *
2546
-     * @access    public
2547
-     */
2548
-    public function __construct()
2549
-    {
2550
-        // set default general admin settings
2551
-        $this->use_personnel_manager = true;
2552
-        $this->use_dashboard_widget = true;
2553
-        $this->events_in_dashboard = 30;
2554
-        $this->use_event_timezones = false;
2555
-        $this->use_full_logging = false;
2556
-        $this->use_remote_logging = false;
2557
-        $this->remote_logging_url = null;
2558
-        $this->show_reg_footer = true;
2559
-        $this->affiliate_id = 'default';
2560
-        $this->help_tour_activation = true;
2561
-        $this->encode_session_data = false;
2562
-    }
2563
-
2564
-
2565
-
2566
-    /**
2567
-     * @param bool $reset
2568
-     * @return string
2569
-     */
2570
-    public function log_file_name($reset = false)
2571
-    {
2572
-        if (empty($this->log_file_name) || $reset) {
2573
-            $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2574
-            EE_Config::instance()->update_espresso_config(false, false);
2575
-        }
2576
-        return $this->log_file_name;
2577
-    }
2578
-
2579
-
2580
-
2581
-    /**
2582
-     * @param bool $reset
2583
-     * @return string
2584
-     */
2585
-    public function debug_file_name($reset = false)
2586
-    {
2587
-        if (empty($this->debug_file_name) || $reset) {
2588
-            $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2589
-            EE_Config::instance()->update_espresso_config(false, false);
2590
-        }
2591
-        return $this->debug_file_name;
2592
-    }
2593
-
2594
-
2595
-
2596
-    /**
2597
-     * @return string
2598
-     */
2599
-    public function affiliate_id()
2600
-    {
2601
-        return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default';
2602
-    }
2603
-
2604
-
2605
-
2606
-    /**
2607
-     * @return boolean
2608
-     */
2609
-    public function encode_session_data()
2610
-    {
2611
-        return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN);
2612
-    }
2613
-
2614
-
2615
-
2616
-    /**
2617
-     * @param boolean $encode_session_data
2618
-     */
2619
-    public function set_encode_session_data($encode_session_data)
2620
-    {
2621
-        $this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN);
2622
-    }
2469
+	/**
2470
+	 * @var boolean $use_personnel_manager
2471
+	 */
2472
+	public $use_personnel_manager;
2473
+
2474
+	/**
2475
+	 * @var boolean $use_dashboard_widget
2476
+	 */
2477
+	public $use_dashboard_widget;
2478
+
2479
+	/**
2480
+	 * @var int $events_in_dashboard
2481
+	 */
2482
+	public $events_in_dashboard;
2483
+
2484
+	/**
2485
+	 * @var boolean $use_event_timezones
2486
+	 */
2487
+	public $use_event_timezones;
2488
+
2489
+	/**
2490
+	 * @var boolean $use_full_logging
2491
+	 */
2492
+	public $use_full_logging;
2493
+
2494
+	/**
2495
+	 * @var string $log_file_name
2496
+	 */
2497
+	public $log_file_name;
2498
+
2499
+	/**
2500
+	 * @var string $debug_file_name
2501
+	 */
2502
+	public $debug_file_name;
2503
+
2504
+	/**
2505
+	 * @var boolean $use_remote_logging
2506
+	 */
2507
+	public $use_remote_logging;
2508
+
2509
+	/**
2510
+	 * @var string $remote_logging_url
2511
+	 */
2512
+	public $remote_logging_url;
2513
+
2514
+	/**
2515
+	 * @var boolean $show_reg_footer
2516
+	 */
2517
+	public $show_reg_footer;
2518
+
2519
+	/**
2520
+	 * @var string $affiliate_id
2521
+	 */
2522
+	public $affiliate_id;
2523
+
2524
+	/**
2525
+	 * help tours on or off (global setting)
2526
+	 *
2527
+	 * @var boolean
2528
+	 */
2529
+	public $help_tour_activation;
2530
+
2531
+	/**
2532
+	 * adds extra layer of encoding to session data to prevent serialization errors
2533
+	 * but is incompatible with some server configuration errors
2534
+	 * if you get "500 internal server errors" during registration, try turning this on
2535
+	 * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off
2536
+	 *
2537
+	 * @var boolean $encode_session_data
2538
+	 */
2539
+	private $encode_session_data = false;
2540
+
2541
+
2542
+
2543
+	/**
2544
+	 *    class constructor
2545
+	 *
2546
+	 * @access    public
2547
+	 */
2548
+	public function __construct()
2549
+	{
2550
+		// set default general admin settings
2551
+		$this->use_personnel_manager = true;
2552
+		$this->use_dashboard_widget = true;
2553
+		$this->events_in_dashboard = 30;
2554
+		$this->use_event_timezones = false;
2555
+		$this->use_full_logging = false;
2556
+		$this->use_remote_logging = false;
2557
+		$this->remote_logging_url = null;
2558
+		$this->show_reg_footer = true;
2559
+		$this->affiliate_id = 'default';
2560
+		$this->help_tour_activation = true;
2561
+		$this->encode_session_data = false;
2562
+	}
2563
+
2564
+
2565
+
2566
+	/**
2567
+	 * @param bool $reset
2568
+	 * @return string
2569
+	 */
2570
+	public function log_file_name($reset = false)
2571
+	{
2572
+		if (empty($this->log_file_name) || $reset) {
2573
+			$this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2574
+			EE_Config::instance()->update_espresso_config(false, false);
2575
+		}
2576
+		return $this->log_file_name;
2577
+	}
2578
+
2579
+
2580
+
2581
+	/**
2582
+	 * @param bool $reset
2583
+	 * @return string
2584
+	 */
2585
+	public function debug_file_name($reset = false)
2586
+	{
2587
+		if (empty($this->debug_file_name) || $reset) {
2588
+			$this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2589
+			EE_Config::instance()->update_espresso_config(false, false);
2590
+		}
2591
+		return $this->debug_file_name;
2592
+	}
2593
+
2594
+
2595
+
2596
+	/**
2597
+	 * @return string
2598
+	 */
2599
+	public function affiliate_id()
2600
+	{
2601
+		return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default';
2602
+	}
2603
+
2604
+
2605
+
2606
+	/**
2607
+	 * @return boolean
2608
+	 */
2609
+	public function encode_session_data()
2610
+	{
2611
+		return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN);
2612
+	}
2613
+
2614
+
2615
+
2616
+	/**
2617
+	 * @param boolean $encode_session_data
2618
+	 */
2619
+	public function set_encode_session_data($encode_session_data)
2620
+	{
2621
+		$this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN);
2622
+	}
2623 2623
 
2624 2624
 
2625 2625
 
@@ -2633,71 +2633,71 @@  discard block
 block discarded – undo
2633 2633
 class EE_Template_Config extends EE_Config_Base
2634 2634
 {
2635 2635
 
2636
-    /**
2637
-     * @var boolean $enable_default_style
2638
-     */
2639
-    public $enable_default_style;
2640
-
2641
-    /**
2642
-     * @var string $custom_style_sheet
2643
-     */
2644
-    public $custom_style_sheet;
2645
-
2646
-    /**
2647
-     * @var boolean $display_address_in_regform
2648
-     */
2649
-    public $display_address_in_regform;
2650
-
2651
-    /**
2652
-     * @var int $display_description_on_multi_reg_page
2653
-     */
2654
-    public $display_description_on_multi_reg_page;
2655
-
2656
-    /**
2657
-     * @var boolean $use_custom_templates
2658
-     */
2659
-    public $use_custom_templates;
2660
-
2661
-    /**
2662
-     * @var string $current_espresso_theme
2663
-     */
2664
-    public $current_espresso_theme;
2665
-
2666
-    /**
2667
-     * @var EE_Ticket_Selector_Config $EED_Ticket_Selector
2668
-     */
2669
-    public $EED_Ticket_Selector;
2670
-
2671
-    /**
2672
-     * @var EE_Event_Single_Config $EED_Event_Single
2673
-     */
2674
-    public $EED_Event_Single;
2675
-
2676
-    /**
2677
-     * @var EE_Events_Archive_Config $EED_Events_Archive
2678
-     */
2679
-    public $EED_Events_Archive;
2680
-
2681
-
2682
-
2683
-    /**
2684
-     *    class constructor
2685
-     *
2686
-     * @access    public
2687
-     */
2688
-    public function __construct()
2689
-    {
2690
-        // set default template settings
2691
-        $this->enable_default_style = true;
2692
-        $this->custom_style_sheet = null;
2693
-        $this->display_address_in_regform = true;
2694
-        $this->display_description_on_multi_reg_page = false;
2695
-        $this->use_custom_templates = false;
2696
-        $this->current_espresso_theme = 'Espresso_Arabica_2014';
2697
-        $this->EED_Event_Single = null;
2698
-        $this->EED_Events_Archive = null;
2699
-        $this->EED_Ticket_Selector = null;
2700
-    }
2636
+	/**
2637
+	 * @var boolean $enable_default_style
2638
+	 */
2639
+	public $enable_default_style;
2640
+
2641
+	/**
2642
+	 * @var string $custom_style_sheet
2643
+	 */
2644
+	public $custom_style_sheet;
2645
+
2646
+	/**
2647
+	 * @var boolean $display_address_in_regform
2648
+	 */
2649
+	public $display_address_in_regform;
2650
+
2651
+	/**
2652
+	 * @var int $display_description_on_multi_reg_page
2653
+	 */
2654
+	public $display_description_on_multi_reg_page;
2655
+
2656
+	/**
2657
+	 * @var boolean $use_custom_templates
2658
+	 */
2659
+	public $use_custom_templates;
2660
+
2661
+	/**
2662
+	 * @var string $current_espresso_theme
2663
+	 */
2664
+	public $current_espresso_theme;
2665
+
2666
+	/**
2667
+	 * @var EE_Ticket_Selector_Config $EED_Ticket_Selector
2668
+	 */
2669
+	public $EED_Ticket_Selector;
2670
+
2671
+	/**
2672
+	 * @var EE_Event_Single_Config $EED_Event_Single
2673
+	 */
2674
+	public $EED_Event_Single;
2675
+
2676
+	/**
2677
+	 * @var EE_Events_Archive_Config $EED_Events_Archive
2678
+	 */
2679
+	public $EED_Events_Archive;
2680
+
2681
+
2682
+
2683
+	/**
2684
+	 *    class constructor
2685
+	 *
2686
+	 * @access    public
2687
+	 */
2688
+	public function __construct()
2689
+	{
2690
+		// set default template settings
2691
+		$this->enable_default_style = true;
2692
+		$this->custom_style_sheet = null;
2693
+		$this->display_address_in_regform = true;
2694
+		$this->display_description_on_multi_reg_page = false;
2695
+		$this->use_custom_templates = false;
2696
+		$this->current_espresso_theme = 'Espresso_Arabica_2014';
2697
+		$this->EED_Event_Single = null;
2698
+		$this->EED_Events_Archive = null;
2699
+		$this->EED_Ticket_Selector = null;
2700
+	}
2701 2701
 
2702 2702
 }
2703 2703
 
@@ -2709,115 +2709,115 @@  discard block
 block discarded – undo
2709 2709
 class EE_Map_Config extends EE_Config_Base
2710 2710
 {
2711 2711
 
2712
-    /**
2713
-     * @var boolean $use_google_maps
2714
-     */
2715
-    public $use_google_maps;
2716
-
2717
-    /**
2718
-     * @var string $api_key
2719
-     */
2720
-    public $google_map_api_key;
2721
-
2722
-    /**
2723
-     * @var int $event_details_map_width
2724
-     */
2725
-    public $event_details_map_width;
2726
-
2727
-    /**
2728
-     * @var int $event_details_map_height
2729
-     */
2730
-    public $event_details_map_height;
2731
-
2732
-    /**
2733
-     * @var int $event_details_map_zoom
2734
-     */
2735
-    public $event_details_map_zoom;
2736
-
2737
-    /**
2738
-     * @var boolean $event_details_display_nav
2739
-     */
2740
-    public $event_details_display_nav;
2741
-
2742
-    /**
2743
-     * @var boolean $event_details_nav_size
2744
-     */
2745
-    public $event_details_nav_size;
2746
-
2747
-    /**
2748
-     * @var string $event_details_control_type
2749
-     */
2750
-    public $event_details_control_type;
2751
-
2752
-    /**
2753
-     * @var string $event_details_map_align
2754
-     */
2755
-    public $event_details_map_align;
2756
-
2757
-    /**
2758
-     * @var int $event_list_map_width
2759
-     */
2760
-    public $event_list_map_width;
2761
-
2762
-    /**
2763
-     * @var int $event_list_map_height
2764
-     */
2765
-    public $event_list_map_height;
2766
-
2767
-    /**
2768
-     * @var int $event_list_map_zoom
2769
-     */
2770
-    public $event_list_map_zoom;
2771
-
2772
-    /**
2773
-     * @var boolean $event_list_display_nav
2774
-     */
2775
-    public $event_list_display_nav;
2776
-
2777
-    /**
2778
-     * @var boolean $event_list_nav_size
2779
-     */
2780
-    public $event_list_nav_size;
2781
-
2782
-    /**
2783
-     * @var string $event_list_control_type
2784
-     */
2785
-    public $event_list_control_type;
2786
-
2787
-    /**
2788
-     * @var string $event_list_map_align
2789
-     */
2790
-    public $event_list_map_align;
2791
-
2792
-
2793
-
2794
-    /**
2795
-     *    class constructor
2796
-     *
2797
-     * @access    public
2798
-     */
2799
-    public function __construct()
2800
-    {
2801
-        // set default map settings
2802
-        $this->use_google_maps = true;
2803
-        $this->google_map_api_key = '';
2804
-        // for event details pages (reg page)
2805
-        $this->event_details_map_width = 585;            // ee_map_width_single
2806
-        $this->event_details_map_height = 362;            // ee_map_height_single
2807
-        $this->event_details_map_zoom = 14;            // ee_map_zoom_single
2808
-        $this->event_details_display_nav = true;            // ee_map_nav_display_single
2809
-        $this->event_details_nav_size = false;            // ee_map_nav_size_single
2810
-        $this->event_details_control_type = 'default';        // ee_map_type_control_single
2811
-        $this->event_details_map_align = 'center';            // ee_map_align_single
2812
-        // for event list pages
2813
-        $this->event_list_map_width = 300;            // ee_map_width
2814
-        $this->event_list_map_height = 185;        // ee_map_height
2815
-        $this->event_list_map_zoom = 12;            // ee_map_zoom
2816
-        $this->event_list_display_nav = false;        // ee_map_nav_display
2817
-        $this->event_list_nav_size = true;            // ee_map_nav_size
2818
-        $this->event_list_control_type = 'dropdown';        // ee_map_type_control
2819
-        $this->event_list_map_align = 'center';            // ee_map_align
2820
-    }
2712
+	/**
2713
+	 * @var boolean $use_google_maps
2714
+	 */
2715
+	public $use_google_maps;
2716
+
2717
+	/**
2718
+	 * @var string $api_key
2719
+	 */
2720
+	public $google_map_api_key;
2721
+
2722
+	/**
2723
+	 * @var int $event_details_map_width
2724
+	 */
2725
+	public $event_details_map_width;
2726
+
2727
+	/**
2728
+	 * @var int $event_details_map_height
2729
+	 */
2730
+	public $event_details_map_height;
2731
+
2732
+	/**
2733
+	 * @var int $event_details_map_zoom
2734
+	 */
2735
+	public $event_details_map_zoom;
2736
+
2737
+	/**
2738
+	 * @var boolean $event_details_display_nav
2739
+	 */
2740
+	public $event_details_display_nav;
2741
+
2742
+	/**
2743
+	 * @var boolean $event_details_nav_size
2744
+	 */
2745
+	public $event_details_nav_size;
2746
+
2747
+	/**
2748
+	 * @var string $event_details_control_type
2749
+	 */
2750
+	public $event_details_control_type;
2751
+
2752
+	/**
2753
+	 * @var string $event_details_map_align
2754
+	 */
2755
+	public $event_details_map_align;
2756
+
2757
+	/**
2758
+	 * @var int $event_list_map_width
2759
+	 */
2760
+	public $event_list_map_width;
2761
+
2762
+	/**
2763
+	 * @var int $event_list_map_height
2764
+	 */
2765
+	public $event_list_map_height;
2766
+
2767
+	/**
2768
+	 * @var int $event_list_map_zoom
2769
+	 */
2770
+	public $event_list_map_zoom;
2771
+
2772
+	/**
2773
+	 * @var boolean $event_list_display_nav
2774
+	 */
2775
+	public $event_list_display_nav;
2776
+
2777
+	/**
2778
+	 * @var boolean $event_list_nav_size
2779
+	 */
2780
+	public $event_list_nav_size;
2781
+
2782
+	/**
2783
+	 * @var string $event_list_control_type
2784
+	 */
2785
+	public $event_list_control_type;
2786
+
2787
+	/**
2788
+	 * @var string $event_list_map_align
2789
+	 */
2790
+	public $event_list_map_align;
2791
+
2792
+
2793
+
2794
+	/**
2795
+	 *    class constructor
2796
+	 *
2797
+	 * @access    public
2798
+	 */
2799
+	public function __construct()
2800
+	{
2801
+		// set default map settings
2802
+		$this->use_google_maps = true;
2803
+		$this->google_map_api_key = '';
2804
+		// for event details pages (reg page)
2805
+		$this->event_details_map_width = 585;            // ee_map_width_single
2806
+		$this->event_details_map_height = 362;            // ee_map_height_single
2807
+		$this->event_details_map_zoom = 14;            // ee_map_zoom_single
2808
+		$this->event_details_display_nav = true;            // ee_map_nav_display_single
2809
+		$this->event_details_nav_size = false;            // ee_map_nav_size_single
2810
+		$this->event_details_control_type = 'default';        // ee_map_type_control_single
2811
+		$this->event_details_map_align = 'center';            // ee_map_align_single
2812
+		// for event list pages
2813
+		$this->event_list_map_width = 300;            // ee_map_width
2814
+		$this->event_list_map_height = 185;        // ee_map_height
2815
+		$this->event_list_map_zoom = 12;            // ee_map_zoom
2816
+		$this->event_list_display_nav = false;        // ee_map_nav_display
2817
+		$this->event_list_nav_size = true;            // ee_map_nav_size
2818
+		$this->event_list_control_type = 'dropdown';        // ee_map_type_control
2819
+		$this->event_list_map_align = 'center';            // ee_map_align
2820
+	}
2821 2821
 
2822 2822
 }
2823 2823
 
@@ -2829,47 +2829,47 @@  discard block
 block discarded – undo
2829 2829
 class EE_Events_Archive_Config extends EE_Config_Base
2830 2830
 {
2831 2831
 
2832
-    public $display_status_banner;
2832
+	public $display_status_banner;
2833 2833
 
2834
-    public $display_description;
2834
+	public $display_description;
2835 2835
 
2836
-    public $display_ticket_selector;
2836
+	public $display_ticket_selector;
2837 2837
 
2838
-    public $display_datetimes;
2838
+	public $display_datetimes;
2839 2839
 
2840
-    public $display_venue;
2840
+	public $display_venue;
2841 2841
 
2842
-    public $display_expired_events;
2842
+	public $display_expired_events;
2843 2843
 
2844
-    public $use_sortable_display_order;
2844
+	public $use_sortable_display_order;
2845 2845
 
2846
-    public $display_order_tickets;
2846
+	public $display_order_tickets;
2847 2847
 
2848
-    public $display_order_datetimes;
2848
+	public $display_order_datetimes;
2849 2849
 
2850
-    public $display_order_event;
2850
+	public $display_order_event;
2851 2851
 
2852
-    public $display_order_venue;
2852
+	public $display_order_venue;
2853 2853
 
2854 2854
 
2855 2855
 
2856
-    /**
2857
-     *    class constructor
2858
-     */
2859
-    public function __construct()
2860
-    {
2861
-        $this->display_status_banner = 0;
2862
-        $this->display_description = 1;
2863
-        $this->display_ticket_selector = 0;
2864
-        $this->display_datetimes = 1;
2865
-        $this->display_venue = 0;
2866
-        $this->display_expired_events = 0;
2867
-        $this->use_sortable_display_order = false;
2868
-        $this->display_order_tickets = 100;
2869
-        $this->display_order_datetimes = 110;
2870
-        $this->display_order_event = 120;
2871
-        $this->display_order_venue = 130;
2872
-    }
2856
+	/**
2857
+	 *    class constructor
2858
+	 */
2859
+	public function __construct()
2860
+	{
2861
+		$this->display_status_banner = 0;
2862
+		$this->display_description = 1;
2863
+		$this->display_ticket_selector = 0;
2864
+		$this->display_datetimes = 1;
2865
+		$this->display_venue = 0;
2866
+		$this->display_expired_events = 0;
2867
+		$this->use_sortable_display_order = false;
2868
+		$this->display_order_tickets = 100;
2869
+		$this->display_order_datetimes = 110;
2870
+		$this->display_order_event = 120;
2871
+		$this->display_order_venue = 130;
2872
+	}
2873 2873
 }
2874 2874
 
2875 2875
 
@@ -2880,35 +2880,35 @@  discard block
 block discarded – undo
2880 2880
 class EE_Event_Single_Config extends EE_Config_Base
2881 2881
 {
2882 2882
 
2883
-    public $display_status_banner_single;
2883
+	public $display_status_banner_single;
2884 2884
 
2885
-    public $display_venue;
2885
+	public $display_venue;
2886 2886
 
2887
-    public $use_sortable_display_order;
2887
+	public $use_sortable_display_order;
2888 2888
 
2889
-    public $display_order_tickets;
2889
+	public $display_order_tickets;
2890 2890
 
2891
-    public $display_order_datetimes;
2891
+	public $display_order_datetimes;
2892 2892
 
2893
-    public $display_order_event;
2893
+	public $display_order_event;
2894 2894
 
2895
-    public $display_order_venue;
2895
+	public $display_order_venue;
2896 2896
 
2897 2897
 
2898 2898
 
2899
-    /**
2900
-     *    class constructor
2901
-     */
2902
-    public function __construct()
2903
-    {
2904
-        $this->display_status_banner_single = 0;
2905
-        $this->display_venue = 1;
2906
-        $this->use_sortable_display_order = false;
2907
-        $this->display_order_tickets = 100;
2908
-        $this->display_order_datetimes = 110;
2909
-        $this->display_order_event = 120;
2910
-        $this->display_order_venue = 130;
2911
-    }
2899
+	/**
2900
+	 *    class constructor
2901
+	 */
2902
+	public function __construct()
2903
+	{
2904
+		$this->display_status_banner_single = 0;
2905
+		$this->display_venue = 1;
2906
+		$this->use_sortable_display_order = false;
2907
+		$this->display_order_tickets = 100;
2908
+		$this->display_order_datetimes = 110;
2909
+		$this->display_order_event = 120;
2910
+		$this->display_order_venue = 130;
2911
+	}
2912 2912
 }
2913 2913
 
2914 2914
 
@@ -2919,152 +2919,152 @@  discard block
 block discarded – undo
2919 2919
 class EE_Ticket_Selector_Config extends EE_Config_Base
2920 2920
 {
2921 2921
 
2922
-    /**
2923
-     * constant to indicate that a datetime selector should NEVER be shown for ticket selectors
2924
-     */
2925
-    const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector';
2926
-
2927
-    /**
2928
-     * constant to indicate that a datetime selector should only be shown for ticket selectors
2929
-     * when the number of datetimes for the event matches the value set for $datetime_selector_threshold
2930
-     */
2931
-    const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector';
2932
-
2933
-    /**
2934
-     * @var boolean $show_ticket_sale_columns
2935
-     */
2936
-    public $show_ticket_sale_columns;
2937
-
2938
-    /**
2939
-     * @var boolean $show_ticket_details
2940
-     */
2941
-    public $show_ticket_details;
2942
-
2943
-    /**
2944
-     * @var boolean $show_expired_tickets
2945
-     */
2946
-    public $show_expired_tickets;
2947
-
2948
-    /**
2949
-     * whether or not to display a dropdown box populated with event datetimes
2950
-     * that toggles which tickets are displayed for a ticket selector.
2951
-     * uses one of the *_DATETIME_SELECTOR constants defined above
2952
-     *
2953
-     * @var string $show_datetime_selector
2954
-     */
2955
-    private $show_datetime_selector = 'no_datetime_selector';
2956
-
2957
-    /**
2958
-     * the number of datetimes an event has to have before conditionally displaying a datetime selector
2959
-     *
2960
-     * @var int $datetime_selector_threshold
2961
-     */
2962
-    private $datetime_selector_threshold = 3;
2963
-
2964
-
2965
-
2966
-    /**
2967
-     *    class constructor
2968
-     */
2969
-    public function __construct()
2970
-    {
2971
-        $this->show_ticket_sale_columns = true;
2972
-        $this->show_ticket_details = true;
2973
-        $this->show_expired_tickets = true;
2974
-        $this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
2975
-        $this->datetime_selector_threshold = 3;
2976
-    }
2977
-
2978
-
2979
-
2980
-    /**
2981
-     * returns true if a datetime selector should be displayed
2982
-     *
2983
-     * @param array $datetimes
2984
-     * @return bool
2985
-     */
2986
-    public function showDatetimeSelector(array $datetimes)
2987
-    {
2988
-        // if the settings are NOT: don't show OR below threshold, THEN active = true
2989
-        return ! (
2990
-            $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
2991
-            || (
2992
-                $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR
2993
-                && count($datetimes) < $this->getDatetimeSelectorThreshold()
2994
-            )
2995
-        );
2996
-    }
2997
-
2998
-
2999
-
3000
-    /**
3001
-     * @return string
3002
-     */
3003
-    public function getShowDatetimeSelector()
3004
-    {
3005
-        return $this->show_datetime_selector;
3006
-    }
3007
-
3008
-
3009
-
3010
-    /**
3011
-     * @param bool $keys_only
3012
-     * @return array
3013
-     */
3014
-    public function getShowDatetimeSelectorOptions($keys_only = true)
3015
-    {
3016
-        return $keys_only
3017
-            ? array(
3018
-                \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
3019
-                \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
3020
-            )
3021
-            : array(
3022
-                \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__(
3023
-                    'Do not show date & time filter', 'event_espresso'
3024
-                ),
3025
-                \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR  => esc_html__(
3026
-                    'Maybe show date & time filter', 'event_espresso'
3027
-                ),
3028
-            );
3029
-    }
3030
-
3031
-
3032
-
3033
-    /**
3034
-     * @param string $show_datetime_selector
3035
-     */
3036
-    public function setShowDatetimeSelector($show_datetime_selector)
3037
-    {
3038
-        $this->show_datetime_selector = in_array(
3039
-            $show_datetime_selector,
3040
-            $this->getShowDatetimeSelectorOptions(),
3041
-            true
3042
-        )
3043
-            ? $show_datetime_selector
3044
-            : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3045
-    }
3046
-
3047
-
3048
-
3049
-    /**
3050
-     * @return int
3051
-     */
3052
-    public function getDatetimeSelectorThreshold()
3053
-    {
3054
-        return $this->datetime_selector_threshold;
3055
-    }
3056
-
3057
-
3058
-
3059
-
3060
-    /**
3061
-     * @param int $datetime_selector_threshold
3062
-     */
3063
-    public function setDatetimeSelectorThreshold($datetime_selector_threshold)
3064
-    {
3065
-        $datetime_selector_threshold = absint($datetime_selector_threshold);
3066
-        $this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3;
3067
-    }
2922
+	/**
2923
+	 * constant to indicate that a datetime selector should NEVER be shown for ticket selectors
2924
+	 */
2925
+	const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector';
2926
+
2927
+	/**
2928
+	 * constant to indicate that a datetime selector should only be shown for ticket selectors
2929
+	 * when the number of datetimes for the event matches the value set for $datetime_selector_threshold
2930
+	 */
2931
+	const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector';
2932
+
2933
+	/**
2934
+	 * @var boolean $show_ticket_sale_columns
2935
+	 */
2936
+	public $show_ticket_sale_columns;
2937
+
2938
+	/**
2939
+	 * @var boolean $show_ticket_details
2940
+	 */
2941
+	public $show_ticket_details;
2942
+
2943
+	/**
2944
+	 * @var boolean $show_expired_tickets
2945
+	 */
2946
+	public $show_expired_tickets;
2947
+
2948
+	/**
2949
+	 * whether or not to display a dropdown box populated with event datetimes
2950
+	 * that toggles which tickets are displayed for a ticket selector.
2951
+	 * uses one of the *_DATETIME_SELECTOR constants defined above
2952
+	 *
2953
+	 * @var string $show_datetime_selector
2954
+	 */
2955
+	private $show_datetime_selector = 'no_datetime_selector';
2956
+
2957
+	/**
2958
+	 * the number of datetimes an event has to have before conditionally displaying a datetime selector
2959
+	 *
2960
+	 * @var int $datetime_selector_threshold
2961
+	 */
2962
+	private $datetime_selector_threshold = 3;
2963
+
2964
+
2965
+
2966
+	/**
2967
+	 *    class constructor
2968
+	 */
2969
+	public function __construct()
2970
+	{
2971
+		$this->show_ticket_sale_columns = true;
2972
+		$this->show_ticket_details = true;
2973
+		$this->show_expired_tickets = true;
2974
+		$this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
2975
+		$this->datetime_selector_threshold = 3;
2976
+	}
2977
+
2978
+
2979
+
2980
+	/**
2981
+	 * returns true if a datetime selector should be displayed
2982
+	 *
2983
+	 * @param array $datetimes
2984
+	 * @return bool
2985
+	 */
2986
+	public function showDatetimeSelector(array $datetimes)
2987
+	{
2988
+		// if the settings are NOT: don't show OR below threshold, THEN active = true
2989
+		return ! (
2990
+			$this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
2991
+			|| (
2992
+				$this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR
2993
+				&& count($datetimes) < $this->getDatetimeSelectorThreshold()
2994
+			)
2995
+		);
2996
+	}
2997
+
2998
+
2999
+
3000
+	/**
3001
+	 * @return string
3002
+	 */
3003
+	public function getShowDatetimeSelector()
3004
+	{
3005
+		return $this->show_datetime_selector;
3006
+	}
3007
+
3008
+
3009
+
3010
+	/**
3011
+	 * @param bool $keys_only
3012
+	 * @return array
3013
+	 */
3014
+	public function getShowDatetimeSelectorOptions($keys_only = true)
3015
+	{
3016
+		return $keys_only
3017
+			? array(
3018
+				\EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
3019
+				\EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
3020
+			)
3021
+			: array(
3022
+				\EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__(
3023
+					'Do not show date & time filter', 'event_espresso'
3024
+				),
3025
+				\EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR  => esc_html__(
3026
+					'Maybe show date & time filter', 'event_espresso'
3027
+				),
3028
+			);
3029
+	}
3030
+
3031
+
3032
+
3033
+	/**
3034
+	 * @param string $show_datetime_selector
3035
+	 */
3036
+	public function setShowDatetimeSelector($show_datetime_selector)
3037
+	{
3038
+		$this->show_datetime_selector = in_array(
3039
+			$show_datetime_selector,
3040
+			$this->getShowDatetimeSelectorOptions(),
3041
+			true
3042
+		)
3043
+			? $show_datetime_selector
3044
+			: \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3045
+	}
3046
+
3047
+
3048
+
3049
+	/**
3050
+	 * @return int
3051
+	 */
3052
+	public function getDatetimeSelectorThreshold()
3053
+	{
3054
+		return $this->datetime_selector_threshold;
3055
+	}
3056
+
3057
+
3058
+
3059
+
3060
+	/**
3061
+	 * @param int $datetime_selector_threshold
3062
+	 */
3063
+	public function setDatetimeSelectorThreshold($datetime_selector_threshold)
3064
+	{
3065
+		$datetime_selector_threshold = absint($datetime_selector_threshold);
3066
+		$this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3;
3067
+	}
3068 3068
 
3069 3069
 
3070 3070
 
@@ -3082,85 +3082,85 @@  discard block
 block discarded – undo
3082 3082
 class EE_Environment_Config extends EE_Config_Base
3083 3083
 {
3084 3084
 
3085
-    /**
3086
-     * Hold any php environment variables that we want to track.
3087
-     *
3088
-     * @var stdClass;
3089
-     */
3090
-    public $php;
3091
-
3092
-
3093
-
3094
-    /**
3095
-     *    constructor
3096
-     */
3097
-    public function __construct()
3098
-    {
3099
-        $this->php = new stdClass();
3100
-        $this->_set_php_values();
3101
-    }
3102
-
3103
-
3104
-
3105
-    /**
3106
-     * This sets the php environment variables.
3107
-     *
3108
-     * @since 4.4.0
3109
-     * @return void
3110
-     */
3111
-    protected function _set_php_values()
3112
-    {
3113
-        $this->php->max_input_vars = ini_get('max_input_vars');
3114
-        $this->php->version = phpversion();
3115
-    }
3116
-
3117
-
3118
-
3119
-    /**
3120
-     * helper method for determining whether input_count is
3121
-     * reaching the potential maximum the server can handle
3122
-     * according to max_input_vars
3123
-     *
3124
-     * @param int   $input_count the count of input vars.
3125
-     * @return array {
3126
-     *                           An array that represents whether available space and if no available space the error
3127
-     *                           message.
3128
-     * @type bool   $has_space   whether more inputs can be added.
3129
-     * @type string $msg         Any message to be displayed.
3130
-     *                           }
3131
-     */
3132
-    public function max_input_vars_limit_check($input_count = 0)
3133
-    {
3134
-        if (! empty($this->php->max_input_vars)
3135
-            && ($input_count >= $this->php->max_input_vars)
3136
-            && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9)
3137
-        ) {
3138
-            return sprintf(
3139
-                __(
3140
-                    'The maximum number of inputs on this page has been exceeded.  You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.',
3141
-                    'event_espresso'
3142
-                ),
3143
-                '<br>',
3144
-                $input_count,
3145
-                $this->php->max_input_vars
3146
-            );
3147
-        } else {
3148
-            return '';
3149
-        }
3150
-    }
3151
-
3152
-
3153
-
3154
-    /**
3155
-     * The purpose of this method is just to force rechecking php values so if they've changed, they get updated.
3156
-     *
3157
-     * @since 4.4.1
3158
-     * @return void
3159
-     */
3160
-    public function recheck_values()
3161
-    {
3162
-        $this->_set_php_values();
3163
-    }
3085
+	/**
3086
+	 * Hold any php environment variables that we want to track.
3087
+	 *
3088
+	 * @var stdClass;
3089
+	 */
3090
+	public $php;
3091
+
3092
+
3093
+
3094
+	/**
3095
+	 *    constructor
3096
+	 */
3097
+	public function __construct()
3098
+	{
3099
+		$this->php = new stdClass();
3100
+		$this->_set_php_values();
3101
+	}
3102
+
3103
+
3104
+
3105
+	/**
3106
+	 * This sets the php environment variables.
3107
+	 *
3108
+	 * @since 4.4.0
3109
+	 * @return void
3110
+	 */
3111
+	protected function _set_php_values()
3112
+	{
3113
+		$this->php->max_input_vars = ini_get('max_input_vars');
3114
+		$this->php->version = phpversion();
3115
+	}
3116
+
3117
+
3118
+
3119
+	/**
3120
+	 * helper method for determining whether input_count is
3121
+	 * reaching the potential maximum the server can handle
3122
+	 * according to max_input_vars
3123
+	 *
3124
+	 * @param int   $input_count the count of input vars.
3125
+	 * @return array {
3126
+	 *                           An array that represents whether available space and if no available space the error
3127
+	 *                           message.
3128
+	 * @type bool   $has_space   whether more inputs can be added.
3129
+	 * @type string $msg         Any message to be displayed.
3130
+	 *                           }
3131
+	 */
3132
+	public function max_input_vars_limit_check($input_count = 0)
3133
+	{
3134
+		if (! empty($this->php->max_input_vars)
3135
+			&& ($input_count >= $this->php->max_input_vars)
3136
+			&& (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9)
3137
+		) {
3138
+			return sprintf(
3139
+				__(
3140
+					'The maximum number of inputs on this page has been exceeded.  You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.',
3141
+					'event_espresso'
3142
+				),
3143
+				'<br>',
3144
+				$input_count,
3145
+				$this->php->max_input_vars
3146
+			);
3147
+		} else {
3148
+			return '';
3149
+		}
3150
+	}
3151
+
3152
+
3153
+
3154
+	/**
3155
+	 * The purpose of this method is just to force rechecking php values so if they've changed, they get updated.
3156
+	 *
3157
+	 * @since 4.4.1
3158
+	 * @return void
3159
+	 */
3160
+	public function recheck_values()
3161
+	{
3162
+		$this->_set_php_values();
3163
+	}
3164 3164
 
3165 3165
 
3166 3166
 
@@ -3178,22 +3178,22 @@  discard block
 block discarded – undo
3178 3178
 class EE_Tax_Config extends EE_Config_Base
3179 3179
 {
3180 3180
 
3181
-    /*
3181
+	/*
3182 3182
      * flag to indicate whether or not to display ticket prices with the taxes included
3183 3183
      *
3184 3184
      * @var boolean $prices_displayed_including_taxes
3185 3185
      */
3186
-    public $prices_displayed_including_taxes;
3186
+	public $prices_displayed_including_taxes;
3187 3187
 
3188 3188
 
3189 3189
 
3190
-    /**
3191
-     *    class constructor
3192
-     */
3193
-    public function __construct()
3194
-    {
3195
-        $this->prices_displayed_including_taxes = true;
3196
-    }
3190
+	/**
3191
+	 *    class constructor
3192
+	 */
3193
+	public function __construct()
3194
+	{
3195
+		$this->prices_displayed_including_taxes = true;
3196
+	}
3197 3197
 }
3198 3198
 
3199 3199
 
@@ -3208,17 +3208,17 @@  discard block
 block discarded – undo
3208 3208
 class EE_Messages_Config extends EE_Config_Base
3209 3209
 {
3210 3210
 
3211
-    /**
3212
-     * This is an integer representing the deletion threshold in months for when old messages will get deleted.
3213
-     * A value of 0 represents never deleting.  Default is 0.
3214
-     *
3215
-     * @var integer
3216
-     */
3217
-    public $delete_threshold;
3218
-
3219
-    public function __construct() {
3220
-        $this->delete_threshold = 0;
3221
-    }
3211
+	/**
3212
+	 * This is an integer representing the deletion threshold in months for when old messages will get deleted.
3213
+	 * A value of 0 represents never deleting.  Default is 0.
3214
+	 *
3215
+	 * @var integer
3216
+	 */
3217
+	public $delete_threshold;
3218
+
3219
+	public function __construct() {
3220
+		$this->delete_threshold = 0;
3221
+	}
3222 3222
 }
3223 3223
 
3224 3224
 
@@ -3230,34 +3230,34 @@  discard block
 block discarded – undo
3230 3230
 class EE_Gateway_Config extends EE_Config_Base
3231 3231
 {
3232 3232
 
3233
-    /**
3234
-     * Array with keys that are payment gateways slugs, and values are arrays
3235
-     * with any config info the gateway wants to store
3236
-     *
3237
-     * @var array
3238
-     */
3239
-    public $payment_settings;
3240
-
3241
-    /**
3242
-     * Where keys are gateway slugs, and values are booleans indicating whether or not
3243
-     * the gateway is stored in the uploads directory
3244
-     *
3245
-     * @var array
3246
-     */
3247
-    public $active_gateways;
3248
-
3249
-
3250
-
3251
-    /**
3252
-     *    class constructor
3253
-     *
3254
-     * @deprecated
3255
-     */
3256
-    public function __construct()
3257
-    {
3258
-        $this->payment_settings = array();
3259
-        $this->active_gateways = array('Invoice' => false);
3260
-    }
3233
+	/**
3234
+	 * Array with keys that are payment gateways slugs, and values are arrays
3235
+	 * with any config info the gateway wants to store
3236
+	 *
3237
+	 * @var array
3238
+	 */
3239
+	public $payment_settings;
3240
+
3241
+	/**
3242
+	 * Where keys are gateway slugs, and values are booleans indicating whether or not
3243
+	 * the gateway is stored in the uploads directory
3244
+	 *
3245
+	 * @var array
3246
+	 */
3247
+	public $active_gateways;
3248
+
3249
+
3250
+
3251
+	/**
3252
+	 *    class constructor
3253
+	 *
3254
+	 * @deprecated
3255
+	 */
3256
+	public function __construct()
3257
+	{
3258
+		$this->payment_settings = array();
3259
+		$this->active_gateways = array('Invoice' => false);
3260
+	}
3261 3261
 }
3262 3262
 
3263 3263
 // End of file EE_Config.core.php
Please login to merge, or discard this patch.
core/admin/EE_Admin.core.php 2 patches
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
     public static function instance()
41 41
     {
42 42
         // check if class object is instantiated
43
-        if (! self::$_instance instanceof EE_Admin) {
43
+        if ( ! self::$_instance instanceof EE_Admin) {
44 44
             self::$_instance = new self();
45 45
         }
46 46
         return self::$_instance;
@@ -100,11 +100,11 @@  discard block
 block discarded – undo
100 100
      */
101 101
     private function _define_all_constants()
102 102
     {
103
-        if (! defined('EE_ADMIN_URL')) {
104
-            define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/');
105
-            define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/');
106
-            define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates' . DS);
107
-            define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/');
103
+        if ( ! defined('EE_ADMIN_URL')) {
104
+            define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL.'core/admin/');
105
+            define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL.'admin_pages/');
106
+            define('EE_ADMIN_TEMPLATE', EE_ADMIN.'templates'.DS);
107
+            define('WP_ADMIN_PATH', ABSPATH.'wp-admin/');
108 108
             define('WP_AJAX_URL', admin_url('admin-ajax.php'));
109 109
         }
110 110
     }
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
         // set $main_file in stone
123 123
         static $main_file;
124 124
         // if $main_file is not set yet
125
-        if (! $main_file) {
125
+        if ( ! $main_file) {
126 126
             $main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE);
127 127
         }
128 128
         if ($plugin === $main_file) {
@@ -175,9 +175,9 @@  discard block
 block discarded – undo
175 175
     public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array())
176 176
     {
177 177
         return array(
178
-            'maintenance' => EE_ADMIN_PAGES . 'maintenance' . DS,
179
-            'about'       => EE_ADMIN_PAGES . 'about' . DS,
180
-            'support'     => EE_ADMIN_PAGES . 'support' . DS,
178
+            'maintenance' => EE_ADMIN_PAGES.'maintenance'.DS,
179
+            'about'       => EE_ADMIN_PAGES.'about'.DS,
180
+            'support'     => EE_ADMIN_PAGES.'support'.DS,
181 181
         );
182 182
     }
183 183
 
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
             add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 2);
220 220
         }
221 221
         // run the admin page factory but ONLY if we are doing an ee admin ajax request
222
-        if (! defined('DOING_AJAX') || EE_ADMIN_AJAX) {
222
+        if ( ! defined('DOING_AJAX') || EE_ADMIN_AJAX) {
223 223
             try {
224 224
                 //this loads the controller for the admin pages which will setup routing etc
225 225
                 EE_Registry::instance()->load_core('Admin_Page_Loader');
@@ -267,13 +267,13 @@  discard block
 block discarded – undo
267 267
                     '</strong>',
268 268
                     '<a href="https://eventespresso.com/2017/08/important-upcoming-changes-dates-times">',
269 269
                     '</a>',
270
-                    '<a href="' . EE_Admin_Page::add_query_args_and_nonce(
270
+                    '<a href="'.EE_Admin_Page::add_query_args_and_nonce(
271 271
                         array(
272 272
                             'page' => 'espresso_maintenance_settings',
273 273
                             'action' => 'datetime_tools'
274 274
                         ),
275 275
                         admin_url('admin.php')
276
-                    ) . '">'
276
+                    ).'">'
277 277
                 ),
278 278
                 false,
279 279
                 'manage_options',
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
     public function enable_hidden_ee_nav_menu_metaboxes()
322 322
     {
323 323
         global $wp_meta_boxes, $pagenow;
324
-        if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') {
324
+        if ( ! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') {
325 325
             return;
326 326
         }
327 327
         $user = wp_get_current_user();
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
      */
393 393
     public function modify_edit_post_link($link, $id)
394 394
     {
395
-        if (! $post = get_post($id)) {
395
+        if ( ! $post = get_post($id)) {
396 396
             return $link;
397 397
         }
398 398
         if ($post->post_type === 'espresso_attendees') {
@@ -618,7 +618,7 @@  discard block
 block discarded – undo
618 618
 
619 619
         //loop through to remove any critical pages from the array.
620 620
         foreach ($critical_pages as $page_id) {
621
-            $needle = 'value="' . $page_id . '"';
621
+            $needle = 'value="'.$page_id.'"';
622 622
             foreach ($split_output as $key => $haystack) {
623 623
                 if (strpos($haystack, $needle) !== false) {
624 624
                     unset($split_output[$key]);
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
         // calls.
643 643
         wp_enqueue_script(
644 644
             'ee-inject-wp',
645
-            EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js',
645
+            EE_ADMIN_URL.'assets/ee-cpt-wp-injects.js',
646 646
             array('jquery'),
647 647
             EVENT_ESPRESSO_VERSION,
648 648
             true
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
         // register cookie script for future dependencies
651 651
         wp_register_script(
652 652
             'jquery-cookie',
653
-            EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js',
653
+            EE_THIRD_PARTY_URL.'joyride/jquery.cookie.js',
654 654
             array('jquery'),
655 655
             '2.1',
656 656
             true
@@ -659,16 +659,16 @@  discard block
 block discarded – undo
659 659
         // via: add_filter('FHEE_load_joyride', '__return_true' );
660 660
         if (apply_filters('FHEE_load_joyride', false)) {
661 661
             //joyride style
662
-            wp_register_style('joyride-css', EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css', array(), '2.1');
662
+            wp_register_style('joyride-css', EE_THIRD_PARTY_URL.'joyride/joyride-2.1.css', array(), '2.1');
663 663
             wp_register_style(
664 664
                 'ee-joyride-css',
665
-                EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css',
665
+                EE_GLOBAL_ASSETS_URL.'css/ee-joyride-styles.css',
666 666
                 array('joyride-css'),
667 667
                 EVENT_ESPRESSO_VERSION
668 668
             );
669 669
             wp_register_script(
670 670
                 'joyride-modernizr',
671
-                EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js',
671
+                EE_THIRD_PARTY_URL.'joyride/modernizr.mq.js',
672 672
                 array(),
673 673
                 '2.1',
674 674
                 true
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
             //joyride JS
677 677
             wp_register_script(
678 678
                 'jquery-joyride',
679
-                EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js',
679
+                EE_THIRD_PARTY_URL.'joyride/jquery.joyride-2.1.js',
680 680
                 array('jquery-cookie', 'joyride-modernizr'),
681 681
                 '2.1',
682 682
                 true
@@ -725,21 +725,21 @@  discard block
 block discarded – undo
725 725
                 ),
726 726
             )
727 727
         );
728
-        $items['registrations']['url']   = EE_Admin_Page::add_query_args_and_nonce(
728
+        $items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce(
729 729
             array('page' => 'espresso_registrations'),
730 730
             admin_url('admin.php')
731 731
         );
732
-        $items['registrations']['text']  = sprintf(
732
+        $items['registrations']['text'] = sprintf(
733 733
             _n('%s Registration', '%s Registrations', $registrations),
734 734
             number_format_i18n($registrations)
735 735
         );
736 736
         $items['registrations']['title'] = esc_html__('Click to view all registrations', 'event_espresso');
737 737
 
738
-        $items = (array)apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items);
738
+        $items = (array) apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items);
739 739
 
740 740
         foreach ($items as $type => $item_properties) {
741 741
             $elements[] = sprintf(
742
-                '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>',
742
+                '<a class="ee-dashboard-link-'.$type.'" href="%s" title="%s">%s</a>',
743 743
                 $item_properties['url'],
744 744
                 $item_properties['title'],
745 745
                 $item_properties['text']
@@ -764,10 +764,10 @@  discard block
 block discarded – undo
764 764
         // check for date_format or time_format
765 765
         switch ($option) {
766 766
             case 'date_format':
767
-                $date_time_format = $value . ' ' . get_option('time_format');
767
+                $date_time_format = $value.' '.get_option('time_format');
768 768
                 break;
769 769
             case 'time_format':
770
-                $date_time_format = get_option('date_format') . ' ' . $value;
770
+                $date_time_format = get_option('date_format').' '.$value;
771 771
                 break;
772 772
             default:
773 773
                 $date_time_format = false;
@@ -790,7 +790,7 @@  discard block
 block discarded – undo
790 790
 
791 791
 
792 792
                 foreach ($error_msg as $error) {
793
-                    $msg .= '<li>' . $error . '</li>';
793
+                    $msg .= '<li>'.$error.'</li>';
794 794
                 }
795 795
 
796 796
                 $msg .= '</ul></p><p>'
Please login to merge, or discard this patch.
Indentation   +899 added lines, -899 removed lines patch added patch discarded remove patch
@@ -22,457 +22,457 @@  discard block
 block discarded – undo
22 22
 final class EE_Admin implements InterminableInterface
23 23
 {
24 24
 
25
-    /**
26
-     * @var EE_Admin $_instance
27
-     */
28
-    private static $_instance;
29
-
30
-    /**
31
-     * @var PersistentAdminNoticeManager $persistent_admin_notice_manager
32
-     */
33
-    private $persistent_admin_notice_manager;
34
-
35
-    /**
36
-     * @singleton method used to instantiate class object
37
-     * @return EE_Admin
38
-     * @throws EE_Error
39
-     */
40
-    public static function instance()
41
-    {
42
-        // check if class object is instantiated
43
-        if (! self::$_instance instanceof EE_Admin) {
44
-            self::$_instance = new self();
45
-        }
46
-        return self::$_instance;
47
-    }
48
-
49
-
50
-    /**
51
-     * @return EE_Admin
52
-     * @throws EE_Error
53
-     */
54
-    public static function reset()
55
-    {
56
-        self::$_instance = null;
57
-        return self::instance();
58
-    }
59
-
60
-
61
-    /**
62
-     * class constructor
63
-     *
64
-     * @throws EE_Error
65
-     * @throws InvalidDataTypeException
66
-     * @throws InvalidInterfaceException
67
-     * @throws InvalidArgumentException
68
-     */
69
-    protected function __construct()
70
-    {
71
-        // define global EE_Admin constants
72
-        $this->_define_all_constants();
73
-        // set autoloaders for our admin page classes based on included path information
74
-        EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_ADMIN);
75
-        // admin hooks
76
-        add_filter('plugin_action_links', array($this, 'filter_plugin_actions'), 10, 2);
77
-        // load EE_Request_Handler early
78
-        add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'get_request'));
79
-        add_action('AHEE__EE_System__initialize_last', array($this, 'init'));
80
-        add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'route_admin_request'), 100, 2);
81
-        add_action('wp_loaded', array($this, 'wp_loaded'), 100);
82
-        add_action('admin_init', array($this, 'admin_init'), 100);
83
-        add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'), 20);
84
-        add_action('admin_notices', array($this, 'display_admin_notices'), 10);
85
-        add_action('network_admin_notices', array($this, 'display_admin_notices'), 10);
86
-        add_filter('pre_update_option', array($this, 'check_for_invalid_datetime_formats'), 100, 2);
87
-        add_filter('admin_footer_text', array($this, 'espresso_admin_footer'));
88
-        //reset Environment config (we only do this on admin page loads);
89
-        EE_Registry::instance()->CFG->environment->recheck_values();
90
-        do_action('AHEE__EE_Admin__loaded');
91
-    }
92
-
93
-
94
-
95
-    /**
96
-     * _define_all_constants
97
-     * define constants that are set globally for all admin pages
98
-     *
99
-     * @return void
100
-     */
101
-    private function _define_all_constants()
102
-    {
103
-        if (! defined('EE_ADMIN_URL')) {
104
-            define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/');
105
-            define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/');
106
-            define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates' . DS);
107
-            define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/');
108
-            define('WP_AJAX_URL', admin_url('admin-ajax.php'));
109
-        }
110
-    }
111
-
112
-
113
-    /**
114
-     * filter_plugin_actions - adds links to the Plugins page listing
115
-     *
116
-     * @param    array  $links
117
-     * @param    string $plugin
118
-     * @return    array
119
-     */
120
-    public function filter_plugin_actions($links, $plugin)
121
-    {
122
-        // set $main_file in stone
123
-        static $main_file;
124
-        // if $main_file is not set yet
125
-        if (! $main_file) {
126
-            $main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE);
127
-        }
128
-        if ($plugin === $main_file) {
129
-            // compare current plugin to this one
130
-            if (EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance) {
131
-                $maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings"'
132
-                                    . ' title="Event Espresso is in maintenance mode.  Click this link to learn why.">'
133
-                                    . esc_html__('Maintenance Mode Active', 'event_espresso')
134
-                                    . '</a>';
135
-                array_unshift($links, $maintenance_link);
136
-            } else {
137
-                $org_settings_link = '<a href="admin.php?page=espresso_general_settings">'
138
-                                     . esc_html__('Settings', 'event_espresso')
139
-                                     . '</a>';
140
-                $events_link       = '<a href="admin.php?page=espresso_events">'
141
-                                     . esc_html__('Events', 'event_espresso')
142
-                                     . '</a>';
143
-                // add before other links
144
-                array_unshift($links, $org_settings_link, $events_link);
145
-            }
146
-        }
147
-        return $links;
148
-    }
149
-
150
-
151
-    /**
152
-     * _get_request
153
-     *
154
-     * @return void
155
-     * @throws EE_Error
156
-     * @throws InvalidArgumentException
157
-     * @throws InvalidDataTypeException
158
-     * @throws InvalidInterfaceException
159
-     * @throws ReflectionException
160
-     */
161
-    public function get_request()
162
-    {
163
-        EE_Registry::instance()->load_core('Request_Handler');
164
-        EE_Registry::instance()->load_core('CPT_Strategy');
165
-    }
166
-
167
-
168
-
169
-    /**
170
-     * hide_admin_pages_except_maintenance_mode
171
-     *
172
-     * @param array $admin_page_folder_names
173
-     * @return array
174
-     */
175
-    public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array())
176
-    {
177
-        return array(
178
-            'maintenance' => EE_ADMIN_PAGES . 'maintenance' . DS,
179
-            'about'       => EE_ADMIN_PAGES . 'about' . DS,
180
-            'support'     => EE_ADMIN_PAGES . 'support' . DS,
181
-        );
182
-    }
183
-
184
-
185
-
186
-    /**
187
-     * init- should fire after shortcode, module,  addon, other plugin (default priority), and even
188
-     * EE_Front_Controller's init phases have run
189
-     *
190
-     * @return void
191
-     * @throws EE_Error
192
-     * @throws InvalidArgumentException
193
-     * @throws InvalidDataTypeException
194
-     * @throws InvalidInterfaceException
195
-     * @throws ReflectionException
196
-     * @throws ServiceNotFoundException
197
-     */
198
-    public function init()
199
-    {
200
-        //only enable most of the EE_Admin IF we're not in full maintenance mode
201
-        if (EE_Maintenance_Mode::instance()->models_can_query()) {
202
-            //ok so we want to enable the entire admin
203
-            $this->persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared(
204
-                'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
205
-            );
206
-            $this->persistent_admin_notice_manager->setReturnUrl(
207
-                EE_Admin_Page::add_query_args_and_nonce(
208
-                    array(
209
-                        'page'   => EE_Registry::instance()->REQ->get('page', ''),
210
-                        'action' => EE_Registry::instance()->REQ->get('action', ''),
211
-                    ),
212
-                    EE_ADMIN_URL
213
-                )
214
-            );
215
-            $this->maybeSetDatetimeWarningNotice();
216
-            //at a glance dashboard widget
217
-            add_filter('dashboard_glance_items', array($this, 'dashboard_glance_items'), 10);
218
-            //filter for get_edit_post_link used on comments for custom post types
219
-            add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 2);
220
-        }
221
-        // run the admin page factory but ONLY if we are doing an ee admin ajax request
222
-        if (! defined('DOING_AJAX') || EE_ADMIN_AJAX) {
223
-            try {
224
-                //this loads the controller for the admin pages which will setup routing etc
225
-                EE_Registry::instance()->load_core('Admin_Page_Loader');
226
-            } catch (EE_Error $e) {
227
-                $e->get_error();
228
-            }
229
-        }
230
-        add_filter('content_save_pre', array($this, 'its_eSpresso'), 10, 1);
231
-        //make sure our CPTs and custom taxonomy metaboxes get shown for first time users
232
-        add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes'), 10);
233
-        add_action('admin_head', array($this, 'register_custom_nav_menu_boxes'), 10);
234
-        //exclude EE critical pages from all nav menus and wp_list_pages
235
-        add_filter('nav_menu_meta_box_object', array($this, 'remove_pages_from_nav_menu'), 10);
236
-    }
237
-
238
-
239
-    /**
240
-     *    get_persistent_admin_notices
241
-     *
242
-     * @access    public
243
-     * @return void
244
-     * @throws EE_Error
245
-     * @throws InvalidArgumentException
246
-     * @throws InvalidDataTypeException
247
-     * @throws InvalidInterfaceException
248
-     */
249
-    public function maybeSetDatetimeWarningNotice()
250
-    {
251
-        //add dismissable notice for datetime changes.  Only valid if site does not have a timezone_string set.
252
-        //@todo This needs to stay in core for a bit to catch anyone upgrading from a version without this to a version
253
-        //with this.  But after enough time (indeterminate at this point) we can just remove this notice.
254
-        //this was added with https://events.codebasehq.com/projects/event-espresso/tickets/10626
255
-        if (apply_filters('FHEE__EE_Admin__maybeSetDatetimeWarningNotice', true)
256
-            && ! get_option('timezone_string')
257
-            && EEM_Event::instance()->count() > 0
258
-        ) {
259
-            new PersistentAdminNotice(
260
-                'datetime_fix_notice',
261
-                sprintf(
262
-                    esc_html__(
263
-                        '%1$sImportant announcement related to your install of Event Espresso%2$s: There are some changes made to your site that could affect how dates display for your events and other related items with dates and times.  Read more about it %3$shere%4$s. If your dates and times are displaying incorrectly (incorrect offset), you can fix it using the tool on %5$sthis page%4$s.',
264
-                        'event_espresso'
265
-                    ),
266
-                    '<strong>',
267
-                    '</strong>',
268
-                    '<a href="https://eventespresso.com/2017/08/important-upcoming-changes-dates-times">',
269
-                    '</a>',
270
-                    '<a href="' . EE_Admin_Page::add_query_args_and_nonce(
271
-                        array(
272
-                            'page' => 'espresso_maintenance_settings',
273
-                            'action' => 'datetime_tools'
274
-                        ),
275
-                        admin_url('admin.php')
276
-                    ) . '">'
277
-                ),
278
-                false,
279
-                'manage_options',
280
-                'datetime_fix_persistent_notice'
281
-            );
282
-        }
283
-    }
284
-
285
-
286
-
287
-    /**
288
-     * this simply hooks into the nav menu setup of pages metabox and makes sure that we remove EE critical pages from
289
-     * the list of options. the wp function "wp_nav_menu_item_post_type_meta_box" found in
290
-     * wp-admin/includes/nav-menu.php looks for the "_default_query" property on the post_type object and it uses that
291
-     * to override any queries found in the existing query for the given post type.  Note that _default_query is not a
292
-     * normal property on the post_type object.  It's found ONLY in this particular context.
293
-     *
294
-     * @param WP_Post $post_type WP post type object
295
-     * @return WP_Post
296
-     * @throws InvalidArgumentException
297
-     * @throws InvalidDataTypeException
298
-     * @throws InvalidInterfaceException
299
-     */
300
-    public function remove_pages_from_nav_menu($post_type)
301
-    {
302
-        //if this isn't the "pages" post type let's get out
303
-        if ($post_type->name !== 'page') {
304
-            return $post_type;
305
-        }
306
-        $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();
307
-        $post_type->_default_query = array(
308
-            'post__not_in' => $critical_pages,
309
-        );
310
-        return $post_type;
311
-    }
312
-
313
-
314
-
315
-    /**
316
-     * WP by default only shows three metaboxes in "nav-menus.php" for first times users.  We want to make sure our
317
-     * metaboxes get shown as well
318
-     *
319
-     * @return void
320
-     */
321
-    public function enable_hidden_ee_nav_menu_metaboxes()
322
-    {
323
-        global $wp_meta_boxes, $pagenow;
324
-        if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') {
325
-            return;
326
-        }
327
-        $user = wp_get_current_user();
328
-        //has this been done yet?
329
-        if (get_user_option('ee_nav_menu_initialized', $user->ID)) {
330
-            return;
331
-        }
332
-
333
-        $hidden_meta_boxes  = get_user_option('metaboxhidden_nav-menus', $user->ID);
334
-        $initial_meta_boxes = apply_filters(
335
-            'FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes',
336
-            array(
337
-                'nav-menu-theme-locations',
338
-                'add-page',
339
-                'add-custom-links',
340
-                'add-category',
341
-                'add-espresso_events',
342
-                'add-espresso_venues',
343
-                'add-espresso_event_categories',
344
-                'add-espresso_venue_categories',
345
-                'add-post-type-post',
346
-                'add-post-type-page',
347
-            )
348
-        );
349
-
350
-        if (is_array($hidden_meta_boxes)) {
351
-            foreach ($hidden_meta_boxes as $key => $meta_box_id) {
352
-                if (in_array($meta_box_id, $initial_meta_boxes, true)) {
353
-                    unset($hidden_meta_boxes[$key]);
354
-                }
355
-            }
356
-        }
357
-        update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true);
358
-        update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true);
359
-    }
360
-
361
-
362
-
363
-    /**
364
-     * This method simply registers custom nav menu boxes for "nav_menus.php route"
365
-     * Currently EE is using this to make sure there are menu options for our CPT archive page routes.
366
-     *
367
-     * @todo   modify this so its more dynamic and automatic for all ee CPTs and setups and can also be hooked into by
368
-     *         addons etc.
369
-     * @return void
370
-     */
371
-    public function register_custom_nav_menu_boxes()
372
-    {
373
-        add_meta_box(
374
-            'add-extra-nav-menu-pages',
375
-            esc_html__('Event Espresso Pages', 'event_espresso'),
376
-            array($this, 'ee_cpt_archive_pages'),
377
-            'nav-menus',
378
-            'side',
379
-            'core'
380
-        );
381
-    }
382
-
383
-
384
-
385
-    /**
386
-     * Use this to edit the post link for our cpts so that the edit link points to the correct page.
387
-     *
388
-     * @since   4.3.0
389
-     * @param string $link the original link generated by wp
390
-     * @param int    $id   post id
391
-     * @return string  the (maybe) modified link
392
-     */
393
-    public function modify_edit_post_link($link, $id)
394
-    {
395
-        if (! $post = get_post($id)) {
396
-            return $link;
397
-        }
398
-        if ($post->post_type === 'espresso_attendees') {
399
-            $query_args = array(
400
-                'action' => 'edit_attendee',
401
-                'post'   => $id,
402
-            );
403
-            return EEH_URL::add_query_args_and_nonce(
404
-                $query_args,
405
-                admin_url('admin.php?page=espresso_registrations')
406
-            );
407
-        }
408
-        return $link;
409
-    }
410
-
411
-
412
-
413
-    public function ee_cpt_archive_pages()
414
-    {
415
-        global $nav_menu_selected_id;
416
-        $db_fields   = false;
417
-        $walker      = new Walker_Nav_Menu_Checklist($db_fields);
418
-        $current_tab = 'event-archives';
419
-        $removed_args = array(
420
-            'action',
421
-            'customlink-tab',
422
-            'edit-menu-item',
423
-            'menu-item',
424
-            'page-tab',
425
-            '_wpnonce',
426
-        );
427
-        ?>
25
+	/**
26
+	 * @var EE_Admin $_instance
27
+	 */
28
+	private static $_instance;
29
+
30
+	/**
31
+	 * @var PersistentAdminNoticeManager $persistent_admin_notice_manager
32
+	 */
33
+	private $persistent_admin_notice_manager;
34
+
35
+	/**
36
+	 * @singleton method used to instantiate class object
37
+	 * @return EE_Admin
38
+	 * @throws EE_Error
39
+	 */
40
+	public static function instance()
41
+	{
42
+		// check if class object is instantiated
43
+		if (! self::$_instance instanceof EE_Admin) {
44
+			self::$_instance = new self();
45
+		}
46
+		return self::$_instance;
47
+	}
48
+
49
+
50
+	/**
51
+	 * @return EE_Admin
52
+	 * @throws EE_Error
53
+	 */
54
+	public static function reset()
55
+	{
56
+		self::$_instance = null;
57
+		return self::instance();
58
+	}
59
+
60
+
61
+	/**
62
+	 * class constructor
63
+	 *
64
+	 * @throws EE_Error
65
+	 * @throws InvalidDataTypeException
66
+	 * @throws InvalidInterfaceException
67
+	 * @throws InvalidArgumentException
68
+	 */
69
+	protected function __construct()
70
+	{
71
+		// define global EE_Admin constants
72
+		$this->_define_all_constants();
73
+		// set autoloaders for our admin page classes based on included path information
74
+		EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_ADMIN);
75
+		// admin hooks
76
+		add_filter('plugin_action_links', array($this, 'filter_plugin_actions'), 10, 2);
77
+		// load EE_Request_Handler early
78
+		add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'get_request'));
79
+		add_action('AHEE__EE_System__initialize_last', array($this, 'init'));
80
+		add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'route_admin_request'), 100, 2);
81
+		add_action('wp_loaded', array($this, 'wp_loaded'), 100);
82
+		add_action('admin_init', array($this, 'admin_init'), 100);
83
+		add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'), 20);
84
+		add_action('admin_notices', array($this, 'display_admin_notices'), 10);
85
+		add_action('network_admin_notices', array($this, 'display_admin_notices'), 10);
86
+		add_filter('pre_update_option', array($this, 'check_for_invalid_datetime_formats'), 100, 2);
87
+		add_filter('admin_footer_text', array($this, 'espresso_admin_footer'));
88
+		//reset Environment config (we only do this on admin page loads);
89
+		EE_Registry::instance()->CFG->environment->recheck_values();
90
+		do_action('AHEE__EE_Admin__loaded');
91
+	}
92
+
93
+
94
+
95
+	/**
96
+	 * _define_all_constants
97
+	 * define constants that are set globally for all admin pages
98
+	 *
99
+	 * @return void
100
+	 */
101
+	private function _define_all_constants()
102
+	{
103
+		if (! defined('EE_ADMIN_URL')) {
104
+			define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/');
105
+			define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/');
106
+			define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates' . DS);
107
+			define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/');
108
+			define('WP_AJAX_URL', admin_url('admin-ajax.php'));
109
+		}
110
+	}
111
+
112
+
113
+	/**
114
+	 * filter_plugin_actions - adds links to the Plugins page listing
115
+	 *
116
+	 * @param    array  $links
117
+	 * @param    string $plugin
118
+	 * @return    array
119
+	 */
120
+	public function filter_plugin_actions($links, $plugin)
121
+	{
122
+		// set $main_file in stone
123
+		static $main_file;
124
+		// if $main_file is not set yet
125
+		if (! $main_file) {
126
+			$main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE);
127
+		}
128
+		if ($plugin === $main_file) {
129
+			// compare current plugin to this one
130
+			if (EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance) {
131
+				$maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings"'
132
+									. ' title="Event Espresso is in maintenance mode.  Click this link to learn why.">'
133
+									. esc_html__('Maintenance Mode Active', 'event_espresso')
134
+									. '</a>';
135
+				array_unshift($links, $maintenance_link);
136
+			} else {
137
+				$org_settings_link = '<a href="admin.php?page=espresso_general_settings">'
138
+									 . esc_html__('Settings', 'event_espresso')
139
+									 . '</a>';
140
+				$events_link       = '<a href="admin.php?page=espresso_events">'
141
+									 . esc_html__('Events', 'event_espresso')
142
+									 . '</a>';
143
+				// add before other links
144
+				array_unshift($links, $org_settings_link, $events_link);
145
+			}
146
+		}
147
+		return $links;
148
+	}
149
+
150
+
151
+	/**
152
+	 * _get_request
153
+	 *
154
+	 * @return void
155
+	 * @throws EE_Error
156
+	 * @throws InvalidArgumentException
157
+	 * @throws InvalidDataTypeException
158
+	 * @throws InvalidInterfaceException
159
+	 * @throws ReflectionException
160
+	 */
161
+	public function get_request()
162
+	{
163
+		EE_Registry::instance()->load_core('Request_Handler');
164
+		EE_Registry::instance()->load_core('CPT_Strategy');
165
+	}
166
+
167
+
168
+
169
+	/**
170
+	 * hide_admin_pages_except_maintenance_mode
171
+	 *
172
+	 * @param array $admin_page_folder_names
173
+	 * @return array
174
+	 */
175
+	public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array())
176
+	{
177
+		return array(
178
+			'maintenance' => EE_ADMIN_PAGES . 'maintenance' . DS,
179
+			'about'       => EE_ADMIN_PAGES . 'about' . DS,
180
+			'support'     => EE_ADMIN_PAGES . 'support' . DS,
181
+		);
182
+	}
183
+
184
+
185
+
186
+	/**
187
+	 * init- should fire after shortcode, module,  addon, other plugin (default priority), and even
188
+	 * EE_Front_Controller's init phases have run
189
+	 *
190
+	 * @return void
191
+	 * @throws EE_Error
192
+	 * @throws InvalidArgumentException
193
+	 * @throws InvalidDataTypeException
194
+	 * @throws InvalidInterfaceException
195
+	 * @throws ReflectionException
196
+	 * @throws ServiceNotFoundException
197
+	 */
198
+	public function init()
199
+	{
200
+		//only enable most of the EE_Admin IF we're not in full maintenance mode
201
+		if (EE_Maintenance_Mode::instance()->models_can_query()) {
202
+			//ok so we want to enable the entire admin
203
+			$this->persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared(
204
+				'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
205
+			);
206
+			$this->persistent_admin_notice_manager->setReturnUrl(
207
+				EE_Admin_Page::add_query_args_and_nonce(
208
+					array(
209
+						'page'   => EE_Registry::instance()->REQ->get('page', ''),
210
+						'action' => EE_Registry::instance()->REQ->get('action', ''),
211
+					),
212
+					EE_ADMIN_URL
213
+				)
214
+			);
215
+			$this->maybeSetDatetimeWarningNotice();
216
+			//at a glance dashboard widget
217
+			add_filter('dashboard_glance_items', array($this, 'dashboard_glance_items'), 10);
218
+			//filter for get_edit_post_link used on comments for custom post types
219
+			add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 2);
220
+		}
221
+		// run the admin page factory but ONLY if we are doing an ee admin ajax request
222
+		if (! defined('DOING_AJAX') || EE_ADMIN_AJAX) {
223
+			try {
224
+				//this loads the controller for the admin pages which will setup routing etc
225
+				EE_Registry::instance()->load_core('Admin_Page_Loader');
226
+			} catch (EE_Error $e) {
227
+				$e->get_error();
228
+			}
229
+		}
230
+		add_filter('content_save_pre', array($this, 'its_eSpresso'), 10, 1);
231
+		//make sure our CPTs and custom taxonomy metaboxes get shown for first time users
232
+		add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes'), 10);
233
+		add_action('admin_head', array($this, 'register_custom_nav_menu_boxes'), 10);
234
+		//exclude EE critical pages from all nav menus and wp_list_pages
235
+		add_filter('nav_menu_meta_box_object', array($this, 'remove_pages_from_nav_menu'), 10);
236
+	}
237
+
238
+
239
+	/**
240
+	 *    get_persistent_admin_notices
241
+	 *
242
+	 * @access    public
243
+	 * @return void
244
+	 * @throws EE_Error
245
+	 * @throws InvalidArgumentException
246
+	 * @throws InvalidDataTypeException
247
+	 * @throws InvalidInterfaceException
248
+	 */
249
+	public function maybeSetDatetimeWarningNotice()
250
+	{
251
+		//add dismissable notice for datetime changes.  Only valid if site does not have a timezone_string set.
252
+		//@todo This needs to stay in core for a bit to catch anyone upgrading from a version without this to a version
253
+		//with this.  But after enough time (indeterminate at this point) we can just remove this notice.
254
+		//this was added with https://events.codebasehq.com/projects/event-espresso/tickets/10626
255
+		if (apply_filters('FHEE__EE_Admin__maybeSetDatetimeWarningNotice', true)
256
+			&& ! get_option('timezone_string')
257
+			&& EEM_Event::instance()->count() > 0
258
+		) {
259
+			new PersistentAdminNotice(
260
+				'datetime_fix_notice',
261
+				sprintf(
262
+					esc_html__(
263
+						'%1$sImportant announcement related to your install of Event Espresso%2$s: There are some changes made to your site that could affect how dates display for your events and other related items with dates and times.  Read more about it %3$shere%4$s. If your dates and times are displaying incorrectly (incorrect offset), you can fix it using the tool on %5$sthis page%4$s.',
264
+						'event_espresso'
265
+					),
266
+					'<strong>',
267
+					'</strong>',
268
+					'<a href="https://eventespresso.com/2017/08/important-upcoming-changes-dates-times">',
269
+					'</a>',
270
+					'<a href="' . EE_Admin_Page::add_query_args_and_nonce(
271
+						array(
272
+							'page' => 'espresso_maintenance_settings',
273
+							'action' => 'datetime_tools'
274
+						),
275
+						admin_url('admin.php')
276
+					) . '">'
277
+				),
278
+				false,
279
+				'manage_options',
280
+				'datetime_fix_persistent_notice'
281
+			);
282
+		}
283
+	}
284
+
285
+
286
+
287
+	/**
288
+	 * this simply hooks into the nav menu setup of pages metabox and makes sure that we remove EE critical pages from
289
+	 * the list of options. the wp function "wp_nav_menu_item_post_type_meta_box" found in
290
+	 * wp-admin/includes/nav-menu.php looks for the "_default_query" property on the post_type object and it uses that
291
+	 * to override any queries found in the existing query for the given post type.  Note that _default_query is not a
292
+	 * normal property on the post_type object.  It's found ONLY in this particular context.
293
+	 *
294
+	 * @param WP_Post $post_type WP post type object
295
+	 * @return WP_Post
296
+	 * @throws InvalidArgumentException
297
+	 * @throws InvalidDataTypeException
298
+	 * @throws InvalidInterfaceException
299
+	 */
300
+	public function remove_pages_from_nav_menu($post_type)
301
+	{
302
+		//if this isn't the "pages" post type let's get out
303
+		if ($post_type->name !== 'page') {
304
+			return $post_type;
305
+		}
306
+		$critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();
307
+		$post_type->_default_query = array(
308
+			'post__not_in' => $critical_pages,
309
+		);
310
+		return $post_type;
311
+	}
312
+
313
+
314
+
315
+	/**
316
+	 * WP by default only shows three metaboxes in "nav-menus.php" for first times users.  We want to make sure our
317
+	 * metaboxes get shown as well
318
+	 *
319
+	 * @return void
320
+	 */
321
+	public function enable_hidden_ee_nav_menu_metaboxes()
322
+	{
323
+		global $wp_meta_boxes, $pagenow;
324
+		if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') {
325
+			return;
326
+		}
327
+		$user = wp_get_current_user();
328
+		//has this been done yet?
329
+		if (get_user_option('ee_nav_menu_initialized', $user->ID)) {
330
+			return;
331
+		}
332
+
333
+		$hidden_meta_boxes  = get_user_option('metaboxhidden_nav-menus', $user->ID);
334
+		$initial_meta_boxes = apply_filters(
335
+			'FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes',
336
+			array(
337
+				'nav-menu-theme-locations',
338
+				'add-page',
339
+				'add-custom-links',
340
+				'add-category',
341
+				'add-espresso_events',
342
+				'add-espresso_venues',
343
+				'add-espresso_event_categories',
344
+				'add-espresso_venue_categories',
345
+				'add-post-type-post',
346
+				'add-post-type-page',
347
+			)
348
+		);
349
+
350
+		if (is_array($hidden_meta_boxes)) {
351
+			foreach ($hidden_meta_boxes as $key => $meta_box_id) {
352
+				if (in_array($meta_box_id, $initial_meta_boxes, true)) {
353
+					unset($hidden_meta_boxes[$key]);
354
+				}
355
+			}
356
+		}
357
+		update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true);
358
+		update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true);
359
+	}
360
+
361
+
362
+
363
+	/**
364
+	 * This method simply registers custom nav menu boxes for "nav_menus.php route"
365
+	 * Currently EE is using this to make sure there are menu options for our CPT archive page routes.
366
+	 *
367
+	 * @todo   modify this so its more dynamic and automatic for all ee CPTs and setups and can also be hooked into by
368
+	 *         addons etc.
369
+	 * @return void
370
+	 */
371
+	public function register_custom_nav_menu_boxes()
372
+	{
373
+		add_meta_box(
374
+			'add-extra-nav-menu-pages',
375
+			esc_html__('Event Espresso Pages', 'event_espresso'),
376
+			array($this, 'ee_cpt_archive_pages'),
377
+			'nav-menus',
378
+			'side',
379
+			'core'
380
+		);
381
+	}
382
+
383
+
384
+
385
+	/**
386
+	 * Use this to edit the post link for our cpts so that the edit link points to the correct page.
387
+	 *
388
+	 * @since   4.3.0
389
+	 * @param string $link the original link generated by wp
390
+	 * @param int    $id   post id
391
+	 * @return string  the (maybe) modified link
392
+	 */
393
+	public function modify_edit_post_link($link, $id)
394
+	{
395
+		if (! $post = get_post($id)) {
396
+			return $link;
397
+		}
398
+		if ($post->post_type === 'espresso_attendees') {
399
+			$query_args = array(
400
+				'action' => 'edit_attendee',
401
+				'post'   => $id,
402
+			);
403
+			return EEH_URL::add_query_args_and_nonce(
404
+				$query_args,
405
+				admin_url('admin.php?page=espresso_registrations')
406
+			);
407
+		}
408
+		return $link;
409
+	}
410
+
411
+
412
+
413
+	public function ee_cpt_archive_pages()
414
+	{
415
+		global $nav_menu_selected_id;
416
+		$db_fields   = false;
417
+		$walker      = new Walker_Nav_Menu_Checklist($db_fields);
418
+		$current_tab = 'event-archives';
419
+		$removed_args = array(
420
+			'action',
421
+			'customlink-tab',
422
+			'edit-menu-item',
423
+			'menu-item',
424
+			'page-tab',
425
+			'_wpnonce',
426
+		);
427
+		?>
428 428
         <div id="posttype-extra-nav-menu-pages" class="posttypediv">
429 429
             <ul id="posttype-extra-nav-menu-pages-tabs" class="posttype-tabs add-menu-item-tabs">
430 430
                 <li <?php echo('event-archives' === $current_tab ? ' class="tabs"' : ''); ?>>
431 431
                     <a class="nav-tab-link" data-type="tabs-panel-posttype-extra-nav-menu-pages-event-archives"
432 432
                        href="<?php if ($nav_menu_selected_id) {
433
-                            echo esc_url(
434
-                                add_query_arg(
435
-                                    'extra-nav-menu-pages-tab',
436
-                                    'event-archives',
437
-                                    remove_query_arg($removed_args)
438
-                                )
439
-                            );
440
-                       } ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives">
433
+							echo esc_url(
434
+								add_query_arg(
435
+									'extra-nav-menu-pages-tab',
436
+									'event-archives',
437
+									remove_query_arg($removed_args)
438
+								)
439
+							);
440
+					   } ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives">
441 441
                         <?php _e('Event Archive Pages', 'event_espresso'); ?>
442 442
                     </a>
443 443
                 </li>
444 444
             </ul><!-- .posttype-tabs -->
445 445
 
446 446
             <div id="tabs-panel-posttype-extra-nav-menu-pages-event-archives" class="tabs-panel <?php
447
-                echo('event-archives' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive');
448
-                ?>">
447
+				echo('event-archives' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive');
448
+				?>">
449 449
                     <ul id="extra-nav-menu-pageschecklist-event-archives" class="categorychecklist form-no-clear">
450 450
                         <?php
451
-                        $pages          = $this->_get_extra_nav_menu_pages_items();
452
-                        $args['walker'] = $walker;
453
-                        echo walk_nav_menu_tree(
454
-                            array_map(
455
-                                array($this, '_setup_extra_nav_menu_pages_items'),
456
-                                $pages
457
-                            ),
458
-                            0,
459
-                            (object) $args
460
-                        );
461
-                        ?>
451
+						$pages          = $this->_get_extra_nav_menu_pages_items();
452
+						$args['walker'] = $walker;
453
+						echo walk_nav_menu_tree(
454
+							array_map(
455
+								array($this, '_setup_extra_nav_menu_pages_items'),
456
+								$pages
457
+							),
458
+							0,
459
+							(object) $args
460
+						);
461
+						?>
462 462
                     </ul>
463 463
                 </div><!-- /.tabs-panel -->
464 464
 
465 465
                 <p class="button-controls">
466 466
                 <span class="list-controls">
467 467
                     <a href="<?php
468
-                    echo esc_url(add_query_arg(
469
-                        array(
470
-                            'extra-nav-menu-pages-tab' => 'event-archives',
471
-                            'selectall'                => 1,
472
-                        ),
473
-                        remove_query_arg($removed_args)
474
-                    ));
475
-                    ?>#posttype-extra-nav-menu-pages>" class="select-all"><?php _e('Select All'); ?></a>
468
+					echo esc_url(add_query_arg(
469
+						array(
470
+							'extra-nav-menu-pages-tab' => 'event-archives',
471
+							'selectall'                => 1,
472
+						),
473
+						remove_query_arg($removed_args)
474
+					));
475
+					?>#posttype-extra-nav-menu-pages>" class="select-all"><?php _e('Select All'); ?></a>
476 476
                 </span>
477 477
                 <span class="add-to-menu">
478 478
                     <input type="submit"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?>
@@ -485,471 +485,471 @@  discard block
 block discarded – undo
485 485
 
486 486
         </div><!-- /.posttypediv -->
487 487
         <?php
488
-    }
489
-
490
-
491
-    /**
492
-     * Returns an array of event archive nav items.
493
-     *
494
-     * @todo  for now this method is just in place so when it gets abstracted further we can substitute in whatever
495
-     *        method we use for getting the extra nav menu items
496
-     * @return array
497
-     */
498
-    private function _get_extra_nav_menu_pages_items()
499
-    {
500
-        $menuitems[] = array(
501
-            'title'       => esc_html__('Event List', 'event_espresso'),
502
-            'url'         => get_post_type_archive_link('espresso_events'),
503
-            'description' => esc_html__('Archive page for all events.', 'event_espresso'),
504
-        );
505
-        return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems);
506
-    }
507
-
508
-
509
-    /**
510
-     * Setup nav menu walker item for usage in the event archive nav menu metabox.  It receives a menu_item array with
511
-     * the properties and converts it to the menu item object.
512
-     *
513
-     * @see wp_setup_nav_menu_item() in wp-includes/nav-menu.php
514
-     * @param $menu_item_values
515
-     * @return stdClass
516
-     */
517
-    private function _setup_extra_nav_menu_pages_items($menu_item_values)
518
-    {
519
-        $menu_item = new stdClass();
520
-        $keys      = array(
521
-            'ID'               => 0,
522
-            'db_id'            => 0,
523
-            'menu_item_parent' => 0,
524
-            'object_id'        => -1,
525
-            'post_parent'      => 0,
526
-            'type'             => 'custom',
527
-            'object'           => '',
528
-            'type_label'       => esc_html__('Extra Nav Menu Item', 'event_espresso'),
529
-            'title'            => '',
530
-            'url'              => '',
531
-            'target'           => '',
532
-            'attr_title'       => '',
533
-            'description'      => '',
534
-            'classes'          => array(),
535
-            'xfn'              => '',
536
-        );
537
-
538
-        foreach ($keys as $key => $value) {
539
-            $menu_item->{$key} = isset($menu_item_values[$key]) ? $menu_item_values[$key] : $value;
540
-        }
541
-        return $menu_item;
542
-    }
543
-
544
-
545
-    /**
546
-     * This is the action hook for the AHEE__EE_Admin_Page__route_admin_request hook that fires off right before an
547
-     * EE_Admin_Page route is called.
548
-     *
549
-     * @return void
550
-     */
551
-    public function route_admin_request()
552
-    {
553
-    }
554
-
555
-
556
-    /**
557
-     * wp_loaded should fire on the WordPress wp_loaded hook.  This fires on a VERY late priority.
558
-     *
559
-     * @return void
560
-     */
561
-    public function wp_loaded()
562
-    {
563
-    }
564
-
565
-
566
-    /**
567
-     * admin_init
568
-     *
569
-     * @return void
570
-     * @throws EE_Error
571
-     * @throws InvalidArgumentException
572
-     * @throws InvalidDataTypeException
573
-     * @throws InvalidInterfaceException
574
-     * @throws ReflectionException
575
-     */
576
-    public function admin_init()
577
-    {
578
-
579
-        /**
580
-         * our cpt models must be instantiated on WordPress post processing routes (wp-admin/post.php),
581
-         * so any hooking into core WP routes is taken care of.  So in this next few lines of code:
582
-         * - check if doing post processing.
583
-         * - check if doing post processing of one of EE CPTs
584
-         * - instantiate the corresponding EE CPT model for the post_type being processed.
585
-         */
586
-        if (isset($_POST['action'], $_POST['post_type']) && $_POST['action'] === 'editpost') {
587
-            EE_Registry::instance()->load_core('Register_CPTs');
588
-            EE_Register_CPTs::instantiate_cpt_models($_POST['post_type']);
589
-        }
590
-
591
-
592
-        /**
593
-         * This code excludes EE critical pages anywhere `wp_dropdown_pages` is used to create a dropdown for selecting
594
-         * critical pages.  The only place critical pages need included in a generated dropdown is on the "Critical
595
-         * Pages" tab in the EE General Settings Admin page.
596
-         * This is for user-proofing.
597
-         */
598
-        add_filter('wp_dropdown_pages', array($this, 'modify_dropdown_pages'));
599
-    }
600
-
601
-
602
-    /**
603
-     * Callback for wp_dropdown_pages hook to remove ee critical pages from the dropdown selection.
604
-     *
605
-     * @param string $output Current output.
606
-     * @return string
607
-     * @throws InvalidArgumentException
608
-     * @throws InvalidDataTypeException
609
-     * @throws InvalidInterfaceException
610
-     */
611
-    public function modify_dropdown_pages($output)
612
-    {
613
-        //get critical pages
614
-        $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();
615
-
616
-        //split current output by line break for easier parsing.
617
-        $split_output = explode("\n", $output);
618
-
619
-        //loop through to remove any critical pages from the array.
620
-        foreach ($critical_pages as $page_id) {
621
-            $needle = 'value="' . $page_id . '"';
622
-            foreach ($split_output as $key => $haystack) {
623
-                if (strpos($haystack, $needle) !== false) {
624
-                    unset($split_output[$key]);
625
-                }
626
-            }
627
-        }
628
-        //replace output with the new contents
629
-        return implode("\n", $split_output);
630
-    }
631
-
632
-
633
-    /**
634
-     * enqueue all admin scripts that need loaded for admin pages
635
-     *
636
-     * @return void
637
-     */
638
-    public function enqueue_admin_scripts()
639
-    {
640
-        // this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js.
641
-        // Note: the intention of this script is to only do TARGETED injections.  I.E, only injecting on certain script
642
-        // calls.
643
-        wp_enqueue_script(
644
-            'ee-inject-wp',
645
-            EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js',
646
-            array('jquery'),
647
-            EVENT_ESPRESSO_VERSION,
648
-            true
649
-        );
650
-        // register cookie script for future dependencies
651
-        wp_register_script(
652
-            'jquery-cookie',
653
-            EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js',
654
-            array('jquery'),
655
-            '2.1',
656
-            true
657
-        );
658
-        //joyride is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again
659
-        // via: add_filter('FHEE_load_joyride', '__return_true' );
660
-        if (apply_filters('FHEE_load_joyride', false)) {
661
-            //joyride style
662
-            wp_register_style('joyride-css', EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css', array(), '2.1');
663
-            wp_register_style(
664
-                'ee-joyride-css',
665
-                EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css',
666
-                array('joyride-css'),
667
-                EVENT_ESPRESSO_VERSION
668
-            );
669
-            wp_register_script(
670
-                'joyride-modernizr',
671
-                EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js',
672
-                array(),
673
-                '2.1',
674
-                true
675
-            );
676
-            //joyride JS
677
-            wp_register_script(
678
-                'jquery-joyride',
679
-                EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js',
680
-                array('jquery-cookie', 'joyride-modernizr'),
681
-                '2.1',
682
-                true
683
-            );
684
-            // wanna go for a joyride?
685
-            wp_enqueue_style('ee-joyride-css');
686
-            wp_enqueue_script('jquery-joyride');
687
-        }
688
-    }
689
-
690
-
691
-    /**
692
-     * display_admin_notices
693
-     *
694
-     * @return void
695
-     */
696
-    public function display_admin_notices()
697
-    {
698
-        echo EE_Error::get_notices();
699
-    }
700
-
701
-
702
-
703
-    /**
704
-     * @param array $elements
705
-     * @return array
706
-     * @throws EE_Error
707
-     * @throws InvalidArgumentException
708
-     * @throws InvalidDataTypeException
709
-     * @throws InvalidInterfaceException
710
-     */
711
-    public function dashboard_glance_items($elements)
712
-    {
713
-        $elements                        = is_array($elements) ? $elements : array($elements);
714
-        $events                          = EEM_Event::instance()->count();
715
-        $items['events']['url']          = EE_Admin_Page::add_query_args_and_nonce(
716
-            array('page' => 'espresso_events'),
717
-            admin_url('admin.php')
718
-        );
719
-        $items['events']['text']         = sprintf(_n('%s Event', '%s Events', $events), number_format_i18n($events));
720
-        $items['events']['title']        = esc_html__('Click to view all Events', 'event_espresso');
721
-        $registrations                   = EEM_Registration::instance()->count(
722
-            array(
723
-                array(
724
-                    'STS_ID' => array('!=', EEM_Registration::status_id_incomplete),
725
-                ),
726
-            )
727
-        );
728
-        $items['registrations']['url']   = EE_Admin_Page::add_query_args_and_nonce(
729
-            array('page' => 'espresso_registrations'),
730
-            admin_url('admin.php')
731
-        );
732
-        $items['registrations']['text']  = sprintf(
733
-            _n('%s Registration', '%s Registrations', $registrations),
734
-            number_format_i18n($registrations)
735
-        );
736
-        $items['registrations']['title'] = esc_html__('Click to view all registrations', 'event_espresso');
737
-
738
-        $items = (array)apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items);
739
-
740
-        foreach ($items as $type => $item_properties) {
741
-            $elements[] = sprintf(
742
-                '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>',
743
-                $item_properties['url'],
744
-                $item_properties['title'],
745
-                $item_properties['text']
746
-            );
747
-        }
748
-        return $elements;
749
-    }
750
-
751
-
752
-    /**
753
-     * check_for_invalid_datetime_formats
754
-     * if an admin changes their date or time format settings on the WP General Settings admin page, verify that
755
-     * their selected format can be parsed by PHP
756
-     *
757
-     * @param    $value
758
-     * @param    $option
759
-     * @throws EE_Error
760
-     * @return    string
761
-     */
762
-    public function check_for_invalid_datetime_formats($value, $option)
763
-    {
764
-        // check for date_format or time_format
765
-        switch ($option) {
766
-            case 'date_format':
767
-                $date_time_format = $value . ' ' . get_option('time_format');
768
-                break;
769
-            case 'time_format':
770
-                $date_time_format = get_option('date_format') . ' ' . $value;
771
-                break;
772
-            default:
773
-                $date_time_format = false;
774
-        }
775
-        // do we have a date_time format to check ?
776
-        if ($date_time_format) {
777
-            $error_msg = EEH_DTT_Helper::validate_format_string($date_time_format);
778
-
779
-            if (is_array($error_msg)) {
780
-                $msg = '<p>'
781
-                       . sprintf(
782
-                           esc_html__(
783
-                               'The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:',
784
-                               'event_espresso'
785
-                           ),
786
-                           date($date_time_format),
787
-                           $date_time_format
788
-                       )
789
-                       . '</p><p><ul>';
790
-
791
-
792
-                foreach ($error_msg as $error) {
793
-                    $msg .= '<li>' . $error . '</li>';
794
-                }
795
-
796
-                $msg .= '</ul></p><p>'
797
-                        . sprintf(
798
-                            esc_html__(
799
-                                '%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s',
800
-                                'event_espresso'
801
-                            ),
802
-                            '<span style="color:#D54E21;">',
803
-                            '</span>'
804
-                        )
805
-                        . '</p>';
806
-
807
-                // trigger WP settings error
808
-                add_settings_error(
809
-                    'date_format',
810
-                    'date_format',
811
-                    $msg
812
-                );
813
-
814
-                // set format to something valid
815
-                switch ($option) {
816
-                    case 'date_format':
817
-                        $value = 'F j, Y';
818
-                        break;
819
-                    case 'time_format':
820
-                        $value = 'g:i a';
821
-                        break;
822
-                }
823
-            }
824
-        }
825
-        return $value;
826
-    }
827
-
828
-
829
-    /**
830
-     * its_eSpresso - converts the less commonly used spelling of "Expresso" to "Espresso"
831
-     *
832
-     * @param $content
833
-     * @return    string
834
-     */
835
-    public function its_eSpresso($content)
836
-    {
837
-        return str_replace('[EXPRESSO_', '[ESPRESSO_', $content);
838
-    }
839
-
840
-
841
-    /**
842
-     * espresso_admin_footer
843
-     *
844
-     * @return    string
845
-     */
846
-    public function espresso_admin_footer()
847
-    {
848
-        return \EEH_Template::powered_by_event_espresso('aln-cntr', '', array('utm_content' => 'admin_footer'));
849
-    }
850
-
851
-
852
-    /**
853
-     * static method for registering ee admin page.
854
-     * This method is deprecated in favor of the new location in EE_Register_Admin_Page::register.
855
-     *
856
-     * @since      4.3.0
857
-     * @deprecated 4.3.0    Use EE_Register_Admin_Page::register() instead
858
-     * @see        EE_Register_Admin_Page::register()
859
-     * @param       $page_basename
860
-     * @param       $page_path
861
-     * @param array $config
862
-     * @return void
863
-     * @throws EE_Error
864
-     */
865
-    public static function register_ee_admin_page($page_basename, $page_path, $config = array())
866
-    {
867
-        EE_Error::doing_it_wrong(
868
-            __METHOD__,
869
-            sprintf(
870
-                esc_html__(
871
-                    'Usage is deprecated.  Use EE_Register_Admin_Page::register() for registering the %s admin page.',
872
-                    'event_espresso'
873
-                ),
874
-                $page_basename
875
-            ),
876
-            '4.3'
877
-        );
878
-        if (class_exists('EE_Register_Admin_Page')) {
879
-            $config['page_path'] = $page_path;
880
-        }
881
-        EE_Register_Admin_Page::register($page_basename, $config);
882
-    }
883
-
884
-
885
-    /**
886
-     * @deprecated 4.8.41
887
-     * @param  int      $post_ID
888
-     * @param  \WP_Post $post
889
-     * @return void
890
-     */
891
-    public static function parse_post_content_on_save($post_ID, $post)
892
-    {
893
-        EE_Error::doing_it_wrong(
894
-            __METHOD__,
895
-            esc_html__('Usage is deprecated', 'event_espresso'),
896
-            '4.8.41'
897
-        );
898
-    }
899
-
900
-
901
-    /**
902
-     * @deprecated 4.8.41
903
-     * @param  $option
904
-     * @param  $old_value
905
-     * @param  $value
906
-     * @return void
907
-     */
908
-    public function reset_page_for_posts_on_change($option, $old_value, $value)
909
-    {
910
-        EE_Error::doing_it_wrong(
911
-            __METHOD__,
912
-            esc_html__('Usage is deprecated', 'event_espresso'),
913
-            '4.8.41'
914
-        );
915
-    }
916
-
917
-
918
-
919
-    /**
920
-     * @deprecated 4.9.27
921
-     * @return void
922
-     */
923
-    public function get_persistent_admin_notices()
924
-    {
925
-        EE_Error::doing_it_wrong(
926
-            __METHOD__,
927
-            sprintf(
928
-                __('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
929
-                '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
930
-            ),
931
-            '4.9.27'
932
-        );
933
-    }
934
-
935
-
936
-
937
-    /**
938
-     * @deprecated 4.9.27
939
-     * @throws InvalidInterfaceException
940
-     * @throws InvalidDataTypeException
941
-     * @throws DomainException
942
-     */
943
-    public function dismiss_ee_nag_notice_callback()
944
-    {
945
-        EE_Error::doing_it_wrong(
946
-            __METHOD__,
947
-            sprintf(
948
-                __('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
949
-                '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
950
-            ),
951
-            '4.9.27'
952
-        );
953
-        $this->persistent_admin_notice_manager->dismissNotice();
954
-    }
488
+	}
489
+
490
+
491
+	/**
492
+	 * Returns an array of event archive nav items.
493
+	 *
494
+	 * @todo  for now this method is just in place so when it gets abstracted further we can substitute in whatever
495
+	 *        method we use for getting the extra nav menu items
496
+	 * @return array
497
+	 */
498
+	private function _get_extra_nav_menu_pages_items()
499
+	{
500
+		$menuitems[] = array(
501
+			'title'       => esc_html__('Event List', 'event_espresso'),
502
+			'url'         => get_post_type_archive_link('espresso_events'),
503
+			'description' => esc_html__('Archive page for all events.', 'event_espresso'),
504
+		);
505
+		return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems);
506
+	}
507
+
508
+
509
+	/**
510
+	 * Setup nav menu walker item for usage in the event archive nav menu metabox.  It receives a menu_item array with
511
+	 * the properties and converts it to the menu item object.
512
+	 *
513
+	 * @see wp_setup_nav_menu_item() in wp-includes/nav-menu.php
514
+	 * @param $menu_item_values
515
+	 * @return stdClass
516
+	 */
517
+	private function _setup_extra_nav_menu_pages_items($menu_item_values)
518
+	{
519
+		$menu_item = new stdClass();
520
+		$keys      = array(
521
+			'ID'               => 0,
522
+			'db_id'            => 0,
523
+			'menu_item_parent' => 0,
524
+			'object_id'        => -1,
525
+			'post_parent'      => 0,
526
+			'type'             => 'custom',
527
+			'object'           => '',
528
+			'type_label'       => esc_html__('Extra Nav Menu Item', 'event_espresso'),
529
+			'title'            => '',
530
+			'url'              => '',
531
+			'target'           => '',
532
+			'attr_title'       => '',
533
+			'description'      => '',
534
+			'classes'          => array(),
535
+			'xfn'              => '',
536
+		);
537
+
538
+		foreach ($keys as $key => $value) {
539
+			$menu_item->{$key} = isset($menu_item_values[$key]) ? $menu_item_values[$key] : $value;
540
+		}
541
+		return $menu_item;
542
+	}
543
+
544
+
545
+	/**
546
+	 * This is the action hook for the AHEE__EE_Admin_Page__route_admin_request hook that fires off right before an
547
+	 * EE_Admin_Page route is called.
548
+	 *
549
+	 * @return void
550
+	 */
551
+	public function route_admin_request()
552
+	{
553
+	}
554
+
555
+
556
+	/**
557
+	 * wp_loaded should fire on the WordPress wp_loaded hook.  This fires on a VERY late priority.
558
+	 *
559
+	 * @return void
560
+	 */
561
+	public function wp_loaded()
562
+	{
563
+	}
564
+
565
+
566
+	/**
567
+	 * admin_init
568
+	 *
569
+	 * @return void
570
+	 * @throws EE_Error
571
+	 * @throws InvalidArgumentException
572
+	 * @throws InvalidDataTypeException
573
+	 * @throws InvalidInterfaceException
574
+	 * @throws ReflectionException
575
+	 */
576
+	public function admin_init()
577
+	{
578
+
579
+		/**
580
+		 * our cpt models must be instantiated on WordPress post processing routes (wp-admin/post.php),
581
+		 * so any hooking into core WP routes is taken care of.  So in this next few lines of code:
582
+		 * - check if doing post processing.
583
+		 * - check if doing post processing of one of EE CPTs
584
+		 * - instantiate the corresponding EE CPT model for the post_type being processed.
585
+		 */
586
+		if (isset($_POST['action'], $_POST['post_type']) && $_POST['action'] === 'editpost') {
587
+			EE_Registry::instance()->load_core('Register_CPTs');
588
+			EE_Register_CPTs::instantiate_cpt_models($_POST['post_type']);
589
+		}
590
+
591
+
592
+		/**
593
+		 * This code excludes EE critical pages anywhere `wp_dropdown_pages` is used to create a dropdown for selecting
594
+		 * critical pages.  The only place critical pages need included in a generated dropdown is on the "Critical
595
+		 * Pages" tab in the EE General Settings Admin page.
596
+		 * This is for user-proofing.
597
+		 */
598
+		add_filter('wp_dropdown_pages', array($this, 'modify_dropdown_pages'));
599
+	}
600
+
601
+
602
+	/**
603
+	 * Callback for wp_dropdown_pages hook to remove ee critical pages from the dropdown selection.
604
+	 *
605
+	 * @param string $output Current output.
606
+	 * @return string
607
+	 * @throws InvalidArgumentException
608
+	 * @throws InvalidDataTypeException
609
+	 * @throws InvalidInterfaceException
610
+	 */
611
+	public function modify_dropdown_pages($output)
612
+	{
613
+		//get critical pages
614
+		$critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();
615
+
616
+		//split current output by line break for easier parsing.
617
+		$split_output = explode("\n", $output);
618
+
619
+		//loop through to remove any critical pages from the array.
620
+		foreach ($critical_pages as $page_id) {
621
+			$needle = 'value="' . $page_id . '"';
622
+			foreach ($split_output as $key => $haystack) {
623
+				if (strpos($haystack, $needle) !== false) {
624
+					unset($split_output[$key]);
625
+				}
626
+			}
627
+		}
628
+		//replace output with the new contents
629
+		return implode("\n", $split_output);
630
+	}
631
+
632
+
633
+	/**
634
+	 * enqueue all admin scripts that need loaded for admin pages
635
+	 *
636
+	 * @return void
637
+	 */
638
+	public function enqueue_admin_scripts()
639
+	{
640
+		// this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js.
641
+		// Note: the intention of this script is to only do TARGETED injections.  I.E, only injecting on certain script
642
+		// calls.
643
+		wp_enqueue_script(
644
+			'ee-inject-wp',
645
+			EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js',
646
+			array('jquery'),
647
+			EVENT_ESPRESSO_VERSION,
648
+			true
649
+		);
650
+		// register cookie script for future dependencies
651
+		wp_register_script(
652
+			'jquery-cookie',
653
+			EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js',
654
+			array('jquery'),
655
+			'2.1',
656
+			true
657
+		);
658
+		//joyride is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again
659
+		// via: add_filter('FHEE_load_joyride', '__return_true' );
660
+		if (apply_filters('FHEE_load_joyride', false)) {
661
+			//joyride style
662
+			wp_register_style('joyride-css', EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css', array(), '2.1');
663
+			wp_register_style(
664
+				'ee-joyride-css',
665
+				EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css',
666
+				array('joyride-css'),
667
+				EVENT_ESPRESSO_VERSION
668
+			);
669
+			wp_register_script(
670
+				'joyride-modernizr',
671
+				EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js',
672
+				array(),
673
+				'2.1',
674
+				true
675
+			);
676
+			//joyride JS
677
+			wp_register_script(
678
+				'jquery-joyride',
679
+				EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js',
680
+				array('jquery-cookie', 'joyride-modernizr'),
681
+				'2.1',
682
+				true
683
+			);
684
+			// wanna go for a joyride?
685
+			wp_enqueue_style('ee-joyride-css');
686
+			wp_enqueue_script('jquery-joyride');
687
+		}
688
+	}
689
+
690
+
691
+	/**
692
+	 * display_admin_notices
693
+	 *
694
+	 * @return void
695
+	 */
696
+	public function display_admin_notices()
697
+	{
698
+		echo EE_Error::get_notices();
699
+	}
700
+
701
+
702
+
703
+	/**
704
+	 * @param array $elements
705
+	 * @return array
706
+	 * @throws EE_Error
707
+	 * @throws InvalidArgumentException
708
+	 * @throws InvalidDataTypeException
709
+	 * @throws InvalidInterfaceException
710
+	 */
711
+	public function dashboard_glance_items($elements)
712
+	{
713
+		$elements                        = is_array($elements) ? $elements : array($elements);
714
+		$events                          = EEM_Event::instance()->count();
715
+		$items['events']['url']          = EE_Admin_Page::add_query_args_and_nonce(
716
+			array('page' => 'espresso_events'),
717
+			admin_url('admin.php')
718
+		);
719
+		$items['events']['text']         = sprintf(_n('%s Event', '%s Events', $events), number_format_i18n($events));
720
+		$items['events']['title']        = esc_html__('Click to view all Events', 'event_espresso');
721
+		$registrations                   = EEM_Registration::instance()->count(
722
+			array(
723
+				array(
724
+					'STS_ID' => array('!=', EEM_Registration::status_id_incomplete),
725
+				),
726
+			)
727
+		);
728
+		$items['registrations']['url']   = EE_Admin_Page::add_query_args_and_nonce(
729
+			array('page' => 'espresso_registrations'),
730
+			admin_url('admin.php')
731
+		);
732
+		$items['registrations']['text']  = sprintf(
733
+			_n('%s Registration', '%s Registrations', $registrations),
734
+			number_format_i18n($registrations)
735
+		);
736
+		$items['registrations']['title'] = esc_html__('Click to view all registrations', 'event_espresso');
737
+
738
+		$items = (array)apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items);
739
+
740
+		foreach ($items as $type => $item_properties) {
741
+			$elements[] = sprintf(
742
+				'<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>',
743
+				$item_properties['url'],
744
+				$item_properties['title'],
745
+				$item_properties['text']
746
+			);
747
+		}
748
+		return $elements;
749
+	}
750
+
751
+
752
+	/**
753
+	 * check_for_invalid_datetime_formats
754
+	 * if an admin changes their date or time format settings on the WP General Settings admin page, verify that
755
+	 * their selected format can be parsed by PHP
756
+	 *
757
+	 * @param    $value
758
+	 * @param    $option
759
+	 * @throws EE_Error
760
+	 * @return    string
761
+	 */
762
+	public function check_for_invalid_datetime_formats($value, $option)
763
+	{
764
+		// check for date_format or time_format
765
+		switch ($option) {
766
+			case 'date_format':
767
+				$date_time_format = $value . ' ' . get_option('time_format');
768
+				break;
769
+			case 'time_format':
770
+				$date_time_format = get_option('date_format') . ' ' . $value;
771
+				break;
772
+			default:
773
+				$date_time_format = false;
774
+		}
775
+		// do we have a date_time format to check ?
776
+		if ($date_time_format) {
777
+			$error_msg = EEH_DTT_Helper::validate_format_string($date_time_format);
778
+
779
+			if (is_array($error_msg)) {
780
+				$msg = '<p>'
781
+					   . sprintf(
782
+						   esc_html__(
783
+							   'The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:',
784
+							   'event_espresso'
785
+						   ),
786
+						   date($date_time_format),
787
+						   $date_time_format
788
+					   )
789
+					   . '</p><p><ul>';
790
+
791
+
792
+				foreach ($error_msg as $error) {
793
+					$msg .= '<li>' . $error . '</li>';
794
+				}
795
+
796
+				$msg .= '</ul></p><p>'
797
+						. sprintf(
798
+							esc_html__(
799
+								'%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s',
800
+								'event_espresso'
801
+							),
802
+							'<span style="color:#D54E21;">',
803
+							'</span>'
804
+						)
805
+						. '</p>';
806
+
807
+				// trigger WP settings error
808
+				add_settings_error(
809
+					'date_format',
810
+					'date_format',
811
+					$msg
812
+				);
813
+
814
+				// set format to something valid
815
+				switch ($option) {
816
+					case 'date_format':
817
+						$value = 'F j, Y';
818
+						break;
819
+					case 'time_format':
820
+						$value = 'g:i a';
821
+						break;
822
+				}
823
+			}
824
+		}
825
+		return $value;
826
+	}
827
+
828
+
829
+	/**
830
+	 * its_eSpresso - converts the less commonly used spelling of "Expresso" to "Espresso"
831
+	 *
832
+	 * @param $content
833
+	 * @return    string
834
+	 */
835
+	public function its_eSpresso($content)
836
+	{
837
+		return str_replace('[EXPRESSO_', '[ESPRESSO_', $content);
838
+	}
839
+
840
+
841
+	/**
842
+	 * espresso_admin_footer
843
+	 *
844
+	 * @return    string
845
+	 */
846
+	public function espresso_admin_footer()
847
+	{
848
+		return \EEH_Template::powered_by_event_espresso('aln-cntr', '', array('utm_content' => 'admin_footer'));
849
+	}
850
+
851
+
852
+	/**
853
+	 * static method for registering ee admin page.
854
+	 * This method is deprecated in favor of the new location in EE_Register_Admin_Page::register.
855
+	 *
856
+	 * @since      4.3.0
857
+	 * @deprecated 4.3.0    Use EE_Register_Admin_Page::register() instead
858
+	 * @see        EE_Register_Admin_Page::register()
859
+	 * @param       $page_basename
860
+	 * @param       $page_path
861
+	 * @param array $config
862
+	 * @return void
863
+	 * @throws EE_Error
864
+	 */
865
+	public static function register_ee_admin_page($page_basename, $page_path, $config = array())
866
+	{
867
+		EE_Error::doing_it_wrong(
868
+			__METHOD__,
869
+			sprintf(
870
+				esc_html__(
871
+					'Usage is deprecated.  Use EE_Register_Admin_Page::register() for registering the %s admin page.',
872
+					'event_espresso'
873
+				),
874
+				$page_basename
875
+			),
876
+			'4.3'
877
+		);
878
+		if (class_exists('EE_Register_Admin_Page')) {
879
+			$config['page_path'] = $page_path;
880
+		}
881
+		EE_Register_Admin_Page::register($page_basename, $config);
882
+	}
883
+
884
+
885
+	/**
886
+	 * @deprecated 4.8.41
887
+	 * @param  int      $post_ID
888
+	 * @param  \WP_Post $post
889
+	 * @return void
890
+	 */
891
+	public static function parse_post_content_on_save($post_ID, $post)
892
+	{
893
+		EE_Error::doing_it_wrong(
894
+			__METHOD__,
895
+			esc_html__('Usage is deprecated', 'event_espresso'),
896
+			'4.8.41'
897
+		);
898
+	}
899
+
900
+
901
+	/**
902
+	 * @deprecated 4.8.41
903
+	 * @param  $option
904
+	 * @param  $old_value
905
+	 * @param  $value
906
+	 * @return void
907
+	 */
908
+	public function reset_page_for_posts_on_change($option, $old_value, $value)
909
+	{
910
+		EE_Error::doing_it_wrong(
911
+			__METHOD__,
912
+			esc_html__('Usage is deprecated', 'event_espresso'),
913
+			'4.8.41'
914
+		);
915
+	}
916
+
917
+
918
+
919
+	/**
920
+	 * @deprecated 4.9.27
921
+	 * @return void
922
+	 */
923
+	public function get_persistent_admin_notices()
924
+	{
925
+		EE_Error::doing_it_wrong(
926
+			__METHOD__,
927
+			sprintf(
928
+				__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
929
+				'\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
930
+			),
931
+			'4.9.27'
932
+		);
933
+	}
934
+
935
+
936
+
937
+	/**
938
+	 * @deprecated 4.9.27
939
+	 * @throws InvalidInterfaceException
940
+	 * @throws InvalidDataTypeException
941
+	 * @throws DomainException
942
+	 */
943
+	public function dismiss_ee_nag_notice_callback()
944
+	{
945
+		EE_Error::doing_it_wrong(
946
+			__METHOD__,
947
+			sprintf(
948
+				__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
949
+				'\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
950
+			),
951
+			'4.9.27'
952
+		);
953
+		$this->persistent_admin_notice_manager->dismissNotice();
954
+	}
955 955
 }
Please login to merge, or discard this patch.